_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q253700
CustomFieldsGroupController.indexAction
validation
public function indexAction() { $em = $this->getDoctrine()->getManager(); $cfGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->findAll(); $defaultGroups = $this->getDefaultGroupsId(); $makeDefaultFormViews = array(); foreach ($cfGroups as $group) { if (!in_array($group->getId(), $defaultGroups)){ $makeDefaultFormViews[$group->getId()] = $this->createMakeDefaultForm($group)->createView(); } } return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:index.html.twig', array( 'entities' => $cfGroups, 'default_groups' => $defaultGroups, 'make_default_forms' => $makeDefaultFormViews )); }
php
{ "resource": "" }
q253701
CustomFieldsGroupController.getDefaultGroupsId
validation
private function getDefaultGroupsId() { $em = $this->getDoctrine()->getManager(); $customFieldsGroupIds = $em->createQuery('SELECT g.id FROM ' . 'ChillCustomFieldsBundle:CustomFieldsDefaultGroup d ' . 'JOIN d.customFieldsGroup g') ->getResult(Query::HYDRATE_SCALAR); $result = array(); foreach ($customFieldsGroupIds as $row) { $result[] = $row['id']; } return $result; }
php
{ "resource": "" }
q253702
CustomFieldsGroupController.createMakeDefaultForm
validation
private function createMakeDefaultForm(CustomFieldsGroup $group = null) { return $this->createFormBuilder($group, array( 'method' => 'POST', 'action' => $this->generateUrl('customfieldsgroup_makedefault') )) ->add('id', 'hidden') ->add('submit', 'submit', array('label' => 'Make default')) ->getForm(); }
php
{ "resource": "" }
q253703
CustomFieldsGroupController.createCreateForm
validation
private function createCreateForm(CustomFieldsGroup $entity) { $form = $this->createForm('custom_fields_group', $entity, array( 'action' => $this->generateUrl('customfieldsgroup_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
php
{ "resource": "" }
q253704
CustomFieldsGroupController.newAction
validation
public function newAction() { $entity = new CustomFieldsGroup(); $form = $this->createCreateForm($entity); return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:new.html.twig', array( 'entity' => $entity, 'form' => $form->createView(), )); }
php
{ "resource": "" }
q253705
CustomFieldsGroupController.showAction
validation
public function showAction($id) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find CustomFieldsGroup entity.'); } $options = $this->getOptionsAvailable($entity->getEntity()); return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:show.html.twig', array( 'entity' => $entity, 'create_field_form' => $this->createCreateFieldForm($entity)->createView(), 'options' => $options )); }
php
{ "resource": "" }
q253706
CustomFieldsGroupController.getOptionsAvailable
validation
private function getOptionsAvailable($entity) { $options = $this->getParameter('chill_custom_fields.' . 'customizables_entities'); foreach($options as $key => $definition) { if ($definition['class'] == $entity) { foreach ($definition['options'] as $key => $value) { yield $key; } } } // [$entity->getEntity()]; }
php
{ "resource": "" }
q253707
CustomFieldsGroupController.createEditForm
validation
private function createEditForm(CustomFieldsGroup $entity) { $form = $this->createForm('custom_fields_group', $entity, array( 'action' => $this->generateUrl('customfieldsgroup_update', array('id' => $entity->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
php
{ "resource": "" }
q253708
CustomFieldsGroupController.renderFormAction
validation
public function renderFormAction($id, Request $request) { $em = $this->getDoctrine()->getManager(); $entity = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find CustomFieldsGroups entity.'); } $form = $this->createForm('custom_field', null, array('group' => $entity)); $form->add('submit_dump', 'submit', array('label' => 'POST AND DUMP')); $form->add('submit_render','submit', array('label' => 'POST AND RENDER')); $form->handleRequest($request); $this->get('twig.loader') ->addPath(__DIR__.'/../Tests/Fixtures/App/app/Resources/views/', $namespace = 'test'); if ($form->isSubmitted()) { if ($form->get('submit_render')->isClicked()) { return $this->render('ChillCustomFieldsBundle:CustomFieldsGroup:render_for_test.html.twig', array( 'fields' => $form->getData(), 'customFieldsGroup' => $entity )); } var_dump($form->getData()); var_dump(json_enccode($form->getData())); } return $this ->render('@test/CustomField/simple_form_render.html.twig', array( 'form' => $form->createView() )); }
php
{ "resource": "" }
q253709
Temporary.getStream
validation
public function getStream($mediaId) { $response = $this->getHttp()->get(self::API_GET, ['media_id' => $mediaId]); $response->getBody()->rewind(); $body = $response->getBody()->getContents(); $json = json_decode($body, true); if (JSON_ERROR_NONE === json_last_error()) { $this->checkAndThrow($json); } return $body; }
php
{ "resource": "" }
q253710
LumenAppNameCommand.replaceNamespace
validation
protected function replaceNamespace($path) { $search = [ 'namespace ' . $this->currentRoot . ';', $this->currentRoot . '\\' ]; $replace = [ 'namespace ' . $this->argument('name') . ';', $this->argument('name') . '\\' ]; $this->replaceIn($path, $search, $replace); }
php
{ "resource": "" }
q253711
LumenAppNameCommand.setAppConfigNamespaces
validation
protected function setAppConfigNamespaces() { $search = [ $this->currentRoot . '\\Providers', $this->currentRoot . '\\Http\\Controllers\\' ]; $replace = [ $this->argument('name') . '\\Providers', $this->argument('name') . '\\Http\\Controllers\\' ]; //$this->replaceIn($this->getConfigPath('app'), $search, $replace); }
php
{ "resource": "" }
q253712
LumenAppNameCommand.setDatabaseFactoryNamespaces
validation
protected function setDatabaseFactoryNamespaces() { $this->replaceIn($this->laravel->databasePath() . '/factories/ModelFactory.php', $this->currentRoot, $this->argument('name')); }
php
{ "resource": "" }
q253713
Module.isEnabled
validation
public static function isEnabled() { $class = self::className(); foreach (\Yii::$app->modules as $module => $params) { switch (gettype($params)) { case 'array' : if ($class == @$params['class']) return true; break; case 'object': if ($class == get_class($params)) return true; break; default : if ($class == $params) return true; } if ($module == $class || (isset($module['class']) && $module['class'] == $class)) { return true; } } return false; }
php
{ "resource": "" }
q253714
Base.lookForPreMinifiedAsset
validation
private function lookForPreMinifiedAsset() { $min_path = (string)Str::s($this->file->getRealPath())->replace ( '.'.$this->file->getExtension(), '.min.'.$this->file->getExtension() ); if (!file_exists($min_path)) return false; return file_get_contents($min_path); }
php
{ "resource": "" }
q253715
ThemeHandler.getTheme
validation
public function getTheme($identifier) { $themes = $this->getAvailableThemes(); if ( !isset($themes[$identifier]) ) { $themeIds = array(); foreach ($themes as $key => $value) { $themeIds[] = $key; } throw new \Exception(sprintf('Theme "%s" does not exist. Possible values are [%s]', $identifier, implode(', ', $themeIds)), 1); } return $themes[$identifier]; }
php
{ "resource": "" }
q253716
ThemeHandler.getCurrentTheme
validation
public function getCurrentTheme() { $theme = $this->getDefaultTheme(); if ( $this->container->get('session')->has('_admin_theme') ) { $theme = $this->container->get('session')->get('_admin_theme'); } return $theme; }
php
{ "resource": "" }
q253717
ThemeHandler.setCurrentTheme
validation
public function setCurrentTheme($identifier) { $theme = $this->getTheme($identifier); $this->container->get('session')->set('_admin_theme', $theme); }
php
{ "resource": "" }
q253718
FieldManager.getTransformation
validation
private function getTransformation() { $transforms = []; foreach ($this->fields as $field => $extra) { if (is_int($field)) { $transforms[$extra] = $extra; continue; } $transform = (key_exists('transform', $extra)) ? $extra['transform'] : $field; if ($transform === false) { continue; } $transforms[$field] = $transform; } return $transforms; }
php
{ "resource": "" }
q253719
ElFinderConnector.connect
validation
public function connect() { $this->loadConnectors(); $connector = new \elFinderConnector(new \elFinder($this->options)); $connector->run(); }
php
{ "resource": "" }
q253720
ElFinderConnector.generateOptions
validation
private function generateOptions($folder, $rootAlias) { $assetsPath = $this->configurationHandler->uploadAssetsDir() . '/' . $folder; if (!is_dir($assetsPath)) { @mkdir($assetsPath); } $options = array( 'locale' => '', 'roots' => array( array( 'driver' => 'LocalFileSystem', // driver for accessing file system (REQUIRED) 'path' => $assetsPath, // path to files (REQUIRED) 'URL' => $this->configurationHandler->absoluteUploadAssetsDir() . '/' . $folder, // URL to files (REQUIRED) 'accessControl' => 'access', // disable and hide dot starting files (OPTIONAL) 'rootAlias' => $rootAlias // disable and hide dot starting files (OPTIONAL) ) ) ); return $options; }
php
{ "resource": "" }
q253721
ThemeBase.findSlotsInTemplates
validation
protected function findSlotsInTemplates() { $templates = $this->findTemplates(); $slots = array(); foreach ($templates["base"] as $templateName => $templateFile) { $templateContents = FilesystemTools::readFile($templateFile); $slots = array_merge_recursive($slots, $this->findSlots($templateName, $templateContents)); } $baseSlots["base"] = $slots; $slots = array(); foreach ($templates["template"] as $templateName => $templateFile) { $templateContents = FilesystemTools::readFile($templateFile); $slots[$templateName] = $this->findSlots($templateName, $templateContents); } return array( 'base' => $baseSlots, 'templates' => $slots, ); }
php
{ "resource": "" }
q253722
DoctrinePackage.registerServices
validation
public function registerServices(ServicesFactory $servicesFactory, array $entityManagers) { foreach ($entityManagers as $name => $entityManager) { //TODO: handle isDev depending on app config $emConfig = Setup::createAnnotationMetadataConfiguration( (array) $entityManager->getEntities(), true, null, null, true ); $emConfig->setNamingStrategy(new UnderscoreNamingStrategy()); $em = $this->createEntityManager($entityManager->toArray(), $emConfig); // register entity manager as a service $emServiceId = 'doctrine.em.' . Str::cast($name)->lower(); $servicesFactory->registerService(['id' => $emServiceId, 'instance' => $em]); $servicesFactory->registerService([ 'id' => 'db.connection.' . $name, 'instance' => $em->getConnection()->getWrappedConnection() ]); } }
php
{ "resource": "" }
q253723
Calc.mapByGeneration
validation
private function mapByGeneration($mapByDepthDesc, $mapById) { $result = []; // [ $custId=>[$genId => $totalPv, ...], ... ] foreach ($mapByDepthDesc as $depth => $ids) { foreach ($ids as $custId) { /** @var EBonDwnl $entry */ $entry = $mapById[$custId]; $path = $entry->getPath(); $parents = $this->hlpTree->getParentsFromPathReversed($path); $level = 0; foreach ($parents as $parentId) { $level += 1; if (!isset($result[$parentId])) { $result[$parentId] = []; } if (!isset($result[$parentId][$level])) { $result[$parentId][$level] = []; } $result[$parentId][$level][] = $custId; } } } return $result; }
php
{ "resource": "" }
q253724
Calc.plainBonus
validation
private function plainBonus($bonus) { /* prepare data for updates */ $result = []; /** @var DEntry $item */ foreach ($bonus as $item) { $bonusData = $item->getEntries(); /** @var DBonus $entry */ foreach ($bonusData as $entry) { $bonus = $entry->getValue(); if ($bonus > Cfg::DEF_ZERO) { $result[] = $entry; } } } return $result; }
php
{ "resource": "" }
q253725
Application.getDefaultOptionIds
validation
protected function getDefaultOptionIds() { $optionIds = []; $defaultDefinition = $this->getDefaultInputDefinition(); foreach ($defaultDefinition->getOptions() as $option) { $optionIds[] = $option->getName(); }; return $optionIds; }
php
{ "resource": "" }
q253726
Guesser.adapterHasBehavior
validation
public function adapterHasBehavior(Adapter $adapter, $behavior) { if ($adapter instanceof KnowsItsBehaviors) { return in_array($behavior, $adapter->getBehaviors()); } return true === is_a($adapter, $behavior); }
php
{ "resource": "" }
q253727
Guesser.allFromAdapter
validation
public function allFromAdapter(Adapter $adapter) { if ($adapter instanceof KnowsItsBehaviors) { return $adapter->getBehaviors(); } $rfl = new \ReflectionClass($adapter); $behaviors = array(); foreach ($rfl->getInterfaces() as $interface) { if (true === $interface->isSubclassOf('Gaufrette\Core\Adapter\Behavior')) { $behaviors[] = $interface->getName(); } } return $behaviors; }
php
{ "resource": "" }
q253728
Log.enableLogging
validation
public static function enableLogging($writePath) { if (is_file($writePath)) { self::$enabled = true; self::$logFilePath = $writePath; return true; } throw new \Exception('Impossible d\'activer les logs dans le fichier '.$writePath.' : celui ci n\'existe pas.'); return false; }
php
{ "resource": "" }
q253729
Log.write
validation
public static function write($output) { if (self::$enabled) { $d = new \DateTime(); $f = new File(self::$logFilePath, true); $f->write($d->format('d/m/Y H:i:s') . ' - ' . $output . "\n", true); } }
php
{ "resource": "" }
q253730
Log.setPath
validation
protected static function setPath($writePath) { if (is_file($writePath)) { self::$logFilePath = $writePath; return true; } throw new \Exception('Impossible de modifier la destination des logs : le fichier '.$writePath.' n\'existe pas.'); return false; }
php
{ "resource": "" }
q253731
Parser.select
validation
public static function select($select) { if (gettype($select)=="array") { foreach ($select as $key => $field) { if ($field instanceof Key) { $alias = '"'.$field.'"'; $field = self::field($field); $select[$key] = "{$field} as {$alias}"; } } $select = implode(", ", $select); } elseif (gettype($select)!="string") { throw new ClusterpointException("\"->select()\" function: passed parametr is not in valid format.", 9002); } return $select; }
php
{ "resource": "" }
q253732
Parser.where
validation
public static function where($field, $operator, $value, $logical) { if (gettype($field)=="array") { throw new ClusterpointException("\"->where()\" function: passed field selector is not in valid format.", 9002); } if ($operator===null) { return "{$logical} {$field} "; } elseif ($value===null) { $value = $operator; $operator = '=='; } if ($field instanceof Key) { $field = self::field("{$field}"); } if (!($value instanceof Raw)) { if (is_string($value)){ $value = '"'.Client::escape($value).'"'; } else { $value = json_encode($value); } } return "{$logical} {$field}{$operator}{$value} "; }
php
{ "resource": "" }
q253733
Parser.orderBy
validation
public static function orderBy($field, $order) { if (!$order) { $order = 'DESC'; } $order = strtoupper($order); if (!($order=='ASC' || $order=='DESC')) { throw new ClusterpointException("\"->order()\" function: ordering should be DESC or ASC.", 9002); } if (!(gettype($field)=="string" || $field instanceof Key || $field instanceof Raw)) { throw new ClusterpointException("\"->order()\" function: passed field selector is not in valid format.", 9002); } if ($field instanceof Key) { $field = self::field("{$field}"); } return "{$field} {$order}"; }
php
{ "resource": "" }
q253734
Parser.groupBy
validation
public static function groupBy($field) { if (!(gettype($field)=="string" || $field instanceof Key || $field instanceof Raw)) { throw new ClusterpointException("\"->group()\" function: passed field selector is not in valid format.", 9002); } if ($field instanceof Key) { $field = self::field("{$field}"); } return "{$field}"; }
php
{ "resource": "" }
q253735
Parser.find
validation
public static function find($id = null, $connection) { if (gettype($id)!="string" && !is_numeric($id)) { throw new ClusterpointException("\"->find()\" function: \"_id\" is not in valid format.", 9002); } $connection->method = 'GET'; $connection->action = '['.urlencode($id).']'; $connection->multiple = false; return self::sendQuery($connection); }
php
{ "resource": "" }
q253736
Parser.get
validation
public static function get(Scope $scope, $connection, $multiple, $return = false) { $from = $connection->db; if (strpos($from, '.') !== false) { $tmp = explode('.', $connection->db); $from = end($tmp); } if (!is_null($scope->listWordsField)) { if ($scope->listWordsField === '') { $from = 'LIST_WORDS(' . $from . ')'; } else { $from = 'LIST_WORDS(' . $from . '.' . $scope->listWordsField . ')'; } } if (!is_null($scope->alternativesField)) { if ($scope->alternativesField === '') { $from = 'ALTERNATIVES(' . $from . ')'; } else { $from = 'ALTERNATIVES(' . $from . '.' . $scope->alternativesField . ')'; } } $connection->query = $scope->prepend.'SELECT '.$scope->select.' FROM '.$from.' '; if (!is_null($scope->join)){ $connection->query .= $scope->join.' '; } if ($scope->where!='') { $connection->query .= 'WHERE'.$scope->where; } if (count($scope->groupBy)) { $connection->query .= 'GROUP BY '.implode(", ", $scope->groupBy).' '; } if (count($scope->orderBy)) { $connection->query .= 'ORDER BY '.implode(", ", $scope->orderBy).' '; } $connection->query .= 'LIMIT '.$scope->offset.', '.$scope->limit; if ($return) { return $connection->query; } $connection->method = 'POST'; $connection->action = '/_query'; $connection->multiple = $multiple; $scope->resetSelf(); return self::sendQuery($connection); }
php
{ "resource": "" }
q253737
Parser.delete
validation
public static function delete($id = null, $connection) { if (gettype($id)!="string" && !is_numeric($id)) { throw new ClusterpointException("\"->delete()\" function: \"_id\" is not in valid format.", 9002); } $connection->method = 'DELETE'; $connection->action = '['.urlencode($id).']'; return self::sendQuery($connection); }
php
{ "resource": "" }
q253738
Parser.deleteMany
validation
public static function deleteMany(array $ids = array(), $connection) { if (!is_array($ids)) { throw new ClusterpointException("\"->deleteMany()\" function: \"_id\" is not in valid format.", 9002); } $connection->method = 'DELETE'; $connection->action = ''; // force strings! REST hates DELETE with integers for now... foreach ($ids as &$id) { $id = (string)$id; } $connection->query = json_encode($ids); return self::sendQuery($connection); }
php
{ "resource": "" }
q253739
Parser.insertOne
validation
public static function insertOne($document, $connection) { $connection->query = self::singleDocument($document); return self::insert($connection); }
php
{ "resource": "" }
q253740
Parser.insertMany
validation
public static function insertMany($document, $connection) { if (gettype($document)!="array" && gettype($document)!="object") { throw new ClusterpointException("\"->insert()\" function: parametr passed ".json_encode(self::escape_string($document))." is not in valid document format.", 9002); } if (gettype($document)=="object") { $document_array = array(); foreach ($document as $value) { $document_array[] = $value; } $document = $document_array; } $connection->query = json_encode(array_values($document)); $connection->multiple = true; return self::insert($connection); }
php
{ "resource": "" }
q253741
Parser.update
validation
public static function update($id, $document, $connection) { $from = $connection->db; if (strpos($from, '.') !== false) { $tmp = explode('.', $connection->db); $from = end($tmp); } $connection->method = 'PATCH'; $connection->action = '['.urlencode($id).']'; switch (gettype($document)) { case "string": $connection->query = $document; break; case "array": case "object": $connection->method = 'POST'; $connection->action = '/_query'; $connection->query = 'UPDATE '.$from.'["'.$id.'"] SET '.self::updateRecursion($document); break; default: throw new ClusterpointException("\"->update()\" function: parametr passed ".json_encode(self::escape_string($document))." is not in valid format.", 9002); break; } return self::sendQuery($connection); }
php
{ "resource": "" }
q253742
Parser.updateRecursion
validation
private static function updateRecursion($document) { $result = array(); foreach (self::toDotted($document, '', 1) as $path => $value) { $result[] = $path . $value; } return implode(' ', $result); }
php
{ "resource": "" }
q253743
Parser.replace
validation
public static function replace($id, $document, $connection) { $connection->query = self::singleDocument($document); $connection->method = 'PUT'; $connection->action = '['.urlencode($id).']'; return self::sendQuery($connection); }
php
{ "resource": "" }
q253744
Parser.beginTransaction
validation
public static function beginTransaction($connection) { $connection->query = 'BEGIN_TRANSACTION'; $connection->method = 'POST'; $connection->action = '/_query'; return self::sendQuery($connection); }
php
{ "resource": "" }
q253745
Parser.rollbackTransaction
validation
public static function rollbackTransaction($connection) { $connection->query = 'ROLLBACK'; $connection->method = 'POST'; $connection->action = '/_query'; return self::sendQuery($connection); }
php
{ "resource": "" }
q253746
Parser.commitTransaction
validation
public static function commitTransaction($connection) { $connection->query = 'COMMIT'; $connection->method = 'POST'; $connection->action = '/_query'; return self::sendQuery($connection); }
php
{ "resource": "" }
q253747
Parser.sendQuery
validation
public static function sendQuery(ConnectionInterface $connection) { $response = DataLayer::execute($connection); $connection->resetSelf(); return $response; }
php
{ "resource": "" }
q253748
Parser.singleDocument
validation
public static function singleDocument($document) { if (gettype($document)!="array" && gettype($document)!="object") { throw new ClusterpointException("\"->insert()\" function: parametr passed ".json_encode(self::escape_string($document))." is not in valid document format.", 9002); } $query = "{"; $first = true; foreach ($document as $key => $value) { if (!$first) { $query .= ","; } $query .= '"'.self::escape_string($key).'" : '.json_encode($value); $first = false; } $query .= '}'; return $query; }
php
{ "resource": "" }
q253749
MessageBuilder.msgType
validation
public function msgType($msgType) { if (!in_array($msgType, $this->msgTypes, true)) { throw new InvalidArgumentException('This message type not exist.'); } $this->msgType = $msgType; return $this; }
php
{ "resource": "" }
q253750
MessageBuilder.build
validation
public function build() { if (empty($this->msgType)) { throw new RuntimeException('message type not exist.'); } if (empty($this->message)) { throw new RuntimeException('No message content to send.'); } // 群发视频消息给用户列表时,视频消息格式需要另外处理,具体见文档 if ($this->msgType === Broadcast::MSG_TYPE_VIDEO) { if (is_array($this->message)) { $this->message = array_shift($this->message); } $this->msgType = 'mpvideo'; } $content = (new Transformer($this->msgType, $this->message))->transform(); $group = isset($this->to) ? $this->to : null; $message = array_merge($this->buildGroup($group), $content); return $message; }
php
{ "resource": "" }
q253751
MessageBuilder.buildPreview
validation
public function buildPreview($by) { if (!in_array($by, $this->previewBys, true)) { throw new InvalidArgumentException('This preview by not exist.'); } if (empty($this->msgType)) { throw new RuntimeException('Message type not exist.'); } elseif ($this->msgType === Broadcast::MSG_TYPE_VIDEO) { if (is_array($this->message)) { $this->message = array_shift($this->message); } $this->msgType = 'mpvideo'; } if (empty($this->message)) { throw new RuntimeException('No message content to send.'); } if (empty($this->to)) { throw new RuntimeException('No to.'); } $content = (new Transformer($this->msgType, $this->message))->transform(); $message = array_merge($this->buildTo($this->to, $by), $content); return $message; }
php
{ "resource": "" }
q253752
MessageBuilder.buildGroup
validation
private function buildGroup($group) { if (is_null($group)) { $group = [ 'filter' => [ 'is_to_all' => true, ], ]; } elseif (is_array($group)) { $group = [ 'touser' => $group, ]; } else { $group = [ 'filter' => [ 'is_to_all' => false, 'group_id' => $group, ], ]; } return $group; }
php
{ "resource": "" }
q253753
LoginForm.login
validation
public function login() { if ($this->validate()) { return \Yii::$app->getUser()->login($this->user, $this->rememberMe ? $this->module->rememberFor : 0); } else { return false; } }
php
{ "resource": "" }
q253754
Folder.copy
validation
public static function copy($src, $dest, $force=false, $delete=false) { $src = Path::clean($src); $dest = Path::clean($dest); $fs = new Filesystem(); try { $fs->mirror($src, $dest, null, [ 'override' => $force, 'delete' => $delete, 'copy_on_windows' => true ]); } catch(IOExceptionInterface $e){ throw new Exception(Helper::getTranslation('CANNOT_FIND_SOURCE').' '.$e->getPath()); } return true; }
php
{ "resource": "" }
q253755
Folder.create
validation
public static function create($path='', $mode=0777) { $path = Path::clean($path); $fs = new Filesystem(); try { $fs->mkdir($path); } catch(IOExceptionInterface $e){ throw new Exception(Helper::getTranslation('FAILED_CREATING').' '.$e->getPath()); } return true; }
php
{ "resource": "" }
q253756
Folder.exists
validation
public static function exists($path) { $path = Path::clean($path); $fs = new Filesystem(); return $fs->exists($path); }
php
{ "resource": "" }
q253757
Folder.delete
validation
public static function delete($path) { if ( !Folder::exists($path) ){ return true; } $path = Path::clean($path); if ( trim($path) === '' ){ throw new Exception(Helper::getTranslation('FAILED_DELETING').' : Cannot delete root path'); } $fs = new Filesystem(); try { $fs->remove($path); } catch(IOExceptionInterface $e){ throw new Exception(Helper::getTranslation('FAILED_DELETING').' - ('.$e->getMessage().')'); } return true; }
php
{ "resource": "" }
q253758
Folder.move
validation
public static function move($src, $dest, $overwrite=false) { $src = Path::clean($src); $dest = Path::clean($dest); if ( !Folder::exists($src) ){ throw new Exception(Helper::getTranslation('CANNOT_FIND_SOURCE').' : '.$src); } if ( Folder::exists($dest) ){ throw new Exception(Helper::getTranslation('ALREADY_EXISTS').' : '.$dest); } $fs = new Filesystem(); try { $fs->rename($src, $dest, $overwrite); } catch(IOExceptionInterface $e){ throw new Exception(Helper::getTranslation('FAILED_RENAMING').' - ('.$e->getMessage().')'); } return true; }
php
{ "resource": "" }
q253759
Folder.files
validation
public static function files($path, $filter = '.', $recurse = false, $full = false, $exclude = array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'Thumbs.db'), $excludefilter = array('^\..*', '.*~'), $naturalSort = true) { $path = Path::clean($path); if ( !is_dir($path) ){ throw new Exception(Helper::getTranslation('NOT_A_FOLDER')); } if ( count($excludefilter) ){ $excludefilter_string = '/(' . implode('|', $excludefilter) . ')/'; } else { $excludefilter_string = ''; } $arr = Folder::_items($path, $filter, $recurse, $full, $exclude, $excludefilter_string, true); if ( $naturalSort ){ natsort($arr); } else { asort($arr); } return array_values($arr); }
php
{ "resource": "" }
q253760
Downline.getByCalcId
validation
public function getByCalcId($calcId) { $where = Entity::A_CALC_REF . '=' . (int)$calcId; $result = $this->get($where); return $result; }
php
{ "resource": "" }
q253761
DbSettingsMapper.getWhereFromParameter
validation
protected function getWhereFromParameter(ParameterInterface $parameter) { if ($parameter instanceof IdAwareParameterInterface && $parameter->getId()) { return ['id' => $parameter->getId()]; } else { return ['namespace' => $parameter->getNamespace(), 'name' => $parameter->getName()]; } }
php
{ "resource": "" }
q253762
CustomFieldRenderingTwig.renderLabel
validation
public function renderLabel($customFieldOrClass, $slug = null, array $params = array()) { $resolvedParams = array_merge($this->defaultParams, $params); $customField = ($customFieldOrClass instanceof CustomField) ? $customFieldOrClass : $this->container->get('chill.custom_field.provider') ->getCustomField($customFieldOrClass, $slug); return $this->container->get('templating') ->render($resolvedParams['label_layout'], array('customField' => $customField)); }
php
{ "resource": "" }
q253763
CustomFieldRenderingTwig.renderWidget
validation
public function renderWidget(array $fields, $customFieldOrClass, $documentType='html', $slug = null) { return $this->container->get('chill.custom_field.helper') ->renderCustomField($fields, $customFieldOrClass, $documentType, $slug); }
php
{ "resource": "" }
q253764
Command.update
validation
public function update(array $arguments = null, array $options = null): void { /* Update Arguments */ if ($arguments) { $keys = array_keys($this->arguments); for ($index = 0; $index < count($keys); $index++) { $this->arguments[$keys[$index]] = $arguments[$index]; } } /* Update Options */ if ($options) { foreach ($options as $option => $value) { $this->options[$option] = $value; } } }
php
{ "resource": "" }
q253765
Template.deserializeJSON
validation
public function deserializeJSON($jsonString) { $data = json_decode($jsonString); $this->setContent($data->content); $this->setContext($data->context); }
php
{ "resource": "" }
q253766
SharedLock.release
validation
static function release( $token, $mode, $opts=array() ) { // just in case (is_file results might be cached!)... clearstatcache(); $lockDir = self::lockDir( $opts ); if ( $mode == LOCK_EX ) { $wLockFile = "$lockDir/{$token}_W.lock"; if ( is_file( $wLockFile ) && !unlink( $wLockFile ) ) { // what to do here? we echo an error msg but do not throw an exception pake_echo_error( "Could not remove W lock file '$wLockFile'" ); } return; } // assume a read lock $rLockFile = "$lockDir/{$token}_R/" . getmypid() . ".lock"; if ( is_file( $rLockFile ) && !unlink( $rLockFile ) ) { // what to do here? we echo an error msg but do not throw an exception pake_echo_error( "Could not remove R lock file '$rLockFile'" ); } }
php
{ "resource": "" }
q253767
SharedLock.cleanup
validation
static public function cleanup( $opts=array() ) { if ( strtoupper( substr( PHP_OS, 0, 3 ) ) == 'WIN' ) { exec( 'tasklist /FO CSV', $runningProcesses, $return_var ); $runningProcesses = array_map( function( $line ){ $cols = explode( ',', $line ); return trim( $cols[1], '"' ); }, $runningProcesses ); unset( $runningProcesses[0] ); // 'PID' sort( $runningProcesses ); unset( $runningProcesses[0] ); // 0 } else { exec( 'ps -e -o pid', $runningProcesses, $return_var ); } if ( $return_var != 0 ) { pake_echo_error( "Could not get list of processes to remove stale lock files" ); return; } $lockDir = self::lockDir( $opts ); foreach( glob( $lockDir . "/*_W.lock" ) as $writeLock ) { $pid = file_get_contents( $writeLock ); //strstr( file_get_contents( $writeLock ), ' ', true ); if ( !in_array( $pid, $runningProcesses ) ) { pake_unlink( $writeLock ); } } foreach( glob( $lockDir . "/*_R/*.lock" ) as $readLock ) { $pid = file_get_contents( $readLock ); // strstr( file_get_contents( $readLock ), ' ', true ); if ( !in_array( $pid, $runningProcesses ) ) { pake_unlink( $readLock ); } } }
php
{ "resource": "" }
q253768
Module.getDataSources
validation
public function getDataSources() { if (is_null($this->_dataSources)) { $this->_dataSources = []; foreach ($this->dataSources() as $foreignModel => $dataSource) { if (is_numeric($foreignModel) || isset($dataSources['foreignModel'])) { if (!isset($dataSources['foreignModel'])) { continue; } $foreignModel = $dataSources['foreignModel']; unset($dataSources['foreignModel']); } if (!isset($dataSource['class'])) { $dataSource['class'] = $this->dataSourceClass; } $dataSource['name'] = $foreignModel; $dataSource['foreignModel'] = $this->getForeignModel($foreignModel); if (empty($dataSource['foreignModel'])) { continue; } $this->_dataSources[$foreignModel] = Yii::createObject(array_merge(['module' => $this], $dataSource)); } } return $this->_dataSources; }
php
{ "resource": "" }
q253769
Module.getLocalDataSource
validation
public function getLocalDataSource($localModelClass) { foreach ($this->dataSources as $dataSource) { if ($dataSource->localModel === $localModelClass) { return $dataSource; } } return false; }
php
{ "resource": "" }
q253770
Module.getForeignDataSource
validation
public function getForeignDataSource($foreignModelClass) { foreach ($this->dataSources as $dataSource) { if ($dataSource->foreignModel->modelName === $foreignModelClass) { return $dataSource; } } return false; }
php
{ "resource": "" }
q253771
Device.apply
validation
public function apply($quantity, $reason, $comment = '', $poiId = null) { $params = [ 'quantity' => intval($quantity), 'apply_reason' => $reason, ]; if (!empty($comment)) { $params['comment'] = $comment; } if (!is_null($poiId)) { $params['poi_id'] = intval($poiId); } return $this->parseJSON('json', [self::API_DEVICE_APPLYID, $params]); }
php
{ "resource": "" }
q253772
Device.getStatus
validation
public function getStatus($applyId) { $params = [ 'apply_id' => intval($applyId), ]; return $this->parseJSON('json', [self::API_DEVICE_APPLYSTATUS, $params]); }
php
{ "resource": "" }
q253773
Device.update
validation
public function update(array $deviceIdentifier, $comment) { $params = [ 'device_identifier' => $deviceIdentifier, 'comment' => $comment, ]; return $this->parseJSON('json', [self::API_DEVICE_UPDATE, $params]); }
php
{ "resource": "" }
q253774
Device.bindLocation
validation
public function bindLocation(array $deviceIdentifier, $poiId, $type = 1, $poiAppid = null) { $params = [ 'device_identifier' => $deviceIdentifier, 'poi_id' => intval($poiId), ]; if ($type === 2) { if (is_null($poiAppid)) { throw new InvalidArgumentException('If value of argument #3 is 2, argument #4 is required.'); } $params['type'] = 2; $params['poi_appid'] = $poiAppid; } return $this->parseJSON('json', [self::API_DEVICE_BINDLOCATION, $params]); }
php
{ "resource": "" }
q253775
Device.pagination
validation
public function pagination($lastSeen, $count) { $params = [ 'type' => 2, 'last_seen' => intval($lastSeen), 'count' => intval($count), ]; return $this->fetch($params); }
php
{ "resource": "" }
q253776
Device.fetchByApplyId
validation
public function fetchByApplyId($applyId, $lastSeen, $count) { $params = [ 'type' => 3, 'apply_id' => intval($applyId), 'last_seen' => intval($lastSeen), 'count' => intval($count), ]; return $this->fetch($params); }
php
{ "resource": "" }
q253777
SecurityController.authenticate
validation
public function authenticate(ClientInterface $client) { $attributes = $client->getUserAttributes(); $provider = $client->getId(); $clientId = $attributes['id']; $account = $this->finder->findAccountByProviderAndClientId($provider, $clientId); if ($account === null) { $account = \Yii::createObject([ 'class' => Account::className(), 'provider' => $provider, 'client_id' => $clientId, 'data' => json_encode($attributes), ]); $account->save(false); } if (null === ($user = $account->user)) { $this->action->successUrl = Url::to(['/user/registration/connect', 'account_id' => $account->id]); } else { \Yii::$app->user->login($user, $this->module->rememberFor); } }
php
{ "resource": "" }
q253778
RelatedObjects.setRelatedObjects
validation
public function setRelatedObjects($relatedObjects) { foreach ($relatedObjects as $modelName => $objects) { if (!isset($this->_relatedObjects[$modelName])) { $this->_relatedObjects[$modelName] = []; } foreach ($objects as $tabId => $objectAttributes) { if (!isset($objectAttributes['_moduleHandler'])) { continue; } list($relationship, $role) = $this->owner->objectType->getRelationship($objectAttributes['_moduleHandler']); $relatedHandler = $this->owner->objectType->getRelatedType($objectAttributes['_moduleHandler']); if (!$relatedHandler) { continue; } $objectAttributes = array_merge([ 'companionObject' => $this->owner, 'companionRelationship' => $relationship, 'companionRole' => $role, ], $objectAttributes); $object = $relatedHandler->getModel(null, $objectAttributes); $object->tabularId = $objectAttributes['_moduleHandler']; if ((!$object || $object->isEmptyObject()) && !($relationship->required) ) { continue; } $object->companionObject = $object->indirectObject = $this->owner; $object->companionRelationship = $relationship; $object->companionRole = $role; $this->_relatedObjects[$modelName][$tabId] = $object; $this->_relatedObjectsFlat[] = $object; } } }
php
{ "resource": "" }
q253779
RelatedObjects.setRelations
validation
public function setRelations($value) { if ($this->companionObject) { $baseObject = $this->companionObject; } else { $baseObject = $this->owner; } $fields = $baseObject->getFields(); foreach ($value as $tabId => $relation) { if (!isset($relation['_moduleHandler'])) { \d("boom"); exit; continue; } if (!isset($fields[$relation['_moduleHandler']])) { \d($relation['_moduleHandler']); \d(array_keys($fields)); exit; continue; } $baseAttributes = []; $model = $fields[$relation['_moduleHandler']]->model; if (empty($model)) { $model = $fields[$relation['_moduleHandler']]->resetModel(); } $model->attributes = $relation; $model->_moduleHandler = $relation['_moduleHandler']; $model->tabularId = $relation['_moduleHandler']; list($relationship, $role) = $baseObject->objectType->getRelationship($model->_moduleHandler); $relatedHandler = $baseObject->objectType->getRelatedType($model->_moduleHandler); if (!$relatedHandler) { continue; } if (!$this->owner->tabularId // primary object && !$this->owner->isNewRecord && empty($model->parent_object_id) && empty($model->child_object_id)) { continue; } $this->_relations[$tabId] = $model; } }
php
{ "resource": "" }
q253780
Benri_Util_String.dasherize
validation
public static function dasherize($str, $replacement = '_') { return preg_replace_callback( '/([A-Z0-9-\s]+)/', function ($match) use ($replacement) { return $replacement . strtolower($match[1]); }, lcfirst($str) ); }
php
{ "resource": "" }
q253781
Benri_Util_String.camelize
validation
public static function camelize($str, $ucfirst = false) { $replace = str_replace( ' ', '', ucwords(str_replace(['_', '-'], ' ', strtolower($str))) ); if (!$ucfirst) { return lcfirst($replace); } return $replace; }
php
{ "resource": "" }
q253782
Benri_Util_String.random
validation
public static function random( $length = 8, $allowedChars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXY346789' ) { $return = ''; $hashLength = strlen($allowedChars) - 1; for (;$length > 0; --$length) { $return .= $allowedChars{rand(0, $hashLength)}; } return str_shuffle($return); }
php
{ "resource": "" }
q253783
View.get
validation
public function get(): \TheCMSThread\Core\Main\View { if ($this->getLink() == '/') { $this->details = Model\Page::find(1); } else { $this->details = Model\Page::where('link', $this->getLink()); if ($this->auth->allow(["min" => 3, "max" => 1]) === false) { $this->details->where('status', true); } $this->details = $this->details->first(); } if ($this->details === null) { $this->details = false; } return $this; }
php
{ "resource": "" }
q253784
View.getLink
validation
public function getLink(): string { if ($this->link === null) { return str_replace("?" . $_SERVER["QUERY_STRING"], "", $_SERVER["REQUEST_URI"]); } else { return $this->link; } }
php
{ "resource": "" }
q253785
View.setLink
validation
public function setLink(string $link = null): \TheCMSThread\Core\Main\View { $this->link = $link; return $this; }
php
{ "resource": "" }
q253786
Dispatcher.listen
validation
public function listen($event, callable $callback, $priority = 100) { $this->event->on($event, $callback, $priority); }
php
{ "resource": "" }
q253787
Dispatcher.once
validation
public function once($event, callable $callback, $priority = 100) { $this->event->once($event, $callback, $priority); }
php
{ "resource": "" }
q253788
PluginManager.getBlockPlugin
validation
public function getBlockPlugin($name) { if (!array_key_exists($name, $this->blocks)) { return null; } return $this->blocks[$name]; }
php
{ "resource": "" }
q253789
PluginManager.getThemePlugin
validation
public function getThemePlugin($name) { if (!array_key_exists($name, $this->themes)) { return null; } return $this->themes[$name]; }
php
{ "resource": "" }
q253790
PluginManager.boot
validation
public function boot() { $pluginFolders = $this->configurationHandler->pluginFolders(); $this->core = $this->findPlugins($this->configurationHandler->corePluginsDir() . "/Core"); foreach ($pluginFolders as $pluginFolder) { $this->blocks += $this->findPlugins($pluginFolder . "/Block"); $this->themes += $this->findPlugins($pluginFolder . "/Theme"); } return $this; }
php
{ "resource": "" }
q253791
PluginManager.installAssets
validation
public function installAssets() { $this->doInstallAssets($this->core); $this->doInstallAssets($this->blocks); $this->doInstallAssets($this->themes); }
php
{ "resource": "" }
q253792
SerializedObject.isSerialized
validation
public function isSerialized() { // if it isn't a string, it isn't serialized if (!is_string($this->serialized)) { return false; } $this->serialized = trim($this->serialized); if ('N;' == $this->serialized) { return true; } $length = strlen($this->serialized); if ($length < 4) { return false; } if (':' !== $this->serialized[1]) { return false; } $lastc = $this->serialized[$length - 1]; if (';' !== $lastc && '}' !== $lastc) { return false; } $token = $this->serialized[0]; switch ($token) { case 's' : if ('"' !== $this->serialized[$length - 2]) { return false; } case 'a' : case 'O' : return (bool)preg_match("/^{$token}:[0-9]+:/s", $this->serialized); case 'b' : case 'i' : case 'd' : return (bool)preg_match("/^{$token}:[0-9.E-]+;\$/", $this->serialized); } return false; }
php
{ "resource": "" }
q253793
Session.addHeaders
validation
private function addHeaders() { self::response()->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate'); // HTTP 1.1 self::response()->addHeader('Pragma', 'no-cache'); // HTTP 1.0 self::response()->addHeader('Expires', '-1'); // Proxies }
php
{ "resource": "" }
q253794
FileUploaded.save
validation
public function save($path,$name=null){ if(!file_exists($path)){ mkdir($path,0777,true); } $destinationPath=rtrim($path, '/'); if($name){ $destinationPath.='/'.$name; } else{ $destinationPath.='/'.$this->name; } if(!copy($this->tmpName, $destinationPath)){ //detect error reason $reason='Unknown'; if(!file_exists($path)){ $reason='Path "'.$path.'" not exists.'; } else if(!is_writeable($path)) $reason='Path "'.$path.'" required permission to write.'; throw new FileFailSavedException($reason); } }
php
{ "resource": "" }
q253795
MMySQLCacheManager.createTable
validation
public function createTable() { $stmt = $this->pdoConnection->prepare( sprintf( self::$CREATE_TABLE, $this->tableName ) ); return $stmt->execute(); }
php
{ "resource": "" }
q253796
TagController.showAction
validation
public function showAction(Tag $tag) { $deleteForm = $this->createDeleteForm($tag); return array( 'entity' => $tag, 'delete_form' => $deleteForm->createView(), ); }
php
{ "resource": "" }
q253797
TagController.createDeleteForm
validation
private function createDeleteForm(Tag $tag) { return $this->createFormBuilder() ->setAction($this->generateUrl('blog_tag_delete', array('id' => $tag->getId()))) ->setMethod('DELETE') ->getForm() ; }
php
{ "resource": "" }
q253798
Flash.init
validation
private static function init() : void { static $inited = false; if (!$inited) { if (!isset($_SESSION['Booby']) || !$_SESSION['Booby']) { $_SESSION['Booby'] = []; } self::$store =& $_SESSION['Booby']; $inited = true; } }
php
{ "resource": "" }
q253799
ToolsController.actionFlush
validation
public function actionFlush($category = null) { if (is_null($category)) { $category = $this->prompt("Category (blank for all): "); } if (empty($category)) { $category = 'all'; } else { $category = ['category', $category]; } Cacher::invalidateGroup($category); $this->out("Done!"); }
php
{ "resource": "" }