id int32 0 241k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
236,200 | eix/core | src/php/main/Eix/Core/User.php | User.authenticate | public function authenticate(IdentityProvider $identityProvider)
{
try {
// Authenticate the user.
$identityProvider->authenticate();
// Success!
$this->isAuthenticated = true;
// Set the data obtained from the identity provider.
$this->name = $identityProvider->getUserName();
$this->email = $identityProvider->getUserEmail();
} catch (IdentityException $exception) {
$this->isAuthenticated = false;
throw $exception;
}
} | php | public function authenticate(IdentityProvider $identityProvider)
{
try {
// Authenticate the user.
$identityProvider->authenticate();
// Success!
$this->isAuthenticated = true;
// Set the data obtained from the identity provider.
$this->name = $identityProvider->getUserName();
$this->email = $identityProvider->getUserEmail();
} catch (IdentityException $exception) {
$this->isAuthenticated = false;
throw $exception;
}
} | [
"public",
"function",
"authenticate",
"(",
"IdentityProvider",
"$",
"identityProvider",
")",
"{",
"try",
"{",
"// Authenticate the user.",
"$",
"identityProvider",
"->",
"authenticate",
"(",
")",
";",
"// Success!",
"$",
"this",
"->",
"isAuthenticated",
"=",
"true",... | Authenticates a user against an identity provider.
@param IdentityProvider $identityProvider | [
"Authenticates",
"a",
"user",
"against",
"an",
"identity",
"provider",
"."
] | a5b4c09cc168221e85804fdfeb78e519a0415466 | https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/User.php#L173-L187 |
236,201 | sellerlabs/quip | src/Quip/Quip.php | Quip.parse | public function parse()
{
$input = $this->queryString;
// Parse string if it's not already parsed into an array
if (is_string($this->queryString)) {
$input = [];
parse_str($this->queryString, $input);
}
$this->query = new Query($input);
$this->parseQ();
$this->parseEmbeds();
$this->parseIncludes();
$this->parseExcludes();
$this->parseSorts();
return $this->query;
} | php | public function parse()
{
$input = $this->queryString;
// Parse string if it's not already parsed into an array
if (is_string($this->queryString)) {
$input = [];
parse_str($this->queryString, $input);
}
$this->query = new Query($input);
$this->parseQ();
$this->parseEmbeds();
$this->parseIncludes();
$this->parseExcludes();
$this->parseSorts();
return $this->query;
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"input",
"=",
"$",
"this",
"->",
"queryString",
";",
"// Parse string if it's not already parsed into an array",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"queryString",
")",
")",
"{",
"$",
"input",
"=",... | Parse a raw query into something more meaningful
@return Query | [
"Parse",
"a",
"raw",
"query",
"into",
"something",
"more",
"meaningful"
] | d4211f96edfc1893a3690e93adfecfb3dc19ad32 | https://github.com/sellerlabs/quip/blob/d4211f96edfc1893a3690e93adfecfb3dc19ad32/src/Quip/Quip.php#L42-L61 |
236,202 | sellerlabs/quip | src/Quip/Quip.php | Quip.parseEmbeds | protected function parseEmbeds()
{
if ($this->query->has('embeds')) {
$embeds = explode(',', $this->query->getRaw('embeds'));
foreach ($embeds as $embed) {
$this->query->addEmbed($this->parseEmbed($embed));
}
}
} | php | protected function parseEmbeds()
{
if ($this->query->has('embeds')) {
$embeds = explode(',', $this->query->getRaw('embeds'));
foreach ($embeds as $embed) {
$this->query->addEmbed($this->parseEmbed($embed));
}
}
} | [
"protected",
"function",
"parseEmbeds",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"has",
"(",
"'embeds'",
")",
")",
"{",
"$",
"embeds",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"query",
"->",
"getRaw",
"(",
"'embeds'",
... | Parse the embeds from the query string | [
"Parse",
"the",
"embeds",
"from",
"the",
"query",
"string"
] | d4211f96edfc1893a3690e93adfecfb3dc19ad32 | https://github.com/sellerlabs/quip/blob/d4211f96edfc1893a3690e93adfecfb3dc19ad32/src/Quip/Quip.php#L81-L90 |
236,203 | sellerlabs/quip | src/Quip/Quip.php | Quip.parseIncludes | protected function parseIncludes()
{
if ($this->query->has('includes')) {
$this->query->setIncludes(
explode(',', $this->query->getRaw('includes'))
);
}
} | php | protected function parseIncludes()
{
if ($this->query->has('includes')) {
$this->query->setIncludes(
explode(',', $this->query->getRaw('includes'))
);
}
} | [
"protected",
"function",
"parseIncludes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"has",
"(",
"'includes'",
")",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"setIncludes",
"(",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"query... | Parse the includees from the query string | [
"Parse",
"the",
"includees",
"from",
"the",
"query",
"string"
] | d4211f96edfc1893a3690e93adfecfb3dc19ad32 | https://github.com/sellerlabs/quip/blob/d4211f96edfc1893a3690e93adfecfb3dc19ad32/src/Quip/Quip.php#L95-L102 |
236,204 | sellerlabs/quip | src/Quip/Quip.php | Quip.parseExcludes | protected function parseExcludes()
{
if ($this->query->has('excludes')) {
$this->query->setExcludes(
explode(',', $this->query->getRaw('excludes'))
);
}
} | php | protected function parseExcludes()
{
if ($this->query->has('excludes')) {
$this->query->setExcludes(
explode(',', $this->query->getRaw('excludes'))
);
}
} | [
"protected",
"function",
"parseExcludes",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"has",
"(",
"'excludes'",
")",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"setExcludes",
"(",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"query... | Parse the excludes from the query string | [
"Parse",
"the",
"excludes",
"from",
"the",
"query",
"string"
] | d4211f96edfc1893a3690e93adfecfb3dc19ad32 | https://github.com/sellerlabs/quip/blob/d4211f96edfc1893a3690e93adfecfb3dc19ad32/src/Quip/Quip.php#L107-L114 |
236,205 | sellerlabs/quip | src/Quip/Quip.php | Quip.parseSorts | protected function parseSorts()
{
if ($this->query->has('sort')) {
$sorts = explode(',', $this->query->getRaw('sort'));
foreach($sorts as $sort) {
$this->query->addSort($this->parseSort($sort));
}
}
} | php | protected function parseSorts()
{
if ($this->query->has('sort')) {
$sorts = explode(',', $this->query->getRaw('sort'));
foreach($sorts as $sort) {
$this->query->addSort($this->parseSort($sort));
}
}
} | [
"protected",
"function",
"parseSorts",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"query",
"->",
"has",
"(",
"'sort'",
")",
")",
"{",
"$",
"sorts",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"query",
"->",
"getRaw",
"(",
"'sort'",
")",
... | Parse the sorts from the query string
@throws NoSuchSortException | [
"Parse",
"the",
"sorts",
"from",
"the",
"query",
"string"
] | d4211f96edfc1893a3690e93adfecfb3dc19ad32 | https://github.com/sellerlabs/quip/blob/d4211f96edfc1893a3690e93adfecfb3dc19ad32/src/Quip/Quip.php#L121-L130 |
236,206 | sellerlabs/quip | src/Quip/Quip.php | Quip.parseSort | protected function parseSort($sort)
{
$type = substr($sort, 0, 1);
$key = substr($sort, 1);
switch ($type) {
case '+': $type = Sort::TYPE_ASC; break;
case '-': $type = Sort::TYPE_DESC; break;
default:
throw new NoSuchSortException();
}
return new Sort($type, $key);
} | php | protected function parseSort($sort)
{
$type = substr($sort, 0, 1);
$key = substr($sort, 1);
switch ($type) {
case '+': $type = Sort::TYPE_ASC; break;
case '-': $type = Sort::TYPE_DESC; break;
default:
throw new NoSuchSortException();
}
return new Sort($type, $key);
} | [
"protected",
"function",
"parseSort",
"(",
"$",
"sort",
")",
"{",
"$",
"type",
"=",
"substr",
"(",
"$",
"sort",
",",
"0",
",",
"1",
")",
";",
"$",
"key",
"=",
"substr",
"(",
"$",
"sort",
",",
"1",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{... | Parse a single sort from a raw query string
@param $sort
@return Sort
@throws NoSuchSortException | [
"Parse",
"a",
"single",
"sort",
"from",
"a",
"raw",
"query",
"string"
] | d4211f96edfc1893a3690e93adfecfb3dc19ad32 | https://github.com/sellerlabs/quip/blob/d4211f96edfc1893a3690e93adfecfb3dc19ad32/src/Quip/Quip.php#L141-L154 |
236,207 | Sija/markdown | src/Markdown/Parser/MarkdownParser.php | MarkdownParser.doAutoLinks | protected function doAutoLinks($text)
{
if(!$this->features['auto_mailto'])
{
return preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}i',
array(&$this, '_doAutoLinks_url_callback'), $text);
}
return parent::doAutoLinks($text);
} | php | protected function doAutoLinks($text)
{
if(!$this->features['auto_mailto'])
{
return preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}i',
array(&$this, '_doAutoLinks_url_callback'), $text);
}
return parent::doAutoLinks($text);
} | [
"protected",
"function",
"doAutoLinks",
"(",
"$",
"text",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"features",
"[",
"'auto_mailto'",
"]",
")",
"{",
"return",
"preg_replace_callback",
"(",
"'{<((https?|ftp|dict):[^\\'\">\\s]+)>}i'",
",",
"array",
"(",
"&",
... | Disable mailto unless auto_mailto | [
"Disable",
"mailto",
"unless",
"auto_mailto"
] | 5fdad4bfb6a394405f8903ee196836791c7bdcf3 | https://github.com/Sija/markdown/blob/5fdad4bfb6a394405f8903ee196836791c7bdcf3/src/Markdown/Parser/MarkdownParser.php#L133-L142 |
236,208 | praxisnetau/silverware-social | src/Model/SharingIcon.php | SharingIcon.getDataAttributes | public function getDataAttributes()
{
$attributes = [
'data-toggle' => 'popover',
'data-container' => 'body',
'data-placement' => $this->getPlacement()
];
if (($parent = $this->getParent()) && $parent->ShowTitles) {
$attributes['data-title'] = $this->Title;
}
$this->extend('updateDataAttributes', $attributes);
return $attributes;
} | php | public function getDataAttributes()
{
$attributes = [
'data-toggle' => 'popover',
'data-container' => 'body',
'data-placement' => $this->getPlacement()
];
if (($parent = $this->getParent()) && $parent->ShowTitles) {
$attributes['data-title'] = $this->Title;
}
$this->extend('updateDataAttributes', $attributes);
return $attributes;
} | [
"public",
"function",
"getDataAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"[",
"'data-toggle'",
"=>",
"'popover'",
",",
"'data-container'",
"=>",
"'body'",
",",
"'data-placement'",
"=>",
"$",
"this",
"->",
"getPlacement",
"(",
")",
"]",
";",
"if",
"(... | Answers an array of data attributes for the receiver.
@return array | [
"Answers",
"an",
"array",
"of",
"data",
"attributes",
"for",
"the",
"receiver",
"."
] | 99d9092dae674ef0898bbee99386ae356cf6d3c3 | https://github.com/praxisnetau/silverware-social/blob/99d9092dae674ef0898bbee99386ae356cf6d3c3/src/Model/SharingIcon.php#L180-L195 |
236,209 | praxisnetau/silverware-social | src/Model/SharingIcon.php | SharingIcon.getPlacement | public function getPlacement()
{
if (($parent = $this->getParent()) && $parent->Placement) {
return $parent->Placement;
}
return $this->config()->default_placement;
} | php | public function getPlacement()
{
if (($parent = $this->getParent()) && $parent->Placement) {
return $parent->Placement;
}
return $this->config()->default_placement;
} | [
"public",
"function",
"getPlacement",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
")",
"&&",
"$",
"parent",
"->",
"Placement",
")",
"{",
"return",
"$",
"parent",
"->",
"Placement",
";",
"}",
"return",
... | Answers the popover placement for the receiver.
@return string | [
"Answers",
"the",
"popover",
"placement",
"for",
"the",
"receiver",
"."
] | 99d9092dae674ef0898bbee99386ae356cf6d3c3 | https://github.com/praxisnetau/silverware-social/blob/99d9092dae674ef0898bbee99386ae356cf6d3c3/src/Model/SharingIcon.php#L236-L243 |
236,210 | praxisnetau/silverware-social | src/Model/SharingIcon.php | SharingIcon.getPlacementOptions | public function getPlacementOptions()
{
return [
self::PLACEMENT_AUTO => _t(__CLASS__ . '.AUTO', 'Auto'),
self::PLACEMENT_TOP => _t(__CLASS__ . '.TOP', 'Top'),
self::PLACEMENT_LEFT => _t(__CLASS__ . '.LEFT', 'Left'),
self::PLACEMENT_RIGHT => _t(__CLASS__ . '.RIGHT', 'Right'),
self::PLACEMENT_BOTTOM => _t(__CLASS__ . '.BOTTOM', 'Bottom'),
];
} | php | public function getPlacementOptions()
{
return [
self::PLACEMENT_AUTO => _t(__CLASS__ . '.AUTO', 'Auto'),
self::PLACEMENT_TOP => _t(__CLASS__ . '.TOP', 'Top'),
self::PLACEMENT_LEFT => _t(__CLASS__ . '.LEFT', 'Left'),
self::PLACEMENT_RIGHT => _t(__CLASS__ . '.RIGHT', 'Right'),
self::PLACEMENT_BOTTOM => _t(__CLASS__ . '.BOTTOM', 'Bottom'),
];
} | [
"public",
"function",
"getPlacementOptions",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"PLACEMENT_AUTO",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.AUTO'",
",",
"'Auto'",
")",
",",
"self",
"::",
"PLACEMENT_TOP",
"=>",
"_t",
"(",
"__CLASS__",
".",
"'.TOP'",
",... | Answers an array of options for a placement field.
@return array | [
"Answers",
"an",
"array",
"of",
"options",
"for",
"a",
"placement",
"field",
"."
] | 99d9092dae674ef0898bbee99386ae356cf6d3c3 | https://github.com/praxisnetau/silverware-social/blob/99d9092dae674ef0898bbee99386ae356cf6d3c3/src/Model/SharingIcon.php#L295-L304 |
236,211 | praxisnetau/silverware-social | src/Model/SharingIcon.php | SharingIcon.getButton | public function getButton()
{
if ($class = $this->config()->button_class) {
// Create Button:
$button = $class::create();
// Extend Button:
$this->extend('updateButton', $button);
// Answer Button:
return $button;
}
} | php | public function getButton()
{
if ($class = $this->config()->button_class) {
// Create Button:
$button = $class::create();
// Extend Button:
$this->extend('updateButton', $button);
// Answer Button:
return $button;
}
} | [
"public",
"function",
"getButton",
"(",
")",
"{",
"if",
"(",
"$",
"class",
"=",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"button_class",
")",
"{",
"// Create Button:",
"$",
"button",
"=",
"$",
"class",
"::",
"create",
"(",
")",
";",
"// Extend Butt... | Answers the sharing button instance for the receiver.
@return SharingButton | [
"Answers",
"the",
"sharing",
"button",
"instance",
"for",
"the",
"receiver",
"."
] | 99d9092dae674ef0898bbee99386ae356cf6d3c3 | https://github.com/praxisnetau/silverware-social/blob/99d9092dae674ef0898bbee99386ae356cf6d3c3/src/Model/SharingIcon.php#L311-L328 |
236,212 | Dhii/state-machine-abstract | src/StateListAwareTrait.php | StateListAwareTrait._getState | protected function _getState($key)
{
$sKey = (string) $key;
return array_key_exists($sKey, $this->states)
? $this->states[$sKey]
: null;
} | php | protected function _getState($key)
{
$sKey = (string) $key;
return array_key_exists($sKey, $this->states)
? $this->states[$sKey]
: null;
} | [
"protected",
"function",
"_getState",
"(",
"$",
"key",
")",
"{",
"$",
"sKey",
"=",
"(",
"string",
")",
"$",
"key",
";",
"return",
"array_key_exists",
"(",
"$",
"sKey",
",",
"$",
"this",
"->",
"states",
")",
"?",
"$",
"this",
"->",
"states",
"[",
"$... | Retrieves the state with a specific key.
@since [*next-version*]
@param string|Stringable $key The state key.
@return string|Stringable|null The state, or null if no state for the given key was found. | [
"Retrieves",
"the",
"state",
"with",
"a",
"specific",
"key",
"."
] | cb5f706edd74d1c747f09f505b859255b13a5b27 | https://github.com/Dhii/state-machine-abstract/blob/cb5f706edd74d1c747f09f505b859255b13a5b27/src/StateListAwareTrait.php#L63-L70 |
236,213 | Dhii/state-machine-abstract | src/StateListAwareTrait.php | StateListAwareTrait._addState | protected function _addState($state)
{
if (!is_string($state) && !($state instanceof Stringable)) {
throw $this->_createInvalidArgumentException(
$this->__('Argument is not a valid state.'),
null,
null,
$state
);
}
$this->states[(string) $state] = $state;
} | php | protected function _addState($state)
{
if (!is_string($state) && !($state instanceof Stringable)) {
throw $this->_createInvalidArgumentException(
$this->__('Argument is not a valid state.'),
null,
null,
$state
);
}
$this->states[(string) $state] = $state;
} | [
"protected",
"function",
"_addState",
"(",
"$",
"state",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"state",
")",
"&&",
"!",
"(",
"$",
"state",
"instanceof",
"Stringable",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"_createInvalidArgumentException",
... | Adds a state to this instance.
@since [*next-version*]
@param string|Stringable $state The state to add. | [
"Adds",
"a",
"state",
"to",
"this",
"instance",
"."
] | cb5f706edd74d1c747f09f505b859255b13a5b27 | https://github.com/Dhii/state-machine-abstract/blob/cb5f706edd74d1c747f09f505b859255b13a5b27/src/StateListAwareTrait.php#L93-L105 |
236,214 | rseyferth/activerecord | lib/Connection.php | Connection.instance | public static function instance($connectionStringOrConnectionName=null)
{
$config = Config::instance();
// Is it a connection string or name?
if (strpos($connectionStringOrConnectionName, '://') === false) {
$connectionString = $connectionStringOrConnectionName ?
$config->getConnection($connectionStringOrConnectionName) :
$config->getDefaultConnectionString();
} else {
$connectionString = $connectionStringOrConnectionName;
}
if (!$connectionString) throw new DatabaseException("Empty connection string");
$info = static::parseConnectionUrl($connectionString);
$fqclass = static::loadAdapterClass($info->protocol);
try {
$connection = new $fqclass($info);
$connection->protocol = $info->protocol;
$connection->logging = $config->getLogging();
$connection->logger = $connection->logging ? $config->getLogger() : null;
if (isset($info->charset))
$connection->setEncoding($info->charset);
} catch (PDOException $e) {
throw new DatabaseException($e);
}
return $connection;
} | php | public static function instance($connectionStringOrConnectionName=null)
{
$config = Config::instance();
// Is it a connection string or name?
if (strpos($connectionStringOrConnectionName, '://') === false) {
$connectionString = $connectionStringOrConnectionName ?
$config->getConnection($connectionStringOrConnectionName) :
$config->getDefaultConnectionString();
} else {
$connectionString = $connectionStringOrConnectionName;
}
if (!$connectionString) throw new DatabaseException("Empty connection string");
$info = static::parseConnectionUrl($connectionString);
$fqclass = static::loadAdapterClass($info->protocol);
try {
$connection = new $fqclass($info);
$connection->protocol = $info->protocol;
$connection->logging = $config->getLogging();
$connection->logger = $connection->logging ? $config->getLogger() : null;
if (isset($info->charset))
$connection->setEncoding($info->charset);
} catch (PDOException $e) {
throw new DatabaseException($e);
}
return $connection;
} | [
"public",
"static",
"function",
"instance",
"(",
"$",
"connectionStringOrConnectionName",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"Config",
"::",
"instance",
"(",
")",
";",
"// Is it a connection string or name?",
"if",
"(",
"strpos",
"(",
"$",
"connectionStrin... | Retrieve a database connection.
@param string A database connection string (ex. mysql://user:pass@host[:port]/dbname)
Everything after the protocol:// part is specific to the connection adapter.
OR
A connection name that is set in ActiveRecord\Config
If null it will use the default connection specified by ActiveRecord\Config->set_default_connection
@return Connection
@see parse_connection_url | [
"Retrieve",
"a",
"database",
"connection",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Connection.php#L91-L121 |
236,215 | rseyferth/activerecord | lib/Connection.php | Connection.loadAdapterClass | private static function loadAdapterClass($adapter)
{
$class = ucwords($adapter) . 'Adapter';
$fqclass = 'ActiveRecord\\' . $class;
$source = __DIR__ . "/Adapters/$class.php";
if (!file_exists($source))
throw new DatabaseException("$fqclass not found!");
require_once($source);
return $fqclass;
} | php | private static function loadAdapterClass($adapter)
{
$class = ucwords($adapter) . 'Adapter';
$fqclass = 'ActiveRecord\\' . $class;
$source = __DIR__ . "/Adapters/$class.php";
if (!file_exists($source))
throw new DatabaseException("$fqclass not found!");
require_once($source);
return $fqclass;
} | [
"private",
"static",
"function",
"loadAdapterClass",
"(",
"$",
"adapter",
")",
"{",
"$",
"class",
"=",
"ucwords",
"(",
"$",
"adapter",
")",
".",
"'Adapter'",
";",
"$",
"fqclass",
"=",
"'ActiveRecord\\\\'",
".",
"$",
"class",
";",
"$",
"source",
"=",
"__D... | Loads the specified class for an adapter.
@param string $adapter Name of the adapter.
@return string The full name of the class including namespace. | [
"Loads",
"the",
"specified",
"class",
"for",
"an",
"adapter",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Connection.php#L129-L140 |
236,216 | rseyferth/activerecord | lib/Connection.php | Connection.parseConnectionUrl | public static function parseConnectionUrl($connectionUrl)
{
// Parse Url for parts
$url = @parse_url($connectionUrl);
// No host?!
if (!isset($url['host'])) {
throw new DatabaseException('Database host must be specified in the connection string. If you want to specify an absolute filename, use e.g. sqlite://unix(/path/to/file)');
}
// Create info object
$info = new \stdClass();
$info->protocol = $url['scheme'];
$info->host = $url['host'];
$info->db = isset($url['path']) ? substr($url['path'], 1) : null;
$info->user = isset($url['user']) ? $url['user'] : null;
$info->pass = isset($url['pass']) ? $url['pass'] : null;
$allowBlankDb = ($info->protocol == 'sqlite');
if ($info->host == 'unix(') {
$socketDatabase = $info->host . '/' . $info->db;
if ($allowBlankDb)
$unixRegex = '/^unix\((.+)\)\/?().*$/';
else
$unixRegex = '/^unix\((.+)\)\/(.+)$/';
if (preg_match_all($unixRegex, $socketDatabase, $matches) > 0)
{
$info->host = $matches[1][0];
$info->db = $matches[2][0];
}
} elseif (substr($info->host, 0, 8) == 'windows(') {
$info->host = urldecode(substr($info->host, 8) . '/' . substr($info->db, 0, -1));
$info->db = null;
}
if ($allowBlankDb && $info->db) {
$info->host .= '/' . $info->db;
}
if (isset($url['port'])) {
$info->port = $url['port'];
}
if (strpos($connectionUrl, 'decode=true') !== false)
{
if ($info->user)
$info->user = urldecode($info->user);
if ($info->pass)
$info->pass = urldecode($info->pass);
}
if (isset($url['query'])) {
foreach (explode('/&/', $url['query']) as $pair) {
list($name, $value) = explode('=', $pair);
if ($name == 'charset') {
$info->charset = $value;
}
}
}
return $info;
} | php | public static function parseConnectionUrl($connectionUrl)
{
// Parse Url for parts
$url = @parse_url($connectionUrl);
// No host?!
if (!isset($url['host'])) {
throw new DatabaseException('Database host must be specified in the connection string. If you want to specify an absolute filename, use e.g. sqlite://unix(/path/to/file)');
}
// Create info object
$info = new \stdClass();
$info->protocol = $url['scheme'];
$info->host = $url['host'];
$info->db = isset($url['path']) ? substr($url['path'], 1) : null;
$info->user = isset($url['user']) ? $url['user'] : null;
$info->pass = isset($url['pass']) ? $url['pass'] : null;
$allowBlankDb = ($info->protocol == 'sqlite');
if ($info->host == 'unix(') {
$socketDatabase = $info->host . '/' . $info->db;
if ($allowBlankDb)
$unixRegex = '/^unix\((.+)\)\/?().*$/';
else
$unixRegex = '/^unix\((.+)\)\/(.+)$/';
if (preg_match_all($unixRegex, $socketDatabase, $matches) > 0)
{
$info->host = $matches[1][0];
$info->db = $matches[2][0];
}
} elseif (substr($info->host, 0, 8) == 'windows(') {
$info->host = urldecode(substr($info->host, 8) . '/' . substr($info->db, 0, -1));
$info->db = null;
}
if ($allowBlankDb && $info->db) {
$info->host .= '/' . $info->db;
}
if (isset($url['port'])) {
$info->port = $url['port'];
}
if (strpos($connectionUrl, 'decode=true') !== false)
{
if ($info->user)
$info->user = urldecode($info->user);
if ($info->pass)
$info->pass = urldecode($info->pass);
}
if (isset($url['query'])) {
foreach (explode('/&/', $url['query']) as $pair) {
list($name, $value) = explode('=', $pair);
if ($name == 'charset') {
$info->charset = $value;
}
}
}
return $info;
} | [
"public",
"static",
"function",
"parseConnectionUrl",
"(",
"$",
"connectionUrl",
")",
"{",
"// Parse Url for parts",
"$",
"url",
"=",
"@",
"parse_url",
"(",
"$",
"connectionUrl",
")",
";",
"// No host?!",
"if",
"(",
"!",
"isset",
"(",
"$",
"url",
"[",
"'host... | Use this for any adapters that can take connection info in the form below
to set the adapters connection info.
<code>
protocol://username:password@host[:port]/dbname
protocol://urlencoded%20username:urlencoded%20password@host[:port]/dbname?decode=true
protocol://username:password@unix(/some/file/path)/dbname
</code>
Sqlite has a special syntax, as it does not need a database name or user authentication:
<code>
sqlite://file.db
sqlite://../relative/path/to/file.db
sqlite://unix(/absolute/path/to/file.db)
sqlite://windows(c%2A/absolute/path/to/file.db)
</code>
@param string $connection_url A connection URL
@return object the parsed URL as an object. | [
"Use",
"this",
"for",
"any",
"adapters",
"that",
"can",
"take",
"connection",
"info",
"in",
"the",
"form",
"below",
"to",
"set",
"the",
"adapters",
"connection",
"info",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Connection.php#L164-L234 |
236,217 | rseyferth/activerecord | lib/Connection.php | Connection.columns | public function columns($table)
{
$columns = array();
$sth = $this->queryColumnInfo($table);
while (($row = $sth->fetch())) {
$c = $this->createColumn($row);
$columns[$c->name] = $c;
}
return $columns;
} | php | public function columns($table)
{
$columns = array();
$sth = $this->queryColumnInfo($table);
while (($row = $sth->fetch())) {
$c = $this->createColumn($row);
$columns[$c->name] = $c;
}
return $columns;
} | [
"public",
"function",
"columns",
"(",
"$",
"table",
")",
"{",
"$",
"columns",
"=",
"array",
"(",
")",
";",
"$",
"sth",
"=",
"$",
"this",
"->",
"queryColumnInfo",
"(",
"$",
"table",
")",
";",
"while",
"(",
"(",
"$",
"row",
"=",
"$",
"sth",
"->",
... | Retrieves column meta data for the specified table.
@param string $table Name of a table
@return array An array of {@link Column} objects. | [
"Retrieves",
"column",
"meta",
"data",
"for",
"the",
"specified",
"table",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Connection.php#L268-L278 |
236,218 | rseyferth/activerecord | lib/Connection.php | Connection.query | public function query($sql, &$values=array())
{
if ($this->logging)
{
if ($values) {
$this->logger->addInfo($sql, $values);
} else {
$this->logger->addInfo($sql);
}
}
$this->lastQuery = $sql;
try {
if (!($sth = $this->connection->prepare($sql)))
throw new DatabaseException($this);
} catch (PDOException $e) {
throw new DatabaseException($this);
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
try {
if (!$sth->execute($values))
throw new DatabaseException($this);
} catch (PDOException $e) {
throw new DatabaseException($e);
}
return $sth;
} | php | public function query($sql, &$values=array())
{
if ($this->logging)
{
if ($values) {
$this->logger->addInfo($sql, $values);
} else {
$this->logger->addInfo($sql);
}
}
$this->lastQuery = $sql;
try {
if (!($sth = $this->connection->prepare($sql)))
throw new DatabaseException($this);
} catch (PDOException $e) {
throw new DatabaseException($this);
}
$sth->setFetchMode(PDO::FETCH_ASSOC);
try {
if (!$sth->execute($values))
throw new DatabaseException($this);
} catch (PDOException $e) {
throw new DatabaseException($e);
}
return $sth;
} | [
"public",
"function",
"query",
"(",
"$",
"sql",
",",
"&",
"$",
"values",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logging",
")",
"{",
"if",
"(",
"$",
"values",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addInfo",
"(",... | Execute a raw SQL query on the database.
@param string $sql Raw SQL string to execute.
@param array &$values Optional array of bind values
@return mixed A result set object | [
"Execute",
"a",
"raw",
"SQL",
"query",
"on",
"the",
"database",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Connection.php#L309-L337 |
236,219 | rseyferth/activerecord | lib/Connection.php | Connection.queryAndFetchOne | public function queryAndFetchOne($sql, &$values=array())
{
$sth = $this->query($sql, $values);
$row = $sth->fetch(PDO::FETCH_NUM);
return $row[0];
} | php | public function queryAndFetchOne($sql, &$values=array())
{
$sth = $this->query($sql, $values);
$row = $sth->fetch(PDO::FETCH_NUM);
return $row[0];
} | [
"public",
"function",
"queryAndFetchOne",
"(",
"$",
"sql",
",",
"&",
"$",
"values",
"=",
"array",
"(",
")",
")",
"{",
"$",
"sth",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"sql",
",",
"$",
"values",
")",
";",
"$",
"row",
"=",
"$",
"sth",
"->",... | Execute a query that returns maximum of one row with one field and return it.
@param string $sql Raw SQL string to execute.
@param array &$values Optional array of values to bind to the query.
@return string | [
"Execute",
"a",
"query",
"that",
"returns",
"maximum",
"of",
"one",
"row",
"with",
"one",
"field",
"and",
"return",
"it",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Connection.php#L346-L351 |
236,220 | rseyferth/activerecord | lib/Connection.php | Connection.queryAndFetch | public function queryAndFetch($sql, Closure $handler)
{
$sth = $this->query($sql);
while (($row = $sth->fetch(PDO::FETCH_ASSOC)))
$handler($row);
} | php | public function queryAndFetch($sql, Closure $handler)
{
$sth = $this->query($sql);
while (($row = $sth->fetch(PDO::FETCH_ASSOC)))
$handler($row);
} | [
"public",
"function",
"queryAndFetch",
"(",
"$",
"sql",
",",
"Closure",
"$",
"handler",
")",
"{",
"$",
"sth",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"while",
"(",
"(",
"$",
"row",
"=",
"$",
"sth",
"->",
"fetch",
"(",
"PDO",
... | Execute a raw SQL query and fetch the results.
@param string $sql Raw SQL string to execute.
@param Closure $handler Closure that will be passed the fetched results. | [
"Execute",
"a",
"raw",
"SQL",
"query",
"and",
"fetch",
"the",
"results",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Connection.php#L359-L365 |
236,221 | rseyferth/activerecord | lib/Connection.php | Connection.tables | public function tables()
{
$tables = array();
$sth = $this->queryForTables();
while (($row = $sth->fetch(PDO::FETCH_NUM)))
$tables[] = $row[0];
return $tables;
} | php | public function tables()
{
$tables = array();
$sth = $this->queryForTables();
while (($row = $sth->fetch(PDO::FETCH_NUM)))
$tables[] = $row[0];
return $tables;
} | [
"public",
"function",
"tables",
"(",
")",
"{",
"$",
"tables",
"=",
"array",
"(",
")",
";",
"$",
"sth",
"=",
"$",
"this",
"->",
"queryForTables",
"(",
")",
";",
"while",
"(",
"(",
"$",
"row",
"=",
"$",
"sth",
"->",
"fetch",
"(",
"PDO",
"::",
"FE... | Returns all tables for the current database.
@return array Array containing table names. | [
"Returns",
"all",
"tables",
"for",
"the",
"current",
"database",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Connection.php#L372-L381 |
236,222 | rseyferth/activerecord | lib/Connection.php | Connection.quoteName | public function quoteName($string)
{
return $string[0] === static::$QUOTE_CHARACTER || $string[strlen($string) - 1] === static::$QUOTE_CHARACTER ?
$string : static::$QUOTE_CHARACTER . $string . static::$QUOTE_CHARACTER;
} | php | public function quoteName($string)
{
return $string[0] === static::$QUOTE_CHARACTER || $string[strlen($string) - 1] === static::$QUOTE_CHARACTER ?
$string : static::$QUOTE_CHARACTER . $string . static::$QUOTE_CHARACTER;
} | [
"public",
"function",
"quoteName",
"(",
"$",
"string",
")",
"{",
"return",
"$",
"string",
"[",
"0",
"]",
"===",
"static",
"::",
"$",
"QUOTE_CHARACTER",
"||",
"$",
"string",
"[",
"strlen",
"(",
"$",
"string",
")",
"-",
"1",
"]",
"===",
"static",
"::",... | Quote a name like table names and field names.
@param string $string String to quote.
@return string | [
"Quote",
"a",
"name",
"like",
"table",
"names",
"and",
"field",
"names",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Connection.php#L449-L453 |
236,223 | rseyferth/activerecord | lib/Connection.php | Connection.stringToDateTime | public function stringToDateTime($string)
{
$date = date_create($string);
$errors = \DateTime::getLastErrors();
if ($errors['warning_count'] > 0 || $errors['error_count'] > 0)
return null;
return new DateTime($date->format(static::$dateTimeFormat));
} | php | public function stringToDateTime($string)
{
$date = date_create($string);
$errors = \DateTime::getLastErrors();
if ($errors['warning_count'] > 0 || $errors['error_count'] > 0)
return null;
return new DateTime($date->format(static::$dateTimeFormat));
} | [
"public",
"function",
"stringToDateTime",
"(",
"$",
"string",
")",
"{",
"$",
"date",
"=",
"date_create",
"(",
"$",
"string",
")",
";",
"$",
"errors",
"=",
"\\",
"DateTime",
"::",
"getLastErrors",
"(",
")",
";",
"if",
"(",
"$",
"errors",
"[",
"'warning_... | Converts a string representation of a datetime into a DateTime object.
@param string $string A datetime in the form accepted by date_create()
@return DateTime | [
"Converts",
"a",
"string",
"representation",
"of",
"a",
"datetime",
"into",
"a",
"DateTime",
"object",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/Connection.php#L483-L492 |
236,224 | bavix/content | src/Context/Container.php | Container.cleanup | public function cleanup(): void
{
foreach ($this->getStore() as $key => $value)
{
$this->remove($key);
}
} | php | public function cleanup(): void
{
foreach ($this->getStore() as $key => $value)
{
$this->remove($key);
}
} | [
"public",
"function",
"cleanup",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getStore",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"key",
")",
";",
"}",
"}"
] | cleanup content from container | [
"cleanup",
"content",
"from",
"container"
] | 1ea074bc64aef702c1458961d0c623699f9e56d6 | https://github.com/bavix/content/blob/1ea074bc64aef702c1458961d0c623699f9e56d6/src/Context/Container.php#L95-L101 |
236,225 | flavorzyb/simple | src/Controller/Controller.php | Controller.getDefaultTemplateEngine | protected function getDefaultTemplateEngine()
{
$smarty = new Smarty();
$smarty->debugging = false;
$smarty->caching = false;
$smarty->left_delimiter = '{|';
$smarty->right_delimiter = '|}';
$smarty->setTemplateDir($this->resourcePath);
return $smarty;
} | php | protected function getDefaultTemplateEngine()
{
$smarty = new Smarty();
$smarty->debugging = false;
$smarty->caching = false;
$smarty->left_delimiter = '{|';
$smarty->right_delimiter = '|}';
$smarty->setTemplateDir($this->resourcePath);
return $smarty;
} | [
"protected",
"function",
"getDefaultTemplateEngine",
"(",
")",
"{",
"$",
"smarty",
"=",
"new",
"Smarty",
"(",
")",
";",
"$",
"smarty",
"->",
"debugging",
"=",
"false",
";",
"$",
"smarty",
"->",
"caching",
"=",
"false",
";",
"$",
"smarty",
"->",
"left_del... | get default template engine
@return Smarty | [
"get",
"default",
"template",
"engine"
] | 8c4c539ae2057217b2637fc72c2a90ba266e8e6c | https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Controller/Controller.php#L93-L103 |
236,226 | flavorzyb/simple | src/Controller/Controller.php | Controller.getTemplateEngine | public function getTemplateEngine()
{
if (null == $this->templateEngine) {
$this->setTemplateEngine($this->getDefaultTemplateEngine());
}
return $this->templateEngine;
} | php | public function getTemplateEngine()
{
if (null == $this->templateEngine) {
$this->setTemplateEngine($this->getDefaultTemplateEngine());
}
return $this->templateEngine;
} | [
"public",
"function",
"getTemplateEngine",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"templateEngine",
")",
"{",
"$",
"this",
"->",
"setTemplateEngine",
"(",
"$",
"this",
"->",
"getDefaultTemplateEngine",
"(",
")",
")",
";",
"}",
"return",... | set template engine
@return Smarty | [
"set",
"template",
"engine"
] | 8c4c539ae2057217b2637fc72c2a90ba266e8e6c | https://github.com/flavorzyb/simple/blob/8c4c539ae2057217b2637fc72c2a90ba266e8e6c/src/Controller/Controller.php#L121-L128 |
236,227 | cundd/test-flight | src/CodeExtractor.php | CodeExtractor.getCodeFromDocComment | public function getCodeFromDocComment(string $docComment): string
{
$startExampleKeyword = strpos($docComment, Constants::EXAMPLE_KEYWORD);
$startCodeKeyword = strpos($docComment, Constants::CODE_KEYWORD);
if ($startExampleKeyword !== false) {
$matches = $this->getCodeWithExampleKeyword($docComment, $startExampleKeyword);
} elseif ($startCodeKeyword !== false) {
$matches = $this->getCodeWithCodeKeyword($docComment, $startCodeKeyword);
} else {
// None of the keywords was found
return '';
}
if (!$matches) {
return '';
}
$codeLines = array_filter(
array_map(
function ($line) {
return ltrim(trim($line, " \t\n\r\0\x0B"), '*');
},
// TODO: Check what type $matches has
is_array($matches) ? $matches : explode("\n", (string)$matches)
)
);
return rtrim(implode("\n", $codeLines) . ';');
} | php | public function getCodeFromDocComment(string $docComment): string
{
$startExampleKeyword = strpos($docComment, Constants::EXAMPLE_KEYWORD);
$startCodeKeyword = strpos($docComment, Constants::CODE_KEYWORD);
if ($startExampleKeyword !== false) {
$matches = $this->getCodeWithExampleKeyword($docComment, $startExampleKeyword);
} elseif ($startCodeKeyword !== false) {
$matches = $this->getCodeWithCodeKeyword($docComment, $startCodeKeyword);
} else {
// None of the keywords was found
return '';
}
if (!$matches) {
return '';
}
$codeLines = array_filter(
array_map(
function ($line) {
return ltrim(trim($line, " \t\n\r\0\x0B"), '*');
},
// TODO: Check what type $matches has
is_array($matches) ? $matches : explode("\n", (string)$matches)
)
);
return rtrim(implode("\n", $codeLines) . ';');
} | [
"public",
"function",
"getCodeFromDocComment",
"(",
"string",
"$",
"docComment",
")",
":",
"string",
"{",
"$",
"startExampleKeyword",
"=",
"strpos",
"(",
"$",
"docComment",
",",
"Constants",
"::",
"EXAMPLE_KEYWORD",
")",
";",
"$",
"startCodeKeyword",
"=",
"strpo... | Extract the example code from the doc comment
@param string $docComment
@return string | [
"Extract",
"the",
"example",
"code",
"from",
"the",
"doc",
"comment"
] | 9d8424dfb586f823f9dad2dcb81ff3986e255d56 | https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/CodeExtractor.php#L24-L53 |
236,228 | cundd/test-flight | src/CodeExtractor.php | CodeExtractor.getCodeFromDocumentation | public function getCodeFromDocumentation(string $fileContent): array
{
$start = strpos($fileContent, Constants::MARKDOWN_PHP_CODE_KEYWORD);
$code = substr($fileContent, $start);
$regularExpression = '!' . Constants::MARKDOWN_PHP_CODE_KEYWORD . self::DOCUMENTATION_REGEX . '!';
if (!preg_match_all($regularExpression, $code, $matches)) {
return [];
}
return array_map(
function ($line) {
return trim($line);
},
$matches[1]
);
} | php | public function getCodeFromDocumentation(string $fileContent): array
{
$start = strpos($fileContent, Constants::MARKDOWN_PHP_CODE_KEYWORD);
$code = substr($fileContent, $start);
$regularExpression = '!' . Constants::MARKDOWN_PHP_CODE_KEYWORD . self::DOCUMENTATION_REGEX . '!';
if (!preg_match_all($regularExpression, $code, $matches)) {
return [];
}
return array_map(
function ($line) {
return trim($line);
},
$matches[1]
);
} | [
"public",
"function",
"getCodeFromDocumentation",
"(",
"string",
"$",
"fileContent",
")",
":",
"array",
"{",
"$",
"start",
"=",
"strpos",
"(",
"$",
"fileContent",
",",
"Constants",
"::",
"MARKDOWN_PHP_CODE_KEYWORD",
")",
";",
"$",
"code",
"=",
"substr",
"(",
... | Extract the example code from the documentation file
@param string $fileContent
@return string[] | [
"Extract",
"the",
"example",
"code",
"from",
"the",
"documentation",
"file"
] | 9d8424dfb586f823f9dad2dcb81ff3986e255d56 | https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/CodeExtractor.php#L61-L77 |
236,229 | diatem-net/jin-ui | src/UI/Components/Boolean.php | Boolean.render | public function render()
{
$html = parent::render();
if (is_null($this->value)) {
$html = str_replace('%value%', '', $html);
} else if ($this->value) {
$content = static::getAssetContent('true');
$html = str_replace('%value%', $content, $html);
} else {
$content = static::getAssetContent('false');
$html = str_replace('%value%', $content, $html);
}
return $html;
} | php | public function render()
{
$html = parent::render();
if (is_null($this->value)) {
$html = str_replace('%value%', '', $html);
} else if ($this->value) {
$content = static::getAssetContent('true');
$html = str_replace('%value%', $content, $html);
} else {
$content = static::getAssetContent('false');
$html = str_replace('%value%', $content, $html);
}
return $html;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"html",
"=",
"parent",
"::",
"render",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"$",
"html",
"=",
"str_replace",
"(",
"'%value%'",
",",
"''",
",",
"$"... | Effectue le rendu du composant
@return string | [
"Effectue",
"le",
"rendu",
"du",
"composant"
] | d0825d3d0a983ee3d22b23e545eb9724b67bbaa5 | https://github.com/diatem-net/jin-ui/blob/d0825d3d0a983ee3d22b23e545eb9724b67bbaa5/src/UI/Components/Boolean.php#L30-L44 |
236,230 | cliffparnitzky/TinyMceInsertDateTime | system/modules/TinyMceInsertDateTime/classes/TinyMceInsertDateTime.php | TinyMceInsertDateTime.editTinyMcePluginLoaderConfig | public function editTinyMcePluginLoaderConfig ($arrTinyConfig) {
$arrTinyConfig["insertdatetime_formats"] = '["' . $this->transformFormat($GLOBALS['TL_CONFIG']['dateFormat']) . '", "' . $this->transformFormat($GLOBALS['TL_CONFIG']['timeFormat']) . '"],';
return $arrTinyConfig;
} | php | public function editTinyMcePluginLoaderConfig ($arrTinyConfig) {
$arrTinyConfig["insertdatetime_formats"] = '["' . $this->transformFormat($GLOBALS['TL_CONFIG']['dateFormat']) . '", "' . $this->transformFormat($GLOBALS['TL_CONFIG']['timeFormat']) . '"],';
return $arrTinyConfig;
} | [
"public",
"function",
"editTinyMcePluginLoaderConfig",
"(",
"$",
"arrTinyConfig",
")",
"{",
"$",
"arrTinyConfig",
"[",
"\"insertdatetime_formats\"",
"]",
"=",
"'[\"'",
".",
"$",
"this",
"->",
"transformFormat",
"(",
"$",
"GLOBALS",
"[",
"'TL_CONFIG'",
"]",
"[",
... | Adding config for output behavoir | [
"Adding",
"config",
"for",
"output",
"behavoir"
] | 6fd1cc15d363a89a67a300d8ddd988806344c46d | https://github.com/cliffparnitzky/TinyMceInsertDateTime/blob/6fd1cc15d363a89a67a300d8ddd988806344c46d/system/modules/TinyMceInsertDateTime/classes/TinyMceInsertDateTime.php#L70-L73 |
236,231 | cliffparnitzky/TinyMceInsertDateTime | system/modules/TinyMceInsertDateTime/classes/TinyMceInsertDateTime.php | TinyMceInsertDateTime.transformFormat | private function transformFormat($strFormat)
{
$arrFormatTokens = str_split($strFormat);
foreach ($arrFormatTokens as $i => $token)
{
if (ctype_alpha($token))
{
$arrFormatTokens[$i] = $this->arrMapping[$token];
}
}
return implode('', $arrFormatTokens);
} | php | private function transformFormat($strFormat)
{
$arrFormatTokens = str_split($strFormat);
foreach ($arrFormatTokens as $i => $token)
{
if (ctype_alpha($token))
{
$arrFormatTokens[$i] = $this->arrMapping[$token];
}
}
return implode('', $arrFormatTokens);
} | [
"private",
"function",
"transformFormat",
"(",
"$",
"strFormat",
")",
"{",
"$",
"arrFormatTokens",
"=",
"str_split",
"(",
"$",
"strFormat",
")",
";",
"foreach",
"(",
"$",
"arrFormatTokens",
"as",
"$",
"i",
"=>",
"$",
"token",
")",
"{",
"if",
"(",
"ctype_... | Transforms a format from PHP into TinyMCE preferred | [
"Transforms",
"a",
"format",
"from",
"PHP",
"into",
"TinyMCE",
"preferred"
] | 6fd1cc15d363a89a67a300d8ddd988806344c46d | https://github.com/cliffparnitzky/TinyMceInsertDateTime/blob/6fd1cc15d363a89a67a300d8ddd988806344c46d/system/modules/TinyMceInsertDateTime/classes/TinyMceInsertDateTime.php#L78-L91 |
236,232 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/package.php | Package.load | public static function load($package, $path = null)
{
if (is_array($package))
{
foreach ($package as $pkg => $path)
{
if (is_numeric($pkg))
{
$pkg = $path;
$path = null;
}
static::load($pkg, $path);
}
return false;
}
if (static::loaded($package))
{
return;
}
// if no path is given, try to locate the package
if ($path === null)
{
$paths = \Config::get('package_paths', array());
empty($paths) and $paths = array(PKGPATH);
if ( ! empty($paths))
{
foreach ($paths as $modpath)
{
if (is_dir($path = $modpath.strtolower($package).DS))
{
break;
}
}
}
}
if ( ! is_dir($path))
{
throw new \PackageNotFoundException("Package '$package' could not be found at '".\Fuel::clean_path($path)."'");
}
\Finder::instance()->add_path($path, 1);
\Fuel::load($path.'bootstrap.php');
static::$packages[$package] = $path;
return true;
} | php | public static function load($package, $path = null)
{
if (is_array($package))
{
foreach ($package as $pkg => $path)
{
if (is_numeric($pkg))
{
$pkg = $path;
$path = null;
}
static::load($pkg, $path);
}
return false;
}
if (static::loaded($package))
{
return;
}
// if no path is given, try to locate the package
if ($path === null)
{
$paths = \Config::get('package_paths', array());
empty($paths) and $paths = array(PKGPATH);
if ( ! empty($paths))
{
foreach ($paths as $modpath)
{
if (is_dir($path = $modpath.strtolower($package).DS))
{
break;
}
}
}
}
if ( ! is_dir($path))
{
throw new \PackageNotFoundException("Package '$package' could not be found at '".\Fuel::clean_path($path)."'");
}
\Finder::instance()->add_path($path, 1);
\Fuel::load($path.'bootstrap.php');
static::$packages[$package] = $path;
return true;
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"package",
",",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"package",
")",
")",
"{",
"foreach",
"(",
"$",
"package",
"as",
"$",
"pkg",
"=>",
"$",
"path",
")",
"{",
"if",
... | Loads the given package. If a path is not given, if will search through
the defined package_paths. If not defined, then PKGPATH is used.
It also accepts an array of packages as the first parameter.
@param string|array $package The package name or array of packages.
@param string|null $path The path to the package
@return bool True on success
@throws PackageNotFoundException | [
"Loads",
"the",
"given",
"package",
".",
"If",
"a",
"path",
"is",
"not",
"given",
"if",
"will",
"search",
"through",
"the",
"defined",
"package_paths",
".",
"If",
"not",
"defined",
"then",
"PKGPATH",
"is",
"used",
".",
"It",
"also",
"accepts",
"an",
"arr... | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/package.php#L47-L97 |
236,233 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/package.php | Package.exists | public static function exists($package)
{
if (array_key_exists($package, static::$packages))
{
return static::$packages[$package];
}
else
{
$paths = \Config::get('package_paths', array());
empty($paths) and $paths = array(PKGPATH);
foreach ($paths as $path)
{
if (is_dir($path.$package))
{
return $path.$package.DS;
}
}
}
return false;
} | php | public static function exists($package)
{
if (array_key_exists($package, static::$packages))
{
return static::$packages[$package];
}
else
{
$paths = \Config::get('package_paths', array());
empty($paths) and $paths = array(PKGPATH);
foreach ($paths as $path)
{
if (is_dir($path.$package))
{
return $path.$package.DS;
}
}
}
return false;
} | [
"public",
"static",
"function",
"exists",
"(",
"$",
"package",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"package",
",",
"static",
"::",
"$",
"packages",
")",
")",
"{",
"return",
"static",
"::",
"$",
"packages",
"[",
"$",
"package",
"]",
";",
... | Checks if the given package exists.
@param string $package The package name
@return bool|string Path to the package found, or false if not found | [
"Checks",
"if",
"the",
"given",
"package",
"exists",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/package.php#L134-L155 |
236,234 | OWeb/OWeb-Framework | OWeb/utils/Singleton.php | Singleton.forceInstance | static function forceInstance(Singleton $object, $class = null)
{
if($class == null)
$class = get_class($object);
if(!isset(self::$instances[$class]))
{
self::$instances[$class] = $object;
}
else
{
throw new \Exception(sprintf('Object of class %s was previously instanciated', $class));
}
} | php | static function forceInstance(Singleton $object, $class = null)
{
if($class == null)
$class = get_class($object);
if(!isset(self::$instances[$class]))
{
self::$instances[$class] = $object;
}
else
{
throw new \Exception(sprintf('Object of class %s was previously instanciated', $class));
}
} | [
"static",
"function",
"forceInstance",
"(",
"Singleton",
"$",
"object",
",",
"$",
"class",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"class",
"==",
"null",
")",
"$",
"class",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"if",
"(",
"!",
"isset",
"("... | Force a singleton object to be instanciated with the given instance
Use with care! | [
"Force",
"a",
"singleton",
"object",
"to",
"be",
"instanciated",
"with",
"the",
"given",
"instance",
"Use",
"with",
"care!"
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/utils/Singleton.php#L54-L67 |
236,235 | konservs/brilliant.framework | libraries/Config/BConfigCategory.php | BConfigCategory.registerGroup | public function registerGroup($name,$alias,$fields){
$grp=new BConfigCategoryGroup();
$grp->alias=$alias;
$grp->name=$name;
foreach($fields as $fld){
$grp->fields[$fld->alias]=$fld;
}
$this->groups[$alias]=$grp;
return $grp;
} | php | public function registerGroup($name,$alias,$fields){
$grp=new BConfigCategoryGroup();
$grp->alias=$alias;
$grp->name=$name;
foreach($fields as $fld){
$grp->fields[$fld->alias]=$fld;
}
$this->groups[$alias]=$grp;
return $grp;
} | [
"public",
"function",
"registerGroup",
"(",
"$",
"name",
",",
"$",
"alias",
",",
"$",
"fields",
")",
"{",
"$",
"grp",
"=",
"new",
"BConfigCategoryGroup",
"(",
")",
";",
"$",
"grp",
"->",
"alias",
"=",
"$",
"alias",
";",
"$",
"grp",
"->",
"name",
"=... | Register group
Create BConfigCategoryGroup object & register it
@param string $name name of the group
@param string $alias group alias
@param array $fields array of BConfigField objects
@return \BConfigCategoryGroup created group object | [
"Register",
"group",
"Create",
"BConfigCategoryGroup",
"object",
"&",
"register",
"it"
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Config/BConfigCategory.php#L22-L31 |
236,236 | ionutmilica/ionix-framework | src/Foundation/Config.php | Config.get | public function get($name, $default = null)
{
$parts = explode('.', $name);
$partsSize = count($parts);
if ($partsSize < 1) {
throw new Exception('Invalid config::get format !');
}
$this->loadData($parts[0]);
if ($partsSize == 1) {
return $this->data[$parts[0]];
}
$path = implode('.', array_slice($parts, 1, $partsSize));
return Arr::get($this->data[$parts[0]], $path, $default);
} | php | public function get($name, $default = null)
{
$parts = explode('.', $name);
$partsSize = count($parts);
if ($partsSize < 1) {
throw new Exception('Invalid config::get format !');
}
$this->loadData($parts[0]);
if ($partsSize == 1) {
return $this->data[$parts[0]];
}
$path = implode('.', array_slice($parts, 1, $partsSize));
return Arr::get($this->data[$parts[0]], $path, $default);
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
")",
";",
"$",
"partsSize",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"if",
"(",
"$",
"parts... | Get config option
@param $name
@param null $default
@return mixed
@throws Exception | [
"Get",
"config",
"option"
] | a0363667ff677f1772bdd9ac9530a9f4710f9321 | https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Foundation/Config.php#L45-L63 |
236,237 | binsoul/db | src/DefaultConnectionPool.php | DefaultConnectionPool.connect | private function connect(array &$connections)
{
$exceptions = [];
while (count($connections) > 0) {
/** @var Connection $connection */
$connection = array_pop($connections);
try {
if ($connection->open()) {
return $connection;
}
} catch (DatabaseException $e) {
$exceptions[] = $e->getMessage();
}
}
throw new ConnectionException(
'Unable to select connection.',
'',
0,
count($exceptions) > 0 ? new ConnectionException(implode(' ', $exceptions)) : null
);
} | php | private function connect(array &$connections)
{
$exceptions = [];
while (count($connections) > 0) {
/** @var Connection $connection */
$connection = array_pop($connections);
try {
if ($connection->open()) {
return $connection;
}
} catch (DatabaseException $e) {
$exceptions[] = $e->getMessage();
}
}
throw new ConnectionException(
'Unable to select connection.',
'',
0,
count($exceptions) > 0 ? new ConnectionException(implode(' ', $exceptions)) : null
);
} | [
"private",
"function",
"connect",
"(",
"array",
"&",
"$",
"connections",
")",
"{",
"$",
"exceptions",
"=",
"[",
"]",
";",
"while",
"(",
"count",
"(",
"$",
"connections",
")",
">",
"0",
")",
"{",
"/** @var Connection $connection */",
"$",
"connection",
"=",... | Calls the connect method for every connection in the given array and returns the connection on success.
@param Connection[] $connections
@throws ConnectionException
@return Connection | [
"Calls",
"the",
"connect",
"method",
"for",
"every",
"connection",
"in",
"the",
"given",
"array",
"and",
"returns",
"the",
"connection",
"on",
"success",
"."
] | ad12854d6c1541975de0d2747842f012c4579cc6 | https://github.com/binsoul/db/blob/ad12854d6c1541975de0d2747842f012c4579cc6/src/DefaultConnectionPool.php#L143-L165 |
236,238 | phproberto/joomla-common | src/Traits/HasLayouts.php | HasLayouts.debug | public function debug($layoutId = null, $data = array())
{
$layoutId = $layoutId ?: 'default';
$renderer = new \JLayoutFile($layoutId);
$renderer->setIncludePaths($this->getLayoutPaths());
return $renderer->debug(array_merge($this->getLayoutData(), $data));
} | php | public function debug($layoutId = null, $data = array())
{
$layoutId = $layoutId ?: 'default';
$renderer = new \JLayoutFile($layoutId);
$renderer->setIncludePaths($this->getLayoutPaths());
return $renderer->debug(array_merge($this->getLayoutData(), $data));
} | [
"public",
"function",
"debug",
"(",
"$",
"layoutId",
"=",
"null",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"layoutId",
"=",
"$",
"layoutId",
"?",
":",
"'default'",
";",
"$",
"renderer",
"=",
"new",
"\\",
"JLayoutFile",
"(",
"$",
"la... | Debug a layout rendering.
@param string $layoutId Layout identifier
@param array $data Optional data for the layout
@return string | [
"Debug",
"a",
"layout",
"rendering",
"."
] | bbb37df453bfcb545c3a2c6f14340f0a27e448b2 | https://github.com/phproberto/joomla-common/blob/bbb37df453bfcb545c3a2c6f14340f0a27e448b2/src/Traits/HasLayouts.php#L28-L36 |
236,239 | themichaelhall/bluemvc-api | src/ApiController.php | ApiController.readContent | private function readContent(): bool
{
$rawContent = $this->getRequest()->getRawContent();
if ($rawContent === '') {
$this->content = null;
return true;
}
$this->content = json_decode($rawContent, true);
if (json_last_error() !== JSON_ERROR_NONE) {
$this->getResponse()->setStatusCode(new StatusCode(StatusCode::BAD_REQUEST));
return false;
}
return true;
} | php | private function readContent(): bool
{
$rawContent = $this->getRequest()->getRawContent();
if ($rawContent === '') {
$this->content = null;
return true;
}
$this->content = json_decode($rawContent, true);
if (json_last_error() !== JSON_ERROR_NONE) {
$this->getResponse()->setStatusCode(new StatusCode(StatusCode::BAD_REQUEST));
return false;
}
return true;
} | [
"private",
"function",
"readContent",
"(",
")",
":",
"bool",
"{",
"$",
"rawContent",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getRawContent",
"(",
")",
";",
"if",
"(",
"$",
"rawContent",
"===",
"''",
")",
"{",
"$",
"this",
"->",
"conten... | Reads the content.
@return bool True if content was successfully read, false otherwise. | [
"Reads",
"the",
"content",
"."
] | 25d96c4db44bbe8a74c9fa0747522b584fb88222 | https://github.com/themichaelhall/bluemvc-api/blob/25d96c4db44bbe8a74c9fa0747522b584fb88222/src/ApiController.php#L112-L129 |
236,240 | jmpantoja/planb-utils | src/Type/Text/Text.php | Text.concat | public static function concat(iterable $pieces, ?string $delimiter = null): self
{
$delimiter = is_null($delimiter) ? Text::EMPTY_TEXT : $delimiter;
$temp = TextVector::make($pieces)
->concat($delimiter);
return self::make($temp);
} | php | public static function concat(iterable $pieces, ?string $delimiter = null): self
{
$delimiter = is_null($delimiter) ? Text::EMPTY_TEXT : $delimiter;
$temp = TextVector::make($pieces)
->concat($delimiter);
return self::make($temp);
} | [
"public",
"static",
"function",
"concat",
"(",
"iterable",
"$",
"pieces",
",",
"?",
"string",
"$",
"delimiter",
"=",
"null",
")",
":",
"self",
"{",
"$",
"delimiter",
"=",
"is_null",
"(",
"$",
"delimiter",
")",
"?",
"Text",
"::",
"EMPTY_TEXT",
":",
"$",... | Crea una nueva instancia concatenando varias cadenas de texto
@param string[] $pieces
@param string $delimiter
@return \PlanB\Type\Text\Text | [
"Crea",
"una",
"nueva",
"instancia",
"concatenando",
"varias",
"cadenas",
"de",
"texto"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Text/Text.php#L88-L96 |
236,241 | jmpantoja/planb-utils | src/Type/Text/Text.php | Text.toCamelCase | public function toCamelCase(): self
{
return $this->split('/[_\s\W]+/')
->reduce(function (Text $carry, Text $piece) {
return $carry->append($piece->toUpperFirst()->stringify());
}, self::make())
->toLowerFirst();
} | php | public function toCamelCase(): self
{
return $this->split('/[_\s\W]+/')
->reduce(function (Text $carry, Text $piece) {
return $carry->append($piece->toUpperFirst()->stringify());
}, self::make())
->toLowerFirst();
} | [
"public",
"function",
"toCamelCase",
"(",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"split",
"(",
"'/[_\\s\\W]+/'",
")",
"->",
"reduce",
"(",
"function",
"(",
"Text",
"$",
"carry",
",",
"Text",
"$",
"piece",
")",
"{",
"return",
"$",
"carry",
... | Transforma la cadena de texto a formato camelCase
@return \PlanB\Type\Text\Text | [
"Transforma",
"la",
"cadena",
"de",
"texto",
"a",
"formato",
"camelCase"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Text/Text.php#L192-L200 |
236,242 | jmpantoja/planb-utils | src/Type/Text/Text.php | Text.toSnakeCase | public function toSnakeCase(string $separator = '_'): self
{
return $this->toCamelCase()
->replace('/[A-Z]/', function ($piece) use ($separator) {
return sprintf('%s%s', $separator, strtolower($piece));
});
} | php | public function toSnakeCase(string $separator = '_'): self
{
return $this->toCamelCase()
->replace('/[A-Z]/', function ($piece) use ($separator) {
return sprintf('%s%s', $separator, strtolower($piece));
});
} | [
"public",
"function",
"toSnakeCase",
"(",
"string",
"$",
"separator",
"=",
"'_'",
")",
":",
"self",
"{",
"return",
"$",
"this",
"->",
"toCamelCase",
"(",
")",
"->",
"replace",
"(",
"'/[A-Z]/'",
",",
"function",
"(",
"$",
"piece",
")",
"use",
"(",
"$",
... | Transforma la cadena de texto a formato snake_case
@param string $separator
@return \PlanB\Type\Text\Text | [
"Transforma",
"la",
"cadena",
"de",
"texto",
"a",
"formato",
"snake_case"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Text/Text.php#L209-L216 |
236,243 | jmpantoja/planb-utils | src/Type/Text/Text.php | Text.explode | public function explode(string $delimiter, int $limit = PHP_INT_MAX): TextVector
{
$pieces = explode($delimiter, $this->text, $limit);
return TextVector::make($pieces);
} | php | public function explode(string $delimiter, int $limit = PHP_INT_MAX): TextVector
{
$pieces = explode($delimiter, $this->text, $limit);
return TextVector::make($pieces);
} | [
"public",
"function",
"explode",
"(",
"string",
"$",
"delimiter",
",",
"int",
"$",
"limit",
"=",
"PHP_INT_MAX",
")",
":",
"TextVector",
"{",
"$",
"pieces",
"=",
"explode",
"(",
"$",
"delimiter",
",",
"$",
"this",
"->",
"text",
",",
"$",
"limit",
")",
... | Divide una cadena en varias, mediante un delimitador
@param string $delimiter
@param int $limit
@return \PlanB\Type\Text\TextVector | [
"Divide",
"una",
"cadena",
"en",
"varias",
"mediante",
"un",
"delimitador"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Text/Text.php#L246-L251 |
236,244 | markstory/cakephp_geshi | src/View/Helper/GeshiHelper.php | GeshiHelper.highlight | public function highlight($htmlString)
{
$tags = implode('|', $this->validContainers);
$pattern = '#(<(' . $tags . ')[^>]'.$this->langAttribute . '=["\']+([^\'".]*)["\']+>)(.*?)(</\2\s*>|$)#s';
/*
matches[0] = whole string
matches[1] = open tag including lang attribute
matches[2] = tag name
matches[3] = value of lang attribute
matches[4] = text to be highlighted
matches[5] = end tag
*/
return preg_replace_callback($pattern, array($this, '_processCodeBlock'), $htmlString);
} | php | public function highlight($htmlString)
{
$tags = implode('|', $this->validContainers);
$pattern = '#(<(' . $tags . ')[^>]'.$this->langAttribute . '=["\']+([^\'".]*)["\']+>)(.*?)(</\2\s*>|$)#s';
/*
matches[0] = whole string
matches[1] = open tag including lang attribute
matches[2] = tag name
matches[3] = value of lang attribute
matches[4] = text to be highlighted
matches[5] = end tag
*/
return preg_replace_callback($pattern, array($this, '_processCodeBlock'), $htmlString);
} | [
"public",
"function",
"highlight",
"(",
"$",
"htmlString",
")",
"{",
"$",
"tags",
"=",
"implode",
"(",
"'|'",
",",
"$",
"this",
"->",
"validContainers",
")",
";",
"$",
"pattern",
"=",
"'#(<('",
".",
"$",
"tags",
".",
"')[^>]'",
".",
"$",
"this",
"->"... | Highlight a block of HTML containing defined blocks. Converts blocks from plain text
into highlighted code.
@param string $htmlString
@return void | [
"Highlight",
"a",
"block",
"of",
"HTML",
"containing",
"defined",
"blocks",
".",
"Converts",
"blocks",
"from",
"plain",
"text",
"into",
"highlighted",
"code",
"."
] | 8c3fe7a977d26ae4d991e839a52b09f2b3120047 | https://github.com/markstory/cakephp_geshi/blob/8c3fe7a977d26ae4d991e839a52b09f2b3120047/src/View/Helper/GeshiHelper.php#L124-L137 |
236,245 | markstory/cakephp_geshi | src/View/Helper/GeshiHelper.php | GeshiHelper.highlightText | public function highlightText($text, $language, $withStylesheet = false)
{
$this->_getGeshi();
$this->_geshi->set_source($text);
$this->_geshi->set_language($language);
return !$withStylesheet ?
$this->_geshi->parse_code() :
$this->_includeStylesheet() . $this->_geshi->parse_code();
} | php | public function highlightText($text, $language, $withStylesheet = false)
{
$this->_getGeshi();
$this->_geshi->set_source($text);
$this->_geshi->set_language($language);
return !$withStylesheet ?
$this->_geshi->parse_code() :
$this->_includeStylesheet() . $this->_geshi->parse_code();
} | [
"public",
"function",
"highlightText",
"(",
"$",
"text",
",",
"$",
"language",
",",
"$",
"withStylesheet",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"_getGeshi",
"(",
")",
";",
"$",
"this",
"->",
"_geshi",
"->",
"set_source",
"(",
"$",
"text",
")",
... | Highlight all the provided text as a given language.
@param string $text The text to highight.
@param string $language The language to highlight as.
@param bool $withStylesheet If true will include GeSHi's generated stylesheet.
@return string Highlighted HTML. | [
"Highlight",
"all",
"the",
"provided",
"text",
"as",
"a",
"given",
"language",
"."
] | 8c3fe7a977d26ae4d991e839a52b09f2b3120047 | https://github.com/markstory/cakephp_geshi/blob/8c3fe7a977d26ae4d991e839a52b09f2b3120047/src/View/Helper/GeshiHelper.php#L147-L155 |
236,246 | markstory/cakephp_geshi | src/View/Helper/GeshiHelper.php | GeshiHelper._getGeshi | protected function _getGeshi()
{
if (!$this->_geshi) {
$this->_geshi = new GeSHi();
}
$this->_configureInstance($this->_geshi);
return $this->_geshi;
} | php | protected function _getGeshi()
{
if (!$this->_geshi) {
$this->_geshi = new GeSHi();
}
$this->_configureInstance($this->_geshi);
return $this->_geshi;
} | [
"protected",
"function",
"_getGeshi",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_geshi",
")",
"{",
"$",
"this",
"->",
"_geshi",
"=",
"new",
"GeSHi",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_configureInstance",
"(",
"$",
"this",
"->",
"_ges... | Get the instance of GeSHI used by the helper. | [
"Get",
"the",
"instance",
"of",
"GeSHI",
"used",
"by",
"the",
"helper",
"."
] | 8c3fe7a977d26ae4d991e839a52b09f2b3120047 | https://github.com/markstory/cakephp_geshi/blob/8c3fe7a977d26ae4d991e839a52b09f2b3120047/src/View/Helper/GeshiHelper.php#L207-L214 |
236,247 | markstory/cakephp_geshi | src/View/Helper/GeshiHelper.php | GeshiHelper._processCodeBlock | protected function _processCodeBlock($matches)
{
list($block, $openTag, $tagName, $lang, $code, $closeTag) = $matches;
unset($matches);
// check language
$lang = $this->validLang($lang);
$code = html_entity_decode($code, ENT_QUOTES); // decode text in code block as GeSHi will re-encode it.
if (isset($this->containerMap[$tagName])) {
$patt = '/' . preg_quote($tagName) . '/';
$openTag = preg_replace($patt, $this->containerMap[$tagName][0], $openTag);
$closeTag = preg_replace($patt, $this->containerMap[$tagName][1], $closeTag);
}
if ($this->showPlainTextButton) {
$button = '<a href="#null" class="geshi-plain-text">Show Plain Text</a>';
$openTag = $button . $openTag;
}
if ($lang) {
$highlighted = $this->highlightText(trim($code), $lang);
return $openTag . $highlighted . $closeTag;
}
return $openTag . $code . $closeTag;
} | php | protected function _processCodeBlock($matches)
{
list($block, $openTag, $tagName, $lang, $code, $closeTag) = $matches;
unset($matches);
// check language
$lang = $this->validLang($lang);
$code = html_entity_decode($code, ENT_QUOTES); // decode text in code block as GeSHi will re-encode it.
if (isset($this->containerMap[$tagName])) {
$patt = '/' . preg_quote($tagName) . '/';
$openTag = preg_replace($patt, $this->containerMap[$tagName][0], $openTag);
$closeTag = preg_replace($patt, $this->containerMap[$tagName][1], $closeTag);
}
if ($this->showPlainTextButton) {
$button = '<a href="#null" class="geshi-plain-text">Show Plain Text</a>';
$openTag = $button . $openTag;
}
if ($lang) {
$highlighted = $this->highlightText(trim($code), $lang);
return $openTag . $highlighted . $closeTag;
}
return $openTag . $code . $closeTag;
} | [
"protected",
"function",
"_processCodeBlock",
"(",
"$",
"matches",
")",
"{",
"list",
"(",
"$",
"block",
",",
"$",
"openTag",
",",
"$",
"tagName",
",",
"$",
"lang",
",",
"$",
"code",
",",
"$",
"closeTag",
")",
"=",
"$",
"matches",
";",
"unset",
"(",
... | Preg Replace Callback
Uses matches made earlier runs geshi returns processed code blocks.
@return string Completed replacement string | [
"Preg",
"Replace",
"Callback",
"Uses",
"matches",
"made",
"earlier",
"runs",
"geshi",
"returns",
"processed",
"code",
"blocks",
"."
] | 8c3fe7a977d26ae4d991e839a52b09f2b3120047 | https://github.com/markstory/cakephp_geshi/blob/8c3fe7a977d26ae4d991e839a52b09f2b3120047/src/View/Helper/GeshiHelper.php#L222-L247 |
236,248 | markstory/cakephp_geshi | src/View/Helper/GeshiHelper.php | GeshiHelper.validLang | public function validLang($lang)
{
if (in_array($lang, $this->validLanguages)) {
return $lang;
}
if ($this->defaultLanguage) {
return $this->defaultLanguage;
}
return false;
} | php | public function validLang($lang)
{
if (in_array($lang, $this->validLanguages)) {
return $lang;
}
if ($this->defaultLanguage) {
return $this->defaultLanguage;
}
return false;
} | [
"public",
"function",
"validLang",
"(",
"$",
"lang",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"lang",
",",
"$",
"this",
"->",
"validLanguages",
")",
")",
"{",
"return",
"$",
"lang",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"defaultLanguage",
")",
... | Check if the current language is a valid language.
@param string $lang Language
@return mixed. | [
"Check",
"if",
"the",
"current",
"language",
"is",
"a",
"valid",
"language",
"."
] | 8c3fe7a977d26ae4d991e839a52b09f2b3120047 | https://github.com/markstory/cakephp_geshi/blob/8c3fe7a977d26ae4d991e839a52b09f2b3120047/src/View/Helper/GeshiHelper.php#L255-L264 |
236,249 | markstory/cakephp_geshi | src/View/Helper/GeshiHelper.php | GeshiHelper._configureInstance | protected function _configureInstance($geshi)
{
if (empty($this->features)) {
if (empty($this->configPath)) {
$this->configPath = ROOT . DS . 'config' . DS;
}
if (file_exists($this->configPath . 'geshi.php')) {
include $this->configPath . 'geshi.php';
}
return;
}
foreach ($this->features as $key => $value) {
foreach ($value as &$test) {
if (defined($test)) {
// convert strings to Geshi's constant values
// (exists possibility of name collisions)
$test = constant($test);
}
}
unset($test);
call_user_func_array(array($geshi, $key), $value);
}
} | php | protected function _configureInstance($geshi)
{
if (empty($this->features)) {
if (empty($this->configPath)) {
$this->configPath = ROOT . DS . 'config' . DS;
}
if (file_exists($this->configPath . 'geshi.php')) {
include $this->configPath . 'geshi.php';
}
return;
}
foreach ($this->features as $key => $value) {
foreach ($value as &$test) {
if (defined($test)) {
// convert strings to Geshi's constant values
// (exists possibility of name collisions)
$test = constant($test);
}
}
unset($test);
call_user_func_array(array($geshi, $key), $value);
}
} | [
"protected",
"function",
"_configureInstance",
"(",
"$",
"geshi",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"features",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"configPath",
")",
")",
"{",
"$",
"this",
"->",
"configPath... | Configure a geshi Instance the way we want it.
$this->Geshi->features = array(...)
@param Geshi $geshi
@return void | [
"Configure",
"a",
"geshi",
"Instance",
"the",
"way",
"we",
"want",
"it",
"."
] | 8c3fe7a977d26ae4d991e839a52b09f2b3120047 | https://github.com/markstory/cakephp_geshi/blob/8c3fe7a977d26ae4d991e839a52b09f2b3120047/src/View/Helper/GeshiHelper.php#L274-L296 |
236,250 | FuturaSoft/Pabana | src/Html/Head/Title.php | Title.render | public function render()
{
if (!empty(self::$titleList->toArray())) {
return '<title>' . implode('', self::$titleList->toArray()) . '</title>' . PHP_EOL;
} else {
return false;
}
} | php | public function render()
{
if (!empty(self::$titleList->toArray())) {
return '<title>' . implode('', self::$titleList->toArray()) . '</title>' . PHP_EOL;
} else {
return false;
}
} | [
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"self",
"::",
"$",
"titleList",
"->",
"toArray",
"(",
")",
")",
")",
"{",
"return",
"'<title>'",
".",
"implode",
"(",
"''",
",",
"self",
"::",
"$",
"titleList",
"->",
"toA... | Return HTML code for Title
@since 1.0
@return string|boolean Html code for Title or false is empty | [
"Return",
"HTML",
"code",
"for",
"Title"
] | b3a95eeb976042ac2a393cc10755a7adbc164c24 | https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Html/Head/Title.php#L96-L103 |
236,251 | Arcavias/ext-zend | lib/custom/src/MW/Common/Criteria/Expression/Compare/Lucene.php | MW_Common_Criteria_Expression_Compare_Lucene._createTerm | protected function _createTerm( $name, $type, $value )
{
switch( $this->getOperator() )
{
case '==':
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( $this->_empty( $escaped ), $name );
return new Zend_Search_Lucene_Search_Query_Term( $term );
case '!=':
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( $this->_empty( $escaped ), $name );
return new Zend_Search_Lucene_Search_Query_MultiTerm( array( $term ), array( false ) );
case '~=':
if( ( $parts = explode( ' ', $value ) ) === false ) {
throw new MW_Common_Exception( 'Empty term is not allowed for wildcard queries' );
}
$query = new Zend_Search_Lucene_Search_Query_Boolean();
foreach( $parts as $part )
{
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $part );
$term = new Zend_Search_Lucene_Index_Term( strtolower( $this->_empty( $escaped ) ) . '*', $name );
$query->addSubquery( new Zend_Search_Lucene_Search_Query_Wildcard( $term ) );
}
return $query;
case '>=':
case '>':
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( $this->_empty( $escaped ), $name );
$inclusive = self::$_operators[$this->getOperator()];
return new Zend_Search_Lucene_Search_Query_Range( $term, null, $inclusive );
case '<=':
case '<':
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( $this->_empty( $escaped ), $name );
$inclusive = self::$_operators[$this->getOperator()];
return new Zend_Search_Lucene_Search_Query_Range( null, $term, $inclusive );
}
} | php | protected function _createTerm( $name, $type, $value )
{
switch( $this->getOperator() )
{
case '==':
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( $this->_empty( $escaped ), $name );
return new Zend_Search_Lucene_Search_Query_Term( $term );
case '!=':
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( $this->_empty( $escaped ), $name );
return new Zend_Search_Lucene_Search_Query_MultiTerm( array( $term ), array( false ) );
case '~=':
if( ( $parts = explode( ' ', $value ) ) === false ) {
throw new MW_Common_Exception( 'Empty term is not allowed for wildcard queries' );
}
$query = new Zend_Search_Lucene_Search_Query_Boolean();
foreach( $parts as $part )
{
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $part );
$term = new Zend_Search_Lucene_Index_Term( strtolower( $this->_empty( $escaped ) ) . '*', $name );
$query->addSubquery( new Zend_Search_Lucene_Search_Query_Wildcard( $term ) );
}
return $query;
case '>=':
case '>':
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( $this->_empty( $escaped ), $name );
$inclusive = self::$_operators[$this->getOperator()];
return new Zend_Search_Lucene_Search_Query_Range( $term, null, $inclusive );
case '<=':
case '<':
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( $this->_empty( $escaped ), $name );
$inclusive = self::$_operators[$this->getOperator()];
return new Zend_Search_Lucene_Search_Query_Range( null, $term, $inclusive );
}
} | [
"protected",
"function",
"_createTerm",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"getOperator",
"(",
")",
")",
"{",
"case",
"'=='",
":",
"$",
"escaped",
"=",
"$",
"this",
"->",
"_escape",
"(... | Creates a Lucene query object from the given parameters.
@param string $name Translated name of variable that should be compared
@param integer $type Type constant
@param mixed $value Value that the variable should be compared to
@return Zend_Search_Lucene_Search_Query Lucene query object | [
"Creates",
"a",
"Lucene",
"query",
"object",
"from",
"the",
"given",
"parameters",
"."
] | 1d2adc81ae0091a70f1053e0f095d55e656a3c96 | https://github.com/Arcavias/ext-zend/blob/1d2adc81ae0091a70f1053e0f095d55e656a3c96/lib/custom/src/MW/Common/Criteria/Expression/Compare/Lucene.php#L59-L112 |
236,252 | Arcavias/ext-zend | lib/custom/src/MW/Common/Criteria/Expression/Compare/Lucene.php | MW_Common_Criteria_Expression_Compare_Lucene._createListTerm | protected function _createListTerm( $name, $type )
{
$sign = null;
switch( $this->getOperator() )
{
case '!=':
$sign = false;
case '==':
$multiterm = new Zend_Search_Lucene_Search_Query_MultiTerm();
foreach( $this->getValue() as $value )
{
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( $this->_empty( $escaped ), $name );
$multiterm->addTerm( $term, $sign );
}
return $multiterm;
case '~=':
$query = new Zend_Search_Lucene_Search_Query_Boolean();
foreach( $this->getValue() as $value )
{
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( strtolower( $this->_empty( $escaped ) ) . '*', $name );
$query->addSubquery( new Zend_Search_Lucene_Search_Query_Wildcard( $term ) );
}
return $query;
}
} | php | protected function _createListTerm( $name, $type )
{
$sign = null;
switch( $this->getOperator() )
{
case '!=':
$sign = false;
case '==':
$multiterm = new Zend_Search_Lucene_Search_Query_MultiTerm();
foreach( $this->getValue() as $value )
{
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( $this->_empty( $escaped ), $name );
$multiterm->addTerm( $term, $sign );
}
return $multiterm;
case '~=':
$query = new Zend_Search_Lucene_Search_Query_Boolean();
foreach( $this->getValue() as $value )
{
$escaped = $this->_escape( $this->getOperator(), SORT_STRING, $value );
$term = new Zend_Search_Lucene_Index_Term( strtolower( $this->_empty( $escaped ) ) . '*', $name );
$query->addSubquery( new Zend_Search_Lucene_Search_Query_Wildcard( $term ) );
}
return $query;
}
} | [
"protected",
"function",
"_createListTerm",
"(",
"$",
"name",
",",
"$",
"type",
")",
"{",
"$",
"sign",
"=",
"null",
";",
"switch",
"(",
"$",
"this",
"->",
"getOperator",
"(",
")",
")",
"{",
"case",
"'!='",
":",
"$",
"sign",
"=",
"false",
";",
"case... | Creates a Lucene query object from a list of values.
@param string $name Translated name of the variable or column
@param integer $type Type constant
@return Zend_Search_Lucene_Search_Query Lucene query object | [
"Creates",
"a",
"Lucene",
"query",
"object",
"from",
"a",
"list",
"of",
"values",
"."
] | 1d2adc81ae0091a70f1053e0f095d55e656a3c96 | https://github.com/Arcavias/ext-zend/blob/1d2adc81ae0091a70f1053e0f095d55e656a3c96/lib/custom/src/MW/Common/Criteria/Expression/Compare/Lucene.php#L134-L169 |
236,253 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategories.getInstance | public static function getInstance($extension, $options = array())
{
$hash = md5($extension . serialize($options));
if (isset(self::$instances[$hash]))
{
return self::$instances[$hash];
}
$parts = explode('.', $extension);
$component = 'com_' . strtolower($parts[0]);
$section = count($parts) > 1 ? $parts[1] : '';
$classname = ucfirst(substr($component, 4)) . ucfirst($section) . 'Categories';
if (!class_exists($classname))
{
$path = JPATH_SITE . '/components/' . $component . '/helpers/category.php';
if (is_file($path))
{
include_once $path;
}
else
{
return false;
}
}
self::$instances[$hash] = new $classname($options);
return self::$instances[$hash];
} | php | public static function getInstance($extension, $options = array())
{
$hash = md5($extension . serialize($options));
if (isset(self::$instances[$hash]))
{
return self::$instances[$hash];
}
$parts = explode('.', $extension);
$component = 'com_' . strtolower($parts[0]);
$section = count($parts) > 1 ? $parts[1] : '';
$classname = ucfirst(substr($component, 4)) . ucfirst($section) . 'Categories';
if (!class_exists($classname))
{
$path = JPATH_SITE . '/components/' . $component . '/helpers/category.php';
if (is_file($path))
{
include_once $path;
}
else
{
return false;
}
}
self::$instances[$hash] = new $classname($options);
return self::$instances[$hash];
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"extension",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"hash",
"=",
"md5",
"(",
"$",
"extension",
".",
"serialize",
"(",
"$",
"options",
")",
")",
";",
"if",
"(",
"isset",
"... | Returns a reference to a JCategories object
@param string $extension Name of the categories extension
@param array $options An array of options
@return JCategories JCategories object
@since 11.1 | [
"Returns",
"a",
"reference",
"to",
"a",
"JCategories",
"object"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L126-L157 |
236,254 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategories.get | public function get($id = 'root', $forceload = false)
{
if ($id !== 'root')
{
$id = (int) $id;
if ($id == 0)
{
$id = 'root';
}
}
// If this $id has not been processed yet, execute the _load method
if ((!isset($this->_nodes[$id]) && !isset($this->_checkedCategories[$id])) || $forceload)
{
$this->_load($id);
}
// If we already have a value in _nodes for this $id, then use it.
if (isset($this->_nodes[$id]))
{
return $this->_nodes[$id];
}
// If we processed this $id already and it was not valid, then return null.
elseif (isset($this->_checkedCategories[$id]))
{
return;
}
return false;
} | php | public function get($id = 'root', $forceload = false)
{
if ($id !== 'root')
{
$id = (int) $id;
if ($id == 0)
{
$id = 'root';
}
}
// If this $id has not been processed yet, execute the _load method
if ((!isset($this->_nodes[$id]) && !isset($this->_checkedCategories[$id])) || $forceload)
{
$this->_load($id);
}
// If we already have a value in _nodes for this $id, then use it.
if (isset($this->_nodes[$id]))
{
return $this->_nodes[$id];
}
// If we processed this $id already and it was not valid, then return null.
elseif (isset($this->_checkedCategories[$id]))
{
return;
}
return false;
} | [
"public",
"function",
"get",
"(",
"$",
"id",
"=",
"'root'",
",",
"$",
"forceload",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"id",
"!==",
"'root'",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"if",
"(",
"$",
"id",
"==",
"0",
")... | Loads a specific category and all its children in a JCategoryNode object
@param mixed $id an optional id integer or equal to 'root'
@param boolean $forceload True to force the _load method to execute
@return mixed JCategoryNode object or null if $id is not valid
@since 11.1 | [
"Loads",
"a",
"specific",
"category",
"and",
"all",
"its",
"children",
"in",
"a",
"JCategoryNode",
"object"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L169-L199 |
236,255 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategoryNode.setParent | public function setParent($parent)
{
if ($parent instanceof JCategoryNode || is_null($parent))
{
if (!is_null($this->_parent))
{
$key = array_search($this, $this->_parent->_children);
unset($this->_parent->_children[$key]);
}
if (!is_null($parent))
{
$parent->_children[] = & $this;
}
$this->_parent = $parent;
if ($this->id != 'root')
{
if ($this->parent_id != 1)
{
$this->_path = $parent->getPath();
}
$this->_path[] = $this->id . ':' . $this->alias;
}
if (count($parent->_children) > 1)
{
end($parent->_children);
$this->_leftSibling = prev($parent->_children);
$this->_leftSibling->_rightsibling = & $this;
}
}
} | php | public function setParent($parent)
{
if ($parent instanceof JCategoryNode || is_null($parent))
{
if (!is_null($this->_parent))
{
$key = array_search($this, $this->_parent->_children);
unset($this->_parent->_children[$key]);
}
if (!is_null($parent))
{
$parent->_children[] = & $this;
}
$this->_parent = $parent;
if ($this->id != 'root')
{
if ($this->parent_id != 1)
{
$this->_path = $parent->getPath();
}
$this->_path[] = $this->id . ':' . $this->alias;
}
if (count($parent->_children) > 1)
{
end($parent->_children);
$this->_leftSibling = prev($parent->_children);
$this->_leftSibling->_rightsibling = & $this;
}
}
} | [
"public",
"function",
"setParent",
"(",
"$",
"parent",
")",
"{",
"if",
"(",
"$",
"parent",
"instanceof",
"JCategoryNode",
"||",
"is_null",
"(",
"$",
"parent",
")",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"_parent",
")",
")",
"{",... | Set the parent of this category
If the category already has a parent, the link is unset
@param mixed $parent JCategoryNode for the parent to be set or null
@return void
@since 11.1 | [
"Set",
"the",
"parent",
"of",
"this",
"category"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L711-L745 |
236,256 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategoryNode.removeChild | public function removeChild($id)
{
$key = array_search($this, $this->_parent->_children);
unset($this->_parent->_children[$key]);
} | php | public function removeChild($id)
{
$key = array_search($this, $this->_parent->_children);
unset($this->_parent->_children[$key]);
} | [
"public",
"function",
"removeChild",
"(",
"$",
"id",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"_parent",
"->",
"_children",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_parent",
"->",
"_children",
"[",
"$",... | Remove a specific child
@param integer $id ID of a category
@return void
@since 11.1 | [
"Remove",
"a",
"specific",
"child"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L775-L779 |
236,257 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategoryNode.& | public function &getChildren($recursive = false)
{
if (!$this->_allChildrenloaded)
{
$temp = $this->_constructor->get($this->id, true);
if ($temp)
{
$this->_children = $temp->getChildren();
$this->_leftSibling = $temp->getSibling(false);
$this->_rightSibling = $temp->getSibling(true);
$this->setAllLoaded();
}
}
if ($recursive)
{
$items = array();
foreach ($this->_children as $child)
{
$items[] = $child;
$items = array_merge($items, $child->getChildren(true));
}
return $items;
}
return $this->_children;
} | php | public function &getChildren($recursive = false)
{
if (!$this->_allChildrenloaded)
{
$temp = $this->_constructor->get($this->id, true);
if ($temp)
{
$this->_children = $temp->getChildren();
$this->_leftSibling = $temp->getSibling(false);
$this->_rightSibling = $temp->getSibling(true);
$this->setAllLoaded();
}
}
if ($recursive)
{
$items = array();
foreach ($this->_children as $child)
{
$items[] = $child;
$items = array_merge($items, $child->getChildren(true));
}
return $items;
}
return $this->_children;
} | [
"public",
"function",
"&",
"getChildren",
"(",
"$",
"recursive",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_allChildrenloaded",
")",
"{",
"$",
"temp",
"=",
"$",
"this",
"->",
"_constructor",
"->",
"get",
"(",
"$",
"this",
"->",
"id"... | Get the children of this node
@param boolean $recursive False by default
@return array The children
@since 11.1 | [
"Get",
"the",
"children",
"of",
"this",
"node"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L790-L819 |
236,258 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategoryNode.setSibling | public function setSibling($sibling, $right = true)
{
if ($right)
{
$this->_rightSibling = $sibling;
}
else
{
$this->_leftSibling = $sibling;
}
} | php | public function setSibling($sibling, $right = true)
{
if ($right)
{
$this->_rightSibling = $sibling;
}
else
{
$this->_leftSibling = $sibling;
}
} | [
"public",
"function",
"setSibling",
"(",
"$",
"sibling",
",",
"$",
"right",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"right",
")",
"{",
"$",
"this",
"->",
"_rightSibling",
"=",
"$",
"sibling",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_leftSibling",
... | Function to set the left or right sibling of a category
@param JCategoryNode $sibling JCategoryNode object for the sibling
@param boolean $right If set to false, the sibling is the left one
@return void
@since 11.1 | [
"Function",
"to",
"set",
"the",
"left",
"or",
"right",
"sibling",
"of",
"a",
"category"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L867-L877 |
236,259 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategoryNode.getSibling | public function getSibling($right = true)
{
if (!$this->_allChildrenloaded)
{
$temp = $this->_constructor->get($this->id, true);
$this->_children = $temp->getChildren();
$this->_leftSibling = $temp->getSibling(false);
$this->_rightSibling = $temp->getSibling(true);
$this->setAllLoaded();
}
if ($right)
{
return $this->_rightSibling;
}
else
{
return $this->_leftSibling;
}
} | php | public function getSibling($right = true)
{
if (!$this->_allChildrenloaded)
{
$temp = $this->_constructor->get($this->id, true);
$this->_children = $temp->getChildren();
$this->_leftSibling = $temp->getSibling(false);
$this->_rightSibling = $temp->getSibling(true);
$this->setAllLoaded();
}
if ($right)
{
return $this->_rightSibling;
}
else
{
return $this->_leftSibling;
}
} | [
"public",
"function",
"getSibling",
"(",
"$",
"right",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_allChildrenloaded",
")",
"{",
"$",
"temp",
"=",
"$",
"this",
"->",
"_constructor",
"->",
"get",
"(",
"$",
"this",
"->",
"id",
",",
"t... | Returns the right or left sibling of a category
@param boolean $right If set to false, returns the left sibling
@return mixed JCategoryNode object with the sibling information or
NULL if there is no sibling on that side.
@since 11.1 | [
"Returns",
"the",
"right",
"or",
"left",
"sibling",
"of",
"a",
"category"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L889-L908 |
236,260 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategoryNode.getParams | public function getParams()
{
if (!($this->params instanceof Registry))
{
$temp = new Registry;
$temp->loadString($this->params);
$this->params = $temp;
}
return $this->params;
} | php | public function getParams()
{
if (!($this->params instanceof Registry))
{
$temp = new Registry;
$temp->loadString($this->params);
$this->params = $temp;
}
return $this->params;
} | [
"public",
"function",
"getParams",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"params",
"instanceof",
"Registry",
")",
")",
"{",
"$",
"temp",
"=",
"new",
"Registry",
";",
"$",
"temp",
"->",
"loadString",
"(",
"$",
"this",
"->",
"params",
... | Returns the category parameters
@return Registry
@since 11.1 | [
"Returns",
"the",
"category",
"parameters"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L917-L927 |
236,261 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategoryNode.getMetadata | public function getMetadata()
{
if (!($this->metadata instanceof Registry))
{
$temp = new Registry;
$temp->loadString($this->metadata);
$this->metadata = $temp;
}
return $this->metadata;
} | php | public function getMetadata()
{
if (!($this->metadata instanceof Registry))
{
$temp = new Registry;
$temp->loadString($this->metadata);
$this->metadata = $temp;
}
return $this->metadata;
} | [
"public",
"function",
"getMetadata",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"metadata",
"instanceof",
"Registry",
")",
")",
"{",
"$",
"temp",
"=",
"new",
"Registry",
";",
"$",
"temp",
"->",
"loadString",
"(",
"$",
"this",
"->",
"metad... | Returns the category metadata
@return Registry A Registry object containing the metadata
@since 11.1 | [
"Returns",
"the",
"category",
"metadata"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L936-L946 |
236,262 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategoryNode.getAuthor | public function getAuthor($modified_user = false)
{
if ($modified_user)
{
return JFactory::getUser($this->modified_user_id);
}
return JFactory::getUser($this->created_user_id);
} | php | public function getAuthor($modified_user = false)
{
if ($modified_user)
{
return JFactory::getUser($this->modified_user_id);
}
return JFactory::getUser($this->created_user_id);
} | [
"public",
"function",
"getAuthor",
"(",
"$",
"modified_user",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"modified_user",
")",
"{",
"return",
"JFactory",
"::",
"getUser",
"(",
"$",
"this",
"->",
"modified_user_id",
")",
";",
"}",
"return",
"JFactory",
"::",
... | Returns the user that created the category
@param boolean $modified_user Returns the modified_user when set to true
@return JUser A JUser object containing a userid
@since 11.1 | [
"Returns",
"the",
"user",
"that",
"created",
"the",
"category"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L969-L977 |
236,263 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategoryNode.setAllLoaded | public function setAllLoaded()
{
$this->_allChildrenloaded = true;
foreach ($this->_children as $child)
{
$child->setAllLoaded();
}
} | php | public function setAllLoaded()
{
$this->_allChildrenloaded = true;
foreach ($this->_children as $child)
{
$child->setAllLoaded();
}
} | [
"public",
"function",
"setAllLoaded",
"(",
")",
"{",
"$",
"this",
"->",
"_allChildrenloaded",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"_children",
"as",
"$",
"child",
")",
"{",
"$",
"child",
"->",
"setAllLoaded",
"(",
")",
";",
"}",
"}"
] | Set to load all children
@return void
@since 11.1 | [
"Set",
"to",
"load",
"all",
"children"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L986-L994 |
236,264 | joomlatools/joomlatools-platform-categories | administrator/components/com_categories/libraries/categories.php | JCategoryNode.getNumItems | public function getNumItems($recursive = false)
{
if ($recursive)
{
$count = $this->numitems;
foreach ($this->getChildren() as $child)
{
$count = $count + $child->getNumItems(true);
}
return $count;
}
return $this->numitems;
} | php | public function getNumItems($recursive = false)
{
if ($recursive)
{
$count = $this->numitems;
foreach ($this->getChildren() as $child)
{
$count = $count + $child->getNumItems(true);
}
return $count;
}
return $this->numitems;
} | [
"public",
"function",
"getNumItems",
"(",
"$",
"recursive",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"recursive",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"numitems",
";",
"foreach",
"(",
"$",
"this",
"->",
"getChildren",
"(",
")",
"as",
"$",
... | Returns the number of items.
@param boolean $recursive If false number of children, if true number of descendants
@return integer Number of children or descendants
@since 11.1 | [
"Returns",
"the",
"number",
"of",
"items",
"."
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/administrator/components/com_categories/libraries/categories.php#L1005-L1020 |
236,265 | gplcart/installer | models/Install.php | Install.fromZip | public function fromZip($zip)
{
$this->data = null;
$this->error = null;
$this->renamed = false;
$this->tempname = null;
$this->module_id = null;
$this->destination = null;
if (!$this->setModuleId($zip)) {
return $this->error;
}
if (!$this->extract()) {
$this->rollback();
return $this->error;
}
if (!$this->validate()) {
$this->rollback();
return $this->error;
}
if (!$this->backup()) {
return $this->error;
}
return true;
} | php | public function fromZip($zip)
{
$this->data = null;
$this->error = null;
$this->renamed = false;
$this->tempname = null;
$this->module_id = null;
$this->destination = null;
if (!$this->setModuleId($zip)) {
return $this->error;
}
if (!$this->extract()) {
$this->rollback();
return $this->error;
}
if (!$this->validate()) {
$this->rollback();
return $this->error;
}
if (!$this->backup()) {
return $this->error;
}
return true;
} | [
"public",
"function",
"fromZip",
"(",
"$",
"zip",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"null",
";",
"$",
"this",
"->",
"error",
"=",
"null",
";",
"$",
"this",
"->",
"renamed",
"=",
"false",
";",
"$",
"this",
"->",
"tempname",
"=",
"null",
";... | Installs a module from a ZIP file
@param string $zip
@return string|bool | [
"Installs",
"a",
"module",
"from",
"a",
"ZIP",
"file"
] | a0cc7525268c176c910953f422365e86e5e0dac7 | https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/models/Install.php#L140-L168 |
236,266 | gplcart/installer | models/Install.php | Install.fromUrl | public function fromUrl(array $sources)
{
$total = count($sources);
$finish_message = $this->translation->text('New modules: %inserted, updated: %updated');
$vars = array('@url' => $this->url->get('', array('download_errors' => true)));
$errors_message = $this->translation->text('New modules: %inserted, updated: %updated, errors: %errors. <a href="@url">See error log</a>', $vars);
$data = array(
'total' => $total,
'data' => array('sources' => $sources),
'id' => 'installer_download_module',
'log' => array('errors' => $this->getErrorLogFile()),
'redirect_message' => array('finish' => $finish_message, 'errors' => $errors_message)
);
$this->job->submit($data);
} | php | public function fromUrl(array $sources)
{
$total = count($sources);
$finish_message = $this->translation->text('New modules: %inserted, updated: %updated');
$vars = array('@url' => $this->url->get('', array('download_errors' => true)));
$errors_message = $this->translation->text('New modules: %inserted, updated: %updated, errors: %errors. <a href="@url">See error log</a>', $vars);
$data = array(
'total' => $total,
'data' => array('sources' => $sources),
'id' => 'installer_download_module',
'log' => array('errors' => $this->getErrorLogFile()),
'redirect_message' => array('finish' => $finish_message, 'errors' => $errors_message)
);
$this->job->submit($data);
} | [
"public",
"function",
"fromUrl",
"(",
"array",
"$",
"sources",
")",
"{",
"$",
"total",
"=",
"count",
"(",
"$",
"sources",
")",
";",
"$",
"finish_message",
"=",
"$",
"this",
"->",
"translation",
"->",
"text",
"(",
"'New modules: %inserted, updated: %updated'",
... | Install modules from multiple URLs
@param array $sources | [
"Install",
"modules",
"from",
"multiple",
"URLs"
] | a0cc7525268c176c910953f422365e86e5e0dac7 | https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/models/Install.php#L174-L190 |
236,267 | gplcart/installer | models/Install.php | Install.backup | protected function backup()
{
if (empty($this->tempname)) {
return true;
}
$module = $this->data;
$module += array(
'directory' => $this->tempname,
'module_id' => $this->module_id
);
$result = $this->getBackupModule()->backup('module', $module);
if ($result === true) {
gplcart_file_delete_recursive($this->tempname);
return true;
}
$this->error = $this->translation->text('Failed to backup module @id', array('@id' => $this->module_id));
return false;
} | php | protected function backup()
{
if (empty($this->tempname)) {
return true;
}
$module = $this->data;
$module += array(
'directory' => $this->tempname,
'module_id' => $this->module_id
);
$result = $this->getBackupModule()->backup('module', $module);
if ($result === true) {
gplcart_file_delete_recursive($this->tempname);
return true;
}
$this->error = $this->translation->text('Failed to backup module @id', array('@id' => $this->module_id));
return false;
} | [
"protected",
"function",
"backup",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"tempname",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"module",
"=",
"$",
"this",
"->",
"data",
";",
"$",
"module",
"+=",
"array",
"(",
"'directory'... | Backup the previous version of the updated module | [
"Backup",
"the",
"previous",
"version",
"of",
"the",
"updated",
"module"
] | a0cc7525268c176c910953f422365e86e5e0dac7 | https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/models/Install.php#L204-L226 |
236,268 | gplcart/installer | models/Install.php | Install.extract | protected function extract()
{
$this->destination = GC_DIR_MODULE . "/{$this->module_id}";
if (file_exists($this->destination)) {
$this->tempname = gplcart_file_unique($this->destination . '~');
if (!rename($this->destination, $this->tempname)) {
$this->error = $this->translation->text('Failed to rename @old to @new', array(
'@old' => $this->destination, '@new' => $this->tempname));
return false;
}
$this->renamed = true;
}
if ($this->zip->extract(GC_DIR_MODULE)) {
return true;
}
$this->error = $this->translation->text('Failed to extract to @name', array('@name' => $this->destination));
return false;
} | php | protected function extract()
{
$this->destination = GC_DIR_MODULE . "/{$this->module_id}";
if (file_exists($this->destination)) {
$this->tempname = gplcart_file_unique($this->destination . '~');
if (!rename($this->destination, $this->tempname)) {
$this->error = $this->translation->text('Failed to rename @old to @new', array(
'@old' => $this->destination, '@new' => $this->tempname));
return false;
}
$this->renamed = true;
}
if ($this->zip->extract(GC_DIR_MODULE)) {
return true;
}
$this->error = $this->translation->text('Failed to extract to @name', array('@name' => $this->destination));
return false;
} | [
"protected",
"function",
"extract",
"(",
")",
"{",
"$",
"this",
"->",
"destination",
"=",
"GC_DIR_MODULE",
".",
"\"/{$this->module_id}\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"destination",
")",
")",
"{",
"$",
"this",
"->",
"tempname",
"... | Extracts module files to the system directory
@return boolean | [
"Extracts",
"module",
"files",
"to",
"the",
"system",
"directory"
] | a0cc7525268c176c910953f422365e86e5e0dac7 | https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/models/Install.php#L243-L266 |
236,269 | gplcart/installer | models/Install.php | Install.rollback | protected function rollback()
{
if (!$this->isUpdate() || ($this->isUpdate() && $this->renamed)) {
gplcart_file_delete_recursive($this->destination);
}
if (isset($this->tempname)) {
rename($this->tempname, $this->destination);
}
} | php | protected function rollback()
{
if (!$this->isUpdate() || ($this->isUpdate() && $this->renamed)) {
gplcart_file_delete_recursive($this->destination);
}
if (isset($this->tempname)) {
rename($this->tempname, $this->destination);
}
} | [
"protected",
"function",
"rollback",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isUpdate",
"(",
")",
"||",
"(",
"$",
"this",
"->",
"isUpdate",
"(",
")",
"&&",
"$",
"this",
"->",
"renamed",
")",
")",
"{",
"gplcart_file_delete_recursive",
"(",
... | Restore the original module files | [
"Restore",
"the",
"original",
"module",
"files"
] | a0cc7525268c176c910953f422365e86e5e0dac7 | https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/models/Install.php#L271-L280 |
236,270 | gplcart/installer | models/Install.php | Install.validate | protected function validate()
{
$this->data = $this->module->getInfo($this->module_id);
if (empty($this->data)) {
$this->error = $this->translation->text('Failed to read module @id', array('@id' => $this->module_id));
return false;
}
try {
$this->module_model->checkCore($this->data);
$this->module_model->checkPhpVersion($this->data);
return true;
} catch (Exception $ex) {
$this->error = $ex->getMessage();
return false;
}
} | php | protected function validate()
{
$this->data = $this->module->getInfo($this->module_id);
if (empty($this->data)) {
$this->error = $this->translation->text('Failed to read module @id', array('@id' => $this->module_id));
return false;
}
try {
$this->module_model->checkCore($this->data);
$this->module_model->checkPhpVersion($this->data);
return true;
} catch (Exception $ex) {
$this->error = $ex->getMessage();
return false;
}
} | [
"protected",
"function",
"validate",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"module",
"->",
"getInfo",
"(",
"$",
"this",
"->",
"module_id",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"$... | Validates a module data
@return boolean | [
"Validates",
"a",
"module",
"data"
] | a0cc7525268c176c910953f422365e86e5e0dac7 | https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/models/Install.php#L286-L303 |
236,271 | gplcart/installer | models/Install.php | Install.getFilesFromZip | public function getFilesFromZip($file)
{
try {
$files = $this->zip->set($file)->getList();
} catch (Exception $e) {
return array();
}
return count($files) < 2 ? array() : $files;
} | php | public function getFilesFromZip($file)
{
try {
$files = $this->zip->set($file)->getList();
} catch (Exception $e) {
return array();
}
return count($files) < 2 ? array() : $files;
} | [
"public",
"function",
"getFilesFromZip",
"(",
"$",
"file",
")",
"{",
"try",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"zip",
"->",
"set",
"(",
"$",
"file",
")",
"->",
"getList",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
... | Returns an array of files from a ZIP file
@param string $file
@return array | [
"Returns",
"an",
"array",
"of",
"files",
"from",
"a",
"ZIP",
"file"
] | a0cc7525268c176c910953f422365e86e5e0dac7 | https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/models/Install.php#L310-L319 |
236,272 | gplcart/installer | models/Install.php | Install.setModuleId | protected function setModuleId($file)
{
$module_id = $this->getModuleIdFromZip($file);
try {
$this->module_model->checkModuleId($module_id);
} catch (Exception $ex) {
$this->error = $ex->getMessage();
return false;
}
// Do not deal with enabled modules as it may cause fatal results
// Check if the module ID actually has enabled status in the database
// Alternative system methods are based on the scanned module folders so may return incorrect results
if ($this->isEnabledModule($module_id)) {
$this->error = $this->translation->text('Module @id is enabled and cannot be updated', array('@id' => $module_id));
return false;
}
$this->module_id = $module_id;
return true;
} | php | protected function setModuleId($file)
{
$module_id = $this->getModuleIdFromZip($file);
try {
$this->module_model->checkModuleId($module_id);
} catch (Exception $ex) {
$this->error = $ex->getMessage();
return false;
}
// Do not deal with enabled modules as it may cause fatal results
// Check if the module ID actually has enabled status in the database
// Alternative system methods are based on the scanned module folders so may return incorrect results
if ($this->isEnabledModule($module_id)) {
$this->error = $this->translation->text('Module @id is enabled and cannot be updated', array('@id' => $module_id));
return false;
}
$this->module_id = $module_id;
return true;
} | [
"protected",
"function",
"setModuleId",
"(",
"$",
"file",
")",
"{",
"$",
"module_id",
"=",
"$",
"this",
"->",
"getModuleIdFromZip",
"(",
"$",
"file",
")",
";",
"try",
"{",
"$",
"this",
"->",
"module_model",
"->",
"checkModuleId",
"(",
"$",
"module_id",
"... | Set a module id
@param string $file
@return boolean | [
"Set",
"a",
"module",
"id"
] | a0cc7525268c176c910953f422365e86e5e0dac7 | https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/models/Install.php#L326-L347 |
236,273 | gplcart/installer | models/Install.php | Install.isEnabledModule | protected function isEnabledModule($module_id)
{
$sql = 'SELECT module_id FROM module WHERE module_id=? AND status > 0';
$result = $this->db->fetchColumn($sql, array($module_id));
return !empty($result);
} | php | protected function isEnabledModule($module_id)
{
$sql = 'SELECT module_id FROM module WHERE module_id=? AND status > 0';
$result = $this->db->fetchColumn($sql, array($module_id));
return !empty($result);
} | [
"protected",
"function",
"isEnabledModule",
"(",
"$",
"module_id",
")",
"{",
"$",
"sql",
"=",
"'SELECT module_id FROM module WHERE module_id=? AND status > 0'",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"db",
"->",
"fetchColumn",
"(",
"$",
"sql",
",",
"array",
... | Check if a module ID has enabled status in the database
@param string $module_id
@return bool | [
"Check",
"if",
"a",
"module",
"ID",
"has",
"enabled",
"status",
"in",
"the",
"database"
] | a0cc7525268c176c910953f422365e86e5e0dac7 | https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/models/Install.php#L354-L359 |
236,274 | gplcart/installer | models/Install.php | Install.getModuleIdFromZip | public function getModuleIdFromZip($file)
{
$list = $this->getFilesFromZip($file);
if (empty($list)) {
return false;
}
$folder = reset($list);
if (strrchr($folder, '/') !== '/') {
return false;
}
$nested = 0;
foreach ($list as $item) {
if (strpos($item, $folder) === 0) {
$nested++;
}
}
if (count($list) != $nested) {
return false;
}
return rtrim($folder, '/');
} | php | public function getModuleIdFromZip($file)
{
$list = $this->getFilesFromZip($file);
if (empty($list)) {
return false;
}
$folder = reset($list);
if (strrchr($folder, '/') !== '/') {
return false;
}
$nested = 0;
foreach ($list as $item) {
if (strpos($item, $folder) === 0) {
$nested++;
}
}
if (count($list) != $nested) {
return false;
}
return rtrim($folder, '/');
} | [
"public",
"function",
"getModuleIdFromZip",
"(",
"$",
"file",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"getFilesFromZip",
"(",
"$",
"file",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"list",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"fold... | Returns a module id from a zip file or false on error
@param string $file
@return boolean|string | [
"Returns",
"a",
"module",
"id",
"from",
"a",
"zip",
"file",
"or",
"false",
"on",
"error"
] | a0cc7525268c176c910953f422365e86e5e0dac7 | https://github.com/gplcart/installer/blob/a0cc7525268c176c910953f422365e86e5e0dac7/models/Install.php#L366-L392 |
236,275 | olajoscs/QueryBuilder | src/SQLite/Connection.php | Connection.checkResultCount | private function checkResultCount(array $result, $query)
{
if (count($result) === 0) {
throw new RowNotFoundException('Row not found for query: ' . $query);
}
if (count($result) > 1) {
throw new MultipleRowFoundException('Multiple row found for query: ' . $query);
}
} | php | private function checkResultCount(array $result, $query)
{
if (count($result) === 0) {
throw new RowNotFoundException('Row not found for query: ' . $query);
}
if (count($result) > 1) {
throw new MultipleRowFoundException('Multiple row found for query: ' . $query);
}
} | [
"private",
"function",
"checkResultCount",
"(",
"array",
"$",
"result",
",",
"$",
"query",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"result",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"RowNotFoundException",
"(",
"'Row not found for query: '",
".",
"$",
"q... | Checks the result against the proper row number
@param array $result
@param string $query
@return void
@throws MultipleRowFoundException
@throws RowNotFoundException | [
"Checks",
"the",
"result",
"against",
"the",
"proper",
"row",
"number"
] | 5e1568ced2c2c7f0294cf32f30a290db1e642035 | https://github.com/olajoscs/QueryBuilder/blob/5e1568ced2c2c7f0294cf32f30a290db1e642035/src/SQLite/Connection.php#L112-L121 |
236,276 | silinternational/ssp-utilities | src/AnnouncementUtils.php | AnnouncementUtils.getSimpleAnnouncement | public static function getSimpleAnnouncement(
$announcementPathFile=Null
) {
// If you modify this default path, make sure you use the right kind of slash
if ( ! $announcementPathFile) {
$announcementPathFile = '/data/ssp-announcement.php';
}
if ( ! file_exists($announcementPathFile)) {
return Null;
}
// Note: This will not actually catch errors in the included file
try {
$announcement = include $announcementPathFile;
} catch (Exception $e) {
return Null;
}
if ( ! is_string($announcement)) {
return Null;
}
return $announcement;
} | php | public static function getSimpleAnnouncement(
$announcementPathFile=Null
) {
// If you modify this default path, make sure you use the right kind of slash
if ( ! $announcementPathFile) {
$announcementPathFile = '/data/ssp-announcement.php';
}
if ( ! file_exists($announcementPathFile)) {
return Null;
}
// Note: This will not actually catch errors in the included file
try {
$announcement = include $announcementPathFile;
} catch (Exception $e) {
return Null;
}
if ( ! is_string($announcement)) {
return Null;
}
return $announcement;
} | [
"public",
"static",
"function",
"getSimpleAnnouncement",
"(",
"$",
"announcementPathFile",
"=",
"Null",
")",
"{",
"// If you modify this default path, make sure you use the right kind of slash",
"if",
"(",
"!",
"$",
"announcementPathFile",
")",
"{",
"$",
"announcementPathFile... | Includes a php file and if it is only a string, returns that string. Otherwise, returns Null.
@param string $announcementPathFile - optional for unit tests
If missing, then the announcement file will be expected to be /data/ssp-announcement.php
@return string|null | [
"Includes",
"a",
"php",
"file",
"and",
"if",
"it",
"is",
"only",
"a",
"string",
"returns",
"that",
"string",
".",
"Otherwise",
"returns",
"Null",
"."
] | e8c05bd8e4688aea2960bca74b7d6aa5f9f34286 | https://github.com/silinternational/ssp-utilities/blob/e8c05bd8e4688aea2960bca74b7d6aa5f9f34286/src/AnnouncementUtils.php#L91-L117 |
236,277 | phlexible/phlexible | src/Phlexible/Bundle/GuiBundle/Config/ConfigBuilder.php | ConfigBuilder.build | public function build()
{
$config = new Config();
$event = new GetConfigEvent($config);
$this->eventDispatcher->dispatch(GuiEvents::GET_CONFIG, $event);
return $config;
} | php | public function build()
{
$config = new Config();
$event = new GetConfigEvent($config);
$this->eventDispatcher->dispatch(GuiEvents::GET_CONFIG, $event);
return $config;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"config",
"=",
"new",
"Config",
"(",
")",
";",
"$",
"event",
"=",
"new",
"GetConfigEvent",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"GuiEvents",
"::",
... | Gather configs and return config array.
@return array | [
"Gather",
"configs",
"and",
"return",
"config",
"array",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Config/ConfigBuilder.php#L43-L51 |
236,278 | prastowoagungwidodo/utility | src/Transformatika/Utility/DateTime.php | DateTime.monthInRoman | public function monthInRoman($number)
{
$number = intval($number);
$romanNumbers = array(
1 => 'I',
2 => 'II',
3 => 'III',
4 => 'IV',
5 => 'V',
6 => 'VI',
7 => 'VII',
8 => 'VIII',
9 => 'IX',
10 => 'X',
11 => 'XI',
12 => 'XII');
if ($number >= 0 && $number <= 12) {
return $romanNumbers[$number];
} else {
return $number;
}
} | php | public function monthInRoman($number)
{
$number = intval($number);
$romanNumbers = array(
1 => 'I',
2 => 'II',
3 => 'III',
4 => 'IV',
5 => 'V',
6 => 'VI',
7 => 'VII',
8 => 'VIII',
9 => 'IX',
10 => 'X',
11 => 'XI',
12 => 'XII');
if ($number >= 0 && $number <= 12) {
return $romanNumbers[$number];
} else {
return $number;
}
} | [
"public",
"function",
"monthInRoman",
"(",
"$",
"number",
")",
"{",
"$",
"number",
"=",
"intval",
"(",
"$",
"number",
")",
";",
"$",
"romanNumbers",
"=",
"array",
"(",
"1",
"=>",
"'I'",
",",
"2",
"=>",
"'II'",
",",
"3",
"=>",
"'III'",
",",
"4",
"... | Convert month into romans
@param integer $number month in integer
@return string | [
"Convert",
"month",
"into",
"romans"
] | bbacc1a8ec15befae83c6a29b60e568fd02d66b7 | https://github.com/prastowoagungwidodo/utility/blob/bbacc1a8ec15befae83c6a29b60e568fd02d66b7/src/Transformatika/Utility/DateTime.php#L12-L33 |
236,279 | prastowoagungwidodo/utility | src/Transformatika/Utility/DateTime.php | DateTime.humanTimeDiff | public function humanTimeDiff($time, $chunk = false)
{
if (!is_integer($time)) {
$time = strtotime($time);
}
if ($chunk) {
$different = time() - $time;
$seconds = $different;
$minutes = round($different / 60);
$hours = round($different / 3600);
$days = round($different / 86400);
$weeks = round($different / 604800);
$months = round($different / 2419200);
$years = round($different / 29030400);
if ($seconds <= 60) {
if ($seconds == 1) {
return "$seconds second ago";
} else {
return "$seconds seconds ago";
}
} elseif ($minutes <= 60) {
if ($minutes == 1) {
return "$minutes minute ago";
} else {
return "$minutes minutes ago";
}
} elseif ($hours <= 24) {
if ($hours == 1) {
return "$hours hour ago";
} else {
return "$hours hours ago";
}
} elseif ($days <= 7) {
if ($days = 1) {
return "$days day ago";
} else {
return "$days days ago";
}
} elseif ($weeks <= 4) {
if ($weeks == 1) {
return "$weeks week ago";
} else {
return "$weeks weeks ago";
}
} elseif ($months <= 12) {
if ($months == 1) {
return "$months month ago";
} else {
return "$months months ago";
}
} else {
if ($years == 1) {
return "$years year ago";
} else {
return "$years years ago";
}
}
} else {
$dtF = new \DateTime('@0');
$dtT = new \DateTime("@$time");
return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds');
}
} | php | public function humanTimeDiff($time, $chunk = false)
{
if (!is_integer($time)) {
$time = strtotime($time);
}
if ($chunk) {
$different = time() - $time;
$seconds = $different;
$minutes = round($different / 60);
$hours = round($different / 3600);
$days = round($different / 86400);
$weeks = round($different / 604800);
$months = round($different / 2419200);
$years = round($different / 29030400);
if ($seconds <= 60) {
if ($seconds == 1) {
return "$seconds second ago";
} else {
return "$seconds seconds ago";
}
} elseif ($minutes <= 60) {
if ($minutes == 1) {
return "$minutes minute ago";
} else {
return "$minutes minutes ago";
}
} elseif ($hours <= 24) {
if ($hours == 1) {
return "$hours hour ago";
} else {
return "$hours hours ago";
}
} elseif ($days <= 7) {
if ($days = 1) {
return "$days day ago";
} else {
return "$days days ago";
}
} elseif ($weeks <= 4) {
if ($weeks == 1) {
return "$weeks week ago";
} else {
return "$weeks weeks ago";
}
} elseif ($months <= 12) {
if ($months == 1) {
return "$months month ago";
} else {
return "$months months ago";
}
} else {
if ($years == 1) {
return "$years year ago";
} else {
return "$years years ago";
}
}
} else {
$dtF = new \DateTime('@0');
$dtT = new \DateTime("@$time");
return $dtF->diff($dtT)->format('%a days, %h hours, %i minutes and %s seconds');
}
} | [
"public",
"function",
"humanTimeDiff",
"(",
"$",
"time",
",",
"$",
"chunk",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"time",
")",
")",
"{",
"$",
"time",
"=",
"strtotime",
"(",
"$",
"time",
")",
";",
"}",
"if",
"(",
"$",
"... | Human time different
@param Timestamp / Date
@return String | [
"Human",
"time",
"different"
] | bbacc1a8ec15befae83c6a29b60e568fd02d66b7 | https://github.com/prastowoagungwidodo/utility/blob/bbacc1a8ec15befae83c6a29b60e568fd02d66b7/src/Transformatika/Utility/DateTime.php#L41-L105 |
236,280 | prastowoagungwidodo/utility | src/Transformatika/Utility/DateTime.php | DateTime.dateArray | public function dateArray($begin, $end, $format = 'Y-m-d')
{
$begin = new \DateTime($begin);
$end = new \DateTime($end);
$end = $end->modify('+1 day');
$interval = new \DateInterval('P1D');
$daterange = new \DatePeriod($begin, $interval, $end);
$dateArray = array();
foreach ($daterange as $date) {
$dateArray[] = $date->format($format);
}
return $dateArray;
} | php | public function dateArray($begin, $end, $format = 'Y-m-d')
{
$begin = new \DateTime($begin);
$end = new \DateTime($end);
$end = $end->modify('+1 day');
$interval = new \DateInterval('P1D');
$daterange = new \DatePeriod($begin, $interval, $end);
$dateArray = array();
foreach ($daterange as $date) {
$dateArray[] = $date->format($format);
}
return $dateArray;
} | [
"public",
"function",
"dateArray",
"(",
"$",
"begin",
",",
"$",
"end",
",",
"$",
"format",
"=",
"'Y-m-d'",
")",
"{",
"$",
"begin",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"begin",
")",
";",
"$",
"end",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"end... | Generate date array
@param Date $begin Date start
@param Date $end Date end
@return array array date | [
"Generate",
"date",
"array"
] | bbacc1a8ec15befae83c6a29b60e568fd02d66b7 | https://github.com/prastowoagungwidodo/utility/blob/bbacc1a8ec15befae83c6a29b60e568fd02d66b7/src/Transformatika/Utility/DateTime.php#L113-L128 |
236,281 | prastowoagungwidodo/utility | src/Transformatika/Utility/DateTime.php | DateTime.monthArray | public function monthArray($begin, $end, $year = '')
{
if (empty($year)) {
$year = date('Y');
}
$dateArray = array();
for ($i = $begin; $i <= $end; ++$i) {
$dateArray[] = $i;
}
return $dateArray;
} | php | public function monthArray($begin, $end, $year = '')
{
if (empty($year)) {
$year = date('Y');
}
$dateArray = array();
for ($i = $begin; $i <= $end; ++$i) {
$dateArray[] = $i;
}
return $dateArray;
} | [
"public",
"function",
"monthArray",
"(",
"$",
"begin",
",",
"$",
"end",
",",
"$",
"year",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"year",
")",
")",
"{",
"$",
"year",
"=",
"date",
"(",
"'Y'",
")",
";",
"}",
"$",
"dateArray",
"=",
"a... | Generate month number array
@param Integer $begin month start
@param Integer $end month end
@param string $year Year
@return array | [
"Generate",
"month",
"number",
"array"
] | bbacc1a8ec15befae83c6a29b60e568fd02d66b7 | https://github.com/prastowoagungwidodo/utility/blob/bbacc1a8ec15befae83c6a29b60e568fd02d66b7/src/Transformatika/Utility/DateTime.php#L137-L147 |
236,282 | prastowoagungwidodo/utility | src/Transformatika/Utility/DateTime.php | DateTime.yearArray | public function yearArray($begin, $end)
{
$dateArray = array();
for ($i = $begin; $i <= $end; ++$i) {
$dateArray[] = $i;
}
return $dateArray;
} | php | public function yearArray($begin, $end)
{
$dateArray = array();
for ($i = $begin; $i <= $end; ++$i) {
$dateArray[] = $i;
}
return $dateArray;
} | [
"public",
"function",
"yearArray",
"(",
"$",
"begin",
",",
"$",
"end",
")",
"{",
"$",
"dateArray",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"begin",
";",
"$",
"i",
"<=",
"$",
"end",
";",
"++",
"$",
"i",
")",
"{",
"$",
"d... | Generate Year array
@param integer $begin [description]
@param integer $end [description]
@return array [description] | [
"Generate",
"Year",
"array"
] | bbacc1a8ec15befae83c6a29b60e568fd02d66b7 | https://github.com/prastowoagungwidodo/utility/blob/bbacc1a8ec15befae83c6a29b60e568fd02d66b7/src/Transformatika/Utility/DateTime.php#L155-L162 |
236,283 | treehouselabs/event-store | src/TreeHouse/EventStore/Upcasting/SimpleUpcasterChain.php | SimpleUpcasterChain.upcast | public function upcast(SerializedEvent $event, UpcastingContext $context)
{
$result = [];
$events = [$event];
foreach ($this->upcasters as $upcaster) {
$result = [];
foreach ($events as $event) {
if ($upcaster->supports($event)) {
$upcasted = $upcaster->upcast($event, $context);
// TODO: remove support of non array values by upcasters in next major release
if (!is_array($upcasted)) {
@trigger_error(
'Upcasters need to return an array collection of upcasted events, ' .
'non array return values are deprecated and support will be removed in the next major release',
E_USER_DEPRECATED
);
$upcasted = [$upcasted];
}
array_push($result, ...$upcasted);
}
}
$events = $result;
}
return $result;
} | php | public function upcast(SerializedEvent $event, UpcastingContext $context)
{
$result = [];
$events = [$event];
foreach ($this->upcasters as $upcaster) {
$result = [];
foreach ($events as $event) {
if ($upcaster->supports($event)) {
$upcasted = $upcaster->upcast($event, $context);
// TODO: remove support of non array values by upcasters in next major release
if (!is_array($upcasted)) {
@trigger_error(
'Upcasters need to return an array collection of upcasted events, ' .
'non array return values are deprecated and support will be removed in the next major release',
E_USER_DEPRECATED
);
$upcasted = [$upcasted];
}
array_push($result, ...$upcasted);
}
}
$events = $result;
}
return $result;
} | [
"public",
"function",
"upcast",
"(",
"SerializedEvent",
"$",
"event",
",",
"UpcastingContext",
"$",
"context",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"events",
"=",
"[",
"$",
"event",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"upcasters",... | Upcasts via a chain of upcasters.
@param SerializedEvent $event
@param UpcastingContext $context
@return array|SerializedEvent[] | [
"Upcasts",
"via",
"a",
"chain",
"of",
"upcasters",
"."
] | 9df697109558f793c1c393746e6a84acb15f0564 | https://github.com/treehouselabs/event-store/blob/9df697109558f793c1c393746e6a84acb15f0564/src/TreeHouse/EventStore/Upcasting/SimpleUpcasterChain.php#L30-L61 |
236,284 | pokap/pool-dbm | src/Pok/PoolDBM/ModelManager.php | ModelManager.getRepository | public function getRepository($className)
{
if (isset($this->repositories[$className])) {
return $this->repositories[$className];
}
$metadata = $this->getClassMetadata($className);
$customRepositoryClassName = $metadata->getCustomRepositoryClassName();
if ($customRepositoryClassName !== null) {
$repository = new $customRepositoryClassName($this, $this->unitOfWork, $metadata);
} else {
$repository = new ModelRepository($this, $this->unitOfWork, $metadata);
}
$this->repositories[$className] = $repository;
return $repository;
} | php | public function getRepository($className)
{
if (isset($this->repositories[$className])) {
return $this->repositories[$className];
}
$metadata = $this->getClassMetadata($className);
$customRepositoryClassName = $metadata->getCustomRepositoryClassName();
if ($customRepositoryClassName !== null) {
$repository = new $customRepositoryClassName($this, $this->unitOfWork, $metadata);
} else {
$repository = new ModelRepository($this, $this->unitOfWork, $metadata);
}
$this->repositories[$className] = $repository;
return $repository;
} | [
"public",
"function",
"getRepository",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"repositories",
"[",
"$",
"className",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"repositories",
"[",
"$",
"className",
"]",
";",... | Returns the model repository instance given by model name.
@param string $className The name of the Model
@return ModelRepository The repository | [
"Returns",
"the",
"model",
"repository",
"instance",
"given",
"by",
"model",
"name",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/ModelManager.php#L205-L223 |
236,285 | pokap/pool-dbm | src/Pok/PoolDBM/ModelManager.php | ModelManager.hydrate | public function hydrate($model, array $fields = array())
{
if (is_array($model)) {
return $this->getRepository($this->resolveModelClassName(reset($model)))->hydrate($model, $fields);
}
$row = $this->getRepository($this->resolveModelClassName($model))->hydrate(array($model), $fields);
if (empty($row)) {
return null;
}
return $row[0];
} | php | public function hydrate($model, array $fields = array())
{
if (is_array($model)) {
return $this->getRepository($this->resolveModelClassName(reset($model)))->hydrate($model, $fields);
}
$row = $this->getRepository($this->resolveModelClassName($model))->hydrate(array($model), $fields);
if (empty($row)) {
return null;
}
return $row[0];
} | [
"public",
"function",
"hydrate",
"(",
"$",
"model",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"model",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"resol... | Hydrate a model.
@param mixed $model
@param array $fields List of fields prime (optional)
@return null|object|object[] | [
"Hydrate",
"a",
"model",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/ModelManager.php#L233-L246 |
236,286 | pokap/pool-dbm | src/Pok/PoolDBM/ModelManager.php | ModelManager.resolveModelClassName | public function resolveModelClassName($model)
{
foreach ($this->metadataFactory->getAllMetadata() as $metadata) {
/** @var Mapping\ClassMetadata $metadata */
foreach ($metadata->getFieldMappings() as $mapping) {
if (is_a($model, $mapping->getName())) {
return $metadata->getName();
}
}
}
return null;
} | php | public function resolveModelClassName($model)
{
foreach ($this->metadataFactory->getAllMetadata() as $metadata) {
/** @var Mapping\ClassMetadata $metadata */
foreach ($metadata->getFieldMappings() as $mapping) {
if (is_a($model, $mapping->getName())) {
return $metadata->getName();
}
}
}
return null;
} | [
"public",
"function",
"resolveModelClassName",
"(",
"$",
"model",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"metadataFactory",
"->",
"getAllMetadata",
"(",
")",
"as",
"$",
"metadata",
")",
"{",
"/** @var Mapping\\ClassMetadata $metadata */",
"foreach",
"(",
"$"... | Resolve model class name by sub model.
@param mixed $model
@return null|string
TODO: adding cache resolve | [
"Resolve",
"model",
"class",
"name",
"by",
"sub",
"model",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/ModelManager.php#L257-L269 |
236,287 | pokap/pool-dbm | src/Pok/PoolDBM/ModelManager.php | ModelManager.contains | public function contains($model)
{
$class = $this->getClassMetadata(get_class($model));
foreach ($class->getFieldManagerNames() as $manager) {
if (!$this->pool->getManager($manager)->contains($model->{'get' . ucfirst($manager)}())) {
return false;
}
}
return true;
} | php | public function contains($model)
{
$class = $this->getClassMetadata(get_class($model));
foreach ($class->getFieldManagerNames() as $manager) {
if (!$this->pool->getManager($manager)->contains($model->{'get' . ucfirst($manager)}())) {
return false;
}
}
return true;
} | [
"public",
"function",
"contains",
"(",
"$",
"model",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getClassMetadata",
"(",
"get_class",
"(",
"$",
"model",
")",
")",
";",
"foreach",
"(",
"$",
"class",
"->",
"getFieldManagerNames",
"(",
")",
"as",
"$"... | Determines whether a model instance is managed in this ModelManager.
@param mixed $model
@return boolean TRUE if this ModelManager currently manages the given document, FALSE otherwise. | [
"Determines",
"whether",
"a",
"model",
"instance",
"is",
"managed",
"in",
"this",
"ModelManager",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/ModelManager.php#L317-L328 |
236,288 | pokap/pool-dbm | src/Pok/PoolDBM/ModelManager.php | ModelManager.getIdentifierRepository | protected function getIdentifierRepository($className)
{
$class = $this->getClassMetadata($className);
return $this->pool->getManager($class->getManagerIdentifier())->getRepository($class->getFieldMapping($class->getManagerIdentifier())->getName());
} | php | protected function getIdentifierRepository($className)
{
$class = $this->getClassMetadata($className);
return $this->pool->getManager($class->getManagerIdentifier())->getRepository($class->getFieldMapping($class->getManagerIdentifier())->getName());
} | [
"protected",
"function",
"getIdentifierRepository",
"(",
"$",
"className",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getClassMetadata",
"(",
"$",
"className",
")",
";",
"return",
"$",
"this",
"->",
"pool",
"->",
"getManager",
"(",
"$",
"class",
"->"... | Returns repository model given by identifier.
@param string $className
@return mixed | [
"Returns",
"repository",
"model",
"given",
"by",
"identifier",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/ModelManager.php#L372-L377 |
236,289 | Opifer/RulesEngineBundle | Templating/TwigExtension.php | TwigExtension.evaluateRule | public function evaluateRule($rule, $limit = null)
{
return $this->rulesEngineProvider->evaluate($rule)->getQueryResults($limit);
} | php | public function evaluateRule($rule, $limit = null)
{
return $this->rulesEngineProvider->evaluate($rule)->getQueryResults($limit);
} | [
"public",
"function",
"evaluateRule",
"(",
"$",
"rule",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"rulesEngineProvider",
"->",
"evaluate",
"(",
"$",
"rule",
")",
"->",
"getQueryResults",
"(",
"$",
"limit",
")",
";",
"}"
] | Get the view for the placeholder
@param string $rule
@return string | [
"Get",
"the",
"view",
"for",
"the",
"placeholder"
] | a7975576d4e3203b1af6614369840c30b1af2312 | https://github.com/Opifer/RulesEngineBundle/blob/a7975576d4e3203b1af6614369840c30b1af2312/Templating/TwigExtension.php#L47-L50 |
236,290 | Opifer/RulesEngineBundle | Templating/TwigExtension.php | TwigExtension.evaluateQueryRule | public function evaluateQueryRule(QueryValue $query, $params = [])
{
if(($rule = $query->getRule()) instanceof Rule) {
$environment = $this->rulesEngineProvider->evaluate($rule);
$this->rulesEngineProvider->setQueryParams($query->getId(), $params);
return $environment->getQueryResults();
}
return [];
} | php | public function evaluateQueryRule(QueryValue $query, $params = [])
{
if(($rule = $query->getRule()) instanceof Rule) {
$environment = $this->rulesEngineProvider->evaluate($rule);
$this->rulesEngineProvider->setQueryParams($query->getId(), $params);
return $environment->getQueryResults();
}
return [];
} | [
"public",
"function",
"evaluateQueryRule",
"(",
"QueryValue",
"$",
"query",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"(",
"$",
"rule",
"=",
"$",
"query",
"->",
"getRule",
"(",
")",
")",
"instanceof",
"Rule",
")",
"{",
"$",
"environment... | Evaluate rule with query parameters
@param QueryValue $query
@param array $params
@return mixed | [
"Evaluate",
"rule",
"with",
"query",
"parameters"
] | a7975576d4e3203b1af6614369840c30b1af2312 | https://github.com/Opifer/RulesEngineBundle/blob/a7975576d4e3203b1af6614369840c30b1af2312/Templating/TwigExtension.php#L59-L69 |
236,291 | vinala/kernel | src/Storage/Cookie.php | Cookie.exists | public static function exists($name)
{
if (isset($_COOKIE[$name]) && !empty($_COOKIE[$name])) {
return true;
} else {
return false;
}
} | php | public static function exists($name)
{
if (isset($_COOKIE[$name]) && !empty($_COOKIE[$name])) {
return true;
} else {
return false;
}
} | [
"public",
"static",
"function",
"exists",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_COOKIE",
"[",
"$",
"name",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"_COOKIE",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"true",
";",
"}"... | Check if a cookie exists.
@param string $name
@return bool | [
"Check",
"if",
"a",
"cookie",
"exists",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Storage/Cookie.php#L54-L61 |
236,292 | vinala/kernel | src/Storage/Cookie.php | Cookie.create | public static function create($name, $value, $lifetime, $path = '/')
{
$expire = self::lifetime($lifetime);
return setcookie($name, $value, $expire, $path);
} | php | public static function create($name, $value, $lifetime, $path = '/')
{
$expire = self::lifetime($lifetime);
return setcookie($name, $value, $expire, $path);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lifetime",
",",
"$",
"path",
"=",
"'/'",
")",
"{",
"$",
"expire",
"=",
"self",
"::",
"lifetime",
"(",
"$",
"lifetime",
")",
";",
"return",
"setcookie",
"(",
"... | Create new cookie.
@param string $name
@param string $value
@param int $lifetime By minutes
@param string $path
@return null | [
"Create",
"new",
"cookie",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Storage/Cookie.php#L87-L92 |
236,293 | diarmuidie/ImageRack-Kernel | src/Image/Process.php | Process.process | public function process(TemplateInterface $template)
{
// Create a new intervention image object
$image = $this->imageManager->make($this->image);
$image = $template->process($image);
// Encode the image if it hasn't
// been encoded in the template.
if (!$image->isEncoded()) {
$image->encode();
}
return $image;
} | php | public function process(TemplateInterface $template)
{
// Create a new intervention image object
$image = $this->imageManager->make($this->image);
$image = $template->process($image);
// Encode the image if it hasn't
// been encoded in the template.
if (!$image->isEncoded()) {
$image->encode();
}
return $image;
} | [
"public",
"function",
"process",
"(",
"TemplateInterface",
"$",
"template",
")",
"{",
"// Create a new intervention image object",
"$",
"image",
"=",
"$",
"this",
"->",
"imageManager",
"->",
"make",
"(",
"$",
"this",
"->",
"image",
")",
";",
"$",
"image",
"=",... | Run the named template against the image.
@param string $template The template to run
@return Intervention\Image\Image The processed image | [
"Run",
"the",
"named",
"template",
"against",
"the",
"image",
"."
] | 0bd14bb561ba0486f60a6d3058587497ae99ea97 | https://github.com/diarmuidie/ImageRack-Kernel/blob/0bd14bb561ba0486f60a6d3058587497ae99ea97/src/Image/Process.php#L44-L58 |
236,294 | slickframework/mvc | src/Application.php | Application.setRequest | public function setRequest(Request $request)
{
$this->request = $request;
$this->getContainer()->register('request', $request);
return $this;
} | php | public function setRequest(Request $request)
{
$this->request = $request;
$this->getContainer()->register('request', $request);
return $this;
} | [
"public",
"function",
"setRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"request",
"=",
"$",
"request",
";",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"register",
"(",
"'request'",
",",
"$",
"request",
")",
";",
"retur... | Sets a new request
@param Request $request
@return Application | [
"Sets",
"a",
"new",
"request"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Application.php#L83-L88 |
236,295 | slickframework/mvc | src/Application.php | Application.getContainer | public function getContainer()
{
if (is_null(self::$container)) {
self::$container = $this->checkContainer();
}
return self::$container;
} | php | public function getContainer()
{
if (is_null(self::$container)) {
self::$container = $this->checkContainer();
}
return self::$container;
} | [
"public",
"function",
"getContainer",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"self",
"::",
"$",
"container",
")",
")",
"{",
"self",
"::",
"$",
"container",
"=",
"$",
"this",
"->",
"checkContainer",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
... | Gets the application dependency injection container
@return ContainerInterface|Container | [
"Gets",
"the",
"application",
"dependency",
"injection",
"container"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Application.php#L95-L101 |
236,296 | slickframework/mvc | src/Application.php | Application.getResponse | public function getResponse()
{
if (is_null($this->response)) {
$this->response = $this->getRunner()->run();
}
return $this->response;
} | php | public function getResponse()
{
if (is_null($this->response)) {
$this->response = $this->getRunner()->run();
}
return $this->response;
} | [
"public",
"function",
"getResponse",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"response",
")",
")",
"{",
"$",
"this",
"->",
"response",
"=",
"$",
"this",
"->",
"getRunner",
"(",
")",
"->",
"run",
"(",
")",
";",
"}",
"return",
... | Returns the processed response
@return Response | [
"Returns",
"the",
"processed",
"response"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Application.php#L145-L151 |
236,297 | slickframework/mvc | src/Application.php | Application.getRunner | public function getRunner()
{
if (null === $this->runner) {
$runner = $this->getContainer()
->get('middleware.runner')
->setRequest($this->getRequest())
;
$this->setRunner($runner);
}
return $this->runner;
} | php | public function getRunner()
{
if (null === $this->runner) {
$runner = $this->getContainer()
->get('middleware.runner')
->setRequest($this->getRequest())
;
$this->setRunner($runner);
}
return $this->runner;
} | [
"public",
"function",
"getRunner",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"runner",
")",
"{",
"$",
"runner",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'middleware.runner'",
")",
"->",
"setRequest",
"(",
... | Gets the HTTP middleware runner for this application
@return MiddlewareRunnerInterface | [
"Gets",
"the",
"HTTP",
"middleware",
"runner",
"for",
"this",
"application"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Application.php#L158-L168 |
236,298 | slickframework/mvc | src/Application.php | Application.getConfigPath | public function getConfigPath()
{
if (null == $this->configPath) {
$this->configPath = getcwd().'/Configuration';
Configuration::addPath($this->configPath);
}
return $this->configPath;
} | php | public function getConfigPath()
{
if (null == $this->configPath) {
$this->configPath = getcwd().'/Configuration';
Configuration::addPath($this->configPath);
}
return $this->configPath;
} | [
"public",
"function",
"getConfigPath",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"configPath",
")",
"{",
"$",
"this",
"->",
"configPath",
"=",
"getcwd",
"(",
")",
".",
"'/Configuration'",
";",
"Configuration",
"::",
"addPath",
"(",
"$",
... | Gets configuration path
@return string | [
"Gets",
"configuration",
"path"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Application.php#L189-L196 |
236,299 | slickframework/mvc | src/Application.php | Application.checkContainer | protected function checkContainer()
{
$container = self::$defaultContainer;
if (
null != $this->configPath &&
file_exists($this->configPath.'/services.php')
) {
$definitions = include $this->configPath.'/services.php';
$container = (
new ContainerBuilder(
$definitions,
true
)
)->getContainer();
}
return $container;
} | php | protected function checkContainer()
{
$container = self::$defaultContainer;
if (
null != $this->configPath &&
file_exists($this->configPath.'/services.php')
) {
$definitions = include $this->configPath.'/services.php';
$container = (
new ContainerBuilder(
$definitions,
true
)
)->getContainer();
}
return $container;
} | [
"protected",
"function",
"checkContainer",
"(",
")",
"{",
"$",
"container",
"=",
"self",
"::",
"$",
"defaultContainer",
";",
"if",
"(",
"null",
"!=",
"$",
"this",
"->",
"configPath",
"&&",
"file_exists",
"(",
"$",
"this",
"->",
"configPath",
".",
"'/servic... | Gets container with user overridden settings
@return ContainerInterface|\Slick\Di\Container | [
"Gets",
"container",
"with",
"user",
"overridden",
"settings"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Application.php#L217-L233 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.