_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
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); // check fields of table $this->validColumns($model->getModelsMetaData(), array_keys($sort), $table, $model); // check sort clause $sort = array_map('strtolower', $sort); if (empty($diff = array_diff(array_values($sort), $this->sort)) === false) {
php
{ "resource": "" }
q5601
Validator.validTypes
train
protected function validTypes(Column $column) { if (in_array($column->getType(), $this->columns) === false)
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',
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 ) ); } $historyCollection = new HistoryCollection(); $searchPath = Installer::BASE_PATH . self::HISTORY_PATH . '*' . self::FILE_EXTENSION;
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)) { $allowed_users[] = $user; } } $oid = new ObjectIdentity('class',
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]); } $initialDirectives = $this->encodeConfiguration($initialConfig); $this->mergeProfileWithConfig($initialConfig);
php
{ "resource": "" }
q5606
EnforceContentSecurity.decodeConfiguration
train
protected function decodeConfiguration($string) { $config = []; $directives = explode($this->directiveSeparator, $string); foreach ($directives as $directive) { $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);
php
{ "resource": "" }
q5608
EnforceContentSecurity.getArrayFromValue
train
protected function getArrayFromValue($value, $separator = ',') { if
php
{ "resource": "" }
q5609
EnforceContentSecurity.loadDefaultProfiles
train
protected function loadDefaultProfiles() { $defaultProfiles = []; if (isset($this->profiles['default'])) { $defaultProfiles = $this->getArrayFromValue(
php
{ "resource": "" }
q5610
EnforceContentSecurity.loadProfileByKey
train
protected function loadProfileByKey($key) { if (isset($this->profiles['profiles'][$key])) { $profile = $this->profiles['profiles'][$key]; if
php
{ "resource": "" }
q5611
EnforceContentSecurity.mergeProfileWithConfig
train
protected function mergeProfileWithConfig(array $profile) { foreach ($profile as $directive => $values) { if (!isset($this->config[$directive])) { $this->config[$directive] = []; }
php
{ "resource": "" }
q5612
Tags.getValue
train
public function getValue() { $arr = []; if (!is_array($this->_options['value'])) {
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) { throw new FileException(['`:extension` file type is not allowed upload', 'extension' => $extension]); } } if ($this->_file['error'] !== UPLOAD_ERR_OK) { throw new FileException(['error code of upload file is not UPLOAD_ERR_OK: :error',
php
{ "resource": "" }
q5614
File.getExtension
train
public function getExtension() { $name = $this->_file['name']; return
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])) {
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 \InvalidArgumentException( sprintf('variable %s does not exist', $variableName) ); } $textExplode = array_map( function ($value) { return str_replace('()', '', $value);
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]; }
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 !== '/') { if (file_exists('public/' . $uri) || preg_match('#\.(?:css|js|gif|png|jpg|jpeg|ttf|woff|ico)$#', $uri) === 1 ) { return false; } } $_GET['_url'] = $uri; $_REQUEST['_url'] = $uri; require_once 'index.php'; STR; if ($value = $this->arguments->getValue(0)) { if (strpos($value, ':')) { list($ip, $port) = explode(':', $value, 2); } elseif (is_numeric($value)) { $port = (int)$value; } else { $ip = $value; }
php
{ "resource": "" }
q5619
TwigTemplateIterator.getIterator
train
public function getIterator() { $this->kernel->boot(); $viewDirectories = $this->getPossibleViewDirectories(); $viewDirectories = $this->removeNotExistingDirectories($viewDirectories); $templates
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);
php
{ "resource": "" }
q5621
CategoryWidgetModel.findWidgetRelationById
train
public function findWidgetRelationById($id) { //iteracja po relacjach foreach ($this->_widgetCollection as $widgetRelationRecord) { //relacja odnaleziona
php
{ "resource": "" }
q5622
PLUGObject.trigger_error
train
protected function trigger_error( $code, $message, $type = E_USER_NOTICE ){ $trace
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 ){
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 ){
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
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
php
{ "resource": "" }
q5627
PLUGObject.is_error
train
function is_error( $emask = null ) { $e = $this->get_error_level();
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 );
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])
php
{ "resource": "" }
q5631
LRNDA.export
train
function export(){ $RootSet = $this->resolve(); $table = array(); $RootSet->export( $table,
php
{ "resource": "" }
q5632
LRNDA.resolve
train
function resolve(){ LRState::clear_index(); LRStation::clear_index(); // create Root Set
php
{ "resource": "" }
q5633
MetaDataSourceFinder.getAllAdapters
train
public function getAllAdapters() { $classCollection = $this->classAwake->wakeByInterfaces( array( __DIR__ . '/Sources/', ), 'CrudGenerator\Metadata\Sources\MetaDataDAOFactoryInterface' ); $adapterCollection = new MetaDataSourceCollection(); foreach ($classCollection as $className) {
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();
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 RuntimeException(['`:collection` collection has none record', 'collection' => $this->getSource()]); } $doc = $docs[0]; } $types = []; foreach ($doc as $field => $value) { $type = gettype($value); if ($type === 'integer') { $types[$field] = 'int'; } elseif ($type === 'string') { $types[$field] = 'string'; } elseif ($type === 'double') { $types[$field] = 'float'; } elseif ($type === 'boolean') {
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, '\\', '/');
php
{ "resource": "" }
q5637
Loader.registerClasses
train
public function registerClasses($classes, $merge = true) { if (DIRECTORY_SEPARATOR === '\\') { foreach ($classes as $key => $path) { $classes[$key] = strtr($path, '\\', '/');
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)
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); } //either linux or phar:// if (PHP_EOL === "\n" || $file[0] === 'p') { /** @noinspection PhpIncludeInspection */ require $file; } else { $this->requireFile($file); } return true; } /** @noinspection LoopWhichDoesNotLoopInspection */ foreach ($this->_namespaces as $namespace => $path) { if (strpos($className, $namespace) !== 0) { continue; } $file = $path .
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)) { $sid = $ace['sid']; $mask = $ace['mask']; } $sidString = ''; if($sid instanceof RoleSecurityIdentity) { $sidPrefix = 'r'; $sidName = $sid->getRole(); $sidString = sprintf('%s:%s', $sidPrefix, $sidName); } elseif($sid instanceof UserSecurityIdentity) { $sidPrefix = 'u';
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 */ $class = $sidParts[2]; } else { if($this->isLdapUser($sidParts[1])) { /* is LDAP user*/ $class = 'Mapbender\LdapIntegrationBundle\Entity\LdapUser'; } else { /* is not a LDAP user*/ $class = 'FOM\UserBundle\Entity\User'; } }
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('-',
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('_',
php
{ "resource": "" }
q5644
Neko.pascalCase
train
public static function pascalCase($value) { if (isset(static::$pascalCache[$value])) { return static::$pascalCache[$value]; }
php
{ "resource": "" }
q5645
Neko.camelCase
train
public static function camelCase($value) { if (isset(static::$camelCache[$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-html-' . $category->id; //buforowanie dozwolone $bufferingAllowed = $this->_bufferingAllowed(); //wczytanie zbuforowanej strony (dla niezalogowanych i z pustym requestem) if ($bufferingAllowed && (null !== $html = \App\Registry::$cache->load($cacheKey))) { //wysyłanie nagłówka o buforowaniu strony $this->getResponse()->setHeader('X-Cache', 'HIT'); //zwrot html return $this->_decorateHtmlWithEditButton($html, $category); } //wysyłanie nagłówka o braku buforowaniu strony
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'); //przekierowanie MVC if ($category->mvcParams) { //tablica z tpl $mvcParams = []; //parsowanie parametrów mvc parse_str($category->mvcParams, $mvcParams); return $request->setParams($mvcParams); }
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()->action(new \Mmi\Http\Request(['module' => 'cms',
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')->cacheLifetime) ? $category->getJoined('cms_category_type')->cacheLifetime : Orm\CmsCategoryRecord::DEFAULT_CACHE_LIFETIME); //jeśli bufor wyłączony (na poziomie typu kategorii, lub pojedynczej kategorii) if (0 == $cacheLifetime) { //brak bufora return 0; } //iteracja po widgetach
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->bufferingAllowedClass; $buffering = new $class($this->_request);
php
{ "resource": "" }
q5651
FileManager.filePutsContent
train
public function filePutsContent($path, $content) { if (@file_put_contents($path, $content) ===
php
{ "resource": "" }
q5652
FileManager.ifDirDoesNotExistCreate
train
public function ifDirDoesNotExistCreate($directory, $recursive = false) { if ($this->isDir($directory) === false) { $this->mkdir($directory, $recursive);
php
{ "resource": "" }
q5653
Grammar.get_rules
train
function get_rules( $nt ){ $rules = array(); if( isset($this->ntindex[$nt]) ){ foreach( $this->ntindex[$nt] as $i ){
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
php
{ "resource": "" }
q5655
ArrayHydrator.extract
train
public function extract(callable $callback = null) { if ($callback === null) { $result = $this->result->toArray();
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"; }
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 ); } // add to error stack if we are keeping this type if error // internal errors are always raised if( PLUG_ERROR_REPORTING & $this->type || $this->type === E_USER_INTERNAL ) { // register self as a raised error $this->id = self::$i++; self::$stack[ $this->type ][
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');
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, $out ) ){ return $out;
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->getMessage(), $Err->getFile(), $Err->getLine()
php
{ "resource": "" }
q5661
PLUGError.clear
train
public function clear() { unset( self::$stack[ $this->type ][ $this->id ] ); if( empty( self::$stack[ $this->type ] ) ){
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 ) {
php
{ "resource": "" }
q5663
PLUGError.&
train
static function &get_reference( $type, $id ) { if( empty( self::$stack[ $type ][ $id ] ) ){ $null = null; return $null;
php
{ "resource": "" }
q5664
PLUGError.is_error
train
static function is_error( $emask = null ) { if( $emask === null ){ return (bool) self::get_global_level(); } else
php
{ "resource": "" }
q5665
PLUGError.get_global_level
train
static function get_global_level () { $e = 0; $types = array_keys( self::$stack );
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',
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->appendRelation( $this->hydrateMetaDataRelationColumn( $daddyName, $this->mergeItems($items), $metadata, $mainCollection ) ); } else { $specialProperties = array(); foreach ($items as $propName => $item) { // Relation of relation
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\Structure\Property)) { throw new \Exception('$propertie is not an instance of Property'); } if (in_array($propertie->getType(), array('object', 'array')) === true) { $specialProperties[$propName] = $propertie;
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) {
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 false; } //walidacja listy adresów "do" $email = new \Mmi\Validator\EmailAddressList; if (!$email->isValid($to)) { return false; } //nowy rekord maila $mail = new Orm\CmsMailRecord; $mail->cmsMailDefinitionId = $def->id; $mail->to = $to; $mail->fromName = $fromName ? $fromName : $def->fromName; $mail->replyTo = $replyTo ? $replyTo : $def->replyTo; $mail->subject = $subject ? $subject : $def->subject; $mail->dateSendAfter = $sendAfter ? $sendAfter : date('Y-m-d H:i:s'); $files = []; //załączniki foreach ($attachments as $fileName => $filePath) { if (!file_exists($filePath)) { continue; } $files[$fileName] = ($filePath);
php
{ "resource": "" }
q5671
Mail.getMultioptions
train
public static function getMultioptions() { $rows = (new Orm\CmsMailServerQuery) ->whereActive()->equals(1) ->find(); $pairs = []; foreach ($rows as $row) {
php
{ "resource": "" }
q5672
Compiler._compileComments
train
protected function _compileComments($value) { $pattern = sprintf('/%s--(.*?)--%s/s', $this->_escapedTags[0], $this->_escapedTags[1]);
php
{ "resource": "" }
q5673
Compiler._compileEchos
train
protected function _compileEchos($value) { foreach ($this->_getEchoMethods() as $method => $length) { $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) { // Ensure the longest tags are processed first if ($methods[$method1] > $methods[$method2]) { return -1; } if ($methods[$method1] < $methods[$method2]) { return 1; } // Otherwise give preference to raw tags (assuming they've overridden) if ($method1 === '_compileRawEchos') { return -1; }
php
{ "resource": "" }
q5675
Compiler._compile_allow
train
protected function _compile_allow($expression) { $parts = explode(',', substr($expression, 1, -1)); $expr = $this->compileString($parts[1]);
php
{ "resource": "" }
q5676
Compiler._compile_asset
train
protected function _compile_asset($expression) { if (strcspn($expression, '$\'"') === strlen($expression)) { $expression = '(\'' . trim($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 = json_decode(file_get_contents($endpoint . 'exportFileMeta'), true); } catch (\Exception $e) { //zwrot pustego statusu return 'ERR';
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\MvcNotFoundException('File not found');
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 foreach ($files as $file) { //spłaszczenie meta-danych $file->data = ($file->data
php
{ "resource": "" }
q5680
Log.add
train
public static function add($operation = null, array $data = []) { \Mmi\App\FrontController::getInstance()->getLogger()->info('Legacy log: ' . $operation);
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));
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()) { //zwrot wartości filtra return $filter->getValue(); } //znaleziony filtr dla tego pola (bez tabeli) if (!$filter->getTableName() && $filter->getField() == $this->getName()) { /** @var \stdClass $value */
php
{ "resource": "" }
q5683
ColumnAbstract.isFieldInRecord
train
public function isFieldInRecord() { //zażądany join if (strpos($this->getName(), '.')) { return true; } //sorawdzenie w rekordzie
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->getTableName() . '.' . $order->getField() == $this->getName()) { //zwrot metody sortowania return $order->getMethod();
php
{ "resource": "" }
q5685
SubscriptionStatus.augment
train
public function augment(SubscriptionNotification $notification)
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': { 'themes': { 'name': 'default', 'variant': 'small', 'responsive' : true, 'stripes' : true }, 'multiple': " . ($this->getOption('multiple') ? 'true' : 'false') . ", 'expand_selected_onload': true, 'check_callback' : false } }) .on('changed.jstree', function (e, data) { var selectedStr = '';
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; $jsRequest = $request->toArray(); $jsRequest['baseUrl'] = $base; $jsRequest['locale'] = \App\Registry::$translate->getLocale();
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') ->setControllerName('user')
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 = new CmsTagRecord; $tagRecord->tag = $filteredTag; $tagRecord->save(); } //znaleziona relacja - nic do zrobienia if (null !== (new CmsTagRelationQuery) ->whereCmsTagId()->equals($tagRecord->id) ->andFieldObject()->equals($this->_object)
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 this in a try/catch since this throws an exception if failure on create $createResult = false; try { $createResult = (boolean)$this->_roleService->create($role); } catch(\Exception $e) {
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["role"] = $this->_getRole($user["role"])->getId(); // create the user
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 (!isset($this->_acl[$controllerClassName])) { /** @var \ManaPHP\Rest\Controller $controllerInstance */ $controllerInstance = new $controllerClassName; $this->_acl[$controllerClassName] = $controllerInstance->getAcl(); } } else { $controllerInstance = $this->dispatcher->getControllerInstance(); $controllerClassName = get_class($controllerInstance); $action = $permission ? lcfirst(Text::camelize($permission)) : $this->dispatcher->getAction();
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']; }
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 - $crop_width) / 2; $offsetY = 0; } else { $crop_width = $_width; $crop_height
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
php
{ "resource": "" }
q5696
Image.scaleFixedHeight
train
public function scaleFixedHeight($height) { $_width = $this->do_getWidth(); $_height =
php
{ "resource": "" }
q5697
Validation.validatePascalCase
train
public static function validatePascalCase($string) { if (SetupHelper::getPascalCase($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf(
php
{ "resource": "" }
q5698
Validation.validateLowerCase
train
public static function validateLowerCase($string) { if (SetupHelper::getLowerCase($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf(
php
{ "resource": "" }
q5699
Validation.validateTrimmed
train
public static function validateTrimmed($string) { if (SetupHelper::trim($string) === $string) { return (string)$string; } throw new InvalidArgumentException( sprintf(
php
{ "resource": "" }