_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q252600
PermalinkManager.update
validation
public function update($previousPermalink, $newPermalink) { $blocks = $this->permalinks[$previousPermalink]; $this->remove($previousPermalink); $this->permalinks[$newPermalink] = $blocks; return $this; }
php
{ "resource": "" }
q252601
Column.setSortBy
validation
public function setSortBy($sortKeys){ if($sortKeys==null){ $sortKeys=[]; } if(!is_array($sortKeys)){ $sortKeys=[$sortKeys]; } $this->sortKeys=$sortKeys; }
php
{ "resource": "" }
q252602
Input.isClicked
validation
public function isClicked(string $sType) : bool { if ($this->getType() === 'submit' || $this->getType() === 'button') { if (isset($_POST[$this->getName()])) { return true; } } return false; }
php
{ "resource": "" }
q252603
Helper.mailTagger
validation
public static function mailTagger($mail = '', $name = null) { return((!is_int($name) ? "\"".$name."\" <" : '').$mail.(!is_int($name) ? ">" : '')); }
php
{ "resource": "" }
q252604
Helper.mailListTagger
validation
public static function mailListTagger(array $list) { $str = ''; foreach ($list as $name=>$mail) { if (is_string($mail)) { $str .= self::mailTagger($mail, $name).Mailer::$ADDERSSES_SEPARATOR; } elseif (is_array($mail)) { foreach ($mail as $subname=>$submail) { $str .= self::mailTagger($submail, $subname).Mailer::$ADDERSSES_SEPARATOR; } } } return $str; }
php
{ "resource": "" }
q252605
Helper.headerTagger
validation
public static function headerTagger($name = '', $value = '', $adds = array()) { $str = $name.': '.$value; if (count($adds)) { foreach ($adds as $n=>$v) { $str .= Mailer::$HEADERS_SEPARATOR.($n=='boundary' ? "\n\t" : '').$n."=\"".$v."\""; } } return(trim($str, Mailer::$HEADERS_SEPARATOR)); }
php
{ "resource": "" }
q252606
Helper.listAddresses
validation
public static function listAddresses($list = array(), $type = 'to') { if (empty($list)) { return; } $str = ucfirst(strtolower($type)).': '.self::mailListTagger($list); return(trim($str, Mailer::$ADDERSSES_SEPARATOR).Mailer::$LINE_ENDING); }
php
{ "resource": "" }
q252607
Helper.formatText
validation
public static function formatText($txt = '', $type = 'plain', $spaces = false) { switch ($type) { case 'ascii' : $_txt = ''; if ($spaces==true) { $txt = str_replace(' ', '_', $txt); } for ($i=0; $i<strlen($txt);$i++) { $_txt .= self::charAscii($txt[$i]); } $txt = $_txt; break; default : break; } $mailer = Mailer::getInstance(); $limit = $mailer->getOption('wordwrap_limit'); $formated=''; foreach (explode("\n", $txt) as $_line) { $_line = trim($_line); if (strlen($_line)>$limit) { $_line = wordwrap($_line, $limit, Mailer::$LINE_ENDING); } if (strlen($_line)) { $formated .= $_line.Mailer::$LINE_ENDING; } } return $formated; }
php
{ "resource": "" }
q252608
Helper.getMimeType
validation
public static function getMimeType($filename = '') { $ext = strtolower(substr($filename, strrpos($filename, '.'))); switch ($ext) { case '.jpeg': case '.jpg': $mimetype = 'image/jpeg'; break; case '.gif': $mimetype = 'image/gif'; break; case '.png': $mimetype = 'image/png'; break; case '.txt': $mimetype = 'text/plain'; break; case '.html': case '.htm': $mimetype = 'text/html'; break; case '.zip': $mimetype = 'application/x-zip-compressed'; break; default: $mimetype = 'application/octet-stream'; } return $mimetype; }
php
{ "resource": "" }
q252609
Helper.deduplicate
validation
public static function deduplicate($array) { if (empty($array)) { return $array; } $known = array(); foreach ($array as $_index=>$entry) { if (is_array($entry)) { foreach ($entry as $i=>$_email) { if (!in_array($_email, $known)) { $known[] = $_email; } else { unset($array[$_index]); } } } elseif (is_string($entry)) { if (!in_array($entry, $known)) { $known[] = $entry; } else { unset($array[$_index]); } } } return $array; }
php
{ "resource": "" }
q252610
Helper.checkPeopleArgs
validation
public static function checkPeopleArgs() { $args = func_get_args(); if (empty($args)) { return array(); } // 1 only email if (count($args)==1 && is_string($args[0]) && self::isEmail($args[0])) { return array( array($args[0]) ); } // 2 args and 2nd is not an email if ( count($args)==2 && (isset($args[0]) && true===self::isEmail($args[0])) && (isset($args[1]) && false===self::isEmail($args[1])) ) { return array( array( $args[1]=>$args[0] ) ); } // a set of name=>email pairs if (count($args)==1) { $args = $args[0]; } $result=array(); foreach ($args as $name=>$email) { if (is_string($name) && true===self::isEmail($email)) { $result[] = array( $name=>$email ); } elseif (is_numeric($name) && true===self::isEmail($email)) { $result[] = array($email); } } return $result; }
php
{ "resource": "" }
q252611
Helper.charAscii
validation
public static function charAscii($char) { if (self::isAscii($char)) { return $char; } $char = htmlentities($char); return $char; }
php
{ "resource": "" }
q252612
Menu.destroy
validation
public function destroy($menuId = null) { if ($menuId !== null) { return $this->parseJSON('json', [self::API_CONDITIONAL_DELETE, ['menuid' => $menuId]]); } return $this->parseJSON('get', [self::API_DELETE]); }
php
{ "resource": "" }
q252613
Builder.onClassFound
validation
protected function onClassFound(ScannedPhpClass $subject) { $class = $subject->getClass(); $main = $this->reader->getClassAnnotation($class, Di\DiServiceAnnotation::class); if ($main instanceof Di\DiServiceAnnotation) { // add the service definition $definition = $this->provideServiceDefinitionFor( new ServiceDefinitionProvider\Frame($class, $main, DiOptionsCollection::from($this->reader, $class), null) ); $this->addServiceDefinition($definition); } }
php
{ "resource": "" }
q252614
Builder.createPublicMethodInjection
validation
public function createPublicMethodInjection(\ReflectionMethod $method) : MethodInjection { /** @var ParameterInjection[] $injections */ $injections = []; foreach ($method->getParameters() as $parameter) { $injections[] = new ParameterInjection( $parameter->getName(), (string) $parameter->getType(), $parameter->isArray(), $this->getInjectHint($method, $parameter) ); } return new MethodInjection($injections, $method->getName()); }
php
{ "resource": "" }
q252615
Builder.getInjectHint
validation
private function getInjectHint(\ReflectionMethod $method, \ReflectionParameter $parameter) { // find the first injection hint for the given parameter $hint = Psi::it($this->reader->getMethodAnnotations($method)) ->filter(new IsInstanceOf(Di\DiInjectHintAnnotation::class)) ->filter(function (Di\DiInjectHintAnnotation $i) use ($parameter) { return $i->getParameter() === $parameter->getName(); }) ->getFirst(); if ($hint !== null) { return $hint; } // No hint is given. We do the default injection strategy. try { if ($parameter->getClass() === null) { throw new \InvalidArgumentException( "Cannot inject constructor-param '{$parameter->getName()}' into {$method->getDeclaringClass()->getName()}. " . 'The parameter does not have a an @Inject hint and it has no type-hint.' ); } } catch (\ReflectionException $e) { // We ignore not existing class errors. But why? // Well, it is very likely that the service to be injected does not yet exist and will be created by a code-generator, e.g. the storage. } return Di\Inject\ByType::create($parameter->getName(), Util::normalizeFqcn((string) $parameter->getType())); }
php
{ "resource": "" }
q252616
Upload.upload
validation
public function upload(string $sFile) { if ($_FILES[$sFile]['error'] > 0) { $this->_sError = "Error while the upload"; return false; } if ($_FILES[$sFile]['size'] > $this->_iMaxFile) { $this->_sError = "The file is too big"; return false; } $sExtension = strtolower(substr(strrchr($_FILES[$sFile]['name'], '.'), 1)); if (count($this->_aAllowExtension) > 0 && !in_array($sExtension ,$this->_aAllowExtension)) { $this->_sError = "The extension is not good"; return false; } $sPath = str_replace('bundles'.DIRECTORY_SEPARATOR.'lib', 'data'.DIRECTORY_SEPARATOR.'upload'.DIRECTORY_SEPARATOR, __DIR__); if ($this->_sExtension === null) { $this->setExtension($sExtension); } if ($this->_sName) { $sName = $sPath.$this->_sName.'.'.$this->_sExtension; } else { $sName = $sPath.md5(uniqid(rand(), true)).'.'.$this->_sExtension;} if ($this->_bProportion === true && ($this->_iWidth || $this->_iHeight)) { $aImageSizes = getimagesize($_FILES[$sFile]['tmp_name']); $fRatio = min($aImageSizes[0] / $this->_iWidth, $aImageSizes[1] / $this->_iHeight); $iHeight = $aImageSizes[1] / $fRatio; $iWidth = $aImageSizes[0] / $fRatio; $fY = ($iHeight - $this->_iHeight) / 2 * $fRatio; $fX = ($iWidth - $this->_iWidth) / 2 * $fRatio; $rNewImage = imagecreatefromjpeg($_FILES[$sFile]['tmp_name']); $rNewImgTrueColor = imagecreatetruecolor($this->_iWidth , $this->_iHeight); imagecopyresampled($rNewImgTrueColor , $rNewImage, 0, 0, $fX, $fY, $this->_iWidth, $this->_iHeight, $iWidth * $fRatio - $fX * 2, $iHeight * $fRatio - $fY * 2); imagejpeg($rNewImgTrueColor , $sName, 100); } else { $bResultat = move_uploaded_file($_FILES[$sFile]['tmp_name'], $sName); if ($bResultat) { return true; } } }
php
{ "resource": "" }
q252617
CollectorModule.loadSubmodules
validation
public function loadSubmodules() { $this->modules = $this->submodules; foreach ($this->submodules as $module => $settings) { $mod = $this->getModule($module); $mod->init(); } return true; }
php
{ "resource": "" }
q252618
TextService.getAction
validation
public function getAction() { if (!preg_match('/\/page\/(\w+[\-\w]*)\/text\/(..)(\/(\w+))?$/', $this->name, $matches)) { throw new InvalidParameterException("Invalid parameters"); } $pageName = $matches[1]; $language = $matches[2]; $pageTexts = $this->getTextModel($pageName); if (empty($matches[4])) { $result = array_values($pageTexts->getTextsWithBaseTexts($language)); } else { $result = $pageTexts->getText($matches[4], $language); } $this->environment->sendJSONResult($result); }
php
{ "resource": "" }
q252619
TextService.postAction
validation
public function postAction() { if (!preg_match('/\/page\/(\w+[\-\w]*)\/text\/(..)$/', $this->name, $matches)) { throw new InvalidParameterException("Invalid parameters"); } list($dummy, $pageName, $language) = $matches; $request = $this->environment->getRequestHelper(); $name = $request->getIdentifierParam('name'); $content = $request->getParam('content', ''); try { $pageTexts = $this->getTextModel($pageName); $text = $pageTexts->addTextContainer($name, $this->filter($content), $language); $this->environment->sendJSONResult($text); } catch (\Exception $e) { throw new InvalidParameterException($e->getMessage()); } }
php
{ "resource": "" }
q252620
TextService.putAction
validation
public function putAction() { if (!preg_match('/\/page\/(\w+[\-\w]*)\/text\/(..)\/(\w+)$/', $this->name, $matches)) { throw new InvalidParameterException("Invalid parameters"); } list($dummy, $pageName, $language, $oldName) = $matches; $request = $this->environment->getRequestHelper(); $newName = $request->getIdentifierParam('name'); $content = $request->getParam('content', ''); try { $pageTexts = $this->getTextModel($pageName); $text = $pageTexts->modifyTextContainer($oldName, $newName, $this->filter($content), $language); $this->environment->sendJSONResult($text); } catch (\Exception $e) { throw new InvalidParameterException($e->getMessage()); } }
php
{ "resource": "" }
q252621
TextService.deleteAction
validation
public function deleteAction() { // @todo It's not necessary to specify a language, since the texts in all languages are removed. if (!preg_match('/\/page\/(\w+[\-\w]*)\/text\/..\/(\w+)$/', $this->name, $matches)) { throw new InvalidParameterException("Invalid parameters"); } list($dummy, $pageName, $containerName) = $matches; $pageTexts = $this->getTextModel($pageName); $pageTexts->deleteTextContainer($containerName); $this->environment->sendJSONResult('ok'); }
php
{ "resource": "" }
q252622
Form.render
validation
public function render(FormInterface $form) { if (method_exists($form, 'prepare')) { $form->prepare(); } // Set form role if (!$form->getAttribute('role')) { $form->setAttribute('role', 'form'); } $formContent = ''; foreach ($form as $element) { /** @var $element \Zend\Form\Form */ if ($element instanceof FieldsetInterface) { /** @noinspection PhpUndefinedMethodInspection */ $formContent .= $this->getView()->formCollection($element); } else { $element->setOption('_form', $form); /** @noinspection PhpUndefinedMethodInspection */ $formContent .= $this->getView()->formRow($element); } } return $this->openTag($form) . $formContent . $this->closeTag(); }
php
{ "resource": "" }
q252623
Containerized.pipe
validation
public function pipe($stage) { $pipeline = new self($this->container, $this->stages); $this->handleStage($pipeline->stages, $stage); return $pipeline; }
php
{ "resource": "" }
q252624
Containerized.build
validation
protected function build($stage) { if ($stage instanceof MiddlewareInterface) { return $stage; } if ($this->container->has($stage)) { $stage = $this->container->get($stage); if ($stage instanceof RequestHandlerInterface) { return new RequestHandler($stage); } if ($stage instanceof MiddlewareInterface) { return $stage; } throw new \RuntimeException("Stage is not a valid " . MiddlewareInterface::class); } // Support aura/di if (method_exists($this->container, 'newInstance')) { return $this->container->newInstance($stage); } throw new \RuntimeException("Unable to resolve $stage"); }
php
{ "resource": "" }
q252625
Containerized.resolve
validation
protected function resolve() { if ($this->resolved) { return; } $this->resolved = []; foreach ($this->stages as $stage) { $this->resolved[] = $this->build($stage); } }
php
{ "resource": "" }
q252626
Geocoding.signUrlForGoogle
validation
public static function signUrlForGoogle(string $sUrlToSign, string $sClientId, string $sPrivateKey) : string { $aUrl = parse_url($sUrlToSign); $aUrl['query'] .= '&client=' .$sClientId; $aUrlToSign = $aUrl['path']."?".$aUrl['query']; $decodedKey = base64_decode(str_replace(array('-', '_'), array('+', '/'), $sPrivateKey)); $sSignature = hash_hmac("sha1", $aUrlToSign, $decodedKey, true); $sEncodedSignature = str_replace(array('+', '/'), array('-', '_'), base64_encode($sSignature)); $sOriginalUrl = $aUrl['scheme']."://".$aUrl['host'].$aUrl['path'] . "?".$aUrl['query']; return $sOriginalUrl. '&signature='. $sEncodedSignature; }
php
{ "resource": "" }
q252627
GetCustomersIds.exec
validation
public function exec($calcId = null) { if (is_null($calcId)) { $calcId = $this->queryGetCalcId->exec(); } if (!isset($this->cachedIds[$calcId])) { $ids = []; $where = \Praxigento\BonusHybrid\Repo\Data\Registry\SignUpDebit::A_CALC_REF . '=' . (int)$calcId; $rs = $this->daoRegistry->get($where); /** @var \Praxigento\BonusHybrid\Repo\Data\Registry\SignUpDebit $one */ foreach ($rs as $one) { $ids[] = $one->getCustomerRef(); } $this->cachedIds[$calcId] = $ids; } return $this->cachedIds[$calcId]; }
php
{ "resource": "" }
q252628
LazyFile.hydrate
validation
private function hydrate() { if (true === $this->hydrated) { return; } $this->filesystem->get($this->file); $this->hydrated = true; }
php
{ "resource": "" }
q252629
BlockManagerFactory.create
validation
public function create($action) { $actionName = ucfirst($action); $class = sprintf('RedKiteCms\Content\BlockManager\BlockManager%s', $actionName); if (!class_exists($class)) { return null; } $reflectionClass = new \ReflectionClass($class); return $reflectionClass->newInstance($this->serializer, $this->optionsResolver); }
php
{ "resource": "" }
q252630
ActionTrait.getLog
validation
public function getLog() { if (!isset($this->_log)) { $this->_log = new DataInterfaceLog(); if (!empty($this->interface)) { $this->_log->data_interface_id = $this->interface->interfaceObject->id; } $this->_log->status = 'running'; $this->_log->started = date("Y-m-d G:i:s"); $this->_log->peak_memory = memory_get_usage(); } return $this->_log; }
php
{ "resource": "" }
q252631
ActionTrait.getStatus
validation
public function getStatus() { if (isset($this->_log)) { $this->_status = $this->log->statusLog; } elseif (!isset($this->_status)) { $this->_status = new Status($this->log); } return $this->_status; }
php
{ "resource": "" }
q252632
MenuBuilder.createMainMenu
validation
public function createMainMenu(Request $request) { $menu = $this->factory->createItem('root'); $menu->setCurrentUri($request->getBaseUrl().$request->getPathInfo()); // create menu from admin pool $admin_pool = $this->container->get('sonata.admin.pool'); foreach ($admin_pool->getDashboardGroups() as $group) { $menu->addChild($group['label'], array('translationDomain'=>$group['label_catalogue'])); foreach ($group['items'] as $admin) { if ( $admin->hasRoute('list') && $admin->isGranted('LIST') ) { $menu[$group['label']]->addChild($admin->getLabel(), array('admin'=>$admin)); } } } $dispatcher = $this->container->get('event_dispatcher'); $event = new MenuCreateEvent($menu); $dispatcher->dispatch(MenuEvents::ADMIN_MENU_CREATE, $event); return $menu; }
php
{ "resource": "" }
q252633
Debug.getInstance
validation
public static function getInstance() : Debug { if (!(self::$_oInstance instanceof self)) { self::$_oInstance = new self(); } return self::$_oInstance; }
php
{ "resource": "" }
q252634
Debug.activateError
validation
public static function activateError($iLevel) { if (self::$_bFirstActivation === true) { self::_setFileNameInErrorFile(); self::$_bFirstActivation = false; } self::_initLogFile(); self::$_bActivateError = true; error_reporting($iLevel); set_error_handler(function ($iErrNo, $sErrStr, $sErrFile, $iErrLine) { $aContext = array('file' => $sErrFile, 'line' => $iErrLine); $sType = self::getTranslateErrorCode($iErrNo); self::getInstance()->$sType($sErrStr, $aContext); return true; }, $iLevel); register_shutdown_function(function() { if (null !== ($aLastError = error_get_last())) { $aContext = array('file' => $aLastError['file'], 'line' => $aLastError['line']); $sType = self::getTranslateErrorCode($aLastError['type']); self::getInstance()->$sType($aLastError['message'], $aContext); } }); }
php
{ "resource": "" }
q252635
Debug.setKindOfReportLog
validation
public static function setKindOfReportLog(string $sKindOfReportLog) { if ($sKindOfReportLog === 'screen' || $sKindOfReportLog === 'all') { self::$_sKindOfReportLog = $sKindOfReportLog; } else { self::$_sKindOfReportLog = 'error_log'; } }
php
{ "resource": "" }
q252636
Debug.getTranslateErrorCode
validation
public static function getTranslateErrorCode(int $iCode) : string { if ($iCode === 1 && $iCode === 16 && $iCode === 256 && $iCode === 4096) { return LogLevel::ERROR; } else if ($iCode === 2 && $iCode === 32 && $iCode === 128 && $iCode === 512) { return LogLevel::WARNING; } else if ($iCode === 4 && $iCode === 64) { return LogLevel::EMERGENCY; } else if ($iCode === 8 && $iCode === 1024) { return LogLevel::NOTICE; } else if ($iCode === 2048 && $iCode === 8192 && $iCode === 16384) { return LogLevel::INFO; } else return LogLevel::DEBUG; }
php
{ "resource": "" }
q252637
Debug._setFileNameInErrorFile
validation
private static function _setFileNameInErrorFile() { /** * We see if it's a cli call or a web call */ if (defined('BASH_CALLED')) { error_log(Bash::setColor('############### '.BASH_CALLED.' ###############', 'cyan')); } else { if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['REQUEST_URI'])) { error_log(Bash::setColor('############### ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . ' ###############', 'cyan')); } } }
php
{ "resource": "" }
q252638
XmlRpcParser.parseFault
validation
public static function parseFault(\SimpleXMLElement $fault) { $faultData = static::parseStruct($fault->value->struct); return new \Devedge\XmlRpc\Client\RemoteException($faultData['faultString'], $faultData['faultCode']); }
php
{ "resource": "" }
q252639
BlockManagerRemove.remove
validation
public function remove($sourceDir, array $options, $username) { $dir = $this ->init($sourceDir, $options, $username) ->getDirInUse(); $blockName = $options["blockname"]; $blocksDir = $dir . '/blocks'; $filename = sprintf('%s/%s.json', $blocksDir, $blockName); $options["block"] = JsonTools::jsonDecode(FilesystemTools::readFile($filename)); Dispatcher::dispatch(BlockEvents::BLOCK_REMOVING, new BlockRemovingEvent($this->serializer, $filename)); $this->filesystem->remove($filename); $this->removeBlockFromSlotFile($options, $dir); Dispatcher::dispatch(BlockEvents::BLOCK_REMOVED, new BlockRemovedEvent($this->serializer, $filename)); DataLogger::log( sprintf( 'Block "%s" has been removed from the "%s" slot on page "%s" for the "%s_%s" language', $options["blockname"], $options["slot"], $options["page"], $options["language"], $options["country"] ) ); }
php
{ "resource": "" }
q252640
CustomFieldProvider.getCustomFieldByType
validation
public function getCustomFieldByType($type) { if (isset($this->servicesByType[$type])) { return $this->servicesByType[$type]; } else { throw new \LogicException('the custom field with type '.$type.' ' . 'is not found'); } }
php
{ "resource": "" }
q252641
ImportAbstract.fromData
validation
public function fromData($data) { $this->fromdata = $data; $resource = fopen('php://memory', 'r+'); fwrite($resource, $data); rewind($resource); // $resource = fopen('data://text/plain,' . $data, 'r+'); $this->setResource($resource); return $this; }
php
{ "resource": "" }
q252642
ImportAbstract.startAt
validation
public function startAt($startAt=0){ if (!is_numeric($startAt) || $startAt < 0){ throw new Exception("startAt: bad value", 10); } $this->startAt = $startAt; return $this; }
php
{ "resource": "" }
q252643
QRCode.getAppCode
validation
public function getAppCode($path, $width = 430, $autoColor = false, $lineColor = ['r' => 0, 'g' => 0, 'b' => 0]) { $params = [ 'path' => $path, 'width' => $width, 'auto_color' => $autoColor, 'line_color' => $lineColor, ]; return $this->getStream(self::API_GET_WXACODE, $params); }
php
{ "resource": "" }
q252644
QRCode.getAppCodeUnlimit
validation
public function getAppCodeUnlimit($scene, $width = 430, $autoColor = false, $lineColor = ['r' => 0, 'g' => 0, 'b' => 0]) { $params = [ 'scene' => $scene, 'width' => $width, 'auto_color' => $autoColor, 'line_color' => $lineColor, ]; return $this->getStream(self::API_GET_WXACODE_UNLIMIT, $params); }
php
{ "resource": "" }
q252645
ThemeController.changeAction
validation
public function changeAction() { $theme = $this->container->get('request')->request->get('admin_theme'); $this->container->get('vince_t.admin.theme.handler')->setCurrentTheme($theme); $headers = $this->container->get('request')->server->getHeaders(); $referer = $headers['REFERER']; return new RedirectResponse($referer); }
php
{ "resource": "" }
q252646
CacheManagerFactory.createService
validation
public function createService(ServiceLocatorInterface $serviceLocator) { $cacheManager = new CacheManager($serviceLocator->get('HtSettingsModule\Options\ModuleOptions')->getCacheOptions()); $cacheManager->setServiceLocator($serviceLocator); return $cacheManager; }
php
{ "resource": "" }
q252647
ItemController.actionCreate
validation
public function actionCreate() { $model = new Item(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', [ 'model' => $model, ]); } }
php
{ "resource": "" }
q252648
ItemController.actionTriggerEvents
validation
public function actionTriggerEvents() { Yii::$app->response->format = Response::FORMAT_JSON; $result = ($post = Yii::$app->request->post('depdrop_parents')) ? Item::eventList($post[0]) : []; $output = []; foreach ($result as $id => $name) { $output[] = compact('id', 'name'); } echo Json::encode(['output' => $output, 'selected' => '']); }
php
{ "resource": "" }
q252649
RegistrationListener.onBootstrap
validation
public function onBootstrap(MvcEvent $e) { if (!$e->getRequest() instanceof HttpRequest) { return; } $app = $e->getApplication(); $services = $app->getServiceManager(); $eventManager = $app->getEventManager(); $sharedEventManager = $eventManager->getSharedManager(); $sharedEventManager->attach(UserService::class, 'register', function($e) use ($services) { $user = $e->getParam('user'); if ($user instanceof RoleableInterface && $services->has(AuthorizationModuleOptions::class) ) { /* @var $config PermissionsModuleOptions */ $config = $services->get(PermissionsModuleOptions::class); $roleClass = $config->getRoleEntityClass(); $mapper = $services->get('MapperManager')->get($roleClass); if ($defaultRole = $mapper->find($config->getAuthenticatedRole())) { $user->addRole($defaultRole); } } }, 100); }
php
{ "resource": "" }
q252650
ShowThemeController.showAction
validation
public function showAction(Request $request, Application $app) { $options = array( 'twig' => $app["twig"], 'template_assets' => $app["red_kite_cms.template_assets"], "configuration_handler" => $app["red_kite_cms.configuration_handler"], "plugin_manager" => $app["red_kite_cms.plugin_manager"], ); return parent::show($options); }
php
{ "resource": "" }
q252651
Tag.update
validation
public function update($tagId, $name) { $params = [ 'tag' => [ 'id' => $tagId, 'name' => $name, ], ]; return $this->parseJSON('json', [self::API_UPDATE, $params]); }
php
{ "resource": "" }
q252652
Tag.usersOfTag
validation
public function usersOfTag($tagId, $nextOpenId = '') { $params = ['tagid' => $tagId, 'next_openid' => $nextOpenId]; return $this->parseJSON('json', [self::API_USERS_OF_TAG, $params]); }
php
{ "resource": "" }
q252653
Tag.batchTagUsers
validation
public function batchTagUsers(array $openIds, $tagId) { $params = [ 'openid_list' => $openIds, 'tagid' => $tagId, ]; return $this->parseJSON('json', [self::API_MEMBER_BATCH_TAG, $params]); }
php
{ "resource": "" }
q252654
Tag.batchUntagUsers
validation
public function batchUntagUsers(array $openIds, $tagId) { $params = [ 'openid_list' => $openIds, 'tagid' => $tagId, ]; return $this->parseJSON('json', [self::API_MEMBER_BATCH_UNTAG, $params]); }
php
{ "resource": "" }
q252655
Encryptor.decryptData
validation
public function decryptData($sessionKey, $iv, $encrypted) { try { $decrypted = openssl_decrypt( base64_decode($encrypted, true), 'aes-128-cbc', base64_decode($sessionKey, true), OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, base64_decode($iv, true) ); } catch (Exception $e) { throw new EncryptionException($e->getMessage(), EncryptionException::ERROR_DECRYPT_AES); } if (is_null($result = json_decode($this->decode($decrypted), true))) { throw new EncryptionException('ILLEGAL_BUFFER', EncryptionException::ILLEGAL_BUFFER); } return $result; }
php
{ "resource": "" }
q252656
Personal.calcBonus
validation
private function calcBonus($dwnlCurrent, $dwnlCompress, $levels) { $result = []; $mapCustomer = $this->hlpDwnlTree->mapById($dwnlCurrent, ECustomer::A_CUSTOMER_REF); /** @var \Praxigento\BonusHybrid\Repo\Data\Downline $one */ foreach ($dwnlCompress as $one) { $custId = $one->getCustomerRef(); $pvValue = $one->getPv(); $customer = $mapCustomer[$custId]; $scheme = $this->hlpScheme->getSchemeByCustomer($customer); if ($scheme == Cfg::SCHEMA_DEFAULT) { $bonusValue = $this->hlpCalc->calcForLevelPercent($pvValue, $levels); if ($bonusValue > 0) { $entry = new DBonus(); $entry->setCustomerRef($custId); $entry->setValue($bonusValue); $result[] = $entry; } } } return $result; }
php
{ "resource": "" }
q252657
Personal.saveLog
validation
private function saveLog($operId, $calcId) { $entity = new ELogOper(); $entity->setOperId($operId); $entity->setCalcId($calcId); $this->daoLogOper->create($entity); }
php
{ "resource": "" }
q252658
Module.addPiwikCode
validation
public function addPiwikCode(ViewEvent $event) { $model = $event->getModel(); if (! $model instanceof \Zend\View\Model\ViewModel) { return; } // Return if this is a subrenderer. Therefore we only render once! $options = $model->getOptions(); if (array_key_exists('has_parent', $options) && $options['has_parent']) { return; } $renderer = $event->getRenderer(); if (! $renderer instanceof \Zend\View\Renderer\PhpRenderer) { return; } $config = $this->serviceManager->get('config'); $piwikConfig = $config['orgHeiglPiwik']; $code = str_replace(array_map(function($e){ return '%%' . $e . '%%'; }, array_keys($piwikConfig)), array_values($piwikConfig), $this->template); $renderer->headScript()->appendScript('//<![CDATA[' . "\n" . $code . "\n" . '//]]>'); return $renderer; }
php
{ "resource": "" }
q252659
Benri_Application.createInstance
validation
public static function createInstance($environment, $options = null) { if (!self::$_instance) { self::$_instance = new static($environment, $options, false); } return self::$_instance; }
php
{ "resource": "" }
q252660
BaseDB.getValues
validation
protected function getValues($fields, $preCalculatedResult = false) { if ($preCalculatedResult) { return $preCalculatedResult; } $app = App::getInstance(); $sql = $this->constructSelectSQL($fields); // get cache $item = $this->getCache($fields[$this->pk]); $results = $item->get(\Stash\Invalidation::PRECOMPUTE, 300); if ($item->isMiss()) { $results = $this->runGetRow($sql); if ($app['db']->last_error) { throw new SQLException( $app['db']->last_error, $app['db']->captured_errors ); } if (is_null($results)) { throw new ModelNotFoundException( 'No model in database', $this->dbtable, $this->constructorId ); } $app['cache']->save($item->set($results)); } return $results; }
php
{ "resource": "" }
q252661
BaseDB.getCache
validation
protected function getCache($pk) { $app = App::getInstance(); return $app['cache']->getItem($this->dbtable.'/'.$pk->getValue()); }
php
{ "resource": "" }
q252662
BaseDB.constructSelectSQL
validation
public function constructSelectSQL($fields) { $sql = array(); $sql[] = "SELECT"; $sql[] = "`" . implode("`, `", array_keys($fields)) . "`"; $sql[] = "FROM `" . $this->dbtable . "`"; $sql[] = "WHERE `" . $this->pk . "` = " . $fields[$this->pk]->getSQL(); return implode(" ", $sql); }
php
{ "resource": "" }
q252663
User.get
validation
public function get($openId, $lang = 'zh_CN') { $params = [ 'openid' => $openId, 'lang' => $lang, ]; return $this->parseJSON('get', [self::API_GET, $params]); }
php
{ "resource": "" }
q252664
User.batchGet
validation
public function batchGet(array $openIds, $lang = 'zh_CN') { $params = []; $params['user_list'] = array_map(function ($openId) use ($lang) { return [ 'openid' => $openId, 'lang' => $lang, ]; }, $openIds); return $this->parseJSON('json', [self::API_BATCH_GET, $params]); }
php
{ "resource": "" }
q252665
User.lists
validation
public function lists($nextOpenId = null) { $params = ['next_openid' => $nextOpenId]; return $this->parseJSON('get', [self::API_LIST, $params]); }
php
{ "resource": "" }
q252666
User.remark
validation
public function remark($openId, $remark) { $params = [ 'openid' => $openId, 'remark' => $remark, ]; return $this->parseJSON('json', [self::API_REMARK, $params]); }
php
{ "resource": "" }
q252667
User.blacklist
validation
public function blacklist($beginOpenid = null) { $params = ['begin_openid' => $beginOpenid]; return $this->parseJSON('json', [self::API_GET_BLACK_LIST, $params]); }
php
{ "resource": "" }
q252668
TreeGroup.toObject
validation
public function toObject() { $groups = $this->groups; foreach($groups as &$group){ $group = $group->toObject(); } $items = $this->items; foreach($items as &$item){ $item = $item->toObject(); } return (object)[ 'type' => $this->type, 'value' => $this->value, 'text' => $this->text, 'groups' => $groups, 'items' => $items, ]; }
php
{ "resource": "" }
q252669
TreeGroup.toSelect
validation
public function toSelect(array &$optgroups=[], $level=1, $root=true) { $options = []; foreach($this->items as $item){ $options[] = $item->toSelect(); } if ( $root === true ){ $text = $this->text; } else { $text = '|'.str_repeat('-', $level).' '.$this->text; } $optgroups[] = [ 'text' => $text, 'options' => $options, ]; foreach($this->groups as $group){ $group->toSelect($optgroups, $level+1, false); } }
php
{ "resource": "" }
q252670
FrontController.run
validation
public function run(Request $request) { $dispatcher = $this->router->getDispatcher(); $routeInfo = $dispatcher->dispatch($request->server('REQUEST_METHOD'), $request->server('REQUEST_URI_PATH')); switch ($routeInfo[0]) { case Dispatcher::NOT_FOUND: $routeInfo = $this->getNotFoundRoute($dispatcher); break; case Dispatcher::METHOD_NOT_ALLOWED: $routeInfo = $this->runMethodNotAllowed($dispatcher); break; case Dispatcher::FOUND: break; } $response = $this->runRoute($routeInfo); $response->send(); }
php
{ "resource": "" }
q252671
FrontController.runRoute
validation
private function runRoute(array $routeInfo): Response { /** @noinspection PhpUnusedLocalVariableInspection */ list($_, $callback, $vars) = $routeInfo; $vars = array_filter($vars, function($var) { return strpos($var, '_') !== 0; }, ARRAY_FILTER_USE_KEY); if (!class_exists($callback[0])) { throw new ControllerNotFoundException( 'Trying to instantiate a non existent controller (`' . $callback[0] . '`)' ); } $controller = new $callback[0]($this->response, $this->session); if (!method_exists($controller, $callback[1])) { throw new ActionNotFoundException( 'Trying to call a non existent action (`' . $callback[0] . '::' . $callback[1] . '`)' ); } return $this->injector->execute([$controller, $callback[1]], array_map('urldecode', $vars)); }
php
{ "resource": "" }
q252672
AbstractApi.get
validation
protected function get($path, array $parameters = array(), $requestHeaders = array()) { if (array_key_exists('ref', $parameters) && is_null($parameters['ref'])) { unset($parameters['ref']); } $response = $this->client->getHttpClient()->get($path, $parameters, $requestHeaders); return ResponseMediator::getContent($response); }
php
{ "resource": "" }
q252673
AbstractApi.head
validation
protected function head($path, array $parameters = array(), $requestHeaders = array()) { if (array_key_exists('ref', $parameters) && is_null($parameters['ref'])) { unset($parameters['ref']); } $response = $this->client->getHttpClient()->request($path, null, 'HEAD', $requestHeaders, array( 'query' => $parameters )); return $response; }
php
{ "resource": "" }
q252674
Semantic.query
validation
public function query($keyword, $categories, array $other = []) { $params = [ 'query' => $keyword, 'category' => implode(',', (array) $categories), 'appid' => $this->getAccessToken()->getAppId(), ]; return $this->parseJSON('json', [self::API_SEARCH, array_merge($params, $other)]); }
php
{ "resource": "" }
q252675
TranslationLoader.registerResources
validation
public function registerResources(Translator $translator, array $dirs) { $finder = new Finder(); $files = $finder->files()->depth(0)->ignoreUnreadableDirs()->in($dirs); foreach ($files as $file) { $file = (string)$file; preg_match_all('/[^.]+/', basename($file), $match); $translator->addResource('xliff', $file, $match[0][1], "RedKiteCms"); } }
php
{ "resource": "" }
q252676
File.delete
validation
public function delete(string $sName) { return unlink($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac'); }
php
{ "resource": "" }
q252677
File._removeDirectory
validation
private function _removeDirectory($sName) { if ($rDirectory = opendir($sName)) { while (($sFile = readdir($rDirectory)) !== false) { if ($sFile > '0' && filetype($sName.$sFile) == "file") { unlink($sName.$sFile); } elseif ($sFile > '0' && filetype($sName.$sFile) == "dir") { remove_dir($sName.$sFile."\\"); } } closedir($rDirectory); rmdir($sName); } }
php
{ "resource": "" }
q252678
Mailer.init
validation
protected function init(array $options = null) { $this->boot(); if (!is_null($options)) { $this->setOptions( array_merge($this->getOptions(), $options) ); } }
php
{ "resource": "" }
q252679
Mailer.getDefault
validation
public function getDefault($name) { return isset($this->options['defaults'][$name]) ? $this->options['defaults'][$name] : null; }
php
{ "resource": "" }
q252680
Mailer.getErrors
validation
public function getErrors($echoable = false) { if (true===$echoable) { return join("\n<br />", $this->errors); } else { return $this->errors; } }
php
{ "resource": "" }
q252681
Mailer.getInfos
validation
public function getInfos($echoable = false) { if (true===$echoable) { return join("\n<br />", $this->infos); } else { return $this->infos; } }
php
{ "resource": "" }
q252682
Mailer.setRegistry
validation
public function setRegistry($var = null, $val = null, $section = false) { if (is_null($var)) { return; } if ($section) { if (!isset($this->registry[$section])) { $this->registry[$section] = array(); } $this->registry[$section][$var] = $val; } else { $this->registry[$var] = $val; } return $this; }
php
{ "resource": "" }
q252683
Mailer.getRegistry
validation
public function getRegistry($var = null, $section = false, $default = false) { if (is_null($var)) { return; } if ($section && isset($this->registry[$section])) { if (isset($this->registry[$section][$var])) { return $this->registry[$section][$var]; } else { return $default; } } if (isset($this->registry[$var])) { return $this->registry[$var]; } return $default; }
php
{ "resource": "" }
q252684
Mailer.getMessage
validation
public function getMessage($id = null) { if (!is_null($id)) { return array_key_exists($id, $this->messages) ? $this->messages[$id] : null; } elseif (count($this->messages)>0) { return current($this->messages); } else { $message_class = $this->getDefault('messager'); if (class_exists($message_class)) { $this->addMessage(new $message_class); return current($this->messages); } else { throw new \Exception( sprintf('Default message class "%s" not found!', $message_class) ); } } }
php
{ "resource": "" }
q252685
Mailer.setTransporter
validation
public function setTransporter(TransportInterface $transporter) { if ($transporter->validate()) { $this->transporter = $transporter; } else { throw new \Exception( sprintf('Transporter "%s" is not valid for current environment!', get_class($transporter)) ); } return $this; }
php
{ "resource": "" }
q252686
Mailer.getTransporter
validation
public function getTransporter() { if (empty($this->transporter)) { $transport_class = $this->getDefault('transporter'); if (class_exists($transport_class)) { $this->setTransporter(new $transport_class); } else { throw new \Exception( sprintf('Default transport class "%s" not found!', $transport_class) ); } } return $this->transporter; }
php
{ "resource": "" }
q252687
Mailer.getSpooler
validation
public function getSpooler() { if (empty($this->spooler)) { $spool_class = $this->getDefault('spooler'); if (class_exists($spool_class)) { $this->setSpooler(new $spool_class); } else { throw new \Exception( sprintf('Default spool class "%s" not found!', $spool_class) ); } } return $this->spooler; }
php
{ "resource": "" }
q252688
DefaultController.actionIndex
validation
public function actionIndex($option = null) { $fixtures = Yii::createObject(Fixtures::className()); $option = Question::displayWithQuit('Select operation', ['Export', 'Import'], $option); if($option == 'e') { $allTables = $fixtures->tableNameList(); if(!empty($allTables)) { $answer = Select::display('Select tables for export', $allTables, 1); $tables = $fixtures->export($answer); Output::items($tables, 'Exported tables'); } else { Output::block("not tables for export!"); } } elseif($option == 'i') { $allTables = $fixtures->fixtureNameList(); if(!empty($allTables)) { $answer = Select::display('Select tables for import', $allTables, 1); $tables = $fixtures->import($answer); Output::items($tables, 'Imported tables'); } else { Output::block("not tables for import!"); } } }
php
{ "resource": "" }
q252689
DefaultController.actionOne
validation
public function actionOne($option = null) { $fixtures = Yii::createObject(Fixtures::className()); $option = Question::displayWithQuit('Select operation', ['Export', 'Import'], $option); if($option == 'e') { $table = Enter::display('Enter table name for export'); $tables = $fixtures->export([$table]); Output::items($tables, 'Exported tables'); } elseif($option == 'i') { $table = Enter::display('Enter table name for import'); $tables = $fixtures->import([$table]); Output::items($tables, 'Imported tables'); } }
php
{ "resource": "" }
q252690
Entity.fill
validation
public function fill(array $attributes) { if ($this->getFieldManager()) { $attributes = $this->getFieldManager()->transformToResource($attributes); } return parent::fill($attributes); }
php
{ "resource": "" }
q252691
Entity.getParentUri
validation
public function getParentUri() { if ($this->getParentName()) { $func = $this->getParentName(); if (! is_string($func)) { return; } $relat = $this->$func(); $parentResourceName = $relat->getRelated()->getResourceName(); $field = $relat->getForeignKey(); if (! $this->$field/* || ! Request::is($parentResourceName . '/*')*/) { return Api::url(); } return Api::url() . '/' . $parentResourceName . '/' . Api::encodeHashId($this->$field); } return Api::url(); }
php
{ "resource": "" }
q252692
Entity.getParentKeyName
validation
public function getParentKeyName() { if ($this->getParentName()) { $func = $this->getParentName(); $relat = $this->$func(); /* * if (! $relat instanceof \Illuminate\Database\Eloquent\Relations\BelongsTo) { * $field = $relat->getForeignKey(); * } else { * $field = 'id'; * } */ $field = $relat->getForeignKey(); return $field; } return 'id'; }
php
{ "resource": "" }
q252693
Entity.getActions
validation
public function getActions() { $actions = []; if (is_array($this->actions)) { foreach ($this->actions as $action) { $actions[$action] = $action; } } return $actions; }
php
{ "resource": "" }
q252694
Entity.getPublicIdAttribute
validation
protected function getPublicIdAttribute() { if ($id = Api::decodeHashId($this->attributes['id'])) { return $id; } return Api::encodeHashId($this->attributes['id']); }
php
{ "resource": "" }
q252695
Entity.autoload
validation
public function autoload() { if (self::$loaded) { return; } if (is_array($this->load)) { foreach ($this->load as $k => $load) { $this->load($load); } } if (is_array($this->loadUri)) { foreach ($this->loadUri as $k => $load) { $this->load([ $load => function ($query) { $query->select('id', $query->getForeignKey()); } ]); } } self::$loaded = true; }
php
{ "resource": "" }
q252696
Stats.deviceSummary
validation
public function deviceSummary(array $deviceIdentifier, $beginDate, $endDate) { $params = [ 'device_identifier' => $deviceIdentifier, 'begin_date' => $beginDate, 'end_date' => $endDate, ]; return $this->parseJSON('json', [self::API_DEVICE, $params]); }
php
{ "resource": "" }
q252697
Stats.batchDeviceSummary
validation
public function batchDeviceSummary($timestamp, $pageIndex) { $params = [ 'date' => $timestamp, 'page_index' => $pageIndex, ]; return $this->parseJSON('json', [self::API_DEVICE_LIST, $params]); }
php
{ "resource": "" }
q252698
Stats.pageSummary
validation
public function pageSummary($pageId, $beginDate, $endDate) { $params = [ 'page_id' => $pageId, 'begin_date' => $beginDate, 'end_date' => $endDate, ]; return $this->parseJSON('json', [self::API_PAGE, $params]); }
php
{ "resource": "" }
q252699
Stats.batchPageSummary
validation
public function batchPageSummary($timestamp, $pageIndex) { $params = [ 'date' => $timestamp, 'page_index' => $pageIndex, ]; return $this->parseJSON('json', [self::API_PAGE_LIST, $params]); }
php
{ "resource": "" }