repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
malenkiki/aleavatar
src/Malenki/Aleavatar/Unit.php
Unit.svg
public function svg() { $str_g = ''; $bg = new Primitive\Square(); $bg->point(0, 0)->size(self::SIZE); $bg->color($this->bg()); $str_g .= $bg->svg(); foreach ($this->arr_primitives as $p) { $str_g .= $p->svg(); } return $str_g; }
php
public function svg() { $str_g = ''; $bg = new Primitive\Square(); $bg->point(0, 0)->size(self::SIZE); $bg->color($this->bg()); $str_g .= $bg->svg(); foreach ($this->arr_primitives as $p) { $str_g .= $p->svg(); } return $str_g; }
[ "public", "function", "svg", "(", ")", "{", "$", "str_g", "=", "''", ";", "$", "bg", "=", "new", "Primitive", "\\", "Square", "(", ")", ";", "$", "bg", "->", "point", "(", "0", ",", "0", ")", "->", "size", "(", "self", "::", "SIZE", ")", ";",...
SVG output Outputs the primitive groups as SVG code. @access public @return string
[ "SVG", "output" ]
train
https://github.com/malenkiki/aleavatar/blob/91affa83f8580c8e6da62c77ce34b1c4451784bf/src/Malenki/Aleavatar/Unit.php#L2951-L2966
opus-online/yii2-payment
lib/services/ServicesAbstract.php
ServicesAbstract.loadAdapters
public function loadAdapters() { $this->paymentAdapters = array(); foreach ($this->paymentHandler->getAdapters() as $adapterName => $paymentAdapter) { $interfaceClass = sprintf( '%s\%s\AdapterInterface', __NAMESPACE__, ucwords($this->getServiceCode()) ); if ($paymentAdapter instanceof $interfaceClass) { $this->paymentAdapters[$adapterName] = $paymentAdapter; } } }
php
public function loadAdapters() { $this->paymentAdapters = array(); foreach ($this->paymentHandler->getAdapters() as $adapterName => $paymentAdapter) { $interfaceClass = sprintf( '%s\%s\AdapterInterface', __NAMESPACE__, ucwords($this->getServiceCode()) ); if ($paymentAdapter instanceof $interfaceClass) { $this->paymentAdapters[$adapterName] = $paymentAdapter; } } }
[ "public", "function", "loadAdapters", "(", ")", "{", "$", "this", "->", "paymentAdapters", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "paymentHandler", "->", "getAdapters", "(", ")", "as", "$", "adapterName", "=>", "$", "paymentAdapter...
Load supported adapters for this service
[ "Load", "supported", "adapters", "for", "this", "service" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/ServicesAbstract.php#L48-L61
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.validateParentID
public function validateParentID($attribute) { if ($this->{$attribute} !== NULL) { $comment = self::find()->where(['id' => $this->{$attribute}, 'entity' => $this->entity, 'entityId' => $this->entityId])->active()->exists(); if ($comment === FALSE) { $this->addError('content', Yii::t('app', 'Oops, something went wrong. Please try again later.')); } } }
php
public function validateParentID($attribute) { if ($this->{$attribute} !== NULL) { $comment = self::find()->where(['id' => $this->{$attribute}, 'entity' => $this->entity, 'entityId' => $this->entityId])->active()->exists(); if ($comment === FALSE) { $this->addError('content', Yii::t('app', 'Oops, something went wrong. Please try again later.')); } } }
[ "public", "function", "validateParentID", "(", "$", "attribute", ")", "{", "if", "(", "$", "this", "->", "{", "$", "attribute", "}", "!==", "NULL", ")", "{", "$", "comment", "=", "self", "::", "find", "(", ")", "->", "where", "(", "[", "'id'", "=>"...
Validate parentId attribute @param $attribute
[ "Validate", "parentId", "attribute" ]
train
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L102-L112
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.behaviors
public function behaviors() { return [ 'blameable' => [ 'class' => BlameableBehavior::className(), 'createdByAttribute' => 'createdBy', 'updatedByAttribute' => 'updatedBy', ], 'timestamp' => [ 'class' => TimestampBehavior::className(), 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['createdAt'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updatedAt'] ] ], 'purify' => [ 'class' => PurifyBehavior::className(), 'attributes' => ['content'] ] ]; }
php
public function behaviors() { return [ 'blameable' => [ 'class' => BlameableBehavior::className(), 'createdByAttribute' => 'createdBy', 'updatedByAttribute' => 'updatedBy', ], 'timestamp' => [ 'class' => TimestampBehavior::className(), 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['createdAt'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updatedAt'] ] ], 'purify' => [ 'class' => PurifyBehavior::className(), 'attributes' => ['content'] ] ]; }
[ "public", "function", "behaviors", "(", ")", "{", "return", "[", "'blameable'", "=>", "[", "'class'", "=>", "BlameableBehavior", "::", "className", "(", ")", ",", "'createdByAttribute'", "=>", "'createdBy'", ",", "'updatedByAttribute'", "=>", "'updatedBy'", ",", ...
Returns a list of behaviors that this component should behave as. @return array
[ "Returns", "a", "list", "of", "behaviors", "that", "this", "component", "should", "behave", "as", "." ]
train
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L119-L139
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.beforeSave
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->parentId > 0) { $parentNodeLevel = (int)self::find()->select('level')->where(['id' => $this->parentId])->scalar(); $this->level = $parentNodeLevel + 1; } return TRUE; } else { return FALSE; } }
php
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->parentId > 0) { $parentNodeLevel = (int)self::find()->select('level')->where(['id' => $this->parentId])->scalar(); $this->level = $parentNodeLevel + 1; } return TRUE; } else { return FALSE; } }
[ "public", "function", "beforeSave", "(", "$", "insert", ")", "{", "if", "(", "parent", "::", "beforeSave", "(", "$", "insert", ")", ")", "{", "if", "(", "$", "this", "->", "parentId", ">", "0", ")", "{", "$", "parentNodeLevel", "=", "(", "int", ")"...
This method is called at the beginning of inserting or updating a record. @param bool $insert @return bool
[ "This", "method", "is", "called", "at", "the", "beginning", "of", "inserting", "or", "updating", "a", "record", "." ]
train
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L174-L190
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.getAuthor
public function getAuthor() { $module = Yii::$app->getModule(Module::$name); return $this->hasOne($module->userIdentityClass, ['id' => 'createdBy']); }
php
public function getAuthor() { $module = Yii::$app->getModule(Module::$name); return $this->hasOne($module->userIdentityClass, ['id' => 'createdBy']); }
[ "public", "function", "getAuthor", "(", ")", "{", "$", "module", "=", "Yii", "::", "$", "app", "->", "getModule", "(", "Module", "::", "$", "name", ")", ";", "return", "$", "this", "->", "hasOne", "(", "$", "module", "->", "userIdentityClass", ",", "...
Author relation @return \yii\db\ActiveQuery
[ "Author", "relation" ]
train
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L246-L251
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.getContent
public function getContent($deletedCommentText = NULL) { if (is_null($deletedCommentText)) { $deletedCommentText = Yii::t('app', 'Comment was deleted.'); } return $this->isDeleted ? $deletedCommentText : Yii::$app->formatter->asNtext($this->content); }
php
public function getContent($deletedCommentText = NULL) { if (is_null($deletedCommentText)) { $deletedCommentText = Yii::t('app', 'Comment was deleted.'); } return $this->isDeleted ? $deletedCommentText : Yii::$app->formatter->asNtext($this->content); }
[ "public", "function", "getContent", "(", "$", "deletedCommentText", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "deletedCommentText", ")", ")", "{", "$", "deletedCommentText", "=", "Yii", "::", "t", "(", "'app'", ",", "'Comment was deleted.'", ")"...
Get comment content @param string $deletedCommentText @return string
[ "Get", "comment", "content" ]
train
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L394-L402
Patroklo/yii2-comments
models/CommentModel.php
CommentModel.getAvatar
public function getAvatar($imgOptions = []) { $imgOptions = ArrayHelper::merge($imgOptions, ['class' => 'img-responsive']); if (is_null($this->createdBy)) { return Html::img("http://gravatar.com/avatar/1/?s=50", $imgOptions); } return Html::img("http://gravatar.com/avatar/{$this->author->id}/?s=50", $imgOptions); }
php
public function getAvatar($imgOptions = []) { $imgOptions = ArrayHelper::merge($imgOptions, ['class' => 'img-responsive']); if (is_null($this->createdBy)) { return Html::img("http://gravatar.com/avatar/1/?s=50", $imgOptions); } return Html::img("http://gravatar.com/avatar/{$this->author->id}/?s=50", $imgOptions); }
[ "public", "function", "getAvatar", "(", "$", "imgOptions", "=", "[", "]", ")", "{", "$", "imgOptions", "=", "ArrayHelper", "::", "merge", "(", "$", "imgOptions", ",", "[", "'class'", "=>", "'img-responsive'", "]", ")", ";", "if", "(", "is_null", "(", "...
Get avatar user @param array $imgOptions @return string
[ "Get", "avatar", "user" ]
train
https://github.com/Patroklo/yii2-comments/blob/e06409ea52b12dc14d0594030088fd7d2c2e160a/models/CommentModel.php#L409-L419
civicrm/civicrm-setup
src/Setup/UI/SetupController.php
SetupController.runStart
public function runStart($method, $fields) { $checkInstalled = $this->setup->checkInstalled(); if ($checkInstalled->isDatabaseInstalled() || $checkInstalled->isSettingInstalled()) { return $this->createError("CiviCRM is already installed"); } /** * @var \Civi\Setup\Model $model */ $model = $this->setup->getModel(); $tplFile = $this->getResourcePath('template.php'); $tplVars = [ 'ctrl' => $this, 'civicrm_version' => \CRM_Utils_System::version(), 'installURLPath' => $this->urls['res'], 'short_lang_code' => \CRM_Core_I18n_PseudoConstant::shortForLong($GLOBALS['tsLocale']), 'text_direction' => (\CRM_Core_I18n::isLanguageRTL($GLOBALS['tsLocale']) ? 'rtl' : 'ltr'), 'model' => $model, 'reqs' => $this->setup->checkRequirements(), ]; // $body = "<pre>" . htmlentities(print_r(['method' => $method, 'urls' => $this->urls, 'data' => $fields], 1)) . "</pre>"; $body = $this->render($tplFile, $tplVars); return array(array(), $body); }
php
public function runStart($method, $fields) { $checkInstalled = $this->setup->checkInstalled(); if ($checkInstalled->isDatabaseInstalled() || $checkInstalled->isSettingInstalled()) { return $this->createError("CiviCRM is already installed"); } /** * @var \Civi\Setup\Model $model */ $model = $this->setup->getModel(); $tplFile = $this->getResourcePath('template.php'); $tplVars = [ 'ctrl' => $this, 'civicrm_version' => \CRM_Utils_System::version(), 'installURLPath' => $this->urls['res'], 'short_lang_code' => \CRM_Core_I18n_PseudoConstant::shortForLong($GLOBALS['tsLocale']), 'text_direction' => (\CRM_Core_I18n::isLanguageRTL($GLOBALS['tsLocale']) ? 'rtl' : 'ltr'), 'model' => $model, 'reqs' => $this->setup->checkRequirements(), ]; // $body = "<pre>" . htmlentities(print_r(['method' => $method, 'urls' => $this->urls, 'data' => $fields], 1)) . "</pre>"; $body = $this->render($tplFile, $tplVars); return array(array(), $body); }
[ "public", "function", "runStart", "(", "$", "method", ",", "$", "fields", ")", "{", "$", "checkInstalled", "=", "$", "this", "->", "setup", "->", "checkInstalled", "(", ")", ";", "if", "(", "$", "checkInstalled", "->", "isDatabaseInstalled", "(", ")", "|...
Run the main installer page. @param string $method Ex: 'GET' or 'POST'. @param array $fields List of any HTTP GET/POST fields. @return array The HTTP headers and response text. [0 => array $headers, 1 => string $body].
[ "Run", "the", "main", "installer", "page", "." ]
train
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/UI/SetupController.php#L81-L107
civicrm/civicrm-setup
src/Setup/UI/SetupController.php
SetupController.runInstall
public function runInstall($method, $fields) { $checkInstalled = $this->setup->checkInstalled(); if ($checkInstalled->isDatabaseInstalled() || $checkInstalled->isSettingInstalled()) { return $this->createError("CiviCRM is already installed"); } $reqs = $this->setup->checkRequirements(); if (count($reqs->getErrors())) { return $this->runStart($method, $fields); } $this->setup->installFiles(); $this->setup->installDatabase(); $m = $this->setup->getModel(); $tplFile = $this->getResourcePath('finished.' . $m->cms . '.php'); if (file_exists($tplFile)) { $tplVars = array(); return array(array(), $this->render($tplFile, $tplVars)); } else { return $this->createError("Installation succeeded. However, the final page ($tplFile) was not available."); } }
php
public function runInstall($method, $fields) { $checkInstalled = $this->setup->checkInstalled(); if ($checkInstalled->isDatabaseInstalled() || $checkInstalled->isSettingInstalled()) { return $this->createError("CiviCRM is already installed"); } $reqs = $this->setup->checkRequirements(); if (count($reqs->getErrors())) { return $this->runStart($method, $fields); } $this->setup->installFiles(); $this->setup->installDatabase(); $m = $this->setup->getModel(); $tplFile = $this->getResourcePath('finished.' . $m->cms . '.php'); if (file_exists($tplFile)) { $tplVars = array(); return array(array(), $this->render($tplFile, $tplVars)); } else { return $this->createError("Installation succeeded. However, the final page ($tplFile) was not available."); } }
[ "public", "function", "runInstall", "(", "$", "method", ",", "$", "fields", ")", "{", "$", "checkInstalled", "=", "$", "this", "->", "setup", "->", "checkInstalled", "(", ")", ";", "if", "(", "$", "checkInstalled", "->", "isDatabaseInstalled", "(", ")", ...
Perform the installation action. @param string $method Ex: 'GET' or 'POST'. @param array $fields List of any HTTP GET/POST fields. @return array The HTTP headers and response text. [0 => array $headers, 1 => string $body].
[ "Perform", "the", "installation", "action", "." ]
train
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/UI/SetupController.php#L120-L143
civicrm/civicrm-setup
src/Setup/UI/SetupController.php
SetupController.boot
protected function boot($method, $fields) { $model = $this->setup->getModel(); define('CIVICRM_UF', $model->cms); // Set the Locale (required by CRM_Core_Config) global $tsLocale; $tsLocale = 'en_US'; // CRM-16801 This validates that lang is valid by looking in $langs. // NB: the variable is initial a $_REQUEST for the initial page reload, // then becomes a $_POST when the installation form is submitted. $langs = $model->getField('lang', 'options'); if (array_key_exists('lang', $fields)) { $model->lang = $fields['lang']; } if ($model->lang and isset($langs[$model->lang])) { $tsLocale = $model->lang; } \CRM_Core_Config::singleton(FALSE); $GLOBALS['civicrm_default_error_scope'] = NULL; // The translation files are in the parent directory (l10n) \CRM_Core_I18n::singleton(); $this->setup->getDispatcher()->dispatch('civi.setupui.boot', new UIBootEvent($this, $method, $fields)); }
php
protected function boot($method, $fields) { $model = $this->setup->getModel(); define('CIVICRM_UF', $model->cms); // Set the Locale (required by CRM_Core_Config) global $tsLocale; $tsLocale = 'en_US'; // CRM-16801 This validates that lang is valid by looking in $langs. // NB: the variable is initial a $_REQUEST for the initial page reload, // then becomes a $_POST when the installation form is submitted. $langs = $model->getField('lang', 'options'); if (array_key_exists('lang', $fields)) { $model->lang = $fields['lang']; } if ($model->lang and isset($langs[$model->lang])) { $tsLocale = $model->lang; } \CRM_Core_Config::singleton(FALSE); $GLOBALS['civicrm_default_error_scope'] = NULL; // The translation files are in the parent directory (l10n) \CRM_Core_I18n::singleton(); $this->setup->getDispatcher()->dispatch('civi.setupui.boot', new UIBootEvent($this, $method, $fields)); }
[ "protected", "function", "boot", "(", "$", "method", ",", "$", "fields", ")", "{", "$", "model", "=", "$", "this", "->", "setup", "->", "getModel", "(", ")", ";", "define", "(", "'CIVICRM_UF'", ",", "$", "model", "->", "cms", ")", ";", "// Set the Lo...
Partially bootstrap Civi services (such as localization).
[ "Partially", "bootstrap", "Civi", "services", "(", "such", "as", "localization", ")", "." ]
train
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/UI/SetupController.php#L148-L175
civicrm/civicrm-setup
src/Setup/UI/SetupController.php
SetupController.parseAction
protected function parseAction($fields, $default) { if (empty($fields[self::PREFIX]['action'])) { return $default; } else { if (is_array($fields[self::PREFIX]['action'])) { foreach ($fields[self::PREFIX]['action'] as $name => $label) { return $name; } } elseif (is_string($fields[self::PREFIX]['action'])) { return $fields[self::PREFIX]['action']; } } return NULL; }
php
protected function parseAction($fields, $default) { if (empty($fields[self::PREFIX]['action'])) { return $default; } else { if (is_array($fields[self::PREFIX]['action'])) { foreach ($fields[self::PREFIX]['action'] as $name => $label) { return $name; } } elseif (is_string($fields[self::PREFIX]['action'])) { return $fields[self::PREFIX]['action']; } } return NULL; }
[ "protected", "function", "parseAction", "(", "$", "fields", ",", "$", "default", ")", "{", "if", "(", "empty", "(", "$", "fields", "[", "self", "::", "PREFIX", "]", "[", "'action'", "]", ")", ")", "{", "return", "$", "default", ";", "}", "else", "{...
Given an HTML submission, determine the name. @param array $fields HTTP inputs -- e.g. with a form element like this: `<input type="submit" name="civisetup[action][Foo]" value="Do the foo">` @return string The name of the action. Ex: 'Foo'.
[ "Given", "an", "HTML", "submission", "determine", "the", "name", "." ]
train
https://github.com/civicrm/civicrm-setup/blob/556b312faf78781c85c4fc4ae6c1c3b658da9e09/src/Setup/UI/SetupController.php#L232-L247
CampaignChain/core
Wizard/InstallWizard.php
InstallWizard.getSortedSteps
private function getSortedSteps() { $sortedSteps = array(); ksort($this->steps); foreach ($this->steps as $steps) { $sortedSteps = array_merge($sortedSteps, $steps); } return $sortedSteps; }
php
private function getSortedSteps() { $sortedSteps = array(); ksort($this->steps); foreach ($this->steps as $steps) { $sortedSteps = array_merge($sortedSteps, $steps); } return $sortedSteps; }
[ "private", "function", "getSortedSteps", "(", ")", "{", "$", "sortedSteps", "=", "array", "(", ")", ";", "ksort", "(", "$", "this", "->", "steps", ")", ";", "foreach", "(", "$", "this", "->", "steps", "as", "$", "steps", ")", "{", "$", "sortedSteps",...
Sort routers by priority. The lowest number is the highest priority @return StepInterface[]
[ "Sort", "routers", "by", "priority", ".", "The", "lowest", "number", "is", "the", "highest", "priority" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Wizard/InstallWizard.php#L71-L81
notthatbad/silverstripe-rest-api
code/serializers/SerializerFactory.php
SerializerFactory.create
public static function create($mimeType='application/json') { $availableSerializers = \ClassInfo::implementorsOf('Ntb\RestAPI\IRestSerializer'); foreach($availableSerializers as $serializer) { /** @var IRestSerializer $instance */ $instance = new $serializer(); if($instance->active() && $instance->contentType() === $mimeType) { return $instance; } } throw new RestUserException("Requested Accept '$mimeType' not supported", 404); }
php
public static function create($mimeType='application/json') { $availableSerializers = \ClassInfo::implementorsOf('Ntb\RestAPI\IRestSerializer'); foreach($availableSerializers as $serializer) { /** @var IRestSerializer $instance */ $instance = new $serializer(); if($instance->active() && $instance->contentType() === $mimeType) { return $instance; } } throw new RestUserException("Requested Accept '$mimeType' not supported", 404); }
[ "public", "static", "function", "create", "(", "$", "mimeType", "=", "'application/json'", ")", "{", "$", "availableSerializers", "=", "\\", "ClassInfo", "::", "implementorsOf", "(", "'Ntb\\RestAPI\\IRestSerializer'", ")", ";", "foreach", "(", "$", "availableSeriali...
Returns a new instance of a serializer depending on the given type. @param string $mimeType the serializer type; Default: application/json @return IRestSerializer an instance of a serializer @throws RestUserException
[ "Returns", "a", "new", "instance", "of", "a", "serializer", "depending", "on", "the", "given", "type", "." ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/serializers/SerializerFactory.php#L24-L34
notthatbad/silverstripe-rest-api
code/serializers/SerializerFactory.php
SerializerFactory.create_from_request
public static function create_from_request($request) { if($type = $request->getVar('accept')) { try { if(array_key_exists($type, self::$lookup)) { return self::create(self::$lookup[$type]); } } catch(\Exception $e) {} } $types = $request->getAcceptMimetypes(); foreach($types as $type) { try { return self::create($type); } catch(RestUserException $e) {} } return self::create(); }
php
public static function create_from_request($request) { if($type = $request->getVar('accept')) { try { if(array_key_exists($type, self::$lookup)) { return self::create(self::$lookup[$type]); } } catch(\Exception $e) {} } $types = $request->getAcceptMimetypes(); foreach($types as $type) { try { return self::create($type); } catch(RestUserException $e) {} } return self::create(); }
[ "public", "static", "function", "create_from_request", "(", "$", "request", ")", "{", "if", "(", "$", "type", "=", "$", "request", "->", "getVar", "(", "'accept'", ")", ")", "{", "try", "{", "if", "(", "array_key_exists", "(", "$", "type", ",", "self",...
Determines the correct serializer from an incoming request. @param \SS_HTTPRequest $request the request object @return IRestSerializer a new instance of a serializer which fits the request best @throws RestUserException
[ "Determines", "the", "correct", "serializer", "from", "an", "incoming", "request", "." ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/serializers/SerializerFactory.php#L43-L58
diemuzi/mp3
src/Mp3/Service/Factory/IndexFactory.php
IndexFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { /** * @var array $config */ $config = $serviceLocator->get('config'); /** * @var \Zend\View\HelperPluginManager $serverUrl */ $serverUrl = $serviceLocator->get('ViewHelperManager'); /** * @var \Zend\Mvc\I18n\Translator $translator */ $translator = $serviceLocator->get('translator'); return new Index( $config, $serverUrl, $translator ); }
php
public function createService(ServiceLocatorInterface $serviceLocator) { /** * @var array $config */ $config = $serviceLocator->get('config'); /** * @var \Zend\View\HelperPluginManager $serverUrl */ $serverUrl = $serviceLocator->get('ViewHelperManager'); /** * @var \Zend\Mvc\I18n\Translator $translator */ $translator = $serviceLocator->get('translator'); return new Index( $config, $serverUrl, $translator ); }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "/**\n * @var array $config\n */", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'config'", ")", ";", "/**\n * @var \\Zend\\View\\...
@param ServiceLocatorInterface $serviceLocator @return Index
[ "@param", "ServiceLocatorInterface", "$serviceLocator" ]
train
https://github.com/diemuzi/mp3/blob/2093883ccdb473ab519a0d6f06bf6ee66e8c4a5f/src/Mp3/Service/Factory/IndexFactory.php#L29-L51
prooph/link-process-manager
src/Api/Factory/TaskFactory.php
TaskFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $taskResource = new Task(); $taskResource->setTaskFinder($serviceLocator->getServiceLocator()->get(TaskFinder::class)); return $taskResource; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $taskResource = new Task(); $taskResource->setTaskFinder($serviceLocator->getServiceLocator()->get(TaskFinder::class)); return $taskResource; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "taskResource", "=", "new", "Task", "(", ")", ";", "$", "taskResource", "->", "setTaskFinder", "(", "$", "serviceLocator", "->", "getServiceLocator", "(", ...
Create service @param ServiceLocatorInterface $serviceLocator @return mixed
[ "Create", "service" ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Api/Factory/TaskFactory.php#L31-L36
prooph/link-process-manager
src/Infrastructure/DbalProcessLogger.php
DbalProcessLogger.logProcessStartedByMessage
public function logProcessStartedByMessage(ProcessId $processId, $startMessageName) { $data = [ 'start_message' => $startMessageName, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $data['status'] = self::STATUS_RUNNING; $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
php
public function logProcessStartedByMessage(ProcessId $processId, $startMessageName) { $data = [ 'start_message' => $startMessageName, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $data['status'] = self::STATUS_RUNNING; $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
[ "public", "function", "logProcessStartedByMessage", "(", "ProcessId", "$", "processId", ",", "$", "startMessageName", ")", "{", "$", "data", "=", "[", "'start_message'", "=>", "$", "startMessageName", ",", "]", ";", "$", "entry", "=", "$", "this", "->", "loa...
Create or update entry for process with the start message name. If a new process needs to be created set status to "running". @param string $startMessageName @param ProcessId $processId @return void
[ "Create", "or", "update", "entry", "for", "process", "with", "the", "start", "message", "name", ".", "If", "a", "new", "process", "needs", "to", "be", "created", "set", "status", "to", "running", "." ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Infrastructure/DbalProcessLogger.php#L57-L72
prooph/link-process-manager
src/Infrastructure/DbalProcessLogger.php
DbalProcessLogger.logProcessStartedAt
public function logProcessStartedAt(ProcessId $processId, \DateTimeImmutable $startedAt) { $data = [ 'started_at' => $startedAt->format(\DateTime::ISO8601), ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $data['status'] = self::STATUS_RUNNING; $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
php
public function logProcessStartedAt(ProcessId $processId, \DateTimeImmutable $startedAt) { $data = [ 'started_at' => $startedAt->format(\DateTime::ISO8601), ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $data['status'] = self::STATUS_RUNNING; $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
[ "public", "function", "logProcessStartedAt", "(", "ProcessId", "$", "processId", ",", "\\", "DateTimeImmutable", "$", "startedAt", ")", "{", "$", "data", "=", "[", "'started_at'", "=>", "$", "startedAt", "->", "format", "(", "\\", "DateTime", "::", "ISO8601", ...
Create or update entry for process with the started at information. If a new process needs to be created set status to "running". @param ProcessId $processId @param \DateTimeImmutable $startedAt @return void
[ "Create", "or", "update", "entry", "for", "process", "with", "the", "started", "at", "information", ".", "If", "a", "new", "process", "needs", "to", "be", "created", "set", "status", "to", "running", "." ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Infrastructure/DbalProcessLogger.php#L82-L97
prooph/link-process-manager
src/Infrastructure/DbalProcessLogger.php
DbalProcessLogger.logProcessSucceed
public function logProcessSucceed(ProcessId $processId, \DateTimeImmutable $finishedAt) { $data = [ 'finished_at' => $finishedAt->format(\DateTime::ISO8601), 'status' => self::STATUS_SUCCEED, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
php
public function logProcessSucceed(ProcessId $processId, \DateTimeImmutable $finishedAt) { $data = [ 'finished_at' => $finishedAt->format(\DateTime::ISO8601), 'status' => self::STATUS_SUCCEED, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
[ "public", "function", "logProcessSucceed", "(", "ProcessId", "$", "processId", ",", "\\", "DateTimeImmutable", "$", "finishedAt", ")", "{", "$", "data", "=", "[", "'finished_at'", "=>", "$", "finishedAt", "->", "format", "(", "\\", "DateTime", "::", "ISO8601",...
Create or update entry for process with finished at information. Set status to "succeed". @param ProcessId $processId @param \DateTimeImmutable $finishedAt @return void
[ "Create", "or", "update", "entry", "for", "process", "with", "finished", "at", "information", ".", "Set", "status", "to", "succeed", "." ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Infrastructure/DbalProcessLogger.php#L107-L121
prooph/link-process-manager
src/Infrastructure/DbalProcessLogger.php
DbalProcessLogger.logProcessFailed
public function logProcessFailed(ProcessId $processId, \DateTimeImmutable $finishedAt) { $data = [ 'finished_at' => $finishedAt->format(\DateTime::ISO8601), 'status' => self::STATUS_FAILED, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
php
public function logProcessFailed(ProcessId $processId, \DateTimeImmutable $finishedAt) { $data = [ 'finished_at' => $finishedAt->format(\DateTime::ISO8601), 'status' => self::STATUS_FAILED, ]; $entry = $this->loadProcessEntryIfExists($processId); if (is_null($entry)) { $this->insertNewEntry($processId, $data); } else { $this->updateEntry($processId, $data); } }
[ "public", "function", "logProcessFailed", "(", "ProcessId", "$", "processId", ",", "\\", "DateTimeImmutable", "$", "finishedAt", ")", "{", "$", "data", "=", "[", "'finished_at'", "=>", "$", "finishedAt", "->", "format", "(", "\\", "DateTime", "::", "ISO8601", ...
Create or update entry for process with finished at information. Set status to "failed". @param ProcessId $processId @param \DateTimeImmutable $finishedAt @return void
[ "Create", "or", "update", "entry", "for", "process", "with", "finished", "at", "information", ".", "Set", "status", "to", "failed", "." ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Infrastructure/DbalProcessLogger.php#L131-L145
scaytrase/symfony-sms-interface
src/ScayTrase/SmsDeliveryBundle/DependencyInjection/Compiler/TransportCompilerPass.php
TransportCompilerPass.process
public function process(ContainerBuilder $container) { if (!$container->hasDefinition('sms_delivery.sender')) { return; } $sender = $container->getDefinition('sms_delivery.sender'); $transport = $container->getDefinition($container->getParameter('sms_delivery.transport')); if ( $container->hasParameter('sms_delivery.delivery_recipient') && $container->getParameter('sms_delivery.delivery_recipient') !== null ) { $overrideTransport = new Definition('ScayTrase\SmsDeliveryBundle\Transport\OverrideRecipientTransport'); $overrideTransport->setArguments( array( $transport, $container->getParameter('sms_delivery.delivery_recipient') ) ); $sender->replaceArgument(0, $overrideTransport); } else { $sender->replaceArgument(0, $transport); } }
php
public function process(ContainerBuilder $container) { if (!$container->hasDefinition('sms_delivery.sender')) { return; } $sender = $container->getDefinition('sms_delivery.sender'); $transport = $container->getDefinition($container->getParameter('sms_delivery.transport')); if ( $container->hasParameter('sms_delivery.delivery_recipient') && $container->getParameter('sms_delivery.delivery_recipient') !== null ) { $overrideTransport = new Definition('ScayTrase\SmsDeliveryBundle\Transport\OverrideRecipientTransport'); $overrideTransport->setArguments( array( $transport, $container->getParameter('sms_delivery.delivery_recipient') ) ); $sender->replaceArgument(0, $overrideTransport); } else { $sender->replaceArgument(0, $transport); } }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "!", "$", "container", "->", "hasDefinition", "(", "'sms_delivery.sender'", ")", ")", "{", "return", ";", "}", "$", "sender", "=", "$", "container", "->", "get...
You can modify the container here before it is dumped to PHP code. @param ContainerBuilder $container @api
[ "You", "can", "modify", "the", "container", "here", "before", "it", "is", "dumped", "to", "PHP", "code", "." ]
train
https://github.com/scaytrase/symfony-sms-interface/blob/5645a47652e6511b51f8fcdfba747a167dad0e2c/src/ScayTrase/SmsDeliveryBundle/DependencyInjection/Compiler/TransportCompilerPass.php#L25-L49
vinterskogen/laravel-uploaded-image
src/Concerns/HandlesImage.php
HandlesImage.fitSquare
public function fitSquare($size) { $this->toggleModified(); $this->getInterventionImage()->fit($size, $size); return $this; }
php
public function fitSquare($size) { $this->toggleModified(); $this->getInterventionImage()->fit($size, $size); return $this; }
[ "public", "function", "fitSquare", "(", "$", "size", ")", "{", "$", "this", "->", "toggleModified", "(", ")", ";", "$", "this", "->", "getInterventionImage", "(", ")", "->", "fit", "(", "$", "size", ",", "$", "size", ")", ";", "return", "$", "this", ...
Resize and crop the uploaded image to fit a square with given side size (in pixels), keeping aspect ratio. @param int $size @return $this
[ "Resize", "and", "crop", "the", "uploaded", "image", "to", "fit", "a", "square", "with", "given", "side", "size", "(", "in", "pixels", ")", "keeping", "aspect", "ratio", "." ]
train
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/Concerns/HandlesImage.php#L68-L75
vinterskogen/laravel-uploaded-image
src/Concerns/HandlesImage.php
HandlesImage.fit
public function fit($width, $height) { $this->toggleModified(); $this->getInterventionImage()->fit($width, $height); return $this; }
php
public function fit($width, $height) { $this->toggleModified(); $this->getInterventionImage()->fit($width, $height); return $this; }
[ "public", "function", "fit", "(", "$", "width", ",", "$", "height", ")", "{", "$", "this", "->", "toggleModified", "(", ")", ";", "$", "this", "->", "getInterventionImage", "(", ")", "->", "fit", "(", "$", "width", ",", "$", "height", ")", ";", "re...
Resize and crop the uploaded image to fit a given dimensions (in pixels), keeping aspect ratio. @param int $width @param int $height @return $this
[ "Resize", "and", "crop", "the", "uploaded", "image", "to", "fit", "a", "given", "dimensions", "(", "in", "pixels", ")", "keeping", "aspect", "ratio", "." ]
train
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/Concerns/HandlesImage.php#L85-L92
vinterskogen/laravel-uploaded-image
src/Concerns/HandlesImage.php
HandlesImage.crop
public function crop($width, $height, $x = null, $y = null) { $this->toggleModified(); $this->getInterventionImage()->crop($width, $height, $x, $y); return $this; }
php
public function crop($width, $height, $x = null, $y = null) { $this->toggleModified(); $this->getInterventionImage()->crop($width, $height, $x, $y); return $this; }
[ "public", "function", "crop", "(", "$", "width", ",", "$", "height", ",", "$", "x", "=", "null", ",", "$", "y", "=", "null", ")", "{", "$", "this", "->", "toggleModified", "(", ")", ";", "$", "this", "->", "getInterventionImage", "(", ")", "->", ...
Crop uploaded image to given width and height (in pixels). @param int $width @param int $height @param int|null $x @param int|null $y @return $this
[ "Crop", "uploaded", "image", "to", "given", "width", "and", "height", "(", "in", "pixels", ")", "." ]
train
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/Concerns/HandlesImage.php#L103-L110
vinterskogen/laravel-uploaded-image
src/Concerns/HandlesImage.php
HandlesImage.encode
public function encode($format, $quality = null) { $this->toggleModified(); $this->getInterventionImage()->encode($format, $quality); return $this; }
php
public function encode($format, $quality = null) { $this->toggleModified(); $this->getInterventionImage()->encode($format, $quality); return $this; }
[ "public", "function", "encode", "(", "$", "format", ",", "$", "quality", "=", "null", ")", "{", "$", "this", "->", "toggleModified", "(", ")", ";", "$", "this", "->", "getInterventionImage", "(", ")", "->", "encode", "(", "$", "format", ",", "$", "qu...
Encode uploaded image to given format and quality. @param mixed $format @param int|null $quality @return $this
[ "Encode", "uploaded", "image", "to", "given", "format", "and", "quality", "." ]
train
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/Concerns/HandlesImage.php#L119-L126
vinterskogen/laravel-uploaded-image
src/Concerns/HandlesImage.php
HandlesImage.scale
public function scale($percentage) { $this->validatePercentageValue($percentage); $this->toggleModified(); $percentage = floatval($percentage); $width = $this->width() / 100 * $percentage; $height = $this->height() / 100 * $percentage; $this->getInterventionImage()->resize($width, $height); return $this; }
php
public function scale($percentage) { $this->validatePercentageValue($percentage); $this->toggleModified(); $percentage = floatval($percentage); $width = $this->width() / 100 * $percentage; $height = $this->height() / 100 * $percentage; $this->getInterventionImage()->resize($width, $height); return $this; }
[ "public", "function", "scale", "(", "$", "percentage", ")", "{", "$", "this", "->", "validatePercentageValue", "(", "$", "percentage", ")", ";", "$", "this", "->", "toggleModified", "(", ")", ";", "$", "percentage", "=", "floatval", "(", "$", "percentage",...
Scale the uploaded image size using given percentage. @param int|float $percentage @return $this
[ "Scale", "the", "uploaded", "image", "size", "using", "given", "percentage", "." ]
train
https://github.com/vinterskogen/laravel-uploaded-image/blob/1b2c06ce3386622ac9360cc7895c5e5db0211797/src/Concerns/HandlesImage.php#L134-L147
MW-Peachy/Peachy
Plugins/Email.php
Email.addTarget
public function addTarget( $toEmail, $toName = null ) { if( !is_null( $toName ) ) { $this->mTo[$toName] = $toEmail; } else { $this->mTo[] = $toEmail; } }
php
public function addTarget( $toEmail, $toName = null ) { if( !is_null( $toName ) ) { $this->mTo[$toName] = $toEmail; } else { $this->mTo[] = $toEmail; } }
[ "public", "function", "addTarget", "(", "$", "toEmail", ",", "$", "toName", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "toName", ")", ")", "{", "$", "this", "->", "mTo", "[", "$", "toName", "]", "=", "$", "toEmail", ";", "}", "...
Adds another email to the To: field. @param string $toEmail Email address of recipient @param string $toName Name of recipient. Default null
[ "Adds", "another", "email", "to", "the", "To", ":", "field", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Email.php#L91-L97
MW-Peachy/Peachy
Plugins/Email.php
Email.addCC
public function addCC( $ccEmail, $ccName = null ) { if( !is_null( $ccName ) ) { $this->mCC[$ccName] = $ccEmail; } else { $this->mCC[] = $ccEmail; } }
php
public function addCC( $ccEmail, $ccName = null ) { if( !is_null( $ccName ) ) { $this->mCC[$ccName] = $ccEmail; } else { $this->mCC[] = $ccEmail; } }
[ "public", "function", "addCC", "(", "$", "ccEmail", ",", "$", "ccName", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "ccName", ")", ")", "{", "$", "this", "->", "mCC", "[", "$", "ccName", "]", "=", "$", "ccEmail", ";", "}", "else...
Adds another email to the CC: field. @param string $ccEmail Email address of cc @param string $ccName Name of cc. Default null
[ "Adds", "another", "email", "to", "the", "CC", ":", "field", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Email.php#L104-L110
MW-Peachy/Peachy
Plugins/Email.php
Email.addBCC
public function addBCC( $bccEmail, $bccName = null ) { if( !is_null( $bccName ) ) { $this->mBCC[$bccName] = $bccEmail; } else { $this->mBCC[] = $bccEmail; } }
php
public function addBCC( $bccEmail, $bccName = null ) { if( !is_null( $bccName ) ) { $this->mBCC[$bccName] = $bccEmail; } else { $this->mBCC[] = $bccEmail; } }
[ "public", "function", "addBCC", "(", "$", "bccEmail", ",", "$", "bccName", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "bccName", ")", ")", "{", "$", "this", "->", "mBCC", "[", "$", "bccName", "]", "=", "$", "bccEmail", ";", "}", ...
Adds another email to the BCC: field. @param string $bccEmail Email address of bcc @param string $bccName Name of bcc. Default null
[ "Adds", "another", "email", "to", "the", "BCC", ":", "field", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Email.php#L117-L123
MW-Peachy/Peachy
Plugins/Email.php
Email.addReplyTo
public function addReplyTo( $rtEmail, $rtName = null ) { if( !is_null( $rtName ) ) { $this->mRT[$rtName] = $rtEmail; } else { $this->mRT[] = $rtEmail; } }
php
public function addReplyTo( $rtEmail, $rtName = null ) { if( !is_null( $rtName ) ) { $this->mRT[$rtName] = $rtEmail; } else { $this->mRT[] = $rtEmail; } }
[ "public", "function", "addReplyTo", "(", "$", "rtEmail", ",", "$", "rtName", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "rtName", ")", ")", "{", "$", "this", "->", "mRT", "[", "$", "rtName", "]", "=", "$", "rtEmail", ";", "}", ...
Adds another email to the Reply-to: field. @param string $rtEmail Email address to reply to @param string $rtName Name to reply to. Default null
[ "Adds", "another", "email", "to", "the", "Reply", "-", "to", ":", "field", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Email.php#L130-L136
MW-Peachy/Peachy
Plugins/Email.php
Email.send
public function send() { $msg = array(); $msg_to = array(); foreach( $this->mTo as $name => $target ){ if( !is_string( $name ) ) { $msg_to[] = $target; } else { $msg_to[] = "$name <$target>"; } } $msg['to'] = implode( ', ', $msg_to ); $msg_from = array(); foreach( $this->mFrom as $name => $target ){ if( !is_string( $name ) ) { $msg_from[] = $target; } else { $msg_from[] = "$name <$target>"; } } $msg['from'] = null; if( count( $msg_from ) > 0 ) $msg['from'] = "From: " . implode( ', ', $msg_from ); $msg_cc = array(); foreach( $this->mCC as $name => $target ){ if( !is_string( $name ) ) { $msg_cc[] = $target; } else { $msg_cc[] = "$name <$target>"; } } $msg['cc'] = null; if( count( $msg_cc ) > 0 ) $msg['cc'] = "CC: " . implode( ', ', $msg_cc ); $msg_bcc = array(); foreach( $this->mBCC as $name => $target ){ if( !is_string( $name ) ) { $msg_bcc[] = $target; } else { $msg_bcc[] = "$name"; } } $msg['bcc'] = null; if( count( $msg_bcc ) > 0 ) $msg['bcc'] = "BCC: " . implode( ', ', $msg_bcc ); $msg_rt = array(); foreach( $this->mRT as $name => $target ){ if( !is_string( $name ) ) { $msg_rt[] = $target; } else { $msg_rt[] = "$name <$target>"; } } $msg['rt'] = null; if( count( $msg_rt ) > 0 ) $msg['rt'] = "Reply-to: " . implode( ', ', $msg_rt ); $msg['subject'] = $this->mSubject; $msg['message'] = $this->mMessage; $msg['version'] = 'X-Mailer: PHP/' . phpversion(); $msg['headers'] = $msg['from'] . "\r\n"; if( !is_null( $msg['rt'] ) ) $msg['headers'] .= $msg['rt'] . "\r\n"; if( !is_null( $msg['cc'] ) ) $msg['headers'] .= $msg['cc'] . "\r\n"; if( !is_null( $msg['bcc'] ) ) $msg['headers'] .= $msg['bcc'] . "\r\n"; $msg['headers'] .= $msg['version']; $result = mail( $msg['to'], $msg['subject'], $msg['message'], $msg['headers'] ); return $result; }
php
public function send() { $msg = array(); $msg_to = array(); foreach( $this->mTo as $name => $target ){ if( !is_string( $name ) ) { $msg_to[] = $target; } else { $msg_to[] = "$name <$target>"; } } $msg['to'] = implode( ', ', $msg_to ); $msg_from = array(); foreach( $this->mFrom as $name => $target ){ if( !is_string( $name ) ) { $msg_from[] = $target; } else { $msg_from[] = "$name <$target>"; } } $msg['from'] = null; if( count( $msg_from ) > 0 ) $msg['from'] = "From: " . implode( ', ', $msg_from ); $msg_cc = array(); foreach( $this->mCC as $name => $target ){ if( !is_string( $name ) ) { $msg_cc[] = $target; } else { $msg_cc[] = "$name <$target>"; } } $msg['cc'] = null; if( count( $msg_cc ) > 0 ) $msg['cc'] = "CC: " . implode( ', ', $msg_cc ); $msg_bcc = array(); foreach( $this->mBCC as $name => $target ){ if( !is_string( $name ) ) { $msg_bcc[] = $target; } else { $msg_bcc[] = "$name"; } } $msg['bcc'] = null; if( count( $msg_bcc ) > 0 ) $msg['bcc'] = "BCC: " . implode( ', ', $msg_bcc ); $msg_rt = array(); foreach( $this->mRT as $name => $target ){ if( !is_string( $name ) ) { $msg_rt[] = $target; } else { $msg_rt[] = "$name <$target>"; } } $msg['rt'] = null; if( count( $msg_rt ) > 0 ) $msg['rt'] = "Reply-to: " . implode( ', ', $msg_rt ); $msg['subject'] = $this->mSubject; $msg['message'] = $this->mMessage; $msg['version'] = 'X-Mailer: PHP/' . phpversion(); $msg['headers'] = $msg['from'] . "\r\n"; if( !is_null( $msg['rt'] ) ) $msg['headers'] .= $msg['rt'] . "\r\n"; if( !is_null( $msg['cc'] ) ) $msg['headers'] .= $msg['cc'] . "\r\n"; if( !is_null( $msg['bcc'] ) ) $msg['headers'] .= $msg['bcc'] . "\r\n"; $msg['headers'] .= $msg['version']; $result = mail( $msg['to'], $msg['subject'], $msg['message'], $msg['headers'] ); return $result; }
[ "public", "function", "send", "(", ")", "{", "$", "msg", "=", "array", "(", ")", ";", "$", "msg_to", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "mTo", "as", "$", "name", "=>", "$", "target", ")", "{", "if", "(", "!", "is_...
Sends the email.
[ "Sends", "the", "email", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Email.php#L141-L211
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getDBInstance
public function getDBInstance() { if ($this->database === null) { $this->database = new MySQLDBImpl($this->config); } return $this->database; }
php
public function getDBInstance() { if ($this->database === null) { $this->database = new MySQLDBImpl($this->config); } return $this->database; }
[ "public", "function", "getDBInstance", "(", ")", "{", "if", "(", "$", "this", "->", "database", "===", "null", ")", "{", "$", "this", "->", "database", "=", "new", "MySQLDBImpl", "(", "$", "this", "->", "config", ")", ";", "}", "return", "$", "this",...
This will return a DB. The same from time to time @return DB
[ "This", "will", "return", "a", "DB", ".", "The", "same", "from", "time", "to", "time" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L81-L88
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getAJAXServerInstance
public function getAJAXServerInstance() { if ($this->ajaxServer === null) { $this->ajaxServer = new ServerImpl($this); } return $this->ajaxServer; }
php
public function getAJAXServerInstance() { if ($this->ajaxServer === null) { $this->ajaxServer = new ServerImpl($this); } return $this->ajaxServer; }
[ "public", "function", "getAJAXServerInstance", "(", ")", "{", "if", "(", "$", "this", "->", "ajaxServer", "===", "null", ")", "{", "$", "this", "->", "ajaxServer", "=", "new", "ServerImpl", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", ...
This will return an ajax register, and reuse it from time to time @return ServerImpl
[ "This", "will", "return", "an", "ajax", "register", "and", "reuse", "it", "from", "time", "to", "time" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L95-L101
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getPageOrderInstance
public function getPageOrderInstance() { if ($this->pageOrder === null) { $this->pageOrder = new PageOrderImpl($this); } return $this->pageOrder; }
php
public function getPageOrderInstance() { if ($this->pageOrder === null) { $this->pageOrder = new PageOrderImpl($this); } return $this->pageOrder; }
[ "public", "function", "getPageOrderInstance", "(", ")", "{", "if", "(", "$", "this", "->", "pageOrder", "===", "null", ")", "{", "$", "this", "->", "pageOrder", "=", "new", "PageOrderImpl", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", ...
This will return an instance of PageOrder, and reuse it. @return PageOrder
[ "This", "will", "return", "an", "instance", "of", "PageOrder", "and", "reuse", "it", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L107-L113
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getCurrentPageStrategyInstance
public function getCurrentPageStrategyInstance() { if ($this->currentPageStrategy === null) { $this->currentPageStrategy = new CurrentPageStrategyImpl($this); } return $this->currentPageStrategy; }
php
public function getCurrentPageStrategyInstance() { if ($this->currentPageStrategy === null) { $this->currentPageStrategy = new CurrentPageStrategyImpl($this); } return $this->currentPageStrategy; }
[ "public", "function", "getCurrentPageStrategyInstance", "(", ")", "{", "if", "(", "$", "this", "->", "currentPageStrategy", "===", "null", ")", "{", "$", "this", "->", "currentPageStrategy", "=", "new", "CurrentPageStrategyImpl", "(", "$", "this", ")", ";", "}...
This will return an instance of CurrentPageStrategy, and reuse it. @return CurrentPageStrategy
[ "This", "will", "return", "an", "instance", "of", "CurrentPageStrategy", "and", "reuse", "it", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L119-L125
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getUserLibraryInstance
public function getUserLibraryInstance() { if ($this->userLibrary === null) { $this->userLibrary = new UserLibraryImpl($this); } return $this->userLibrary; }
php
public function getUserLibraryInstance() { if ($this->userLibrary === null) { $this->userLibrary = new UserLibraryImpl($this); } return $this->userLibrary; }
[ "public", "function", "getUserLibraryInstance", "(", ")", "{", "if", "(", "$", "this", "->", "userLibrary", "===", "null", ")", "{", "$", "this", "->", "userLibrary", "=", "new", "UserLibraryImpl", "(", "$", "this", ")", ";", "}", "return", "$", "this", ...
Will create and reuse an instance of UserLibrary @return UserLibrary
[ "Will", "create", "and", "reuse", "an", "instance", "of", "UserLibrary" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L141-L147
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getDefaultPageLibraryInstance
public function getDefaultPageLibraryInstance() { if ($this->defaultPageLibrary === null) { $this->defaultPageLibrary = new DefaultPageLibraryImpl($this); } return $this->defaultPageLibrary; }
php
public function getDefaultPageLibraryInstance() { if ($this->defaultPageLibrary === null) { $this->defaultPageLibrary = new DefaultPageLibraryImpl($this); } return $this->defaultPageLibrary; }
[ "public", "function", "getDefaultPageLibraryInstance", "(", ")", "{", "if", "(", "$", "this", "->", "defaultPageLibrary", "===", "null", ")", "{", "$", "this", "->", "defaultPageLibrary", "=", "new", "DefaultPageLibraryImpl", "(", "$", "this", ")", ";", "}", ...
Will create and reuse an instance of DefaultPageLibrary @return DefaultPageLibrary
[ "Will", "create", "and", "reuse", "an", "instance", "of", "DefaultPageLibrary" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L154-L161
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getCacheControlInstance
public function getCacheControlInstance() { if ($this->cacheControl == null) { $this->cacheControl = new CacheControlImpl($this->getSiteInstance(), $this->getCurrentPageStrategyInstance()); } return $this->cacheControl; }
php
public function getCacheControlInstance() { if ($this->cacheControl == null) { $this->cacheControl = new CacheControlImpl($this->getSiteInstance(), $this->getCurrentPageStrategyInstance()); } return $this->cacheControl; }
[ "public", "function", "getCacheControlInstance", "(", ")", "{", "if", "(", "$", "this", "->", "cacheControl", "==", "null", ")", "{", "$", "this", "->", "cacheControl", "=", "new", "CacheControlImpl", "(", "$", "this", "->", "getSiteInstance", "(", ")", ",...
Will create and reuse an instance of CacheControl @return CacheControl
[ "Will", "create", "and", "reuse", "an", "instance", "of", "CacheControl" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L168-L174
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getUpdaterInstance
public function getUpdaterInstance() { if ($this->updater == null) { $this->updater = new GitUpdaterImpl($this, $this->getConfigInstance()->getRootPath()); } return $this->updater; }
php
public function getUpdaterInstance() { if ($this->updater == null) { $this->updater = new GitUpdaterImpl($this, $this->getConfigInstance()->getRootPath()); } return $this->updater; }
[ "public", "function", "getUpdaterInstance", "(", ")", "{", "if", "(", "$", "this", "->", "updater", "==", "null", ")", "{", "$", "this", "->", "updater", "=", "new", "GitUpdaterImpl", "(", "$", "this", ",", "$", "this", "->", "getConfigInstance", "(", ...
Will create and reuse an instance of Updater @return mixed
[ "Will", "create", "and", "reuse", "an", "instance", "of", "Updater" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L180-L186
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getSiteInstance
public function getSiteInstance() { return $this->site == null ? $this->site = new SiteImpl($this) : $this->site; }
php
public function getSiteInstance() { return $this->site == null ? $this->site = new SiteImpl($this) : $this->site; }
[ "public", "function", "getSiteInstance", "(", ")", "{", "return", "$", "this", "->", "site", "==", "null", "?", "$", "this", "->", "site", "=", "new", "SiteImpl", "(", "$", "this", ")", ":", "$", "this", "->", "site", ";", "}" ]
Will create and reuse an instance of Variables. These should reflect the site scoped variables. @return Site
[ "Will", "create", "and", "reuse", "an", "instance", "of", "Variables", ".", "These", "should", "reflect", "the", "site", "scoped", "variables", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L193-L196
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getFileLibraryInstance
public function getFileLibraryInstance() { return $this->fileLibrary == null ? $this->fileLibrary = new FileLibraryImpl($this, new FolderImpl($this->getConfigInstance()->getRootPath() . "/files/")) : $this->fileLibrary; }
php
public function getFileLibraryInstance() { return $this->fileLibrary == null ? $this->fileLibrary = new FileLibraryImpl($this, new FolderImpl($this->getConfigInstance()->getRootPath() . "/files/")) : $this->fileLibrary; }
[ "public", "function", "getFileLibraryInstance", "(", ")", "{", "return", "$", "this", "->", "fileLibrary", "==", "null", "?", "$", "this", "->", "fileLibrary", "=", "new", "FileLibraryImpl", "(", "$", "this", ",", "new", "FolderImpl", "(", "$", "this", "->...
Will create and reuse an instance of FileLibrary. @return FileLibrary
[ "Will", "create", "and", "reuse", "an", "instance", "of", "FileLibrary", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L202-L205
budde377/Part
lib/BackendSingletonContainerImpl.php
BackendSingletonContainerImpl.getTypeHandlerLibraryInstance
public function getTypeHandlerLibraryInstance() { return $this->typeHandlerLib == null ? $this->typeHandlerLib = new TypeHandlerLibraryImpl($this) : $this->typeHandlerLib; }
php
public function getTypeHandlerLibraryInstance() { return $this->typeHandlerLib == null ? $this->typeHandlerLib = new TypeHandlerLibraryImpl($this) : $this->typeHandlerLib; }
[ "public", "function", "getTypeHandlerLibraryInstance", "(", ")", "{", "return", "$", "this", "->", "typeHandlerLib", "==", "null", "?", "$", "this", "->", "typeHandlerLib", "=", "new", "TypeHandlerLibraryImpl", "(", "$", "this", ")", ":", "$", "this", "->", ...
Will create and reuse instance of TypeHandlerLibrary. @return TypeHandlerLibrary
[ "Will", "create", "and", "reuse", "instance", "of", "TypeHandlerLibrary", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/BackendSingletonContainerImpl.php#L361-L364
skeeks-semenov/yii2-ckeditor
src/assets/lib/geshi/geshi.php
GeSHi.set_comments_style
function set_comments_style($key, $style, $preserve_defaults = false) { if('*' == $key) { foreach($this->language_data['STYLES']['COMMENTS'] as $_key => $_value) { if (!$preserve_defaults) { $this->language_data['STYLES']['COMMENTS'][$_key] = $style; } else { $this->language_data['STYLES']['COMMENTS'][$_key] .= $style; } } } else { if (!$preserve_defaults) { $this->language_data['STYLES']['COMMENTS'][$key] = $style; } else { $this->language_data['STYLES']['COMMENTS'][$key] .= $style; } } }
php
function set_comments_style($key, $style, $preserve_defaults = false) { if('*' == $key) { foreach($this->language_data['STYLES']['COMMENTS'] as $_key => $_value) { if (!$preserve_defaults) { $this->language_data['STYLES']['COMMENTS'][$_key] = $style; } else { $this->language_data['STYLES']['COMMENTS'][$_key] .= $style; } } } else { if (!$preserve_defaults) { $this->language_data['STYLES']['COMMENTS'][$key] = $style; } else { $this->language_data['STYLES']['COMMENTS'][$key] .= $style; } } }
[ "function", "set_comments_style", "(", "$", "key", ",", "$", "style", ",", "$", "preserve_defaults", "=", "false", ")", "{", "if", "(", "'*'", "==", "$", "key", ")", "{", "foreach", "(", "$", "this", "->", "language_data", "[", "'STYLES'", "]", "[", ...
Sets the styles for comment groups. If $preserve_defaults is true, then styles are merged with the default styles, with the user defined styles having priority @param int The key of the comment group to change the styles of @param string The style to make the comments @param boolean Whether to merge the new styles with the old or just to overwrite them @since 1.0.0
[ "Sets", "the", "styles", "for", "comment", "groups", ".", "If", "$preserve_defaults", "is", "true", "then", "styles", "are", "merged", "with", "the", "default", "styles", "with", "the", "user", "defined", "styles", "having", "priority" ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/assets/lib/geshi/geshi.php#L1066-L1082
skeeks-semenov/yii2-ckeditor
src/assets/lib/geshi/geshi.php
GeSHi.set_strings_style
function set_strings_style($style, $preserve_defaults = false, $group = 0) { if (!$preserve_defaults) { $this->language_data['STYLES']['STRINGS'][$group] = $style; } else { $this->language_data['STYLES']['STRINGS'][$group] .= $style; } }
php
function set_strings_style($style, $preserve_defaults = false, $group = 0) { if (!$preserve_defaults) { $this->language_data['STYLES']['STRINGS'][$group] = $style; } else { $this->language_data['STYLES']['STRINGS'][$group] .= $style; } }
[ "function", "set_strings_style", "(", "$", "style", ",", "$", "preserve_defaults", "=", "false", ",", "$", "group", "=", "0", ")", "{", "if", "(", "!", "$", "preserve_defaults", ")", "{", "$", "this", "->", "language_data", "[", "'STYLES'", "]", "[", "...
Sets the styles for strings. If $preserve_defaults is true, then styles are merged with the default styles, with the user defined styles having priority @param string The style to make the escape characters @param boolean Whether to merge the new styles with the old or just to overwrite them @param int Tells the group of strings for which style should be set. @since 1.0.0
[ "Sets", "the", "styles", "for", "strings", ".", "If", "$preserve_defaults", "is", "true", "then", "styles", "are", "merged", "with", "the", "default", "styles", "with", "the", "user", "defined", "styles", "having", "priority" ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/assets/lib/geshi/geshi.php#L1209-L1215
skeeks-semenov/yii2-ckeditor
src/assets/lib/geshi/geshi.php
GeSHi.optimize_keyword_group
function optimize_keyword_group($key) { $this->language_data['CACHED_KEYWORD_LISTS'][$key] = $this->optimize_regexp_list($this->language_data['KEYWORDS'][$key]); $space_as_whitespace = false; if(isset($this->language_data['PARSER_CONTROL'])) { if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS'])) { if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS']['SPACE_AS_WHITESPACE'])) { $space_as_whitespace = $this->language_data['PARSER_CONTROL']['KEYWORDS']['SPACE_AS_WHITESPACE']; } if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS'][$key]['SPACE_AS_WHITESPACE'])) { if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS'][$key]['SPACE_AS_WHITESPACE'])) { $space_as_whitespace = $this->language_data['PARSER_CONTROL']['KEYWORDS'][$key]['SPACE_AS_WHITESPACE']; } } } } if($space_as_whitespace) { foreach($this->language_data['CACHED_KEYWORD_LISTS'][$key] as $rxk => $rxv) { $this->language_data['CACHED_KEYWORD_LISTS'][$key][$rxk] = str_replace(" ", "\\s+", $rxv); } } }
php
function optimize_keyword_group($key) { $this->language_data['CACHED_KEYWORD_LISTS'][$key] = $this->optimize_regexp_list($this->language_data['KEYWORDS'][$key]); $space_as_whitespace = false; if(isset($this->language_data['PARSER_CONTROL'])) { if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS'])) { if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS']['SPACE_AS_WHITESPACE'])) { $space_as_whitespace = $this->language_data['PARSER_CONTROL']['KEYWORDS']['SPACE_AS_WHITESPACE']; } if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS'][$key]['SPACE_AS_WHITESPACE'])) { if(isset($this->language_data['PARSER_CONTROL']['KEYWORDS'][$key]['SPACE_AS_WHITESPACE'])) { $space_as_whitespace = $this->language_data['PARSER_CONTROL']['KEYWORDS'][$key]['SPACE_AS_WHITESPACE']; } } } } if($space_as_whitespace) { foreach($this->language_data['CACHED_KEYWORD_LISTS'][$key] as $rxk => $rxv) { $this->language_data['CACHED_KEYWORD_LISTS'][$key][$rxk] = str_replace(" ", "\\s+", $rxv); } } }
[ "function", "optimize_keyword_group", "(", "$", "key", ")", "{", "$", "this", "->", "language_data", "[", "'CACHED_KEYWORD_LISTS'", "]", "[", "$", "key", "]", "=", "$", "this", "->", "optimize_regexp_list", "(", "$", "this", "->", "language_data", "[", "'KEY...
compile optimized regexp list for keyword group @param int The key of the keyword group to compile & optimize @since 1.0.8
[ "compile", "optimized", "regexp", "list", "for", "keyword", "group" ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/assets/lib/geshi/geshi.php#L1683-L1705
skeeks-semenov/yii2-ckeditor
src/assets/lib/geshi/geshi.php
GeSHi.load_language
function load_language($file_name) { if ($file_name == $this->loaded_language) { // this file is already loaded! return; } //Prepare some stuff before actually loading the language file $this->loaded_language = $file_name; $this->parse_cache_built = false; $this->enable_highlighting(); $language_data = array(); //Load the language file require $file_name; // Perhaps some checking might be added here later to check that // $language data is a valid thing but maybe not $this->language_data = $language_data; // Set strict mode if should be set $this->strict_mode = $this->language_data['STRICT_MODE_APPLIES']; // Set permissions for all lexics to true // so they'll be highlighted by default foreach (array_keys($this->language_data['KEYWORDS']) as $key) { if (!empty($this->language_data['KEYWORDS'][$key])) { $this->lexic_permissions['KEYWORDS'][$key] = true; } else { $this->lexic_permissions['KEYWORDS'][$key] = false; } } foreach (array_keys($this->language_data['COMMENT_SINGLE']) as $key) { $this->lexic_permissions['COMMENTS'][$key] = true; } foreach (array_keys($this->language_data['REGEXPS']) as $key) { $this->lexic_permissions['REGEXPS'][$key] = true; } // for BenBE and future code reviews: // we can use empty here since we only check for existance and emptiness of an array // if it is not an array at all but rather false or null this will work as intended as well // even if $this->language_data['PARSER_CONTROL'] is undefined this won't trigger a notice if (!empty($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS'])) { foreach ($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS'] as $flag => $value) { // it's either true or false and maybe is true as well $perm = $value !== GESHI_NEVER; if ($flag == 'ALL') { $this->enable_highlighting($perm); continue; } if (!isset($this->lexic_permissions[$flag])) { // unknown lexic permission continue; } if (is_array($this->lexic_permissions[$flag])) { foreach ($this->lexic_permissions[$flag] as $key => $val) { $this->lexic_permissions[$flag][$key] = $perm; } } else { $this->lexic_permissions[$flag] = $perm; } } unset($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS']); } //Fix: Problem where hardescapes weren't handled if no ESCAPE_CHAR was given //You need to set one for HARDESCAPES only in this case. if(!isset($this->language_data['HARDCHAR'])) { $this->language_data['HARDCHAR'] = $this->language_data['ESCAPE_CHAR']; } //NEW in 1.0.8: Allow styles to be loaded from a separate file to override defaults $style_filename = substr($file_name, 0, -4) . '.style.php'; if (is_readable($style_filename)) { //Clear any style_data that could have been set before ... if (isset($style_data)) { unset($style_data); } //Read the Style Information from the style file include $style_filename; //Apply the new styles to our current language styles if (isset($style_data) && is_array($style_data)) { $this->language_data['STYLES'] = $this->merge_arrays($this->language_data['STYLES'], $style_data); } } }
php
function load_language($file_name) { if ($file_name == $this->loaded_language) { // this file is already loaded! return; } //Prepare some stuff before actually loading the language file $this->loaded_language = $file_name; $this->parse_cache_built = false; $this->enable_highlighting(); $language_data = array(); //Load the language file require $file_name; // Perhaps some checking might be added here later to check that // $language data is a valid thing but maybe not $this->language_data = $language_data; // Set strict mode if should be set $this->strict_mode = $this->language_data['STRICT_MODE_APPLIES']; // Set permissions for all lexics to true // so they'll be highlighted by default foreach (array_keys($this->language_data['KEYWORDS']) as $key) { if (!empty($this->language_data['KEYWORDS'][$key])) { $this->lexic_permissions['KEYWORDS'][$key] = true; } else { $this->lexic_permissions['KEYWORDS'][$key] = false; } } foreach (array_keys($this->language_data['COMMENT_SINGLE']) as $key) { $this->lexic_permissions['COMMENTS'][$key] = true; } foreach (array_keys($this->language_data['REGEXPS']) as $key) { $this->lexic_permissions['REGEXPS'][$key] = true; } // for BenBE and future code reviews: // we can use empty here since we only check for existance and emptiness of an array // if it is not an array at all but rather false or null this will work as intended as well // even if $this->language_data['PARSER_CONTROL'] is undefined this won't trigger a notice if (!empty($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS'])) { foreach ($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS'] as $flag => $value) { // it's either true or false and maybe is true as well $perm = $value !== GESHI_NEVER; if ($flag == 'ALL') { $this->enable_highlighting($perm); continue; } if (!isset($this->lexic_permissions[$flag])) { // unknown lexic permission continue; } if (is_array($this->lexic_permissions[$flag])) { foreach ($this->lexic_permissions[$flag] as $key => $val) { $this->lexic_permissions[$flag][$key] = $perm; } } else { $this->lexic_permissions[$flag] = $perm; } } unset($this->language_data['PARSER_CONTROL']['ENABLE_FLAGS']); } //Fix: Problem where hardescapes weren't handled if no ESCAPE_CHAR was given //You need to set one for HARDESCAPES only in this case. if(!isset($this->language_data['HARDCHAR'])) { $this->language_data['HARDCHAR'] = $this->language_data['ESCAPE_CHAR']; } //NEW in 1.0.8: Allow styles to be loaded from a separate file to override defaults $style_filename = substr($file_name, 0, -4) . '.style.php'; if (is_readable($style_filename)) { //Clear any style_data that could have been set before ... if (isset($style_data)) { unset($style_data); } //Read the Style Information from the style file include $style_filename; //Apply the new styles to our current language styles if (isset($style_data) && is_array($style_data)) { $this->language_data['STYLES'] = $this->merge_arrays($this->language_data['STYLES'], $style_data); } } }
[ "function", "load_language", "(", "$", "file_name", ")", "{", "if", "(", "$", "file_name", "==", "$", "this", "->", "loaded_language", ")", "{", "// this file is already loaded!", "return", ";", "}", "//Prepare some stuff before actually loading the language file", "$",...
Gets language information and stores it for later use @param string The filename of the language file you want to load @since 1.0.0 @access private @todo Needs to load keys for lexic permissions for keywords, regexps etc
[ "Gets", "language", "information", "and", "stores", "it", "for", "later", "use" ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/assets/lib/geshi/geshi.php#L3761-L3850
skeeks-semenov/yii2-ckeditor
src/assets/lib/geshi/geshi.php
GeSHi.footer
function footer() { $footer = $this->footer_content; if ($footer) { if ($this->header_type == GESHI_HEADER_PRE) { $footer = str_replace("\n", '', $footer);; } $footer = $this->replace_keywords($footer); if ($this->use_classes) { $attr = ' class="foot"'; } else { $attr = " style=\"{$this->footer_content_style}\""; } if ($this->header_type == GESHI_HEADER_PRE_TABLE && $this->line_numbers != GESHI_NO_LINE_NUMBERS) { $footer = "<tfoot><tr><td colspan=\"2\">$footer</td></tr></tfoot>"; } else { $footer = "<div$attr>$footer</div>"; } } if (GESHI_HEADER_NONE == $this->header_type) { return ($this->line_numbers != GESHI_NO_LINE_NUMBERS) ? '</ol>' . $footer : $footer; } if ($this->header_type == GESHI_HEADER_DIV || $this->header_type == GESHI_HEADER_PRE_VALID) { if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { return "</ol>$footer</div>"; } return ($this->force_code_block ? '</div>' : '') . "$footer</div>"; } elseif ($this->header_type == GESHI_HEADER_PRE_TABLE) { if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { return "</tr></tbody>$footer</table>"; } return ($this->force_code_block ? '</div>' : '') . "$footer</div>"; } else { if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { return "</ol>$footer</pre>"; } return ($this->force_code_block ? '</div>' : '') . "$footer</pre>"; } }
php
function footer() { $footer = $this->footer_content; if ($footer) { if ($this->header_type == GESHI_HEADER_PRE) { $footer = str_replace("\n", '', $footer);; } $footer = $this->replace_keywords($footer); if ($this->use_classes) { $attr = ' class="foot"'; } else { $attr = " style=\"{$this->footer_content_style}\""; } if ($this->header_type == GESHI_HEADER_PRE_TABLE && $this->line_numbers != GESHI_NO_LINE_NUMBERS) { $footer = "<tfoot><tr><td colspan=\"2\">$footer</td></tr></tfoot>"; } else { $footer = "<div$attr>$footer</div>"; } } if (GESHI_HEADER_NONE == $this->header_type) { return ($this->line_numbers != GESHI_NO_LINE_NUMBERS) ? '</ol>' . $footer : $footer; } if ($this->header_type == GESHI_HEADER_DIV || $this->header_type == GESHI_HEADER_PRE_VALID) { if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { return "</ol>$footer</div>"; } return ($this->force_code_block ? '</div>' : '') . "$footer</div>"; } elseif ($this->header_type == GESHI_HEADER_PRE_TABLE) { if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { return "</tr></tbody>$footer</table>"; } return ($this->force_code_block ? '</div>' : '') . "$footer</div>"; } else { if ($this->line_numbers != GESHI_NO_LINE_NUMBERS) { return "</ol>$footer</pre>"; } return ($this->force_code_block ? '</div>' : '') . "$footer</pre>"; } }
[ "function", "footer", "(", ")", "{", "$", "footer", "=", "$", "this", "->", "footer_content", ";", "if", "(", "$", "footer", ")", "{", "if", "(", "$", "this", "->", "header_type", "==", "GESHI_HEADER_PRE", ")", "{", "$", "footer", "=", "str_replace", ...
Returns the footer for the code block. @return string The footer for the code block @since 1.0.0 @access private
[ "Returns", "the", "footer", "for", "the", "code", "block", "." ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/assets/lib/geshi/geshi.php#L4185-L4230
skeeks-semenov/yii2-ckeditor
src/assets/lib/geshi/geshi.php
GeSHi.get_stylesheet
function get_stylesheet($economy_mode = true) { // If there's an error, chances are that the language file // won't have populated the language data file, so we can't // risk getting a stylesheet... if ($this->error) { return ''; } //Check if the style rearrangements have been processed ... //This also does some preprocessing to check which style groups are useable ... if(!isset($this->language_data['NUMBERS_CACHE'])) { $this->build_style_cache(); } // First, work out what the selector should be. If there's an ID, // that should be used, the same for a class. Otherwise, a selector // of '' means that these styles will be applied anywhere if ($this->overall_id) { $selector = '#' . $this->_genCSSName($this->overall_id); } else { $selector = '.' . $this->_genCSSName($this->language); if ($this->overall_class) { $selector .= '.' . $this->_genCSSName($this->overall_class); } } $selector .= ' '; // Header of the stylesheet if (!$economy_mode) { $stylesheet = "/**\n". " * GeSHi Dynamically Generated Stylesheet\n". " * --------------------------------------\n". " * Dynamically generated stylesheet for {$this->language}\n". " * CSS class: {$this->overall_class}, CSS id: {$this->overall_id}\n". " * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2014 Benny Baumann\n" . " * (http://qbnz.com/highlighter/ and http://geshi.org/)\n". " * --------------------------------------\n". " */\n"; } else { $stylesheet = "/**\n". " * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2014 Benny Baumann\n" . " * (http://qbnz.com/highlighter/ and http://geshi.org/)\n". " */\n"; } // Set the <ol> to have no effect at all if there are line numbers // (<ol>s have margins that should be destroyed so all layout is // controlled by the set_overall_style method, which works on the // <pre> or <div> container). Additionally, set default styles for lines if (!$economy_mode || $this->line_numbers != GESHI_NO_LINE_NUMBERS) { //$stylesheet .= "$selector, {$selector}ol, {$selector}ol li {margin: 0;}\n"; $stylesheet .= "$selector.de1, $selector.de2 {{$this->code_style}}\n"; } // Add overall styles // note: neglect economy_mode, empty styles are meaningless if ($this->overall_style != '') { $stylesheet .= "$selector {{$this->overall_style}}\n"; } // Add styles for links // note: economy mode does not make _any_ sense here // either the style is empty and thus no selector is needed // or the appropriate key is given. foreach ($this->link_styles as $key => $style) { if ($style != '') { switch ($key) { case GESHI_LINK: $stylesheet .= "{$selector}a:link {{$style}}\n"; break; case GESHI_HOVER: $stylesheet .= "{$selector}a:hover {{$style}}\n"; break; case GESHI_ACTIVE: $stylesheet .= "{$selector}a:active {{$style}}\n"; break; case GESHI_VISITED: $stylesheet .= "{$selector}a:visited {{$style}}\n"; break; } } } // Header and footer // note: neglect economy_mode, empty styles are meaningless if ($this->header_content_style != '') { $stylesheet .= "$selector.head {{$this->header_content_style}}\n"; } if ($this->footer_content_style != '') { $stylesheet .= "$selector.foot {{$this->footer_content_style}}\n"; } // Styles for important stuff // note: neglect economy_mode, empty styles are meaningless if ($this->important_styles != '') { $stylesheet .= "$selector.imp {{$this->important_styles}}\n"; } // Simple line number styles if ((!$economy_mode || $this->line_numbers != GESHI_NO_LINE_NUMBERS) && $this->line_style1 != '') { $stylesheet .= "{$selector}li, {$selector}.li1 {{$this->line_style1}}\n"; } if ((!$economy_mode || $this->line_numbers != GESHI_NO_LINE_NUMBERS) && $this->table_linenumber_style != '') { $stylesheet .= "{$selector}.ln {{$this->table_linenumber_style}}\n"; } // If there is a style set for fancy line numbers, echo it out if ((!$economy_mode || $this->line_numbers == GESHI_FANCY_LINE_NUMBERS) && $this->line_style2 != '') { $stylesheet .= "{$selector}.li2 {{$this->line_style2}}\n"; } // note: empty styles are meaningless foreach ($this->language_data['STYLES']['KEYWORDS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || (isset($this->lexic_permissions['KEYWORDS'][$group]) && $this->lexic_permissions['KEYWORDS'][$group]))) { $stylesheet .= "$selector.kw$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['COMMENTS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || (isset($this->lexic_permissions['COMMENTS'][$group]) && $this->lexic_permissions['COMMENTS'][$group]) || (!empty($this->language_data['COMMENT_REGEXP']) && !empty($this->language_data['COMMENT_REGEXP'][$group])))) { $stylesheet .= "$selector.co$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['ESCAPE_CHAR'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['ESCAPE_CHAR'])) { // NEW: since 1.0.8 we have to handle hardescapes if ($group === 'HARD') { $group = '_h'; } $stylesheet .= "$selector.es$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['BRACKETS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['BRACKETS'])) { $stylesheet .= "$selector.br$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['SYMBOLS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['SYMBOLS'])) { $stylesheet .= "$selector.sy$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['STRINGS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['STRINGS'])) { // NEW: since 1.0.8 we have to handle hardquotes if ($group === 'HARD') { $group = '_h'; } $stylesheet .= "$selector.st$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['NUMBERS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['NUMBERS'])) { $stylesheet .= "$selector.nu$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['METHODS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['METHODS'])) { $stylesheet .= "$selector.me$group {{$styles}}\n"; } } // note: neglect economy_mode, empty styles are meaningless foreach ($this->language_data['STYLES']['SCRIPT'] as $group => $styles) { if ($styles != '') { $stylesheet .= "$selector.sc$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['REGEXPS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || (isset($this->lexic_permissions['REGEXPS'][$group]) && $this->lexic_permissions['REGEXPS'][$group]))) { if (is_array($this->language_data['REGEXPS'][$group]) && array_key_exists(GESHI_CLASS, $this->language_data['REGEXPS'][$group])) { $stylesheet .= "$selector."; $stylesheet .= $this->language_data['REGEXPS'][$group][GESHI_CLASS]; $stylesheet .= " {{$styles}}\n"; } else { $stylesheet .= "$selector.re$group {{$styles}}\n"; } } } // Styles for lines being highlighted extra if (!$economy_mode || (count($this->highlight_extra_lines)!=count($this->highlight_extra_lines_styles))) { $stylesheet .= "{$selector}.ln-xtra, {$selector}li.ln-xtra, {$selector}div.ln-xtra {{$this->highlight_extra_lines_style}}\n"; } $stylesheet .= "{$selector}span.xtra { display:block; }\n"; foreach ($this->highlight_extra_lines_styles as $lineid => $linestyle) { $stylesheet .= "{$selector}.lx$lineid, {$selector}li.lx$lineid, {$selector}div.lx$lineid {{$linestyle}}\n"; } return $stylesheet; }
php
function get_stylesheet($economy_mode = true) { // If there's an error, chances are that the language file // won't have populated the language data file, so we can't // risk getting a stylesheet... if ($this->error) { return ''; } //Check if the style rearrangements have been processed ... //This also does some preprocessing to check which style groups are useable ... if(!isset($this->language_data['NUMBERS_CACHE'])) { $this->build_style_cache(); } // First, work out what the selector should be. If there's an ID, // that should be used, the same for a class. Otherwise, a selector // of '' means that these styles will be applied anywhere if ($this->overall_id) { $selector = '#' . $this->_genCSSName($this->overall_id); } else { $selector = '.' . $this->_genCSSName($this->language); if ($this->overall_class) { $selector .= '.' . $this->_genCSSName($this->overall_class); } } $selector .= ' '; // Header of the stylesheet if (!$economy_mode) { $stylesheet = "/**\n". " * GeSHi Dynamically Generated Stylesheet\n". " * --------------------------------------\n". " * Dynamically generated stylesheet for {$this->language}\n". " * CSS class: {$this->overall_class}, CSS id: {$this->overall_id}\n". " * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2014 Benny Baumann\n" . " * (http://qbnz.com/highlighter/ and http://geshi.org/)\n". " * --------------------------------------\n". " */\n"; } else { $stylesheet = "/**\n". " * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2014 Benny Baumann\n" . " * (http://qbnz.com/highlighter/ and http://geshi.org/)\n". " */\n"; } // Set the <ol> to have no effect at all if there are line numbers // (<ol>s have margins that should be destroyed so all layout is // controlled by the set_overall_style method, which works on the // <pre> or <div> container). Additionally, set default styles for lines if (!$economy_mode || $this->line_numbers != GESHI_NO_LINE_NUMBERS) { //$stylesheet .= "$selector, {$selector}ol, {$selector}ol li {margin: 0;}\n"; $stylesheet .= "$selector.de1, $selector.de2 {{$this->code_style}}\n"; } // Add overall styles // note: neglect economy_mode, empty styles are meaningless if ($this->overall_style != '') { $stylesheet .= "$selector {{$this->overall_style}}\n"; } // Add styles for links // note: economy mode does not make _any_ sense here // either the style is empty and thus no selector is needed // or the appropriate key is given. foreach ($this->link_styles as $key => $style) { if ($style != '') { switch ($key) { case GESHI_LINK: $stylesheet .= "{$selector}a:link {{$style}}\n"; break; case GESHI_HOVER: $stylesheet .= "{$selector}a:hover {{$style}}\n"; break; case GESHI_ACTIVE: $stylesheet .= "{$selector}a:active {{$style}}\n"; break; case GESHI_VISITED: $stylesheet .= "{$selector}a:visited {{$style}}\n"; break; } } } // Header and footer // note: neglect economy_mode, empty styles are meaningless if ($this->header_content_style != '') { $stylesheet .= "$selector.head {{$this->header_content_style}}\n"; } if ($this->footer_content_style != '') { $stylesheet .= "$selector.foot {{$this->footer_content_style}}\n"; } // Styles for important stuff // note: neglect economy_mode, empty styles are meaningless if ($this->important_styles != '') { $stylesheet .= "$selector.imp {{$this->important_styles}}\n"; } // Simple line number styles if ((!$economy_mode || $this->line_numbers != GESHI_NO_LINE_NUMBERS) && $this->line_style1 != '') { $stylesheet .= "{$selector}li, {$selector}.li1 {{$this->line_style1}}\n"; } if ((!$economy_mode || $this->line_numbers != GESHI_NO_LINE_NUMBERS) && $this->table_linenumber_style != '') { $stylesheet .= "{$selector}.ln {{$this->table_linenumber_style}}\n"; } // If there is a style set for fancy line numbers, echo it out if ((!$economy_mode || $this->line_numbers == GESHI_FANCY_LINE_NUMBERS) && $this->line_style2 != '') { $stylesheet .= "{$selector}.li2 {{$this->line_style2}}\n"; } // note: empty styles are meaningless foreach ($this->language_data['STYLES']['KEYWORDS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || (isset($this->lexic_permissions['KEYWORDS'][$group]) && $this->lexic_permissions['KEYWORDS'][$group]))) { $stylesheet .= "$selector.kw$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['COMMENTS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || (isset($this->lexic_permissions['COMMENTS'][$group]) && $this->lexic_permissions['COMMENTS'][$group]) || (!empty($this->language_data['COMMENT_REGEXP']) && !empty($this->language_data['COMMENT_REGEXP'][$group])))) { $stylesheet .= "$selector.co$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['ESCAPE_CHAR'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['ESCAPE_CHAR'])) { // NEW: since 1.0.8 we have to handle hardescapes if ($group === 'HARD') { $group = '_h'; } $stylesheet .= "$selector.es$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['BRACKETS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['BRACKETS'])) { $stylesheet .= "$selector.br$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['SYMBOLS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['SYMBOLS'])) { $stylesheet .= "$selector.sy$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['STRINGS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['STRINGS'])) { // NEW: since 1.0.8 we have to handle hardquotes if ($group === 'HARD') { $group = '_h'; } $stylesheet .= "$selector.st$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['NUMBERS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['NUMBERS'])) { $stylesheet .= "$selector.nu$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['METHODS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || $this->lexic_permissions['METHODS'])) { $stylesheet .= "$selector.me$group {{$styles}}\n"; } } // note: neglect economy_mode, empty styles are meaningless foreach ($this->language_data['STYLES']['SCRIPT'] as $group => $styles) { if ($styles != '') { $stylesheet .= "$selector.sc$group {{$styles}}\n"; } } foreach ($this->language_data['STYLES']['REGEXPS'] as $group => $styles) { if ($styles != '' && (!$economy_mode || (isset($this->lexic_permissions['REGEXPS'][$group]) && $this->lexic_permissions['REGEXPS'][$group]))) { if (is_array($this->language_data['REGEXPS'][$group]) && array_key_exists(GESHI_CLASS, $this->language_data['REGEXPS'][$group])) { $stylesheet .= "$selector."; $stylesheet .= $this->language_data['REGEXPS'][$group][GESHI_CLASS]; $stylesheet .= " {{$styles}}\n"; } else { $stylesheet .= "$selector.re$group {{$styles}}\n"; } } } // Styles for lines being highlighted extra if (!$economy_mode || (count($this->highlight_extra_lines)!=count($this->highlight_extra_lines_styles))) { $stylesheet .= "{$selector}.ln-xtra, {$selector}li.ln-xtra, {$selector}div.ln-xtra {{$this->highlight_extra_lines_style}}\n"; } $stylesheet .= "{$selector}span.xtra { display:block; }\n"; foreach ($this->highlight_extra_lines_styles as $lineid => $linestyle) { $stylesheet .= "{$selector}.lx$lineid, {$selector}li.lx$lineid, {$selector}div.lx$lineid {{$linestyle}}\n"; } return $stylesheet; }
[ "function", "get_stylesheet", "(", "$", "economy_mode", "=", "true", ")", "{", "// If there's an error, chances are that the language file", "// won't have populated the language data file, so we can't", "// risk getting a stylesheet...", "if", "(", "$", "this", "->", "error", ")...
Returns a stylesheet for the highlighted code. If $economy mode is true, we only return the stylesheet declarations that matter for this code block instead of the whole thing @param boolean Whether to use economy mode or not @return string A stylesheet built on the data for the current language @since 1.0.0
[ "Returns", "a", "stylesheet", "for", "the", "highlighted", "code", ".", "If", "$economy", "mode", "is", "true", "we", "only", "return", "the", "stylesheet", "declarations", "that", "matter", "for", "this", "code", "block", "instead", "of", "the", "whole", "t...
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/assets/lib/geshi/geshi.php#L4370-L4565
skeeks-semenov/yii2-ckeditor
src/assets/lib/geshi/geshi.php
GeSHi.optimize_regexp_list
function optimize_regexp_list($list, $regexp_delimiter = '/') { $regex_chars = array('.', '\\', '+', '-', '*', '?', '[', '^', ']', '$', '(', ')', '{', '}', '=', '!', '<', '>', '|', ':', $regexp_delimiter); sort($list); $regexp_list = array(''); $num_subpatterns = 0; $list_key = 0; // the tokens which we will use to generate the regexp list $tokens = array(); $prev_keys = array(); // go through all entries of the list and generate the token list $cur_len = 0; for ($i = 0, $i_max = count($list); $i < $i_max; ++$i) { if ($cur_len > GESHI_MAX_PCRE_LENGTH) { // seems like the length of this pcre is growing exorbitantly $regexp_list[++$list_key] = $this->_optimize_regexp_list_tokens_to_string($tokens); $num_subpatterns = substr_count($regexp_list[$list_key], '(?:'); $tokens = array(); $cur_len = 0; } $level = 0; $entry = preg_quote((string) $list[$i], $regexp_delimiter); $pointer = &$tokens; // properly assign the new entry to the correct position in the token array // possibly generate smaller common denominator keys while (true) { // get the common denominator if (isset($prev_keys[$level])) { if ($prev_keys[$level] == $entry) { // this is a duplicate entry, skip it continue 2; } $char = 0; while (isset($entry[$char]) && isset($prev_keys[$level][$char]) && $entry[$char] == $prev_keys[$level][$char]) { ++$char; } if ($char > 0) { // this entry has at least some chars in common with the current key if ($char == strlen($prev_keys[$level])) { // current key is totally matched, i.e. this entry has just some bits appended $pointer = &$pointer[$prev_keys[$level]]; } else { // only part of the keys match $new_key_part1 = substr($prev_keys[$level], 0, $char); $new_key_part2 = substr($prev_keys[$level], $char); if (in_array($new_key_part1[0], $regex_chars) || in_array($new_key_part2[0], $regex_chars)) { // this is bad, a regex char as first character $pointer[$entry] = array('' => true); array_splice($prev_keys, $level, count($prev_keys), $entry); $cur_len += strlen($entry); continue; } else { // relocate previous tokens $pointer[$new_key_part1] = array($new_key_part2 => $pointer[$prev_keys[$level]]); unset($pointer[$prev_keys[$level]]); $pointer = &$pointer[$new_key_part1]; // recreate key index array_splice($prev_keys, $level, count($prev_keys), array($new_key_part1, $new_key_part2)); $cur_len += strlen($new_key_part2); } } ++$level; $entry = substr($entry, $char); continue; } // else: fall trough, i.e. no common denominator was found } if ($level == 0 && !empty($tokens)) { // we can dump current tokens into the string and throw them away afterwards $new_entry = $this->_optimize_regexp_list_tokens_to_string($tokens); $new_subpatterns = substr_count($new_entry, '(?:'); if (GESHI_MAX_PCRE_SUBPATTERNS && $num_subpatterns + $new_subpatterns > GESHI_MAX_PCRE_SUBPATTERNS) { $regexp_list[++$list_key] = $new_entry; $num_subpatterns = $new_subpatterns; } else { if (!empty($regexp_list[$list_key])) { $new_entry = '|' . $new_entry; } $regexp_list[$list_key] .= $new_entry; $num_subpatterns += $new_subpatterns; } $tokens = array(); $cur_len = 0; } // no further common denominator found $pointer[$entry] = array('' => true); array_splice($prev_keys, $level, count($prev_keys), $entry); $cur_len += strlen($entry); break; } unset($list[$i]); } // make sure the last tokens get converted as well $new_entry = $this->_optimize_regexp_list_tokens_to_string($tokens); if (GESHI_MAX_PCRE_SUBPATTERNS && $num_subpatterns + substr_count($new_entry, '(?:') > GESHI_MAX_PCRE_SUBPATTERNS) { if ( !empty($regexp_list[$list_key]) ) { ++$list_key; } $regexp_list[$list_key] = $new_entry; } else { if (!empty($regexp_list[$list_key])) { $new_entry = '|' . $new_entry; } $regexp_list[$list_key] .= $new_entry; } return $regexp_list; }
php
function optimize_regexp_list($list, $regexp_delimiter = '/') { $regex_chars = array('.', '\\', '+', '-', '*', '?', '[', '^', ']', '$', '(', ')', '{', '}', '=', '!', '<', '>', '|', ':', $regexp_delimiter); sort($list); $regexp_list = array(''); $num_subpatterns = 0; $list_key = 0; // the tokens which we will use to generate the regexp list $tokens = array(); $prev_keys = array(); // go through all entries of the list and generate the token list $cur_len = 0; for ($i = 0, $i_max = count($list); $i < $i_max; ++$i) { if ($cur_len > GESHI_MAX_PCRE_LENGTH) { // seems like the length of this pcre is growing exorbitantly $regexp_list[++$list_key] = $this->_optimize_regexp_list_tokens_to_string($tokens); $num_subpatterns = substr_count($regexp_list[$list_key], '(?:'); $tokens = array(); $cur_len = 0; } $level = 0; $entry = preg_quote((string) $list[$i], $regexp_delimiter); $pointer = &$tokens; // properly assign the new entry to the correct position in the token array // possibly generate smaller common denominator keys while (true) { // get the common denominator if (isset($prev_keys[$level])) { if ($prev_keys[$level] == $entry) { // this is a duplicate entry, skip it continue 2; } $char = 0; while (isset($entry[$char]) && isset($prev_keys[$level][$char]) && $entry[$char] == $prev_keys[$level][$char]) { ++$char; } if ($char > 0) { // this entry has at least some chars in common with the current key if ($char == strlen($prev_keys[$level])) { // current key is totally matched, i.e. this entry has just some bits appended $pointer = &$pointer[$prev_keys[$level]]; } else { // only part of the keys match $new_key_part1 = substr($prev_keys[$level], 0, $char); $new_key_part2 = substr($prev_keys[$level], $char); if (in_array($new_key_part1[0], $regex_chars) || in_array($new_key_part2[0], $regex_chars)) { // this is bad, a regex char as first character $pointer[$entry] = array('' => true); array_splice($prev_keys, $level, count($prev_keys), $entry); $cur_len += strlen($entry); continue; } else { // relocate previous tokens $pointer[$new_key_part1] = array($new_key_part2 => $pointer[$prev_keys[$level]]); unset($pointer[$prev_keys[$level]]); $pointer = &$pointer[$new_key_part1]; // recreate key index array_splice($prev_keys, $level, count($prev_keys), array($new_key_part1, $new_key_part2)); $cur_len += strlen($new_key_part2); } } ++$level; $entry = substr($entry, $char); continue; } // else: fall trough, i.e. no common denominator was found } if ($level == 0 && !empty($tokens)) { // we can dump current tokens into the string and throw them away afterwards $new_entry = $this->_optimize_regexp_list_tokens_to_string($tokens); $new_subpatterns = substr_count($new_entry, '(?:'); if (GESHI_MAX_PCRE_SUBPATTERNS && $num_subpatterns + $new_subpatterns > GESHI_MAX_PCRE_SUBPATTERNS) { $regexp_list[++$list_key] = $new_entry; $num_subpatterns = $new_subpatterns; } else { if (!empty($regexp_list[$list_key])) { $new_entry = '|' . $new_entry; } $regexp_list[$list_key] .= $new_entry; $num_subpatterns += $new_subpatterns; } $tokens = array(); $cur_len = 0; } // no further common denominator found $pointer[$entry] = array('' => true); array_splice($prev_keys, $level, count($prev_keys), $entry); $cur_len += strlen($entry); break; } unset($list[$i]); } // make sure the last tokens get converted as well $new_entry = $this->_optimize_regexp_list_tokens_to_string($tokens); if (GESHI_MAX_PCRE_SUBPATTERNS && $num_subpatterns + substr_count($new_entry, '(?:') > GESHI_MAX_PCRE_SUBPATTERNS) { if ( !empty($regexp_list[$list_key]) ) { ++$list_key; } $regexp_list[$list_key] = $new_entry; } else { if (!empty($regexp_list[$list_key])) { $new_entry = '|' . $new_entry; } $regexp_list[$list_key] .= $new_entry; } return $regexp_list; }
[ "function", "optimize_regexp_list", "(", "$", "list", ",", "$", "regexp_delimiter", "=", "'/'", ")", "{", "$", "regex_chars", "=", "array", "(", "'.'", ",", "'\\\\'", ",", "'+'", ",", "'-'", ",", "'*'", ",", "'?'", ",", "'['", ",", "'^'", ",", "']'",...
this functions creates an optimized regular expression list of an array of strings. Example: <code>$list = array('faa', 'foo', 'foobar'); => string 'f(aa|oo(bar)?)'</code> @param $list array of (unquoted) strings @param $regexp_delimiter your regular expression delimiter, @see preg_quote() @return string for regular expression @author Milian Wolff <mail@milianw.de> @since 1.0.8 @access private
[ "this", "functions", "creates", "an", "optimized", "regular", "expression", "list", "of", "an", "array", "of", "strings", "." ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/assets/lib/geshi/geshi.php#L4601-L4712
yeephp/yeephp
Yee/Log.php
Log.setLevel
public function setLevel($level) { if (!isset(self::$levels[$level])) { throw new \InvalidArgumentException('Invalid log level'); } $this->level = $level; }
php
public function setLevel($level) { if (!isset(self::$levels[$level])) { throw new \InvalidArgumentException('Invalid log level'); } $this->level = $level; }
[ "public", "function", "setLevel", "(", "$", "level", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "levels", "[", "$", "level", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid log level'", ")", ";", "}"...
Set level @param int $level @throws \InvalidArgumentException If invalid log level specified
[ "Set", "level" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Log.php#L140-L146
yeephp/yeephp
Yee/Log.php
Log.log
public function log($level, $object, $context = array()) { if (!isset(self::$levels[$level])) { throw new \InvalidArgumentException('Invalid log level supplied to function'); } else if ($this->enabled && $this->writer && $level <= $this->level) { $message = (string)$object; if (count($context) > 0) { if (isset($context['exception']) && $context['exception'] instanceof \Exception) { $message .= ' - ' . $context['exception']; unset($context['exception']); } $message = $this->interpolate($message, $context); } return $this->writer->write($message, $level); } else { return false; } }
php
public function log($level, $object, $context = array()) { if (!isset(self::$levels[$level])) { throw new \InvalidArgumentException('Invalid log level supplied to function'); } else if ($this->enabled && $this->writer && $level <= $this->level) { $message = (string)$object; if (count($context) > 0) { if (isset($context['exception']) && $context['exception'] instanceof \Exception) { $message .= ' - ' . $context['exception']; unset($context['exception']); } $message = $this->interpolate($message, $context); } return $this->writer->write($message, $level); } else { return false; } }
[ "public", "function", "log", "(", "$", "level", ",", "$", "object", ",", "$", "context", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "levels", "[", "$", "level", "]", ")", ")", "{", "throw", "new", "\\", ...
Log message @param mixed $level @param mixed $object @param array $context @return mixed|bool What the Logger returns, or false if Logger not set or not enabled @throws \InvalidArgumentException If invalid log level
[ "Log", "message" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Log.php#L304-L321
MW-Peachy/Peachy
Plugins/Xml.php
Xml.element
public static function element( $element = null, $attribs = null, $contents = '', $allowShortTag = true ) { $out = '<' . $element; if( !is_null( $attribs ) ) { $out .= self::expandAttributes( $attribs ); } if( is_null( $contents ) ) { $out .= '>'; } else { if( $allowShortTag && $contents === '' ) { $out .= ' />'; } else { $out .= '>' . htmlspecialchars( $contents ) . "</$element>"; } } return $out; }
php
public static function element( $element = null, $attribs = null, $contents = '', $allowShortTag = true ) { $out = '<' . $element; if( !is_null( $attribs ) ) { $out .= self::expandAttributes( $attribs ); } if( is_null( $contents ) ) { $out .= '>'; } else { if( $allowShortTag && $contents === '' ) { $out .= ' />'; } else { $out .= '>' . htmlspecialchars( $contents ) . "</$element>"; } } return $out; }
[ "public", "static", "function", "element", "(", "$", "element", "=", "null", ",", "$", "attribs", "=", "null", ",", "$", "contents", "=", "''", ",", "$", "allowShortTag", "=", "true", ")", "{", "$", "out", "=", "'<'", ".", "$", "element", ";", "if"...
Format an XML element with given attributes and, optionally, text content. Element and attribute names are assumed to be ready for literal inclusion. Strings are assumed to not contain XML-illegal characters; special characters (<, >, &) are escaped but illegals are not touched. @param string|null $element element name @param array $attribs Name=>value pairs. Values will be escaped. @param string $contents NULL to make an open tag only; '' for a contentless closed tag (default) @param bool $allowShortTag whether '' in $contents will result in a contentless closed tag @return string
[ "Format", "an", "XML", "element", "with", "given", "attributes", "and", "optionally", "text", "content", ".", "Element", "and", "attribute", "names", "are", "assumed", "to", "be", "ready", "for", "literal", "inclusion", ".", "Strings", "are", "assumed", "to", ...
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L35-L50
MW-Peachy/Peachy
Plugins/Xml.php
Xml.expandAttributes
public static function expandAttributes( $attribs = null ) { $out = ''; if( is_null( $attribs ) ) { return null; } elseif( is_array( $attribs ) ) { foreach( $attribs as $name => $val ){ $out .= " {$name}=\"" . self::encodeAttribute( $val ) . '"'; } return $out; } else { throw new Exception( 'Expected attribute array, got something else in ' . __METHOD__ ); } }
php
public static function expandAttributes( $attribs = null ) { $out = ''; if( is_null( $attribs ) ) { return null; } elseif( is_array( $attribs ) ) { foreach( $attribs as $name => $val ){ $out .= " {$name}=\"" . self::encodeAttribute( $val ) . '"'; } return $out; } else { throw new Exception( 'Expected attribute array, got something else in ' . __METHOD__ ); } }
[ "public", "static", "function", "expandAttributes", "(", "$", "attribs", "=", "null", ")", "{", "$", "out", "=", "''", ";", "if", "(", "is_null", "(", "$", "attribs", ")", ")", "{", "return", "null", ";", "}", "elseif", "(", "is_array", "(", "$", "...
Given an array of ('attributename' => 'value'), it generates the code to set the XML attributes : attributename="value". The values are passed to self::encodeAttribute. Return null if no attributes given. @param array|null $attribs of attributes for an XML element @throws Exception @return null|string
[ "Given", "an", "array", "of", "(", "attributename", "=", ">", "value", ")", "it", "generates", "the", "code", "to", "set", "the", "XML", "attributes", ":", "attributename", "=", "value", ".", "The", "values", "are", "passed", "to", "self", "::", "encodeA...
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L78-L90
MW-Peachy/Peachy
Plugins/Xml.php
Xml.elementClean
public static function elementClean( $element, $attribs = array(), $contents = '' ) { if( $attribs ) { $attribs = array_map( array( 'UtfNormal', 'cleanUp' ), $attribs ); } if( $contents ) { $contents = WebRequest::normalize_static( $contents ); } return self::element( $element, $attribs, $contents ); }
php
public static function elementClean( $element, $attribs = array(), $contents = '' ) { if( $attribs ) { $attribs = array_map( array( 'UtfNormal', 'cleanUp' ), $attribs ); } if( $contents ) { $contents = WebRequest::normalize_static( $contents ); } return self::element( $element, $attribs, $contents ); }
[ "public", "static", "function", "elementClean", "(", "$", "element", ",", "$", "attribs", "=", "array", "(", ")", ",", "$", "contents", "=", "''", ")", "{", "if", "(", "$", "attribs", ")", "{", "$", "attribs", "=", "array_map", "(", "array", "(", "...
Format an XML element as with self::element(), but run text through the $wgContLang->normalize() validator first to ensure that no invalid UTF-8 is passed. @param $element String: @param array $attribs Name=>value pairs. Values will be escaped. @param string $contents NULL to make an open tag only; '' for a contentless closed tag (default) @return string
[ "Format", "an", "XML", "element", "as", "with", "self", "::", "element", "()", "but", "run", "text", "through", "the", "$wgContLang", "-", ">", "normalize", "()", "validator", "first", "to", "ensure", "that", "no", "invalid", "UTF", "-", "8", "is", "pass...
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L102-L110
MW-Peachy/Peachy
Plugins/Xml.php
Xml.tags
public static function tags( $element, $attribs = null, $contents ) { return self::openElement( $element, $attribs ) . $contents . "</$element>"; }
php
public static function tags( $element, $attribs = null, $contents ) { return self::openElement( $element, $attribs ) . $contents . "</$element>"; }
[ "public", "static", "function", "tags", "(", "$", "element", ",", "$", "attribs", "=", "null", ",", "$", "contents", ")", "{", "return", "self", "::", "openElement", "(", "$", "element", ",", "$", "attribs", ")", ".", "$", "contents", ".", "\"</$elemen...
Same as self::element(), but does not escape contents. Handy when the content you have is already valid xml. @param string $element element name @param array $attribs of attributes @param string $contents content of the element @return string
[ "Same", "as", "self", "::", "element", "()", "but", "does", "not", "escape", "contents", ".", "Handy", "when", "the", "content", "you", "have", "is", "already", "valid", "xml", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L141-L143
MW-Peachy/Peachy
Plugins/Xml.php
Xml.input
public static function input( $name, $size = false, $value = false, $attribs = array() ) { $attributes = array( 'name' => $name ); if( $size ) { $attributes['size'] = $size; } if( $value !== false ) { // maybe 0 $attributes['value'] = $value; } return self::element( 'input', $attributes + $attribs ); }
php
public static function input( $name, $size = false, $value = false, $attribs = array() ) { $attributes = array( 'name' => $name ); if( $size ) { $attributes['size'] = $size; } if( $value !== false ) { // maybe 0 $attributes['value'] = $value; } return self::element( 'input', $attributes + $attribs ); }
[ "public", "static", "function", "input", "(", "$", "name", ",", "$", "size", "=", "false", ",", "$", "value", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "$", "attributes", "=", "array", "(", "'name'", "=>", "$", "name", ...
Convenience function to build an HTML text input field @param string $name value of the name attribute @param bool|int $size value of the size attribute @param mixed $value mixed value of the value attribute @param array $attribs other attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "text", "input", "field" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L176-L188
MW-Peachy/Peachy
Plugins/Xml.php
Xml.password
public static function password( $name, $size = false, $value = false, $attribs = array() ) { return self::input( $name, $size, $value, array_merge( $attribs, array( 'type' => 'password' ) ) ); }
php
public static function password( $name, $size = false, $value = false, $attribs = array() ) { return self::input( $name, $size, $value, array_merge( $attribs, array( 'type' => 'password' ) ) ); }
[ "public", "static", "function", "password", "(", "$", "name", ",", "$", "size", "=", "false", ",", "$", "value", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "input", "(", "$", "name", ",", "$", "si...
Convenience function to build an HTML password input field @param string $name value of the name attribute @param bool|int $size value of the size attribute @param $value mixed value of the value attribute @param array $attribs other attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "password", "input", "field" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L198-L200
MW-Peachy/Peachy
Plugins/Xml.php
Xml.check
public static function check( $name, $checked = false, $attribs = array() ) { return self::element( 'input', array_merge( array( 'name' => $name, 'type' => 'checkbox', 'value' => 1 ), self::attrib( 'checked', $checked ), $attribs ) ); }
php
public static function check( $name, $checked = false, $attribs = array() ) { return self::element( 'input', array_merge( array( 'name' => $name, 'type' => 'checkbox', 'value' => 1 ), self::attrib( 'checked', $checked ), $attribs ) ); }
[ "public", "static", "function", "check", "(", "$", "name", ",", "$", "checked", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "element", "(", "'input'", ",", "array_merge", "(", "array", "(", "'name'", "...
Convenience function to build an HTML checkbox @param string $name value of the name attribute @param bool $checked Whether the checkbox is checked or not @param array $attribs other attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "checkbox" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L221-L233
MW-Peachy/Peachy
Plugins/Xml.php
Xml.radio
public static function radio( $name, $value, $checked = false, $attribs = array() ) { return self::element( 'input', array( 'name' => $name, 'type' => 'radio', 'value' => $value ) + self::attrib( 'checked', $checked ) + $attribs ); }
php
public static function radio( $name, $value, $checked = false, $attribs = array() ) { return self::element( 'input', array( 'name' => $name, 'type' => 'radio', 'value' => $value ) + self::attrib( 'checked', $checked ) + $attribs ); }
[ "public", "static", "function", "radio", "(", "$", "name", ",", "$", "value", ",", "$", "checked", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "element", "(", "'input'", ",", "array", "(", "'name'", ...
Convenience function to build an HTML radio button @param string $name value of the name attribute @param string $value value of the value attribute @param bool $checked Whether the checkbox is checked or not @param array $attribs other attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "radio", "button" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L243-L251
MW-Peachy/Peachy
Plugins/Xml.php
Xml.label
public static function label( $label, $id, $attribs = array() ) { $a = array( 'for' => $id ); // FIXME avoid copy pasting below: if( isset( $attribs['class'] ) ) { $a['class'] = $attribs['class']; } if( isset( $attribs['title'] ) ) { $a['title'] = $attribs['title']; } return self::element( 'label', $a, $label ); }
php
public static function label( $label, $id, $attribs = array() ) { $a = array( 'for' => $id ); // FIXME avoid copy pasting below: if( isset( $attribs['class'] ) ) { $a['class'] = $attribs['class']; } if( isset( $attribs['title'] ) ) { $a['title'] = $attribs['title']; } return self::element( 'label', $a, $label ); }
[ "public", "static", "function", "label", "(", "$", "label", ",", "$", "id", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "$", "a", "=", "array", "(", "'for'", "=>", "$", "id", ")", ";", "// FIXME avoid copy pasting below:", "if", "(", "isse...
Convenience function to build an HTML form label @param string $label text of the label @param $id @param array $attribs an attribute array. This will usually be the same array as is passed to the corresponding input element, so this function will cherry-pick appropriate attributes to apply to the label as well; only class and title are applied. @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "form", "label" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L263-L275
MW-Peachy/Peachy
Plugins/Xml.php
Xml.inputLabel
public static function inputLabel( $label, $name, $id, $size = false, $value = false, $attribs = array() ) { list( $label, $input ) = self::inputLabelSep( $label, $name, $id, $size, $value, $attribs ); return $label . '&#160;' . $input; }
php
public static function inputLabel( $label, $name, $id, $size = false, $value = false, $attribs = array() ) { list( $label, $input ) = self::inputLabelSep( $label, $name, $id, $size, $value, $attribs ); return $label . '&#160;' . $input; }
[ "public", "static", "function", "inputLabel", "(", "$", "label", ",", "$", "name", ",", "$", "id", ",", "$", "size", "=", "false", ",", "$", "value", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "list", "(", "$", "label", ...
Convenience function to build an HTML text input field with a label @param string $label text of the label @param string $name value of the name attribute @param string $id id of the input @param int|Bool $size value of the size attribute @param string|Bool $value value of the value attribute @param array $attribs other attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "text", "input", "field", "with", "a", "label" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L287-L290
MW-Peachy/Peachy
Plugins/Xml.php
Xml.checkLabel
public static function checkLabel( $label, $name, $id, $checked = false, $attribs = array() ) { return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) . '&#160;' . self::label( $label, $id, $attribs ); }
php
public static function checkLabel( $label, $name, $id, $checked = false, $attribs = array() ) { return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) . '&#160;' . self::label( $label, $id, $attribs ); }
[ "public", "static", "function", "checkLabel", "(", "$", "label", ",", "$", "name", ",", "$", "id", ",", "$", "checked", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "check", "(", "$", "name", ",", "...
Convenience function to build an HTML checkbox with a label @param $label @param $name @param $id @param $checked bool @param $attribs array @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "checkbox", "with", "a", "label" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L322-L326
MW-Peachy/Peachy
Plugins/Xml.php
Xml.radioLabel
public static function radioLabel( $label, $name, $value, $id, $checked = false, $attribs = array() ) { return self::radio( $name, $value, $checked, array( 'id' => $id ) + $attribs ) . '&#160;' . self::label( $label, $id, $attribs ); }
php
public static function radioLabel( $label, $name, $value, $id, $checked = false, $attribs = array() ) { return self::radio( $name, $value, $checked, array( 'id' => $id ) + $attribs ) . '&#160;' . self::label( $label, $id, $attribs ); }
[ "public", "static", "function", "radioLabel", "(", "$", "label", ",", "$", "name", ",", "$", "value", ",", "$", "id", ",", "$", "checked", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "radio", "(", ...
Convenience function to build an HTML radio button with a label @param $label @param $name @param $value @param $id @param $checked bool @param $attribs array @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "radio", "button", "with", "a", "label" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L340-L344
MW-Peachy/Peachy
Plugins/Xml.php
Xml.option
public static function option( $text, $value = null, $selected = false, $attribs = array() ) { if( !is_null( $value ) ) { $attribs['value'] = $value; } if( $selected ) { $attribs['selected'] = 'selected'; } return self::element( 'option', $attribs, $text ); }
php
public static function option( $text, $value = null, $selected = false, $attribs = array() ) { if( !is_null( $value ) ) { $attribs['value'] = $value; } if( $selected ) { $attribs['selected'] = 'selected'; } return self::element( 'option', $attribs, $text ); }
[ "public", "static", "function", "option", "(", "$", "text", ",", "$", "value", "=", "null", ",", "$", "selected", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", ...
Convenience function to build an HTML drop-down list item. @param string $text text for this item. Will be HTML escaped @param string $value form submission value; if empty, use text @param $selected boolean: if true, will be the default selected item @param array $attribs optional additional HTML attributes @return string HTML
[ "Convenience", "function", "to", "build", "an", "HTML", "drop", "-", "down", "list", "item", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L364-L373
MW-Peachy/Peachy
Plugins/Xml.php
Xml.listDropDown
public static function listDropDown( $name = '', $list = '', $other = '', $selected = '', $class = '', $tabindex = null ) { $optgroup = false; $options = self::option( $other, 'other', $selected === 'other' ); foreach( explode( "\n", $list ) as $option ){ $value = trim( $option ); if( $value == '' ) { continue; } elseif( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) { // A new group is starting ... $value = trim( substr( $value, 1 ) ); if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $options .= self::openElement( 'optgroup', array( 'label' => $value ) ); $optgroup = true; } elseif( substr( $value, 0, 2 ) == '**' ) { // groupmember $value = trim( substr( $value, 2 ) ); $options .= self::option( $value, $value, $selected === $value ); } else { // groupless reason list if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $options .= self::option( $value, $value, $selected === $value ); $optgroup = false; } } if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $attribs = array(); if( $name ) { $attribs['id'] = $name; $attribs['name'] = $name; } if( $class ) { $attribs['class'] = $class; } if( $tabindex ) { $attribs['tabindex'] = $tabindex; } return self::openElement( 'select', $attribs ) . "\n" . $options . "\n" . self::closeElement( 'select' ); }
php
public static function listDropDown( $name = '', $list = '', $other = '', $selected = '', $class = '', $tabindex = null ) { $optgroup = false; $options = self::option( $other, 'other', $selected === 'other' ); foreach( explode( "\n", $list ) as $option ){ $value = trim( $option ); if( $value == '' ) { continue; } elseif( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) { // A new group is starting ... $value = trim( substr( $value, 1 ) ); if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $options .= self::openElement( 'optgroup', array( 'label' => $value ) ); $optgroup = true; } elseif( substr( $value, 0, 2 ) == '**' ) { // groupmember $value = trim( substr( $value, 2 ) ); $options .= self::option( $value, $value, $selected === $value ); } else { // groupless reason list if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $options .= self::option( $value, $value, $selected === $value ); $optgroup = false; } } if( $optgroup ) { $options .= self::closeElement( 'optgroup' ); } $attribs = array(); if( $name ) { $attribs['id'] = $name; $attribs['name'] = $name; } if( $class ) { $attribs['class'] = $class; } if( $tabindex ) { $attribs['tabindex'] = $tabindex; } return self::openElement( 'select', $attribs ) . "\n" . $options . "\n" . self::closeElement( 'select' ); }
[ "public", "static", "function", "listDropDown", "(", "$", "name", "=", "''", ",", "$", "list", "=", "''", ",", "$", "other", "=", "''", ",", "$", "selected", "=", "''", ",", "$", "class", "=", "''", ",", "$", "tabindex", "=", "null", ")", "{", ...
Build a drop-down box from a textual list. @param $name Mixed: Name and id for the drop-down @param $list Mixed: Correctly formatted text (newline delimited) to be used to generate the options @param $other Mixed: Text for the "Other reasons" option @param $selected Mixed: Option which should be pre-selected @param $class Mixed: CSS classes for the drop-down @param $tabindex Mixed: Value of the tabindex attribute @return string
[ "Build", "a", "drop", "-", "down", "box", "from", "a", "textual", "list", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L386-L441
MW-Peachy/Peachy
Plugins/Xml.php
Xml.fieldset
public static function fieldset( $legend = false, $content = false, $attribs = array() ) { $s = self::openElement( 'fieldset', $attribs ) . "\n"; if( $legend ) { $s .= self::element( 'legend', null, $legend ) . "\n"; } if( $content !== false ) { $s .= $content . "\n"; $s .= self::closeElement( 'fieldset' ) . "\n"; } return $s; }
php
public static function fieldset( $legend = false, $content = false, $attribs = array() ) { $s = self::openElement( 'fieldset', $attribs ) . "\n"; if( $legend ) { $s .= self::element( 'legend', null, $legend ) . "\n"; } if( $content !== false ) { $s .= $content . "\n"; $s .= self::closeElement( 'fieldset' ) . "\n"; } return $s; }
[ "public", "static", "function", "fieldset", "(", "$", "legend", "=", "false", ",", "$", "content", "=", "false", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "$", "s", "=", "self", "::", "openElement", "(", "'fieldset'", ",", "$", "attribs"...
Shortcut for creating fieldsets. @param string|bool $legend Legend of the fieldset. If evaluates to false, legend is not added. @param string|bool $content Pre-escaped content for the fieldset. If false, only open fieldset is returned. @param array $attribs Any attributes to fieldset-element. @return string
[ "Shortcut", "for", "creating", "fieldsets", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L452-L465
MW-Peachy/Peachy
Plugins/Xml.php
Xml.textarea
public static function textarea( $name, $content, $cols = 40, $rows = 5, $attribs = array() ) { return self::element( 'textarea', array( 'name' => $name, 'id' => $name, 'cols' => $cols, 'rows' => $rows ) + $attribs, $content, false ); }
php
public static function textarea( $name, $content, $cols = 40, $rows = 5, $attribs = array() ) { return self::element( 'textarea', array( 'name' => $name, 'id' => $name, 'cols' => $cols, 'rows' => $rows ) + $attribs, $content, false ); }
[ "public", "static", "function", "textarea", "(", "$", "name", ",", "$", "content", ",", "$", "cols", "=", "40", ",", "$", "rows", "=", "5", ",", "$", "attribs", "=", "array", "(", ")", ")", "{", "return", "self", "::", "element", "(", "'textarea'",...
Shortcut for creating textareas. @param string $name The 'name' for the textarea @param string $content Content for the textarea @param int $cols The number of columns for the textarea @param int $rows The number of rows for the textarea @param array $attribs Any other attributes for the textarea @return string
[ "Shortcut", "for", "creating", "textareas", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L478-L489
MW-Peachy/Peachy
Plugins/Xml.php
Xml.encodeJsVar
public static function encodeJsVar( $value ) { if( is_bool( $value ) ) { $s = $value ? 'true' : 'false'; } elseif( is_null( $value ) ) { $s = 'null'; } elseif( is_int( $value ) ) { $s = $value; } elseif( is_array( $value ) && // Make sure it's not associative. array_keys( $value ) === range( 0, count( $value ) - 1 ) || count( $value ) == 0 ) { $s = '['; foreach( $value as $elt ){ if( $s != '[' ) { $s .= ', '; } $s .= self::encodeJsVar( $elt ); } $s .= ']'; } elseif( is_object( $value ) || is_array( $value ) ) { // Objects and associative arrays $s = '{'; foreach( (array)$value as $name => $elt ){ if( $s != '{' ) { $s .= ', '; } $s .= '"' . self::escapeJsString( $name ) . '": ' . self::encodeJsVar( $elt ); } $s .= '}'; } else { $s = '"' . self::escapeJsString( $value ) . '"'; } return $s; }
php
public static function encodeJsVar( $value ) { if( is_bool( $value ) ) { $s = $value ? 'true' : 'false'; } elseif( is_null( $value ) ) { $s = 'null'; } elseif( is_int( $value ) ) { $s = $value; } elseif( is_array( $value ) && // Make sure it's not associative. array_keys( $value ) === range( 0, count( $value ) - 1 ) || count( $value ) == 0 ) { $s = '['; foreach( $value as $elt ){ if( $s != '[' ) { $s .= ', '; } $s .= self::encodeJsVar( $elt ); } $s .= ']'; } elseif( is_object( $value ) || is_array( $value ) ) { // Objects and associative arrays $s = '{'; foreach( (array)$value as $name => $elt ){ if( $s != '{' ) { $s .= ', '; } $s .= '"' . self::escapeJsString( $name ) . '": ' . self::encodeJsVar( $elt ); } $s .= '}'; } else { $s = '"' . self::escapeJsString( $value ) . '"'; } return $s; }
[ "public", "static", "function", "encodeJsVar", "(", "$", "value", ")", "{", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "s", "=", "$", "value", "?", "'true'", ":", "'false'", ";", "}", "elseif", "(", "is_null", "(", "$", "value", ...
Encode a variable of unknown type to JavaScript. Arrays are converted to JS arrays, objects are converted to JS associative arrays (objects). So cast your PHP associative arrays to objects before passing them to here. @param $value @return int|string
[ "Encode", "a", "variable", "of", "unknown", "type", "to", "JavaScript", ".", "Arrays", "are", "converted", "to", "JS", "arrays", "objects", "are", "converted", "to", "JS", "associative", "arrays", "(", "objects", ")", ".", "So", "cast", "your", "PHP", "ass...
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L535-L569
MW-Peachy/Peachy
Plugins/Xml.php
Xml.encodeJsCall
public static function encodeJsCall( $name, $args, $pretty = false ) { foreach( $args as &$arg ){ $arg = self::encodeJsVar($arg); if( $arg === false ) { return false; } } return "$name(" . ( $pretty ? ( ' ' . implode( ', ', $args ) . ' ' ) : implode( ',', $args ) ) . ");"; }
php
public static function encodeJsCall( $name, $args, $pretty = false ) { foreach( $args as &$arg ){ $arg = self::encodeJsVar($arg); if( $arg === false ) { return false; } } return "$name(" . ( $pretty ? ( ' ' . implode( ', ', $args ) . ' ' ) : implode( ',', $args ) ) . ");"; }
[ "public", "static", "function", "encodeJsCall", "(", "$", "name", ",", "$", "args", ",", "$", "pretty", "=", "false", ")", "{", "foreach", "(", "$", "args", "as", "&", "$", "arg", ")", "{", "$", "arg", "=", "self", "::", "encodeJsVar", "(", "$", ...
Create a call to a JavaScript function. The supplied arguments will be encoded using self::encodeJsVar(). @since 1.17 @param string $name The name of the function to call, or a JavaScript expression which evaluates to a function object which is called. @param array $args The arguments to pass to the function. @param bool $pretty If true, add non-significant whitespace to improve readability. @return string|bool: String if successful; false upon failure
[ "Create", "a", "call", "to", "a", "JavaScript", "function", ".", "The", "supplied", "arguments", "will", "be", "encoded", "using", "self", "::", "encodeJsVar", "()", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L582-L594
MW-Peachy/Peachy
Plugins/Xml.php
Xml.isWellFormed
public static function isWellFormed( $text ) { $parser = xml_parser_create( "UTF-8" ); # case folding violates XML standard, turn it off xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false ); if( !xml_parse( $parser, $text, true ) ) { //$err = xml_error_string( xml_get_error_code( $parser ) ); //$position = xml_get_current_byte_index( $parser ); //$fragment = $this->extractFragment( $html, $position ); //$this->mXmlError = "$err at byte $position:\n$fragment"; xml_parser_free( $parser ); return false; } xml_parser_free( $parser ); return true; }
php
public static function isWellFormed( $text ) { $parser = xml_parser_create( "UTF-8" ); # case folding violates XML standard, turn it off xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false ); if( !xml_parse( $parser, $text, true ) ) { //$err = xml_error_string( xml_get_error_code( $parser ) ); //$position = xml_get_current_byte_index( $parser ); //$fragment = $this->extractFragment( $html, $position ); //$this->mXmlError = "$err at byte $position:\n$fragment"; xml_parser_free( $parser ); return false; } xml_parser_free( $parser ); return true; }
[ "public", "static", "function", "isWellFormed", "(", "$", "text", ")", "{", "$", "parser", "=", "xml_parser_create", "(", "\"UTF-8\"", ")", ";", "# case folding violates XML standard, turn it off", "xml_parser_set_option", "(", "$", "parser", ",", "XML_OPTION_CASE_FOLDI...
Check if a string is well-formed XML. Must include the surrounding tag. @param string $text string to test. @return bool @todo Error position reporting return
[ "Check", "if", "a", "string", "is", "well", "-", "formed", "XML", ".", "Must", "include", "the", "surrounding", "tag", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L605-L623
MW-Peachy/Peachy
Plugins/Xml.php
Xml.buildTable
public static function buildTable( $rows, $attribs = array(), $headers = null ) { $s = self::openElement( 'table', $attribs ); if( is_array( $headers ) ) { $s .= self::openElement( 'thead', $attribs ); foreach( $headers as $id => $header ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::element( 'th', $attribs, $header ); } $s .= self::closeElement( 'thead' ); } foreach( $rows as $id => $row ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::buildTableRow( $attribs, $row ); } $s .= self::closeElement( 'table' ); return $s; }
php
public static function buildTable( $rows, $attribs = array(), $headers = null ) { $s = self::openElement( 'table', $attribs ); if( is_array( $headers ) ) { $s .= self::openElement( 'thead', $attribs ); foreach( $headers as $id => $header ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::element( 'th', $attribs, $header ); } $s .= self::closeElement( 'thead' ); } foreach( $rows as $id => $row ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::buildTableRow( $attribs, $row ); } $s .= self::closeElement( 'table' ); return $s; }
[ "public", "static", "function", "buildTable", "(", "$", "rows", ",", "$", "attribs", "=", "array", "(", ")", ",", "$", "headers", "=", "null", ")", "{", "$", "s", "=", "self", "::", "openElement", "(", "'table'", ",", "$", "attribs", ")", ";", "if"...
Build a table of data @param array $rows An array of arrays of strings, each to be a row in a table @param array $attribs An array of attributes to apply to the table tag [optional] @param array $headers An array of strings to use as table headers [optional] @return string
[ "Build", "a", "table", "of", "data" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L928-L959
MW-Peachy/Peachy
Plugins/Xml.php
Xml.buildTableRow
public static function buildTableRow( $attribs, $cells ) { $s = self::openElement( 'tr', $attribs ); foreach( $cells as $id => $cell ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::element( 'td', $attribs, $cell ); } $s .= self::closeElement( 'tr' ); return $s; }
php
public static function buildTableRow( $attribs, $cells ) { $s = self::openElement( 'tr', $attribs ); foreach( $cells as $id => $cell ){ $attribs = array(); if( is_string( $id ) ) { $attribs['id'] = $id; } $s .= self::element( 'td', $attribs, $cell ); } $s .= self::closeElement( 'tr' ); return $s; }
[ "public", "static", "function", "buildTableRow", "(", "$", "attribs", ",", "$", "cells", ")", "{", "$", "s", "=", "self", "::", "openElement", "(", "'tr'", ",", "$", "attribs", ")", ";", "foreach", "(", "$", "cells", "as", "$", "id", "=>", "$", "ce...
Build a row for a table @param array $attribs An array of attributes to apply to the tr tag @param array $cells An array of strings to put in <td> @return string
[ "Build", "a", "row", "for", "a", "table" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L967-L983
MW-Peachy/Peachy
Plugins/Xml.php
XmlSelect.formatOptions
static function formatOptions( $options, $default = false ) { $data = ''; foreach( $options as $label => $value ){ if( is_array( $value ) ) { $contents = self::formatOptions( $value, $default ); $data .= self::tags( 'optgroup', array( 'label' => $label ), $contents ) . "\n"; } else { $data .= self::option( $label, $value, $value === $default ) . "\n"; } } return $data; }
php
static function formatOptions( $options, $default = false ) { $data = ''; foreach( $options as $label => $value ){ if( is_array( $value ) ) { $contents = self::formatOptions( $value, $default ); $data .= self::tags( 'optgroup', array( 'label' => $label ), $contents ) . "\n"; } else { $data .= self::option( $label, $value, $value === $default ) . "\n"; } } return $data; }
[ "static", "function", "formatOptions", "(", "$", "options", ",", "$", "default", "=", "false", ")", "{", "$", "data", "=", "''", ";", "foreach", "(", "$", "options", "as", "$", "label", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$",...
This accepts an array of form label => value label => ( label => value, label => value ) @param $options @param bool $default @return string
[ "This", "accepts", "an", "array", "of", "form", "label", "=", ">", "value", "label", "=", ">", "(", "label", "=", ">", "value", "label", "=", ">", "value", ")" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/Xml.php#L1063-L1076
joomla-framework/input
src/Files.php
Files.get
public function get($name, $default = null, $filter = 'cmd') { if (isset($this->data[$name])) { $results = $this->decodeData( array( $this->data[$name]['name'], $this->data[$name]['type'], $this->data[$name]['tmp_name'], $this->data[$name]['error'], $this->data[$name]['size'], ) ); return $results; } return $default; }
php
public function get($name, $default = null, $filter = 'cmd') { if (isset($this->data[$name])) { $results = $this->decodeData( array( $this->data[$name]['name'], $this->data[$name]['type'], $this->data[$name]['tmp_name'], $this->data[$name]['error'], $this->data[$name]['size'], ) ); return $results; } return $default; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ",", "$", "filter", "=", "'cmd'", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "name", "]", ")", ")", "{", "$", "results", "=", "$", "...
Gets a value from the input data. @param string $name The name of the input property (usually the name of the files INPUT tag) to get. @param mixed $default The default value to return if the named property does not exist. @param string $filter The filter to apply to the value. @return mixed The filtered input value. @see \Joomla\Filter\InputFilter::clean() @since 1.0
[ "Gets", "a", "value", "from", "the", "input", "data", "." ]
train
https://github.com/joomla-framework/input/blob/62c28fa6f5f2d754918d6727ea7e24d4affcff11/src/Files.php#L67-L85
scherersoftware/cake-notifications
src/Transport/EmailTransport.php
EmailTransport.sendNotification
public static function sendNotification(Notification $notification, $content = null) { $beforeSendCallback = $notification->beforeSendCallback(); self::_performCallback($beforeSendCallback, $notification); if ($notification->locale() !== null) { I18n::locale($notification->locale()); } else { I18n::locale(Configure::read('Notifications.defaultLocale')); } $notification->email()->send($content); $afterSendCallback = $notification->afterSendCallback(); self::_performCallback($afterSendCallback); return $notification; }
php
public static function sendNotification(Notification $notification, $content = null) { $beforeSendCallback = $notification->beforeSendCallback(); self::_performCallback($beforeSendCallback, $notification); if ($notification->locale() !== null) { I18n::locale($notification->locale()); } else { I18n::locale(Configure::read('Notifications.defaultLocale')); } $notification->email()->send($content); $afterSendCallback = $notification->afterSendCallback(); self::_performCallback($afterSendCallback); return $notification; }
[ "public", "static", "function", "sendNotification", "(", "Notification", "$", "notification", ",", "$", "content", "=", "null", ")", "{", "$", "beforeSendCallback", "=", "$", "notification", "->", "beforeSendCallback", "(", ")", ";", "self", "::", "_performCallb...
Send function @param Notification $notification Notification object @param string|array|null $content String with message or array with messages @return Notification
[ "Send", "function" ]
train
https://github.com/scherersoftware/cake-notifications/blob/916fa8d60dbe94c0b146339eed147b1a1f2a1902/src/Transport/EmailTransport.php#L22-L39
scherersoftware/cake-notifications
src/Transport/EmailTransport.php
EmailTransport.processQueueObject
public static function processQueueObject(Base $job) { $notification = new EmailNotification(); if ($job->data('beforeSendCallback') !== []) { foreach ($job->data('beforeSendCallback') as $callback) { $notification->addBeforeSendCallback($callback['class'], $callback['args']); } } if ($job->data('afterSendCallback') !== []) { foreach ($job->data('afterSendCallback') as $callback) { $notification->addAfterSendCallback($callback['class'], $callback['args']); } } if ($job->data('locale') !== '') { $notification->locale($job->data('locale')); } $notification->unserialize($job->data('email')); return self::sendNotification($notification); }
php
public static function processQueueObject(Base $job) { $notification = new EmailNotification(); if ($job->data('beforeSendCallback') !== []) { foreach ($job->data('beforeSendCallback') as $callback) { $notification->addBeforeSendCallback($callback['class'], $callback['args']); } } if ($job->data('afterSendCallback') !== []) { foreach ($job->data('afterSendCallback') as $callback) { $notification->addAfterSendCallback($callback['class'], $callback['args']); } } if ($job->data('locale') !== '') { $notification->locale($job->data('locale')); } $notification->unserialize($job->data('email')); return self::sendNotification($notification); }
[ "public", "static", "function", "processQueueObject", "(", "Base", "$", "job", ")", "{", "$", "notification", "=", "new", "EmailNotification", "(", ")", ";", "if", "(", "$", "job", "->", "data", "(", "'beforeSendCallback'", ")", "!==", "[", "]", ")", "{"...
Process the job coming from the queue @param Base $job Queuesadilla base job @return void
[ "Process", "the", "job", "coming", "from", "the", "queue" ]
train
https://github.com/scherersoftware/cake-notifications/blob/916fa8d60dbe94c0b146339eed147b1a1f2a1902/src/Transport/EmailTransport.php#L47-L67
marvin255/bxcodegen
src/service/filesystem/PathHelper.php
PathHelper.unify
public static function unify($path, $separator = null) { $separator = $separator ?: self::getDirectorySeparator(); $unified = trim($path, " \t\n\r\0\x0B"); $unified = str_replace(['/', '\\'], $separator, $unified); $unified = preg_replace('#[' . preg_quote($separator, '#') . ']{2,}#', $separator, $unified); $unified = rtrim($unified, $separator); return $unified; }
php
public static function unify($path, $separator = null) { $separator = $separator ?: self::getDirectorySeparator(); $unified = trim($path, " \t\n\r\0\x0B"); $unified = str_replace(['/', '\\'], $separator, $unified); $unified = preg_replace('#[' . preg_quote($separator, '#') . ']{2,}#', $separator, $unified); $unified = rtrim($unified, $separator); return $unified; }
[ "public", "static", "function", "unify", "(", "$", "path", ",", "$", "separator", "=", "null", ")", "{", "$", "separator", "=", "$", "separator", "?", ":", "self", "::", "getDirectorySeparator", "(", ")", ";", "$", "unified", "=", "trim", "(", "$", "...
Преобразует путь в файловой системе к общему стандартному виду. @param string $path @param string|null $separator @return string
[ "Преобразует", "путь", "в", "файловой", "системе", "к", "общему", "стандартному", "виду", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/filesystem/PathHelper.php#L18-L27
marvin255/bxcodegen
src/service/filesystem/PathHelper.php
PathHelper.getRealPath
public static function getRealPath($path) { $real = realpath(self::unify($path)); return $real ? self::unify($real) : null; }
php
public static function getRealPath($path) { $real = realpath(self::unify($path)); return $real ? self::unify($real) : null; }
[ "public", "static", "function", "getRealPath", "(", "$", "path", ")", "{", "$", "real", "=", "realpath", "(", "self", "::", "unify", "(", "$", "path", ")", ")", ";", "return", "$", "real", "?", "self", "::", "unify", "(", "$", "real", ")", ":", "...
Возвращает канонизированнный абсолютный путь для указанного. @param string $path @return string|null
[ "Возвращает", "канонизированнный", "абсолютный", "путь", "для", "указанного", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/filesystem/PathHelper.php#L36-L41
marvin255/bxcodegen
src/service/filesystem/PathHelper.php
PathHelper.combine
public static function combine(array $parts, $separator = null) { $separator = $separator ?: self::getDirectorySeparator(); $unifiedParts = array_values($parts); array_walk($unifiedParts, function (&$part, $key) use ($separator) { $part = PathHelper::unify($part); $part = $key === 0 ? $part : ltrim($part, $separator); }); return implode($separator, $unifiedParts); }
php
public static function combine(array $parts, $separator = null) { $separator = $separator ?: self::getDirectorySeparator(); $unifiedParts = array_values($parts); array_walk($unifiedParts, function (&$part, $key) use ($separator) { $part = PathHelper::unify($part); $part = $key === 0 ? $part : ltrim($part, $separator); }); return implode($separator, $unifiedParts); }
[ "public", "static", "function", "combine", "(", "array", "$", "parts", ",", "$", "separator", "=", "null", ")", "{", "$", "separator", "=", "$", "separator", "?", ":", "self", "::", "getDirectorySeparator", "(", ")", ";", "$", "unifiedParts", "=", "array...
Объединяет отрезки пути в общий путь. @param array $parts @param string|null $separator @return string
[ "Объединяет", "отрезки", "пути", "в", "общий", "путь", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/filesystem/PathHelper.php#L51-L62
marvin255/bxcodegen
src/service/filesystem/PathHelper.php
PathHelper.isAbsolute
public static function isAbsolute($path, $separator = null) { $separator = $separator ?: self::getDirectorySeparator(); $unified = self::unify($path, $separator); return preg_match('#^' . preg_quote($separator, '#') . '.*#', $unified) || preg_match('#^[a-zA-Z]{1}:.*#', $unified); }
php
public static function isAbsolute($path, $separator = null) { $separator = $separator ?: self::getDirectorySeparator(); $unified = self::unify($path, $separator); return preg_match('#^' . preg_quote($separator, '#') . '.*#', $unified) || preg_match('#^[a-zA-Z]{1}:.*#', $unified); }
[ "public", "static", "function", "isAbsolute", "(", "$", "path", ",", "$", "separator", "=", "null", ")", "{", "$", "separator", "=", "$", "separator", "?", ":", "self", "::", "getDirectorySeparator", "(", ")", ";", "$", "unified", "=", "self", "::", "u...
Проверяет является ли путь абсолютным (начинается ли от корня). @param string $path @param string|null $separator @return bool
[ "Проверяет", "является", "ли", "путь", "абсолютным", "(", "начинается", "ли", "от", "корня", ")", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/filesystem/PathHelper.php#L72-L79
budde377/Part
lib/controller/ajax/type_handler/BackendTypeHandlerImpl.php
BackendTypeHandlerImpl.setUp
public function setUp(Server $server, $type) { $server->registerHandler($this->backend->getUserLibraryInstance()->generateTypeHandler()); if(($user = $this->backend->getUserLibraryInstance()->getUserLoggedIn()) != null){ $server->registerHandler($user->generateTypeHandler()); } $server->registerHandler($this->backend->getPageOrderInstance()->generateTypeHandler()); if(($page = $this->backend->getPageOrderInstance()->getCurrentPage()) != null){ $server->registerHandler($page->generateTypeHandler()); } $server->registerHandler($this->backend->getLoggerInstance()->generateTypeHandler()); $server->registerHandler($this->backend->getUpdaterInstance()->generateTypeHandler()); $server->registerHandler($this->backend->getSiteInstance()->generateTypeHandler()); $server->registerHandler($this->backend->getFileLibraryInstance()->generateTypeHandler()); $server->registerHandler(new PostGetFilesArrayAccessTypeHandlerImpl()); $server->registerHandler(new ParserTypeHandlerImpl()); }
php
public function setUp(Server $server, $type) { $server->registerHandler($this->backend->getUserLibraryInstance()->generateTypeHandler()); if(($user = $this->backend->getUserLibraryInstance()->getUserLoggedIn()) != null){ $server->registerHandler($user->generateTypeHandler()); } $server->registerHandler($this->backend->getPageOrderInstance()->generateTypeHandler()); if(($page = $this->backend->getPageOrderInstance()->getCurrentPage()) != null){ $server->registerHandler($page->generateTypeHandler()); } $server->registerHandler($this->backend->getLoggerInstance()->generateTypeHandler()); $server->registerHandler($this->backend->getUpdaterInstance()->generateTypeHandler()); $server->registerHandler($this->backend->getSiteInstance()->generateTypeHandler()); $server->registerHandler($this->backend->getFileLibraryInstance()->generateTypeHandler()); $server->registerHandler(new PostGetFilesArrayAccessTypeHandlerImpl()); $server->registerHandler(new ParserTypeHandlerImpl()); }
[ "public", "function", "setUp", "(", "Server", "$", "server", ",", "$", "type", ")", "{", "$", "server", "->", "registerHandler", "(", "$", "this", "->", "backend", "->", "getUserLibraryInstance", "(", ")", "->", "generateTypeHandler", "(", ")", ")", ";", ...
Sets up the type handler for provided type. This should be called for each registered type. @param Server $server The server which is setting-up the handler @param string $type The type currently being set-up @return void
[ "Sets", "up", "the", "type", "handler", "for", "provided", "type", ".", "This", "should", "be", "called", "for", "each", "registered", "type", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/controller/ajax/type_handler/BackendTypeHandlerImpl.php#L38-L58
goalio/GoalioMailService
src/GoalioMailService/Mail/Service/Message.php
Message.createHtmlMessage
public function createHtmlMessage($from, $to, $subject, $nameOrModel, $values = array()) { $renderer = $this->getRenderer(); $content = $renderer->render($nameOrModel, $values); $text = new MimePart(''); $text->type = "text/plain"; $html = new MimePart($content); $html->type = "text/html; charset=UTF-8"; $html->encoding = Mime::ENCODING_QUOTEDPRINTABLE; $body = new MimeMessage(); $body->setParts(array($text, $html)); return $this->getDefaultMessage($from, 'utf-8', $to, $subject, $body); }
php
public function createHtmlMessage($from, $to, $subject, $nameOrModel, $values = array()) { $renderer = $this->getRenderer(); $content = $renderer->render($nameOrModel, $values); $text = new MimePart(''); $text->type = "text/plain"; $html = new MimePart($content); $html->type = "text/html; charset=UTF-8"; $html->encoding = Mime::ENCODING_QUOTEDPRINTABLE; $body = new MimeMessage(); $body->setParts(array($text, $html)); return $this->getDefaultMessage($from, 'utf-8', $to, $subject, $body); }
[ "public", "function", "createHtmlMessage", "(", "$", "from", ",", "$", "to", ",", "$", "subject", ",", "$", "nameOrModel", ",", "$", "values", "=", "array", "(", ")", ")", "{", "$", "renderer", "=", "$", "this", "->", "getRenderer", "(", ")", ";", ...
Return a HTML message ready to be sent @param array|string $from A string containing the sender e-mail address, or if array with keys email and name @param array|string $to An array containing the recipients of the mail @param string $subject Subject of the mail @param string|\Zend\View\Model\ModelInterface $nameOrModel Either the template to use, or a ViewModel @param null|array $values Values to use when the template is rendered @return Message
[ "Return", "a", "HTML", "message", "ready", "to", "be", "sent" ]
train
https://github.com/goalio/GoalioMailService/blob/49f69fb5e29885b70712660b1ac5bb934164bbbb/src/GoalioMailService/Mail/Service/Message.php#L64-L79
goalio/GoalioMailService
src/GoalioMailService/Mail/Service/Message.php
Message.createTextMessage
public function createTextMessage($from, $to, $subject, $nameOrModel, $values = array()) { $renderer = $this->getRenderer(); $content = $renderer->render($nameOrModel, $values); return $this->getDefaultMessage($from, 'utf-8', $to, $subject, $content); }
php
public function createTextMessage($from, $to, $subject, $nameOrModel, $values = array()) { $renderer = $this->getRenderer(); $content = $renderer->render($nameOrModel, $values); return $this->getDefaultMessage($from, 'utf-8', $to, $subject, $content); }
[ "public", "function", "createTextMessage", "(", "$", "from", ",", "$", "to", ",", "$", "subject", ",", "$", "nameOrModel", ",", "$", "values", "=", "array", "(", ")", ")", "{", "$", "renderer", "=", "$", "this", "->", "getRenderer", "(", ")", ";", ...
Return a text message ready to be sent @param array|string $from A string containing the sender e-mail address, or if array with keys email and name @param array|string $to An array containing the recipients of the mail @param string $subject Subject of the mail @param string|\Zend\View\Model\ModelInterface $nameOrModel Either the template to use, or a ViewModel @param null|array $values Values to use when the template is rendered @return Message
[ "Return", "a", "text", "message", "ready", "to", "be", "sent" ]
train
https://github.com/goalio/GoalioMailService/blob/49f69fb5e29885b70712660b1ac5bb934164bbbb/src/GoalioMailService/Mail/Service/Message.php#L96-L101
goalio/GoalioMailService
src/GoalioMailService/Mail/Service/Message.php
Message.getTransport
public function getTransport() { if($this->transport === null) { $this->transport = $this->getServiceManager() ->get('goaliomailservice_transport'); } return $this->transport; }
php
public function getTransport() { if($this->transport === null) { $this->transport = $this->getServiceManager() ->get('goaliomailservice_transport'); } return $this->transport; }
[ "public", "function", "getTransport", "(", ")", "{", "if", "(", "$", "this", "->", "transport", "===", "null", ")", "{", "$", "this", "->", "transport", "=", "$", "this", "->", "getServiceManager", "(", ")", "->", "get", "(", "'goaliomailservice_transport'...
Get the transport @return \Zend\Mail\Transport\TransportInterface
[ "Get", "the", "transport" ]
train
https://github.com/goalio/GoalioMailService/blob/49f69fb5e29885b70712660b1ac5bb934164bbbb/src/GoalioMailService/Mail/Service/Message.php#L143-L150
goalio/GoalioMailService
src/GoalioMailService/Mail/Service/Message.php
Message.getDefaultMessage
protected function getDefaultMessage($from, $encoding, $to, $subject, $body) { if(is_string($from)) { $from = array('email' => $from, 'name' => $from); } $message = new MailMessage(); $message->setFrom($from['email'], $from['name']) ->setEncoding($encoding) ->setSubject($subject) ->setBody($body) ->setTo($to); return $message; }
php
protected function getDefaultMessage($from, $encoding, $to, $subject, $body) { if(is_string($from)) { $from = array('email' => $from, 'name' => $from); } $message = new MailMessage(); $message->setFrom($from['email'], $from['name']) ->setEncoding($encoding) ->setSubject($subject) ->setBody($body) ->setTo($to); return $message; }
[ "protected", "function", "getDefaultMessage", "(", "$", "from", ",", "$", "encoding", ",", "$", "to", ",", "$", "subject", ",", "$", "body", ")", "{", "if", "(", "is_string", "(", "$", "from", ")", ")", "{", "$", "from", "=", "array", "(", "'email'...
@param $from @param $encoding @param $to @param $subject @param $body @return MailMessage
[ "@param", "$from", "@param", "$encoding", "@param", "$to", "@param", "$subject", "@param", "$body" ]
train
https://github.com/goalio/GoalioMailService/blob/49f69fb5e29885b70712660b1ac5bb934164bbbb/src/GoalioMailService/Mail/Service/Message.php#L172-L185
cevou/BehatScreenshotCompareExtension
src/Cevou/Behat/ScreenshotCompareExtension/ServiceContainer/Adapter/FtpAdapterFactory.php
FtpAdapterFactory.addConfiguration
function addConfiguration(NodeDefinition $builder) { $builder ->children() ->scalarNode('directory')->isRequired()->end() ->scalarNode('host')->isRequired()->end() ->scalarNode('port')->defaultValue(21)->end() ->scalarNode('username')->defaultNull()->end() ->scalarNode('password')->defaultNull()->end() ->booleanNode('passive')->defaultFalse()->end() ->booleanNode('create')->defaultFalse()->end() ->booleanNode('ssl')->defaultFalse()->end() ->scalarNode('mode') ->defaultValue(defined('FTP_ASCII') ? FTP_ASCII : null) ->beforeNormalization() ->ifString() ->then(function($v) { return constant($v); }) ->end() ->end() ; }
php
function addConfiguration(NodeDefinition $builder) { $builder ->children() ->scalarNode('directory')->isRequired()->end() ->scalarNode('host')->isRequired()->end() ->scalarNode('port')->defaultValue(21)->end() ->scalarNode('username')->defaultNull()->end() ->scalarNode('password')->defaultNull()->end() ->booleanNode('passive')->defaultFalse()->end() ->booleanNode('create')->defaultFalse()->end() ->booleanNode('ssl')->defaultFalse()->end() ->scalarNode('mode') ->defaultValue(defined('FTP_ASCII') ? FTP_ASCII : null) ->beforeNormalization() ->ifString() ->then(function($v) { return constant($v); }) ->end() ->end() ; }
[ "function", "addConfiguration", "(", "NodeDefinition", "$", "builder", ")", "{", "$", "builder", "->", "children", "(", ")", "->", "scalarNode", "(", "'directory'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'host'"...
{@inheritdoc}
[ "{" ]
train
https://github.com/cevou/BehatScreenshotCompareExtension/blob/b10465b0c69d237f8608c78e829bc6f10c31455a/src/Cevou/Behat/ScreenshotCompareExtension/ServiceContainer/Adapter/FtpAdapterFactory.php#L34-L54
wardrobecms/core-archived
src/Wardrobe/Core/Models/Post.php
Post.getParsedContentAttribute
public function getParsedContentAttribute() { if (Config::get('core::wardrobe.cache')) { $content = $this->attributes['content']; return Cache::rememberForever('post-'.$this->attributes['id'], function() use ($content) { return md($content); }); } return md($this->attributes['content']); }
php
public function getParsedContentAttribute() { if (Config::get('core::wardrobe.cache')) { $content = $this->attributes['content']; return Cache::rememberForever('post-'.$this->attributes['id'], function() use ($content) { return md($content); }); } return md($this->attributes['content']); }
[ "public", "function", "getParsedContentAttribute", "(", ")", "{", "if", "(", "Config", "::", "get", "(", "'core::wardrobe.cache'", ")", ")", "{", "$", "content", "=", "$", "this", "->", "attributes", "[", "'content'", "]", ";", "return", "Cache", "::", "re...
Get the content parsed into html @return string
[ "Get", "the", "content", "parsed", "into", "html" ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Models/Post.php#L47-L60
wardrobecms/core-archived
src/Wardrobe/Core/Models/Post.php
Post.getParsedIntroAttribute
public function getParsedIntroAttribute() { $intro = $this->getIntroAttribute(); if (Config::get('core::wardrobe.cache')) { return Cache::rememberForever('post-intro-'.$this->attributes['id'], function() use ($intro) { return md($intro); }); } return md($intro); }
php
public function getParsedIntroAttribute() { $intro = $this->getIntroAttribute(); if (Config::get('core::wardrobe.cache')) { return Cache::rememberForever('post-intro-'.$this->attributes['id'], function() use ($intro) { return md($intro); }); } return md($intro); }
[ "public", "function", "getParsedIntroAttribute", "(", ")", "{", "$", "intro", "=", "$", "this", "->", "getIntroAttribute", "(", ")", ";", "if", "(", "Config", "::", "get", "(", "'core::wardrobe.cache'", ")", ")", "{", "return", "Cache", "::", "rememberForeve...
Get the parsed short version of a post @return string
[ "Get", "the", "parsed", "short", "version", "of", "a", "post" ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Models/Post.php#L113-L126
budde377/Part
lib/view/template/PageVariableTwigTokenParserImpl.php
PageVariableTwigTokenParserImpl.parse
public function parse(Twig_Token $token) { $stream = $this->parser->getStream(); $id = $page_id = null; if($stream->getCurrent()->getType() != Twig_Token::BLOCK_END_TYPE){ $id = $this->parser->getExpressionParser()->parseExpression(); } $stream->expect(Twig_Token::BLOCK_END_TYPE); return new PageVariableTwigNodeImpl($token->getLine(), $this->getTag(), $id); }
php
public function parse(Twig_Token $token) { $stream = $this->parser->getStream(); $id = $page_id = null; if($stream->getCurrent()->getType() != Twig_Token::BLOCK_END_TYPE){ $id = $this->parser->getExpressionParser()->parseExpression(); } $stream->expect(Twig_Token::BLOCK_END_TYPE); return new PageVariableTwigNodeImpl($token->getLine(), $this->getTag(), $id); }
[ "public", "function", "parse", "(", "Twig_Token", "$", "token", ")", "{", "$", "stream", "=", "$", "this", "->", "parser", "->", "getStream", "(", ")", ";", "$", "id", "=", "$", "page_id", "=", "null", ";", "if", "(", "$", "stream", "->", "getCurre...
Parses a token and returns a node. @param Twig_Token $token A Twig_Token instance @return Twig_Node A Twig_NodeInterface instance @throws Twig_Error_Syntax
[ "Parses", "a", "token", "and", "returns", "a", "node", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/view/template/PageVariableTwigTokenParserImpl.php#L26-L37
scherersoftware/cake-notifications
src/Notification/Notification.php
Notification.queueOptions
public function queueOptions(array $options = null) { if ($options === null) { return $this->_queueOptions; } return $this->__setQueueOptions($options); }
php
public function queueOptions(array $options = null) { if ($options === null) { return $this->_queueOptions; } return $this->__setQueueOptions($options); }
[ "public", "function", "queueOptions", "(", "array", "$", "options", "=", "null", ")", "{", "if", "(", "$", "options", "===", "null", ")", "{", "return", "$", "this", "->", "_queueOptions", ";", "}", "return", "$", "this", "->", "__setQueueOptions", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/scherersoftware/cake-notifications/blob/916fa8d60dbe94c0b146339eed147b1a1f2a1902/src/Notification/Notification.php#L142-L149
scherersoftware/cake-notifications
src/Notification/Notification.php
Notification.locale
public function locale($locale = null) { if ($locale === null) { return $this->_locale; } return $this->__setLocale($locale); }
php
public function locale($locale = null) { if ($locale === null) { return $this->_locale; } return $this->__setLocale($locale); }
[ "public", "function", "locale", "(", "$", "locale", "=", "null", ")", "{", "if", "(", "$", "locale", "===", "null", ")", "{", "return", "$", "this", "->", "_locale", ";", "}", "return", "$", "this", "->", "__setLocale", "(", "$", "locale", ")", ";"...
{@inheritdoc}
[ "{" ]
train
https://github.com/scherersoftware/cake-notifications/blob/916fa8d60dbe94c0b146339eed147b1a1f2a1902/src/Notification/Notification.php#L170-L177
scherersoftware/cake-notifications
src/Notification/Notification.php
Notification.__setQueueOptions
private function __setQueueOptions($options) { $this->_queueOptions = Hash::merge($this->_queueOptions, $options); return $this; }
php
private function __setQueueOptions($options) { $this->_queueOptions = Hash::merge($this->_queueOptions, $options); return $this; }
[ "private", "function", "__setQueueOptions", "(", "$", "options", ")", "{", "$", "this", "->", "_queueOptions", "=", "Hash", "::", "merge", "(", "$", "this", "->", "_queueOptions", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Set settings @param array $options Queue options @return $this
[ "Set", "settings" ]
train
https://github.com/scherersoftware/cake-notifications/blob/916fa8d60dbe94c0b146339eed147b1a1f2a1902/src/Notification/Notification.php#L214-L219
scherersoftware/cake-notifications
src/Notification/Notification.php
Notification.__setCallback
private function __setCallback($type, $class, array $args) { if (!is_array($class)) { $this->{$type} = [ [ 'class' => $class, 'args' => $args ] ]; return $this; } elseif (is_array($class) && count($class) == 2) { $className = $class[0]; $methodName = $class[1]; } else { if (is_array($class)) { $class = implode($class); } throw new \InvalidArgumentException("{$class} is missformated"); } $this->{$type} = [ [ 'class' => [$className, $methodName], 'args' => $args ] ]; return $this; }
php
private function __setCallback($type, $class, array $args) { if (!is_array($class)) { $this->{$type} = [ [ 'class' => $class, 'args' => $args ] ]; return $this; } elseif (is_array($class) && count($class) == 2) { $className = $class[0]; $methodName = $class[1]; } else { if (is_array($class)) { $class = implode($class); } throw new \InvalidArgumentException("{$class} is missformated"); } $this->{$type} = [ [ 'class' => [$className, $methodName], 'args' => $args ] ]; return $this; }
[ "private", "function", "__setCallback", "(", "$", "type", ",", "$", "class", ",", "array", "$", "args", ")", "{", "if", "(", "!", "is_array", "(", "$", "class", ")", ")", "{", "$", "this", "->", "{", "$", "type", "}", "=", "[", "[", "'class'", ...
Set callback @param string $type _beforeSendCallback or _afterSendCallback @param string $class name of the class @param array $args array of arguments @return $this
[ "Set", "callback" ]
train
https://github.com/scherersoftware/cake-notifications/blob/916fa8d60dbe94c0b146339eed147b1a1f2a1902/src/Notification/Notification.php#L229-L258
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php
ClassWithEmbeddedMessagePropertyMeta.create
public static function create() { switch (func_num_args()) { case 0: return new ClassWithEmbeddedMessageProperty(); case 1: return new ClassWithEmbeddedMessageProperty(func_get_arg(0)); case 2: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1)); case 3: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new ClassWithEmbeddedMessageProperty(); case 1: return new ClassWithEmbeddedMessageProperty(func_get_arg(0)); case 2: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1)); case 3: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new ClassWithEmbeddedMessageProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "ClassWithEmbeddedMessageProperty", "(", ")", ";", "case", "1", ":", "return", "new", "ClassWithEmbeddedMessagePrope...
Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty @throws \InvalidArgumentException @return ClassWithEmbeddedMessageProperty
[ "Creates", "new", "instance", "of", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithEmbeddedMessageProperty" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php#L67-L91
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php
ClassWithEmbeddedMessagePropertyMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->x)) { hash_update($ctx, 'x'); EmbeddedMeta::hash($object->x, $ctx); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
php
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->x)) { hash_update($ctx, 'x'); EmbeddedMeta::hash($object->x, $ctx); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
[ "public", "static", "function", "hash", "(", "$", "object", ",", "$", "algoOrCtx", "=", "'md5'", ",", "$", "raw", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "$", "ctx", "=", "hash_init", "(", "$", "algoOrC...
Computes hash of \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithEmbeddedMessageProperty" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php#L122-L140
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php
ClassWithEmbeddedMessagePropertyMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->x) && ($filter === null || isset($filter['x']))) { $output .= "\x0a"; $buffer = EmbeddedMeta::toProtobuf($object->x, $filter === null ? null : $filter['x']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->x) && ($filter === null || isset($filter['x']))) { $output .= "\x0a"; $buffer = EmbeddedMeta::toProtobuf($object->x, $filter === null ? null : $filter['x']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "x", ")", "&&", "(", "$", "filter", "===", "null", "||", "is...
Serialized \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty to Protocol Buffers message. @param ClassWithEmbeddedMessageProperty $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithEmbeddedMessageProperty", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithEmbeddedMessagePropertyMeta.php#L396-L408
marvin255/bxcodegen
src/service/renderer/Twig.php
Twig.renderTemplate
public function renderTemplate($pathToTemplateFile, array $options = []) { if (!file_exists($pathToTemplateFile)) { throw new InvalidArgumentException( "Can't find template file: {$pathToTemplateFile}" ); } $renderName = 'from_file'; $this->twigLoader->setTemplate($renderName, file_get_contents($pathToTemplateFile)); try { $return = $this->twig->load($renderName)->render($options); } catch (\Exception $e) { throw new Exception($e->getMessage(), $e->getCode(), $e); } return $return; }
php
public function renderTemplate($pathToTemplateFile, array $options = []) { if (!file_exists($pathToTemplateFile)) { throw new InvalidArgumentException( "Can't find template file: {$pathToTemplateFile}" ); } $renderName = 'from_file'; $this->twigLoader->setTemplate($renderName, file_get_contents($pathToTemplateFile)); try { $return = $this->twig->load($renderName)->render($options); } catch (\Exception $e) { throw new Exception($e->getMessage(), $e->getCode(), $e); } return $return; }
[ "public", "function", "renderTemplate", "(", "$", "pathToTemplateFile", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "file_exists", "(", "$", "pathToTemplateFile", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"C...
{@inheritdoc} @throws \InvalidArgumentException @throws \marvin255\bxcodegen\Exception
[ "{", "@inheritdoc", "}" ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/renderer/Twig.php#L39-L57
scherersoftware/cake-model-history
src/Model/Entity/HistoryContextTrait.php
HistoryContextTrait.setHistoryContext
public function setHistoryContext(string $type, $dataObject = null, $slug = null): void { if (!in_array($type, array_keys(ModelHistory::getContextTypes()))) { throw new InvalidArgumentException("$type is not allowed as context type. Allowed types are: " . implode(', ', ModelHistory::getContextTypes())); } switch ($type) { case ModelHistory::CONTEXT_TYPE_SHELL: if (!$dataObject instanceof Shell) { throw new InvalidArgumentException('You have to specify a Shell data object for this context type.'); } $context = [ 'OptionParser' => $dataObject->OptionParser, 'interactive' => $dataObject->interactive, 'params' => $dataObject->params, 'command' => $dataObject->command, 'args' => $dataObject->args, 'name' => $dataObject->name, 'plugin' => $dataObject->plugin, 'tasks' => $dataObject->tasks, 'taskNames' => $dataObject->taskNames ]; $contextSlug = null; if ($slug !== null) { $contextSlug = $slug; } break; case ModelHistory::CONTEXT_TYPE_CONTROLLER: if (!$dataObject instanceof Request) { throw new InvalidArgumentException('You have to specify a Request data object for this context type.'); } $context = [ 'params' => $dataObject->params, 'method' => $dataObject->method() ]; if ($slug !== null) { $contextSlug = $slug; } else { $contextSlug = Text::insert(':plugin/:controller/:action', [ 'plugin' => $context['params']['plugin'], 'controller' => $context['params']['controller'], 'action' => $context['params']['action'] ]); } break; case ModelHistory::CONTEXT_TYPE_SLUG: default: $context = []; if ($slug === null) { throw new InvalidArgumentException('You have to specify a slug for this context type.'); } $contextSlug = $slug; break; } $this->_context = Hash::merge([ 'type' => $type, 'namespace' => get_class($this) ], $context); $this->_contextSlug = $contextSlug; $this->_contextType = $type; }
php
public function setHistoryContext(string $type, $dataObject = null, $slug = null): void { if (!in_array($type, array_keys(ModelHistory::getContextTypes()))) { throw new InvalidArgumentException("$type is not allowed as context type. Allowed types are: " . implode(', ', ModelHistory::getContextTypes())); } switch ($type) { case ModelHistory::CONTEXT_TYPE_SHELL: if (!$dataObject instanceof Shell) { throw new InvalidArgumentException('You have to specify a Shell data object for this context type.'); } $context = [ 'OptionParser' => $dataObject->OptionParser, 'interactive' => $dataObject->interactive, 'params' => $dataObject->params, 'command' => $dataObject->command, 'args' => $dataObject->args, 'name' => $dataObject->name, 'plugin' => $dataObject->plugin, 'tasks' => $dataObject->tasks, 'taskNames' => $dataObject->taskNames ]; $contextSlug = null; if ($slug !== null) { $contextSlug = $slug; } break; case ModelHistory::CONTEXT_TYPE_CONTROLLER: if (!$dataObject instanceof Request) { throw new InvalidArgumentException('You have to specify a Request data object for this context type.'); } $context = [ 'params' => $dataObject->params, 'method' => $dataObject->method() ]; if ($slug !== null) { $contextSlug = $slug; } else { $contextSlug = Text::insert(':plugin/:controller/:action', [ 'plugin' => $context['params']['plugin'], 'controller' => $context['params']['controller'], 'action' => $context['params']['action'] ]); } break; case ModelHistory::CONTEXT_TYPE_SLUG: default: $context = []; if ($slug === null) { throw new InvalidArgumentException('You have to specify a slug for this context type.'); } $contextSlug = $slug; break; } $this->_context = Hash::merge([ 'type' => $type, 'namespace' => get_class($this) ], $context); $this->_contextSlug = $contextSlug; $this->_contextType = $type; }
[ "public", "function", "setHistoryContext", "(", "string", "$", "type", ",", "$", "dataObject", "=", "null", ",", "$", "slug", "=", "null", ")", ":", "void", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "array_keys", "(", "ModelHistory", "::"...
Sets a context given through a request to identify the creation point of the revision. @param string $type Context type @param object $dataObject Optional dataobject to get additional data from @param string $slug Optional slug. Must implement getContexts() when using @return void
[ "Sets", "a", "context", "given", "through", "a", "request", "to", "identify", "the", "creation", "point", "of", "the", "revision", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Entity/HistoryContextTrait.php#L48-L109
yeephp/yeephp
Yee/Yee.php
Yee.getDefaultSettings
public static function getDefaultSettings() { return array( // Application 'mode' => 'development', // Debugging 'debug' => true, // Logging 'log.writer' => null, 'log.level' => \Yee\Log::DEBUG, 'log.enabled' => true, // View 'templates.path' => './templates', 'view' => '\Yee\View', // Cookies 'cookies.encrypt' => false, 'cookies.lifetime' => '20 minutes', 'cookies.path' => '/', 'cookies.domain' => null, 'cookies.secure' => false, 'cookies.httponly' => false, // Encryption 'cookies.secret_key' => 'CHANGE_ME', 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.cipher_mode' => MCRYPT_MODE_CBC, // HTTP 'http.version' => '1.1', // Routing 'routes.case_sensitive' => true ); }
php
public static function getDefaultSettings() { return array( // Application 'mode' => 'development', // Debugging 'debug' => true, // Logging 'log.writer' => null, 'log.level' => \Yee\Log::DEBUG, 'log.enabled' => true, // View 'templates.path' => './templates', 'view' => '\Yee\View', // Cookies 'cookies.encrypt' => false, 'cookies.lifetime' => '20 minutes', 'cookies.path' => '/', 'cookies.domain' => null, 'cookies.secure' => false, 'cookies.httponly' => false, // Encryption 'cookies.secret_key' => 'CHANGE_ME', 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.cipher_mode' => MCRYPT_MODE_CBC, // HTTP 'http.version' => '1.1', // Routing 'routes.case_sensitive' => true ); }
[ "public", "static", "function", "getDefaultSettings", "(", ")", "{", "return", "array", "(", "// Application", "'mode'", "=>", "'development'", ",", "// Debugging", "'debug'", "=>", "true", ",", "// Logging", "'log.writer'", "=>", "null", ",", "'log.level'", "=>",...
Get default application settings @return array
[ "Get", "default", "application", "settings" ]
train
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Yee.php#L292-L322