_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q29200 | ArrayUtils.array_has | train | public static function array_has($arr, $path) {
if(!$path)
return false;
if(!is_array($path))
$path = [$path];
foreach($path as $key) {
if(!isset($arr[$key]))
return false;
else
$arr = $arr[$key];
}
return true;
} | php | {
"resource": ""
} |
q29201 | ArrayUtils.array_delete | train | public static function array_delete(&$arr, $path) {
if(!$path)
return;
if(!is_array($path))
$path = [$path];
$lastkey = array_pop($path);
foreach($path as $parent)
$arr =& $arr[$parent];
unset($arr[$lastkey]);
} | php | {
"resource": ""
} |
q29202 | ArrayUtils.before | train | public static function before($arr, $i) {
$res = [];
foreach($arr as $k=>$v) {
if($k === $i)
return $res;
$res[$k] = $v;
}
return $res;
} | php | {
"resource": ""
} |
q29203 | ArrayUtils.after | train | public static function after($arr, $i) {
$res = [];
$do = false;
foreach($arr as $k=>$v) {
if($do)
$res[$k] = $v;
if($k === $i)
$do = true;
}
return $res;
} | php | {
"resource": ""
} |
q29204 | PluginUpdate.canUpdate | train | private function canUpdate()
{
$this->info("Validating");
// Exists as a directory
if(!file_exists(pluginsPath($this->pluginNamespace))) {
throw new \Exception("Plugin ".$this->pluginNamespace." not found in plugins directory!");
}
// Plugin should be in DB Tabl... | php | {
"resource": ""
} |
q29205 | GnCommunityApi.GetCommunity | train | public function GetCommunity(string $community = NULL)
{
$result = $this->ExecuteCall("GetCommunity", (object)[
"community" => $community
], GnResponseType::GnCommunity);
return $result;
} | php | {
"resource": ""
} |
q29206 | GnCommunityApi.InviteMemberToCommunity | train | public function InviteMemberToCommunity(string $toLoginName, string $community = NULL)
{
$this->ExecuteCall("InviteMemberToCommunity", (object)[
"community" => $community,
"toLoginName" => $toLoginName
], GnResponseType::Json, FALSE, PHP_INT_MAX);
} | php | {
"resource": ""
} |
q29207 | AbstractLoader.load | train | public function load($ident)
{
// Handle dynamic template
if (substr($ident, 0, 1) === '$') {
$tryLegacy = ($ident === '$widget_template');
$ident = $this->dynamicTemplate(substr($ident, 1));
// Legacy dynamic template hack
if ($tryLegacy) {
... | php | {
"resource": ""
} |
q29208 | BaseCategoryController.menuPanelItems | train | public function menuPanelItems($lang = "")
{
// check if user has permissions to access this link
if(!User::hasAccess('PostType', 'read')) {
return $this->noPermission();
}
// Find categories
$categoryObj = Category::visible();
if(Input::input('keyword'))... | php | {
"resource": ""
} |
q29209 | BaseCategoryController.getTree | train | public function getTree($lang = "", $postTypeID)
{
$orderBy = (isset($_GET['order'])) ? $orderBy = $_GET['order'] : 'order';
$orderType = (isset($_GET['type'])) ? $orderType = $_GET['type'] : 'ASC';
$parentList = Category::where('postTypeID', $postTypeID)->where('parentID', null)
... | php | {
"resource": ""
} |
q29210 | BaseCategoryController.delete | train | public function delete($lang, $id)
{
if(!User::hasAccess('Categories', 'delete')) {
return $this->noPermission();
}
$categoryDeleteRes = $this->deleteCategory($id);
if(gettype($categoryDeleteRes) == "boolean") {
if($categoryDeleteRes) {
return... | php | {
"resource": ""
} |
q29211 | BaseCategoryController.bulkDelete | train | public function bulkDelete(Request $request)
{
// check if user has permissions to access this link
if(!User::hasAccess('Categories', 'delete')) {
return $this->noPermission();
}
// if there are no item selected
if (count($request->all()) <= 0) {
retu... | php | {
"resource": ""
} |
q29212 | BaseCategoryController.deleteCategory | train | private function deleteCategory(int $id)
{
$category = Category::find($id);
if($category) {
$postType = PostType::findByID($category->postTypeID);
if(Category::isInMenuLinks($id)) {
return $this->response("You can't delete this Category. It is part of a menu",... | php | {
"resource": ""
} |
q29213 | BaseCategoryController.store | train | public function store(Request $request)
{
// check if user has permissions to access this link
if(!User::hasAccess('Categories', 'create')) {
return $this->noPermission();
}
$data = $request->all();
$structuredData = $this->generateTitleAndSlug($data['form']);
... | php | {
"resource": ""
} |
q29214 | BaseCategoryController.generateTitleAndSlug | train | private function generateTitleAndSlug($form)
{
$errors = [];
$requiredMessage = " is required";
$defaultLanguage = Language::getDefault();
$result = $form;
$defaultLanguageTitle = '';
// title in default language should no be empty
if(isset($form['title'])
... | php | {
"resource": ""
} |
q29215 | BaseCategoryController.redirect | train | private function redirect(string $redirect, int $categoryID, int $postTypeID)
{
$adminPrefix = Config::get('project')['adminPrefix'];
if($redirect == 'save') {
$redirectUrl = "/".$adminPrefix."/".App::getLocale()."/post-type/categoryupdate/".$categoryID;
$view = 'categoryupda... | php | {
"resource": ""
} |
q29216 | BaseCategoryController.detailsJSON | train | public function detailsJSON($lang, $id)
{
// check if user has permissions to access this link
if(!User::hasAccess('Categories', 'update')) {
return $this->noPermission();
}
$category = Category::find($id);
$featuredImage = Media::find($category->featuredImageID)... | php | {
"resource": ""
} |
q29217 | BaseCategoryController.makeSearch | train | public function makeSearch($lang, $postTypeID, $term)
{
// check if user has permissions to access this link
if(!User::hasAccess('Categories', 'read')) {
return $this->noPermission();
}
$orderBy = (isset($_GET['order'])) ? $_GET['order'] : 'categoryID';
$orderTyp... | php | {
"resource": ""
} |
q29218 | BaseCategoryController.getAllWithoutPagination | train | public function getAllWithoutPagination($lang = "")
{
$result = DB::table('categories')->join('post_type', 'post_type.postTypeID', 'categories.postTypeID')->orderBy('name', 'postTypeID')->get();
return Language::filterRows($result, false);
} | php | {
"resource": ""
} |
q29219 | BaseCategoryController.getPostType | train | public function getPostType($lang = "", $categoryID)
{
$result = DB::table('categories')
->join('post_type', 'post_type.postTypeID', 'categories.postTypeID')
->where('categoryID', $categoryID)
->first();
return array('list' => $result);
} | php | {
"resource": ""
} |
q29220 | HeadersProperty.headers | train | public function headers(): Headers
{
return !is_null($this->headers) ? $this->headers : ($this->headers = new Headers());
} | php | {
"resource": ""
} |
q29221 | GnLoginApiEndUser.GenerateQrCode | train | public function GenerateQrCode(bool $mustJoin = FALSE, bool $needsActivation = FALSE, int $acls = GnMashupLoginAcl::None)
{
$qrCode = parent::GenerateQrCodeInternal(NULL, $mustJoin, $needsActivation, $acls);
return $qrCode;
} | php | {
"resource": ""
} |
q29222 | TagRenderer.getRenderer | train | private function getRenderer(array $options)
{
if ($options['text']) {
if ($options['badge']) {
return function (TagInterface $tag) {
return sprintf(
'<span class="label label-%s"><i class="fa fa-%s"></i> %s</span>',
... | php | {
"resource": ""
} |
q29223 | Group.offsetGet | train | public function offsetGet($offset) {
return isset($this->fields[$offset]) ? $this->fields[$offset] : null;
} | php | {
"resource": ""
} |
q29224 | Group.getValidator | train | protected function getValidator() {
$validator = $this->createValidator();
$constrains = [];
$messages = [];
foreach($this->fields as $name=>$field) {
if($field instanceof Field) {
if($field_rules = $field->getValidationRules())
$constrains[$name] = $field_rules;
if($field_messages = $... | php | {
"resource": ""
} |
q29225 | Group.setErrors | train | protected function setErrors(\Asgard\Validation\Report $errors) {
foreach($errors->attributes() as $name=>$_errors) {
if(isset($this->fields[$name]))
$this->fields[$name]->setErrors($_errors);
}
} | php | {
"resource": ""
} |
q29226 | Group.parseFields | train | protected function parseFields($fields, $name) {
if(is_array($fields)) {
return new self(
$fields,
$name,
(isset($this->data[$name]) ? $this->data[$name]:[]),
$this
);
}
elseif($fields instanceof Field) {
$field = $fields;
$field->setName($name);
$field->setParent($this)... | php | {
"resource": ""
} |
q29227 | Group._save | train | protected function _save($group=null) {
if(!$group)
$group = $this;
$group->doSave();
if($group instanceof self) {
foreach($group->fields as $name=>$field) {
if($field instanceof self)
$field->_save($field);
}
}
} | php | {
"resource": ""
} |
q29228 | Group.updateChilds | train | protected function updateChilds() {
foreach($this->fields as $name=>$field) {
if($field instanceof self) {
$field->setData(
(isset($this->data[$name]) ? $this->data[$name]:[])
);
}
elseif($field instanceof Field) {
if(isset($this->data[$name]))
$field->setValue($this->data[$nam... | php | {
"resource": ""
} |
q29229 | Group.myErrors | train | protected function myErrors($validationGroups=[]) {
$data = $this->data;
$report = $this->getValidator()->errors($data, $validationGroups);
foreach($this->fields as $name=>$field) {
if($field instanceof Field\FileField && isset($this->data[$name])) {
$f = $this->data[$name];
switch($f->error(... | php | {
"resource": ""
} |
q29230 | Group.getReportErrors | train | protected function getReportErrors(\Asgard\Validation\Report $report) {
if($report->attributes()) {
$errors = [];
foreach($report->attributes() as $attribute=>$attrReport) {
$attrErrors = $this->getReportErrors($attrReport);
if($attrErrors)
$errors[$attribute] = $attrErrors;
}
return ... | php | {
"resource": ""
} |
q29231 | CollectionCursor.filterModelsByIndex | train | public function filterModelsByIndex($indexes)
{
$this->filteredIndexes = array_merge($this->filteredIndexes, $indexes);
$this->filteredIndexCount = count($this->filteredIndexes);
} | php | {
"resource": ""
} |
q29232 | CollectionCursor.setAugmentationData | train | public final function setAugmentationData($data)
{
foreach($data as $id => $rowData){
if (!isset($this->augmentationData[$id])){
$this->augmentationData[$id] = $rowData;
} else {
$this->augmentationData[$id] = array_merge($this->augmentationData[$id], ... | php | {
"resource": ""
} |
q29233 | DOMNodeTrait.setChildren | train | public function setChildren (array $components = [])
{
self::removeAll ($components);
$this->children = $components;
$this->attach ($components);
} | php | {
"resource": ""
} |
q29234 | DOMNodeTrait.getIndex | train | public function getIndex ()
{
if (!isset($this->parent))
throw new ComponentException($this, "The component is not attached to a parent.");
if (!$this->parent->children)
throw new ComponentException($this, "The parent component has no children.");
return array_search ($this, $this->parent->ch... | php | {
"resource": ""
} |
q29235 | DOMNodeTrait.removeChildren | train | public function removeChildren ()
{
$children = $this->children;
$this->children = [];
if ($children)
self::detachAll ($children);
return $children;
} | php | {
"resource": ""
} |
q29236 | DOMNodeTrait.replaceBy | train | public function replaceBy (array $components = null)
{
$p = $this->getIndex ();
if ($p !== false) {
array_splice ($this->parent->children, $p, 1, $components);
$this->parent->attach ($components);
}
else {
$t = ComponentInspector::inspectSet ($this->parent->children);
throw new... | php | {
"resource": ""
} |
q29237 | Client.generateRequestToken | train | private function generateRequestToken()
{
// Set the callback URL.
if ($this->getOption('callback'))
{
$parameters = array(
'oauth_callback' => $this->getOption('callback'),
);
}
else
{
$parameters = array();
}
// Make an OAuth request for the Request Token.
$response = $this->oauthRequ... | php | {
"resource": ""
} |
q29238 | Client.authorise | train | private function authorise()
{
$url = $this->getOption('authoriseURL') . '?oauth_token=' . $this->token['key'];
if ($this->getOption('scope'))
{
$scope = \is_array($this->getOption('scope')) ? implode(' ', $this->getOption('scope')) : $this->getOption('scope');
$url .= '&scope=' . urlencode($scope);
}
... | php | {
"resource": ""
} |
q29239 | Client.oauthRequest | train | public function oauthRequest($url, $method, $parameters, $data = array(), $headers = array())
{
// Set the parameters.
$defaults = array(
'oauth_consumer_key' => $this->getOption('consumer_key'),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_version' => '1.0',
'oauth_nonce' =>... | php | {
"resource": ""
} |
q29240 | Client.createHeader | train | private function createHeader($parameters)
{
$header = 'OAuth ';
foreach ($parameters as $key => $value)
{
if (!strcmp($header, 'OAuth '))
{
$header .= $key . '="' . $this->safeEncode($value) . '"';
}
else
{
$header .= ', ' . $key . '="' . $value . '"';
}
}
return $header;
} | php | {
"resource": ""
} |
q29241 | Client.toUrl | train | public function toUrl($url, $parameters)
{
foreach ($parameters as $key => $value)
{
if (\is_array($value))
{
foreach ($value as $k => $v)
{
if (strpos($url, '?') === false)
{
$url .= '?' . $key . '=' . $v;
}
else
{
$url .= '&' . $key . '=' . $v;
}
}
}... | php | {
"resource": ""
} |
q29242 | Client.baseString | train | private function baseString($url, $method, $parameters)
{
// Sort the parameters alphabetically
uksort($parameters, 'strcmp');
// Encode parameters.
foreach ($parameters as $key => $value)
{
$key = $this->safeEncode($key);
if (\is_array($value))
{
foreach ($value as $k => $v)
{
$v ... | php | {
"resource": ""
} |
q29243 | InstallCommand.updateComposer | train | protected function updateComposer($dir) {
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
$cmd = '"vendor/bin/composer.bat" update --working-dir "'.$dir.'"';
else
$cmd = './vendor/bin/composer update --working-dir "'.$dir.'"';
return $this->runCommand($cmd);
} | php | {
"resource": ""
} |
q29244 | SlideShow.addSlide | train | public function addSlide(Slide $slide)
{
if (!$this->slides->contains($slide)) {
$this->slides->add($slide);
$slide->setSlideShow($this);
}
return $this;
} | php | {
"resource": ""
} |
q29245 | SlideShow.removeSlide | train | public function removeSlide(Slide $slide)
{
if ($this->slides->contains($slide)) {
$this->slides->removeElement($slide);
$slide->setSlideShow(null);
}
return $this;
} | php | {
"resource": ""
} |
q29246 | PageExtension.isActive | train | public function isActive($path, $strict = false)
{
// Check if path is relative
$pathData = parse_url($path);
if ( ! empty($pathData['scheme'])
|| ! empty($pathData['host'])
|| ! empty($pathData['port'])
|| ! empty($pathData['user'])
|| ! empty($pathData['pass'])
) {
return false;
}
$path =... | php | {
"resource": ""
} |
q29247 | PageExtension.isPropertyValueEmpty | train | public function isPropertyValueEmpty($name)
{
$value = $this->getBlockExecutionContext()
->controller->getProperty($name)->getValue();
return empty($value);
} | php | {
"resource": ""
} |
q29248 | AbstractPage.getLocalization | train | public function getLocalization($locale)
{
$dataCollection = $this->getLocalizations();
$data = $dataCollection->get($locale);
return $data;
} | php | {
"resource": ""
} |
q29249 | TableBuilder.buildQuery | train | public function buildQuery()
{
foreach ($this->fields as $_nextRow) {
$this->columns[$_nextRow['name']] = $this->buildNextField($_nextRow);
}
} | php | {
"resource": ""
} |
q29250 | TableBuilder.prepStr | train | protected static function prepStr($str, $countSymb = 255)
{
//$str = str_replace(['-', '_'], ['', ''], $str);
$len = strlen($str);
$len = $len > $countSymb ? $countSymb : $len;
return substr($str, 0, $len);
} | php | {
"resource": ""
} |
q29251 | TableBuilder.getNameForeignKey | train | public static function getNameForeignKey($tableName, $tableNameRelated, $fieldName, $fieldNameRelated, $wordWrap = false)
{
return is_bool($wordWrap) ? 'fk_' . self::prepStr($tableName) . '_' . self::prepStr($fieldName) . '_' . self::prepStr($tableNameRelated) . '_' . self::prepStr($fieldNameRelated)
... | php | {
"resource": ""
} |
q29252 | PDO.setAttribute | train | public function setAttribute ($attribute, $value) {
// @see https://github.com/gajus/doll/issues/16
if ($attribute === \PDO::ATTR_ERRMODE) {
throw new Exception\InvalidArgumentException('Doll does not allow to change PDO::ATTR_ERRMODE.');
}
// @see
if ($attribute ===... | php | {
"resource": ""
} |
q29253 | PDO.on | train | public function on ($method, $statement, $execution_wall_time = null, array $parameters = []) {
if ($method === 'prepare' || !$this->getAttribute(\Gajus\Doll\PDO::ATTR_LOGGING)) {
return;
}
$statement = trim(preg_replace('/\s+/', ' ', str_replace("\n", ' ', $statement)));
$b... | php | {
"resource": ""
} |
q29254 | PDO.connect | train | private function connect () {
if ($this->isConnected()) {
return;
}
parent::__construct(
$this->data_source->getDSN(),
$this->data_source->getUser(),
$this->data_source->getPassword(),
$this->data_source->getDriverOptions()
);
... | php | {
"resource": ""
} |
q29255 | MinistryPlatformProcAPI.exec | train | public function exec()
{
// Set the header
$this->buildHttpHeader();
$parameters = [
'headers' => $this->headers,
'body' => $this->postFields,
'curl' => $this->setPostCurlopts(),
];
// Get all of the results 1000 at a time
return ... | php | {
"resource": ""
} |
q29256 | Request.fromGlobals | train | public static function fromGlobals(
array $server = null,
array $query = null,
array $body = null,
array $cookies = null,
array $files = null
) {
$server = \Zend\Diactoros\normalizeServer($server ?: $_SERVER);
$files = \Zend\Diactoros\normalizeUploadedFiles... | php | {
"resource": ""
} |
q29257 | Request.getCookie | train | public function getCookie($key = null, $default = null, $mode = null)
{
return $this->getValue($this->getCookieParams(), $key, $default, $mode);
} | php | {
"resource": ""
} |
q29258 | Request.getQuery | train | public function getQuery($key = null, $default = null, $mode = null)
{
return $this->getValue($this->getQueryParams(), $key, $default, $mode);
} | php | {
"resource": ""
} |
q29259 | Request.getAuthorization | train | public function getAuthorization()
{
if (!$this->hasHeader('Authorization')) {
return null;
}
$temp = explode(' ', trim($this->getHeaderLine('Authorization')), 2);
switch (strtolower($temp[0])) {
case 'basic':
$temp[1] = base64_decode($temp[1])... | php | {
"resource": ""
} |
q29260 | Request.isCors | train | public function isCors()
{
if (!$this->hasHeader('Origin')) {
return false;
}
$origin = parse_url($this->getHeaderLine('Origin'));
$host = $this->getUri()->getHost();
$scheme = $this->getUri()->getScheme();
return (
!$host ||
strt... | php | {
"resource": ""
} |
q29261 | Request.getPreferredResponseFormats | train | public function getPreferredResponseFormats($default = 'text/html')
{
// parse accept header (uses default instead of 406 header)
$acpt = $this->getHeaderLine('Accept') ?: $default;
$acpt = explode(',', $acpt);
foreach ($acpt as $k => $v) {
$v = array_pad(explode(';', $v,... | php | {
"resource": ""
} |
q29262 | PersistentCollection.count | train | public function count() {
if(!$this->initialized)
$this->initialize();
return count($this->elements) - count($this->toRemove) + count($this->toAdd);
} | php | {
"resource": ""
} |
q29263 | Request.parseQuery | train | private function parseQuery($string)
{
$return = array();
$parts = explode("&", $string);
foreach ($parts as $part) {
list($key, $value) = explode('=', $part, 2);
$value = urldecode($value);
if (isset($return[$key])) {
if (!is_array... | php | {
"resource": ""
} |
q29264 | Request.buildQuery | train | private function buildQuery($parts)
{
$return = array();
foreach ($parts as $key => $value) {
if (is_array($value)) {
foreach ($value as $v) {
$return[] = urlencode($key) . "=" . urlencode($v);
}
continue;
... | php | {
"resource": ""
} |
q29265 | InternalUserManagerController.resetAction | train | public function resetAction(Request $request)
{
// TODO: Add validation class to have ability check like " if (empty($validation['errors'])){} "
if (!$request->request->has('user_id')) {
throw new CmsException(null, 'User id is not set');
}
$userId = $request->request->get('user_id');
$user = $this->con... | php | {
"resource": ""
} |
q29266 | InternalUserManagerController.deleteAction | train | public function deleteAction(Request $request)
{
// TODO: Add validation class to have ability check like " if (empty($validation['errors'])){} "
if (!$request->request->get('user_id')) {
throw new CmsException(null, 'User id is not set');
}
$userId = $request->request->get('user_id');
$currentUser = $t... | php | {
"resource": ""
} |
q29267 | RowController.createBlockAction | train | public function createBlockAction(Request $request)
{
$row = $this->findRowByRequest($request);
$type = $request->request->get('type', null);
try {
$block = $this->getEditor()->createDefaultBlock($type, [], $row);
} catch (EditorExceptionInterface $e) {
retur... | php | {
"resource": ""
} |
q29268 | RowController.layoutAction | train | public function layoutAction(Request $request)
{
$row = $this->findRowByRequest($request);
$data = $request->request->get('data', []);
try {
$this->getEditor()->getLayoutAdapter()->updateRowLayout($row, $data);
} catch (EditorExceptionInterface $e) {
return ... | php | {
"resource": ""
} |
q29269 | RowController.removeAction | train | public function removeAction(Request $request)
{
$row = $this->findRowByRequest($request);
$container = $row->getContainer();
try {
$this->getEditor()->getRowManager()->delete($row);
} catch (EditorExceptionInterface $e) {
return $this->handleException($e);
... | php | {
"resource": ""
} |
q29270 | RowController.moveDownAction | train | public function moveDownAction(Request $request)
{
$row = $this->findRowByRequest($request);
try {
$sibling = $this->getEditor()->getRowManager()->moveDown($row);
} catch (EditorExceptionInterface $e) {
return $this->handleException($e);
}
$container... | php | {
"resource": ""
} |
q29271 | AbleObject.grant | train | public function grant($ability) {
if (!in_array($ability, $this->abilities)) {
return $this->abilities = array_merge([$ability], $this->abilities);
}
return true;
} | php | {
"resource": ""
} |
q29272 | AbleObject.revoke | train | public function revoke($ability) {
if (in_array($ability, $this->abilities)) {
return $this->abilities =
array_values(array_diff($this->abilities, [$ability]));
}
return true;
} | php | {
"resource": ""
} |
q29273 | PageRepository.getLastUpdatedAt | train | public function getLastUpdatedAt()
{
$qb = $this->createQueryBuilder('p');
$date = $qb
->select('p.updatedAt')
->addOrderBy('p.updatedAt', 'DESC')
->getQuery()
->setMaxResults(1)
->getSingleScalarResult();
if (null !== $date) {
... | php | {
"resource": ""
} |
q29274 | PageRepository.findOneByRoute | train | public function findOneByRoute($routeName)
{
$qb = $this->getQueryBuilder('p');
return $qb
->leftJoin('p.seo', 's')
->leftJoin('s.translations', 's_t', Expr\Join::WITH, $this->getLocaleCondition('s_t'))
->addSelect('s', 's_t')
->andWhere($qb->expr()->... | php | {
"resource": ""
} |
q29275 | PageRepository.getPagesRoutes | train | public function getPagesRoutes()
{
$qb = $this->createQueryBuilder('p');
$results = $qb
->select('p.route')
->getQuery()
->getScalarResult();
return array_column($results, 'route');
} | php | {
"resource": ""
} |
q29276 | Collection.addDirectory | train | public function addDirectory($path)
{
$finder = new \Symfony\Component\Finder\Finder();
$patterns = $this->getIgnorePatterns()->getRegularExpression();
if ($this->follow_symlinks) {
$finder->followLinks();
}
// restrict names to those ending in the given extens... | php | {
"resource": ""
} |
q29277 | Collection.addFile | train | public function addFile($path)
{
$paths = $this->getGlobbedPaths($path);
foreach ($paths as $path) {
$file = new File($path);
$path = $file->getRealPath()
? $file->getRealPath()
: $file->getPathname();
$this[$path] = $file;
... | php | {
"resource": ""
} |
q29278 | Collection.getProjectRoot | train | public function getProjectRoot()
{
$base = '';
$files = array_keys($this->getArrayCopy());
$parts = explode(DIRECTORY_SEPARATOR, reset($files));
foreach ($parts as $part) {
$base_part = $base . $part . DIRECTORY_SEPARATOR;
foreach ($files as $dir) {
... | php | {
"resource": ""
} |
q29279 | Field.addChoice | train | public function addChoice(\DOMElement $node) {
if($node->nodeName != 'input')
return;
$inputValue = $node->getAttribute('value');
$this->choices[] = $inputValue;
switch($node->getAttribute('type')) {
case 'radio':
if($node->getAttribute('checked') == 'checked')
$this->value = $inputValue;
bre... | php | {
"resource": ""
} |
q29280 | FormParser.getPath | train | protected function getPath($name) {
$path = [];
$matches = null;
preg_match('/^([^\[]+)/', $name, $matches);
$path[] = $matches[0];
preg_match_all('/\[([^\]]*)\]/', $name, $matches);
$path = array_merge($path, $matches[1]);
return $path;
} | php | {
"resource": ""
} |
q29281 | FormParser.values | train | public function values() {
$res = [];
foreach($this->fields as $name=>$field) {
$value = $field->getValue();
if($value === null)
continue;
if(($field->getType() == 'image' || $field->getType() == 'submit') && $name !== $this->submit)
continue;
$path = $this->getPath($name);
$arr =& $res;
... | php | {
"resource": ""
} |
q29282 | FormParser.parse | train | public static function parse($html, $xpath) {
$doc = new \DOMDocument();
$doc->loadHTML($html);
$domxpath = new \DOMXPath($doc);
$node = $domxpath->evaluate($xpath)->item(0);
return new static($node);
} | php | {
"resource": ""
} |
q29283 | LocaleSegmentParameter.extractLocaleSegmentFromParameters | train | public static function extractLocaleSegmentFromParameters(Scope $scope, string $routeKey, array &$parameters = [])
{
$localeSegment = null;
// If none given, we should be returning the current active locale segment
// If value is explicitly null, we assume the current locale is expected
... | php | {
"resource": ""
} |
q29284 | DAL.setBatch | train | public function setBatch($size, array $replace=[]) {
$this->batch_size = $size;
$this->batch_replace = $replace;
return $this;
} | php | {
"resource": ""
} |
q29285 | DAL.insertBatch | train | public function insertBatch(array $row) {
$this->batch[] = $row;
if(count($this->batch) >= $this->batch_size) {
$this->flushBatch();
return true;
}
return false;
} | php | {
"resource": ""
} |
q29286 | DAL.flushBatch | train | public function flushBatch() {
if(count($this->batch) > 0) {
$this->insertMany($this->batch, $this->batch_replace);
$this->batch = [];
return true;
}
return false;
} | php | {
"resource": ""
} |
q29287 | DAL.reverse | train | public function reverse() {
if(!$this->orderBy)
throw new \Exception('Cannot reverse a query without order by.');
preg_match_all('/([^,])*([(].*?[)])([^,])*|([^,])+/', $this->orderBy, $e);
$e = $e[0];
foreach($e as $k=>$v) {
$v = preg_replace_callback('/(DESC|ASC)[\s]*/', function($r) {
$r = ... | php | {
"resource": ""
} |
q29288 | DAL.from | train | public function from($tables, $alias=null) {
$this->tables = [];
if(is_string($tables))
return $this->addFrom($tables);
else
return $this->addFrom([$alias => $tables]);
} | php | {
"resource": ""
} |
q29289 | DAL.addFrom | train | public function addFrom($tables) {
if(!$tables)
return $this;
if(is_string($tables))
$tables = explode(',', $tables);
elseif(!is_array($tables))
$tables = [$tables];
foreach($tables as $k=>$tablestr) {
if($tablestr instanceof static) {
$table = $tablestr;
$alias = $k;
}
e... | php | {
"resource": ""
} |
q29290 | DAL.removeFrom | train | public function removeFrom($what) {
foreach($this->tables as $alias=>$table) {
if($alias === $what) {
unset($this->tables[$alias]);
break;
}
}
return $this;
} | php | {
"resource": ""
} |
q29291 | DAL.join | train | public function join($type, $table, $conditions=null, $recursive=true) {
if($recursive && is_array($table)) {
foreach($table as $_table=>$_conditions) {
if($_conditions instanceof static)
$this->join($type, $table, $conditions, false);
elseif($_conditions instanceof Raw)
$this->join($type, ... | php | {
"resource": ""
} |
q29292 | DAL.next | train | public function next() {
if($this->query === null)
$this->query();
return $this->current = $this->query->next();
} | php | {
"resource": ""
} |
q29293 | DAL.reset | train | public function reset() {
$this->tables = [];
$this->columns = [];
$this->where = [];
$this->offset = null;
$this->limit = null;
$this->orderBy = [];
$this->groupBy = [];
$this->joins = [];
$this->params = [];
return $this;
} | php | {
"resource": ""
} |
q29294 | DAL.paginate | train | public function paginate($page, $per_page=10) {
$this->page = $page = $page ? $page:1;
$this->per_page = $per_page;
$this->offset(($page-1)*$per_page);
$this->limit($per_page);
return $this;
} | php | {
"resource": ""
} |
q29295 | DAL.addSelect | train | public function addSelect($columns) {
if(is_array($columns))
return $this->_addSelect($columns);
$columns = explode(',', $columns);
foreach($columns as $columnstr) {
$columnstr = trim($columnstr);
preg_match('/(.*?)\s+as\s+([a-z_][a-zA-Z0-9_]*)?$/i', $columnstr, $matches);
if(isset($matches... | php | {
"resource": ""
} |
q29296 | DAL._addSelect | train | protected function _addSelect(array $columns) {
if(array_values($columns) === $columns) {
foreach($columns as $k=>$v) {
unset($columns[$k]);
$columns[$v] = $v;
}
}
$this->columns = array_merge($this->columns, $columns);
return $this;
} | php | {
"resource": ""
} |
q29297 | DAL.removeSelect | train | public function removeSelect($what) {
foreach($this->columns as $alias=>$column) {
if($alias === $what) {
unset($this->columns[$alias]);
break;
}
}
return $this;
} | php | {
"resource": ""
} |
q29298 | DAL.where | train | public function where($conditions, $values=null) {
if(!$conditions)
return $this;
if($values !== null)
$this->where[] = [$conditions => $values];
else
$this->where[] = $conditions;
return $this;
} | php | {
"resource": ""
} |
q29299 | DAL.replace | train | protected function replace($condition, $setTable=true) {
$condition = preg_replace_callback('/(?<![\.a-zA-Z0-9_'.$this->quote.'\(\)])[a-z_][a-zA-Z0-9._]*(?![^\(]*\))/', function($matches) use($setTable) {
if($setTable && strpos($matches[0], '.')===false && count($this->joins) > 0 && count($this->tables)===1)
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.