repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
ansas/php-component
src/Component/File/FtpClient.php
FtpClient.passive
public function passive(bool $passive) { if (!@ftp_pasv($this->ftp, $passive)) { throw new Exception(sprintf("Cannot switch to passive = %s", $passive ? "true" : "false")); } return $this; }
php
public function passive(bool $passive) { if (!@ftp_pasv($this->ftp, $passive)) { throw new Exception(sprintf("Cannot switch to passive = %s", $passive ? "true" : "false")); } return $this; }
[ "public", "function", "passive", "(", "bool", "$", "passive", ")", "{", "if", "(", "!", "@", "ftp_pasv", "(", "$", "this", "->", "ftp", ",", "$", "passive", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "\"Cannot switch to passive = %s...
Switch to active or passive mode. @param bool $passive @return $this @throws Exception
[ "Switch", "to", "active", "or", "passive", "mode", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/File/FtpClient.php#L326-L333
train
ansas/php-component
src/Component/File/FtpClient.php
FtpClient.fput
public function fput(string $remoteFile, $handle, int $resumePos = 0) { if (!@ftp_fput($this->ftp, $remoteFile, $handle, FTP_BINARY, $resumePos)) { throw new Exception(sprintf("Cannot copy data from file handle to %s", $remoteFile)); } return $this; }
php
public function fput(string $remoteFile, $handle, int $resumePos = 0) { if (!@ftp_fput($this->ftp, $remoteFile, $handle, FTP_BINARY, $resumePos)) { throw new Exception(sprintf("Cannot copy data from file handle to %s", $remoteFile)); } return $this; }
[ "public", "function", "fput", "(", "string", "$", "remoteFile", ",", "$", "handle", ",", "int", "$", "resumePos", "=", "0", ")", "{", "if", "(", "!", "@", "ftp_fput", "(", "$", "this", "->", "ftp", ",", "$", "remoteFile", ",", "$", "handle", ",", ...
Read directly from file and put data on ftp-server. @param string $remoteFile Remote file path. @param mixed $handle File handle. @param int $resumePos [optional] Start or resume position in file. @return $this @throws Exception
[ "Read", "directly", "from", "file", "and", "put", "data", "on", "ftp", "-", "server", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/File/FtpClient.php#L368-L375
train
ansas/php-component
src/Component/File/FtpClient.php
FtpClient.delete
public function delete(string $remoteFile) { if (!@ftp_delete($this->ftp, $remoteFile)) { throw new Exception(sprintf("Cannot delete file %s", $remoteFile)); } return $this; }
php
public function delete(string $remoteFile) { if (!@ftp_delete($this->ftp, $remoteFile)) { throw new Exception(sprintf("Cannot delete file %s", $remoteFile)); } return $this; }
[ "public", "function", "delete", "(", "string", "$", "remoteFile", ")", "{", "if", "(", "!", "@", "ftp_delete", "(", "$", "this", "->", "ftp", ",", "$", "remoteFile", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "\"Cannot delete file %...
Delete a file from ftp-server. @param string $remoteFile Remote file path. @return $this @throws Exception
[ "Delete", "a", "file", "from", "ftp", "-", "server", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/File/FtpClient.php#L385-L392
train
ansas/php-component
src/Component/File/FtpClient.php
FtpClient.getSize
public function getSize(string $remoteFile) { $size = @ftp_size($this->ftp, $remoteFile); if ($size == -1) { throw new Exception("Cannot get file size"); } return $size; }
php
public function getSize(string $remoteFile) { $size = @ftp_size($this->ftp, $remoteFile); if ($size == -1) { throw new Exception("Cannot get file size"); } return $size; }
[ "public", "function", "getSize", "(", "string", "$", "remoteFile", ")", "{", "$", "size", "=", "@", "ftp_size", "(", "$", "this", "->", "ftp", ",", "$", "remoteFile", ")", ";", "if", "(", "$", "size", "==", "-", "1", ")", "{", "throw", "new", "Ex...
Get size of file on ftp-server. @param string $remoteFile Remote file path. @return int File size in byte. @throws Exception
[ "Get", "size", "of", "file", "on", "ftp", "-", "server", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/File/FtpClient.php#L420-L429
train
ansas/php-component
src/Component/File/FtpClient.php
FtpClient.getModifiedTimestamp
public function getModifiedTimestamp(string $remoteFile, int $attempts = 1, int $sleepBetweenAttempts = 5) { $timestamp = @ftp_mdtm($this->ftp, $remoteFile); if ($timestamp < 0) { if (--$attempts > 0) { sleep($sleepBetweenAttempts); return $this->getModifiedTimestamp($remoteFile, $attempts, $sleepBetweenAttempts); } throw new Exception("Cannot get file modification timestamp"); } return $timestamp; }
php
public function getModifiedTimestamp(string $remoteFile, int $attempts = 1, int $sleepBetweenAttempts = 5) { $timestamp = @ftp_mdtm($this->ftp, $remoteFile); if ($timestamp < 0) { if (--$attempts > 0) { sleep($sleepBetweenAttempts); return $this->getModifiedTimestamp($remoteFile, $attempts, $sleepBetweenAttempts); } throw new Exception("Cannot get file modification timestamp"); } return $timestamp; }
[ "public", "function", "getModifiedTimestamp", "(", "string", "$", "remoteFile", ",", "int", "$", "attempts", "=", "1", ",", "int", "$", "sleepBetweenAttempts", "=", "5", ")", "{", "$", "timestamp", "=", "@", "ftp_mdtm", "(", "$", "this", "->", "ftp", ","...
Get timestamp of last modification of file on ftp-server. @param string $remoteFile Remote file path. @param int $attempts [optional] Number of retries in case of error. @param int $sleepBetweenAttempts [optional] Sleep time in seconds between attempts. @return int Timestamp. @throws Exception
[ "Get", "timestamp", "of", "last", "modification", "of", "file", "on", "ftp", "-", "server", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Component/File/FtpClient.php#L441-L456
train
Corviz/framework
src/Routing/Route.php
Route.all
public static function all( string $routeStr, array $info ) { $methods = Request::getValidMethods(); self::create($methods, $routeStr, $info); }
php
public static function all( string $routeStr, array $info ) { $methods = Request::getValidMethods(); self::create($methods, $routeStr, $info); }
[ "public", "static", "function", "all", "(", "string", "$", "routeStr", ",", "array", "$", "info", ")", "{", "$", "methods", "=", "Request", "::", "getValidMethods", "(", ")", ";", "self", "::", "create", "(", "$", "methods", ",", "$", "routeStr", ",", ...
Creates a route that listens to all supported. @param string $routeStr @param array $info
[ "Creates", "a", "route", "that", "listens", "to", "all", "supported", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Routing/Route.php#L59-L65
train
Corviz/framework
src/Routing/Route.php
Route.create
public static function create( array $methods, string $routeStr, array $info ) { $middlewareList = isset($info['middleware']) ? (array) $info['middleware'] : []; array_walk_recursive( self::$middlewareGroupStack, function ($middleware) use (&$middlewareList) { $middlewareList[] = $middleware; } ); $route = new self(); $route->setMethods($methods); $route->setAction(isset($info['action']) ? $info['action'] : 'index'); $route->setAlias(isset($info['alias']) ? $info['alias'] : ''); $route->setMiddlewareList($middlewareList); $route->setControllerName($info['controller']); $route->setMethods($methods); $route->setRouteStr($routeStr); Map::addRoute($route); }
php
public static function create( array $methods, string $routeStr, array $info ) { $middlewareList = isset($info['middleware']) ? (array) $info['middleware'] : []; array_walk_recursive( self::$middlewareGroupStack, function ($middleware) use (&$middlewareList) { $middlewareList[] = $middleware; } ); $route = new self(); $route->setMethods($methods); $route->setAction(isset($info['action']) ? $info['action'] : 'index'); $route->setAlias(isset($info['alias']) ? $info['alias'] : ''); $route->setMiddlewareList($middlewareList); $route->setControllerName($info['controller']); $route->setMethods($methods); $route->setRouteStr($routeStr); Map::addRoute($route); }
[ "public", "static", "function", "create", "(", "array", "$", "methods", ",", "string", "$", "routeStr", ",", "array", "$", "info", ")", "{", "$", "middlewareList", "=", "isset", "(", "$", "info", "[", "'middleware'", "]", ")", "?", "(", "array", ")", ...
Build a new route and add it to the Map. @param array $methods Array containing http methods. The supported methods are defined by Request::METHOD_* constants @param string $routeStr A string that may contain parameters that will be passed to the controller. For example: - /home - /product/{productId} - /tag/{slug} @param array $info An array containing the following indexes: - controller: Name of a controller class - action: Method of the defined controller (Default: index) - alias: Short name of the route, for easy referencing
[ "Build", "a", "new", "route", "and", "add", "it", "to", "the", "Map", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Routing/Route.php#L83-L106
train
Corviz/framework
src/Routing/Route.php
Route.delete
public static function delete( string $routeStr, array $info ) { self::create([Request::METHOD_DELETE], $routeStr, $info); }
php
public static function delete( string $routeStr, array $info ) { self::create([Request::METHOD_DELETE], $routeStr, $info); }
[ "public", "static", "function", "delete", "(", "string", "$", "routeStr", ",", "array", "$", "info", ")", "{", "self", "::", "create", "(", "[", "Request", "::", "METHOD_DELETE", "]", ",", "$", "routeStr", ",", "$", "info", ")", ";", "}" ]
Creates a route that listens to DELETE http method. @param string $routeStr @param array $info
[ "Creates", "a", "route", "that", "listens", "to", "DELETE", "http", "method", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Routing/Route.php#L114-L119
train
Corviz/framework
src/Routing/Route.php
Route.get
public static function get( string $routeStr, array $info ) { self::create([Request::METHOD_GET], $routeStr, $info); }
php
public static function get( string $routeStr, array $info ) { self::create([Request::METHOD_GET], $routeStr, $info); }
[ "public", "static", "function", "get", "(", "string", "$", "routeStr", ",", "array", "$", "info", ")", "{", "self", "::", "create", "(", "[", "Request", "::", "METHOD_GET", "]", ",", "$", "routeStr", ",", "$", "info", ")", ";", "}" ]
Creates a route that listens to GET http method. @param string $routeStr @param array $info
[ "Creates", "a", "route", "that", "listens", "to", "GET", "http", "method", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Routing/Route.php#L127-L132
train
Corviz/framework
src/Routing/Route.php
Route.group
public static function group(string $prefix, Closure $closure, $middleware = []) { $prefix = trim($prefix, self::SEPARATOR); //Prepend prefixes if ($prefix) { self::$prefixGroupStack[] = $prefix; } //Add group middleware if ($middleware) { self::$middlewareGroupStack[] = $middleware; } //Call group closure $closure(); //Remove prefix if ($prefix) { array_pop(self::$prefixGroupStack); } //Remove current group middleware from the list if ($middleware) { array_pop(self::$middlewareGroupStack); } }
php
public static function group(string $prefix, Closure $closure, $middleware = []) { $prefix = trim($prefix, self::SEPARATOR); //Prepend prefixes if ($prefix) { self::$prefixGroupStack[] = $prefix; } //Add group middleware if ($middleware) { self::$middlewareGroupStack[] = $middleware; } //Call group closure $closure(); //Remove prefix if ($prefix) { array_pop(self::$prefixGroupStack); } //Remove current group middleware from the list if ($middleware) { array_pop(self::$middlewareGroupStack); } }
[ "public", "static", "function", "group", "(", "string", "$", "prefix", ",", "Closure", "$", "closure", ",", "$", "middleware", "=", "[", "]", ")", "{", "$", "prefix", "=", "trim", "(", "$", "prefix", ",", "self", "::", "SEPARATOR", ")", ";", "//Prepe...
Creates a route group. @param string $prefix @param Closure $closure @param array|string $middleware
[ "Creates", "a", "route", "group", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Routing/Route.php#L141-L167
train
Corviz/framework
src/Routing/Route.php
Route.post
public static function post( string $routeStr, array $info ) { self::create([Request::METHOD_POST], $routeStr, $info); }
php
public static function post( string $routeStr, array $info ) { self::create([Request::METHOD_POST], $routeStr, $info); }
[ "public", "static", "function", "post", "(", "string", "$", "routeStr", ",", "array", "$", "info", ")", "{", "self", "::", "create", "(", "[", "Request", "::", "METHOD_POST", "]", ",", "$", "routeStr", ",", "$", "info", ")", ";", "}" ]
Creates a route that listens to POST http method. @param string $routeStr @param array $info
[ "Creates", "a", "route", "that", "listens", "to", "POST", "http", "method", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Routing/Route.php#L175-L180
train
Corviz/framework
src/Routing/Route.php
Route.patch
public static function patch( string $routeStr, array $info ) { self::create([Request::METHOD_PATCH], $routeStr, $info); }
php
public static function patch( string $routeStr, array $info ) { self::create([Request::METHOD_PATCH], $routeStr, $info); }
[ "public", "static", "function", "patch", "(", "string", "$", "routeStr", ",", "array", "$", "info", ")", "{", "self", "::", "create", "(", "[", "Request", "::", "METHOD_PATCH", "]", ",", "$", "routeStr", ",", "$", "info", ")", ";", "}" ]
Creates a route that listens to PATCH http method. @param string $routeStr @param array $info
[ "Creates", "a", "route", "that", "listens", "to", "PATCH", "http", "method", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Routing/Route.php#L188-L193
train
Corviz/framework
src/Routing/Route.php
Route.put
public static function put( string $routeStr, array $info ) { self::create([Request::METHOD_PUT], $routeStr, $info); }
php
public static function put( string $routeStr, array $info ) { self::create([Request::METHOD_PUT], $routeStr, $info); }
[ "public", "static", "function", "put", "(", "string", "$", "routeStr", ",", "array", "$", "info", ")", "{", "self", "::", "create", "(", "[", "Request", "::", "METHOD_PUT", "]", ",", "$", "routeStr", ",", "$", "info", ")", ";", "}" ]
Creates a route that listens to PUT http method. @param string $routeStr @param array $info
[ "Creates", "a", "route", "that", "listens", "to", "PUT", "http", "method", "." ]
e297f890aa1c5aad28aae383b2df5c913bf6c780
https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Routing/Route.php#L201-L206
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/Core/Model/UserGroups/Group.php
Group.addLogin
public function addLogin($login) { if (!isset($this->logins[$login])) { $this->logins[$login] = true; $this->dispatcher->dispatch(self::EVENT_NEW_USER, [$this, $login]); } }
php
public function addLogin($login) { if (!isset($this->logins[$login])) { $this->logins[$login] = true; $this->dispatcher->dispatch(self::EVENT_NEW_USER, [$this, $login]); } }
[ "public", "function", "addLogin", "(", "$", "login", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "logins", "[", "$", "login", "]", ")", ")", "{", "$", "this", "->", "logins", "[", "$", "login", "]", "=", "true", ";", "$", "this",...
Add user to the group. @param string $login
[ "Add", "user", "to", "the", "group", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Model/UserGroups/Group.php#L56-L62
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/Core/Model/UserGroups/Group.php
Group.removeLogin
public function removeLogin($login) { if (isset($this->logins[$login])) { unset($this->logins[$login]); $this->dispatcher->dispatch(self::EVENT_REMOVE_USER, [$this, $login]); } if (!$this->isPersistent() && empty($this->logins)) { $this->dispatcher->dispatch(self::EVENT_DESTROY, [$this, $login]); } }
php
public function removeLogin($login) { if (isset($this->logins[$login])) { unset($this->logins[$login]); $this->dispatcher->dispatch(self::EVENT_REMOVE_USER, [$this, $login]); } if (!$this->isPersistent() && empty($this->logins)) { $this->dispatcher->dispatch(self::EVENT_DESTROY, [$this, $login]); } }
[ "public", "function", "removeLogin", "(", "$", "login", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "logins", "[", "$", "login", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "logins", "[", "$", "login", "]", ")", ";", "$", "th...
Remove user from the group. @param $login
[ "Remove", "user", "from", "the", "group", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Model/UserGroups/Group.php#L69-L80
train
stanislav-web/PhalconSonar
src/Sonar/Mappers/Db/Mongo/VisitorMapper.php
VisitorMapper.add
public function add(array $data) { try { $document = (new Visitor($data))->toArray(); $this->collection->insert($document, ['w' => true]); return new \MongoId($document['_id']); } catch (\MongoCursorException $e) { throw new MongoMapperException($e->getMessage()); } catch (\MongoException $e) { throw new MongoMapperException($e->getMessage()); } }
php
public function add(array $data) { try { $document = (new Visitor($data))->toArray(); $this->collection->insert($document, ['w' => true]); return new \MongoId($document['_id']); } catch (\MongoCursorException $e) { throw new MongoMapperException($e->getMessage()); } catch (\MongoException $e) { throw new MongoMapperException($e->getMessage()); } }
[ "public", "function", "add", "(", "array", "$", "data", ")", "{", "try", "{", "$", "document", "=", "(", "new", "Visitor", "(", "$", "data", ")", ")", "->", "toArray", "(", ")", ";", "$", "this", "->", "collection", "->", "insert", "(", "$", "doc...
Add records to collection @param array $data @throws \Sonar\Exceptions\MongoMapperException @return \MongoId
[ "Add", "records", "to", "collection" ]
4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa
https://github.com/stanislav-web/PhalconSonar/blob/4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa/src/Sonar/Mappers/Db/Mongo/VisitorMapper.php#L35-L51
train
Celarius/spin-framework
src/Helpers/ArrayToXml.php
ArrayToXML.buildXML
public function buildXML(array $data, $startElement = 'data') { if (!\is_array($data)) { $err = 'Invalid variable type supplied, expected array not found on line ' . __LINE__ . ' in Class: ' . __CLASS__ . ' Method: ' . __METHOD__; \trigger_error($err); return false; //return false error occurred } $xml = new \XmlWriter(); $xml->openMemory(); $xml->startDocument($this->version, $this->encoding); $xml->startElement($startElement); $data = $this->writeAttr($xml, $data); $this->writeEl($xml, $data); $xml->endElement(); //write end element //returns the XML results return $xml->outputMemory(true); }
php
public function buildXML(array $data, $startElement = 'data') { if (!\is_array($data)) { $err = 'Invalid variable type supplied, expected array not found on line ' . __LINE__ . ' in Class: ' . __CLASS__ . ' Method: ' . __METHOD__; \trigger_error($err); return false; //return false error occurred } $xml = new \XmlWriter(); $xml->openMemory(); $xml->startDocument($this->version, $this->encoding); $xml->startElement($startElement); $data = $this->writeAttr($xml, $data); $this->writeEl($xml, $data); $xml->endElement(); //write end element //returns the XML results return $xml->outputMemory(true); }
[ "public", "function", "buildXML", "(", "array", "$", "data", ",", "$", "startElement", "=", "'data'", ")", "{", "if", "(", "!", "\\", "is_array", "(", "$", "data", ")", ")", "{", "$", "err", "=", "'Invalid variable type supplied, expected array not found on li...
Build an XML Data Set @param array $data Associative Array containing values to be parsed into an XML Data Set(s) @param string $startElement Root Opening Tag, default data @return string XML String containing values @return mixed Boolean false on failure, string XML result on success
[ "Build", "an", "XML", "Data", "Set" ]
2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0
https://github.com/Celarius/spin-framework/blob/2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0/src/Helpers/ArrayToXml.php#L42-L60
train
Celarius/spin-framework
src/Helpers/ArrayToXml.php
ArrayToXML.writeEl
protected function writeEl(XMLWriter $xml, $data) { foreach ($data as $key => $value) { if (\is_array($value) && !$this->isAssoc($value)) { //numeric array foreach ($value as $itemValue) { if (\is_array($itemValue)) { $xml->startElement($key); $itemValue = $this->writeAttr($xml, $itemValue); $this->writeEl($xml, $itemValue); $xml->endElement(); } else { $itemValue = $this->writeAttr($xml, $itemValue); $xml->writeElement($key, "$itemValue"); } } } else if (\is_array($value)) { //associative array $xml->startElement($key); $value = $this->writeAttr($xml, $value); $this->writeEl($xml, $value); $xml->endElement(); } else { //scalar $value = $this->writeAttr($xml, $value); $xml->writeElement($key, "$value"); } } }
php
protected function writeEl(XMLWriter $xml, $data) { foreach ($data as $key => $value) { if (\is_array($value) && !$this->isAssoc($value)) { //numeric array foreach ($value as $itemValue) { if (\is_array($itemValue)) { $xml->startElement($key); $itemValue = $this->writeAttr($xml, $itemValue); $this->writeEl($xml, $itemValue); $xml->endElement(); } else { $itemValue = $this->writeAttr($xml, $itemValue); $xml->writeElement($key, "$itemValue"); } } } else if (\is_array($value)) { //associative array $xml->startElement($key); $value = $this->writeAttr($xml, $value); $this->writeEl($xml, $value); $xml->endElement(); } else { //scalar $value = $this->writeAttr($xml, $value); $xml->writeElement($key, "$value"); } } }
[ "protected", "function", "writeEl", "(", "XMLWriter", "$", "xml", ",", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "\\", "is_array", "(", "$", "value", ")", "&&", "!", "$", "this"...
Write XML as per Associative Array @param XMLWriter $xml object @param array $data Associative Data Array
[ "Write", "XML", "as", "per", "Associative", "Array" ]
2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0
https://github.com/Celarius/spin-framework/blob/2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0/src/Helpers/ArrayToXml.php#L107-L132
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper._getActiveMenuPattern
protected function _getActiveMenuPattern($level = 0, $urlInfo = null) { if (empty($urlInfo) || !is_array($urlInfo)) { return false; } $level = (int)$level; extract($urlInfo); if (($level < 0) || ($level > 2)) { $level = 0; } if ($level > 1) { $action = 'index'; } if ($level == 0) { $userPrefix = $this->Session->read('Auth.User.prefix'); if (empty($prefix) && !empty($userPrefix)) { $prefix = $userPrefix; } } $url = compact( 'controller', 'action', 'plugin', 'prefix' ); if (!empty($prefix)) { $url[$prefix] = true; } $href = $this->url($url); $href = preg_quote($href, '/'); if (!empty($pass) || !empty($named)) { if (((($level == 0) && (mb_stripos($action, 'index') === false)) || ($level == 2)) && ($href !== '\/')) { $href .= '\/?.*'; } } $activePattern = '/<a\s+href=\"' . $href . '\".*>/iu'; return $activePattern; }
php
protected function _getActiveMenuPattern($level = 0, $urlInfo = null) { if (empty($urlInfo) || !is_array($urlInfo)) { return false; } $level = (int)$level; extract($urlInfo); if (($level < 0) || ($level > 2)) { $level = 0; } if ($level > 1) { $action = 'index'; } if ($level == 0) { $userPrefix = $this->Session->read('Auth.User.prefix'); if (empty($prefix) && !empty($userPrefix)) { $prefix = $userPrefix; } } $url = compact( 'controller', 'action', 'plugin', 'prefix' ); if (!empty($prefix)) { $url[$prefix] = true; } $href = $this->url($url); $href = preg_quote($href, '/'); if (!empty($pass) || !empty($named)) { if (((($level == 0) && (mb_stripos($action, 'index') === false)) || ($level == 2)) && ($href !== '\/')) { $href .= '\/?.*'; } } $activePattern = '/<a\s+href=\"' . $href . '\".*>/iu'; return $activePattern; }
[ "protected", "function", "_getActiveMenuPattern", "(", "$", "level", "=", "0", ",", "$", "urlInfo", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "urlInfo", ")", "||", "!", "is_array", "(", "$", "urlInfo", ")", ")", "{", "return", "false", ";"...
Return pattern for PCRE of active menu item. @param int $level Level of pattern for PCRE @param array $urlInfo Array information of current URL. @return string|bool Pattern for PCRE, or False on failure. @see ViewExtensionHelper::_parseCurrentUrl()
[ "Return", "pattern", "for", "PCRE", "of", "active", "menu", "item", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L353-L394
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper._getActiveMenuPatterns
protected function _getActiveMenuPatterns($urlInfo = null) { $deepLevelsActivePattern = $this->_getDeepLevelsActiveMenuPattern(); $activePatterns = []; for ($activePatternLevel = 0; $activePatternLevel <= $deepLevelsActivePattern; $activePatternLevel++) { $activePatterns[] = $this->_getActiveMenuPattern($activePatternLevel, $urlInfo); } return $activePatterns; }
php
protected function _getActiveMenuPatterns($urlInfo = null) { $deepLevelsActivePattern = $this->_getDeepLevelsActiveMenuPattern(); $activePatterns = []; for ($activePatternLevel = 0; $activePatternLevel <= $deepLevelsActivePattern; $activePatternLevel++) { $activePatterns[] = $this->_getActiveMenuPattern($activePatternLevel, $urlInfo); } return $activePatterns; }
[ "protected", "function", "_getActiveMenuPatterns", "(", "$", "urlInfo", "=", "null", ")", "{", "$", "deepLevelsActivePattern", "=", "$", "this", "->", "_getDeepLevelsActiveMenuPattern", "(", ")", ";", "$", "activePatterns", "=", "[", "]", ";", "for", "(", "$",...
Return Array of pattern for PCRE of active menu item. @param array $urlInfo Array information of current URL. @return array Return array of patterns for PCRE for all levels. @see ViewExtensionHelper::_getActiveMenuPattern()
[ "Return", "Array", "of", "pattern", "for", "PCRE", "of", "active", "menu", "item", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L403-L411
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper._prepareIconList
protected function _prepareIconList(array &$iconList) { if (empty($iconList) || !is_array($iconList)) { return; } foreach ($iconList as $i => &$iconListItem) { if (is_array($iconListItem) && isAssoc($iconListItem)) { foreach ($iconListItem as $topMenu => $subMenu) { $subMenuList = ''; foreach ($subMenu as $subMenuItem) { $subMenuClass = null; if ($subMenuItem === 'divider') { $subMenuItem = ''; $subMenuClass = 'divider'; } $subMenuList .= $this->Html->tag('li', $subMenuItem, ['class' => $subMenuClass]); } $topMenuItem = $topMenu . $this->Html->tag('ul', $subMenuList, ['class' => 'dropdown-menu']); } $iconListItem = $topMenuItem; } } }
php
protected function _prepareIconList(array &$iconList) { if (empty($iconList) || !is_array($iconList)) { return; } foreach ($iconList as $i => &$iconListItem) { if (is_array($iconListItem) && isAssoc($iconListItem)) { foreach ($iconListItem as $topMenu => $subMenu) { $subMenuList = ''; foreach ($subMenu as $subMenuItem) { $subMenuClass = null; if ($subMenuItem === 'divider') { $subMenuItem = ''; $subMenuClass = 'divider'; } $subMenuList .= $this->Html->tag('li', $subMenuItem, ['class' => $subMenuClass]); } $topMenuItem = $topMenu . $this->Html->tag('ul', $subMenuList, ['class' => 'dropdown-menu']); } $iconListItem = $topMenuItem; } } }
[ "protected", "function", "_prepareIconList", "(", "array", "&", "$", "iconList", ")", "{", "if", "(", "empty", "(", "$", "iconList", ")", "||", "!", "is_array", "(", "$", "iconList", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "iconList", ...
Prepare a list of the icons main menu by adding a drop-down element for sub-menu item. @param array &$iconList Array list of icons for main menu. @return void @see ViewExtensionHelper::_getActiveMenuPattern()
[ "Prepare", "a", "list", "of", "the", "icons", "main", "menu", "by", "adding", "a", "drop", "-", "down", "element", "for", "sub", "-", "menu", "item", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L421-L443
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper._parseCurrentUrl
protected function _parseCurrentUrl() { $prefix = $this->request->param('prefix'); $plugin = $this->request->param('plugin'); $controller = $this->request->param('controller'); $action = $this->request->param('action'); $named = $this->request->param('named'); $pass = $this->request->param('pass'); $named = (!empty($named) ? true : false); $pass = (!empty($pass) ? true : false); $result = compact( 'prefix', 'plugin', 'controller', 'action', 'named', 'pass' ); return $result; }
php
protected function _parseCurrentUrl() { $prefix = $this->request->param('prefix'); $plugin = $this->request->param('plugin'); $controller = $this->request->param('controller'); $action = $this->request->param('action'); $named = $this->request->param('named'); $pass = $this->request->param('pass'); $named = (!empty($named) ? true : false); $pass = (!empty($pass) ? true : false); $result = compact( 'prefix', 'plugin', 'controller', 'action', 'named', 'pass' ); return $result; }
[ "protected", "function", "_parseCurrentUrl", "(", ")", "{", "$", "prefix", "=", "$", "this", "->", "request", "->", "param", "(", "'prefix'", ")", ";", "$", "plugin", "=", "$", "this", "->", "request", "->", "param", "(", "'plugin'", ")", ";", "$", "...
Return array information of current URL. @return array Information of current URL.
[ "Return", "array", "information", "of", "current", "URL", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L450-L470
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.getMenuList
public function getMenuList($iconList = null) { $activeMenuUrl = $this->_View->get('activeMenuUrl'); $urlInfo = $this->_parseCurrentUrl(); if (!empty($activeMenuUrl) && is_array($activeMenuUrl)) { $urlInfo = $activeMenuUrl + $urlInfo; } $activePatterns = $this->_getActiveMenuPatterns($urlInfo); $deepLevelsActivePattern = $this->_getDeepLevelsActiveMenuPattern(); $activeMenu = []; $menuList = ''; $cachePath = null; if (empty($iconList) || !is_array($iconList)) { return $menuList; } $this->_prepareIconList($iconList); $dataStr = serialize($iconList + $urlInfo) . '_' . $this->_currUIlang; $cachePath = 'MenuList.' . md5($dataStr); $cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS); if (!empty($cached)) { return $cached; } foreach ($iconList as $i => $iconListItem) { for ($activePatternLevel = 0; $activePatternLevel <= $deepLevelsActivePattern; $activePatternLevel++) { if (!$activePatterns[$activePatternLevel]) { continue; } if (preg_match($activePatterns[$activePatternLevel], $iconListItem)) { $activeMenu[$activePatternLevel][] = $i; } } } for ($activePatternLevel = 0; $activePatternLevel <= $deepLevelsActivePattern; $activePatternLevel++) { if (isset($activeMenu[$activePatternLevel]) && !empty($activeMenu[$activePatternLevel])) { break; } } foreach ($iconList as $i => $iconListItem) { $iconListItemClass = null; if (isset($activeMenu[$activePatternLevel]) && in_array($i, $activeMenu[$activePatternLevel])) { $iconListItemClass = 'active'; } $menuList .= $this->Html->tag('li', $iconListItem, ['class' => $iconListItemClass]); } if (!empty($menuList)) { $menuList = $this->Html->tag('ul', $menuList, ['class' => 'nav navbar-nav navbar-right']); } Cache::write($cachePath, $menuList, CAKE_THEME_CACHE_KEY_HELPERS); return $menuList; }
php
public function getMenuList($iconList = null) { $activeMenuUrl = $this->_View->get('activeMenuUrl'); $urlInfo = $this->_parseCurrentUrl(); if (!empty($activeMenuUrl) && is_array($activeMenuUrl)) { $urlInfo = $activeMenuUrl + $urlInfo; } $activePatterns = $this->_getActiveMenuPatterns($urlInfo); $deepLevelsActivePattern = $this->_getDeepLevelsActiveMenuPattern(); $activeMenu = []; $menuList = ''; $cachePath = null; if (empty($iconList) || !is_array($iconList)) { return $menuList; } $this->_prepareIconList($iconList); $dataStr = serialize($iconList + $urlInfo) . '_' . $this->_currUIlang; $cachePath = 'MenuList.' . md5($dataStr); $cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS); if (!empty($cached)) { return $cached; } foreach ($iconList as $i => $iconListItem) { for ($activePatternLevel = 0; $activePatternLevel <= $deepLevelsActivePattern; $activePatternLevel++) { if (!$activePatterns[$activePatternLevel]) { continue; } if (preg_match($activePatterns[$activePatternLevel], $iconListItem)) { $activeMenu[$activePatternLevel][] = $i; } } } for ($activePatternLevel = 0; $activePatternLevel <= $deepLevelsActivePattern; $activePatternLevel++) { if (isset($activeMenu[$activePatternLevel]) && !empty($activeMenu[$activePatternLevel])) { break; } } foreach ($iconList as $i => $iconListItem) { $iconListItemClass = null; if (isset($activeMenu[$activePatternLevel]) && in_array($i, $activeMenu[$activePatternLevel])) { $iconListItemClass = 'active'; } $menuList .= $this->Html->tag('li', $iconListItem, ['class' => $iconListItemClass]); } if (!empty($menuList)) { $menuList = $this->Html->tag('ul', $menuList, ['class' => 'nav navbar-nav navbar-right']); } Cache::write($cachePath, $menuList, CAKE_THEME_CACHE_KEY_HELPERS); return $menuList; }
[ "public", "function", "getMenuList", "(", "$", "iconList", "=", "null", ")", "{", "$", "activeMenuUrl", "=", "$", "this", "->", "_View", "->", "get", "(", "'activeMenuUrl'", ")", ";", "$", "urlInfo", "=", "$", "this", "->", "_parseCurrentUrl", "(", ")", ...
Return HTML element of main menu. For mark menu item as active, define view variable `activeMenuUrl` as array with URL contained in this menu item. @param array $iconList Array list of icons for main menu. @return string HTML element of main menu. @link http://getbootstrap.com/components/#navbar
[ "Return", "HTML", "element", "of", "main", "menu", ".", "For", "mark", "menu", "item", "as", "active", "define", "view", "variable", "activeMenuUrl", "as", "array", "with", "URL", "contained", "in", "this", "menu", "item", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L481-L538
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.yesNo
public function yesNo($data = null) { if ((bool)$data) { $result = $this->_getOptionsForElem('yesNo.yes'); } else { $result = $this->_getOptionsForElem('yesNo.no'); } return $result; }
php
public function yesNo($data = null) { if ((bool)$data) { $result = $this->_getOptionsForElem('yesNo.yes'); } else { $result = $this->_getOptionsForElem('yesNo.no'); } return $result; }
[ "public", "function", "yesNo", "(", "$", "data", "=", "null", ")", "{", "if", "(", "(", "bool", ")", "$", "data", ")", "{", "$", "result", "=", "$", "this", "->", "_getOptionsForElem", "(", "'yesNo.yes'", ")", ";", "}", "else", "{", "$", "result", ...
Return text `Yes` or `No` for target data. @param mixed $data Data for checking. @return string Text `Yes` or `No`.
[ "Return", "text", "Yes", "or", "No", "for", "target", "data", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L546-L554
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.popupModalLink
public function popupModalLink($title = null, $url = null, $options = []) { $optionsDefault = $this->_getOptionsForElem('popupModalLink'); return $this->_createLink('modal-popover', $title, $url, $options, $optionsDefault); }
php
public function popupModalLink($title = null, $url = null, $options = []) { $optionsDefault = $this->_getOptionsForElem('popupModalLink'); return $this->_createLink('modal-popover', $title, $url, $options, $optionsDefault); }
[ "public", "function", "popupModalLink", "(", "$", "title", "=", "null", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "optionsDefault", "=", "$", "this", "->", "_getOptionsForElem", "(", "'popupModalLink'", ")", ";", ...
Return popover and modal link. @param string $title The content to be wrapped by `<a>` tags. @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for link element @return string An `<a />` element. @link http://getbootstrap.com/javascript/#popovers, http://getbootstrap.com/javascript/#modals
[ "Return", "popover", "and", "modal", "link", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L612-L616
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.confirmLink
public function confirmLink($title = null, $url = null, $options = []) { $optionsDefault = $this->_getOptionsConfirmLink(); return $this->_createLink(null, $title, $url, $options, $optionsDefault); }
php
public function confirmLink($title = null, $url = null, $options = []) { $optionsDefault = $this->_getOptionsConfirmLink(); return $this->_createLink(null, $title, $url, $options, $optionsDefault); }
[ "public", "function", "confirmLink", "(", "$", "title", "=", "null", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "optionsDefault", "=", "$", "this", "->", "_getOptionsConfirmLink", "(", ")", ";", "return", "$", "t...
Return link with confirmation dialog. @param string $title The content to be wrapped by `<a>` tags. @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for link element @return string An `<a />` element. @link http://bootboxjs.com
[ "Return", "link", "with", "confirmation", "dialog", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L668-L672
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.confirmPostLink
public function confirmPostLink($title = null, $url = null, $options = []) { if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $optionsDefault = $this->_getOptionsConfirmLink(); $optionsDefault['role'] = 'post-link'; return $this->ExtBs3Form->postLink($title, $url, $options + $optionsDefault); }
php
public function confirmPostLink($title = null, $url = null, $options = []) { if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $optionsDefault = $this->_getOptionsConfirmLink(); $optionsDefault['role'] = 'post-link'; return $this->ExtBs3Form->postLink($title, $url, $options + $optionsDefault); }
[ "public", "function", "confirmPostLink", "(", "$", "title", "=", "null", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "options", ")", ")", "{", "$", "options", "=", "[", "]", ";", "}"...
Return link with confirmation dialog used POST request. @param string $title The content to be wrapped by `<a>` tags. @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for link element @return string An `<a />` element. @link http://bootboxjs.com
[ "Return", "link", "with", "confirmation", "dialog", "used", "POST", "request", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L683-L694
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper._createLink
protected function _createLink($toggle = null, $title = null, $url = null, $options = [], $optionsDefault = []) { if (empty($options)) { $options = []; } if (empty($optionsDefault)) { $optionsDefault = []; } if (!empty($toggle)) { $options['data-toggle'] = $toggle; } if (!empty($optionsDefault)) { $options += $optionsDefault; } return $this->Html->link($title, $url, $options); }
php
protected function _createLink($toggle = null, $title = null, $url = null, $options = [], $optionsDefault = []) { if (empty($options)) { $options = []; } if (empty($optionsDefault)) { $optionsDefault = []; } if (!empty($toggle)) { $options['data-toggle'] = $toggle; } if (!empty($optionsDefault)) { $options += $optionsDefault; } return $this->Html->link($title, $url, $options); }
[ "protected", "function", "_createLink", "(", "$", "toggle", "=", "null", ",", "$", "title", "=", "null", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ",", "$", "optionsDefault", "=", "[", "]", ")", "{", "if", "(", "empty", "(...
Return link used with data-toggle attribute. @param string $toggle Value of attribute `data-toggle` for `<a>` tags. @param string $title The content to be wrapped by `<a>` tags. @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array $options Array of options and HTML attributes. @param array $optionsDefault Default HTML options for link element @return string An `<a />` element. @link http://ashleydw.github.io/lightbox
[ "Return", "link", "used", "with", "data", "-", "toggle", "attribute", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L707-L723
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.ajaxLink
public function ajaxLink($title, $url = null, $options = []) { return $this->_createLink('ajax', $title, $url, $options); }
php
public function ajaxLink($title, $url = null, $options = []) { return $this->_createLink('ajax', $title, $url, $options); }
[ "public", "function", "ajaxLink", "(", "$", "title", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_createLink", "(", "'ajax'", ",", "$", "title", ",", "$", "url", ",", "$", "options", "...
Return link used AJAX request. @param string $title The content to be wrapped by `<a>` tags. @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for link element @return string An `<a />` element.
[ "Return", "link", "used", "AJAX", "request", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L733-L735
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.requestOnlyLink
public function requestOnlyLink($title, $url = null, $options = []) { return $this->_createLink('request-only', $title, $url, $options); }
php
public function requestOnlyLink($title, $url = null, $options = []) { return $this->_createLink('request-only', $title, $url, $options); }
[ "public", "function", "requestOnlyLink", "(", "$", "title", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_createLink", "(", "'request-only'", ",", "$", "title", ",", "$", "url", ",", "$", ...
Return link used AJAX request without render result. @param string $title The content to be wrapped by `<a>` tags. @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for link element @return string An `<a />` element.
[ "Return", "link", "used", "AJAX", "request", "without", "render", "result", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L745-L747
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.pjaxLink
public function pjaxLink($title, $url = null, $options = []) { return $this->_createLink('pjax', $title, $url, $options); }
php
public function pjaxLink($title, $url = null, $options = []) { return $this->_createLink('pjax', $title, $url, $options); }
[ "public", "function", "pjaxLink", "(", "$", "title", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_createLink", "(", "'pjax'", ",", "$", "title", ",", "$", "url", ",", "$", "options", "...
Return link used PJAX request. @param string $title The content to be wrapped by `<a>` tags. @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for link element @return string An `<a />` element. @link https://github.com/defunkt/jquery-pjax
[ "Return", "link", "used", "PJAX", "request", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L758-L760
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.lightboxLink
public function lightboxLink($title, $url = null, $options = []) { return $this->_createLink('lightbox', $title, $url, $options); }
php
public function lightboxLink($title, $url = null, $options = []) { return $this->_createLink('lightbox', $title, $url, $options); }
[ "public", "function", "lightboxLink", "(", "$", "title", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_createLink", "(", "'lightbox'", ",", "$", "title", ",", "$", "url", ",", "$", "optio...
Return link used Lightbox for Bootstrap. @param string $title The content to be wrapped by `<a>` tags. @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for link element @return string An `<a />` element. @link http://ashleydw.github.io/lightbox
[ "Return", "link", "used", "Lightbox", "for", "Bootstrap", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L771-L773
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.paginationSortPjax
public function paginationSortPjax($key = null, $title = null, $options = []) { if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $optionsDefault = $this->_getOptionsForElem('paginationSortPjax.linkOpt'); if ($this->request->is('modal')) { $optionsDefault['data-toggle'] = 'modal'; //$optionsDefault['data-disable-use-stack'] = 'true'; } $sortKey = $this->Paginator->sortKey(); if (!empty($sortKey) && ($key === $sortKey)) { $sortDir = $this->Paginator->sortDir(); if ($sortDir === 'asc') { $dirIcon = $this->_getOptionsForElem('paginationSortPjax.iconDir.asc'); } else { $dirIcon = $this->_getOptionsForElem('paginationSortPjax.iconDir.desc'); } $title .= $dirIcon; $options['escape'] = false; } return $this->Paginator->sort($key, $title, $options + $optionsDefault); }
php
public function paginationSortPjax($key = null, $title = null, $options = []) { if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $optionsDefault = $this->_getOptionsForElem('paginationSortPjax.linkOpt'); if ($this->request->is('modal')) { $optionsDefault['data-toggle'] = 'modal'; //$optionsDefault['data-disable-use-stack'] = 'true'; } $sortKey = $this->Paginator->sortKey(); if (!empty($sortKey) && ($key === $sortKey)) { $sortDir = $this->Paginator->sortDir(); if ($sortDir === 'asc') { $dirIcon = $this->_getOptionsForElem('paginationSortPjax.iconDir.asc'); } else { $dirIcon = $this->_getOptionsForElem('paginationSortPjax.iconDir.desc'); } $title .= $dirIcon; $options['escape'] = false; } return $this->Paginator->sort($key, $title, $options + $optionsDefault); }
[ "public", "function", "paginationSortPjax", "(", "$", "key", "=", "null", ",", "$", "title", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "options", ")", ")", "{", "$", "options", "=", "[", "]", ";", ...
Generates a sorting link used PJAX request. Sets named parameters for the sort and direction. Handles direction switching automatically. ### Options: - `escape` Whether you want the contents html entity encoded, defaults to true. - `model` The model to use, defaults to PaginatorHelper::defaultModel(). - `direction` The default direction to use when this link isn't active. - `lock` Lock direction. Will only use the default direction then, defaults to false. @param string $key The name of the key that the recordset should be sorted. @param string $title Title for the link. If $title is null $key will be used for the title and will be generated by inflection. @param array|string $options Options for sorting link. See above for list of keys. @return string A link sorting default by 'asc'. If the resultset is sorted 'asc' by the specified key the returned link will sort by 'desc'. @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::sort, https://github.com/defunkt/jquery-pjax
[ "Generates", "a", "sorting", "link", "used", "PJAX", "request", ".", "Sets", "named", "parameters", "for", "the", "sort", "and", "direction", ".", "Handles", "direction", "switching", "automatically", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L795-L821
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.progressSseLink
public function progressSseLink($title, $url = null, $options = []) { return $this->_createLink('progress-sse', $title, $url, $options); }
php
public function progressSseLink($title, $url = null, $options = []) { return $this->_createLink('progress-sse', $title, $url, $options); }
[ "public", "function", "progressSseLink", "(", "$", "title", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_createLink", "(", "'progress-sse'", ",", "$", "title", ",", "$", "url", ",", "$", ...
Return link used AJAX request and show progress bar of execution task from queue. @param string $title The content to be wrapped by `<a>` tags. @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for link element @return string An `<a />` element. @link http://ricostacruz.com/nprogress
[ "Return", "link", "used", "AJAX", "request", "and", "show", "progress", "bar", "of", "execution", "task", "from", "queue", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L833-L835
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper._getClassForElement
protected function _getClassForElement($elementClass = null) { $elementClass = mb_strtolower((string)$elementClass); $cachePath = 'ClassForElem.' . md5($elementClass); $cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS); if (!empty($cached)) { return $cached; } $result = ''; if (empty($elementClass)) { return $result; } if (mb_strpos($elementClass, 'fa-') !== false) { $elemList = []; $elemPrefixes = $this->_getListIconPrefixes(); $elemPrefix = (string)$this->_config['defaultIconPrefix']; $elemSizes = $this->_getListIconSizes(); $elemSize = (string)$this->_config['defaultIconSize']; } elseif (mb_strpos($elementClass, 'btn-') !== false) { $elemList = $this->_getListButtons(); $elemPrefixes = $this->_getListButtonPrefixes(); $elemPrefix = (string)$this->_config['defaultBtnPrefix']; $elemSizes = $this->_getListButtonSizes(); $elemSize = (string)$this->_config['defaultBtnSize']; } else { return $result; } $aElem = explode(' ', $elementClass, 5); $aClass = []; foreach ($aElem as $elemItem) { if (empty($elemItem)) { continue; } if (in_array($elemItem, $elemSizes)) { $elemSize = $elemItem; } elseif (in_array($elemItem, $elemPrefixes)) { $elemPrefix = $elemItem; } elseif (empty($elemList) || (!empty($elemList) && in_array($elemItem, $elemList))) { $aClass[] = $elemItem; } } if (!empty($elemList) && empty($aClass)) { return $result; } if (!empty($elemPrefix)) { array_unshift($aClass, $elemPrefix); } if (!empty($elemSize)) { array_push($aClass, $elemSize); } $aClass = array_unique($aClass); $result = implode(' ', $aClass); Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS); return $result; }
php
protected function _getClassForElement($elementClass = null) { $elementClass = mb_strtolower((string)$elementClass); $cachePath = 'ClassForElem.' . md5($elementClass); $cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS); if (!empty($cached)) { return $cached; } $result = ''; if (empty($elementClass)) { return $result; } if (mb_strpos($elementClass, 'fa-') !== false) { $elemList = []; $elemPrefixes = $this->_getListIconPrefixes(); $elemPrefix = (string)$this->_config['defaultIconPrefix']; $elemSizes = $this->_getListIconSizes(); $elemSize = (string)$this->_config['defaultIconSize']; } elseif (mb_strpos($elementClass, 'btn-') !== false) { $elemList = $this->_getListButtons(); $elemPrefixes = $this->_getListButtonPrefixes(); $elemPrefix = (string)$this->_config['defaultBtnPrefix']; $elemSizes = $this->_getListButtonSizes(); $elemSize = (string)$this->_config['defaultBtnSize']; } else { return $result; } $aElem = explode(' ', $elementClass, 5); $aClass = []; foreach ($aElem as $elemItem) { if (empty($elemItem)) { continue; } if (in_array($elemItem, $elemSizes)) { $elemSize = $elemItem; } elseif (in_array($elemItem, $elemPrefixes)) { $elemPrefix = $elemItem; } elseif (empty($elemList) || (!empty($elemList) && in_array($elemItem, $elemList))) { $aClass[] = $elemItem; } } if (!empty($elemList) && empty($aClass)) { return $result; } if (!empty($elemPrefix)) { array_unshift($aClass, $elemPrefix); } if (!empty($elemSize)) { array_push($aClass, $elemSize); } $aClass = array_unique($aClass); $result = implode(' ', $aClass); Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS); return $result; }
[ "protected", "function", "_getClassForElement", "(", "$", "elementClass", "=", "null", ")", "{", "$", "elementClass", "=", "mb_strtolower", "(", "(", "string", ")", "$", "elementClass", ")", ";", "$", "cachePath", "=", "'ClassForElem.'", ".", "md5", "(", "$"...
Return class name for icon or button. Exclude base class `fa` or `btn`, and add class of size, if need. @param string $elementClass Class of target element. @return string Class name for icon or button.
[ "Return", "class", "name", "for", "icon", "or", "button", ".", "Exclude", "base", "class", "fa", "or", "btn", "and", "add", "class", "of", "size", "if", "need", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L935-L993
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.getBtnClass
public function getBtnClass($btn = null) { $btnClass = $this->_getClassForElement($btn); if (!empty($btnClass)) { $result = $btnClass; } else { $result = $this->_getClassForElement('btn-default'); } return $result; }
php
public function getBtnClass($btn = null) { $btnClass = $this->_getClassForElement($btn); if (!empty($btnClass)) { $result = $btnClass; } else { $result = $this->_getClassForElement('btn-default'); } return $result; }
[ "public", "function", "getBtnClass", "(", "$", "btn", "=", "null", ")", "{", "$", "btnClass", "=", "$", "this", "->", "_getClassForElement", "(", "$", "btn", ")", ";", "if", "(", "!", "empty", "(", "$", "btnClass", ")", ")", "{", "$", "result", "="...
Return class for button element @param string $btn class of button for process @return string Class for button element @link http://getbootstrap.com/css/#buttons
[ "Return", "class", "for", "button", "element" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1045-L1054
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.iconTag
public function iconTag($icon = null, $options = []) { $icon = mb_strtolower((string)$icon); $dataStr = serialize(compact('icon', 'options')) . '_' . $this->_currUIlang; $cachePath = 'iconTag.' . md5($dataStr); $cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS); if (!empty($cached)) { return $cached; } $result = ''; if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $iconClass = $this->_getClassForElement($icon); if (empty($iconClass)) { return $result; } $options['class'] = $iconClass; $result = $this->Html->tag('span', '', $options); Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS); return $result; }
php
public function iconTag($icon = null, $options = []) { $icon = mb_strtolower((string)$icon); $dataStr = serialize(compact('icon', 'options')) . '_' . $this->_currUIlang; $cachePath = 'iconTag.' . md5($dataStr); $cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS); if (!empty($cached)) { return $cached; } $result = ''; if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $iconClass = $this->_getClassForElement($icon); if (empty($iconClass)) { return $result; } $options['class'] = $iconClass; $result = $this->Html->tag('span', '', $options); Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS); return $result; }
[ "public", "function", "iconTag", "(", "$", "icon", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "icon", "=", "mb_strtolower", "(", "(", "string", ")", "$", "icon", ")", ";", "$", "dataStr", "=", "serialize", "(", "compact", "(", ...
Return HTML element of icon @param string $icon class of icon @param array|string $options HTML options for icon element @return string HTML element of icon @link http://fontawesome.io
[ "Return", "HTML", "element", "of", "icon" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1064-L1090
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.buttonLink
public function buttonLink($icon = null, $btn = null, $url = null, $options = []) { $result = ''; if (empty($icon)) { return $result; } $title = ''; if ($icon === strip_tags($icon)) { if ($this->_getClassForElement($icon)) { $icon .= ' fa-fw'; } $title = $this->iconTag($icon); } if (empty($title)) { $title = $icon; } $button = $this->getBtnClass($btn); if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $options['class'] = $button . (isset($options['class']) ? ' ' . $options['class'] : ''); $optionsDefault = [ 'escape' => false, ]; if (isset($options['title'])) { $optionsDefault['data-toggle'] = 'title'; } $postLink = $this->_processActionTypeOpt($options); if ($postLink) { if (!isset($options['block'])) { $options['block'] = 'confirm-form'; } $result = $this->ExtBs3Form->postLink($title, $url, $options + $optionsDefault); } else { $result = $this->Html->link($title, $url, $options + $optionsDefault); } return $result; }
php
public function buttonLink($icon = null, $btn = null, $url = null, $options = []) { $result = ''; if (empty($icon)) { return $result; } $title = ''; if ($icon === strip_tags($icon)) { if ($this->_getClassForElement($icon)) { $icon .= ' fa-fw'; } $title = $this->iconTag($icon); } if (empty($title)) { $title = $icon; } $button = $this->getBtnClass($btn); if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $options['class'] = $button . (isset($options['class']) ? ' ' . $options['class'] : ''); $optionsDefault = [ 'escape' => false, ]; if (isset($options['title'])) { $optionsDefault['data-toggle'] = 'title'; } $postLink = $this->_processActionTypeOpt($options); if ($postLink) { if (!isset($options['block'])) { $options['block'] = 'confirm-form'; } $result = $this->ExtBs3Form->postLink($title, $url, $options + $optionsDefault); } else { $result = $this->Html->link($title, $url, $options + $optionsDefault); } return $result; }
[ "public", "function", "buttonLink", "(", "$", "icon", "=", "null", ",", "$", "btn", "=", "null", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "result", "=", "''", ";", "if", "(", "empty", "(", "$", "icon", ...
Return HTML element of button by link @param string $icon class of icon @param string $btn class of button @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for button element List of values option `action-type`: - `confirm`: create link with confirmation action; - `confirm-post`: create link with confirmation action and POST request; - `post`: create link with POST request; - `modal`: create link with opening result in modal window. @return string HTML element of button. @link http://fontawesome.io, http://getbootstrap.com/css/#buttons
[ "Return", "HTML", "element", "of", "button", "by", "link" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1109-L1152
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.button
public function button($icon = null, $btn = null, $options = []) { $result = ''; if (empty($icon)) { return $result; } $title = ''; if ($icon === strip_tags($icon)) { if ($this->_getClassForElement($icon)) { $icon .= ' fa-fw'; } $title = $this->iconTag($icon); } if (empty($title)) { $title = $icon; } $button = $this->getBtnClass($btn); if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $options['class'] = $button . (isset($options['class']) ? ' ' . $options['class'] : ''); $optionsDefault = [ 'escape' => false, 'type' => 'button', ]; if (isset($options['title'])) { $optionsDefault['data-toggle'] = 'title'; } $result = $this->ExtBs3Form->button($title, $options + $optionsDefault); return $result; }
php
public function button($icon = null, $btn = null, $options = []) { $result = ''; if (empty($icon)) { return $result; } $title = ''; if ($icon === strip_tags($icon)) { if ($this->_getClassForElement($icon)) { $icon .= ' fa-fw'; } $title = $this->iconTag($icon); } if (empty($title)) { $title = $icon; } $button = $this->getBtnClass($btn); if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $options['class'] = $button . (isset($options['class']) ? ' ' . $options['class'] : ''); $optionsDefault = [ 'escape' => false, 'type' => 'button', ]; if (isset($options['title'])) { $optionsDefault['data-toggle'] = 'title'; } $result = $this->ExtBs3Form->button($title, $options + $optionsDefault); return $result; }
[ "public", "function", "button", "(", "$", "icon", "=", "null", ",", "$", "btn", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "result", "=", "''", ";", "if", "(", "empty", "(", "$", "icon", ")", ")", "{", "return", "$", "res...
Return HTML element of button @param string $icon class of icon @param string $btn class of button @param array|string $options HTML options for button element @return string HTML element of button. @link http://fontawesome.io, http://getbootstrap.com/css/#buttons
[ "Return", "HTML", "element", "of", "button" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1164-L1199
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.addUserPrefixUrl
public function addUserPrefixUrl($url = null) { if (empty($url)) { return $url; } $userPrefix = $this->Session->read('Auth.User.prefix'); if (empty($userPrefix)) { return $url; } if (!is_array($url)) { if (($url === '/') || (stripos($url, '/') === false)) { return $url; } $url = Router::parse($url); } if (isset($url['prefix']) && ($url['prefix'] === false)) { $url[$userPrefix] = false; if (isset($url['prefix'])) { unset($url['prefix']); } return $url; } $url[$userPrefix] = true; return $url; }
php
public function addUserPrefixUrl($url = null) { if (empty($url)) { return $url; } $userPrefix = $this->Session->read('Auth.User.prefix'); if (empty($userPrefix)) { return $url; } if (!is_array($url)) { if (($url === '/') || (stripos($url, '/') === false)) { return $url; } $url = Router::parse($url); } if (isset($url['prefix']) && ($url['prefix'] === false)) { $url[$userPrefix] = false; if (isset($url['prefix'])) { unset($url['prefix']); } return $url; } $url[$userPrefix] = true; return $url; }
[ "public", "function", "addUserPrefixUrl", "(", "$", "url", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "url", ")", ")", "{", "return", "$", "url", ";", "}", "$", "userPrefix", "=", "$", "this", "->", "Session", "->", "read", "(", "'Auth.Us...
Return URL with user role prefix For disable use user prefix, add to url array key `prefix` with value `false`. @param array|string $url URL for adding prefix @return array|string Return URL with user role prefix
[ "Return", "URL", "with", "user", "role", "prefix", "For", "disable", "use", "user", "prefix", "add", "to", "url", "array", "key", "prefix", "with", "value", "false", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1209-L1238
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.menuItemLabel
public function menuItemLabel($title = null) { $result = ''; if (empty($title)) { return $result; } $result = $this->Html->tag('span', $title, ['class' => 'menu-item-label visible-xs-inline']); return $result; }
php
public function menuItemLabel($title = null) { $result = ''; if (empty($title)) { return $result; } $result = $this->Html->tag('span', $title, ['class' => 'menu-item-label visible-xs-inline']); return $result; }
[ "public", "function", "menuItemLabel", "(", "$", "title", "=", "null", ")", "{", "$", "result", "=", "''", ";", "if", "(", "empty", "(", "$", "title", ")", ")", "{", "return", "$", "result", ";", "}", "$", "result", "=", "$", "this", "->", "Html"...
Return HTML element of menu item label @param string $title Title of menu label @return string HTML element of menu item label
[ "Return", "HTML", "element", "of", "menu", "item", "label" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1246-L1255
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.menuItemLink
public function menuItemLink($icon = null, $title = null, $url = null, $options = [], $badgeNumber = 0) { $result = ''; if (empty($icon) || empty($title)) { return $result; } $caret = ''; if (empty($options) || !is_array($options)) { $options = []; } $options['escape'] = false; $options['title'] = $title; $badgeNumber = (int)$badgeNumber; if (empty($url)) { $url = '#'; $caret = $this->Html->tag('span', '', ['class' => 'caret']); $options += [ 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'role' => 'button', 'aria-haspopup' => 'true', 'aria-expanded' => 'false' ]; } else { $url = $this->addUserPrefixUrl($url); } if ($this->_getClassForElement($icon)) { $icon .= ' fa-fw'; } $iconTag = $this->iconTag($icon) . $this->menuItemLabel($title) . $caret; if ($badgeNumber > 0) { $iconTag .= '&nbsp;' . $this->Html->tag('span', $this->Number->format( $badgeNumber, ['thousands' => ' ', 'before' => '', 'places' => 0] ), ['class' => 'badge']); } if (!isset($options['data-toggle'])) { $options['data-toggle'] = 'tooltip'; } $result = $this->Html->link( $iconTag, $url, $options ); return $result; }
php
public function menuItemLink($icon = null, $title = null, $url = null, $options = [], $badgeNumber = 0) { $result = ''; if (empty($icon) || empty($title)) { return $result; } $caret = ''; if (empty($options) || !is_array($options)) { $options = []; } $options['escape'] = false; $options['title'] = $title; $badgeNumber = (int)$badgeNumber; if (empty($url)) { $url = '#'; $caret = $this->Html->tag('span', '', ['class' => 'caret']); $options += [ 'class' => 'dropdown-toggle', 'data-toggle' => 'dropdown', 'role' => 'button', 'aria-haspopup' => 'true', 'aria-expanded' => 'false' ]; } else { $url = $this->addUserPrefixUrl($url); } if ($this->_getClassForElement($icon)) { $icon .= ' fa-fw'; } $iconTag = $this->iconTag($icon) . $this->menuItemLabel($title) . $caret; if ($badgeNumber > 0) { $iconTag .= '&nbsp;' . $this->Html->tag('span', $this->Number->format( $badgeNumber, ['thousands' => ' ', 'before' => '', 'places' => 0] ), ['class' => 'badge']); } if (!isset($options['data-toggle'])) { $options['data-toggle'] = 'tooltip'; } $result = $this->Html->link( $iconTag, $url, $options ); return $result; }
[ "public", "function", "menuItemLink", "(", "$", "icon", "=", "null", ",", "$", "title", "=", "null", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ",", "$", "badgeNumber", "=", "0", ")", "{", "$", "result", "=", "''", ";", "...
Return HTML element of menu item @param string $icon class of icon @param string $title Title of menu label @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for button element @param int $badgeNumber The number for display to the right of the menu item @return string HTML element of menu item @link http://getbootstrap.com/components/#navbar, http://fontawesome.io, http://getbootstrap.com/css/#buttons
[ "Return", "HTML", "element", "of", "menu", "item" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1270-L1317
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.menuActionLink
public function menuActionLink($icon = null, $titleText = null, $url = null, $options = []) { $result = ''; if (empty($icon)) { return $result; } if ($this->_getClassForElement($icon)) { $icon .= ' fa-fw'; } $iconClass = $this->_getClassForElement($icon); if (empty($iconClass)) { return $result; } $title = $this->Html->tag('span', '', ['class' => $iconClass]); if (!empty($titleText)) { $title .= $this->Html->tag('span', $titleText, ['class' => 'menu-item-label']); } if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $optionsDefault = [ 'escape' => false, ]; if (isset($options['title'])) { $optionsDefault['data-toggle'] = 'title'; } $url = $this->addUserPrefixUrl($url); $postLink = $this->_processActionTypeOpt($options); if ($postLink) { $result = $this->ExtBs3Form->postLink($title, $url, $options + $optionsDefault); } else { $result = $this->Html->link($title, $url, $options + $optionsDefault); } return $result; }
php
public function menuActionLink($icon = null, $titleText = null, $url = null, $options = []) { $result = ''; if (empty($icon)) { return $result; } if ($this->_getClassForElement($icon)) { $icon .= ' fa-fw'; } $iconClass = $this->_getClassForElement($icon); if (empty($iconClass)) { return $result; } $title = $this->Html->tag('span', '', ['class' => $iconClass]); if (!empty($titleText)) { $title .= $this->Html->tag('span', $titleText, ['class' => 'menu-item-label']); } if (empty($options)) { $options = []; } elseif (!is_array($options)) { $options = [$options]; } $optionsDefault = [ 'escape' => false, ]; if (isset($options['title'])) { $optionsDefault['data-toggle'] = 'title'; } $url = $this->addUserPrefixUrl($url); $postLink = $this->_processActionTypeOpt($options); if ($postLink) { $result = $this->ExtBs3Form->postLink($title, $url, $options + $optionsDefault); } else { $result = $this->Html->link($title, $url, $options + $optionsDefault); } return $result; }
[ "public", "function", "menuActionLink", "(", "$", "icon", "=", "null", ",", "$", "titleText", "=", "null", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "result", "=", "''", ";", "if", "(", "empty", "(", "$", ...
Return HTML element of item for page header menu @param string $icon class of icon @param string $titleText Title of menu label @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array|string $options HTML options for button element List of values option `action-type`: - `confirm`: create link with confirmation action; - `confirm-post`: create link with confirmation action and POST request; - `post`: create link with POST request; - `modal`: create link with opening result in modal window. @return string HTML element of item for page header menu @link http://fontawesome.io
[ "Return", "HTML", "element", "of", "item", "for", "page", "header", "menu" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1335-L1376
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.timeAgo
public function timeAgo($time = null, $format = null) { if (empty($time)) { $time = time(); } if (empty($format)) { $format = '%x %X'; } $result = $this->Html->tag( 'time', $this->Time->i18nFormat($time, $format), [ 'data-toggle' => 'timeago', 'datetime' => date('c', $this->Time->fromString($time)), 'class' => 'help' ] ); return $result; }
php
public function timeAgo($time = null, $format = null) { if (empty($time)) { $time = time(); } if (empty($format)) { $format = '%x %X'; } $result = $this->Html->tag( 'time', $this->Time->i18nFormat($time, $format), [ 'data-toggle' => 'timeago', 'datetime' => date('c', $this->Time->fromString($time)), 'class' => 'help' ] ); return $result; }
[ "public", "function", "timeAgo", "(", "$", "time", "=", "null", ",", "$", "format", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "time", ")", ")", "{", "$", "time", "=", "time", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "forma...
Return HTML element of time ago @param int|string|DateTime $time UNIX timestamp, strtotime() valid string or DateTime object @param string $format strftime format string @return string HTML element of time ago @link http://timeago.yarp.com
[ "Return", "HTML", "element", "of", "time", "ago" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1387-L1406
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.getIconForExtension
public function getIconForExtension($extension = null) { $extension = mb_strtolower((string)$extension); $cachePath = 'IconForExtension.' . md5($extension); $cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS); if (!empty($cached)) { return $cached; } $result = 'far fa-file'; if (empty($extension)) { Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS); return $result; } $extensions = [ 'far fa-file-archive' => ['zip', 'rar', '7z'], 'far fa-file-word' => ['doc', 'docx'], 'far fa-file-code' => ['htm', 'html', 'xml', 'js'], 'far fa-file-image' => ['jpg', 'jpeg', 'png', 'gif'], 'far fa-file-pdf' => ['pdf'], 'far fa-file-video' => ['avi', 'mp4'], 'far fa-file-powerpoint' => ['ppt', 'pptx'], 'far fa-file-audio' => ['mp3', 'wav', 'flac'], 'far fa-file-excel' => ['xls', 'xlsx'], 'far fa-file-alt' => ['txt'], ]; foreach ($extensions as $icon => $extensionsList) { if (in_array($extension, $extensionsList)) { $result = $icon; break; } } Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS); return $result; }
php
public function getIconForExtension($extension = null) { $extension = mb_strtolower((string)$extension); $cachePath = 'IconForExtension.' . md5($extension); $cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_HELPERS); if (!empty($cached)) { return $cached; } $result = 'far fa-file'; if (empty($extension)) { Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS); return $result; } $extensions = [ 'far fa-file-archive' => ['zip', 'rar', '7z'], 'far fa-file-word' => ['doc', 'docx'], 'far fa-file-code' => ['htm', 'html', 'xml', 'js'], 'far fa-file-image' => ['jpg', 'jpeg', 'png', 'gif'], 'far fa-file-pdf' => ['pdf'], 'far fa-file-video' => ['avi', 'mp4'], 'far fa-file-powerpoint' => ['ppt', 'pptx'], 'far fa-file-audio' => ['mp3', 'wav', 'flac'], 'far fa-file-excel' => ['xls', 'xlsx'], 'far fa-file-alt' => ['txt'], ]; foreach ($extensions as $icon => $extensionsList) { if (in_array($extension, $extensionsList)) { $result = $icon; break; } } Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_HELPERS); return $result; }
[ "public", "function", "getIconForExtension", "(", "$", "extension", "=", "null", ")", "{", "$", "extension", "=", "mb_strtolower", "(", "(", "string", ")", "$", "extension", ")", ";", "$", "cachePath", "=", "'IconForExtension.'", ".", "md5", "(", "$", "ext...
Return icon for file from extension. @param string $extension Extension of file @return string Icon for file. @link http://fontawesome.io
[ "Return", "icon", "for", "file", "from", "extension", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1415-L1452
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.truncateText
public function truncateText($text = null, $length = 0) { $result = ''; if (empty($text)) { return $result; } $text = (string)$text; $length = (int)$length; if ($length <= 0) { $length = 50; } if (($text === h($text)) && (mb_strlen($text) <= $length)) { return $text; } $truncateOpt = $this->_getOptionsForElem('truncateText.truncateOpt'); $tuncatedText = $this->Text->truncate($text, $length, $truncateOpt); if ($tuncatedText === $text) { return $tuncatedText; } $result = $this->Html->div('collapse-text-truncated', $tuncatedText); $result .= $this->Html->div( 'collapse-text-original', $text . $this->_getOptionsForElem('truncateText.collapseLink') ); $result = $this->Html->div('collapse-text-expanded', $result); return $result; }
php
public function truncateText($text = null, $length = 0) { $result = ''; if (empty($text)) { return $result; } $text = (string)$text; $length = (int)$length; if ($length <= 0) { $length = 50; } if (($text === h($text)) && (mb_strlen($text) <= $length)) { return $text; } $truncateOpt = $this->_getOptionsForElem('truncateText.truncateOpt'); $tuncatedText = $this->Text->truncate($text, $length, $truncateOpt); if ($tuncatedText === $text) { return $tuncatedText; } $result = $this->Html->div('collapse-text-truncated', $tuncatedText); $result .= $this->Html->div( 'collapse-text-original', $text . $this->_getOptionsForElem('truncateText.collapseLink') ); $result = $this->Html->div('collapse-text-expanded', $result); return $result; }
[ "public", "function", "truncateText", "(", "$", "text", "=", "null", ",", "$", "length", "=", "0", ")", "{", "$", "result", "=", "''", ";", "if", "(", "empty", "(", "$", "text", ")", ")", "{", "return", "$", "result", ";", "}", "$", "text", "="...
Return truncated text with button `expand` and `roll up`. @param string $text Text to truncate. @param int $length Length of returned string. @return string Truncated text.
[ "Return", "truncated", "text", "with", "button", "expand", "and", "roll", "up", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1461-L1491
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.getFormOptions
public function getFormOptions($options = []) { if (empty($options) || !is_array($options)) { $options = []; } $optionsDefault = $this->_getOptionsForElem('form'); $result = $optionsDefault + $options; return $result; }
php
public function getFormOptions($options = []) { if (empty($options) || !is_array($options)) { $options = []; } $optionsDefault = $this->_getOptionsForElem('form'); $result = $optionsDefault + $options; return $result; }
[ "public", "function", "getFormOptions", "(", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "options", ")", "||", "!", "is_array", "(", "$", "options", ")", ")", "{", "$", "options", "=", "[", "]", ";", "}", "$", "optionsD...
Return array of options for HTML Form element. @param array $options HTML options for Form element @return array Return array of options.
[ "Return", "array", "of", "options", "for", "HTML", "Form", "element", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1499-L1508
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper._getLangForNumberText
protected function _getLangForNumberText($langCode = null) { if (!is_object($this->_NumberTextLib)) { return false; } $cachePath = 'lang_code_number_lib_' . md5(serialize(func_get_args())); $cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_LANG_CODE); if (!empty($cached)) { return $cached; } $langNumb = $this->_Language->getLangForNumberText($langCode); $result = $this->_NumberTextLib->setLang($langNumb); Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_LANG_CODE); return $result; }
php
protected function _getLangForNumberText($langCode = null) { if (!is_object($this->_NumberTextLib)) { return false; } $cachePath = 'lang_code_number_lib_' . md5(serialize(func_get_args())); $cached = Cache::read($cachePath, CAKE_THEME_CACHE_KEY_LANG_CODE); if (!empty($cached)) { return $cached; } $langNumb = $this->_Language->getLangForNumberText($langCode); $result = $this->_NumberTextLib->setLang($langNumb); Cache::write($cachePath, $result, CAKE_THEME_CACHE_KEY_LANG_CODE); return $result; }
[ "protected", "function", "_getLangForNumberText", "(", "$", "langCode", "=", "null", ")", "{", "if", "(", "!", "is_object", "(", "$", "this", "->", "_NumberTextLib", ")", ")", "{", "return", "false", ";", "}", "$", "cachePath", "=", "'lang_code_number_lib_'"...
Return language name for library Tools.NumberText. @param string $langCode Languge code in format `ISO 639-1` or `ISO 639-2` @return string|bool Return language name in format RFC5646, or False on failure. @link http://numbertext.org/ Universal number to text conversion languag
[ "Return", "language", "name", "for", "library", "Tools", ".", "NumberText", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1517-L1532
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.numberText
public function numberText($number = null, $langCode = null) { if (!is_object($this->_NumberTextLib)) { return false; } $langNumb = $this->_getLangForNumberText($langCode); return $this->_NumberTextLib->numberText($number, $langNumb); }
php
public function numberText($number = null, $langCode = null) { if (!is_object($this->_NumberTextLib)) { return false; } $langNumb = $this->_getLangForNumberText($langCode); return $this->_NumberTextLib->numberText($number, $langNumb); }
[ "public", "function", "numberText", "(", "$", "number", "=", "null", ",", "$", "langCode", "=", "null", ")", "{", "if", "(", "!", "is_object", "(", "$", "this", "->", "_NumberTextLib", ")", ")", "{", "return", "false", ";", "}", "$", "langNumb", "=",...
Return number as text. @param string $number Number for processing @param string $langCode Languge code in format `ISO 639-1` or `ISO 639-2` @return string|bool Return number as text, or False on failure.
[ "Return", "number", "as", "text", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1541-L1548
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.barState
public function barState($stateData = null) { $result = ''; if (!is_array($stateData)) { $stateData = []; } if (empty($stateData)) { $stateData = [ [ 'stateName' => $this->showEmpty(null), 'stateId' => null, 'amount' => 0, 'stateUrl' => null, ] ]; } $totalAmount = Hash::apply($stateData, '{n}.amount', 'array_sum'); $percSum = 0; $countState = count($stateData); foreach ($stateData as $i => $stateItem) { $class = 'progress-bar'; if (isset($stateItem['class']) && !empty($stateItem['class'])) { $class .= ' ' . $stateItem['class']; } if ($totalAmount > 0) { $perc = round($stateItem['amount'] / $totalAmount * 100, 2); } else { $perc = 100; } $percRound = round($perc); if ($percSum + $percRound > 100) { $percRound = 100 - $percSum; } else { if ($i == $countState - 1) { $percRound = 100 - $percSum; } } $percSum += $percRound; $stateName = $stateItem['stateName']; $progressBar = $this->Html->div( $class, $stateName, ['role' => 'progressbar', 'style' => 'width:' . $percRound . '%', 'title' => $stateName . ': ' . $this->Number->format( $stateItem['amount'], ['thousands' => ' ', 'before' => '', 'places' => 0] ) . ' (' . $perc . '%)', 'data-toggle' => 'tooltip'] ); if (isset($stateItem['stateUrl']) && !empty($stateItem['stateUrl'])) { $progressBar = $this->Html->link( $progressBar, $stateItem['stateUrl'], ['target' => '_blank', 'escape' => false] ); } $result .= $progressBar; } $result = $this->Html->div('progress', $result); return $result; }
php
public function barState($stateData = null) { $result = ''; if (!is_array($stateData)) { $stateData = []; } if (empty($stateData)) { $stateData = [ [ 'stateName' => $this->showEmpty(null), 'stateId' => null, 'amount' => 0, 'stateUrl' => null, ] ]; } $totalAmount = Hash::apply($stateData, '{n}.amount', 'array_sum'); $percSum = 0; $countState = count($stateData); foreach ($stateData as $i => $stateItem) { $class = 'progress-bar'; if (isset($stateItem['class']) && !empty($stateItem['class'])) { $class .= ' ' . $stateItem['class']; } if ($totalAmount > 0) { $perc = round($stateItem['amount'] / $totalAmount * 100, 2); } else { $perc = 100; } $percRound = round($perc); if ($percSum + $percRound > 100) { $percRound = 100 - $percSum; } else { if ($i == $countState - 1) { $percRound = 100 - $percSum; } } $percSum += $percRound; $stateName = $stateItem['stateName']; $progressBar = $this->Html->div( $class, $stateName, ['role' => 'progressbar', 'style' => 'width:' . $percRound . '%', 'title' => $stateName . ': ' . $this->Number->format( $stateItem['amount'], ['thousands' => ' ', 'before' => '', 'places' => 0] ) . ' (' . $perc . '%)', 'data-toggle' => 'tooltip'] ); if (isset($stateItem['stateUrl']) && !empty($stateItem['stateUrl'])) { $progressBar = $this->Html->link( $progressBar, $stateItem['stateUrl'], ['target' => '_blank', 'escape' => false] ); } $result .= $progressBar; } $result = $this->Html->div('progress', $result); return $result; }
[ "public", "function", "barState", "(", "$", "stateData", "=", "null", ")", "{", "$", "result", "=", "''", ";", "if", "(", "!", "is_array", "(", "$", "stateData", ")", ")", "{", "$", "stateData", "=", "[", "]", ";", "}", "if", "(", "empty", "(", ...
Return bar of state. @param array $stateData Array of state in format: - key `stateName`, value: name of state; - key `stateId`, value: ID of state; - key `amount`, value: amount elements in this state; - key `stateUrl`, value: url for state, e.g.: array('controller' => 'trips', 'action' => 'index', '?' => array('data[FilterData][0][Trip][state_id]' => '2')) [Not necessary]; - key `class`: ID of state, value: class of state for progress bar, e.g.: 'progress-bar-danger progress-bar-striped' [Not necessary]. @return string Return bar of state.
[ "Return", "bar", "of", "state", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1563-L1626
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.listLastInfo
public function listLastInfo($lastInfo = null, $labelList = null, $controllerName = null, $actionName = null, $linkOptions = [], $length = 0) { if (!is_array($lastInfo)) { $lastInfo = []; } if (empty($labelList) && !empty($controllerName)) { $labelList = Inflector::humanize(Inflector::underscore($controllerName)); } if (empty($actionName)) { $actionName = 'view'; } $lastInfoList = ''; if (!empty($labelList)) { $lastInfoList .= $this->Html->tag('dt', $labelList . ':'); } if (!empty($lastInfo)) { $lastInfoListData = []; foreach ($lastInfo as $lastInfoItem) { $label = $this->truncateText(h($lastInfoItem['label']), $length); if (!empty($controllerName) && !empty($lastInfoItem['id'])) { $url = $this->addUserPrefixUrl(['controller' => $controllerName, 'action' => $actionName, $lastInfoItem['id']]); $label = $this->popupModalLink($label, $url, $linkOptions); } $lastInfoListData[] = $label . ' (' . $this->timeAgo($lastInfoItem['modified']) . ')'; } $lastInfoListItem = $this->Html->nestedList($lastInfoListData, null, null, 'ol'); } else { $lastInfoListItem = $this->showEmpty(null); } $lastInfoList .= $this->Html->tag('dd', $lastInfoListItem); $result = $this->Html->tag('dl', $lastInfoList, ['class' => 'dl-horizontal']); return $result; }
php
public function listLastInfo($lastInfo = null, $labelList = null, $controllerName = null, $actionName = null, $linkOptions = [], $length = 0) { if (!is_array($lastInfo)) { $lastInfo = []; } if (empty($labelList) && !empty($controllerName)) { $labelList = Inflector::humanize(Inflector::underscore($controllerName)); } if (empty($actionName)) { $actionName = 'view'; } $lastInfoList = ''; if (!empty($labelList)) { $lastInfoList .= $this->Html->tag('dt', $labelList . ':'); } if (!empty($lastInfo)) { $lastInfoListData = []; foreach ($lastInfo as $lastInfoItem) { $label = $this->truncateText(h($lastInfoItem['label']), $length); if (!empty($controllerName) && !empty($lastInfoItem['id'])) { $url = $this->addUserPrefixUrl(['controller' => $controllerName, 'action' => $actionName, $lastInfoItem['id']]); $label = $this->popupModalLink($label, $url, $linkOptions); } $lastInfoListData[] = $label . ' (' . $this->timeAgo($lastInfoItem['modified']) . ')'; } $lastInfoListItem = $this->Html->nestedList($lastInfoListData, null, null, 'ol'); } else { $lastInfoListItem = $this->showEmpty(null); } $lastInfoList .= $this->Html->tag('dd', $lastInfoListItem); $result = $this->Html->tag('dl', $lastInfoList, ['class' => 'dl-horizontal']); return $result; }
[ "public", "function", "listLastInfo", "(", "$", "lastInfo", "=", "null", ",", "$", "labelList", "=", "null", ",", "$", "controllerName", "=", "null", ",", "$", "actionName", "=", "null", ",", "$", "linkOptions", "=", "[", "]", ",", "$", "length", "=", ...
Return list of last changed data. @param array $lastInfo Array of last information in format: - key `label`, value: label of list item; - key `modified`, value: date and time of last modification; - key `id`, value: ID of record. @param string $labelList Label of list. @param string $controllerName Name of controller for viewing. @param string $actionName Name of controller action for viewing. @param array|string $linkOptions HTML options for link element. @param int $length Length of list item label string. @return string Return list of last changed data.
[ "Return", "list", "of", "last", "changed", "data", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1642-L1678
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.buttonsMove
public function buttonsMove($url = null, $useDrag = true, $glue = '', $useGroup = false) { $result = ''; if (empty($url) || !is_array($url)) { return $result; } $actions = []; if ($useDrag) { $actions[] = $this->_getOptionsForElem('buttonsMove.btnDrag'); } $buttons = $this->_getOptionsForElem('buttonsMove.btnsMove'); foreach ($buttons as $button) { $actions[] = $this->buttonLink( $button['icon'], 'btn-info', array_merge($button['url'], $url), ['title' => $button['title'], 'data-toggle' => 'move'] ); } $result = implode($glue, $actions); if (empty($glue) && $useGroup) { $result = $this->Html->div('btn-group', $result, ['role' => 'group']); } return $result; }
php
public function buttonsMove($url = null, $useDrag = true, $glue = '', $useGroup = false) { $result = ''; if (empty($url) || !is_array($url)) { return $result; } $actions = []; if ($useDrag) { $actions[] = $this->_getOptionsForElem('buttonsMove.btnDrag'); } $buttons = $this->_getOptionsForElem('buttonsMove.btnsMove'); foreach ($buttons as $button) { $actions[] = $this->buttonLink( $button['icon'], 'btn-info', array_merge($button['url'], $url), ['title' => $button['title'], 'data-toggle' => 'move'] ); } $result = implode($glue, $actions); if (empty($glue) && $useGroup) { $result = $this->Html->div('btn-group', $result, ['role' => 'group']); } return $result; }
[ "public", "function", "buttonsMove", "(", "$", "url", "=", "null", ",", "$", "useDrag", "=", "true", ",", "$", "glue", "=", "''", ",", "$", "useGroup", "=", "false", ")", "{", "$", "result", "=", "''", ";", "if", "(", "empty", "(", "$", "url", ...
Return buttons for moving items. @param array $url Base url for moving items @param bool $useDrag If True, add button `Drag` @param string $glue String as glue for buttons @param bool $useGroup If True and empty $glue, use group buttons. @return string Return buttons for moving items. @see MoveComponent::moveItem() @see MoveComponent::dropItem()
[ "Return", "buttons", "for", "moving", "items", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1858-L1883
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.buttonLoadMore
public function buttonLoadMore($targetSelector = null) { $result = ''; if (empty($targetSelector)) { $targetSelector = 'table tbody'; } $hasNext = $this->Paginator->hasNext(); if (!$hasNext) { $paginatorParams = $this->Paginator->params(); $count = (int)Hash::get($paginatorParams, 'count'); $records = __dn('view_extension', 'record', 'records', $count); $result = $this->Html->div( 'load-more', $this->Html->para('small', $this->Paginator->counter(__d('view_extension', 'Showing {:count} %s', $records))) ); return $result; } $urlPaginator = []; if (isset($this->Paginator->options['url'])) { $urlPaginator = (array)$this->Paginator->options['url']; } $paginatorParams = $this->Paginator->params(); $count = (int)Hash::get($paginatorParams, 'count'); $page = (int)Hash::get($paginatorParams, 'page'); $limit = (int)Hash::get($paginatorParams, 'limit'); $urlLoadMore = $this->Paginator->url(['page' => $page + 1, 'show' => 'list'], true); $urlLoadMore = array_merge($urlPaginator, $urlLoadMore); $btnClass = $this->getBtnClass('btn-default btn-sm'); $btnClass .= ' btn-block'; $startRecord = 0; if ($count >= 1) { $startRecord = (($page - 1) * $limit) + 1; } $endRecord = $startRecord + $limit - 1; $records = __dn('view_extension', 'record', 'records', $endRecord); $result = $this->Html->div( 'load-more', $this->Html->para('small', $this->Paginator->counter( __d('view_extension', 'Current loaded page {:page} of {:pages}, showing {:end} %s of {:count} total', $records) )) . $this->Html->link( $this->_getOptionsForElem('loadMore.linkTitle'), $urlLoadMore, [ 'class' => $btnClass . ' hidden-print', 'data-target-selector' => $targetSelector, ] + $this->_getOptionsForElem('loadMore.linkOpt') ) ); return $result; }
php
public function buttonLoadMore($targetSelector = null) { $result = ''; if (empty($targetSelector)) { $targetSelector = 'table tbody'; } $hasNext = $this->Paginator->hasNext(); if (!$hasNext) { $paginatorParams = $this->Paginator->params(); $count = (int)Hash::get($paginatorParams, 'count'); $records = __dn('view_extension', 'record', 'records', $count); $result = $this->Html->div( 'load-more', $this->Html->para('small', $this->Paginator->counter(__d('view_extension', 'Showing {:count} %s', $records))) ); return $result; } $urlPaginator = []; if (isset($this->Paginator->options['url'])) { $urlPaginator = (array)$this->Paginator->options['url']; } $paginatorParams = $this->Paginator->params(); $count = (int)Hash::get($paginatorParams, 'count'); $page = (int)Hash::get($paginatorParams, 'page'); $limit = (int)Hash::get($paginatorParams, 'limit'); $urlLoadMore = $this->Paginator->url(['page' => $page + 1, 'show' => 'list'], true); $urlLoadMore = array_merge($urlPaginator, $urlLoadMore); $btnClass = $this->getBtnClass('btn-default btn-sm'); $btnClass .= ' btn-block'; $startRecord = 0; if ($count >= 1) { $startRecord = (($page - 1) * $limit) + 1; } $endRecord = $startRecord + $limit - 1; $records = __dn('view_extension', 'record', 'records', $endRecord); $result = $this->Html->div( 'load-more', $this->Html->para('small', $this->Paginator->counter( __d('view_extension', 'Current loaded page {:page} of {:pages}, showing {:end} %s of {:count} total', $records) )) . $this->Html->link( $this->_getOptionsForElem('loadMore.linkTitle'), $urlLoadMore, [ 'class' => $btnClass . ' hidden-print', 'data-target-selector' => $targetSelector, ] + $this->_getOptionsForElem('loadMore.linkOpt') ) ); return $result; }
[ "public", "function", "buttonLoadMore", "(", "$", "targetSelector", "=", "null", ")", "{", "$", "result", "=", "''", ";", "if", "(", "empty", "(", "$", "targetSelector", ")", ")", "{", "$", "targetSelector", "=", "'table tbody'", ";", "}", "$", "hasNext"...
Return controls of pagination as button `Load more`. @param string $targetSelector jQuery selector to select data from server response and selection of the element on the page to add new data. @return string Return button `Load more`.
[ "Return", "controls", "of", "pagination", "as", "button", "Load", "more", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1893-L1946
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.buttonsPaging
public function buttonsPaging($targetSelector = null, $showCounterInfo = true, $useShowList = true, $useGoToPage = true, $useChangeNumLines = true) { $showType = (string)$this->request->param('named.show'); if (mb_stripos($showType, 'list') === 0) { $result = $this->buttonLoadMore($targetSelector); } else { $result = $this->barPaging($showCounterInfo, $useShowList, $useGoToPage, $useChangeNumLines); } return $result; }
php
public function buttonsPaging($targetSelector = null, $showCounterInfo = true, $useShowList = true, $useGoToPage = true, $useChangeNumLines = true) { $showType = (string)$this->request->param('named.show'); if (mb_stripos($showType, 'list') === 0) { $result = $this->buttonLoadMore($targetSelector); } else { $result = $this->barPaging($showCounterInfo, $useShowList, $useGoToPage, $useChangeNumLines); } return $result; }
[ "public", "function", "buttonsPaging", "(", "$", "targetSelector", "=", "null", ",", "$", "showCounterInfo", "=", "true", ",", "$", "useShowList", "=", "true", ",", "$", "useGoToPage", "=", "true", ",", "$", "useChangeNumLines", "=", "true", ")", "{", "$",...
Return controls of pagination depending on the state of the named parameter "show" @param string $targetSelector jQuery selector to select data from server response and selection of the element on the page to add new data. @param bool $showCounterInfo If true, show information about pages and records @param bool $useShowList If true, show button `Show as list` @param bool $useGoToPage If true, show button `Go to the page` @param bool $useChangeNumLines If true, show select `Number of lines` @return string Return controls of pagination. @see ViewExtension::buttonLoadMore() @see ViewExtension::barPaging()
[ "Return", "controls", "of", "pagination", "depending", "on", "the", "state", "of", "the", "named", "parameter", "show" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1964-L1973
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.menuHeaderPage
public function menuHeaderPage($headerMenuActions = null) { $result = ''; if (empty($headerMenuActions)) { return $result; } if (!is_array($headerMenuActions)) { $headerMenuActions = [$headerMenuActions]; } $headerMenuActionsPrep = ''; foreach ($headerMenuActions as $action) { $actionOptions = []; if (!is_array($action)) { if ($action === 'divider') { $action = ''; $actionOptions = ['class' => 'divider']; } $headerMenuActionsPrep .= $this->Html->tag('li', $action, $actionOptions); } elseif (is_array($action)) { $actionSize = count($action); if ($actionSize == 1) { $actionLabal = array_shift($action); if (empty($actionLabal)) { continue; } $headerMenuActionsPrep .= $this->Html->tag('li', $actionLabal); } elseif ($actionSize == 2) { $actionLabal = array_shift($action); if (empty($actionLabal)) { continue; } $actionOptions = array_shift($action); if (!is_array($actionOptions)) { $actionOptions = []; } $headerMenuActionsPrep .= $this->Html->tag('li', $actionLabal, $actionOptions); } elseif (($actionSize >= 3) && ($actionSize <= 4)) { $action = call_user_func_array([$this, 'menuActionLink'], $action); $headerMenuActionsPrep .= $this->Html->tag('li', $action, $actionOptions); } } } if (empty($headerMenuActionsPrep)) { return $result; } $result = $this->Html->div( 'btn-group page-header-menu hidden-print', $this->_getOptionsForElem('btnHeaderMenu') . $this->Html->tag('ul', $headerMenuActionsPrep, ['class' => 'dropdown-menu', 'aria-labelledby' => 'pageHeaderMenu']) ); return $result; }
php
public function menuHeaderPage($headerMenuActions = null) { $result = ''; if (empty($headerMenuActions)) { return $result; } if (!is_array($headerMenuActions)) { $headerMenuActions = [$headerMenuActions]; } $headerMenuActionsPrep = ''; foreach ($headerMenuActions as $action) { $actionOptions = []; if (!is_array($action)) { if ($action === 'divider') { $action = ''; $actionOptions = ['class' => 'divider']; } $headerMenuActionsPrep .= $this->Html->tag('li', $action, $actionOptions); } elseif (is_array($action)) { $actionSize = count($action); if ($actionSize == 1) { $actionLabal = array_shift($action); if (empty($actionLabal)) { continue; } $headerMenuActionsPrep .= $this->Html->tag('li', $actionLabal); } elseif ($actionSize == 2) { $actionLabal = array_shift($action); if (empty($actionLabal)) { continue; } $actionOptions = array_shift($action); if (!is_array($actionOptions)) { $actionOptions = []; } $headerMenuActionsPrep .= $this->Html->tag('li', $actionLabal, $actionOptions); } elseif (($actionSize >= 3) && ($actionSize <= 4)) { $action = call_user_func_array([$this, 'menuActionLink'], $action); $headerMenuActionsPrep .= $this->Html->tag('li', $action, $actionOptions); } } } if (empty($headerMenuActionsPrep)) { return $result; } $result = $this->Html->div( 'btn-group page-header-menu hidden-print', $this->_getOptionsForElem('btnHeaderMenu') . $this->Html->tag('ul', $headerMenuActionsPrep, ['class' => 'dropdown-menu', 'aria-labelledby' => 'pageHeaderMenu']) ); return $result; }
[ "public", "function", "menuHeaderPage", "(", "$", "headerMenuActions", "=", "null", ")", "{", "$", "result", "=", "''", ";", "if", "(", "empty", "(", "$", "headerMenuActions", ")", ")", "{", "return", "$", "result", ";", "}", "if", "(", "!", "is_array"...
Return menu for header of page. @param array|string $headerMenuActions List of menu actions. If is array with number of elements: - 1: use as menu item label; - 2: first item use as menu item label, second item use as menu item options; - 3 or 4: use parameters for ViewExtensionHelper::menuActionLink(). @return string Return menu for header of page. @see ViewExtensionHelper::menuActionLink()
[ "Return", "menu", "for", "header", "of", "page", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L1997-L2051
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.headerPage
public function headerPage($pageHeader = null, $headerMenuActions = null) { $result = ''; if (empty($pageHeader)) { return $result; } $pageHeader = (string)$pageHeader; $pageHeader .= $this->menuHeaderPage($headerMenuActions); return $this->Html->div('page-header well', $this->Html->tag('h2', $pageHeader, ['class' => 'header'])); }
php
public function headerPage($pageHeader = null, $headerMenuActions = null) { $result = ''; if (empty($pageHeader)) { return $result; } $pageHeader = (string)$pageHeader; $pageHeader .= $this->menuHeaderPage($headerMenuActions); return $this->Html->div('page-header well', $this->Html->tag('h2', $pageHeader, ['class' => 'header'])); }
[ "public", "function", "headerPage", "(", "$", "pageHeader", "=", "null", ",", "$", "headerMenuActions", "=", "null", ")", "{", "$", "result", "=", "''", ";", "if", "(", "empty", "(", "$", "pageHeader", ")", ")", "{", "return", "$", "result", ";", "}"...
Return header of page. @param string $pageHeader Text of page header @param array|string $headerMenuActions List of menu actions @return string Return header of page. @see ViewExtensionHelper::menuHeaderPage()
[ "Return", "header", "of", "page", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L2061-L2071
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.collapsibleList
public function collapsibleList($listData = [], $showLimit = 10, $listClass = 'list-unstyled', $listTag = 'ul') { $result = ''; if (empty($listData)) { return $result; } $showLimit = (int)$showLimit; if ($showLimit < 1) { return $result; } if (!empty($listClass)) { $listClass = ' ' . $listClass; } $tagsAllowed = ['ul', 'ol']; if (!in_array($listTag, $tagsAllowed)) { $listTag = 'ul'; } $listDataShown = array_slice($listData, 0, $showLimit); $result = $this->Html->nestedList($listDataShown, ['class' => 'list-collapsible-compact' . $listClass], [], $listTag); if (count($listData) <= $showLimit) { return $result; } $listId = uniqid('collapsible-list-'); $listDataHidden = array_slice($listData, $showLimit); $result .= $this->Html->nestedList( $listDataHidden, [ 'class' => 'list-collapsible-compact collapse' . $listClass, 'id' => $listId ], [], $listTag ) . $this->button( 'fas fa-angle-double-down', 'btn-default', [ 'class' => 'top-buffer hide-popup', 'title' => __d('view_extension', 'Show or hide full list'), 'data-toggle' => 'collapse', 'data-target' => '#' . $listId, 'aria-expanded' => 'false', 'data-toggle-icons' => 'fa-angle-double-down,fa-angle-double-up' ] ); return $result; }
php
public function collapsibleList($listData = [], $showLimit = 10, $listClass = 'list-unstyled', $listTag = 'ul') { $result = ''; if (empty($listData)) { return $result; } $showLimit = (int)$showLimit; if ($showLimit < 1) { return $result; } if (!empty($listClass)) { $listClass = ' ' . $listClass; } $tagsAllowed = ['ul', 'ol']; if (!in_array($listTag, $tagsAllowed)) { $listTag = 'ul'; } $listDataShown = array_slice($listData, 0, $showLimit); $result = $this->Html->nestedList($listDataShown, ['class' => 'list-collapsible-compact' . $listClass], [], $listTag); if (count($listData) <= $showLimit) { return $result; } $listId = uniqid('collapsible-list-'); $listDataHidden = array_slice($listData, $showLimit); $result .= $this->Html->nestedList( $listDataHidden, [ 'class' => 'list-collapsible-compact collapse' . $listClass, 'id' => $listId ], [], $listTag ) . $this->button( 'fas fa-angle-double-down', 'btn-default', [ 'class' => 'top-buffer hide-popup', 'title' => __d('view_extension', 'Show or hide full list'), 'data-toggle' => 'collapse', 'data-target' => '#' . $listId, 'aria-expanded' => 'false', 'data-toggle-icons' => 'fa-angle-double-down,fa-angle-double-up' ] ); return $result; }
[ "public", "function", "collapsibleList", "(", "$", "listData", "=", "[", "]", ",", "$", "showLimit", "=", "10", ",", "$", "listClass", "=", "'list-unstyled'", ",", "$", "listTag", "=", "'ul'", ")", "{", "$", "result", "=", "''", ";", "if", "(", "empt...
Return collapsible list. @param array $listData List data @param int $showLimit Limit of the displayed list @param string $listClass Class of the list tag @param string $listTag Type of list tag to use (ol/ul) @return string Return collapsible list.
[ "Return", "collapsible", "list", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L2082-L2132
train
anklimsk/cakephp-theme
View/Helper/ViewExtensionHelper.php
ViewExtensionHelper.addBreadCrumbs
public function addBreadCrumbs($breadCrumbs = null) { if (empty($breadCrumbs) || !is_array($breadCrumbs)) { return; } foreach ($breadCrumbs as $breadCrumbInfo) { if (empty($breadCrumbInfo)) { continue; } $link = null; if (is_array($breadCrumbInfo)) { $name = array_shift($breadCrumbInfo); $link = array_shift($breadCrumbInfo); } else { $name = $breadCrumbInfo; } if (empty($name)) { continue; } $this->Html->addCrumb(h($name), $link); } }
php
public function addBreadCrumbs($breadCrumbs = null) { if (empty($breadCrumbs) || !is_array($breadCrumbs)) { return; } foreach ($breadCrumbs as $breadCrumbInfo) { if (empty($breadCrumbInfo)) { continue; } $link = null; if (is_array($breadCrumbInfo)) { $name = array_shift($breadCrumbInfo); $link = array_shift($breadCrumbInfo); } else { $name = $breadCrumbInfo; } if (empty($name)) { continue; } $this->Html->addCrumb(h($name), $link); } }
[ "public", "function", "addBreadCrumbs", "(", "$", "breadCrumbs", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "breadCrumbs", ")", "||", "!", "is_array", "(", "$", "breadCrumbs", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "breadCrum...
Adds a links to the breadcrumbs array. @param array $breadCrumbs List of breadcrumbs in format: - first element in list item: text for link; - second element in list item: URL for link. @return void
[ "Adds", "a", "links", "to", "the", "breadcrumbs", "array", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/View/Helper/ViewExtensionHelper.php#L2142-L2165
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Repositories/Period/EloquentPeriod.php
EloquentPeriod.byOrganizationWithYear
public function byOrganizationWithYear($id) { // return $this->Period->where('organization_id', '=', $id)->with('year')->get(); -> Evitar los with $periods = $this->DB->connection($this->databaseConnectionName) ->table('ACCT_Period As p') ->join('ACCT_Fiscal_Year AS f', 'f.id', '=', 'p.fiscal_year_id') ->where('p.organization_id', '=', $id) ->get(array('p.id', 'p.month', 'f.year')); return new Collection($periods); }
php
public function byOrganizationWithYear($id) { // return $this->Period->where('organization_id', '=', $id)->with('year')->get(); -> Evitar los with $periods = $this->DB->connection($this->databaseConnectionName) ->table('ACCT_Period As p') ->join('ACCT_Fiscal_Year AS f', 'f.id', '=', 'p.fiscal_year_id') ->where('p.organization_id', '=', $id) ->get(array('p.id', 'p.month', 'f.year')); return new Collection($periods); }
[ "public", "function", "byOrganizationWithYear", "(", "$", "id", ")", "{", "// return $this->Period->where('organization_id', '=', $id)->with('year')->get(); -> Evitar los with", "$", "periods", "=", "$", "this", "->", "DB", "->", "connection", "(", "$", "this", "->", "dat...
Retrieve periods by organization with its year @param int $id Organization id @return Illuminate\Database\Eloquent\Collection
[ "Retrieve", "periods", "by", "organization", "with", "its", "year" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Repositories/Period/EloquentPeriod.php#L103-L114
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Repositories/Period/EloquentPeriod.php
EloquentPeriod.lastPeriodbyOrganizationAndByFiscalYear
public function lastPeriodbyOrganizationAndByFiscalYear($organizationId, $fiscalYearId) { $Period = $this->Period->selectRaw('id, end_date, max(month) as month') ->where('organization_id', '=', $organizationId) ->where('fiscal_year_id', '=', $fiscalYearId) ->orderBy('month', 'desc') ->groupBy(array('id', 'end_date')) ->first(); return $Period; }
php
public function lastPeriodbyOrganizationAndByFiscalYear($organizationId, $fiscalYearId) { $Period = $this->Period->selectRaw('id, end_date, max(month) as month') ->where('organization_id', '=', $organizationId) ->where('fiscal_year_id', '=', $fiscalYearId) ->orderBy('month', 'desc') ->groupBy(array('id', 'end_date')) ->first(); return $Period; }
[ "public", "function", "lastPeriodbyOrganizationAndByFiscalYear", "(", "$", "organizationId", ",", "$", "fiscalYearId", ")", "{", "$", "Period", "=", "$", "this", "->", "Period", "->", "selectRaw", "(", "'id, end_date, max(month) as month'", ")", "->", "where", "(", ...
Get last period by organization and by fiscal year @param int $id Organization id @return Illuminate\Database\Eloquent\Collection
[ "Get", "last", "period", "by", "organization", "and", "by", "fiscal", "year" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Repositories/Period/EloquentPeriod.php#L123-L133
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Repositories/Period/EloquentPeriod.php
EloquentPeriod.create
public function create(array $data) { $Period = new Period(); $Period->setConnection($this->databaseConnectionName); $Period->fill($data)->save(); return $Period; }
php
public function create(array $data) { $Period = new Period(); $Period->setConnection($this->databaseConnectionName); $Period->fill($data)->save(); return $Period; }
[ "public", "function", "create", "(", "array", "$", "data", ")", "{", "$", "Period", "=", "new", "Period", "(", ")", ";", "$", "Period", "->", "setConnection", "(", "$", "this", "->", "databaseConnectionName", ")", ";", "$", "Period", "->", "fill", "(",...
Create a new period @param array $data An array as follows: array('month'=>$month, 'start_date'=>$startDate, 'end_date'=>$endDate, 'is_closed'=>$isClosed, 'fiscal_year_id' => $fiscalYearId, 'organization_id'=>$organizationId ); @return boolean
[ "Create", "a", "new", "period" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Repositories/Period/EloquentPeriod.php#L205-L212
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Repositories/Period/EloquentPeriod.php
EloquentPeriod.update
public function update(array $data, $Period = null) { if(empty($Period)) { $Period = $this->byId($data['id']); } foreach ($data as $key => $value) { $Period->$key = $value; } return $Period->save(); }
php
public function update(array $data, $Period = null) { if(empty($Period)) { $Period = $this->byId($data['id']); } foreach ($data as $key => $value) { $Period->$key = $value; } return $Period->save(); }
[ "public", "function", "update", "(", "array", "$", "data", ",", "$", "Period", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "Period", ")", ")", "{", "$", "Period", "=", "$", "this", "->", "byId", "(", "$", "data", "[", "'id'", "]", ")",...
Update an existing period @param array $data An array as follows: array('month'=>$month, 'start_date'=>$startDate, 'end_date'=>$endDate, 'is_closed'=>$isClosed, 'fiscal_year_id' => $fiscalYearId, 'organization_id'=>$organizationId ); @param Mgallegos\DecimaAccounting\Period $Period @return boolean
[ "Update", "an", "existing", "period" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Repositories/Period/EloquentPeriod.php#L226-L239
train
sebastianfeldmann/ftp
src/File.php
File.setModificationDate
private function setModificationDate(array $ftpInfo) { $modDate = !empty($ftpInfo['modify']) ? DateTimeImmutable::createFromFormat('YmdHis', $ftpInfo['modify']) : false; $this->modify = !empty($modDate) ? $modDate : new DateTimeImmutable(); }
php
private function setModificationDate(array $ftpInfo) { $modDate = !empty($ftpInfo['modify']) ? DateTimeImmutable::createFromFormat('YmdHis', $ftpInfo['modify']) : false; $this->modify = !empty($modDate) ? $modDate : new DateTimeImmutable(); }
[ "private", "function", "setModificationDate", "(", "array", "$", "ftpInfo", ")", "{", "$", "modDate", "=", "!", "empty", "(", "$", "ftpInfo", "[", "'modify'", "]", ")", "?", "DateTimeImmutable", "::", "createFromFormat", "(", "'YmdHis'", ",", "$", "ftpInfo",...
Set modification date. @param array $ftpInfo @throws \Exception
[ "Set", "modification", "date", "." ]
b75e590f248abd6707b86b5df70daad71e7ab6bc
https://github.com/sebastianfeldmann/ftp/blob/b75e590f248abd6707b86b5df70daad71e7ab6bc/src/File.php#L87-L93
train
byjg/xmlnuke
xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukeMediaGallery.php
XmlnukeMediaGallery.addIFrame
public function addIFrame($src, $windowWidth, $windowHeight, $thumb="", $title = "", $caption="", $width="", $height="") { $this->addXmlnukeObject(XmlnukeMediaItem::IFrameFactory($src, $windowWidth, $windowHeight, $thumb, $title, $caption, $width, $height)); }
php
public function addIFrame($src, $windowWidth, $windowHeight, $thumb="", $title = "", $caption="", $width="", $height="") { $this->addXmlnukeObject(XmlnukeMediaItem::IFrameFactory($src, $windowWidth, $windowHeight, $thumb, $title, $caption, $width, $height)); }
[ "public", "function", "addIFrame", "(", "$", "src", ",", "$", "windowWidth", ",", "$", "windowHeight", ",", "$", "thumb", "=", "\"\"", ",", "$", "title", "=", "\"\"", ",", "$", "caption", "=", "\"\"", ",", "$", "width", "=", "\"\"", ",", "$", "heig...
Create an Media Item of IFrame type @param $src @param $windowWidth @param $windowHeight @param $thumb @param $title @param $caption @param $width @param $height @return XmlnukeMediaItem
[ "Create", "an", "Media", "Item", "of", "IFrame", "type" ]
aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7
https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukeMediaGallery.php#L153-L156
train
JBZoo/Html
src/Render/Render.php
Render.buildAttrs
public function buildAttrs(array $attrs = array()) { $result = ' '; foreach ($attrs as $key => $param) { $param = (array) $param; if ($key === 'data') { $result .= $this->_buildDataAttrs($param); continue; } $value = implode(' ', $param); $value = $this->_cleanValue($value); if ($key !== 'data' && $attr = $this->_buildAttr($key, $value)) { $result .= $attr; } } return trim($result); }
php
public function buildAttrs(array $attrs = array()) { $result = ' '; foreach ($attrs as $key => $param) { $param = (array) $param; if ($key === 'data') { $result .= $this->_buildDataAttrs($param); continue; } $value = implode(' ', $param); $value = $this->_cleanValue($value); if ($key !== 'data' && $attr = $this->_buildAttr($key, $value)) { $result .= $attr; } } return trim($result); }
[ "public", "function", "buildAttrs", "(", "array", "$", "attrs", "=", "array", "(", ")", ")", "{", "$", "result", "=", "' '", ";", "foreach", "(", "$", "attrs", "as", "$", "key", "=>", "$", "param", ")", "{", "$", "param", "=", "(", "array", ")", ...
Build attributes. @param $attrs @return string
[ "Build", "attributes", "." ]
bd61d49a78199f425a2ed3270621e47dff4a014e
https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Render.php#L41-L60
train
JBZoo/Html
src/Render/Render.php
Render._buildAttr
protected function _buildAttr($key, $val) { $return = null; if (!empty($val) || $val === '0' || $key === 'value') { $return = ' ' . $key . '="' . $val . '"'; } return $return; }
php
protected function _buildAttr($key, $val) { $return = null; if (!empty($val) || $val === '0' || $key === 'value') { $return = ' ' . $key . '="' . $val . '"'; } return $return; }
[ "protected", "function", "_buildAttr", "(", "$", "key", ",", "$", "val", ")", "{", "$", "return", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "val", ")", "||", "$", "val", "===", "'0'", "||", "$", "key", "===", "'value'", ")", "{", "$"...
Build attribute. @param string $key @param string $val @return null|string
[ "Build", "attribute", "." ]
bd61d49a78199f425a2ed3270621e47dff4a014e
https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Render.php#L69-L77
train
JBZoo/Html
src/Render/Render.php
Render._buildDataAttrs
protected function _buildDataAttrs(array $param = array()) { $return = ''; foreach ($param as $data => $val) { $dKey = 'data-' . trim($data); if (is_object($val)) { $val = (array) $val; } if (is_array($val)) { $val = str_replace('"', '\'', json_encode($val)); $return .= $this->_buildAttr($dKey, $val); continue; } $return .= $this->_buildAttr($dKey, $val); } return $return; }
php
protected function _buildDataAttrs(array $param = array()) { $return = ''; foreach ($param as $data => $val) { $dKey = 'data-' . trim($data); if (is_object($val)) { $val = (array) $val; } if (is_array($val)) { $val = str_replace('"', '\'', json_encode($val)); $return .= $this->_buildAttr($dKey, $val); continue; } $return .= $this->_buildAttr($dKey, $val); } return $return; }
[ "protected", "function", "_buildDataAttrs", "(", "array", "$", "param", "=", "array", "(", ")", ")", "{", "$", "return", "=", "''", ";", "foreach", "(", "$", "param", "as", "$", "data", "=>", "$", "val", ")", "{", "$", "dKey", "=", "'data-'", ".", ...
Build html data attributes. @param array $param @return null|string
[ "Build", "html", "data", "attributes", "." ]
bd61d49a78199f425a2ed3270621e47dff4a014e
https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Render.php#L85-L105
train
JBZoo/Html
src/Render/Render.php
Render._cleanAttrs
protected function _cleanAttrs(array $attrs = array()) { foreach ($attrs as $key => $val) { if (Arr::in($key, $this->_disallowAttr)) { unset($attrs[$key]); } } return $attrs; }
php
protected function _cleanAttrs(array $attrs = array()) { foreach ($attrs as $key => $val) { if (Arr::in($key, $this->_disallowAttr)) { unset($attrs[$key]); } } return $attrs; }
[ "protected", "function", "_cleanAttrs", "(", "array", "$", "attrs", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "attrs", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "Arr", "::", "in", "(", "$", "key", ",", "$", "this", "...
Remove disallow attributes. @param array $attrs @return array @SuppressWarnings("unused")
[ "Remove", "disallow", "attributes", "." ]
bd61d49a78199f425a2ed3270621e47dff4a014e
https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Render.php#L114-L123
train
JBZoo/Html
src/Render/Render.php
Render._cleanValue
protected function _cleanValue($value, $trim = false) { $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); return ($trim) ? trim($value) : $value; }
php
protected function _cleanValue($value, $trim = false) { $value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); return ($trim) ? trim($value) : $value; }
[ "protected", "function", "_cleanValue", "(", "$", "value", ",", "$", "trim", "=", "false", ")", "{", "$", "value", "=", "htmlspecialchars", "(", "$", "value", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ";", "return", "(", "$", "trim", ")", "?", "trim", ...
Clear attribute value @param $value @param bool|false $trim @return string
[ "Clear", "attribute", "value" ]
bd61d49a78199f425a2ed3270621e47dff4a014e
https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Render.php#L132-L136
train
JBZoo/Html
src/Render/Render.php
Render._mergeAttr
protected function _mergeAttr(array $attrs = array(), $val = null, $key = 'class') { if (Arr::key($key, $attrs)) { $attrs[$key] .= ' ' . $val; } else { $attrs[$key] = $val; } return $attrs; }
php
protected function _mergeAttr(array $attrs = array(), $val = null, $key = 'class') { if (Arr::key($key, $attrs)) { $attrs[$key] .= ' ' . $val; } else { $attrs[$key] = $val; } return $attrs; }
[ "protected", "function", "_mergeAttr", "(", "array", "$", "attrs", "=", "array", "(", ")", ",", "$", "val", "=", "null", ",", "$", "key", "=", "'class'", ")", "{", "if", "(", "Arr", "::", "key", "(", "$", "key", ",", "$", "attrs", ")", ")", "{"...
Merge attributes by given key. @param array $attrs @param null $val @param string $key @return array
[ "Merge", "attributes", "by", "given", "key", "." ]
bd61d49a78199f425a2ed3270621e47dff4a014e
https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Render.php#L157-L165
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Bundle/Menu/Plugins/Gui/MenuContentFactory.php
MenuContentFactory.createTabsMenu
protected function createTabsMenu(ManialinkInterface $manialink, ParentItem $rootItem, $openId) { /** @var Frame $tabsFrame */ $tabsFrame = $manialink->getData('tabs_frame'); $tabsFrame->removeAllChildren(); $this->menuTabsFactory->createTabsMenu($manialink, $tabsFrame, $rootItem, [$this, 'callbackItemClick'], $openId); }
php
protected function createTabsMenu(ManialinkInterface $manialink, ParentItem $rootItem, $openId) { /** @var Frame $tabsFrame */ $tabsFrame = $manialink->getData('tabs_frame'); $tabsFrame->removeAllChildren(); $this->menuTabsFactory->createTabsMenu($manialink, $tabsFrame, $rootItem, [$this, 'callbackItemClick'], $openId); }
[ "protected", "function", "createTabsMenu", "(", "ManialinkInterface", "$", "manialink", ",", "ParentItem", "$", "rootItem", ",", "$", "openId", ")", "{", "/** @var Frame $tabsFrame */", "$", "tabsFrame", "=", "$", "manialink", "->", "getData", "(", "'tabs_frame'", ...
Create tabs level menu. @param ManialinkInterface $manialink @param ItemInterface|null $rootItem @param $openId
[ "Create", "tabs", "level", "menu", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/Menu/Plugins/Gui/MenuContentFactory.php#L179-L187
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Bundle/Menu/Plugins/Gui/MenuContentFactory.php
MenuContentFactory.callbackClose
public function callbackClose( ManialinkInterface $manialink, $login, $params, $args ) { $this->destroy($manialink->getUserGroup()); }
php
public function callbackClose( ManialinkInterface $manialink, $login, $params, $args ) { $this->destroy($manialink->getUserGroup()); }
[ "public", "function", "callbackClose", "(", "ManialinkInterface", "$", "manialink", ",", "$", "login", ",", "$", "params", ",", "$", "args", ")", "{", "$", "this", "->", "destroy", "(", "$", "manialink", "->", "getUserGroup", "(", ")", ")", ";", "}" ]
Callback when the close button is clicked. @param $login @param $params @param $args
[ "Callback", "when", "the", "close", "button", "is", "clicked", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/Menu/Plugins/Gui/MenuContentFactory.php#L401-L408
train
honeybee/trellis
src/Runtime/Attribute/Float/FloatValueHolder.php
FloatValueHolder.almostEqual
public static function almostEqual($a, $b, $epsilon = 0.0000000001) { $diff = abs($a - $b); if ($a === $b) { // just compare values, handles e.g. INF return true; } elseif ($a === 0.0 || $b === 0.0 || $diff < self::FLOAT_MIN) { // a or b is zero or both are extremely close to it // relative error is less meaningful here return $diff < ($epsilon * self::FLOAT_MIN); } else { // use relative error $abs_a = abs($a); $abs_b = abs($b); return $diff / ($abs_a + $abs_b) < $epsilon; } }
php
public static function almostEqual($a, $b, $epsilon = 0.0000000001) { $diff = abs($a - $b); if ($a === $b) { // just compare values, handles e.g. INF return true; } elseif ($a === 0.0 || $b === 0.0 || $diff < self::FLOAT_MIN) { // a or b is zero or both are extremely close to it // relative error is less meaningful here return $diff < ($epsilon * self::FLOAT_MIN); } else { // use relative error $abs_a = abs($a); $abs_b = abs($b); return $diff / ($abs_a + $abs_b) < $epsilon; } }
[ "public", "static", "function", "almostEqual", "(", "$", "a", ",", "$", "b", ",", "$", "epsilon", "=", "0.0000000001", ")", "{", "$", "diff", "=", "abs", "(", "$", "a", "-", "$", "b", ")", ";", "if", "(", "$", "a", "===", "$", "b", ")", "{", ...
Compare two float values for equality. @see http://floating-point-gui.de/errors/comparison/ @param float $a @param float $b @param float $epsilon delta when comparing unequal values @return boolean true if float values are considered to be of equal value
[ "Compare", "two", "float", "values", "for", "equality", "." ]
511300e193b22adc48a22e8ea8294ad40d53f681
https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Attribute/Float/FloatValueHolder.php#L97-L114
train
TheBnl/event-tickets
code/forms/CheckInForm.php
CheckInForm.doCheckIn
public function doCheckIn($data, CheckInForm $form) { /** @var CheckInController $controller */ $controller = $form->getController(); $validator = CheckInValidator::create(); $result = $validator->validate($data['TicketCode']); switch ($result['Code']) { case CheckInValidator::MESSAGE_CHECK_OUT_SUCCESS: $validator->getAttendee()->checkOut(); break; case CheckInValidator::MESSAGE_CHECK_IN_SUCCESS: $validator->getAttendee()->checkIn(); break; } $form->sessionMessage($result['Message'], strtolower($result['Type']), false); $this->extend('onAfterCheckIn', $response, $form, $result); return $response ? $response : $controller->redirect($controller->Link()); }
php
public function doCheckIn($data, CheckInForm $form) { /** @var CheckInController $controller */ $controller = $form->getController(); $validator = CheckInValidator::create(); $result = $validator->validate($data['TicketCode']); switch ($result['Code']) { case CheckInValidator::MESSAGE_CHECK_OUT_SUCCESS: $validator->getAttendee()->checkOut(); break; case CheckInValidator::MESSAGE_CHECK_IN_SUCCESS: $validator->getAttendee()->checkIn(); break; } $form->sessionMessage($result['Message'], strtolower($result['Type']), false); $this->extend('onAfterCheckIn', $response, $form, $result); return $response ? $response : $controller->redirect($controller->Link()); }
[ "public", "function", "doCheckIn", "(", "$", "data", ",", "CheckInForm", "$", "form", ")", "{", "/** @var CheckInController $controller */", "$", "controller", "=", "$", "form", "->", "getController", "(", ")", ";", "$", "validator", "=", "CheckInValidator", "::...
Do the check in, if all checks pass return a success @param $data @param CheckInForm $form @return \SS_HTTPResponse
[ "Do", "the", "check", "in", "if", "all", "checks", "pass", "return", "a", "success" ]
d18db4146a141795fd50689057130a6fd41ac397
https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/forms/CheckInForm.php#L43-L61
train
anklimsk/cakephp-theme
Model/ExtendQueuedTask.php
ExtendQueuedTask.getLengthQueue
public function getLengthQueue($jobType = null) { $jobType = (string)$jobType; $queueLength = 0; $pendingStats = $this->getPendingStats(); if (empty($pendingStats)) { return $queueLength; } foreach ($pendingStats as $pendingStatsItem) { if ((!empty($jobType) && (strcmp($pendingStatsItem[$this->alias]['jobtype'], $jobType) !== 0)) || ($pendingStatsItem[$this->alias]['status'] !== 'NOT_STARTED')) { continue; } $queueLength++; } return $queueLength; }
php
public function getLengthQueue($jobType = null) { $jobType = (string)$jobType; $queueLength = 0; $pendingStats = $this->getPendingStats(); if (empty($pendingStats)) { return $queueLength; } foreach ($pendingStats as $pendingStatsItem) { if ((!empty($jobType) && (strcmp($pendingStatsItem[$this->alias]['jobtype'], $jobType) !== 0)) || ($pendingStatsItem[$this->alias]['status'] !== 'NOT_STARTED')) { continue; } $queueLength++; } return $queueLength; }
[ "public", "function", "getLengthQueue", "(", "$", "jobType", "=", "null", ")", "{", "$", "jobType", "=", "(", "string", ")", "$", "jobType", ";", "$", "queueLength", "=", "0", ";", "$", "pendingStats", "=", "$", "this", "->", "getPendingStats", "(", ")...
Get length of job queue for not started task @param string $jobType Type of job. @return int Length of job queue
[ "Get", "length", "of", "job", "queue", "for", "not", "started", "task" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/ExtendQueuedTask.php#L55-L73
train
anklimsk/cakephp-theme
Model/ExtendQueuedTask.php
ExtendQueuedTask.getPendingJob
public function getPendingJob($jobType = null, $includeFinished = false, $timestamp = null) { if (empty($jobType)) { return false; } if (empty($timestamp) || (!is_int($timestamp) || !ctype_digit($timestamp))) { $timestamp = strtotime('-15 minute'); } $fetchedTime = date('Y-m-d H:i:s', $timestamp); $fields = [ $this->alias . '.jobtype', $this->alias . '.created', $this->alias . '.status', $this->alias . '.age', $this->alias . '.fetched', $this->alias . '.progress', $this->alias . '.completed', $this->alias . '.reference', $this->alias . '.failed', $this->alias . '.failure_message' ]; $conditions = [ 'OR' => [ [ // NOT_READY $this->alias . '.notbefore > NOW()', ], [ // NOT_STARTED $this->alias . '.fetched' => null, ], [ // IN_PROGRESS 'AND' => [ $this->alias . '.fetched NOT' => null, $this->alias . '.fetched >' => $fetchedTime, $this->alias . '.completed' => null, $this->alias . '.failed' => 0, ], ] ], $this->alias . '.jobtype' => $jobType, ]; if ($includeFinished) { $conditions['OR'][] = [ // FAILED 'AND' => [ $this->alias . '.fetched NOT' => null, $this->alias . '.fetched >' => $fetchedTime, $this->alias . '.completed' => null, $this->alias . '.failed >' => 0, ], ]; $conditions['OR'][] = [ // COMPLETED 'AND' => [ $this->alias . '.fetched NOT' => null, $this->alias . '.fetched >' => $fetchedTime, $this->alias . '.completed NOT' => null, ], ]; } $order = [ 'FIELD(' . $this->alias . '__status' . ', \'NOT_READY\', \'NOT_STARTED\', \'IN_PROGRESS\', \'FAILED\', \'COMPLETED\')' => 'ASC', 'CAST(' . $this->alias . '__age AS SIGNED)' => 'DESC', 'CASE WHEN ' . $this->alias . '__status' . ' IN(\'NOT_READY\', \'NOT_STARTED\', \'IN_PROGRESS\') THEN ' . $this->alias . '.id END ASC', 'CASE WHEN ' . $this->alias . '__status' . ' IN(\'FAILED\', \'COMPLETED\') THEN ' . $this->alias . '.id END DESC', ]; return $this->find('first', compact('fields', 'conditions', 'order')); }
php
public function getPendingJob($jobType = null, $includeFinished = false, $timestamp = null) { if (empty($jobType)) { return false; } if (empty($timestamp) || (!is_int($timestamp) || !ctype_digit($timestamp))) { $timestamp = strtotime('-15 minute'); } $fetchedTime = date('Y-m-d H:i:s', $timestamp); $fields = [ $this->alias . '.jobtype', $this->alias . '.created', $this->alias . '.status', $this->alias . '.age', $this->alias . '.fetched', $this->alias . '.progress', $this->alias . '.completed', $this->alias . '.reference', $this->alias . '.failed', $this->alias . '.failure_message' ]; $conditions = [ 'OR' => [ [ // NOT_READY $this->alias . '.notbefore > NOW()', ], [ // NOT_STARTED $this->alias . '.fetched' => null, ], [ // IN_PROGRESS 'AND' => [ $this->alias . '.fetched NOT' => null, $this->alias . '.fetched >' => $fetchedTime, $this->alias . '.completed' => null, $this->alias . '.failed' => 0, ], ] ], $this->alias . '.jobtype' => $jobType, ]; if ($includeFinished) { $conditions['OR'][] = [ // FAILED 'AND' => [ $this->alias . '.fetched NOT' => null, $this->alias . '.fetched >' => $fetchedTime, $this->alias . '.completed' => null, $this->alias . '.failed >' => 0, ], ]; $conditions['OR'][] = [ // COMPLETED 'AND' => [ $this->alias . '.fetched NOT' => null, $this->alias . '.fetched >' => $fetchedTime, $this->alias . '.completed NOT' => null, ], ]; } $order = [ 'FIELD(' . $this->alias . '__status' . ', \'NOT_READY\', \'NOT_STARTED\', \'IN_PROGRESS\', \'FAILED\', \'COMPLETED\')' => 'ASC', 'CAST(' . $this->alias . '__age AS SIGNED)' => 'DESC', 'CASE WHEN ' . $this->alias . '__status' . ' IN(\'NOT_READY\', \'NOT_STARTED\', \'IN_PROGRESS\') THEN ' . $this->alias . '.id END ASC', 'CASE WHEN ' . $this->alias . '__status' . ' IN(\'FAILED\', \'COMPLETED\') THEN ' . $this->alias . '.id END DESC', ]; return $this->find('first', compact('fields', 'conditions', 'order')); }
[ "public", "function", "getPendingJob", "(", "$", "jobType", "=", "null", ",", "$", "includeFinished", "=", "false", ",", "$", "timestamp", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "jobType", ")", ")", "{", "return", "false", ";", "}", "if...
Return statistics about job still in the Database. @param string $jobType Type of job. @param bool $includeFinished If True, include finished task in result. @param int $timestamp Timestamp for retrieving statistics. @return array|bool Return statistics, or False on failure.
[ "Return", "statistics", "about", "job", "still", "in", "the", "Database", "." ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/ExtendQueuedTask.php#L83-L149
train
anklimsk/cakephp-theme
Model/ExtendQueuedTask.php
ExtendQueuedTask.updateMessage
public function updateMessage($id = null, $message = null) { if (empty($id) || !$this->exists($id)) { return false; } $message = (string)$message; if (empty($message)) { $message = null; } $this->id = (int)$id; return (bool)$this->saveField('failure_message', $message); }
php
public function updateMessage($id = null, $message = null) { if (empty($id) || !$this->exists($id)) { return false; } $message = (string)$message; if (empty($message)) { $message = null; } $this->id = (int)$id; return (bool)$this->saveField('failure_message', $message); }
[ "public", "function", "updateMessage", "(", "$", "id", "=", "null", ",", "$", "message", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "id", ")", "||", "!", "$", "this", "->", "exists", "(", "$", "id", ")", ")", "{", "return", "false", "...
Update massage of job @param int $id ID of job @param string $message Message for update @return bool Success
[ "Update", "massage", "of", "job" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/ExtendQueuedTask.php#L158-L171
train
anklimsk/cakephp-theme
Model/ExtendQueuedTask.php
ExtendQueuedTask.updateTaskProgress
public function updateTaskProgress($id, &$step, $maxStep = 0) { if (empty($id) || !$this->exists($id) || ($maxStep < 1) || ($maxStep < $step)) { return false; } $step++; $progress = $step / $maxStep; return $this->updateProgress($id, $progress); }
php
public function updateTaskProgress($id, &$step, $maxStep = 0) { if (empty($id) || !$this->exists($id) || ($maxStep < 1) || ($maxStep < $step)) { return false; } $step++; $progress = $step / $maxStep; return $this->updateProgress($id, $progress); }
[ "public", "function", "updateTaskProgress", "(", "$", "id", ",", "&", "$", "step", ",", "$", "maxStep", "=", "0", ")", "{", "if", "(", "empty", "(", "$", "id", ")", "||", "!", "$", "this", "->", "exists", "(", "$", "id", ")", "||", "(", "$", ...
Update progress of job @param int $id ID of job @param int &$step Current step of job @param int $maxStep Maximum steps of job @return bool Success
[ "Update", "progress", "of", "job" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/ExtendQueuedTask.php#L181-L191
train
anklimsk/cakephp-theme
Model/ExtendQueuedTask.php
ExtendQueuedTask.updateTaskErrorMessage
public function updateTaskErrorMessage($id = null, $errorMessage = null, $keepExistingMessage = false) { if (empty($id) || !$this->exists($id) || empty($errorMessage)) { return false; } if ($keepExistingMessage) { $this->id = $id; $message = $this->field('failure_message'); if (!empty($message)) { $errorMessage = $message . "\n" . $errorMessage; } } return $this->markJobFailed($id, $errorMessage); }
php
public function updateTaskErrorMessage($id = null, $errorMessage = null, $keepExistingMessage = false) { if (empty($id) || !$this->exists($id) || empty($errorMessage)) { return false; } if ($keepExistingMessage) { $this->id = $id; $message = $this->field('failure_message'); if (!empty($message)) { $errorMessage = $message . "\n" . $errorMessage; } } return $this->markJobFailed($id, $errorMessage); }
[ "public", "function", "updateTaskErrorMessage", "(", "$", "id", "=", "null", ",", "$", "errorMessage", "=", "null", ",", "$", "keepExistingMessage", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "id", ")", "||", "!", "$", "this", "->", "exists"...
Update error massage of job @param int $id ID of job @param string $errorMessage Error message for update @param bool $keepExistingMessage If True, keep existing error message @return bool Success
[ "Update", "error", "massage", "of", "job" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/ExtendQueuedTask.php#L202-L216
train
anklimsk/cakephp-theme
Model/ExtendQueuedTask.php
ExtendQueuedTask.deleteTasks
public function deleteTasks($data = null) { if (empty($data) || !is_array($data)) { return false; } $excludeFields = [ 'data', 'failure_message', 'workerkey', ]; $data = array_diff_key($data, array_flip($excludeFields)); $conditions = []; foreach ($data as $field => $value) { $conditions[$this->alias . '.' . $field] = $value; } if (empty($conditions)) { return false; } $countTasks = $this->find('count', compact('conditions')); if (($countTasks == 0) || !$this->deleteAll($conditions)) { return false; } return true; }
php
public function deleteTasks($data = null) { if (empty($data) || !is_array($data)) { return false; } $excludeFields = [ 'data', 'failure_message', 'workerkey', ]; $data = array_diff_key($data, array_flip($excludeFields)); $conditions = []; foreach ($data as $field => $value) { $conditions[$this->alias . '.' . $field] = $value; } if (empty($conditions)) { return false; } $countTasks = $this->find('count', compact('conditions')); if (($countTasks == 0) || !$this->deleteAll($conditions)) { return false; } return true; }
[ "public", "function", "deleteTasks", "(", "$", "data", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "data", ")", "||", "!", "is_array", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "$", "excludeFields", "=", "[", "'data'", ...
Delete tasks by fields value @param array $data Data of task for deleting @return bool Success
[ "Delete", "tasks", "by", "fields", "value" ]
b815a4aaabaaf03ef1df3d547200f73f332f38a7
https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/ExtendQueuedTask.php#L224-L250
train
Celarius/spin-framework
src/Core/ConnectionManager.php
ConnectionManager.findConnection
public function findConnection(string $name=null) { if ( empty($name) ) { # Take first available connection $connection = \reset($this->connections); if ($connection === false) return null; } else { # Attempt to find the connection from the pool $connection = ( $this->connections[\strtolower($name)] ?? null); } return $connection; }
php
public function findConnection(string $name=null) { if ( empty($name) ) { # Take first available connection $connection = \reset($this->connections); if ($connection === false) return null; } else { # Attempt to find the connection from the pool $connection = ( $this->connections[\strtolower($name)] ?? null); } return $connection; }
[ "public", "function", "findConnection", "(", "string", "$", "name", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "# Take first available connection", "$", "connection", "=", "\\", "reset", "(", "$", "this", "->", "connections...
Find a connection in the pool If the $name is empty/null we'll return the 1st connection in the internal connection list (if there is one) @param string $name Name of the connection (from Config) @return null | PdoConnection
[ "Find", "a", "connection", "in", "the", "pool" ]
2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0
https://github.com/Celarius/spin-framework/blob/2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0/src/Core/ConnectionManager.php#L67-L80
train
Celarius/spin-framework
src/Core/ConnectionManager.php
ConnectionManager.addConnection
public function addConnection(PdoConnectionInterface $connection) { $this->connections[\strtolower($connection->getName())] = $connection; return $connection; }
php
public function addConnection(PdoConnectionInterface $connection) { $this->connections[\strtolower($connection->getName())] = $connection; return $connection; }
[ "public", "function", "addConnection", "(", "PdoConnectionInterface", "$", "connection", ")", "{", "$", "this", "->", "connections", "[", "\\", "strtolower", "(", "$", "connection", "->", "getName", "(", ")", ")", "]", "=", "$", "connection", ";", "return", ...
Adds a Connection to the Pool @param PdoConnectionInterface $connection [description] @return connection
[ "Adds", "a", "Connection", "to", "the", "Pool" ]
2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0
https://github.com/Celarius/spin-framework/blob/2c0d1dfc3c2ed556632dfe5ff9113600a72a93d0/src/Core/ConnectionManager.php#L89-L94
train
narrowspark/mimetypes
src/MimeType.php
MimeType.register
public static function register(string $guesser): void { if (\in_array(MimeTypeGuesserContract::class, \class_implements($guesser), true)) { \array_unshift(self::$guessers, $guesser); } throw new RuntimeException(\sprintf('You guesser [%s] should implement the [\%s].', $guesser, MimeTypeGuesserContract::class)); }
php
public static function register(string $guesser): void { if (\in_array(MimeTypeGuesserContract::class, \class_implements($guesser), true)) { \array_unshift(self::$guessers, $guesser); } throw new RuntimeException(\sprintf('You guesser [%s] should implement the [\%s].', $guesser, MimeTypeGuesserContract::class)); }
[ "public", "static", "function", "register", "(", "string", "$", "guesser", ")", ":", "void", "{", "if", "(", "\\", "in_array", "(", "MimeTypeGuesserContract", "::", "class", ",", "\\", "class_implements", "(", "$", "guesser", ")", ",", "true", ")", ")", ...
Registers a new mime type guesser. When guessing, this guesser is preferred over previously registered ones. @param string $guesser Should implement \Narrowspark\MimeType\Contract\MimeTypeGuesser interface @return void
[ "Registers", "a", "new", "mime", "type", "guesser", ".", "When", "guessing", "this", "guesser", "is", "preferred", "over", "previously", "registered", "ones", "." ]
3ce9277e7e93edb04b269bc3e37181e2e51ce0ac
https://github.com/narrowspark/mimetypes/blob/3ce9277e7e93edb04b269bc3e37181e2e51ce0ac/src/MimeType.php#L41-L48
train
narrowspark/mimetypes
src/MimeType.php
MimeType.guess
public static function guess(string $guess): ?string { $guessers = self::getGuessers(); if (\count($guessers) === 0) { $msg = 'Unable to guess the mime type as no guessers are available'; if (! MimeTypeFileInfoGuesser::isSupported()) { $msg .= ' (Did you enable the php_fileinfo extension?).'; } throw new \LogicException($msg); } $exception = null; foreach ($guessers as $guesser) { try { $mimeType = $guesser::guess($guess); } catch (RuntimeException $e) { $exception = $e; continue; } if ($mimeType !== null) { return $mimeType; } } // Throw the last catched exception. if ($exception !== null) { throw $exception; } return null; }
php
public static function guess(string $guess): ?string { $guessers = self::getGuessers(); if (\count($guessers) === 0) { $msg = 'Unable to guess the mime type as no guessers are available'; if (! MimeTypeFileInfoGuesser::isSupported()) { $msg .= ' (Did you enable the php_fileinfo extension?).'; } throw new \LogicException($msg); } $exception = null; foreach ($guessers as $guesser) { try { $mimeType = $guesser::guess($guess); } catch (RuntimeException $e) { $exception = $e; continue; } if ($mimeType !== null) { return $mimeType; } } // Throw the last catched exception. if ($exception !== null) { throw $exception; } return null; }
[ "public", "static", "function", "guess", "(", "string", "$", "guess", ")", ":", "?", "string", "{", "$", "guessers", "=", "self", "::", "getGuessers", "(", ")", ";", "if", "(", "\\", "count", "(", "$", "guessers", ")", "===", "0", ")", "{", "$", ...
Tries to guess the mime type. @param string $guess The path to the file or the file extension @throws \Narrowspark\MimeType\Exception\FileNotFoundException If the file does not exist @throws \Narrowspark\MimeType\Exception\AccessDeniedException If the file could not be read @return null|string The guessed extension or NULL, if none could be guessed
[ "Tries", "to", "guess", "the", "mime", "type", "." ]
3ce9277e7e93edb04b269bc3e37181e2e51ce0ac
https://github.com/narrowspark/mimetypes/blob/3ce9277e7e93edb04b269bc3e37181e2e51ce0ac/src/MimeType.php#L60-L96
train
narrowspark/mimetypes
src/MimeType.php
MimeType.getGuessers
private static function getGuessers(): array { if (! self::$nativeGuessersLoaded) { if (MimeTypeFileExtensionGuesser::isSupported()) { self::$guessers[] = MimeTypeFileExtensionGuesser::class; } if (MimeTypeFileInfoGuesser::isSupported()) { self::$guessers[] = MimeTypeFileInfoGuesser::class; } if (MimeTypeFileBinaryGuesser::isSupported()) { self::$guessers[] = MimeTypeFileBinaryGuesser::class; } self::$nativeGuessersLoaded = true; } return self::$guessers; }
php
private static function getGuessers(): array { if (! self::$nativeGuessersLoaded) { if (MimeTypeFileExtensionGuesser::isSupported()) { self::$guessers[] = MimeTypeFileExtensionGuesser::class; } if (MimeTypeFileInfoGuesser::isSupported()) { self::$guessers[] = MimeTypeFileInfoGuesser::class; } if (MimeTypeFileBinaryGuesser::isSupported()) { self::$guessers[] = MimeTypeFileBinaryGuesser::class; } self::$nativeGuessersLoaded = true; } return self::$guessers; }
[ "private", "static", "function", "getGuessers", "(", ")", ":", "array", "{", "if", "(", "!", "self", "::", "$", "nativeGuessersLoaded", ")", "{", "if", "(", "MimeTypeFileExtensionGuesser", "::", "isSupported", "(", ")", ")", "{", "self", "::", "$", "guesse...
Register all natively provided mime type guessers. @return string[]
[ "Register", "all", "natively", "provided", "mime", "type", "guessers", "." ]
3ce9277e7e93edb04b269bc3e37181e2e51ce0ac
https://github.com/narrowspark/mimetypes/blob/3ce9277e7e93edb04b269bc3e37181e2e51ce0ac/src/MimeType.php#L103-L122
train
inc2734/wp-oembed-blog-card
src/App/View/View.php
View.get_block_template
public static function get_block_template( $url ) { $template = static::get_template( $url ); $template = str_replace( '<a ', '<span ', $template ); $template = str_replace( '</a>', '</span>', $template ); // @codingStandardsIgnoreStart $template .= sprintf( '<link rel="stylesheet" href="%1$s">', esc_url_raw( get_template_directory_uri() . '/vendor/inc2734/wp-oembed-blog-card/src/assets/css/gutenberg-embed.min.css' ) ); $template .= sprintf( '<link rel="stylesheet" href="%1$s">', esc_url_raw( get_template_directory_uri() . '/vendor/inc2734/wp-oembed-blog-card/src/assets/css/app.min.css' ) ); // @codingStandardsIgnoreEnd return static::_strip_newlines( apply_filters( 'wp_oembed_blog_card_gutenberg_template', $template, $url ) ); }
php
public static function get_block_template( $url ) { $template = static::get_template( $url ); $template = str_replace( '<a ', '<span ', $template ); $template = str_replace( '</a>', '</span>', $template ); // @codingStandardsIgnoreStart $template .= sprintf( '<link rel="stylesheet" href="%1$s">', esc_url_raw( get_template_directory_uri() . '/vendor/inc2734/wp-oembed-blog-card/src/assets/css/gutenberg-embed.min.css' ) ); $template .= sprintf( '<link rel="stylesheet" href="%1$s">', esc_url_raw( get_template_directory_uri() . '/vendor/inc2734/wp-oembed-blog-card/src/assets/css/app.min.css' ) ); // @codingStandardsIgnoreEnd return static::_strip_newlines( apply_filters( 'wp_oembed_blog_card_gutenberg_template', $template, $url ) ); }
[ "public", "static", "function", "get_block_template", "(", "$", "url", ")", "{", "$", "template", "=", "static", "::", "get_template", "(", "$", "url", ")", ";", "$", "template", "=", "str_replace", "(", "'<a '", ",", "'<span '", ",", "$", "template", ")...
Render template for block editor @param string $url @return string
[ "Render", "template", "for", "block", "editor" ]
4882994152f9003db9c68517a53090cbef13ff4d
https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/View/View.php#L20-L37
train
inc2734/wp-oembed-blog-card
src/App/View/View.php
View.get_pre_blog_card_template
public static function get_pre_blog_card_template( $url ) { if ( ! $url ) { return; } if ( 0 === strpos( $url, home_url() ) ) { $target = '_self'; } else { $target = '_blank'; } return static::_strip_newlines( sprintf( '<div class="js-wp-oembed-blog-card"> <a class="js-wp-oembed-blog-card__link" href="%1$s" target="%2$s">%1$s</a> </div>', esc_url( $url ), esc_attr( $target ) ) ); }
php
public static function get_pre_blog_card_template( $url ) { if ( ! $url ) { return; } if ( 0 === strpos( $url, home_url() ) ) { $target = '_self'; } else { $target = '_blank'; } return static::_strip_newlines( sprintf( '<div class="js-wp-oembed-blog-card"> <a class="js-wp-oembed-blog-card__link" href="%1$s" target="%2$s">%1$s</a> </div>', esc_url( $url ), esc_attr( $target ) ) ); }
[ "public", "static", "function", "get_pre_blog_card_template", "(", "$", "url", ")", "{", "if", "(", "!", "$", "url", ")", "{", "return", ";", "}", "if", "(", "0", "===", "strpos", "(", "$", "url", ",", "home_url", "(", ")", ")", ")", "{", "$", "t...
Render pre blog card template @param string $url @return string
[ "Render", "pre", "blog", "card", "template" ]
4882994152f9003db9c68517a53090cbef13ff4d
https://github.com/inc2734/wp-oembed-blog-card/blob/4882994152f9003db9c68517a53090cbef13ff4d/src/App/View/View.php#L45-L65
train
ansas/php-component
src/Util/Path.php
Path.combine
public static function combine($part1, $part2) { if ($part1 && $part2) { return sprintf("%s/%s", rtrim($part1, '/'), ltrim($part2, '/')); } throw new InvalidArgumentException("All parts must be filled"); }
php
public static function combine($part1, $part2) { if ($part1 && $part2) { return sprintf("%s/%s", rtrim($part1, '/'), ltrim($part2, '/')); } throw new InvalidArgumentException("All parts must be filled"); }
[ "public", "static", "function", "combine", "(", "$", "part1", ",", "$", "part2", ")", "{", "if", "(", "$", "part1", "&&", "$", "part2", ")", "{", "return", "sprintf", "(", "\"%s/%s\"", ",", "rtrim", "(", "$", "part1", ",", "'/'", ")", ",", "ltrim",...
Combine path parts. @param string $part1 @param string $part2 @return string @throws InvalidArgumentException
[ "Combine", "path", "parts", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Path.php#L58-L65
train
ansas/php-component
src/Util/Path.php
Path.getRoot
public static function getRoot($rootForPath = null, $rootHasDir = 'lib') { if (!$rootForPath) { $includes = get_included_files(); $rootForPath = $includes[0]; } $rootForPath = rtrim($rootForPath, DIRECTORY_SEPARATOR); $rootHasDir = ltrim($rootHasDir, DIRECTORY_SEPARATOR); while (!is_dir($rootForPath . DIRECTORY_SEPARATOR . $rootHasDir)) { $rootForPath = dirname($rootForPath); if ($rootForPath == DIRECTORY_SEPARATOR) { throw new Exception("Cannot determine root path."); } } return $rootForPath; }
php
public static function getRoot($rootForPath = null, $rootHasDir = 'lib') { if (!$rootForPath) { $includes = get_included_files(); $rootForPath = $includes[0]; } $rootForPath = rtrim($rootForPath, DIRECTORY_SEPARATOR); $rootHasDir = ltrim($rootHasDir, DIRECTORY_SEPARATOR); while (!is_dir($rootForPath . DIRECTORY_SEPARATOR . $rootHasDir)) { $rootForPath = dirname($rootForPath); if ($rootForPath == DIRECTORY_SEPARATOR) { throw new Exception("Cannot determine root path."); } } return $rootForPath; }
[ "public", "static", "function", "getRoot", "(", "$", "rootForPath", "=", "null", ",", "$", "rootHasDir", "=", "'lib'", ")", "{", "if", "(", "!", "$", "rootForPath", ")", "{", "$", "includes", "=", "get_included_files", "(", ")", ";", "$", "rootForPath", ...
Get the "project" root path. For an optionally specified $rootForPath (default is start script path) it traverses the path structure until it finds an optionally specified $rootHasDir (default is "lib") and returns it. Throws an Exception if root path cannot be determined. @param string $rootForPath [optional] The file or path to get project root path for. @param string $rootHasDir [optional] The directory that must exist in root path. @return string The root path @throws Exception If root path cannot be determined
[ "Get", "the", "project", "root", "path", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Path.php#L170-L188
train
ansas/php-component
src/Util/Path.php
Path.purge
public static function purge($path, $fileFilterRegex = null, $dirFilterRegex = null) { Path::validatePath($path); $iterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); $iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST); foreach ((array) $fileFilterRegex as $regex) { $iterator = new FileRegexIterator($iterator, $regex); } foreach ((array) $dirFilterRegex as $regex) { $iterator = new DirectoryRegexIterator($iterator, $regex); } foreach ($iterator as $file) { if ($file->isDir()) { Path::delete($file->getPathName()); continue; } File::delete($file->getPathname()); } }
php
public static function purge($path, $fileFilterRegex = null, $dirFilterRegex = null) { Path::validatePath($path); $iterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); $iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST); foreach ((array) $fileFilterRegex as $regex) { $iterator = new FileRegexIterator($iterator, $regex); } foreach ((array) $dirFilterRegex as $regex) { $iterator = new DirectoryRegexIterator($iterator, $regex); } foreach ($iterator as $file) { if ($file->isDir()) { Path::delete($file->getPathName()); continue; } File::delete($file->getPathname()); } }
[ "public", "static", "function", "purge", "(", "$", "path", ",", "$", "fileFilterRegex", "=", "null", ",", "$", "dirFilterRegex", "=", "null", ")", "{", "Path", "::", "validatePath", "(", "$", "path", ")", ";", "$", "iterator", "=", "new", "RecursiveDirec...
Delete directory content. @param string $path @param string|array $fileFilterRegex [optional] Regex of files to purge (can be negated to skip files) @param string|array $dirFilterRegex [optional] Regex of dirs to purge (can be negated to skip dirs)
[ "Delete", "directory", "content", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Path.php#L197-L219
train
ansas/php-component
src/Slim/Http/ExtendedRequest.php
ExtendedRequest.getIp
public function getIp() { $keys = ['X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP', 'REMOTE_ADDR']; foreach ($keys as $key) { $ip = $this->getServerParam($key); if (!$ip) { continue; } $ip = preg_replace('/,.*$/u', '', $ip); $ip = trim($ip); return $ip; } return null; }
php
public function getIp() { $keys = ['X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP', 'REMOTE_ADDR']; foreach ($keys as $key) { $ip = $this->getServerParam($key); if (!$ip) { continue; } $ip = preg_replace('/,.*$/u', '', $ip); $ip = trim($ip); return $ip; } return null; }
[ "public", "function", "getIp", "(", ")", "{", "$", "keys", "=", "[", "'X_FORWARDED_FOR'", ",", "'HTTP_X_FORWARDED_FOR'", ",", "'CLIENT_IP'", ",", "'REMOTE_ADDR'", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "ip", "=", "$", "...
Get request ip. Note: This method is not part of the PSR-7 standard. @return string|null
[ "Get", "request", "ip", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Slim/Http/ExtendedRequest.php#L162-L180
train
ansas/php-component
src/Slim/Http/ExtendedRequest.php
ExtendedRequest.getRequestTargetWithParams
public function getRequestTargetWithParams($params) { $target = $this->getFullPath(); if ($params) { $target .= '?' . http_build_query($params); } return $target; }
php
public function getRequestTargetWithParams($params) { $target = $this->getFullPath(); if ($params) { $target .= '?' . http_build_query($params); } return $target; }
[ "public", "function", "getRequestTargetWithParams", "(", "$", "params", ")", "{", "$", "target", "=", "$", "this", "->", "getFullPath", "(", ")", ";", "if", "(", "$", "params", ")", "{", "$", "target", ".=", "'?'", ".", "http_build_query", "(", "$", "p...
Get Request URI. Note: This method is not part of the PSR-7 standard. @param array $params @return string
[ "Get", "Request", "URI", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Slim/Http/ExtendedRequest.php#L291-L300
train
ansas/php-component
src/Slim/Http/ExtendedRequest.php
ExtendedRequest.withHost
public function withHost($host) { $uri = $this->getUri()->withHost($host); /** @var static $clone */ $clone = $this->withUri($uri); return $clone; }
php
public function withHost($host) { $uri = $this->getUri()->withHost($host); /** @var static $clone */ $clone = $this->withUri($uri); return $clone; }
[ "public", "function", "withHost", "(", "$", "host", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", ")", "->", "withHost", "(", "$", "host", ")", ";", "/** @var static $clone */", "$", "clone", "=", "$", "this", "->", "withUri", "(", "$"...
Returns an instance with the provided host. Note: This method is not part of the PSR-7 standard. @param string $host @return static
[ "Returns", "an", "instance", "with", "the", "provided", "host", "." ]
24574a1e32d5f1355a6e2b6f20f49b1eda7250ba
https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Slim/Http/ExtendedRequest.php#L323-L331
train
mridang/pearify
src/Pearify/Pearify.php
Pearify.getTempDir
protected static function getTempDir() { $name = tempnam(sys_get_temp_dir(), 'tmp'); unlink($name); mkdir($name, 0777, true); return $name; }
php
protected static function getTempDir() { $name = tempnam(sys_get_temp_dir(), 'tmp'); unlink($name); mkdir($name, 0777, true); return $name; }
[ "protected", "static", "function", "getTempDir", "(", ")", "{", "$", "name", "=", "tempnam", "(", "sys_get_temp_dir", "(", ")", ",", "'tmp'", ")", ";", "unlink", "(", "$", "name", ")", ";", "mkdir", "(", "$", "name", ",", "0777", ",", "true", ")", ...
Returns a newly created temporary directory in the OS's temporary location. All the files and folders of the package are moved to this directory and packaged. @return string the path the newly created temporary directory
[ "Returns", "a", "newly", "created", "temporary", "directory", "in", "the", "OS", "s", "temporary", "location", ".", "All", "the", "files", "and", "folders", "of", "the", "package", "are", "moved", "to", "this", "directory", "and", "packaged", "." ]
7bc0710beb4165164e07f88b456de47cad8b3002
https://github.com/mridang/pearify/blob/7bc0710beb4165164e07f88b456de47cad8b3002/src/Pearify/Pearify.php#L104-L110
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/PlayersBundle/Model/Base/Player.php
Player.initRecords
public function initRecords($overrideExisting = true) { if (null !== $this->collRecords && !$overrideExisting) { return; } $collectionClassName = RecordTableMap::getTableMap()->getCollectionClassName(); $this->collRecords = new $collectionClassName; $this->collRecords->setModel('\eXpansion\Bundle\LocalRecords\Model\Record'); }
php
public function initRecords($overrideExisting = true) { if (null !== $this->collRecords && !$overrideExisting) { return; } $collectionClassName = RecordTableMap::getTableMap()->getCollectionClassName(); $this->collRecords = new $collectionClassName; $this->collRecords->setModel('\eXpansion\Bundle\LocalRecords\Model\Record'); }
[ "public", "function", "initRecords", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collRecords", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "collectionClassName", "=", "Record...
Initializes the collRecords collection. By default this just sets the collRecords collection to an empty array (like clearcollRecords()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collRecords", "collection", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/Player.php#L1474-L1484
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/PlayersBundle/Model/Base/Player.php
Player.getRecords
public function getRecords(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collRecordsPartial && !$this->isNew(); if (null === $this->collRecords || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRecords) { // return empty collection $this->initRecords(); } else { $collRecords = RecordQuery::create(null, $criteria) ->filterByPlayer($this) ->find($con); if (null !== $criteria) { if (false !== $this->collRecordsPartial && count($collRecords)) { $this->initRecords(false); foreach ($collRecords as $obj) { if (false == $this->collRecords->contains($obj)) { $this->collRecords->append($obj); } } $this->collRecordsPartial = true; } return $collRecords; } if ($partial && $this->collRecords) { foreach ($this->collRecords as $obj) { if ($obj->isNew()) { $collRecords[] = $obj; } } } $this->collRecords = $collRecords; $this->collRecordsPartial = false; } } return $this->collRecords; }
php
public function getRecords(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collRecordsPartial && !$this->isNew(); if (null === $this->collRecords || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRecords) { // return empty collection $this->initRecords(); } else { $collRecords = RecordQuery::create(null, $criteria) ->filterByPlayer($this) ->find($con); if (null !== $criteria) { if (false !== $this->collRecordsPartial && count($collRecords)) { $this->initRecords(false); foreach ($collRecords as $obj) { if (false == $this->collRecords->contains($obj)) { $this->collRecords->append($obj); } } $this->collRecordsPartial = true; } return $collRecords; } if ($partial && $this->collRecords) { foreach ($this->collRecords as $obj) { if ($obj->isNew()) { $collRecords[] = $obj; } } } $this->collRecords = $collRecords; $this->collRecordsPartial = false; } } return $this->collRecords; }
[ "public", "function", "getRecords", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collRecordsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")...
Gets an array of Record objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildPlayer is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return ObjectCollection|Record[] List of Record objects @throws PropelException
[ "Gets", "an", "array", "of", "Record", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/Player.php#L1500-L1542
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/PlayersBundle/Model/Base/Player.php
Player.countRecords
public function countRecords(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRecordsPartial && !$this->isNew(); if (null === $this->collRecords || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRecords) { return 0; } if ($partial && !$criteria) { return count($this->getRecords()); } $query = RecordQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByPlayer($this) ->count($con); } return count($this->collRecords); }
php
public function countRecords(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collRecordsPartial && !$this->isNew(); if (null === $this->collRecords || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collRecords) { return 0; } if ($partial && !$criteria) { return count($this->getRecords()); } $query = RecordQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByPlayer($this) ->count($con); } return count($this->collRecords); }
[ "public", "function", "countRecords", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collRecordsPartial", "&&", "!",...
Returns the number of related BaseRecord objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related BaseRecord objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "BaseRecord", "objects", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/Player.php#L1586-L1609
train
eXpansionPluginPack/eXpansion2
src/eXpansion/Framework/PlayersBundle/Model/Base/Player.php
Player.addRecord
public function addRecord(Record $l) { if ($this->collRecords === null) { $this->initRecords(); $this->collRecordsPartial = true; } if (!$this->collRecords->contains($l)) { $this->doAddRecord($l); if ($this->recordsScheduledForDeletion and $this->recordsScheduledForDeletion->contains($l)) { $this->recordsScheduledForDeletion->remove($this->recordsScheduledForDeletion->search($l)); } } return $this; }
php
public function addRecord(Record $l) { if ($this->collRecords === null) { $this->initRecords(); $this->collRecordsPartial = true; } if (!$this->collRecords->contains($l)) { $this->doAddRecord($l); if ($this->recordsScheduledForDeletion and $this->recordsScheduledForDeletion->contains($l)) { $this->recordsScheduledForDeletion->remove($this->recordsScheduledForDeletion->search($l)); } } return $this; }
[ "public", "function", "addRecord", "(", "Record", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collRecords", "===", "null", ")", "{", "$", "this", "->", "initRecords", "(", ")", ";", "$", "this", "->", "collRecordsPartial", "=", "true", ";", "}...
Method called to associate a Record object to this object through the Record foreign key attribute. @param Record $l Record @return $this|\eXpansion\Framework\PlayersBundle\Model\Player The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "Record", "object", "to", "this", "object", "through", "the", "Record", "foreign", "key", "attribute", "." ]
e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31
https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Base/Player.php#L1618-L1634
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Repositories/Account/EloquentAccount.php
EloquentAccount.byIds
public function byIds(array $ids, $databaseConnectionName = null) { if(empty($databaseConnectionName)) { $databaseConnectionName = $this->databaseConnectionName; } return $this->Account->setConnection($databaseConnectionName) ->whereIn('id',$ids) ->get(); }
php
public function byIds(array $ids, $databaseConnectionName = null) { if(empty($databaseConnectionName)) { $databaseConnectionName = $this->databaseConnectionName; } return $this->Account->setConnection($databaseConnectionName) ->whereIn('id',$ids) ->get(); }
[ "public", "function", "byIds", "(", "array", "$", "ids", ",", "$", "databaseConnectionName", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "databaseConnectionName", ")", ")", "{", "$", "databaseConnectionName", "=", "$", "this", "->", "databaseConnect...
Get an account by ID's @param int $id @return Mgallegos\DecimaAccounting\Account
[ "Get", "an", "account", "by", "ID", "s" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Repositories/Account/EloquentAccount.php#L77-L87
train
mgallegos/decima-accounting
src/Mgallegos/DecimaAccounting/Accounting/Repositories/Account/EloquentAccount.php
EloquentAccount.byOrganizationAndByKey
public function byOrganizationAndByKey($organizationId, $key) { if(empty($databaseConnectionName)) { $databaseConnectionName = $this->databaseConnectionName; } return $this->Account->setConnection($databaseConnectionName) ->where('organization_id', '=', $organizationId) ->where('key', '=', $key)->get(); }
php
public function byOrganizationAndByKey($organizationId, $key) { if(empty($databaseConnectionName)) { $databaseConnectionName = $this->databaseConnectionName; } return $this->Account->setConnection($databaseConnectionName) ->where('organization_id', '=', $organizationId) ->where('key', '=', $key)->get(); }
[ "public", "function", "byOrganizationAndByKey", "(", "$", "organizationId", ",", "$", "key", ")", "{", "if", "(", "empty", "(", "$", "databaseConnectionName", ")", ")", "{", "$", "databaseConnectionName", "=", "$", "this", "->", "databaseConnectionName", ";", ...
Retrieve accounts by organization and by key @param int $organizationId @param string $key @return Illuminate\Database\Eloquent\Collection
[ "Retrieve", "accounts", "by", "organization", "and", "by", "key" ]
6410585303a13892e64e9dfeacbae0ca212b458b
https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Repositories/Account/EloquentAccount.php#L116-L126
train