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/component/koowa/template/helper/listbox.php | ComKoowaTemplateHelperListbox.users | public function users($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'model' => 'users',
'name' => 'user',
'value' => 'id',
'label' => 'name',
'sort' => 'name',
'validate' => false
));
return $this->_autocomplete($config);
} | php | public function users($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'model' => 'users',
'name' => 'user',
'value' => 'id',
'label' => 'name',
'sort' => 'name',
'validate' => false
));
return $this->_autocomplete($config);
} | [
"public",
"function",
"users",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'model'",
"=>",
"'users'",
",",
"'na... | Provides a users select box.
@param array|KObjectConfig $config An optional configuration array.
@return string The autocomplete users select box. | [
"Provides",
"a",
"users",
"select",
"box",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/listbox.php#L24-L37 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/listbox.php | ComKoowaTemplateHelperListbox.access | public function access($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'name' => 'access',
'attribs' => array(),
'deselect_value' => '',
'deselect' => true,
'select2' => false,
'prompt' => '- '.$this->getObject('translator')->translate('Select').' -'
))->append(array(
'selected' => $config->{$config->name}
));
$prompt = false;
// without Joomla strips the last hyphen of the prompt
if ($config->deselect) {
$prompt = array((object) array('value' => $config->deselect_value, 'text' => $config->prompt.' '));
}
$html = JHtml::_('access.level', $config->name, $config->selected, $config->attribs->toArray(), $prompt);
if ($config->select2)
{
$html .= $this->getTemplate()->helper('behavior.select2', array(
'element' => 'select[name=\"'.$config->name.'\"]'
));
}
return $html;
} | php | public function access($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'name' => 'access',
'attribs' => array(),
'deselect_value' => '',
'deselect' => true,
'select2' => false,
'prompt' => '- '.$this->getObject('translator')->translate('Select').' -'
))->append(array(
'selected' => $config->{$config->name}
));
$prompt = false;
// without Joomla strips the last hyphen of the prompt
if ($config->deselect) {
$prompt = array((object) array('value' => $config->deselect_value, 'text' => $config->prompt.' '));
}
$html = JHtml::_('access.level', $config->name, $config->selected, $config->attribs->toArray(), $prompt);
if ($config->select2)
{
$html .= $this->getTemplate()->helper('behavior.select2', array(
'element' => 'select[name=\"'.$config->name.'\"]'
));
}
return $html;
} | [
"public",
"function",
"access",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'name'",
"=>",
"'access'",
",",
"'a... | Generates an HTML access listbox
@param array $config An optional array with configuration options
@return string Html | [
"Generates",
"an",
"HTML",
"access",
"listbox"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/listbox.php#L45-L76 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/handler/database.php | KUserSessionHandlerDatabase.read | public function read($session_id)
{
$result = '';
if ($this->getTable()->isConnected())
{
$row = $this->_table->select($session_id, KDatabase::FETCH_ROW);
if (!$row->isNew()) {
$result = $row->data;
}
}
/*
* It turns out that session_start() doesn't like the read method of a custom session handler
* returning false or null if there's no session in existence.
*
* See: https://stackoverflow.com/a/48245947
* See: http://php.net/manual/en/function.session-start.php#120589
*/
return $result !== null ? $result : '';
} | php | public function read($session_id)
{
$result = '';
if ($this->getTable()->isConnected())
{
$row = $this->_table->select($session_id, KDatabase::FETCH_ROW);
if (!$row->isNew()) {
$result = $row->data;
}
}
/*
* It turns out that session_start() doesn't like the read method of a custom session handler
* returning false or null if there's no session in existence.
*
* See: https://stackoverflow.com/a/48245947
* See: http://php.net/manual/en/function.session-start.php#120589
*/
return $result !== null ? $result : '';
} | [
"public",
"function",
"read",
"(",
"$",
"session_id",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"isConnected",
"(",
")",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"_table",
"->",
"selec... | Read session data for a particular session identifier from the session handler backend
@param string $session_id The session identifier
@return string The session data | [
"Read",
"session",
"data",
"for",
"a",
"particular",
"session",
"identifier",
"from",
"the",
"session",
"handler",
"backend"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/handler/database.php#L65-L87 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/handler/database.php | KUserSessionHandlerDatabase.write | public function write($session_id, $session_data)
{
$result = false;
if ($this->getTable()->isConnected())
{
$row = $this->_table->select($session_id, KDatabase::FETCH_ROW);
if ($row->isNew()) {
$row->id = $session_id;
}
$row->time = time();
$row->data = $session_data;
$row->domain = ini_get('session.cookie_domain');
$row->path = ini_get('session.cookie_path');
$result = $row->save();
}
return $result;
} | php | public function write($session_id, $session_data)
{
$result = false;
if ($this->getTable()->isConnected())
{
$row = $this->_table->select($session_id, KDatabase::FETCH_ROW);
if ($row->isNew()) {
$row->id = $session_id;
}
$row->time = time();
$row->data = $session_data;
$row->domain = ini_get('session.cookie_domain');
$row->path = ini_get('session.cookie_path');
$result = $row->save();
}
return $result;
} | [
"public",
"function",
"write",
"(",
"$",
"session_id",
",",
"$",
"session_data",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"isConnected",
"(",
")",
")",
"{",
"$",
"row",
"=",
"$",
"this",
... | Write session data to the session handler backend
@param string $session_id The session identifier
@param string $session_data The session data
@return boolean True on success, false otherwise | [
"Write",
"session",
"data",
"to",
"the",
"session",
"handler",
"backend"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/handler/database.php#L96-L117 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/handler/database.php | KUserSessionHandlerDatabase.destroy | public function destroy($session_id)
{
$result = false;
if ($this->getTable()->isConnected())
{
$row = $this->_table->select($session_id, KDatabase::FETCH_ROW);
if (!$row->isNew()) {
$result = $row->delete();
}
}
return $result;
} | php | public function destroy($session_id)
{
$result = false;
if ($this->getTable()->isConnected())
{
$row = $this->_table->select($session_id, KDatabase::FETCH_ROW);
if (!$row->isNew()) {
$result = $row->delete();
}
}
return $result;
} | [
"public",
"function",
"destroy",
"(",
"$",
"session_id",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
"->",
"isConnected",
"(",
")",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"_table",
"->",
... | Destroy the data for a particular session identifier in the session handler backend
@param string $session_id The session identifier
@return boolean True on success, false otherwise | [
"Destroy",
"the",
"data",
"for",
"a",
"particular",
"session",
"identifier",
"in",
"the",
"session",
"handler",
"backend"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/handler/database.php#L125-L139 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/editable.php | ComKoowaControllerBehaviorEditable._actionSave2new | protected function _actionSave2new(KControllerContextInterface $context)
{
// Cache and lock the referrer since _ActionSave would unset it
$referrer = $this->getReferrer($context);
$this->_lockReferrer($context);
$entity = $this->save($context);
// Re-set the referrer
$cookie = $this->getObject('lib:http.cookie', array(
'name' => $this->_cookie_name,
'value' => (string) $referrer,
'path' => $this->_cookie_path
));
$context->response->headers->addCookie($cookie);
$identifier = $this->getMixer()->getIdentifier();
$view = KStringInflector::singularize($identifier->name);
$url = sprintf('index.php?option=com_%s&view=%s', $identifier->package, $view);
$context->response->setRedirect($this->getObject('lib:http.url',array('url' => $url)));
return $entity;
} | php | protected function _actionSave2new(KControllerContextInterface $context)
{
// Cache and lock the referrer since _ActionSave would unset it
$referrer = $this->getReferrer($context);
$this->_lockReferrer($context);
$entity = $this->save($context);
// Re-set the referrer
$cookie = $this->getObject('lib:http.cookie', array(
'name' => $this->_cookie_name,
'value' => (string) $referrer,
'path' => $this->_cookie_path
));
$context->response->headers->addCookie($cookie);
$identifier = $this->getMixer()->getIdentifier();
$view = KStringInflector::singularize($identifier->name);
$url = sprintf('index.php?option=com_%s&view=%s', $identifier->package, $view);
$context->response->setRedirect($this->getObject('lib:http.url',array('url' => $url)));
return $entity;
} | [
"protected",
"function",
"_actionSave2new",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"// Cache and lock the referrer since _ActionSave would unset it",
"$",
"referrer",
"=",
"$",
"this",
"->",
"getReferrer",
"(",
"$",
"context",
")",
";",
"$",
"this... | Saves the current row and redirects to a new edit form
@param KControllerContextInterface $context
@return KModelEntityInterface | [
"Saves",
"the",
"current",
"row",
"and",
"redirects",
"to",
"a",
"new",
"edit",
"form"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/editable.php#L59-L83 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/editable.php | ComKoowaControllerBehaviorEditable._lockResource | protected function _lockResource(KControllerContextInterface $context)
{
$domain = $this->getMixer()->getIdentifier()->domain;
if ($domain === 'admin' || $this->getRequest()->query->layout === 'form') {
parent::_lockResource($context);
}
} | php | protected function _lockResource(KControllerContextInterface $context)
{
$domain = $this->getMixer()->getIdentifier()->domain;
if ($domain === 'admin' || $this->getRequest()->query->layout === 'form') {
parent::_lockResource($context);
}
} | [
"protected",
"function",
"_lockResource",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"$",
"domain",
"=",
"$",
"this",
"->",
"getMixer",
"(",
")",
"->",
"getIdentifier",
"(",
")",
"->",
"domain",
";",
"if",
"(",
"$",
"domain",
"===",
"'ad... | Only lock entities in administrator or in form layouts in site
{@inheritdoc} | [
"Only",
"lock",
"entities",
"in",
"administrator",
"or",
"in",
"form",
"layouts",
"in",
"site"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/editable.php#L90-L97 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/behavior/mixin/mixin.php | KBehaviorMixin.addBehavior | public function addBehavior($behavior, $config = array())
{
//Create the complete identifier if a partial identifier was passed
if (is_string($behavior) && strpos($behavior, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
if($identifier['path']) {
$identifier['path'] = array($identifier['path'][0], 'behavior');
} else {
$identifier['path'] = array($identifier['name'], 'behavior');
}
$identifier['name'] = $behavior;
$identifier = $this->getIdentifier($identifier);
}
else
{
if($behavior instanceof KBehaviorInterface) {
$identifier = $behavior->getIdentifier();
} else {
$identifier = $this->getIdentifier($behavior);
}
}
//Attach the behavior if it doesn't exist yet
if (!$this->hasCommandHandler($identifier))
{
//Create the behavior object
if (!($behavior instanceof KBehaviorInterface))
{
$config['mixer'] = $this->getMixer();
$behavior = $this->getObject($identifier, $config);
}
if (!($behavior instanceof KBehaviorInterface)) {
throw new UnexpectedValueException("Behavior $identifier does not implement KBehaviorInterface");
}
if(!$this->hasBehavior($behavior->getName()))
{
//Force set the mixer
$behavior->setMixer($this->getMixer());
//Add the behavior
$this->addCommandHandler($behavior);
//Mixin the behavior
$this->mixin($behavior);
//Store the behavior to allow for named lookups
$this->__behaviors[$behavior->getName()] = $behavior;
}
}
return $this->getMixer();
} | php | public function addBehavior($behavior, $config = array())
{
//Create the complete identifier if a partial identifier was passed
if (is_string($behavior) && strpos($behavior, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
if($identifier['path']) {
$identifier['path'] = array($identifier['path'][0], 'behavior');
} else {
$identifier['path'] = array($identifier['name'], 'behavior');
}
$identifier['name'] = $behavior;
$identifier = $this->getIdentifier($identifier);
}
else
{
if($behavior instanceof KBehaviorInterface) {
$identifier = $behavior->getIdentifier();
} else {
$identifier = $this->getIdentifier($behavior);
}
}
//Attach the behavior if it doesn't exist yet
if (!$this->hasCommandHandler($identifier))
{
//Create the behavior object
if (!($behavior instanceof KBehaviorInterface))
{
$config['mixer'] = $this->getMixer();
$behavior = $this->getObject($identifier, $config);
}
if (!($behavior instanceof KBehaviorInterface)) {
throw new UnexpectedValueException("Behavior $identifier does not implement KBehaviorInterface");
}
if(!$this->hasBehavior($behavior->getName()))
{
//Force set the mixer
$behavior->setMixer($this->getMixer());
//Add the behavior
$this->addCommandHandler($behavior);
//Mixin the behavior
$this->mixin($behavior);
//Store the behavior to allow for named lookups
$this->__behaviors[$behavior->getName()] = $behavior;
}
}
return $this->getMixer();
} | [
"public",
"function",
"addBehavior",
"(",
"$",
"behavior",
",",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"//Create the complete identifier if a partial identifier was passed",
"if",
"(",
"is_string",
"(",
"$",
"behavior",
")",
"&&",
"strpos",
"(",
"$",
"... | Add a behavior
@param mixed $behavior An object that implements KBehaviorInterface, an KObjectIdentifier
or valid identifier string
@param array $config An optional associative array of configuration settings
@throws UnexpectedValueException
@return KObject The mixer object | [
"Add",
"a",
"behavior"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/behavior/mixin/mixin.php#L78-L133 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/behavior/mixin/mixin.php | KBehaviorMixin.getBehavior | public function getBehavior($name)
{
$result = null;
if(isset($this->__behaviors[$name])) {
$result = $this->__behaviors[$name];
}
return $result;
} | php | public function getBehavior($name)
{
$result = null;
if(isset($this->__behaviors[$name])) {
$result = $this->__behaviors[$name];
}
return $result;
} | [
"public",
"function",
"getBehavior",
"(",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__behaviors",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"__behaviors",... | Get a behavior by name
@param string $name The behavior name
@return KBehaviorInterface | [
"Get",
"a",
"behavior",
"by",
"name"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/behavior/mixin/mixin.php#L152-L161 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/ui.php | ComKoowaTemplateHelperUi.styles | public function styles($config = array())
{
$identifier = $this->getTemplate()->getIdentifier();
$config = new KObjectConfigJson($config);
$config->append(array(
'debug' => JFactory::getApplication()->getCfg('debug'),
'package' => $identifier->package,
'domain' => $identifier->domain
))->append(array(
'folder' => 'com_'.$config->package,
'file' => ($identifier->type === 'mod' ? 'module' : $config->domain) ?: 'admin',
'media_path' => (defined('JOOMLATOOLS_PLATFORM') ? JPATH_WEB : JPATH_ROOT) . '/media'
));
$html = '';
$path = sprintf('%s/%s/css/%s.css', $config->media_path, $config->folder, $config->file);
if (!file_exists($path))
{
if ($config->file === 'module') {
$config->css_file = false;
} else {
$config->folder = 'koowa';
}
}
if ($this->getTemplate()->decorator() == 'joomla')
{
$app = JFactory::getApplication();
$template = $app->getTemplate();
// Load Bootstrap file if it's explicitly asked for
if ($app->isSite() && file_exists(JPATH_THEMES.'/'.$template.'/enable-koowa-bootstrap.txt')) {
$html .= $this->getTemplate()->helper('behavior.bootstrap', ['javascript' => false, 'css' => true]);
}
// Load overrides for the current admin template
if ($app->isAdmin() && $config->file === 'admin')
{
if (file_exists((defined('JOOMLATOOLS_PLATFORM') ? JPATH_WEB : JPATH_ROOT) . '/media/koowa/com_koowa/css/'.$template.'.css')) {
$html .= '<ktml:style src="assets://koowa/css/'.$template.'.css" />';
}
}
}
$html .= parent::styles($config);
return $html;
} | php | public function styles($config = array())
{
$identifier = $this->getTemplate()->getIdentifier();
$config = new KObjectConfigJson($config);
$config->append(array(
'debug' => JFactory::getApplication()->getCfg('debug'),
'package' => $identifier->package,
'domain' => $identifier->domain
))->append(array(
'folder' => 'com_'.$config->package,
'file' => ($identifier->type === 'mod' ? 'module' : $config->domain) ?: 'admin',
'media_path' => (defined('JOOMLATOOLS_PLATFORM') ? JPATH_WEB : JPATH_ROOT) . '/media'
));
$html = '';
$path = sprintf('%s/%s/css/%s.css', $config->media_path, $config->folder, $config->file);
if (!file_exists($path))
{
if ($config->file === 'module') {
$config->css_file = false;
} else {
$config->folder = 'koowa';
}
}
if ($this->getTemplate()->decorator() == 'joomla')
{
$app = JFactory::getApplication();
$template = $app->getTemplate();
// Load Bootstrap file if it's explicitly asked for
if ($app->isSite() && file_exists(JPATH_THEMES.'/'.$template.'/enable-koowa-bootstrap.txt')) {
$html .= $this->getTemplate()->helper('behavior.bootstrap', ['javascript' => false, 'css' => true]);
}
// Load overrides for the current admin template
if ($app->isAdmin() && $config->file === 'admin')
{
if (file_exists((defined('JOOMLATOOLS_PLATFORM') ? JPATH_WEB : JPATH_ROOT) . '/media/koowa/com_koowa/css/'.$template.'.css')) {
$html .= '<ktml:style src="assets://koowa/css/'.$template.'.css" />';
}
}
}
$html .= parent::styles($config);
return $html;
} | [
"public",
"function",
"styles",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
")",
"->",
"getIdentifier",
"(",
")",
";",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
... | Loads admin.css in frontend forms and force-loads Bootstrap if requested
@param array $config
@return string | [
"Loads",
"admin",
".",
"css",
"in",
"frontend",
"forms",
"and",
"force",
"-",
"loads",
"Bootstrap",
"if",
"requested"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/ui.php#L67-L117 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/iterator/iterator.php | KFilesystemStreamIterator.seek | public function seek($position)
{
if ($position > $this->getStream()->getSize()) {
throw new OutOfBoundsException('Invalid seek position ('.$position.')');
}
$this->getStream()->seek($position, SEEK_SET);
} | php | public function seek($position)
{
if ($position > $this->getStream()->getSize()) {
throw new OutOfBoundsException('Invalid seek position ('.$position.')');
}
$this->getStream()->seek($position, SEEK_SET);
} | [
"public",
"function",
"seek",
"(",
"$",
"position",
")",
"{",
"if",
"(",
"$",
"position",
">",
"$",
"this",
"->",
"getStream",
"(",
")",
"->",
"getSize",
"(",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"'Invalid seek position ('",
".",
"... | Seeks to a given position in the stream
@param int $position
@throws OutOfBoundsException If the position is not seekable. | [
"Seeks",
"to",
"a",
"given",
"position",
"in",
"the",
"stream"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/iterator/iterator.php#L49-L56 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/row/abstract.php | KDatabaseRowAbstract.reset | public function reset()
{
$this->_data = array();
$this->_modified = array();
if ($this->isConnected()) {
$this->_data = $this->getTable()->getDefaults();
}
return $this;
} | php | public function reset()
{
$this->_data = array();
$this->_modified = array();
if ($this->isConnected()) {
$this->_data = $this->getTable()->getDefaults();
}
return $this;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"_data",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_modified",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isConnected",
"(",
")",
")",
"{",
"$",
"this",
"-... | Reset the row data using the defaults
@return KDatabaseRowInterface | [
"Reset",
"the",
"row",
"data",
"using",
"the",
"defaults"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/row/abstract.php#L184-L194 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/row/abstract.php | KDatabaseRowAbstract.setTable | public function setTable($table)
{
if (!($table instanceof KDatabaseTableInterface))
{
if (is_string($table) && strpos($table, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('database', 'table');
$identifier['name'] = KStringInflector::pluralize(KStringInflector::underscore($table));
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($table);
if ($identifier->path[1] != 'table') {
throw new UnexpectedValueException('Identifier: ' . $identifier . ' is not a table identifier');
}
$table = $identifier;
}
$this->_table = $table;
return $this;
} | php | public function setTable($table)
{
if (!($table instanceof KDatabaseTableInterface))
{
if (is_string($table) && strpos($table, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('database', 'table');
$identifier['name'] = KStringInflector::pluralize(KStringInflector::underscore($table));
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($table);
if ($identifier->path[1] != 'table') {
throw new UnexpectedValueException('Identifier: ' . $identifier . ' is not a table identifier');
}
$table = $identifier;
}
$this->_table = $table;
return $this;
} | [
"public",
"function",
"setTable",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"table",
"instanceof",
"KDatabaseTableInterface",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"table",
")",
"&&",
"strpos",
"(",
"$",
"table",
",",
"'.'",
"... | Method to set a table object attached to the rowset
@param mixed $table An object that implements ObjectInterface, ObjectIdentifier object
or valid identifier string
@throws \UnexpectedValueException If the identifier is not a table identifier
@return KDatabaseRowInterface | [
"Method",
"to",
"set",
"a",
"table",
"object",
"attached",
"to",
"the",
"rowset"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/row/abstract.php#L505-L529 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/dispatcher/http.php | ComKoowaDispatcherHttp._enableExceptionHandler | protected function _enableExceptionHandler(KDispatcherContextInterface $context)
{
$handler = $this->getObject('exception.handler');
if (!$handler->isEnabled(KExceptionHandlerInterface::TYPE_EXCEPTION))
{
$handler->enable(KExceptionHandlerInterface::TYPE_EXCEPTION);
$this->addCommandCallback('after.send', '_revertExceptionHandler');
}
} | php | protected function _enableExceptionHandler(KDispatcherContextInterface $context)
{
$handler = $this->getObject('exception.handler');
if (!$handler->isEnabled(KExceptionHandlerInterface::TYPE_EXCEPTION))
{
$handler->enable(KExceptionHandlerInterface::TYPE_EXCEPTION);
$this->addCommandCallback('after.send', '_revertExceptionHandler');
}
} | [
"protected",
"function",
"_enableExceptionHandler",
"(",
"KDispatcherContextInterface",
"$",
"context",
")",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'exception.handler'",
")",
";",
"if",
"(",
"!",
"$",
"handler",
"->",
"isEnabled",
"(",
... | Enables our own exception handler at all times before dispatching
@param KDispatcherContextInterface $context | [
"Enables",
"our",
"own",
"exception",
"handler",
"at",
"all",
"times",
"before",
"dispatching"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/http.php#L63-L72 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/plugin/koowa/subscriber.php | PlgKoowaSubscriber.unsubscribe | public function unsubscribe(KEventPublisherInterface $publisher)
{
$handle = $publisher->getHandle();
if($this->isSubscribed($publisher));
{
foreach ($this->__publishers[$handle] as $index => $listener)
{
$publisher->removeListener($listener, array($this, $listener));
unset($this->__publishers[$handle][$index]);
}
}
} | php | public function unsubscribe(KEventPublisherInterface $publisher)
{
$handle = $publisher->getHandle();
if($this->isSubscribed($publisher));
{
foreach ($this->__publishers[$handle] as $index => $listener)
{
$publisher->removeListener($listener, array($this, $listener));
unset($this->__publishers[$handle][$index]);
}
}
} | [
"public",
"function",
"unsubscribe",
"(",
"KEventPublisherInterface",
"$",
"publisher",
")",
"{",
"$",
"handle",
"=",
"$",
"publisher",
"->",
"getHandle",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isSubscribed",
"(",
"$",
"publisher",
")",
")",
";",
... | Detach all previously attached listeners for the specific dispatcher
@param KEventPublisherInterface $publisher
@return void | [
"Detach",
"all",
"previously",
"attached",
"listeners",
"for",
"the",
"specific",
"dispatcher"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/plugin/koowa/subscriber.php#L70-L82 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/event/subscriber/factory.php | KEventSubscriberFactory.subscribeEvent | public function subscribeEvent($event, $event_publisher)
{
foreach($this->getSubscribers($event) as $identifier)
{
if(!$this->__subscribers[(string)$identifier] instanceof KEventSubscriberInterface)
{
$subscriber = $this->getObject($identifier);
$subscriber->subscribe($event_publisher);
$this->__subscribers[(string)$identifier] = $subscriber;
}
}
return $this;
} | php | public function subscribeEvent($event, $event_publisher)
{
foreach($this->getSubscribers($event) as $identifier)
{
if(!$this->__subscribers[(string)$identifier] instanceof KEventSubscriberInterface)
{
$subscriber = $this->getObject($identifier);
$subscriber->subscribe($event_publisher);
$this->__subscribers[(string)$identifier] = $subscriber;
}
}
return $this;
} | [
"public",
"function",
"subscribeEvent",
"(",
"$",
"event",
",",
"$",
"event_publisher",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSubscribers",
"(",
"$",
"event",
")",
"as",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"__subs... | Instantiate the subscribers for the specified event
The subscribers will be created if does not exist yet.
@param mixed $event An object that implements ObjectInterface, ObjectIdentifier object
or valid identifier string
@param array $event_publisher An optional associative array of configuration settings
@throws UnexpectedValueException If the subscriber is not implementing the EventSubscriberInterface
@return KEventSubscriberFactory | [
"Instantiate",
"the",
"subscribers",
"for",
"the",
"specified",
"event"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/event/subscriber/factory.php#L138-L152 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/event/subscriber/factory.php | KEventSubscriberFactory.getSubscribers | public function getSubscribers($event)
{
$result = array();
if(isset($this->__listeners[$event])) {
$result = $this->__listeners[$event];
}
return $result;
} | php | public function getSubscribers($event)
{
$result = array();
if(isset($this->__listeners[$event])) {
$result = $this->__listeners[$event];
}
return $result;
} | [
"public",
"function",
"getSubscribers",
"(",
"$",
"event",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"__listeners",
"[",
"$",
"event",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"-... | Get the subscribers for a specific event
@param string $event The name of the event
@return array | [
"Get",
"the",
"subscribers",
"for",
"a",
"specific",
"event"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/event/subscriber/factory.php#L160-L168 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/translator/locator/abstract.php | KTranslatorLocatorAbstract.find | public function find(array $info)
{
$result = array();
if($info['path'] && $info['locale'])
{
$pattern = $info['path'].'/'.$info['locale'].'.*';
$results = glob($pattern);
if ($results)
{
foreach($results as $file)
{
if($path = $this->realPath($file))
{
$result[] = $path;
break;
}
}
}
}
return $result;
} | php | public function find(array $info)
{
$result = array();
if($info['path'] && $info['locale'])
{
$pattern = $info['path'].'/'.$info['locale'].'.*';
$results = glob($pattern);
if ($results)
{
foreach($results as $file)
{
if($path = $this->realPath($file))
{
$result[] = $path;
break;
}
}
}
}
return $result;
} | [
"public",
"function",
"find",
"(",
"array",
"$",
"info",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"info",
"[",
"'path'",
"]",
"&&",
"$",
"info",
"[",
"'locale'",
"]",
")",
"{",
"$",
"pattern",
"=",
"$",
"info",
"[",... | Find a translation path
@param array $info The path information
@return array | [
"Find",
"a",
"translation",
"path"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/translator/locator/abstract.php#L134-L157 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/locator/identifier.php | KTemplateLocatorIdentifier.getLayout | public function getLayout($url)
{
$engines = $this->getObject('template.engine.factory')->getFileTypes();
$parts = explode('.', $url);
if(in_array(end($parts), $engines))
{
$type = array_pop($parts);
$format = array_pop($parts);
}
else $format = array_pop($parts);
return $this->getIdentifier(implode('.', $parts));
} | php | public function getLayout($url)
{
$engines = $this->getObject('template.engine.factory')->getFileTypes();
$parts = explode('.', $url);
if(in_array(end($parts), $engines))
{
$type = array_pop($parts);
$format = array_pop($parts);
}
else $format = array_pop($parts);
return $this->getIdentifier(implode('.', $parts));
} | [
"public",
"function",
"getLayout",
"(",
"$",
"url",
")",
"{",
"$",
"engines",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'template.engine.factory'",
")",
"->",
"getFileTypes",
"(",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"url",
")... | Get the layout identifier based on the url
If the identifier has been aliased the alias will be returned.
@param string $url The template url
@return KObjectIdentifier | [
"Get",
"the",
"layout",
"identifier",
"based",
"on",
"the",
"url"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/locator/identifier.php#L74-L87 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/locator/identifier.php | KTemplateLocatorIdentifier.parseIdentifier | public function parseIdentifier($url)
{
$engines = $this->getObject('template.engine.factory')->getFileTypes();
//Set defaults
$path = null;
$file = null;
$format = null;
$type = null;
//Qualify partial templates.
if(strpos($url, ':') === false)
{
/**
* Parse identifiers in following formats :
*
* - '[file.[format].[type]';
* - '[file].[format];
*/
$parts = explode('.', $url);
if(in_array(end($parts), $engines)) {
$type = array_pop($parts);
}
$format = array_pop($parts);
$file = array_pop($parts);
$info = array(
'package' => '',
'path' => '',
'file' => $file,
'format' => $format,
'type' => $type,
);
}
else
{
/**
* Parse identifiers in following formats :
*
* - '[package].[path].[file].[format].[type]';
* - '[package].[path].[file].[format];
*/
$parts = explode('.', $url);
if(in_array(end($parts), $engines))
{
$type = array_pop($parts);
$format = array_pop($parts);
$file = array_pop($parts);
}
else
{
$format = array_pop($parts);
$file = array_pop($parts);
}
$info = array(
'package' => array_shift($parts),
'path' => implode('.', $parts),
'file' => $file,
'format' => $format,
'type' => $type,
);
}
return $info;
} | php | public function parseIdentifier($url)
{
$engines = $this->getObject('template.engine.factory')->getFileTypes();
//Set defaults
$path = null;
$file = null;
$format = null;
$type = null;
//Qualify partial templates.
if(strpos($url, ':') === false)
{
/**
* Parse identifiers in following formats :
*
* - '[file.[format].[type]';
* - '[file].[format];
*/
$parts = explode('.', $url);
if(in_array(end($parts), $engines)) {
$type = array_pop($parts);
}
$format = array_pop($parts);
$file = array_pop($parts);
$info = array(
'package' => '',
'path' => '',
'file' => $file,
'format' => $format,
'type' => $type,
);
}
else
{
/**
* Parse identifiers in following formats :
*
* - '[package].[path].[file].[format].[type]';
* - '[package].[path].[file].[format];
*/
$parts = explode('.', $url);
if(in_array(end($parts), $engines))
{
$type = array_pop($parts);
$format = array_pop($parts);
$file = array_pop($parts);
}
else
{
$format = array_pop($parts);
$file = array_pop($parts);
}
$info = array(
'package' => array_shift($parts),
'path' => implode('.', $parts),
'file' => $file,
'format' => $format,
'type' => $type,
);
}
return $info;
} | [
"public",
"function",
"parseIdentifier",
"(",
"$",
"url",
")",
"{",
"$",
"engines",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'template.engine.factory'",
")",
"->",
"getFileTypes",
"(",
")",
";",
"//Set defaults",
"$",
"path",
"=",
"null",
";",
"$",
"file... | Parse a template identifier
@return array | [
"Parse",
"a",
"template",
"identifier"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/locator/identifier.php#L94-L164 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.getColumn | public function getColumn($column, $base = false)
{
$columns = $this->getColumns($base);
return isset($columns[$column]) ? $columns[$column] : null;
} | php | public function getColumn($column, $base = false)
{
$columns = $this->getColumns($base);
return isset($columns[$column]) ? $columns[$column] : null;
} | [
"public",
"function",
"getColumn",
"(",
"$",
"column",
",",
"$",
"base",
"=",
"false",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"getColumns",
"(",
"$",
"base",
")",
";",
"return",
"isset",
"(",
"$",
"columns",
"[",
"$",
"column",
"]",
")",... | Get a column by name
@param string $column The name of the column
@param boolean $base If TRUE, get the column information from the base table.
@return KDatabaseSchemaColumn Returns a KDatabaseSchemaColumn object or NULL if the column does not exist | [
"Get",
"a",
"column",
"by",
"name"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L265-L269 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.mapColumns | public function mapColumns($data, $reverse = false)
{
$map = $reverse ? array_flip($this->_column_map) : $this->_column_map;
$result = null;
if (is_array($data) || is_object($data))
{
$result = array();
foreach ($data as $column => $value)
{
if (is_string($column))
{
//Map the key
if (isset($map[$column])) {
$column = $map[$column];
}
}
else
{
//Map the value
if (isset($map[$value])) {
$value = $map[$value];
}
}
$result[$column] = $value;
}
if (is_object($data)) {
$result = (object) $result;
}
}
if (is_string($data))
{
$result = $data;
if (isset($map[$data])) {
$result = $map[$data];
}
}
return $result;
} | php | public function mapColumns($data, $reverse = false)
{
$map = $reverse ? array_flip($this->_column_map) : $this->_column_map;
$result = null;
if (is_array($data) || is_object($data))
{
$result = array();
foreach ($data as $column => $value)
{
if (is_string($column))
{
//Map the key
if (isset($map[$column])) {
$column = $map[$column];
}
}
else
{
//Map the value
if (isset($map[$value])) {
$value = $map[$value];
}
}
$result[$column] = $value;
}
if (is_object($data)) {
$result = (object) $result;
}
}
if (is_string($data))
{
$result = $data;
if (isset($map[$data])) {
$result = $map[$data];
}
}
return $result;
} | [
"public",
"function",
"mapColumns",
"(",
"$",
"data",
",",
"$",
"reverse",
"=",
"false",
")",
"{",
"$",
"map",
"=",
"$",
"reverse",
"?",
"array_flip",
"(",
"$",
"this",
"->",
"_column_map",
")",
":",
"$",
"this",
"->",
"_column_map",
";",
"$",
"resul... | Table map method
This functions maps the column names to those in the table schema
@param array|string $data An associative array of data to be mapped, or a column name
@param boolean $reverse If TRUE, perform a reverse mapping
@return array|string The mapped data or column name | [
"Table",
"map",
"method"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L297-L341 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.getIdentityColumn | public function getIdentityColumn()
{
$result = null;
if (isset($this->_identity_column)) {
$result = $this->_identity_column;
}
return $result;
} | php | public function getIdentityColumn()
{
$result = null;
if (isset($this->_identity_column)) {
$result = $this->_identity_column;
}
return $result;
} | [
"public",
"function",
"getIdentityColumn",
"(",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_identity_column",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_identity_column",
";",
"}",
"return",
"$"... | Get the identity column of the table.
@return string | [
"Get",
"the",
"identity",
"column",
"of",
"the",
"table",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L348-L356 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.getUniqueColumns | public function getUniqueColumns()
{
$result = array();
$columns = $this->getColumns(true);
foreach ($columns as $name => $description)
{
if ($description->unique) {
$result[$name] = $description;
}
}
return $result;
} | php | public function getUniqueColumns()
{
$result = array();
$columns = $this->getColumns(true);
foreach ($columns as $name => $description)
{
if ($description->unique) {
$result[$name] = $description;
}
}
return $result;
} | [
"public",
"function",
"getUniqueColumns",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"columns",
"=",
"$",
"this",
"->",
"getColumns",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"name",
"=>",
"$",
"descripti... | Gets the unique columns of the table
@return array An associative array of unique table columns by column name | [
"Gets",
"the",
"unique",
"columns",
"of",
"the",
"table"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L382-L395 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.getDefaults | public function getDefaults()
{
if (!isset($this->_defaults))
{
$defaults = array();
$columns = $this->getColumns();
foreach ($columns as $name => $description) {
$defaults[$name] = $description->default;
}
$this->_defaults = $defaults;
}
return $this->_defaults;
} | php | public function getDefaults()
{
if (!isset($this->_defaults))
{
$defaults = array();
$columns = $this->getColumns();
foreach ($columns as $name => $description) {
$defaults[$name] = $description->default;
}
$this->_defaults = $defaults;
}
return $this->_defaults;
} | [
"public",
"function",
"getDefaults",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_defaults",
")",
")",
"{",
"$",
"defaults",
"=",
"array",
"(",
")",
";",
"$",
"columns",
"=",
"$",
"this",
"->",
"getColumns",
"(",
")",
";",
"f... | Get default values for all columns
@return array | [
"Get",
"default",
"values",
"for",
"all",
"columns"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L402-L417 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.getDefault | public function getDefault($column)
{
$defaults = $this->getDefaults();
return isset($defaults[$column]) ? $defaults[$column] : null;
} | php | public function getDefault($column)
{
$defaults = $this->getDefaults();
return isset($defaults[$column]) ? $defaults[$column] : null;
} | [
"public",
"function",
"getDefault",
"(",
"$",
"column",
")",
"{",
"$",
"defaults",
"=",
"$",
"this",
"->",
"getDefaults",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"defaults",
"[",
"$",
"column",
"]",
")",
"?",
"$",
"defaults",
"[",
"$",
"column",
... | Get a default by name
@param string $column The name of the column
@return mixed Returns the column default value or NULL if the column does not exist | [
"Get",
"a",
"default",
"by",
"name"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L425-L429 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.setDefault | public function setDefault($column, $value)
{
$defaults = $this->getDefaults();
if(isset($defaults[$column])) {
$this->_defaults[$column] = $value;
}
return $this;
} | php | public function setDefault($column, $value)
{
$defaults = $this->getDefaults();
if(isset($defaults[$column])) {
$this->_defaults[$column] = $value;
}
return $this;
} | [
"public",
"function",
"setDefault",
"(",
"$",
"column",
",",
"$",
"value",
")",
"{",
"$",
"defaults",
"=",
"$",
"this",
"->",
"getDefaults",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"defaults",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"th... | Set a default value for a column
@param string $column The name of the column
@param string $value The value for the column
@return KDatabaseTableAbstract | [
"Set",
"a",
"default",
"value",
"for",
"a",
"column"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L438-L447 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.createRowset | public function createRowset(array $options = array())
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('database', 'rowset');
//Force the table
$options['table'] = $this;
//Set the identity column if not set already
if (!isset($options['identity_column'])) {
$options['identity_column'] = $this->mapColumns($this->getIdentityColumn(), true);
}
return $this->getObject($identifier, $options);
} | php | public function createRowset(array $options = array())
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('database', 'rowset');
//Force the table
$options['table'] = $this;
//Set the identity column if not set already
if (!isset($options['identity_column'])) {
$options['identity_column'] = $this->mapColumns($this->getIdentityColumn(), true);
}
return $this->getObject($identifier, $options);
} | [
"public",
"function",
"createRowset",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"identifier",
"[",
"'path'",
"]",
"=",
"a... | Get an instance of a rowset object for this table
@param array $options An optional associative array of configuration settings.
@return KDatabaseRowInterface | [
"Get",
"an",
"instance",
"of",
"a",
"rowset",
"object",
"for",
"this",
"table"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L478-L492 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.count | public function count($query = null, array $options = array())
{
//Count using the identity column
if (is_scalar($query))
{
$key = $this->getIdentityColumn();
$query = array($key => $query);
}
//Create query object
if (is_array($query) && !is_numeric(key($query)))
{
$columns = $this->mapColumns($query);
$query = $this->getObject('lib:database.query.select');
foreach ($columns as $column => $value)
{
$query->where($column . ' ' . (is_array($value) ? 'IN' : '=') . ' :' . $column)
->bind(array($column => $value));
}
}
if ($query instanceof KDatabaseQuerySelect)
{
if (!$query->columns) {
$query->columns('COUNT(*)');
}
if (!$query->table) {
$query->table(array('tbl' => $this->getName()));
}
}
$result = (int)$this->select($query, KDatabase::FETCH_FIELD, $options);
return $result;
} | php | public function count($query = null, array $options = array())
{
//Count using the identity column
if (is_scalar($query))
{
$key = $this->getIdentityColumn();
$query = array($key => $query);
}
//Create query object
if (is_array($query) && !is_numeric(key($query)))
{
$columns = $this->mapColumns($query);
$query = $this->getObject('lib:database.query.select');
foreach ($columns as $column => $value)
{
$query->where($column . ' ' . (is_array($value) ? 'IN' : '=') . ' :' . $column)
->bind(array($column => $value));
}
}
if ($query instanceof KDatabaseQuerySelect)
{
if (!$query->columns) {
$query->columns('COUNT(*)');
}
if (!$query->table) {
$query->table(array('tbl' => $this->getName()));
}
}
$result = (int)$this->select($query, KDatabase::FETCH_FIELD, $options);
return $result;
} | [
"public",
"function",
"count",
"(",
"$",
"query",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"//Count using the identity column",
"if",
"(",
"is_scalar",
"(",
"$",
"query",
")",
")",
"{",
"$",
"key",
"=",
"$",
"this",
... | Count table rows
@param mixed $query KDatabaseQuery object or query string or null to count all rows
@param array $options An optional associative array of configuration options.
@return int Number of rows | [
"Count",
"table",
"rows"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L628-L663 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.insert | public function insert(KDatabaseRowInterface $row)
{
// Create query object.
$query = $this->getObject('lib:database.query.insert')
->table($this->getBase());
//Create commandchain context
$context = $this->getContext();
$context->table = $this->getBase();
$context->data = $row;
$context->query = $query;
$context->affected = false;
if ($this->invokeCommand('before.insert', $context) !== false)
{
// Filter the data and remove unwanted columns.
$data = $this->filter($context->data->getProperties());
$context->query->values($this->mapColumns($data));
// Execute the insert query.
$context->affected = $this->getAdapter()->insert($context->query);
// Set the status and data before calling the command chain
if ($context->affected !== false)
{
if ($context->affected)
{
if(($column = $this->getIdentityColumn()) && $this->getColumn($this->mapColumns($column, true), true)->autoinc) {
$data[$this->getIdentityColumn()] = $this->getAdapter()->getInsertId();
}
$context->data->setProperties($this->mapColumns($data, true))->setStatus(KDatabase::STATUS_CREATED);
}
else $context->data->setStatus(KDatabase::STATUS_FAILED);
}
$this->invokeCommand('after.insert', $context);
}
return $context->affected;
} | php | public function insert(KDatabaseRowInterface $row)
{
// Create query object.
$query = $this->getObject('lib:database.query.insert')
->table($this->getBase());
//Create commandchain context
$context = $this->getContext();
$context->table = $this->getBase();
$context->data = $row;
$context->query = $query;
$context->affected = false;
if ($this->invokeCommand('before.insert', $context) !== false)
{
// Filter the data and remove unwanted columns.
$data = $this->filter($context->data->getProperties());
$context->query->values($this->mapColumns($data));
// Execute the insert query.
$context->affected = $this->getAdapter()->insert($context->query);
// Set the status and data before calling the command chain
if ($context->affected !== false)
{
if ($context->affected)
{
if(($column = $this->getIdentityColumn()) && $this->getColumn($this->mapColumns($column, true), true)->autoinc) {
$data[$this->getIdentityColumn()] = $this->getAdapter()->getInsertId();
}
$context->data->setProperties($this->mapColumns($data, true))->setStatus(KDatabase::STATUS_CREATED);
}
else $context->data->setStatus(KDatabase::STATUS_FAILED);
}
$this->invokeCommand('after.insert', $context);
}
return $context->affected;
} | [
"public",
"function",
"insert",
"(",
"KDatabaseRowInterface",
"$",
"row",
")",
"{",
"// Create query object.",
"$",
"query",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'lib:database.query.insert'",
")",
"->",
"table",
"(",
"$",
"this",
"->",
"getBase",
"(",
")... | Table insert method
@param KDatabaseRowInterface $row A KDatabaseRow object
@return bool|integer Returns the number of rows inserted, or FALSE if insert query was not executed. | [
"Table",
"insert",
"method"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L671-L711 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.update | public function update(KDatabaseRowInterface $row)
{
// Create query object.
$query = $this->getObject('lib:database.query.update')
->table($this->getBase());
// Create commandchain context.
$context = $this->getContext();
$context->table = $this->getBase();
$context->data = $row;
$context->query = $query;
$context->affected = false;
if ($this->invokeCommand('before.update', $context) !== false)
{
foreach ($this->getPrimaryKey() as $key => $column)
{
$context->query->where($column->name . ' = :' . $key)
->bind(array($key => $context->data->$key));
}
// Filter the data and remove unwanted columns.
$data = $this->filter($context->data->getProperties(true));
foreach ($this->mapColumns($data) as $key => $value) {
$query->values($key . ' = :_' . $key)->bind(array('_' . $key => $value));
}
// Execute the update query.
$context->affected = $this->getAdapter()->update($context->query);
// Set the status and data before calling the command chain
if ($context->affected !== false)
{
if ($context->affected) {
$context->data->setProperties($this->mapColumns($data, true), true)->setStatus(KDatabase::STATUS_UPDATED);
} else {
$context->data->setStatus(KDatabase::STATUS_FAILED);
}
}
$this->invokeCommand('after.update', $context);
}
return $context->affected;
} | php | public function update(KDatabaseRowInterface $row)
{
// Create query object.
$query = $this->getObject('lib:database.query.update')
->table($this->getBase());
// Create commandchain context.
$context = $this->getContext();
$context->table = $this->getBase();
$context->data = $row;
$context->query = $query;
$context->affected = false;
if ($this->invokeCommand('before.update', $context) !== false)
{
foreach ($this->getPrimaryKey() as $key => $column)
{
$context->query->where($column->name . ' = :' . $key)
->bind(array($key => $context->data->$key));
}
// Filter the data and remove unwanted columns.
$data = $this->filter($context->data->getProperties(true));
foreach ($this->mapColumns($data) as $key => $value) {
$query->values($key . ' = :_' . $key)->bind(array('_' . $key => $value));
}
// Execute the update query.
$context->affected = $this->getAdapter()->update($context->query);
// Set the status and data before calling the command chain
if ($context->affected !== false)
{
if ($context->affected) {
$context->data->setProperties($this->mapColumns($data, true), true)->setStatus(KDatabase::STATUS_UPDATED);
} else {
$context->data->setStatus(KDatabase::STATUS_FAILED);
}
}
$this->invokeCommand('after.update', $context);
}
return $context->affected;
} | [
"public",
"function",
"update",
"(",
"KDatabaseRowInterface",
"$",
"row",
")",
"{",
"// Create query object.",
"$",
"query",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'lib:database.query.update'",
")",
"->",
"table",
"(",
"$",
"this",
"->",
"getBase",
"(",
")... | Table update method
@param KDatabaseRowInterface $row A KDatabaseRow object
@return boolean|integer Returns the number of rows updated, or FALSE if insert query was not executed. | [
"Table",
"update",
"method"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L719-L764 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/table/abstract.php | KDatabaseTableAbstract.filter | public function filter(array $data, $base = true)
{
// Filter out any extra columns.
$data = array_intersect_key($data, $this->getColumns($base));
// Filter data based on column type
foreach ($data as $key => $value)
{
$column = $this->getColumn($key, $base);
if ($column->filter) {
$data[$key] = $this->getObject('filter.factory')->createChain($column->filter)->sanitize($value);
}
// If NULL is allowed and default is NULL, set value to NULL in the following cases.
if (!$column->required && is_null($column->default))
{
// If value is empty.
if (empty($data[$key])) {
$data[$key] = null;
}
// If type is date, time or datetime and value is like 0000-00-00 00:00:00.
$date_types = array('date', 'time', 'datetime');
if (in_array($column->type, $date_types) && !preg_match('/[^-0:\s]/', $data[$key])) {
$data[$key] = null;
}
}
}
return $data;
} | php | public function filter(array $data, $base = true)
{
// Filter out any extra columns.
$data = array_intersect_key($data, $this->getColumns($base));
// Filter data based on column type
foreach ($data as $key => $value)
{
$column = $this->getColumn($key, $base);
if ($column->filter) {
$data[$key] = $this->getObject('filter.factory')->createChain($column->filter)->sanitize($value);
}
// If NULL is allowed and default is NULL, set value to NULL in the following cases.
if (!$column->required && is_null($column->default))
{
// If value is empty.
if (empty($data[$key])) {
$data[$key] = null;
}
// If type is date, time or datetime and value is like 0000-00-00 00:00:00.
$date_types = array('date', 'time', 'datetime');
if (in_array($column->type, $date_types) && !preg_match('/[^-0:\s]/', $data[$key])) {
$data[$key] = null;
}
}
}
return $data;
} | [
"public",
"function",
"filter",
"(",
"array",
"$",
"data",
",",
"$",
"base",
"=",
"true",
")",
"{",
"// Filter out any extra columns.",
"$",
"data",
"=",
"array_intersect_key",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"getColumns",
"(",
"$",
"base",
")",
... | Table filter method
This function removes extra columns based on the table columns taking any table mappings into account and
filters the data based on each column type.
@param array $data An associative array of data to be filtered
@param boolean $base If TRUE, get the column information from the base table.
@return array The filtered data | [
"Table",
"filter",
"method"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/table/abstract.php#L865-L896 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/event/publisher/profiler.php | KEventPublisherProfiler.setListenerPriority | public function setListenerPriority($event, $listener, $priority)
{
$this->getDelegate()->setListenerPriority($event, $listener, $priority);
return $this;
} | php | public function setListenerPriority($event, $listener, $priority)
{
$this->getDelegate()->setListenerPriority($event, $listener, $priority);
return $this;
} | [
"public",
"function",
"setListenerPriority",
"(",
"$",
"event",
",",
"$",
"listener",
",",
"$",
"priority",
")",
"{",
"$",
"this",
"->",
"getDelegate",
"(",
")",
"->",
"setListenerPriority",
"(",
"$",
"event",
",",
"$",
"listener",
",",
"$",
"priority",
... | Set the priority of a listener
@param string|KEventInterface $event The event name or a KEventInterface object
@param callable $listener The listener
@param integer $priority The event priority
@throws InvalidArgumentException If the listener is not a callable
@throws InvalidArgumentException If the event is not a string or does not implement the KEventInterface
@return KEventPublisherProfiler | [
"Set",
"the",
"priority",
"of",
"a",
"listener"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/event/publisher/profiler.php#L155-L159 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/event/publisher/profiler.php | KEventPublisherProfiler.getMemoryUsage | public function getMemoryUsage()
{
$size = memory_get_usage(true);
$unit = array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
} | php | public function getMemoryUsage()
{
$size = memory_get_usage(true);
$unit = array('b','kb','mb','gb','tb','pb');
return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
} | [
"public",
"function",
"getMemoryUsage",
"(",
")",
"{",
"$",
"size",
"=",
"memory_get_usage",
"(",
"true",
")",
";",
"$",
"unit",
"=",
"array",
"(",
"'b'",
",",
"'kb'",
",",
"'mb'",
",",
"'gb'",
",",
"'tb'",
",",
"'pb'",
")",
";",
"return",
"@",
"ro... | Get information about current memory usage.
@return int The memory usage
@link PHP_MANUAL#memory_get_usage | [
"Get",
"information",
"about",
"current",
"memory",
"usage",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/event/publisher/profiler.php#L191-L197 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/event/publisher/profiler.php | KEventPublisherProfiler.getListenerInfo | public function getListenerInfo($listener)
{
$info = array();
if(is_callable($listener))
{
if (get_class('Closure') && $listener instanceof Closure)
{
$info += array(
'type' => 'Closure',
'pretty' => 'closure'
);
}
if (is_string($listener))
{
try
{
$r = new ReflectionFunction($listener);
$file = $r->getFileName();
$line = $r->getStartLine();
}
catch (ReflectionException $e)
{
$file = null;
$line = null;
}
$info += array
(
'type' => 'Function',
'function' => $listener,
'file' => $file,
'line' => $line,
'pretty' => $listener,
);
}
if (is_array($listener) || (is_object($listener)))
{
if (!is_array($listener)) {
$listener = array($listener, '__invoke');
}
$class = is_object($listener[0]) ? get_class($listener[0]) : $listener[0];
try
{
$r = new ReflectionMethod($class, $listener[1]);
$file = $r->getFileName();
$line = $r->getStartLine();
}
catch (ReflectionException $e)
{
$file = null;
$line = null;
}
$info += array
(
'type' => 'Method',
'class' => $class,
'method' => $listener[1],
'file' => $file,
'line' => $line,
'pretty' => $class.'::'.$listener[1],
);
}
}
return $info;
} | php | public function getListenerInfo($listener)
{
$info = array();
if(is_callable($listener))
{
if (get_class('Closure') && $listener instanceof Closure)
{
$info += array(
'type' => 'Closure',
'pretty' => 'closure'
);
}
if (is_string($listener))
{
try
{
$r = new ReflectionFunction($listener);
$file = $r->getFileName();
$line = $r->getStartLine();
}
catch (ReflectionException $e)
{
$file = null;
$line = null;
}
$info += array
(
'type' => 'Function',
'function' => $listener,
'file' => $file,
'line' => $line,
'pretty' => $listener,
);
}
if (is_array($listener) || (is_object($listener)))
{
if (!is_array($listener)) {
$listener = array($listener, '__invoke');
}
$class = is_object($listener[0]) ? get_class($listener[0]) : $listener[0];
try
{
$r = new ReflectionMethod($class, $listener[1]);
$file = $r->getFileName();
$line = $r->getStartLine();
}
catch (ReflectionException $e)
{
$file = null;
$line = null;
}
$info += array
(
'type' => 'Method',
'class' => $class,
'method' => $listener[1],
'file' => $file,
'line' => $line,
'pretty' => $class.'::'.$listener[1],
);
}
}
return $info;
} | [
"public",
"function",
"getListenerInfo",
"(",
"$",
"listener",
")",
"{",
"$",
"info",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"listener",
")",
")",
"{",
"if",
"(",
"get_class",
"(",
"'Closure'",
")",
"&&",
"$",
"listener",
"i... | Returns information about a listener
@param callable $listener The listener
@return array Information about the listener | [
"Returns",
"information",
"about",
"a",
"listener"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/event/publisher/profiler.php#L205-L276 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/event/publisher/profiler.php | KEventPublisherProfiler.setDelegate | public function setDelegate($delegate)
{
if (!$delegate instanceof KEventPublisherInterface) {
throw new InvalidArgumentException('Delegate: '.get_class($delegate).' does not implement KEventPublisherInterface');
}
return parent::setDelegate($delegate);
} | php | public function setDelegate($delegate)
{
if (!$delegate instanceof KEventPublisherInterface) {
throw new InvalidArgumentException('Delegate: '.get_class($delegate).' does not implement KEventPublisherInterface');
}
return parent::setDelegate($delegate);
} | [
"public",
"function",
"setDelegate",
"(",
"$",
"delegate",
")",
"{",
"if",
"(",
"!",
"$",
"delegate",
"instanceof",
"KEventPublisherInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Delegate: '",
".",
"get_class",
"(",
"$",
"delegate",
")"... | Set the decorated event dispatcher
@param KEventPublisherInterface $delegate The decorated event publisher
@return KEventPublisherProfiler
@throws InvalidArgumentException If the delegate is not an event publisher | [
"Set",
"the",
"decorated",
"event",
"dispatcher"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/event/publisher/profiler.php#L295-L302 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/findable.php | ComKoowaControllerBehaviorFindable._getModel | protected function _getModel()
{
if (!$this->_model instanceof KModelInterface)
{
if (strpos($this->_model, '.') === false) {
$this->_model = 'com://admin/'.$this->_package.'.model.'.$this->_model;
}
$this->_model = $this->getObject($this->_model);
}
return $this->_model;
} | php | protected function _getModel()
{
if (!$this->_model instanceof KModelInterface)
{
if (strpos($this->_model, '.') === false) {
$this->_model = 'com://admin/'.$this->_package.'.model.'.$this->_model;
}
$this->_model = $this->getObject($this->_model);
}
return $this->_model;
} | [
"protected",
"function",
"_getModel",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_model",
"instanceof",
"KModelInterface",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"_model",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"$",
"this"... | Returns the model
@return KModelAbstract | [
"Returns",
"the",
"model"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/findable.php#L113-L125 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/findable.php | ComKoowaControllerBehaviorFindable._getDispatcher | protected function _getDispatcher()
{
if (!self::$_dispatcher)
{
JPluginHelper::importPlugin('finder');
self::$_dispatcher = JEventDispatcher::getInstance();
}
return self::$_dispatcher;
} | php | protected function _getDispatcher()
{
if (!self::$_dispatcher)
{
JPluginHelper::importPlugin('finder');
self::$_dispatcher = JEventDispatcher::getInstance();
}
return self::$_dispatcher;
} | [
"protected",
"function",
"_getDispatcher",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_dispatcher",
")",
"{",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'finder'",
")",
";",
"self",
"::",
"$",
"_dispatcher",
"=",
"JEventDispatcher",
"::",
"getInsta... | Gets the Joomla event dispatcher
@return JEventDispatcher | [
"Gets",
"the",
"Joomla",
"event",
"dispatcher"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/findable.php#L132-L141 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/findable.php | ComKoowaControllerBehaviorFindable._beforeEdit | protected function _beforeEdit(KControllerContextInterface $context)
{
if ($this->getMixer()->getIdentifier()->name === $this->_category_entity)
{
$collection = $this->getModel()->fetch();
foreach ($collection as $entity)
{
$entity->old_enabled = $entity->enabled;
$entity->old_access = $entity->access;
}
}
} | php | protected function _beforeEdit(KControllerContextInterface $context)
{
if ($this->getMixer()->getIdentifier()->name === $this->_category_entity)
{
$collection = $this->getModel()->fetch();
foreach ($collection as $entity)
{
$entity->old_enabled = $entity->enabled;
$entity->old_access = $entity->access;
}
}
} | [
"protected",
"function",
"_beforeEdit",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getMixer",
"(",
")",
"->",
"getIdentifier",
"(",
")",
"->",
"name",
"===",
"$",
"this",
"->",
"_category_entity",
")",
"{",
... | Caches the current state and access for categories before they are changed.
@param KControllerContextInterface $context | [
"Caches",
"the",
"current",
"state",
"and",
"access",
"for",
"categories",
"before",
"they",
"are",
"changed",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/findable.php#L148-L160 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/findable.php | ComKoowaControllerBehaviorFindable._afterEdit | protected function _afterEdit(KControllerContextInterface $context)
{
$name = $this->getMixer()->getIdentifier()->name;
foreach ($context->result as $entity)
{
if ($entity->getStatus() !== KDatabase::STATUS_FAILED)
{
if ($name === $this->_category_entity)
{
if (($entity->old_enabled !== $entity->enabled) || ($entity->old_access !== $entity->access))
{
$category_context = 'com_'.$this->_package.'.'.$this->_category_entity;
$this->_getDispatcher()->trigger('onFinderAfterSave', array($category_context, $entity, false));
}
} else {
$this->_getDispatcher()->trigger('onFinderAfterSave', array($this->_event_context, $entity, false));
}
}
}
} | php | protected function _afterEdit(KControllerContextInterface $context)
{
$name = $this->getMixer()->getIdentifier()->name;
foreach ($context->result as $entity)
{
if ($entity->getStatus() !== KDatabase::STATUS_FAILED)
{
if ($name === $this->_category_entity)
{
if (($entity->old_enabled !== $entity->enabled) || ($entity->old_access !== $entity->access))
{
$category_context = 'com_'.$this->_package.'.'.$this->_category_entity;
$this->_getDispatcher()->trigger('onFinderAfterSave', array($category_context, $entity, false));
}
} else {
$this->_getDispatcher()->trigger('onFinderAfterSave', array($this->_event_context, $entity, false));
}
}
}
} | [
"protected",
"function",
"_afterEdit",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getMixer",
"(",
")",
"->",
"getIdentifier",
"(",
")",
"->",
"name",
";",
"foreach",
"(",
"$",
"context",
"->",
"resul... | Modifies the index after save
Also updates the state and access of items that belong to an edited category
@param KControllerContextInterface $context | [
"Modifies",
"the",
"index",
"after",
"save"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/findable.php#L169-L190 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/findable.php | ComKoowaControllerBehaviorFindable._afterAdd | protected function _afterAdd(KControllerContextInterface $context)
{
$entity = $context->result;
$name = $entity->getIdentifier()->name;
if ($name === $this->_entity && $entity->getStatus() !== KDatabase::STATUS_FAILED) {
$this->_getDispatcher()->trigger('onFinderAfterSave', array($this->_event_context, $entity, true));
}
} | php | protected function _afterAdd(KControllerContextInterface $context)
{
$entity = $context->result;
$name = $entity->getIdentifier()->name;
if ($name === $this->_entity && $entity->getStatus() !== KDatabase::STATUS_FAILED) {
$this->_getDispatcher()->trigger('onFinderAfterSave', array($this->_event_context, $entity, true));
}
} | [
"protected",
"function",
"_afterAdd",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"$",
"entity",
"=",
"$",
"context",
"->",
"result",
";",
"$",
"name",
"=",
"$",
"entity",
"->",
"getIdentifier",
"(",
")",
"->",
"name",
";",
"if",
"(",
"... | Add new items to the index
@param KControllerContextInterface $context | [
"Add",
"new",
"items",
"to",
"the",
"index"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/findable.php#L197-L205 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/findable.php | ComKoowaControllerBehaviorFindable._afterDelete | protected function _afterDelete(KControllerContextInterface $context)
{
$name = $this->getMixer()->getIdentifier()->name;
if ($name === $this->_entity)
{
foreach ($context->result as $entity)
{
if ($entity->getStatus() === KDatabase::STATUS_DELETED) {
$this->_getDispatcher()->trigger('onFinderAfterDelete', array($this->_event_context, $entity));
}
}
}
} | php | protected function _afterDelete(KControllerContextInterface $context)
{
$name = $this->getMixer()->getIdentifier()->name;
if ($name === $this->_entity)
{
foreach ($context->result as $entity)
{
if ($entity->getStatus() === KDatabase::STATUS_DELETED) {
$this->_getDispatcher()->trigger('onFinderAfterDelete', array($this->_event_context, $entity));
}
}
}
} | [
"protected",
"function",
"_afterDelete",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getMixer",
"(",
")",
"->",
"getIdentifier",
"(",
")",
"->",
"name",
";",
"if",
"(",
"$",
"name",
"===",
"$",
"thi... | Delete items from the index
@param KControllerContextInterface $context | [
"Delete",
"items",
"from",
"the",
"index"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/findable.php#L212-L225 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/abstract.php | KDispatcherAbstract._actionForward | protected function _actionForward(KDispatcherContextInterface $context)
{
//Get the dispatcher identifier
if(is_string($context->param) && strpos($context->param, '.') === false )
{
$identifier = $this->getIdentifier()->toArray();
$identifier['package'] = $context->param;
}
else $identifier = $this->getIdentifier($context->param);
//Create the dispatcher
$config = array(
'request' => $context->request,
'response' => $context->response,
'user' => $context->user,
'forwarded' => $this
);
$dispatcher = $this->getObject($identifier, $config);
if(!$dispatcher instanceof KDispatcherInterface)
{
throw new UnexpectedValueException(
'Dispatcher: '.get_class($dispatcher).' does not implement KDispatcherInterface'
);
}
$dispatcher->dispatch($context);
} | php | protected function _actionForward(KDispatcherContextInterface $context)
{
//Get the dispatcher identifier
if(is_string($context->param) && strpos($context->param, '.') === false )
{
$identifier = $this->getIdentifier()->toArray();
$identifier['package'] = $context->param;
}
else $identifier = $this->getIdentifier($context->param);
//Create the dispatcher
$config = array(
'request' => $context->request,
'response' => $context->response,
'user' => $context->user,
'forwarded' => $this
);
$dispatcher = $this->getObject($identifier, $config);
if(!$dispatcher instanceof KDispatcherInterface)
{
throw new UnexpectedValueException(
'Dispatcher: '.get_class($dispatcher).' does not implement KDispatcherInterface'
);
}
$dispatcher->dispatch($context);
} | [
"protected",
"function",
"_actionForward",
"(",
"KDispatcherContextInterface",
"$",
"context",
")",
"{",
"//Get the dispatcher identifier",
"if",
"(",
"is_string",
"(",
"$",
"context",
"->",
"param",
")",
"&&",
"strpos",
"(",
"$",
"context",
"->",
"param",
",",
... | Forward the request
Forward to another dispatcher internally. Method makes an internal sub-request, calling the specified
dispatcher and passing along the context.
@param KDispatcherContextInterface $context A dispatcher context object
@throws UnexpectedValueException If the dispatcher doesn't implement the KDispatcherInterface | [
"Forward",
"the",
"request"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/abstract.php#L303-L331 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/exception/error.php | KExceptionError.getSeverityMessage | public function getSeverityMessage()
{
$severity = $this->getSeverity();
if(isset(self::$severity_messages[$severity])) {
$message = self::$severity_messages[$severity];
} else {
$message = 'Unknown error';
}
return $message;
} | php | public function getSeverityMessage()
{
$severity = $this->getSeverity();
if(isset(self::$severity_messages[$severity])) {
$message = self::$severity_messages[$severity];
} else {
$message = 'Unknown error';
}
return $message;
} | [
"public",
"function",
"getSeverityMessage",
"(",
")",
"{",
"$",
"severity",
"=",
"$",
"this",
"->",
"getSeverity",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"severity_messages",
"[",
"$",
"severity",
"]",
")",
")",
"{",
"$",
"message",... | Return the severity message
@return string | [
"Return",
"the",
"severity",
"message"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/exception/error.php#L48-L59 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/class/registry/registry.php | KClassRegistry.find | public function find($class)
{
//Resolve the real identifier in case an alias was passed
while(array_key_exists($class, $this->_aliases)) {
$class = $this->_aliases[$class];
}
//Find the identifier
if($this->offsetExists($class)) {
$result = $this->offsetGet($class);
} else {
$result = null;
}
return $result;
} | php | public function find($class)
{
//Resolve the real identifier in case an alias was passed
while(array_key_exists($class, $this->_aliases)) {
$class = $this->_aliases[$class];
}
//Find the identifier
if($this->offsetExists($class)) {
$result = $this->offsetGet($class);
} else {
$result = null;
}
return $result;
} | [
"public",
"function",
"find",
"(",
"$",
"class",
")",
"{",
"//Resolve the real identifier in case an alias was passed",
"while",
"(",
"array_key_exists",
"(",
"$",
"class",
",",
"$",
"this",
"->",
"_aliases",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->"... | Try to find an class path based on a class name
@param string $class
@return string The class path, or NULL if the class is not registered | [
"Try",
"to",
"find",
"an",
"class",
"path",
"based",
"on",
"a",
"class",
"name"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/class/registry/registry.php#L95-L110 | train |
joomlatools/joomlatools-framework | code/plugins/system/joomlatools/script.php | JoomlatoolsTemporaryDispatcher.disableLogman | public static function disableLogman()
{
$dispatcher = JEventDispatcher::getInstance();
foreach ($dispatcher->_observers as $key => $observer)
{
if (is_object($observer)
&& (substr(get_class($observer), 0, 9) === 'PlgLogman' || get_class($observer) === 'PlgSystemKoowa')) {
$dispatcher->detach($observer);
}
}
$logman_manifest = JPATH_ADMINISTRATOR.'/components/com_logman/logman.xml';
if (file_exists($logman_manifest))
{
$manifest = simplexml_load_file($logman_manifest);
if ($manifest && $manifest->version)
{
$version = (string)$manifest->version;
if ($version && version_compare($version, '3', '<'))
{
$db = JFactory::getDbo();
$query = "UPDATE #__extensions SET enabled = 0 WHERE type='plugin' AND folder='koowa' AND element='logman'";
$db->setQuery($query)->query();
$query = "UPDATE #__extensions SET enabled = 0 WHERE type='plugin' AND folder='system' AND element='logman'";
$db->setQuery($query)->query();
$query = "UPDATE #__modules SET published = 0 WHERE module='mod_logman'";
$db->setQuery($query)->query();
}
}
}
} | php | public static function disableLogman()
{
$dispatcher = JEventDispatcher::getInstance();
foreach ($dispatcher->_observers as $key => $observer)
{
if (is_object($observer)
&& (substr(get_class($observer), 0, 9) === 'PlgLogman' || get_class($observer) === 'PlgSystemKoowa')) {
$dispatcher->detach($observer);
}
}
$logman_manifest = JPATH_ADMINISTRATOR.'/components/com_logman/logman.xml';
if (file_exists($logman_manifest))
{
$manifest = simplexml_load_file($logman_manifest);
if ($manifest && $manifest->version)
{
$version = (string)$manifest->version;
if ($version && version_compare($version, '3', '<'))
{
$db = JFactory::getDbo();
$query = "UPDATE #__extensions SET enabled = 0 WHERE type='plugin' AND folder='koowa' AND element='logman'";
$db->setQuery($query)->query();
$query = "UPDATE #__extensions SET enabled = 0 WHERE type='plugin' AND folder='system' AND element='logman'";
$db->setQuery($query)->query();
$query = "UPDATE #__modules SET published = 0 WHERE module='mod_logman'";
$db->setQuery($query)->query();
}
}
}
} | [
"public",
"static",
"function",
"disableLogman",
"(",
")",
"{",
"$",
"dispatcher",
"=",
"JEventDispatcher",
"::",
"getInstance",
"(",
")",
";",
"foreach",
"(",
"$",
"dispatcher",
"->",
"_observers",
"as",
"$",
"key",
"=>",
"$",
"observer",
")",
"{",
"if",
... | Get rid of registered Logman plugins and disable it permanently afterwards if it's version 1 or 2 | [
"Get",
"rid",
"of",
"registered",
"Logman",
"plugins",
"and",
"disable",
"it",
"permanently",
"afterwards",
"if",
"it",
"s",
"version",
"1",
"or",
"2"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/plugins/system/joomlatools/script.php#L16-L52 | train |
joomlatools/joomlatools-framework | code/plugins/system/joomlatools/script.php | PlgSystemJoomlatoolsInstallerScript.bootFramework | public function bootFramework()
{
if (class_exists('Koowa')) {
return true;
}
$path = JPATH_PLUGINS.'/system/joomlatools/joomlatools.php';
if (!file_exists($path)) {
return false;
}
require_once $path;
$dispatcher = JEventDispatcher::getInstance();
$className = 'PlgSystemJoomlatools';
// Constructor does all the work in the plugin
if (class_exists($className))
{
$db = JFactory::getDbo();
$db->setQuery(/** @lang text */"SELECT folder AS type, element AS name, params
FROM #__extensions
WHERE folder = 'system' AND element = 'joomlatools'"
);
$plugin = $db->loadObject();
new $className($dispatcher, (array) ($plugin));
}
return class_exists('Koowa');
} | php | public function bootFramework()
{
if (class_exists('Koowa')) {
return true;
}
$path = JPATH_PLUGINS.'/system/joomlatools/joomlatools.php';
if (!file_exists($path)) {
return false;
}
require_once $path;
$dispatcher = JEventDispatcher::getInstance();
$className = 'PlgSystemJoomlatools';
// Constructor does all the work in the plugin
if (class_exists($className))
{
$db = JFactory::getDbo();
$db->setQuery(/** @lang text */"SELECT folder AS type, element AS name, params
FROM #__extensions
WHERE folder = 'system' AND element = 'joomlatools'"
);
$plugin = $db->loadObject();
new $className($dispatcher, (array) ($plugin));
}
return class_exists('Koowa');
} | [
"public",
"function",
"bootFramework",
"(",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'Koowa'",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"path",
"=",
"JPATH_PLUGINS",
".",
"'/system/joomlatools/joomlatools.php'",
";",
"if",
"(",
"!",
"file_exists",
"... | Can't use JPluginHelper here since there is no way
of clearing the cached list of plugins.
@return bool | [
"Can",
"t",
"use",
"JPluginHelper",
"here",
"since",
"there",
"is",
"no",
"way",
"of",
"clearing",
"the",
"cached",
"list",
"of",
"plugins",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/plugins/system/joomlatools/script.php#L417-L448 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/abstract.php | KFilesystemStreamAbstract.copy | public function copy($stream)
{
if($this->getResource())
{
if (!$stream instanceof KFilesystemStreamInterface && !is_resource($stream) && !get_resource_type($stream) == 'stream')
{
throw new InvalidArgumentException(sprintf(
'Stream must be on object implementing the FilesystemStreamInterface or a resource of type "stream".'
));
}
if($stream instanceof KFilesystemStreamInterface) {
$resource = $stream->getResource();
} else {
$resource = $stream;
}
return fwrite($resource, $this->read());
}
return false;
} | php | public function copy($stream)
{
if($this->getResource())
{
if (!$stream instanceof KFilesystemStreamInterface && !is_resource($stream) && !get_resource_type($stream) == 'stream')
{
throw new InvalidArgumentException(sprintf(
'Stream must be on object implementing the FilesystemStreamInterface or a resource of type "stream".'
));
}
if($stream instanceof KFilesystemStreamInterface) {
$resource = $stream->getResource();
} else {
$resource = $stream;
}
return fwrite($resource, $this->read());
}
return false;
} | [
"public",
"function",
"copy",
"(",
"$",
"stream",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getResource",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"stream",
"instanceof",
"KFilesystemStreamInterface",
"&&",
"!",
"is_resource",
"(",
"$",
"stream",
")",
"... | Copy data from one stream to another stream
@param resource|KFilesystemStreamInterface $stream The stream resource to copy the data too
@return bool Returns TRUE on success, FALSE on failure | [
"Copy",
"data",
"from",
"one",
"stream",
"to",
"another",
"stream"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/abstract.php#L346-L367 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/abstract.php | KFilesystemStreamAbstract.getSize | public function getSize()
{
// If the stream is a file based stream and local, then use fstat
clearstatcache(true, $this->getPath());
$info = $this->getInfo();
if (isset($info['size'])) {
$size = $info['size'];
} else {
$size = strlen((string) $this->toString());
}
return $size;
} | php | public function getSize()
{
// If the stream is a file based stream and local, then use fstat
clearstatcache(true, $this->getPath());
$info = $this->getInfo();
if (isset($info['size'])) {
$size = $info['size'];
} else {
$size = strlen((string) $this->toString());
}
return $size;
} | [
"public",
"function",
"getSize",
"(",
")",
"{",
"// If the stream is a file based stream and local, then use fstat",
"clearstatcache",
"(",
"true",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"getInfo",
"(",
")",
... | Get the size of the stream
@return int|bool | [
"Get",
"the",
"size",
"of",
"the",
"stream"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/abstract.php#L607-L621 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/abstract.php | KFilesystemStreamAbstract.getOptions | public function getOptions()
{
if($resource = $this->getResource())
{
$options = stream_context_get_options($resource);
if(!empty($options))
{
$name = key($options);
$result = $options[$name];
}
else $result = array();
return $result;
}
return $this->_options;
} | php | public function getOptions()
{
if($resource = $this->getResource())
{
$options = stream_context_get_options($resource);
if(!empty($options))
{
$name = key($options);
$result = $options[$name];
}
else $result = array();
return $result;
}
return $this->_options;
} | [
"public",
"function",
"getOptions",
"(",
")",
"{",
"if",
"(",
"$",
"resource",
"=",
"$",
"this",
"->",
"getResource",
"(",
")",
")",
"{",
"$",
"options",
"=",
"stream_context_get_options",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"!",
"empty",
"(",
... | Get the stream options
@return array | [
"Get",
"the",
"stream",
"options"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/abstract.php#L628-L645 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/abstract.php | KFilesystemStreamAbstract.setBuffer | public function setBuffer($mode, $size)
{
if($resource = $this->getResource()) {
return stream_set_write_buffer($resource, $size);
}
return false;
} | php | public function setBuffer($mode, $size)
{
if($resource = $this->getResource()) {
return stream_set_write_buffer($resource, $size);
}
return false;
} | [
"public",
"function",
"setBuffer",
"(",
"$",
"mode",
",",
"$",
"size",
")",
"{",
"if",
"(",
"$",
"resource",
"=",
"$",
"this",
"->",
"getResource",
"(",
")",
")",
"{",
"return",
"stream_set_write_buffer",
"(",
"$",
"resource",
",",
"$",
"size",
")",
... | Sets write file buffering on the given stream
@param int $mode STREAM_BUFFER_NONE or STREAM_BUFFER_FULL
@param int $size The number of bytes to buffer. If buffer is 0 then write operations are unbuffered. This
ensures that all writes with fwrite() are completed before other processes are allowed to
write to the stream
@return int|false Returns 0 on success, or FALSE on failure | [
"Sets",
"write",
"file",
"buffering",
"on",
"the",
"given",
"stream"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/abstract.php#L789-L796 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/abstract.php | KFilesystemStreamAbstract.addFilter | public function addFilter($filter, $config = array())
{
$result = false;
if(is_resource($this->_resource))
{
//Handle custom filters
if(!in_array($filter, stream_get_filters()))
{
//Create the complete identifier if a partial identifier was passed
if (is_string($filter) && strpos($filter, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('stream', 'filter');
$identifier['name'] = $filter;
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($filter);
//Make sure the class
$class = $this->getObject('manager')->getClass($identifier);
if(array_key_exists('KFilesystemStreamFilterInterface', class_implements($class)))
{
$filter = $class::getName();
if (!empty($filter) && !in_array($filter, stream_get_filters())) {
stream_filter_register($filter, $class);
}
}
}
//If we have a valid filter name create the filter and append it
if(is_string($filter) && !empty($filter))
{
$mode = 0;
if($this->isReadable()) {
$mode = $mode & STREAM_FILTER_READ;
}
if($this->isWritable()) {
$mode = $mode & STREAM_FILTER_WRITE;
}
if($resource = stream_filter_append($this->_resource, $filter, $mode, $config))
{
$this->_filters[$filter] = $filter;
$result = true;
}
}
}
return $result;
} | php | public function addFilter($filter, $config = array())
{
$result = false;
if(is_resource($this->_resource))
{
//Handle custom filters
if(!in_array($filter, stream_get_filters()))
{
//Create the complete identifier if a partial identifier was passed
if (is_string($filter) && strpos($filter, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('stream', 'filter');
$identifier['name'] = $filter;
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($filter);
//Make sure the class
$class = $this->getObject('manager')->getClass($identifier);
if(array_key_exists('KFilesystemStreamFilterInterface', class_implements($class)))
{
$filter = $class::getName();
if (!empty($filter) && !in_array($filter, stream_get_filters())) {
stream_filter_register($filter, $class);
}
}
}
//If we have a valid filter name create the filter and append it
if(is_string($filter) && !empty($filter))
{
$mode = 0;
if($this->isReadable()) {
$mode = $mode & STREAM_FILTER_READ;
}
if($this->isWritable()) {
$mode = $mode & STREAM_FILTER_WRITE;
}
if($resource = stream_filter_append($this->_resource, $filter, $mode, $config))
{
$this->_filters[$filter] = $filter;
$result = true;
}
}
}
return $result;
} | [
"public",
"function",
"addFilter",
"(",
"$",
"filter",
",",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"_resource",
")",
")",
"{",
"//Handle custom filters",
"if"... | Add a filter in FIFO order
@param mixed $filter An object that implements ObjectInterface, ObjectIdentifier object
or valid identifier string
@param array $config An optional array of filter config options
@return bool Returns TRUE if the filter was added, FALSE otherwise | [
"Add",
"a",
"filter",
"in",
"FIFO",
"order"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/abstract.php#L806-L860 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/abstract.php | KFilesystemStreamAbstract.removeFilter | public function removeFilter($filter)
{
$result = false;
if(!is_resource($filter) && isset($this->_filters[$filter])){
$filter = $this->_filters[$filter];
}
if(is_resource($filter)) {
$result = stream_filter_remove($filter);
}
return $result;
} | php | public function removeFilter($filter)
{
$result = false;
if(!is_resource($filter) && isset($this->_filters[$filter])){
$filter = $this->_filters[$filter];
}
if(is_resource($filter)) {
$result = stream_filter_remove($filter);
}
return $result;
} | [
"public",
"function",
"removeFilter",
"(",
"$",
"filter",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"filter",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"_filters",
"[",
"$",
"filter",
"]",
")",
")",
"{",... | Remove a filter
@param string $filter The name of the filter
@return bool Returns TRUE if the filter was detached, FALSE otherwise | [
"Remove",
"a",
"filter"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/abstract.php#L868-L880 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/abstract.php | KFilesystemStreamAbstract.getFilter | public function getFilter($name)
{
$filter = null;
if(isset($this->_filters[$name])) {
$filter = $this->_filters[$name];
}
return $filter;
} | php | public function getFilter($name)
{
$filter = null;
if(isset($this->_filters[$name])) {
$filter = $this->_filters[$name];
}
return $filter;
} | [
"public",
"function",
"getFilter",
"(",
"$",
"name",
")",
"{",
"$",
"filter",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_filters",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"_filters",
"[",
... | Get a filter
@param string $name The name of the filter
@return resource The filter resource | [
"Get",
"a",
"filter"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/abstract.php#L899-L907 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/abstract.php | KFilesystemStreamAbstract.isSeekable | public function isSeekable()
{
if($resource = $this->getResource())
{
$data = stream_get_meta_data($resource);
return (bool) $data['seekable'];
}
return false;
} | php | public function isSeekable()
{
if($resource = $this->getResource())
{
$data = stream_get_meta_data($resource);
return (bool) $data['seekable'];
}
return false;
} | [
"public",
"function",
"isSeekable",
"(",
")",
"{",
"if",
"(",
"$",
"resource",
"=",
"$",
"this",
"->",
"getResource",
"(",
")",
")",
"{",
"$",
"data",
"=",
"stream_get_meta_data",
"(",
"$",
"resource",
")",
";",
"return",
"(",
"bool",
")",
"$",
"data... | Check if the stream is seekable
@return bool Returns TRUE on success or FALSE on failure. | [
"Check",
"if",
"the",
"stream",
"is",
"seekable"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/abstract.php#L944-L954 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/abstract.php | KFilesystemStreamAbstract.toString | public function toString()
{
$result = '';
if ($this->isReadable() && $this->isSeekable())
{
$position = $this->peek();
$this->seek(0);
$result = stream_get_contents($this->_resource);
$this->seek($position);
}
return $result;
} | php | public function toString()
{
$result = '';
if ($this->isReadable() && $this->isSeekable())
{
$position = $this->peek();
$this->seek(0);
$result = stream_get_contents($this->_resource);
$this->seek($position);
}
return $result;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"isReadable",
"(",
")",
"&&",
"$",
"this",
"->",
"isSeekable",
"(",
")",
")",
"{",
"$",
"position",
"=",
"$",
"this",
"->",
"peek",
"(",... | Reads all data from the stream into a string, from the beginning to end.
This method MUST attempt to seek to the beginning of the stream before reading data and read the stream until
the end is reached. The file pointer should stay at it's original position.
Warning: This could attempt to load a large amount of data into memory.
@return string | [
"Reads",
"all",
"data",
"from",
"the",
"stream",
"into",
"a",
"string",
"from",
"the",
"beginning",
"to",
"end",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/abstract.php#L1034-L1048 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/locator/abstract.php | KObjectLocatorAbstract.find | public function find(array $info, $fallback = true)
{
$result = false;
//Find the class
foreach($this->_sequence as $template)
{
$class = str_replace(
array('<Package>' ,'<Path>' ,'<File>' , '<Class>'),
array($info['package'], $info['path'], $info['file'], $info['class']),
$template
);
if(class_exists($class))
{
$result = $class;
break;
}
if(!$fallback) {
break;
}
}
return $result;
} | php | public function find(array $info, $fallback = true)
{
$result = false;
//Find the class
foreach($this->_sequence as $template)
{
$class = str_replace(
array('<Package>' ,'<Path>' ,'<File>' , '<Class>'),
array($info['package'], $info['path'], $info['file'], $info['class']),
$template
);
if(class_exists($class))
{
$result = $class;
break;
}
if(!$fallback) {
break;
}
}
return $result;
} | [
"public",
"function",
"find",
"(",
"array",
"$",
"info",
",",
"$",
"fallback",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"false",
";",
"//Find the class",
"foreach",
"(",
"$",
"this",
"->",
"_sequence",
"as",
"$",
"template",
")",
"{",
"$",
"class",
... | Find a class
@param array $info The class information
@param bool $fallback If TRUE use the fallback sequence
@return bool|mixed | [
"Find",
"a",
"class"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/locator/abstract.php#L95-L120 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/view/csv.php | KViewCsv._quoteValue | protected function _quoteValue($value)
{
if(is_numeric($value)) {
return false;
}
if(strpos($value, $this->separator) !== false) { // Separator is present in field
return true;
}
if(strpos($value, $this->quote) !== false) { // Quote character is present in field
return true;
}
if (strpos($value, "\n") !== false || strpos($value, "\r") !== false ) { // Newline is present in field
return true;
}
if(substr($value, 0, 1) == " " || substr($value, -1) == " ") { // Space found at beginning or end of field value
return true;
}
return false;
} | php | protected function _quoteValue($value)
{
if(is_numeric($value)) {
return false;
}
if(strpos($value, $this->separator) !== false) { // Separator is present in field
return true;
}
if(strpos($value, $this->quote) !== false) { // Quote character is present in field
return true;
}
if (strpos($value, "\n") !== false || strpos($value, "\r") !== false ) { // Newline is present in field
return true;
}
if(substr($value, 0, 1) == " " || substr($value, -1) == " ") { // Space found at beginning or end of field value
return true;
}
return false;
} | [
"protected",
"function",
"_quoteValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"separator",
")",
"!==",
"f... | Check if the value should be quoted
@param string $value Value
@return boolean | [
"Check",
"if",
"the",
"value",
"should",
"be",
"quoted"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/view/csv.php#L135-L158 | train |
joomlatools/joomlatools-framework | code/plugins/system/joomlatools/joomlatools.php | PlgSystemJoomlatools._proxyEvent | protected function _proxyEvent($event, $args = array())
{
//Publish the event
if (class_exists('Koowa')) {
KObjectManager::getInstance()->getObject('event.publisher')->publishEvent($event, $args, JFactory::getApplication());
}
} | php | protected function _proxyEvent($event, $args = array())
{
//Publish the event
if (class_exists('Koowa')) {
KObjectManager::getInstance()->getObject('event.publisher')->publishEvent($event, $args, JFactory::getApplication());
}
} | [
"protected",
"function",
"_proxyEvent",
"(",
"$",
"event",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"//Publish the event",
"if",
"(",
"class_exists",
"(",
"'Koowa'",
")",
")",
"{",
"KObjectManager",
"::",
"getInstance",
"(",
")",
"->",
"getObjec... | Proxy all Joomla events
@param array &$args Arguments
@return mixed Routine return value | [
"Proxy",
"all",
"Joomla",
"events"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/plugins/system/joomlatools/joomlatools.php#L299-L305 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/editor.php | ComKoowaTemplateHelperEditor.display | public function display($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'editor' => null,
'name' => 'description',
'value' => '',
'width' => '100%',
'height' => '500',
'cols' => '75',
'rows' => '20',
'buttons' => true,
'options' => array()
));
// Add editor styles and scripts in JDocument to page when rendering
$this->getIdentifier('com:koowa.view.page.html')->getConfig()->append(['template_filters' => ['document']]);
$editor = JFactory::getEditor($config->editor);
$options = KObjectConfig::unbox($config->options);
$result = $editor->display($config->name, $config->value, $config->width, $config->height, $config->cols, $config->rows, KObjectConfig::unbox($config->buttons), $config->name, null, null, $options);
// Some editors like CKEditor return inline JS.
$result = str_replace('<script', '<script data-inline', $result);
return $result;
} | php | public function display($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'editor' => null,
'name' => 'description',
'value' => '',
'width' => '100%',
'height' => '500',
'cols' => '75',
'rows' => '20',
'buttons' => true,
'options' => array()
));
// Add editor styles and scripts in JDocument to page when rendering
$this->getIdentifier('com:koowa.view.page.html')->getConfig()->append(['template_filters' => ['document']]);
$editor = JFactory::getEditor($config->editor);
$options = KObjectConfig::unbox($config->options);
$result = $editor->display($config->name, $config->value, $config->width, $config->height, $config->cols, $config->rows, KObjectConfig::unbox($config->buttons), $config->name, null, null, $options);
// Some editors like CKEditor return inline JS.
$result = str_replace('<script', '<script data-inline', $result);
return $result;
} | [
"public",
"function",
"display",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'editor'",
"=>",
"null",
",",
"'na... | Generates an HTML editor
@param array $config An optional array with configuration options
@return string Html | [
"Generates",
"an",
"HTML",
"editor"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/editor.php#L24-L51 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/abstract.php | KUserSessionAbstract.getContainer | public function getContainer($name)
{
if (!($name instanceof KObjectIdentifier))
{
//Create the complete identifier if a partial identifier was passed
if (is_string($name) && strpos($name, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('session', 'container');
$identifier['name'] = $name;
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($name);
}
else $identifier = $name;
if (!isset($this->_containers[$identifier->name]))
{
$container = $this->getObject($identifier);
if (!($container instanceof KUserSessionContainerInterface))
{
throw new UnexpectedValueException(
'Container: '. get_class($container) .' does not implement KUserSessionContainerInterface'
);
}
//Load the container from the session
$namespace = $this->getNamespace();
$container->load($_SESSION[$namespace]);
$this->_containers[$container->getIdentifier()->name] = $container;
}
else $container = $this->_containers[$identifier->name];
return $container;
} | php | public function getContainer($name)
{
if (!($name instanceof KObjectIdentifier))
{
//Create the complete identifier if a partial identifier was passed
if (is_string($name) && strpos($name, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('session', 'container');
$identifier['name'] = $name;
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($name);
}
else $identifier = $name;
if (!isset($this->_containers[$identifier->name]))
{
$container = $this->getObject($identifier);
if (!($container instanceof KUserSessionContainerInterface))
{
throw new UnexpectedValueException(
'Container: '. get_class($container) .' does not implement KUserSessionContainerInterface'
);
}
//Load the container from the session
$namespace = $this->getNamespace();
$container->load($_SESSION[$namespace]);
$this->_containers[$container->getIdentifier()->name] = $container;
}
else $container = $this->_containers[$identifier->name];
return $container;
} | [
"public",
"function",
"getContainer",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"name",
"instanceof",
"KObjectIdentifier",
")",
")",
"{",
"//Create the complete identifier if a partial identifier was passed",
"if",
"(",
"is_string",
"(",
"$",
"name",
"... | Get the session attribute container object
If the container does not exist a container will be created on the fly.
@param mixed $name An object that implements ObjectInterface, ObjectIdentifier object
or valid identifier string
@throws UnexpectedValueException If the identifier is not a session container identifier
@return KUserSessionContainerInterface | [
"Get",
"the",
"session",
"attribute",
"container",
"object"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/abstract.php#L378-L415 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/abstract.php | KUserSessionAbstract.isActive | public function isActive()
{
$sid = defined('SID') ? constant('SID') : false;
if ($sid !== false && session_id()) {
return true;
}
if (headers_sent()) {
return true;
}
return false;
} | php | public function isActive()
{
$sid = defined('SID') ? constant('SID') : false;
if ($sid !== false && session_id()) {
return true;
}
if (headers_sent()) {
return true;
}
return false;
} | [
"public",
"function",
"isActive",
"(",
")",
"{",
"$",
"sid",
"=",
"defined",
"(",
"'SID'",
")",
"?",
"constant",
"(",
"'SID'",
")",
":",
"false",
";",
"if",
"(",
"$",
"sid",
"!==",
"false",
"&&",
"session_id",
"(",
")",
")",
"{",
"return",
"true",
... | Is this session active
@return boolean True on success, false otherwise | [
"Is",
"this",
"session",
"active"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/abstract.php#L422-L434 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/abstract.php | KUserSessionAbstract.start | public function start()
{
if (!$this->isActive())
{
//Make sure we have a registered session handler
if (!$this->getHandler()->isRegistered()) {
$this->getHandler()->register();
}
session_cache_limiter('none');
if (ini_get('session.use_cookies') && headers_sent()) {
throw new RuntimeException('Failed to start the session because headers have already been sent');
}
if (!session_start()) {
throw new RuntimeException('Session could not be started');
}
//Re-load the session containers
$this->refesh();
// Destroy an expired session
if ($this->getContainer('metadata')->isExpired()) {
$this->destroy();
}
}
return $this;
} | php | public function start()
{
if (!$this->isActive())
{
//Make sure we have a registered session handler
if (!$this->getHandler()->isRegistered()) {
$this->getHandler()->register();
}
session_cache_limiter('none');
if (ini_get('session.use_cookies') && headers_sent()) {
throw new RuntimeException('Failed to start the session because headers have already been sent');
}
if (!session_start()) {
throw new RuntimeException('Session could not be started');
}
//Re-load the session containers
$this->refesh();
// Destroy an expired session
if ($this->getContainer('metadata')->isExpired()) {
$this->destroy();
}
}
return $this;
} | [
"public",
"function",
"start",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isActive",
"(",
")",
")",
"{",
"//Make sure we have a registered session handler",
"if",
"(",
"!",
"$",
"this",
"->",
"getHandler",
"(",
")",
"->",
"isRegistered",
"(",
")",
... | Starts the session storage and load the session data into memory
@see session_start()
@throws RuntimeException If something goes wrong starting the session.
@return $this | [
"Starts",
"the",
"session",
"storage",
"and",
"load",
"the",
"session",
"data",
"into",
"memory"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/abstract.php#L443-L472 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/abstract.php | KUserSessionAbstract.refresh | public function refresh()
{
//Create the namespace if it doesn't exist
$namespace = $this->getNamespace();
if(!isset($_SESSION[$namespace])) {
$_SESSION[$namespace] = array();
}
//Re-load the session containers
foreach($this->_containers as $container)
{
$namespace = $this->getNamespace();
$container->load($_SESSION[$namespace]);
}
return $this;
} | php | public function refresh()
{
//Create the namespace if it doesn't exist
$namespace = $this->getNamespace();
if(!isset($_SESSION[$namespace])) {
$_SESSION[$namespace] = array();
}
//Re-load the session containers
foreach($this->_containers as $container)
{
$namespace = $this->getNamespace();
$container->load($_SESSION[$namespace]);
}
return $this;
} | [
"public",
"function",
"refresh",
"(",
")",
"{",
"//Create the namespace if it doesn't exist",
"$",
"namespace",
"=",
"$",
"this",
"->",
"getNamespace",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"namespace",
"]",
")",
")",
"{",... | Refresh the session data in the memory containers
This function will load the data from $_SESSION in the various registered containers, based on the container
namespace.
@return $this | [
"Refresh",
"the",
"session",
"data",
"in",
"the",
"memory",
"containers"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/abstract.php#L482-L499 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/abstract.php | KUserSessionAbstract.fork | public function fork($destroy = true, $lifetime = null)
{
if ($this->isActive())
{
if ($lifetime !== null) {
ini_set('session.cookie_lifetime', $lifetime);
}
if (!session_regenerate_id($destroy)) {
throw new RuntimeException('Session could not be forked');
}
}
return $this;
} | php | public function fork($destroy = true, $lifetime = null)
{
if ($this->isActive())
{
if ($lifetime !== null) {
ini_set('session.cookie_lifetime', $lifetime);
}
if (!session_regenerate_id($destroy)) {
throw new RuntimeException('Session could not be forked');
}
}
return $this;
} | [
"public",
"function",
"fork",
"(",
"$",
"destroy",
"=",
"true",
",",
"$",
"lifetime",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isActive",
"(",
")",
")",
"{",
"if",
"(",
"$",
"lifetime",
"!==",
"null",
")",
"{",
"ini_set",
"(",
"'sess... | Migrates the current session to a new session id while maintaining all session data
Note : fork should not clear the session data in memory only delete the session data from persistent storage.
@param Boolean $destroy If TRUE, destroy session when forking.
@param integer $lifetime Sets the cookie lifetime for the session cookie. A null value will leave the system
settings unchanged, 0 sets the cookie to expire with browser session. Time is in seconds,
and is not a Unix timestamp.
@see session_regenerate_id()
@throws RuntimeException If an error occurs while forking this storage
@return $this | [
"Migrates",
"the",
"current",
"session",
"to",
"a",
"new",
"session",
"id",
"while",
"maintaining",
"all",
"session",
"data"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/abstract.php#L594-L608 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/date.php | ComKoowaTemplateHelperDate.format | public function format($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'date' => 'now',
'timezone' => true,
'format' => $this->getObject('translator')->translate('DATE_FORMAT_LC3')
));
return JHtml::_('date', $config->date, $config->format, $config->timezone);
} | php | public function format($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'date' => 'now',
'timezone' => true,
'format' => $this->getObject('translator')->translate('DATE_FORMAT_LC3')
));
return JHtml::_('date', $config->date, $config->format, $config->timezone);
} | [
"public",
"function",
"format",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'date'",
"=>",
"'now'",
",",
"'time... | Returns formatted date according to current local
@param array $config An optional array with configuration options.
@return string Formatted date. | [
"Returns",
"formatted",
"date",
"according",
"to",
"current",
"local"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/date.php#L24-L34 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/config/xml.php | KObjectConfigXml._decodeValue | protected static function _decodeValue($node)
{
switch ($node['type'])
{
case 'integer':
$value = (string) $node;
return (int) $value;
break;
case 'string':
return (string) $node;
break;
case 'boolean':
$value = (string) $node;
return (bool) $value;
break;
case 'double':
$value = (string) $node;
return (float) $value;
break;
case 'array':
default :
$value = array();
foreach ($node->children() as $child) {
$value[(string) $child['name']] = self::_decodeValue($child);
}
break;
}
return $value;
} | php | protected static function _decodeValue($node)
{
switch ($node['type'])
{
case 'integer':
$value = (string) $node;
return (int) $value;
break;
case 'string':
return (string) $node;
break;
case 'boolean':
$value = (string) $node;
return (bool) $value;
break;
case 'double':
$value = (string) $node;
return (float) $value;
break;
case 'array':
default :
$value = array();
foreach ($node->children() as $child) {
$value[(string) $child['name']] = self::_decodeValue($child);
}
break;
}
return $value;
} | [
"protected",
"static",
"function",
"_decodeValue",
"(",
"$",
"node",
")",
"{",
"switch",
"(",
"$",
"node",
"[",
"'type'",
"]",
")",
"{",
"case",
"'integer'",
":",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"node",
";",
"return",
"(",
"int",
")",
"... | Method to get a PHP native value for a SimpleXMLElement object
@param object $node SimpleXMLElement object for which to get the native value.
@return mixed Native value of the SimpleXMLElement object. | [
"Method",
"to",
"get",
"a",
"PHP",
"native",
"value",
"for",
"a",
"SimpleXMLElement",
"object"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/config/xml.php#L91-L126 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/event.php | ComKoowaTemplateHelperEvent.trigger | public function trigger($config = array())
{
// Can't put arguments through KObjectConfig as it loses referenced variables
$attributes = isset($config['attributes']) ? $config['attributes'] : array();
$config = new KObjectConfig($config);
$config->append(array(
'name' => null,
'import_group' => null
));
if (empty($config->name)) {
throw new InvalidArgumentException('Event name is required');
}
if(!(count($attributes) > 1)) {
throw new InvalidArgumentException('Event requires at least 2 attributes');
}
if ($config->import_group) {
JPluginHelper::importPlugin($config->import_group);
}
$results = JEventDispatcher::getInstance()->trigger($config->name, $attributes);
if($config->name == 'onContentPrepare')
{
if(isset($attributes[1]) && isset($attributes[1]->text)) {
$result = $attributes[1]->text;
}
}
else $result = trim(implode("\n", $results));
// Leave third party JavaScript as-is
$result = str_replace('<script', '<script data-inline', $result);
return $result;
} | php | public function trigger($config = array())
{
// Can't put arguments through KObjectConfig as it loses referenced variables
$attributes = isset($config['attributes']) ? $config['attributes'] : array();
$config = new KObjectConfig($config);
$config->append(array(
'name' => null,
'import_group' => null
));
if (empty($config->name)) {
throw new InvalidArgumentException('Event name is required');
}
if(!(count($attributes) > 1)) {
throw new InvalidArgumentException('Event requires at least 2 attributes');
}
if ($config->import_group) {
JPluginHelper::importPlugin($config->import_group);
}
$results = JEventDispatcher::getInstance()->trigger($config->name, $attributes);
if($config->name == 'onContentPrepare')
{
if(isset($attributes[1]) && isset($attributes[1]->text)) {
$result = $attributes[1]->text;
}
}
else $result = trim(implode("\n", $results));
// Leave third party JavaScript as-is
$result = str_replace('<script', '<script data-inline', $result);
return $result;
} | [
"public",
"function",
"trigger",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"// Can't put arguments through KObjectConfig as it loses referenced variables",
"$",
"attributes",
"=",
"isset",
"(",
"$",
"config",
"[",
"'attributes'",
"]",
")",
"?",
"$",
"c... | Triggers an event and returns the results
@param array $config
@throws InvalidArgumentException
@return string | [
"Triggers",
"an",
"event",
"and",
"returns",
"the",
"results"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/event.php#L25-L61 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/locator/abstract.php | KTemplateLocatorAbstract.realPath | public function realPath($file)
{
$result = false;
$path = dirname($file);
// Is the path based on a stream?
if (strpos($path, '://') === false)
{
// Not a stream, so do a realpath() to avoid directory traversal attempts on the local file system.
$path = realpath($path); // needed for substr() later
$file = realpath($file);
}
// The substr() check added to make sure that the realpath() results in a directory registered so that
// non-registered directories are not accessible via directory traversal attempts.
if (file_exists($file) && substr($file, 0, strlen($path)) == $path) {
$result = $file;
}
return $result;
} | php | public function realPath($file)
{
$result = false;
$path = dirname($file);
// Is the path based on a stream?
if (strpos($path, '://') === false)
{
// Not a stream, so do a realpath() to avoid directory traversal attempts on the local file system.
$path = realpath($path); // needed for substr() later
$file = realpath($file);
}
// The substr() check added to make sure that the realpath() results in a directory registered so that
// non-registered directories are not accessible via directory traversal attempts.
if (file_exists($file) && substr($file, 0, strlen($path)) == $path) {
$result = $file;
}
return $result;
} | [
"public",
"function",
"realPath",
"(",
"$",
"file",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"path",
"=",
"dirname",
"(",
"$",
"file",
")",
";",
"// Is the path based on a stream?",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'://'",
")",
"===... | Get a path from an file
Function will check if the path is an alias and return the real file path
@param string $file The file path
@return string The real file path | [
"Get",
"a",
"path",
"from",
"an",
"file"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/locator/abstract.php#L71-L91 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filter/chain.php | KFilterChain.validate | public function validate($value)
{
$result = true;
foreach($this->_queue as $filter)
{
if($filter->validate($value) === false) {
$result = false;
}
}
return $result;
} | php | public function validate($value)
{
$result = true;
foreach($this->_queue as $filter)
{
if($filter->validate($value) === false) {
$result = false;
}
}
return $result;
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
")",
"{",
"$",
"result",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"_queue",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"filter",
"->",
"validate",
"(",
"$",
"value",
")",
"===",
... | Validate a scalar or traversable value
NOTE: This should always be a simple yes/no question (is $value valid?), so only true or false should be returned
@param mixed $value Value to be validated
@return bool True when the value is valid. False otherwise. | [
"Validate",
"a",
"scalar",
"or",
"traversable",
"value"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filter/chain.php#L80-L92 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filter/chain.php | KFilterChain.sanitize | public function sanitize($value)
{
foreach($this->_queue as $filter) {
$value = $filter->sanitize($value);
}
return $value;
} | php | public function sanitize($value)
{
foreach($this->_queue as $filter) {
$value = $filter->sanitize($value);
}
return $value;
} | [
"public",
"function",
"sanitize",
"(",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_queue",
"as",
"$",
"filter",
")",
"{",
"$",
"value",
"=",
"$",
"filter",
"->",
"sanitize",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",... | Sanitize a scalar or traversable value
@param mixed $value Value to be sanitized
@return mixed The sanitized value | [
"Sanitize",
"a",
"scalar",
"or",
"traversable",
"value"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filter/chain.php#L100-L107 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filter/chain.php | KFilterChain.addFilter | public function addFilter(KFilterInterface $filter, $priority = null)
{
//Store reference to be used for filter chaining
$this->_last = $filter;
//Enqueue the filter
$this->_queue->enqueue($filter, $priority);
return $this;
} | php | public function addFilter(KFilterInterface $filter, $priority = null)
{
//Store reference to be used for filter chaining
$this->_last = $filter;
//Enqueue the filter
$this->_queue->enqueue($filter, $priority);
return $this;
} | [
"public",
"function",
"addFilter",
"(",
"KFilterInterface",
"$",
"filter",
",",
"$",
"priority",
"=",
"null",
")",
"{",
"//Store reference to be used for filter chaining",
"$",
"this",
"->",
"_last",
"=",
"$",
"filter",
";",
"//Enqueue the filter",
"$",
"this",
"-... | Add a filter to the queue based on priority
@param KFilterInterface $filter A Filter
@param integer $priority The command priority, usually between 1 (high priority) and 5 (lowest),
default is 3. If no priority is set, the command priority will be used
instead.
@return KFilterChain | [
"Add",
"a",
"filter",
"to",
"the",
"queue",
"based",
"on",
"priority"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filter/chain.php#L119-L127 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filter/chain.php | KFilterChain.getErrors | public function getErrors()
{
$errors = array();
foreach($this->_queue as $filter) {
$errors = array_merge($errors, $filter->getErrors());
}
return $errors;
} | php | public function getErrors()
{
$errors = array();
foreach($this->_queue as $filter) {
$errors = array_merge($errors, $filter->getErrors());
}
return $errors;
} | [
"public",
"function",
"getErrors",
"(",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_queue",
"as",
"$",
"filter",
")",
"{",
"$",
"errors",
"=",
"array_merge",
"(",
"$",
"errors",
",",
"$",
"filter",
"->... | Get a list of error that occurred during sanitize or validate
@return array | [
"Get",
"a",
"list",
"of",
"error",
"that",
"occurred",
"during",
"sanitize",
"or",
"validate"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filter/chain.php#L134-L142 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/filesystem/stream/buffer.php | ComKoowaFilesystemStreamBuffer.getTemporaryDirectory | public function getTemporaryDirectory()
{
if (!self::$_temporary_directory)
{
$result = false;
$candidates = array(
ini_get('upload_tmp_dir'),
JFactory::getApplication()->getCfg('tmp_path'),
JPATH_ROOT.'/tmp'
);
if (function_exists('sys_get_temp_dir')) {
array_unshift($candidates, sys_get_temp_dir());
}
foreach ($candidates as $folder)
{
if ($folder && @is_dir($folder) && is_writable($folder))
{
$result = rtrim($folder, '\\/');
break;
}
}
if ($result === false) {
throw new RuntimeException('Cannot find a writable temporary directory');
}
self::$_temporary_directory = $result;
}
return self::$_temporary_directory;
} | php | public function getTemporaryDirectory()
{
if (!self::$_temporary_directory)
{
$result = false;
$candidates = array(
ini_get('upload_tmp_dir'),
JFactory::getApplication()->getCfg('tmp_path'),
JPATH_ROOT.'/tmp'
);
if (function_exists('sys_get_temp_dir')) {
array_unshift($candidates, sys_get_temp_dir());
}
foreach ($candidates as $folder)
{
if ($folder && @is_dir($folder) && is_writable($folder))
{
$result = rtrim($folder, '\\/');
break;
}
}
if ($result === false) {
throw new RuntimeException('Cannot find a writable temporary directory');
}
self::$_temporary_directory = $result;
}
return self::$_temporary_directory;
} | [
"public",
"function",
"getTemporaryDirectory",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_temporary_directory",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"candidates",
"=",
"array",
"(",
"ini_get",
"(",
"'upload_tmp_dir'",
")",
",",
"JFacto... | Returns a directory path for temporary files
Additionally checks for Joomla tmp folder if the system directory is not writable
@throws RuntimeException If a temporary writable directory cannot be found
@return string Folder path | [
"Returns",
"a",
"directory",
"path",
"for",
"temporary",
"files"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/filesystem/stream/buffer.php#L31-L63 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/behavior/identifiable.php | KDatabaseBehaviorIdentifiable._uuid | protected function _uuid($hex = false)
{
$pr_bits = false;
$fp = @fopen ( '/dev/urandom', 'rb' );
if ($fp !== false)
{
$pr_bits = @fread ( $fp, 16 );
@fclose ( $fp );
}
// If /dev/urandom isn't available (eg: in non-unix systems), use mt_rand().
if(empty($pr_bits))
{
$pr_bits = "";
for($cnt = 0; $cnt < 16; $cnt ++) {
$pr_bits .= chr ( mt_rand ( 0, 255 ) );
}
}
$time_low = bin2hex ( substr ( $pr_bits, 0, 4 ) );
$time_mid = bin2hex ( substr ( $pr_bits, 4, 2 ) );
$time_hi_and_version = bin2hex ( substr ( $pr_bits, 6, 2 ) );
$clock_seq_hi_and_reserved = bin2hex ( substr ( $pr_bits, 8, 2 ) );
$node = bin2hex ( substr ( $pr_bits, 10, 6 ) );
/**
* Set the four most significant bits (bits 12 through 15) of the
* time_hi_and_version field to the 4-bit version number from
* Section 4.1.3.
* @see http://tools.ietf.org/html/rfc4122#section-4.1.3
*/
$time_hi_and_version = hexdec ( $time_hi_and_version );
$time_hi_and_version = $time_hi_and_version >> 4;
$time_hi_and_version = $time_hi_and_version | 0x4000;
/**
* Set the two most significant bits (bits 6 and 7) of the
* clock_seq_hi_and_reserved to zero and one, respectively.
*/
$clock_seq_hi_and_reserved = hexdec ( $clock_seq_hi_and_reserved );
$clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
$clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
//Either return as hex or as string
$format = $hex ? '%08s%04s%04x%04x%012s' : '%08s-%04s-%04x-%04x-%012s';
return sprintf ( $format, $time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node );
} | php | protected function _uuid($hex = false)
{
$pr_bits = false;
$fp = @fopen ( '/dev/urandom', 'rb' );
if ($fp !== false)
{
$pr_bits = @fread ( $fp, 16 );
@fclose ( $fp );
}
// If /dev/urandom isn't available (eg: in non-unix systems), use mt_rand().
if(empty($pr_bits))
{
$pr_bits = "";
for($cnt = 0; $cnt < 16; $cnt ++) {
$pr_bits .= chr ( mt_rand ( 0, 255 ) );
}
}
$time_low = bin2hex ( substr ( $pr_bits, 0, 4 ) );
$time_mid = bin2hex ( substr ( $pr_bits, 4, 2 ) );
$time_hi_and_version = bin2hex ( substr ( $pr_bits, 6, 2 ) );
$clock_seq_hi_and_reserved = bin2hex ( substr ( $pr_bits, 8, 2 ) );
$node = bin2hex ( substr ( $pr_bits, 10, 6 ) );
/**
* Set the four most significant bits (bits 12 through 15) of the
* time_hi_and_version field to the 4-bit version number from
* Section 4.1.3.
* @see http://tools.ietf.org/html/rfc4122#section-4.1.3
*/
$time_hi_and_version = hexdec ( $time_hi_and_version );
$time_hi_and_version = $time_hi_and_version >> 4;
$time_hi_and_version = $time_hi_and_version | 0x4000;
/**
* Set the two most significant bits (bits 6 and 7) of the
* clock_seq_hi_and_reserved to zero and one, respectively.
*/
$clock_seq_hi_and_reserved = hexdec ( $clock_seq_hi_and_reserved );
$clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved >> 2;
$clock_seq_hi_and_reserved = $clock_seq_hi_and_reserved | 0x8000;
//Either return as hex or as string
$format = $hex ? '%08s%04s%04x%04x%012s' : '%08s-%04s-%04x-%04x-%012s';
return sprintf ( $format, $time_low, $time_mid, $time_hi_and_version, $clock_seq_hi_and_reserved, $node );
} | [
"protected",
"function",
"_uuid",
"(",
"$",
"hex",
"=",
"false",
")",
"{",
"$",
"pr_bits",
"=",
"false",
";",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"'/dev/urandom'",
",",
"'rb'",
")",
";",
"if",
"(",
"$",
"fp",
"!==",
"false",
")",
"{",
"$",
"pr_bit... | Generates a Universally Unique Identifier, version 4.
This function generates a truly random UUID.
@param boolean $hex If TRUE return the uuid in hex format, otherwise as a string
@see http://tools.ietf.org/html/rfc4122#section-4.4
@see http://en.wikipedia.org/wiki/UUID
@return string A UUID, made up of 36 characters or 16 hex digits. | [
"Generates",
"a",
"Universally",
"Unique",
"Identifier",
"version",
"4",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/behavior/identifiable.php#L132-L180 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/behavior/sluggable.php | KDatabaseBehaviorSluggable._createFilter | protected function _createFilter()
{
$config = array();
$config['separator'] = $this->_separator;
if (!isset($this->_length)) {
$config['length'] = $this->getTable()->getColumn('slug')->length;
} else {
$config['length'] = $this->_length;
}
return $this->getObject('filter.factory')->createChain($this->_filter, $config);
} | php | protected function _createFilter()
{
$config = array();
$config['separator'] = $this->_separator;
if (!isset($this->_length)) {
$config['length'] = $this->getTable()->getColumn('slug')->length;
} else {
$config['length'] = $this->_length;
}
return $this->getObject('filter.factory')->createChain($this->_filter, $config);
} | [
"protected",
"function",
"_createFilter",
"(",
")",
"{",
"$",
"config",
"=",
"array",
"(",
")",
";",
"$",
"config",
"[",
"'separator'",
"]",
"=",
"$",
"this",
"->",
"_separator",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_length",
")",
... | Create a sluggable filter
@return KFilterInterface | [
"Create",
"a",
"sluggable",
"filter"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/behavior/sluggable.php#L185-L197 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/cacheable.php | ComKoowaControllerBehaviorCacheable._beforeRender | protected function _beforeRender(KControllerContextInterface $context)
{
$cache = $this->_getCache($this->_getGroup(), 'output');
$key = $this->_getKey();
if($data = $cache->get($key))
{
$data = unserialize($data);
//Render the view output
$context->result = $data['component'];
//Render the modules
if(isset($data['modules']))
{
foreach($data['modules'] as $name => $content) {
JFactory::getDocument()->setBuffer($content, 'modules', $name);
}
}
$this->_output = $context->result;
}
} | php | protected function _beforeRender(KControllerContextInterface $context)
{
$cache = $this->_getCache($this->_getGroup(), 'output');
$key = $this->_getKey();
if($data = $cache->get($key))
{
$data = unserialize($data);
//Render the view output
$context->result = $data['component'];
//Render the modules
if(isset($data['modules']))
{
foreach($data['modules'] as $name => $content) {
JFactory::getDocument()->setBuffer($content, 'modules', $name);
}
}
$this->_output = $context->result;
}
} | [
"protected",
"function",
"_beforeRender",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"$",
"cache",
"=",
"$",
"this",
"->",
"_getCache",
"(",
"$",
"this",
"->",
"_getGroup",
"(",
")",
",",
"'output'",
")",
";",
"$",
"key",
"=",
"$",
"th... | Fetch the unrendered view data from the cache
@param KControllerContextInterface $context A command context object
@return void | [
"Fetch",
"the",
"unrendered",
"view",
"data",
"from",
"the",
"cache"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/cacheable.php#L68-L90 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/cacheable.php | ComKoowaControllerBehaviorCacheable._afterRender | protected function _afterRender(KControllerContextInterface $context)
{
if(empty($this->_output))
{
$view = $this->getView();
$cache = $this->_getCache($this->_getGroup(), 'output');
$key = $this->_getKey();
$data = array();
//Store the unrendered view output
if($view instanceof KViewTemplate)
{
$data['component'] = (string) $view->getTemplate()->render();
$buffer = JFactory::getDocument()->getBuffer();
if(isset($buffer['modules'])) {
$data['modules'] = array_intersect_key($buffer['modules'], array_flip($this->_modules));
}
}
else $data['component'] = $context->result;
$cache->store(serialize($data), $key);
}
} | php | protected function _afterRender(KControllerContextInterface $context)
{
if(empty($this->_output))
{
$view = $this->getView();
$cache = $this->_getCache($this->_getGroup(), 'output');
$key = $this->_getKey();
$data = array();
//Store the unrendered view output
if($view instanceof KViewTemplate)
{
$data['component'] = (string) $view->getTemplate()->render();
$buffer = JFactory::getDocument()->getBuffer();
if(isset($buffer['modules'])) {
$data['modules'] = array_intersect_key($buffer['modules'], array_flip($this->_modules));
}
}
else $data['component'] = $context->result;
$cache->store(serialize($data), $key);
}
} | [
"protected",
"function",
"_afterRender",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_output",
")",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
";",
"$",
"cache",
"=... | Store the unrendered view data in the cache
@param KControllerContextInterface $context A command context object
@return void | [
"Store",
"the",
"unrendered",
"view",
"data",
"in",
"the",
"cache"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/cacheable.php#L98-L122 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/cacheable.php | ComKoowaControllerBehaviorCacheable._afterRead | protected function _afterRead(KControllerContextInterface $context)
{
if(!empty($this->_output)) {
$context->result = $this->_output;
}
} | php | protected function _afterRead(KControllerContextInterface $context)
{
if(!empty($this->_output)) {
$context->result = $this->_output;
}
} | [
"protected",
"function",
"_afterRead",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_output",
")",
")",
"{",
"$",
"context",
"->",
"result",
"=",
"$",
"this",
"->",
"_output",
";",
"}",
... | Return the cached data after read
Only if cached data was found return it but allow the chain to continue to allow
processing all the read commands
@param KControllerContextInterface $context A command context object
@return void | [
"Return",
"the",
"cached",
"data",
"after",
"read"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/cacheable.php#L133-L138 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/cacheable.php | ComKoowaControllerBehaviorCacheable._beforeBrowse | protected function _beforeBrowse(KControllerContextInterface $context)
{
if(!empty($this->_output))
{
$context->result = $this->_output;
return false;
}
return null;
} | php | protected function _beforeBrowse(KControllerContextInterface $context)
{
if(!empty($this->_output))
{
$context->result = $this->_output;
return false;
}
return null;
} | [
"protected",
"function",
"_beforeBrowse",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_output",
")",
")",
"{",
"$",
"context",
"->",
"result",
"=",
"$",
"this",
"->",
"_output",
";",
"re... | Return the cached data before browse
Only if cached data was fetch return it and break the chain to disallow any
further processing to take place
@param KControllerContextInterface $context A command context object
@return null|boolean | [
"Return",
"the",
"cached",
"data",
"before",
"browse"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/cacheable.php#L149-L158 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/behavior/cacheable.php | ComKoowaControllerBehaviorCacheable._getCache | protected function _getCache($group = '', $handler = 'callback', $storage = null)
{
return JFactory::getCache($group, $handler, $storage);
} | php | protected function _getCache($group = '', $handler = 'callback', $storage = null)
{
return JFactory::getCache($group, $handler, $storage);
} | [
"protected",
"function",
"_getCache",
"(",
"$",
"group",
"=",
"''",
",",
"$",
"handler",
"=",
"'callback'",
",",
"$",
"storage",
"=",
"null",
")",
"{",
"return",
"JFactory",
"::",
"getCache",
"(",
"$",
"group",
",",
"$",
"handler",
",",
"$",
"storage",... | Create a JCache instance
@param string $group
@param string $handler
@param null $storage
@return JCacheController | [
"Create",
"a",
"JCache",
"instance"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/behavior/cacheable.php#L219-L222 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/translator/abstract.php | KTranslatorAbstract.translate | public function translate($string, array $parameters = array())
{
$translation = '';
if(!empty($string))
{
$catalogue = $this->getCatalogue();
$translation = $catalogue->has($string) ? $catalogue->get($string) : $string;
if (count($parameters)) {
$translation = $this->_replaceParameters($translation, $parameters);
}
}
return $translation;
} | php | public function translate($string, array $parameters = array())
{
$translation = '';
if(!empty($string))
{
$catalogue = $this->getCatalogue();
$translation = $catalogue->has($string) ? $catalogue->get($string) : $string;
if (count($parameters)) {
$translation = $this->_replaceParameters($translation, $parameters);
}
}
return $translation;
} | [
"public",
"function",
"translate",
"(",
"$",
"string",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"translation",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"string",
")",
")",
"{",
"$",
"catalogue",
"=",
"$",
... | Translates a string and handles parameter replacements
Parameters are wrapped in curly braces. So {foo} would be replaced with bar given that $parameters['foo'] = 'bar'
@param string $string String to translate
@param array $parameters An array of parameters
@return string Translated string | [
"Translates",
"a",
"string",
"and",
"handles",
"parameter",
"replacements"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/translator/abstract.php#L120-L135 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/translator/abstract.php | KTranslatorAbstract._replaceParameters | protected function _replaceParameters($string, array $parameters = array())
{
//Adds curly braces around keys to make strtr work in replaceParameters method
$replace_keys = function ($key) {
return '{'.$key.'}';
};
$keys = array_map($replace_keys, array_keys($parameters));
$parameters = array_combine($keys, $parameters);
return strtr($string, $parameters);
} | php | protected function _replaceParameters($string, array $parameters = array())
{
//Adds curly braces around keys to make strtr work in replaceParameters method
$replace_keys = function ($key) {
return '{'.$key.'}';
};
$keys = array_map($replace_keys, array_keys($parameters));
$parameters = array_combine($keys, $parameters);
return strtr($string, $parameters);
} | [
"protected",
"function",
"_replaceParameters",
"(",
"$",
"string",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"//Adds curly braces around keys to make strtr work in replaceParameters method",
"$",
"replace_keys",
"=",
"function",
"(",
"$",
"key",... | Handles parameter replacements
@param string $string String
@param array $parameters An array of parameters
@return string String after replacing the parameters | [
"Handles",
"parameter",
"replacements"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/translator/abstract.php#L399-L410 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filter/iterator.php | KFilterIterator.validate | public function validate($data)
{
$result = true;
if(is_array($data) || $data instanceof Traversable)
{
foreach($data as $value)
{
if($this->validate($value) === false) {
$result = false;
}
}
}
else $result = $this->getDelegate()->validate($data);
return $result;
} | php | public function validate($data)
{
$result = true;
if(is_array($data) || $data instanceof Traversable)
{
foreach($data as $value)
{
if($this->validate($value) === false) {
$result = false;
}
}
}
else $result = $this->getDelegate()->validate($data);
return $result;
} | [
"public",
"function",
"validate",
"(",
"$",
"data",
")",
"{",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"||",
"$",
"data",
"instanceof",
"Traversable",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"value",
... | Validate a scalar or traversable data
NOTE: This should always be a simple yes/no question (is $data valid?), so only true or false should be returned
@param mixed $data Value to be validated
@return bool True when the data is valid. False otherwise. | [
"Validate",
"a",
"scalar",
"or",
"traversable",
"data"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filter/iterator.php#L28-L44 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filter/iterator.php | KFilterIterator.sanitize | public function sanitize($data)
{
if(is_array($data) || $data instanceof Traversable)
{
foreach((array)$data as $key => $value)
{
if(is_array($data)) {
$data[$key] = $this->sanitize($value);
} else {
$data->$key = $this->sanitize($value);
}
}
}
else $data = $this->getDelegate()->sanitize($data);
return $data;
} | php | public function sanitize($data)
{
if(is_array($data) || $data instanceof Traversable)
{
foreach((array)$data as $key => $value)
{
if(is_array($data)) {
$data[$key] = $this->sanitize($value);
} else {
$data->$key = $this->sanitize($value);
}
}
}
else $data = $this->getDelegate()->sanitize($data);
return $data;
} | [
"public",
"function",
"sanitize",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"||",
"$",
"data",
"instanceof",
"Traversable",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"valu... | Sanitize a scalar or traversable data
@param mixed $data Value to be sanitized
@return mixed The sanitized value | [
"Sanitize",
"a",
"scalar",
"or",
"traversable",
"data"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filter/iterator.php#L52-L68 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/locator/file.php | ComKoowaTemplateLocatorFile.find | public function find(array $info)
{
//Qualify partial templates.
if(dirname($info['url']) === '.')
{
if(empty($info['base'])) {
throw new RuntimeException('Cannot qualify partial template path');
}
$relative_path = dirname($info['base']);
}
else $relative_path = dirname($info['url']);
$file = pathinfo($info['url'], PATHINFO_FILENAME);
$format = pathinfo($info['url'], PATHINFO_EXTENSION);
$base_paths = array(JPATH_ROOT);
if (!empty($this->_override_paths)) {
foreach ($this->_override_paths as $override_path) {
array_unshift($base_paths, $override_path);
}
}
foreach ($base_paths as $base_path)
{
$path = $base_path.'/'.str_replace(parse_url($relative_path, PHP_URL_SCHEME).'://', '', $relative_path);
// Remove /view from the end of the override path
if (in_array($base_path, KObjectConfig::unbox($this->_override_paths)) && substr($path, strrpos($path, '/')) === '/view') {
$path = substr($path, 0, -5);
}
if(!$result = $this->realPath($path.'/'.$file.'.'.$format))
{
$pattern = $path.'/'.$file.'.'.$format.'.*';
$results = glob($pattern);
//Try to find the file
if ($results)
{
foreach($results as $file)
{
if($result = $this->realPath($file)) {
return $result;
}
}
}
}
}
return $result;
} | php | public function find(array $info)
{
//Qualify partial templates.
if(dirname($info['url']) === '.')
{
if(empty($info['base'])) {
throw new RuntimeException('Cannot qualify partial template path');
}
$relative_path = dirname($info['base']);
}
else $relative_path = dirname($info['url']);
$file = pathinfo($info['url'], PATHINFO_FILENAME);
$format = pathinfo($info['url'], PATHINFO_EXTENSION);
$base_paths = array(JPATH_ROOT);
if (!empty($this->_override_paths)) {
foreach ($this->_override_paths as $override_path) {
array_unshift($base_paths, $override_path);
}
}
foreach ($base_paths as $base_path)
{
$path = $base_path.'/'.str_replace(parse_url($relative_path, PHP_URL_SCHEME).'://', '', $relative_path);
// Remove /view from the end of the override path
if (in_array($base_path, KObjectConfig::unbox($this->_override_paths)) && substr($path, strrpos($path, '/')) === '/view') {
$path = substr($path, 0, -5);
}
if(!$result = $this->realPath($path.'/'.$file.'.'.$format))
{
$pattern = $path.'/'.$file.'.'.$format.'.*';
$results = glob($pattern);
//Try to find the file
if ($results)
{
foreach($results as $file)
{
if($result = $this->realPath($file)) {
return $result;
}
}
}
}
}
return $result;
} | [
"public",
"function",
"find",
"(",
"array",
"$",
"info",
")",
"{",
"//Qualify partial templates.",
"if",
"(",
"dirname",
"(",
"$",
"info",
"[",
"'url'",
"]",
")",
"===",
"'.'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"info",
"[",
"'base'",
"]",
")",
... | Find a template override
@param array $info The path information
@return bool|mixed | [
"Find",
"a",
"template",
"override"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/locator/file.php#L75-L127 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/rowset/abstract.php | KDatabaseRowsetAbstract.insert | public function insert(KObjectHandlable $row)
{
if (!$row instanceof KDatabaseRowInterface) {
throw new InvalidArgumentException('Row needs to implement KDatabaseRowInterface');
}
$this->offsetSet($row, null);
return true;
} | php | public function insert(KObjectHandlable $row)
{
if (!$row instanceof KDatabaseRowInterface) {
throw new InvalidArgumentException('Row needs to implement KDatabaseRowInterface');
}
$this->offsetSet($row, null);
return true;
} | [
"public",
"function",
"insert",
"(",
"KObjectHandlable",
"$",
"row",
")",
"{",
"if",
"(",
"!",
"$",
"row",
"instanceof",
"KDatabaseRowInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Row needs to implement KDatabaseRowInterface'",
")",
";",
"... | Insert a row into the rowset
The row will be stored by it's identity_column if set or otherwise by it's object handle.
@param KObjectHandlable|KDatabaseRowInterface $row
@throws \InvalidArgumentException if the object doesn't implement KDatabaseRowInterface
@return boolean TRUE on success FALSE on failure | [
"Insert",
"a",
"row",
"into",
"the",
"rowset"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/rowset/abstract.php#L115-L124 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/rowset/abstract.php | KDatabaseRowsetAbstract.create | public function create(array $properties = array(), $status = null)
{
if($this->_prototypable)
{
if(!$this->_prototype instanceof KDatabaseRowInterface) {
$this->_prototype = $this->getTable()->createRow();
}
$row = clone $this->_prototype;
$row->setStatus($status);
$row->setProperties($properties, $row->isNew());
}
else
{
$config = array(
'data' => $properties,
'status' => $status,
);
$row = $this->getTable()->createRow($config);
}
//Insert the row into the rowset
$this->insert($row);
return $row;
} | php | public function create(array $properties = array(), $status = null)
{
if($this->_prototypable)
{
if(!$this->_prototype instanceof KDatabaseRowInterface) {
$this->_prototype = $this->getTable()->createRow();
}
$row = clone $this->_prototype;
$row->setStatus($status);
$row->setProperties($properties, $row->isNew());
}
else
{
$config = array(
'data' => $properties,
'status' => $status,
);
$row = $this->getTable()->createRow($config);
}
//Insert the row into the rowset
$this->insert($row);
return $row;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"properties",
"=",
"array",
"(",
")",
",",
"$",
"status",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_prototypable",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_prototype",
"instanceof"... | Create a new row and insert it
This function will either clone the row prototype, or create a new instance of the row object for each row
being inserted. By default the prototype will be cloned.
@param array $properties The entity properties
@param string $status The entity status
@return KModelEntityComposite | [
"Create",
"a",
"new",
"row",
"and",
"insert",
"it"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/rowset/abstract.php#L170-L197 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/rowset/abstract.php | KDatabaseRowsetAbstract.isNew | public function isNew()
{
$result = true;
if($row = $this->getIterator()->current()) {
$result = $row->isNew();
}
return $result;
} | php | public function isNew()
{
$result = true;
if($row = $this->getIterator()->current()) {
$result = $row->isNew();
}
return $result;
} | [
"public",
"function",
"isNew",
"(",
")",
"{",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"$",
"row",
"=",
"$",
"this",
"->",
"getIterator",
"(",
")",
"->",
"current",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"row",
"->",
"isNew",
"(",
")",... | Checks if the row is new or not
@return boolean | [
"Checks",
"if",
"the",
"row",
"is",
"new",
"or",
"not"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/rowset/abstract.php#L575-L583 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/grid.php | ComKoowaTemplateHelperGrid.order | public function order($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'entity' => null,
'total' => null,
'field' => 'ordering',
'data' => array('order' => 0)
));
$translator = $this->getObject('translator');
$config->data->order = -1;
$updata = $config->data->toArray();
$updata = htmlentities(json_encode($updata));
$config->data->order = +1;
$downdata = $config->data->toArray();
$downdata = htmlentities(json_encode($downdata));
$html = '';
$html .= '<span class="k-table-data--sort">';
if ($config->sort === $config->field)
{
$tmpl = '
<a class="k-grid-sort jgrid" href="#" title="%s" data-action="edit" data-data="%s">
<span class="state %s">
<span class="text">%s</span>
</span>
</a>
';
}
else
{
$tmpl = '
<span class="k-grid-sort">
<span class="state %3$s">
<span class="text">%4$s</span>
</span>
</span>';
}
if ($config->entity->{$config->field} > 1)
{
$icon = '<span class="k-icon-chevron-top"></span>';
$html .= sprintf($tmpl, $translator->translate('Move up'), $updata, 'uparrow', $icon);
} else {
$html .= '<span class="k-grid-sort k-icon-placeholder"></span>';
}
$html .= '<span class="k-grid-sort k-grid-sort--text">' . $config->entity->{$config->field} . '</span>';
if ($config->entity->{$config->field} != $config->total)
{
$icon = '<span class="k-icon-chevron-bottom"></span>';
$html .= sprintf($tmpl, $translator->translate('Move down'), $downdata, 'downarrow', $icon);
}
else {
$html .= '<span class="k-grid-sort k-icon-placeholder"></span>';
}
if ($config->sort !== $config->field)
{
$html .= $this->getTemplate()->helper('behavior.tooltip');
$html = '<div data-k-tooltip="'.htmlentities(json_encode(array('placement' => 'bottom'))).'"
title="'.$translator->translate('Please order by this column first by clicking the column title').'">'
.$html.
'</div>';
}
$html .= '</span>';
return $html;
} | php | public function order($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'entity' => null,
'total' => null,
'field' => 'ordering',
'data' => array('order' => 0)
));
$translator = $this->getObject('translator');
$config->data->order = -1;
$updata = $config->data->toArray();
$updata = htmlentities(json_encode($updata));
$config->data->order = +1;
$downdata = $config->data->toArray();
$downdata = htmlentities(json_encode($downdata));
$html = '';
$html .= '<span class="k-table-data--sort">';
if ($config->sort === $config->field)
{
$tmpl = '
<a class="k-grid-sort jgrid" href="#" title="%s" data-action="edit" data-data="%s">
<span class="state %s">
<span class="text">%s</span>
</span>
</a>
';
}
else
{
$tmpl = '
<span class="k-grid-sort">
<span class="state %3$s">
<span class="text">%4$s</span>
</span>
</span>';
}
if ($config->entity->{$config->field} > 1)
{
$icon = '<span class="k-icon-chevron-top"></span>';
$html .= sprintf($tmpl, $translator->translate('Move up'), $updata, 'uparrow', $icon);
} else {
$html .= '<span class="k-grid-sort k-icon-placeholder"></span>';
}
$html .= '<span class="k-grid-sort k-grid-sort--text">' . $config->entity->{$config->field} . '</span>';
if ($config->entity->{$config->field} != $config->total)
{
$icon = '<span class="k-icon-chevron-bottom"></span>';
$html .= sprintf($tmpl, $translator->translate('Move down'), $downdata, 'downarrow', $icon);
}
else {
$html .= '<span class="k-grid-sort k-icon-placeholder"></span>';
}
if ($config->sort !== $config->field)
{
$html .= $this->getTemplate()->helper('behavior.tooltip');
$html = '<div data-k-tooltip="'.htmlentities(json_encode(array('placement' => 'bottom'))).'"
title="'.$translator->translate('Please order by this column first by clicking the column title').'">'
.$html.
'</div>';
}
$html .= '</span>';
return $html;
} | [
"public",
"function",
"order",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'entity'",
"=>",
"null",
",",
"'tota... | Render an order field
@param array $config An optional array with configuration options
@return string Html | [
"Render",
"an",
"order",
"field"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/grid.php#L24-L103 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/grid.php | ComKoowaTemplateHelperGrid.access | public function access($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'entity' => null,
'field' => 'access'
));
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.title AS text');
$query->from('#__viewlevels AS a');
$query->where('id = '.(int) $config->entity->{$config->field});
$query->group('a.id, a.title, a.ordering');
$query->order('a.ordering ASC');
$query->order($query->qn('title') . ' ASC');
// Get the options.
$db->setQuery($query);
$html = $db->loadResult();
return $html;
} | php | public function access($config = array())
{
$config = new KObjectConfigJson($config);
$config->append(array(
'entity' => null,
'field' => 'access'
));
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('a.title AS text');
$query->from('#__viewlevels AS a');
$query->where('id = '.(int) $config->entity->{$config->field});
$query->group('a.id, a.title, a.ordering');
$query->order('a.ordering ASC');
$query->order($query->qn('title') . ' ASC');
// Get the options.
$db->setQuery($query);
$html = $db->loadResult();
return $html;
} | [
"public",
"function",
"access",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"new",
"KObjectConfigJson",
"(",
"$",
"config",
")",
";",
"$",
"config",
"->",
"append",
"(",
"array",
"(",
"'entity'",
"=>",
"null",
",",
"'fie... | Render an access field
@param array $config An optional array with configuration options
@return string Html | [
"Render",
"an",
"access",
"field"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/grid.php#L111-L134 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/container/message.php | KUserSessionContainerMessage.get | public function get($type, $default = array())
{
if(isset($this->_previous[$type]))
{
$result = $this->_previous[$type];
unset($this->_previous[$type]);
}
else $result = $default;
return $result;
} | php | public function get($type, $default = array())
{
if(isset($this->_previous[$type]))
{
$result = $this->_previous[$type];
unset($this->_previous[$type]);
}
else $result = $default;
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"type",
",",
"$",
"default",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_previous",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_previo... | Get previous flash messages for a given type and flush them from the container
@param string $type Message category type.
@param array $default Default value if $type does not exist.
@return array | [
"Get",
"previous",
"flash",
"messages",
"for",
"a",
"given",
"type",
"and",
"flush",
"them",
"from",
"the",
"container"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/message.php#L49-L59 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/session/container/message.php | KUserSessionContainerMessage.set | public function set($type, $messages)
{
foreach((array) $messages as $message) {
parent::set($type, $message);
}
return $this;
} | php | public function set($type, $messages)
{
foreach((array) $messages as $message) {
parent::set($type, $message);
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"type",
",",
"$",
"messages",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"parent",
"::",
"set",
"(",
"$",
"type",
",",
"$",
"message",
")",
";",
"}",
"retur... | Set current flash messages for a given type.
@param string $type Message category type.
@param string|array $messages
@return KUserSessionContainerMessage | [
"Set",
"current",
"flash",
"messages",
"for",
"a",
"given",
"type",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/session/container/message.php#L68-L75 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filter/abstract.php | KFilterAbstract.getInstance | public static function getInstance(KObjectConfigInterface $config, KObjectManagerInterface $manager)
{
//Create the singleton
$class = $manager->getClass($config->object_identifier);
$instance = new $class($config);
if($instance instanceof KFilterTraversable) {
$instance = $instance->decorate('lib:filter.iterator');
}
return $instance;
} | php | public static function getInstance(KObjectConfigInterface $config, KObjectManagerInterface $manager)
{
//Create the singleton
$class = $manager->getClass($config->object_identifier);
$instance = new $class($config);
if($instance instanceof KFilterTraversable) {
$instance = $instance->decorate('lib:filter.iterator');
}
return $instance;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"KObjectConfigInterface",
"$",
"config",
",",
"KObjectManagerInterface",
"$",
"manager",
")",
"{",
"//Create the singleton",
"$",
"class",
"=",
"$",
"manager",
"->",
"getClass",
"(",
"$",
"config",
"->",
"object_... | Create filter and decorate it with KFilterIterator if the filter implements KFilterTraversable
@param KObjectConfigInterface $config Configuration options
@param KObjectManagerInterface $manager A KObjectManagerInterface object
@return KFilterInterface
@see KFilterTraversable | [
"Create",
"filter",
"and",
"decorate",
"it",
"with",
"KFilterIterator",
"if",
"the",
"filter",
"implements",
"KFilterTraversable"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filter/abstract.php#L80-L91 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/request/abstract.php | KDispatcherRequestAbstract.setUrl | public function setUrl($url)
{
if(!empty($url)) {
$this->_url = $this->getObject('lib:http.url', array('url' => $url));
}
return $this;
} | php | public function setUrl($url)
{
if(!empty($url)) {
$this->_url = $this->getObject('lib:http.url', array('url' => $url));
}
return $this;
} | [
"public",
"function",
"setUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"$",
"this",
"->",
"_url",
"=",
"$",
"this",
"->",
"getObject",
"(",
"'lib:http.url'",
",",
"array",
"(",
"'url'",
"=>",
"$",
"url... | Set the url for this request
@param string|array $url Part(s) of an URL in form of a string or associative array like parse_url() returns
@return KHttpRequest | [
"Set",
"the",
"url",
"for",
"this",
"request"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/request/abstract.php#L521-L528 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/request/abstract.php | KDispatcherRequestAbstract.getRanges | public function getRanges()
{
if(!isset($this->_ranges))
{
$this->_ranges = array();
if($this->_headers->has('Range'))
{
$range = $this->_headers->get('Range');
if(!preg_match('/^bytes=((\d*-\d*,? ?)+)$/', $range)) {
throw new KHttpExceptionRangeNotSatisfied('Invalid range');
}
$ranges = explode(',', substr($range, 6));
foreach ($ranges as $key => $range)
{
$parts = explode('-', $range);
$first = $parts[0];
$last = $parts[1];
$ranges[$key] = array('first' => $first, 'last' => $last);
}
$this->_ranges = $ranges;
}
}
return $this->_ranges;
} | php | public function getRanges()
{
if(!isset($this->_ranges))
{
$this->_ranges = array();
if($this->_headers->has('Range'))
{
$range = $this->_headers->get('Range');
if(!preg_match('/^bytes=((\d*-\d*,? ?)+)$/', $range)) {
throw new KHttpExceptionRangeNotSatisfied('Invalid range');
}
$ranges = explode(',', substr($range, 6));
foreach ($ranges as $key => $range)
{
$parts = explode('-', $range);
$first = $parts[0];
$last = $parts[1];
$ranges[$key] = array('first' => $first, 'last' => $last);
}
$this->_ranges = $ranges;
}
}
return $this->_ranges;
} | [
"public",
"function",
"getRanges",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_ranges",
")",
")",
"{",
"$",
"this",
"->",
"_ranges",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_headers",
"->",
"has",
"(",
... | Gets the request ranges
@link : http://tools.ietf.org/html/rfc2616#section-14.35
@throws KHttpExceptionRangeNotSatisfied If the range info is not valid or if the start offset is large then the end offset
@return array List of request ranges | [
"Gets",
"the",
"request",
"ranges"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/request/abstract.php#L872-L901 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/request/abstract.php | KDispatcherRequestAbstract.getETags | public function getETags()
{
$result = array();
if($this->_headers->has('If-None-Match'))
{
$result = preg_split('/\s*,\s*/', $this->_headers->get('If-None-Match'), null, PREG_SPLIT_NO_EMPTY);
//Remove the encoding from the etag
//
//RFC-7232 explicitly states that ETags should be content-coding aware
$result = str_replace('-gzip', '', $result);
}
return $result;
} | php | public function getETags()
{
$result = array();
if($this->_headers->has('If-None-Match'))
{
$result = preg_split('/\s*,\s*/', $this->_headers->get('If-None-Match'), null, PREG_SPLIT_NO_EMPTY);
//Remove the encoding from the etag
//
//RFC-7232 explicitly states that ETags should be content-coding aware
$result = str_replace('-gzip', '', $result);
}
return $result;
} | [
"public",
"function",
"getETags",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_headers",
"->",
"has",
"(",
"'If-None-Match'",
")",
")",
"{",
"$",
"result",
"=",
"preg_split",
"(",
"'/\\s*,\\s*/'",
",",
"$... | Gets the etags
@link https://tools.ietf.org/html/rfc7232#page-14
@return array The entity tags | [
"Gets",
"the",
"etags"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/request/abstract.php#L910-L924 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/dispatcher/request/abstract.php | KDispatcherRequestAbstract.isProxied | public function isProxied()
{
if(!empty($this->_proxies) && $this->_headers->has('X-Forwarded-By'))
{
$ip = $this->_headers->get('X-Forwarded-By');
$proxies = $this->getProxies();
//Validates the proxied IP-address against the list of trusted proxies.
foreach ($proxies as $proxy)
{
if (strpos($proxy, '/') !== false)
{
list($address, $netmask) = explode('/', $proxy, 2);
if ($netmask < 1 || $netmask > 32) {
return false;
}
}
else
{
$address = $proxy;
$netmask = 32;
}
if(substr_compare(sprintf('%032b', ip2long($ip)), sprintf('%032b', ip2long($address)), 0, $netmask) === 0) {
return true;
}
}
}
return false;
} | php | public function isProxied()
{
if(!empty($this->_proxies) && $this->_headers->has('X-Forwarded-By'))
{
$ip = $this->_headers->get('X-Forwarded-By');
$proxies = $this->getProxies();
//Validates the proxied IP-address against the list of trusted proxies.
foreach ($proxies as $proxy)
{
if (strpos($proxy, '/') !== false)
{
list($address, $netmask) = explode('/', $proxy, 2);
if ($netmask < 1 || $netmask > 32) {
return false;
}
}
else
{
$address = $proxy;
$netmask = 32;
}
if(substr_compare(sprintf('%032b', ip2long($ip)), sprintf('%032b', ip2long($address)), 0, $netmask) === 0) {
return true;
}
}
}
return false;
} | [
"public",
"function",
"isProxied",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_proxies",
")",
"&&",
"$",
"this",
"->",
"_headers",
"->",
"has",
"(",
"'X-Forwarded-By'",
")",
")",
"{",
"$",
"ip",
"=",
"$",
"this",
"->",
"_heade... | Checks whether the request is proxied or not.
This method reads the proxy IP from the "X-Forwarded-By" header. The "X-Forwarded-By" header must contain the
proxy IP address and, potentially, a port number). If no "X-Forwarded-By" header can be found, or the header
IP address doesn't match the list of trusted proxies the function will return false.
@link http://tools.ietf.org/html/draft-ietf-appsawg-http-forwarded-10#page-7
@return boolean Returns TRUE if the request is proxied and the proxy is trusted. FALSE otherwise. | [
"Checks",
"whether",
"the",
"request",
"is",
"proxied",
"or",
"not",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/dispatcher/request/abstract.php#L959-L990 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/query/select.php | KDatabaseQuerySelect.columns | public function columns($columns = array())
{
foreach ((array) $columns as $key => $value)
{
if (is_string($key)) {
$this->columns[$key] = $value;
} else {
$this->columns[] = $value;
}
}
return $this;
} | php | public function columns($columns = array())
{
foreach ((array) $columns as $key => $value)
{
if (is_string($key)) {
$this->columns[$key] = $value;
} else {
$this->columns[] = $value;
}
}
return $this;
} | [
"public",
"function",
"columns",
"(",
"$",
"columns",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"columns",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"... | Build a select query
@param array|string $columns A string or an array of column names
@return $this | [
"Build",
"a",
"select",
"query"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/query/select.php#L126-L138 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/database/query/select.php | KDatabaseQuerySelect.join | public function join($table, $condition = null, $type = 'LEFT')
{
settype($table, 'array');
$data = array(
'table' => current($table),
'condition' => $condition,
'type' => $type
);
if (is_string(key($table))) {
$this->join[key($table)] = $data;
} else {
$this->join[] = $data;
}
return $this;
} | php | public function join($table, $condition = null, $type = 'LEFT')
{
settype($table, 'array');
$data = array(
'table' => current($table),
'condition' => $condition,
'type' => $type
);
if (is_string(key($table))) {
$this->join[key($table)] = $data;
} else {
$this->join[] = $data;
}
return $this;
} | [
"public",
"function",
"join",
"(",
"$",
"table",
",",
"$",
"condition",
"=",
"null",
",",
"$",
"type",
"=",
"'LEFT'",
")",
"{",
"settype",
"(",
"$",
"table",
",",
"'array'",
")",
";",
"$",
"data",
"=",
"array",
"(",
"'table'",
"=>",
"current",
"(",... | Build the join clause
@param string $table The table name to join to.
@param string $condition The join condition statement.
@param string|array $type The type of join; empty for a plain JOIN, or "LEFT", "INNER", etc.
@return $this | [
"Build",
"the",
"join",
"clause"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/database/query/select.php#L160-L177 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.