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
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/database/query/select.php
KDatabaseQuerySelect.where
public function where($condition, $combination = 'AND') { $this->where[] = array( 'condition' => $condition, 'combination' => count($this->where) ? $combination : '' ); return $this; }
php
public function where($condition, $combination = 'AND') { $this->where[] = array( 'condition' => $condition, 'combination' => count($this->where) ? $combination : '' ); return $this; }
[ "public", "function", "where", "(", "$", "condition", ",", "$", "combination", "=", "'AND'", ")", "{", "$", "this", "->", "where", "[", "]", "=", "array", "(", "'condition'", "=>", "$", "condition", ",", "'combination'", "=>", "count", "(", "$", "this"...
Build the where clause @param string $condition The where condition statement @param string $combination The where combination, defaults to 'AND' @return $this
[ "Build", "the", "where", "clause" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/query/select.php#L186-L194
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/database/query/select.php
KDatabaseQuerySelect.order
public function order($columns, $direction = 'ASC') { foreach ((array) $columns as $column) { $this->order[] = array( 'column' => $column, 'direction' => $direction ); } return $this; }
php
public function order($columns, $direction = 'ASC') { foreach ((array) $columns as $column) { $this->order[] = array( 'column' => $column, 'direction' => $direction ); } return $this; }
[ "public", "function", "order", "(", "$", "columns", ",", "$", "direction", "=", "'ASC'", ")", "{", "foreach", "(", "(", "array", ")", "$", "columns", "as", "$", "column", ")", "{", "$", "this", "->", "order", "[", "]", "=", "array", "(", "'column'"...
Build the order clause @param array|string $columns A string or array of ordering columns @param string $direction Either DESC or ASC @return $this
[ "Build", "the", "order", "clause" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/query/select.php#L227-L238
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/template/engine/markdown.php
KTemplateEngineMarkdown.loadFile
public function loadFile($url) { if(!$this->_source) { //Locate the template if (!$file = $this->getObject('template.locator.factory')->locate($url)) { throw new InvalidArgumentException(sprintf('The template "%s" cannot be located.', $url)); } if(!$cache_file = $this->isCached($file)) { //Load the template if(!$source = file_get_contents($file)) { throw new RuntimeException(sprintf('The template "%s" cannot be loaded.', $file)); } //Compile the template if(!$source = $this->_compile($source)) { throw new RuntimeException(sprintf('The template "%s" cannot be compiled.', $file)); } $this->cache($file, $source); $this->_source = $source; } else $this->_source = include $cache_file; } return $this; }
php
public function loadFile($url) { if(!$this->_source) { //Locate the template if (!$file = $this->getObject('template.locator.factory')->locate($url)) { throw new InvalidArgumentException(sprintf('The template "%s" cannot be located.', $url)); } if(!$cache_file = $this->isCached($file)) { //Load the template if(!$source = file_get_contents($file)) { throw new RuntimeException(sprintf('The template "%s" cannot be loaded.', $file)); } //Compile the template if(!$source = $this->_compile($source)) { throw new RuntimeException(sprintf('The template "%s" cannot be compiled.', $file)); } $this->cache($file, $source); $this->_source = $source; } else $this->_source = include $cache_file; } return $this; }
[ "public", "function", "loadFile", "(", "$", "url", ")", "{", "if", "(", "!", "$", "this", "->", "_source", ")", "{", "//Locate the template", "if", "(", "!", "$", "file", "=", "$", "this", "->", "getObject", "(", "'template.locator.factory'", ")", "->", ...
Load a template by url @param string $url The template url @throws InvalidArgumentException If the template could not be located @throws RuntimeException If the template could not be loaded @throws RuntimeException If the template could not be compiled @return KTemplateEngineMarkdown
[ "Load", "a", "template", "by", "url" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/markdown.php#L74-L102
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/template/engine/markdown.php
KTemplateEngineMarkdown.loadString
public function loadString($source) { $name = crc32($source); if(!$file = $this->isCached($name)) { //Compile the template if(!$this->_source = $this->_compile($source)) { throw new RuntimeException(sprintf('The template content cannot be compiled.')); } $this->cache($name, $this->_source); } else $this->_source = file_get_contents($file); return $this; }
php
public function loadString($source) { $name = crc32($source); if(!$file = $this->isCached($name)) { //Compile the template if(!$this->_source = $this->_compile($source)) { throw new RuntimeException(sprintf('The template content cannot be compiled.')); } $this->cache($name, $this->_source); } else $this->_source = file_get_contents($file); return $this; }
[ "public", "function", "loadString", "(", "$", "source", ")", "{", "$", "name", "=", "crc32", "(", "$", "source", ")", ";", "if", "(", "!", "$", "file", "=", "$", "this", "->", "isCached", "(", "$", "name", ")", ")", "{", "//Compile the template", "...
Load the template from a string @param string $source The template source @throws RuntimeException If the template could not be compiled @return KTemplateEngineMarkdown
[ "Load", "the", "template", "from", "a", "string" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/markdown.php#L111-L127
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/template/filter/chrome.php
ComKoowaTemplateFilterChrome.filter
public function filter(&$text) { $name = $this->getIdentifier()->package . '_' . $this->getIdentifier()->name; //Create a module object $module = new KObject(new KObjectConfig()); $module->id = uniqid(); $module->module = 'mod_'.$name; $module->content = $text; $module->position = $name; $module->params = 'moduleclass_sfx='.$this->_class; $module->showtitle = (bool) $this->_title; $module->title = $this->_title; $module->user = 0; $text = $this->getObject('mod://admin/koowa.html')->module($module)->attribs($this->_attribs)->styles($this->_styles)->render(); return $this; }
php
public function filter(&$text) { $name = $this->getIdentifier()->package . '_' . $this->getIdentifier()->name; //Create a module object $module = new KObject(new KObjectConfig()); $module->id = uniqid(); $module->module = 'mod_'.$name; $module->content = $text; $module->position = $name; $module->params = 'moduleclass_sfx='.$this->_class; $module->showtitle = (bool) $this->_title; $module->title = $this->_title; $module->user = 0; $text = $this->getObject('mod://admin/koowa.html')->module($module)->attribs($this->_attribs)->styles($this->_styles)->render(); return $this; }
[ "public", "function", "filter", "(", "&", "$", "text", ")", "{", "$", "name", "=", "$", "this", "->", "getIdentifier", "(", ")", "->", "package", ".", "'_'", ".", "$", "this", "->", "getIdentifier", "(", ")", "->", "name", ";", "//Create a module objec...
Apply module chrome to the template output @param string $text Block of text to parse @return ComKoowaTemplateFilterChrome
[ "Apply", "module", "chrome", "to", "the", "template", "output" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/filter/chrome.php#L97-L115
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/template/locator/file.php
KTemplateLocatorFile.qualify
public function qualify($url, $base) { if(!parse_url($url, PHP_URL_SCHEME)) { if ($url[0] != '/') { //Relative path $url = dirname($base) . '/' . $url; } else { //Absolute path $url = parse_url($base, PHP_URL_SCHEME) . ':/' . $url; } } return $this->normalise($url); }
php
public function qualify($url, $base) { if(!parse_url($url, PHP_URL_SCHEME)) { if ($url[0] != '/') { //Relative path $url = dirname($base) . '/' . $url; } else { //Absolute path $url = parse_url($base, PHP_URL_SCHEME) . ':/' . $url; } } return $this->normalise($url); }
[ "public", "function", "qualify", "(", "$", "url", ",", "$", "base", ")", "{", "if", "(", "!", "parse_url", "(", "$", "url", ",", "PHP_URL_SCHEME", ")", ")", "{", "if", "(", "$", "url", "[", "0", "]", "!=", "'/'", ")", "{", "//Relative path", "$",...
Qualify a template url @param string $url The template to qualify @param string $base A fully qualified template url used to qualify. @return string|false The qualified template path or FALSE if the path could not be qualified
[ "Qualify", "a", "template", "url" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/locator/file.php#L137-L154
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/template/locator/file.php
KTemplateLocatorFile.normalise
public function normalise($url) { $scheme = parse_url($url, PHP_URL_SCHEME); $path = str_replace(array('/', '\\', $scheme.'://'), DIRECTORY_SEPARATOR, $url); $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); $absolutes = array(); foreach ($parts as $part) { if ('.' == $part) { continue; } if ('..' == $part) { array_pop($absolutes); } else { $absolutes[] = $part; } } $path = implode(DIRECTORY_SEPARATOR, $absolutes); $url = $scheme ? $scheme.'://'.$path : $path; return $url; }
php
public function normalise($url) { $scheme = parse_url($url, PHP_URL_SCHEME); $path = str_replace(array('/', '\\', $scheme.'://'), DIRECTORY_SEPARATOR, $url); $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); $absolutes = array(); foreach ($parts as $part) { if ('.' == $part) { continue; } if ('..' == $part) { array_pop($absolutes); } else { $absolutes[] = $part; } } $path = implode(DIRECTORY_SEPARATOR, $absolutes); $url = $scheme ? $scheme.'://'.$path : $path; return $url; }
[ "public", "function", "normalise", "(", "$", "url", ")", "{", "$", "scheme", "=", "parse_url", "(", "$", "url", ",", "PHP_URL_SCHEME", ")", ";", "$", "path", "=", "str_replace", "(", "array", "(", "'/'", ",", "'\\\\'", ",", "$", "scheme", ".", "'://'...
Normalise a template url Resolves references to /./, /../ and extra / characters in the input path and returns the canonicalize absolute url. Equivalent of realpath() method. @param string $url The template to normalise @return string|false The normalised template url
[ "Normalise", "a", "template", "url" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/locator/file.php#L165-L190
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/template/locator/file.php
KTemplateLocatorFile.realPath
public function realPath($file) { $path = parent::realPath($file); if($base = $this->getBasePath()) { if(strpos($file, $base) !== 0) { return false; } } return $path; }
php
public function realPath($file) { $path = parent::realPath($file); if($base = $this->getBasePath()) { if(strpos($file, $base) !== 0) { return false; } } return $path; }
[ "public", "function", "realPath", "(", "$", "file", ")", "{", "$", "path", "=", "parent", "::", "realPath", "(", "$", "file", ")", ";", "if", "(", "$", "base", "=", "$", "this", "->", "getBasePath", "(", ")", ")", "{", "if", "(", "strpos", "(", ...
Prevent directory traversal attempts outside of the base path @param string $file The file path @return string The real file path
[ "Prevent", "directory", "traversal", "attempts", "outside", "of", "the", "base", "path" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/locator/file.php#L198-L210
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/user/session/container/abstract.php
KUserSessionContainerAbstract.add
public function add(array $attributes) { foreach ($attributes as $key => $values) { $this->set($key, $values); } return $this; }
php
public function add(array $attributes) { foreach ($attributes as $key => $values) { $this->set($key, $values); } return $this; }
[ "public", "function", "add", "(", "array", "$", "attributes", ")", "{", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "values", ")", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "values", ")", ";", "}", "return", "$...
Adds new attributes the active session. @param array $attributes An array of attributes @return KUserSessionContainerAbstract
[ "Adds", "new", "attributes", "the", "active", "session", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/abstract.php#L146-L153
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/user/session/container/abstract.php
KUserSessionContainerAbstract.offsetExists
public function offsetExists($identifier) { $keys = $this->_parseIdentifier($identifier); $last = count($keys)-1; $data = &$this->_data; $result = false; foreach($keys as $index => $key) { if (!array_key_exists($key, $data)) { break; } if ($index < $last) { $data =& $data[$key]; } else $result = true; } return $result; }
php
public function offsetExists($identifier) { $keys = $this->_parseIdentifier($identifier); $last = count($keys)-1; $data = &$this->_data; $result = false; foreach($keys as $index => $key) { if (!array_key_exists($key, $data)) { break; } if ($index < $last) { $data =& $data[$key]; } else $result = true; } return $result; }
[ "public", "function", "offsetExists", "(", "$", "identifier", ")", "{", "$", "keys", "=", "$", "this", "->", "_parseIdentifier", "(", "$", "identifier", ")", ";", "$", "last", "=", "count", "(", "$", "keys", ")", "-", "1", ";", "$", "data", "=", "&...
Check if an attribute exists @param string $identifier Attribute identifier, eg foo.bar @return boolean
[ "Check", "if", "an", "attribute", "exists" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/abstract.php#L257-L277
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/user/session/container/abstract.php
KUserSessionContainerAbstract.offsetUnset
public function offsetUnset($identifier) { $keys = $this->_parseIdentifier($identifier); $last = count($keys)-1; $data =& $this->_data; foreach($keys as $index => $key) { if (!array_key_exists($key, $data)) { break; } if ($index < $last) { $data =& $data[$key]; } else unset($data[$key]); } }
php
public function offsetUnset($identifier) { $keys = $this->_parseIdentifier($identifier); $last = count($keys)-1; $data =& $this->_data; foreach($keys as $index => $key) { if (!array_key_exists($key, $data)) { break; } if ($index < $last) { $data =& $data[$key]; } else unset($data[$key]); } }
[ "public", "function", "offsetUnset", "(", "$", "identifier", ")", "{", "$", "keys", "=", "$", "this", "->", "_parseIdentifier", "(", "$", "identifier", ")", ";", "$", "last", "=", "count", "(", "$", "keys", ")", "-", "1", ";", "$", "data", "=", "&"...
Unset an attribute @param string $identifier Attribute identifier, eg foo.bar @return void
[ "Unset", "an", "attribute" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/abstract.php#L285-L302
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/object/config/ini.php
KObjectConfigIni._encodeValue
protected static function _encodeValue($value) { $string = ''; switch (gettype($value)) { case 'integer': case 'double': $string = $value; break; case 'boolean': $string = $value ? 'true' : 'false'; break; case 'string': // Sanitize any CRLF characters.. $string = '"' . str_replace(array("\r\n", "\n"), '\\n', $value) . '"'; break; } return $string; }
php
protected static function _encodeValue($value) { $string = ''; switch (gettype($value)) { case 'integer': case 'double': $string = $value; break; case 'boolean': $string = $value ? 'true' : 'false'; break; case 'string': // Sanitize any CRLF characters.. $string = '"' . str_replace(array("\r\n", "\n"), '\\n', $value) . '"'; break; } return $string; }
[ "protected", "static", "function", "_encodeValue", "(", "$", "value", ")", "{", "$", "string", "=", "''", ";", "switch", "(", "gettype", "(", "$", "value", ")", ")", "{", "case", "'integer'", ":", "case", "'double'", ":", "$", "string", "=", "$", "va...
Encode a value for INI. @param mixed $value @return string
[ "Encode", "a", "value", "for", "INI", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/config/ini.php#L95-L117
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/object/registry/registry.php
KObjectRegistry.get
public function get($identifier) { $identifier = (string) $identifier; if($this->offsetExists($identifier)) { $result = $this->offsetGet($identifier); } else { $result = null; } return $result; }
php
public function get($identifier) { $identifier = (string) $identifier; if($this->offsetExists($identifier)) { $result = $this->offsetGet($identifier); } else { $result = null; } return $result; }
[ "public", "function", "get", "(", "$", "identifier", ")", "{", "$", "identifier", "=", "(", "string", ")", "$", "identifier", ";", "if", "(", "$", "this", "->", "offsetExists", "(", "$", "identifier", ")", ")", "{", "$", "result", "=", "$", "this", ...
Get a an object from the registry @param KObjectIdentifier|string $identifier An ObjectIdentifier, identifier string @return KObjectInterface The object or NULL if the identifier could not be found
[ "Get", "a", "an", "object", "from", "the", "registry" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/registry/registry.php#L38-L49
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/object/registry/registry.php
KObjectRegistry.set
public function set($identifier, $data = null) { if($data == null) { $data = is_string($identifier) ? new KObjectIdentifier($identifier) : $identifier; } $this->offsetSet((string) $identifier, $data); return $data; }
php
public function set($identifier, $data = null) { if($data == null) { $data = is_string($identifier) ? new KObjectIdentifier($identifier) : $identifier; } $this->offsetSet((string) $identifier, $data); return $data; }
[ "public", "function", "set", "(", "$", "identifier", ",", "$", "data", "=", "null", ")", "{", "if", "(", "$", "data", "==", "null", ")", "{", "$", "data", "=", "is_string", "(", "$", "identifier", ")", "?", "new", "KObjectIdentifier", "(", "$", "id...
Set an object in the registry @param KObjectIdentifier|string $identifier An ObjectIdentifier, identifier string @param mixed $data @return KObjectIdentifier The object identifier that was set in the registry.
[ "Set", "an", "object", "in", "the", "registry" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/registry/registry.php#L58-L66
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/object/registry/registry.php
KObjectRegistry.find
public function find($identifier) { $identifier = (string) $identifier; //Resolve the real identifier in case an alias was passed while(array_key_exists($identifier, $this->_aliases)) { $identifier = $this->_aliases[$identifier]; } //Find the identifier if($this->offsetExists($identifier)) { $result = $this->offsetGet($identifier); if($result instanceof KObjectInterface) { $result = $result->getIdentifier(); } } else $result = null; return $result; }
php
public function find($identifier) { $identifier = (string) $identifier; //Resolve the real identifier in case an alias was passed while(array_key_exists($identifier, $this->_aliases)) { $identifier = $this->_aliases[$identifier]; } //Find the identifier if($this->offsetExists($identifier)) { $result = $this->offsetGet($identifier); if($result instanceof KObjectInterface) { $result = $result->getIdentifier(); } } else $result = null; return $result; }
[ "public", "function", "find", "(", "$", "identifier", ")", "{", "$", "identifier", "=", "(", "string", ")", "$", "identifier", ";", "//Resolve the real identifier in case an alias was passed", "while", "(", "array_key_exists", "(", "$", "identifier", ",", "$", "th...
Try to find an object based on an identifier string @param mixed $identifier @return KObjectIdentifier An ObjectIdentifier or NULL if the identifier does not exist.
[ "Try", "to", "find", "an", "object", "based", "on", "an", "identifier", "string" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/registry/registry.php#L108-L129
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/object/registry/registry.php
KObjectRegistry.alias
public function alias($identifier, $alias) { $alias = trim((string) $alias); $identifier = (string) $identifier; //Don't register the alias if it's the same as the identifier if($alias != $identifier) { $this->_aliases[$alias] = (string) $identifier; } return $this; }
php
public function alias($identifier, $alias) { $alias = trim((string) $alias); $identifier = (string) $identifier; //Don't register the alias if it's the same as the identifier if($alias != $identifier) { $this->_aliases[$alias] = (string) $identifier; } return $this; }
[ "public", "function", "alias", "(", "$", "identifier", ",", "$", "alias", ")", "{", "$", "alias", "=", "trim", "(", "(", "string", ")", "$", "alias", ")", ";", "$", "identifier", "=", "(", "string", ")", "$", "identifier", ";", "//Don't register the al...
Register an alias for an identifier @param KObjectIdentifier|string $identifier An ObjectIdentifier, identifier string @param mixed $alias The alias @return KObjectRegistry
[ "Register", "an", "alias", "for", "an", "identifier" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/registry/registry.php#L138-L149
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/command/callback/abstract.php
KCommandCallbackAbstract.invokeCallbacks
public function invokeCallbacks($command, $attributes = null, $subject = null) { //Make sure we have an command object if (!$command instanceof KCommandInterface) { if($attributes instanceof KCommandInterface) { $name = $command; $command = $attributes; $command->setName($name); } else $command = new KCommand($command, $attributes, $subject); } foreach($this->getCommandCallbacks($command->getName()) as $handler) { $method = $handler['method']; $params = $handler['params']; if(is_string($method)) { $result = $this->invokeCommandCallback($method, $command->append($params)); } else { $result = $method($command->append($params)); } if($result !== null && $result === $this->getBreakCondition()) { return $result; } } }
php
public function invokeCallbacks($command, $attributes = null, $subject = null) { //Make sure we have an command object if (!$command instanceof KCommandInterface) { if($attributes instanceof KCommandInterface) { $name = $command; $command = $attributes; $command->setName($name); } else $command = new KCommand($command, $attributes, $subject); } foreach($this->getCommandCallbacks($command->getName()) as $handler) { $method = $handler['method']; $params = $handler['params']; if(is_string($method)) { $result = $this->invokeCommandCallback($method, $command->append($params)); } else { $result = $method($command->append($params)); } if($result !== null && $result === $this->getBreakCondition()) { return $result; } } }
[ "public", "function", "invokeCallbacks", "(", "$", "command", ",", "$", "attributes", "=", "null", ",", "$", "subject", "=", "null", ")", "{", "//Make sure we have an command object", "if", "(", "!", "$", "command", "instanceof", "KCommandInterface", ")", "{", ...
Invoke a command by calling all the registered callbacks @param string|KCommandInterface $command The command name or a KCommandInterface object @param array|Traversable $attributes An associative array or a Traversable object @param KObjectInterface $subject The command subject @return mixed|null If a callback break, returns the break condition. NULL otherwise.
[ "Invoke", "a", "command", "by", "calling", "all", "the", "registered", "callbacks" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/command/callback/abstract.php#L77-L107
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/command/callback/abstract.php
KCommandCallbackAbstract.getCommandCallbacks
public function getCommandCallbacks($command = null) { $result = array(); if($command) { if(isset($this->__command_callbacks[$command])) { $result = $this->__command_callbacks[$command]; } } else $result = $this->__command_callbacks; return $result; }
php
public function getCommandCallbacks($command = null) { $result = array(); if($command) { if(isset($this->__command_callbacks[$command])) { $result = $this->__command_callbacks[$command]; } } else $result = $this->__command_callbacks; return $result; }
[ "public", "function", "getCommandCallbacks", "(", "$", "command", "=", "null", ")", "{", "$", "result", "=", "array", "(", ")", ";", "if", "(", "$", "command", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "__command_callbacks", "[", "$", "co...
Get the command callbacks @param mixed $command @return array
[ "Get", "the", "command", "callbacks" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/command/callback/abstract.php#L189-L201
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/module/mod_koowa/html.php
ModKoowaHtml._loadTranslations
protected function _loadTranslations(KViewContext $context) { if(isset($this->module->module)) { $package = $this->getIdentifier()->package; $domain = $this->getIdentifier()->domain; if($domain) { $identifier = 'mod://'.$domain.'/'.$package; } else { $identifier = 'mod:'.$package; } $this->getObject('translator')->load($identifier); } }
php
protected function _loadTranslations(KViewContext $context) { if(isset($this->module->module)) { $package = $this->getIdentifier()->package; $domain = $this->getIdentifier()->domain; if($domain) { $identifier = 'mod://'.$domain.'/'.$package; } else { $identifier = 'mod:'.$package; } $this->getObject('translator')->load($identifier); } }
[ "protected", "function", "_loadTranslations", "(", "KViewContext", "$", "context", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "module", "->", "module", ")", ")", "{", "$", "package", "=", "$", "this", "->", "getIdentifier", "(", ")", "->", "...
Load the controller translations @param KViewContext $context @return void
[ "Load", "the", "controller", "translations" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/module/mod_koowa/html.php#L54-L69
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/module/mod_koowa/html.php
ModKoowaHtml.set
public function set($property, $value) { if($property == 'module') { $value = clone $value; if(is_string($value->params)) { $value->params = $this->getObject('object.config.factory')->fromString('json', $value->params); } } parent::set($property, $value); }
php
public function set($property, $value) { if($property == 'module') { $value = clone $value; if(is_string($value->params)) { $value->params = $this->getObject('object.config.factory')->fromString('json', $value->params); } } parent::set($property, $value); }
[ "public", "function", "set", "(", "$", "property", ",", "$", "value", ")", "{", "if", "(", "$", "property", "==", "'module'", ")", "{", "$", "value", "=", "clone", "$", "value", ";", "if", "(", "is_string", "(", "$", "value", "->", "params", ")", ...
Set a view properties @param string $property The property name. @param mixed $value The property value.
[ "Set", "a", "view", "properties" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/module/mod_koowa/html.php#L136-L148
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/database/adapter/mysqli.php
KDatabaseAdapterMysqli.lockTable
public function lockTable($table) { $query = 'LOCK TABLES '.$this->quoteIdentifier($this->getTableNeedle().$table).' WRITE'; // Create command chain context. $context = $this->getContext(); $context->table = $table; $context->query = $query; if($this->invokeCommand('before.lock', $context) !== false) { $context->result = $this->execute($context->query, KDatabase::RESULT_USE); $this->invokeCommand('after.lock', $context); } return $context->result; }
php
public function lockTable($table) { $query = 'LOCK TABLES '.$this->quoteIdentifier($this->getTableNeedle().$table).' WRITE'; // Create command chain context. $context = $this->getContext(); $context->table = $table; $context->query = $query; if($this->invokeCommand('before.lock', $context) !== false) { $context->result = $this->execute($context->query, KDatabase::RESULT_USE); $this->invokeCommand('after.lock', $context); } return $context->result; }
[ "public", "function", "lockTable", "(", "$", "table", ")", "{", "$", "query", "=", "'LOCK TABLES '", ".", "$", "this", "->", "quoteIdentifier", "(", "$", "this", "->", "getTableNeedle", "(", ")", ".", "$", "table", ")", ".", "' WRITE'", ";", "// Create c...
Locks a table @param string $table The name of the table. @return boolean TRUE on success, FALSE otherwise.
[ "Locks", "a", "table" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/adapter/mysqli.php#L251-L267
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/database/adapter/mysqli.php
KDatabaseAdapterMysqli._parseColumnInfo
protected function _parseColumnInfo($info) { list($type, $length, $scope) = $this->_parseColumnType($info->Type); $column = new KDatabaseSchemaColumn(); $column->name = $info->Field; $column->type = $type; $column->length = $length ? $length : null; $column->scope = $scope ? (int) $scope : null; $column->default = $info->Default; $column->required = $info->Null != 'YES'; $column->primary = $info->Key == 'PRI'; $column->unique = ($info->Key == 'UNI' || $info->Key == 'PRI'); $column->autoinc = strpos($info->Extra, 'auto_increment') !== false; $column->filter = $this->_type_map[$type]; // Don't keep "size" for integers. if(substr($type, -3) == 'int') { $column->length = null; } // Get the related fields if the column is primary key or part of a unique multi column index. if($indexes = $this->_table_schema[$info->Table]->indexes) { foreach($indexes as $index) { // We only deal with composite-unique indexes. if(count($index) > 1 && !$index[1]->Non_unique) { $fields = array(); foreach($index as $field) { $fields[$field->Column_name] = $field->Column_name; } if(array_key_exists($column->name, $fields)) { unset($fields[$column->name]); $column->related = array_values($fields); $column->unique = true; break; } } } } return $column; }
php
protected function _parseColumnInfo($info) { list($type, $length, $scope) = $this->_parseColumnType($info->Type); $column = new KDatabaseSchemaColumn(); $column->name = $info->Field; $column->type = $type; $column->length = $length ? $length : null; $column->scope = $scope ? (int) $scope : null; $column->default = $info->Default; $column->required = $info->Null != 'YES'; $column->primary = $info->Key == 'PRI'; $column->unique = ($info->Key == 'UNI' || $info->Key == 'PRI'); $column->autoinc = strpos($info->Extra, 'auto_increment') !== false; $column->filter = $this->_type_map[$type]; // Don't keep "size" for integers. if(substr($type, -3) == 'int') { $column->length = null; } // Get the related fields if the column is primary key or part of a unique multi column index. if($indexes = $this->_table_schema[$info->Table]->indexes) { foreach($indexes as $index) { // We only deal with composite-unique indexes. if(count($index) > 1 && !$index[1]->Non_unique) { $fields = array(); foreach($index as $field) { $fields[$field->Column_name] = $field->Column_name; } if(array_key_exists($column->name, $fields)) { unset($fields[$column->name]); $column->related = array_values($fields); $column->unique = true; break; } } } } return $column; }
[ "protected", "function", "_parseColumnInfo", "(", "$", "info", ")", "{", "list", "(", "$", "type", ",", "$", "length", ",", "$", "scope", ")", "=", "$", "this", "->", "_parseColumnType", "(", "$", "info", "->", "Type", ")", ";", "$", "column", "=", ...
Parse the raw column schema information @param object $info The raw column schema information @return KDatabaseSchemaColumn
[ "Parse", "the", "raw", "column", "schema", "information" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/adapter/mysqli.php#L525-L571
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/response/response.php
KHttpResponse.getStatusMessage
public function getStatusMessage() { $code = $this->getStatusCode(); if (empty($this->_status_message)) { $message = self::$status_messages[$code]; } else { $message = $this->_status_message; } return $message; }
php
public function getStatusMessage() { $code = $this->getStatusCode(); if (empty($this->_status_message)) { $message = self::$status_messages[$code]; } else { $message = $this->_status_message; } return $message; }
[ "public", "function", "getStatusMessage", "(", ")", "{", "$", "code", "=", "$", "this", "->", "getStatusCode", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "_status_message", ")", ")", "{", "$", "message", "=", "self", "::", "$", "statu...
Get the http header status message based on a status code @return string The http status message
[ "Get", "the", "http", "header", "status", "message", "based", "on", "a", "status", "code" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/response/response.php#L226-L237
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/response/response.php
KHttpResponse.getLastModified
public function getLastModified() { $date = null; if ($this->_headers->has('Last-Modified')) { $value = $this->_headers->get('Last-Modified'); $date = new DateTime(date(DATE_RFC2822, strtotime($value))); if ($date === false) { throw new RuntimeException(sprintf('The Last-Modified HTTP header is not parseable (%s).', $value)); } } return $date; }
php
public function getLastModified() { $date = null; if ($this->_headers->has('Last-Modified')) { $value = $this->_headers->get('Last-Modified'); $date = new DateTime(date(DATE_RFC2822, strtotime($value))); if ($date === false) { throw new RuntimeException(sprintf('The Last-Modified HTTP header is not parseable (%s).', $value)); } } return $date; }
[ "public", "function", "getLastModified", "(", ")", "{", "$", "date", "=", "null", ";", "if", "(", "$", "this", "->", "_headers", "->", "has", "(", "'Last-Modified'", ")", ")", "{", "$", "value", "=", "$", "this", "->", "_headers", "->", "get", "(", ...
Returns the Last-Modified HTTP header as a DateTime instance. @link http://tools.ietf.org/html/rfc2616#section-14.29 @throws RuntimeException If the Last-Modified header could not be parsed @return DateTime|null A DateTime instance or NULL if no Last-Modified header exists
[ "Returns", "the", "Last", "-", "Modified", "HTTP", "header", "as", "a", "DateTime", "instance", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/response/response.php#L288-L303
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/response/response.php
KHttpResponse.setMaxAge
public function setMaxAge($max_age, $shared_max_age = null) { $cache_control = $this->getCacheControl(); $cache_control['max-age'] = (int) $max_age; if(!is_null($shared_max_age) && $shared_max_age > $max_age) { $cache_control['s-maxage'] = (int) $shared_max_age; } $this->_headers->set('Cache-Control', $cache_control); return $this; }
php
public function setMaxAge($max_age, $shared_max_age = null) { $cache_control = $this->getCacheControl(); $cache_control['max-age'] = (int) $max_age; if(!is_null($shared_max_age) && $shared_max_age > $max_age) { $cache_control['s-maxage'] = (int) $shared_max_age; } $this->_headers->set('Cache-Control', $cache_control); return $this; }
[ "public", "function", "setMaxAge", "(", "$", "max_age", ",", "$", "shared_max_age", "=", "null", ")", "{", "$", "cache_control", "=", "$", "this", "->", "getCacheControl", "(", ")", ";", "$", "cache_control", "[", "'max-age'", "]", "=", "(", "int", ")", ...
Set the max age This directive specifies the maximum time in seconds that the fetched response is allowed to be reused from the time of the request. For example, "max-age=60" indicates that the response can be cached and reused for the next 60 seconds. @link https://tools.ietf.org/html/rfc2616#section-14.9.3 @param integer $max_age The number of seconds after which the response should no longer be considered fresh. @param integer $share_max_age The number of seconds after which the response should no longer be considered fresh by shared caches. @return KHttpResponse
[ "Set", "the", "max", "age" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/response/response.php#L404-L417
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/response/response.php
KHttpResponse.getCacheControl
public function getCacheControl() { $values = $this->_headers->get('Cache-Control', array()); if (is_string($values)) { $values = explode(',', $values); } foreach ($values as $key => $value) { if(is_string($value)) { $parts = explode('=', $value); if (count($parts) > 1) { unset($values[$key]); $values[trim($parts[0])] = trim($parts[1]); } } } return $values; }
php
public function getCacheControl() { $values = $this->_headers->get('Cache-Control', array()); if (is_string($values)) { $values = explode(',', $values); } foreach ($values as $key => $value) { if(is_string($value)) { $parts = explode('=', $value); if (count($parts) > 1) { unset($values[$key]); $values[trim($parts[0])] = trim($parts[1]); } } } return $values; }
[ "public", "function", "getCacheControl", "(", ")", "{", "$", "values", "=", "$", "this", "->", "_headers", "->", "get", "(", "'Cache-Control'", ",", "array", "(", ")", ")", ";", "if", "(", "is_string", "(", "$", "values", ")", ")", "{", "$", "values"...
Get the cache control @link https://tools.ietf.org/html/rfc2616#page-108 @return array
[ "Get", "the", "cache", "control" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/response/response.php#L454-L477
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/response/response.php
KHttpResponse.isStale
public function isStale() { $result = true; if ($maxAge = $this->getMaxAge()) { $result = ($maxAge - $this->getAge()) <= 0; } return $result; }
php
public function isStale() { $result = true; if ($maxAge = $this->getMaxAge()) { $result = ($maxAge - $this->getAge()) <= 0; } return $result; }
[ "public", "function", "isStale", "(", ")", "{", "$", "result", "=", "true", ";", "if", "(", "$", "maxAge", "=", "$", "this", "->", "getMaxAge", "(", ")", ")", "{", "$", "result", "=", "(", "$", "maxAge", "-", "$", "this", "->", "getAge", "(", "...
Returns true if the response is "stale". When the responses is stale, the response may not be served from cache without first re-validating with the origin. @return Boolean true if the response is stale, false otherwise
[ "Returns", "true", "if", "the", "response", "is", "stale", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/response/response.php#L562-L570
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/response/response.php
KHttpResponse.toString
public function toString() { $status = sprintf('HTTP/%s %d %s', $this->getVersion(), $this->getStatusCode(), $this->getStatusMessage()); $str = trim($status) . "\r\n"; $str .= $this->getHeaders(); $str .= "\r\n"; $str .= $this->getContent(); return $str; }
php
public function toString() { $status = sprintf('HTTP/%s %d %s', $this->getVersion(), $this->getStatusCode(), $this->getStatusMessage()); $str = trim($status) . "\r\n"; $str .= $this->getHeaders(); $str .= "\r\n"; $str .= $this->getContent(); return $str; }
[ "public", "function", "toString", "(", ")", "{", "$", "status", "=", "sprintf", "(", "'HTTP/%s %d %s'", ",", "$", "this", "->", "getVersion", "(", ")", ",", "$", "this", "->", "getStatusCode", "(", ")", ",", "$", "this", "->", "getStatusMessage", "(", ...
Render entire response as HTTP response string @return string
[ "Render", "entire", "response", "as", "HTTP", "response", "string" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/response/response.php#L577-L586
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/controller/toolbar/mixin/mixin.php
KControllerToolbarMixin.getToolbar
public function getToolbar($type = 'actionbar') { $result = null; if(isset($this->__toolbars[$type])) { $result = $this->__toolbars[$type]; } return $result; }
php
public function getToolbar($type = 'actionbar') { $result = null; if(isset($this->__toolbars[$type])) { $result = $this->__toolbars[$type]; } return $result; }
[ "public", "function", "getToolbar", "(", "$", "type", "=", "'actionbar'", ")", "{", "$", "result", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "__toolbars", "[", "$", "type", "]", ")", ")", "{", "$", "result", "=", "$", "this", ...
Get a toolbar by type @param string $type The toolbar name @return KControllerToolbarInterface
[ "Get", "a", "toolbar", "by", "type" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/toolbar/mixin/mixin.php#L149-L158
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/request/request.php
KHttpRequest.isFormSubmit
public function isFormSubmit() { $form_submit = in_array($this->getContentType(), ['application/x-www-form-urlencoded', 'multipart/form-data']); return ($form_submit && !$this->isSafe() && !$this->isAjax()); }
php
public function isFormSubmit() { $form_submit = in_array($this->getContentType(), ['application/x-www-form-urlencoded', 'multipart/form-data']); return ($form_submit && !$this->isSafe() && !$this->isAjax()); }
[ "public", "function", "isFormSubmit", "(", ")", "{", "$", "form_submit", "=", "in_array", "(", "$", "this", "->", "getContentType", "(", ")", ",", "[", "'application/x-www-form-urlencoded'", ",", "'multipart/form-data'", "]", ")", ";", "return", "(", "$", "for...
Is the request a submitted HTTP form? @return boolean
[ "Is", "the", "request", "a", "submitted", "HTTP", "form?" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/request/request.php#L249-L254
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/request/request.php
KHttpRequest.toString
public function toString() { $request = sprintf('%s %s HTTP/%s', $this->getMethod(), (string) $this->getUrl(), $this->getVersion()); $str = trim($request) . "\r\n"; $str .= $this->getHeaders(); $str .= "\r\n"; $str .= $this->getContent(); return $str; }
php
public function toString() { $request = sprintf('%s %s HTTP/%s', $this->getMethod(), (string) $this->getUrl(), $this->getVersion()); $str = trim($request) . "\r\n"; $str .= $this->getHeaders(); $str .= "\r\n"; $str .= $this->getContent(); return $str; }
[ "public", "function", "toString", "(", ")", "{", "$", "request", "=", "sprintf", "(", "'%s %s HTTP/%s'", ",", "$", "this", "->", "getMethod", "(", ")", ",", "(", "string", ")", "$", "this", "->", "getUrl", "(", ")", ",", "$", "this", "->", "getVersio...
Render entire request as HTTP request string @return string
[ "Render", "entire", "request", "as", "HTTP", "request", "string" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/request/request.php#L283-L292
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/database/adapter/abstract.php
KDatabaseAdapterAbstract.insert
public function insert(KDatabaseQueryInsert $query) { $context = $this->getContext(); $context->query = $query; //Execute the insert operation if ($this->invokeCommand('before.insert', $context) !== false) { //Check if we have valid data to insert, if not return false if ($context->query->values) { //Execute the query $context->result = $this->execute($context->query); $context->affected = $this->_affected_rows; $this->invokeCommand('after.insert', $context); } else $context->affected = false; } return $context->affected; }
php
public function insert(KDatabaseQueryInsert $query) { $context = $this->getContext(); $context->query = $query; //Execute the insert operation if ($this->invokeCommand('before.insert', $context) !== false) { //Check if we have valid data to insert, if not return false if ($context->query->values) { //Execute the query $context->result = $this->execute($context->query); $context->affected = $this->_affected_rows; $this->invokeCommand('after.insert', $context); } else $context->affected = false; } return $context->affected; }
[ "public", "function", "insert", "(", "KDatabaseQueryInsert", "$", "query", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "context", "->", "query", "=", "$", "query", ";", "//Execute the insert operation", "if", "(", "$...
Insert a row of data into a table. @param KDatabaseQueryInsert $query The query object. @return bool|integer If the insert query was executed returns the number of rows updated, or 0 if no rows where updated, or -1 if an error occurred. Otherwise FALSE.
[ "Insert", "a", "row", "of", "data", "into", "a", "table", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/adapter/abstract.php#L322-L343
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/database/adapter/abstract.php
KDatabaseAdapterAbstract.update
public function update(KDatabaseQueryUpdate $query) { $context = $this->getContext(); $context->query = $query; //Execute the update operation if ($this->invokeCommand('before.update', $context) !== false) { if (!empty($context->query->values)) { //Execute the query $context->result = $this->execute($context->query); $context->affected = $this->_affected_rows; $this->invokeCommand('after.update', $context); } else $context->affected = false; } return $context->affected; }
php
public function update(KDatabaseQueryUpdate $query) { $context = $this->getContext(); $context->query = $query; //Execute the update operation if ($this->invokeCommand('before.update', $context) !== false) { if (!empty($context->query->values)) { //Execute the query $context->result = $this->execute($context->query); $context->affected = $this->_affected_rows; $this->invokeCommand('after.update', $context); } else $context->affected = false; } return $context->affected; }
[ "public", "function", "update", "(", "KDatabaseQueryUpdate", "$", "query", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "context", "->", "query", "=", "$", "query", ";", "//Execute the update operation", "if", "(", "$...
Update a table with specified data. @param KDatabaseQueryUpdate $query The query object. @return integer If the update query was executed returns the number of rows updated, or 0 if no rows where updated, or -1 if an error occurred. Otherwise FALSE.
[ "Update", "a", "table", "with", "specified", "data", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/adapter/abstract.php#L352-L372
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/database/adapter/abstract.php
KDatabaseAdapterAbstract.delete
public function delete(KDatabaseQueryDelete $query) { $context = $this->getContext(); $context->query = $query; //Execute the delete operation if ($this->invokeCommand('before.delete', $context) !== false) { //Execute the query $context->result = $this->execute($context->query); $context->affected = $this->_affected_rows; $this->invokeCommand('after.delete', $context); } return $context->affected; }
php
public function delete(KDatabaseQueryDelete $query) { $context = $this->getContext(); $context->query = $query; //Execute the delete operation if ($this->invokeCommand('before.delete', $context) !== false) { //Execute the query $context->result = $this->execute($context->query); $context->affected = $this->_affected_rows; $this->invokeCommand('after.delete', $context); } return $context->affected; }
[ "public", "function", "delete", "(", "KDatabaseQueryDelete", "$", "query", ")", "{", "$", "context", "=", "$", "this", "->", "getContext", "(", ")", ";", "$", "context", "->", "query", "=", "$", "query", ";", "//Execute the delete operation", "if", "(", "$...
Delete rows from the table. @param KDatabaseQueryDelete $query The query object. @return integer Number of rows affected, or -1 if an error occurred.
[ "Delete", "rows", "from", "the", "table", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/adapter/abstract.php#L380-L396
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/template/helper/actionbar.php
ComKoowaTemplateHelperActionbar.command
public function command($config = array()) { if (JFactory::getApplication()->isSite()) { $config = new KObjectConfigJson($config); $config->append(array( 'command' => NULL )); $command = $config->command; $command->attribs->class->append(array('btn')); if ($command->id === 'new' || $command->id === 'apply') { $command->attribs->class->append(array('btn-success')); } } return parent::command($config); }
php
public function command($config = array()) { if (JFactory::getApplication()->isSite()) { $config = new KObjectConfigJson($config); $config->append(array( 'command' => NULL )); $command = $config->command; $command->attribs->class->append(array('btn')); if ($command->id === 'new' || $command->id === 'apply') { $command->attribs->class->append(array('btn-success')); } } return parent::command($config); }
[ "public", "function", "command", "(", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "JFactory", "::", "getApplication", "(", ")", "->", "isSite", "(", ")", ")", "{", "$", "config", "=", "new", "KObjectConfigJson", "(", "$", "config", ")...
Use Bootstrap 2.3.2 classes for buttons in frontend @param array $config @return string
[ "Use", "Bootstrap", "2", ".", "3", ".", "2", "classes", "for", "buttons", "in", "frontend" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/actionbar.php#L39-L58
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/template/filter/toolbar.php
ComKoowaTemplateFilterToolbar.setToolbars
public function setToolbars(array $toolbars) { $this->_toolbars = array(); foreach($toolbars as $toolbar) { $this->setToolbar($toolbar); } return $this; }
php
public function setToolbars(array $toolbars) { $this->_toolbars = array(); foreach($toolbars as $toolbar) { $this->setToolbar($toolbar); } return $this; }
[ "public", "function", "setToolbars", "(", "array", "$", "toolbars", ")", "{", "$", "this", "->", "_toolbars", "=", "array", "(", ")", ";", "foreach", "(", "$", "toolbars", "as", "$", "toolbar", ")", "{", "$", "this", "->", "setToolbar", "(", "$", "to...
Set the toolbars to render @param array $toolbars @return $this
[ "Set", "the", "toolbars", "to", "render" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/filter/toolbar.php#L73-L81
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/template/filter/toolbar.php
ComKoowaTemplateFilterToolbar.getToolbar
public function getToolbar($type = 'actionbar') { return isset($this->_toolbars[$type]) ? $this->_toolbars[$type] : null; }
php
public function getToolbar($type = 'actionbar') { return isset($this->_toolbars[$type]) ? $this->_toolbars[$type] : null; }
[ "public", "function", "getToolbar", "(", "$", "type", "=", "'actionbar'", ")", "{", "return", "isset", "(", "$", "this", "->", "_toolbars", "[", "$", "type", "]", ")", "?", "$", "this", "->", "_toolbars", "[", "$", "type", "]", ":", "null", ";", "}...
Returns the specified toolbar instance @param string $type Toolbar type @return KControllerToolbarInterface|null
[ "Returns", "the", "specified", "toolbar", "instance" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/filter/toolbar.php#L89-L92
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/model/entity/user.php
ComKoowaModelEntityUser.toArray
public function toArray() { $data = parent::toArray(); $data = array_intersect_key($data, $this->_fields); return $data; }
php
public function toArray() { $data = parent::toArray(); $data = array_intersect_key($data, $this->_fields); return $data; }
[ "public", "function", "toArray", "(", ")", "{", "$", "data", "=", "parent", "::", "toArray", "(", ")", ";", "$", "data", "=", "array_intersect_key", "(", "$", "data", ",", "$", "this", "->", "_fields", ")", ";", "return", "$", "data", ";", "}" ]
Excludes private fields from JSON representation @return array
[ "Excludes", "private", "fields", "from", "JSON", "representation" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/model/entity/user.php#L46-L53
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/date/date.php
KDate.format
public function format($format) { $format = preg_replace_callback('/(?<!\\\\)[DlFM]/', array($this, '_translate'), $format); return $this->_date->format($format); }
php
public function format($format) { $format = preg_replace_callback('/(?<!\\\\)[DlFM]/', array($this, '_translate'), $format); return $this->_date->format($format); }
[ "public", "function", "format", "(", "$", "format", ")", "{", "$", "format", "=", "preg_replace_callback", "(", "'/(?<!\\\\\\\\)[DlFM]/'", ",", "array", "(", "$", "this", ",", "'_translate'", ")", ",", "$", "format", ")", ";", "return", "$", "this", "->", ...
Returns the date formatted according to given format. @param string $format The format to use @return string The formatted date
[ "Returns", "the", "date", "formatted", "according", "to", "given", "format", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/date/date.php#L65-L69
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/date/date.php
KDate.setDate
public function setDate($year, $month, $day) { if($this->_date->setDate($year, $month, $day) === false) { return false; } return $this; }
php
public function setDate($year, $month, $day) { if($this->_date->setDate($year, $month, $day) === false) { return false; } return $this; }
[ "public", "function", "setDate", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", "{", "if", "(", "$", "this", "->", "_date", "->", "setDate", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", "===", "false", ")", "{", "retur...
Resets the current time of the DateTime object to a different time. @param integer $year Year of the date. @param integer $month Month of the date. @param integer $day Day of the date. @return KDate or FALSE on failure.
[ "Resets", "the", "current", "time", "of", "the", "DateTime", "object", "to", "a", "different", "time", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/date/date.php#L159-L166
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/date/date.php
KDate.setTime
public function setTime($hour, $minute, $second = 0) { if($this->_date->setTime($hour, $minute, $second) === false) { return false; } return $this; }
php
public function setTime($hour, $minute, $second = 0) { if($this->_date->setTime($hour, $minute, $second) === false) { return false; } return $this; }
[ "public", "function", "setTime", "(", "$", "hour", ",", "$", "minute", ",", "$", "second", "=", "0", ")", "{", "if", "(", "$", "this", "->", "_date", "->", "setTime", "(", "$", "hour", ",", "$", "minute", ",", "$", "second", ")", "===", "false", ...
Resets the current date of the DateTime object to a different date. @param integer $hour Hour of the time. @param integer $minute Minute of the time. @param integer $second Second of the time. @return KDate or FALSE on failure.
[ "Resets", "the", "current", "date", "of", "the", "DateTime", "object", "to", "a", "different", "date", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/date/date.php#L176-L183
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/date/date.php
KDate._translate
protected function _translate($matches) { $replacement = ''; $translator = $this->getObject('translator'); switch ($matches[0]) { case 'D': $replacement = $translator->translate(strtoupper($this->_date->format('D'))); break; case 'l': $replacement = $translator->translate(strtoupper($this->_date->format('l'))); break; case 'F': $replacement = $translator->translate(strtoupper($this->_date->format('F'))); break; case 'M': $replacement = $translator->translate(strtoupper($this->_date->format('F').'_SHORT')); break; } $replacement = preg_replace('/([a-z])/i', '\\\\$1', $replacement); return $replacement; }
php
protected function _translate($matches) { $replacement = ''; $translator = $this->getObject('translator'); switch ($matches[0]) { case 'D': $replacement = $translator->translate(strtoupper($this->_date->format('D'))); break; case 'l': $replacement = $translator->translate(strtoupper($this->_date->format('l'))); break; case 'F': $replacement = $translator->translate(strtoupper($this->_date->format('F'))); break; case 'M': $replacement = $translator->translate(strtoupper($this->_date->format('F').'_SHORT')); break; } $replacement = preg_replace('/([a-z])/i', '\\\\$1', $replacement); return $replacement; }
[ "protected", "function", "_translate", "(", "$", "matches", ")", "{", "$", "replacement", "=", "''", ";", "$", "translator", "=", "$", "this", "->", "getObject", "(", "'translator'", ")", ";", "switch", "(", "$", "matches", "[", "0", "]", ")", "{", "...
Translates day and month names. @param array $matches Matched elements of preg_replace_callback. @return string The translated string
[ "Translates", "day", "and", "month", "names", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/date/date.php#L251-L278
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/translator/catalogue/abstract.php
ComKoowaTranslatorCatalogueAbstract.clear
public function clear() { $result = parent::clear(); $this->_data = KObjectConfig::unbox($this->getConfig()->data); return $result; }
php
public function clear() { $result = parent::clear(); $this->_data = KObjectConfig::unbox($this->getConfig()->data); return $result; }
[ "public", "function", "clear", "(", ")", "{", "$", "result", "=", "parent", "::", "clear", "(", ")", ";", "$", "this", "->", "_data", "=", "KObjectConfig", "::", "unbox", "(", "$", "this", "->", "getConfig", "(", ")", "->", "data", ")", ";", "retur...
Sets the default keys again after clearing {@inheritdoc}
[ "Sets", "the", "default", "keys", "again", "after", "clearing" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/translator/catalogue/abstract.php#L119-L126
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/translator/catalogue/abstract.php
ComKoowaTranslatorCatalogueAbstract.get
public function get($string) { $lowercase = strtolower($string); if (!parent::has($lowercase)) { if (isset($this->_aliases[$lowercase])) { $key = $this->_aliases[$lowercase]; } else if(!JFactory::getLanguage()->hasKey($string)) { if (substr($string, 0, strlen($this->getPrefix())) === $this->getPrefix()) { $key = $string; } else { //Gets a key from the catalogue and prefixes it $key = $this->getPrefix().$this->generateKey($string); } } else $key = $string; $this->set($lowercase, JFactory::getLanguage()->_($key)); } return parent::get($lowercase); }
php
public function get($string) { $lowercase = strtolower($string); if (!parent::has($lowercase)) { if (isset($this->_aliases[$lowercase])) { $key = $this->_aliases[$lowercase]; } else if(!JFactory::getLanguage()->hasKey($string)) { if (substr($string, 0, strlen($this->getPrefix())) === $this->getPrefix()) { $key = $string; } else { //Gets a key from the catalogue and prefixes it $key = $this->getPrefix().$this->generateKey($string); } } else $key = $string; $this->set($lowercase, JFactory::getLanguage()->_($key)); } return parent::get($lowercase); }
[ "public", "function", "get", "(", "$", "string", ")", "{", "$", "lowercase", "=", "strtolower", "(", "$", "string", ")", ";", "if", "(", "!", "parent", "::", "has", "(", "$", "lowercase", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->",...
Get a string from the catalogue @param string $string @return string
[ "Get", "a", "string", "from", "the", "catalogue" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/translator/catalogue/abstract.php#L134-L158
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/translator/catalogue/abstract.php
ComKoowaTranslatorCatalogueAbstract.has
public function has($string) { $lowercase = strtolower($string); if (!parent::has($lowercase) && !JFactory::getLanguage()->hasKey($string)) { if (isset($this->_aliases[$lowercase])) { $key = $this->_aliases[$lowercase]; } elseif (substr($string, 0, strlen($this->getPrefix())) === $this->getPrefix()) { $key = $string; } else { //Gets a key from the catalogue and prefixes it $key = $this->getPrefix().$this->generateKey($string); } $result = JFactory::getLanguage()->hasKey($key); } else $result = true; return $result; }
php
public function has($string) { $lowercase = strtolower($string); if (!parent::has($lowercase) && !JFactory::getLanguage()->hasKey($string)) { if (isset($this->_aliases[$lowercase])) { $key = $this->_aliases[$lowercase]; } elseif (substr($string, 0, strlen($this->getPrefix())) === $this->getPrefix()) { $key = $string; } else { //Gets a key from the catalogue and prefixes it $key = $this->getPrefix().$this->generateKey($string); } $result = JFactory::getLanguage()->hasKey($key); } else $result = true; return $result; }
[ "public", "function", "has", "(", "$", "string", ")", "{", "$", "lowercase", "=", "strtolower", "(", "$", "string", ")", ";", "if", "(", "!", "parent", "::", "has", "(", "$", "lowercase", ")", "&&", "!", "JFactory", "::", "getLanguage", "(", ")", "...
Check if a string exists in the catalogue @param string $string @return boolean
[ "Check", "if", "a", "string", "exists", "in", "the", "catalogue" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/translator/catalogue/abstract.php#L166-L187
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/translator/catalogue/abstract.php
ComKoowaTranslatorCatalogueAbstract.generateKey
public function generateKey($string) { $limit = $this->getConfig()->key_length; $key = strtolower($string); if(!isset($this->_keys[$string])) { if (!$limit || strlen($key) <= $limit) { $key = strip_tags($key); $key = preg_replace('#\s+#m', ' ', $key); $key = preg_replace('#\{([A-Za-z0-9_\-\.]+)\}#', '$1', $key); $key = preg_replace('#(%[^%|^\s|^\b]+)#', 'X', $key); $key = preg_replace('#&.*?;#', '', $key); $key = preg_replace('#[\s-]+#', '_', $key); $key = preg_replace('#[^A-Za-z0-9_]#', '', $key); $key = preg_replace('#_+#', '_', $key); $key = trim($key, '_'); $key = trim(strtoupper($key)); } else { $hash = substr(md5($key), 0, 5); $key = $this->generateKey(substr($string, 0, $limit)); $key .= '_'.strtoupper($hash); } } else $key = $this->_keys[$string]; return $key; }
php
public function generateKey($string) { $limit = $this->getConfig()->key_length; $key = strtolower($string); if(!isset($this->_keys[$string])) { if (!$limit || strlen($key) <= $limit) { $key = strip_tags($key); $key = preg_replace('#\s+#m', ' ', $key); $key = preg_replace('#\{([A-Za-z0-9_\-\.]+)\}#', '$1', $key); $key = preg_replace('#(%[^%|^\s|^\b]+)#', 'X', $key); $key = preg_replace('#&.*?;#', '', $key); $key = preg_replace('#[\s-]+#', '_', $key); $key = preg_replace('#[^A-Za-z0-9_]#', '', $key); $key = preg_replace('#_+#', '_', $key); $key = trim($key, '_'); $key = trim(strtoupper($key)); } else { $hash = substr(md5($key), 0, 5); $key = $this->generateKey(substr($string, 0, $limit)); $key .= '_'.strtoupper($hash); } } else $key = $this->_keys[$string]; return $key; }
[ "public", "function", "generateKey", "(", "$", "string", ")", "{", "$", "limit", "=", "$", "this", "->", "getConfig", "(", ")", "->", "key_length", ";", "$", "key", "=", "strtolower", "(", "$", "string", ")", ";", "if", "(", "!", "isset", "(", "$",...
Generates a translation key that is safe for INI format Uses key_length in object config to limit the keys @param string $string @return string
[ "Generates", "a", "translation", "key", "that", "is", "safe", "for", "INI", "format" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/translator/catalogue/abstract.php#L197-L227
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/translator/language.php
ComKoowaTranslatorLanguage.loadFile
static public function loadFile($file, $extension, KTranslatorInterface $translator) { $lang = JFactory::getLanguage(); $result = false; if (!isset(self::$_paths[$extension][$file])) { $strings = self::parseFile($file, $translator); if (count($strings)) { ksort($strings, SORT_STRING); $lang->strings = array_merge($lang->strings, $strings); if (!empty($lang->override)) { $lang->strings = array_merge($lang->strings, $lang->override); } $result = true; } // Record the result of loading the extension's file. if (!isset($lang->paths[$extension])) { $lang->paths[$extension] = array(); } self::$_paths[$extension][$file] = $result; } return $result; }
php
static public function loadFile($file, $extension, KTranslatorInterface $translator) { $lang = JFactory::getLanguage(); $result = false; if (!isset(self::$_paths[$extension][$file])) { $strings = self::parseFile($file, $translator); if (count($strings)) { ksort($strings, SORT_STRING); $lang->strings = array_merge($lang->strings, $strings); if (!empty($lang->override)) { $lang->strings = array_merge($lang->strings, $lang->override); } $result = true; } // Record the result of loading the extension's file. if (!isset($lang->paths[$extension])) { $lang->paths[$extension] = array(); } self::$_paths[$extension][$file] = $result; } return $result; }
[ "static", "public", "function", "loadFile", "(", "$", "file", ",", "$", "extension", ",", "KTranslatorInterface", "$", "translator", ")", "{", "$", "lang", "=", "JFactory", "::", "getLanguage", "(", ")", ";", "$", "result", "=", "false", ";", "if", "(", ...
Adds file translations to the JLanguage catalogue. @param string $file The file containing translations. @param string $extension The name of the extension containing the file. @param KTranslatorInterface $translator The Translator object. @return bool True if translations where loaded, false otherwise.
[ "Adds", "file", "translations", "to", "the", "JLanguage", "catalogue", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/translator/language.php#L36-L67
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/template/helper/debug.php
ComKoowaTemplateHelperDebug.path
public function path($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'root' => JPATH_ROOT, )); return parent::path($config); }
php
public function path($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'root' => JPATH_ROOT, )); return parent::path($config); }
[ "public", "function", "path", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "KObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'root'", "=>", "JPATH_ROOT", ",", ")"...
Removes Joomla root from a filename replacing them with the plain text equivalents. @param array $config An optional array with configuration options @return string Html
[ "Removes", "Joomla", "root", "from", "a", "filename", "replacing", "them", "with", "the", "plain", "text", "equivalents", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/debug.php#L24-L32
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/filesystem/stream/filter/whitespace.php
KFilesystemStreamFilterWhitespace.filter
public function filter($in, $out, &$consumed, $closing) { while($bucket = stream_bucket_make_writeable($in)) { $bucket->data = trim(preg_replace('/>\s+</', '><', $bucket->data)); $consumed += $bucket->datalen; stream_bucket_prepend($out, $bucket); } return PSFS_PASS_ON; }
php
public function filter($in, $out, &$consumed, $closing) { while($bucket = stream_bucket_make_writeable($in)) { $bucket->data = trim(preg_replace('/>\s+</', '><', $bucket->data)); $consumed += $bucket->datalen; stream_bucket_prepend($out, $bucket); } return PSFS_PASS_ON; }
[ "public", "function", "filter", "(", "$", "in", ",", "$", "out", ",", "&", "$", "consumed", ",", "$", "closing", ")", "{", "while", "(", "$", "bucket", "=", "stream_bucket_make_writeable", "(", "$", "in", ")", ")", "{", "$", "bucket", "->", "data", ...
Called when applying the filter @param resource $in Resource pointing to a bucket brigade which contains one or more bucket objects containing data to be filtered @param resource $out Resource pointing to a second bucket brigade into which your modified buckets should be placed. @param integer $consumed Consumed, which must always be declared by reference, should be incremented by the length of the data which your filter reads in and alters. In most cases this means you will increment consumed by $bucket->datalen for each $bucket. @param bool $closing If the stream is in the process of closing (and therefore this is the last pass through the filterchain), the closing parameter will be set to TRUE. @return int
[ "Called", "when", "applying", "the", "filter" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/filter/whitespace.php#L41-L51
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/message/headers.php
KHttpMessageHeaders.remove
public function remove($key) { $key = strtr(strtolower($key), '_', '-'); unset($this->_data[$key]); return $this; }
php
public function remove($key) { $key = strtr(strtolower($key), '_', '-'); unset($this->_data[$key]); return $this; }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "$", "key", "=", "strtr", "(", "strtolower", "(", "$", "key", ")", ",", "'_'", ",", "'-'", ")", ";", "unset", "(", "$", "this", "->", "_data", "[", "$", "key", "]", ")", ";", "return", ...
Removes a header nu name @param string $key The HTTP header name @return KHttpMessageHeaders
[ "Removes", "a", "header", "nu", "name" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/message/headers.php#L151-L156
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/message/headers.php
KHttpMessageHeaders.toArray
public function toArray() { $headers = array(); //Method to implode header parameters $implode = function($parameters) { $results = array(); foreach ($parameters as $key => $parameter) { if(!is_numeric($key)) { //Parameters if(is_array($parameter)) { $modifiers = array(); foreach($parameter as $k => $v) { $modifiers[] = $k.'='.$v; } $results[] = $key.';'.implode($modifiers, ','); } else $results[] = $key.'='.$parameter; } else $results[] = $parameter; } return $value = implode($results, ', '); }; //Serialise the headers to an array ksort($this->_data); foreach ($this->_data as $name => $values) { $name = implode('-', array_map('ucfirst', explode('-', $name))); $results = array(); foreach($values as $value) { if(is_array($value)) { $results[] = $implode($value); } else { $results[] = $value; } } if ($value = implode($results, ', ')) { $headers[$name] = $value; } } return $headers; }
php
public function toArray() { $headers = array(); //Method to implode header parameters $implode = function($parameters) { $results = array(); foreach ($parameters as $key => $parameter) { if(!is_numeric($key)) { //Parameters if(is_array($parameter)) { $modifiers = array(); foreach($parameter as $k => $v) { $modifiers[] = $k.'='.$v; } $results[] = $key.';'.implode($modifiers, ','); } else $results[] = $key.'='.$parameter; } else $results[] = $parameter; } return $value = implode($results, ', '); }; //Serialise the headers to an array ksort($this->_data); foreach ($this->_data as $name => $values) { $name = implode('-', array_map('ucfirst', explode('-', $name))); $results = array(); foreach($values as $value) { if(is_array($value)) { $results[] = $implode($value); } else { $results[] = $value; } } if ($value = implode($results, ', ')) { $headers[$name] = $value; } } return $headers; }
[ "public", "function", "toArray", "(", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "//Method to implode header parameters", "$", "implode", "=", "function", "(", "$", "parameters", ")", "{", "$", "results", "=", "array", "(", ")", ";", "foreach",...
Returns the headers as an array @return array An associative array
[ "Returns", "the", "headers", "as", "an", "array" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/message/headers.php#L174-L226
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/message/headers.php
KHttpMessageHeaders.offsetGet
public function offsetGet($key) { $key = strtr(strtolower($key), '_', '-'); $result = null; if (isset($this->_data[$key])) { $result = $this->_data[$key]; } return $result; }
php
public function offsetGet($key) { $key = strtr(strtolower($key), '_', '-'); $result = null; if (isset($this->_data[$key])) { $result = $this->_data[$key]; } return $result; }
[ "public", "function", "offsetGet", "(", "$", "key", ")", "{", "$", "key", "=", "strtr", "(", "strtolower", "(", "$", "key", ")", ",", "'_'", ",", "'-'", ")", ";", "$", "result", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "_da...
Get a value by key @param string $key The key name. @return string The corresponding value.
[ "Get", "a", "value", "by", "key" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/message/headers.php#L252-L262
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/message/headers.php
KHttpMessageHeaders.offsetSet
public function offsetSet($key, $value) { $key = strtr(strtolower($key), '_', '-'); $this->_data[$key] = $value; }
php
public function offsetSet($key, $value) { $key = strtr(strtolower($key), '_', '-'); $this->_data[$key] = $value; }
[ "public", "function", "offsetSet", "(", "$", "key", ",", "$", "value", ")", "{", "$", "key", "=", "strtr", "(", "strtolower", "(", "$", "key", ")", ",", "'_'", ",", "'-'", ")", ";", "$", "this", "->", "_data", "[", "$", "key", "]", "=", "$", ...
Set a value by key @param string $key The key name @param mixed $value The value for the key @return void
[ "Set", "a", "value", "by", "key" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/message/headers.php#L271-L276
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/message/headers.php
KHttpMessageHeaders.offsetExists
public function offsetExists($key) { $key = strtr(strtolower($key), '_', '-'); return array_key_exists($key, $this->_data); }
php
public function offsetExists($key) { $key = strtr(strtolower($key), '_', '-'); return array_key_exists($key, $this->_data); }
[ "public", "function", "offsetExists", "(", "$", "key", ")", "{", "$", "key", "=", "strtr", "(", "strtolower", "(", "$", "key", ")", ",", "'_'", ",", "'-'", ")", ";", "return", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_data", ")...
Test existence of a key @param string $key The key name @return boolean
[ "Test", "existence", "of", "a", "key" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/message/headers.php#L284-L289
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/controller/toolbar/actionbar.php
ComKoowaControllerToolbarActionbar._afterRead
protected function _afterRead(KControllerContextInterface $context) { $controller = $this->getController(); $translator = $this->getObject('translator'); $name = $translator->translate(strtolower($context->subject->getIdentifier()->name)); if($controller->getModel()->getState()->isUnique()) { $title = $translator->translate('Edit {item_type}', array('item_type' => $name)); } else { $title = $translator->translate('Create new {item_type}', array('item_type' => $name)); } $this->getCommand('title')->title = $title; parent::_afterRead($context); }
php
protected function _afterRead(KControllerContextInterface $context) { $controller = $this->getController(); $translator = $this->getObject('translator'); $name = $translator->translate(strtolower($context->subject->getIdentifier()->name)); if($controller->getModel()->getState()->isUnique()) { $title = $translator->translate('Edit {item_type}', array('item_type' => $name)); } else { $title = $translator->translate('Create new {item_type}', array('item_type' => $name)); } $this->getCommand('title')->title = $title; parent::_afterRead($context); }
[ "protected", "function", "_afterRead", "(", "KControllerContextInterface", "$", "context", ")", "{", "$", "controller", "=", "$", "this", "->", "getController", "(", ")", ";", "$", "translator", "=", "$", "this", "->", "getObject", "(", "'translator'", ")", ...
Add default action commands and set the action bar title . @param KControllerContextInterface $context A command context object
[ "Add", "default", "action", "commands", "and", "set", "the", "action", "bar", "title", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/toolbar/actionbar.php#L59-L74
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/controller/toolbar/actionbar.php
ComKoowaControllerToolbarActionbar.addCommand
public function addCommand($name, $config = array()) { if (!isset($config['label']) && in_array($name, self::$_default_buttons)) { $config['label'] = 'JTOOLBAR_'.$name; } return parent::addCommand($name, $config); }
php
public function addCommand($name, $config = array()) { if (!isset($config['label']) && in_array($name, self::$_default_buttons)) { $config['label'] = 'JTOOLBAR_'.$name; } return parent::addCommand($name, $config); }
[ "public", "function", "addCommand", "(", "$", "name", ",", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'label'", "]", ")", "&&", "in_array", "(", "$", "name", ",", "self", "::", "$", "_defau...
If the method is called with one of the standard Joomla toolbar buttons translate the label correctly @param string $name The command name @param array $config The command configuration options @return $this
[ "If", "the", "method", "is", "called", "with", "one", "of", "the", "standard", "Joomla", "toolbar", "buttons", "translate", "the", "label", "correctly" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/toolbar/actionbar.php#L100-L107
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/controller/toolbar/actionbar.php
ComKoowaControllerToolbarActionbar._commandOptions
protected function _commandOptions(KControllerToolbarCommand $command) { $option = $this->getIdentifier()->package; $return = urlencode(base64_encode(JUri::getInstance())); $link = 'option=com_config&view=component&component=com_'.$option.'&path=&return='.$return; $command->icon = 'k-icon-cog'; // Need to do a JRoute call here, otherwise component is turned into option in the query string by our router $command->attribs['href'] = JRoute::_('index.php?'.$link, false); }
php
protected function _commandOptions(KControllerToolbarCommand $command) { $option = $this->getIdentifier()->package; $return = urlencode(base64_encode(JUri::getInstance())); $link = 'option=com_config&view=component&component=com_'.$option.'&path=&return='.$return; $command->icon = 'k-icon-cog'; // Need to do a JRoute call here, otherwise component is turned into option in the query string by our router $command->attribs['href'] = JRoute::_('index.php?'.$link, false); }
[ "protected", "function", "_commandOptions", "(", "KControllerToolbarCommand", "$", "command", ")", "{", "$", "option", "=", "$", "this", "->", "getIdentifier", "(", ")", "->", "package", ";", "$", "return", "=", "urlencode", "(", "base64_encode", "(", "JUri", ...
Options Toolbar Command @param KControllerToolbarCommand $command A KControllerToolbarCommand object @return void
[ "Options", "Toolbar", "Command" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/toolbar/actionbar.php#L174-L184
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/cookie/cookie.php
KHttpCookie.setName
public function setName($name) { //Check for invalid cookie name (from PHP source code) if (preg_match("/[=,; \t\r\n\013\014]/", $name)) { throw new InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name)); } //Check for empty cookie name if (empty($name)) { throw new InvalidArgumentException('The cookie name cannot be empty.'); } $this->_name = $name; return $this; }
php
public function setName($name) { //Check for invalid cookie name (from PHP source code) if (preg_match("/[=,; \t\r\n\013\014]/", $name)) { throw new InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name)); } //Check for empty cookie name if (empty($name)) { throw new InvalidArgumentException('The cookie name cannot be empty.'); } $this->_name = $name; return $this; }
[ "public", "function", "setName", "(", "$", "name", ")", "{", "//Check for invalid cookie name (from PHP source code)", "if", "(", "preg_match", "(", "\"/[=,; \\t\\r\\n\\013\\014]/\"", ",", "$", "name", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "s...
Set the cookie name @param string $name The name of the cookie @throws \InvalidArgumentException If the cookie name is not valid or is empty @return KHttpCookie
[ "Set", "the", "cookie", "name" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/cookie/cookie.php#L126-L140
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/cookie/cookie.php
KHttpCookie.setExpire
public function setExpire($expire) { // Convert expiration time to a Unix timestamp if ($expire instanceof DateTime) { $expire = $expire->format('U'); } if (!is_numeric($expire)) { $expire = strtotime($expire); if ($expire === false || $expire === -1) { throw new InvalidArgumentException('The cookie expiration time is not valid.'); } } $this->_expire = $expire; return $this; }
php
public function setExpire($expire) { // Convert expiration time to a Unix timestamp if ($expire instanceof DateTime) { $expire = $expire->format('U'); } if (!is_numeric($expire)) { $expire = strtotime($expire); if ($expire === false || $expire === -1) { throw new InvalidArgumentException('The cookie expiration time is not valid.'); } } $this->_expire = $expire; return $this; }
[ "public", "function", "setExpire", "(", "$", "expire", ")", "{", "// Convert expiration time to a Unix timestamp", "if", "(", "$", "expire", "instanceof", "DateTime", ")", "{", "$", "expire", "=", "$", "expire", "->", "format", "(", "'U'", ")", ";", "}", "if...
Set the cookie expiration time @param integer|string|\DateTime $expire The expiration time of the cookie @throws \InvalidArgumentException If the cookie expiration time is not valid @return KHttpCookie
[ "Set", "the", "cookie", "expiration", "time" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/cookie/cookie.php#L149-L167
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/cookie/cookie.php
KHttpCookie.setPath
public function setPath($path) { if(empty($path)) { $this->_path = '/'; } else { $this->_path = $path; } return $this; }
php
public function setPath($path) { if(empty($path)) { $this->_path = '/'; } else { $this->_path = $path; } return $this; }
[ "public", "function", "setPath", "(", "$", "path", ")", "{", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "$", "this", "->", "_path", "=", "'/'", ";", "}", "else", "{", "$", "this", "->", "_path", "=", "$", "path", ";", "}", "return", ...
Set the cookie path @param string $path The cookie path @return KHttpCookie
[ "Set", "the", "cookie", "path" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/cookie/cookie.php#L175-L184
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/cookie/cookie.php
KHttpCookie.toString
public function toString() { $str = urlencode($this->name) . '='; if ((string)$this->value !== '' ) { $str .= urlencode($this->value); if ($this->_expire !== 0) { $str .= '; expires=' . gmdate(DateTime::COOKIE, $this->_expire); } } else $str .= 'deleted; expires=' . gmdate(DateTime::COOKIE, time() - 31536001); if ($this->_path) { $str .= '; path=' . $this->_path; } if ($this->domain !== null) { $str .= '; domain=' . $this->domain; } if ($this->isSecure() === true) { $str .= '; secure'; } if ($this->isHttpOnly() === true) { $str .= '; httponly'; } return $str; }
php
public function toString() { $str = urlencode($this->name) . '='; if ((string)$this->value !== '' ) { $str .= urlencode($this->value); if ($this->_expire !== 0) { $str .= '; expires=' . gmdate(DateTime::COOKIE, $this->_expire); } } else $str .= 'deleted; expires=' . gmdate(DateTime::COOKIE, time() - 31536001); if ($this->_path) { $str .= '; path=' . $this->_path; } if ($this->domain !== null) { $str .= '; domain=' . $this->domain; } if ($this->isSecure() === true) { $str .= '; secure'; } if ($this->isHttpOnly() === true) { $str .= '; httponly'; } return $str; }
[ "public", "function", "toString", "(", ")", "{", "$", "str", "=", "urlencode", "(", "$", "this", "->", "name", ")", ".", "'='", ";", "if", "(", "(", "string", ")", "$", "this", "->", "value", "!==", "''", ")", "{", "$", "str", ".=", "urlencode", ...
Return a string representation of the cookie @return string
[ "Return", "a", "string", "representation", "of", "the", "cookie" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/cookie/cookie.php#L221-L252
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/http/cookie/cookie.php
KHttpCookie.&
public function &__get($key) { $result = null; if ($key == 'name') { $result = $this->_name; } if ($key == 'expire') { $result = $this->_expire; } if ($key == 'path') { $result = $this->_path; } return $result; }
php
public function &__get($key) { $result = null; if ($key == 'name') { $result = $this->_name; } if ($key == 'expire') { $result = $this->_expire; } if ($key == 'path') { $result = $this->_path; } return $result; }
[ "public", "function", "&", "__get", "(", "$", "key", ")", "{", "$", "result", "=", "null", ";", "if", "(", "$", "key", "==", "'name'", ")", "{", "$", "result", "=", "$", "this", "->", "_name", ";", "}", "if", "(", "$", "key", "==", "'expire'", ...
Get a cookie attribute by key @param string $key The key name. @return string $value The corresponding value.
[ "Get", "a", "cookie", "attribute", "by", "key" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/cookie/cookie.php#L282-L299
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/template/helper/behavior.php
ComKoowaTemplateHelperBehavior.koowa
public function koowa($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'debug' => JFactory::getApplication()->getCfg('debug') )); return parent::koowa($config); }
php
public function koowa($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'debug' => JFactory::getApplication()->getCfg('debug') )); return parent::koowa($config); }
[ "public", "function", "koowa", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "KObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'debug'", "=>", "JFactory", "::", "g...
Loads koowa.js @param array|KObjectConfig $config @return string
[ "Loads", "koowa", ".", "js" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/behavior.php#L24-L32
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/template/helper/behavior.php
ComKoowaTemplateHelperBehavior.vue
public function vue($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'debug' => JFactory::getApplication()->getCfg('debug') )); return parent::vue($config); }
php
public function vue($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'debug' => JFactory::getApplication()->getCfg('debug') )); return parent::vue($config); }
[ "public", "function", "vue", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "KObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'debug'", "=>", "JFactory", "::", "get...
Loads Vue.js @param array|KObjectConfig $config @return string
[ "Loads", "Vue", ".", "js" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/behavior.php#L40-L48
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/template/helper/behavior.php
ComKoowaTemplateHelperBehavior.kodekitui
public function kodekitui($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'debug' => JFactory::getApplication()->getCfg('debug') )); return parent::kodekitui($config); }
php
public function kodekitui($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'debug' => JFactory::getApplication()->getCfg('debug') )); return parent::kodekitui($config); }
[ "public", "function", "kodekitui", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "KObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'debug'", "=>", "JFactory", "::", ...
Loads KUI initialize @param array|KObjectConfig $config @return string
[ "Loads", "KUI", "initialize" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/behavior.php#L72-L80
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/template/helper/behavior.php
ComKoowaTemplateHelperBehavior.tree
public function tree($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'debug' => JFactory::getApplication()->getCfg('debug') )); return parent::tree($config); }
php
public function tree($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'debug' => JFactory::getApplication()->getCfg('debug') )); return parent::tree($config); }
[ "public", "function", "tree", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "KObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'debug'", "=>", "JFactory", "::", "ge...
Loads the Koowa customized jQtree behavior and renders a sidebar-nav list useful in split views @see http://mbraak.github.io/jqTree/ @note If no 'element' option is passed, then only assets will be loaded. @param array|KObjectConfig $config @throws InvalidArgumentException @return string The html output
[ "Loads", "the", "Koowa", "customized", "jQtree", "behavior", "and", "renders", "a", "sidebar", "-", "nav", "list", "useful", "in", "split", "views" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/behavior.php#L210-L218
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/template/helper/grid.php
KTemplateHelperGrid.publish
public function publish($config = array()) { $translator = $this->getObject('translator'); $config = new KObjectConfigJson($config); $config->append(array( 'entity' => null, 'field' => 'enabled', 'clickable' => true ))->append(array( 'enabled' => (bool) $config->entity->{$config->field}, ))->append(array( 'alt' => $config->enabled ? $translator->translate('Published') : $translator->translate('Unpublished'), 'tooltip' => $config->enabled ? $translator->translate('Unpublish Item') : $translator->translate('Publish Item'), 'color' => $config->enabled ? '#468847' : '#b94a48', 'icon' => $config->enabled ? 'enabled' : 'disabled', )); return $this->enable($config); }
php
public function publish($config = array()) { $translator = $this->getObject('translator'); $config = new KObjectConfigJson($config); $config->append(array( 'entity' => null, 'field' => 'enabled', 'clickable' => true ))->append(array( 'enabled' => (bool) $config->entity->{$config->field}, ))->append(array( 'alt' => $config->enabled ? $translator->translate('Published') : $translator->translate('Unpublished'), 'tooltip' => $config->enabled ? $translator->translate('Unpublish Item') : $translator->translate('Publish Item'), 'color' => $config->enabled ? '#468847' : '#b94a48', 'icon' => $config->enabled ? 'enabled' : 'disabled', )); return $this->enable($config); }
[ "public", "function", "publish", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "translator", "=", "$", "this", "->", "getObject", "(", "'translator'", ")", ";", "$", "config", "=", "new", "KObjectConfigJson", "(", "$", "config", ")", ";", ...
Render a publish field @param array $config An optional array with configuration options @return string Html
[ "Render", "a", "publish", "field" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/helper/grid.php#L296-L315
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/database/behavior/lockable.php
KDatabaseBehaviorLockable.lock
public function lock() { //Prevent lock take over, only an saved and unlocked row and be locked if(!$this->isNew() && !$this->isLocked()) { $this->locked_by = (int) $this->getObject('user')->getId(); $this->locked_on = gmdate('Y-m-d H:i:s'); $this->save(); } return true; }
php
public function lock() { //Prevent lock take over, only an saved and unlocked row and be locked if(!$this->isNew() && !$this->isLocked()) { $this->locked_by = (int) $this->getObject('user')->getId(); $this->locked_on = gmdate('Y-m-d H:i:s'); $this->save(); } return true; }
[ "public", "function", "lock", "(", ")", "{", "//Prevent lock take over, only an saved and unlocked row and be locked", "if", "(", "!", "$", "this", "->", "isNew", "(", ")", "&&", "!", "$", "this", "->", "isLocked", "(", ")", ")", "{", "$", "this", "->", "loc...
Lock a row Requires an 'locked_on' and 'locked_by' column @return boolean If successful return TRUE, otherwise FALSE
[ "Lock", "a", "row" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/behavior/lockable.php#L90-L101
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/database/behavior/lockable.php
KDatabaseBehaviorLockable.unlock
public function unlock() { $userid = $this->getObject('user')->getId(); //Only an saved row can be unlocked by the user who locked it if(!$this->isNew() && $this->locked_by != 0 && $this->locked_by == $userid) { $this->locked_by = 0; $this->locked_on = 0; $this->save(); } return true; }
php
public function unlock() { $userid = $this->getObject('user')->getId(); //Only an saved row can be unlocked by the user who locked it if(!$this->isNew() && $this->locked_by != 0 && $this->locked_by == $userid) { $this->locked_by = 0; $this->locked_on = 0; $this->save(); } return true; }
[ "public", "function", "unlock", "(", ")", "{", "$", "userid", "=", "$", "this", "->", "getObject", "(", "'user'", ")", "->", "getId", "(", ")", ";", "//Only an saved row can be unlocked by the user who locked it", "if", "(", "!", "$", "this", "->", "isNew", ...
Unlock a row Requires an locked_on and locked_by column to be present in the table @return boolean If successful return TRUE, otherwise FALSE
[ "Unlock", "a", "row" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/behavior/lockable.php#L110-L124
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/database/behavior/lockable.php
KDatabaseBehaviorLockable.isLocked
public function isLocked() { $result = false; if(!$this->isNew()) { if(isset($this->locked_on) && isset($this->locked_by)) { $locked = strtotime($this->locked_on); $current = strtotime(gmdate('Y-m-d H:i:s')); //Check if the lock has gone stale if($current - $locked < $this->_lifetime) { $userid = $this->getObject('user')->getId(); if($this->locked_by != 0 && $this->locked_by != $userid) { $result= true; } } } } return $result; }
php
public function isLocked() { $result = false; if(!$this->isNew()) { if(isset($this->locked_on) && isset($this->locked_by)) { $locked = strtotime($this->locked_on); $current = strtotime(gmdate('Y-m-d H:i:s')); //Check if the lock has gone stale if($current - $locked < $this->_lifetime) { $userid = $this->getObject('user')->getId(); if($this->locked_by != 0 && $this->locked_by != $userid) { $result= true; } } } } return $result; }
[ "public", "function", "isLocked", "(", ")", "{", "$", "result", "=", "false", ";", "if", "(", "!", "$", "this", "->", "isNew", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "locked_on", ")", "&&", "isset", "(", "$", "this", "-...
Checks if a row is locked @return boolean If the row is locked TRUE, otherwise FALSE
[ "Checks", "if", "a", "row", "is", "locked" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/behavior/lockable.php#L131-L153
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/template/helper/menubar.php
ComKoowaTemplateHelperMenubar.render
public function render($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'toolbar' => null )); $html = '<ul class="k-navigation">'; foreach ($config->toolbar->getCommands() as $command) { $command->append(array( 'attribs' => array( 'href' => '#', 'class' => array() ) )); if(!empty($command->href)) { $command->attribs['href'] = $this->getTemplate()->route($command->href); } $url = KHttpUrl::fromString($command->attribs->href); if (isset($url->query['view'])) { $command->attribs->class->append('k-navigation-'.$url->query['view']); } $attribs = clone $command->attribs; $attribs->class = implode(" ", KObjectConfig::unbox($attribs->class)); $html .= '<li'.($command->active ? ' class="k-is-active"' : '').'>'; $html .= '<a '.$this->buildAttributes($attribs).'>'; $html .= $this->getObject('translator')->translate($command->label); $html .= '</a>'; $html .= '</li>'; } $html .= '</ul>'; return $html; }
php
public function render($config = array()) { $config = new KObjectConfigJson($config); $config->append(array( 'toolbar' => null )); $html = '<ul class="k-navigation">'; foreach ($config->toolbar->getCommands() as $command) { $command->append(array( 'attribs' => array( 'href' => '#', 'class' => array() ) )); if(!empty($command->href)) { $command->attribs['href'] = $this->getTemplate()->route($command->href); } $url = KHttpUrl::fromString($command->attribs->href); if (isset($url->query['view'])) { $command->attribs->class->append('k-navigation-'.$url->query['view']); } $attribs = clone $command->attribs; $attribs->class = implode(" ", KObjectConfig::unbox($attribs->class)); $html .= '<li'.($command->active ? ' class="k-is-active"' : '').'>'; $html .= '<a '.$this->buildAttributes($attribs).'>'; $html .= $this->getObject('translator')->translate($command->label); $html .= '</a>'; $html .= '</li>'; } $html .= '</ul>'; return $html; }
[ "public", "function", "render", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "new", "KObjectConfigJson", "(", "$", "config", ")", ";", "$", "config", "->", "append", "(", "array", "(", "'toolbar'", "=>", "null", ")", ")",...
Render the menu bar @param array $config An optional array with configuration options @return string Html
[ "Render", "the", "menu", "bar" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/menubar.php#L24-L65
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php
ComKoowaDispatcherBehaviorDecoratable._beforeDispatch
protected function _beforeDispatch(KDispatcherContextInterface $context) { if ($this->getDecorator() != 'joomla') { $app = JFactory::getApplication(); if ($app->isSite()) { $app->setTemplate('system'); } } }
php
protected function _beforeDispatch(KDispatcherContextInterface $context) { if ($this->getDecorator() != 'joomla') { $app = JFactory::getApplication(); if ($app->isSite()) { $app->setTemplate('system'); } } }
[ "protected", "function", "_beforeDispatch", "(", "KDispatcherContextInterface", "$", "context", ")", "{", "if", "(", "$", "this", "->", "getDecorator", "(", ")", "!=", "'joomla'", ")", "{", "$", "app", "=", "JFactory", "::", "getApplication", "(", ")", ";", ...
Set the Joomla application context @param KDispatcherContextInterface $context A command context object @return void
[ "Set", "the", "Joomla", "application", "context" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php#L42-L52
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php
ComKoowaDispatcherBehaviorDecoratable._beforeSend
protected function _beforeSend(KDispatcherContextInterface $context) { $response = $context->getResponse(); if(!$response->isDownloadable() && !$response->isRedirect()) { //Render the page $result = $this->getObject('com:koowa.controller.page', array('response' => $response)) ->layout($this->getDecorator()) ->render(); //Set the result in the response $response->setContent($result); } }
php
protected function _beforeSend(KDispatcherContextInterface $context) { $response = $context->getResponse(); if(!$response->isDownloadable() && !$response->isRedirect()) { //Render the page $result = $this->getObject('com:koowa.controller.page', array('response' => $response)) ->layout($this->getDecorator()) ->render(); //Set the result in the response $response->setContent($result); } }
[ "protected", "function", "_beforeSend", "(", "KDispatcherContextInterface", "$", "context", ")", "{", "$", "response", "=", "$", "context", "->", "getResponse", "(", ")", ";", "if", "(", "!", "$", "response", "->", "isDownloadable", "(", ")", "&&", "!", "$...
Decorate the response @param KDispatcherContextInterface $context A command context object @return void
[ "Decorate", "the", "response" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php#L60-L75
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php
ComKoowaDispatcherBehaviorDecoratable._beforeTerminate
protected function _beforeTerminate(KDispatcherContextInterface $context) { $response = $context->getResponse(); //Pass back to Joomla if(!$response->isRedirect() && !$response->isDownloadable() && $this->getDecorator() == 'joomla') { // #237 - Since Joomla will wrap the page we do not know the actual content-length and should not send it $response->getHeaders()->remove('Content-length'); header_remove('Content-Length'); //Contenttype JFactory::getDocument()->setMimeEncoding($response->getContentType()); //Set messages for any request method $messages = $response->getMessages(); foreach($messages as $type => $group) { if ($type === 'success') { $type = 'message'; } foreach($group as $message) { JFactory::getApplication()->enqueueMessage($message, $type); } } //Set the cache state JFactory::getApplication()->allowCache($context->getRequest()->isCacheable()); //Do not flush the response return false; } }
php
protected function _beforeTerminate(KDispatcherContextInterface $context) { $response = $context->getResponse(); //Pass back to Joomla if(!$response->isRedirect() && !$response->isDownloadable() && $this->getDecorator() == 'joomla') { // #237 - Since Joomla will wrap the page we do not know the actual content-length and should not send it $response->getHeaders()->remove('Content-length'); header_remove('Content-Length'); //Contenttype JFactory::getDocument()->setMimeEncoding($response->getContentType()); //Set messages for any request method $messages = $response->getMessages(); foreach($messages as $type => $group) { if ($type === 'success') { $type = 'message'; } foreach($group as $message) { JFactory::getApplication()->enqueueMessage($message, $type); } } //Set the cache state JFactory::getApplication()->allowCache($context->getRequest()->isCacheable()); //Do not flush the response return false; } }
[ "protected", "function", "_beforeTerminate", "(", "KDispatcherContextInterface", "$", "context", ")", "{", "$", "response", "=", "$", "context", "->", "getResponse", "(", ")", ";", "//Pass back to Joomla", "if", "(", "!", "$", "response", "->", "isRedirect", "("...
Pass the response to Joomla @param KDispatcherContextInterface $context A command context object @return bool
[ "Pass", "the", "response", "to", "Joomla" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php#L83-L116
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php
ComKoowaDispatcherBehaviorDecoratable.getDecorator
public function getDecorator() { $request = $this->getRequest(); $response = $this->getResponse(); if($request->getQuery()->tmpl === 'koowa' || $request->getHeaders()->has('X-Flush-Response') || $response->isError()) { $result = 'koowa'; } else { $result = $this->getController()->getView()->getDecorator(); } return $result; }
php
public function getDecorator() { $request = $this->getRequest(); $response = $this->getResponse(); if($request->getQuery()->tmpl === 'koowa' || $request->getHeaders()->has('X-Flush-Response') || $response->isError()) { $result = 'koowa'; } else { $result = $this->getController()->getView()->getDecorator(); } return $result; }
[ "public", "function", "getDecorator", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "response", "=", "$", "this", "->", "getResponse", "(", ")", ";", "if", "(", "$", "request", "->", "getQuery", "(", ")", ...
Get the decorator name @return string
[ "Get", "the", "decorator", "name" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/behavior/decoratable.php#L123-L135
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/user/provider/abstract.php
KUserProviderAbstract.load
public function load($identifier, $refresh = false) { //Fetch a user from the backend if($refresh || !$this->isLoaded($identifier)) { $user = $this->fetch($identifier); $this->_users[$identifier] = $user; } return $this->_users[$identifier]; }
php
public function load($identifier, $refresh = false) { //Fetch a user from the backend if($refresh || !$this->isLoaded($identifier)) { $user = $this->fetch($identifier); $this->_users[$identifier] = $user; } return $this->_users[$identifier]; }
[ "public", "function", "load", "(", "$", "identifier", ",", "$", "refresh", "=", "false", ")", "{", "//Fetch a user from the backend", "if", "(", "$", "refresh", "||", "!", "$", "this", "->", "isLoaded", "(", "$", "identifier", ")", ")", "{", "$", "user",...
Loads the user for the given user identifier @param string $identifier A unique user identifier, (i.e a username or email address) @param bool $refresh If TRUE and the user has already been loaded it will be re-loaded. @return KUserInterface Returns a UserInterface object
[ "Loads", "the", "user", "for", "the", "given", "user", "identifier" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/provider/abstract.php#L67-L77
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/object/config/config.php
KObjectConfig.get
public function get($name, $default = null) { $result = $default; if(isset($this->__options[$name]) || array_key_exists($name, $this->__options)) { $result = $this->__options[$name]; } return $result; }
php
public function get($name, $default = null) { $result = $default; if(isset($this->__options[$name]) || array_key_exists($name, $this->__options)) { $result = $this->__options[$name]; } return $result; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "result", "=", "$", "default", ";", "if", "(", "isset", "(", "$", "this", "->", "__options", "[", "$", "name", "]", ")", "||", "array_key_exists", "(", ...
Retrieve a configuration option If the option does not exist return the default. @param string $name @param mixed $default @return mixed
[ "Retrieve", "a", "configuration", "option" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/config/config.php#L57-L65
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/event/subscriber/application.php
ComKoowaEventSubscriberApplication.onAfterApplicationInitialise
public function onAfterApplicationInitialise(KEventInterface $event) { if(JFactory::getUser()->guest) { $authenticator = $this->getObject('com:koowa.dispatcher.authenticator.jwt'); if ($authenticator->getAuthToken()) { $dispatcher = $this->getObject('com:koowa.dispatcher.http'); $authenticator->authenticateRequest($dispatcher->getContext()); } } }
php
public function onAfterApplicationInitialise(KEventInterface $event) { if(JFactory::getUser()->guest) { $authenticator = $this->getObject('com:koowa.dispatcher.authenticator.jwt'); if ($authenticator->getAuthToken()) { $dispatcher = $this->getObject('com:koowa.dispatcher.http'); $authenticator->authenticateRequest($dispatcher->getContext()); } } }
[ "public", "function", "onAfterApplicationInitialise", "(", "KEventInterface", "$", "event", ")", "{", "if", "(", "JFactory", "::", "getUser", "(", ")", "->", "guest", ")", "{", "$", "authenticator", "=", "$", "this", "->", "getObject", "(", "'com:koowa.dispatc...
Log user in from the JWT token in the request if possible onAfterInitialise is used here to make sure that Joomla doesn't display error messages for menu items with registered and above access levels.
[ "Log", "user", "in", "from", "the", "JWT", "token", "in", "the", "request", "if", "possible" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/event/subscriber/application.php#L33-L45
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/event/subscriber/application.php
ComKoowaEventSubscriberApplication.onBeforeApplicationTerminate
public function onBeforeApplicationTerminate(KEventInterface $event) { if (JDEBUG && !headers_sent()) { $buffer = JProfiler::getInstance('Application')->getBuffer(); if ($buffer) { $data = strip_tags(end($buffer)); $row = array(array($data), null, 'info'); $header = array( 'version' => '4.1.0', 'columns' => array('log', 'backtrace', 'type'), 'rows' => array($row) ); header('X-ChromeLogger-Data: ' . base64_encode(utf8_encode(json_encode($header)))); } } }
php
public function onBeforeApplicationTerminate(KEventInterface $event) { if (JDEBUG && !headers_sent()) { $buffer = JProfiler::getInstance('Application')->getBuffer(); if ($buffer) { $data = strip_tags(end($buffer)); $row = array(array($data), null, 'info'); $header = array( 'version' => '4.1.0', 'columns' => array('log', 'backtrace', 'type'), 'rows' => array($row) ); header('X-ChromeLogger-Data: ' . base64_encode(utf8_encode(json_encode($header)))); } } }
[ "public", "function", "onBeforeApplicationTerminate", "(", "KEventInterface", "$", "event", ")", "{", "if", "(", "JDEBUG", "&&", "!", "headers_sent", "(", ")", ")", "{", "$", "buffer", "=", "JProfiler", "::", "getInstance", "(", "'Application'", ")", "->", "...
Adds application response time and memory usage to Chrome Inspector with ChromeLogger extension See: https://chrome.google.com/webstore/detail/chrome-logger/noaneddfkdjfnfdakjjmocngnfkfehhd
[ "Adds", "application", "response", "time", "and", "memory", "usage", "to", "Chrome", "Inspector", "with", "ChromeLogger", "extension" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/event/subscriber/application.php#L105-L124
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/object/manager/manager.php
KObjectManager.getObject
public function getObject($identifier, array $config = array()) { $identifier = $this->getIdentifier($identifier); if (!$instance = $this->isRegistered($identifier)) { //Instantiate the identifier $instance = $this->_instantiate($identifier, $config); //Mixins's are early mixed in KObject::_construct() //$instance = $this->_mixin($identifier, $instance); //Decorate the object $instance = $this->_decorate($identifier, $instance); //Auto register the object if($this->isMultiton($identifier)) { $this->setObject($identifier, $instance); } } return $instance; }
php
public function getObject($identifier, array $config = array()) { $identifier = $this->getIdentifier($identifier); if (!$instance = $this->isRegistered($identifier)) { //Instantiate the identifier $instance = $this->_instantiate($identifier, $config); //Mixins's are early mixed in KObject::_construct() //$instance = $this->_mixin($identifier, $instance); //Decorate the object $instance = $this->_decorate($identifier, $instance); //Auto register the object if($this->isMultiton($identifier)) { $this->setObject($identifier, $instance); } } return $instance; }
[ "public", "function", "getObject", "(", "$", "identifier", ",", "array", "$", "config", "=", "array", "(", ")", ")", "{", "$", "identifier", "=", "$", "this", "->", "getIdentifier", "(", "$", "identifier", ")", ";", "if", "(", "!", "$", "instance", "...
Get an object instance based on an object identifier If the object implements the ObjectInstantiable interface the manager will delegate object instantiation to the object itself. @param mixed $identifier An KObjectIdentifier, identifier string or object implementing KObjectInterface @param array $config An optional associative array of configuration settings @return KObjectInterface Return object on success, throws exception on failure @throws KObjectExceptionInvalidIdentifier If the identifier is not valid @throws KObjectExceptionInvalidObject If the object doesn't implement the KObjectInterface @throws KObjectExceptionNotFound If object cannot be loaded @throws KObjectExceptionNotInstantiated If object cannot be instantiated
[ "Get", "an", "object", "instance", "based", "on", "an", "object", "identifier" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/manager/manager.php#L154-L176
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/object/manager/manager.php
KObjectManager._configure
protected function _configure(KObjectIdentifier $identifier, array $data = array()) { //Prevent config settings from being stored in the identifier $config = clone $identifier->getConfig(); //Append the config data from the singleton if($identifier->getType() != 'lib' && $this->isSingleton($identifier)) { $parts = $identifier->toArray(); unset($parts['type']); unset($parts['domain']); unset($parts['package']); //Append the config from the singleton $config->append($this->getIdentifier($parts)->getConfig()); } //Append the config data for the object $config->append($data); //Set the service container and identifier $config->object_manager = $this; $config->object_identifier = $identifier; return $config; }
php
protected function _configure(KObjectIdentifier $identifier, array $data = array()) { //Prevent config settings from being stored in the identifier $config = clone $identifier->getConfig(); //Append the config data from the singleton if($identifier->getType() != 'lib' && $this->isSingleton($identifier)) { $parts = $identifier->toArray(); unset($parts['type']); unset($parts['domain']); unset($parts['package']); //Append the config from the singleton $config->append($this->getIdentifier($parts)->getConfig()); } //Append the config data for the object $config->append($data); //Set the service container and identifier $config->object_manager = $this; $config->object_identifier = $identifier; return $config; }
[ "protected", "function", "_configure", "(", "KObjectIdentifier", "$", "identifier", ",", "array", "$", "data", "=", "array", "(", ")", ")", "{", "//Prevent config settings from being stored in the identifier", "$", "config", "=", "clone", "$", "identifier", "->", "g...
Configure an identifier @param KObjectIdentifier $identifier @param array $data @return KObjectConfig
[ "Configure", "an", "identifier" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/manager/manager.php#L623-L649
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/component/koowa/controller/model.php
ComKoowaControllerModel._actionRead
protected function _actionRead(KControllerContextInterface $context) { //Request if($this->getIdentifier()->domain === 'admin') { if($this->isEditable() && KStringInflector::isSingular($this->getView()->getName())) { //Use JInput as we do not pass the request query back into the Joomla context JFactory::getApplication()->input->set('hidemainmenu', 1); } } return parent::_actionRead($context); }
php
protected function _actionRead(KControllerContextInterface $context) { //Request if($this->getIdentifier()->domain === 'admin') { if($this->isEditable() && KStringInflector::isSingular($this->getView()->getName())) { //Use JInput as we do not pass the request query back into the Joomla context JFactory::getApplication()->input->set('hidemainmenu', 1); } } return parent::_actionRead($context); }
[ "protected", "function", "_actionRead", "(", "KControllerContextInterface", "$", "context", ")", "{", "//Request", "if", "(", "$", "this", "->", "getIdentifier", "(", ")", "->", "domain", "===", "'admin'", ")", "{", "if", "(", "$", "this", "->", "isEditable"...
Generic read action, fetches an item @param KControllerContextInterface $context A command context object @throws KControllerExceptionResourceNotFound @return KModelEntityInterface
[ "Generic", "read", "action", "fetches", "an", "item" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/model.php#L51-L64
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/template/helper/paginator.php
KTemplateHelperPaginator._pages
protected function _pages($pages) { $html = ''; //$html .= $pages['first']->active ? '<li>'.$this->_link($pages['first'], '<i class="icon-fast-backward icon-first"></i>').'</li>' : ''; $html .= $pages['previous']->active ? '<li>'.$this->_link($pages['previous'], '&laquo;').'</li>' : ''; $previous = null; foreach ($pages['pages'] as $page) { if ($previous && $page->page - $previous->page > 1) { $html .= '<li class="k-is-disabled"><span>&hellip;</span></li>'; } $html .= '<li class="'.($page->active && !$page->current ? '' : 'k-is-active').'">'; $html .= $this->_link($page, $page->page); $html .= '</li>'; $previous = $page; } $html .= $pages['next']->active ? '<li>'.$this->_link($pages['next'], '&raquo;').'</li>' : ''; //$html .= $pages['last']->active ? '<li>'.$this->_link($pages['last'], '<i class="icon-fast-forward icon-last"></i>').'</li>' : ''; return $html; }
php
protected function _pages($pages) { $html = ''; //$html .= $pages['first']->active ? '<li>'.$this->_link($pages['first'], '<i class="icon-fast-backward icon-first"></i>').'</li>' : ''; $html .= $pages['previous']->active ? '<li>'.$this->_link($pages['previous'], '&laquo;').'</li>' : ''; $previous = null; foreach ($pages['pages'] as $page) { if ($previous && $page->page - $previous->page > 1) { $html .= '<li class="k-is-disabled"><span>&hellip;</span></li>'; } $html .= '<li class="'.($page->active && !$page->current ? '' : 'k-is-active').'">'; $html .= $this->_link($page, $page->page); $html .= '</li>'; $previous = $page; } $html .= $pages['next']->active ? '<li>'.$this->_link($pages['next'], '&raquo;').'</li>' : ''; //$html .= $pages['last']->active ? '<li>'.$this->_link($pages['last'], '<i class="icon-fast-forward icon-last"></i>').'</li>' : ''; return $html; }
[ "protected", "function", "_pages", "(", "$", "pages", ")", "{", "$", "html", "=", "''", ";", "//$html .= $pages['first']->active ? '<li>'.$this->_link($pages['first'], '<i class=\"icon-fast-backward icon-first\"></i>').'</li>' : '';", "$", "html", ".=", "$", "pages", "[", "'p...
Render a list of page links @param array $pages An array of page data @return string Html
[ "Render", "a", "list", "of", "page", "links" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/helper/paginator.php#L168-L195
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/template/helper/paginator.php
KTemplateHelperPaginator._link
protected function _link($page, $title) { $url = $this->getObject('request')->getUrl(); $query = $url->getQuery(true); //For compatibility with Joomla use limitstart instead of offset $query['limit'] = $page->limit; $query['limitstart'] = $page->offset; unset($query['offset']); $url->setQuery($query); if ($page->active && !$page->current) { $html = '<a href="'.$url.'">'.$this->getObject('translator')->translate($title).'</a>'; } else { $html = '<a>'.$this->getObject('translator')->translate($title).'</a>'; } return $html; }
php
protected function _link($page, $title) { $url = $this->getObject('request')->getUrl(); $query = $url->getQuery(true); //For compatibility with Joomla use limitstart instead of offset $query['limit'] = $page->limit; $query['limitstart'] = $page->offset; unset($query['offset']); $url->setQuery($query); if ($page->active && !$page->current) { $html = '<a href="'.$url.'">'.$this->getObject('translator')->translate($title).'</a>'; } else { $html = '<a>'.$this->getObject('translator')->translate($title).'</a>'; } return $html; }
[ "protected", "function", "_link", "(", "$", "page", ",", "$", "title", ")", "{", "$", "url", "=", "$", "this", "->", "getObject", "(", "'request'", ")", "->", "getUrl", "(", ")", ";", "$", "query", "=", "$", "url", "->", "getQuery", "(", "true", ...
Generates a pagination link @param KObject $page Page object @param string $title Page title @return string
[ "Generates", "a", "pagination", "link" ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/helper/paginator.php#L204-L224
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/filter/timestamp.php
KFilterTimestamp._validateIsoDate
protected function _validateIsoDate($value) { // Test if value is blank. if(trim($value) != '') { // Test basic date format (yyyy-mm-dd) $pattern = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/D'; $return = preg_match($pattern, $value, $matches) && checkdate($matches[2], $matches[3], $matches[1]); } else $return = false; return $return; }
php
protected function _validateIsoDate($value) { // Test if value is blank. if(trim($value) != '') { // Test basic date format (yyyy-mm-dd) $pattern = '/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/D'; $return = preg_match($pattern, $value, $matches) && checkdate($matches[2], $matches[3], $matches[1]); } else $return = false; return $return; }
[ "protected", "function", "_validateIsoDate", "(", "$", "value", ")", "{", "// Test if value is blank.", "if", "(", "trim", "(", "$", "value", ")", "!=", "''", ")", "{", "// Test basic date format (yyyy-mm-dd)", "$", "pattern", "=", "'/^([0-9]{4})-([0-9]{2})-([0-9]{2})...
Validates that the value is an ISO 8601 date string. The format is "yyyy-mm-dd". Also checks to see that the date itself is valid (for example, no Feb 30). @param string $value The value to validate. @return bool True if valid, false if not.
[ "Validates", "that", "the", "value", "is", "an", "ISO", "8601", "date", "string", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filter/timestamp.php#L171-L183
train
joomlatools/joomlatools-framework
code/libraries/joomlatools/library/template/helper/date.php
KTemplateHelperDate.format
public function format($config = array()) { $translator = $this->getObject('translator'); $config = new KObjectConfig($config); $config->append(array( 'date' => 'now', 'timezone' => date_default_timezone_get(), 'format' => $translator->translate('DATE_FORMAT_LC1'), 'default' => '' )); $return = $config->default; if(!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00'))) { try { $date = $this->getObject('lib:date', array('date' => $config->date, 'timezone' => 'UTC')); $date->setTimezone(new DateTimeZone($config->timezone)); $return = $date->format($config->format); } catch(Exception $e) {} } return $return; }
php
public function format($config = array()) { $translator = $this->getObject('translator'); $config = new KObjectConfig($config); $config->append(array( 'date' => 'now', 'timezone' => date_default_timezone_get(), 'format' => $translator->translate('DATE_FORMAT_LC1'), 'default' => '' )); $return = $config->default; if(!in_array($config->date, array('0000-00-00 00:00:00', '0000-00-00'))) { try { $date = $this->getObject('lib:date', array('date' => $config->date, 'timezone' => 'UTC')); $date->setTimezone(new DateTimeZone($config->timezone)); $return = $date->format($config->format); } catch(Exception $e) {} } return $return; }
[ "public", "function", "format", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "translator", "=", "$", "this", "->", "getObject", "(", "'translator'", ")", ";", "$", "config", "=", "new", "KObjectConfig", "(", "$", "config", ")", ";", "$"...
Returns formatted date according to current local and adds time offset. @param array $config An optional array with configuration options. @return string Formatted date.
[ "Returns", "formatted", "date", "according", "to", "current", "local", "and", "adds", "time", "offset", "." ]
5ea3cc6b48b68fd8899a573b191de983e768d56e
https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/helper/date.php#L24-L51
train
avalanche123/AvalancheImagineBundle
Imagine/CachePathResolver.php
CachePathResolver.getBrowserPath
public function getBrowserPath($path, $filter, $absolute = false) { // identify if current path is not under specified source root and return // unmodified path in that case $realPath = realpath($this->sourceRoot.$path); if (!0 === strpos($realPath, $this->sourceRoot)) { return $path; } $path = str_replace( urlencode(ltrim($path, '/')), urldecode(ltrim($path, '/')), $this->router->generate('_imagine_'.$filter, array( 'path' => ltrim($path, '/') ), $absolute) ); $cached = realpath($this->webRoot.$path); if (file_exists($cached) && !is_dir($cached) && filemtime($realPath) > filemtime($cached)) { unlink($cached); } return $path; }
php
public function getBrowserPath($path, $filter, $absolute = false) { // identify if current path is not under specified source root and return // unmodified path in that case $realPath = realpath($this->sourceRoot.$path); if (!0 === strpos($realPath, $this->sourceRoot)) { return $path; } $path = str_replace( urlencode(ltrim($path, '/')), urldecode(ltrim($path, '/')), $this->router->generate('_imagine_'.$filter, array( 'path' => ltrim($path, '/') ), $absolute) ); $cached = realpath($this->webRoot.$path); if (file_exists($cached) && !is_dir($cached) && filemtime($realPath) > filemtime($cached)) { unlink($cached); } return $path; }
[ "public", "function", "getBrowserPath", "(", "$", "path", ",", "$", "filter", ",", "$", "absolute", "=", "false", ")", "{", "// identify if current path is not under specified source root and return", "// unmodified path in that case", "$", "realPath", "=", "realpath", "(...
Gets filtered path for rendering in the browser @param string $path @param string $filter @param boolean $absolute
[ "Gets", "filtered", "path", "for", "rendering", "in", "the", "browser" ]
8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa
https://github.com/avalanche123/AvalancheImagineBundle/blob/8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa/Imagine/CachePathResolver.php#L46-L71
train
avalanche123/AvalancheImagineBundle
Controller/ImagineController.php
ImagineController.filter
public function filter($path, $filter) { try { $cachedPath = $this->cacheManager->cacheImage($this->request->getBaseUrl(), $path, $filter); } catch (RouteNotFoundException $e) { throw new NotFoundHttpException('Filter doesn\'t exist.'); } // if cache path cannot be determined, return 404 if (null === $cachedPath) { throw new NotFoundHttpException('Image doesn\'t exist'); } ob_start(); try { $format = $this->filterManager->getOption($filter, "format", "png"); $this->imagine->open($cachedPath)->show($format); $type = 'image/' . $format; $length = ob_get_length(); $content = ob_get_clean(); // TODO: add more media headers $response = new Response($content, 201, array( 'content-type' => $type, 'content-length' => $length, )); // Cache $cacheType = $this->filterManager->getOption($filter, "cache_type", false); if (false == $cacheType) { return $response; } ($cacheType === "public") ? $response->setPublic() : $response->setPrivate(); $cacheExpires = $this->filterManager->getOption($filter, "cache_expires", "1 day"); $expirationDate = new \DateTime("+" . $cacheExpires); $maxAge = $expirationDate->format("U") - time(); if ($maxAge < 0) { throw new \InvalidArgumentException("Invalid cache expiration date"); } $response->setExpires($expirationDate); $response->setMaxAge($maxAge); return $response; } catch (\Exception $e) { ob_end_clean(); throw $e; } }
php
public function filter($path, $filter) { try { $cachedPath = $this->cacheManager->cacheImage($this->request->getBaseUrl(), $path, $filter); } catch (RouteNotFoundException $e) { throw new NotFoundHttpException('Filter doesn\'t exist.'); } // if cache path cannot be determined, return 404 if (null === $cachedPath) { throw new NotFoundHttpException('Image doesn\'t exist'); } ob_start(); try { $format = $this->filterManager->getOption($filter, "format", "png"); $this->imagine->open($cachedPath)->show($format); $type = 'image/' . $format; $length = ob_get_length(); $content = ob_get_clean(); // TODO: add more media headers $response = new Response($content, 201, array( 'content-type' => $type, 'content-length' => $length, )); // Cache $cacheType = $this->filterManager->getOption($filter, "cache_type", false); if (false == $cacheType) { return $response; } ($cacheType === "public") ? $response->setPublic() : $response->setPrivate(); $cacheExpires = $this->filterManager->getOption($filter, "cache_expires", "1 day"); $expirationDate = new \DateTime("+" . $cacheExpires); $maxAge = $expirationDate->format("U") - time(); if ($maxAge < 0) { throw new \InvalidArgumentException("Invalid cache expiration date"); } $response->setExpires($expirationDate); $response->setMaxAge($maxAge); return $response; } catch (\Exception $e) { ob_end_clean(); throw $e; } }
[ "public", "function", "filter", "(", "$", "path", ",", "$", "filter", ")", "{", "try", "{", "$", "cachedPath", "=", "$", "this", "->", "cacheManager", "->", "cacheImage", "(", "$", "this", "->", "request", "->", "getBaseUrl", "(", ")", ",", "$", "pat...
This action applies a given filter to a given image, saves the image and outputs it to the browser at the same time @param string $path @param string $filter @return Response
[ "This", "action", "applies", "a", "given", "filter", "to", "a", "given", "image", "saves", "the", "image", "and", "outputs", "it", "to", "the", "browser", "at", "the", "same", "time" ]
8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa
https://github.com/avalanche123/AvalancheImagineBundle/blob/8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa/Controller/ImagineController.php#L59-L112
train
avalanche123/AvalancheImagineBundle
Imagine/CacheManager.php
CacheManager.cacheImage
public function cacheImage($basePath, $path, $filter) { $path = '/'.ltrim($path, '/'); //TODO: find out why I need double urldecode to get a valid path $browserPath = urldecode(urldecode($this->cachePathResolver->getBrowserPath($path, $filter))); if (!empty($basePath) && 0 === strpos($browserPath, $basePath)) { $browserPath = substr($browserPath, strlen($basePath)); } // if cache path cannot be determined, return 404 if (null === $browserPath) { return null; } $realPath = $this->webRoot.$browserPath; $sourcePathRoot = $this->filterManager->getOption($filter, "source_root", $this->sourceRoot); $sourcePath = $sourcePathRoot.$path; // if the file has already been cached, just return path if (is_file($realPath)) { return $realPath; } if (!is_file($sourcePath)) { return null; } $dir = pathinfo($realPath, PATHINFO_DIRNAME); if (!is_dir($dir)) { try { if (false === $this->filesystem->mkdir($dir)) { throw new \RuntimeException(sprintf( 'Could not create directory %s', $dir )); } } catch (\Exception $e) { if (!is_dir($dir)) { throw $e; } } } // TODO: get rid of hard-coded quality and format $this->filterManager->getFilter($filter) ->apply($this->imagine->open($sourcePath)) ->save($realPath, array( 'quality' => $this->filterManager->getOption($filter, "quality", 100), 'format' => $this->filterManager->getOption($filter, "format", null) )) ; try { if (!chmod($realPath, $this->permissions)) { throw new \RuntimeException(sprintf( 'Could not set permissions %s on image saved in %s', $this->permissions, $realPath )); } } catch (Exception $e) { throw $e; } return $realPath; }
php
public function cacheImage($basePath, $path, $filter) { $path = '/'.ltrim($path, '/'); //TODO: find out why I need double urldecode to get a valid path $browserPath = urldecode(urldecode($this->cachePathResolver->getBrowserPath($path, $filter))); if (!empty($basePath) && 0 === strpos($browserPath, $basePath)) { $browserPath = substr($browserPath, strlen($basePath)); } // if cache path cannot be determined, return 404 if (null === $browserPath) { return null; } $realPath = $this->webRoot.$browserPath; $sourcePathRoot = $this->filterManager->getOption($filter, "source_root", $this->sourceRoot); $sourcePath = $sourcePathRoot.$path; // if the file has already been cached, just return path if (is_file($realPath)) { return $realPath; } if (!is_file($sourcePath)) { return null; } $dir = pathinfo($realPath, PATHINFO_DIRNAME); if (!is_dir($dir)) { try { if (false === $this->filesystem->mkdir($dir)) { throw new \RuntimeException(sprintf( 'Could not create directory %s', $dir )); } } catch (\Exception $e) { if (!is_dir($dir)) { throw $e; } } } // TODO: get rid of hard-coded quality and format $this->filterManager->getFilter($filter) ->apply($this->imagine->open($sourcePath)) ->save($realPath, array( 'quality' => $this->filterManager->getOption($filter, "quality", 100), 'format' => $this->filterManager->getOption($filter, "format", null) )) ; try { if (!chmod($realPath, $this->permissions)) { throw new \RuntimeException(sprintf( 'Could not set permissions %s on image saved in %s', $this->permissions, $realPath )); } } catch (Exception $e) { throw $e; } return $realPath; }
[ "public", "function", "cacheImage", "(", "$", "basePath", ",", "$", "path", ",", "$", "filter", ")", "{", "$", "path", "=", "'/'", ".", "ltrim", "(", "$", "path", ",", "'/'", ")", ";", "//TODO: find out why I need double urldecode to get a valid path", "$", ...
Forces image caching and returns path to cached image. @param string $basePath @param string $path @param string $filter @return string|null
[ "Forces", "image", "caching", "and", "returns", "path", "to", "cached", "image", "." ]
8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa
https://github.com/avalanche123/AvalancheImagineBundle/blob/8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa/Imagine/CacheManager.php#L51-L119
train
avalanche123/AvalancheImagineBundle
Templating/ImagineExtension.php
ImagineExtension.applyFilter
public function applyFilter($path, $filter, $absolute = false) { return $this->cachePathResolver->getBrowserPath($path, $filter, $absolute); }
php
public function applyFilter($path, $filter, $absolute = false) { return $this->cachePathResolver->getBrowserPath($path, $filter, $absolute); }
[ "public", "function", "applyFilter", "(", "$", "path", ",", "$", "filter", ",", "$", "absolute", "=", "false", ")", "{", "return", "$", "this", "->", "cachePathResolver", "->", "getBrowserPath", "(", "$", "path", ",", "$", "filter", ",", "$", "absolute",...
Gets cache path of an image to be filtered @param string $path @param string $filter @param boolean $absolute @return string
[ "Gets", "cache", "path", "of", "an", "image", "to", "be", "filtered" ]
8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa
https://github.com/avalanche123/AvalancheImagineBundle/blob/8ee4e5fd29bc02d1cffea800eabca31b0c6be0fa/Templating/ImagineExtension.php#L45-L48
train
jaimz22/Overcast
src/ClientAdapters/ClientAdapter.php
ClientAdapter.buildRequestURL
protected function buildRequestURL($latitude, $longitude, \DateTime $time = NULL, array $parameters = NULL) { $requestUrl = Overcast::API_ENDPOINT . Overcast::getApiKey() . '/' . $latitude . ',' . $longitude; if (NULL !== $time) { $requestUrl .= ',' . $time->getTimestamp(); } $requestUrl .= '?' . $this->buildRequestParameters($parameters); return $requestUrl; }
php
protected function buildRequestURL($latitude, $longitude, \DateTime $time = NULL, array $parameters = NULL) { $requestUrl = Overcast::API_ENDPOINT . Overcast::getApiKey() . '/' . $latitude . ',' . $longitude; if (NULL !== $time) { $requestUrl .= ',' . $time->getTimestamp(); } $requestUrl .= '?' . $this->buildRequestParameters($parameters); return $requestUrl; }
[ "protected", "function", "buildRequestURL", "(", "$", "latitude", ",", "$", "longitude", ",", "\\", "DateTime", "$", "time", "=", "NULL", ",", "array", "$", "parameters", "=", "NULL", ")", "{", "$", "requestUrl", "=", "Overcast", "::", "API_ENDPOINT", ".",...
Builds the URL to request from the Dark Sky API @param float $latitude @param float $longitude @param \DateTime|NULL $time @param array|NULL $parameters @return string
[ "Builds", "the", "URL", "to", "request", "from", "the", "Dark", "Sky", "API" ]
f595f8876bf2b23965e2fb9104e019216bfda858
https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/ClientAdapters/ClientAdapter.php#L27-L38
train
jaimz22/Overcast
src/ClientAdapters/GuzzleClientAdapter.php
GuzzleClientAdapter.getForecast
public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null) { $this->requestedUrl = $this->buildRequestURL($latitude, $longitude, $time, $parameters); $response = $this->guzzleClient->get($this->requestedUrl); $cacheDirectives = $this->buildCacheDirectives($response); $this->responseHeaders = [ 'cache' => $cacheDirectives, 'responseTime' => (int)$response->getHeader('x-response-time'), 'apiCalls' => (int)$response->getHeader('x-forecast-api-calls') ]; return json_decode($response->getBody(), true); }
php
public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null) { $this->requestedUrl = $this->buildRequestURL($latitude, $longitude, $time, $parameters); $response = $this->guzzleClient->get($this->requestedUrl); $cacheDirectives = $this->buildCacheDirectives($response); $this->responseHeaders = [ 'cache' => $cacheDirectives, 'responseTime' => (int)$response->getHeader('x-response-time'), 'apiCalls' => (int)$response->getHeader('x-forecast-api-calls') ]; return json_decode($response->getBody(), true); }
[ "public", "function", "getForecast", "(", "$", "latitude", ",", "$", "longitude", ",", "\\", "DateTime", "$", "time", "=", "null", ",", "array", "$", "parameters", "=", "null", ")", "{", "$", "this", "->", "requestedUrl", "=", "$", "this", "->", "build...
Returns the response data from the Dark Sky API in the form of an array. @param float $latitude @param float $longitude @param \DateTime $time @param array $parameters @return array
[ "Returns", "the", "response", "data", "from", "the", "Dark", "Sky", "API", "in", "the", "form", "of", "an", "array", "." ]
f595f8876bf2b23965e2fb9104e019216bfda858
https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/ClientAdapters/GuzzleClientAdapter.php#L53-L67
train
jaimz22/Overcast
src/ClientAdapters/GuzzleClientAdapter.php
GuzzleClientAdapter.buildCacheDirectives
protected function buildCacheDirectives($response) { $cacheControlHeader = null; if ($response->hasHeader('cache-control')) { $cacheControlHeader = $this->parseHeader($response->getHeader('cache-control')); $cacheControlHeader = current($cacheControlHeader); $cacheControlHeader = (isset($cacheControlHeader['max-age'])?$cacheControlHeader['max-age']:null); } $expiresHeader = null; if ($response->hasHeader('expires')){ $expiresHeader = implode(' ',array_column($this->parseHeader($response->getHeader('expires')),0)); } return array_filter([ 'maxAge'=>$cacheControlHeader, 'expires'=>$expiresHeader, ]); }
php
protected function buildCacheDirectives($response) { $cacheControlHeader = null; if ($response->hasHeader('cache-control')) { $cacheControlHeader = $this->parseHeader($response->getHeader('cache-control')); $cacheControlHeader = current($cacheControlHeader); $cacheControlHeader = (isset($cacheControlHeader['max-age'])?$cacheControlHeader['max-age']:null); } $expiresHeader = null; if ($response->hasHeader('expires')){ $expiresHeader = implode(' ',array_column($this->parseHeader($response->getHeader('expires')),0)); } return array_filter([ 'maxAge'=>$cacheControlHeader, 'expires'=>$expiresHeader, ]); }
[ "protected", "function", "buildCacheDirectives", "(", "$", "response", ")", "{", "$", "cacheControlHeader", "=", "null", ";", "if", "(", "$", "response", "->", "hasHeader", "(", "'cache-control'", ")", ")", "{", "$", "cacheControlHeader", "=", "$", "this", "...
Builds the cache directives from response headers. @param $response @return string[]
[ "Builds", "the", "cache", "directives", "from", "response", "headers", "." ]
f595f8876bf2b23965e2fb9104e019216bfda858
https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/ClientAdapters/GuzzleClientAdapter.php#L86-L104
train
jaimz22/Overcast
src/ClientAdapters/FileGetContentsClientAdapter.php
FileGetContentsClientAdapter.getForecast
public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null) { $this->requestedUrl = $this->buildRequestURL($latitude, $longitude, $time, $parameters); $this->response = json_decode(file_get_contents($this->requestedUrl), true); $this->responseHeaders = $this->parseForecastResponseHeaders($http_response_header); return $this->response; }
php
public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null) { $this->requestedUrl = $this->buildRequestURL($latitude, $longitude, $time, $parameters); $this->response = json_decode(file_get_contents($this->requestedUrl), true); $this->responseHeaders = $this->parseForecastResponseHeaders($http_response_header); return $this->response; }
[ "public", "function", "getForecast", "(", "$", "latitude", ",", "$", "longitude", ",", "\\", "DateTime", "$", "time", "=", "null", ",", "array", "$", "parameters", "=", "null", ")", "{", "$", "this", "->", "requestedUrl", "=", "$", "this", "->", "build...
Returns the response data from the Dark Sky API in the form of an array @param float $latitude @param float $longitude @param \DateTime $time @param array $parameters @return array
[ "Returns", "the", "response", "data", "from", "the", "Dark", "Sky", "API", "in", "the", "form", "of", "an", "array" ]
f595f8876bf2b23965e2fb9104e019216bfda858
https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/ClientAdapters/FileGetContentsClientAdapter.php#L39-L47
train
jaimz22/Overcast
src/ClientAdapters/FileGetContentsClientAdapter.php
FileGetContentsClientAdapter.parseForecastResponseHeaders
private function parseForecastResponseHeaders($headers) { $responseHeaders = [ 'cache' => [ 'maxAge' => null, 'expires' => null ], 'responseTime' => null, 'apiCalls' => null ]; foreach ($headers as $header) { switch (true) { case (substr($header, 0, 14) === 'Cache-Control:'): $responseHeaders['cache']['maxAge'] = trim(substr($header, strrpos($header, '=') + 1)); break; case (substr($header, 0, 8) === 'Expires:'): $responseHeaders['cache']['expires'] = trim(substr($header, 8)); break; case (substr($header, 0, 21) === 'X-Forecast-API-Calls:'): $responseHeaders['apiCalls'] = trim(substr($header, 21)); break; case (substr($header, 0, 16) === 'X-Response-Time:'): $responseHeaders['responseTime'] = (int)trim(substr($header, 16)); break; default: break; } } return $responseHeaders; }
php
private function parseForecastResponseHeaders($headers) { $responseHeaders = [ 'cache' => [ 'maxAge' => null, 'expires' => null ], 'responseTime' => null, 'apiCalls' => null ]; foreach ($headers as $header) { switch (true) { case (substr($header, 0, 14) === 'Cache-Control:'): $responseHeaders['cache']['maxAge'] = trim(substr($header, strrpos($header, '=') + 1)); break; case (substr($header, 0, 8) === 'Expires:'): $responseHeaders['cache']['expires'] = trim(substr($header, 8)); break; case (substr($header, 0, 21) === 'X-Forecast-API-Calls:'): $responseHeaders['apiCalls'] = trim(substr($header, 21)); break; case (substr($header, 0, 16) === 'X-Response-Time:'): $responseHeaders['responseTime'] = (int)trim(substr($header, 16)); break; default: break; } } return $responseHeaders; }
[ "private", "function", "parseForecastResponseHeaders", "(", "$", "headers", ")", "{", "$", "responseHeaders", "=", "[", "'cache'", "=>", "[", "'maxAge'", "=>", "null", ",", "'expires'", "=>", "null", "]", ",", "'responseTime'", "=>", "null", ",", "'apiCalls'",...
Parses the response headers @param array $headers @return array
[ "Parses", "the", "response", "headers" ]
f595f8876bf2b23965e2fb9104e019216bfda858
https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/ClientAdapters/FileGetContentsClientAdapter.php#L66-L95
train
jaimz22/Overcast
src/Overcast.php
Overcast.getForecast
public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null) { try { $response = $this->adapter->getForecast($latitude, $longitude, $time, $parameters); $responseHeaders = $this->adapter->getHeaders(); if (NULL !== $responseHeaders['apiCalls']) { $this->apiCalls = $responseHeaders['apiCalls']; } $cacheAge = 0; if (NULL !== $responseHeaders['cache']['maxAge']) { $cacheAge = $responseHeaders['cache']['maxAge']; } elseif (NULL !== $responseHeaders['cache']['expires']) { $cacheAge = (new \DateTime())->getTimestamp() - (new \DateTime($responseHeaders['cache']['expires']))->getTimestamp(); } return new Forecast($response, $cacheAge, $responseHeaders['responseTime']); } catch (\Exception $e) { return null; } }
php
public function getForecast($latitude, $longitude, \DateTime $time = null, array $parameters = null) { try { $response = $this->adapter->getForecast($latitude, $longitude, $time, $parameters); $responseHeaders = $this->adapter->getHeaders(); if (NULL !== $responseHeaders['apiCalls']) { $this->apiCalls = $responseHeaders['apiCalls']; } $cacheAge = 0; if (NULL !== $responseHeaders['cache']['maxAge']) { $cacheAge = $responseHeaders['cache']['maxAge']; } elseif (NULL !== $responseHeaders['cache']['expires']) { $cacheAge = (new \DateTime())->getTimestamp() - (new \DateTime($responseHeaders['cache']['expires']))->getTimestamp(); } return new Forecast($response, $cacheAge, $responseHeaders['responseTime']); } catch (\Exception $e) { return null; } }
[ "public", "function", "getForecast", "(", "$", "latitude", ",", "$", "longitude", ",", "\\", "DateTime", "$", "time", "=", "null", ",", "array", "$", "parameters", "=", "null", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "adapter", ...
Retrieve the forecast for the specified latitude and longitude and optionally the specified date and time. @param $latitude @param $longitude @param \DateTime $time @param array $parameters @return Forecast
[ "Retrieve", "the", "forecast", "for", "the", "specified", "latitude", "and", "longitude", "and", "optionally", "the", "specified", "date", "and", "time", "." ]
f595f8876bf2b23965e2fb9104e019216bfda858
https://github.com/jaimz22/Overcast/blob/f595f8876bf2b23965e2fb9104e019216bfda858/src/Overcast.php#L82-L103
train
nezamy/view
system/Views/View.php
View.view
public function view($file, array $vars = []) { if ( is_file($file = $this->getPath($file . '.php')) ) { $this->data = $vars; extract($vars, EXTR_OVERWRITE|EXTR_REFS); include($this->cache($file)); $this->end(); } else { throw new \Exception("Views: File not found $file"); } return $this; }
php
public function view($file, array $vars = []) { if ( is_file($file = $this->getPath($file . '.php')) ) { $this->data = $vars; extract($vars, EXTR_OVERWRITE|EXTR_REFS); include($this->cache($file)); $this->end(); } else { throw new \Exception("Views: File not found $file"); } return $this; }
[ "public", "function", "view", "(", "$", "file", ",", "array", "$", "vars", "=", "[", "]", ")", "{", "if", "(", "is_file", "(", "$", "file", "=", "$", "this", "->", "getPath", "(", "$", "file", ".", "'.php'", ")", ")", ")", "{", "$", "this", "...
section in layout is calling section in view if is definded @param string $file view file path name without .php @param array $vars array of the vars "key => value" @return this
[ "section", "in", "layout", "is", "calling", "section", "in", "view", "if", "is", "definded" ]
e19d3ad2c276a1e2588204a52fd0c3783c340440
https://github.com/nezamy/view/blob/e19d3ad2c276a1e2588204a52fd0c3783c340440/system/Views/View.php#L75-L87
train
nezamy/view
system/Views/View.php
View.end
public function end() { if ($this->config['layout'] !== false && is_file($file = $this->getLayoutPath()) ) { extract($this->data, EXTR_OVERWRITE|EXTR_REFS); require($this->cache($file, true)); } }
php
public function end() { if ($this->config['layout'] !== false && is_file($file = $this->getLayoutPath()) ) { extract($this->data, EXTR_OVERWRITE|EXTR_REFS); require($this->cache($file, true)); } }
[ "public", "function", "end", "(", ")", "{", "if", "(", "$", "this", "->", "config", "[", "'layout'", "]", "!==", "false", "&&", "is_file", "(", "$", "file", "=", "$", "this", "->", "getLayoutPath", "(", ")", ")", ")", "{", "extract", "(", "$", "t...
end and include layout
[ "end", "and", "include", "layout" ]
e19d3ad2c276a1e2588204a52fd0c3783c340440
https://github.com/nezamy/view/blob/e19d3ad2c276a1e2588204a52fd0c3783c340440/system/Views/View.php#L122-L128
train
nezamy/view
system/Views/View.php
View.ViewBag
public function ViewBag($k=null, $v=null) { if($v !== null){ $this->viewBag->$k = $v; }elseif($k !== null){ return $this->viewBag->$k; }else{ return $this->viewBag; } return $this; }
php
public function ViewBag($k=null, $v=null) { if($v !== null){ $this->viewBag->$k = $v; }elseif($k !== null){ return $this->viewBag->$k; }else{ return $this->viewBag; } return $this; }
[ "public", "function", "ViewBag", "(", "$", "k", "=", "null", ",", "$", "v", "=", "null", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "this", "->", "viewBag", "->", "$", "k", "=", "$", "v", ";", "}", "elseif", "(", "$", "k",...
share data to all views files @param string $k @param mixed $v @return mixed
[ "share", "data", "to", "all", "views", "files" ]
e19d3ad2c276a1e2588204a52fd0c3783c340440
https://github.com/nezamy/view/blob/e19d3ad2c276a1e2588204a52fd0c3783c340440/system/Views/View.php#L138-L148
train
nezamy/view
system/Views/View.php
View.cache
private function cache($file, $layout=false) { if(!$this->config['compiler']){ return $file; } return (new Cache([ 'path' => $this->config['cache'] ]))->compiled($file, $file, $this->setCacheCompiler($file, $layout)); }
php
private function cache($file, $layout=false) { if(!$this->config['compiler']){ return $file; } return (new Cache([ 'path' => $this->config['cache'] ]))->compiled($file, $file, $this->setCacheCompiler($file, $layout)); }
[ "private", "function", "cache", "(", "$", "file", ",", "$", "layout", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "config", "[", "'compiler'", "]", ")", "{", "return", "$", "file", ";", "}", "return", "(", "new", "Cache", "(", "[",...
Cache compiled file @param string $file @param bool $layout @return string
[ "Cache", "compiled", "file" ]
e19d3ad2c276a1e2588204a52fd0c3783c340440
https://github.com/nezamy/view/blob/e19d3ad2c276a1e2588204a52fd0c3783c340440/system/Views/View.php#L157-L166
train