repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
koolkode/bpmn
src/Repository/DeploymentBuilder.php
DeploymentBuilder.collectFiles
protected function collectFiles(string $dir, string $basePath): array { $files = []; $dh = \opendir($dir); try { while (false !== ($entry = \readdir($dh))) { if ($entry == '.' || $entry == '..') { continue; } $check = $dir . \DIRECTORY_SEPARATOR . $entry; if (\is_dir($check)) { foreach ($this->collectFiles($check, $basePath . '/' . $entry) as $k => $v) { $files[$k] = $v; } } elseif (\is_file($check)) { $files[$basePath . '/' . $entry] = $check; } } return $files; } finally { \closedir($dh); } }
php
protected function collectFiles(string $dir, string $basePath): array { $files = []; $dh = \opendir($dir); try { while (false !== ($entry = \readdir($dh))) { if ($entry == '.' || $entry == '..') { continue; } $check = $dir . \DIRECTORY_SEPARATOR . $entry; if (\is_dir($check)) { foreach ($this->collectFiles($check, $basePath . '/' . $entry) as $k => $v) { $files[$k] = $v; } } elseif (\is_file($check)) { $files[$basePath . '/' . $entry] = $check; } } return $files; } finally { \closedir($dh); } }
[ "protected", "function", "collectFiles", "(", "string", "$", "dir", ",", "string", "$", "basePath", ")", ":", "array", "{", "$", "files", "=", "[", "]", ";", "$", "dh", "=", "\\", "opendir", "(", "$", "dir", ")", ";", "try", "{", "while", "(", "f...
Collect all files from the directory, uses recursion to grab files from sub-directories.
[ "Collect", "all", "files", "from", "the", "directory", "uses", "recursion", "to", "grab", "files", "from", "sub", "-", "directories", "." ]
49ff924fa97e0bbe1b74e914393b22760dcf7281
https://github.com/koolkode/bpmn/blob/49ff924fa97e0bbe1b74e914393b22760dcf7281/src/Repository/DeploymentBuilder.php#L183-L209
train
koolkode/bpmn
src/Engine/ExecutionInterceptorChain.php
ExecutionInterceptorChain.performExecution
public function performExecution() { if (!$this->interceptors->isEmpty()) { return $this->interceptors->extract()->interceptExecution($this, $this->executionDepth); } return ($this->callback)(); }
php
public function performExecution() { if (!$this->interceptors->isEmpty()) { return $this->interceptors->extract()->interceptExecution($this, $this->executionDepth); } return ($this->callback)(); }
[ "public", "function", "performExecution", "(", ")", "{", "if", "(", "!", "$", "this", "->", "interceptors", "->", "isEmpty", "(", ")", ")", "{", "return", "$", "this", "->", "interceptors", "->", "extract", "(", ")", "->", "interceptExecution", "(", "$",...
Delegate to the next interceptor or actually perform the queued execution. @return mixed The result of the command execution.
[ "Delegate", "to", "the", "next", "interceptor", "or", "actually", "perform", "the", "queued", "execution", "." ]
49ff924fa97e0bbe1b74e914393b22760dcf7281
https://github.com/koolkode/bpmn/blob/49ff924fa97e0bbe1b74e914393b22760dcf7281/src/Engine/ExecutionInterceptorChain.php#L45-L52
train
koolkode/bpmn
src/Job/Executor/JobExecutor.php
JobExecutor.findJobHandler
protected function findJobHandler(Job $job) { foreach ($this->handlers as $type => $handler) { if ($job->getHandlerType() == $type) { return $handler; } } throw new \OutOfBoundsException(\sprintf('Job handler "%s" not found for job %s', $job->getHandlerType(), $job->getId())); }
php
protected function findJobHandler(Job $job) { foreach ($this->handlers as $type => $handler) { if ($job->getHandlerType() == $type) { return $handler; } } throw new \OutOfBoundsException(\sprintf('Job handler "%s" not found for job %s', $job->getHandlerType(), $job->getId())); }
[ "protected", "function", "findJobHandler", "(", "Job", "$", "job", ")", "{", "foreach", "(", "$", "this", "->", "handlers", "as", "$", "type", "=>", "$", "handler", ")", "{", "if", "(", "$", "job", "->", "getHandlerType", "(", ")", "==", "$", "type",...
Find a handler for the given job by matching the handler type value of the job. @param Job $job @return JobHandlerInterface @throws \OutOfBoundsException When no handler for the job could be resolved.
[ "Find", "a", "handler", "for", "the", "given", "job", "by", "matching", "the", "handler", "type", "value", "of", "the", "job", "." ]
49ff924fa97e0bbe1b74e914393b22760dcf7281
https://github.com/koolkode/bpmn/blob/49ff924fa97e0bbe1b74e914393b22760dcf7281/src/Job/Executor/JobExecutor.php#L291-L300
train
LaravelCollective/iron-queue
src/IronQueueServiceProvider.php
IronQueueServiceProvider.registerIronRequestBinder
protected function registerIronRequestBinder() { $this->app->rebinding('request', function ($app, $request) { if ($app['queue']->connected('iron')) { $app['queue']->connection('iron')->setRequest($request); } }); }
php
protected function registerIronRequestBinder() { $this->app->rebinding('request', function ($app, $request) { if ($app['queue']->connected('iron')) { $app['queue']->connection('iron')->setRequest($request); } }); }
[ "protected", "function", "registerIronRequestBinder", "(", ")", "{", "$", "this", "->", "app", "->", "rebinding", "(", "'request'", ",", "function", "(", "$", "app", ",", "$", "request", ")", "{", "if", "(", "$", "app", "[", "'queue'", "]", "->", "conn...
Register the request rebinding event for the Iron queue. @return void
[ "Register", "the", "request", "rebinding", "event", "for", "the", "Iron", "queue", "." ]
a873575da0ebec506db3631b9835074e06543060
https://github.com/LaravelCollective/iron-queue/blob/a873575da0ebec506db3631b9835074e06543060/src/IronQueueServiceProvider.php#L28-L35
train
LaravelCollective/iron-queue
src/IronQueue.php
IronQueue.deleteMessage
public function deleteMessage($queue, $id, $reservation_id) { $this->iron->deleteMessage($queue, $id, $reservation_id); }
php
public function deleteMessage($queue, $id, $reservation_id) { $this->iron->deleteMessage($queue, $id, $reservation_id); }
[ "public", "function", "deleteMessage", "(", "$", "queue", ",", "$", "id", ",", "$", "reservation_id", ")", "{", "$", "this", "->", "iron", "->", "deleteMessage", "(", "$", "queue", ",", "$", "id", ",", "$", "reservation_id", ")", ";", "}" ]
Delete a message from the Iron queue. @param string $queue @param string $id @param string $reservation_id @return void
[ "Delete", "a", "message", "from", "the", "Iron", "queue", "." ]
a873575da0ebec506db3631b9835074e06543060
https://github.com/LaravelCollective/iron-queue/blob/a873575da0ebec506db3631b9835074e06543060/src/IronQueue.php#L167-L170
train
brainworxx/kreXX
src/Analyse/Callback/Iterate/ThroughGetter.php
ThroughGetter.callMe
public function callMe() { $output = $this->dispatchStartEvent(); $this->parameters[static::CURRENT_PREFIX] = 'get'; $output .= $this->goThroughMethodList($this->parameters[static::PARAM_NORMAL_GETTER]); $this->parameters[static::CURRENT_PREFIX] = 'is'; $output .= $this->goThroughMethodList($this->parameters[static::PARAM_IS_GETTER]); $this->parameters[static::CURRENT_PREFIX] = 'has'; return $output . $this->goThroughMethodList($this->parameters[static::PARAM_HAS_GETTER]); }
php
public function callMe() { $output = $this->dispatchStartEvent(); $this->parameters[static::CURRENT_PREFIX] = 'get'; $output .= $this->goThroughMethodList($this->parameters[static::PARAM_NORMAL_GETTER]); $this->parameters[static::CURRENT_PREFIX] = 'is'; $output .= $this->goThroughMethodList($this->parameters[static::PARAM_IS_GETTER]); $this->parameters[static::CURRENT_PREFIX] = 'has'; return $output . $this->goThroughMethodList($this->parameters[static::PARAM_HAS_GETTER]); }
[ "public", "function", "callMe", "(", ")", "{", "$", "output", "=", "$", "this", "->", "dispatchStartEvent", "(", ")", ";", "$", "this", "->", "parameters", "[", "static", "::", "CURRENT_PREFIX", "]", "=", "'get'", ";", "$", "output", ".=", "$", "this",...
Try to get the possible result of all getter methods. @return string The generated markup.
[ "Try", "to", "get", "the", "possible", "result", "of", "all", "getter", "methods", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughGetter.php#L107-L119
train
brainworxx/kreXX
src/Analyse/Callback/Iterate/ThroughGetter.php
ThroughGetter.goThroughMethodList
protected function goThroughMethodList(array $methodList) { $output = ''; /** @var \ReflectionMethod $reflectionMethod */ foreach ($methodList as $reflectionMethod) { // Back to level 0, we reset the deep counter. $this->deep = 0; // Now we have three possible outcomes: // 1.) We have an actual value // 2.) We got NULL as a value // 3.) We were unable to get any info at all. $comments = nl2br($this->commentAnalysis->getComment( $reflectionMethod, $this->parameters[static::PARAM_REF] )); /** @var Model $model */ $model = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model') ->setName($reflectionMethod->getName()) ->addToJson(static::META_METHOD_COMMENT, $comments); // We need to decide if we are handling static getters. if ($reflectionMethod->isStatic() === true) { $model->setConnectorType(Connectors::STATIC_METHOD); } else { $model->setConnectorType(Connectors::METHOD); } // Get ourselves a possible return value $output .= $this->retrievePropertyValue( $reflectionMethod, $this->dispatchEventWithModel( __FUNCTION__ . static::EVENT_MARKER_END, $model ) ); } return $output; }
php
protected function goThroughMethodList(array $methodList) { $output = ''; /** @var \ReflectionMethod $reflectionMethod */ foreach ($methodList as $reflectionMethod) { // Back to level 0, we reset the deep counter. $this->deep = 0; // Now we have three possible outcomes: // 1.) We have an actual value // 2.) We got NULL as a value // 3.) We were unable to get any info at all. $comments = nl2br($this->commentAnalysis->getComment( $reflectionMethod, $this->parameters[static::PARAM_REF] )); /** @var Model $model */ $model = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model') ->setName($reflectionMethod->getName()) ->addToJson(static::META_METHOD_COMMENT, $comments); // We need to decide if we are handling static getters. if ($reflectionMethod->isStatic() === true) { $model->setConnectorType(Connectors::STATIC_METHOD); } else { $model->setConnectorType(Connectors::METHOD); } // Get ourselves a possible return value $output .= $this->retrievePropertyValue( $reflectionMethod, $this->dispatchEventWithModel( __FUNCTION__ . static::EVENT_MARKER_END, $model ) ); } return $output; }
[ "protected", "function", "goThroughMethodList", "(", "array", "$", "methodList", ")", "{", "$", "output", "=", "''", ";", "/** @var \\ReflectionMethod $reflectionMethod */", "foreach", "(", "$", "methodList", "as", "$", "reflectionMethod", ")", "{", "// Back to level ...
Iterating through a list of reflection methods. @param array $methodList The list of methods we are going through, consisting of \ReflectionMethod @return string The generated DOM.
[ "Iterating", "through", "a", "list", "of", "reflection", "methods", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughGetter.php#L130-L171
train
brainworxx/kreXX
src/Analyse/Callback/Iterate/ThroughGetter.php
ThroughGetter.retrievePropertyValue
protected function retrievePropertyValue(\ReflectionMethod $reflectionMethod, Model $model) { /** @var \Brainworxx\Krexx\Service\Reflection\ReflectionClass $reflectionClass */ $reflectionClass = $this->parameters[static::PARAM_REF]; $refProp = $this->getReflectionProperty($reflectionClass, $reflectionMethod); $nothingFound = true; $value = null; if (empty($refProp) === false) { // We've got ourselves a possible result! $nothingFound = false; $value = $reflectionClass->retrieveValue($refProp); $model->setData($value); if ($value === null) { // A NULL value might mean that the values does not // exist, until the getter computes it. $model->addToJson(static::META_HINT, $this->pool->messages->getHelp('getterNull')); } } // Give the plugins the opportunity to do something with the value, or // try to resolve it, if nothing was found. // We also add the stuff, that we were able to do so far. $this->parameters[static::PARAM_ADDITIONAL] = array( 'nothingFound' => $nothingFound, 'value' => $value, 'refProperty' => $refProp, 'refMethod' => $reflectionMethod ); $this->dispatchEventWithModel(__FUNCTION__ . '::resolving', $model); if ($this->parameters[static::PARAM_ADDITIONAL]['nothingFound'] === true) { // Found nothing :-( // We literally have no info. We need to tell the user. $model->setType(static::TYPE_UNKNOWN) ->setNormal(static::TYPE_UNKNOWN); // We render this right away, without any routing. return $this->pool->render->renderSingleChild($model); } return $this->pool->routing->analysisHub( $this->dispatchEventWithModel( __FUNCTION__ . static::EVENT_MARKER_END, $model ) ); }
php
protected function retrievePropertyValue(\ReflectionMethod $reflectionMethod, Model $model) { /** @var \Brainworxx\Krexx\Service\Reflection\ReflectionClass $reflectionClass */ $reflectionClass = $this->parameters[static::PARAM_REF]; $refProp = $this->getReflectionProperty($reflectionClass, $reflectionMethod); $nothingFound = true; $value = null; if (empty($refProp) === false) { // We've got ourselves a possible result! $nothingFound = false; $value = $reflectionClass->retrieveValue($refProp); $model->setData($value); if ($value === null) { // A NULL value might mean that the values does not // exist, until the getter computes it. $model->addToJson(static::META_HINT, $this->pool->messages->getHelp('getterNull')); } } // Give the plugins the opportunity to do something with the value, or // try to resolve it, if nothing was found. // We also add the stuff, that we were able to do so far. $this->parameters[static::PARAM_ADDITIONAL] = array( 'nothingFound' => $nothingFound, 'value' => $value, 'refProperty' => $refProp, 'refMethod' => $reflectionMethod ); $this->dispatchEventWithModel(__FUNCTION__ . '::resolving', $model); if ($this->parameters[static::PARAM_ADDITIONAL]['nothingFound'] === true) { // Found nothing :-( // We literally have no info. We need to tell the user. $model->setType(static::TYPE_UNKNOWN) ->setNormal(static::TYPE_UNKNOWN); // We render this right away, without any routing. return $this->pool->render->renderSingleChild($model); } return $this->pool->routing->analysisHub( $this->dispatchEventWithModel( __FUNCTION__ . static::EVENT_MARKER_END, $model ) ); }
[ "protected", "function", "retrievePropertyValue", "(", "\\", "ReflectionMethod", "$", "reflectionMethod", ",", "Model", "$", "model", ")", "{", "/** @var \\Brainworxx\\Krexx\\Service\\Reflection\\ReflectionClass $reflectionClass */", "$", "reflectionClass", "=", "$", "this", ...
Try to get a possible return value and render the result. @param \ReflectionMethod $reflectionMethod A reflection ot the method we are analysing @param Model $model The model so far. @return string The rendered markup.
[ "Try", "to", "get", "a", "possible", "return", "value", "and", "render", "the", "result", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughGetter.php#L184-L230
train
brainworxx/kreXX
src/Analyse/Callback/Iterate/ThroughGetter.php
ThroughGetter.preparePropertyName
protected function preparePropertyName(\ReflectionMethod $reflectionMethod) { $currentPrefix = $this->parameters[static::CURRENT_PREFIX]; // Get the name and remove the 'get' . . . $getterName = $reflectionMethod->getName(); if (strpos($getterName, $currentPrefix) === 0) { return lcfirst(substr($getterName, strlen($currentPrefix))); } // . . . or the '_get'. if (strpos($getterName, '_' . $currentPrefix) === 0) { return lcfirst(substr($getterName, strlen($currentPrefix) + 1)); } // Still here?!? At least make the first letter lowercase. return lcfirst($getterName); }
php
protected function preparePropertyName(\ReflectionMethod $reflectionMethod) { $currentPrefix = $this->parameters[static::CURRENT_PREFIX]; // Get the name and remove the 'get' . . . $getterName = $reflectionMethod->getName(); if (strpos($getterName, $currentPrefix) === 0) { return lcfirst(substr($getterName, strlen($currentPrefix))); } // . . . or the '_get'. if (strpos($getterName, '_' . $currentPrefix) === 0) { return lcfirst(substr($getterName, strlen($currentPrefix) + 1)); } // Still here?!? At least make the first letter lowercase. return lcfirst($getterName); }
[ "protected", "function", "preparePropertyName", "(", "\\", "ReflectionMethod", "$", "reflectionMethod", ")", "{", "$", "currentPrefix", "=", "$", "this", "->", "parameters", "[", "static", "::", "CURRENT_PREFIX", "]", ";", "// Get the name and remove the 'get' . . .", ...
Get a first impression ot the possible property name for the getter. @param \ReflectionMethod $reflectionMethod A reflection of the getter method we are analysing. @return string The first impression of the property name.
[ "Get", "a", "first", "impression", "ot", "the", "possible", "property", "name", "for", "the", "getter", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughGetter.php#L329-L346
train
brainworxx/kreXX
src/Analyse/Callback/Iterate/ThroughGetter.php
ThroughGetter.findIt
protected function findIt(array $searchArray, $haystack) { // Defining our regex. $regex = '/(?<=###0###).*?(?=###1###)/'; // Regex escaping our search stuff $searchArray[0] = $this->regexEscaping($searchArray[0]); $searchArray[1] = $this->regexEscaping($searchArray[1]); // Add the search stuff to the regex $regex = str_replace('###0###', $searchArray[0], $regex); $regex = str_replace('###1###', $searchArray[1], $regex); // Trigger the search. preg_match_all($regex, $haystack, $findings); // Return the file name as well as stuff from the path. return $findings[0]; }
php
protected function findIt(array $searchArray, $haystack) { // Defining our regex. $regex = '/(?<=###0###).*?(?=###1###)/'; // Regex escaping our search stuff $searchArray[0] = $this->regexEscaping($searchArray[0]); $searchArray[1] = $this->regexEscaping($searchArray[1]); // Add the search stuff to the regex $regex = str_replace('###0###', $searchArray[0], $regex); $regex = str_replace('###1###', $searchArray[1], $regex); // Trigger the search. preg_match_all($regex, $haystack, $findings); // Return the file name as well as stuff from the path. return $findings[0]; }
[ "protected", "function", "findIt", "(", "array", "$", "searchArray", ",", "$", "haystack", ")", "{", "// Defining our regex.", "$", "regex", "=", "'/(?<=###0###).*?(?=###1###)/'", ";", "// Regex escaping our search stuff", "$", "searchArray", "[", "0", "]", "=", "$"...
Searching for stuff via regex. Yay, dynamic regex stuff for fun and profit! @param array $searchArray The search definition. @param string $haystack The haystack, obviously. @return array The findings.
[ "Searching", "for", "stuff", "via", "regex", ".", "Yay", "dynamic", "regex", "stuff", "for", "fun", "and", "profit!" ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Iterate/ThroughGetter.php#L432-L451
train
silverorange/swat
Swat/SwatAccordion.php
SwatAccordion.getInlineJavaScript
protected function getInlineJavaScript() { $javascript = sprintf( "var %1\$s_obj = new %2\$s('%1\$s', %3\$s);", $this->id, $this->getJavascriptClassName(), $this->animate ? 'true' : 'false' ); $javascript .= sprintf( "\n%s_obj.animate = %s;", $this->id, $this->animate ? 'true' : 'false' ); $javascript .= sprintf( "\n%s_obj.always_open = %s;", $this->id, $this->always_open ? 'true' : 'false' ); return $javascript; }
php
protected function getInlineJavaScript() { $javascript = sprintf( "var %1\$s_obj = new %2\$s('%1\$s', %3\$s);", $this->id, $this->getJavascriptClassName(), $this->animate ? 'true' : 'false' ); $javascript .= sprintf( "\n%s_obj.animate = %s;", $this->id, $this->animate ? 'true' : 'false' ); $javascript .= sprintf( "\n%s_obj.always_open = %s;", $this->id, $this->always_open ? 'true' : 'false' ); return $javascript; }
[ "protected", "function", "getInlineJavaScript", "(", ")", "{", "$", "javascript", "=", "sprintf", "(", "\"var %1\\$s_obj = new %2\\$s('%1\\$s', %3\\$s);\"", ",", "$", "this", "->", "id", ",", "$", "this", "->", "getJavascriptClassName", "(", ")", ",", "$", "this",...
Gets the inline JavaScript used by this accordion view @return string the inline JavaScript used by this accordion view.
[ "Gets", "the", "inline", "JavaScript", "used", "by", "this", "accordion", "view" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatAccordion.php#L138-L160
train
brainworxx/kreXX
src/Service/Misc/Encoding.php
Encoding.encodeString
public function encodeString($data, $code = false) { // We will not encode an empty string. if ($data === '') { return ''; } // Initialize the encoding configuration. if ($code === true) { // We encoding @, because we need them for our chunks. // The { are needed in the marker of the skin. // We also replace tabs with two nbsp's. $sortingCallback = array($this, 'arrayMapCallbackCode'); $search = array('@', '{', chr(9)); $replace = array('&#64;', '&#123;', '&nbsp;&nbsp;'); } else { // We encoding @, because we need them for our chunks. // The { are needed in the marker of the skin. $sortingCallback = array($this, 'arrayMapCallbackNormal'); $search = array('@', '{', ' '); $replace = array('&#64;', '&#123;', '&nbsp;&nbsp;'); } // There are several places here, that may throw a warning. set_error_handler( function () { // Do nothing. } ); $result = str_replace($search, $replace, htmlentities($data)); // Check if encoding was successful. // 99.99% of the time, the encoding works. if (empty($result) === true) { // Here we have another SPOF. When the string is large enough // we will run out of memory! // @see https://sourceforge.net/p/krexx/bugs/21/ // We will *NOT* return the unescaped string. So we must check if it // is small enough for the unpack(). // 100 kb should be save enough. if (strlen($data) > 102400) { $result = $this->pool->messages->getHelp('stringTooLarge'); } else { // Something went wrong with the encoding, we need to // completely encode this one to be able to display it at all! $data = mb_convert_encoding($data, 'UTF-32', mb_detect_encoding($data)); $result = implode("", array_map($sortingCallback, unpack("N*", $data))); } } // Reactivate whatever error handling we had previously. restore_error_handler(); return $result; }
php
public function encodeString($data, $code = false) { // We will not encode an empty string. if ($data === '') { return ''; } // Initialize the encoding configuration. if ($code === true) { // We encoding @, because we need them for our chunks. // The { are needed in the marker of the skin. // We also replace tabs with two nbsp's. $sortingCallback = array($this, 'arrayMapCallbackCode'); $search = array('@', '{', chr(9)); $replace = array('&#64;', '&#123;', '&nbsp;&nbsp;'); } else { // We encoding @, because we need them for our chunks. // The { are needed in the marker of the skin. $sortingCallback = array($this, 'arrayMapCallbackNormal'); $search = array('@', '{', ' '); $replace = array('&#64;', '&#123;', '&nbsp;&nbsp;'); } // There are several places here, that may throw a warning. set_error_handler( function () { // Do nothing. } ); $result = str_replace($search, $replace, htmlentities($data)); // Check if encoding was successful. // 99.99% of the time, the encoding works. if (empty($result) === true) { // Here we have another SPOF. When the string is large enough // we will run out of memory! // @see https://sourceforge.net/p/krexx/bugs/21/ // We will *NOT* return the unescaped string. So we must check if it // is small enough for the unpack(). // 100 kb should be save enough. if (strlen($data) > 102400) { $result = $this->pool->messages->getHelp('stringTooLarge'); } else { // Something went wrong with the encoding, we need to // completely encode this one to be able to display it at all! $data = mb_convert_encoding($data, 'UTF-32', mb_detect_encoding($data)); $result = implode("", array_map($sortingCallback, unpack("N*", $data))); } } // Reactivate whatever error handling we had previously. restore_error_handler(); return $result; }
[ "public", "function", "encodeString", "(", "$", "data", ",", "$", "code", "=", "false", ")", "{", "// We will not encode an empty string.", "if", "(", "$", "data", "===", "''", ")", "{", "return", "''", ";", "}", "// Initialize the encoding configuration.", "if"...
Sanitizes a string, by completely encoding it. Should work with mixed encoding. @param string $data The data which needs to be sanitized. @param boolean $code Do we need to format the string as code? @return string The encoded string.
[ "Sanitizes", "a", "string", "by", "completely", "encoding", "it", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Misc/Encoding.php#L151-L206
train
brainworxx/kreXX
src/Service/Misc/Encoding.php
Encoding.mbStrLen
public function mbStrLen($string, $encoding = null) { // Meh, the original mb_strlen interprets a null here as an empty string. if ($encoding === null) { return mb_strlen($string); } return mb_strlen($string, $encoding); }
php
public function mbStrLen($string, $encoding = null) { // Meh, the original mb_strlen interprets a null here as an empty string. if ($encoding === null) { return mb_strlen($string); } return mb_strlen($string, $encoding); }
[ "public", "function", "mbStrLen", "(", "$", "string", ",", "$", "encoding", "=", "null", ")", "{", "// Meh, the original mb_strlen interprets a null here as an empty string.", "if", "(", "$", "encoding", "===", "null", ")", "{", "return", "mb_strlen", "(", "$", "s...
Wrapper around mb_strlen, to circumvent a not installed mb_string php extension. @param string $string The string we want to analyse @param string $encoding The known encoding of the string, if known. @return integer The result.
[ "Wrapper", "around", "mb_strlen", "to", "circumvent", "a", "not", "installed", "mb_string", "php", "extension", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Misc/Encoding.php#L239-L246
train
silverorange/swat
Swat/SwatCalendar.php
SwatCalendar.display
public function display() { if (!$this->visible) { return; } parent::display(); $container_div_tag = new SwatHtmlTag('div'); $container_div_tag->id = $this->id; $container_div_tag->class = $this->getCSSClassString(); $container_div_tag->open(); // toggle button content is displayed with JavaScript if ($this->valid_range_start === null) { $today = new SwatDate(); $value = $today->formatLikeIntl('MM/dd/yyyy'); } else { $value = $this->valid_range_start->formatLikeIntl('MM/dd/yyyy'); } $input_tag = new SwatHtmlTag('input'); $input_tag->type = 'hidden'; $input_tag->id = $this->id . '_value'; $input_tag->name = $this->id . '_value'; $input_tag->value = $value; $input_tag->display(); $container_div_tag->close(); Swat::displayInlineJavaScript($this->getInlineJavaScript()); }
php
public function display() { if (!$this->visible) { return; } parent::display(); $container_div_tag = new SwatHtmlTag('div'); $container_div_tag->id = $this->id; $container_div_tag->class = $this->getCSSClassString(); $container_div_tag->open(); // toggle button content is displayed with JavaScript if ($this->valid_range_start === null) { $today = new SwatDate(); $value = $today->formatLikeIntl('MM/dd/yyyy'); } else { $value = $this->valid_range_start->formatLikeIntl('MM/dd/yyyy'); } $input_tag = new SwatHtmlTag('input'); $input_tag->type = 'hidden'; $input_tag->id = $this->id . '_value'; $input_tag->name = $this->id . '_value'; $input_tag->value = $value; $input_tag->display(); $container_div_tag->close(); Swat::displayInlineJavaScript($this->getInlineJavaScript()); }
[ "public", "function", "display", "(", ")", "{", "if", "(", "!", "$", "this", "->", "visible", ")", "{", "return", ";", "}", "parent", "::", "display", "(", ")", ";", "$", "container_div_tag", "=", "new", "SwatHtmlTag", "(", "'div'", ")", ";", "$", ...
Displays this calendar widget
[ "Displays", "this", "calendar", "widget" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCalendar.php#L63-L95
train
silverorange/swat
Swat/SwatCalendar.php
SwatCalendar.getInlineJavaScript
protected function getInlineJavaScript() { static $shown = false; if (!$shown) { $javascript = $this->getInlineJavaScriptTranslations(); $shown = true; } else { $javascript = ''; } if (isset($this->valid_range_start)) { $start_date = $this->valid_range_start->formatLikeIntl( 'MM/dd/yyyy' ); } else { $start_date = ''; } if (isset($this->valid_range_end)) { // JavaScript calendar is inclusive, subtract one second from range $tmp = clone $this->valid_range_end; $tmp->subtractSeconds(1); $end_date = $tmp->formatLikeIntl('MM/dd/yyyy'); } else { $end_date = ''; } $javascript .= sprintf( "var %s_obj = new SwatCalendar('%s', '%s', '%s');", $this->id, $this->id, $start_date, $end_date ); return $javascript; }
php
protected function getInlineJavaScript() { static $shown = false; if (!$shown) { $javascript = $this->getInlineJavaScriptTranslations(); $shown = true; } else { $javascript = ''; } if (isset($this->valid_range_start)) { $start_date = $this->valid_range_start->formatLikeIntl( 'MM/dd/yyyy' ); } else { $start_date = ''; } if (isset($this->valid_range_end)) { // JavaScript calendar is inclusive, subtract one second from range $tmp = clone $this->valid_range_end; $tmp->subtractSeconds(1); $end_date = $tmp->formatLikeIntl('MM/dd/yyyy'); } else { $end_date = ''; } $javascript .= sprintf( "var %s_obj = new SwatCalendar('%s', '%s', '%s');", $this->id, $this->id, $start_date, $end_date ); return $javascript; }
[ "protected", "function", "getInlineJavaScript", "(", ")", "{", "static", "$", "shown", "=", "false", ";", "if", "(", "!", "$", "shown", ")", "{", "$", "javascript", "=", "$", "this", "->", "getInlineJavaScriptTranslations", "(", ")", ";", "$", "shown", "...
Gets inline calendar JavaScript Inline JavaScript is the majority of the calendar code.
[ "Gets", "inline", "calendar", "JavaScript" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCalendar.php#L121-L158
train
rhoone/yii2-rhoone
Module.php
Module.bootstrapExtensions
protected function bootstrapExtensions($app) { $rhoone = Yii::$app->rhoone; /* @var $rhoone \rhoone\base\Rhoone */ $extensions = $rhoone->extensions; if (empty($extensions)) { return 0; } foreach ($extensions as $id => $extension) { if ($extension instanceof BootstrapInterface) { try { $extension->bootstrap($app); } catch (\Exception $ex) { Yii::error($ex->getMessage(), __METHOD__); continue; } } } $count = 0; foreach ($extensions as $ext) { $moduleConfig = []; try { $moduleConfig = $ext->getModule(); } catch (\Exception $ex) { continue; } if (empty($moduleConfig)) { continue; } Yii::info("`" . $moduleConfig['id'] . '` enabled.', __METHOD__); $app->setModule($moduleConfig['id'], $moduleConfig); $module = $app->getModule($moduleConfig['id']); if ($module instanceof BootstrapInterface) { $app->bootstrap[] = $module->id; Yii::trace('Bootstrap with ' . $module->className() . '::' . 'bootstrap()', __METHOD__); $module->bootstrap($app); $count++; } } return $count; }
php
protected function bootstrapExtensions($app) { $rhoone = Yii::$app->rhoone; /* @var $rhoone \rhoone\base\Rhoone */ $extensions = $rhoone->extensions; if (empty($extensions)) { return 0; } foreach ($extensions as $id => $extension) { if ($extension instanceof BootstrapInterface) { try { $extension->bootstrap($app); } catch (\Exception $ex) { Yii::error($ex->getMessage(), __METHOD__); continue; } } } $count = 0; foreach ($extensions as $ext) { $moduleConfig = []; try { $moduleConfig = $ext->getModule(); } catch (\Exception $ex) { continue; } if (empty($moduleConfig)) { continue; } Yii::info("`" . $moduleConfig['id'] . '` enabled.', __METHOD__); $app->setModule($moduleConfig['id'], $moduleConfig); $module = $app->getModule($moduleConfig['id']); if ($module instanceof BootstrapInterface) { $app->bootstrap[] = $module->id; Yii::trace('Bootstrap with ' . $module->className() . '::' . 'bootstrap()', __METHOD__); $module->bootstrap($app); $count++; } } return $count; }
[ "protected", "function", "bootstrapExtensions", "(", "$", "app", ")", "{", "$", "rhoone", "=", "Yii", "::", "$", "app", "->", "rhoone", ";", "/* @var $rhoone \\rhoone\\base\\Rhoone */", "$", "extensions", "=", "$", "rhoone", "->", "extensions", ";", "if", "(",...
Bootstrap with Extensions. @param \yii\base\Application $app @return int
[ "Bootstrap", "with", "Extensions", "." ]
f6ae90d466ea6f34bba404be0aba03e37ef369ad
https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/Module.php#L104-L145
train
silverorange/swat
Swat/SwatSelectList.php
SwatSelectList.display
public function display() { $options = $this->getOptions(); if (!$this->visible || count($options) === 0) { return; } SwatWidget::display(); $this->getForm()->addHiddenField($this->id . '_submitted', 1); $select_tag = new SwatHtmlTag('select'); $select_tag->id = $this->id; $select_tag->name = $this->id . '[]'; $select_tag->class = 'swat-select-list'; $select_tag->multiple = 'multiple'; $select_tag->size = $this->size; $select_tag->open(); foreach ($options as $key => $option) { $option_tag = new SwatHtmlTag('option'); $option_tag->value = (string) $option->value; $option_tag->id = $this->id . '_' . $key . '_' . $option_tag->value; $option_tag->selected = null; if (in_array($option->value, $this->values)) { $option_tag->selected = 'selected'; } $option_tag->setContent($option->title, $option->content_type); $option_tag->display(); } $select_tag->close(); }
php
public function display() { $options = $this->getOptions(); if (!$this->visible || count($options) === 0) { return; } SwatWidget::display(); $this->getForm()->addHiddenField($this->id . '_submitted', 1); $select_tag = new SwatHtmlTag('select'); $select_tag->id = $this->id; $select_tag->name = $this->id . '[]'; $select_tag->class = 'swat-select-list'; $select_tag->multiple = 'multiple'; $select_tag->size = $this->size; $select_tag->open(); foreach ($options as $key => $option) { $option_tag = new SwatHtmlTag('option'); $option_tag->value = (string) $option->value; $option_tag->id = $this->id . '_' . $key . '_' . $option_tag->value; $option_tag->selected = null; if (in_array($option->value, $this->values)) { $option_tag->selected = 'selected'; } $option_tag->setContent($option->title, $option->content_type); $option_tag->display(); } $select_tag->close(); }
[ "public", "function", "display", "(", ")", "{", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "!", "$", "this", "->", "visible", "||", "count", "(", "$", "options", ")", "===", "0", ")", "{", "return", ";", "}", ...
Displays this select list
[ "Displays", "this", "select", "list" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatSelectList.php#L27-L61
train
rhoone/yii2-rhoone
base/ExtensionHelperTrait.php
ExtensionHelperTrait.getModel
public static function getModel($class) { if ($class instanceof \rhoone\extension\Extension) { $class = $class->className(); } if (is_string($class)) { return \rhoone\models\Extension::find()->where(['classname' => static::normalizeClass($class)])->one(); } if ($class instanceof \rhoone\models\Extension) { return \rhoone\models\Extension::find()->guid($class->guid)->one(); } return null; }
php
public static function getModel($class) { if ($class instanceof \rhoone\extension\Extension) { $class = $class->className(); } if (is_string($class)) { return \rhoone\models\Extension::find()->where(['classname' => static::normalizeClass($class)])->one(); } if ($class instanceof \rhoone\models\Extension) { return \rhoone\models\Extension::find()->guid($class->guid)->one(); } return null; }
[ "public", "static", "function", "getModel", "(", "$", "class", ")", "{", "if", "(", "$", "class", "instanceof", "\\", "rhoone", "\\", "extension", "\\", "Extension", ")", "{", "$", "class", "=", "$", "class", "->", "className", "(", ")", ";", "}", "i...
Get extension model. @param string|\rhoone\extension\Extension|\rhoone\models\Extension $class @return \rhoone\models\Extension
[ "Get", "extension", "model", "." ]
f6ae90d466ea6f34bba404be0aba03e37ef369ad
https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/base/ExtensionHelperTrait.php#L123-L135
train
rhoone/yii2-rhoone
base/ExtensionHelperTrait.php
ExtensionHelperTrait.validate
public static function validate($class) { if ($class instanceof \rhoone\extension\Extension) { $class = $class->className(); } if ($class instanceof \rhoone\models\Extension) { $class = $class->classname; } if (!is_string($class)) { Yii::error('the class name is not a string.', __METHOD__); throw new InvalidParamException('the class name is not a string. (' . __METHOD__ . ')'); } Yii::trace('validate extension: `' . $class . '`', __METHOD__); $class = static::normalizeClass($class); $extension = static::validateExtension($class); $dic = DictionaryManager::validate($extension); return $extension; }
php
public static function validate($class) { if ($class instanceof \rhoone\extension\Extension) { $class = $class->className(); } if ($class instanceof \rhoone\models\Extension) { $class = $class->classname; } if (!is_string($class)) { Yii::error('the class name is not a string.', __METHOD__); throw new InvalidParamException('the class name is not a string. (' . __METHOD__ . ')'); } Yii::trace('validate extension: `' . $class . '`', __METHOD__); $class = static::normalizeClass($class); $extension = static::validateExtension($class); $dic = DictionaryManager::validate($extension); return $extension; }
[ "public", "static", "function", "validate", "(", "$", "class", ")", "{", "if", "(", "$", "class", "instanceof", "\\", "rhoone", "\\", "extension", "\\", "Extension", ")", "{", "$", "class", "=", "$", "class", "->", "className", "(", ")", ";", "}", "i...
Validate extension class. @param string|\rhoone\extension\Extension|\rhoone\models\Extension $class `string` if extension class name. `\rhoone\extension\Extension` if extension instance. `\rhoone\models\Extension` if extension record. @return \rhoone\extension\Extension @throws InvalidParamException
[ "Validate", "extension", "class", "." ]
f6ae90d466ea6f34bba404be0aba03e37ef369ad
https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/base/ExtensionHelperTrait.php#L271-L289
train
rhoone/yii2-rhoone
base/ExtensionHelperTrait.php
ExtensionHelperTrait.deregister
public static function deregister($class, $force = false) { $model = static::getModel($class); if (!$model) { throw new InvalidParamException("`$class` does not exist."); } if ($model->isEnabled && !$force) { throw new InvalidParamException("Unable to remove the enabled extensions."); } return $model->delete() == 1; }
php
public static function deregister($class, $force = false) { $model = static::getModel($class); if (!$model) { throw new InvalidParamException("`$class` does not exist."); } if ($model->isEnabled && !$force) { throw new InvalidParamException("Unable to remove the enabled extensions."); } return $model->delete() == 1; }
[ "public", "static", "function", "deregister", "(", "$", "class", ",", "$", "force", "=", "false", ")", "{", "$", "model", "=", "static", "::", "getModel", "(", "$", "class", ")", ";", "if", "(", "!", "$", "model", ")", "{", "throw", "new", "Invalid...
Deregister extension. @param string|\rhoone\extension\Extension|\rhoone\models\Extension $class @return boolean True if extension deregistered.
[ "Deregister", "extension", "." ]
f6ae90d466ea6f34bba404be0aba03e37ef369ad
https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/base/ExtensionHelperTrait.php#L296-L306
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.get
public static function get($locale = null) { $locale_object = null; if ($locale === null) { $locale_key = self::setlocale(LC_ALL, '0'); if (array_key_exists($locale_key, self::$locales)) { $locale_object = self::$locales[$locale_key]; } } elseif (is_array($locale)) { foreach ($locale as $locale_key) { if (array_key_exists($locale_key, self::$locales)) { $locale_object = self::$locales[$locale_key]; break; } } } else { if (array_key_exists($locale, self::$locales)) { $locale_object = self::$locales[$locale]; } } if ($locale_object === null) { $locale_object = new SwatI18NLocale($locale); if ($locale === null) { $locale_key = $locale_object->__toString(); self::$locales[$locale_key] = $locale_object; } elseif (is_array($locale)) { foreach ($locale as $locale_key) { self::$locales[$locale_key] = $locale_object; } } else { self::$locales[$locale] = $locale_object; } } return $locale_object; }
php
public static function get($locale = null) { $locale_object = null; if ($locale === null) { $locale_key = self::setlocale(LC_ALL, '0'); if (array_key_exists($locale_key, self::$locales)) { $locale_object = self::$locales[$locale_key]; } } elseif (is_array($locale)) { foreach ($locale as $locale_key) { if (array_key_exists($locale_key, self::$locales)) { $locale_object = self::$locales[$locale_key]; break; } } } else { if (array_key_exists($locale, self::$locales)) { $locale_object = self::$locales[$locale]; } } if ($locale_object === null) { $locale_object = new SwatI18NLocale($locale); if ($locale === null) { $locale_key = $locale_object->__toString(); self::$locales[$locale_key] = $locale_object; } elseif (is_array($locale)) { foreach ($locale as $locale_key) { self::$locales[$locale_key] = $locale_object; } } else { self::$locales[$locale] = $locale_object; } } return $locale_object; }
[ "public", "static", "function", "get", "(", "$", "locale", "=", "null", ")", "{", "$", "locale_object", "=", "null", ";", "if", "(", "$", "locale", "===", "null", ")", "{", "$", "locale_key", "=", "self", "::", "setlocale", "(", "LC_ALL", ",", "'0'",...
Gets a locale object @param array|string $locale the locale identifier of this locale object. If the locale is not valid for the current operating system, an exception is thrown. If no locale is specified, the current locale is used. Multiple locale identifiers may be specified in an array. In this case, the first valid locale is used. @return SwatI18NLocale a locale object for the requested <i>$locale</i>. @throws SwatException if the specified <i>$locale</i> is not valid for the current operating system.
[ "Gets", "a", "locale", "object" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L106-L143
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.setlocale
public static function setlocale($category, $locale) { $return = false; static $categories = array( 'LC_COLLATE' => LC_COLLATE, 'LC_CTYPE' => LC_CTYPE, 'LC_MONETARY' => LC_MONETARY, 'LC_NUMERIC' => LC_NUMERIC, 'LC_TIME' => LC_TIME, 'LC_MESSAGES' => LC_MESSAGES ); $parts = explode(';', $locale); if ($category === LC_ALL && count($parts) > 1) { // Handle case when LC_ALL is undefined and we're passing a giant // string with all the separate lc-type values. foreach ($parts as $part) { $part_exp = explode('=', $part, 2); if ( count($part_exp) === 2 && array_key_exists($part_exp[0], $categories) ) { $return = setlocale( $categories[$part_exp[0]], $part_exp[1] ); } } } else { $return = setlocale($category, $locale); } return $return; }
php
public static function setlocale($category, $locale) { $return = false; static $categories = array( 'LC_COLLATE' => LC_COLLATE, 'LC_CTYPE' => LC_CTYPE, 'LC_MONETARY' => LC_MONETARY, 'LC_NUMERIC' => LC_NUMERIC, 'LC_TIME' => LC_TIME, 'LC_MESSAGES' => LC_MESSAGES ); $parts = explode(';', $locale); if ($category === LC_ALL && count($parts) > 1) { // Handle case when LC_ALL is undefined and we're passing a giant // string with all the separate lc-type values. foreach ($parts as $part) { $part_exp = explode('=', $part, 2); if ( count($part_exp) === 2 && array_key_exists($part_exp[0], $categories) ) { $return = setlocale( $categories[$part_exp[0]], $part_exp[1] ); } } } else { $return = setlocale($category, $locale); } return $return; }
[ "public", "static", "function", "setlocale", "(", "$", "category", ",", "$", "locale", ")", "{", "$", "return", "=", "false", ";", "static", "$", "categories", "=", "array", "(", "'LC_COLLATE'", "=>", "LC_COLLATE", ",", "'LC_CTYPE'", "=>", "LC_CTYPE", ",",...
Sets the current locale This is a wrapper for the system setlocale() function that provides extra compatibility. @param integer $category optional. The lc-type constant specifying the category of functions affected by setting the system locale. @param array|string $locale the locale identifier. Use '0' to return the current system locale. Multiple locale identifiers may be specified in an array. In this case, the first valid locale is used. @return string|boolean the new or current locale, or false if an invalid <i>$locale</i> is specified.
[ "Sets", "the", "current", "locale" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L166-L200
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.set
public function set($category = LC_ALL) { $this->old_locale_by_category[$category] = self::setlocale( $category, '0' ); self::setlocale($category, $this->locale); }
php
public function set($category = LC_ALL) { $this->old_locale_by_category[$category] = self::setlocale( $category, '0' ); self::setlocale($category, $this->locale); }
[ "public", "function", "set", "(", "$", "category", "=", "LC_ALL", ")", "{", "$", "this", "->", "old_locale_by_category", "[", "$", "category", "]", "=", "self", "::", "setlocale", "(", "$", "category", ",", "'0'", ")", ";", "self", "::", "setlocale", "...
Sets the system locale to this locale @param integer $category optional. The lc-type constant specifying the category of functions affected by setting the system locale. If not specified, defaults to LC_ALL.
[ "Sets", "the", "system", "locale", "to", "this", "locale" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L213-L221
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.formatNumber
public function formatNumber( $value, $decimals = null, array $format = array() ) { $value = (float) $value; $format = $this->getNumberFormat()->override($format); if ($decimals === null) { $decimals = $this->getFractionalPrecision($value); } $value = round($value, $decimals); $integer_part = $this->formatIntegerGroupings($value, $format); $fractional_part = $this->formatFractionalPart( $value, $decimals, $format ); $sign = $value < 0 ? '-' : ''; $formatted_value = $sign . $integer_part . $fractional_part; return $formatted_value; }
php
public function formatNumber( $value, $decimals = null, array $format = array() ) { $value = (float) $value; $format = $this->getNumberFormat()->override($format); if ($decimals === null) { $decimals = $this->getFractionalPrecision($value); } $value = round($value, $decimals); $integer_part = $this->formatIntegerGroupings($value, $format); $fractional_part = $this->formatFractionalPart( $value, $decimals, $format ); $sign = $value < 0 ? '-' : ''; $formatted_value = $sign . $integer_part . $fractional_part; return $formatted_value; }
[ "public", "function", "formatNumber", "(", "$", "value", ",", "$", "decimals", "=", "null", ",", "array", "$", "format", "=", "array", "(", ")", ")", "{", "$", "value", "=", "(", "float", ")", "$", "value", ";", "$", "format", "=", "$", "this", "...
Formats a numeric value for this locale This methods uses the POSIX.2 LC_NUMERIC specification for formatting numeric values. Numeric values are rounded to the specified number of fractional digits using a round-half-up rounding method (PHP's default round). @param float $value the numeric value to format. @param integer $decimals optional. The number of fractional digits to include in the returned string. If not specified, all fractional digits are included. @param array $format optional. An associative array of number formatting information that overrides the formatting for this locale. The array is of the form <i>'property' => value</i>. For example, use the value <code>array('grouping' => 0)</code> to turn off numeric groupings. @return string a UTF-8 encoded string containing the formatted numeric value. @throws SwatException if a property name specified in the <i>$format</i> parameter is invalid.
[ "Formats", "a", "numeric", "value", "for", "this", "locale" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L562-L589
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.parseFloat
public function parseFloat($string) { $value = null; $lc = $this->getLocaleInfo(); $string = $this->parseNegativeNotation($string); $search = array( $lc['thousands_sep'], $lc['decimal_point'], $lc['positive_sign'], ' ' ); $replace = array('', '.', '', ''); $string = str_replace($search, $replace, $string); if (is_numeric($string)) { $value = floatval($string); } return $value; }
php
public function parseFloat($string) { $value = null; $lc = $this->getLocaleInfo(); $string = $this->parseNegativeNotation($string); $search = array( $lc['thousands_sep'], $lc['decimal_point'], $lc['positive_sign'], ' ' ); $replace = array('', '.', '', ''); $string = str_replace($search, $replace, $string); if (is_numeric($string)) { $value = floatval($string); } return $value; }
[ "public", "function", "parseFloat", "(", "$", "string", ")", "{", "$", "value", "=", "null", ";", "$", "lc", "=", "$", "this", "->", "getLocaleInfo", "(", ")", ";", "$", "string", "=", "$", "this", "->", "parseNegativeNotation", "(", "$", "string", "...
Parses a numeric string formatted for this locale into a floating-point number Note: The number does not have to be formatted exactly correctly to be parsed. Checking too closely how well a formatted number matches its locale would be annoying for users. For example, '1000' should not be rejected because it wasn't formatted as '1,000'. @param string $string the formatted string. @return float the numeric value of the parsed string. If the given value could not be parsed, null is returned.
[ "Parses", "a", "numeric", "string", "formatted", "for", "this", "locale", "into", "a", "floating", "-", "point", "number" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L657-L681
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.parseInteger
public function parseInteger($string) { $value = null; $lc = $this->getLocaleInfo(); $string = $this->parseNegativeNotation($string); $search = array($lc['thousands_sep'], $lc['positive_sign'], ' '); $replace = array('', '', ''); $string = str_replace($search, $replace, $string); if (is_numeric($string)) { if ($string > (float) PHP_INT_MAX) { throw new SwatIntegerOverflowException( 'Floating point value is too big to be an integer', null, 1 ); } if ($string < (float) (-PHP_INT_MAX - 1)) { throw new SwatIntegerOverflowException( 'Floating point value is too small to be an integer', null, -1 ); } $value = intval($string); } return $value; }
php
public function parseInteger($string) { $value = null; $lc = $this->getLocaleInfo(); $string = $this->parseNegativeNotation($string); $search = array($lc['thousands_sep'], $lc['positive_sign'], ' '); $replace = array('', '', ''); $string = str_replace($search, $replace, $string); if (is_numeric($string)) { if ($string > (float) PHP_INT_MAX) { throw new SwatIntegerOverflowException( 'Floating point value is too big to be an integer', null, 1 ); } if ($string < (float) (-PHP_INT_MAX - 1)) { throw new SwatIntegerOverflowException( 'Floating point value is too small to be an integer', null, -1 ); } $value = intval($string); } return $value; }
[ "public", "function", "parseInteger", "(", "$", "string", ")", "{", "$", "value", "=", "null", ";", "$", "lc", "=", "$", "this", "->", "getLocaleInfo", "(", ")", ";", "$", "string", "=", "$", "this", "->", "parseNegativeNotation", "(", "$", "string", ...
Parses a numeric string formatted for this locale into an integer number If the string has fractional digits, the returned integer value is rounded according to the rounding rules for {@link http://php.net/manual/en/function.intval.php intval()}. Note: The number does not have to be formatted exactly correctly to be parsed. Checking too closely how well a formatted number matches its locale would be annoying for users. For example, '1000' should not be rejected because it wasn't formatted as '1,000'. If the number is too large to fit in PHP's integer range (depends on system architecture), an exception is thrown. @param string $string the formatted string. @return integer the numeric value of the parsed string. If the given value could not be parsed, null is returned. @throws SwatIntegerOverflowException if the converted number is too large to fit in an integer or if the converted number is too small to fit in an integer.
[ "Parses", "a", "numeric", "string", "formatted", "for", "this", "locale", "into", "an", "integer", "number" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L710-L745
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.detectCharacterEncoding
protected function detectCharacterEncoding() { $encoding = null; if (function_exists('nl_langinfo') && is_callable('nl_langinfo')) { $encoding = nl_langinfo(CODESET); } else { // try to detect encoding from locale identifier $lc_ctype = null; $lc_all = self::setlocale(LC_ALL, '0'); $lc_all_exp = explode(';', $lc_all); if (count($lc_all_exp) === 1) { $lc_ctype = reset($lc_all_exp); } else { foreach ($lc_all_exp as $lc) { if (strncmp($lc, 'LC_CTYPE', 8) === 0) { $lc_ctype = $lc; break; } } } if ($lc_ctype !== null) { $lc_ctype_exp = explode('.', $lc_ctype, 2); if (count($lc_ctype_exp) === 2) { $encoding = $lc_ctype_exp[1]; } } } // assume encoding is a code-page if encoding is numeric if ($encoding !== null && ctype_digit($encoding)) { $encoding = 'CP' . $encoding; } return $encoding; }
php
protected function detectCharacterEncoding() { $encoding = null; if (function_exists('nl_langinfo') && is_callable('nl_langinfo')) { $encoding = nl_langinfo(CODESET); } else { // try to detect encoding from locale identifier $lc_ctype = null; $lc_all = self::setlocale(LC_ALL, '0'); $lc_all_exp = explode(';', $lc_all); if (count($lc_all_exp) === 1) { $lc_ctype = reset($lc_all_exp); } else { foreach ($lc_all_exp as $lc) { if (strncmp($lc, 'LC_CTYPE', 8) === 0) { $lc_ctype = $lc; break; } } } if ($lc_ctype !== null) { $lc_ctype_exp = explode('.', $lc_ctype, 2); if (count($lc_ctype_exp) === 2) { $encoding = $lc_ctype_exp[1]; } } } // assume encoding is a code-page if encoding is numeric if ($encoding !== null && ctype_digit($encoding)) { $encoding = 'CP' . $encoding; } return $encoding; }
[ "protected", "function", "detectCharacterEncoding", "(", ")", "{", "$", "encoding", "=", "null", ";", "if", "(", "function_exists", "(", "'nl_langinfo'", ")", "&&", "is_callable", "(", "'nl_langinfo'", ")", ")", "{", "$", "encoding", "=", "nl_langinfo", "(", ...
Detects the character encoding used by this locale @return string the character encoding used by this locale. If the encoding could not be detected, null is returned.
[ "Detects", "the", "character", "encoding", "used", "by", "this", "locale" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L854-L890
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.buildNumberFormat
protected function buildNumberFormat() { $lc = $this->getLocaleInfo(); $format = new SwatI18NNumberFormat(); $format->decimal_separator = $lc['decimal_point']; $format->thousands_separator = $lc['thousands_sep']; $format->grouping = $lc['grouping']; $this->number_format = $format; }
php
protected function buildNumberFormat() { $lc = $this->getLocaleInfo(); $format = new SwatI18NNumberFormat(); $format->decimal_separator = $lc['decimal_point']; $format->thousands_separator = $lc['thousands_sep']; $format->grouping = $lc['grouping']; $this->number_format = $format; }
[ "protected", "function", "buildNumberFormat", "(", ")", "{", "$", "lc", "=", "$", "this", "->", "getLocaleInfo", "(", ")", ";", "$", "format", "=", "new", "SwatI18NNumberFormat", "(", ")", ";", "$", "format", "->", "decimal_separator", "=", "$", "lc", "[...
Builds the number format of this locale
[ "Builds", "the", "number", "format", "of", "this", "locale" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L937-L948
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.buildNationalCurrencyFormat
protected function buildNationalCurrencyFormat() { $lc = $this->getLocaleInfo(); $format = new SwatI18NCurrencyFormat(); $format->fractional_digits = $lc['frac_digits']; $format->p_cs_precedes = $lc['p_cs_precedes']; $format->n_cs_precedes = $lc['n_cs_precedes']; $format->p_separate_by_space = $lc['p_sep_by_space']; $format->n_separate_by_space = $lc['n_sep_by_space']; $format->p_sign_position = $lc['p_sign_posn']; $format->n_sign_position = $lc['n_sign_posn']; $format->decimal_separator = $lc['mon_decimal_point'] == '' ? $lc['decimal_point'] : $lc['mon_decimal_point']; $format->thousands_separator = $lc['mon_thousands_sep']; $format->symbol = $lc['currency_symbol']; $format->grouping = $lc['mon_grouping']; $format->p_sign = $lc['positive_sign']; $format->n_sign = $lc['negative_sign']; // special-cases and workarounds switch ($this->preferred_locale) { // Hebrew-Israeli case 'he_IL': case 'he_IL.utf8': $format->p_sign_position = 1; $format->n_sign_position = 1; $format->p_cs_precedes = false; $format->n_cs_precedes = false; break; } $this->national_currency_format = $format; }
php
protected function buildNationalCurrencyFormat() { $lc = $this->getLocaleInfo(); $format = new SwatI18NCurrencyFormat(); $format->fractional_digits = $lc['frac_digits']; $format->p_cs_precedes = $lc['p_cs_precedes']; $format->n_cs_precedes = $lc['n_cs_precedes']; $format->p_separate_by_space = $lc['p_sep_by_space']; $format->n_separate_by_space = $lc['n_sep_by_space']; $format->p_sign_position = $lc['p_sign_posn']; $format->n_sign_position = $lc['n_sign_posn']; $format->decimal_separator = $lc['mon_decimal_point'] == '' ? $lc['decimal_point'] : $lc['mon_decimal_point']; $format->thousands_separator = $lc['mon_thousands_sep']; $format->symbol = $lc['currency_symbol']; $format->grouping = $lc['mon_grouping']; $format->p_sign = $lc['positive_sign']; $format->n_sign = $lc['negative_sign']; // special-cases and workarounds switch ($this->preferred_locale) { // Hebrew-Israeli case 'he_IL': case 'he_IL.utf8': $format->p_sign_position = 1; $format->n_sign_position = 1; $format->p_cs_precedes = false; $format->n_cs_precedes = false; break; } $this->national_currency_format = $format; }
[ "protected", "function", "buildNationalCurrencyFormat", "(", ")", "{", "$", "lc", "=", "$", "this", "->", "getLocaleInfo", "(", ")", ";", "$", "format", "=", "new", "SwatI18NCurrencyFormat", "(", ")", ";", "$", "format", "->", "fractional_digits", "=", "$", ...
Builds the national currency format of this locale
[ "Builds", "the", "national", "currency", "format", "of", "this", "locale" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L956-L993
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.buildInternationalCurrencyFormat
protected function buildInternationalCurrencyFormat() { $lc = $this->getLocaleInfo(); $format = new SwatI18NCurrencyFormat(); $format->fractional_digits = $lc['int_frac_digits']; $format->p_cs_precedes = $lc['p_cs_precedes']; $format->n_cs_precedes = $lc['n_cs_precedes']; $format->p_separate_by_space = $lc['p_sep_by_space']; $format->n_separate_by_space = $lc['n_sep_by_space']; $format->p_sign_position = $lc['p_sign_posn']; $format->n_sign_position = $lc['n_sign_posn']; $format->decimal_separator = $lc['mon_decimal_point'] == '' ? $lc['decimal_point'] : $lc['mon_decimal_point']; $format->thousands_separator = $lc['mon_thousands_sep']; $format->symbol = $lc['int_curr_symbol']; $format->grouping = $lc['mon_grouping']; $format->p_sign = $lc['positive_sign']; $format->n_sign = $lc['negative_sign']; $this->international_currency_format = $format; }
php
protected function buildInternationalCurrencyFormat() { $lc = $this->getLocaleInfo(); $format = new SwatI18NCurrencyFormat(); $format->fractional_digits = $lc['int_frac_digits']; $format->p_cs_precedes = $lc['p_cs_precedes']; $format->n_cs_precedes = $lc['n_cs_precedes']; $format->p_separate_by_space = $lc['p_sep_by_space']; $format->n_separate_by_space = $lc['n_sep_by_space']; $format->p_sign_position = $lc['p_sign_posn']; $format->n_sign_position = $lc['n_sign_posn']; $format->decimal_separator = $lc['mon_decimal_point'] == '' ? $lc['decimal_point'] : $lc['mon_decimal_point']; $format->thousands_separator = $lc['mon_thousands_sep']; $format->symbol = $lc['int_curr_symbol']; $format->grouping = $lc['mon_grouping']; $format->p_sign = $lc['positive_sign']; $format->n_sign = $lc['negative_sign']; $this->international_currency_format = $format; }
[ "protected", "function", "buildInternationalCurrencyFormat", "(", ")", "{", "$", "lc", "=", "$", "this", "->", "getLocaleInfo", "(", ")", ";", "$", "format", "=", "new", "SwatI18NCurrencyFormat", "(", ")", ";", "$", "format", "->", "fractional_digits", "=", ...
Builds the internatiobal currency format for this locale
[ "Builds", "the", "internatiobal", "currency", "format", "for", "this", "locale" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L1001-L1026
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.formatIntegerGroupings
protected function formatIntegerGroupings( $value, SwatI18NNumberFormat $format ) { // group integer part with thousands separators $grouping_values = array(); $groupings = $format->grouping; $grouping_total = intval(floor(abs($value))); if ( count($groupings) === 0 || $grouping_total === 0 || $format->thousands_separator == '' ) { array_push($grouping_values, $grouping_total); } else { $grouping_previous = 0; while (count($groupings) > 1 && $grouping_total > 0) { $grouping = array_shift($groupings); if ($grouping === 0) { // a grouping of 0 means use previous grouping $grouping = $grouping_previous; } elseif ($grouping === CHAR_MAX) { // a grouping of CHAR_MAX means no more grouping array_push($grouping_values, $grouping_total); break; } else { $grouping_previous = $grouping; } $grouping_value = floor( fmod($grouping_total, pow(10, $grouping)) ); $grouping_total = floor($grouping_total / pow(10, $grouping)); if ($grouping_total > 0) { $grouping_value = str_pad( $grouping_value, $grouping, '0', STR_PAD_LEFT ); } array_push($grouping_values, $grouping_value); } // last grouping repeats until integer part is finished $grouping = array_shift($groupings); // a grouping of CHAR_MAX means no more grouping if ($grouping === CHAR_MAX) { array_push($grouping_values, $grouping_total); } else { // a grouping of 0 means use previous grouping if ($grouping === 0) { $grouping = $grouping_previous; } // a grouping of 0 as the last grouping means no more grouping if ($grouping === 0) { array_push($grouping_values, $grouping_total); } else { while ($grouping_total > 0) { $grouping_value = floor( fmod($grouping_total, pow(10, $grouping)) ); $grouping_total = floor( $grouping_total / pow(10, $grouping) ); if ($grouping_total > 0) { $grouping_value = str_pad( $grouping_value, $grouping, '0', STR_PAD_LEFT ); } array_push($grouping_values, $grouping_value); } } } } $grouping_values = array_reverse($grouping_values); // join groupings using thousands separator $formatted_value = implode( $format->thousands_separator, $grouping_values ); return $formatted_value; }
php
protected function formatIntegerGroupings( $value, SwatI18NNumberFormat $format ) { // group integer part with thousands separators $grouping_values = array(); $groupings = $format->grouping; $grouping_total = intval(floor(abs($value))); if ( count($groupings) === 0 || $grouping_total === 0 || $format->thousands_separator == '' ) { array_push($grouping_values, $grouping_total); } else { $grouping_previous = 0; while (count($groupings) > 1 && $grouping_total > 0) { $grouping = array_shift($groupings); if ($grouping === 0) { // a grouping of 0 means use previous grouping $grouping = $grouping_previous; } elseif ($grouping === CHAR_MAX) { // a grouping of CHAR_MAX means no more grouping array_push($grouping_values, $grouping_total); break; } else { $grouping_previous = $grouping; } $grouping_value = floor( fmod($grouping_total, pow(10, $grouping)) ); $grouping_total = floor($grouping_total / pow(10, $grouping)); if ($grouping_total > 0) { $grouping_value = str_pad( $grouping_value, $grouping, '0', STR_PAD_LEFT ); } array_push($grouping_values, $grouping_value); } // last grouping repeats until integer part is finished $grouping = array_shift($groupings); // a grouping of CHAR_MAX means no more grouping if ($grouping === CHAR_MAX) { array_push($grouping_values, $grouping_total); } else { // a grouping of 0 means use previous grouping if ($grouping === 0) { $grouping = $grouping_previous; } // a grouping of 0 as the last grouping means no more grouping if ($grouping === 0) { array_push($grouping_values, $grouping_total); } else { while ($grouping_total > 0) { $grouping_value = floor( fmod($grouping_total, pow(10, $grouping)) ); $grouping_total = floor( $grouping_total / pow(10, $grouping) ); if ($grouping_total > 0) { $grouping_value = str_pad( $grouping_value, $grouping, '0', STR_PAD_LEFT ); } array_push($grouping_values, $grouping_value); } } } } $grouping_values = array_reverse($grouping_values); // join groupings using thousands separator $formatted_value = implode( $format->thousands_separator, $grouping_values ); return $formatted_value; }
[ "protected", "function", "formatIntegerGroupings", "(", "$", "value", ",", "SwatI18NNumberFormat", "$", "format", ")", "{", "// group integer part with thousands separators", "$", "grouping_values", "=", "array", "(", ")", ";", "$", "groupings", "=", "$", "format", ...
Formats the integer part of a value according to format-specific numeric groupings This is a number formatting helper method. It is responsible for grouping integer-part digits. Grouped digits are separated using the thousands separator character specified by the format object. @param float $value the value to format. @param SwatI18NNumberFormat the number format to use. @return string the grouped integer part of the value.
[ "Formats", "the", "integer", "part", "of", "a", "value", "according", "to", "format", "-", "specific", "numeric", "groupings" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L1044-L1140
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.formatFractionalPart
protected function formatFractionalPart( $value, $fractional_digits, SwatI18NNumberFormat $format ) { if ($fractional_digits === 0) { $formatted_value = ''; } else { $frac_part = abs(fmod($value, 1)); $frac_part = round($frac_part * pow(10, $fractional_digits)); $frac_part = str_pad( $frac_part, $fractional_digits, '0', STR_PAD_LEFT ); $formatted_value = $format->decimal_separator . $frac_part; } return $formatted_value; }
php
protected function formatFractionalPart( $value, $fractional_digits, SwatI18NNumberFormat $format ) { if ($fractional_digits === 0) { $formatted_value = ''; } else { $frac_part = abs(fmod($value, 1)); $frac_part = round($frac_part * pow(10, $fractional_digits)); $frac_part = str_pad( $frac_part, $fractional_digits, '0', STR_PAD_LEFT ); $formatted_value = $format->decimal_separator . $frac_part; } return $formatted_value; }
[ "protected", "function", "formatFractionalPart", "(", "$", "value", ",", "$", "fractional_digits", ",", "SwatI18NNumberFormat", "$", "format", ")", "{", "if", "(", "$", "fractional_digits", "===", "0", ")", "{", "$", "formatted_value", "=", "''", ";", "}", "...
Formats the fractional part of a value @param float $value the value to format. @param integer $fractional_digits the number of fractional digits to include in the returned string. @param SwatI18NNumberFormat $format the number formatting object to use to format the fractional digits. @return string the formatted fractional digits. If the number of displayed fractional digits is greater than zero, the string is prepended with the decimal separator character of the format object.
[ "Formats", "the", "fractional", "part", "of", "a", "value" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L1159-L1180
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.parseNegativeNotation
protected function parseNegativeNotation( $string, $n_sign = null, $n_sign_position = 1 ) { $lc = $this->getLocaleInfo(); $negative = false; if ($n_sign == '') { if ($lc['negative_sign'] == '') { $negative_sign = '-'; } else { $negative_sign = $lc['negative_sign']; } } else { $negative_sign = $n_sign; } // filter out all chars except for digits and negative formatting chars $char_class = '0-9' . preg_quote($negative_sign, '/'); if ($n_sign_position === 0) { $char_class = '()' . $char_class; } $exp = '/[^' . $char_class . ']/u'; $filtered = preg_replace($exp, '', $string); if ($filtered != '') { if ($filtered[0] === '-' || mb_substr($filtered, -1) === '-') { // always allow parsing by negative sign $negative = true; $string = str_replace($negative_sign, '', $string); } elseif ( $n_sign_position === 0 && $filtered[0] === '(' && mb_substr($filtered, -1) === ')' ) { // parse parenthetical negative shown as: (5.00) $negative = true; $string = str_replace(array('(', ')'), '', $string); } } if ($negative) { $string = '-' . $string; } return $string; }
php
protected function parseNegativeNotation( $string, $n_sign = null, $n_sign_position = 1 ) { $lc = $this->getLocaleInfo(); $negative = false; if ($n_sign == '') { if ($lc['negative_sign'] == '') { $negative_sign = '-'; } else { $negative_sign = $lc['negative_sign']; } } else { $negative_sign = $n_sign; } // filter out all chars except for digits and negative formatting chars $char_class = '0-9' . preg_quote($negative_sign, '/'); if ($n_sign_position === 0) { $char_class = '()' . $char_class; } $exp = '/[^' . $char_class . ']/u'; $filtered = preg_replace($exp, '', $string); if ($filtered != '') { if ($filtered[0] === '-' || mb_substr($filtered, -1) === '-') { // always allow parsing by negative sign $negative = true; $string = str_replace($negative_sign, '', $string); } elseif ( $n_sign_position === 0 && $filtered[0] === '(' && mb_substr($filtered, -1) === ')' ) { // parse parenthetical negative shown as: (5.00) $negative = true; $string = str_replace(array('(', ')'), '', $string); } } if ($negative) { $string = '-' . $string; } return $string; }
[ "protected", "function", "parseNegativeNotation", "(", "$", "string", ",", "$", "n_sign", "=", "null", ",", "$", "n_sign_position", "=", "1", ")", "{", "$", "lc", "=", "$", "this", "->", "getLocaleInfo", "(", ")", ";", "$", "negative", "=", "false", ";...
Parses the negative notation for a numeric string formatted in this locale @param string $string the formatted string. @param string $n_sign optional. The negative sign to parse. If not specified, the negative sign for this locale is used. @param integer $n_sign_position optional. The position of the negative sign in the formatted string. If not specified, the value 1 is assumed. This may be used to allow parsing parenthetical formatted negative values as used by some currencies. @return string the formatted string with the negative notation parsed and normalized into a form readable by intval() and floatval().
[ "Parses", "the", "negative", "notation", "for", "a", "numeric", "string", "formatted", "in", "this", "locale" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L1204-L1252
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.getFractionalPrecision
protected function getFractionalPrecision($value) { /* * This is a bit hacky (and probably slow). We get the string * representation and then count the number of digits after the decimal * separator. This may or may not be faster than the equivalent * IEEE-754 decomposition (written in PHP). The string-based code has * not been profiled against the equivalent IEEE-754 code. */ $value = (float) $value; // get current locale $locale = self::get(); $precision = 0; $lc = $locale->getLocaleInfo(); $str_value = (string) $value; $e_pos = mb_stripos($str_value, 'E-'); if ($e_pos !== false) { $precision += (int) mb_substr($str_value, $e_pos + 2); $str_value = mb_substr($str_value, 0, $e_pos); } $decimal_pos = mb_strpos($str_value, $lc['decimal_point']); if ($decimal_pos !== false) { $precision += mb_strlen($str_value) - $decimal_pos - mb_strlen($lc['decimal_point']); } return $precision; }
php
protected function getFractionalPrecision($value) { /* * This is a bit hacky (and probably slow). We get the string * representation and then count the number of digits after the decimal * separator. This may or may not be faster than the equivalent * IEEE-754 decomposition (written in PHP). The string-based code has * not been profiled against the equivalent IEEE-754 code. */ $value = (float) $value; // get current locale $locale = self::get(); $precision = 0; $lc = $locale->getLocaleInfo(); $str_value = (string) $value; $e_pos = mb_stripos($str_value, 'E-'); if ($e_pos !== false) { $precision += (int) mb_substr($str_value, $e_pos + 2); $str_value = mb_substr($str_value, 0, $e_pos); } $decimal_pos = mb_strpos($str_value, $lc['decimal_point']); if ($decimal_pos !== false) { $precision += mb_strlen($str_value) - $decimal_pos - mb_strlen($lc['decimal_point']); } return $precision; }
[ "protected", "function", "getFractionalPrecision", "(", "$", "value", ")", "{", "/*\n * This is a bit hacky (and probably slow). We get the string\n * representation and then count the number of digits after the decimal\n * separator. This may or may not be faster than the eq...
Gets the fractional precision of a floating point number This gets the number of digits after the decimal point. @param float $value the value for which to get the fractional precision. @return integer the fractional precision of the value.
[ "Gets", "the", "fractional", "precision", "of", "a", "floating", "point", "number" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L1266-L1300
train
silverorange/swat
SwatI18N/SwatI18NLocale.php
SwatI18NLocale.iconvArray
private function iconvArray($from, $to, array $array) { if ($from != $to) { foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = $this->iconvArray($from, $to, $value); } elseif (is_string($value)) { $output = iconv($from, $to, $value); if ($output === false) { throw new SwatException( sprintf( 'Could not convert %s output to %s', $from, $to ) ); } $array[$key] = $output; } } } return $array; }
php
private function iconvArray($from, $to, array $array) { if ($from != $to) { foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = $this->iconvArray($from, $to, $value); } elseif (is_string($value)) { $output = iconv($from, $to, $value); if ($output === false) { throw new SwatException( sprintf( 'Could not convert %s output to %s', $from, $to ) ); } $array[$key] = $output; } } } return $array; }
[ "private", "function", "iconvArray", "(", "$", "from", ",", "$", "to", ",", "array", "$", "array", ")", "{", "if", "(", "$", "from", "!=", "$", "to", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", ...
Recursivly converts the character encoding of all strings in an array @param string $from the character encoding to convert from. @param string $to the character encoding to convert to. @param array $array the array to convert. @return array a new array with all strings converted to the given character encoding. @throws SwatException if any component of the array can not be converted from the <i>$from</i> character encoding to the <i>$to</i> character encoding.
[ "Recursivly", "converts", "the", "character", "encoding", "of", "all", "strings", "in", "an", "array" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatI18N/SwatI18NLocale.php#L1406-L1430
train
brainworxx/kreXX
src/Controller/ErrorController.php
ErrorController.errorAction
public function errorAction(array $errorData) { $this->pool->reset(); // Get the main part. $main = $this->pool->render->renderFatalMain( $errorData[static::TRACE_TYPE], $errorData[static::TRACE_ERROR_STRING], $errorData[static::TRACE_ERROR_FILE], $errorData[static::TRACE_ERROR_LINE] ); // Get the backtrace. $backtrace = $this->pool ->createClass('Brainworxx\\Krexx\\Analyse\\Routing\\Process\\ProcessBacktrace') ->process($errorData[static::TRACE_BACKTRACE]); if ($this->pool->emergencyHandler->checkEmergencyBreak() === true) { return $this; } // Detect the encoding on the start-chunk-string of the analysis // for a complete encoding picture. $this->pool->chunks->detectEncoding($main . $backtrace); // Get the header, footer and messages $footer = $this->outputFooter(array()); $header = $this->pool->render->renderFatalHeader($this->outputCssAndJs()); $messages = $this->pool->messages->outputMessages(); // Add the caller as metadata to the chunks class. It will be saved as // additional info, in case we are logging to a file. $this->pool->chunks->addMetadata( array( static::TRACE_FILE => $errorData[static::TRACE_ERROR_FILE], static::TRACE_LINE => $errorData[static::TRACE_ERROR_LINE] + 1, static::TRACE_VARNAME => ' Fatal Error', ) ); $this->outputService->addChunkString($header) ->addChunkString($messages) ->addChunkString($main) ->addChunkString($backtrace) ->addChunkString($footer) ->finalize(); return $this; }
php
public function errorAction(array $errorData) { $this->pool->reset(); // Get the main part. $main = $this->pool->render->renderFatalMain( $errorData[static::TRACE_TYPE], $errorData[static::TRACE_ERROR_STRING], $errorData[static::TRACE_ERROR_FILE], $errorData[static::TRACE_ERROR_LINE] ); // Get the backtrace. $backtrace = $this->pool ->createClass('Brainworxx\\Krexx\\Analyse\\Routing\\Process\\ProcessBacktrace') ->process($errorData[static::TRACE_BACKTRACE]); if ($this->pool->emergencyHandler->checkEmergencyBreak() === true) { return $this; } // Detect the encoding on the start-chunk-string of the analysis // for a complete encoding picture. $this->pool->chunks->detectEncoding($main . $backtrace); // Get the header, footer and messages $footer = $this->outputFooter(array()); $header = $this->pool->render->renderFatalHeader($this->outputCssAndJs()); $messages = $this->pool->messages->outputMessages(); // Add the caller as metadata to the chunks class. It will be saved as // additional info, in case we are logging to a file. $this->pool->chunks->addMetadata( array( static::TRACE_FILE => $errorData[static::TRACE_ERROR_FILE], static::TRACE_LINE => $errorData[static::TRACE_ERROR_LINE] + 1, static::TRACE_VARNAME => ' Fatal Error', ) ); $this->outputService->addChunkString($header) ->addChunkString($messages) ->addChunkString($main) ->addChunkString($backtrace) ->addChunkString($footer) ->finalize(); return $this; }
[ "public", "function", "errorAction", "(", "array", "$", "errorData", ")", "{", "$", "this", "->", "pool", "->", "reset", "(", ")", ";", "// Get the main part.", "$", "main", "=", "$", "this", "->", "pool", "->", "render", "->", "renderFatalMain", "(", "$...
Renders the info to the error, warning or notice. @param array $errorData The data from the error. This should be a backtrace with code samples. @return $this Return $this for chaining
[ "Renders", "the", "info", "to", "the", "error", "warning", "or", "notice", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Controller/ErrorController.php#L56-L104
train
brainworxx/kreXX
src/Controller/ErrorController.php
ErrorController.registerFatalAction
public function registerFatalAction() { // As of PHP Version 7.0.2, the register_tick_function() causes PHP to // crash, with a connection reset! We need to check the version to avoid // this, and then tell the dev what happened. // Not to mention that fatals got removed anyway. if (version_compare(phpversion(), '7.0.0', '>=')) { // Too high! 420 Method Failure :-( $this->pool->messages->addMessage($this->pool->messages->getHelp('php7yellow')); krexx($this->pool->messages->getHelp('php7')); // Just return, there is nothing more to do here. return $this; } // Do we need another shutdown handler? if (static::$krexxFatal === null) { static::$krexxFatal = $this->pool->createClass('Brainworxx\\Krexx\\Errorhandler\\Fatal'); declare(ticks = 1); register_shutdown_function( array( static::$krexxFatal, 'shutdownCallback', ) ); } static::$krexxFatal->setIsActive(true); $this->fatalShouldActive = true; register_tick_function(array($this::$krexxFatal, 'tickCallback')); return $this; }
php
public function registerFatalAction() { // As of PHP Version 7.0.2, the register_tick_function() causes PHP to // crash, with a connection reset! We need to check the version to avoid // this, and then tell the dev what happened. // Not to mention that fatals got removed anyway. if (version_compare(phpversion(), '7.0.0', '>=')) { // Too high! 420 Method Failure :-( $this->pool->messages->addMessage($this->pool->messages->getHelp('php7yellow')); krexx($this->pool->messages->getHelp('php7')); // Just return, there is nothing more to do here. return $this; } // Do we need another shutdown handler? if (static::$krexxFatal === null) { static::$krexxFatal = $this->pool->createClass('Brainworxx\\Krexx\\Errorhandler\\Fatal'); declare(ticks = 1); register_shutdown_function( array( static::$krexxFatal, 'shutdownCallback', ) ); } static::$krexxFatal->setIsActive(true); $this->fatalShouldActive = true; register_tick_function(array($this::$krexxFatal, 'tickCallback')); return $this; }
[ "public", "function", "registerFatalAction", "(", ")", "{", "// As of PHP Version 7.0.2, the register_tick_function() causes PHP to", "// crash, with a connection reset! We need to check the version to avoid", "// this, and then tell the dev what happened.", "// Not to mention that fatals got remo...
Register the fatal error handler. @return $this Return $this for chaining
[ "Register", "the", "fatal", "error", "handler", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Controller/ErrorController.php#L112-L144
train
brainworxx/kreXX
src/Controller/ErrorController.php
ErrorController.unregisterFatalAction
public function unregisterFatalAction() { $this->fatalShouldActive = false; if ($this::$krexxFatal === null) { // There is no fatal error handler to begin with. return $this; } // Now we need to tell the shutdown function, that is must // not do anything on shutdown. $this::$krexxFatal->setIsActive(false); unregister_tick_function(array($this::$krexxFatal, 'tickCallback')); return $this; }
php
public function unregisterFatalAction() { $this->fatalShouldActive = false; if ($this::$krexxFatal === null) { // There is no fatal error handler to begin with. return $this; } // Now we need to tell the shutdown function, that is must // not do anything on shutdown. $this::$krexxFatal->setIsActive(false); unregister_tick_function(array($this::$krexxFatal, 'tickCallback')); return $this; }
[ "public", "function", "unregisterFatalAction", "(", ")", "{", "$", "this", "->", "fatalShouldActive", "=", "false", ";", "if", "(", "$", "this", "::", "$", "krexxFatal", "===", "null", ")", "{", "// There is no fatal error handler to begin with.", "return", "$", ...
"Unregister" the fatal error handler. Actually we can not unregister it. We simply tell it to not activate and we unregister the tick function which provides us with the backtrace. @return $this Return $this for chaining
[ "Unregister", "the", "fatal", "error", "handler", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Controller/ErrorController.php#L156-L170
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.init
public function init() { parent::init(); $this->createEmbeddedWidgets(); $this->enter_another_link->title = $this->enter_text; $this->enter_another_link->link = sprintf( "javascript:%s_obj.addRow();", $this->getId() ); $this->enter_another_link->init(); // init input cells foreach ($this->input_cells as $cell) { $cell->init(); } /* * Initialize replicators * * Don't use getHiddenField() here because the serialized field is not * updated by the controlling JavaScript and will not contain added * replicator ids. */ $data = $this->getForm()->getFormData(); $replicator_field = isset($data[$this->getId() . '_replicators']) ? $data[$this->getId() . '_replicators'] : null; if ($replicator_field === null || $replicator_field == '') { // use generated ids for ($i = 0; $i < $this->number; $i++) { $this->replicators[] = $i; } } else { // retrieve ids from form $this->replicators = explode(',', $replicator_field); } }
php
public function init() { parent::init(); $this->createEmbeddedWidgets(); $this->enter_another_link->title = $this->enter_text; $this->enter_another_link->link = sprintf( "javascript:%s_obj.addRow();", $this->getId() ); $this->enter_another_link->init(); // init input cells foreach ($this->input_cells as $cell) { $cell->init(); } /* * Initialize replicators * * Don't use getHiddenField() here because the serialized field is not * updated by the controlling JavaScript and will not contain added * replicator ids. */ $data = $this->getForm()->getFormData(); $replicator_field = isset($data[$this->getId() . '_replicators']) ? $data[$this->getId() . '_replicators'] : null; if ($replicator_field === null || $replicator_field == '') { // use generated ids for ($i = 0; $i < $this->number; $i++) { $this->replicators[] = $i; } } else { // retrieve ids from form $this->replicators = explode(',', $replicator_field); } }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "$", "this", "->", "createEmbeddedWidgets", "(", ")", ";", "$", "this", "->", "enter_another_link", "->", "title", "=", "$", "this", "->", "enter_text", ";", "$", "this...
Initializes this input row This initializes each input cell in this row. @see SwatTableViewRow::init()
[ "Initializes", "this", "input", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L128-L167
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.process
public function process() { parent::process(); // process input cells foreach ($this->replicators as $replicator_id) { foreach ($this->input_cells as $cell) { $cell->process($replicator_id); } } }
php
public function process() { parent::process(); // process input cells foreach ($this->replicators as $replicator_id) { foreach ($this->input_cells as $cell) { $cell->process($replicator_id); } } }
[ "public", "function", "process", "(", ")", "{", "parent", "::", "process", "(", ")", ";", "// process input cells", "foreach", "(", "$", "this", "->", "replicators", "as", "$", "replicator_id", ")", "{", "foreach", "(", "$", "this", "->", "input_cells", "a...
Processes this input row This gets the replicator ids of rows the user entered as well as processing all cloned widgets in input cells that the user submitted.
[ "Processes", "this", "input", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L178-L188
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.display
public function display() { if (!$this->isVisible()) { return; } parent::display(); if (count($this->replicators) < $this->number) { $diff = $this->number - count($this->replicators); $next_replicator = count($this->replicators) === 0 ? 0 : end($this->replicators) + 1; for ($i = $next_replicator; $i < $diff + $next_replicator; $i++) { $this->replicators[] = $i; } } // add replicator ids to the form as a hidden field $this->getForm()->addHiddenField( $this->getId() . '_replicators', implode(',', $this->replicators) ); $this->displayInputRows(); $this->displayEnterAnotherRow(); }
php
public function display() { if (!$this->isVisible()) { return; } parent::display(); if (count($this->replicators) < $this->number) { $diff = $this->number - count($this->replicators); $next_replicator = count($this->replicators) === 0 ? 0 : end($this->replicators) + 1; for ($i = $next_replicator; $i < $diff + $next_replicator; $i++) { $this->replicators[] = $i; } } // add replicator ids to the form as a hidden field $this->getForm()->addHiddenField( $this->getId() . '_replicators', implode(',', $this->replicators) ); $this->displayInputRows(); $this->displayEnterAnotherRow(); }
[ "public", "function", "display", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isVisible", "(", ")", ")", "{", "return", ";", "}", "parent", "::", "display", "(", ")", ";", "if", "(", "count", "(", "$", "this", "->", "replicators", ")", "<",...
Displays this row Uses widget cloning inside {@link SwatInputCell} to display rows and also displays the 'enter-another-row' button. The number of rows displayed is set either through {SwatTableViewInputRow::$number} or by the number of rows the user submitted. When a user submits a different number of rows than {SwatTableViewInputRow::$number} it the user submitted number takes precedence.
[ "Displays", "this", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L225-L253
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.getWidget
public function getWidget($column_id, $row_identifier, $widget_id = null) { if (isset($this->input_cells[$column_id])) { return $this->input_cells[$column_id]->getWidget( $row_identifier, $widget_id ); } throw new SwatException( 'No input cell for this row exists for the ' . 'given column identifier.' ); }
php
public function getWidget($column_id, $row_identifier, $widget_id = null) { if (isset($this->input_cells[$column_id])) { return $this->input_cells[$column_id]->getWidget( $row_identifier, $widget_id ); } throw new SwatException( 'No input cell for this row exists for the ' . 'given column identifier.' ); }
[ "public", "function", "getWidget", "(", "$", "column_id", ",", "$", "row_identifier", ",", "$", "widget_id", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "input_cells", "[", "$", "column_id", "]", ")", ")", "{", "return", "$", "...
Gets a particular widget in this row This method is used to get or set properties of specific cloned widgets within this input row. The most common case is when you want to iterate through the user submitted data in this input row. @param string $column_id the unique identifier of the table-view column the widget resides in. @param integer $row_identifier the numeric row identifier of the widget. @param string $widget_id the unique identifier of the widget. If no id is specified, the root widget of the column's cell is returned for the given row. @return SwatWidget @see SwatInputCell::getWidget() @throws SwatException
[ "Gets", "a", "particular", "widget", "in", "this", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L314-L327
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.getPrototypeWidget
public function getPrototypeWidget($column_id) { if (isset($this->input_cells[$column_id])) { return $this->input_cells[$column_id]->getPrototypeWidget(); } throw new SwatException( 'The specified column does not have an input ' . 'cell bound to this row or the column does not exist.' ); }
php
public function getPrototypeWidget($column_id) { if (isset($this->input_cells[$column_id])) { return $this->input_cells[$column_id]->getPrototypeWidget(); } throw new SwatException( 'The specified column does not have an input ' . 'cell bound to this row or the column does not exist.' ); }
[ "public", "function", "getPrototypeWidget", "(", "$", "column_id", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "input_cells", "[", "$", "column_id", "]", ")", ")", "{", "return", "$", "this", "->", "input_cells", "[", "$", "column_id", "]", "...
Gets the prototype widget for a column attached to this row Note: The UI tree must be inited before this method works correctly. This is because the column identifiers are not finalized until init() has run and this method uses colum identifiers for lookup. This method is useful for setting properties on the prototype widget; however, the {@link SwatTableViewColumn::getInputCell()} method is even more useful because it may be safely used before init() is called on the UI tree. You can then call {@link SwatInputCell::getPrototypeWidget()} on the returned input cell. @param string $column_id the unique identifier of the column to get the prototype widget from. @return SwatWidget the prototype widget from the given column. @see SwatTableViewColumn::getInputCell() @throws SwatException
[ "Gets", "the", "prototype", "widget", "for", "a", "column", "attached", "to", "this", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L353-L363
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.removeReplicatedRow
public function removeReplicatedRow($replicator_id) { $this->replicators = array_diff($this->replicators, array( $replicator_id )); foreach ($this->input_cells as $cell) { $cell->unsetWidget($replicator_id); } }
php
public function removeReplicatedRow($replicator_id) { $this->replicators = array_diff($this->replicators, array( $replicator_id )); foreach ($this->input_cells as $cell) { $cell->unsetWidget($replicator_id); } }
[ "public", "function", "removeReplicatedRow", "(", "$", "replicator_id", ")", "{", "$", "this", "->", "replicators", "=", "array_diff", "(", "$", "this", "->", "replicators", ",", "array", "(", "$", "replicator_id", ")", ")", ";", "foreach", "(", "$", "this...
Removes a row from this input row by its replicator id This also unsets any cloned widgets from this row's input cells. @param integer $replicator_id the replicator id of the row to remove.
[ "Removes", "a", "row", "from", "this", "input", "row", "by", "its", "replicator", "id" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L375-L384
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.rowHasMessage
public function rowHasMessage($replicator_id) { $row_has_message = false; foreach ($this->input_cells as $cell) { if ($cell->getWidget($replicator_id)->hasMessage()) { $row_has_message = true; break; } } return $row_has_message; }
php
public function rowHasMessage($replicator_id) { $row_has_message = false; foreach ($this->input_cells as $cell) { if ($cell->getWidget($replicator_id)->hasMessage()) { $row_has_message = true; break; } } return $row_has_message; }
[ "public", "function", "rowHasMessage", "(", "$", "replicator_id", ")", "{", "$", "row_has_message", "=", "false", ";", "foreach", "(", "$", "this", "->", "input_cells", "as", "$", "cell", ")", "{", "if", "(", "$", "cell", "->", "getWidget", "(", "$", "...
Gets whether or not a given replicated row has messages @param integer $replicator_id the replicator id of the row to check for messages. @return boolean true if the replicated row has one or more messages and false if it does not.
[ "Gets", "whether", "or", "not", "a", "given", "replicated", "row", "has", "messages" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L418-L430
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.getMessages
public function getMessages() { $messages = array(); foreach ($this->replicators as $replicator_id) { foreach ($this->input_cells as $cell) { $messages = array_merge( $messages, $cell->getWidget($replicator_id)->getMessages() ); } } return $messages; }
php
public function getMessages() { $messages = array(); foreach ($this->replicators as $replicator_id) { foreach ($this->input_cells as $cell) { $messages = array_merge( $messages, $cell->getWidget($replicator_id)->getMessages() ); } } return $messages; }
[ "public", "function", "getMessages", "(", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "replicators", "as", "$", "replicator_id", ")", "{", "foreach", "(", "$", "this", "->", "input_cells", "as", "$", "cell...
Gathers all messages from this table-view row @return array an array of {@link SwatMessage} objects.
[ "Gathers", "all", "messages", "from", "this", "table", "-", "view", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L440-L454
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.getInlineJavaScript
public function getInlineJavaScript() { /* * Encode row string * * Mimize entities so that we do not have to specify a DTD when parsing * the final XML string. If we specify a DTD, Internet Explorer takes a * long time to strictly parse everything. If we do not specify a DTD * and try to parse the final XML string with XHTML entities in it we * get an undefined entity error. */ $row_string = $this->getRowString(); // these entities need to be double escaped $row_string = str_replace('&amp;', '&amp;amp;', $row_string); $row_string = str_replace('&quot;', '&amp;quot;', $row_string); $row_string = str_replace('&lt;', '&amp;lt;', $row_string); $row_string = SwatString::minimizeEntities($row_string); $row_string = str_replace("'", "\'", $row_string); // encode newlines for JavaScript string $row_string = str_replace("\n", '\n', $row_string); return sprintf( "var %s_obj = new SwatTableViewInputRow('%s', '%s');", $this->getId(), $this->getId(), trim($row_string) ); }
php
public function getInlineJavaScript() { /* * Encode row string * * Mimize entities so that we do not have to specify a DTD when parsing * the final XML string. If we specify a DTD, Internet Explorer takes a * long time to strictly parse everything. If we do not specify a DTD * and try to parse the final XML string with XHTML entities in it we * get an undefined entity error. */ $row_string = $this->getRowString(); // these entities need to be double escaped $row_string = str_replace('&amp;', '&amp;amp;', $row_string); $row_string = str_replace('&quot;', '&amp;quot;', $row_string); $row_string = str_replace('&lt;', '&amp;lt;', $row_string); $row_string = SwatString::minimizeEntities($row_string); $row_string = str_replace("'", "\'", $row_string); // encode newlines for JavaScript string $row_string = str_replace("\n", '\n', $row_string); return sprintf( "var %s_obj = new SwatTableViewInputRow('%s', '%s');", $this->getId(), $this->getId(), trim($row_string) ); }
[ "public", "function", "getInlineJavaScript", "(", ")", "{", "/*\n * Encode row string\n *\n * Mimize entities so that we do not have to specify a DTD when parsing\n * the final XML string. If we specify a DTD, Internet Explorer takes a\n * long time to strictly pa...
Creates a JavaScript object to control the client behaviour of this input row @return string the inline JavaScript required by this row.
[ "Creates", "a", "JavaScript", "object", "to", "control", "the", "client", "behaviour", "of", "this", "input", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L490-L518
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.getHtmlHeadEntrySet
public function getHtmlHeadEntrySet() { $set = parent::getHtmlHeadEntrySet(); $this->createEmbeddedWidgets(); $set->addEntrySet($this->enter_another_link->getHtmlHeadEntrySet()); return $set; }
php
public function getHtmlHeadEntrySet() { $set = parent::getHtmlHeadEntrySet(); $this->createEmbeddedWidgets(); $set->addEntrySet($this->enter_another_link->getHtmlHeadEntrySet()); return $set; }
[ "public", "function", "getHtmlHeadEntrySet", "(", ")", "{", "$", "set", "=", "parent", "::", "getHtmlHeadEntrySet", "(", ")", ";", "$", "this", "->", "createEmbeddedWidgets", "(", ")", ";", "$", "set", "->", "addEntrySet", "(", "$", "this", "->", "enter_an...
Gets the SwatHtmlHeadEntry objects needed by this input row @return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects needed by this input row. @see SwatUIObject::getHtmlHeadEntrySet()
[ "Gets", "the", "SwatHtmlHeadEntry", "objects", "needed", "by", "this", "input", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L531-L539
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.getAvailableHtmlHeadEntrySet
public function getAvailableHtmlHeadEntrySet() { $set = parent::getAvailableHtmlHeadEntrySet(); $this->createEmbeddedWidgets(); $set->addEntrySet( $this->enter_another_link->getAvailableHtmlHeadEntrySet() ); return $set; }
php
public function getAvailableHtmlHeadEntrySet() { $set = parent::getAvailableHtmlHeadEntrySet(); $this->createEmbeddedWidgets(); $set->addEntrySet( $this->enter_another_link->getAvailableHtmlHeadEntrySet() ); return $set; }
[ "public", "function", "getAvailableHtmlHeadEntrySet", "(", ")", "{", "$", "set", "=", "parent", "::", "getAvailableHtmlHeadEntrySet", "(", ")", ";", "$", "this", "->", "createEmbeddedWidgets", "(", ")", ";", "$", "set", "->", "addEntrySet", "(", "$", "this", ...
Gets the SwatHtmlHeadEntry objects that may be needed by this input row @return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects that may be needed by this input row. @see SwatUIObject::getAvailableHtmlHeadEntrySet()
[ "Gets", "the", "SwatHtmlHeadEntry", "objects", "that", "may", "be", "needed", "by", "this", "input", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L552-L562
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.displayInputRows
private function displayInputRows() { $columns = $this->parent->getVisibleColumns(); foreach ($this->replicators as $replicator_id) { $messages = array(); $row_has_messages = false; foreach ($this->input_cells as $cell) { if ($cell->getWidget($replicator_id)->hasMessage()) { $row_has_messages = true; break; } } $tr_tag = new SwatHtmlTag('tr'); $tr_tag->class = 'swat-table-view-input-row'; $tr_tag->id = $this->getId() . '_row_' . $replicator_id; if ($row_has_messages && $this->show_row_messages) { $tr_tag->class .= ' swat-error'; } $tr_tag->open(); foreach ($columns as $column) { // use the same style as table-view column $td_attributes = $column->getTdAttributes(); $td_tag = new SwatHtmlTag('td', $td_attributes); if (isset($this->input_cells[$column->id])) { $widget = $this->input_cells[$column->id]->getWidget( $replicator_id ); if ( $this->show_row_messages && count($widget->getMessages()) > 0 ) { $messages = array_merge( $messages, $widget->getMessages() ); $td_tag->class .= ' swat-error'; } } $td_tag->open(); if (isset($this->input_cells[$column->id])) { $this->input_cells[$column->id]->display($replicator_id); } else { echo '&nbsp;'; } $td_tag->close(); } $tr_tag->close(); if ($this->show_row_messages && count($messages) > 0) { $tr_tag = new SwatHtmlTag('tr'); $tr_tag->class = 'swat-table-view-input-row-messages'; $tr_tag->open(); $td_tag = new SwatHtmlTag('td'); $td_tag->colspan = count($columns); $td_tag->open(); $ul_tag = new SwatHtmlTag('ul'); $ul_tag->class = 'swat-table-view-input-row-messages'; $ul_tag->open(); $li_tag = new SwatHtmlTag('li'); foreach ($messages as &$message) { $li_tag->setContent( $message->primary_content, $message->content_type ); $li_tag->class = $message->getCSSClassString(); $li_tag->display(); } $ul_tag->close(); $td_tag->close(); $tr_tag->close(); } } }
php
private function displayInputRows() { $columns = $this->parent->getVisibleColumns(); foreach ($this->replicators as $replicator_id) { $messages = array(); $row_has_messages = false; foreach ($this->input_cells as $cell) { if ($cell->getWidget($replicator_id)->hasMessage()) { $row_has_messages = true; break; } } $tr_tag = new SwatHtmlTag('tr'); $tr_tag->class = 'swat-table-view-input-row'; $tr_tag->id = $this->getId() . '_row_' . $replicator_id; if ($row_has_messages && $this->show_row_messages) { $tr_tag->class .= ' swat-error'; } $tr_tag->open(); foreach ($columns as $column) { // use the same style as table-view column $td_attributes = $column->getTdAttributes(); $td_tag = new SwatHtmlTag('td', $td_attributes); if (isset($this->input_cells[$column->id])) { $widget = $this->input_cells[$column->id]->getWidget( $replicator_id ); if ( $this->show_row_messages && count($widget->getMessages()) > 0 ) { $messages = array_merge( $messages, $widget->getMessages() ); $td_tag->class .= ' swat-error'; } } $td_tag->open(); if (isset($this->input_cells[$column->id])) { $this->input_cells[$column->id]->display($replicator_id); } else { echo '&nbsp;'; } $td_tag->close(); } $tr_tag->close(); if ($this->show_row_messages && count($messages) > 0) { $tr_tag = new SwatHtmlTag('tr'); $tr_tag->class = 'swat-table-view-input-row-messages'; $tr_tag->open(); $td_tag = new SwatHtmlTag('td'); $td_tag->colspan = count($columns); $td_tag->open(); $ul_tag = new SwatHtmlTag('ul'); $ul_tag->class = 'swat-table-view-input-row-messages'; $ul_tag->open(); $li_tag = new SwatHtmlTag('li'); foreach ($messages as &$message) { $li_tag->setContent( $message->primary_content, $message->content_type ); $li_tag->class = $message->getCSSClassString(); $li_tag->display(); } $ul_tag->close(); $td_tag->close(); $tr_tag->close(); } } }
[ "private", "function", "displayInputRows", "(", ")", "{", "$", "columns", "=", "$", "this", "->", "parent", "->", "getVisibleColumns", "(", ")", ";", "foreach", "(", "$", "this", "->", "replicators", "as", "$", "replicator_id", ")", "{", "$", "messages", ...
Displays the actual XHTML input rows for this input row Displays a row for each replicator id in this input row. Each row is displayed using cloned widgets inside {@link SwatInputCell} objects. @see SwatTableViewInputRow::display()
[ "Displays", "the", "actual", "XHTML", "input", "rows", "for", "this", "input", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L589-L679
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.createEmbeddedWidgets
private function createEmbeddedWidgets() { if (!$this->widgets_created) { $this->enter_another_link = new SwatToolLink(); $this->enter_another_link->parent = $this; $this->enter_another_link->stock_id = 'add'; $this->enter_another_link->classes[] = 'swat-table-view-input-row-add'; $this->widgets_created = true; } }
php
private function createEmbeddedWidgets() { if (!$this->widgets_created) { $this->enter_another_link = new SwatToolLink(); $this->enter_another_link->parent = $this; $this->enter_another_link->stock_id = 'add'; $this->enter_another_link->classes[] = 'swat-table-view-input-row-add'; $this->widgets_created = true; } }
[ "private", "function", "createEmbeddedWidgets", "(", ")", "{", "if", "(", "!", "$", "this", "->", "widgets_created", ")", "{", "$", "this", "->", "enter_another_link", "=", "new", "SwatToolLink", "(", ")", ";", "$", "this", "->", "enter_another_link", "->", ...
Instantiates the tool-link for this input row
[ "Instantiates", "the", "tool", "-", "link", "for", "this", "input", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L687-L698
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.displayEnterAnotherRow
private function displayEnterAnotherRow() { $columns = $this->parent->getVisibleColumns(); $this->createEmbeddedWidgets(); /* * Get column position of enter-a-new-row text. The text is displayed * underneath the first input cell that is not blank. If all cells are * blank, text is displayed underneath the first cell. */ $position = 0; $colspan = 0; foreach ($columns as $column) { if ( array_key_exists($column->id, $this->input_cells) && !( $this->input_cells[$column->id] instanceof SwatRemoveInputCell ) ) { $position = $colspan; break; } $colspan += $column->getXhtmlColspan(); } $close_length = $this->parent->getXhtmlColspan() - $position - 1; $tr_tag = new SwatHtmlTag('tr'); $tr_tag->id = $this->getId() . '_enter_row'; $tr_tag->class = 'swat-table-view-input-row-add-row'; $tr_tag->open(); if ($position > 0) { $td = new SwatHtmlTag('td'); $td->colspan = $position; $td->open(); echo '&nbsp;'; $td->close(); } // use the same style as table-view column $td = new SwatHtmlTag('td', $column->getTdAttributes()); $td->open(); $this->enter_another_link->display(); $td->close(); if ($close_length > 0) { $td = new SwatHtmlTag('td'); $td->colspan = $close_length; $td->open(); echo '&nbsp;'; $td->close(); } $tr_tag->close(); }
php
private function displayEnterAnotherRow() { $columns = $this->parent->getVisibleColumns(); $this->createEmbeddedWidgets(); /* * Get column position of enter-a-new-row text. The text is displayed * underneath the first input cell that is not blank. If all cells are * blank, text is displayed underneath the first cell. */ $position = 0; $colspan = 0; foreach ($columns as $column) { if ( array_key_exists($column->id, $this->input_cells) && !( $this->input_cells[$column->id] instanceof SwatRemoveInputCell ) ) { $position = $colspan; break; } $colspan += $column->getXhtmlColspan(); } $close_length = $this->parent->getXhtmlColspan() - $position - 1; $tr_tag = new SwatHtmlTag('tr'); $tr_tag->id = $this->getId() . '_enter_row'; $tr_tag->class = 'swat-table-view-input-row-add-row'; $tr_tag->open(); if ($position > 0) { $td = new SwatHtmlTag('td'); $td->colspan = $position; $td->open(); echo '&nbsp;'; $td->close(); } // use the same style as table-view column $td = new SwatHtmlTag('td', $column->getTdAttributes()); $td->open(); $this->enter_another_link->display(); $td->close(); if ($close_length > 0) { $td = new SwatHtmlTag('td'); $td->colspan = $close_length; $td->open(); echo '&nbsp;'; $td->close(); } $tr_tag->close(); }
[ "private", "function", "displayEnterAnotherRow", "(", ")", "{", "$", "columns", "=", "$", "this", "->", "parent", "->", "getVisibleColumns", "(", ")", ";", "$", "this", "->", "createEmbeddedWidgets", "(", ")", ";", "/*\n * Get column position of enter-a-new-...
Displays the enter-another-row row
[ "Displays", "the", "enter", "-", "another", "-", "row", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L706-L763
train
silverorange/swat
Swat/SwatTableViewInputRow.php
SwatTableViewInputRow.getRowString
private function getRowString() { $columns = $this->parent->getVisibleColumns(); ob_start(); // properties of the dynamic tr's are set in javascript $tr_tag = new SwatHtmlTag('tr'); $tr_tag->open(); foreach ($columns as $column) { $td_attributes = $column->getTdAttributes(); $td_tag = new SwatHtmlTag('td', $td_attributes); $td_tag->open(); $suffix = '_' . $this->getId() . '_%s'; if (isset($this->input_cells[$column->id])) { $widget = $this->input_cells[$column->id]->getPrototypeWidget(); $widget = $widget->copy($suffix); $widget->parent = $this->getForm(); // so display will work. $widget->display(); unset($widget); } else { echo '&nbsp;'; } $td_tag->close(); } $tr_tag->close(); return ob_get_clean(); }
php
private function getRowString() { $columns = $this->parent->getVisibleColumns(); ob_start(); // properties of the dynamic tr's are set in javascript $tr_tag = new SwatHtmlTag('tr'); $tr_tag->open(); foreach ($columns as $column) { $td_attributes = $column->getTdAttributes(); $td_tag = new SwatHtmlTag('td', $td_attributes); $td_tag->open(); $suffix = '_' . $this->getId() . '_%s'; if (isset($this->input_cells[$column->id])) { $widget = $this->input_cells[$column->id]->getPrototypeWidget(); $widget = $widget->copy($suffix); $widget->parent = $this->getForm(); // so display will work. $widget->display(); unset($widget); } else { echo '&nbsp;'; } $td_tag->close(); } $tr_tag->close(); return ob_get_clean(); }
[ "private", "function", "getRowString", "(", ")", "{", "$", "columns", "=", "$", "this", "->", "parent", "->", "getVisibleColumns", "(", ")", ";", "ob_start", "(", ")", ";", "// properties of the dynamic tr's are set in javascript", "$", "tr_tag", "=", "new", "Sw...
Gets this input row as an XHTML table row with the row identifier as a placeholder '%s' Returning the row identifier as a placeholder means we can use this function to display multiple copies of this row just by substituting a new identifier. @return string this input row as an XHTML table row with the row identifier as a placeholder '%s'.
[ "Gets", "this", "input", "row", "as", "an", "XHTML", "table", "row", "with", "the", "row", "identifier", "as", "a", "placeholder", "%s" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewInputRow.php#L779-L812
train
silverorange/swat
Swat/SwatFileEntry.php
SwatFileEntry.process
public function process() { parent::process(); // The $_FILES[$this->id] array is always set unless the POST data // was greater than the PHP's post_max_size ini setting. if (!isset($_FILES[$this->id]) || !$this->isSensitive()) { return; } if ($_FILES[$this->id]['error'] === UPLOAD_ERR_OK) { $this->file = $_FILES[$this->id]; if (!$this->hasValidMimeType()) { $this->addMessage($this->getValidationMessage('mime-type')); } } elseif ($_FILES[$this->id]['error'] === UPLOAD_ERR_NO_FILE) { if ($this->required) { $this->addMessage($this->getValidationMessage('required')); } } elseif ( $_FILES[$this->id]['error'] === UPLOAD_ERR_INI_SIZE || $_FILES[$this->id]['error'] === UPLOAD_ERR_FORM_SIZE ) { $this->addMessage($this->getValidationMessage('too-large')); } else { // There are other status codes we may want to check for in the // future. Upload status codes can be found here: // http://php.net/manual/en/features.file-upload.errors.php $this->addMessage($this->getValidationMessage('upload-error')); } }
php
public function process() { parent::process(); // The $_FILES[$this->id] array is always set unless the POST data // was greater than the PHP's post_max_size ini setting. if (!isset($_FILES[$this->id]) || !$this->isSensitive()) { return; } if ($_FILES[$this->id]['error'] === UPLOAD_ERR_OK) { $this->file = $_FILES[$this->id]; if (!$this->hasValidMimeType()) { $this->addMessage($this->getValidationMessage('mime-type')); } } elseif ($_FILES[$this->id]['error'] === UPLOAD_ERR_NO_FILE) { if ($this->required) { $this->addMessage($this->getValidationMessage('required')); } } elseif ( $_FILES[$this->id]['error'] === UPLOAD_ERR_INI_SIZE || $_FILES[$this->id]['error'] === UPLOAD_ERR_FORM_SIZE ) { $this->addMessage($this->getValidationMessage('too-large')); } else { // There are other status codes we may want to check for in the // future. Upload status codes can be found here: // http://php.net/manual/en/features.file-upload.errors.php $this->addMessage($this->getValidationMessage('upload-error')); } }
[ "public", "function", "process", "(", ")", "{", "parent", "::", "process", "(", ")", ";", "// The $_FILES[$this->id] array is always set unless the POST data", "// was greater than the PHP's post_max_size ini setting.", "if", "(", "!", "isset", "(", "$", "_FILES", "[", "$...
Processes this file entry widget If any validation type errors occur, an error message is attached to this entry widget.
[ "Processes", "this", "file", "entry", "widget" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFileEntry.php#L163-L194
train
silverorange/swat
Swat/SwatFileEntry.php
SwatFileEntry.getNote
public function getNote() { $message = null; if ($this->accept_mime_types !== null && $this->display_mime_types) { $displayable_types = $this->getDisplayableTypes(); $message = new SwatMessage( sprintf( Swat::ngettext( 'Valid files are the following type: %s.', 'Valid files are the following type(s): %s.', count($displayable_types) ), implode(', ', $displayable_types) ) ); } return $message; }
php
public function getNote() { $message = null; if ($this->accept_mime_types !== null && $this->display_mime_types) { $displayable_types = $this->getDisplayableTypes(); $message = new SwatMessage( sprintf( Swat::ngettext( 'Valid files are the following type: %s.', 'Valid files are the following type(s): %s.', count($displayable_types) ), implode(', ', $displayable_types) ) ); } return $message; }
[ "public", "function", "getNote", "(", ")", "{", "$", "message", "=", "null", ";", "if", "(", "$", "this", "->", "accept_mime_types", "!==", "null", "&&", "$", "this", "->", "display_mime_types", ")", "{", "$", "displayable_types", "=", "$", "this", "->",...
Gets a note specifying the mime types this file entry accepts The file types are only returned if {@link SwatFileEntry::$display_mime_types} is set to true and {@link SwatFileEntry::$accept_mime_types} has entries. If {@link SwatFileEntry::$human_file_types} is set, the note displays the human-readable file types where possible. @return SwatMessage a note listing the accepted mime-types for this file entry widget or null if any mime-type is accepted. @see SwatControl::getNote()
[ "Gets", "a", "note", "specifying", "the", "mime", "types", "this", "file", "entry", "accepts" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFileEntry.php#L214-L233
train
silverorange/swat
Swat/SwatFileEntry.php
SwatFileEntry.getMimeType
public function getMimeType() { if ($this->isUploaded() && $this->mime_type === null) { $temp_file_name = $this->getTempFileName(); if (file_exists($temp_file_name)) { if (extension_loaded('fileinfo')) { // Use the fileinfo extension if available. $finfo = $this->getFinfo(); $this->mime_type = explode( ';', $finfo->file($temp_file_name) )[0]; } elseif (function_exists('mime_content_type')) { // Fall back to mime_content_type() if available. $this->mime_type = mime_content_type($temp_file_name); } // No mime-detection functions, or mime-detection function // failed to detect the type. Default to // 'application/octet-stream'. Relying on HTTP headers could // be a security problem so we never fall back to that option. if ($this->mime_type == '') { $this->mime_type = 'application/octet-stream'; } } else { $this->mime_type = $this->file['type']; } } return $this->mime_type; }
php
public function getMimeType() { if ($this->isUploaded() && $this->mime_type === null) { $temp_file_name = $this->getTempFileName(); if (file_exists($temp_file_name)) { if (extension_loaded('fileinfo')) { // Use the fileinfo extension if available. $finfo = $this->getFinfo(); $this->mime_type = explode( ';', $finfo->file($temp_file_name) )[0]; } elseif (function_exists('mime_content_type')) { // Fall back to mime_content_type() if available. $this->mime_type = mime_content_type($temp_file_name); } // No mime-detection functions, or mime-detection function // failed to detect the type. Default to // 'application/octet-stream'. Relying on HTTP headers could // be a security problem so we never fall back to that option. if ($this->mime_type == '') { $this->mime_type = 'application/octet-stream'; } } else { $this->mime_type = $this->file['type']; } } return $this->mime_type; }
[ "public", "function", "getMimeType", "(", ")", "{", "if", "(", "$", "this", "->", "isUploaded", "(", ")", "&&", "$", "this", "->", "mime_type", "===", "null", ")", "{", "$", "temp_file_name", "=", "$", "this", "->", "getTempFileName", "(", ")", ";", ...
Gets the mime type of the uploaded file @return mixed the mime type of the uploaded file or null if no file was uploaded.
[ "Gets", "the", "mime", "type", "of", "the", "uploaded", "file" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFileEntry.php#L329-L359
train
silverorange/swat
Swat/SwatFileEntry.php
SwatFileEntry.saveFile
public function saveFile($dst_dir, $dst_filename = null) { if (!$this->isUploaded()) { return false; } if ($dst_filename === null) { $dst_filename = $this->getUniqueFileName($dst_dir); } if (is_dir($dst_dir)) { return move_uploaded_file( $this->file['tmp_name'], $dst_dir . '/' . $dst_filename ); } else { throw new SwatException( "Destination of '{$dst_dir}' is not a " . 'directory or does not exist.' ); } }
php
public function saveFile($dst_dir, $dst_filename = null) { if (!$this->isUploaded()) { return false; } if ($dst_filename === null) { $dst_filename = $this->getUniqueFileName($dst_dir); } if (is_dir($dst_dir)) { return move_uploaded_file( $this->file['tmp_name'], $dst_dir . '/' . $dst_filename ); } else { throw new SwatException( "Destination of '{$dst_dir}' is not a " . 'directory or does not exist.' ); } }
[ "public", "function", "saveFile", "(", "$", "dst_dir", ",", "$", "dst_filename", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isUploaded", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "dst_filename", "===", "null", ...
Saves the uploaded file to the server @param string $dst_dir the directory on the server to save the uploaded file in. @param string $dst_filename an optional filename to save the file under. If no filename is specified, the file is saved with the original filename. @return boolean true if the file was saved correctly and false if there was an error or no file was uploaded. @throws SwatException if the destination directory does not exist.
[ "Saves", "the", "uploaded", "file", "to", "the", "server" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFileEntry.php#L378-L399
train
silverorange/swat
Swat/SwatFileEntry.php
SwatFileEntry.getValidationMessage
protected function getValidationMessage($id) { switch ($id) { case 'mime-type': $displayable_types = $this->getDisplayableTypes(); if ($this->show_field_title_in_messages) { $text = sprintf( Swat::ngettext( 'The %%s field must be of the following type: %s.', 'The %%s field must be of the following type(s): %s.', count($displayable_types) ), implode(', ', $displayable_types) ); } else { $text = sprintf( Swat::ngettext( 'This field must be of the following type: %s.', 'This field must be of the following type(s): %s.', count($displayable_types) ), implode(', ', $displayable_types) ); } $message = new SwatMessage($text, 'error'); break; case 'too-large': if ($this->show_field_title_in_messages) { $text = Swat::_( 'The %s field exceeds the maximum allowable file size.' ); } else { $text = Swat::_( 'This field exceeds the maximum allowable file size.' ); } $message = new SwatMessage($text, 'error'); break; case 'upload-error': if ($this->show_field_title_in_messages) { $text = Swat::_( 'The %s field encounted an error when trying to upload ' . 'the file. Please try again.' ); } else { $text = Swat::_( 'This field encounted an error when trying to upload the ' . 'file. Please try again.' ); } $message = new SwatMessage($text, 'error'); break; default: $message = parent::getValidationMessage($id); break; } return $message; }
php
protected function getValidationMessage($id) { switch ($id) { case 'mime-type': $displayable_types = $this->getDisplayableTypes(); if ($this->show_field_title_in_messages) { $text = sprintf( Swat::ngettext( 'The %%s field must be of the following type: %s.', 'The %%s field must be of the following type(s): %s.', count($displayable_types) ), implode(', ', $displayable_types) ); } else { $text = sprintf( Swat::ngettext( 'This field must be of the following type: %s.', 'This field must be of the following type(s): %s.', count($displayable_types) ), implode(', ', $displayable_types) ); } $message = new SwatMessage($text, 'error'); break; case 'too-large': if ($this->show_field_title_in_messages) { $text = Swat::_( 'The %s field exceeds the maximum allowable file size.' ); } else { $text = Swat::_( 'This field exceeds the maximum allowable file size.' ); } $message = new SwatMessage($text, 'error'); break; case 'upload-error': if ($this->show_field_title_in_messages) { $text = Swat::_( 'The %s field encounted an error when trying to upload ' . 'the file. Please try again.' ); } else { $text = Swat::_( 'This field encounted an error when trying to upload the ' . 'file. Please try again.' ); } $message = new SwatMessage($text, 'error'); break; default: $message = parent::getValidationMessage($id); break; } return $message; }
[ "protected", "function", "getValidationMessage", "(", "$", "id", ")", "{", "switch", "(", "$", "id", ")", "{", "case", "'mime-type'", ":", "$", "displayable_types", "=", "$", "this", "->", "getDisplayableTypes", "(", ")", ";", "if", "(", "$", "this", "->...
Gets a validation message for this file entry Can be used by sub-classes to change the validation messages. @param string $id the string identifier of the validation message. @return SwatMessage the validation message.
[ "Gets", "a", "validation", "message", "for", "this", "file", "entry" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFileEntry.php#L453-L518
train
silverorange/swat
Swat/SwatFileEntry.php
SwatFileEntry.hasValidMimeType
protected function hasValidMimeType() { $valid = false; if ($this->isUploaded()) { // Some container formats can contain return multiple mime-types. // If any of the contained types are valid, we consider the file // valid. $mime_types = explode(' ', $this->getMimeType()); if ( is_array($this->accept_mime_types) && count($this->accept_mime_types) > 0 ) { $types = array_intersect($mime_types, $this->accept_mime_types); $valid = count($types) > 0; } else { $valid = true; } } return $valid; }
php
protected function hasValidMimeType() { $valid = false; if ($this->isUploaded()) { // Some container formats can contain return multiple mime-types. // If any of the contained types are valid, we consider the file // valid. $mime_types = explode(' ', $this->getMimeType()); if ( is_array($this->accept_mime_types) && count($this->accept_mime_types) > 0 ) { $types = array_intersect($mime_types, $this->accept_mime_types); $valid = count($types) > 0; } else { $valid = true; } } return $valid; }
[ "protected", "function", "hasValidMimeType", "(", ")", "{", "$", "valid", "=", "false", ";", "if", "(", "$", "this", "->", "isUploaded", "(", ")", ")", "{", "// Some container formats can contain return multiple mime-types.", "// If any of the contained types are valid, w...
Whether or not the uploaded file's mime type is valid Gets whether or not the upload file's mime type matches the accepted mime types of this widget. Valid mime types for this widget are stored in the {@link SwatFileEntry::$accept_mime_types} array. If the <kbd>$accept_mime_types</kbd> array is empty, the uploaded file's mime type is always valid. Some container formats may have multiple mime-types. In this case, if any of the contained types are valid, we consider the file valid. @return boolean whether or not this file's mime type is valid.
[ "Whether", "or", "not", "the", "uploaded", "file", "s", "mime", "type", "is", "valid" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFileEntry.php#L553-L574
train
silverorange/swat
Swat/SwatFileEntry.php
SwatFileEntry.getDisplayableTypes
protected function getDisplayableTypes() { $displayable_types = array(); foreach ($this->accept_mime_types as $mime_type) { $displayable_type = isset($this->human_file_types[$mime_type]) ? $this->human_file_types[$mime_type] : $mime_type; // Use the value as the key to de-dupe. $displayable_types[$displayable_type] = $displayable_type; } return $displayable_types; }
php
protected function getDisplayableTypes() { $displayable_types = array(); foreach ($this->accept_mime_types as $mime_type) { $displayable_type = isset($this->human_file_types[$mime_type]) ? $this->human_file_types[$mime_type] : $mime_type; // Use the value as the key to de-dupe. $displayable_types[$displayable_type] = $displayable_type; } return $displayable_types; }
[ "protected", "function", "getDisplayableTypes", "(", ")", "{", "$", "displayable_types", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "accept_mime_types", "as", "$", "mime_type", ")", "{", "$", "displayable_type", "=", "isset", "(", "$", ...
Gets a unique array of acceptable human-readable file and mime types for display. If {@link SwatFileEntry::$human_file_types} is set, and the mime type exists within it, we display the corresponding human-readable file type. Otherwise we fall back to the mime type. @return array unique mime and human-readable file types.
[ "Gets", "a", "unique", "array", "of", "acceptable", "human", "-", "readable", "file", "and", "mime", "types", "for", "display", "." ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatFileEntry.php#L621-L635
train
zeroem/ZeroemCurlBundle
HttpKernel/RemoteHttpKernel.php
RemoteHttpKernel.handleRaw
private function handleRaw(Request $request) { $curl = $this->lastCurlRequest = $this->getCurlRequest(); $curl->setOptionArray( array( CURLOPT_URL=>$request->getUri(), CURLOPT_HTTPHEADER=>$this->buildHeadersArray($request->headers), CURLINFO_HEADER_OUT=>true ) ); $curl->setMethod($request->getMethod()); if ("POST" === $request->getMethod()) { $this->setPostFields($curl, $request); } if("PUT" === $request->getMethod() && count($request->files->all()) > 0) { $file = current($request->files->all()); $curl->setOptionArray( array( CURLOPT_INFILE=>'@'.$file->getRealPath(), CURLOPT_INFILESIZE=>$file->getSize() ) ); } $content = new ContentCollector(); $headers = new HeaderCollector(); // These options must not be tampered with to ensure proper functionality $curl->setOptionArray( array( CURLOPT_HEADERFUNCTION=>array($headers, "collect"), CURLOPT_WRITEFUNCTION=>array($content, "collect"), ) ); $curl->execute(); $response = new Response( $content->retrieve(), $headers->getCode(), $headers->retrieve() ); $response->setProtocolVersion($headers->getVersion()); $response->setStatusCode($headers->getCode(), $headers->getMessage()); return $response; }
php
private function handleRaw(Request $request) { $curl = $this->lastCurlRequest = $this->getCurlRequest(); $curl->setOptionArray( array( CURLOPT_URL=>$request->getUri(), CURLOPT_HTTPHEADER=>$this->buildHeadersArray($request->headers), CURLINFO_HEADER_OUT=>true ) ); $curl->setMethod($request->getMethod()); if ("POST" === $request->getMethod()) { $this->setPostFields($curl, $request); } if("PUT" === $request->getMethod() && count($request->files->all()) > 0) { $file = current($request->files->all()); $curl->setOptionArray( array( CURLOPT_INFILE=>'@'.$file->getRealPath(), CURLOPT_INFILESIZE=>$file->getSize() ) ); } $content = new ContentCollector(); $headers = new HeaderCollector(); // These options must not be tampered with to ensure proper functionality $curl->setOptionArray( array( CURLOPT_HEADERFUNCTION=>array($headers, "collect"), CURLOPT_WRITEFUNCTION=>array($content, "collect"), ) ); $curl->execute(); $response = new Response( $content->retrieve(), $headers->getCode(), $headers->retrieve() ); $response->setProtocolVersion($headers->getVersion()); $response->setStatusCode($headers->getCode(), $headers->getMessage()); return $response; }
[ "private", "function", "handleRaw", "(", "Request", "$", "request", ")", "{", "$", "curl", "=", "$", "this", "->", "lastCurlRequest", "=", "$", "this", "->", "getCurlRequest", "(", ")", ";", "$", "curl", "->", "setOptionArray", "(", "array", "(", "CURLOP...
Execute a Request object via cURL @param Request $request the request to execute @param array $options additional curl options to set/override @return Response @throws CurlErrorException
[ "Execute", "a", "Request", "object", "via", "cURL" ]
1045e2093bec5a013ff9458828721e581725f1a0
https://github.com/zeroem/ZeroemCurlBundle/blob/1045e2093bec5a013ff9458828721e581725f1a0/HttpKernel/RemoteHttpKernel.php#L100-L150
train
zeroem/ZeroemCurlBundle
HttpKernel/RemoteHttpKernel.php
RemoteHttpKernel.setPostFields
private function setPostFields(CurlRequest $curl, Request $request) { $postfields = null; $content = $request->getContent(); if (!empty($content)) { $postfields = $content; } else if (count($request->request->all()) > 0) { $postfields = $request->request->all(); } $curl->setOption(CURLOPT_POSTFIELDS, $postfields); }
php
private function setPostFields(CurlRequest $curl, Request $request) { $postfields = null; $content = $request->getContent(); if (!empty($content)) { $postfields = $content; } else if (count($request->request->all()) > 0) { $postfields = $request->request->all(); } $curl->setOption(CURLOPT_POSTFIELDS, $postfields); }
[ "private", "function", "setPostFields", "(", "CurlRequest", "$", "curl", ",", "Request", "$", "request", ")", "{", "$", "postfields", "=", "null", ";", "$", "content", "=", "$", "request", "->", "getContent", "(", ")", ";", "if", "(", "!", "empty", "("...
Populate the POSTFIELDS option @param CurlRequest $curl cURL request object @param Request $request the Request object we're populating
[ "Populate", "the", "POSTFIELDS", "option" ]
1045e2093bec5a013ff9458828721e581725f1a0
https://github.com/zeroem/ZeroemCurlBundle/blob/1045e2093bec5a013ff9458828721e581725f1a0/HttpKernel/RemoteHttpKernel.php#L159-L170
train
silverorange/swat
Swat/SwatBooleanCellRenderer.php
SwatBooleanCellRenderer.setFromStock
public function setFromStock($stock_id, $overwrite_properties = true) { $content_type = 'text/plain'; switch ($stock_id) { case 'yes-no': $false_content = Swat::_('No'); $true_content = Swat::_('Yes'); break; case 'check-only': $content_type = 'text/xml'; $false_content = ' '; // non-breaking space ob_start(); $this->displayCheck(); $true_content = ob_get_clean(); break; default: throw new SwatUndefinedStockTypeException( "Stock type with id of '{$stock_id}' not found.", 0, $stock_id ); } if ($overwrite_properties || $this->false_content === null) { $this->false_content = $false_content; } if ($overwrite_properties || $this->true_content === null) { $this->true_content = $true_content; } if ($overwrite_properties || $this->content_type === null) { $this->content_type = $content_type; } }
php
public function setFromStock($stock_id, $overwrite_properties = true) { $content_type = 'text/plain'; switch ($stock_id) { case 'yes-no': $false_content = Swat::_('No'); $true_content = Swat::_('Yes'); break; case 'check-only': $content_type = 'text/xml'; $false_content = ' '; // non-breaking space ob_start(); $this->displayCheck(); $true_content = ob_get_clean(); break; default: throw new SwatUndefinedStockTypeException( "Stock type with id of '{$stock_id}' not found.", 0, $stock_id ); } if ($overwrite_properties || $this->false_content === null) { $this->false_content = $false_content; } if ($overwrite_properties || $this->true_content === null) { $this->true_content = $true_content; } if ($overwrite_properties || $this->content_type === null) { $this->content_type = $content_type; } }
[ "public", "function", "setFromStock", "(", "$", "stock_id", ",", "$", "overwrite_properties", "=", "true", ")", "{", "$", "content_type", "=", "'text/plain'", ";", "switch", "(", "$", "stock_id", ")", "{", "case", "'yes-no'", ":", "$", "false_content", "=", ...
Sets the values of this boolean cell renderer to a stock type Valid stock type ids are: - check-only - yes-no @param string $stock_id the identifier of the stock type to use. @param boolean $overwrite_properties optional. Whether to overwrite properties if they are already set. By default, properties are overwritten. @throws SwatUndefinedStockTypeException if an undefined <i>$stock_id</i> is used.
[ "Sets", "the", "values", "of", "this", "boolean", "cell", "renderer", "to", "a", "stock", "type" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatBooleanCellRenderer.php#L78-L116
train
silverorange/swat
Swat/SwatBooleanCellRenderer.php
SwatBooleanCellRenderer.displayCheck
protected function displayCheck() { $image_tag = new SwatHtmlTag('img'); $image_tag->src = 'packages/swat/images/check.png'; $image_tag->alt = Swat::_('Yes'); $image_tag->height = '14'; $image_tag->width = '14'; $image_tag->display(); }
php
protected function displayCheck() { $image_tag = new SwatHtmlTag('img'); $image_tag->src = 'packages/swat/images/check.png'; $image_tag->alt = Swat::_('Yes'); $image_tag->height = '14'; $image_tag->width = '14'; $image_tag->display(); }
[ "protected", "function", "displayCheck", "(", ")", "{", "$", "image_tag", "=", "new", "SwatHtmlTag", "(", "'img'", ")", ";", "$", "image_tag", "->", "src", "=", "'packages/swat/images/check.png'", ";", "$", "image_tag", "->", "alt", "=", "Swat", "::", "_", ...
Renders a checkmark image for this boolean cell renderer This is used when this cell renderer has a {@link SwatBooleanCellRenderer::$stock_id} of 'check-only'.
[ "Renders", "a", "checkmark", "image", "for", "this", "boolean", "cell", "renderer" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatBooleanCellRenderer.php#L211-L219
train
rollun-com/rollun-datastore
src/DataStore/src/DataStore/Cacheable.php
Cacheable.update
public function update($itemData, $createIfAbsent = false) { if ($createIfAbsent) { trigger_error("Option 'createIfAbsent' is no more use.", E_DEPRECATED); } if (method_exists($this->dataSource, "update")) { return $this->dataSource->update($itemData, $createIfAbsent); } else { throw new DataStoreException("Refreshable don't haw method update"); } }
php
public function update($itemData, $createIfAbsent = false) { if ($createIfAbsent) { trigger_error("Option 'createIfAbsent' is no more use.", E_DEPRECATED); } if (method_exists($this->dataSource, "update")) { return $this->dataSource->update($itemData, $createIfAbsent); } else { throw new DataStoreException("Refreshable don't haw method update"); } }
[ "public", "function", "update", "(", "$", "itemData", ",", "$", "createIfAbsent", "=", "false", ")", "{", "if", "(", "$", "createIfAbsent", ")", "{", "trigger_error", "(", "\"Option 'createIfAbsent' is no more use.\"", ",", "E_DEPRECATED", ")", ";", "}", "if", ...
By default, update existing Item. If item with PrimaryKey == $item["id"] is existing in store, item will update. Fields which don't present in $item will not change in item in store.<br> Method will return updated item<br> <br> If $item["id"] isn't set - method will throw exception.<br> <br> If item with PrimaryKey == $item["id"] is absent - method will throw exception,<br> but if $createIfAbsent = true item will be created and method return inserted item<br> <br> @param array $itemData associated array with PrimaryKey @param bool $createIfAbsent @return array updated item or inserted item @throws DataStoreException
[ "By", "default", "update", "existing", "Item", "." ]
ef433b58b94e1c311123ad1b2a0360e95a636bd1
https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/DataStore/Cacheable.php#L165-L176
train
rollun-com/rollun-datastore
src/DataStore/src/DataStore/Cacheable.php
Cacheable.publicdelete
public function publicdelete($id) { if (method_exists($this->dataSource, "delete")) { return $this->dataSource->delete($id); } else { throw new DataStoreException("Refreshable don't haw method delete"); } }
php
public function publicdelete($id) { if (method_exists($this->dataSource, "delete")) { return $this->dataSource->delete($id); } else { throw new DataStoreException("Refreshable don't haw method delete"); } }
[ "public", "function", "publicdelete", "(", "$", "id", ")", "{", "if", "(", "method_exists", "(", "$", "this", "->", "dataSource", ",", "\"delete\"", ")", ")", "{", "return", "$", "this", "->", "dataSource", "->", "delete", "(", "$", "id", ")", ";", "...
Delete Item by id. Method do nothing if item with that id is absent. @param int|string $id PrimaryKey @return int number of deleted items: 0 , 1 or null if object doesn't support it @throws DataStoreException
[ "Delete", "Item", "by", "id", ".", "Method", "do", "nothing", "if", "item", "with", "that", "id", "is", "absent", "." ]
ef433b58b94e1c311123ad1b2a0360e95a636bd1
https://github.com/rollun-com/rollun-datastore/blob/ef433b58b94e1c311123ad1b2a0360e95a636bd1/src/DataStore/src/DataStore/Cacheable.php#L185-L192
train
brainworxx/kreXX
src/View/Output/File.php
File.finalize
public function finalize() { // Output our chunks. // Every output is split into 4 chunk strings (header, messages, // data, footer). foreach ($this->chunkStrings as $chunkString) { // Save everything to the file after we are done. $this->pool->chunks->saveDechunkedToFile($chunkString); } }
php
public function finalize() { // Output our chunks. // Every output is split into 4 chunk strings (header, messages, // data, footer). foreach ($this->chunkStrings as $chunkString) { // Save everything to the file after we are done. $this->pool->chunks->saveDechunkedToFile($chunkString); } }
[ "public", "function", "finalize", "(", ")", "{", "// Output our chunks.", "// Every output is split into 4 chunk strings (header, messages,", "// data, footer).", "foreach", "(", "$", "this", "->", "chunkStrings", "as", "$", "chunkString", ")", "{", "// Save everything to the...
Creating the logfile after the analysis.
[ "Creating", "the", "logfile", "after", "the", "analysis", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/View/Output/File.php#L79-L88
train
TeknooSoftware/states
demo/Acme/Extendable/GrandDaughter/GrandDaughter.php
GrandDaughter.listMethodsByStates
public function listMethodsByStates() { $methodsList = array(); foreach ($this->getStatesList() as $stateName => $stateContainer) { $methodsList[$stateName] = $stateContainer->listMethods(); } ksort($methodsList); return $methodsList; }
php
public function listMethodsByStates() { $methodsList = array(); foreach ($this->getStatesList() as $stateName => $stateContainer) { $methodsList[$stateName] = $stateContainer->listMethods(); } ksort($methodsList); return $methodsList; }
[ "public", "function", "listMethodsByStates", "(", ")", "{", "$", "methodsList", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getStatesList", "(", ")", "as", "$", "stateName", "=>", "$", "stateContainer", ")", "{", "$", "methodsList", ...
Return the list of available state in this class. @return array
[ "Return", "the", "list", "of", "available", "state", "in", "this", "class", "." ]
0c675b768781ee3a3a15c2663cffec5d50c1d5fd
https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/demo/Acme/Extendable/GrandDaughter/GrandDaughter.php#L53-L63
train
silverorange/swat
Swat/SwatProgressBar.php
SwatProgressBar.display
public function display() { if (!$this->visible) { return; } parent::display(); $div_tag = new SwatHtmlTag('div'); $div_tag->id = $this->id; $div_tag->class = $this->getCSSClassString(); $div_tag->open(); $this->displayBar(); $this->displayText(); $div_tag->close(); Swat::displayInlineJavaScript($this->getInlineJavaScript()); }
php
public function display() { if (!$this->visible) { return; } parent::display(); $div_tag = new SwatHtmlTag('div'); $div_tag->id = $this->id; $div_tag->class = $this->getCSSClassString(); $div_tag->open(); $this->displayBar(); $this->displayText(); $div_tag->close(); Swat::displayInlineJavaScript($this->getInlineJavaScript()); }
[ "public", "function", "display", "(", ")", "{", "if", "(", "!", "$", "this", "->", "visible", ")", "{", "return", ";", "}", "parent", "::", "display", "(", ")", ";", "$", "div_tag", "=", "new", "SwatHtmlTag", "(", "'div'", ")", ";", "$", "div_tag",...
Displays this progress bar @throws SwatException if this progress bar's <i>$length</i> property is not a valid cascading style-sheet dimension.
[ "Displays", "this", "progress", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatProgressBar.php#L153-L173
train
silverorange/swat
Swat/SwatProgressBar.php
SwatProgressBar.displayBar
protected function displayBar() { // ensure length is in cascading style-sheet units $dimension_pattern = '/([0-9]+(%|p[xtc]|e[mx]|in|[cm]m|)|auto)/'; if (preg_match($dimension_pattern, $this->length) === 0) { throw new SwatException( sprintf( '$length must be specified in ' . 'cascading style-sheet units. Value was: %s', $this->length ) ); } $bar_div_tag = new SwatHtmlTag('div'); $bar_div_tag->id = "{$this->id}_bar"; $bar_div_tag->class = 'swat-progress-bar-bar'; $full_div_tag = new SwatHtmlTag('div'); $full_div_tag->id = "{$this->id}_full"; $full_div_tag->class = 'swat-progress-bar-full'; $full_div_tag->setContent(''); $empty_div_tag = new SwatHtmlTag('div'); $empty_div_tag->id = "{$this->id}_empty"; $empty_div_tag->class = 'swat-progress-bar-empty'; $empty_div_tag->setContent(''); $full_length = min(100, round($this->value * 100, 4)); $full_length = sprintf('%s%%', $full_length); $empty_length = max(0, round(100 - $this->value * 100, 4)); $empty_length = sprintf('%s%%', $empty_length); switch ($this->orientation) { case self::ORIENTATION_LEFT_TO_RIGHT: default: $bar_div_tag->class .= ' swat-progress-bar-left-to-right'; $bar_div_tag->style = sprintf('width: %s;', $this->length); $full_div_tag->style = sprintf('width: %s;', $full_length); $empty_div_tag->style = sprintf('width: %s;', $empty_length); break; case self::ORIENTATION_RIGHT_TO_LEFT: $bar_div_tag->class .= ' swat-progress-bar-right-to-left'; $bar_div_tag->style = sprintf('width: %s;', $this->length); $full_div_tag->style = sprintf('width: %s;', $full_length); $empty_div_tag->style = sprintf('width: %s;', $empty_length); break; case self::ORIENTATION_BOTTOM_TO_TOP: $bar_div_tag->class .= ' swat-progress-bar-bottom-to-top'; $bar_div_tag->style = sprintf('height: %s;', $this->length); $full_div_tag->style = sprintf( 'height: %s; top: %s;', $full_length, $empty_length ); $empty_div_tag->style = sprintf( 'height: %s; top: -%s;', $empty_length, $full_length ); break; case self::ORIENTATION_TOP_TO_BOTTOM: $bar_div_tag->class .= ' swat-progress-bar-top-to-bottom'; $bar_div_tag->style = sprintf('height: %s;', $this->length); $full_div_tag->style = sprintf('height: %s;', $full_length); $empty_div_tag->style = sprintf('height: %s;', $empty_length); break; } $bar_div_tag->open(); $full_div_tag->display(); $empty_div_tag->display(); $bar_div_tag->close(); }
php
protected function displayBar() { // ensure length is in cascading style-sheet units $dimension_pattern = '/([0-9]+(%|p[xtc]|e[mx]|in|[cm]m|)|auto)/'; if (preg_match($dimension_pattern, $this->length) === 0) { throw new SwatException( sprintf( '$length must be specified in ' . 'cascading style-sheet units. Value was: %s', $this->length ) ); } $bar_div_tag = new SwatHtmlTag('div'); $bar_div_tag->id = "{$this->id}_bar"; $bar_div_tag->class = 'swat-progress-bar-bar'; $full_div_tag = new SwatHtmlTag('div'); $full_div_tag->id = "{$this->id}_full"; $full_div_tag->class = 'swat-progress-bar-full'; $full_div_tag->setContent(''); $empty_div_tag = new SwatHtmlTag('div'); $empty_div_tag->id = "{$this->id}_empty"; $empty_div_tag->class = 'swat-progress-bar-empty'; $empty_div_tag->setContent(''); $full_length = min(100, round($this->value * 100, 4)); $full_length = sprintf('%s%%', $full_length); $empty_length = max(0, round(100 - $this->value * 100, 4)); $empty_length = sprintf('%s%%', $empty_length); switch ($this->orientation) { case self::ORIENTATION_LEFT_TO_RIGHT: default: $bar_div_tag->class .= ' swat-progress-bar-left-to-right'; $bar_div_tag->style = sprintf('width: %s;', $this->length); $full_div_tag->style = sprintf('width: %s;', $full_length); $empty_div_tag->style = sprintf('width: %s;', $empty_length); break; case self::ORIENTATION_RIGHT_TO_LEFT: $bar_div_tag->class .= ' swat-progress-bar-right-to-left'; $bar_div_tag->style = sprintf('width: %s;', $this->length); $full_div_tag->style = sprintf('width: %s;', $full_length); $empty_div_tag->style = sprintf('width: %s;', $empty_length); break; case self::ORIENTATION_BOTTOM_TO_TOP: $bar_div_tag->class .= ' swat-progress-bar-bottom-to-top'; $bar_div_tag->style = sprintf('height: %s;', $this->length); $full_div_tag->style = sprintf( 'height: %s; top: %s;', $full_length, $empty_length ); $empty_div_tag->style = sprintf( 'height: %s; top: -%s;', $empty_length, $full_length ); break; case self::ORIENTATION_TOP_TO_BOTTOM: $bar_div_tag->class .= ' swat-progress-bar-top-to-bottom'; $bar_div_tag->style = sprintf('height: %s;', $this->length); $full_div_tag->style = sprintf('height: %s;', $full_length); $empty_div_tag->style = sprintf('height: %s;', $empty_length); break; } $bar_div_tag->open(); $full_div_tag->display(); $empty_div_tag->display(); $bar_div_tag->close(); }
[ "protected", "function", "displayBar", "(", ")", "{", "// ensure length is in cascading style-sheet units", "$", "dimension_pattern", "=", "'/([0-9]+(%|p[xtc]|e[mx]|in|[cm]m|)|auto)/'", ";", "if", "(", "preg_match", "(", "$", "dimension_pattern", ",", "$", "this", "->", "...
Displays the bar part of this progress bar @throws SwatException if this progress bar's <i>$length</i> property is not a valid cascading style-sheet dimension.
[ "Displays", "the", "bar", "part", "of", "this", "progress", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatProgressBar.php#L184-L263
train
silverorange/swat
Swat/SwatProgressBar.php
SwatProgressBar.displayText
protected function displayText() { if ($this->text === null) { // still show an empty span if there is no text for this // progress bar $text = ''; } else { if ($this->text_value === null) { $text = $this->text; } elseif (is_array($this->text_value)) { $text = vsprintf($this->text, $this->text_value); } else { $text = sprintf($this->text, $this->text_value); } } $span_tag = new SwatHtmlTag('span'); $span_tag->id = $this->id . '_text'; $span_tag->class = 'swat-progress-bar-text'; $span_tag->setContent($text, $this->content_type); $span_tag->display(); }
php
protected function displayText() { if ($this->text === null) { // still show an empty span if there is no text for this // progress bar $text = ''; } else { if ($this->text_value === null) { $text = $this->text; } elseif (is_array($this->text_value)) { $text = vsprintf($this->text, $this->text_value); } else { $text = sprintf($this->text, $this->text_value); } } $span_tag = new SwatHtmlTag('span'); $span_tag->id = $this->id . '_text'; $span_tag->class = 'swat-progress-bar-text'; $span_tag->setContent($text, $this->content_type); $span_tag->display(); }
[ "protected", "function", "displayText", "(", ")", "{", "if", "(", "$", "this", "->", "text", "===", "null", ")", "{", "// still show an empty span if there is no text for this", "// progress bar", "$", "text", "=", "''", ";", "}", "else", "{", "if", "(", "$", ...
Displays the text part of this progress bar
[ "Displays", "the", "text", "part", "of", "this", "progress", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatProgressBar.php#L271-L292
train
silverorange/swat
Swat/SwatProgressBar.php
SwatProgressBar.getInlineJavaScript
protected function getInlineJavaScript() { return sprintf( "var %s_obj = new SwatProgressBar('%s', %s, %s);", $this->id, $this->id, $this->orientation, $this->value ); }
php
protected function getInlineJavaScript() { return sprintf( "var %s_obj = new SwatProgressBar('%s', %s, %s);", $this->id, $this->id, $this->orientation, $this->value ); }
[ "protected", "function", "getInlineJavaScript", "(", ")", "{", "return", "sprintf", "(", "\"var %s_obj = new SwatProgressBar('%s', %s, %s);\"", ",", "$", "this", "->", "id", ",", "$", "this", "->", "id", ",", "$", "this", "->", "orientation", ",", "$", "this", ...
Gets inline JavaScript for this progress bar @return string inline JavaScript for this progress bar.
[ "Gets", "inline", "JavaScript", "for", "this", "progress", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatProgressBar.php#L302-L311
train
neos/composer-plugin
Classes/Installer.php
Installer.camelCaseFlowPackageType
protected function camelCaseFlowPackageType($flowPackageType) { $packageTypeParts = explode('-', $flowPackageType); $packageTypeParts = array_map('ucfirst', $packageTypeParts); return implode('', $packageTypeParts); }
php
protected function camelCaseFlowPackageType($flowPackageType) { $packageTypeParts = explode('-', $flowPackageType); $packageTypeParts = array_map('ucfirst', $packageTypeParts); return implode('', $packageTypeParts); }
[ "protected", "function", "camelCaseFlowPackageType", "(", "$", "flowPackageType", ")", "{", "$", "packageTypeParts", "=", "explode", "(", "'-'", ",", "$", "flowPackageType", ")", ";", "$", "packageTypeParts", "=", "array_map", "(", "'ucfirst'", ",", "$", "packag...
Camel case the flow package type. "framework" => "Framework" "some-project" => "SomeProject" @param string $flowPackageType @return string
[ "Camel", "case", "the", "flow", "package", "type", ".", "framework", "=", ">", "Framework", "some", "-", "project", "=", ">", "SomeProject" ]
fe4a2b526cc784032d53f6229ef34d7304a5d13d
https://github.com/neos/composer-plugin/blob/fe4a2b526cc784032d53f6229ef34d7304a5d13d/Classes/Installer.php#L83-L88
train
neos/composer-plugin
Classes/Installer.php
Installer.replacePlaceholdersInPath
protected function replacePlaceholdersInPath($path, $arguments) { foreach ($arguments as $argumentName => $argumentValue) { $path = str_replace('{' . $argumentName . '}', $argumentValue, $path); } return $path; }
php
protected function replacePlaceholdersInPath($path, $arguments) { foreach ($arguments as $argumentName => $argumentValue) { $path = str_replace('{' . $argumentName . '}', $argumentValue, $path); } return $path; }
[ "protected", "function", "replacePlaceholdersInPath", "(", "$", "path", ",", "$", "arguments", ")", "{", "foreach", "(", "$", "arguments", "as", "$", "argumentName", "=>", "$", "argumentValue", ")", "{", "$", "path", "=", "str_replace", "(", "'{'", ".", "$...
Replace placeholders in the install path. @param string $path @param array $arguments @return string
[ "Replace", "placeholders", "in", "the", "install", "path", "." ]
fe4a2b526cc784032d53f6229ef34d7304a5d13d
https://github.com/neos/composer-plugin/blob/fe4a2b526cc784032d53f6229ef34d7304a5d13d/Classes/Installer.php#L97-L104
train
neos/composer-plugin
Classes/Installer.php
Installer.getFlowPackageType
protected function getFlowPackageType($composerPackageType) { foreach ($this->allowedPackageTypePrefixes as $allowedPackagePrefix) { $packagePrefixPosition = strpos($composerPackageType, $allowedPackagePrefix); if ($packagePrefixPosition === 0) { return substr($composerPackageType, strlen($allowedPackagePrefix)); } } return false; }
php
protected function getFlowPackageType($composerPackageType) { foreach ($this->allowedPackageTypePrefixes as $allowedPackagePrefix) { $packagePrefixPosition = strpos($composerPackageType, $allowedPackagePrefix); if ($packagePrefixPosition === 0) { return substr($composerPackageType, strlen($allowedPackagePrefix)); } } return false; }
[ "protected", "function", "getFlowPackageType", "(", "$", "composerPackageType", ")", "{", "foreach", "(", "$", "this", "->", "allowedPackageTypePrefixes", "as", "$", "allowedPackagePrefix", ")", "{", "$", "packagePrefixPosition", "=", "strpos", "(", "$", "composerPa...
Gets the Flow package type based on the given composer package type. "typo3-flow-framework" would return "framework". Returns FALSE if the given composerPackageType is not a Flow package type. @param string $composerPackageType @return bool|string
[ "Gets", "the", "Flow", "package", "type", "based", "on", "the", "given", "composer", "package", "type", ".", "typo3", "-", "flow", "-", "framework", "would", "return", "framework", ".", "Returns", "FALSE", "if", "the", "given", "composerPackageType", "is", "...
fe4a2b526cc784032d53f6229ef34d7304a5d13d
https://github.com/neos/composer-plugin/blob/fe4a2b526cc784032d53f6229ef34d7304a5d13d/Classes/Installer.php#L113-L123
train
brainworxx/kreXX
src/Analyse/Callback/Analyse/Objects.php
Objects.callMe
public function callMe() { $output = $this->pool->render->renderSingeChildHr() . $this->dispatchStartEvent(); $ref = $this->parameters[static::PARAM_REF] = new ReflectionClass($this->parameters[static::PARAM_DATA]); // Dumping public properties. $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\PublicProperties'); // Dumping getter methods. // We will not dump the getters for internal classes, though. if ($this->pool->config->getSetting(Fallback::SETTING_ANALYSE_GETTER) === true && $ref->isUserDefined() === true ) { $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\Getter'); } // When analysing an error object, get the backtrace and then analyse it. $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\ErrorObject'); // Dumping protected properties. if ($this->pool->config->getSetting(Fallback::SETTING_ANALYSE_PROTECTED) === true || $this->pool->scope->isInScope() === true ) { $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\ProtectedProperties'); } // Dumping private properties. if ($this->pool->config->getSetting(Fallback::SETTING_ANALYSE_PRIVATE) === true || $this->pool->scope->isInScope() === true ) { $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\PrivateProperties'); } // Dumping class constants. $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\Constants'); // Dumping all methods. $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\Methods'); // Dumping traversable data. if ($this->pool->config->getSetting(Fallback::SETTING_ANALYSE_TRAVERSABLE) === true && $this->parameters[static::PARAM_DATA] instanceof \Traversable ) { $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\Traversable'); } // Dumping all configured debug functions. // Adding a HR for a better readability. return $output . $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\DebugMethods') . $this->pool->render->renderSingeChildHr(); }
php
public function callMe() { $output = $this->pool->render->renderSingeChildHr() . $this->dispatchStartEvent(); $ref = $this->parameters[static::PARAM_REF] = new ReflectionClass($this->parameters[static::PARAM_DATA]); // Dumping public properties. $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\PublicProperties'); // Dumping getter methods. // We will not dump the getters for internal classes, though. if ($this->pool->config->getSetting(Fallback::SETTING_ANALYSE_GETTER) === true && $ref->isUserDefined() === true ) { $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\Getter'); } // When analysing an error object, get the backtrace and then analyse it. $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\ErrorObject'); // Dumping protected properties. if ($this->pool->config->getSetting(Fallback::SETTING_ANALYSE_PROTECTED) === true || $this->pool->scope->isInScope() === true ) { $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\ProtectedProperties'); } // Dumping private properties. if ($this->pool->config->getSetting(Fallback::SETTING_ANALYSE_PRIVATE) === true || $this->pool->scope->isInScope() === true ) { $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\PrivateProperties'); } // Dumping class constants. $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\Constants'); // Dumping all methods. $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\Methods'); // Dumping traversable data. if ($this->pool->config->getSetting(Fallback::SETTING_ANALYSE_TRAVERSABLE) === true && $this->parameters[static::PARAM_DATA] instanceof \Traversable ) { $output .= $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\Traversable'); } // Dumping all configured debug functions. // Adding a HR for a better readability. return $output . $this->dumpStuff('Brainworxx\\Krexx\\Analyse\\Callback\\Analyse\\Objects\\DebugMethods') . $this->pool->render->renderSingeChildHr(); }
[ "public", "function", "callMe", "(", ")", "{", "$", "output", "=", "$", "this", "->", "pool", "->", "render", "->", "renderSingeChildHr", "(", ")", ".", "$", "this", "->", "dispatchStartEvent", "(", ")", ";", "$", "ref", "=", "$", "this", "->", "para...
Starts the dump of an object. @throws \ReflectionException @return string The generated markup.
[ "Starts", "the", "dump", "of", "an", "object", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Analyse/Objects.php#L66-L118
train
brainworxx/kreXX
src/Analyse/Callback/Analyse/Objects.php
Objects.dumpStuff
protected function dumpStuff($classname) { return $this->pool ->createClass($classname) ->setParams($this->parameters) ->callMe(); }
php
protected function dumpStuff($classname) { return $this->pool ->createClass($classname) ->setParams($this->parameters) ->callMe(); }
[ "protected", "function", "dumpStuff", "(", "$", "classname", ")", "{", "return", "$", "this", "->", "pool", "->", "createClass", "(", "$", "classname", ")", "->", "setParams", "(", "$", "this", "->", "parameters", ")", "->", "callMe", "(", ")", ";", "}...
Dumping stuff is everywhere the same, only the callback class is changing. @var string $classname The name of the callback class we are using. @return string The generated html markup.
[ "Dumping", "stuff", "is", "everywhere", "the", "same", "only", "the", "callback", "class", "is", "changing", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Analyse/Objects.php#L129-L135
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.replace
public function replace(SwatWidget $widget, SwatWidget $new_widget) { foreach ($this->children as $key => $child_widget) { if ($child_widget === $widget) { $this->children[$key] = $new_widget; $new_widget->parent = $this; $widget->parent = null; if ($widget->id !== null) { unset($this->children_by_id[$widget->id]); } if ($new_widget->id !== null) { $this->children_by_id[$new_widget->id] = $new_widget; } return $widget; } } return null; }
php
public function replace(SwatWidget $widget, SwatWidget $new_widget) { foreach ($this->children as $key => $child_widget) { if ($child_widget === $widget) { $this->children[$key] = $new_widget; $new_widget->parent = $this; $widget->parent = null; if ($widget->id !== null) { unset($this->children_by_id[$widget->id]); } if ($new_widget->id !== null) { $this->children_by_id[$new_widget->id] = $new_widget; } return $widget; } } return null; }
[ "public", "function", "replace", "(", "SwatWidget", "$", "widget", ",", "SwatWidget", "$", "new_widget", ")", "{", "foreach", "(", "$", "this", "->", "children", "as", "$", "key", "=>", "$", "child_widget", ")", "{", "if", "(", "$", "child_widget", "==="...
Replace a widget Replaces a child widget in this container. The parent of the removed widget is set to null. @param SwatWidget $widget a reference to the widget to be replaced. @param SwatWidget $widget a reference to the new widget. @return SwatWidget a reference to the removed widget, or null if the widget is not found.
[ "Replace", "a", "widget" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L86-L106
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.remove
public function remove(SwatWidget $widget) { foreach ($this->children as $key => $child_widget) { if ($child_widget === $widget) { // use array_splice here instead of unset in order to re-index // the array keys array_splice($this->children, $key, 1); $widget->parent = null; if ($widget->id !== null) { unset($this->children_by_id[$widget->id]); } return $widget; } } return null; }
php
public function remove(SwatWidget $widget) { foreach ($this->children as $key => $child_widget) { if ($child_widget === $widget) { // use array_splice here instead of unset in order to re-index // the array keys array_splice($this->children, $key, 1); $widget->parent = null; if ($widget->id !== null) { unset($this->children_by_id[$widget->id]); } return $widget; } } return null; }
[ "public", "function", "remove", "(", "SwatWidget", "$", "widget", ")", "{", "foreach", "(", "$", "this", "->", "children", "as", "$", "key", "=>", "$", "child_widget", ")", "{", "if", "(", "$", "child_widget", "===", "$", "widget", ")", "{", "// use ar...
Removes a widget Removes a child widget from this container. The parent of the widget is set to null. @param SwatWidget $widget a reference to the widget to remove. @return SwatWidget a reference to the removed widget, or null if the widget is not found.
[ "Removes", "a", "widget" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L122-L139
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.packStart
public function packStart(SwatWidget $widget) { if ($widget->parent !== null) { throw new SwatException( 'Attempting to add a widget that already has a parent.' ); } array_unshift($this->children, $widget); $widget->parent = $this; if ($widget->id !== null) { $this->children_by_id[$widget->id] = $widget; } $this->sendAddNotifySignal($widget); }
php
public function packStart(SwatWidget $widget) { if ($widget->parent !== null) { throw new SwatException( 'Attempting to add a widget that already has a parent.' ); } array_unshift($this->children, $widget); $widget->parent = $this; if ($widget->id !== null) { $this->children_by_id[$widget->id] = $widget; } $this->sendAddNotifySignal($widget); }
[ "public", "function", "packStart", "(", "SwatWidget", "$", "widget", ")", "{", "if", "(", "$", "widget", "->", "parent", "!==", "null", ")", "{", "throw", "new", "SwatException", "(", "'Attempting to add a widget that already has a parent.'", ")", ";", "}", "arr...
Adds a widget to start Adds a widget to the start of the list of widgets in this container. @param SwatWidget $widget a reference to the widget to add.
[ "Adds", "a", "widget", "to", "start" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L151-L167
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.insertBefore
public function insertBefore(SwatWidget $widget, SwatWidget $child) { if ($widget->parent !== null) { throw new SwatException( 'Attempting to add a widget that already has a parent.' ); } if ($child->parent !== $this) { throw new SwatException( 'Attempting to insert before a child ' . 'that is not in this container.' ); } $index = 0; for ($i = 0; $i < count($this->children); $i++) { if ($this->children[$i] === $child) { $index = $i; break; } } array_splice($this->children, $index, 0, array($widget)); $widget->parent = $this; if ($widget->id !== null) { $this->children_by_id[$widget->id] = $widget; } $this->sendAddNotifySignal($widget); }
php
public function insertBefore(SwatWidget $widget, SwatWidget $child) { if ($widget->parent !== null) { throw new SwatException( 'Attempting to add a widget that already has a parent.' ); } if ($child->parent !== $this) { throw new SwatException( 'Attempting to insert before a child ' . 'that is not in this container.' ); } $index = 0; for ($i = 0; $i < count($this->children); $i++) { if ($this->children[$i] === $child) { $index = $i; break; } } array_splice($this->children, $index, 0, array($widget)); $widget->parent = $this; if ($widget->id !== null) { $this->children_by_id[$widget->id] = $widget; } $this->sendAddNotifySignal($widget); }
[ "public", "function", "insertBefore", "(", "SwatWidget", "$", "widget", ",", "SwatWidget", "$", "child", ")", "{", "if", "(", "$", "widget", "->", "parent", "!==", "null", ")", "{", "throw", "new", "SwatException", "(", "'Attempting to add a widget that already ...
Adds a widget to this container before another widget @param SwatWidget $widget a reference to the widget to add. @param SwatWidget $child a reference to the widget to add before.
[ "Adds", "a", "widget", "to", "this", "container", "before", "another", "widget" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L178-L209
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.packEnd
public function packEnd(SwatWidget $widget) { if ($widget->parent !== null) { throw new SwatException( 'Attempting to add a widget that already has a parent.' ); } $this->children[] = $widget; $widget->parent = $this; if ($widget->id !== null) { $this->children_by_id[$widget->id] = $widget; } $this->sendAddNotifySignal($widget); }
php
public function packEnd(SwatWidget $widget) { if ($widget->parent !== null) { throw new SwatException( 'Attempting to add a widget that already has a parent.' ); } $this->children[] = $widget; $widget->parent = $this; if ($widget->id !== null) { $this->children_by_id[$widget->id] = $widget; } $this->sendAddNotifySignal($widget); }
[ "public", "function", "packEnd", "(", "SwatWidget", "$", "widget", ")", "{", "if", "(", "$", "widget", "->", "parent", "!==", "null", ")", "{", "throw", "new", "SwatException", "(", "'Attempting to add a widget that already has a parent.'", ")", ";", "}", "$", ...
Adds a widget to end Adds a widget to the end of the list of widgets in this container. @param SwatWidget $widget a reference to the widget to add.
[ "Adds", "a", "widget", "to", "end" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L221-L237
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.getChild
public function getChild($id) { if (array_key_exists($id, $this->children_by_id)) { return $this->children_by_id[$id]; } else { return null; } }
php
public function getChild($id) { if (array_key_exists($id, $this->children_by_id)) { return $this->children_by_id[$id]; } else { return null; } }
[ "public", "function", "getChild", "(", "$", "id", ")", "{", "if", "(", "array_key_exists", "(", "$", "id", ",", "$", "this", "->", "children_by_id", ")", ")", "{", "return", "$", "this", "->", "children_by_id", "[", "$", "id", "]", ";", "}", "else", ...
Gets a child widget Retrieves a widget from the list of widgets in the container based on the unique identifier of the widget. @param string $id the unique id of the widget to look for. @return SwatWidget the found widget or null if not found.
[ "Gets", "a", "child", "widget" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L252-L259
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.getFirst
public function getFirst() { if (count($this->children)) { reset($this->children); return current($this->children); } else { return null; } }
php
public function getFirst() { if (count($this->children)) { reset($this->children); return current($this->children); } else { return null; } }
[ "public", "function", "getFirst", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "children", ")", ")", "{", "reset", "(", "$", "this", "->", "children", ")", ";", "return", "current", "(", "$", "this", "->", "children", ")", ";", "}", ...
Gets the first child widget Retrieves the first child widget from the list of widgets in the container. @return SwatWidget the first widget in this container or null if there are no widgets in this container.
[ "Gets", "the", "first", "child", "widget" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L273-L281
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.getChildren
public function getChildren($class_name = null) { if ($class_name === null) { return $this->children; } $out = array(); foreach ($this->children as $child_widget) { if ($child_widget instanceof $class_name) { $out[] = $child_widget; } } return $out; }
php
public function getChildren($class_name = null) { if ($class_name === null) { return $this->children; } $out = array(); foreach ($this->children as $child_widget) { if ($child_widget instanceof $class_name) { $out[] = $child_widget; } } return $out; }
[ "public", "function", "getChildren", "(", "$", "class_name", "=", "null", ")", "{", "if", "(", "$", "class_name", "===", "null", ")", "{", "return", "$", "this", "->", "children", ";", "}", "$", "out", "=", "array", "(", ")", ";", "foreach", "(", "...
Gets all child widgets Retrieves an array of all widgets directly contained by this container. @param string $class_name optional class name. If set, only widgets that are instances of <code>$class_name</code> are returned. @return array the child widgets of this container.
[ "Gets", "all", "child", "widgets" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L297-L312
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.getDescendantStates
public function getDescendantStates() { $states = array(); foreach ($this->getDescendants('SwatState') as $id => $object) { $states[$id] = $object->getState(); } return $states; }
php
public function getDescendantStates() { $states = array(); foreach ($this->getDescendants('SwatState') as $id => $object) { $states[$id] = $object->getState(); } return $states; }
[ "public", "function", "getDescendantStates", "(", ")", "{", "$", "states", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getDescendants", "(", "'SwatState'", ")", "as", "$", "id", "=>", "$", "object", ")", "{", "$", "states", "[", ...
Gets descendant states Retrieves an array of states of all stateful UI-objects in the widget subtree below this container. @return array an array of UI-object states with UI-object identifiers as array keys.
[ "Gets", "descendant", "states" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L414-L423
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.setDescendantStates
public function setDescendantStates(array $states) { foreach ($this->getDescendants('SwatState') as $id => $object) { if (isset($states[$id])) { $object->setState($states[$id]); } } }
php
public function setDescendantStates(array $states) { foreach ($this->getDescendants('SwatState') as $id => $object) { if (isset($states[$id])) { $object->setState($states[$id]); } } }
[ "public", "function", "setDescendantStates", "(", "array", "$", "states", ")", "{", "foreach", "(", "$", "this", "->", "getDescendants", "(", "'SwatState'", ")", "as", "$", "id", "=>", "$", "object", ")", "{", "if", "(", "isset", "(", "$", "states", "[...
Sets descendant states Sets states on all stateful UI-objects in the widget subtree below this container. @param array $states an array of UI-object states with UI-object identifiers as array keys.
[ "Sets", "descendant", "states" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L437-L444
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.getHtmlHeadEntrySet
public function getHtmlHeadEntrySet() { $set = parent::getHtmlHeadEntrySet(); foreach ($this->children as $child_widget) { $set->addEntrySet($child_widget->getHtmlHeadEntrySet()); } return $set; }
php
public function getHtmlHeadEntrySet() { $set = parent::getHtmlHeadEntrySet(); foreach ($this->children as $child_widget) { $set->addEntrySet($child_widget->getHtmlHeadEntrySet()); } return $set; }
[ "public", "function", "getHtmlHeadEntrySet", "(", ")", "{", "$", "set", "=", "parent", "::", "getHtmlHeadEntrySet", "(", ")", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child_widget", ")", "{", "$", "set", "->", "addEntrySet", "(", "...
Gets the SwatHtmlHeadEntry objects needed by this container @return SwatHtmlHeadEntrySet the {@link SwatHtmlHeadEntry} objects needed by this container. @see SwatUIObject::getHtmlHeadEntrySet()
[ "Gets", "the", "SwatHtmlHeadEntry", "objects", "needed", "by", "this", "container" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L571-L580
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.getAvailableHtmlHeadEntrySet
public function getAvailableHtmlHeadEntrySet() { $set = parent::getAvailableHtmlHeadEntrySet(); foreach ($this->children as $child_widget) { $set->addEntrySet($child_widget->getAvailableHtmlHeadEntrySet()); } return $set; }
php
public function getAvailableHtmlHeadEntrySet() { $set = parent::getAvailableHtmlHeadEntrySet(); foreach ($this->children as $child_widget) { $set->addEntrySet($child_widget->getAvailableHtmlHeadEntrySet()); } return $set; }
[ "public", "function", "getAvailableHtmlHeadEntrySet", "(", ")", "{", "$", "set", "=", "parent", "::", "getAvailableHtmlHeadEntrySet", "(", ")", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child_widget", ")", "{", "$", "set", "->", "addEnt...
Gets the SwatHtmlHeadEntry objects that may be needed by this container @return SwatHtmlHeadEntrySet the {@link SwatHtmlHeadEntry} objects that may be needed by this container. @see SwatUIObject::getAvailableHtmlHeadEntrySet()
[ "Gets", "the", "SwatHtmlHeadEntry", "objects", "that", "may", "be", "needed", "by", "this", "container" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L593-L602
train
silverorange/swat
Swat/SwatContainer.php
SwatContainer.sendAddNotifySignal
protected function sendAddNotifySignal($widget) { $this->notifyOfAdd($widget); if ($this->parent !== null && $this->parent instanceof SwatContainer) { $this->parent->sendAddNotifySignal($widget); } }
php
protected function sendAddNotifySignal($widget) { $this->notifyOfAdd($widget); if ($this->parent !== null && $this->parent instanceof SwatContainer) { $this->parent->sendAddNotifySignal($widget); } }
[ "protected", "function", "sendAddNotifySignal", "(", "$", "widget", ")", "{", "$", "this", "->", "notifyOfAdd", "(", "$", "widget", ")", ";", "if", "(", "$", "this", "->", "parent", "!==", "null", "&&", "$", "this", "->", "parent", "instanceof", "SwatCon...
Sends the notification signal up the widget tree This container is notified of the added widget and then this method is called on the container parent. @param SwatWidget $widget the widget that has been added.
[ "Sends", "the", "notification", "signal", "up", "the", "widget", "tree" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatContainer.php#L725-L732
train
silverorange/swat
Swat/SwatSimpleColorEntry.php
SwatSimpleColorEntry.getInlineJavaScript
protected function getInlineJavaScript() { $javascript = parent::getInlineJavaScript(); $colors = "'" . implode("', '", $this->colors) . "'"; if ($this->none_option) { $none_option = $this->none_option_title === null ? 'null' : SwatString::quoteJavaScriptString( $this->none_option_title ); } else { $none_option = 'null'; } $js_class_name = $this->getJavaScriptClassName(); $javascript .= "\nvar {$this->id}_obj = new {$js_class_name}(" . "'{$this->id}', [{$colors}], {$none_option});\n"; return $javascript; }
php
protected function getInlineJavaScript() { $javascript = parent::getInlineJavaScript(); $colors = "'" . implode("', '", $this->colors) . "'"; if ($this->none_option) { $none_option = $this->none_option_title === null ? 'null' : SwatString::quoteJavaScriptString( $this->none_option_title ); } else { $none_option = 'null'; } $js_class_name = $this->getJavaScriptClassName(); $javascript .= "\nvar {$this->id}_obj = new {$js_class_name}(" . "'{$this->id}', [{$colors}], {$none_option});\n"; return $javascript; }
[ "protected", "function", "getInlineJavaScript", "(", ")", "{", "$", "javascript", "=", "parent", "::", "getInlineJavaScript", "(", ")", ";", "$", "colors", "=", "\"'\"", ".", "implode", "(", "\"', '\"", ",", "$", "this", "->", "colors", ")", ".", "\"'\"", ...
Gets simple color selector inline JavaScript The JavaScript is the majority of the simple color selector code @return string simple color selector inline JavaScript.
[ "Gets", "simple", "color", "selector", "inline", "JavaScript" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatSimpleColorEntry.php#L176-L200
train
silverorange/swat
Swat/SwatOptionControl.php
SwatOptionControl.addOptionMetadata
public function addOptionMetadata( SwatOption $option, $metadata, $value = null ) { $key = $this->getOptionMetadataKey($option); if (is_array($metadata)) { $this->option_metadata[$key] = array_merge( $this->option_metadata[$key], $metadata ); } else { $this->option_metadata[$key][$metadata] = $value; } }
php
public function addOptionMetadata( SwatOption $option, $metadata, $value = null ) { $key = $this->getOptionMetadataKey($option); if (is_array($metadata)) { $this->option_metadata[$key] = array_merge( $this->option_metadata[$key], $metadata ); } else { $this->option_metadata[$key][$metadata] = $value; } }
[ "public", "function", "addOptionMetadata", "(", "SwatOption", "$", "option", ",", "$", "metadata", ",", "$", "value", "=", "null", ")", "{", "$", "key", "=", "$", "this", "->", "getOptionMetadataKey", "(", "$", "option", ")", ";", "if", "(", "is_array", ...
Sets the metadata for an option Any metadata may be added to options. It is up to the control to make use of particular metadata fields. Common metadata fields are: - classes - an array of CSS classes @param SwatOption $option the option for which to set the metadata. @param array|string $metadata either an array of metadata to add to the option, or a string specifying the name of the metadata field to add. @param mixed $value optional. If the <i>$metadata</i> parameter is a string, this is the metadata value to set for the option. Otherwise, this parameter is ignored. @see SwatOptionControl::addOption() @see SwatOptionControl::getOptionMetadata()
[ "Sets", "the", "metadata", "for", "an", "option" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatOptionControl.php#L161-L176
train
silverorange/swat
Swat/SwatOptionControl.php
SwatOptionControl.getOptionMetadata
public function getOptionMetadata(SwatOption $option, $metadata = null) { $key = $this->getOptionMetadataKey($option); if ($metadata === null) { if (isset($this->option_metadata[$key])) { $metadata = $this->option_metadata[$key]; } else { $metadata = array(); } } else { if ( isset($this->option_metadata[$key]) && isset($this->option_metadata[$key][$metadata]) ) { $metadata = $this->option_metadata[$key][$metadata]; } else { $metadata = null; } } return $metadata; }
php
public function getOptionMetadata(SwatOption $option, $metadata = null) { $key = $this->getOptionMetadataKey($option); if ($metadata === null) { if (isset($this->option_metadata[$key])) { $metadata = $this->option_metadata[$key]; } else { $metadata = array(); } } else { if ( isset($this->option_metadata[$key]) && isset($this->option_metadata[$key][$metadata]) ) { $metadata = $this->option_metadata[$key][$metadata]; } else { $metadata = null; } } return $metadata; }
[ "public", "function", "getOptionMetadata", "(", "SwatOption", "$", "option", ",", "$", "metadata", "=", "null", ")", "{", "$", "key", "=", "$", "this", "->", "getOptionMetadataKey", "(", "$", "option", ")", ";", "if", "(", "$", "metadata", "===", "null",...
Gets the metadata for an option Any metadata may be added to options. It is up to the control to make use of particular metadata fields. Common metadata fields are: - classes - an array of CSS classes @param SwatOption $option the option for which to get the metadata. @param string $metadata optional. An optional metadata property to get. If not specified, all available metadata for the option is returned. @returns array|mixed an array of the metadata for this option, or a specific metadata value if the <i>$metadata</i> parameter is specified. If <i>$metadata</i> is specified and no such metadata field exists for the specified option, null is returned. @see SwatOptionControl::addOptionMetadata()
[ "Gets", "the", "metadata", "for", "an", "option" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatOptionControl.php#L202-L224
train
silverorange/swat
Swat/SwatOptionControl.php
SwatOptionControl.removeOption
public function removeOption(SwatOption $option) { $removed_option = null; foreach ($this->options as $key => $control_option) { if ($control_option === $option) { $removed_option = $control_option; // remove from options list unset($this->options[$key]); // remove metadata $key = $this->getOptionMetadataKey($control_option); unset($this->option_metadata[$key]); } } return $removed_option; }
php
public function removeOption(SwatOption $option) { $removed_option = null; foreach ($this->options as $key => $control_option) { if ($control_option === $option) { $removed_option = $control_option; // remove from options list unset($this->options[$key]); // remove metadata $key = $this->getOptionMetadataKey($control_option); unset($this->option_metadata[$key]); } } return $removed_option; }
[ "public", "function", "removeOption", "(", "SwatOption", "$", "option", ")", "{", "$", "removed_option", "=", "null", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "key", "=>", "$", "control_option", ")", "{", "if", "(", "$", "control_opt...
Removes an option from this option control @param SwatOption $option the option to remove. @return SwatOption the removed option or null if no option was removed.
[ "Removes", "an", "option", "from", "this", "option", "control" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatOptionControl.php#L236-L254
train
silverorange/swat
Swat/SwatOptionControl.php
SwatOptionControl.removeOptionsByValue
public function removeOptionsByValue($value) { $removed_options = array(); foreach ($this->options as $key => $control_option) { if ($control_option->value === $value) { $removed_options[] = $control_option; // remove from options list unset($this->options[$key]); // remove metadata $metadata_key = $this->getOptionMetadataKey($control_option); unset($this->option_metadata[$metadata_key]); } } return $removed_options; }
php
public function removeOptionsByValue($value) { $removed_options = array(); foreach ($this->options as $key => $control_option) { if ($control_option->value === $value) { $removed_options[] = $control_option; // remove from options list unset($this->options[$key]); // remove metadata $metadata_key = $this->getOptionMetadataKey($control_option); unset($this->option_metadata[$metadata_key]); } } return $removed_options; }
[ "public", "function", "removeOptionsByValue", "(", "$", "value", ")", "{", "$", "removed_options", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "key", "=>", "$", "control_option", ")", "{", "if", "(", "$", "cont...
Removes options from this option control by their value @param mixed $value the value of the option or options to remove. @return array an array of removed SwatOption objects or an empty array if no options are removed.
[ "Removes", "options", "from", "this", "option", "control", "by", "their", "value" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatOptionControl.php#L267-L285
train
silverorange/swat
Swat/SwatOptionControl.php
SwatOptionControl.getOptionsByValue
public function getOptionsByValue($value) { $options = array(); foreach ($this->options as $option) { if ($option->value === $value) { $options[] = $option; } } return $options; }
php
public function getOptionsByValue($value) { $options = array(); foreach ($this->options as $option) { if ($option->value === $value) { $options[] = $option; } } return $options; }
[ "public", "function", "getOptionsByValue", "(", "$", "value", ")", "{", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "option", ")", "{", "if", "(", "$", "option", "->", "value", "===", "$", "...
Gets options from this option control by their value @param mixed $value the value of the option or options to get. @return array an array of SwatOption objects or an empty array if no options with the given value exist within this option control.
[ "Gets", "options", "from", "this", "option", "control", "by", "their", "value" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatOptionControl.php#L320-L331
train
brainworxx/kreXX
src/Analyse/Callback/Analyse/Objects/Traversable.php
Traversable.callMe
public function callMe() { $output = $this->dispatchStartEvent(); // Check nesting level, memory and runtime. $this->pool->emergencyHandler->upOneNestingLevel(); if ($this->pool->emergencyHandler->checkNesting() === true || $this->pool->emergencyHandler->checkEmergencyBreak() === true ) { // We will not be doing this one, but we need to get down with our // nesting level again. $this->pool->emergencyHandler->downOneNestingLevel(); return $output; } // Do the actual analysis return $output . $this->getTaversableData(); }
php
public function callMe() { $output = $this->dispatchStartEvent(); // Check nesting level, memory and runtime. $this->pool->emergencyHandler->upOneNestingLevel(); if ($this->pool->emergencyHandler->checkNesting() === true || $this->pool->emergencyHandler->checkEmergencyBreak() === true ) { // We will not be doing this one, but we need to get down with our // nesting level again. $this->pool->emergencyHandler->downOneNestingLevel(); return $output; } // Do the actual analysis return $output . $this->getTaversableData(); }
[ "public", "function", "callMe", "(", ")", "{", "$", "output", "=", "$", "this", "->", "dispatchStartEvent", "(", ")", ";", "// Check nesting level, memory and runtime.", "$", "this", "->", "pool", "->", "emergencyHandler", "->", "upOneNestingLevel", "(", ")", ";...
Checks runtime, memory and nesting level. Then trigger the actual analysis. @return string The generated markup.
[ "Checks", "runtime", "memory", "and", "nesting", "level", ".", "Then", "trigger", "the", "actual", "analysis", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Analyse/Objects/Traversable.php#L64-L81
train
brainworxx/kreXX
src/Analyse/Callback/Analyse/Objects/Traversable.php
Traversable.getTaversableData
protected function getTaversableData() { $data = $this->parameters[static::PARAM_DATA]; $name = $this->parameters[static::PARAM_NAME]; // Add a try to prevent the hosting CMS from doing something stupid. try { // We need to deactivate the current error handling to // prevent the host system to do anything stupid. set_error_handler( function () { // Do nothing. } ); $parameter = iterator_to_array($data); } catch (\Throwable $e) { //Restore the previous error handler, and return an empty string. restore_error_handler(); $this->pool->emergencyHandler->downOneNestingLevel(); return ''; } catch (\Exception $e) { //Restore the previous error handler, and return an empty string. restore_error_handler(); $this->pool->emergencyHandler->downOneNestingLevel(); return ''; } // Reactivate whatever error handling we had previously. restore_error_handler(); if (is_array($parameter) === true) { // Special Array Access here, resulting in more complicated source // generation. So we tell the callback to to that. $multiline = true; // Normal ArrayAccess, direct access to the array. Nothing special if ($data instanceof \ArrayAccess) { $multiline = false; } // SplObject pool use the object as keys, so we need some // multiline stuff! if ($data instanceof \SplObjectStorage) { $multiline = true; } $count = count($parameter); /** @var Model $model */ $model = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model') ->setName($name) ->setType(static::TYPE_FOREACH) ->addParameter(static::PARAM_DATA, $parameter) ->addParameter(static::PARAM_MULTILINE, $multiline) ->addToJson(static::META_LENGTH, count($parameter)); // Check, if we are handling a huge array. Huge arrays tend to result in a huge // output, maybe even triggering a emergency break. to avoid this, we give them // a special callback. if ($count > (int) $this->pool->config->getSetting(Fallback::SETTING_ARRAY_COUNT_LIMIT)) { $model->injectCallback( $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughLargeArray') )->setNormal('Simplified Traversable Info') ->setHelpid('simpleArray'); } else { $model->injectCallback( $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughArray') )->setNormal('Traversable Info'); } $result = $this->pool->render->renderExpandableChild( $this->dispatchEventWithModel(static::EVENT_MARKER_ANALYSES_END, $model) ); $this->pool->emergencyHandler->downOneNestingLevel(); return $result; } // Still here?!? Return an empty string. $this->pool->emergencyHandler->downOneNestingLevel(); return ''; }
php
protected function getTaversableData() { $data = $this->parameters[static::PARAM_DATA]; $name = $this->parameters[static::PARAM_NAME]; // Add a try to prevent the hosting CMS from doing something stupid. try { // We need to deactivate the current error handling to // prevent the host system to do anything stupid. set_error_handler( function () { // Do nothing. } ); $parameter = iterator_to_array($data); } catch (\Throwable $e) { //Restore the previous error handler, and return an empty string. restore_error_handler(); $this->pool->emergencyHandler->downOneNestingLevel(); return ''; } catch (\Exception $e) { //Restore the previous error handler, and return an empty string. restore_error_handler(); $this->pool->emergencyHandler->downOneNestingLevel(); return ''; } // Reactivate whatever error handling we had previously. restore_error_handler(); if (is_array($parameter) === true) { // Special Array Access here, resulting in more complicated source // generation. So we tell the callback to to that. $multiline = true; // Normal ArrayAccess, direct access to the array. Nothing special if ($data instanceof \ArrayAccess) { $multiline = false; } // SplObject pool use the object as keys, so we need some // multiline stuff! if ($data instanceof \SplObjectStorage) { $multiline = true; } $count = count($parameter); /** @var Model $model */ $model = $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Model') ->setName($name) ->setType(static::TYPE_FOREACH) ->addParameter(static::PARAM_DATA, $parameter) ->addParameter(static::PARAM_MULTILINE, $multiline) ->addToJson(static::META_LENGTH, count($parameter)); // Check, if we are handling a huge array. Huge arrays tend to result in a huge // output, maybe even triggering a emergency break. to avoid this, we give them // a special callback. if ($count > (int) $this->pool->config->getSetting(Fallback::SETTING_ARRAY_COUNT_LIMIT)) { $model->injectCallback( $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughLargeArray') )->setNormal('Simplified Traversable Info') ->setHelpid('simpleArray'); } else { $model->injectCallback( $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughArray') )->setNormal('Traversable Info'); } $result = $this->pool->render->renderExpandableChild( $this->dispatchEventWithModel(static::EVENT_MARKER_ANALYSES_END, $model) ); $this->pool->emergencyHandler->downOneNestingLevel(); return $result; } // Still here?!? Return an empty string. $this->pool->emergencyHandler->downOneNestingLevel(); return ''; }
[ "protected", "function", "getTaversableData", "(", ")", "{", "$", "data", "=", "$", "this", "->", "parameters", "[", "static", "::", "PARAM_DATA", "]", ";", "$", "name", "=", "$", "this", "->", "parameters", "[", "static", "::", "PARAM_NAME", "]", ";", ...
Analyses the traversable data. @return string The generated markup.
[ "Analyses", "the", "traversable", "data", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Callback/Analyse/Objects/Traversable.php#L89-L169
train
silverorange/swat
Swat/SwatCellRenderer.php
SwatCellRenderer.getHtmlHeadEntrySet
public function getHtmlHeadEntrySet() { if ($this->render_count > 0) { $set = new SwatHtmlHeadEntrySet($this->html_head_entry_set); } else { $set = new SwatHtmlHeadEntrySet(); } return $set; }
php
public function getHtmlHeadEntrySet() { if ($this->render_count > 0) { $set = new SwatHtmlHeadEntrySet($this->html_head_entry_set); } else { $set = new SwatHtmlHeadEntrySet(); } return $set; }
[ "public", "function", "getHtmlHeadEntrySet", "(", ")", "{", "if", "(", "$", "this", "->", "render_count", ">", "0", ")", "{", "$", "set", "=", "new", "SwatHtmlHeadEntrySet", "(", "$", "this", "->", "html_head_entry_set", ")", ";", "}", "else", "{", "$", ...
Gets the SwatHtmlHeadEntry objects needed by this cell renderer If this renderer has never been rendered, an empty set is returned to reduce the number of required HTTP requests. @return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects needed by this cell renderer.
[ "Gets", "the", "SwatHtmlHeadEntry", "objects", "needed", "by", "this", "cell", "renderer" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRenderer.php#L235-L244
train
silverorange/swat
Swat/SwatCellRenderer.php
SwatCellRenderer.getInheritanceCSSClassNames
final public function getInheritanceCSSClassNames() { $php_class_name = get_class($this); $css_class_names = array(); // get the ancestors that are swat classes while ($php_class_name !== 'SwatCellRenderer') { if (strncmp($php_class_name, 'Swat', 4) === 0) { $css_class_name = mb_strtolower( preg_replace('/([A-Z])/u', '-\1', $php_class_name) ); if (mb_substr($css_class_name, 0, 1) === '-') { $css_class_name = mb_substr($css_class_name, 1); } array_unshift($css_class_names, $css_class_name); } $php_class_name = get_parent_class($php_class_name); } return $css_class_names; }
php
final public function getInheritanceCSSClassNames() { $php_class_name = get_class($this); $css_class_names = array(); // get the ancestors that are swat classes while ($php_class_name !== 'SwatCellRenderer') { if (strncmp($php_class_name, 'Swat', 4) === 0) { $css_class_name = mb_strtolower( preg_replace('/([A-Z])/u', '-\1', $php_class_name) ); if (mb_substr($css_class_name, 0, 1) === '-') { $css_class_name = mb_substr($css_class_name, 1); } array_unshift($css_class_names, $css_class_name); } $php_class_name = get_parent_class($php_class_name); } return $css_class_names; }
[ "final", "public", "function", "getInheritanceCSSClassNames", "(", ")", "{", "$", "php_class_name", "=", "get_class", "(", "$", "this", ")", ";", "$", "css_class_names", "=", "array", "(", ")", ";", "// get the ancestors that are swat classes", "while", "(", "$", ...
Gets the CSS class names of this cell renderer based on the inheritance tree for this cell renderer For example, a class with the following ancestry: SwatCellRenderer -> SwatTextCellRenderer -> SwatNullTextCellRenderer will return the following array of class names: <code> array( 'swat-cell-renderer', 'swat-text-cell-renderer', 'swat-null-text-cell-renderer', ); </code> @return array the array of CSS class names based on an inheritance tree for this cell renderer.
[ "Gets", "the", "CSS", "class", "names", "of", "this", "cell", "renderer", "based", "on", "the", "inheritance", "tree", "for", "this", "cell", "renderer" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRenderer.php#L306-L328
train