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
brainworxx/kreXX
src/Service/Flow/Emergency.php
Emergency.checkRuntime
protected function checkRuntime() { // Check Runtime. if ($this->timer < time()) { // This is taking longer than expected. $this->pool->messages->addMessage('emergencyTimer'); Krexx::editSettings(); Krexx::disable(); static::$allIsOk = false; return true; } return false; }
php
protected function checkRuntime() { // Check Runtime. if ($this->timer < time()) { // This is taking longer than expected. $this->pool->messages->addMessage('emergencyTimer'); Krexx::editSettings(); Krexx::disable(); static::$allIsOk = false; return true; } return false; }
[ "protected", "function", "checkRuntime", "(", ")", "{", "// Check Runtime.", "if", "(", "$", "this", "->", "timer", "<", "time", "(", ")", ")", "{", "// This is taking longer than expected.", "$", "this", "->", "pool", "->", "messages", "->", "addMessage", "("...
Checks if there is enough time left for the analysis. @return bool Boolean to show if we have enough left. FALSE = all is OK. TRUE = we have a problem.
[ "Checks", "if", "there", "is", "enough", "time", "left", "for", "the", "analysis", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Flow/Emergency.php#L198-L211
train
brainworxx/kreXX
src/Service/Flow/Emergency.php
Emergency.checkMemory
protected function checkMemory() { // We will only check, if we were able to determine a memory limit // in the first place. if ($this->serverMemoryLimit > 2) { $left = $this->serverMemoryLimit - memory_get_usage(); // Is more left than is configured? if ($left < $this->minMemoryLeft) { $this->pool->messages->addMessage('emergencyMemory'); // Show settings to give the dev to repair the situation. Krexx::editSettings(); Krexx::disable(); static::$allIsOk = false; return true; } } return false; }
php
protected function checkMemory() { // We will only check, if we were able to determine a memory limit // in the first place. if ($this->serverMemoryLimit > 2) { $left = $this->serverMemoryLimit - memory_get_usage(); // Is more left than is configured? if ($left < $this->minMemoryLeft) { $this->pool->messages->addMessage('emergencyMemory'); // Show settings to give the dev to repair the situation. Krexx::editSettings(); Krexx::disable(); static::$allIsOk = false; return true; } } return false; }
[ "protected", "function", "checkMemory", "(", ")", "{", "// We will only check, if we were able to determine a memory limit", "// in the first place.", "if", "(", "$", "this", "->", "serverMemoryLimit", ">", "2", ")", "{", "$", "left", "=", "$", "this", "->", "serverMe...
Check if we have enough memory left. @return bool Boolean to show if we have enough left. FALSE = all is OK. TRUE = we have a problem.
[ "Check", "if", "we", "have", "enough", "memory", "left", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Flow/Emergency.php#L221-L239
train
brainworxx/kreXX
src/Service/Flow/Emergency.php
Emergency.resetTimer
public function resetTimer() { if (empty($this->timer) === true) { $this->timer = time() + $this->maxRuntime; } }
php
public function resetTimer() { if (empty($this->timer) === true) { $this->timer = time() + $this->maxRuntime; } }
[ "public", "function", "resetTimer", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "timer", ")", "===", "true", ")", "{", "$", "this", "->", "timer", "=", "time", "(", ")", "+", "$", "this", "->", "maxRuntime", ";", "}", "}" ]
Resets the timer. When a certain time has passed, kreXX will use an emergency break to prevent too large output (or no output at all (WSOD)).
[ "Resets", "the", "timer", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Flow/Emergency.php#L284-L289
train
brainworxx/kreXX
src/Service/Flow/Emergency.php
Emergency.checkMaxCall
public function checkMaxCall() { if ($this->krexxCount >= $this->maxCall) { // Called too often, we might get into trouble here! return true; } // Give feedback if this is our last call. if ($this->krexxCount === ($this->maxCall - 1)) { $this->pool->messages->addMessage('maxCallReached'); } // Count goes up. ++$this->krexxCount; // Tell them that we are still good. return false; }
php
public function checkMaxCall() { if ($this->krexxCount >= $this->maxCall) { // Called too often, we might get into trouble here! return true; } // Give feedback if this is our last call. if ($this->krexxCount === ($this->maxCall - 1)) { $this->pool->messages->addMessage('maxCallReached'); } // Count goes up. ++$this->krexxCount; // Tell them that we are still good. return false; }
[ "public", "function", "checkMaxCall", "(", ")", "{", "if", "(", "$", "this", "->", "krexxCount", ">=", "$", "this", "->", "maxCall", ")", "{", "// Called too often, we might get into trouble here!", "return", "true", ";", "}", "// Give feedback if this is our last cal...
Finds out, if krexx was called too often, to prevent large output. @return bool Whether kreXX was called too often or not.
[ "Finds", "out", "if", "krexx", "was", "called", "too", "often", "to", "prevent", "large", "output", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Flow/Emergency.php#L297-L313
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.each
public function each(callable $callback) { if ($this->isCollection()) { foreach ($this->data as $val) { $callback($this->box($val)); } } else { $callback($this->box($this->data)); } return $this; }
php
public function each(callable $callback) { if ($this->isCollection()) { foreach ($this->data as $val) { $callback($this->box($val)); } } else { $callback($this->box($this->data)); } return $this; }
[ "public", "function", "each", "(", "callable", "$", "callback", ")", "{", "if", "(", "$", "this", "->", "isCollection", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "val", ")", "{", "$", "callback", "(", "$", "this", ...
Fire callback for each member of the array. @param callable $callback @return $this
[ "Fire", "callback", "for", "each", "member", "of", "the", "array", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L63-L74
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.pluckArray
public function pluckArray($key): array { if ($this->isCollection()) { return array_map(function ($val) { return $this->box($val); }, CollectionUtility::pluck($this->data, $key)); } // Non-collection return CollectionUtility::pluck([$this->data], $key); }
php
public function pluckArray($key): array { if ($this->isCollection()) { return array_map(function ($val) { return $this->box($val); }, CollectionUtility::pluck($this->data, $key)); } // Non-collection return CollectionUtility::pluck([$this->data], $key); }
[ "public", "function", "pluckArray", "(", "$", "key", ")", ":", "array", "{", "if", "(", "$", "this", "->", "isCollection", "(", ")", ")", "{", "return", "array_map", "(", "function", "(", "$", "val", ")", "{", "return", "$", "this", "->", "box", "(...
Pluck a value by key from each result and return an array. @param $key @return array
[ "Pluck", "a", "value", "by", "key", "from", "each", "result", "and", "return", "an", "array", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L122-L132
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.filter
public function filter($filter): ArrayObjectInterface { return \is_callable($filter, true) ? $this->filterCallback($filter) : $this->filterConditions($filter); }
php
public function filter($filter): ArrayObjectInterface { return \is_callable($filter, true) ? $this->filterCallback($filter) : $this->filterConditions($filter); }
[ "public", "function", "filter", "(", "$", "filter", ")", ":", "ArrayObjectInterface", "{", "return", "\\", "is_callable", "(", "$", "filter", ",", "true", ")", "?", "$", "this", "->", "filterCallback", "(", "$", "filter", ")", ":", "$", "this", "->", "...
Return a new collection by filtering data within the current collection. @param mixed $filter @return ArrayObjectInterface
[ "Return", "a", "new", "collection", "by", "filtering", "data", "within", "the", "current", "collection", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L141-L144
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.filterCallback
public function filterCallback(callable $fn): ArrayObjectInterface { return new static( array_values( array_filter( $this->isCollection() ? $this->data : [$this->data], function($item) use ($fn) { return $fn($this->box($item)); } ) ) ); }
php
public function filterCallback(callable $fn): ArrayObjectInterface { return new static( array_values( array_filter( $this->isCollection() ? $this->data : [$this->data], function($item) use ($fn) { return $fn($this->box($item)); } ) ) ); }
[ "public", "function", "filterCallback", "(", "callable", "$", "fn", ")", ":", "ArrayObjectInterface", "{", "return", "new", "static", "(", "array_values", "(", "array_filter", "(", "$", "this", "->", "isCollection", "(", ")", "?", "$", "this", "->", "data", ...
Return a new collection by filtering the data via a callback. @param callable|\Closure $fn @return ArrayObjectInterface
[ "Return", "a", "new", "collection", "by", "filtering", "the", "data", "via", "a", "callback", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L153-L165
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.filterConditions
public function filterConditions( array $conditions, string $matchType = CollectionUtility::MATCH_TYPE_LOOSE, $preserveKeys = false ): ArrayObjectInterface { return new static(CollectionUtility::filterWhere($this->isCollection() ? $this->data : [$this->data], $conditions, $matchType, $preserveKeys)); }
php
public function filterConditions( array $conditions, string $matchType = CollectionUtility::MATCH_TYPE_LOOSE, $preserveKeys = false ): ArrayObjectInterface { return new static(CollectionUtility::filterWhere($this->isCollection() ? $this->data : [$this->data], $conditions, $matchType, $preserveKeys)); }
[ "public", "function", "filterConditions", "(", "array", "$", "conditions", ",", "string", "$", "matchType", "=", "CollectionUtility", "::", "MATCH_TYPE_LOOSE", ",", "$", "preserveKeys", "=", "false", ")", ":", "ArrayObjectInterface", "{", "return", "new", "static"...
Return a new collection by filtering the data against a list of conditions. @param array $conditions @param string $matchType @param bool $preserveKeys @return ArrayObjectInterface
[ "Return", "a", "new", "collection", "by", "filtering", "the", "data", "against", "a", "list", "of", "conditions", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L176-L183
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.first
public function first() { if (!$this->isCollection()) { return $this; } return isset($this->data[0]) ? $this->box($this->data[0]) : null; }
php
public function first() { if (!$this->isCollection()) { return $this; } return isset($this->data[0]) ? $this->box($this->data[0]) : null; }
[ "public", "function", "first", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isCollection", "(", ")", ")", "{", "return", "$", "this", ";", "}", "return", "isset", "(", "$", "this", "->", "data", "[", "0", "]", ")", "?", "$", "this", "->",...
Returns the first element in the collection. @return mixed
[ "Returns", "the", "first", "element", "in", "the", "collection", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L190-L197
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.last
public function last() { if (!$this->isCollection()) { return $this; } return isset($this->data[0]) ? $this->box(ArrayUtility::last($this->data)) : null; }
php
public function last() { if (!$this->isCollection()) { return $this; } return isset($this->data[0]) ? $this->box(ArrayUtility::last($this->data)) : null; }
[ "public", "function", "last", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isCollection", "(", ")", ")", "{", "return", "$", "this", ";", "}", "return", "isset", "(", "$", "this", "->", "data", "[", "0", "]", ")", "?", "$", "this", "->", ...
Returns the last element in the collection. @return ArrayObjectInterface|null
[ "Returns", "the", "last", "element", "in", "the", "collection", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L204-L211
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.getNormalizedKey
protected function getNormalizedKey($key): string { // Keys within collections must be offset based if (!\is_int($key) && $this->isCollection() && !preg_match('/^\d+\./', $key)) { $key = "0.$key"; } return $key; }
php
protected function getNormalizedKey($key): string { // Keys within collections must be offset based if (!\is_int($key) && $this->isCollection() && !preg_match('/^\d+\./', $key)) { $key = "0.$key"; } return $key; }
[ "protected", "function", "getNormalizedKey", "(", "$", "key", ")", ":", "string", "{", "// Keys within collections must be offset based", "if", "(", "!", "\\", "is_int", "(", "$", "key", ")", "&&", "$", "this", "->", "isCollection", "(", ")", "&&", "!", "pre...
Forces key to be prefixed with an offset. @param $key @return string
[ "Forces", "key", "to", "be", "prefixed", "with", "an", "offset", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L236-L244
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.has
public function has($key): bool { return ArrayUtility::dotRead($this->data, $this->getNormalizedKey($key)) !== null; }
php
public function has($key): bool { return ArrayUtility::dotRead($this->data, $this->getNormalizedKey($key)) !== null; }
[ "public", "function", "has", "(", "$", "key", ")", ":", "bool", "{", "return", "ArrayUtility", "::", "dotRead", "(", "$", "this", "->", "data", ",", "$", "this", "->", "getNormalizedKey", "(", "$", "key", ")", ")", "!==", "null", ";", "}" ]
Determine if the node contains a property. @param string $key @return bool
[ "Determine", "if", "the", "node", "contains", "a", "property", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L321-L324
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.shift
public function shift() { $this->forceCollection(); if (!$this->hasItems()) { throw new InvalidOffsetException('Cannot shift this array, no more items'); } return $this->box(array_shift($this->data)); }
php
public function shift() { $this->forceCollection(); if (!$this->hasItems()) { throw new InvalidOffsetException('Cannot shift this array, no more items'); } return $this->box(array_shift($this->data)); }
[ "public", "function", "shift", "(", ")", "{", "$", "this", "->", "forceCollection", "(", ")", ";", "if", "(", "!", "$", "this", "->", "hasItems", "(", ")", ")", "{", "throw", "new", "InvalidOffsetException", "(", "'Cannot shift this array, no more items'", "...
Pull the first item off the collection. If the underlying data is not a collection, it will be converted to one. @throws \Rexlabs\ArrayObject\Exceptions\InvalidOffsetException @return mixed
[ "Pull", "the", "first", "item", "off", "the", "collection", ".", "If", "the", "underlying", "data", "is", "not", "a", "collection", "it", "will", "be", "converted", "to", "one", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L346-L354
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.forceCollection
protected function forceCollection() { if (!$this->isCollection()) { $this->isCollection = true; $this->data = [$this->data]; } }
php
protected function forceCollection() { if (!$this->isCollection()) { $this->isCollection = true; $this->data = [$this->data]; } }
[ "protected", "function", "forceCollection", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isCollection", "(", ")", ")", "{", "$", "this", "->", "isCollection", "=", "true", ";", "$", "this", "->", "data", "=", "[", "$", "this", "->", "data", "...
Forces the underlying data-structure to become a collection.
[ "Forces", "the", "underlying", "data", "-", "structure", "to", "become", "a", "collection", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L359-L365
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.unshift
public function unshift(...$values) { $this->forceCollection(); $values = array_map([$this, 'unbox'], $values); array_unshift($this->data, ...$values); return $this; }
php
public function unshift(...$values) { $this->forceCollection(); $values = array_map([$this, 'unbox'], $values); array_unshift($this->data, ...$values); return $this; }
[ "public", "function", "unshift", "(", "...", "$", "values", ")", "{", "$", "this", "->", "forceCollection", "(", ")", ";", "$", "values", "=", "array_map", "(", "[", "$", "this", ",", "'unbox'", "]", ",", "$", "values", ")", ";", "array_unshift", "("...
Add one or more items at the start of the collection. If the underlying data is not a collection, it will be converted to one. @param array $values @throws \Rexlabs\ArrayObject\Exceptions\InvalidOffsetException @return mixed
[ "Add", "one", "or", "more", "items", "at", "the", "start", "of", "the", "collection", ".", "If", "the", "underlying", "data", "is", "not", "a", "collection", "it", "will", "be", "converted", "to", "one", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L397-L404
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.push
public function push(...$values) { $this->forceCollection(); $values = array_map([$this, 'unbox'], $values); array_push($this->data, ...$values); return $this; }
php
public function push(...$values) { $this->forceCollection(); $values = array_map([$this, 'unbox'], $values); array_push($this->data, ...$values); return $this; }
[ "public", "function", "push", "(", "...", "$", "values", ")", "{", "$", "this", "->", "forceCollection", "(", ")", ";", "$", "values", "=", "array_map", "(", "[", "$", "this", ",", "'unbox'", "]", ",", "$", "values", ")", ";", "array_push", "(", "$...
Add one or more items to the end of the collection. If the underlying data is not a collection, it will be converted to one. @param array $values @return mixed
[ "Add", "one", "or", "more", "items", "to", "the", "end", "of", "the", "collection", ".", "If", "the", "underlying", "data", "is", "not", "a", "collection", "it", "will", "be", "converted", "to", "one", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L414-L421
train
rexlabsio/array-object-php
src/ArrayObject.php
ArrayObject.pop
public function pop() { $this->forceCollection(); if (!$this->hasItems()) { throw new InvalidOffsetException('Cannot shift this array, no more items'); } return $this->box(array_pop($this->data)); }
php
public function pop() { $this->forceCollection(); if (!$this->hasItems()) { throw new InvalidOffsetException('Cannot shift this array, no more items'); } return $this->box(array_pop($this->data)); }
[ "public", "function", "pop", "(", ")", "{", "$", "this", "->", "forceCollection", "(", ")", ";", "if", "(", "!", "$", "this", "->", "hasItems", "(", ")", ")", "{", "throw", "new", "InvalidOffsetException", "(", "'Cannot shift this array, no more items'", ")"...
Pull the last item off the end of the collection. If the underlying data is not a collection, it will be converted to one. @throws \Rexlabs\ArrayObject\Exceptions\InvalidOffsetException @return mixed
[ "Pull", "the", "last", "item", "off", "the", "end", "of", "the", "collection", ".", "If", "the", "underlying", "data", "is", "not", "a", "collection", "it", "will", "be", "converted", "to", "one", "." ]
5633cbd556ed6e495cd77aca6ed644262a7d5165
https://github.com/rexlabsio/array-object-php/blob/5633cbd556ed6e495cd77aca6ed644262a7d5165/src/ArrayObject.php#L431-L439
train
brainworxx/kreXX
src/Service/Config/Config.php
Config.getDevHandler
public function getDevHandler() { static $handle = false; if ($handle === false) { $handle = $this->cookieConfig->getConfigFromCookies('deep', static::SETTING_DEV_HANDLE); } return $handle; }
php
public function getDevHandler() { static $handle = false; if ($handle === false) { $handle = $this->cookieConfig->getConfigFromCookies('deep', static::SETTING_DEV_HANDLE); } return $handle; }
[ "public", "function", "getDevHandler", "(", ")", "{", "static", "$", "handle", "=", "false", ";", "if", "(", "$", "handle", "===", "false", ")", "{", "$", "handle", "=", "$", "this", "->", "cookieConfig", "->", "getConfigFromCookies", "(", "'deep'", ",",...
Returns the developer handle from the cookies. @return string The Developer handle.
[ "Returns", "the", "developer", "handle", "from", "the", "cookies", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Config.php#L180-L189
train
brainworxx/kreXX
src/Service/Config/Config.php
Config.loadConfigValue
public function loadConfigValue($name) { $feConfig = $this->iniConfig->getFeConfig($name); $section = $this->feConfigFallback[$name][static::SECTION]; /** @var Model $model */ $model = $this->pool->createClass('Brainworxx\\Krexx\\Service\\Config\\Model') ->setSection($section) ->setEditable($feConfig[0]) ->setType($feConfig[1]); // Do we accept cookie settings here? if ($feConfig[0] === true) { $cookieSetting = $this->cookieConfig->getConfigFromCookies($section, $name); // Do we have a value in the cookies? if ($cookieSetting !== null && ($name === static::SETTING_DISABLED && $cookieSetting === static::VALUE_FALSE) === false ) { // We must not overwrite a disabled=true with local cookie settings! // Otherwise it could get enabled locally, which might be a security // issue. $model->setValue($cookieSetting)->setSource('Local cookie settings'); $this->settings[$name] = $model; return $this; } } // Do we have a value in the ini? $iniSettings = $this->iniConfig->getConfigFromFile($section, $name); if (isset($iniSettings) === true) { $model->setValue($iniSettings)->setSource('Krexx.ini settings'); $this->settings[$name] = $model; return $this; } // Nothing yet? Give back factory settings. $model->setValue($this->feConfigFallback[$name][static::VALUE])->setSource('Factory settings'); $this->settings[$name] = $model; return $this; }
php
public function loadConfigValue($name) { $feConfig = $this->iniConfig->getFeConfig($name); $section = $this->feConfigFallback[$name][static::SECTION]; /** @var Model $model */ $model = $this->pool->createClass('Brainworxx\\Krexx\\Service\\Config\\Model') ->setSection($section) ->setEditable($feConfig[0]) ->setType($feConfig[1]); // Do we accept cookie settings here? if ($feConfig[0] === true) { $cookieSetting = $this->cookieConfig->getConfigFromCookies($section, $name); // Do we have a value in the cookies? if ($cookieSetting !== null && ($name === static::SETTING_DISABLED && $cookieSetting === static::VALUE_FALSE) === false ) { // We must not overwrite a disabled=true with local cookie settings! // Otherwise it could get enabled locally, which might be a security // issue. $model->setValue($cookieSetting)->setSource('Local cookie settings'); $this->settings[$name] = $model; return $this; } } // Do we have a value in the ini? $iniSettings = $this->iniConfig->getConfigFromFile($section, $name); if (isset($iniSettings) === true) { $model->setValue($iniSettings)->setSource('Krexx.ini settings'); $this->settings[$name] = $model; return $this; } // Nothing yet? Give back factory settings. $model->setValue($this->feConfigFallback[$name][static::VALUE])->setSource('Factory settings'); $this->settings[$name] = $model; return $this; }
[ "public", "function", "loadConfigValue", "(", "$", "name", ")", "{", "$", "feConfig", "=", "$", "this", "->", "iniConfig", "->", "getFeConfig", "(", "$", "name", ")", ";", "$", "section", "=", "$", "this", "->", "feConfigFallback", "[", "$", "name", "]...
Load values of the kreXX's configuration. @param string $name The name of the config value. @return $this Return this, for chaining.
[ "Load", "values", "of", "the", "kreXX", "s", "configuration", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Config.php#L214-L253
train
brainworxx/kreXX
src/Service/Config/Config.php
Config.isRequestAjaxOrCli
protected function isRequestAjaxOrCli() { $server = $this->pool->getServer(); if (isset($server['HTTP_X_REQUESTED_WITH']) === true && strtolower($server['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest' && $this->getSetting(static::SETTING_DETECT_AJAX) === true ) { // Appending stuff after a ajax request will most likely // cause a js error. But there are moments when you actually // want to do this. // // We were supposed to detect ajax, and we did it right now. return true; } // Check for CLI. if (php_sapi_name() === 'cli') { return true; } // Still here? This means it's neither. return false; }
php
protected function isRequestAjaxOrCli() { $server = $this->pool->getServer(); if (isset($server['HTTP_X_REQUESTED_WITH']) === true && strtolower($server['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest' && $this->getSetting(static::SETTING_DETECT_AJAX) === true ) { // Appending stuff after a ajax request will most likely // cause a js error. But there are moments when you actually // want to do this. // // We were supposed to detect ajax, and we did it right now. return true; } // Check for CLI. if (php_sapi_name() === 'cli') { return true; } // Still here? This means it's neither. return false; }
[ "protected", "function", "isRequestAjaxOrCli", "(", ")", "{", "$", "server", "=", "$", "this", "->", "pool", "->", "getServer", "(", ")", ";", "if", "(", "isset", "(", "$", "server", "[", "'HTTP_X_REQUESTED_WITH'", "]", ")", "===", "true", "&&", "strtolo...
Check if the current request is an AJAX request. @return bool TRUE when this is AJAX, FALSE if not
[ "Check", "if", "the", "current", "request", "is", "an", "AJAX", "request", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Config.php#L261-L284
train
brainworxx/kreXX
src/Service/Config/Config.php
Config.isAllowedIp
protected function isAllowedIp($whitelist) { $server = $this->pool->getServer(); if (empty($server[static::REMOTE_ADDRESS]) === true) { $remote = ''; } else { $remote = $server[static::REMOTE_ADDRESS]; } $whitelist = explode(',', $whitelist); if (php_sapi_name() === 'cli' || in_array($remote, $whitelist) === true) { // Either the IP is matched, or we are in CLI return true; } // Check the wildcards. foreach ($whitelist as $ip) { $ip = trim($ip); $wildcardPos = strpos($ip, '*'); // Check if the ip has a wildcard. if ($wildcardPos !== false && substr($remote, 0, $wildcardPos) . '*' === $ip) { return true; } } return false; }
php
protected function isAllowedIp($whitelist) { $server = $this->pool->getServer(); if (empty($server[static::REMOTE_ADDRESS]) === true) { $remote = ''; } else { $remote = $server[static::REMOTE_ADDRESS]; } $whitelist = explode(',', $whitelist); if (php_sapi_name() === 'cli' || in_array($remote, $whitelist) === true) { // Either the IP is matched, or we are in CLI return true; } // Check the wildcards. foreach ($whitelist as $ip) { $ip = trim($ip); $wildcardPos = strpos($ip, '*'); // Check if the ip has a wildcard. if ($wildcardPos !== false && substr($remote, 0, $wildcardPos) . '*' === $ip) { return true; } } return false; }
[ "protected", "function", "isAllowedIp", "(", "$", "whitelist", ")", "{", "$", "server", "=", "$", "this", "->", "pool", "->", "getServer", "(", ")", ";", "if", "(", "empty", "(", "$", "server", "[", "static", "::", "REMOTE_ADDRESS", "]", ")", "===", ...
Checks if the current client ip is allowed. @author Chin Leung @see https://stackoverflow.com/questions/35559119/php-ip-address-whitelist-with-wildcards @param string $whitelist The ip whitelist. @return bool Whether the current client ip is allowed or not.
[ "Checks", "if", "the", "current", "client", "ip", "is", "allowed", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Config.php#L331-L358
train
brainworxx/kreXX
src/Service/Config/Config.php
Config.isAllowedDebugCall
public function isAllowedDebugCall($data) { // Check if the class itself is blacklisted. foreach ($this->classBlacklist as $classname) { if (is_a($data, $classname) === true) { // No debug methods for you. return false; } } // Nothing found? return true; }
php
public function isAllowedDebugCall($data) { // Check if the class itself is blacklisted. foreach ($this->classBlacklist as $classname) { if (is_a($data, $classname) === true) { // No debug methods for you. return false; } } // Nothing found? return true; }
[ "public", "function", "isAllowedDebugCall", "(", "$", "data", ")", "{", "// Check if the class itself is blacklisted.", "foreach", "(", "$", "this", "->", "classBlacklist", "as", "$", "classname", ")", "{", "if", "(", "is_a", "(", "$", "data", ",", "$", "class...
Determines if the specific class is blacklisted for debug methods. @param object $data The class we are analysing. @return bool Whether the function is allowed to be called.
[ "Determines", "if", "the", "specific", "class", "is", "blacklisted", "for", "debug", "methods", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Config/Config.php#L369-L381
train
silverorange/swat
Swat/SwatDetailsStore.php
SwatDetailsStore.__isset
public function __isset($name) { $is_set = isset($this->data[$name]); if (!$is_set && $this->base_object !== null) { $is_set = isset($this->base_object->$name); } return $is_set; }
php
public function __isset($name) { $is_set = isset($this->data[$name]); if (!$is_set && $this->base_object !== null) { $is_set = isset($this->base_object->$name); } return $is_set; }
[ "public", "function", "__isset", "(", "$", "name", ")", "{", "$", "is_set", "=", "isset", "(", "$", "this", "->", "data", "[", "$", "name", "]", ")", ";", "if", "(", "!", "$", "is_set", "&&", "$", "this", "->", "base_object", "!==", "null", ")", ...
Gets whether or not a property is set for this details store First, the manually set properties are checked. Then the properties of the base object are checked if there is a base object. @param string $name the name of the property to check. @return boolean true if the property is set for this details store and false if it is not.
[ "Gets", "whether", "or", "not", "a", "property", "is", "set", "for", "this", "details", "store" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatDetailsStore.php#L137-L146
train
silverorange/swat
Swat/Swat.php
Swat.ngettext
public static function ngettext($singular_message, $plural_message, $number) { return dngettext( self::GETTEXT_DOMAIN, $singular_message, $plural_message, $number ); }
php
public static function ngettext($singular_message, $plural_message, $number) { return dngettext( self::GETTEXT_DOMAIN, $singular_message, $plural_message, $number ); }
[ "public", "static", "function", "ngettext", "(", "$", "singular_message", ",", "$", "plural_message", ",", "$", "number", ")", "{", "return", "dngettext", "(", "self", "::", "GETTEXT_DOMAIN", ",", "$", "singular_message", ",", "$", "plural_message", ",", "$", ...
Translates a plural phrase This method should be used when a phrase depends on a number. For example, use ngettext when translating a dynamic phrase like: - "There is 1 new item" for 1 item and - "There are 2 new items" for 2 or more items. This method relies on the php gettext extension and uses dngettext() internally. @param string $singular_message the message to use when the number the phrase depends on is one. @param string $plural_message the message to use when the number the phrase depends on is more than one. @param integer $number the number the phrase depends on. @return string the translated phrase.
[ "Translates", "a", "plural", "phrase" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/Swat.php#L89-L97
train
silverorange/swat
Swat/Swat.php
Swat.displayMethods
public static function displayMethods($object) { echo sprintf(self::_('Methods for class %s:'), get_class($object)); echo '<ul>'; foreach (get_class_methods(get_class($object)) as $method_name) { echo '<li>', $method_name, '</li>'; } echo '</ul>'; }
php
public static function displayMethods($object) { echo sprintf(self::_('Methods for class %s:'), get_class($object)); echo '<ul>'; foreach (get_class_methods(get_class($object)) as $method_name) { echo '<li>', $method_name, '</li>'; } echo '</ul>'; }
[ "public", "static", "function", "displayMethods", "(", "$", "object", ")", "{", "echo", "sprintf", "(", "self", "::", "_", "(", "'Methods for class %s:'", ")", ",", "get_class", "(", "$", "object", ")", ")", ";", "echo", "'<ul>'", ";", "foreach", "(", "g...
Displays the methods of an object This is useful for debugging. @param mixed $object the object whose methods are to be displayed.
[ "Displays", "the", "methods", "of", "an", "object" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/Swat.php#L123-L133
train
silverorange/swat
Swat/Swat.php
Swat.displayProperties
public static function displayProperties($object) { $class = get_class($object); echo sprintf(self::_('Properties for class %s:'), $class); echo '<ul>'; foreach (get_class_vars($class) as $property_name => $value) { $instance_value = $object->$property_name; echo '<li>', $property_name, ' = ', $instance_value, '</li>'; } echo '</ul>'; }
php
public static function displayProperties($object) { $class = get_class($object); echo sprintf(self::_('Properties for class %s:'), $class); echo '<ul>'; foreach (get_class_vars($class) as $property_name => $value) { $instance_value = $object->$property_name; echo '<li>', $property_name, ' = ', $instance_value, '</li>'; } echo '</ul>'; }
[ "public", "static", "function", "displayProperties", "(", "$", "object", ")", "{", "$", "class", "=", "get_class", "(", "$", "object", ")", ";", "echo", "sprintf", "(", "self", "::", "_", "(", "'Properties for class %s:'", ")", ",", "$", "class", ")", ";...
Displays the properties of an object This is useful for debugging. @param mixed $object the object whose properties are to be displayed.
[ "Displays", "the", "properties", "of", "an", "object" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/Swat.php#L145-L158
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.query
public static function query( $db, $sql, $wrapper = 'SwatDBDefaultRecordsetWrapper', $types = null ) { $mdb2_types = $types === null ? true : $types; $rs = self::executeQuery($db, 'query', array( $sql, $mdb2_types, true, false )); // Wrap results. Do it here instead of in MDB2 so we can wrap using // an existing object instance. if (is_string($wrapper)) { $rs = new $wrapper($rs); } elseif ($wrapper instanceof SwatDBRecordsetWrapper) { $wrapper->initializeFromResultSet($rs); $rs = $wrapper; } return $rs; }
php
public static function query( $db, $sql, $wrapper = 'SwatDBDefaultRecordsetWrapper', $types = null ) { $mdb2_types = $types === null ? true : $types; $rs = self::executeQuery($db, 'query', array( $sql, $mdb2_types, true, false )); // Wrap results. Do it here instead of in MDB2 so we can wrap using // an existing object instance. if (is_string($wrapper)) { $rs = new $wrapper($rs); } elseif ($wrapper instanceof SwatDBRecordsetWrapper) { $wrapper->initializeFromResultSet($rs); $rs = $wrapper; } return $rs; }
[ "public", "static", "function", "query", "(", "$", "db", ",", "$", "sql", ",", "$", "wrapper", "=", "'SwatDBDefaultRecordsetWrapper'", ",", "$", "types", "=", "null", ")", "{", "$", "mdb2_types", "=", "$", "types", "===", "null", "?", "true", ":", "$",...
Performs an SQL query @param MDB2_Driver_Common $db the database connection. @param string $sql the SQL to execute. @param string|SwatDBRecordsetWrapper $wrapper optional. The object or name of class with which to wrap the result set. If not specified, {@link SwatDBDefaultRecordsetWrapper} is used. Specify <kbd>null</kbd> to return an unwrapped MDB2 result. @param array $types optional. An array of MDB2 datatypes for the columns of the result set. @return mixed A recordset containing the query result. If <i>$wrapper</i> is specified as null, a MDB2_Result_Common object is returned. @throws SwatDBException
[ "Performs", "an", "SQL", "query" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L87-L112
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.updateColumn
public static function updateColumn( $db, $table, $field, $value, $id_field, $ids, $where = null ) { $ids = self::initArray($ids); if (count($ids) === 0) { return; } $field = new SwatDBField($field, 'integer'); $id_field = new SwatDBField($id_field, 'integer'); $sql = 'update %s set %s = %s where %s in (%s) %s'; foreach ($ids as &$id) { $id = $db->quote($id, $id_field->type); } $id_list = implode(',', $ids); $where = $where === null ? '' : 'and ' . $where; $sql = sprintf( $sql, $table, $field->name, $db->quote($value, $field->type), $id_field->name, $id_list, $where ); return self::exec($db, $sql); }
php
public static function updateColumn( $db, $table, $field, $value, $id_field, $ids, $where = null ) { $ids = self::initArray($ids); if (count($ids) === 0) { return; } $field = new SwatDBField($field, 'integer'); $id_field = new SwatDBField($id_field, 'integer'); $sql = 'update %s set %s = %s where %s in (%s) %s'; foreach ($ids as &$id) { $id = $db->quote($id, $id_field->type); } $id_list = implode(',', $ids); $where = $where === null ? '' : 'and ' . $where; $sql = sprintf( $sql, $table, $field->name, $db->quote($value, $field->type), $id_field->name, $id_list, $where ); return self::exec($db, $sql); }
[ "public", "static", "function", "updateColumn", "(", "$", "db", ",", "$", "table", ",", "$", "field", ",", "$", "value", ",", "$", "id_field", ",", "$", "ids", ",", "$", "where", "=", "null", ")", "{", "$", "ids", "=", "self", "::", "initArray", ...
Update a column Convenience method to update a single database field for one or more rows. One convenient use of this method is for processing {@link SwatAction}s that change a single database field. @param MDB2_Driver_Common $db The database connection. @param string $table The database table to query. @param string $field The name of the database field to update. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param mixed $value The value to store in database field $field. The type should correspond to the type of $field. @param string $id_field The name of the database field that contains the the id. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param array $ids An array of identifiers corresponding to the database rows to be updated. The type of the individual identifiers should correspond to the type of $id_field. @param string $where An optional additional where clause. @return integer the number of rows updated. @throws SwatDBException
[ "Update", "a", "column" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L172-L211
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.queryColumn
public static function queryColumn( $db, $table, $field, $id_field = null, $id = 0 ) { $field = new SwatDBField($field, 'integer'); if ($id_field == null) { $sql = 'select %s from %s'; $sql = sprintf($sql, $field->name, $table); } else { $id_field = new SwatDBField($id_field, 'integer'); $sql = 'select %s from %s where %s = %s'; $sql = sprintf( $sql, $field->name, $table, $id_field->name, $db->quote($id, $id_field->type) ); } $values = self::executeQuery($db, 'queryCol', array( $sql, $field->type )); return $values; }
php
public static function queryColumn( $db, $table, $field, $id_field = null, $id = 0 ) { $field = new SwatDBField($field, 'integer'); if ($id_field == null) { $sql = 'select %s from %s'; $sql = sprintf($sql, $field->name, $table); } else { $id_field = new SwatDBField($id_field, 'integer'); $sql = 'select %s from %s where %s = %s'; $sql = sprintf( $sql, $field->name, $table, $id_field->name, $db->quote($id, $id_field->type) ); } $values = self::executeQuery($db, 'queryCol', array( $sql, $field->type )); return $values; }
[ "public", "static", "function", "queryColumn", "(", "$", "db", ",", "$", "table", ",", "$", "field", ",", "$", "id_field", "=", "null", ",", "$", "id", "=", "0", ")", "{", "$", "field", "=", "new", "SwatDBField", "(", "$", "field", ",", "'integer'"...
Query a column Convenience method to query for values in a single database column. One convenient use of this method is for loading values from a binding table. @param MDB2_Driver_Common $db The database connection. @param string $table The database table to query. @param string $field The name of the database field to query. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param string $id_field The name of the database field that contains the the id. If not null this will be used to construct a where clause to limit results. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param mixed $id The value to look for in the $id_field. The type should correspond to the type of $id_field. @return array An associative array of $id_field => $field @throws SwatDBException
[ "Query", "a", "column" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L245-L275
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.queryOne
public static function queryOne($db, $sql, $type = null) { $mdb2_type = $type === null ? true : $type; return self::executeQuery($db, 'queryOne', array($sql, $mdb2_type)); }
php
public static function queryOne($db, $sql, $type = null) { $mdb2_type = $type === null ? true : $type; return self::executeQuery($db, 'queryOne', array($sql, $mdb2_type)); }
[ "public", "static", "function", "queryOne", "(", "$", "db", ",", "$", "sql", ",", "$", "type", "=", "null", ")", "{", "$", "mdb2_type", "=", "$", "type", "===", "null", "?", "true", ":", "$", "type", ";", "return", "self", "::", "executeQuery", "("...
Query a single value Convenience method to query a single value in a single database column. @param MDB2_Driver_Common $db The database connection. @param string $sql The SQL to execute. @param string $type Optional MDB2 datatype for the result. @return mixed The value queried for a single result. Null when there are no results. @throws SwatDBException
[ "Query", "a", "single", "value" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L294-L298
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.queryRow
public static function queryRow($db, $sql, $types = null) { $mdb2_types = $types === null ? true : $types; $row = self::executeQuery($db, 'queryRow', array( $sql, $mdb2_types, MDB2_FETCHMODE_OBJECT )); return $row; }
php
public static function queryRow($db, $sql, $types = null) { $mdb2_types = $types === null ? true : $types; $row = self::executeQuery($db, 'queryRow', array( $sql, $mdb2_types, MDB2_FETCHMODE_OBJECT )); return $row; }
[ "public", "static", "function", "queryRow", "(", "$", "db", ",", "$", "sql", ",", "$", "types", "=", "null", ")", "{", "$", "mdb2_types", "=", "$", "types", "===", "null", "?", "true", ":", "$", "types", ";", "$", "row", "=", "self", "::", "execu...
Query a single row Convenience method to query for a single row from a database table. @param MDB2_Driver_Common $db The database connection. @param string $sql The SQL to execute. @param array $types Optional array of MDB2 datatypes for the result. @return Object A row object, or null. @throws SwatDBException
[ "Query", "a", "single", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L316-L327
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.queryOneFromTable
public static function queryOneFromTable( $db, $table, $field, $id_field = null, $id = 0 ) { $field = new SwatDBField($field, 'integer'); if ($id_field == null) { $sql = 'select %s from %s'; $sql = sprintf($sql, $field->name, $table); } else { $id_field = new SwatDBField($id_field, 'integer'); $sql = 'select %s from %s where %s = %s'; $sql = sprintf( $sql, $field->name, $table, $id_field->name, $db->quote($id, $id_field->type) ); } $value = self::queryOne($db, $sql, $field->type); return $value; }
php
public static function queryOneFromTable( $db, $table, $field, $id_field = null, $id = 0 ) { $field = new SwatDBField($field, 'integer'); if ($id_field == null) { $sql = 'select %s from %s'; $sql = sprintf($sql, $field->name, $table); } else { $id_field = new SwatDBField($id_field, 'integer'); $sql = 'select %s from %s where %s = %s'; $sql = sprintf( $sql, $field->name, $table, $id_field->name, $db->quote($id, $id_field->type) ); } $value = self::queryOne($db, $sql, $field->type); return $value; }
[ "public", "static", "function", "queryOneFromTable", "(", "$", "db", ",", "$", "table", ",", "$", "field", ",", "$", "id_field", "=", "null", ",", "$", "id", "=", "0", ")", "{", "$", "field", "=", "new", "SwatDBField", "(", "$", "field", ",", "'int...
Query a single value from a specified table and column Convenience method to query a single value in a single database column. @param MDB2_Driver_Common $db The database connection. @param string $table The database table to query. @param string $field The name of the database field to query. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param string $id_field The name of the database field that contains the the id. If not null this will be used to construct a where clause to limit results. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param mixed $id The value to look for in the $id_field. The type should correspond to the type of $id_field. @return mixed The value queried for a single result. @throws SwatDBException
[ "Query", "a", "single", "value", "from", "a", "specified", "table", "and", "column" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L359-L386
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.queryRowFromTable
public static function queryRowFromTable( $db, $table, $fields, $id_field, $id ) { self::initFields($fields); $id_field = new SwatDBField($id_field, 'integer'); $sql = 'select %s from %s where %s = %s'; $field_list = implode(',', self::getFieldNameArray($fields)); $sql = sprintf( $sql, $field_list, $table, $id_field->name, $db->quote($id, $id_field->type) ); $rs = self::query($db, $sql, null); $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT); if (MDB2::isError($row)) { throw new SwatDBException($row); } return $row; }
php
public static function queryRowFromTable( $db, $table, $fields, $id_field, $id ) { self::initFields($fields); $id_field = new SwatDBField($id_field, 'integer'); $sql = 'select %s from %s where %s = %s'; $field_list = implode(',', self::getFieldNameArray($fields)); $sql = sprintf( $sql, $field_list, $table, $id_field->name, $db->quote($id, $id_field->type) ); $rs = self::query($db, $sql, null); $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT); if (MDB2::isError($row)) { throw new SwatDBException($row); } return $row; }
[ "public", "static", "function", "queryRowFromTable", "(", "$", "db", ",", "$", "table", ",", "$", "fields", ",", "$", "id_field", ",", "$", "id", ")", "{", "self", "::", "initFields", "(", "$", "fields", ")", ";", "$", "id_field", "=", "new", "SwatDB...
Query a single row from a specified table and column Convenience method to query for a single row from a database table. One convenient use of this method is for loading data on an edit page. @param MDB2_Driver_Common $db The database connection. @param string $table The database table to query. @param array $fields An array of fields to be queried. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then text is assummed. @param string $id_field The name of the database field that contains the the id. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param mixed $id The value to look for in the id field column. The type should correspond to the type of $field. @return Object A row object. @throws SwatDBException
[ "Query", "a", "single", "row", "from", "a", "specified", "table", "and", "column" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L417-L445
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.executeStoredProc
public static function executeStoredProc( $db, $proc, $params, $wrapper = 'SwatDBDefaultRecordsetWrapper', $types = null ) { if (!is_array($params)) { $params = array($params); } $mdb2_types = $types === null ? true : $types; $db->loadModule('Function'); $rs = $db->function->executeStoredProc( $proc, $params, $mdb2_types, true, false ); if (MDB2::isError($rs)) { throw new SwatDBException($rs); } // Wrap results. Do it here instead of in MDB2 so we can wrap using // an existing object instance. if (is_string($wrapper)) { $rs = new $wrapper($rs); } elseif ($wrapper instanceof SwatDBRecordsetWrapper) { $wrapper->initializeFromResultSet($rs); $rs = $wrapper; } return $rs; }
php
public static function executeStoredProc( $db, $proc, $params, $wrapper = 'SwatDBDefaultRecordsetWrapper', $types = null ) { if (!is_array($params)) { $params = array($params); } $mdb2_types = $types === null ? true : $types; $db->loadModule('Function'); $rs = $db->function->executeStoredProc( $proc, $params, $mdb2_types, true, false ); if (MDB2::isError($rs)) { throw new SwatDBException($rs); } // Wrap results. Do it here instead of in MDB2 so we can wrap using // an existing object instance. if (is_string($wrapper)) { $rs = new $wrapper($rs); } elseif ($wrapper instanceof SwatDBRecordsetWrapper) { $wrapper->initializeFromResultSet($rs); $rs = $wrapper; } return $rs; }
[ "public", "static", "function", "executeStoredProc", "(", "$", "db", ",", "$", "proc", ",", "$", "params", ",", "$", "wrapper", "=", "'SwatDBDefaultRecordsetWrapper'", ",", "$", "types", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "param...
Performs a stored procedure @param MDB2_Driver_Common $db the database connection. @param string $proc the name of the stored procedure to execute. @param mixed $params the parameters to pass to the stored procedure. Use an array for more than one parameter. @param string|SwatDBRecordsetWrapper $wrapper optional. The object or name of class with which to wrap the result set. If not specified, {@link SwatDBDefaultRecordsetWrapper} is used. Specify <kbd>null</kbd> to return an unwrapped MDB2 result. @param array $types optional. An array of MDB2 datatypes for the columns of the result set. @return mixed A recordset containing the query result. If <i>$wrapper</i> is specified as null, a MDB2_Result_Common object is returned. @throws SwatDBException
[ "Performs", "a", "stored", "procedure" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L478-L514
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.executeStoredProcOne
public static function executeStoredProcOne($db, $proc, $params) { if (!is_array($params)) { $params = array($params); } $rs = self::executeStoredProc($db, $proc, $params); $row = $rs->getFirst(); return current($row); }
php
public static function executeStoredProcOne($db, $proc, $params) { if (!is_array($params)) { $params = array($params); } $rs = self::executeStoredProc($db, $proc, $params); $row = $rs->getFirst(); return current($row); }
[ "public", "static", "function", "executeStoredProcOne", "(", "$", "db", ",", "$", "proc", ",", "$", "params", ")", "{", "if", "(", "!", "is_array", "(", "$", "params", ")", ")", "{", "$", "params", "=", "array", "(", "$", "params", ")", ";", "}", ...
Execute a stored procedure that returns a single value Convenience method to execute a stored procedure that returns a single value. @param MDB2_Driver_Common $db The database connection. @param string $proc The name of the stored procedure to execute. @param mixed $params The parameters to pass to the stored procedure. Use an array for more than one parameter. @return mixed The value returned by the stored procedure. @throws SwatDBException
[ "Execute", "a", "stored", "procedure", "that", "returns", "a", "single", "value" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L536-L545
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.updateBinding
public static function updateBinding( $db, $table, $id_field, $id, $value_field, $values, $bound_table, $bound_field ) { $id_field = new SwatDBField($id_field, 'integer'); $value_field = new SwatDBField($value_field, 'integer'); $bound_field = new SwatDBField($bound_field, 'integer'); $values = self::initArray($values); $delete_sql = 'delete from %s where %s = %s'; $delete_sql = sprintf( $delete_sql, $table, $id_field->name, $db->quote($id, $id_field->type) ); if (count($values)) { foreach ($values as &$value) { $value = $db->quote($value, $value_field->type); } $value_list = implode(',', $values); $insert_sql = 'insert into %s (%s, %s) select %s, %s from %s ' . 'where %s not in (select %s from %s where %s = %s) and %s in (%s)'; $insert_sql = sprintf( $insert_sql, $table, $id_field->name, $value_field->name, $db->quote($id, $id_field->type), $bound_field->name, $bound_table, $bound_field->name, $value_field->name, $table, $id_field->name, $db->quote($id, $id_field->type), $bound_field->name, $value_list ); $delete_sql .= sprintf( ' and %s not in (%s)', $value_field->name, $value_list ); } $transaction = new SwatDBTransaction($db); try { if (count($values)) { self::exec($db, $insert_sql); } self::exec($db, $delete_sql); } catch (Exception $e) { $transaction->rollback(); throw $e; } $transaction->commit(); }
php
public static function updateBinding( $db, $table, $id_field, $id, $value_field, $values, $bound_table, $bound_field ) { $id_field = new SwatDBField($id_field, 'integer'); $value_field = new SwatDBField($value_field, 'integer'); $bound_field = new SwatDBField($bound_field, 'integer'); $values = self::initArray($values); $delete_sql = 'delete from %s where %s = %s'; $delete_sql = sprintf( $delete_sql, $table, $id_field->name, $db->quote($id, $id_field->type) ); if (count($values)) { foreach ($values as &$value) { $value = $db->quote($value, $value_field->type); } $value_list = implode(',', $values); $insert_sql = 'insert into %s (%s, %s) select %s, %s from %s ' . 'where %s not in (select %s from %s where %s = %s) and %s in (%s)'; $insert_sql = sprintf( $insert_sql, $table, $id_field->name, $value_field->name, $db->quote($id, $id_field->type), $bound_field->name, $bound_table, $bound_field->name, $value_field->name, $table, $id_field->name, $db->quote($id, $id_field->type), $bound_field->name, $value_list ); $delete_sql .= sprintf( ' and %s not in (%s)', $value_field->name, $value_list ); } $transaction = new SwatDBTransaction($db); try { if (count($values)) { self::exec($db, $insert_sql); } self::exec($db, $delete_sql); } catch (Exception $e) { $transaction->rollback(); throw $e; } $transaction->commit(); }
[ "public", "static", "function", "updateBinding", "(", "$", "db", ",", "$", "table", ",", "$", "id_field", ",", "$", "id", ",", "$", "value_field", ",", "$", "values", ",", "$", "bound_table", ",", "$", "bound_field", ")", "{", "$", "id_field", "=", "...
Update a binding table Convenience method to update rows in a binding table. It will delete and insert rows as necessary. @param MDB2_Driver_Common $db The database connection. @param string $table The binding table to update. @param string $id_field The name of the binding table field that contains the fixed value. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param mixed $id The value to store in the $id_field. The type should correspond to the type of $id_field. @param string $value_field The name of the binding table field that contains the values from the bound table. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param array $values An array of values that should be stored in the $value_field. The type of the individual values should correspond to the type of $value_field. @param string $bound_table The table bound through the binding table. @param string $bound_field The database field in the bound table that the binding table references. @throws SwatDBException
[ "Update", "a", "binding", "table" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L584-L656
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.updateRow
public static function updateRow( $db, $table, $fields, $values, $id_field, $id ) { self::initFields($fields); $id_field = new SwatDBField($id_field, 'integer'); $sql = 'update %s set %s where %s = %s'; $updates = array(); foreach ($fields as &$field) { $value = isset($values[$field->name]) ? $values[$field->name] : null; $updates[] = sprintf( '%s = %s', $field->name, $db->quote($value, $field->type) ); } $update_list = implode(',', $updates); $sql = sprintf( $sql, $table, $update_list, $id_field->name, $db->quote($id, $id_field->type) ); self::exec($db, $sql); }
php
public static function updateRow( $db, $table, $fields, $values, $id_field, $id ) { self::initFields($fields); $id_field = new SwatDBField($id_field, 'integer'); $sql = 'update %s set %s where %s = %s'; $updates = array(); foreach ($fields as &$field) { $value = isset($values[$field->name]) ? $values[$field->name] : null; $updates[] = sprintf( '%s = %s', $field->name, $db->quote($value, $field->type) ); } $update_list = implode(',', $updates); $sql = sprintf( $sql, $table, $update_list, $id_field->name, $db->quote($id, $id_field->type) ); self::exec($db, $sql); }
[ "public", "static", "function", "updateRow", "(", "$", "db", ",", "$", "table", ",", "$", "fields", ",", "$", "values", ",", "$", "id_field", ",", "$", "id", ")", "{", "self", "::", "initFields", "(", "$", "fields", ")", ";", "$", "id_field", "=", ...
Update a row Convenience method to update multiple fields of a single database row. One convenient use of this method is for save data on an edit page. @param MDB2_Driver_Common $db The database connection. @param string $table The database table to update. @param array $fields An array of fields to be updated. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then text is assummed. @param array $values An associative array of values to store in the database. The array keys should correspond to field names. The type of the individual values should correspond to the field type. @param string $id_field The name of the database field that contains an identifier of row to be updated. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param mixed $id The value to look for in the $id_field column. The type should correspond to the type of $field. @throws SwatDBException
[ "Update", "a", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L776-L812
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.deleteRow
public static function deleteRow($db, $table, $id_field, $id) { $id_field = new SwatDBField($id_field, 'integer'); $sql = 'delete from %s where %s = %s'; $sql = sprintf( $sql, $table, $id_field->name, $db->quote($id, $id_field->type) ); self::exec($db, $sql); }
php
public static function deleteRow($db, $table, $id_field, $id) { $id_field = new SwatDBField($id_field, 'integer'); $sql = 'delete from %s where %s = %s'; $sql = sprintf( $sql, $table, $id_field->name, $db->quote($id, $id_field->type) ); self::exec($db, $sql); }
[ "public", "static", "function", "deleteRow", "(", "$", "db", ",", "$", "table", ",", "$", "id_field", ",", "$", "id", ")", "{", "$", "id_field", "=", "new", "SwatDBField", "(", "$", "id_field", ",", "'integer'", ")", ";", "$", "sql", "=", "'delete fr...
Delete a row Convenience method to delete a single database row. @param MDB2_Driver_Common $db The database connection. @param string $table The database table to delete from. @param string $id_field The name of the database field that contains an identifier of row to be deleted. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param mixed $id The value to look for in the $id_field column. The type should correspond to the type of $field. @throws SwatDBException
[ "Delete", "a", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L836-L849
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.getCascadeOptionArray
public static function getCascadeOptionArray( $db, $table, $title_field, $id_field, $cascade_field, $order_by_clause = null, $where_clause = null ) { $title_field = new SwatDBField($title_field, 'text'); $id_field = new SwatDBField($id_field, 'integer'); $cascade_field = new SwatDBField($cascade_field, 'integer'); $sql = 'select %s, %s, %s from %s'; $sql = sprintf( $sql, $id_field->name, $title_field->name, $cascade_field->name, $table ); if ($where_clause !== null) { $sql .= ' where ' . $where_clause; } $sql .= ' order by ' . $cascade_field->name; if ($order_by_clause !== null) { $sql .= ', ' . $order_by_clause; } $rs = self::query($db, $sql, null); $options = array(); $current = null; $title_field_name = $title_field->name; $id_field_name = $id_field->name; $cascade_field_name = $cascade_field->name; $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT); while ($row) { if (MDB2::isError($row)) { throw new SwatDBException($row); } if ($row->$cascade_field_name != $current) { $current = $row->$cascade_field_name; $options[$current] = array(); } $options[$current][$row->$id_field_name] = $row->$title_field_name; $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT); } return $options; }
php
public static function getCascadeOptionArray( $db, $table, $title_field, $id_field, $cascade_field, $order_by_clause = null, $where_clause = null ) { $title_field = new SwatDBField($title_field, 'text'); $id_field = new SwatDBField($id_field, 'integer'); $cascade_field = new SwatDBField($cascade_field, 'integer'); $sql = 'select %s, %s, %s from %s'; $sql = sprintf( $sql, $id_field->name, $title_field->name, $cascade_field->name, $table ); if ($where_clause !== null) { $sql .= ' where ' . $where_clause; } $sql .= ' order by ' . $cascade_field->name; if ($order_by_clause !== null) { $sql .= ', ' . $order_by_clause; } $rs = self::query($db, $sql, null); $options = array(); $current = null; $title_field_name = $title_field->name; $id_field_name = $id_field->name; $cascade_field_name = $cascade_field->name; $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT); while ($row) { if (MDB2::isError($row)) { throw new SwatDBException($row); } if ($row->$cascade_field_name != $current) { $current = $row->$cascade_field_name; $options[$current] = array(); } $options[$current][$row->$id_field_name] = $row->$title_field_name; $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT); } return $options; }
[ "public", "static", "function", "getCascadeOptionArray", "(", "$", "db", ",", "$", "table", ",", "$", "title_field", ",", "$", "id_field", ",", "$", "cascade_field", ",", "$", "order_by_clause", "=", "null", ",", "$", "where_clause", "=", "null", ")", "{",...
Query for an option array cascaded by a field Convenience method to query for a set of options, each consisting of an id, title, and a group-by field. The returned option array in the form of $cascade => array($id => $title, $id => $title) can be passed directly to other classes, such as {@link SwatCascade} for example. @param MDB2_Driver_Common $db The database connection. @param string $table The database table to query. @param string $title_field The name of the database field to query for the title. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then text is assummed for this field. @param string $id_field The name of the database field to query for the id. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param string $cascade_field The name of the database field to cascade the options by. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param string $order_by_clause Optional comma deliminated list of database field names to use in the <i>order by</i> clause. Do not include "order by" in the string; only include the list of field names. Pass null to skip over this paramater. @param string $where_clause Optional <i>where</i> clause to limit the returned results. Do not include "where" in the string; only include the conditionals. @return array An array in the form of $id => $title. @throws SwatDBException
[ "Query", "for", "an", "option", "array", "cascaded", "by", "a", "field" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L973-L1028
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.getGroupedOptionArray
public static function getGroupedOptionArray( $db, $table, $title_field, $id_field, $group_table, $group_title_field, $group_id_field, $group_field, $order_by_clause = null, $where_clause = null, $tree = null ) { $title_field = new SwatDBField($title_field, 'text'); $id_field = new SwatDBField($id_field, 'integer'); $group_title_field = new SwatDBField($group_title_field, 'text'); $group_id_field = new SwatDBField($group_id_field, 'integer'); $group_field = new SwatDBField($group_field, 'text'); $sql = 'select %s as id, %s as title, %s as group_title, %s as group_id from %s'; $sql = sprintf( $sql, "{$table}.{$id_field->name}", "{$table}.{$title_field->name}", "{$group_table}.{$group_title_field->name}", "{$group_table}.{$group_id_field->name}", $table ); $sql .= ' inner join %s on %s = %s'; $sql = sprintf( $sql, $group_table, "{$group_table}.{$group_id_field->name}", "{$table}.{$group_field->name}" ); if ($where_clause != null) { $sql .= ' where ' . $where_clause; } if ($order_by_clause != null) { $sql .= ' order by ' . $order_by_clause; } $rs = self::query($db, $sql, null); $options = array(); if ($tree !== null && $tree instanceof SwatDataTreeNode) { $base_parent = $tree; } else { $base_parent = new SwatDataTreeNode(null, Swat::_('Root')); } $current_group = null; $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT); while ($row) { if ($current_group !== $row->group_id) { $current_parent = new SwatDataTreeNode(null, $row->group_title); $base_parent->addChild($current_parent); $current_group = $row->group_id; } $current_parent->addChild( new SwatDataTreeNode($row->id, $row->title) ); $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT); } return $base_parent; }
php
public static function getGroupedOptionArray( $db, $table, $title_field, $id_field, $group_table, $group_title_field, $group_id_field, $group_field, $order_by_clause = null, $where_clause = null, $tree = null ) { $title_field = new SwatDBField($title_field, 'text'); $id_field = new SwatDBField($id_field, 'integer'); $group_title_field = new SwatDBField($group_title_field, 'text'); $group_id_field = new SwatDBField($group_id_field, 'integer'); $group_field = new SwatDBField($group_field, 'text'); $sql = 'select %s as id, %s as title, %s as group_title, %s as group_id from %s'; $sql = sprintf( $sql, "{$table}.{$id_field->name}", "{$table}.{$title_field->name}", "{$group_table}.{$group_title_field->name}", "{$group_table}.{$group_id_field->name}", $table ); $sql .= ' inner join %s on %s = %s'; $sql = sprintf( $sql, $group_table, "{$group_table}.{$group_id_field->name}", "{$table}.{$group_field->name}" ); if ($where_clause != null) { $sql .= ' where ' . $where_clause; } if ($order_by_clause != null) { $sql .= ' order by ' . $order_by_clause; } $rs = self::query($db, $sql, null); $options = array(); if ($tree !== null && $tree instanceof SwatDataTreeNode) { $base_parent = $tree; } else { $base_parent = new SwatDataTreeNode(null, Swat::_('Root')); } $current_group = null; $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT); while ($row) { if ($current_group !== $row->group_id) { $current_parent = new SwatDataTreeNode(null, $row->group_title); $base_parent->addChild($current_parent); $current_group = $row->group_id; } $current_parent->addChild( new SwatDataTreeNode($row->id, $row->title) ); $row = $rs->fetchRow(MDB2_FETCHMODE_OBJECT); } return $base_parent; }
[ "public", "static", "function", "getGroupedOptionArray", "(", "$", "db", ",", "$", "table", ",", "$", "title_field", ",", "$", "id_field", ",", "$", "group_table", ",", "$", "group_title_field", ",", "$", "group_id_field", ",", "$", "group_field", ",", "$", ...
Queries for a grouped option array Convenience method to query a grouped list of {@link SwatDataTreeNode} objects used for things like {@link SwatCheckboxList} where checkboxes are grouped together under a title. @param MDB2_Driver_Common $db The database connection. @param string $table The database table to query. @param string $title_field The name of the database field to query for the title. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then text is assummed for this field. @param string $id_field The name of the database field to query for the id. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param string $group_table The database table that the group titles come from. @param string $group_idfield The name of the database field to query for the id of the $group_table. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param string $group_title_field The name of the database field to query for the group title. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then text is assummed for this field. @param string $group_field The name of the database field in $table that links with the $group_idfield. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then integer is assummed for this field. @param string $order_by_clause Optional comma deliminated list of database field names to use in the <i>order by</i> clause. Do not include "order by" in the string; only include the list of field names. Pass null to skip over this paramater. @param string $where_clause Optional <i>where</i> clause to limit the returned results. Do not include "where" in the string; only include the conditionals. @param SwatDataTreeNode $tree a tree to add nodes to. If no tree is specified, nodes are added to a new empty tree. @return SwatDataTreeNode a tree composed of {@link SwatDataTreeNode} objects. @throws SwatDBException
[ "Queries", "for", "a", "grouped", "option", "array" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L1089-L1164
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.getFieldMax
public static function getFieldMax($db, $table, $field) { $field = new SwatDBField($field, 'integer'); $sql = sprintf( 'select max(%s) as %s from %s', $field->name, $field->name, $table ); return self::queryOne($db, $sql); }
php
public static function getFieldMax($db, $table, $field) { $field = new SwatDBField($field, 'integer'); $sql = sprintf( 'select max(%s) as %s from %s', $field->name, $field->name, $table ); return self::queryOne($db, $sql); }
[ "public", "static", "function", "getFieldMax", "(", "$", "db", ",", "$", "table", ",", "$", "field", ")", "{", "$", "field", "=", "new", "SwatDBField", "(", "$", "field", ",", "'integer'", ")", ";", "$", "sql", "=", "sprintf", "(", "'select max(%s) as ...
Get max field value Convenience method to grab the max value from a single field. @param MDB2_Driver_Common $db The database connection. @param string $table The database table to update. @param string $field The field to be return the max value of. Can be given in the form type:name where type is a standard MDB2 datatype. If type is ommitted, then text is assummed. @return mixed The max value of field specified. @throws SwatDBException
[ "Get", "max", "field", "value" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L1186-L1198
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.equalityOperator
public static function equalityOperator($value, $neg = false) { if ($value === null && $neg) { return 'is not'; } elseif ($value === null) { return 'is'; } elseif ($neg) { return '!='; } else { return '='; } }
php
public static function equalityOperator($value, $neg = false) { if ($value === null && $neg) { return 'is not'; } elseif ($value === null) { return 'is'; } elseif ($neg) { return '!='; } else { return '='; } }
[ "public", "static", "function", "equalityOperator", "(", "$", "value", ",", "$", "neg", "=", "false", ")", "{", "if", "(", "$", "value", "===", "null", "&&", "$", "neg", ")", "{", "return", "'is not'", ";", "}", "elseif", "(", "$", "value", "===", ...
Get proper conditional operator Convenience method to return proper operators for database values that may be null. @param mixed $value The value to check for null on @param boolean $neg Whether to return the operator for a negative comparison @return string SQL operator
[ "Get", "proper", "conditional", "operator" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L1216-L1227
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.getDataTree
public static function getDataTree( $rs, $title_field_name, $id_field_name, $level_field_name, $tree = null ) { $stack = array(); if ($tree !== null && $tree instanceof SwatDataTreeNode) { $current_parent = $tree; } else { $current_parent = new SwatDataTreeNode('', Swat::_('Root')); } $base_parent = $current_parent; array_push($stack, $current_parent); $last_node = $current_parent; foreach ($rs as $row) { $title = $row->$title_field_name; $id = $row->$id_field_name; $level = $row->$level_field_name; if ($level > count($stack)) { array_push($stack, $current_parent); $current_parent = $last_node; } elseif ($level < count($stack)) { $current_parent = array_pop($stack); } $last_node = new SwatDataTreeNode($id, $title); $current_parent->addChild($last_node); } return $base_parent; }
php
public static function getDataTree( $rs, $title_field_name, $id_field_name, $level_field_name, $tree = null ) { $stack = array(); if ($tree !== null && $tree instanceof SwatDataTreeNode) { $current_parent = $tree; } else { $current_parent = new SwatDataTreeNode('', Swat::_('Root')); } $base_parent = $current_parent; array_push($stack, $current_parent); $last_node = $current_parent; foreach ($rs as $row) { $title = $row->$title_field_name; $id = $row->$id_field_name; $level = $row->$level_field_name; if ($level > count($stack)) { array_push($stack, $current_parent); $current_parent = $last_node; } elseif ($level < count($stack)) { $current_parent = array_pop($stack); } $last_node = new SwatDataTreeNode($id, $title); $current_parent->addChild($last_node); } return $base_parent; }
[ "public", "static", "function", "getDataTree", "(", "$", "rs", ",", "$", "title_field_name", ",", "$", "id_field_name", ",", "$", "level_field_name", ",", "$", "tree", "=", "null", ")", "{", "$", "stack", "=", "array", "(", ")", ";", "if", "(", "$", ...
Get a tree of data nodes Convenience method to take a structured query with each row consisting of an id, levelnum, and a title, and turning it into a tree of {@link SwatDataTreeNode} objects. The returned option array in the form of a collection of {@link SwatDataTreeNode} objects can be used by other classes, such as {@link SwatTreeFlydown} and {@link @SwatChecklistTree}. @param MDB2_Driver_Common $rs The MDB2 result set, usually the result of a stored procedure. Must be wrapped in . {@link SwatDBRecordsetWrapper}. @param string $title_field_name The name of the database field representing the title @param string $idfield_field_name The name of the database field representing the id @param string $level_field_name the name of the database field representing the tree level. @param SwatDataTreeNode $tree an optional tree to add nodes to. If no tree is specified, nodes are added to a new empty tree. @return SwatDataTreeNode a tree composed of {@link SwatDataTreeNode} objects. @throws SwatDBException
[ "Get", "a", "tree", "of", "data", "nodes" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L1259-L1294
train
silverorange/swat
SwatDB/SwatDB.php
SwatDB.implodeSelection
public static function implodeSelection( MDB2_Driver_Common $db, SwatViewSelection $selection, $type = 'integer' ) { $quoted_ids = array(); foreach ($selection as $id) { $quoted_ids[] = $db->quote($id, $type); } return implode(',', $quoted_ids); }
php
public static function implodeSelection( MDB2_Driver_Common $db, SwatViewSelection $selection, $type = 'integer' ) { $quoted_ids = array(); foreach ($selection as $id) { $quoted_ids[] = $db->quote($id, $type); } return implode(',', $quoted_ids); }
[ "public", "static", "function", "implodeSelection", "(", "MDB2_Driver_Common", "$", "db", ",", "SwatViewSelection", "$", "selection", ",", "$", "type", "=", "'integer'", ")", "{", "$", "quoted_ids", "=", "array", "(", ")", ";", "foreach", "(", "$", "selectio...
Implodes a view selection object Each item in the view is quoted using the specified type. @param MDB2_Driver_Common $db the database connection to use to implode the view. @param SwatViewSelection $selection the selection to implode. @param string $type optional. The datatype to use. Must be a valid MDB2 datatype. If unspecified, 'integer' is used. @return string the imploded view ready for inclusion in an SQL statement.
[ "Implodes", "a", "view", "selection", "object" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/SwatDB/SwatDB.php#L1312-L1323
train
rhoone/yii2-rhoone
models/ExtensionQuery.php
ExtensionQuery.enabled
public function enabled($enabled = true) { if (is_bool($enabled)) { return $this->andWhere(['enabled' => $enabled == true ? 1 : 0]); } return $this; }
php
public function enabled($enabled = true) { if (is_bool($enabled)) { return $this->andWhere(['enabled' => $enabled == true ? 1 : 0]); } return $this; }
[ "public", "function", "enabled", "(", "$", "enabled", "=", "true", ")", "{", "if", "(", "is_bool", "(", "$", "enabled", ")", ")", "{", "return", "$", "this", "->", "andWhere", "(", "[", "'enabled'", "=>", "$", "enabled", "==", "true", "?", "1", ":"...
Attach enabled condition. @param mixed $enabled @return \static
[ "Attach", "enabled", "condition", "." ]
f6ae90d466ea6f34bba404be0aba03e37ef369ad
https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/models/ExtensionQuery.php#L30-L36
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.init
public function init() { foreach ($this->renderers as $renderer) { $renderer->init(); } if ($this->id === null) { $this->id = $this->getUniqueId(); $this->has_auto_id = true; } // add the input cell to this column's view's input row if ($this->input_cell !== null) { $input_row = $this->parent->getFirstRowByClass( 'SwatTableViewInputRow' ); if ($input_row === null) { throw new SwatException( 'Table-view does not have an input row.' ); } $input_row->addInputCell($this->input_cell, $this->id); } }
php
public function init() { foreach ($this->renderers as $renderer) { $renderer->init(); } if ($this->id === null) { $this->id = $this->getUniqueId(); $this->has_auto_id = true; } // add the input cell to this column's view's input row if ($this->input_cell !== null) { $input_row = $this->parent->getFirstRowByClass( 'SwatTableViewInputRow' ); if ($input_row === null) { throw new SwatException( 'Table-view does not have an input row.' ); } $input_row->addInputCell($this->input_cell, $this->id); } }
[ "public", "function", "init", "(", ")", "{", "foreach", "(", "$", "this", "->", "renderers", "as", "$", "renderer", ")", "{", "$", "renderer", "->", "init", "(", ")", ";", "}", "if", "(", "$", "this", "->", "id", "===", "null", ")", "{", "$", "...
Initializes this column Gets a unique identifier for this column if one is not provided This calls init on all cell renderers and input cells in this column
[ "Initializes", "this", "column" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L138-L162
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.displayHeaderCell
public function displayHeaderCell() { if (!$this->visible) { return; } $th_tag = new SwatHtmlTag('th', $this->getThAttributes()); $th_tag->scope = 'col'; $colspan = $this->getXhtmlColspan(); if ($colspan > 1) { $th_tag->colspan = $colspan; } $th_tag->open(); $this->displayHeader(); $th_tag->close(); }
php
public function displayHeaderCell() { if (!$this->visible) { return; } $th_tag = new SwatHtmlTag('th', $this->getThAttributes()); $th_tag->scope = 'col'; $colspan = $this->getXhtmlColspan(); if ($colspan > 1) { $th_tag->colspan = $colspan; } $th_tag->open(); $this->displayHeader(); $th_tag->close(); }
[ "public", "function", "displayHeaderCell", "(", ")", "{", "if", "(", "!", "$", "this", "->", "visible", ")", "{", "return", ";", "}", "$", "th_tag", "=", "new", "SwatHtmlTag", "(", "'th'", ",", "$", "this", "->", "getThAttributes", "(", ")", ")", ";"...
Displays the table-view header cell for this column
[ "Displays", "the", "table", "-", "view", "header", "cell", "for", "this", "column" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L191-L208
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.display
public function display($row) { if (!$this->visible) { return; } $this->setupRenderers($row); $this->displayRenderers($row); }
php
public function display($row) { if (!$this->visible) { return; } $this->setupRenderers($row); $this->displayRenderers($row); }
[ "public", "function", "display", "(", "$", "row", ")", "{", "if", "(", "!", "$", "this", "->", "visible", ")", "{", "return", ";", "}", "$", "this", "->", "setupRenderers", "(", "$", "row", ")", ";", "$", "this", "->", "displayRenderers", "(", "$",...
Displays this column using a data object The properties of the cell renderers are set from the data object through the datafield property mappings. @param mixed $row a data object used to display the cell renderers in this column.
[ "Displays", "this", "column", "using", "a", "data", "object" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L257-L265
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.getMessages
public function getMessages($data) { foreach ($this->renderers as $renderer) { $this->renderers->applyMappingsToRenderer($renderer, $data); } $messages = array(); foreach ($this->renderers as $renderer) { $messages = array_merge($messages, $renderer->getMessages()); } return $messages; }
php
public function getMessages($data) { foreach ($this->renderers as $renderer) { $this->renderers->applyMappingsToRenderer($renderer, $data); } $messages = array(); foreach ($this->renderers as $renderer) { $messages = array_merge($messages, $renderer->getMessages()); } return $messages; }
[ "public", "function", "getMessages", "(", "$", "data", ")", "{", "foreach", "(", "$", "this", "->", "renderers", "as", "$", "renderer", ")", "{", "$", "this", "->", "renderers", "->", "applyMappingsToRenderer", "(", "$", "renderer", ",", "$", "data", ")"...
Gathers all messages from this column for the given data object @param mixed $data the data object to use to check this column for messages. @return array an array of {@link SwatMessage} objects.
[ "Gathers", "all", "messages", "from", "this", "column", "for", "the", "given", "data", "object" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L278-L290
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.hasMessage
public function hasMessage($data) { foreach ($this->renderers as $renderer) { $this->renderers->applyMappingsToRenderer($renderer, $data); } $has_message = false; foreach ($this->renderers as $renderer) { if ($renderer->hasMessage()) { $has_message = true; break; } } return $has_message; }
php
public function hasMessage($data) { foreach ($this->renderers as $renderer) { $this->renderers->applyMappingsToRenderer($renderer, $data); } $has_message = false; foreach ($this->renderers as $renderer) { if ($renderer->hasMessage()) { $has_message = true; break; } } return $has_message; }
[ "public", "function", "hasMessage", "(", "$", "data", ")", "{", "foreach", "(", "$", "this", "->", "renderers", "as", "$", "renderer", ")", "{", "$", "this", "->", "renderers", "->", "applyMappingsToRenderer", "(", "$", "renderer", ",", "$", "data", ")",...
Gets whether or not this column has any messages for the given data object @param mixed $data the data object to use to check this column for messages. @return boolean true if this table-view column has one or more messages for the given data object and false if it does not.
[ "Gets", "whether", "or", "not", "this", "column", "has", "any", "messages", "for", "the", "given", "data", "object" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L305-L320
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.getHtmlHeadEntrySet
public function getHtmlHeadEntrySet() { $set = parent::getHtmlHeadEntrySet(); if ($this->input_cell !== null) { $set->addEntrySet($this->input_cell->getHtmlHeadEntrySet()); } return $set; }
php
public function getHtmlHeadEntrySet() { $set = parent::getHtmlHeadEntrySet(); if ($this->input_cell !== null) { $set->addEntrySet($this->input_cell->getHtmlHeadEntrySet()); } return $set; }
[ "public", "function", "getHtmlHeadEntrySet", "(", ")", "{", "$", "set", "=", "parent", "::", "getHtmlHeadEntrySet", "(", ")", ";", "if", "(", "$", "this", "->", "input_cell", "!==", "null", ")", "{", "$", "set", "->", "addEntrySet", "(", "$", "this", "...
Gets the SwatHtmlHeadEntry objects needed by this column @return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects needed by this column. @see SwatUIObject::getHtmlHeadEntrySet()
[ "Gets", "the", "SwatHtmlHeadEntry", "objects", "needed", "by", "this", "column" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L546-L555
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.getAvailableHtmlHeadEntrySet
public function getAvailableHtmlHeadEntrySet() { $set = parent::getAvailableHtmlHeadEntrySet(); if ($this->input_cell !== null) { $set->addEntrySet( $this->input_cell->getAvailableHtmlHeadEntrySet() ); } return $set; }
php
public function getAvailableHtmlHeadEntrySet() { $set = parent::getAvailableHtmlHeadEntrySet(); if ($this->input_cell !== null) { $set->addEntrySet( $this->input_cell->getAvailableHtmlHeadEntrySet() ); } return $set; }
[ "public", "function", "getAvailableHtmlHeadEntrySet", "(", ")", "{", "$", "set", "=", "parent", "::", "getAvailableHtmlHeadEntrySet", "(", ")", ";", "if", "(", "$", "this", "->", "input_cell", "!==", "null", ")", "{", "$", "set", "->", "addEntrySet", "(", ...
Gets the SwatHtmlHeadEntry objects that may be needed by this column @return SwatHtmlHeadEntrySet the SwatHtmlHeadEntry objects that may be needed by this column. @see SwatUIObject::getAvailableHtmlHeadEntrySet()
[ "Gets", "the", "SwatHtmlHeadEntry", "objects", "that", "may", "be", "needed", "by", "this", "column" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L568-L579
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.hasVisibleRenderer
public function hasVisibleRenderer($row) { $this->setupRenderers($row); $visible_renderers = false; foreach ($this->renderers as $renderer) { if ($renderer->visible) { $visible_renderers = true; break; } } return $visible_renderers; }
php
public function hasVisibleRenderer($row) { $this->setupRenderers($row); $visible_renderers = false; foreach ($this->renderers as $renderer) { if ($renderer->visible) { $visible_renderers = true; break; } } return $visible_renderers; }
[ "public", "function", "hasVisibleRenderer", "(", "$", "row", ")", "{", "$", "this", "->", "setupRenderers", "(", "$", "row", ")", ";", "$", "visible_renderers", "=", "false", ";", "foreach", "(", "$", "this", "->", "renderers", "as", "$", "renderer", ")"...
Whether or not this column has one or more visible cell renderers @param mixed $row a data object containing the data for a single row in the table store for this group. This object may affect the visibility of renderers in this column. @return boolean true if this column has one or more visible cell renderers and false if it does not.
[ "Whether", "or", "not", "this", "column", "has", "one", "or", "more", "visible", "cell", "renderers" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L642-L656
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.displayRenderersInternal
protected function displayRenderersInternal($data) { if (count($this->renderers) === 1) { $this->renderers->getFirst()->render(); } else { $div_tag = new SwatHtmlTag('div'); $first = true; foreach ($this->renderers as $renderer) { if (!$renderer->visible) { continue; } if ($first) { $first = false; } else { echo ' '; } // get renderer class names $classes = array('swat-table-view-column-renderer'); $classes = array_merge( $classes, $renderer->getInheritanceCSSClassNames() ); $classes = array_merge( $classes, $renderer->getBaseCSSClassNames() ); $classes = array_merge( $classes, $renderer->getDataSpecificCSSClassNames() ); $classes = array_merge($classes, $renderer->classes); $div_tag->class = implode(' ', $classes); $div_tag->open(); $renderer->render(); $div_tag->close(); } } }
php
protected function displayRenderersInternal($data) { if (count($this->renderers) === 1) { $this->renderers->getFirst()->render(); } else { $div_tag = new SwatHtmlTag('div'); $first = true; foreach ($this->renderers as $renderer) { if (!$renderer->visible) { continue; } if ($first) { $first = false; } else { echo ' '; } // get renderer class names $classes = array('swat-table-view-column-renderer'); $classes = array_merge( $classes, $renderer->getInheritanceCSSClassNames() ); $classes = array_merge( $classes, $renderer->getBaseCSSClassNames() ); $classes = array_merge( $classes, $renderer->getDataSpecificCSSClassNames() ); $classes = array_merge($classes, $renderer->classes); $div_tag->class = implode(' ', $classes); $div_tag->open(); $renderer->render(); $div_tag->close(); } } }
[ "protected", "function", "displayRenderersInternal", "(", "$", "data", ")", "{", "if", "(", "count", "(", "$", "this", "->", "renderers", ")", "===", "1", ")", "{", "$", "this", "->", "renderers", "->", "getFirst", "(", ")", "->", "render", "(", ")", ...
Renders each cell renderer in this column If there is once cell renderer in this column, it is rendered by itself. If there is more than one cell renderer in this column, cell renderers are rendered in order inside separate <i>div</i> elements. Each <i>div</i> element is separated with a breaking space character and the div elements are displayed inline by default. @param mixed $data the data object being used to render the cell renderers of this field.
[ "Renders", "each", "cell", "renderer", "in", "this", "column" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L728-L772
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.setupRenderers
protected function setupRenderers($data) { if (count($this->renderers) === 0) { throw new SwatException( 'No renderer has been provided for this column.' ); } $sensitive = $this->view->isSensitive(); // Set the properties of the renderers to the value of the data field. foreach ($this->renderers as $renderer) { $this->renderers->applyMappingsToRenderer($renderer, $data); $renderer->sensitive = $renderer->sensitive && $sensitive; } }
php
protected function setupRenderers($data) { if (count($this->renderers) === 0) { throw new SwatException( 'No renderer has been provided for this column.' ); } $sensitive = $this->view->isSensitive(); // Set the properties of the renderers to the value of the data field. foreach ($this->renderers as $renderer) { $this->renderers->applyMappingsToRenderer($renderer, $data); $renderer->sensitive = $renderer->sensitive && $sensitive; } }
[ "protected", "function", "setupRenderers", "(", "$", "data", ")", "{", "if", "(", "count", "(", "$", "this", "->", "renderers", ")", "===", "0", ")", "{", "throw", "new", "SwatException", "(", "'No renderer has been provided for this column.'", ")", ";", "}", ...
Sets properties of renderers using data from current row @param mixed $data the data object being used to render the cell renderers of this field.
[ "Sets", "properties", "of", "renderers", "using", "data", "from", "current", "row" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L783-L798
train
silverorange/swat
Swat/SwatTableViewColumn.php
SwatTableViewColumn.getCSSClassNames
protected function getCSSClassNames() { $classes = array(); // instance specific class if ($this->id !== null && !$this->has_auto_id) { $column_class = str_replace('_', '-', $this->id); $classes[] = $column_class; } // base classes $classes = array_merge($classes, $this->getBaseCSSClassNames()); // user-specified classes $classes = array_merge($classes, $this->classes); $first_renderer = $this->renderers->getFirst(); if ( $this->show_renderer_classes && $first_renderer instanceof SwatCellRenderer ) { // renderer inheritance classes $classes = array_merge( $classes, $first_renderer->getInheritanceCSSClassNames() ); // renderer base classes $classes = array_merge( $classes, $first_renderer->getBaseCSSClassNames() ); // renderer data specific classes if ($this->renderers->mappingsApplied()) { $classes = array_merge( $classes, $first_renderer->getDataSpecificCSSClassNames() ); } // renderer user-specified classes $classes = array_merge($classes, $first_renderer->classes); } return $classes; }
php
protected function getCSSClassNames() { $classes = array(); // instance specific class if ($this->id !== null && !$this->has_auto_id) { $column_class = str_replace('_', '-', $this->id); $classes[] = $column_class; } // base classes $classes = array_merge($classes, $this->getBaseCSSClassNames()); // user-specified classes $classes = array_merge($classes, $this->classes); $first_renderer = $this->renderers->getFirst(); if ( $this->show_renderer_classes && $first_renderer instanceof SwatCellRenderer ) { // renderer inheritance classes $classes = array_merge( $classes, $first_renderer->getInheritanceCSSClassNames() ); // renderer base classes $classes = array_merge( $classes, $first_renderer->getBaseCSSClassNames() ); // renderer data specific classes if ($this->renderers->mappingsApplied()) { $classes = array_merge( $classes, $first_renderer->getDataSpecificCSSClassNames() ); } // renderer user-specified classes $classes = array_merge($classes, $first_renderer->classes); } return $classes; }
[ "protected", "function", "getCSSClassNames", "(", ")", "{", "$", "classes", "=", "array", "(", ")", ";", "// instance specific class", "if", "(", "$", "this", "->", "id", "!==", "null", "&&", "!", "$", "this", "->", "has_auto_id", ")", "{", "$", "column_...
Gets the array of CSS classes that are applied to this table-view column CSS classes are added to this column in the following order: 1. a CSS class representing cells in this column's instance if this column has an id set, 2. hard-coded CSS classes from column subclasses, 3. user-specified CSS classes on this column, If {@link SwatTableViewColumn::$show_renderer_classes} is true, the following extra CSS classes are added: 4. the inheritance classes of the first cell renderer in this column, 5. hard-coded CSS classes from the first cell renderer in this column, 6. hard-coded data-specific CSS classes from the first cell renderer in this column if this column has data mappings applied, 7. user-specified CSS classes on the first cell renderer in this column. @return array the array of CSS classes that are applied to this table-view column. @see SwatCellRenderer::getInheritanceCSSClassNames() @see SwatCellRenderer::getBaseCSSClassNames() @see SwatUIObject::getCSSClassNames()
[ "Gets", "the", "array", "of", "CSS", "classes", "that", "are", "applied", "to", "this", "table", "-", "view", "column" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTableViewColumn.php#L829-L875
train
silverorange/swat
Swat/SwatButton.php
SwatButton.display
public function display() { if (!$this->visible) { return; } parent::display(); $input_tag = $this->getInputTag(); $input_tag->display(); if ( $this->show_processing_throbber || $this->confirmation_message !== null ) { Swat::displayInlineJavaScript($this->getInlineJavaScript()); } }
php
public function display() { if (!$this->visible) { return; } parent::display(); $input_tag = $this->getInputTag(); $input_tag->display(); if ( $this->show_processing_throbber || $this->confirmation_message !== null ) { Swat::displayInlineJavaScript($this->getInlineJavaScript()); } }
[ "public", "function", "display", "(", ")", "{", "if", "(", "!", "$", "this", "->", "visible", ")", "{", "return", ";", "}", "parent", "::", "display", "(", ")", ";", "$", "input_tag", "=", "$", "this", "->", "getInputTag", "(", ")", ";", "$", "in...
Displays this button Outputs an XHTML input tag.
[ "Displays", "this", "button" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatButton.php#L157-L174
train
silverorange/swat
Swat/SwatButton.php
SwatButton.process
public function process() { parent::process(); $data = &$this->getForm()->getFormData(); if (isset($data[$this->id])) { $this->clicked = true; $this->getForm()->button = $this; } }
php
public function process() { parent::process(); $data = &$this->getForm()->getFormData(); if (isset($data[$this->id])) { $this->clicked = true; $this->getForm()->button = $this; } }
[ "public", "function", "process", "(", ")", "{", "parent", "::", "process", "(", ")", ";", "$", "data", "=", "&", "$", "this", "->", "getForm", "(", ")", "->", "getFormData", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "$", "this", ...
Does button processing Sets whether this button has been clicked and also updates the form this button belongs to with a reference to this button if this button submitted the form.
[ "Does", "button", "processing" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatButton.php#L186-L196
train
silverorange/swat
Swat/SwatButton.php
SwatButton.setFromStock
public function setFromStock($stock_id, $overwrite_properties = true) { switch ($stock_id) { case 'submit': $title = Swat::_('Submit'); $class = 'swat-button-submit'; break; case 'create': $title = Swat::_('Create'); $class = 'swat-button-create'; break; case 'add': $title = Swat::_('Add'); $class = 'swat-button-add'; break; case 'apply': $title = Swat::_('Apply'); $class = 'swat-button-apply'; break; case 'delete': $title = Swat::_('Delete'); $class = 'swat-button-delete'; break; case 'cancel': $title = Swat::_('Cancel'); $class = 'swat-button-cancel'; break; default: throw new SwatUndefinedStockTypeException( "Stock type with id of '{$stock_id}' not found.", 0, $stock_id ); } if ($overwrite_properties || $this->title === null) { $this->title = $title; } $this->stock_class = $class; }
php
public function setFromStock($stock_id, $overwrite_properties = true) { switch ($stock_id) { case 'submit': $title = Swat::_('Submit'); $class = 'swat-button-submit'; break; case 'create': $title = Swat::_('Create'); $class = 'swat-button-create'; break; case 'add': $title = Swat::_('Add'); $class = 'swat-button-add'; break; case 'apply': $title = Swat::_('Apply'); $class = 'swat-button-apply'; break; case 'delete': $title = Swat::_('Delete'); $class = 'swat-button-delete'; break; case 'cancel': $title = Swat::_('Cancel'); $class = 'swat-button-cancel'; break; default: throw new SwatUndefinedStockTypeException( "Stock type with id of '{$stock_id}' not found.", 0, $stock_id ); } if ($overwrite_properties || $this->title === null) { $this->title = $title; } $this->stock_class = $class; }
[ "public", "function", "setFromStock", "(", "$", "stock_id", ",", "$", "overwrite_properties", "=", "true", ")", "{", "switch", "(", "$", "stock_id", ")", "{", "case", "'submit'", ":", "$", "title", "=", "Swat", "::", "_", "(", "'Submit'", ")", ";", "$"...
Sets the values of this button to a stock type Valid stock type ids are: - submit - create - add - apply - delete - cancel @param string $stock_id the identifier of the stock type to use. @param boolean $overwrite_properties whether to overwrite properties if they are already set. @throws SwatUndefinedStockTypeException
[ "Sets", "the", "values", "of", "this", "button", "to", "a", "stock", "type" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatButton.php#L232-L278
train
silverorange/swat
Swat/SwatButton.php
SwatButton.getInputTag
protected function getInputTag() { // We do not use a 'button' element because it is broken differently in // different versions of Internet Explorer $tag = new SwatHtmlTag('input'); $tag->type = 'submit'; $tag->name = $this->id; $tag->id = $this->id; $tag->value = $this->title; $tag->class = $this->getCSSClassString(); $tag->tabindex = $this->tab_index; $tag->accesskey = $this->access_key; if (!$this->isSensitive()) { $tag->disabled = 'disabled'; } return $tag; }
php
protected function getInputTag() { // We do not use a 'button' element because it is broken differently in // different versions of Internet Explorer $tag = new SwatHtmlTag('input'); $tag->type = 'submit'; $tag->name = $this->id; $tag->id = $this->id; $tag->value = $this->title; $tag->class = $this->getCSSClassString(); $tag->tabindex = $this->tab_index; $tag->accesskey = $this->access_key; if (!$this->isSensitive()) { $tag->disabled = 'disabled'; } return $tag; }
[ "protected", "function", "getInputTag", "(", ")", "{", "// We do not use a 'button' element because it is broken differently in", "// different versions of Internet Explorer", "$", "tag", "=", "new", "SwatHtmlTag", "(", "'input'", ")", ";", "$", "tag", "->", "type", "=", ...
Get the HTML tag to display for this button Can be used by sub-classes to change the setup of the input tag. @return SwatHtmlTag the HTML tag to display for this button.
[ "Get", "the", "HTML", "tag", "to", "display", "for", "this", "button" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatButton.php#L290-L310
train
silverorange/swat
Swat/SwatButton.php
SwatButton.getCSSClassNames
protected function getCSSClassNames() { $classes = array('swat-button'); $form = $this->getFirstAncestor('SwatForm'); $primary = $form !== null && $form->getFirstDescendant('SwatButton') === $this; if ($primary) { $classes[] = 'swat-primary'; } if ($this->stock_class !== null) { $classes[] = $this->stock_class; } $classes = array_merge($classes, parent::getCSSClassNames()); return $classes; }
php
protected function getCSSClassNames() { $classes = array('swat-button'); $form = $this->getFirstAncestor('SwatForm'); $primary = $form !== null && $form->getFirstDescendant('SwatButton') === $this; if ($primary) { $classes[] = 'swat-primary'; } if ($this->stock_class !== null) { $classes[] = $this->stock_class; } $classes = array_merge($classes, parent::getCSSClassNames()); return $classes; }
[ "protected", "function", "getCSSClassNames", "(", ")", "{", "$", "classes", "=", "array", "(", "'swat-button'", ")", ";", "$", "form", "=", "$", "this", "->", "getFirstAncestor", "(", "'SwatForm'", ")", ";", "$", "primary", "=", "$", "form", "!==", "null...
Gets the array of CSS classes that are applied to this button @return array the array of CSS classes that are applied to this button.
[ "Gets", "the", "array", "of", "CSS", "classes", "that", "are", "applied", "to", "this", "button" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatButton.php#L320-L339
train
silverorange/swat
Swat/SwatTileViewGroup.php
SwatTileViewGroup.displayGroupHeader
protected function displayGroupHeader($row) { $div_tag = new SwatHtmlTag('div'); $div_tag->class = 'swat-tile-view-group'; if ($this->header_current === null) { $div_tag->class .= ' swat-tile-view-first-group'; } $div_tag->open(); $heading_tag = new SwatHtmlTag('h4'); $heading_tag->open(); $this->displayRenderersInternal($row); $heading_tag->close(); $div_tag->close(); }
php
protected function displayGroupHeader($row) { $div_tag = new SwatHtmlTag('div'); $div_tag->class = 'swat-tile-view-group'; if ($this->header_current === null) { $div_tag->class .= ' swat-tile-view-first-group'; } $div_tag->open(); $heading_tag = new SwatHtmlTag('h4'); $heading_tag->open(); $this->displayRenderersInternal($row); $heading_tag->close(); $div_tag->close(); }
[ "protected", "function", "displayGroupHeader", "(", "$", "row", ")", "{", "$", "div_tag", "=", "new", "SwatHtmlTag", "(", "'div'", ")", ";", "$", "div_tag", "->", "class", "=", "'swat-tile-view-group'", ";", "if", "(", "$", "this", "->", "header_current", ...
Displays the group header for this grouping tile The grouping header is displayed at the beginning of a group. @param mixed $row a data object containing the data for the first row in in the table model for this group.
[ "Displays", "the", "group", "header", "for", "this", "grouping", "tile" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileViewGroup.php#L93-L110
train
silverorange/swat
Swat/SwatTileViewGroup.php
SwatTileViewGroup.displayRenderers
protected function displayRenderers($row) { if ($this->group_by === null) { throw new SwatException("Attribute 'group_by' must be set."); } $group_by = $this->group_by; // only display the group header if the value of the group-by field has // changed if (!$this->isEqual($this->header_current, $row->$group_by)) { $this->resetSubGroups(); $this->displayGroupHeader($row); $this->header_current = $row->$group_by; } }
php
protected function displayRenderers($row) { if ($this->group_by === null) { throw new SwatException("Attribute 'group_by' must be set."); } $group_by = $this->group_by; // only display the group header if the value of the group-by field has // changed if (!$this->isEqual($this->header_current, $row->$group_by)) { $this->resetSubGroups(); $this->displayGroupHeader($row); $this->header_current = $row->$group_by; } }
[ "protected", "function", "displayRenderers", "(", "$", "row", ")", "{", "if", "(", "$", "this", "->", "group_by", "===", "null", ")", "{", "throw", "new", "SwatException", "(", "\"Attribute 'group_by' must be set.\"", ")", ";", "}", "$", "group_by", "=", "$"...
Displays the renderers for this tile The renderes are only displayed once for every time the value of the group_by field changes and the renderers are displayed as a divider between tiles. @param mixed $row a data object containing the data for a single row in the table model for this group. @throws SwatException
[ "Displays", "the", "renderers", "for", "this", "tile" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTileViewGroup.php#L144-L159
train
TeknooSoftware/states
src/Proxy/ProxyTrait.php
ProxyTrait.pushCallerStatedClassName
private function pushCallerStatedClassName(StateInterface $state): ProxyInterface { $stateClass = \get_class($state); if (!isset($this->classesByStates[$stateClass])) { throw new \RuntimeException("Error, no original class name defined for $stateClass"); } $this->callerStatedClassesStack->push($this->classesByStates[$stateClass]); return $this; }
php
private function pushCallerStatedClassName(StateInterface $state): ProxyInterface { $stateClass = \get_class($state); if (!isset($this->classesByStates[$stateClass])) { throw new \RuntimeException("Error, no original class name defined for $stateClass"); } $this->callerStatedClassesStack->push($this->classesByStates[$stateClass]); return $this; }
[ "private", "function", "pushCallerStatedClassName", "(", "StateInterface", "$", "state", ")", ":", "ProxyInterface", "{", "$", "stateClass", "=", "\\", "get_class", "(", "$", "state", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "classesByState...
To push in the caller stated classes name stack the class of the current object. @param StateInterface $state @return ProxyInterface
[ "To", "push", "in", "the", "caller", "stated", "classes", "name", "stack", "the", "class", "of", "the", "current", "object", "." ]
0c675b768781ee3a3a15c2663cffec5d50c1d5fd
https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/src/Proxy/ProxyTrait.php#L223-L234
train
TeknooSoftware/states
src/Proxy/ProxyTrait.php
ProxyTrait.popCallerStatedClassName
private function popCallerStatedClassName(): ProxyInterface { if (false === $this->callerStatedClassesStack->isEmpty()) { $this->callerStatedClassesStack->pop(); } return $this; }
php
private function popCallerStatedClassName(): ProxyInterface { if (false === $this->callerStatedClassesStack->isEmpty()) { $this->callerStatedClassesStack->pop(); } return $this; }
[ "private", "function", "popCallerStatedClassName", "(", ")", ":", "ProxyInterface", "{", "if", "(", "false", "===", "$", "this", "->", "callerStatedClassesStack", "->", "isEmpty", "(", ")", ")", "{", "$", "this", "->", "callerStatedClassesStack", "->", "pop", ...
To pop the current caller in the stated class name stack. @return ProxyInterface
[ "To", "pop", "the", "current", "caller", "in", "the", "stated", "class", "name", "stack", "." ]
0c675b768781ee3a3a15c2663cffec5d50c1d5fd
https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/src/Proxy/ProxyTrait.php#L241-L248
train
TeknooSoftware/states
src/Proxy/ProxyTrait.php
ProxyTrait.callMethod
private function callMethod( StateInterface $state, string &$methodName, array &$arguments, string &$scopeVisibility, callable &$callback ) : ProxyInterface { $callerStatedClass = $this->getCallerStatedClassName(); $this->pushCallerStatedClassName($state); //Call it try { $state->executeClosure($this, $methodName, $arguments, $scopeVisibility, $callerStatedClass, $callback); } catch (\Throwable $e) { //Restore stated class name stack $this->popCallerStatedClassName(); throw $e; } //Restore stated class name stack $this->popCallerStatedClassName(); return $this; }
php
private function callMethod( StateInterface $state, string &$methodName, array &$arguments, string &$scopeVisibility, callable &$callback ) : ProxyInterface { $callerStatedClass = $this->getCallerStatedClassName(); $this->pushCallerStatedClassName($state); //Call it try { $state->executeClosure($this, $methodName, $arguments, $scopeVisibility, $callerStatedClass, $callback); } catch (\Throwable $e) { //Restore stated class name stack $this->popCallerStatedClassName(); throw $e; } //Restore stated class name stack $this->popCallerStatedClassName(); return $this; }
[ "private", "function", "callMethod", "(", "StateInterface", "$", "state", ",", "string", "&", "$", "methodName", ",", "array", "&", "$", "arguments", ",", "string", "&", "$", "scopeVisibility", ",", "callable", "&", "$", "callback", ")", ":", "ProxyInterface...
Prepare the execution's context and execute a method in a state passed in args with the closure. @param StateInterface $state @param string $methodName @param array $arguments @param string $scopeVisibility self::VISIBILITY_PUBLIC self::VISIBILITY_PROTECTED self::VISIBILITY_PRIVATE @param callable &$callback @return self|ProxyInterface @throws \Throwable
[ "Prepare", "the", "execution", "s", "context", "and", "execute", "a", "method", "in", "a", "state", "passed", "in", "args", "with", "the", "closure", "." ]
0c675b768781ee3a3a15c2663cffec5d50c1d5fd
https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/src/Proxy/ProxyTrait.php#L265-L289
train
TeknooSoftware/states
src/Proxy/ProxyTrait.php
ProxyTrait.initializeProxy
protected function initializeProxy(): void { //Initialize internal vars $this->states = []; $this->activesStates = []; $this->callerStatedClassesStack = new \SplStack(); //Creates $this->loadStates(); }
php
protected function initializeProxy(): void { //Initialize internal vars $this->states = []; $this->activesStates = []; $this->callerStatedClassesStack = new \SplStack(); //Creates $this->loadStates(); }
[ "protected", "function", "initializeProxy", "(", ")", ":", "void", "{", "//Initialize internal vars", "$", "this", "->", "states", "=", "[", "]", ";", "$", "this", "->", "activesStates", "=", "[", "]", ";", "$", "this", "->", "callerStatedClassesStack", "=",...
Method to call into the constructor to initialize proxy's vars. Externalized from the constructor to allow developers to write their own constructors into theirs classes. @throws Exception\StateNotFound
[ "Method", "to", "call", "into", "the", "constructor", "to", "initialize", "proxy", "s", "vars", ".", "Externalized", "from", "the", "constructor", "to", "allow", "developers", "to", "write", "their", "own", "constructors", "into", "theirs", "classes", "." ]
0c675b768781ee3a3a15c2663cffec5d50c1d5fd
https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/src/Proxy/ProxyTrait.php#L372-L380
train
TeknooSoftware/states
src/Proxy/ProxyTrait.php
ProxyTrait.extractVisibilityScopeFromObject
private function extractVisibilityScopeFromObject(&$callerObject): string { if ($this === $callerObject) { //It's me ! Mario ! So Private scope return StateInterface::VISIBILITY_PRIVATE; } if (\get_class($this) === \get_class($callerObject)) { //It's a brother (another instance of this same stated class, not a child), So Private scope too return StateInterface::VISIBILITY_PRIVATE; } if ($callerObject instanceof $this) { //It's a child class, so Protected. return StateInterface::VISIBILITY_PROTECTED; } //All another case (not same class), public scope return StateInterface::VISIBILITY_PUBLIC; }
php
private function extractVisibilityScopeFromObject(&$callerObject): string { if ($this === $callerObject) { //It's me ! Mario ! So Private scope return StateInterface::VISIBILITY_PRIVATE; } if (\get_class($this) === \get_class($callerObject)) { //It's a brother (another instance of this same stated class, not a child), So Private scope too return StateInterface::VISIBILITY_PRIVATE; } if ($callerObject instanceof $this) { //It's a child class, so Protected. return StateInterface::VISIBILITY_PROTECTED; } //All another case (not same class), public scope return StateInterface::VISIBILITY_PUBLIC; }
[ "private", "function", "extractVisibilityScopeFromObject", "(", "&", "$", "callerObject", ")", ":", "string", "{", "if", "(", "$", "this", "===", "$", "callerObject", ")", "{", "//It's me ! Mario ! So Private scope", "return", "StateInterface", "::", "VISIBILITY_PRIVA...
To compute the visibility scope from the object instance of the caller. Called from another class (not a child class), via a static method or an instance of this class : Public scope Called from a child class, via a static method or an instance of this class : Protected scope Called from a static method of this stated class, or from a method of this stated class (but not this instance) : Private scope Called from a method of this stated class instance : Private state @param object $callerObject @return string
[ "To", "compute", "the", "visibility", "scope", "from", "the", "object", "instance", "of", "the", "caller", "." ]
0c675b768781ee3a3a15c2663cffec5d50c1d5fd
https://github.com/TeknooSoftware/states/blob/0c675b768781ee3a3a15c2663cffec5d50c1d5fd/src/Proxy/ProxyTrait.php#L395-L414
train
silverorange/swat
Swat/SwatNavBar.php
SwatNavBar.createEntry
public function createEntry( $title, $link = null, $content_type = 'text/plain' ) { $this->addEntry(new SwatNavBarEntry($title, $link, $content_type)); }
php
public function createEntry( $title, $link = null, $content_type = 'text/plain' ) { $this->addEntry(new SwatNavBarEntry($title, $link, $content_type)); }
[ "public", "function", "createEntry", "(", "$", "title", ",", "$", "link", "=", "null", ",", "$", "content_type", "=", "'text/plain'", ")", "{", "$", "this", "->", "addEntry", "(", "new", "SwatNavBarEntry", "(", "$", "title", ",", "$", "link", ",", "$",...
Creates a SwatNavBarEntry and adds it to the end of this navigation bar @param string $title the entry title. @param string $link an optional entry URI. @param string $content_type an optional content type for the entry title.
[ "Creates", "a", "SwatNavBarEntry", "and", "adds", "it", "to", "the", "end", "of", "this", "navigation", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatNavBar.php#L66-L72
train
silverorange/swat
Swat/SwatNavBar.php
SwatNavBar.replaceEntryByPosition
public function replaceEntryByPosition( $position, SwatNavBarEntry $new_entry ) { if (isset($this->entries[$position])) { $old_entry = $this->entries[$position]; $this->entries[$position] = $new_entry; return $old_entry; } throw new SwatException( sprintf( 'Cannot replace element at position ' . '%s because NavBar does not contain an entry at position %s.', $position, $position ) ); }
php
public function replaceEntryByPosition( $position, SwatNavBarEntry $new_entry ) { if (isset($this->entries[$position])) { $old_entry = $this->entries[$position]; $this->entries[$position] = $new_entry; return $old_entry; } throw new SwatException( sprintf( 'Cannot replace element at position ' . '%s because NavBar does not contain an entry at position %s.', $position, $position ) ); }
[ "public", "function", "replaceEntryByPosition", "(", "$", "position", ",", "SwatNavBarEntry", "$", "new_entry", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "entries", "[", "$", "position", "]", ")", ")", "{", "$", "old_entry", "=", "$", "this",...
Replaces an entry in this navigation bar If the entry is not in this navigation bar, an exception is thrown. @param integer $position zero-based ordinal position of the entry to replace. @param SwatNavBarEntry $entry the navbar entry to replace the element at the given position with. @return SwatNavBarEntry the replaced entry. @thows SwatException
[ "Replaces", "an", "entry", "in", "this", "navigation", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatNavBar.php#L133-L152
train
silverorange/swat
Swat/SwatNavBar.php
SwatNavBar.getEntryByPosition
public function getEntryByPosition($position) { if ($position < 0) { $position = count($this) + $position - 1; } if (isset($this->entries[$position])) { return $this->entries[$position]; } else { throw new SwatException( sprintf( 'Navbar does not contain an entry at position %s.', $position ) ); } }
php
public function getEntryByPosition($position) { if ($position < 0) { $position = count($this) + $position - 1; } if (isset($this->entries[$position])) { return $this->entries[$position]; } else { throw new SwatException( sprintf( 'Navbar does not contain an entry at position %s.', $position ) ); } }
[ "public", "function", "getEntryByPosition", "(", "$", "position", ")", "{", "if", "(", "$", "position", "<", "0", ")", "{", "$", "position", "=", "count", "(", "$", "this", ")", "+", "$", "position", "-", "1", ";", "}", "if", "(", "isset", "(", "...
Gets an entry from this navigation bar If the entry is not in this navigation bar, an exception is thrown. @param integer $position zero-based ordinal position of the entry to fetch. If position is negative, the entry position is counted from the end of the nav bar (-1 will return one from the end). Use getLastEntry() to get the last entry of the nav bar. @return SwatNavBarEntry the entry. @throws SwatException
[ "Gets", "an", "entry", "from", "this", "navigation", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatNavBar.php#L173-L189
train
silverorange/swat
Swat/SwatNavBar.php
SwatNavBar.popEntries
public function popEntries($number) { if (count($this) < $number) { $count = count($this); throw new SwatException( printf( 'Unable to pop %s entries. NavBar ' . 'only contains %s entries.', $number, $count ) ); } else { return array_splice($this->entries, -$number); } }
php
public function popEntries($number) { if (count($this) < $number) { $count = count($this); throw new SwatException( printf( 'Unable to pop %s entries. NavBar ' . 'only contains %s entries.', $number, $count ) ); } else { return array_splice($this->entries, -$number); } }
[ "public", "function", "popEntries", "(", "$", "number", ")", "{", "if", "(", "count", "(", "$", "this", ")", "<", "$", "number", ")", "{", "$", "count", "=", "count", "(", "$", "this", ")", ";", "throw", "new", "SwatException", "(", "printf", "(", ...
Pops one or more entries off the end of this navigational bar If more entries are to be popped than currently exist, an exception is thrown. @param $number integer number of entries to pop off this navigational bar. @return array an array of SwatNavBarEntry objects that were popped off the navagational bar. @throws SwatException
[ "Pops", "one", "or", "more", "entries", "off", "the", "end", "of", "this", "navigational", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatNavBar.php#L283-L299
train
silverorange/swat
Swat/SwatNavBar.php
SwatNavBar.display
public function display() { if (!$this->visible) { return; } parent::display(); $count = count($this); $i = 1; $container_tag = $this->getContainerTag(); $container_tag->open(); foreach ($this->entries as $entry) { // display separator if ($i > 1) { echo SwatString::minimizeEntities($this->separator); } // link all entries or link all but the last entry $link = $this->link_last_entry || $i < $count; $this->displayEntry($entry, $link, $i === 1); $i++; } $container_tag->close(); }
php
public function display() { if (!$this->visible) { return; } parent::display(); $count = count($this); $i = 1; $container_tag = $this->getContainerTag(); $container_tag->open(); foreach ($this->entries as $entry) { // display separator if ($i > 1) { echo SwatString::minimizeEntities($this->separator); } // link all entries or link all but the last entry $link = $this->link_last_entry || $i < $count; $this->displayEntry($entry, $link, $i === 1); $i++; } $container_tag->close(); }
[ "public", "function", "display", "(", ")", "{", "if", "(", "!", "$", "this", "->", "visible", ")", "{", "return", ";", "}", "parent", "::", "display", "(", ")", ";", "$", "count", "=", "count", "(", "$", "this", ")", ";", "$", "i", "=", "1", ...
Displays this navigational bar Displays each entry separated by a special character and outputs navbar entries with links as anchor tags.
[ "Displays", "this", "navigational", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatNavBar.php#L326-L355
train
silverorange/swat
Swat/SwatNavBar.php
SwatNavBar.displayEntry
protected function displayEntry( SwatNavBarEntry $entry, $show_link = true, $first = false ) { $title = $entry->title === null ? '' : $entry->title; $link = $this->getLink($entry); if ($link !== null && $show_link) { $a_tag = new SwatHtmlTag('a'); $a_tag->href = $link; if ($first) { $a_tag->class = 'swat-navbar-first'; } $a_tag->setContent($title, $entry->content_type); $a_tag->display(); } else { $span_tag = new SwatHtmlTag('span'); if ($first) { $span_tag->class = 'swat-navbar-first'; } $span_tag->setContent($title, $entry->content_type); $span_tag->display(); } }
php
protected function displayEntry( SwatNavBarEntry $entry, $show_link = true, $first = false ) { $title = $entry->title === null ? '' : $entry->title; $link = $this->getLink($entry); if ($link !== null && $show_link) { $a_tag = new SwatHtmlTag('a'); $a_tag->href = $link; if ($first) { $a_tag->class = 'swat-navbar-first'; } $a_tag->setContent($title, $entry->content_type); $a_tag->display(); } else { $span_tag = new SwatHtmlTag('span'); if ($first) { $span_tag->class = 'swat-navbar-first'; } $span_tag->setContent($title, $entry->content_type); $span_tag->display(); } }
[ "protected", "function", "displayEntry", "(", "SwatNavBarEntry", "$", "entry", ",", "$", "show_link", "=", "true", ",", "$", "first", "=", "false", ")", "{", "$", "title", "=", "$", "entry", "->", "title", "===", "null", "?", "''", ":", "$", "entry", ...
Displays an entry in this navigational bar @param SwatNavBarEntry $entry the entry to display. @param boolean $link whether or not to hyperlink the given entry if the entry has a link set. @param boolean $first whether or not this entry should be displayed as the first entry.
[ "Displays", "an", "entry", "in", "this", "navigational", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatNavBar.php#L369-L395
train
silverorange/swat
Swat/SwatNavBar.php
SwatNavBar.getContainerTag
protected function getContainerTag() { if ($this->container_tag === null) { $tag = new SwatHtmlTag('div'); } else { $tag = $this->container_tag; } $tag->id = $this->id; $tag->class = $this->getCSSClassString(); return $tag; }
php
protected function getContainerTag() { if ($this->container_tag === null) { $tag = new SwatHtmlTag('div'); } else { $tag = $this->container_tag; } $tag->id = $this->id; $tag->class = $this->getCSSClassString(); return $tag; }
[ "protected", "function", "getContainerTag", "(", ")", "{", "if", "(", "$", "this", "->", "container_tag", "===", "null", ")", "{", "$", "tag", "=", "new", "SwatHtmlTag", "(", "'div'", ")", ";", "}", "else", "{", "$", "tag", "=", "$", "this", "->", ...
Gets the container tag for this navigational bar The container tag wraps around all entries in this navigational bar. @return SwatHtmlTag the container tag for this navigational bar.
[ "Gets", "the", "container", "tag", "for", "this", "navigational", "bar" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatNavBar.php#L438-L449
train
silverorange/swat
Swat/SwatTreeFlydown.php
SwatTreeFlydown.display
public function display() { if (!$this->visible) { return; } $actual_value = $this->value; if (count($this->path) === 0 && $this->value !== null) { // If there is a value but not a path, assume the value is the // first element in the path. $this->value = array($this->value); } else { // temporarily set the value to the path for parent::display() $this->value = $this->path; } parent::display(); // set value back to actual value after parent::display() $this->value = $actual_value; }
php
public function display() { if (!$this->visible) { return; } $actual_value = $this->value; if (count($this->path) === 0 && $this->value !== null) { // If there is a value but not a path, assume the value is the // first element in the path. $this->value = array($this->value); } else { // temporarily set the value to the path for parent::display() $this->value = $this->path; } parent::display(); // set value back to actual value after parent::display() $this->value = $actual_value; }
[ "public", "function", "display", "(", ")", "{", "if", "(", "!", "$", "this", "->", "visible", ")", "{", "return", ";", "}", "$", "actual_value", "=", "$", "this", "->", "value", ";", "if", "(", "count", "(", "$", "this", "->", "path", ")", "===",...
Displays this tree flydown
[ "Displays", "this", "tree", "flydown" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTreeFlydown.php#L62-L82
train
silverorange/swat
Swat/SwatTreeFlydown.php
SwatTreeFlydown.flattenTree
private function flattenTree( &$options, SwatTreeFlydownNode $node, $level = 0, $path = array() ) { $tree_option = clone $node->getOption(); $pad = str_repeat('&nbsp;', $level * 3); $path[] = $tree_option->value; $tree_option->title = $pad . $tree_option->title; $tree_option->value = $path; $options[] = $tree_option; foreach ($node->getChildren() as $child_node) { $this->flattenTree($options, $child_node, $level + 1, $path); } }
php
private function flattenTree( &$options, SwatTreeFlydownNode $node, $level = 0, $path = array() ) { $tree_option = clone $node->getOption(); $pad = str_repeat('&nbsp;', $level * 3); $path[] = $tree_option->value; $tree_option->title = $pad . $tree_option->title; $tree_option->value = $path; $options[] = $tree_option; foreach ($node->getChildren() as $child_node) { $this->flattenTree($options, $child_node, $level + 1, $path); } }
[ "private", "function", "flattenTree", "(", "&", "$", "options", ",", "SwatTreeFlydownNode", "$", "node", ",", "$", "level", "=", "0", ",", "$", "path", "=", "array", "(", ")", ")", "{", "$", "tree_option", "=", "clone", "$", "node", "->", "getOption", ...
Flattens this flydown's tree into an array of flydown options The tree is represented by placing spaces in front of option titles for different levels. The values of the options are set to an array representing the tree nodes's paths in the tree. @param array $options a reference to an array to add the flattened tree nodes to. @param SwatTreeFlydownNode $node the tree node to flatten. @param integer $level the current level of recursion. @param array $path the current path represented as an array of tree node option values.
[ "Flattens", "this", "flydown", "s", "tree", "into", "an", "array", "of", "flydown", "options" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTreeFlydown.php#L122-L141
train
silverorange/swat
Swat/SwatTreeFlydown.php
SwatTreeFlydown.setTree
public function setTree($tree) { if ($tree instanceof SwatDataTreeNode) { $tree = SwatTreeFlydownNode::convertFromDataTree($tree); } elseif (!($tree instanceof SwatTreeFlydownNode)) { throw new SwatInvalidClassException( 'Tree must be an intance of ' . 'either SwatDataTreeNode or SwatTreeFlydownNode.', 0, $tree ); } $this->tree = $tree; }
php
public function setTree($tree) { if ($tree instanceof SwatDataTreeNode) { $tree = SwatTreeFlydownNode::convertFromDataTree($tree); } elseif (!($tree instanceof SwatTreeFlydownNode)) { throw new SwatInvalidClassException( 'Tree must be an intance of ' . 'either SwatDataTreeNode or SwatTreeFlydownNode.', 0, $tree ); } $this->tree = $tree; }
[ "public", "function", "setTree", "(", "$", "tree", ")", "{", "if", "(", "$", "tree", "instanceof", "SwatDataTreeNode", ")", "{", "$", "tree", "=", "SwatTreeFlydownNode", "::", "convertFromDataTree", "(", "$", "tree", ")", ";", "}", "elseif", "(", "!", "(...
Sets the tree to use for display @param SwatTreeFlydownNode|SwatDataTreeNode $tree the tree to use for display.
[ "Sets", "the", "tree", "to", "use", "for", "display" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTreeFlydown.php#L152-L166
train
silverorange/swat
Swat/SwatTreeFlydown.php
SwatTreeFlydown.process
public function process() { parent::process(); if ($this->value === null) { $this->path = array(); } else { $this->path = $this->value; $this->value = end($this->path); } }
php
public function process() { parent::process(); if ($this->value === null) { $this->path = array(); } else { $this->path = $this->value; $this->value = end($this->path); } }
[ "public", "function", "process", "(", ")", "{", "parent", "::", "process", "(", ")", ";", "if", "(", "$", "this", "->", "value", "===", "null", ")", "{", "$", "this", "->", "path", "=", "array", "(", ")", ";", "}", "else", "{", "$", "this", "->...
Processes this tree flydown Populates the path property of this flydown with the path to the node selected by the user. The widget value is set to the last id in the path array.
[ "Processes", "this", "tree", "flydown" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatTreeFlydown.php#L192-L202
train
brainworxx/kreXX
src/Analyse/Routing/Process/ProcessClosure.php
ProcessClosure.process
public function process(Model $model) { $ref = new \ReflectionFunction($model->getData()); $result = array(); // Adding comments from the file. $result[static::META_COMMENT] = $this->pool ->createClass('Brainworxx\\Krexx\\Analyse\\Comment\\Functions') ->getComment($ref); // Adding the sourcecode $highlight = $ref->getStartLine() -1; $result[static::META_SOURCE] = $this->pool->fileService->readSourcecode( $ref->getFileName(), $highlight, $highlight - 3, $ref->getEndLine() -1 ); // Adding the place where it was declared. $result[static::META_DECLARED_IN] = $this->pool->fileService->filterFilePath($ref->getFileName()) . "\n"; $result[static::META_DECLARED_IN] .= 'in line ' . $ref->getStartLine(); // Adding the namespace, but only if we have one. $namespace = $ref->getNamespaceName(); if (empty($namespace) === false) { $result[static::META_NAMESPACE] = $namespace; } // Adding the parameters. $paramList = ''; foreach ($ref->getParameters() as $key => $reflectionParameter) { ++$key; $paramList .= $result[static::META_PARAM_NO . $key] = $this->pool ->codegenHandler ->parameterToString($reflectionParameter); // We add a comma to the parameter list, to separate them for a // better readability. $paramList .= ', '; } return $this->pool->render->renderExpandableChild( $model->setType(static::TYPE_CLOSURE) ->setNormal(static::UNKNOWN_VALUE) // Remove the ',' after the last char. ->setConnectorParameters(trim($paramList, ', ')) ->setDomid($this->generateDomIdFromObject($model->getData())) ->setConnectorType(Connectors::METHOD) ->addParameter(static::PARAM_DATA, $result) ->injectCallback( $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughMethodAnalysis') ) ); }
php
public function process(Model $model) { $ref = new \ReflectionFunction($model->getData()); $result = array(); // Adding comments from the file. $result[static::META_COMMENT] = $this->pool ->createClass('Brainworxx\\Krexx\\Analyse\\Comment\\Functions') ->getComment($ref); // Adding the sourcecode $highlight = $ref->getStartLine() -1; $result[static::META_SOURCE] = $this->pool->fileService->readSourcecode( $ref->getFileName(), $highlight, $highlight - 3, $ref->getEndLine() -1 ); // Adding the place where it was declared. $result[static::META_DECLARED_IN] = $this->pool->fileService->filterFilePath($ref->getFileName()) . "\n"; $result[static::META_DECLARED_IN] .= 'in line ' . $ref->getStartLine(); // Adding the namespace, but only if we have one. $namespace = $ref->getNamespaceName(); if (empty($namespace) === false) { $result[static::META_NAMESPACE] = $namespace; } // Adding the parameters. $paramList = ''; foreach ($ref->getParameters() as $key => $reflectionParameter) { ++$key; $paramList .= $result[static::META_PARAM_NO . $key] = $this->pool ->codegenHandler ->parameterToString($reflectionParameter); // We add a comma to the parameter list, to separate them for a // better readability. $paramList .= ', '; } return $this->pool->render->renderExpandableChild( $model->setType(static::TYPE_CLOSURE) ->setNormal(static::UNKNOWN_VALUE) // Remove the ',' after the last char. ->setConnectorParameters(trim($paramList, ', ')) ->setDomid($this->generateDomIdFromObject($model->getData())) ->setConnectorType(Connectors::METHOD) ->addParameter(static::PARAM_DATA, $result) ->injectCallback( $this->pool->createClass('Brainworxx\\Krexx\\Analyse\\Callback\\Iterate\\ThroughMethodAnalysis') ) ); }
[ "public", "function", "process", "(", "Model", "$", "model", ")", "{", "$", "ref", "=", "new", "\\", "ReflectionFunction", "(", "$", "model", "->", "getData", "(", ")", ")", ";", "$", "result", "=", "array", "(", ")", ";", "// Adding comments from the fi...
Analyses a closure. @param Model $model The closure we want to analyse. @throws \ReflectionException @return string The generated markup.
[ "Analyses", "a", "closure", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Routing/Process/ProcessClosure.php#L59-L114
train
rhoone/yii2-rhoone
base/DictionaryManager.php
DictionaryManager.getHeadwords
public function getHeadwords($class = null, $words = []) { // Method One: if ($class === null || $class === false || (is_string($class) && empty($class))) { $query = Headword::find(); } else { $extensions = ExtensionManager::getModels($class); $guids = []; foreach ($extensions as $extension) { $guids[] = $extension->guid; } $query = Headword::find()->guid($guids); } if (is_array($words) && !empty($words)) { $query = $query->word($words); } foreach ($query->all() as $headword) { yield $headword; } // Method Two: //return Headword::find()->all(); }
php
public function getHeadwords($class = null, $words = []) { // Method One: if ($class === null || $class === false || (is_string($class) && empty($class))) { $query = Headword::find(); } else { $extensions = ExtensionManager::getModels($class); $guids = []; foreach ($extensions as $extension) { $guids[] = $extension->guid; } $query = Headword::find()->guid($guids); } if (is_array($words) && !empty($words)) { $query = $query->word($words); } foreach ($query->all() as $headword) { yield $headword; } // Method Two: //return Headword::find()->all(); }
[ "public", "function", "getHeadwords", "(", "$", "class", "=", "null", ",", "$", "words", "=", "[", "]", ")", "{", "// Method One:", "if", "(", "$", "class", "===", "null", "||", "$", "class", "===", "false", "||", "(", "is_string", "(", "$", "class",...
Headwords generator. @param string|\rhoone\extension\Extension|\rhoone\models\Extension|mixed $class `string` if extension class. @param string[] $words @throws InvalidParamException
[ "Headwords", "generator", "." ]
f6ae90d466ea6f34bba404be0aba03e37ef369ad
https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/base/DictionaryManager.php#L39-L60
train
rhoone/yii2-rhoone
base/DictionaryManager.php
DictionaryManager.getSynonyms
public function getSynonyms($class = null, $words = []) { // Method One: $query = Synonym::find(); if (is_array($words) && !empty($words)) { $query = $query->word($words); } if (!($class === null || $class === false || (is_string($class) && empty($class)))) { $query = $query->extension($class); } foreach ($query->all() as $synonyms) { yield $synonyms; } // Method Two: //return Synonym::find()->all(); }
php
public function getSynonyms($class = null, $words = []) { // Method One: $query = Synonym::find(); if (is_array($words) && !empty($words)) { $query = $query->word($words); } if (!($class === null || $class === false || (is_string($class) && empty($class)))) { $query = $query->extension($class); } foreach ($query->all() as $synonyms) { yield $synonyms; } // Method Two: //return Synonym::find()->all(); }
[ "public", "function", "getSynonyms", "(", "$", "class", "=", "null", ",", "$", "words", "=", "[", "]", ")", "{", "// Method One:", "$", "query", "=", "Synonym", "::", "find", "(", ")", ";", "if", "(", "is_array", "(", "$", "words", ")", "&&", "!", ...
Synonyms generator. @param string|\rhoone\extension\Extension|\rhoone\models\Extension|mixed $class `string` if extension class. @param string[] $words @throws InvalidParamException
[ "Synonyms", "generator", "." ]
f6ae90d466ea6f34bba404be0aba03e37ef369ad
https://github.com/rhoone/yii2-rhoone/blob/f6ae90d466ea6f34bba404be0aba03e37ef369ad/base/DictionaryManager.php#L69-L84
train
brainworxx/kreXX
src/Analyse/Caller/CallerFinder.php
CallerFinder.getVarName
protected function getVarName($file, $line) { // Set a fallback value. $varname = static::UNKNOWN_VALUE; // Retrieve the call from the sourcecode file. if ($this->pool->fileService->fileIsReadable($file) === false) { return $varname; } $line--; // Now that we have the line where it was called, we must check if // we have several commands in there. $possibleCommands = explode(';', $this->pool->fileService->readFile($file, $line, $line)); // Now we must weed out the none krexx commands. foreach ($possibleCommands as $key => $command) { if (strpos(strtolower($command), strtolower($this->pattern)) === false) { unset($possibleCommands[$key]); } } // I have no idea how to determine the actual call of krexx if we // are dealing with several calls per line. if (count($possibleCommands) === 1) { // Now that we have our actual call, we must remove the krexx-part // from it. foreach ($this->callPattern as $funcname) { // This little baby tries to resolve everything inside the // brackets of the kreXX call. preg_match('/' . $funcname . '\s*\((.*)\)\s*/u', reset($possibleCommands), $name); if (isset($name[1]) === true) { $varname = $this->pool->encodingService->encodeString(trim($name[1], " \t\n\r\0\x0B'\"")); break; } } } return $varname; }
php
protected function getVarName($file, $line) { // Set a fallback value. $varname = static::UNKNOWN_VALUE; // Retrieve the call from the sourcecode file. if ($this->pool->fileService->fileIsReadable($file) === false) { return $varname; } $line--; // Now that we have the line where it was called, we must check if // we have several commands in there. $possibleCommands = explode(';', $this->pool->fileService->readFile($file, $line, $line)); // Now we must weed out the none krexx commands. foreach ($possibleCommands as $key => $command) { if (strpos(strtolower($command), strtolower($this->pattern)) === false) { unset($possibleCommands[$key]); } } // I have no idea how to determine the actual call of krexx if we // are dealing with several calls per line. if (count($possibleCommands) === 1) { // Now that we have our actual call, we must remove the krexx-part // from it. foreach ($this->callPattern as $funcname) { // This little baby tries to resolve everything inside the // brackets of the kreXX call. preg_match('/' . $funcname . '\s*\((.*)\)\s*/u', reset($possibleCommands), $name); if (isset($name[1]) === true) { $varname = $this->pool->encodingService->encodeString(trim($name[1], " \t\n\r\0\x0B'\"")); break; } } } return $varname; }
[ "protected", "function", "getVarName", "(", "$", "file", ",", "$", "line", ")", "{", "// Set a fallback value.", "$", "varname", "=", "static", "::", "UNKNOWN_VALUE", ";", "// Retrieve the call from the sourcecode file.", "if", "(", "$", "this", "->", "pool", "->"...
Tries to extract the name of the variable which we try to analyse. @param string $file Path to the sourcecode file. @param int $line The line from where kreXX was called. @return string The name of the variable.
[ "Tries", "to", "extract", "the", "name", "of", "the", "variable", "which", "we", "try", "to", "analyse", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Analyse/Caller/CallerFinder.php#L126-L165
train
silverorange/swat
Swat/SwatHtmlHeadEntry.php
SwatHtmlHeadEntry.display
public function display($uri_prefix = '', $tag = null) { $this->openIECondition(); $this->displayInternal($uri_prefix, $tag); $this->closeIECondition(); }
php
public function display($uri_prefix = '', $tag = null) { $this->openIECondition(); $this->displayInternal($uri_prefix, $tag); $this->closeIECondition(); }
[ "public", "function", "display", "(", "$", "uri_prefix", "=", "''", ",", "$", "tag", "=", "null", ")", "{", "$", "this", "->", "openIECondition", "(", ")", ";", "$", "this", "->", "displayInternal", "(", "$", "uri_prefix", ",", "$", "tag", ")", ";", ...
Displays this html head entry Entries are displayed differently based on type. @param string $uri_prefix an optional string to prefix the URI with. @param string $tag an optional tag to suffix the URI with. This is suffixed as a HTTP get var and can be used to explicitly refresh the browser cache.
[ "Displays", "this", "html", "head", "entry" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatHtmlHeadEntry.php#L64-L69
train
gdbots/schemas
build/php/src/Gdbots/Schemas/Ncr/NodeRef.php
NodeRef.fromFilePath
public static function fromFilePath(string $string): self { $parts = explode('/', $string, 5); unset($parts[2]); unset($parts[3]); return self::fromString( str_replace(['__FS__', '__CLN__'], ['/', ':'], implode(':', $parts)) ); }
php
public static function fromFilePath(string $string): self { $parts = explode('/', $string, 5); unset($parts[2]); unset($parts[3]); return self::fromString( str_replace(['__FS__', '__CLN__'], ['/', ':'], implode(':', $parts)) ); }
[ "public", "static", "function", "fromFilePath", "(", "string", "$", "string", ")", ":", "self", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "string", ",", "5", ")", ";", "unset", "(", "$", "parts", "[", "2", "]", ")", ";", "unset", "...
Creates a NodeRef from a file path, assuming it was generated by the "toFilePath" method. @param string $string @return static
[ "Creates", "a", "NodeRef", "from", "a", "file", "path", "assuming", "it", "was", "generated", "by", "the", "toFilePath", "method", "." ]
daa2d8257b151c6cf48b3fc60ff50155a037045a
https://github.com/gdbots/schemas/blob/daa2d8257b151c6cf48b3fc60ff50155a037045a/build/php/src/Gdbots/Schemas/Ncr/NodeRef.php#L160-L169
train
brainworxx/kreXX
src/Service/Plugin/Registration.php
Registration.registerAdditionalskin
public static function registerAdditionalskin($name, $className, $directory) { static::$additionalSkinList[$name] = array( static::SKIN_CLASS => $className, static::SKIN_DIRECTORY => $directory ); }
php
public static function registerAdditionalskin($name, $className, $directory) { static::$additionalSkinList[$name] = array( static::SKIN_CLASS => $className, static::SKIN_DIRECTORY => $directory ); }
[ "public", "static", "function", "registerAdditionalskin", "(", "$", "name", ",", "$", "className", ",", "$", "directory", ")", "{", "static", "::", "$", "additionalSkinList", "[", "$", "name", "]", "=", "array", "(", "static", "::", "SKIN_CLASS", "=>", "$"...
Register an additional skin. You can also overwrite already existing skins, if you use their name. @param string $name The name of the skin. 'hans' and 'smokygrey' are the bundeled ones. @param string $className The full qualified class name of the renderer @param string $directory The absolute path to the skin html files.
[ "Register", "an", "additional", "skin", ".", "You", "can", "also", "overwrite", "already", "existing", "skins", "if", "you", "use", "their", "name", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Plugin/Registration.php#L256-L262
train
brainworxx/kreXX
src/Service/Plugin/Registration.php
Registration.activatePlugin
public static function activatePlugin($configClass) { if (isset(static::$plugins[$configClass])) { static::$plugins[$configClass][static::IS_ACTIVE] = true; /** @var \Brainworxx\Krexx\Service\Plugin\PluginConfigInterface $staticPlugin */ $staticPlugin = static::$plugins[$configClass][static::CONFIG_CLASS]; $staticPlugin::exec(); if (isset(Krexx::$pool)) { // Update stuff in the pool. Krexx::$pool->rewrite = static::$rewriteList; Krexx::$pool->eventService->register = static::$eventList; Krexx::$pool->messages->readHelpTexts(); } } // No registration, no config, no plugin. // Do nothing. }
php
public static function activatePlugin($configClass) { if (isset(static::$plugins[$configClass])) { static::$plugins[$configClass][static::IS_ACTIVE] = true; /** @var \Brainworxx\Krexx\Service\Plugin\PluginConfigInterface $staticPlugin */ $staticPlugin = static::$plugins[$configClass][static::CONFIG_CLASS]; $staticPlugin::exec(); if (isset(Krexx::$pool)) { // Update stuff in the pool. Krexx::$pool->rewrite = static::$rewriteList; Krexx::$pool->eventService->register = static::$eventList; Krexx::$pool->messages->readHelpTexts(); } } // No registration, no config, no plugin. // Do nothing. }
[ "public", "static", "function", "activatePlugin", "(", "$", "configClass", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "plugins", "[", "$", "configClass", "]", ")", ")", "{", "static", "::", "$", "plugins", "[", "$", "configClass", "]", "["...
We activate the plugin with the name, and execute its configuration method. @param string $configClass The class name of the configuration class for this plugin.
[ "We", "activate", "the", "plugin", "with", "the", "name", "and", "execute", "its", "configuration", "method", "." ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Plugin/Registration.php#L287-L304
train
brainworxx/kreXX
src/Service/Plugin/Registration.php
Registration.deactivatePlugin
public static function deactivatePlugin($configClass) { if (static::$plugins[$configClass][static::IS_ACTIVE] !== true) { // We will not purge everything for a already deactivated plugin. return; } // Purge all settings in the underlying registration class. static::$logFolder = ''; static::$chunkFolder = ''; static::$configFile = ''; static::$blacklistDebugMethods = array(); static::$blacklistDebugClass = array(); static::$additionalHelpFiles = array(); static::$eventList = array(); static::$rewriteList = array(); static::$additionalSkinList = array(); // Go through the remaining plugins. static::$plugins[$configClass][static::IS_ACTIVE] = false; foreach (static::$plugins as $pluginName => $plugin) { if ($plugin[static::IS_ACTIVE]) { call_user_func(array(static::$plugins[$pluginName][static::CONFIG_CLASS], 'exec')); } } // Renew the configuration class, so the new one will load all settings // from the registration class. if (isset(Krexx::$pool)) { Krexx::$pool->rewrite = static::$rewriteList; Krexx::$pool->eventService->register = static::$eventList; Krexx::$pool->config = Krexx::$pool->createClass('Brainworxx\\Krexx\\Service\\Config\\Config'); Krexx::$pool->messages->readHelpTexts(); } }
php
public static function deactivatePlugin($configClass) { if (static::$plugins[$configClass][static::IS_ACTIVE] !== true) { // We will not purge everything for a already deactivated plugin. return; } // Purge all settings in the underlying registration class. static::$logFolder = ''; static::$chunkFolder = ''; static::$configFile = ''; static::$blacklistDebugMethods = array(); static::$blacklistDebugClass = array(); static::$additionalHelpFiles = array(); static::$eventList = array(); static::$rewriteList = array(); static::$additionalSkinList = array(); // Go through the remaining plugins. static::$plugins[$configClass][static::IS_ACTIVE] = false; foreach (static::$plugins as $pluginName => $plugin) { if ($plugin[static::IS_ACTIVE]) { call_user_func(array(static::$plugins[$pluginName][static::CONFIG_CLASS], 'exec')); } } // Renew the configuration class, so the new one will load all settings // from the registration class. if (isset(Krexx::$pool)) { Krexx::$pool->rewrite = static::$rewriteList; Krexx::$pool->eventService->register = static::$eventList; Krexx::$pool->config = Krexx::$pool->createClass('Brainworxx\\Krexx\\Service\\Config\\Config'); Krexx::$pool->messages->readHelpTexts(); } }
[ "public", "static", "function", "deactivatePlugin", "(", "$", "configClass", ")", "{", "if", "(", "static", "::", "$", "plugins", "[", "$", "configClass", "]", "[", "static", "::", "IS_ACTIVE", "]", "!==", "true", ")", "{", "// We will not purge everything for...
We deactivate the plugin and reset the configuration @param string $configClass The name of the plugin.
[ "We", "deactivate", "the", "plugin", "and", "reset", "the", "configuration" ]
a03beaa4507ffb391412b9ac61593d263d3f8bca
https://github.com/brainworxx/kreXX/blob/a03beaa4507ffb391412b9ac61593d263d3f8bca/src/Service/Plugin/Registration.php#L312-L346
train
silverorange/swat
Swat/SwatCascadeFlydown.php
SwatCascadeFlydown.addOptionsByArray
public function addOptionsByArray( array $options, $content_type = 'text/plain' ) { foreach ($options as $parent => $child_options) { foreach ($child_options as $value => $title) { $this->addOption($parent, $value, $title, $content_type); } } }
php
public function addOptionsByArray( array $options, $content_type = 'text/plain' ) { foreach ($options as $parent => $child_options) { foreach ($child_options as $value => $title) { $this->addOption($parent, $value, $title, $content_type); } } }
[ "public", "function", "addOptionsByArray", "(", "array", "$", "options", ",", "$", "content_type", "=", "'text/plain'", ")", "{", "foreach", "(", "$", "options", "as", "$", "parent", "=>", "$", "child_options", ")", "{", "foreach", "(", "$", "child_options",...
Adds options to this option control using an associative array @param array $options an array of options. Keys are option parent values. Values are a 2-element associative array of title => value pairs. @param string $content_type optional. The content type of the option titles. If not specified, defaults to 'text/plain'.
[ "Adds", "options", "to", "this", "option", "control", "using", "an", "associative", "array" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCascadeFlydown.php#L133-L142
train
silverorange/swat
Swat/SwatCascadeFlydown.php
SwatCascadeFlydown.&
protected function &getOptions() { $options = array(); // If the parent flydown is empty, set parent_value to a blank string. // This will then return any options that exist for a blank parent. $parent_value = $this->hasEmptyParent() ? '' : $this->getParentValue(); // parent_value is null when the parent has multiple options if ($parent_value === null) { if ($this->cascade_from->show_blank) { // select the blank option on the cascade from $options = array( new SwatOption('', '&nbsp;'), new SwatOption('', '&nbsp;') ); } else { // select the first option on the cascade from $from_options = $this->cascade_from->getOptions(); $first_value = reset($from_options)->value; $options = $this->options[$first_value]; } } elseif (isset($this->options[$parent_value])) { $options = $this->options[$parent_value]; } else { // if the options array doesn't exist for this parent_value, then // assume that means we don't want any values in this flydown for // that option. $options = array(new SwatOption(null, null)); } return $options; }
php
protected function &getOptions() { $options = array(); // If the parent flydown is empty, set parent_value to a blank string. // This will then return any options that exist for a blank parent. $parent_value = $this->hasEmptyParent() ? '' : $this->getParentValue(); // parent_value is null when the parent has multiple options if ($parent_value === null) { if ($this->cascade_from->show_blank) { // select the blank option on the cascade from $options = array( new SwatOption('', '&nbsp;'), new SwatOption('', '&nbsp;') ); } else { // select the first option on the cascade from $from_options = $this->cascade_from->getOptions(); $first_value = reset($from_options)->value; $options = $this->options[$first_value]; } } elseif (isset($this->options[$parent_value])) { $options = $this->options[$parent_value]; } else { // if the options array doesn't exist for this parent_value, then // assume that means we don't want any values in this flydown for // that option. $options = array(new SwatOption(null, null)); } return $options; }
[ "protected", "function", "&", "getOptions", "(", ")", "{", "$", "options", "=", "array", "(", ")", ";", "// If the parent flydown is empty, set parent_value to a blank string.", "// This will then return any options that exist for a blank parent.", "$", "parent_value", "=", "$"...
Gets the options of this flydown as a flat array For the cascading flydown, the array returned The array is of the form: value => title @return array the options of this flydown as a flat array. @see SwatFlydown::getOptions()
[ "Gets", "the", "options", "of", "this", "flydown", "as", "a", "flat", "array" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCascadeFlydown.php#L159-L191
train
silverorange/swat
Swat/SwatCascadeFlydown.php
SwatCascadeFlydown.getInlineJavaScript
protected function getInlineJavaScript() { // Javascript is unnecessary when the parent flydown is empty, or when // it has a single value as in both cases the parent value never // changes. if ($this->hasEmptyParent() || $this->hasSingleParent()) { return; } $javascript = sprintf( "var %s_cascade = new SwatCascade('%s', '%s');", $this->id, $this->cascade_from->id, $this->id ); $salt = $this->getForm()->getSalt(); $flydown_value = $this->serialize_values ? $this->value : (string) $this->value; foreach ($this->options as $parent => $options) { if ($this->cascade_from->serialize_values) { $parent = SwatString::signedSerialize($parent, $salt); } if ($this->show_blank && count($options) > 0) { if ($this->serialize_values) { $value = SwatString::signedSerialize(null, $salt); } else { $value = ''; } $blank_title = $this->blank_title === null ? Swat::_('choose one ...') : $this->blank_title; $javascript .= sprintf( "\n%s_cascade.addChild(%s, %s, %s);", $this->id, SwatString::quoteJavaScriptString($parent), SwatString::quoteJavaScriptString($value), SwatString::quoteJavaScriptString($blank_title) ); } foreach ($options as $option) { if ($this->serialize_values) { // if they are serialized, we want to compare the actual // values $selected = $flydown_value === $option->value ? 'true' : 'false'; $value = SwatString::signedSerialize($option->value, $salt); } else { // if they are not serialized, we want to compare the string // value $value = (string) $option->value; $selected = $flydown_value === $value ? 'true' : 'false'; } $javascript .= sprintf( "\n%s_cascade.addChild(%s, %s, %s, %s);", $this->id, SwatString::quoteJavaScriptString($parent), SwatString::quoteJavaScriptString($value), SwatString::quoteJavaScriptString($option->title), $selected ); } } $javascript .= sprintf("\n%s_cascade.init();", $this->id); return $javascript; }
php
protected function getInlineJavaScript() { // Javascript is unnecessary when the parent flydown is empty, or when // it has a single value as in both cases the parent value never // changes. if ($this->hasEmptyParent() || $this->hasSingleParent()) { return; } $javascript = sprintf( "var %s_cascade = new SwatCascade('%s', '%s');", $this->id, $this->cascade_from->id, $this->id ); $salt = $this->getForm()->getSalt(); $flydown_value = $this->serialize_values ? $this->value : (string) $this->value; foreach ($this->options as $parent => $options) { if ($this->cascade_from->serialize_values) { $parent = SwatString::signedSerialize($parent, $salt); } if ($this->show_blank && count($options) > 0) { if ($this->serialize_values) { $value = SwatString::signedSerialize(null, $salt); } else { $value = ''; } $blank_title = $this->blank_title === null ? Swat::_('choose one ...') : $this->blank_title; $javascript .= sprintf( "\n%s_cascade.addChild(%s, %s, %s);", $this->id, SwatString::quoteJavaScriptString($parent), SwatString::quoteJavaScriptString($value), SwatString::quoteJavaScriptString($blank_title) ); } foreach ($options as $option) { if ($this->serialize_values) { // if they are serialized, we want to compare the actual // values $selected = $flydown_value === $option->value ? 'true' : 'false'; $value = SwatString::signedSerialize($option->value, $salt); } else { // if they are not serialized, we want to compare the string // value $value = (string) $option->value; $selected = $flydown_value === $value ? 'true' : 'false'; } $javascript .= sprintf( "\n%s_cascade.addChild(%s, %s, %s, %s);", $this->id, SwatString::quoteJavaScriptString($parent), SwatString::quoteJavaScriptString($value), SwatString::quoteJavaScriptString($option->title), $selected ); } } $javascript .= sprintf("\n%s_cascade.init();", $this->id); return $javascript; }
[ "protected", "function", "getInlineJavaScript", "(", ")", "{", "// Javascript is unnecessary when the parent flydown is empty, or when", "// it has a single value as in both cases the parent value never", "// changes.", "if", "(", "$", "this", "->", "hasEmptyParent", "(", ")", "||"...
Gets the inline JavaScript that makes this control work @return string the inline JavaScript that makes this control work.
[ "Gets", "the", "inline", "JavaScript", "that", "makes", "this", "control", "work" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCascadeFlydown.php#L251-L329
train
silverorange/swat
Swat/SwatCellRendererSet.php
SwatCellRendererSet.addRenderer
public function addRenderer(SwatCellRenderer $renderer) { $this->renderers[] = $renderer; $renderer_key = spl_object_hash($renderer); $this->mappings[$renderer_key] = array(); if ($renderer->id !== null) { $this->renderers_by_id[$renderer->id] = $renderer; } }
php
public function addRenderer(SwatCellRenderer $renderer) { $this->renderers[] = $renderer; $renderer_key = spl_object_hash($renderer); $this->mappings[$renderer_key] = array(); if ($renderer->id !== null) { $this->renderers_by_id[$renderer->id] = $renderer; } }
[ "public", "function", "addRenderer", "(", "SwatCellRenderer", "$", "renderer", ")", "{", "$", "this", "->", "renderers", "[", "]", "=", "$", "renderer", ";", "$", "renderer_key", "=", "spl_object_hash", "(", "$", "renderer", ")", ";", "$", "this", "->", ...
Adds a cell renderer to this set An empty datafield-property mapping array is created for the added renderer. @param SwatCellRenderer $renderer the renderer to add.
[ "Adds", "a", "cell", "renderer", "to", "this", "set" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererSet.php#L64-L74
train
silverorange/swat
Swat/SwatCellRendererSet.php
SwatCellRendererSet.addRendererWithMappings
public function addRendererWithMappings( SwatCellRenderer $renderer, array $mappings = array() ) { $this->addRenderer($renderer); $this->addMappingsToRenderer($renderer, $mappings); }
php
public function addRendererWithMappings( SwatCellRenderer $renderer, array $mappings = array() ) { $this->addRenderer($renderer); $this->addMappingsToRenderer($renderer, $mappings); }
[ "public", "function", "addRendererWithMappings", "(", "SwatCellRenderer", "$", "renderer", ",", "array", "$", "mappings", "=", "array", "(", ")", ")", "{", "$", "this", "->", "addRenderer", "(", "$", "renderer", ")", ";", "$", "this", "->", "addMappingsToRen...
Adds a cell renderer to this set with a predefined set of datafield-property mappings @param SwatCellRenderer $renderer the renderer to add. @param array $mappings an array of SwatCellRendererMapping objects. @see SwatCellRendererSet::addRenderer() @see SwatCellRendererSet::addMappingsToRenderer()
[ "Adds", "a", "cell", "renderer", "to", "this", "set", "with", "a", "predefined", "set", "of", "datafield", "-", "property", "mappings" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererSet.php#L89-L95
train
silverorange/swat
Swat/SwatCellRendererSet.php
SwatCellRendererSet.addMappingsToRenderer
public function addMappingsToRenderer( SwatCellRenderer $renderer, array $mappings = array() ) { $renderer_key = spl_object_hash($renderer); foreach ($mappings as $mapping) { if ($renderer->isPropertyStatic($mapping->property)) { throw new SwatException( sprintf( 'The %s property can not be data-mapped', $mapping->property ) ); } $this->mappings[$renderer_key][] = $mapping; } }
php
public function addMappingsToRenderer( SwatCellRenderer $renderer, array $mappings = array() ) { $renderer_key = spl_object_hash($renderer); foreach ($mappings as $mapping) { if ($renderer->isPropertyStatic($mapping->property)) { throw new SwatException( sprintf( 'The %s property can not be data-mapped', $mapping->property ) ); } $this->mappings[$renderer_key][] = $mapping; } }
[ "public", "function", "addMappingsToRenderer", "(", "SwatCellRenderer", "$", "renderer", ",", "array", "$", "mappings", "=", "array", "(", ")", ")", "{", "$", "renderer_key", "=", "spl_object_hash", "(", "$", "renderer", ")", ";", "foreach", "(", "$", "mappi...
Adds a set of datafield-property mappings to a cell renderer already in this set @param SwatCellRenderer $renderer the cell renderer to add the mappings to. @param array $mappings an array of SwatCellRendererMapping objects. @throws SwatException if an attepmt to map a static cell renderer property is made.
[ "Adds", "a", "set", "of", "datafield", "-", "property", "mappings", "to", "a", "cell", "renderer", "already", "in", "this", "set" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererSet.php#L111-L129
train
silverorange/swat
Swat/SwatCellRendererSet.php
SwatCellRendererSet.addMappingToRenderer
public function addMappingToRenderer( SwatCellRenderer $renderer, SwatCellRendererMapping $mapping ) { if ($renderer->isPropertyStatic($mapping->property)) { throw new SwatException( sprintf( 'The %s property can not be data-mapped', $mapping->property ) ); } $renderer_key = spl_object_hash($renderer); $this->mappings[$renderer_key][] = $mapping; }
php
public function addMappingToRenderer( SwatCellRenderer $renderer, SwatCellRendererMapping $mapping ) { if ($renderer->isPropertyStatic($mapping->property)) { throw new SwatException( sprintf( 'The %s property can not be data-mapped', $mapping->property ) ); } $renderer_key = spl_object_hash($renderer); $this->mappings[$renderer_key][] = $mapping; }
[ "public", "function", "addMappingToRenderer", "(", "SwatCellRenderer", "$", "renderer", ",", "SwatCellRendererMapping", "$", "mapping", ")", "{", "if", "(", "$", "renderer", "->", "isPropertyStatic", "(", "$", "mapping", "->", "property", ")", ")", "{", "throw",...
Adds a single property-datafield mapping to a cell renderer already in this set @param SwatCellRenderer $renderer the cell renderer to add the mapping to. @param SwatCellRendererMapping $mapping the mapping to add. @throws SwatException if an attepmt to map a static cell renderer property is made.
[ "Adds", "a", "single", "property", "-", "datafield", "mapping", "to", "a", "cell", "renderer", "already", "in", "this", "set" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererSet.php#L145-L160
train
silverorange/swat
Swat/SwatCellRendererSet.php
SwatCellRendererSet.applyMappingsToRenderer
public function applyMappingsToRenderer( SwatCellRenderer $renderer, $data_object ) { // array to track array properties that we've already seen $array_properties = array(); $renderer_hash = spl_object_hash($renderer); foreach ($this->mappings[$renderer_hash] as $mapping) { // set local variables $property = $mapping->property; $field = $mapping->field; if ($mapping->is_array) { if (in_array($property, $array_properties)) { // already have an array $array_ref = &$renderer->$property; if ($mapping->array_key === null) { $array_ref[] = $data_object->$field; } else { $array_ref[$mapping->array_key] = $data_object->$field; } } else { // starting a new array $array_properties[] = $mapping->property; if ($mapping->array_key === null) { $renderer->$property = array($data_object->$field); } else { $renderer->$property = array( $mapping->array_key => $data_object->$field ); } } } else { // look for leading '!' and inverse value if found if (strncmp($field, '!', 1) === 0) { $field = mb_substr($field, 1); $renderer->$property = !$data_object->$field; } else { $renderer->$property = $data_object->$field; } } } $this->mappings_applied = true; }
php
public function applyMappingsToRenderer( SwatCellRenderer $renderer, $data_object ) { // array to track array properties that we've already seen $array_properties = array(); $renderer_hash = spl_object_hash($renderer); foreach ($this->mappings[$renderer_hash] as $mapping) { // set local variables $property = $mapping->property; $field = $mapping->field; if ($mapping->is_array) { if (in_array($property, $array_properties)) { // already have an array $array_ref = &$renderer->$property; if ($mapping->array_key === null) { $array_ref[] = $data_object->$field; } else { $array_ref[$mapping->array_key] = $data_object->$field; } } else { // starting a new array $array_properties[] = $mapping->property; if ($mapping->array_key === null) { $renderer->$property = array($data_object->$field); } else { $renderer->$property = array( $mapping->array_key => $data_object->$field ); } } } else { // look for leading '!' and inverse value if found if (strncmp($field, '!', 1) === 0) { $field = mb_substr($field, 1); $renderer->$property = !$data_object->$field; } else { $renderer->$property = $data_object->$field; } } } $this->mappings_applied = true; }
[ "public", "function", "applyMappingsToRenderer", "(", "SwatCellRenderer", "$", "renderer", ",", "$", "data_object", ")", "{", "// array to track array properties that we've already seen", "$", "array_properties", "=", "array", "(", ")", ";", "$", "renderer_hash", "=", "...
Applies the property-datafield mappings to a cell renderer already in this set using a specified data object @param SwatCellRenderer $renderer the cell renderer to apply the mappings to. @param mixed $data_object an object containg datafields to be mapped onto the cell renderer.
[ "Applies", "the", "property", "-", "datafield", "mappings", "to", "a", "cell", "renderer", "already", "in", "this", "set", "using", "a", "specified", "data", "object" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererSet.php#L174-L221
train
silverorange/swat
Swat/SwatCellRendererSet.php
SwatCellRendererSet.getRendererByPosition
public function getRendererByPosition($position = 0) { if ($position < count($this->renderers)) { return $this->renderers[$position]; } throw new SwatObjectNotFoundException( 'Set does not contain that many renderers.', 0, $position ); }
php
public function getRendererByPosition($position = 0) { if ($position < count($this->renderers)) { return $this->renderers[$position]; } throw new SwatObjectNotFoundException( 'Set does not contain that many renderers.', 0, $position ); }
[ "public", "function", "getRendererByPosition", "(", "$", "position", "=", "0", ")", "{", "if", "(", "$", "position", "<", "count", "(", "$", "this", "->", "renderers", ")", ")", "{", "return", "$", "this", "->", "renderers", "[", "$", "position", "]", ...
Gets a cell renderer in this set by its ordinal position @param integer $position the ordinal position of the renderer. @return SwatCellRenderer the cell renderer at the specified position. @throws SwatObjectNotFoundException if the requested <i>$position</i> is greater than the number of cell renderers in this set.
[ "Gets", "a", "cell", "renderer", "in", "this", "set", "by", "its", "ordinal", "position" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererSet.php#L237-L248
train
silverorange/swat
Swat/SwatCellRendererSet.php
SwatCellRendererSet.getRenderer
public function getRenderer($renderer_id) { if (array_key_exists($renderer_id, $this->renderers_by_id)) { return $this->renderers_by_id[$renderer_id]; } throw new SwatObjectNotFoundException( "Cell renderer with an id of '{$renderer_id}' not found.", 0, $renderer_id ); }
php
public function getRenderer($renderer_id) { if (array_key_exists($renderer_id, $this->renderers_by_id)) { return $this->renderers_by_id[$renderer_id]; } throw new SwatObjectNotFoundException( "Cell renderer with an id of '{$renderer_id}' not found.", 0, $renderer_id ); }
[ "public", "function", "getRenderer", "(", "$", "renderer_id", ")", "{", "if", "(", "array_key_exists", "(", "$", "renderer_id", ",", "$", "this", "->", "renderers_by_id", ")", ")", "{", "return", "$", "this", "->", "renderers_by_id", "[", "$", "renderer_id",...
Gets a renderer in this set by its id @param string $renderer_id the id of the renderer to get. @return SwatCellRenderer the cell renderer from this set with the given id. @throws SwatObjectNotFoundException if a renderer with the given <i>$renderer_id</i> does not exist in this set.
[ "Gets", "a", "renderer", "in", "this", "set", "by", "its", "id" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererSet.php#L265-L276
train
silverorange/swat
Swat/SwatCellRendererSet.php
SwatCellRendererSet.getFirst
public function getFirst() { $first = null; if (count($this->renderers) > 0) { $first = reset($this->renderers); } return $first; }
php
public function getFirst() { $first = null; if (count($this->renderers) > 0) { $first = reset($this->renderers); } return $first; }
[ "public", "function", "getFirst", "(", ")", "{", "$", "first", "=", "null", ";", "if", "(", "count", "(", "$", "this", "->", "renderers", ")", ">", "0", ")", "{", "$", "first", "=", "reset", "(", "$", "this", "->", "renderers", ")", ";", "}", "...
Gets the first renderer in this set @return SwatCellRenderer the first cell renderer in this set or null if there are no cell renderers in this set.
[ "Gets", "the", "first", "renderer", "in", "this", "set" ]
e65dc5bc351927c61f594068430cdeeb874c8bc5
https://github.com/silverorange/swat/blob/e65dc5bc351927c61f594068430cdeeb874c8bc5/Swat/SwatCellRendererSet.php#L384-L393
train