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/http/token/token.php | KHttpToken.getAge | public function getAge()
{
$result = false;
if (isset($this->_claims['iat']) && is_numeric($this->_claims['iat'])) {
$result = max(time() - $this->_claims['iat'], 0);
}
return $result;
} | php | public function getAge()
{
$result = false;
if (isset($this->_claims['iat']) && is_numeric($this->_claims['iat'])) {
$result = max(time() - $this->_claims['iat'], 0);
}
return $result;
} | [
"public",
"function",
"getAge",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_claims",
"[",
"'iat'",
"]",
")",
"&&",
"is_numeric",
"(",
"$",
"this",
"->",
"_claims",
"[",
"'iat'",
"]",
")",
")",
"{... | Returns the age of the token
@return integer|false The age of the token in seconds or FALSE if the age couldn't be calculated | [
"Returns",
"the",
"age",
"of",
"the",
"token"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/token/token.php#L382-L390 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/token/token.php | KHttpToken.fromString | public function fromString($token)
{
$segments = explode('.', $token);
if (count($segments) == 3)
{
list($header, $payload, $signature) = $segments;
$this->_header = $this->_fromJson($this->_fromBase64url($header));
$this->_claims = $this->_fromJson($this->_fromBase64url($payload));
$this->_signature = $this->_fromBase64url($signature);
if(isset($this->_header['alg'])) {
$this->setAlgorithm($this->_header['alg']);
} else {
$this->setAlgorithm('none');
}
}
else throw new InvalidArgumentException(sprintf('The token "%s" is an invalid JWT', $token));
return $this;
} | php | public function fromString($token)
{
$segments = explode('.', $token);
if (count($segments) == 3)
{
list($header, $payload, $signature) = $segments;
$this->_header = $this->_fromJson($this->_fromBase64url($header));
$this->_claims = $this->_fromJson($this->_fromBase64url($payload));
$this->_signature = $this->_fromBase64url($signature);
if(isset($this->_header['alg'])) {
$this->setAlgorithm($this->_header['alg']);
} else {
$this->setAlgorithm('none');
}
}
else throw new InvalidArgumentException(sprintf('The token "%s" is an invalid JWT', $token));
return $this;
} | [
"public",
"function",
"fromString",
"(",
"$",
"token",
")",
"{",
"$",
"segments",
"=",
"explode",
"(",
"'.'",
",",
"$",
"token",
")",
";",
"if",
"(",
"count",
"(",
"$",
"segments",
")",
"==",
"3",
")",
"{",
"list",
"(",
"$",
"header",
",",
"$",
... | Decode from JWT string
@param string $token A serialised token
@return KHttpToken
@throws InvalidArgumentException If the token is invalid | [
"Decode",
"from",
"JWT",
"string"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/token/token.php#L429-L450 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/token/token.php | KHttpToken.sign | public function sign($secret)
{
$token = $this->toString();
$signature = $this->getSignature($secret);
return sprintf("%s.%s", $token, $this->_toBase64url($signature));
} | php | public function sign($secret)
{
$token = $this->toString();
$signature = $this->getSignature($secret);
return sprintf("%s.%s", $token, $this->_toBase64url($signature));
} | [
"public",
"function",
"sign",
"(",
"$",
"secret",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"toString",
"(",
")",
";",
"$",
"signature",
"=",
"$",
"this",
"->",
"getSignature",
"(",
"$",
"secret",
")",
";",
"return",
"sprintf",
"(",
"\"%s.%s\""... | Sign the token
This method returns the Base64url representation of the JWT token including the Crypto segment.
@param mixed $secret The MAC key or password to be used to compute the HMAC signature bytes.
@return String the Base64url representation of the signed JWT token | [
"Sign",
"the",
"token"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/token/token.php#L484-L490 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/token/token.php | KHttpToken.isExpired | public function isExpired()
{
if (isset($this->_claims['exp']) && is_numeric($this->_claims['exp']))
{
$now = new DateTime('now');
return ($now->format('U') - $this->_claims['exp']) > 0;
}
return false;
} | php | public function isExpired()
{
if (isset($this->_claims['exp']) && is_numeric($this->_claims['exp']))
{
$now = new DateTime('now');
return ($now->format('U') - $this->_claims['exp']) > 0;
}
return false;
} | [
"public",
"function",
"isExpired",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_claims",
"[",
"'exp'",
"]",
")",
"&&",
"is_numeric",
"(",
"$",
"this",
"->",
"_claims",
"[",
"'exp'",
"]",
")",
")",
"{",
"$",
"now",
"=",
"new",
"Dat... | Checks whether the token is expired.
@return bool | [
"Checks",
"whether",
"the",
"token",
"is",
"expired",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/token/token.php#L497-L506 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/helper/select.php | KTemplateHelperSelect.booleanlist | public function booleanlist($config = array())
{
$translator = $this->getObject('translator');
$config = new KObjectConfigJson($config);
$config->append(array(
'name' => '',
'attribs' => array(),
'true' => $translator->translate('Yes'),
'false' => $translator->translate('No'),
'selected' => null,
'translate' => true
));
$name = $config->name;
$attribs = $this->buildAttributes($config->attribs);
$html = array();
$html[] = '<div class="k-optionlist k-optionlist--boolean">';
$html[] = '<div class="k-optionlist__content">';
$extra = $config->selected ? 'checked="checked"' : '';
$text = $config->translate ? $translator->translate( $config->true ) : $config->true;
$html[] = '<input type="radio" name="'.$name.'" id="'.$name.'1" value="1" '.$extra.' '.$attribs.' />';
$html[] = '<label for="'.$name.'1"><span>'.$text.'</span></label>';
$extra = !$config->selected ? 'checked="checked"' : '';
$text = $config->translate ? $translator->translate( $config->false ) : $config->false;
$html[] = '<input type="radio" name="'.$name.'" id="'.$name.'0" value="0" '.$extra.' '.$attribs.' />';
$html[] = '<label for="'.$name.'0"><span>'.$text.'</span></label>';
$html[] = '<div class="k-optionlist__focus"></div>';
$html[] = '</div>';
$html[] = '</div>';
return implode(PHP_EOL, $html);
} | php | public function booleanlist($config = array())
{
$translator = $this->getObject('translator');
$config = new KObjectConfigJson($config);
$config->append(array(
'name' => '',
'attribs' => array(),
'true' => $translator->translate('Yes'),
'false' => $translator->translate('No'),
'selected' => null,
'translate' => true
));
$name = $config->name;
$attribs = $this->buildAttributes($config->attribs);
$html = array();
$html[] = '<div class="k-optionlist k-optionlist--boolean">';
$html[] = '<div class="k-optionlist__content">';
$extra = $config->selected ? 'checked="checked"' : '';
$text = $config->translate ? $translator->translate( $config->true ) : $config->true;
$html[] = '<input type="radio" name="'.$name.'" id="'.$name.'1" value="1" '.$extra.' '.$attribs.' />';
$html[] = '<label for="'.$name.'1"><span>'.$text.'</span></label>';
$extra = !$config->selected ? 'checked="checked"' : '';
$text = $config->translate ? $translator->translate( $config->false ) : $config->false;
$html[] = '<input type="radio" name="'.$name.'" id="'.$name.'0" value="0" '.$extra.' '.$attribs.' />';
$html[] = '<label for="'.$name.'0"><span>'.$text.'</span></label>';
$html[] = '<div class="k-optionlist__focus"></div>';
$html[] = '</div>';
$html[] = '</div>';
return implode(PHP_EOL, $html);
} | [
"public",
"function",
"booleanlist",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'translator'",
")",
";",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
"... | Generates an HTML boolean radio list
@param array|KObjectConfig $config An optional array with configuration options
@return string Html | [
"Generates",
"an",
"HTML",
"boolean",
"radio",
"list"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/helper/select.php#L259-L298 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/helper/actionbar.php | KTemplateHelperActionbar.dialog | public function dialog($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'command' => NULL
));
$html = $this->command($config);
return $html;
} | php | public function dialog($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'command' => NULL
));
$html = $this->command($config);
return $html;
} | [
"public",
"function",
"dialog",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'command'",
"=>",
"NULL",
")",
")",... | Render a modal button
@param array $config An optional array with configuration options
@return string Html | [
"Render",
"a",
"modal",
"button"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/helper/actionbar.php#L139-L149 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/views/users/json.php | ComKoowaViewUsersJson._getEntityRoute | protected function _getEntityRoute(KModelEntityInterface $entity)
{
$package = $this->getIdentifier()->package;
$view = 'users';
return $this->getRoute(sprintf('option=com_%s&view=%s&id=%s&format=json', $package, $view, $entity->id));
} | php | protected function _getEntityRoute(KModelEntityInterface $entity)
{
$package = $this->getIdentifier()->package;
$view = 'users';
return $this->getRoute(sprintf('option=com_%s&view=%s&id=%s&format=json', $package, $view, $entity->id));
} | [
"protected",
"function",
"_getEntityRoute",
"(",
"KModelEntityInterface",
"$",
"entity",
")",
"{",
"$",
"package",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"package",
";",
"$",
"view",
"=",
"'users'",
";",
"return",
"$",
"this",
"->",
"getR... | Overridden to use id instead of slug for links
{@inheritdoc} | [
"Overridden",
"to",
"use",
"id",
"instead",
"of",
"slug",
"for",
"links"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/views/users/json.php#L23-L29 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filter/factory.php | KFilterFactory.createChain | public function createChain($identifier, $config = array())
{
//Get the filter(s) we need to create
$filters = (array) $identifier;
$chain = $this->getObject('lib:filter.chain');
foreach($filters as $name)
{
$instance = $this->createFilter($name, $config);
$chain->addFilter($instance);
}
return $chain;
} | php | public function createChain($identifier, $config = array())
{
//Get the filter(s) we need to create
$filters = (array) $identifier;
$chain = $this->getObject('lib:filter.chain');
foreach($filters as $name)
{
$instance = $this->createFilter($name, $config);
$chain->addFilter($instance);
}
return $chain;
} | [
"public",
"function",
"createChain",
"(",
"$",
"identifier",
",",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"//Get the filter(s) we need to create",
"$",
"filters",
"=",
"(",
"array",
")",
"$",
"identifier",
";",
"$",
"chain",
"=",
"$",
"this",
"->"... | Factory method for KFilterChain classes.
Method accepts an array of filter names, or filter object identifiers and will create a chained filter
using a FIFO approach.
@param string|array $identifier Filter identifier(s)
@param object|array $config An optional KObjectConfig object with configuration options
@return KFilterInterface | [
"Factory",
"method",
"for",
"KFilterChain",
"classes",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filter/factory.php#L28-L41 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/response/headers.php | KHttpResponseHeaders.clearCookie | public function clearCookie($name, $path = '/', $domain = null)
{
$cookie = $this->getObject('lib:http.cookie', array(
'name' => $name,
'path' => $path,
'domain' => $domain,
));
$this->addCookie($cookie);
} | php | public function clearCookie($name, $path = '/', $domain = null)
{
$cookie = $this->getObject('lib:http.cookie', array(
'name' => $name,
'path' => $path,
'domain' => $domain,
));
$this->addCookie($cookie);
} | [
"public",
"function",
"clearCookie",
"(",
"$",
"name",
",",
"$",
"path",
"=",
"'/'",
",",
"$",
"domain",
"=",
"null",
")",
"{",
"$",
"cookie",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'lib:http.cookie'",
",",
"array",
"(",
"'name'",
"=>",
"$",
"nam... | Clears a cookie in the browser
@param string $name
@param string $path
@param string $domain | [
"Clears",
"a",
"cookie",
"in",
"the",
"browser"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/response/headers.php#L75-L84 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/response/headers.php | KHttpResponseHeaders.getCookies | public function getCookies()
{
$result = array();
foreach ($this->_cookies as $path)
{
foreach ($path as $cookies)
{
foreach ($cookies as $cookie) {
$result[] = $cookie;
}
}
}
return $result;
} | php | public function getCookies()
{
$result = array();
foreach ($this->_cookies as $path)
{
foreach ($path as $cookies)
{
foreach ($cookies as $cookie) {
$result[] = $cookie;
}
}
}
return $result;
} | [
"public",
"function",
"getCookies",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_cookies",
"as",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"path",
"as",
"$",
"cookies",
")",
"{",
"foreach",
"(",
... | Returns an array with all cookies
@return array | [
"Returns",
"an",
"array",
"with",
"all",
"cookies"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/response/headers.php#L91-L105 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/class/loader.php | KClassLoader.getLocator | public function getLocator($type)
{
$result = null;
if(isset($this->_locators[$type])) {
$result = $this->_locators[$type];
}
return $result;
} | php | public function getLocator($type)
{
$result = null;
if(isset($this->_locators[$type])) {
$result = $this->_locators[$type];
}
return $result;
} | [
"public",
"function",
"getLocator",
"(",
"$",
"type",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_locators",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_locators",
"[... | Get a registered class locator based on his type
@param string $type The locator type
@return KClassLocatorInterface|null Returns the object locator or NULL if it cannot be found. | [
"Get",
"a",
"registered",
"class",
"locator",
"based",
"on",
"his",
"type"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/class/loader.php#L247-L256 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/class/loader.php | KClassLoader.registerAlias | public function registerAlias($class, $alias)
{
$alias = trim($alias);
$class = trim($class);
$this->__registry->alias($class, $alias);
} | php | public function registerAlias($class, $alias)
{
$alias = trim($alias);
$class = trim($class);
$this->__registry->alias($class, $alias);
} | [
"public",
"function",
"registerAlias",
"(",
"$",
"class",
",",
"$",
"alias",
")",
"{",
"$",
"alias",
"=",
"trim",
"(",
"$",
"alias",
")",
";",
"$",
"class",
"=",
"trim",
"(",
"$",
"class",
")",
";",
"$",
"this",
"->",
"__registry",
"->",
"alias",
... | Register an alias for a class
@param string $class The original
@param string $alias The alias name for the class. | [
"Register",
"an",
"alias",
"for",
"a",
"class"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/class/loader.php#L274-L280 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/url/url.php | KHttpUrl.fromTemplate | public static function fromTemplate($template, array $variables)
{
if (strpos($template, '{') !== false) {
$url = uri_template($template, $variables);
} else {
$url = $template;
}
return self::fromString($url);
} | php | public static function fromTemplate($template, array $variables)
{
if (strpos($template, '{') !== false) {
$url = uri_template($template, $variables);
} else {
$url = $template;
}
return self::fromString($url);
} | [
"public",
"static",
"function",
"fromTemplate",
"(",
"$",
"template",
",",
"array",
"$",
"variables",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"template",
",",
"'{'",
")",
"!==",
"false",
")",
"{",
"$",
"url",
"=",
"uri_template",
"(",
"$",
"template",... | Build the url from a template
@link http://tools.ietf.org/html/rfc6570
@param string $template URI template
@param array $variables Template variables | [
"Build",
"the",
"url",
"from",
"a",
"template"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/url/url.php#L508-L517 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/url/url.php | KHttpUrl.equals | public function equals(KHttpUrlInterface $url)
{
$parts = array('scheme', 'host', 'port', 'path', 'query', 'fragment');
foreach($parts as $part)
{
if($this->{$part} != $url->{$part}) {
return false;
}
}
return true;
} | php | public function equals(KHttpUrlInterface $url)
{
$parts = array('scheme', 'host', 'port', 'path', 'query', 'fragment');
foreach($parts as $part)
{
if($this->{$part} != $url->{$part}) {
return false;
}
}
return true;
} | [
"public",
"function",
"equals",
"(",
"KHttpUrlInterface",
"$",
"url",
")",
"{",
"$",
"parts",
"=",
"array",
"(",
"'scheme'",
",",
"'host'",
",",
"'port'",
",",
"'path'",
",",
"'query'",
",",
"'fragment'",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"... | Check if two url's are equal
@param KHttpUrlInterface $url
@return Boolean | [
"Check",
"if",
"two",
"url",
"s",
"are",
"equal"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/url/url.php#L622-L634 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/behavior/cacheable.php | KDispatcherBehaviorCacheable.isCacheable | public function isCacheable()
{
$request = $this->getRequest();
$cacheable = false;
if($request->isCacheable() && $this->getConfig()->cache)
{
$cacheable = true;
if(!$this->getConfig()->cache_private && $this->getUser()->isAuthentic()) {
$cacheable = false;
}
}
return $cacheable;
} | php | public function isCacheable()
{
$request = $this->getRequest();
$cacheable = false;
if($request->isCacheable() && $this->getConfig()->cache)
{
$cacheable = true;
if(!$this->getConfig()->cache_private && $this->getUser()->isAuthentic()) {
$cacheable = false;
}
}
return $cacheable;
} | [
"public",
"function",
"isCacheable",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"cacheable",
"=",
"false",
";",
"if",
"(",
"$",
"request",
"->",
"isCacheable",
"(",
")",
"&&",
"$",
"this",
"->",
"getConfi... | Check if the response can be cached
@return boolean True on success, false otherwise | [
"Check",
"if",
"the",
"response",
"can",
"be",
"cached"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/behavior/cacheable.php#L77-L92 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/behavior/cacheable.php | KDispatcherBehaviorCacheable._getEtag | protected function _getEtag()
{
$response = $this->getResponse();
if($response->isDownloadable())
{
$info = $response->getStream()->getInfo();
$etag = sprintf('"%x-%x-%s"', $info['ino'], $info['size'],base_convert(str_pad($info['mtime'],16,"0"),10,16));
}
else $etag = crc32($this->getUser()->getId().'/###'.$this->getResponse()->getContent());
return $etag;
} | php | protected function _getEtag()
{
$response = $this->getResponse();
if($response->isDownloadable())
{
$info = $response->getStream()->getInfo();
$etag = sprintf('"%x-%x-%s"', $info['ino'], $info['size'],base_convert(str_pad($info['mtime'],16,"0"),10,16));
}
else $etag = crc32($this->getUser()->getId().'/###'.$this->getResponse()->getContent());
return $etag;
} | [
"protected",
"function",
"_getEtag",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"$",
"response",
"->",
"isDownloadable",
"(",
")",
")",
"{",
"$",
"info",
"=",
"$",
"response",
"->",
"getStream",
"... | Generate a response etag
For files returns a md5 hash of same format as Apache does. Eg "%ino-%size-%0mtime" using the file
info, otherwise return a crc32 digest the user identifier and response content
@link http://stackoverflow.com/questions/44937/how-do-you-make-an-etag-that-matches-apache
@return string | [
"Generate",
"a",
"response",
"etag"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/behavior/cacheable.php#L149-L161 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/twig.php | KTemplateEngineTwig._load | protected function _load($url)
{
$file = $this->_locate($url);
$type = pathinfo($file, PATHINFO_EXTENSION);
if(in_array($type, $this->getFileTypes()))
{
if(!$this->_source = file_get_contents($file)) {
throw new RuntimeException(sprintf('The template "%s" cannot be loaded.', $file));
}
}
else $this->_source = $this->getTemplate()->loadFile($file)->render($this->getData());
return $this->_source;
} | php | protected function _load($url)
{
$file = $this->_locate($url);
$type = pathinfo($file, PATHINFO_EXTENSION);
if(in_array($type, $this->getFileTypes()))
{
if(!$this->_source = file_get_contents($file)) {
throw new RuntimeException(sprintf('The template "%s" cannot be loaded.', $file));
}
}
else $this->_source = $this->getTemplate()->loadFile($file)->render($this->getData());
return $this->_source;
} | [
"protected",
"function",
"_load",
"(",
"$",
"url",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"_locate",
"(",
"$",
"url",
")",
";",
"$",
"type",
"=",
"pathinfo",
"(",
"$",
"file",
",",
"PATHINFO_EXTENSION",
")",
";",
"if",
"(",
"in_array",
"(",... | Load the template source
@param string $url The template url
@throws \RuntimeException If the template could not be loaded
@return string The template source | [
"Load",
"the",
"template",
"source"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/twig.php#L190-L204 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/twig.php | KTemplateEngineTwig._import | protected function _import($url, array $data = array())
{
if (!parse_url($url, PHP_URL_SCHEME))
{
if (!$base = end($this->_stack)) {
throw new \RuntimeException('Cannot qualify partial template url');
}
$url = $this->getObject('template.locator.factory')
->createLocator($base)
->qualify($url, $base);
if(array_search($url, $this->_stack))
{
throw new \RuntimeException(sprintf(
'Template recursion detected while importing "%s" in "%s"', $url, $base
));
}
}
$type = pathinfo( $this->_locate($url), PATHINFO_EXTENSION);
$data = array_merge((array) $this->getData(), $data);
//If the partial requires a different engine create it and delegate
if(!in_array($type, $this->getFileTypes()))
{
$result = $this->getTemplate()
->loadFile($url)
->render($data);
}
else $result = $this->loadFile($url)->render($data);
return $result;
} | php | protected function _import($url, array $data = array())
{
if (!parse_url($url, PHP_URL_SCHEME))
{
if (!$base = end($this->_stack)) {
throw new \RuntimeException('Cannot qualify partial template url');
}
$url = $this->getObject('template.locator.factory')
->createLocator($base)
->qualify($url, $base);
if(array_search($url, $this->_stack))
{
throw new \RuntimeException(sprintf(
'Template recursion detected while importing "%s" in "%s"', $url, $base
));
}
}
$type = pathinfo( $this->_locate($url), PATHINFO_EXTENSION);
$data = array_merge((array) $this->getData(), $data);
//If the partial requires a different engine create it and delegate
if(!in_array($type, $this->getFileTypes()))
{
$result = $this->getTemplate()
->loadFile($url)
->render($data);
}
else $result = $this->loadFile($url)->render($data);
return $result;
} | [
"protected",
"function",
"_import",
"(",
"$",
"url",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_SCHEME",
")",
")",
"{",
"if",
"(",
"!",
"$",
"base",
"=",
"end",
"(",
... | Import a partial template
If importing a partial merges the data passed in with the data from the call to render. If importing a different
template type jump out of engine scope back to the template.
@param string $url The template url
@param array $data The data to pass to the template
@return string The rendered template content | [
"Import",
"a",
"partial",
"template"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/twig.php#L233-L266 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/bootstrapper/bootstrapper.php | KObjectBootstrapper.getComponentPath | public function getComponentPath($name, $domain = null)
{
$result = null;
$identifier = $this->getComponentIdentifier($name, $domain);
if(isset($this->_components[$identifier])) {
$result = $this->_components[$identifier];
}
return $result;
} | php | public function getComponentPath($name, $domain = null)
{
$result = null;
$identifier = $this->getComponentIdentifier($name, $domain);
if(isset($this->_components[$identifier])) {
$result = $this->_components[$identifier];
}
return $result;
} | [
"public",
"function",
"getComponentPath",
"(",
"$",
"name",
",",
"$",
"domain",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getComponentIdentifier",
"(",
"$",
"name",
",",
"$",
"domain",
")",
";",... | Get a registered component path
@param string $name The component name
@param string $domain The component domain. Domain is optional and can be NULL
@return string Returns the component path if the component is registered. FALSE otherwise | [
"Get",
"a",
"registered",
"component",
"path"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/bootstrapper/bootstrapper.php#L452-L462 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/bootstrapper/bootstrapper.php | KObjectBootstrapper.isBootstrapped | public function isBootstrapped($name = null, $domain = null)
{
if($name)
{
$identifier = $this->getComponentIdentifier($name, $domain);
$result = $this->_bootstrapped && isset($this->_components[$identifier]);
}
else $result = $this->_bootstrapped;
return $result;
} | php | public function isBootstrapped($name = null, $domain = null)
{
if($name)
{
$identifier = $this->getComponentIdentifier($name, $domain);
$result = $this->_bootstrapped && isset($this->_components[$identifier]);
}
else $result = $this->_bootstrapped;
return $result;
} | [
"public",
"function",
"isBootstrapped",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"domain",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getComponentIdentifier",
"(",
"$",
"name",
",",
"$",
"doma... | Check if the bootstrapper has been run
If you specify a specific component name the function will check if this component was bootstrapped.
@param string $name The component name
@param string $domain The component domain. Domain is optional and can be NULL
@return bool TRUE if the bootstrapping has run FALSE otherwise | [
"Check",
"if",
"the",
"bootstrapper",
"has",
"been",
"run"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/bootstrapper/bootstrapper.php#L514-L524 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/command/command.php | KCommand.get | final public function get($name, $default = null)
{
$method = 'get'.ucfirst($name);
if(!method_exists($this, $method) ) {
$value = parent::get($name);
} else {
$value = $this->$method();
}
return $value;
} | php | final public function get($name, $default = null)
{
$method = 'get'.ucfirst($name);
if(!method_exists($this, $method) ) {
$value = parent::get($name);
} else {
$value = $this->$method();
}
return $value;
} | [
"final",
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"method",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")... | Get an command property or attribute
If an event property exists the property will be returned, otherwise the attribute will be returned. If no
property or attribute can be found the method will return NULL.
@param string $name The property name
@param mixed $default The default value
@return mixed|null The property value | [
"Get",
"an",
"command",
"property",
"or",
"attribute"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/command/command.php#L175-L185 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/command/command.php | KCommand.set | final public function set($name, $value)
{
$method = 'set'.ucfirst($name);
if(!method_exists($this, $method) ) {
parent::set($name, $value);
} else {
$this->$method($value);
}
return $this;
} | php | final public function set($name, $value)
{
$method = 'set'.ucfirst($name);
if(!method_exists($this, $method) ) {
parent::set($name, $value);
} else {
$this->$method($value);
}
return $this;
} | [
"final",
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
... | Set a command property or attribute
If an event property exists the property will be set, otherwise an attribute will be added.
@param string $name
@param mixed $value
@return KCommand | [
"Set",
"a",
"command",
"property",
"or",
"attribute"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/command/command.php#L196-L206 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/behavior/editable.php | KControllerBehaviorEditable.setReferrer | public function setReferrer(KControllerContextInterface $context)
{
if (!$context->request->cookies->has($this->_cookie_name.'_locked'))
{
$request = $context->request->getUrl();
$referrer = $context->request->getReferrer();
//Compare request url and referrer
if (isset($referrer) && !$request->equals($referrer))
{
//Add the referrer cookie
$cookie = $this->getObject('lib:http.cookie', array(
'name' => $this->_cookie_name,
'value' => $referrer,
'path' => $this->_cookie_path
));
$context->response->headers->addCookie($cookie);
}
}
} | php | public function setReferrer(KControllerContextInterface $context)
{
if (!$context->request->cookies->has($this->_cookie_name.'_locked'))
{
$request = $context->request->getUrl();
$referrer = $context->request->getReferrer();
//Compare request url and referrer
if (isset($referrer) && !$request->equals($referrer))
{
//Add the referrer cookie
$cookie = $this->getObject('lib:http.cookie', array(
'name' => $this->_cookie_name,
'value' => $referrer,
'path' => $this->_cookie_path
));
$context->response->headers->addCookie($cookie);
}
}
} | [
"public",
"function",
"setReferrer",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"$",
"context",
"->",
"request",
"->",
"cookies",
"->",
"has",
"(",
"$",
"this",
"->",
"_cookie_name",
".",
"'_locked'",
")",
")",
"{",
"$",
... | Set the referrer
@param KControllerContextInterface $context A controller context object
@return void | [
"Set",
"the",
"referrer"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/behavior/editable.php#L114-L134 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/behavior/editable.php | KControllerBehaviorEditable._lockReferrer | protected function _lockReferrer(KControllerContextInterface $context)
{
$cookie = $this->getObject('lib:http.cookie', array(
'name' => $this->_cookie_name.'_locked',
'value' => true,
'path' => $this->_cookie_path
));
$context->response->headers->addCookie($cookie);
} | php | protected function _lockReferrer(KControllerContextInterface $context)
{
$cookie = $this->getObject('lib:http.cookie', array(
'name' => $this->_cookie_name.'_locked',
'value' => true,
'path' => $this->_cookie_path
));
$context->response->headers->addCookie($cookie);
} | [
"protected",
"function",
"_lockReferrer",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"$",
"cookie",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'lib:http.cookie'",
",",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"_cookie_name",
".",
"'_... | Lock the referrer from updates
@param KControllerContextInterface $context A controller context object
@return void | [
"Lock",
"the",
"referrer",
"from",
"updates"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/behavior/editable.php#L163-L172 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/behavior/editable.php | KControllerBehaviorEditable._unlockReferrer | protected function _unlockReferrer(KControllerContextInterface $context)
{
$context->response->headers->clearCookie($this->_cookie_name.'_locked', $this->_cookie_path);
} | php | protected function _unlockReferrer(KControllerContextInterface $context)
{
$context->response->headers->clearCookie($this->_cookie_name.'_locked', $this->_cookie_path);
} | [
"protected",
"function",
"_unlockReferrer",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"$",
"context",
"->",
"response",
"->",
"headers",
"->",
"clearCookie",
"(",
"$",
"this",
"->",
"_cookie_name",
".",
"'_locked'",
",",
"$",
"this",
"->",
... | Unlock the referrer for updates
@param KControllerContextInterface $context A controller context object
@return void | [
"Unlock",
"the",
"referrer",
"for",
"updates"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/behavior/editable.php#L180-L183 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/behavior/editable.php | KControllerBehaviorEditable.isLocked | public function isLocked()
{
if($this->getModel()->getState()->isUnique())
{
$entity = $this->getModel()->fetch();
if($entity->isLockable() && $entity->isLocked()) {
return true;
}
}
return false;
} | php | public function isLocked()
{
if($this->getModel()->getState()->isUnique())
{
$entity = $this->getModel()->fetch();
if($entity->isLockable() && $entity->isLocked()) {
return true;
}
}
return false;
} | [
"public",
"function",
"isLocked",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getState",
"(",
")",
"->",
"isUnique",
"(",
")",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"fetch",
"("... | Check if the resource is locked
@return bool Returns TRUE if the resource is locked, FALSE otherwise. | [
"Check",
"if",
"the",
"resource",
"is",
"locked"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/behavior/editable.php#L203-L215 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/behavior/editable.php | KControllerBehaviorEditable.canSave | public function canSave()
{
if($this->getRequest()->getFormat() == 'html')
{
if($this->getModel()->getState()->isUnique())
{
if($this->canEdit() && !$this->isLocked()) {
return true;
}
}
else
{
if($this->canAdd()) {
return true;
}
}
}
return false;
} | php | public function canSave()
{
if($this->getRequest()->getFormat() == 'html')
{
if($this->getModel()->getState()->isUnique())
{
if($this->canEdit() && !$this->isLocked()) {
return true;
}
}
else
{
if($this->canAdd()) {
return true;
}
}
}
return false;
} | [
"public",
"function",
"canSave",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getFormat",
"(",
")",
"==",
"'html'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getState",
"(",
")",
"->",
"is... | Permission handler for save actions
Method returns TRUE if the controller implements the ControllerModellable interface.
@return boolean Return TRUE if action is permitted. FALSE otherwise. | [
"Permission",
"handler",
"for",
"save",
"actions"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/behavior/editable.php#L277-L296 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/filter/module.php | ComKoowaTemplateFilterModule._renderModules | public function _renderModules($modules, $attribs = array())
{
$html = '';
$count = 1;
foreach($modules as $module)
{
//Set the chrome styles
if(isset($attribs['style'])) {
$module->chrome = explode(' ', $attribs['style']);
}
//Set the module attributes
if($count == 1) {
$attribs['rel']['first'] = 'first';
}
if($count == count($modules)) {
$attribs['rel']['last'] = 'last';
}
if(!isset($module->attribs)) {
$module->attribs = $attribs;
} else {
$module->attribs = array_merge($module->attribs, $attribs);
}
//Render the module
$content = ComKoowaModuleHelper::renderModule($module, $attribs);
//Prepend or append the module
if(isset($module->attribs['prepend']) && $module->attribs['prepend']) {
$html = $content.$html;
} else {
$html = $html.$content;
}
$count++;
}
return $html;
} | php | public function _renderModules($modules, $attribs = array())
{
$html = '';
$count = 1;
foreach($modules as $module)
{
//Set the chrome styles
if(isset($attribs['style'])) {
$module->chrome = explode(' ', $attribs['style']);
}
//Set the module attributes
if($count == 1) {
$attribs['rel']['first'] = 'first';
}
if($count == count($modules)) {
$attribs['rel']['last'] = 'last';
}
if(!isset($module->attribs)) {
$module->attribs = $attribs;
} else {
$module->attribs = array_merge($module->attribs, $attribs);
}
//Render the module
$content = ComKoowaModuleHelper::renderModule($module, $attribs);
//Prepend or append the module
if(isset($module->attribs['prepend']) && $module->attribs['prepend']) {
$html = $content.$html;
} else {
$html = $html.$content;
}
$count++;
}
return $html;
} | [
"public",
"function",
"_renderModules",
"(",
"$",
"modules",
",",
"$",
"attribs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"count",
"=",
"1",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"//Set the ... | Render the modules
@param object $modules The module object
@param array $attribs Module attributes
@return string The rendered modules | [
"Render",
"the",
"modules"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/filter/module.php#L204-L244 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/filter/module.php | ComKoowaTemplateFilterModule._countModules | protected function _countModules($condition)
{
$operators = '(\+|\-|\*|\/|==|\!=|\<\>|\<|\>|\<=|\>=|and|or|xor)';
$words = preg_split('# ' . $operators . ' #', $condition, null, PREG_SPLIT_DELIM_CAPTURE);
for ($i = 0, $n = count($words); $i < $n; $i += 2)
{
// Odd parts (blocks)
$name = strtolower($words[$i]);
if(!is_numeric($name)) {
$words[$i] = count(ComKoowaModuleHelper::getModules($name));
} else {
$words[$i] = $name;
}
}
//Use the stream buffer to evaluate the condition
$str = '<?php return ' . implode(' ', $words) .';';
$buffer = $this->getObject('filesystem.stream.factory')->createStream('koowa-buffer://temp', 'w+b');
$buffer->truncate(0);
$buffer->write($str);
$result = include $buffer->getPath();
return $result;
} | php | protected function _countModules($condition)
{
$operators = '(\+|\-|\*|\/|==|\!=|\<\>|\<|\>|\<=|\>=|and|or|xor)';
$words = preg_split('# ' . $operators . ' #', $condition, null, PREG_SPLIT_DELIM_CAPTURE);
for ($i = 0, $n = count($words); $i < $n; $i += 2)
{
// Odd parts (blocks)
$name = strtolower($words[$i]);
if(!is_numeric($name)) {
$words[$i] = count(ComKoowaModuleHelper::getModules($name));
} else {
$words[$i] = $name;
}
}
//Use the stream buffer to evaluate the condition
$str = '<?php return ' . implode(' ', $words) .';';
$buffer = $this->getObject('filesystem.stream.factory')->createStream('koowa-buffer://temp', 'w+b');
$buffer->truncate(0);
$buffer->write($str);
$result = include $buffer->getPath();
return $result;
} | [
"protected",
"function",
"_countModules",
"(",
"$",
"condition",
")",
"{",
"$",
"operators",
"=",
"'(\\+|\\-|\\*|\\/|==|\\!=|\\<\\>|\\<|\\>|\\<=|\\>=|and|or|xor)'",
";",
"$",
"words",
"=",
"preg_split",
"(",
"'# '",
".",
"$",
"operators",
".",
"' #'",
",",
"$",
"c... | Count the modules based on a condition
@param string $condition
@return integer Returns the result of the evaluated condition | [
"Count",
"the",
"modules",
"based",
"on",
"a",
"condition"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/filter/module.php#L252-L276 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/filter/module.php | ComKoowaTemplateFilterModule._injectModule | protected function _injectModule($name, $attributes = array(), $content = null)
{
//Create module object
$module = new stdClass();
$module->content = $content;
$module->id = uniqid();
$module->position = $attributes['position'];
$module->params = $attributes['params'];
$module->showtitle = !empty($attributes['title']);
$module->title = $attributes['title'];
$module->attribs = $attributes;
$module->user = 0;
$module->name = $name;
$module->module = 'mod_'.$name;
$modules = &ComKoowaModuleHelper::getModules(null);
if($module->attribs['prepend']) {
array_push($modules, $module);
} else {
array_unshift($modules, $module);
}
} | php | protected function _injectModule($name, $attributes = array(), $content = null)
{
//Create module object
$module = new stdClass();
$module->content = $content;
$module->id = uniqid();
$module->position = $attributes['position'];
$module->params = $attributes['params'];
$module->showtitle = !empty($attributes['title']);
$module->title = $attributes['title'];
$module->attribs = $attributes;
$module->user = 0;
$module->name = $name;
$module->module = 'mod_'.$name;
$modules = &ComKoowaModuleHelper::getModules(null);
if($module->attribs['prepend']) {
array_push($modules, $module);
} else {
array_unshift($modules, $module);
}
} | [
"protected",
"function",
"_injectModule",
"(",
"$",
"name",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"$",
"content",
"=",
"null",
")",
"{",
"//Create module object",
"$",
"module",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"module",
"->",
... | Inject the module
@param string $name
@param array $attributes
@param string $content | [
"Inject",
"the",
"module"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/filter/module.php#L285-L307 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/filter/module.php | ComKoowaModuleHelper.& | public static function &getModules($position)
{
if($position) {
$modules =& JModuleHelper::getModules($position);
} else {
$modules =& JModuleHelper::_load();
}
return $modules;
} | php | public static function &getModules($position)
{
if($position) {
$modules =& JModuleHelper::getModules($position);
} else {
$modules =& JModuleHelper::_load();
}
return $modules;
} | [
"public",
"static",
"function",
"&",
"getModules",
"(",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"position",
")",
"{",
"$",
"modules",
"=",
"&",
"JModuleHelper",
"::",
"getModules",
"(",
"$",
"position",
")",
";",
"}",
"else",
"{",
"$",
"modules",
... | Return modules, optionally filtered by position
@param string|null $position Module position
@return array | [
"Return",
"modules",
"optionally",
"filtered",
"by",
"position"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/filter/module.php#L326-L335 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/template.php | KTemplate.escape | public function escape($string)
{
if(is_string($string)) {
$string = htmlspecialchars($string, ENT_COMPAT | ENT_SUBSTITUTE, 'UTF-8', false);
}
return $string;
} | php | public function escape($string)
{
if(is_string($string)) {
$string = htmlspecialchars($string, ENT_COMPAT | ENT_SUBSTITUTE, 'UTF-8', false);
}
return $string;
} | [
"public",
"function",
"escape",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"$",
"string",
"=",
"htmlspecialchars",
"(",
"$",
"string",
",",
"ENT_COMPAT",
"|",
"ENT_SUBSTITUTE",
",",
"'UTF-8'",
",",
"false",
... | Escape a string
By default the function uses htmlspecialchars to escape the string
@param string $string String to to be escape
@return string Escaped string | [
"Escape",
"a",
"string"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/template.php#L244-L251 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/template.php | KTemplate.addFilter | public function addFilter($filter, $config = array())
{
//Create the complete identifier if a partial identifier was passed
if (is_string($filter) && strpos($filter, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('template', 'filter');
$identifier['name'] = $filter;
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($filter);
if (!$this->hasFilter($identifier->name))
{
$filter = $this->getObject($identifier, array_merge($config, array('template' => $this)));
if (!($filter instanceof KTemplateFilterInterface))
{
throw new UnexpectedValueException(
"Template filter $identifier does not implement KTemplateFilterInterface"
);
}
//Store the filter
$this->__filters[$filter->getIdentifier()->name] = $filter;
//Enqueue the filter
$this->__filter_queue->enqueue($filter, $filter->getPriority());
}
return $this;
} | php | public function addFilter($filter, $config = array())
{
//Create the complete identifier if a partial identifier was passed
if (is_string($filter) && strpos($filter, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('template', 'filter');
$identifier['name'] = $filter;
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($filter);
if (!$this->hasFilter($identifier->name))
{
$filter = $this->getObject($identifier, array_merge($config, array('template' => $this)));
if (!($filter instanceof KTemplateFilterInterface))
{
throw new UnexpectedValueException(
"Template filter $identifier does not implement KTemplateFilterInterface"
);
}
//Store the filter
$this->__filters[$filter->getIdentifier()->name] = $filter;
//Enqueue the filter
$this->__filter_queue->enqueue($filter, $filter->getPriority());
}
return $this;
} | [
"public",
"function",
"addFilter",
"(",
"$",
"filter",
",",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"//Create the complete identifier if a partial identifier was passed",
"if",
"(",
"is_string",
"(",
"$",
"filter",
")",
"&&",
"strpos",
"(",
"$",
"filter... | Attach a filter for template transformation
@param mixed $filter An object that implements ObjectInterface, ObjectIdentifier object
or valid identifier string
@param array $config An optional associative array of configuration settings
@throws UnexpectedValueException
@return KTemplateAbstract | [
"Attach",
"a",
"filter",
"for",
"template",
"transformation"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/template.php#L364-L396 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/template.php | KTemplate.getFilter | public function getFilter($filter)
{
$result = null;
if(isset($this->__filters[$filter])) {
$result = $this->__filters[$filter];
}
return $result;
} | php | public function getFilter($filter)
{
$result = null;
if(isset($this->__filters[$filter])) {
$result = $this->__filters[$filter];
}
return $result;
} | [
"public",
"function",
"getFilter",
"(",
"$",
"filter",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__filters",
"[",
"$",
"filter",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"__filters",
... | Get a filter by identifier
@param mixed $filter An object that implements ObjectInterface, ObjectIdentifier object
or valid identifier string
@throws UnexpectedValueException
@return KTemplateFilterInterface|null | [
"Get",
"a",
"filter",
"by",
"identifier"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/template.php#L417-L426 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/authenticator/basic.php | KDispatcherAuthenticatorBasic._getAuthParam | protected function _getAuthParam()
{
if(!isset($this->__auth_param))
{
$this->__auth_param = null;
$request = $this->getObject('request');
if($request->headers->has('Authorization'))
{
$authorization = $request->headers->get('Authorization');
if (stripos($authorization, 'basic') === 0)
{
$exploded = explode(':', base64_decode(substr($authorization, 6)));
if (count($exploded) == 2) {
$this->__auth_param = array($exploded[0], $exploded[1]);
}
}
}
}
return $this->__auth_param;
} | php | protected function _getAuthParam()
{
if(!isset($this->__auth_param))
{
$this->__auth_param = null;
$request = $this->getObject('request');
if($request->headers->has('Authorization'))
{
$authorization = $request->headers->get('Authorization');
if (stripos($authorization, 'basic') === 0)
{
$exploded = explode(':', base64_decode(substr($authorization, 6)));
if (count($exploded) == 2) {
$this->__auth_param = array($exploded[0], $exploded[1]);
}
}
}
}
return $this->__auth_param;
} | [
"protected",
"function",
"_getAuthParam",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"__auth_param",
")",
")",
"{",
"$",
"this",
"->",
"__auth_param",
"=",
"null",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'... | Returns the basic authentication credentials from the header
@return array|null | [
"Returns",
"the",
"basic",
"authentication",
"credentials",
"from",
"the",
"header"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/authenticator/basic.php#L100-L124 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/container/metadata.php | KUserSessionContainerMetadata.getSecret | public function getSecret()
{
if ($this->secret === null)
{
$salt = $this->_createSalt(12);
$name = session_name();
$this->secret = sha1($salt . $name);
}
return $this->secret;
} | php | public function getSecret()
{
if ($this->secret === null)
{
$salt = $this->_createSalt(12);
$name = session_name();
$this->secret = sha1($salt . $name);
}
return $this->secret;
} | [
"public",
"function",
"getSecret",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"secret",
"===",
"null",
")",
"{",
"$",
"salt",
"=",
"$",
"this",
"->",
"_createSalt",
"(",
"12",
")",
";",
"$",
"name",
"=",
"session_name",
"(",
")",
";",
"$",
"thi... | Get a session secret, a secret should never be exposed publicly
@return string The session token | [
"Get",
"a",
"session",
"secret",
"a",
"secret",
"should",
"never",
"be",
"exposed",
"publicly"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/metadata.php#L93-L104 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/container/metadata.php | KUserSessionContainerMetadata.createNonce | public function createNonce()
{
$secret = $this->getSecret();
$timeout = $this->getLifetime();
$nonce = $this->_createNonce($secret, $timeout);
$this->nonces[$nonce] = $nonce;
return $nonce;
} | php | public function createNonce()
{
$secret = $this->getSecret();
$timeout = $this->getLifetime();
$nonce = $this->_createNonce($secret, $timeout);
$this->nonces[$nonce] = $nonce;
return $nonce;
} | [
"public",
"function",
"createNonce",
"(",
")",
"{",
"$",
"secret",
"=",
"$",
"this",
"->",
"getSecret",
"(",
")",
";",
"$",
"timeout",
"=",
"$",
"this",
"->",
"getLifetime",
"(",
")",
";",
"$",
"nonce",
"=",
"$",
"this",
"->",
"_createNonce",
"(",
... | Create a new session nonce
@return string The session nonce | [
"Create",
"a",
"new",
"session",
"nonce"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/metadata.php#L111-L120 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/container/metadata.php | KUserSessionContainerMetadata.verifyNonce | public function verifyNonce($nonce)
{
if(isset($this->nonces[$nonce]))
{
//Remove the nonce from the store
unset($this->nonces[$nonce]);
//Validate the nonce
$secret = $this->getSecret();
if($this->_validateNonce($secret, $nonce)) {
return true;
}
}
return false;
} | php | public function verifyNonce($nonce)
{
if(isset($this->nonces[$nonce]))
{
//Remove the nonce from the store
unset($this->nonces[$nonce]);
//Validate the nonce
$secret = $this->getSecret();
if($this->_validateNonce($secret, $nonce)) {
return true;
}
}
return false;
} | [
"public",
"function",
"verifyNonce",
"(",
"$",
"nonce",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"nonces",
"[",
"$",
"nonce",
"]",
")",
")",
"{",
"//Remove the nonce from the store",
"unset",
"(",
"$",
"this",
"->",
"nonces",
"[",
"$",
"no... | Verify a session nonce
Checks to see if the nonce has been generated before. If so, validate it's syntax and remove it.
@param string $nonce The nonce to verify
@return bool Returns true if the nonce exists and is valid. | [
"Verify",
"a",
"session",
"nonce"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/metadata.php#L130-L145 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/container/metadata.php | KUserSessionContainerMetadata.isExpired | public function isExpired()
{
$curTime = $this->timer['now'];
$maxTime = $this->timer['last'] + $this->_lifetime;
return ($maxTime < $curTime);
} | php | public function isExpired()
{
$curTime = $this->timer['now'];
$maxTime = $this->timer['last'] + $this->_lifetime;
return ($maxTime < $curTime);
} | [
"public",
"function",
"isExpired",
"(",
")",
"{",
"$",
"curTime",
"=",
"$",
"this",
"->",
"timer",
"[",
"'now'",
"]",
";",
"$",
"maxTime",
"=",
"$",
"this",
"->",
"timer",
"[",
"'last'",
"]",
"+",
"$",
"this",
"->",
"_lifetime",
";",
"return",
"(",... | Check if the session has expired
@return boolean Returns TRUE if the session has expired | [
"Check",
"if",
"the",
"session",
"has",
"expired"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/metadata.php#L152-L158 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/container/metadata.php | KUserSessionContainerMetadata._createSalt | protected function _createSalt($length = 32)
{
static $chars ='qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM01234567890';
$max = strlen($chars) - 1;
$salt = '';
for ($i = 0; $i < $length; ++$i) {
$salt .= $chars[(mt_rand(0, $max))];
}
return $salt;
} | php | protected function _createSalt($length = 32)
{
static $chars ='qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM01234567890';
$max = strlen($chars) - 1;
$salt = '';
for ($i = 0; $i < $length; ++$i) {
$salt .= $chars[(mt_rand(0, $max))];
}
return $salt;
} | [
"protected",
"function",
"_createSalt",
"(",
"$",
"length",
"=",
"32",
")",
"{",
"static",
"$",
"chars",
"=",
"'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM01234567890'",
";",
"$",
"max",
"=",
"strlen",
"(",
"$",
"chars",
")",
"-",
"1",
";",
"$",
"salt... | Create a random string
@param integer $length Length of string
@return string Generated string | [
"Create",
"a",
"random",
"string"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/metadata.php#L166-L178 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/container/metadata.php | KUserSessionContainerMetadata._createNonce | public function _createNonce($secret, $timeout = 180)
{
if (is_string($secret) == false || strlen($secret) < 10) {
throw new InvalidArgumentException("Missing valid secret");
}
$salt = $this->_createSalt(12);
$lifetime = time() + $timeout;
$nonce = $salt . ':' . $lifetime . ':' . hash_hmac( 'sha1', $salt.$lifetime, $secret );
return $nonce;
} | php | public function _createNonce($secret, $timeout = 180)
{
if (is_string($secret) == false || strlen($secret) < 10) {
throw new InvalidArgumentException("Missing valid secret");
}
$salt = $this->_createSalt(12);
$lifetime = time() + $timeout;
$nonce = $salt . ':' . $lifetime . ':' . hash_hmac( 'sha1', $salt.$lifetime, $secret );
return $nonce;
} | [
"public",
"function",
"_createNonce",
"(",
"$",
"secret",
",",
"$",
"timeout",
"=",
"180",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"secret",
")",
"==",
"false",
"||",
"strlen",
"(",
"$",
"secret",
")",
"<",
"10",
")",
"{",
"throw",
"new",
"Inva... | Generate a Nonce.
The generated nonce will contains three parts, separated by a colon. The first part is the individual salt.
The second part is the time until the nonce is valid. The third part is a HMAC hash of the salt, the time, and
a secret value.
@link http://en.wikipedia.org/wiki/Hash-based_message_authentication_code
@param string $secret String with at least 10 characters. The same value must be passed to _validateNonce().
@param integer $timeout the time in seconds until the nonce becomes invalid.
@throws \InvalidArgumentException If the secret is not valid.
@return string the generated Nonce. | [
"Generate",
"a",
"Nonce",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/metadata.php#L195-L207 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/container/metadata.php | KUserSessionContainerMetadata._validateNonce | public static function _validateNonce($secret, $nonce)
{
if (is_string($nonce) == false) {
return false;
}
$a = explode(':', $nonce);
if (count($a) != 3) {
return false;
}
$salt = $a[0];
$lifetime = intval($a[1]);
$hash = $a[2];
$back = hash_hmac( 'sha1', $salt.$lifetime, $secret );
if ($back != $hash) {
return false;
}
if (time() > $lifetime) {
return false;
}
return true;
} | php | public static function _validateNonce($secret, $nonce)
{
if (is_string($nonce) == false) {
return false;
}
$a = explode(':', $nonce);
if (count($a) != 3) {
return false;
}
$salt = $a[0];
$lifetime = intval($a[1]);
$hash = $a[2];
$back = hash_hmac( 'sha1', $salt.$lifetime, $secret );
if ($back != $hash) {
return false;
}
if (time() > $lifetime) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"_validateNonce",
"(",
"$",
"secret",
",",
"$",
"nonce",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"nonce",
")",
"==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"a",
"=",
"explode",
"(",
"':'",
",",
"$",... | Check a previously generated Nonce.
The nonce should contains three parts, separated by a colon. The first part is the individual salt. The
second part is the time until the nonce is valid. The third part is a hmac hash of the salt, the time, and
a secret value.
@param string $secret String with at least 10 characters. The same value must be passed to _validateNonce().
@param string $nonce
@returns bool Whether the Nonce is valid. | [
"Check",
"a",
"previously",
"generated",
"Nonce",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/metadata.php#L220-L245 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/container/metadata.php | KUserSessionContainerMetadata._updateTimers | protected function _updateTimers()
{
if(!isset($this->timer))
{
$start = time();
$timer = array(
'start' => $start,
'last' => $start,
'now' => $start
);
}
else $timer = $this->timer;
$timer['last'] = $timer['now'];
$timer['now'] = time();
$this->timer = $timer;
} | php | protected function _updateTimers()
{
if(!isset($this->timer))
{
$start = time();
$timer = array(
'start' => $start,
'last' => $start,
'now' => $start
);
}
else $timer = $this->timer;
$timer['last'] = $timer['now'];
$timer['now'] = time();
$this->timer = $timer;
} | [
"protected",
"function",
"_updateTimers",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"timer",
")",
")",
"{",
"$",
"start",
"=",
"time",
"(",
")",
";",
"$",
"timer",
"=",
"array",
"(",
"'start'",
"=>",
"$",
"start",
",",
"'las... | Update the session timers
@return void | [
"Update",
"the",
"session",
"timers"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/metadata.php#L252-L270 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/handler/abstract.php | KUserSessionHandlerAbstract.register | public function register()
{
session_set_save_handler(
array($this, 'open'),
array($this, 'close'),
array($this, 'read'),
array($this, 'write'),
array($this, 'destroy'),
array($this, 'gc')
);
static::$_registered = $this;
} | php | public function register()
{
session_set_save_handler(
array($this, 'open'),
array($this, 'close'),
array($this, 'read'),
array($this, 'write'),
array($this, 'destroy'),
array($this, 'gc')
);
static::$_registered = $this;
} | [
"public",
"function",
"register",
"(",
")",
"{",
"session_set_save_handler",
"(",
"array",
"(",
"$",
"this",
",",
"'open'",
")",
",",
"array",
"(",
"$",
"this",
",",
"'close'",
")",
",",
"array",
"(",
"$",
"this",
",",
"'read'",
")",
",",
"array",
"(... | Register the functions of this class with PHP's session handler
@see http://php.net/session-set-save-handler
@return void | [
"Register",
"the",
"functions",
"of",
"this",
"class",
"with",
"PHP",
"s",
"session",
"handler"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/handler/abstract.php#L72-L84 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/user/provider.php | ComKoowaUserProvider.load | public function load($identifier, $refresh = false)
{
$user = $this->getObject('user');
// Find the user id
if (!is_numeric($identifier))
{
if(!$identifier = JUserHelper::getUserId($identifier)) {
$identifier = 0;
}
}
// Fetch the user
if ($identifier == 0 || $user->getId() != $identifier)
{
$user = parent::load($identifier, $refresh);
if (!$user instanceof KUserInterface)
{
$user = $this->create(array(
'id' => $identifier,
'name' => $this->getObject('translator')->translate('Anonymous')
));
}
}
return $user;
} | php | public function load($identifier, $refresh = false)
{
$user = $this->getObject('user');
// Find the user id
if (!is_numeric($identifier))
{
if(!$identifier = JUserHelper::getUserId($identifier)) {
$identifier = 0;
}
}
// Fetch the user
if ($identifier == 0 || $user->getId() != $identifier)
{
$user = parent::load($identifier, $refresh);
if (!$user instanceof KUserInterface)
{
$user = $this->create(array(
'id' => $identifier,
'name' => $this->getObject('translator')->translate('Anonymous')
));
}
}
return $user;
} | [
"public",
"function",
"load",
"(",
"$",
"identifier",
",",
"$",
"refresh",
"=",
"false",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'user'",
")",
";",
"// Find the user id",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"identifier",
"... | Loads the user for the given username or user id
@param string $identifier A unique user identifier, (i.e a username or user id)
@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",
"username",
"or",
"user",
"id"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/user/provider.php#L25-L52 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/user/provider.php | ComKoowaUserProvider.fetch | public function fetch($identifier)
{
$table = JUser::getTable();
if ($table->load($identifier))
{
$user = JUser::getInstance(0);
$user->setProperties($table->getProperties());
$params = new JRegistry;
$params->loadString($table->params);
$user->setParameters($params);
$data = array(
'id' => $user->id,
'email' => $user->email,
'name' => $user->name,
'username' => $user->username,
'password' => $user->password,
'salt' => '',
'groups' => JAccess::getGroupsByUser($user->id),
'roles' => JAccess::getAuthorisedViewLevels($user->id),
'authentic' => !$user->guest,
'enabled' => !$user->block,
'expired' => (bool) $user->activation,
'attributes' => $user->getParameters()->toArray()
);
$user = $this->create($data);
}
else $user = null;
return $user;
} | php | public function fetch($identifier)
{
$table = JUser::getTable();
if ($table->load($identifier))
{
$user = JUser::getInstance(0);
$user->setProperties($table->getProperties());
$params = new JRegistry;
$params->loadString($table->params);
$user->setParameters($params);
$data = array(
'id' => $user->id,
'email' => $user->email,
'name' => $user->name,
'username' => $user->username,
'password' => $user->password,
'salt' => '',
'groups' => JAccess::getGroupsByUser($user->id),
'roles' => JAccess::getAuthorisedViewLevels($user->id),
'authentic' => !$user->guest,
'enabled' => !$user->block,
'expired' => (bool) $user->activation,
'attributes' => $user->getParameters()->toArray()
);
$user = $this->create($data);
}
else $user = null;
return $user;
} | [
"public",
"function",
"fetch",
"(",
"$",
"identifier",
")",
"{",
"$",
"table",
"=",
"JUser",
"::",
"getTable",
"(",
")",
";",
"if",
"(",
"$",
"table",
"->",
"load",
"(",
"$",
"identifier",
")",
")",
"{",
"$",
"user",
"=",
"JUser",
"::",
"getInstanc... | Fetch the user for the given user identifier from the backend
@param string $identifier A unique user identifier, (i.e a username or email address)
@return KUserInterface|null Returns a UserInterface object or NULL if the user could not be found. | [
"Fetch",
"the",
"user",
"for",
"the",
"given",
"user",
"identifier",
"from",
"the",
"backend"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/user/provider.php#L60-L94 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/behavior/abstract.php | KBehaviorAbstract.getObject | final public function getObject($identifier, array $config = array())
{
$result = $this->__object_manager->getObject($identifier, $config);
return $result;
} | php | final public function getObject($identifier, array $config = array())
{
$result = $this->__object_manager->getObject($identifier, $config);
return $result;
} | [
"final",
"public",
"function",
"getObject",
"(",
"$",
"identifier",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"__object_manager",
"->",
"getObject",
"(",
"$",
"identifier",
",",
"$",
"config",
... | Get an instance of an object identifier
@param KObjectIdentifier|string $identifier An ObjectIdentifier or valid identifier string
@param array $config An optional associative array of configuration settings.
@return KObjectInterface Return object on success, throws exception on failure. | [
"Get",
"an",
"instance",
"of",
"an",
"object",
"identifier"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/behavior/abstract.php#L227-L231 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/behavior/abstract.php | KBehaviorAbstract.getConfig | public function getConfig($identifier = null)
{
if (isset($identifier)) {
$result = $this->__object_manager->getIdentifier($identifier)->getConfig();
} else {
$result = $this->__object_config;
}
return $result;
} | php | public function getConfig($identifier = null)
{
if (isset($identifier)) {
$result = $this->__object_manager->getIdentifier($identifier)->getConfig();
} else {
$result = $this->__object_config;
}
return $result;
} | [
"public",
"function",
"getConfig",
"(",
"$",
"identifier",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"identifier",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"__object_manager",
"->",
"getIdentifier",
"(",
"$",
"identifier",
")",
... | Get the object configuration
If no identifier is passed the object config of this object will be returned. Function recursively
resolves identifier aliases and returns the aliased identifier.
@param string|object $identifier A valid identifier string or object implementing ObjectInterface
@return KObjectConfig | [
"Get",
"the",
"object",
"configuration"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/behavior/abstract.php#L262-L271 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/permission/abstract.php | KControllerPermissionAbstract.canEdit | public function canEdit()
{
if($this->getMixer() instanceof KControllerModellable)
{
$user = $this->getUser();
if ($user->isAuthentic() && $user->isEnabled()) {
return true;
}
}
return false;
} | php | public function canEdit()
{
if($this->getMixer() instanceof KControllerModellable)
{
$user = $this->getUser();
if ($user->isAuthentic() && $user->isEnabled()) {
return true;
}
}
return false;
} | [
"public",
"function",
"canEdit",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getMixer",
"(",
")",
"instanceof",
"KControllerModellable",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
";",
"if",
"(",
"$",
"user",
"->",
"isAuthe... | Permission handler for edit actions
Method returns TRUE iff the controller implements the KControllerModellable interface and the user is authentic
and the account is enabled.
@return boolean Return TRUE if action is permitted. FALSE otherwise. | [
"Permission",
"handler",
"for",
"edit",
"actions"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/permission/abstract.php#L93-L104 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/message/parameters.php | KHttpMessageParameters.add | public function add(array $parameters)
{
foreach ($parameters as $identifier => $value) {
$this->set($identifier, $value, false);
}
return $this;
} | php | public function add(array $parameters)
{
foreach ($parameters as $identifier => $value) {
$this->set($identifier, $value, false);
}
return $this;
} | [
"public",
"function",
"add",
"(",
"array",
"$",
"parameters",
")",
"{",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"identifier",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"identifier",
",",
"$",
"value",
",",
"false",
")",
... | Adds new parameters the current HTTP parameters set.
This function will not add parameters that already exist.
@param array $parameters An array of HTTP headers
@return KHttpMessageParameters | [
"Adds",
"new",
"parameters",
"the",
"current",
"HTTP",
"parameters",
"set",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/message/parameters.php#L184-L191 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/message/parameters.php | KHttpMessageParameters.remove | public function remove($identifier)
{
$keys = $this->_parseIdentifier($identifier);
foreach($keys as $key)
{
if(array_key_exists($key, $this->_data))
{
unset($this->_data[$key]);
break;
};
}
return $this;
} | php | public function remove($identifier)
{
$keys = $this->_parseIdentifier($identifier);
foreach($keys as $key)
{
if(array_key_exists($key, $this->_data))
{
unset($this->_data[$key]);
break;
};
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"identifier",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"_parseIdentifier",
"(",
"$",
"identifier",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
... | Removes a parameter.
@param string $identifier The parameter name
@return KHttpMessageParameters | [
"Removes",
"a",
"parameter",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/message/parameters.php#L199-L213 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/factory.php | KFilesystemStreamFactory.registerStream | public function registerStream($identifier)
{
$result = false;
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KFilesystemStreamInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Stream: '.$identifier.' does not implement KFilesystemStreamInterface'
);
}
$name = $class::getName();
if (!empty($name) && !$this->isRegistered($this->_stream_prefix.$name))
{
if($result = stream_wrapper_register($this->_stream_prefix.$name, 'KFilesystemStreamAdapter')) {
$this->__streams[$this->_stream_prefix.$name] = $identifier;
}
}
return $result;
} | php | public function registerStream($identifier)
{
$result = false;
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KFilesystemStreamInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Stream: '.$identifier.' does not implement KFilesystemStreamInterface'
);
}
$name = $class::getName();
if (!empty($name) && !$this->isRegistered($this->_stream_prefix.$name))
{
if($result = stream_wrapper_register($this->_stream_prefix.$name, 'KFilesystemStreamAdapter')) {
$this->__streams[$this->_stream_prefix.$name] = $identifier;
}
}
return $result;
} | [
"public",
"function",
"registerStream",
"(",
"$",
"identifier",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"identifier",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"getObject",
... | Register a stream
Function prevents from registering the stream twice.
If stream_prefix config option is set, the registered stream will be prefixed and createStream should be called
with the prefix.
@param string $identifier A stream identifier string
@throws UnexpectedValueException
@return bool Returns TRUE on success, FALSE on failure. | [
"Register",
"a",
"stream"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/factory.php#L157-L181 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/factory.php | KFilesystemStreamFactory.unregisterStream | public function unregisterStream($identifier)
{
$result = false;
if(strpos($identifier, '.') !== false )
{
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KFilesystemStreamInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Stream: '.$identifier.' does not implement KFilesystemStreamInterface'
);
}
$name = $class::getName();
}
else $name = $identifier;
if (!empty($name) && $this->isRegistered($this->_stream_prefix.$name))
{
if($result = stream_wrapper_unregister($this->_stream_prefix.$name)) {
unset($this->__streams[$this->_stream_prefix.$name]);
}
}
return $result;
} | php | public function unregisterStream($identifier)
{
$result = false;
if(strpos($identifier, '.') !== false )
{
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KFilesystemStreamInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Stream: '.$identifier.' does not implement KFilesystemStreamInterface'
);
}
$name = $class::getName();
}
else $name = $identifier;
if (!empty($name) && $this->isRegistered($this->_stream_prefix.$name))
{
if($result = stream_wrapper_unregister($this->_stream_prefix.$name)) {
unset($this->__streams[$this->_stream_prefix.$name]);
}
}
return $result;
} | [
"public",
"function",
"unregisterStream",
"(",
"$",
"identifier",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"strpos",
"(",
"$",
"identifier",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentif... | Unregister a stream
@param string $identifier A stream object identifier string or stream name
@throws UnexpectedValueException
@return bool Returns TRUE on success, FALSE on failure. | [
"Unregister",
"a",
"stream"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/factory.php#L190-L219 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/factory.php | KFilesystemStreamFactory.getStream | public function getStream($name)
{
$stream = false;
if($this->isRegistered($name))
{
if(isset($this->__streams[$name])) {
$stream = $this->__streams[$name];
} else {
$stream = 'lib:filesystem.stream.'.$name;
}
}
return $stream;
} | php | public function getStream($name)
{
$stream = false;
if($this->isRegistered($name))
{
if(isset($this->__streams[$name])) {
$stream = $this->__streams[$name];
} else {
$stream = 'lib:filesystem.stream.'.$name;
}
}
return $stream;
} | [
"public",
"function",
"getStream",
"(",
"$",
"name",
")",
"{",
"$",
"stream",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"isRegistered",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__streams",
"[",
"$",
"na... | Get a registered stream identifier
@param string $name The stream name
@return string|false The stream identifier | [
"Get",
"a",
"registered",
"stream",
"identifier"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/factory.php#L227-L241 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/factory.php | KFilesystemStreamFactory.isSupported | public function isSupported($identifier)
{
if(strpos($identifier, '.') !== false )
{
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
$name = $class::getName();
}
else $name = $identifier;
//Check if the stream is registered
$result = $this->isRegistered($name);
//Check if the stream is supported
if(!ini_get('allow_url_fopen'))
{
if(in_array(array('ftp', 'sftp', 'http', 'https'), $name)) {
$result = false;
}
}
return $result;
} | php | public function isSupported($identifier)
{
if(strpos($identifier, '.') !== false )
{
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
$name = $class::getName();
}
else $name = $identifier;
//Check if the stream is registered
$result = $this->isRegistered($name);
//Check if the stream is supported
if(!ini_get('allow_url_fopen'))
{
if(in_array(array('ftp', 'sftp', 'http', 'https'), $name)) {
$result = false;
}
}
return $result;
} | [
"public",
"function",
"isSupported",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"identifier",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"identifier",
")",
";",... | Check if the stream for a registered protocol is supported
@param string $identifier A stream object identifier string or stream name
@return bool TRUE if the stream is a registered and is supported, FALSE otherwise. | [
"Check",
"if",
"the",
"stream",
"for",
"a",
"registered",
"protocol",
"is",
"supported"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/factory.php#L287-L309 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/factory.php | KTemplateEngineFactory.createEngine | public function createEngine($url, array $config = array())
{
//Find the file type
if(!$type = pathinfo($url, PATHINFO_EXTENSION)) {
$type = $url;
}
//Engine not supported
if(!in_array($type, $this->getFileTypes()))
{
throw new RuntimeException(sprintf(
'Unable to find a template engine for the "%s" file format - did you forget to register it ?', $type
));
}
//Create the engine
$identifier = $this->getEngine($type);
$engine = $this->getObject($identifier, $config);
if(!$engine instanceof KTemplateEngineInterface)
{
throw new UnexpectedValueException(
'Engine: '.get_class($engine).' does not implement KTemplateEngineInterface'
);
}
return $engine;
} | php | public function createEngine($url, array $config = array())
{
//Find the file type
if(!$type = pathinfo($url, PATHINFO_EXTENSION)) {
$type = $url;
}
//Engine not supported
if(!in_array($type, $this->getFileTypes()))
{
throw new RuntimeException(sprintf(
'Unable to find a template engine for the "%s" file format - did you forget to register it ?', $type
));
}
//Create the engine
$identifier = $this->getEngine($type);
$engine = $this->getObject($identifier, $config);
if(!$engine instanceof KTemplateEngineInterface)
{
throw new UnexpectedValueException(
'Engine: '.get_class($engine).' does not implement KTemplateEngineInterface'
);
}
return $engine;
} | [
"public",
"function",
"createEngine",
"(",
"$",
"url",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"//Find the file type",
"if",
"(",
"!",
"$",
"type",
"=",
"pathinfo",
"(",
"$",
"url",
",",
"PATHINFO_EXTENSION",
")",
")",
"{",
"$",
... | Create an engine
Note that only paths ending with '.[type]' are supported. If the url is not a path we will assume the url is
the type. If no engine is registered for the specific file type a exception will be thrown.
@param string $url The template url or engine type
@param array $config An optional associative array of configuration options
@throws InvalidArgumentException If the path is not valid
@throws RuntimeException If the engine isn't registered
@throws UnexpectedValueException If the engine object doesn't implement the TemplateEngineInterface
@return KTemplateEngineInterface | [
"Create",
"an",
"engine"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/factory.php#L80-L107 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/factory.php | KTemplateEngineFactory.registerEngine | public function registerEngine($identifier, array $config = array())
{
$result = false;
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KTemplateEngineInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Engine: '.$identifier.' does not implement KTemplateEngineInterface'
);
}
$types = call_user_func(array($class, 'getFileTypes'));/*$class::getFileTypes();*/
if (!empty($types))
{
foreach($types as $type)
{
if(!$this->isRegistered($type))
{
$identifier->getConfig()->merge($config)->append(array(
'debug' => $this->getConfig()->debug,
'cache' => $this->getConfig()->cache,
'cache_path' => $this->getConfig()->cache_path
));
$this->__engines[$type] = $identifier;
}
}
}
return $result;
} | php | public function registerEngine($identifier, array $config = array())
{
$result = false;
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KTemplateEngineInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Engine: '.$identifier.' does not implement KTemplateEngineInterface'
);
}
$types = call_user_func(array($class, 'getFileTypes'));/*$class::getFileTypes();*/
if (!empty($types))
{
foreach($types as $type)
{
if(!$this->isRegistered($type))
{
$identifier->getConfig()->merge($config)->append(array(
'debug' => $this->getConfig()->debug,
'cache' => $this->getConfig()->cache,
'cache_path' => $this->getConfig()->cache_path
));
$this->__engines[$type] = $identifier;
}
}
}
return $result;
} | [
"public",
"function",
"registerEngine",
"(",
"$",
"identifier",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"identifier",
")",
";... | Register an engine
Function prevents from registering the engine twice
@param string $identifier A engine identifier string
@param array $config An optional associative array of configuration options
@throws UnexpectedValueException
@return bool Returns TRUE on success, FALSE on failure. | [
"Register",
"an",
"engine"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/factory.php#L119-L153 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/factory.php | KTemplateEngineFactory.unregisterEngine | public function unregisterEngine($identifier)
{
$result = false;
if(strpos($identifier, '.') !== false )
{
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KTemplateEngineInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Engine: '.$identifier.' does not implement KTemplateEngineInterface'
);
}
$types = call_user_func(array($class, 'getFileTypes'));/*$class::getFileTypes();*/
}
else $types = (array) $identifier;
if (!empty($types))
{
foreach($types as $type)
{
if($this->isRegistered($type)) {
unset($this->__engines[$type]);
}
}
}
return $result;
} | php | public function unregisterEngine($identifier)
{
$result = false;
if(strpos($identifier, '.') !== false )
{
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KTemplateEngineInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Engine: '.$identifier.' does not implement KTemplateEngineInterface'
);
}
$types = call_user_func(array($class, 'getFileTypes'));/*$class::getFileTypes();*/
}
else $types = (array) $identifier;
if (!empty($types))
{
foreach($types as $type)
{
if($this->isRegistered($type)) {
unset($this->__engines[$type]);
}
}
}
return $result;
} | [
"public",
"function",
"unregisterEngine",
"(",
"$",
"identifier",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"strpos",
"(",
"$",
"identifier",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentif... | Unregister an engine
@param string $identifier A engine object identifier string or file type
@throws UnexpectedValueException
@return bool Returns TRUE on success, FALSE on failure. | [
"Unregister",
"an",
"engine"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/factory.php#L162-L194 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/factory.php | KTemplateEngineFactory.getEngine | public function getEngine($type)
{
$engine = false;
if(isset($this->__engines[$type])) {
$engine = $this->__engines[$type];
}
return $engine;
} | php | public function getEngine($type)
{
$engine = false;
if(isset($this->__engines[$type])) {
$engine = $this->__engines[$type];
}
return $engine;
} | [
"public",
"function",
"getEngine",
"(",
"$",
"type",
")",
"{",
"$",
"engine",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__engines",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"engine",
"=",
"$",
"this",
"->",
"__engines",
"[... | Get a registered engine identifier
@param string $type The file type
@return string|false The engine identifier | [
"Get",
"a",
"registered",
"engine",
"identifier"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/factory.php#L202-L211 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/factory.php | KTemplateEngineFactory.getFileTypes | public function getFileTypes()
{
$result = array();
if(is_array($this->__engines)) {
$result = array_keys($this->__engines);
}
return $result;
} | php | public function getFileTypes()
{
$result = array();
if(is_array($this->__engines)) {
$result = array_keys($this->__engines);
}
return $result;
} | [
"public",
"function",
"getFileTypes",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"__engines",
")",
")",
"{",
"$",
"result",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"__engines",
")",
... | Get a list of all the registered file types
@return array | [
"Get",
"a",
"list",
"of",
"all",
"the",
"registered",
"file",
"types"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/factory.php#L218-L226 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/factory.php | KTemplateEngineFactory.isRegistered | public function isRegistered($identifier)
{
if(strpos($identifier, '.') !== false )
{
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KTemplateEngineInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Engine: '.$identifier.' does not implement KTemplateEngineInterface'
);
}
$types = call_user_func(array($class, 'getFileTypes'));/*$class::getFileTypes();*/
}
else $types = (array) $identifier;
$result = in_array($types, $this->getFileTypes());
return $result;
} | php | public function isRegistered($identifier)
{
if(strpos($identifier, '.') !== false )
{
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KTemplateEngineInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Engine: '.$identifier.' does not implement KTemplateEngineInterface'
);
}
$types = call_user_func(array($class, 'getFileTypes'));/*$class::getFileTypes();*/
}
else $types = (array) $identifier;
$result = in_array($types, $this->getFileTypes());
return $result;
} | [
"public",
"function",
"isRegistered",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"identifier",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"identifier",
")",
";"... | Check if the engine is registered
@param string $identifier A engine object identifier string or a file type
@throws UnexpectedValueException
@return bool TRUE if the engine is a registered, FALSE otherwise. | [
"Check",
"if",
"the",
"engine",
"is",
"registered"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/factory.php#L235-L255 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/paginator/paginator.php | KModelPaginator.set | public function set($name, $value)
{
parent::set($name, $value);
//Only calculate the limit and offset if we have a total
if($this->total)
{
$this->limit = (int) max($this->limit, 1);
$this->offset = (int) max($this->offset, 0);
if($this->limit > $this->total) {
$this->offset = 0;
}
if(!$this->limit)
{
$this->offset = 0;
$this->limit = $this->total;
}
$this->count = (int) ceil($this->total / $this->limit);
if($this->offset > $this->total) {
$this->offset = ($this->count-1) * $this->limit;
}
$this->current = (int) floor($this->offset / $this->limit) + 1;
}
} | php | public function set($name, $value)
{
parent::set($name, $value);
//Only calculate the limit and offset if we have a total
if($this->total)
{
$this->limit = (int) max($this->limit, 1);
$this->offset = (int) max($this->offset, 0);
if($this->limit > $this->total) {
$this->offset = 0;
}
if(!$this->limit)
{
$this->offset = 0;
$this->limit = $this->total;
}
$this->count = (int) ceil($this->total / $this->limit);
if($this->offset > $this->total) {
$this->offset = ($this->count-1) * $this->limit;
}
$this->current = (int) floor($this->offset / $this->limit) + 1;
}
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"parent",
"::",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"//Only calculate the limit and offset if we have a total",
"if",
"(",
"$",
"this",
"->",
"total",
")",
"{",
... | Set a configuration element
@param string
@param mixed
@return void | [
"Set",
"a",
"configuration",
"element"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/paginator/paginator.php#L35-L63 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/paginator/paginator.php | KModelPaginator.get | public function get($name, $default = null)
{
if($name == 'pages' && !isset($this->pages)) {
$this->pages = $this->_pages();
}
return parent::get($name);
} | php | public function get($name, $default = null)
{
if($name == 'pages' && !isset($this->pages)) {
$this->pages = $this->_pages();
}
return parent::get($name);
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"==",
"'pages'",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"pages",
")",
")",
"{",
"$",
"this",
"->",
"pages",
"=",
"$",
"this"... | Implements lazy loading of the pages config property.
@param string
@return mixed | [
"Implements",
"lazy",
"loading",
"of",
"the",
"pages",
"config",
"property",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/paginator/paginator.php#L71-L78 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/permission/abstract.php | ComKoowaControllerPermissionAbstract.canAdmin | public function canAdmin()
{
$component = $this->getIdentifier()->package;
return $this->getObject('user')->authorise('core.admin', 'com_'.$component) === true;
} | php | public function canAdmin()
{
$component = $this->getIdentifier()->package;
return $this->getObject('user')->authorise('core.admin', 'com_'.$component) === true;
} | [
"public",
"function",
"canAdmin",
"(",
")",
"{",
"$",
"component",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"package",
";",
"return",
"$",
"this",
"->",
"getObject",
"(",
"'user'",
")",
"->",
"authorise",
"(",
"'core.admin'",
",",
"'com_'... | Check if user can perform administrative tasks such as changing configuration options
@return boolean Can return both true or false. | [
"Check",
"if",
"user",
"can",
"perform",
"administrative",
"tasks",
"such",
"as",
"changing",
"configuration",
"options"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/permission/abstract.php#L53-L58 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/permission/abstract.php | ComKoowaControllerPermissionAbstract.canManage | public function canManage()
{
$component = $this->getIdentifier()->package;
return $this->getObject('user')->authorise('core.manage', 'com_'.$component) === true;
} | php | public function canManage()
{
$component = $this->getIdentifier()->package;
return $this->getObject('user')->authorise('core.manage', 'com_'.$component) === true;
} | [
"public",
"function",
"canManage",
"(",
")",
"{",
"$",
"component",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"package",
";",
"return",
"$",
"this",
"->",
"getObject",
"(",
"'user'",
")",
"->",
"authorise",
"(",
"'core.manage'",
",",
"'com... | Check if user can can access a component in the administrator backend
@return boolean Can return both true or false. | [
"Check",
"if",
"user",
"can",
"can",
"access",
"a",
"component",
"in",
"the",
"administrator",
"backend"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/permission/abstract.php#L65-L70 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/filter/version.php | ComKoowaTemplateFilterVersion._getVersion | protected function _getVersion($component)
{
if (!isset(self::$_versions[$component]))
{
try
{
if ($component === 'koowa') {
$version = Koowa::VERSION;
}
else $version = $this->getObject('com://admin/' . $component.'.version')->getVersion();
}
catch (Exception $e) {
$version = null;
}
self::$_versions[$component] = $version;
}
return self::$_versions[$component];
} | php | protected function _getVersion($component)
{
if (!isset(self::$_versions[$component]))
{
try
{
if ($component === 'koowa') {
$version = Koowa::VERSION;
}
else $version = $this->getObject('com://admin/' . $component.'.version')->getVersion();
}
catch (Exception $e) {
$version = null;
}
self::$_versions[$component] = $version;
}
return self::$_versions[$component];
} | [
"protected",
"function",
"_getVersion",
"(",
"$",
"component",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_versions",
"[",
"$",
"component",
"]",
")",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"component",
"===",
"'koowa'",
")",
"{",
"... | Returns the version information of a component
@param $component
@return string|null | [
"Returns",
"the",
"version",
"information",
"of",
"a",
"component"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/filter/version.php#L51-L70 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/filter/version.php | ComKoowaTemplateFilterVersion.filter | public function filter(&$text)
{
$pattern = '~
<ktml:(?:script|style) # match ktml:script and ktml:style tags
[^(?:src=)]+ # anything before src=
src=" # match the link
((?:media://|assets://) # starts with media:// or assets://
(?:koowa/)? # may or may not be in koowa/ folder
(?:com_([^/]+)/|js/|css/|scss/) # either has package name (com_foo) or in framework
[^"]+)" # match the rest of the link
(.*)/>
~siUx';
// Hold a list of already processed URLs
$processed = array();
if(preg_match_all($pattern, $text, $matches, PREG_SET_ORDER))
{
foreach ($matches as $match)
{
$version = $this->_getVersion(!empty($match[2]) ? $match[2] : 'koowa');
if ($version)
{
$url = $match[1];
if (!in_array($url, $processed))
{
$processed[] = $url;
$version = substr(md5($version), 0, 8);
$suffix = strpos($url, '?') === false ? '?'.$version : '&'.$version;
$text = str_replace($url, $url.$suffix, $text);
}
}
}
}
} | php | public function filter(&$text)
{
$pattern = '~
<ktml:(?:script|style) # match ktml:script and ktml:style tags
[^(?:src=)]+ # anything before src=
src=" # match the link
((?:media://|assets://) # starts with media:// or assets://
(?:koowa/)? # may or may not be in koowa/ folder
(?:com_([^/]+)/|js/|css/|scss/) # either has package name (com_foo) or in framework
[^"]+)" # match the rest of the link
(.*)/>
~siUx';
// Hold a list of already processed URLs
$processed = array();
if(preg_match_all($pattern, $text, $matches, PREG_SET_ORDER))
{
foreach ($matches as $match)
{
$version = $this->_getVersion(!empty($match[2]) ? $match[2] : 'koowa');
if ($version)
{
$url = $match[1];
if (!in_array($url, $processed))
{
$processed[] = $url;
$version = substr(md5($version), 0, 8);
$suffix = strpos($url, '?') === false ? '?'.$version : '&'.$version;
$text = str_replace($url, $url.$suffix, $text);
}
}
}
}
} | [
"public",
"function",
"filter",
"(",
"&",
"$",
"text",
")",
"{",
"$",
"pattern",
"=",
"'~\n <ktml:(?:script|style) # match ktml:script and ktml:style tags\n [^(?:src=)]+ # anything before src=\n src=\" # match the link\n ... | Adds version suffixes to stylesheets and scripts
{@inheritdoc} | [
"Adds",
"version",
"suffixes",
"to",
"stylesheets",
"and",
"scripts"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/filter/version.php#L77-L116 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/response/response.php | KControllerResponse.setRedirect | public function setRedirect($location, $message = '', $type = self::FLASH_SUCCESS)
{
if (!empty($location))
{
if (!is_string($location) && !(is_object($location) && method_exists($location, '__toString')))
{
throw new UnexpectedValueException(
'The Response location must be a string or object implementing __toString(), "'.gettype($location).'" given.'
);
}
}
else throw new InvalidArgumentException('Cannot redirect to an empty URL.');
//Add the message
if(!empty($message)) {
$this->addMessage($message, $type);
}
//Force the status code to 303 if no redirect status code is set.
if(!$this->isRedirect()) {
$this->setStatus(self::SEE_OTHER);
}
//Set the location header.
$this->_headers->set('Location', (string) $location);
return $this;
} | php | public function setRedirect($location, $message = '', $type = self::FLASH_SUCCESS)
{
if (!empty($location))
{
if (!is_string($location) && !(is_object($location) && method_exists($location, '__toString')))
{
throw new UnexpectedValueException(
'The Response location must be a string or object implementing __toString(), "'.gettype($location).'" given.'
);
}
}
else throw new InvalidArgumentException('Cannot redirect to an empty URL.');
//Add the message
if(!empty($message)) {
$this->addMessage($message, $type);
}
//Force the status code to 303 if no redirect status code is set.
if(!$this->isRedirect()) {
$this->setStatus(self::SEE_OTHER);
}
//Set the location header.
$this->_headers->set('Location', (string) $location);
return $this;
} | [
"public",
"function",
"setRedirect",
"(",
"$",
"location",
",",
"$",
"message",
"=",
"''",
",",
"$",
"type",
"=",
"self",
"::",
"FLASH_SUCCESS",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"location",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(... | Sets a redirect
Redirect to a URL externally. Method performs a 303 (see other) redirect if no other redirect status code is set
in the response. The flash message is a self-expiring messages that will only live for exactly one request before
being purged.
@see http://tools.ietf.org/html/rfc2616#section-10.3
@param string $location The URL to redirect to. The URL should be a full URL, with schema etc.,
but practically every browser redirects on paths only as well
@param string $message The flash message
@param string $type The flash message category type. Default is 'success'.
@throws InvalidArgumentException If the location is empty
@throws UnexpectedValueException If the location is not a string, or cannot be cast to a string
@return KControllerResponse | [
"Sets",
"a",
"redirect"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/response/response.php#L138-L165 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/response/response.php | KControllerResponse.getMessages | public function getMessages($flush = true)
{
$result = $this->_messages;
if($flush) {
$this->_messages = array();
}
return $result;
} | php | public function getMessages($flush = true)
{
$result = $this->_messages;
if($flush) {
$this->_messages = array();
}
return $result;
} | [
"public",
"function",
"getMessages",
"(",
"$",
"flush",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_messages",
";",
"if",
"(",
"$",
"flush",
")",
"{",
"$",
"this",
"->",
"_messages",
"=",
"array",
"(",
")",
";",
"}",
"return",
... | Get the response messages
@param boolean $flush If TRUE flush the messages. Default is TRUE.
@return array | [
"Get",
"the",
"response",
"messages"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/response/response.php#L213-L222 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/response/abstract.php | KDispatcherResponseAbstract.terminate | public function terminate()
{
//Cleanup and flush output to client
if (!function_exists('fastcgi_finish_request'))
{
if (PHP_SAPI !== 'cli')
{
for ($i = 0; $i < ob_get_level(); $i++) {
ob_end_flush();
}
flush();
}
}
else fastcgi_finish_request();
//Set the exit status based on the status code.
$status = 0;
if(!$this->isSuccess()) {
$status = (int) $this->getStatusCode();
}
exit($status);
} | php | public function terminate()
{
//Cleanup and flush output to client
if (!function_exists('fastcgi_finish_request'))
{
if (PHP_SAPI !== 'cli')
{
for ($i = 0; $i < ob_get_level(); $i++) {
ob_end_flush();
}
flush();
}
}
else fastcgi_finish_request();
//Set the exit status based on the status code.
$status = 0;
if(!$this->isSuccess()) {
$status = (int) $this->getStatusCode();
}
exit($status);
} | [
"public",
"function",
"terminate",
"(",
")",
"{",
"//Cleanup and flush output to client",
"if",
"(",
"!",
"function_exists",
"(",
"'fastcgi_finish_request'",
")",
")",
"{",
"if",
"(",
"PHP_SAPI",
"!==",
"'cli'",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",... | Flush the output buffer and terminate request
@return void | [
"Flush",
"the",
"output",
"buffer",
"and",
"terminate",
"request"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/response/abstract.php#L115-L138 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/response/abstract.php | KDispatcherResponseAbstract.getStream | public function getStream()
{
if(!isset($this->__stream))
{
$content = $this->getContent();
$factory = $this->getObject('filesystem.stream.factory');
if(!$this->getObject('filter.path')->validate($content))
{
$stream = $factory->createStream('koowa-buffer://memory', 'w+b');
$stream->write($content);
}
else $stream = $factory->createStream($content, 'rb');
$this->__stream = $stream;
}
return $this->__stream;
} | php | public function getStream()
{
if(!isset($this->__stream))
{
$content = $this->getContent();
$factory = $this->getObject('filesystem.stream.factory');
if(!$this->getObject('filter.path')->validate($content))
{
$stream = $factory->createStream('koowa-buffer://memory', 'w+b');
$stream->write($content);
}
else $stream = $factory->createStream($content, 'rb');
$this->__stream = $stream;
}
return $this->__stream;
} | [
"public",
"function",
"getStream",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"__stream",
")",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getContent",
"(",
")",
";",
"$",
"factory",
"=",
"$",
"this",
"->",
"getObject",
... | Get the response stream
The buffer://memory stream wrapper will be used when the response content is a string. If the response content
is of the form "scheme://..." a stream based on the scheme will be created.
See @link http://www.php.net/manual/en/wrappers.php for a list of default PHP stream protocols and wrappers.
@return KFilesystemStreamInterface | [
"Get",
"the",
"response",
"stream"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/response/abstract.php#L172-L190 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/response/abstract.php | KDispatcherResponseAbstract.attachTransport | public function attachTransport($transport, $config = array())
{
if (!($transport instanceof KDispatcherResponseTransportInterface)) {
$transport = $this->getTransport($transport, $config);
}
//Enqueue the transport handler in the command chain
$this->_queue->enqueue($transport, $transport->getPriority());
return $this;
} | php | public function attachTransport($transport, $config = array())
{
if (!($transport instanceof KDispatcherResponseTransportInterface)) {
$transport = $this->getTransport($transport, $config);
}
//Enqueue the transport handler in the command chain
$this->_queue->enqueue($transport, $transport->getPriority());
return $this;
} | [
"public",
"function",
"attachTransport",
"(",
"$",
"transport",
",",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"transport",
"instanceof",
"KDispatcherResponseTransportInterface",
")",
")",
"{",
"$",
"transport",
"=",
"$",
"... | Attach a transport handler
@param mixed $transport An object that implements ObjectInterface, ObjectIdentifier object
or valid identifier string
@param array $config An optional associative array of configuration settings
@return KDispatcherResponseAbstract | [
"Attach",
"a",
"transport",
"handler"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/response/abstract.php#L258-L268 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/response/abstract.php | KDispatcherResponseAbstract.isStreamable | public function isStreamable()
{
$request = $this->getRequest();
$isPDF = $this->getContentType() == 'application/pdf';
$isInline = !$request->isDownload();
$isSeekable = $this->getStream()->isSeekable();
if(!($isPDF && $isInline) && $isSeekable)
{
if($this->_headers->get('Transfer-Encoding') == 'chunked') {
return true;
}
if($this->_headers->get('Accept-Ranges', null) !== 'none') {
return true;
};
}
return false;
} | php | public function isStreamable()
{
$request = $this->getRequest();
$isPDF = $this->getContentType() == 'application/pdf';
$isInline = !$request->isDownload();
$isSeekable = $this->getStream()->isSeekable();
if(!($isPDF && $isInline) && $isSeekable)
{
if($this->_headers->get('Transfer-Encoding') == 'chunked') {
return true;
}
if($this->_headers->get('Accept-Ranges', null) !== 'none') {
return true;
};
}
return false;
} | [
"public",
"function",
"isStreamable",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"isPDF",
"=",
"$",
"this",
"->",
"getContentType",
"(",
")",
"==",
"'application/pdf'",
";",
"$",
"isInline",
"=",
"!",
"$",
... | Check if the response is streamable
A response is considered streamable, if the Accept-Ranges does not have value 'none' or if the
Transfer-Encoding is set the chunked.
If the request is made for a PDF file that is not attached the response will not be streamable.
The build in PDF viewer in IE and Chrome cannot handle inline rendering of PDF files when the
file is streamed.
@link http://tools.ietf.org/html/rfc2616#section-14.5
@return bool | [
"Check",
"if",
"the",
"response",
"is",
"streamable"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/response/abstract.php#L283-L303 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/response/abstract.php | KDispatcherResponseAbstract.isAttachable | public function isAttachable()
{
$request = $this->getRequest();
if(!preg_match('#(iPad|iPod|iPhone)#', $request->getAgent()))
{
if($request->isDownload() || $this->getContentType() == 'application/octet-stream') {
return true;
}
}
if((preg_match('#(Edge)#', $request->getAgent())) )
{
if($this->getContentType() == 'application/pdf') {
return true;
}
}
return false;
} | php | public function isAttachable()
{
$request = $this->getRequest();
if(!preg_match('#(iPad|iPod|iPhone)#', $request->getAgent()))
{
if($request->isDownload() || $this->getContentType() == 'application/octet-stream') {
return true;
}
}
if((preg_match('#(Edge)#', $request->getAgent())) )
{
if($this->getContentType() == 'application/pdf') {
return true;
}
}
return false;
} | [
"public",
"function",
"isAttachable",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'#(iPad|iPod|iPhone)#'",
",",
"$",
"request",
"->",
"getAgent",
"(",
")",
")",
")",
"{",
"if",... | Check if the response is attachable
A response is attachable if the request is downloadable or the content type is 'application/octet-stream'
If the request is made by an Ipad, iPod or iPhone user agent the response will never be attachable. iOS browsers
cannot handle files send as disposition : attachment.
If the request is made by MS Edge for a pdf file always force the response to be attachable to prevent 'Couldn't
open PDF file' errors in Edge.
@return bool | [
"Check",
"if",
"the",
"response",
"is",
"attachable"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/response/abstract.php#L318-L337 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/toolbar/actionbar.php | KControllerToolbarActionbar._afterBrowse | protected function _afterBrowse(KControllerContextInterface $context)
{
$controller = $this->getController();
if($controller->canAdd()) {
$this->addCommand('new');
}
if($controller->canDelete()) {
$this->addCommand('delete');
}
} | php | protected function _afterBrowse(KControllerContextInterface $context)
{
$controller = $this->getController();
if($controller->canAdd()) {
$this->addCommand('new');
}
if($controller->canDelete()) {
$this->addCommand('delete');
}
} | [
"protected",
"function",
"_afterBrowse",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"$",
"controller",
"=",
"$",
"this",
"->",
"getController",
"(",
")",
";",
"if",
"(",
"$",
"controller",
"->",
"canAdd",
"(",
")",
")",
"{",
"$",
"this",... | Add default action commands
.
@param KControllerContextInterface $context A command context object | [
"Add",
"default",
"action",
"commands",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/toolbar/actionbar.php#L86-L97 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/toolbar/actionbar.php | KControllerToolbarActionbar._commandDelete | protected function _commandDelete(KControllerToolbarCommand $command)
{
$translator = $this->getObject('translator');
$command->append(array(
'attribs' => array(
'data-action' => 'delete',
'data-prompt' => $translator->translate('Deleted items will be lost forever. Would you like to continue?')
)
));
$command->icon = 'k-icon-trash';
} | php | protected function _commandDelete(KControllerToolbarCommand $command)
{
$translator = $this->getObject('translator');
$command->append(array(
'attribs' => array(
'data-action' => 'delete',
'data-prompt' => $translator->translate('Deleted items will be lost forever. Would you like to continue?')
)
));
$command->icon = 'k-icon-trash';
} | [
"protected",
"function",
"_commandDelete",
"(",
"KControllerToolbarCommand",
"$",
"command",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'translator'",
")",
";",
"$",
"command",
"->",
"append",
"(",
"array",
"(",
"'attribs'",
"=>",
... | Delete toolbar command
@param KControllerToolbarCommand $command A KControllerToolbarCommand object
@return void | [
"Delete",
"toolbar",
"command"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/toolbar/actionbar.php#L122-L133 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/toolbar/actionbar.php | KControllerToolbarActionbar._commandExport | protected function _commandExport(KControllerToolbarCommand $command)
{
//Get the states
$states = $this->getController()->getModel()->getState()->getValues();
unset($states['limit']);
unset($states['offset']);
$states['format'] = 'csv';
//Get the query options
$query = http_build_query($states, '', '&');
$option = $this->getIdentifier()->package;
$view = $this->getController()->getView()->getName();
$command->href = 'option=com_'.$option.'&view='.$view.'&'.$query;
} | php | protected function _commandExport(KControllerToolbarCommand $command)
{
//Get the states
$states = $this->getController()->getModel()->getState()->getValues();
unset($states['limit']);
unset($states['offset']);
$states['format'] = 'csv';
//Get the query options
$query = http_build_query($states, '', '&');
$option = $this->getIdentifier()->package;
$view = $this->getController()->getView()->getName();
$command->href = 'option=com_'.$option.'&view='.$view.'&'.$query;
} | [
"protected",
"function",
"_commandExport",
"(",
"KControllerToolbarCommand",
"$",
"command",
")",
"{",
"//Get the states",
"$",
"states",
"=",
"$",
"this",
"->",
"getController",
"(",
")",
"->",
"getModel",
"(",
")",
"->",
"getState",
"(",
")",
"->",
"getValue... | Export Toolbar Command
@param KControllerToolbarCommand $command A KControllerToolbarCommand object
@return void | [
"Export",
"Toolbar",
"Command"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/toolbar/actionbar.php#L225-L241 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/toolbar/actionbar.php | KControllerToolbarActionbar._commandDialog | protected function _commandDialog(KControllerToolbarCommand $command)
{
$command->append(array(
'href' => ''
))->append(array(
'attribs' => array(
'href' => $command->href,
'data-k-modal' => array('type' => 'iframe')
)
));
$command->attribs['data-k-modal'] = json_encode($command->attribs['data-k-modal']);
} | php | protected function _commandDialog(KControllerToolbarCommand $command)
{
$command->append(array(
'href' => ''
))->append(array(
'attribs' => array(
'href' => $command->href,
'data-k-modal' => array('type' => 'iframe')
)
));
$command->attribs['data-k-modal'] = json_encode($command->attribs['data-k-modal']);
} | [
"protected",
"function",
"_commandDialog",
"(",
"KControllerToolbarCommand",
"$",
"command",
")",
"{",
"$",
"command",
"->",
"append",
"(",
"array",
"(",
"'href'",
"=>",
"''",
")",
")",
"->",
"append",
"(",
"array",
"(",
"'attribs'",
"=>",
"array",
"(",
"'... | Modal toolbar command
@param KControllerToolbarCommand $command A KControllerToolbarCommand object
@return void | [
"Modal",
"toolbar",
"command"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/toolbar/actionbar.php#L249-L261 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/abstract.php | KUserAbstract.get | public function get($identifier, $default = null)
{
$attributes = $this->getData()->attributes;
$result = $default;
if(isset($attributes[$identifier])) {
$result = $attributes[$identifier];
}
return $result;
} | php | public function get($identifier, $default = null)
{
$attributes = $this->getData()->attributes;
$result = $default;
if(isset($attributes[$identifier])) {
$result = $attributes[$identifier];
}
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"identifier",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
"->",
"attributes",
";",
"$",
"result",
"=",
"$",
"default",
";",
"if",
"(",
"isset",
"... | Get an user attribute
@param string $identifier Attribute identifier, eg .foo.bar
@param mixed $default Default value when the attribute doesn't exist
@return mixed The value | [
"Get",
"an",
"user",
"attribute"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/abstract.php#L226-L236 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/abstract.php | KUserAbstract.set | public function set($identifier, $value)
{
$attributes = $this->getData()->attributes;
$attributes[$identifier] = $value;
return $this;
} | php | public function set($identifier, $value)
{
$attributes = $this->getData()->attributes;
$attributes[$identifier] = $value;
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
"->",
"attributes",
";",
"$",
"attributes",
"[",
"$",
"identifier",
"]",
"=",
"$",
"value",
";",
"return... | Set an user attribute
@param mixed $identifier Attribute identifier, eg foo.bar
@param mixed $value Attribute value
@return KUserAbstract | [
"Set",
"an",
"user",
"attribute"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/abstract.php#L245-L251 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/abstract.php | KUserAbstract.has | public function has($identifier)
{
$attributes = $this->getData()->attributes;
if(isset($attributes[$identifier])) {
return true;
}
return false;
} | php | public function has($identifier)
{
$attributes = $this->getData()->attributes;
if(isset($attributes[$identifier])) {
return true;
}
return false;
} | [
"public",
"function",
"has",
"(",
"$",
"identifier",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
"->",
"attributes",
";",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"return",
... | Check if a user attribute exists
@param string $identifier Attribute identifier, eg foo.bar
@return boolean | [
"Check",
"if",
"a",
"user",
"attribute",
"exists"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/abstract.php#L259-L267 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/event/publisher/exception.php | KEventPublisherException.publishException | public function publishException(Exception $exception, $attributes = array(), $target = null)
{
//Make sure we have an event object
$event = new KEventException('onException', $attributes, $target);
$event->setException($exception);
parent::publishEvent($event);
} | php | public function publishException(Exception $exception, $attributes = array(), $target = null)
{
//Make sure we have an event object
$event = new KEventException('onException', $attributes, $target);
$event->setException($exception);
parent::publishEvent($event);
} | [
"public",
"function",
"publishException",
"(",
"Exception",
"$",
"exception",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"$",
"target",
"=",
"null",
")",
"{",
"//Make sure we have an event object",
"$",
"event",
"=",
"new",
"KEventException",
"(",
"'... | Publish an 'onException' event by calling all listeners that have registered to receive it.
@param Exception $exception The exception to be published.
@param array|Traversable $attributes An associative array or a Traversable object
@param mixed $target The event target
@return KEventException | [
"Publish",
"an",
"onException",
"event",
"by",
"calling",
"all",
"listeners",
"that",
"have",
"registered",
"to",
"receive",
"it",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/event/publisher/exception.php#L93-L100 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/event/publisher/exception.php | KEventPublisherException.setExceptionHandler | public function setExceptionHandler(KExceptionHandlerInterface $handler)
{
$this->__exception_handler = $handler;
//Re-enable the exception handler
if($this->isEnabled())
{
$this->disable();
$this->enable();
}
return $this;
} | php | public function setExceptionHandler(KExceptionHandlerInterface $handler)
{
$this->__exception_handler = $handler;
//Re-enable the exception handler
if($this->isEnabled())
{
$this->disable();
$this->enable();
}
return $this;
} | [
"public",
"function",
"setExceptionHandler",
"(",
"KExceptionHandlerInterface",
"$",
"handler",
")",
"{",
"$",
"this",
"->",
"__exception_handler",
"=",
"$",
"handler",
";",
"//Re-enable the exception handler",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
"(",
")",
... | Set the exception handler object
@param KExceptionHandlerInterface $handler An exception handler object
@return KEventPublisherException | [
"Set",
"the",
"exception",
"handler",
"object"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/event/publisher/exception.php#L131-L143 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/behavior/parameterizable.php | KDatabaseBehaviorParameterizable.getParameters | public function getParameters()
{
$result = false;
if($this->hasProperty($this->_column))
{
$handle = $this->getMixer()->getHandle();
if(!isset($this->_parameters[$handle]))
{
$type = (array) $this->getTable()->getColumn($this->_column)->filter;
$data = $this->getProperty($this->_column);
$config = $this->getObject('object.config.factory')->createFormat($type[0]);
if(!empty($data))
{
if (is_string($data)) {
$config->fromString(trim($data));
} else {
$config->append($data);
}
}
$this->_parameters[$handle] = $config;
}
$result = $this->_parameters[$handle];
}
return $result;
} | php | public function getParameters()
{
$result = false;
if($this->hasProperty($this->_column))
{
$handle = $this->getMixer()->getHandle();
if(!isset($this->_parameters[$handle]))
{
$type = (array) $this->getTable()->getColumn($this->_column)->filter;
$data = $this->getProperty($this->_column);
$config = $this->getObject('object.config.factory')->createFormat($type[0]);
if(!empty($data))
{
if (is_string($data)) {
$config->fromString(trim($data));
} else {
$config->append($data);
}
}
$this->_parameters[$handle] = $config;
}
$result = $this->_parameters[$handle];
}
return $result;
} | [
"public",
"function",
"getParameters",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"hasProperty",
"(",
"$",
"this",
"->",
"_column",
")",
")",
"{",
"$",
"handle",
"=",
"$",
"this",
"->",
"getMixer",
"(",
")",
"->"... | Get the parameters
By default requires a 'parameters' table column. Column can be configured using the 'column' config option.
@return KObjectConfigInterface | [
"Get",
"the",
"parameters"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/behavior/parameterizable.php#L68-L98 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/behavior/parameterizable.php | KDatabaseBehaviorParameterizable.setPropertyParameters | public function setPropertyParameters($value)
{
if(!empty($value))
{
if(!is_string($value)) {
$value = $this->getParameters()->merge($value)->toString();
}
}
return $value;
} | php | public function setPropertyParameters($value)
{
if(!empty($value))
{
if(!is_string($value)) {
$value = $this->getParameters()->merge($value)->toString();
}
}
return $value;
} | [
"public",
"function",
"setPropertyParameters",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getParamete... | Merge the parameters
@param $value | [
"Merge",
"the",
"parameters"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/behavior/parameterizable.php#L105-L115 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/config/yaml.php | KObjectConfigYaml.fromString | public function fromString($string, $object = true)
{
$data = array();
if ($decoder = $this->getDecoder())
{
$data = array();
if(!empty($string))
{
$data = call_user_func($decoder, $string);
if($data === false) {
throw new DomainException('Cannot parse YAML string');
}
}
}
else throw new RuntimeException("No Yaml decoder specified");
return $object ? $this->merge($data) : $data;
} | php | public function fromString($string, $object = true)
{
$data = array();
if ($decoder = $this->getDecoder())
{
$data = array();
if(!empty($string))
{
$data = call_user_func($decoder, $string);
if($data === false) {
throw new DomainException('Cannot parse YAML string');
}
}
}
else throw new RuntimeException("No Yaml decoder specified");
return $object ? $this->merge($data) : $data;
} | [
"public",
"function",
"fromString",
"(",
"$",
"string",
",",
"$",
"object",
"=",
"true",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"decoder",
"=",
"$",
"this",
"->",
"getDecoder",
"(",
")",
")",
"{",
"$",
"data",
"=",
... | Read from a YAML string and create a config object
@param string $string
@param bool $object If TRUE return a ConfigObject, if FALSE return an array. Default TRUE.
@throws DomainException
@throws RuntimeException
@return KObjectConfigYaml|array | [
"Read",
"from",
"a",
"YAML",
"string",
"and",
"create",
"a",
"config",
"object"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/config/yaml.php#L128-L148 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/config/yaml.php | KObjectConfigYaml.toString | public function toString()
{
$result = false;
if ($encoder = $this->getEncoder())
{
$data = $this->toArray();
$result = call_user_func($encoder, $data);
}
else throw new RuntimeException("No Yaml encoder specified");
return $result;
} | php | public function toString()
{
$result = false;
if ($encoder = $this->getEncoder())
{
$data = $this->toArray();
$result = call_user_func($encoder, $data);
}
else throw new RuntimeException("No Yaml encoder specified");
return $result;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"encoder",
"=",
"$",
"this",
"->",
"getEncoder",
"(",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"toArray",
"(",
")",
";",
"$",
"result",
... | Write a config object to a YAML string.
@return string|false Returns a YAML encoded string on success. False on failure. | [
"Write",
"a",
"config",
"object",
"to",
"a",
"YAML",
"string",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/config/yaml.php#L155-L167 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/module/mod_koowa/template/filter/chrome.php | ModKoowaTemplateFilterChrome.filter | public function filter(&$text)
{
$data = (object) $this->getTemplate()->getData();
if (isset($data->styles))
{
foreach($data->styles as $style)
{
$method = 'modChrome_'.$style;
// Apply chrome and render module
if (function_exists($method))
{
$data->module->style = implode(' ', $data->styles);
$data->module->content = $text;
ob_start();
$method($data->module, $data->module->params, $data->attribs);
$data->module->content = ob_get_contents();
ob_end_clean();
}
$text = $data->module->content;
}
}
return $this;
} | php | public function filter(&$text)
{
$data = (object) $this->getTemplate()->getData();
if (isset($data->styles))
{
foreach($data->styles as $style)
{
$method = 'modChrome_'.$style;
// Apply chrome and render module
if (function_exists($method))
{
$data->module->style = implode(' ', $data->styles);
$data->module->content = $text;
ob_start();
$method($data->module, $data->module->params, $data->attribs);
$data->module->content = ob_get_contents();
ob_end_clean();
}
$text = $data->module->content;
}
}
return $this;
} | [
"public",
"function",
"filter",
"(",
"&",
"$",
"text",
")",
"{",
"$",
"data",
"=",
"(",
"object",
")",
"$",
"this",
"->",
"getTemplate",
"(",
")",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"->",
"styles",
")",
")",
"... | Render the module chrome
@param string $text Block of text to parse
@return $this | [
"Render",
"the",
"module",
"chrome"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/module/mod_koowa/template/filter/chrome.php#L59-L86 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/dispatcher/permission/abstract.php | ComKoowaDispatcherPermissionAbstract.canDispatch | public function canDispatch()
{
if(JFactory::getApplication()->isAdmin())
{
if(!$this->canManage())
{
JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
return false;
}
}
return parent::canDispatch();
} | php | public function canDispatch()
{
if(JFactory::getApplication()->isAdmin())
{
if(!$this->canManage())
{
JFactory::getApplication()->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
return false;
}
}
return parent::canDispatch();
} | [
"public",
"function",
"canDispatch",
"(",
")",
"{",
"if",
"(",
"JFactory",
"::",
"getApplication",
"(",
")",
"->",
"isAdmin",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"canManage",
"(",
")",
")",
"{",
"JFactory",
"::",
"getApplication",
... | Permission handler for dispatch actions
@return boolean Return TRUE if action is permitted. FALSE otherwise. | [
"Permission",
"handler",
"for",
"dispatch",
"actions"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/permission/abstract.php#L23-L35 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/filter/form.php | KTemplateFilterForm._addMetatag | protected function _addMetatag(&$text)
{
if (!empty($this->_token_value))
{
$string = '<meta content="'.$this->_token_value.'" name="csrf-token" />';
if (stripos($text, $string) === false) {
$text = $string.$text;
}
}
return $this;
} | php | protected function _addMetatag(&$text)
{
if (!empty($this->_token_value))
{
$string = '<meta content="'.$this->_token_value.'" name="csrf-token" />';
if (stripos($text, $string) === false) {
$text = $string.$text;
}
}
return $this;
} | [
"protected",
"function",
"_addMetatag",
"(",
"&",
"$",
"text",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_token_value",
")",
")",
"{",
"$",
"string",
"=",
"'<meta content=\"'",
".",
"$",
"this",
"->",
"_token_value",
".",
"'\" name=\"cs... | Adds the CSRF token to a meta tag to be used in JavaScript
@param string $text Template text
@return $this | [
"Adds",
"the",
"CSRF",
"token",
"to",
"a",
"meta",
"tag",
"to",
"be",
"used",
"in",
"JavaScript"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/filter/form.php#L91-L102 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/filter/form.php | KTemplateFilterForm._addToken | protected function _addToken(&$text)
{
if (!empty($this->_token_value))
{
// POST: Add token
$text = preg_replace('#(<\s*form[^>]+method="post"[^>]*>)#si',
'\1'.PHP_EOL.'<input type="hidden" name="'.$this->_token_name.'" value="'.$this->_token_value.'" />',
$text
);
// GET: Add token to .k-js-grid-controller forms
$text = preg_replace('#(<\s*form[^>]+class=(?:\'|")[^\'"]*?k-js-grid-controller.*?(?:\'|")[^>]*)>#si',
'\1 data-token-name="'.$this->_token_name.'" data-token-value="'.$this->_token_value.'">',
$text
);
}
return $this;
} | php | protected function _addToken(&$text)
{
if (!empty($this->_token_value))
{
// POST: Add token
$text = preg_replace('#(<\s*form[^>]+method="post"[^>]*>)#si',
'\1'.PHP_EOL.'<input type="hidden" name="'.$this->_token_name.'" value="'.$this->_token_value.'" />',
$text
);
// GET: Add token to .k-js-grid-controller forms
$text = preg_replace('#(<\s*form[^>]+class=(?:\'|")[^\'"]*?k-js-grid-controller.*?(?:\'|")[^>]*)>#si',
'\1 data-token-name="'.$this->_token_name.'" data-token-value="'.$this->_token_value.'">',
$text
);
}
return $this;
} | [
"protected",
"function",
"_addToken",
"(",
"&",
"$",
"text",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_token_value",
")",
")",
"{",
"// POST: Add token",
"$",
"text",
"=",
"preg_replace",
"(",
"'#(<\\s*form[^>]+method=\"post\"[^>]*>)#si'",
"... | Add the token to the form
@param string $text Template text
@return $this | [
"Add",
"the",
"token",
"to",
"the",
"form"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/filter/form.php#L133-L151 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/filter/form.php | KTemplateFilterForm._addQueryParameters | protected function _addQueryParameters(&$text)
{
$matches = array();
if (preg_match_all('#(<\s*form[^>]+action="[^"]*?\?(.*?)"[^>]*>)(.*?)</form>#si', $text, $matches))
{
foreach ($matches[1] as $key => $match)
{
// Only deal with GET forms.
if (strpos($match, 'method="get"') !== false)
{
$query = $matches[2][$key];
parse_str(str_replace('&', '&', $query), $query);
$input = '';
foreach ($query as $name => $value)
{
if (is_array($value)) {
$name = $name . '[]';
}
if (strpos($matches[3][$key], 'name="' . $name . '"') !== false) {
continue;
}
$name = $this->getTemplate()->escape($name);
if (is_array($value))
{
foreach ($value as $k => $v)
{
if (!is_scalar($v) || !is_numeric($k)) {
continue;
}
$v = $this->getTemplate()->escape($v);
$input .= PHP_EOL.'<input type="hidden" name="'.$name.'" value="'.$v.'" />';
}
}
else {
$value = $this->getTemplate()->escape($value);
$input .= PHP_EOL.'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}
}
$text = str_replace($matches[3][$key], $input.$matches[3][$key], $text);
}
}
}
return $this;
} | php | protected function _addQueryParameters(&$text)
{
$matches = array();
if (preg_match_all('#(<\s*form[^>]+action="[^"]*?\?(.*?)"[^>]*>)(.*?)</form>#si', $text, $matches))
{
foreach ($matches[1] as $key => $match)
{
// Only deal with GET forms.
if (strpos($match, 'method="get"') !== false)
{
$query = $matches[2][$key];
parse_str(str_replace('&', '&', $query), $query);
$input = '';
foreach ($query as $name => $value)
{
if (is_array($value)) {
$name = $name . '[]';
}
if (strpos($matches[3][$key], 'name="' . $name . '"') !== false) {
continue;
}
$name = $this->getTemplate()->escape($name);
if (is_array($value))
{
foreach ($value as $k => $v)
{
if (!is_scalar($v) || !is_numeric($k)) {
continue;
}
$v = $this->getTemplate()->escape($v);
$input .= PHP_EOL.'<input type="hidden" name="'.$name.'" value="'.$v.'" />';
}
}
else {
$value = $this->getTemplate()->escape($value);
$input .= PHP_EOL.'<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}
}
$text = str_replace($matches[3][$key], $input.$matches[3][$key], $text);
}
}
}
return $this;
} | [
"protected",
"function",
"_addQueryParameters",
"(",
"&",
"$",
"text",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"'#(<\\s*form[^>]+action=\"[^\"]*?\\?(.*?)\"[^>]*>)(.*?)</form>#si'",
",",
"$",
"text",
",",
"$",
"match... | Add query parameters as hidden fields to the GET forms
@param string $text Template text
@return $this | [
"Add",
"query",
"parameters",
"as",
"hidden",
"fields",
"to",
"the",
"GET",
"forms"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/filter/form.php#L159-L214 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/view/abstract.php | KViewAbstract.setContent | public function setContent($content)
{
if (!is_null($content) && !is_string($content) && !is_callable(array($content, '__toString')))
{
throw new UnexpectedValueException(
'The view content must be a string or object implementing __toString(), "'.gettype($content).'" given.'
);
}
$this->_content = $content;
return $this;
} | php | public function setContent($content)
{
if (!is_null($content) && !is_string($content) && !is_callable(array($content, '__toString')))
{
throw new UnexpectedValueException(
'The view content must be a string or object implementing __toString(), "'.gettype($content).'" given.'
);
}
$this->_content = $content;
return $this;
} | [
"public",
"function",
"setContent",
"(",
"$",
"content",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"content",
")",
"&&",
"!",
"is_string",
"(",
"$",
"content",
")",
"&&",
"!",
"is_callable",
"(",
"array",
"(",
"$",
"content",
",",
"'__toString'",
... | Get the contents
@param object|string $content The contents of the view
@throws \UnexpectedValueException If the content is not a string are cannot be casted to a string.
@return KViewAbstract | [
"Get",
"the",
"contents"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/view/abstract.php#L291-L302 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/dispatcher/router/route.php | ComKoowaDispatcherRouterRoute._getRoute | protected function _getRoute($query, $escape)
{
$current = JFactory::getApplication();
if ($current->getName() !== $this->getApplication())
{
$application = JApplicationCms::getInstance($this->getConfig()->application);
// Force route application during route build.
JFactory::$application = $application;
// Get the router.
$router = $application->getRouter();
$url = 'index.php?'.http_build_query($query, '', '&');
// Build route.
$route = $router->build($url);
// Revert application change.
JFactory::$application = $current;
$route = $route->toString(array('path', 'query', 'fragment'));
// Check if we need to remove "administrator" from the path
if ($current->isAdmin() && $application->getName() == 'site')
{
$base = JUri::base('true');
$replacement = explode('/', $base);
array_pop($replacement);
$replacement = implode('/', $replacement);
$base = str_replace('/', '\/', $base);
$route = preg_replace('/^' . $base . '/', $replacement, $route);
}
// Replace spaces.
$route = preg_replace('/\s/u', '%20', $route);
if ($escape) {
$route = htmlspecialchars($route, ENT_COMPAT, 'UTF-8');
}
}
else $route = JRoute::_('index.php?'.http_build_query($query, '', '&'), $escape);
return $route;
} | php | protected function _getRoute($query, $escape)
{
$current = JFactory::getApplication();
if ($current->getName() !== $this->getApplication())
{
$application = JApplicationCms::getInstance($this->getConfig()->application);
// Force route application during route build.
JFactory::$application = $application;
// Get the router.
$router = $application->getRouter();
$url = 'index.php?'.http_build_query($query, '', '&');
// Build route.
$route = $router->build($url);
// Revert application change.
JFactory::$application = $current;
$route = $route->toString(array('path', 'query', 'fragment'));
// Check if we need to remove "administrator" from the path
if ($current->isAdmin() && $application->getName() == 'site')
{
$base = JUri::base('true');
$replacement = explode('/', $base);
array_pop($replacement);
$replacement = implode('/', $replacement);
$base = str_replace('/', '\/', $base);
$route = preg_replace('/^' . $base . '/', $replacement, $route);
}
// Replace spaces.
$route = preg_replace('/\s/u', '%20', $route);
if ($escape) {
$route = htmlspecialchars($route, ENT_COMPAT, 'UTF-8');
}
}
else $route = JRoute::_('index.php?'.http_build_query($query, '', '&'), $escape);
return $route;
} | [
"protected",
"function",
"_getRoute",
"(",
"$",
"query",
",",
"$",
"escape",
")",
"{",
"$",
"current",
"=",
"JFactory",
"::",
"getApplication",
"(",
")",
";",
"if",
"(",
"$",
"current",
"->",
"getName",
"(",
")",
"!==",
"$",
"this",
"->",
"getApplicati... | Route getter.
@param array $query An array containing query variables.
@param boolean|null $escape If TRUE escapes '&' to '&' for xml compliance. If NULL use the default.
@return string The route. | [
"Route",
"getter",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/router/route.php#L110-L160 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/translator/catalogue/abstract.php | KTranslatorCatalogueAbstract.add | public function add(array $translations, $override = false)
{
if ($override) {
$this->_data = array_merge($this->_data, $translations);
} else {
$this->_data = array_merge($translations, $this->_data);
}
return true;
} | php | public function add(array $translations, $override = false)
{
if ($override) {
$this->_data = array_merge($this->_data, $translations);
} else {
$this->_data = array_merge($translations, $this->_data);
}
return true;
} | [
"public",
"function",
"add",
"(",
"array",
"$",
"translations",
",",
"$",
"override",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"override",
")",
"{",
"$",
"this",
"->",
"_data",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_data",
",",
"$",
"translatio... | Add translations to the catalogue.
@param array $translations Associative array containing translations.
@param bool $override If TRUE override existing translations. Default is FALSE.
@return bool True on success, false otherwise. | [
"Add",
"translations",
"to",
"the",
"catalogue",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/translator/catalogue/abstract.php#L72-L81 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/authenticator/jwt.php | KDispatcherAuthenticatorJwt.getAuthToken | public function getAuthToken()
{
if(!isset($this->__token))
{
$token = false;
$request = $this->getObject('request');
if($request->headers->has('Authorization'))
{
$header = $request->headers->get('Authorization');
if(stripos($header, 'jwt') === 0) {
$token = substr($header , 4);
}
}
if($request->isSafe())
{
if($request->query->has('auth_token')) {
$token = $request->query->get('auth_token', 'url');
}
}
else
{
if($request->data->has('auth_token')) {
$token = $request->data->get('auth_token', 'url');
}
}
if($token) {
$token = $this->getObject('lib:http.token')->fromString($token);
}
$this->__token = $token;
}
return $this->__token;
} | php | public function getAuthToken()
{
if(!isset($this->__token))
{
$token = false;
$request = $this->getObject('request');
if($request->headers->has('Authorization'))
{
$header = $request->headers->get('Authorization');
if(stripos($header, 'jwt') === 0) {
$token = substr($header , 4);
}
}
if($request->isSafe())
{
if($request->query->has('auth_token')) {
$token = $request->query->get('auth_token', 'url');
}
}
else
{
if($request->data->has('auth_token')) {
$token = $request->data->get('auth_token', 'url');
}
}
if($token) {
$token = $this->getObject('lib:http.token')->fromString($token);
}
$this->__token = $token;
}
return $this->__token;
} | [
"public",
"function",
"getAuthToken",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"__token",
")",
")",
"{",
"$",
"token",
"=",
"false",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'request'",
")",
";",
"if",
... | Return the JWT authorisation token
@return KHttpToken The authorisation token or NULL if no token could be found | [
"Return",
"the",
"JWT",
"authorisation",
"token"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/authenticator/jwt.php#L107-L144 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/string/inflector/inflector.php | KStringInflector.pluralize | public static function pluralize($word)
{
//Get the cached noun of it exists
if(isset(self::$_cache['pluralized'][$word])) {
return self::$_cache['pluralized'][$word];
}
//Create the plural noun
if (in_array($word, self::$_rules['countable'])) {
self::$_cache['pluralized'][$word] = $word;
return $word;
}
foreach (self::$_rules['pluralization'] as $regexp => $replacement)
{
$matches = null;
$plural = preg_replace($regexp, $replacement, $word, -1, $matches);
if ($matches > 0) {
self::$_cache['pluralized'][$word] = $plural;
return $plural;
}
}
return $word;
} | php | public static function pluralize($word)
{
//Get the cached noun of it exists
if(isset(self::$_cache['pluralized'][$word])) {
return self::$_cache['pluralized'][$word];
}
//Create the plural noun
if (in_array($word, self::$_rules['countable'])) {
self::$_cache['pluralized'][$word] = $word;
return $word;
}
foreach (self::$_rules['pluralization'] as $regexp => $replacement)
{
$matches = null;
$plural = preg_replace($regexp, $replacement, $word, -1, $matches);
if ($matches > 0) {
self::$_cache['pluralized'][$word] = $plural;
return $plural;
}
}
return $word;
} | [
"public",
"static",
"function",
"pluralize",
"(",
"$",
"word",
")",
"{",
"//Get the cached noun of it exists",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"_cache",
"[",
"'pluralized'",
"]",
"[",
"$",
"word",
"]",
")",
")",
"{",
"return",
"self",
"::",
"... | Singular English word to plural.
@param string $word Word to pluralize
@return string Plural noun | [
"Singular",
"English",
"word",
"to",
"plural",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/string/inflector/inflector.php#L152-L176 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/queue.php | KObjectQueue.contains | public function contains(KObjectHandlable $object)
{
$result = false;
if($handle = $object->getHandle()) {
$result = $this->__object_list->offsetExists($handle);
}
return $result;
} | php | public function contains(KObjectHandlable $object)
{
$result = false;
if($handle = $object->getHandle()) {
$result = $this->__object_list->offsetExists($handle);
}
return $result;
} | [
"public",
"function",
"contains",
"(",
"KObjectHandlable",
"$",
"object",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"handle",
"=",
"$",
"object",
"->",
"getHandle",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"__objec... | Check if the queue contains a given object
@param KObjectHandlable $object
@return bool | [
"Check",
"if",
"the",
"queue",
"contains",
"a",
"given",
"object"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/queue.php#L193-L202 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/query/abstract.php | KDatabaseQueryAbstract.bind | public function bind(array $params)
{
foreach ($params as $key => $value) {
$this->getParameters()->set($key, $value);
}
return $this;
} | php | public function bind(array $params)
{
foreach ($params as $key => $value) {
$this->getParameters()->set($key, $value);
}
return $this;
} | [
"public",
"function",
"bind",
"(",
"array",
"$",
"params",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"getParameters",
"(",
")",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")"... | Bind values to a corresponding named placeholders in the query.
@param array $params Associative array of parameters.
@return \KDatabaseQueryInterface | [
"Bind",
"values",
"to",
"a",
"corresponding",
"named",
"placeholders",
"in",
"the",
"query",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/query/abstract.php#L67-L74 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/query/abstract.php | KDatabaseQueryAbstract.getAdapter | public function getAdapter()
{
if(!$this->_adapter instanceof KDatabaseAdapterInterface)
{
$this->_adapter = $this->getObject($this->_adapter);
if(!$this->_adapter instanceof KDatabaseAdapterInterface)
{
throw new UnexpectedValueException(
'Adapter: '.get_class($this->_adapter).' does not implement KDatabaseAdapterInterface'
);
}
}
return $this->_adapter;
} | php | public function getAdapter()
{
if(!$this->_adapter instanceof KDatabaseAdapterInterface)
{
$this->_adapter = $this->getObject($this->_adapter);
if(!$this->_adapter instanceof KDatabaseAdapterInterface)
{
throw new UnexpectedValueException(
'Adapter: '.get_class($this->_adapter).' does not implement KDatabaseAdapterInterface'
);
}
}
return $this->_adapter;
} | [
"public",
"function",
"getAdapter",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_adapter",
"instanceof",
"KDatabaseAdapterInterface",
")",
"{",
"$",
"this",
"->",
"_adapter",
"=",
"$",
"this",
"->",
"getObject",
"(",
"$",
"this",
"->",
"_adapter",
... | Gets the database adapter
@throws \UnexpectedValueException If the adapter doesn't implement KDatabaseAdapterInterface
@return KDatabaseAdapterInterface | [
"Gets",
"the",
"database",
"adapter"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/query/abstract.php#L104-L119 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.