_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q5600
Validator.isOrdered
train
protected function isOrdered(array $ordered) { // validate fields by exist in tables foreach ($ordered as $table => $sort) { // load model metaData if ($this->isModel($table) === true) { $model = (new Manager())->load($table, new $table); ...
php
{ "resource": "" }
q5601
Validator.validTypes
train
protected function validTypes(Column $column) { if (in_array($column->getType(), $this->columns) === false) { throw new ExceptionFactory('Column', ['COLUMN_DOES_NOT_SUPPORT', $column->getType(), $column->getName()]); } return true; }
php
{ "resource": "" }
q5602
Validator.validColumns
train
protected function validColumns(Memory $meta, array $columns, $table, $model) { if (empty($not = array_diff($columns, $meta->getAttributes($model))) === false) { throw new ExceptionFactory('Column', ['COLUMN_DOES_NOT_EXISTS', $not, $table, $meta->getAttributes($model)]); } retur...
php
{ "resource": "" }
q5603
HistoryManager.findAll
train
public function findAll() { if ($this->fileManager->isDir(Installer::BASE_PATH . self::HISTORY_PATH) === false) { throw new EnvironnementResolverException( sprintf( 'Unable to locate "%d"', Installer::BASE_PATH . self::HISTORY_PATH ...
php
{ "resource": "" }
q5604
UserController.indexAction
train
public function indexAction() { $allowed_users = array(); $users = $this->getDoctrine()->getManager()->createQuery('SELECT r FROM FOMUserBundle:User r')->getResult(); // ACL access check foreach ($users as $index => $user) { if ($this->isGranted('VIEW', $user)) { ...
php
{ "resource": "" }
q5605
EnforceContentSecurity.addPolicyHeader
train
protected function addPolicyHeader(ResponseInterface $response) { $this->loadDefaultProfiles(); $currentHeader = $response->getHeader($this->header); $initialConfig = []; if (count($currentHeader)) { $initialConfig = $this->decodeConfiguration($currentHeader[0]); ...
php
{ "resource": "" }
q5606
EnforceContentSecurity.decodeConfiguration
train
protected function decodeConfiguration($string) { $config = []; $directives = explode($this->directiveSeparator, $string); foreach ($directives as $directive) { $parts = array_filter(explode($this->sourceSeparator, $directive)); $key = trim(array_shift($parts)); ...
php
{ "resource": "" }
q5607
EnforceContentSecurity.encodeConfiguration
train
protected function encodeConfiguration($config = []) { $value = []; ksort($config); foreach ($config as $directive => $values) { $values = array_unique($values); sort($values); array_unshift($values, $directive); $string = implode($this->source...
php
{ "resource": "" }
q5608
EnforceContentSecurity.getArrayFromValue
train
protected function getArrayFromValue($value, $separator = ',') { if (!is_array($value)) { $value = explode($separator, $value); } return $value; }
php
{ "resource": "" }
q5609
EnforceContentSecurity.loadDefaultProfiles
train
protected function loadDefaultProfiles() { $defaultProfiles = []; if (isset($this->profiles['default'])) { $defaultProfiles = $this->getArrayFromValue( $this->profiles['default'] ); } array_map([$this, 'loadProfileByKey'], $defaultProfiles); ...
php
{ "resource": "" }
q5610
EnforceContentSecurity.loadProfileByKey
train
protected function loadProfileByKey($key) { if (isset($this->profiles['profiles'][$key])) { $profile = $this->profiles['profiles'][$key]; if (is_array($profile)) { $this->mergeProfileWithConfig($profile); } } }
php
{ "resource": "" }
q5611
EnforceContentSecurity.mergeProfileWithConfig
train
protected function mergeProfileWithConfig(array $profile) { foreach ($profile as $directive => $values) { if (!isset($this->config[$directive])) { $this->config[$directive] = []; } $values = $this->getArrayFromValue($values); $this->config[$d...
php
{ "resource": "" }
q5612
Tags.getValue
train
public function getValue() { $arr = []; if (!is_array($this->_options['value'])) { return []; } foreach ($this->_options['value'] as $key) { $arr[$key] = $key; } return $arr; }
php
{ "resource": "" }
q5613
File.moveTo
train
public function moveTo($dst, $allowedExtensions = 'jpg,jpeg,png,gif,doc,xls,pdf,zip', $overwrite = false) { if ($allowedExtensions !== '*') { $extension = pathinfo($dst, PATHINFO_EXTENSION); if (!$extension || preg_match("#\b$extension\b#", $allowedExtensions) !== 1) { ...
php
{ "resource": "" }
q5614
File.getExtension
train
public function getExtension() { $name = $this->_file['name']; return ($extension = pathinfo($name, PATHINFO_EXTENSION)) === $name ? '' : $extension; }
php
{ "resource": "" }
q5615
ProviderSelector.select
train
public function select(string $type = null) { if (empty($type)) { $type = $this->provider; } $providers = $this->mergeProviders(); if (!isset($providers[$type])) { throw new InvalidArgumentException(sprintf('Provider %s does not exist', $type)); } ...
php
{ "resource": "" }
q5616
PhpStringParser.staticPhp
train
public function staticPhp($text) { $textExplode = explode('->', $text); $variableName = str_replace('$', '', array_shift($textExplode)); $variableVariable = $this->variables; if (isset($variableVariable[$variableName]) === false) { throw new \InvalidArgumentExce...
php
{ "resource": "" }
q5617
GlideKeyGenerate.setKeyInEnvironmentFile
train
protected function setKeyInEnvironmentFile($key) { $currentContent = file_get_contents(base_path('.env')); $currentValue = ''; if (preg_match('/^GLIDE_SIGN_KEY=(.*)$/m', $currentContent, $matches) && isset($matches[1])) { $currentValue = $matches[1]; } file_put...
php
{ "resource": "" }
q5618
ServeController.defaultCommand
train
public function defaultCommand($ip = '127.0.0.1', $port = 1983) { $router_str = <<<'STR' <?php $_SERVER['SERVER_ADDR'] = ':ip'; $_SERVER['SERVER_PORT'] = ':port'; $_SERVER['REQUEST_SCHEME'] = 'http'; chdir('public'); $uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); if ($uri !== '/') { ...
php
{ "resource": "" }
q5619
TwigTemplateIterator.getIterator
train
public function getIterator() { $this->kernel->boot(); $viewDirectories = $this->getPossibleViewDirectories(); $viewDirectories = $this->removeNotExistingDirectories($viewDirectories); $templates = $this->getTwigTemplatesIn($viewDirectories); return new \ArrayIterator($...
php
{ "resource": "" }
q5620
TwigTemplateIterator.getTwigTemplatesIn
train
protected function getTwigTemplatesIn($directories) { if (count($directories) === 0) { return array(); } $templates = Finder::create()->in($directories)->files()->name('*.*.twig'); $templates = iterator_to_array($templates, false); $templates = array_map(function ...
php
{ "resource": "" }
q5621
CategoryWidgetModel.findWidgetRelationById
train
public function findWidgetRelationById($id) { //iteracja po relacjach foreach ($this->_widgetCollection as $widgetRelationRecord) { //relacja odnaleziona if ($widgetRelationRecord->id == $id) { return $widgetRelationRecord; } } }
php
{ "resource": "" }
q5622
PLUGObject.trigger_error
train
protected function trigger_error( $code, $message, $type = E_USER_NOTICE ){ $trace = debug_backtrace(); $Err = PLUG::raise_error( $code, $message, $type, $trace ); $this->on_trigger_error( $Err ); }
php
{ "resource": "" }
q5623
PLUGObject.get_error_level
train
function get_error_level() { // calculate level in case global errors have been cleared $e = 0; foreach( $this->err_stack as $t => $ids ) { foreach( $ids as $id ){ $Err = PLUGError::get_reference( $t, $id ); if( is_object($Err) ){ $e |= $t; break; } } } return $e; }
php
{ "resource": "" }
q5624
PLUGObject.get_errors
train
function get_errors( $emask = null ) { $errs = array(); foreach( $this->err_stack as $t => $ids ) { if( $emask !== NULL && ( $emask & $t ) == 0 ) { // ignore this error continue; } // collect these errors foreach( $ids as $id ){ $Err = PLUGError::get_reference( $t, $id ); if( is_object($...
php
{ "resource": "" }
q5625
PLUGObject.clear_errors
train
function clear_errors( $emask = null ) { foreach( $this->err_stack as $t => $ids ) { if( $emask !== NULL && ( $emask & $t ) == 0 ) { // ignore this error continue; } // clear these errors foreach( $ids as $id ){ $Err = PLUGError::get_reference( $t, $id ); $Err->clear(); } unset( $thi...
php
{ "resource": "" }
q5626
PLUGObject.dump_errors
train
function dump_errors( $emask = null ) { foreach( $this->err_stack as $t => $ids ) { if( $emask !== NULL && ( $emask & $t ) == 0 ) { // ignore this error continue; } // dump these errors foreach( $ids as $id ){ $Err = PLUGError::get_reference( $t, $id ); echo (string) $Err; echo $Err->g...
php
{ "resource": "" }
q5627
PLUGObject.is_error
train
function is_error( $emask = null ) { $e = $this->get_error_level(); if( $emask === null ){ return (bool) $e; } else { return (bool) ( $e & $emask ); } }
php
{ "resource": "" }
q5628
MetaDataDAOCache.getAllMetadata
train
public function getAllMetadata() { $configName = ($this->config !== null) ? $this->config->getUniqueName() : ''; $cacheFilename = Installer::BASE_PATH . Installer::CACHE_PATH . DIRECTORY_SEPARATOR; $cacheFilename .= md5('all_metadata' . get_class($this->metadataDAO) . $configName); ...
php
{ "resource": "" }
q5629
Lex.defined
train
function defined( $c ){ if( isset($this->literals[$c]) ){ return true; } if( ! defined($c) ){ return false; } $i = constant( $c ); return isset( $this->names[$i] ) && $this->names[$i] === $c; }
php
{ "resource": "" }
q5630
Lex.name
train
function name( $i ){ if( is_int($i) ){ if( ! isset($this->names[$i]) ){ trigger_error("symbol ".var_export($i,1)." is unknown in ".get_class($this), E_USER_NOTICE ); return 'UNKNOWN'; } else { return $this->names[$i]; } } else if ( ! isset($this->literals[$i]) ){ trigger_error("literal ...
php
{ "resource": "" }
q5631
LRNDA.export
train
function export(){ $RootSet = $this->resolve(); $table = array(); $RootSet->export( $table, $this->Grammar ); return new LRParseTableBuilder( $table ); }
php
{ "resource": "" }
q5632
LRNDA.resolve
train
function resolve(){ LRState::clear_index(); LRStation::clear_index(); // create Root Set // we SHOULD have a single etransition to an intial state return LRStateSet::init( $this->etransitions[0], $this->Grammar ); }
php
{ "resource": "" }
q5633
MetaDataSourceFinder.getAllAdapters
train
public function getAllAdapters() { $classCollection = $this->classAwake->wakeByInterfaces( array( __DIR__ . '/Sources/', ), 'CrudGenerator\Metadata\Sources\MetaDataDAOFactoryInterface' ); $adapterCollection = new MetaDataSourceCollection()...
php
{ "resource": "" }
q5634
Amqp.purgeQueue
train
public function purgeQueue($name) { if (!isset($this->_queues[$name])) { throw new InvalidKeyException(['purge `:queue` queue failed: it is NOT exists', 'queue' => $name]); } try { $this->_queues[$name]->purge(); } catch (\Exception $e) { throw ne...
php
{ "resource": "" }
q5635
Model.getFieldTypes
train
public function getFieldTypes() { static $cached = []; $class = static::class; if (!isset($cached[$class])) { if (!$doc = static::sample()) { if (!$docs = $this->getConnection()->fetchAll($this->getSource(), [], ['limit' => 1])) { throw new ...
php
{ "resource": "" }
q5636
Loader.registerNamespaces
train
public function registerNamespaces($namespaces, $merge = true) { foreach ($namespaces as $namespace => $path) { $path = rtrim($path, '\\/'); if (DIRECTORY_SEPARATOR === '\\') { $namespaces[$namespace] = strtr($path, '\\', '/'); } } $this->...
php
{ "resource": "" }
q5637
Loader.registerClasses
train
public function registerClasses($classes, $merge = true) { if (DIRECTORY_SEPARATOR === '\\') { foreach ($classes as $key => $path) { $classes[$key] = strtr($path, '\\', '/'); } } $this->_classes = $merge ? array_merge($this->_classes, $classes) : $cla...
php
{ "resource": "" }
q5638
Loader.requireFile
train
public function requireFile($file) { if (PHP_EOL !== "\n" && strpos($file, 'phar://') !== 0) { $realPath = strtr(realpath($file), '\\', '/'); if ($realPath !== $file) { trigger_error("File name ($realPath) case mismatch for .$file", E_USER_ERROR); } ...
php
{ "resource": "" }
q5639
Loader.load
train
public function load($className) { if (isset($this->_classes[$className])) { $file = $this->_classes[$className]; if (!is_file($file)) { trigger_error(strtr('load `:class` class failed: `:file` is not exists.', [':class' => $className, ':file' => $file]), E_USER_ERROR...
php
{ "resource": "" }
q5640
ACEDataTransformer.transform
train
public function transform($ace) { $sid = null; $mask = null; $sidPrefix = ''; $sidName = ''; $permissions = array(); if($ace instanceof Entry) { $sid = $ace->getSecurityIdentity(); $mask = $ace->getMask(); } elseif(is_array($ace)) { ...
php
{ "resource": "" }
q5641
ACEDataTransformer.reverseTransform
train
public function reverseTransform($data) { $sidParts = explode(':', $data['sid']); if(strtoupper($sidParts[0]) == 'R') { /* is rolebased */ $sid = new RoleSecurityIdentity($sidParts[1]); } else { if(3 == count($sidParts)) { /* has 3 sidParts...
php
{ "resource": "" }
q5642
Neko.snakeCase
train
public static function snakeCase($value) { $key = $value; if (isset(static::$snakeCache[$key])) { return static::$snakeCache[$key]; } $value = preg_replace('/\s+/', '', ucwords($value)); $value = str_replace('-', '_', $value); $value = static::normalizeSc...
php
{ "resource": "" }
q5643
Neko.kebabCase
train
public static function kebabCase($value) { $key = $value; if (isset(static::$kebabCache[$key])) { return static::$kebabCache[$key]; } $value = preg_replace('/\s+/', '', ucwords($value)); $value = str_replace('_', '-', $value); $value = static::normalizeSc...
php
{ "resource": "" }
q5644
Neko.pascalCase
train
public static function pascalCase($value) { if (isset(static::$pascalCache[$value])) { return static::$pascalCache[$value]; } $value = static::normalizeScreamingCase($value); return static::$pascalCache[$value] = str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', ...
php
{ "resource": "" }
q5645
Neko.camelCase
train
public static function camelCase($value) { if (isset(static::$camelCache[$value])) { return static::$camelCache[$value]; } return static::$camelCache[$value] = lcfirst(static::pascalCase($value)); }
php
{ "resource": "" }
q5646
CategoryController.dispatchAction
train
public function dispatchAction() { //pobranie kategorii $category = $this->_getPublishedCategoryByUri($this->uri); //wpięcie kategorii do głównego widoku aplikacji FrontController::getInstance()->getView()->category = $category; //klucz bufora $cacheKey = 'category-ht...
php
{ "resource": "" }
q5647
CategoryController._prepareForwardRequest
train
protected function _prepareForwardRequest(\Cms\Orm\CmsCategoryRecord $category) { //tworzenie nowego requestu na podstawie obecnego $request = clone $this->getRequest(); $request->setModuleName('cms') ->setControllerName('category') ->setActionName('article'); ...
php
{ "resource": "" }
q5648
CategoryController._decorateHtmlWithEditButton
train
protected function _decorateHtmlWithEditButton($html, \Cms\Orm\CmsCategoryRecord $category) { //brak roli redaktora if (!$this->_hasRedactorRole()) { return $html; } //zwraca wyrenderowany HTML return str_replace('</body>', \Mmi\Mvc\ActionHelper::getInstance()->ac...
php
{ "resource": "" }
q5649
CategoryController._getCategoryCacheLifetime
train
protected function _getCategoryCacheLifetime(\Cms\Orm\CmsCategoryRecord $category) { //czas buforowania (na podstawie typu kategorii i pojedynczej kategorii $cacheLifetime = (null !== $category->cacheLifetime) ? $category->cacheLifetime : ((null !== $category->getJoined('cms_category_type')->cacheLi...
php
{ "resource": "" }
q5650
CategoryController._bufferingAllowed
train
protected function _bufferingAllowed() { //jeśli zdefiniowano własny obiekt sprawdzający, czy można buforować if (\App\Registry::$config->category instanceof \Cms\Config\CategoryConfig && \App\Registry::$config->category->bufferingAllowedClass) { $class = \App\Registry::$config->category...
php
{ "resource": "" }
q5651
FileManager.filePutsContent
train
public function filePutsContent($path, $content) { if (@file_put_contents($path, $content) === false) { throw new \RuntimeException(sprintf("Could't puts content %s", $path)); } chmod($path, 0777); }
php
{ "resource": "" }
q5652
FileManager.ifDirDoesNotExistCreate
train
public function ifDirDoesNotExistCreate($directory, $recursive = false) { if ($this->isDir($directory) === false) { $this->mkdir($directory, $recursive); return true; } else { return false; } }
php
{ "resource": "" }
q5653
Grammar.get_rules
train
function get_rules( $nt ){ $rules = array(); if( isset($this->ntindex[$nt]) ){ foreach( $this->ntindex[$nt] as $i ){ $rules[$i] = $this->rules[$i]; } } return $rules; }
php
{ "resource": "" }
q5654
Grammar.follow_set
train
function follow_set( $s ){ if( ! isset($this->follows[$s]) ){ $type = $this->is_terminal($s) ? 'terminal' : 'non-terminal'; trigger_error("No follow set for $type $s", E_USER_WARNING ); return array(); } return $this->follows[$s]; }
php
{ "resource": "" }
q5655
ArrayHydrator.extract
train
public function extract(callable $callback = null) { if ($callback === null) { $result = $this->result->toArray(); } else { $result = $callback($this->result->toArray()); } return $result; }
php
{ "resource": "" }
q5656
PLUGError.getTraceAsString
train
public function getTraceAsString() { $lines = array (); for( $i = 0; $i < count($this->trace); $i++ ){ $a = $this->trace[$i]; $call = "{$a['function']}()"; if( isset($a['class']) ){ $call = "{$a['class']}{$a['type']}$call"; } $lines[] = "#$i {$a['file']}({$a['line']}): $call"; } $lines[] = "...
php
{ "resource": "" }
q5657
PLUGError.raise
train
public function raise() { // log error to file according to PLUG_ERROR_LOGGING if( PLUG_ERROR_LOGGING & $this->type ) { // send to standard, or configured log file $logfile = defined('PLUG_ERROR_LOG') ? PLUG_ERROR_LOG : ''; $logged = self::log( call_user_func(self::$logfunc,$this), $logfile ); } // ad...
php
{ "resource": "" }
q5658
PLUGError.death
train
private static function death( PLUGError $Err ){ if( PLUG_CLI ){ // Print final death message to stderr if last error was logged $logfile = ini_get('error_log'); if( $logfile ){ PLUGCli::stdout("Error, %s exiting %s\n", $Err->getMessage(), $Err->code ); } } else { // display all errors in brows...
php
{ "resource": "" }
q5659
PLUGError.log
train
static function log( $logline, $out = '' ) { // Output log line, no error checking to save performance // Send to descriptor or other stream if resource passed if( is_resource($out) && fwrite( $out, "$logline\n" ) ){ return true; } // Log to specified file else if( $out && error_log( "$logline\n", 3, $ou...
php
{ "resource": "" }
q5660
PLUGError.display
train
static function display( PLUGError $Err ){ $html = ini_get('html_errors'); if( $html ){ $s = '<div class="error"><strong>%s:</strong> %s. in <strong>%s</strong> on line <strong>%u</strong></div>'; } else { $s = "\n%s: %s. in %s on line %u"; } $args = array ( $s, $Err->getTypeString(), $Err->...
php
{ "resource": "" }
q5661
PLUGError.clear
train
public function clear() { unset( self::$stack[ $this->type ][ $this->id ] ); if( empty( self::$stack[ $this->type ] ) ){ unset( self::$stack[ $this->type ] ); } $this->id = null; }
php
{ "resource": "" }
q5662
PLUGError.get_errors
train
static function get_errors( $emask = null ) { $all = array(); foreach( self::$stack as $type => $errs ){ if( $emask === null || $type & $emask ) { foreach( $errs as $Err ){ $all[] = $Err; } } } return $all; }
php
{ "resource": "" }
q5663
PLUGError.&
train
static function &get_reference( $type, $id ) { if( empty( self::$stack[ $type ][ $id ] ) ){ $null = null; return $null; } else { return self::$stack[ $type ][ $id ]; } }
php
{ "resource": "" }
q5664
PLUGError.is_error
train
static function is_error( $emask = null ) { if( $emask === null ){ return (bool) self::get_global_level(); } else { return (bool) ( self::get_global_level() & $emask ); } }
php
{ "resource": "" }
q5665
PLUGError.get_global_level
train
static function get_global_level () { $e = 0; $types = array_keys( self::$stack ); foreach( $types as $t ) { $e |= $t; } return $e; }
php
{ "resource": "" }
q5666
JsonMetaDataDAO.isFirstLevelIsDto
train
private function isFirstLevelIsDto(\JSONSchema\Structure\Schema $schema) { $isFirstLevelIsDto = false; foreach ($schema->getProperties() as $propertie) { if (in_array($propertie->getType(), array('object', 'array')) === false) { $isFirstLevelIsDto = true; } ...
php
{ "resource": "" }
q5667
JsonMetaDataDAO.hydrateItems
train
private function hydrateItems( $daddyName, array $items, MetadataDataObjectJson $metadata, MetaDataCollection $mainCollection ) { $mergeArray = true; if ($mergeArray === true && $this->itemsAreAllOfType($items, array('object')) === true) { $metadata->appe...
php
{ "resource": "" }
q5668
JsonMetaDataDAO.hydrateProperties
train
private function hydrateProperties( array $properties, MetadataDataObjectJson $metadata, MetaDataCollection $mainCollection ) { $specialProperties = array(); foreach ($properties as $propName => $propertie) { if (false === ($propertie instanceof \JSONSchema\Struc...
php
{ "resource": "" }
q5669
JsonMetaDataDAO.getMetadataFor
train
public function getMetadataFor($tableName, array $parentName = array()) { $avaibleData = array(); foreach ($this->getAllMetadata() as $metadata) { $avaibleData[] = $metadata->getName(); if ($metadata->getName() === $tableName) { return $metadata; }...
php
{ "resource": "" }
q5670
Mail.pushEmail
train
public static function pushEmail($name, $to, array $params = [], $fromName = null, $replyTo = null, $subject = null, $sendAfter = null, array $attachments = []) { //brak definicji if (null === ($def = Orm\CmsMailDefinitionQuery::langByName($name) ->findFirst())) { return fals...
php
{ "resource": "" }
q5671
Mail.getMultioptions
train
public static function getMultioptions() { $rows = (new Orm\CmsMailServerQuery) ->whereActive()->equals(1) ->find(); $pairs = []; foreach ($rows as $row) { $pairs[$row->id] = $row->address . ':' . $row->port . ' (' . $row->username . ')'; } ...
php
{ "resource": "" }
q5672
Compiler._compileComments
train
protected function _compileComments($value) { $pattern = sprintf('/%s--(.*?)--%s/s', $this->_escapedTags[0], $this->_escapedTags[1]); return preg_replace($pattern, '<?php /*$1*/ ?> ', $value); }
php
{ "resource": "" }
q5673
Compiler._compileEchos
train
protected function _compileEchos($value) { foreach ($this->_getEchoMethods() as $method => $length) { $value = $this->$method($value); } return $value; }
php
{ "resource": "" }
q5674
Compiler._getEchoMethods
train
protected function _getEchoMethods() { $methods = [ '_compileRawEchos' => strlen(stripcslashes($this->_rawTags[0])), '_compileEscapedEchos' => strlen(stripcslashes($this->_escapedTags[0])), ]; uksort($methods, static function ($method1, $method2) use ($methods) { ...
php
{ "resource": "" }
q5675
Compiler._compile_allow
train
protected function _compile_allow($expression) { $parts = explode(',', substr($expression, 1, -1)); $expr = $this->compileString($parts[1]); return "<?php if (\$di->authorization->isAllowed($parts[0])): ?>$expr<?php endif ?>"; }
php
{ "resource": "" }
q5676
Compiler._compile_asset
train
protected function _compile_asset($expression) { if (strcspn($expression, '$\'"') === strlen($expression)) { $expression = '(\'' . trim($expression, '()') . '\')'; } return asset(substr($expression, 2, -2)); /*return "<?= asset{$expression}; ?>";*/ }
php
{ "resource": "" }
q5677
ConnectorController.importFileAction
train
public function importFileAction() { //text/plain $this->getResponse()->setTypePlain(); //adres endpointu $endpoint = base64_decode($this->url) . '/?module=cms&controller=connector&name=' . $this->name . '&action='; try { //wczytanie danych $data = jso...
php
{ "resource": "" }
q5678
ConnectorController.exportFileBinaryAction
train
public function exportFileBinaryAction() { $this->getResponse()->setType('application/octet-stream') ->send(); //wyszukiwanie pliku if (null === $file = (new Orm\CmsFileQuery)->whereName()->equals($this->name) ->findFirst()) { throw new \Mmi\Mvc\MvcNotFoun...
php
{ "resource": "" }
q5679
ConnectorController.exportFileMetaAction
train
public function exportFileMetaAction() { //wyszukiwanie pliku if (null === $files = (new Orm\CmsFileQuery)->whereName()->equals($this->name) ->find()) { throw new \Mmi\Mvc\MvcNotFoundException('File not found'); } $data = []; //iteracja po plikach ...
php
{ "resource": "" }
q5680
Log.add
train
public static function add($operation = null, array $data = []) { \Mmi\App\FrontController::getInstance()->getLogger()->info('Legacy log: ' . $operation); \Mmi\App\FrontController::getInstance()->getLogger()->warning('\Cms\Log\Model deprecated, use MMi PSR logger instead'); }
php
{ "resource": "" }
q5681
Comment.create
train
public function create($projectId,$taskId,array $params = array()) { $defaults = array( 'text' => null, 'user_id' => null, 'user_email' => null ); $params = array_filter(array_merge($defaults, $params)); $data = array('comment'=>...
php
{ "resource": "" }
q5682
ColumnAbstract.getFilterValue
train
public function getFilterValue($param = null) { //iteracja po filtrach w gridzie foreach ($this->_grid->getState()->getFilters() as $filter) { //znaleziony filtr dla tego pola z tabelą if ($filter->getTableName() . '.' . $filter->getField() == $this->getName()) { ...
php
{ "resource": "" }
q5683
ColumnAbstract.isFieldInRecord
train
public function isFieldInRecord() { //zażądany join if (strpos($this->getName(), '.')) { return true; } //sorawdzenie w rekordzie return property_exists($this->_grid->getQuery()->getRecordName(), $this->getName()); }
php
{ "resource": "" }
q5684
ColumnAbstract.getOrderMethod
train
public function getOrderMethod() { //iteracja po sortowaniach w gridzie foreach ($this->_grid->getState()->getOrder() as $order) { //znalezione sortowanie tego pola //gdy jest podana nazwa tabeli if ($order->getTableName()) { if ($order->getTableNa...
php
{ "resource": "" }
q5685
SubscriptionStatus.augment
train
public function augment(SubscriptionNotification $notification) { $this->in = $notification->in; $this->out = $notification->out; }
php
{ "resource": "" }
q5686
Tree._generateJs
train
private function _generateJs($treeId) { $id = $this->getOption('id'); $treeClearId = $treeId . '_clear'; $view = \Mmi\App\FrontController::getInstance()->getView(); $view->headScript()->appendScript("$(document).ready(function () { $('#$treeId').jstree({ 'core': { 'the...
php
{ "resource": "" }
q5687
CmsFrontControllerPlugin.postDispatch
train
public function postDispatch(\Mmi\Http\Request $request) { //ustawienie widoku $view = \Mmi\App\FrontController::getInstance()->getView(); $base = $view->baseUrl; $view->domain = \App\Registry::$config->host; $view->languages = \App\Registry::$config->languages; $jsRe...
php
{ "resource": "" }
q5688
CmsFrontControllerPlugin._setLoginRequest
train
protected function _setLoginRequest(\Mmi\Http\Request $request, $preferAdmin) { //logowanie bez preferencji admina, tylko gdy uprawniony if (false === $preferAdmin && \App\Registry::$acl->isRoleAllowed('guest', 'cms:user:login')) { return $request->setModuleName('cms') ->...
php
{ "resource": "" }
q5689
TagRelationModel.createTagRelation
train
public function createTagRelation($tag) { //filtrowanie tagu $filteredTag = (new \Mmi\Filter\Input)->filter($tag); //kreacja tagu jeśli brak if (null === $tagRecord = (new CmsTagQuery) ->whereTag()->equals($filteredTag) ->findFirst()) { $tagRecord...
php
{ "resource": "" }
q5690
ErdikoUsersInstall.installRoles
train
public function installRoles() { $this->_roleService = new erdiko\users\models\Role(); $results = array( "successes" => array(), "failures" => array(), ); foreach($this->_rolesArray as $role) { // attempt to create the role // wrap t...
php
{ "resource": "" }
q5691
ErdikoUsersInstall.installUsers
train
public function installUsers() { $this->_userService = new erdiko\users\models\User(); $results = array( "successes" => array(), "failures" => array(), ); foreach($this->_usersArray as $user) { // get role ID from the name $user["ro...
php
{ "resource": "" }
q5692
Authorization.isAllowed
train
public function isAllowed($permission = null, $role = null) { if ($permission && strpos($permission, '/') !== false) { list($controllerClassName, $action) = $this->inferControllerAction($permission); $controllerClassName = $this->alias->resolveNS($controllerClassName); if...
php
{ "resource": "" }
q5693
RequestCreditCardPayment.withRedirectUrls
train
public function withRedirectUrls($redirects) { if (isset($redirects['success'])) { $this->returnUrlSuccess = $redirects['success']; } if (isset($redirects['cancel'])) { $this->returnUrlCancel = $redirects['cancel']; } if (isset($redirects['back'])) {...
php
{ "resource": "" }
q5694
Image.resizeCropCenter
train
public function resizeCropCenter($width, $height) { $_width = $this->do_getWidth(); $_height = $this->do_getHeight(); if ($_width / $_height > $width / $height) { $crop_height = $_height; $crop_width = $width * $crop_height / $height; $offsetX = ($_width ...
php
{ "resource": "" }
q5695
Image.scale
train
public function scale($ratio) { $_width = (int)$this->do_getWidth(); $_height = (int)$this->do_getHeight(); if ($ratio === 1) { return $this; } $width = (int)($_width * $ratio); $height = (int)($_height * $ratio); $this->do_resize($width, $heigh...
php
{ "resource": "" }
q5696
Image.scaleFixedHeight
train
public function scaleFixedHeight($height) { $_width = $this->do_getWidth(); $_height = $this->do_getHeight(); $width = (int)($_width * $height / $_height); $this->do_resize($width, $height); return $this; }
php
{ "resource": "" }
q5697
Validation.validatePascalCase
train
public static function validatePascalCase($string) { if (SetupHelper::getPascalCase($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not in PascalCase.', $string...
php
{ "resource": "" }
q5698
Validation.validateLowerCase
train
public static function validateLowerCase($string) { if (SetupHelper::getLowerCase($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not in lowercase.', $string ...
php
{ "resource": "" }
q5699
Validation.validateTrimmed
train
public static function validateTrimmed($string) { if (SetupHelper::trim($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf( 'Provided string "%1$s" was not trimmed.', $string ) ...
php
{ "resource": "" }