id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
9,600
extendsframework/extends-event
src/Publisher/EventPublisher.php
EventPublisher.addEventListener
public function addEventListener(EventListenerInterface $eventListener, string $payloadName): EventPublisher { $this->eventListeners[$payloadName][] = $eventListener; return $this; }
php
public function addEventListener(EventListenerInterface $eventListener, string $payloadName): EventPublisher { $this->eventListeners[$payloadName][] = $eventListener; return $this; }
[ "public", "function", "addEventListener", "(", "EventListenerInterface", "$", "eventListener", ",", "string", "$", "payloadName", ")", ":", "EventPublisher", "{", "$", "this", "->", "eventListeners", "[", "$", "payloadName", "]", "[", "]", "=", "$", "eventListener", ";", "return", "$", "this", ";", "}" ]
Add event listener. @param EventListenerInterface $eventListener @param string $payloadName @return EventPublisher
[ "Add", "event", "listener", "." ]
43344d3a803081431c688aa8eb11fd3680eb8956
https://github.com/extendsframework/extends-event/blob/43344d3a803081431c688aa8eb11fd3680eb8956/src/Publisher/EventPublisher.php#L36-L41
9,601
emaphp/eMapper
lib/eMapper/Dynamic/Provider/EnvironmentProvider.php
EnvironmentProvider.getEnvironment
public static function getEnvironment($id) { if (!array_key_exists($id, self::$environments)) throw new \InvalidArgumentException("Environment with ID $id does not exists"); return self::$environments[$id]; }
php
public static function getEnvironment($id) { if (!array_key_exists($id, self::$environments)) throw new \InvalidArgumentException("Environment with ID $id does not exists"); return self::$environments[$id]; }
[ "public", "static", "function", "getEnvironment", "(", "$", "id", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "id", ",", "self", "::", "$", "environments", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Environment with ID $id does not exists\"", ")", ";", "return", "self", "::", "$", "environments", "[", "$", "id", "]", ";", "}" ]
Obtains a dynamic SQL environment instance by ID @param string $id @throws \InvalidArgumentException
[ "Obtains", "a", "dynamic", "SQL", "environment", "instance", "by", "ID" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Dynamic/Provider/EnvironmentProvider.php#L30-L35
9,602
emaphp/eMapper
lib/eMapper/Dynamic/Provider/EnvironmentProvider.php
EnvironmentProvider.buildEnvironment
public static function buildEnvironment($id, $classname) { //validate id if (!is_string($id) || empty($id)) throw new \InvalidArgumentException("Environment id must be defined as a valid string"); //validate class name if (!is_string($classname) || empty($classname)) throw new \InvalidArgumentException("Parameter is not a valid environment class"); elseif (!class_exists($classname, true)) throw new \InvalidArgumentException("Environment class $classname was not found"); $rc = new \ReflectionClass($classname); //validate if class is a valid environment if (!$rc->isSubclassOf('eMapper\Dynamic\Environment\DynamicSQLEnvironment') && $classname != 'eMapper\Dynamic\Environment\DynamicSQLEnvironment') throw new \InvalidArgumentException("Class $classname is not a valid environment class"); self::$environments[$id] = new $classname(); return true; }
php
public static function buildEnvironment($id, $classname) { //validate id if (!is_string($id) || empty($id)) throw new \InvalidArgumentException("Environment id must be defined as a valid string"); //validate class name if (!is_string($classname) || empty($classname)) throw new \InvalidArgumentException("Parameter is not a valid environment class"); elseif (!class_exists($classname, true)) throw new \InvalidArgumentException("Environment class $classname was not found"); $rc = new \ReflectionClass($classname); //validate if class is a valid environment if (!$rc->isSubclassOf('eMapper\Dynamic\Environment\DynamicSQLEnvironment') && $classname != 'eMapper\Dynamic\Environment\DynamicSQLEnvironment') throw new \InvalidArgumentException("Class $classname is not a valid environment class"); self::$environments[$id] = new $classname(); return true; }
[ "public", "static", "function", "buildEnvironment", "(", "$", "id", ",", "$", "classname", ")", "{", "//validate id", "if", "(", "!", "is_string", "(", "$", "id", ")", "||", "empty", "(", "$", "id", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Environment id must be defined as a valid string\"", ")", ";", "//validate class name", "if", "(", "!", "is_string", "(", "$", "classname", ")", "||", "empty", "(", "$", "classname", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Parameter is not a valid environment class\"", ")", ";", "elseif", "(", "!", "class_exists", "(", "$", "classname", ",", "true", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Environment class $classname was not found\"", ")", ";", "$", "rc", "=", "new", "\\", "ReflectionClass", "(", "$", "classname", ")", ";", "//validate if class is a valid environment", "if", "(", "!", "$", "rc", "->", "isSubclassOf", "(", "'eMapper\\Dynamic\\Environment\\DynamicSQLEnvironment'", ")", "&&", "$", "classname", "!=", "'eMapper\\Dynamic\\Environment\\DynamicSQLEnvironment'", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Class $classname is not a valid environment class\"", ")", ";", "self", "::", "$", "environments", "[", "$", "id", "]", "=", "new", "$", "classname", "(", ")", ";", "return", "true", ";", "}" ]
Generates a new environment @param string $id @param string $classname @throws \InvalidArgumentException @return boolean
[ "Generates", "a", "new", "environment" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Dynamic/Provider/EnvironmentProvider.php#L44-L63
9,603
demmonico/yii2-helpers
src/ReflectionHelper.php
ReflectionHelper.parseGetterName
public static function parseGetterName($getterName) { if (false !== $pos = strpos($getterName, 'get')) $getterName = substr($getterName, 3); return strtolower($getterName); }
php
public static function parseGetterName($getterName) { if (false !== $pos = strpos($getterName, 'get')) $getterName = substr($getterName, 3); return strtolower($getterName); }
[ "public", "static", "function", "parseGetterName", "(", "$", "getterName", ")", "{", "if", "(", "false", "!==", "$", "pos", "=", "strpos", "(", "$", "getterName", ",", "'get'", ")", ")", "$", "getterName", "=", "substr", "(", "$", "getterName", ",", "3", ")", ";", "return", "strtolower", "(", "$", "getterName", ")", ";", "}" ]
Returns name of getter without 'get' @param $getterName @return string
[ "Returns", "name", "of", "getter", "without", "get" ]
b6e1841d114b2f3eecfdd187ce2643a49cd5730d
https://github.com/demmonico/yii2-helpers/blob/b6e1841d114b2f3eecfdd187ce2643a49cd5730d/src/ReflectionHelper.php#L20-L25
9,604
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Infobar.php
Infobar.getRenderedPublished
public function getRenderedPublished() { $rendered = $this->getRenderedContent(); if ( $rendered instanceof Content ) { return DateTime::max( $rendered->publishedFrom, $rendered->created ); } return null; }
php
public function getRenderedPublished() { $rendered = $this->getRenderedContent(); if ( $rendered instanceof Content ) { return DateTime::max( $rendered->publishedFrom, $rendered->created ); } return null; }
[ "public", "function", "getRenderedPublished", "(", ")", "{", "$", "rendered", "=", "$", "this", "->", "getRenderedContent", "(", ")", ";", "if", "(", "$", "rendered", "instanceof", "Content", ")", "{", "return", "DateTime", "::", "max", "(", "$", "rendered", "->", "publishedFrom", ",", "$", "rendered", "->", "created", ")", ";", "}", "return", "null", ";", "}" ]
Get published date @return \DateTime
[ "Get", "published", "date" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Infobar.php#L152-L165
9,605
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Infobar.php
Infobar.setRootCreated
public function setRootCreated( $value ) { $content = $this->getDependentContent(); if ( $content ) { $content->created = $value; } return $this; }
php
public function setRootCreated( $value ) { $content = $this->getDependentContent(); if ( $content ) { $content->created = $value; } return $this; }
[ "public", "function", "setRootCreated", "(", "$", "value", ")", "{", "$", "content", "=", "$", "this", "->", "getDependentContent", "(", ")", ";", "if", "(", "$", "content", ")", "{", "$", "content", "->", "created", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set root's created time @param string $value @return \Paragraph\Model\Paragraph\Structure\Infobar
[ "Set", "root", "s", "created", "time" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Infobar.php#L190-L200
9,606
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Infobar.php
Infobar.setRootUserId
public function setRootUserId( $value ) { $content = $this->getDependentContent(); if ( $content ) { $content->userId = $value; } return $this; }
php
public function setRootUserId( $value ) { $content = $this->getDependentContent(); if ( $content ) { $content->userId = $value; } return $this; }
[ "public", "function", "setRootUserId", "(", "$", "value", ")", "{", "$", "content", "=", "$", "this", "->", "getDependentContent", "(", ")", ";", "if", "(", "$", "content", ")", "{", "$", "content", "->", "userId", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set root's user-id @param string $value @return \Paragraph\Model\Paragraph\Structure\Infobar
[ "Set", "root", "s", "user", "-", "id" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/Infobar.php#L225-L235
9,607
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/session.php
Session._init
public static function _init() { \Config::load('session', true); if (\Config::get('session.auto_initialize', true)) { static::instance(); } if (\Config::get('session.native_emulation', false)) { // emulate native PHP sessions session_set_save_handler ( // open function ($savePath, $sessionName) { }, // close function () { }, // read function ($sessionId) { // copy all existing session vars into the PHP session store $_SESSION = \Session::get(); $_SESSION['__org'] = $_SESSION; }, // write function ($sessionId, $data) { // get the original data $org = isset($_SESSION['__org']) ? $_SESSION['__org'] : array(); unset($_SESSION['__org']); // do we need to remove stuff? if ($remove = array_diff_key($org, $_SESSION)) { \Session::delete(array_keys($remove)); } // add or update the remainder empty($_SESSION) or \Session::set($_SESSION); }, // destroy function ($sessionId) { \Session::destroy(); }, // gc function ($lifetime) { } ); } }
php
public static function _init() { \Config::load('session', true); if (\Config::get('session.auto_initialize', true)) { static::instance(); } if (\Config::get('session.native_emulation', false)) { // emulate native PHP sessions session_set_save_handler ( // open function ($savePath, $sessionName) { }, // close function () { }, // read function ($sessionId) { // copy all existing session vars into the PHP session store $_SESSION = \Session::get(); $_SESSION['__org'] = $_SESSION; }, // write function ($sessionId, $data) { // get the original data $org = isset($_SESSION['__org']) ? $_SESSION['__org'] : array(); unset($_SESSION['__org']); // do we need to remove stuff? if ($remove = array_diff_key($org, $_SESSION)) { \Session::delete(array_keys($remove)); } // add or update the remainder empty($_SESSION) or \Session::set($_SESSION); }, // destroy function ($sessionId) { \Session::destroy(); }, // gc function ($lifetime) { } ); } }
[ "public", "static", "function", "_init", "(", ")", "{", "\\", "Config", "::", "load", "(", "'session'", ",", "true", ")", ";", "if", "(", "\\", "Config", "::", "get", "(", "'session.auto_initialize'", ",", "true", ")", ")", "{", "static", "::", "instance", "(", ")", ";", "}", "if", "(", "\\", "Config", "::", "get", "(", "'session.native_emulation'", ",", "false", ")", ")", "{", "// emulate native PHP sessions", "session_set_save_handler", "(", "// open", "function", "(", "$", "savePath", ",", "$", "sessionName", ")", "{", "}", ",", "// close", "function", "(", ")", "{", "}", ",", "// read", "function", "(", "$", "sessionId", ")", "{", "// copy all existing session vars into the PHP session store", "$", "_SESSION", "=", "\\", "Session", "::", "get", "(", ")", ";", "$", "_SESSION", "[", "'__org'", "]", "=", "$", "_SESSION", ";", "}", ",", "// write", "function", "(", "$", "sessionId", ",", "$", "data", ")", "{", "// get the original data", "$", "org", "=", "isset", "(", "$", "_SESSION", "[", "'__org'", "]", ")", "?", "$", "_SESSION", "[", "'__org'", "]", ":", "array", "(", ")", ";", "unset", "(", "$", "_SESSION", "[", "'__org'", "]", ")", ";", "// do we need to remove stuff?", "if", "(", "$", "remove", "=", "array_diff_key", "(", "$", "org", ",", "$", "_SESSION", ")", ")", "{", "\\", "Session", "::", "delete", "(", "array_keys", "(", "$", "remove", ")", ")", ";", "}", "// add or update the remainder", "empty", "(", "$", "_SESSION", ")", "or", "\\", "Session", "::", "set", "(", "$", "_SESSION", ")", ";", "}", ",", "// destroy", "function", "(", "$", "sessionId", ")", "{", "\\", "Session", "::", "destroy", "(", ")", ";", "}", ",", "// gc", "function", "(", "$", "lifetime", ")", "{", "}", ")", ";", "}", "}" ]
Initialize by loading config & starting default session
[ "Initialize", "by", "loading", "config", "&", "starting", "default", "session" ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/session.php#L60-L109
9,608
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/MetaContent.php
MetaContent.setLayoutId
public function setLayoutId( $layoutId ) { $this->_layout = null; $this->layoutId = ( (int) $layoutId ) ?: null; return $this; }
php
public function setLayoutId( $layoutId ) { $this->_layout = null; $this->layoutId = ( (int) $layoutId ) ?: null; return $this; }
[ "public", "function", "setLayoutId", "(", "$", "layoutId", ")", "{", "$", "this", "->", "_layout", "=", "null", ";", "$", "this", "->", "layoutId", "=", "(", "(", "int", ")", "$", "layoutId", ")", "?", ":", "null", ";", "return", "$", "this", ";", "}" ]
Set layout-id @param int $layoutId @return \Paragraph\Model\Paragraph\Structure\Content
[ "Set", "layout", "-", "id" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/MetaContent.php#L138-L143
9,609
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/MetaContent.php
MetaContent.getTags
function getTags() { if( $this->getRenderedMetaContent() instanceof TagsAwareInterface ) { return array_unique( array_merge( parent::getTags(), $this->getRenderedMetaContent()->getTags() )); } return parent::getTags(); }
php
function getTags() { if( $this->getRenderedMetaContent() instanceof TagsAwareInterface ) { return array_unique( array_merge( parent::getTags(), $this->getRenderedMetaContent()->getTags() )); } return parent::getTags(); }
[ "function", "getTags", "(", ")", "{", "if", "(", "$", "this", "->", "getRenderedMetaContent", "(", ")", "instanceof", "TagsAwareInterface", ")", "{", "return", "array_unique", "(", "array_merge", "(", "parent", "::", "getTags", "(", ")", ",", "$", "this", "->", "getRenderedMetaContent", "(", ")", "->", "getTags", "(", ")", ")", ")", ";", "}", "return", "parent", "::", "getTags", "(", ")", ";", "}" ]
Get tags of the paragraph @return array
[ "Get", "tags", "of", "the", "paragraph" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/MetaContent.php#L218-L229
9,610
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/MetaContent.php
MetaContent.getTagIds
function getTagIds() { if( $this->getRenderedMetaContent() instanceof TagsAwareInterface ) { return array_unique( array_merge( parent::getTagIds(), $this->getRenderedMetaContent()->getTagIds() )); } return parent::getTagIds(); }
php
function getTagIds() { if( $this->getRenderedMetaContent() instanceof TagsAwareInterface ) { return array_unique( array_merge( parent::getTagIds(), $this->getRenderedMetaContent()->getTagIds() )); } return parent::getTagIds(); }
[ "function", "getTagIds", "(", ")", "{", "if", "(", "$", "this", "->", "getRenderedMetaContent", "(", ")", "instanceof", "TagsAwareInterface", ")", "{", "return", "array_unique", "(", "array_merge", "(", "parent", "::", "getTagIds", "(", ")", ",", "$", "this", "->", "getRenderedMetaContent", "(", ")", "->", "getTagIds", "(", ")", ")", ")", ";", "}", "return", "parent", "::", "getTagIds", "(", ")", ";", "}" ]
Get tag ids of the paragraph @return array
[ "Get", "tag", "ids", "of", "the", "paragraph" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/MetaContent.php#L236-L247
9,611
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/MetaContent.php
MetaContent.getLocaleTags
function getLocaleTags() { if( $this->getRenderedMetaContent() instanceof TagsAwareInterface ) { return array_unique( array_merge( parent::getLocaleTags(), $this->getRenderedMetaContent()->getLocaleTags() )); } return parent::getLocaleTags(); }
php
function getLocaleTags() { if( $this->getRenderedMetaContent() instanceof TagsAwareInterface ) { return array_unique( array_merge( parent::getLocaleTags(), $this->getRenderedMetaContent()->getLocaleTags() )); } return parent::getLocaleTags(); }
[ "function", "getLocaleTags", "(", ")", "{", "if", "(", "$", "this", "->", "getRenderedMetaContent", "(", ")", "instanceof", "TagsAwareInterface", ")", "{", "return", "array_unique", "(", "array_merge", "(", "parent", "::", "getLocaleTags", "(", ")", ",", "$", "this", "->", "getRenderedMetaContent", "(", ")", "->", "getLocaleTags", "(", ")", ")", ")", ";", "}", "return", "parent", "::", "getLocaleTags", "(", ")", ";", "}" ]
Get locale-tags of the paragraph @return array
[ "Get", "locale", "-", "tags", "of", "the", "paragraph" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Paragraph/Structure/MetaContent.php#L254-L265
9,612
BlackBoxRepo/PandoContentBundle
Service/BlockVariableService.php
BlockVariableService.populateBlockVariables
public function populateBlockVariables() { /** @var BlockVariableDocument $variable */ foreach ($this->block->getVariables() as $variable) { $this->setBlockVariable($variable->getName(), $this->methodService->call($variable->getMethodArgument())); } }
php
public function populateBlockVariables() { /** @var BlockVariableDocument $variable */ foreach ($this->block->getVariables() as $variable) { $this->setBlockVariable($variable->getName(), $this->methodService->call($variable->getMethodArgument())); } }
[ "public", "function", "populateBlockVariables", "(", ")", "{", "/** @var BlockVariableDocument $variable */", "foreach", "(", "$", "this", "->", "block", "->", "getVariables", "(", ")", "as", "$", "variable", ")", "{", "$", "this", "->", "setBlockVariable", "(", "$", "variable", "->", "getName", "(", ")", ",", "$", "this", "->", "methodService", "->", "call", "(", "$", "variable", "->", "getMethodArgument", "(", ")", ")", ")", ";", "}", "}" ]
Sets the blocks viewVariables where the keys are the BlockVariableDocument names and the values are the return of the associated method @return ArrayCollection
[ "Sets", "the", "blocks", "viewVariables", "where", "the", "keys", "are", "the", "BlockVariableDocument", "names", "and", "the", "values", "are", "the", "return", "of", "the", "associated", "method" ]
fa54d0c7542c1d359a5dbb4f32dab3e195e41007
https://github.com/BlackBoxRepo/PandoContentBundle/blob/fa54d0c7542c1d359a5dbb4f32dab3e195e41007/Service/BlockVariableService.php#L59-L65
9,613
AlphaLabs/FilterEngine
src/FilterBag/Factory/ExpressionParserFactory.php
ExpressionParserFactory.getFilterBagFromExpression
public function getFilterBagFromExpression($filtersExpression) { $parser = new Parser($filtersExpression); $filtersAST = $parser->getAST(); $filterBag = new FilterBag(); $filterBag->set('filter_' . md5($filtersExpression), $filtersAST); return $filterBag; }
php
public function getFilterBagFromExpression($filtersExpression) { $parser = new Parser($filtersExpression); $filtersAST = $parser->getAST(); $filterBag = new FilterBag(); $filterBag->set('filter_' . md5($filtersExpression), $filtersAST); return $filterBag; }
[ "public", "function", "getFilterBagFromExpression", "(", "$", "filtersExpression", ")", "{", "$", "parser", "=", "new", "Parser", "(", "$", "filtersExpression", ")", ";", "$", "filtersAST", "=", "$", "parser", "->", "getAST", "(", ")", ";", "$", "filterBag", "=", "new", "FilterBag", "(", ")", ";", "$", "filterBag", "->", "set", "(", "'filter_'", ".", "md5", "(", "$", "filtersExpression", ")", ",", "$", "filtersAST", ")", ";", "return", "$", "filterBag", ";", "}" ]
Build a FilterBag object by parsing the given filters expression @param $filtersExpression @return FilterBagInterface
[ "Build", "a", "FilterBag", "object", "by", "parsing", "the", "given", "filters", "expression" ]
806a7c31e50839033dbf0d41aed34b8d14c347f6
https://github.com/AlphaLabs/FilterEngine/blob/806a7c31e50839033dbf0d41aed34b8d14c347f6/src/FilterBag/Factory/ExpressionParserFactory.php#L26-L35
9,614
mszewcz/php-light-framework
src/Html/Controlls/Text.php
Text.textarea
public static function textarea(string $name = '', $value = '', array $attributes = []): string { $defaultAttributes = ['method-get' => false, 'cols' => 20, 'rows' => 40, 'class' => 'form-textarea']; $userAttributes = \array_merge($defaultAttributes, $attributes); $attributes = []; $attributes['name'] = $userAttributes['method-get'] === false ? \sprintf('MFVARS[%s]', $name) : $name; $attributes['id'] = isset($userAttributes['id']) ? $userAttributes['id'] : $name; $userAttributes = static::clearAttributes($userAttributes, ['method-get', 'id']); return Tags::textarea($value, \array_merge($attributes, $userAttributes)); }
php
public static function textarea(string $name = '', $value = '', array $attributes = []): string { $defaultAttributes = ['method-get' => false, 'cols' => 20, 'rows' => 40, 'class' => 'form-textarea']; $userAttributes = \array_merge($defaultAttributes, $attributes); $attributes = []; $attributes['name'] = $userAttributes['method-get'] === false ? \sprintf('MFVARS[%s]', $name) : $name; $attributes['id'] = isset($userAttributes['id']) ? $userAttributes['id'] : $name; $userAttributes = static::clearAttributes($userAttributes, ['method-get', 'id']); return Tags::textarea($value, \array_merge($attributes, $userAttributes)); }
[ "public", "static", "function", "textarea", "(", "string", "$", "name", "=", "''", ",", "$", "value", "=", "''", ",", "array", "$", "attributes", "=", "[", "]", ")", ":", "string", "{", "$", "defaultAttributes", "=", "[", "'method-get'", "=>", "false", ",", "'cols'", "=>", "20", ",", "'rows'", "=>", "40", ",", "'class'", "=>", "'form-textarea'", "]", ";", "$", "userAttributes", "=", "\\", "array_merge", "(", "$", "defaultAttributes", ",", "$", "attributes", ")", ";", "$", "attributes", "=", "[", "]", ";", "$", "attributes", "[", "'name'", "]", "=", "$", "userAttributes", "[", "'method-get'", "]", "===", "false", "?", "\\", "sprintf", "(", "'MFVARS[%s]'", ",", "$", "name", ")", ":", "$", "name", ";", "$", "attributes", "[", "'id'", "]", "=", "isset", "(", "$", "userAttributes", "[", "'id'", "]", ")", "?", "$", "userAttributes", "[", "'id'", "]", ":", "$", "name", ";", "$", "userAttributes", "=", "static", "::", "clearAttributes", "(", "$", "userAttributes", ",", "[", "'method-get'", ",", "'id'", "]", ")", ";", "return", "Tags", "::", "textarea", "(", "$", "value", ",", "\\", "array_merge", "(", "$", "attributes", ",", "$", "userAttributes", ")", ")", ";", "}" ]
This method returns textarea controll @param string $name @param mixed $value @param array $attributes @return string
[ "This", "method", "returns", "textarea", "controll" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Controlls/Text.php#L97-L107
9,615
getconnect/connect-php
src/Client.php
Client.pushEvent
private function pushEvent($collection, $eventDetails) { $event = new Event($eventDetails); return $this->client->pushEvent($collection, $event->getDetails()); }
php
private function pushEvent($collection, $eventDetails) { $event = new Event($eventDetails); return $this->client->pushEvent($collection, $event->getDetails()); }
[ "private", "function", "pushEvent", "(", "$", "collection", ",", "$", "eventDetails", ")", "{", "$", "event", "=", "new", "Event", "(", "$", "eventDetails", ")", ";", "return", "$", "this", "->", "client", "->", "pushEvent", "(", "$", "collection", ",", "$", "event", "->", "getDetails", "(", ")", ")", ";", "}" ]
Push an event to the API client. @param string $collection The name of the collection to push to @param array $eventDetails The event details @return Response
[ "Push", "an", "event", "to", "the", "API", "client", "." ]
cbce3daae58eca16450df811ac6f1280fc1ef6b1
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/Client.php#L47-L50
9,616
novuso/common
src/Domain/Value/Money/Money.php
Money.add
public function add(Money $other): Money { $this->guardCurrency($other); $amount = $this->amount + $other->amount; $this->guardAmountInBounds($amount); return $this->withAmount($amount); }
php
public function add(Money $other): Money { $this->guardCurrency($other); $amount = $this->amount + $other->amount; $this->guardAmountInBounds($amount); return $this->withAmount($amount); }
[ "public", "function", "add", "(", "Money", "$", "other", ")", ":", "Money", "{", "$", "this", "->", "guardCurrency", "(", "$", "other", ")", ";", "$", "amount", "=", "$", "this", "->", "amount", "+", "$", "other", "->", "amount", ";", "$", "this", "->", "guardAmountInBounds", "(", "$", "amount", ")", ";", "return", "$", "this", "->", "withAmount", "(", "$", "amount", ")", ";", "}" ]
Creates instance that adds the given monetary value @param Money $other The other monetary value @return Money @throws DomainException When other has different currency @throws RangeException When integer overflow occurs
[ "Creates", "instance", "that", "adds", "the", "given", "monetary", "value" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Money/Money.php#L173-L182
9,617
novuso/common
src/Domain/Value/Money/Money.php
Money.subtract
public function subtract(Money $other): Money { $this->guardCurrency($other); $amount = $this->amount - $other->amount; $this->guardAmountInBounds($amount); return $this->withAmount($amount); }
php
public function subtract(Money $other): Money { $this->guardCurrency($other); $amount = $this->amount - $other->amount; $this->guardAmountInBounds($amount); return $this->withAmount($amount); }
[ "public", "function", "subtract", "(", "Money", "$", "other", ")", ":", "Money", "{", "$", "this", "->", "guardCurrency", "(", "$", "other", ")", ";", "$", "amount", "=", "$", "this", "->", "amount", "-", "$", "other", "->", "amount", ";", "$", "this", "->", "guardAmountInBounds", "(", "$", "amount", ")", ";", "return", "$", "this", "->", "withAmount", "(", "$", "amount", ")", ";", "}" ]
Creates instance that subtracts the given monetary value @param Money $other The other monetary value @return Money @throws DomainException When other has different currency @throws RangeException When integer overflow occurs
[ "Creates", "instance", "that", "subtracts", "the", "given", "monetary", "value" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Money/Money.php#L194-L203
9,618
novuso/common
src/Domain/Value/Money/Money.php
Money.multiply
public function multiply($multiplier, ?RoundingMode $mode = null): Money { if ($mode === null) { $mode = RoundingMode::HALF_UP(); } $this->guardOperand($multiplier); $amount = round($this->amount * $multiplier, 0, $mode->value()); $amount = $this->castToInteger($amount); return $this->withAmount($amount); }
php
public function multiply($multiplier, ?RoundingMode $mode = null): Money { if ($mode === null) { $mode = RoundingMode::HALF_UP(); } $this->guardOperand($multiplier); $amount = round($this->amount * $multiplier, 0, $mode->value()); $amount = $this->castToInteger($amount); return $this->withAmount($amount); }
[ "public", "function", "multiply", "(", "$", "multiplier", ",", "?", "RoundingMode", "$", "mode", "=", "null", ")", ":", "Money", "{", "if", "(", "$", "mode", "===", "null", ")", "{", "$", "mode", "=", "RoundingMode", "::", "HALF_UP", "(", ")", ";", "}", "$", "this", "->", "guardOperand", "(", "$", "multiplier", ")", ";", "$", "amount", "=", "round", "(", "$", "this", "->", "amount", "*", "$", "multiplier", ",", "0", ",", "$", "mode", "->", "value", "(", ")", ")", ";", "$", "amount", "=", "$", "this", "->", "castToInteger", "(", "$", "amount", ")", ";", "return", "$", "this", "->", "withAmount", "(", "$", "amount", ")", ";", "}" ]
Creates instance that multiplies this value by the given value @param int|float $multiplier The multiplier @param RoundingMode|null $mode The rounding mode; null for HALF_UP @return Money @throws DomainException When multiplier is not an int or float @throws RangeException When integer overflow occurs
[ "Creates", "instance", "that", "multiplies", "this", "value", "by", "the", "given", "value" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Money/Money.php#L216-L228
9,619
novuso/common
src/Domain/Value/Money/Money.php
Money.divide
public function divide($divisor, ?RoundingMode $mode = null): Money { if ($mode === null) { $mode = RoundingMode::HALF_UP(); } $this->guardOperand($divisor); if ($divisor === 0 || $divisor === 0.0) { throw new DomainException('Division by zero'); } $amount = round($this->amount / $divisor, 0, $mode->value()); $amount = $this->castToInteger($amount); return $this->withAmount($amount); }
php
public function divide($divisor, ?RoundingMode $mode = null): Money { if ($mode === null) { $mode = RoundingMode::HALF_UP(); } $this->guardOperand($divisor); if ($divisor === 0 || $divisor === 0.0) { throw new DomainException('Division by zero'); } $amount = round($this->amount / $divisor, 0, $mode->value()); $amount = $this->castToInteger($amount); return $this->withAmount($amount); }
[ "public", "function", "divide", "(", "$", "divisor", ",", "?", "RoundingMode", "$", "mode", "=", "null", ")", ":", "Money", "{", "if", "(", "$", "mode", "===", "null", ")", "{", "$", "mode", "=", "RoundingMode", "::", "HALF_UP", "(", ")", ";", "}", "$", "this", "->", "guardOperand", "(", "$", "divisor", ")", ";", "if", "(", "$", "divisor", "===", "0", "||", "$", "divisor", "===", "0.0", ")", "{", "throw", "new", "DomainException", "(", "'Division by zero'", ")", ";", "}", "$", "amount", "=", "round", "(", "$", "this", "->", "amount", "/", "$", "divisor", ",", "0", ",", "$", "mode", "->", "value", "(", ")", ")", ";", "$", "amount", "=", "$", "this", "->", "castToInteger", "(", "$", "amount", ")", ";", "return", "$", "this", "->", "withAmount", "(", "$", "amount", ")", ";", "}" ]
Creates instance that divides this value by the given value @param int|float $divisor The divisor @param RoundingMode|null $mode The rounding mode; null for HALF_UP @return Money @throws DomainException When divisor is not an int or float @throws DomainException When the divisor is zero @throws RangeException When integer overflow occurs
[ "Creates", "instance", "that", "divides", "this", "value", "by", "the", "given", "value" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Money/Money.php#L242-L258
9,620
novuso/common
src/Domain/Value/Money/Money.php
Money.allocate
public function allocate(array $ratios): array { $total = array_sum($ratios); $remainder = $this->amount; $shares = []; foreach ($ratios as $ratio) { $amount = $this->castToInteger($this->amount * $ratio / $total); $shares[] = $this->withAmount($amount); $remainder -= $amount; } for ($i = 0; $i < $remainder; $i++) { $shares[$i] = $this->withAmount($shares[$i]->amount + 1); } return $shares; }
php
public function allocate(array $ratios): array { $total = array_sum($ratios); $remainder = $this->amount; $shares = []; foreach ($ratios as $ratio) { $amount = $this->castToInteger($this->amount * $ratio / $total); $shares[] = $this->withAmount($amount); $remainder -= $amount; } for ($i = 0; $i < $remainder; $i++) { $shares[$i] = $this->withAmount($shares[$i]->amount + 1); } return $shares; }
[ "public", "function", "allocate", "(", "array", "$", "ratios", ")", ":", "array", "{", "$", "total", "=", "array_sum", "(", "$", "ratios", ")", ";", "$", "remainder", "=", "$", "this", "->", "amount", ";", "$", "shares", "=", "[", "]", ";", "foreach", "(", "$", "ratios", "as", "$", "ratio", ")", "{", "$", "amount", "=", "$", "this", "->", "castToInteger", "(", "$", "this", "->", "amount", "*", "$", "ratio", "/", "$", "total", ")", ";", "$", "shares", "[", "]", "=", "$", "this", "->", "withAmount", "(", "$", "amount", ")", ";", "$", "remainder", "-=", "$", "amount", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "remainder", ";", "$", "i", "++", ")", "{", "$", "shares", "[", "$", "i", "]", "=", "$", "this", "->", "withAmount", "(", "$", "shares", "[", "$", "i", "]", "->", "amount", "+", "1", ")", ";", "}", "return", "$", "shares", ";", "}" ]
Allocates the money according to a list of ratios @param array $ratios The list of ratios @return Money[]
[ "Allocates", "the", "money", "according", "to", "a", "list", "of", "ratios" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Money/Money.php#L267-L284
9,621
novuso/common
src/Domain/Value/Money/Money.php
Money.split
public function split(int $num): array { if ($num <= 0) { $message = sprintf('%s expects $num to be greater than zero', __METHOD__); throw new DomainException($message); } $amount = $this->castToInteger($this->amount / $num); $remainder = $this->amount % $num; $shares = []; for ($i = 0; $i < $num; $i++) { $shares[] = $this->withAmount($amount); } for ($i = 0; $i < $remainder; $i++) { $shares[$i] = $this->withAmount($shares[$i]->amount + 1); } return $shares; }
php
public function split(int $num): array { if ($num <= 0) { $message = sprintf('%s expects $num to be greater than zero', __METHOD__); throw new DomainException($message); } $amount = $this->castToInteger($this->amount / $num); $remainder = $this->amount % $num; $shares = []; for ($i = 0; $i < $num; $i++) { $shares[] = $this->withAmount($amount); } for ($i = 0; $i < $remainder; $i++) { $shares[$i] = $this->withAmount($shares[$i]->amount + 1); } return $shares; }
[ "public", "function", "split", "(", "int", "$", "num", ")", ":", "array", "{", "if", "(", "$", "num", "<=", "0", ")", "{", "$", "message", "=", "sprintf", "(", "'%s expects $num to be greater than zero'", ",", "__METHOD__", ")", ";", "throw", "new", "DomainException", "(", "$", "message", ")", ";", "}", "$", "amount", "=", "$", "this", "->", "castToInteger", "(", "$", "this", "->", "amount", "/", "$", "num", ")", ";", "$", "remainder", "=", "$", "this", "->", "amount", "%", "$", "num", ";", "$", "shares", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "num", ";", "$", "i", "++", ")", "{", "$", "shares", "[", "]", "=", "$", "this", "->", "withAmount", "(", "$", "amount", ")", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "remainder", ";", "$", "i", "++", ")", "{", "$", "shares", "[", "$", "i", "]", "=", "$", "this", "->", "withAmount", "(", "$", "shares", "[", "$", "i", "]", "->", "amount", "+", "1", ")", ";", "}", "return", "$", "shares", ";", "}" ]
Allocates the money among a given number of targets @param int $num The number of targets @return Money[] @throws DomainException When num is not greater than zero
[ "Allocates", "the", "money", "among", "a", "given", "number", "of", "targets" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Money/Money.php#L295-L315
9,622
novuso/common
src/Domain/Value/Money/Money.php
Money.guardOperand
protected function guardOperand($operand): void { if (!is_int($operand) && !is_float($operand)) { $message = sprintf( 'Operand must be an integer or float; received (%s) %s', gettype($operand), VarPrinter::toString($operand) ); throw new DomainException($message); } }
php
protected function guardOperand($operand): void { if (!is_int($operand) && !is_float($operand)) { $message = sprintf( 'Operand must be an integer or float; received (%s) %s', gettype($operand), VarPrinter::toString($operand) ); throw new DomainException($message); } }
[ "protected", "function", "guardOperand", "(", "$", "operand", ")", ":", "void", "{", "if", "(", "!", "is_int", "(", "$", "operand", ")", "&&", "!", "is_float", "(", "$", "operand", ")", ")", "{", "$", "message", "=", "sprintf", "(", "'Operand must be an integer or float; received (%s) %s'", ",", "gettype", "(", "$", "operand", ")", ",", "VarPrinter", "::", "toString", "(", "$", "operand", ")", ")", ";", "throw", "new", "DomainException", "(", "$", "message", ")", ";", "}", "}" ]
Validates monetary operand is an integer or float @param mixed $operand The operand @return void @throws DomainException When operand is not an int or float
[ "Validates", "monetary", "operand", "is", "an", "integer", "or", "float" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Money/Money.php#L460-L470
9,623
silvercommerce/settings
src/extensions/ControllerExtension.php
ControllerExtension.onBeforeInit
public function onBeforeInit() { $disallowed_controllers = [ DevelopmentAdmin::class, DevBuildController::class, DatabaseAdmin::class ]; // Don't run this during dev/build or dev/tasks if (!in_array(get_class($this->owner), $disallowed_controllers)) { // Set global local based on Site Config $config = SiteConfig::current_site_config(); i18n::set_locale($config->SiteLocale); // Now find and set the desired currency symbol $number_format = new NumberFormatter($config->SiteLocale, NumberFormatter::CURRENCY); $symbol = $number_format->getSymbol(NumberFormatter::CURRENCY_SYMBOL); DBCurrency::config()->currency_symbol = $symbol; } }
php
public function onBeforeInit() { $disallowed_controllers = [ DevelopmentAdmin::class, DevBuildController::class, DatabaseAdmin::class ]; // Don't run this during dev/build or dev/tasks if (!in_array(get_class($this->owner), $disallowed_controllers)) { // Set global local based on Site Config $config = SiteConfig::current_site_config(); i18n::set_locale($config->SiteLocale); // Now find and set the desired currency symbol $number_format = new NumberFormatter($config->SiteLocale, NumberFormatter::CURRENCY); $symbol = $number_format->getSymbol(NumberFormatter::CURRENCY_SYMBOL); DBCurrency::config()->currency_symbol = $symbol; } }
[ "public", "function", "onBeforeInit", "(", ")", "{", "$", "disallowed_controllers", "=", "[", "DevelopmentAdmin", "::", "class", ",", "DevBuildController", "::", "class", ",", "DatabaseAdmin", "::", "class", "]", ";", "// Don't run this during dev/build or dev/tasks", "if", "(", "!", "in_array", "(", "get_class", "(", "$", "this", "->", "owner", ")", ",", "$", "disallowed_controllers", ")", ")", "{", "// Set global local based on Site Config", "$", "config", "=", "SiteConfig", "::", "current_site_config", "(", ")", ";", "i18n", "::", "set_locale", "(", "$", "config", "->", "SiteLocale", ")", ";", "// Now find and set the desired currency symbol", "$", "number_format", "=", "new", "NumberFormatter", "(", "$", "config", "->", "SiteLocale", ",", "NumberFormatter", "::", "CURRENCY", ")", ";", "$", "symbol", "=", "$", "number_format", "->", "getSymbol", "(", "NumberFormatter", "::", "CURRENCY_SYMBOL", ")", ";", "DBCurrency", "::", "config", "(", ")", "->", "currency_symbol", "=", "$", "symbol", ";", "}", "}" ]
Customise the default silverstripe locale config
[ "Customise", "the", "default", "silverstripe", "locale", "config" ]
632e4443866a3b4de57c3e641fac33a8b5c76308
https://github.com/silvercommerce/settings/blob/632e4443866a3b4de57c3e641fac33a8b5c76308/src/extensions/ControllerExtension.php#L19-L38
9,624
PSESD/cascade-core-types
TypeTime/widgets/SummaryWidget.php
SummaryWidget.getModule
public function getModule() { $method = ArrayHelper::getValue($this->parentWidget->settings, 'queryRole', 'all'); $relationship = ArrayHelper::getValue($this->parentWidget->settings, 'relationship', false); if ($method === 'children') { return $relationship->child; } elseif ($method === 'parents') { return $relationship->parent; } return false; }
php
public function getModule() { $method = ArrayHelper::getValue($this->parentWidget->settings, 'queryRole', 'all'); $relationship = ArrayHelper::getValue($this->parentWidget->settings, 'relationship', false); if ($method === 'children') { return $relationship->child; } elseif ($method === 'parents') { return $relationship->parent; } return false; }
[ "public", "function", "getModule", "(", ")", "{", "$", "method", "=", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "parentWidget", "->", "settings", ",", "'queryRole'", ",", "'all'", ")", ";", "$", "relationship", "=", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "parentWidget", "->", "settings", ",", "'relationship'", ",", "false", ")", ";", "if", "(", "$", "method", "===", "'children'", ")", "{", "return", "$", "relationship", "->", "child", ";", "}", "elseif", "(", "$", "method", "===", "'parents'", ")", "{", "return", "$", "relationship", "->", "parent", ";", "}", "return", "false", ";", "}" ]
Get module. @return [[@doctodo return_type:getModule]] [[@doctodo return_description:getModule]]
[ "Get", "module", "." ]
5a2bc524bd89545f0f28230e34518c9f92e7db1f
https://github.com/PSESD/cascade-core-types/blob/5a2bc524bd89545f0f28230e34518c9f92e7db1f/TypeTime/widgets/SummaryWidget.php#L87-L98
9,625
mtils/beetree
src/BeeTree/Eloquent/ActAsEloquentNode.php
ActAsEloquentNode.getChildren
public function getChildren() { if (isset($this->relations['children'])) { return $this->relations['children']; } $children = $this->getAttribute('children'); return $children === null ? [] : $children; }
php
public function getChildren() { if (isset($this->relations['children'])) { return $this->relations['children']; } $children = $this->getAttribute('children'); return $children === null ? [] : $children; }
[ "public", "function", "getChildren", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "relations", "[", "'children'", "]", ")", ")", "{", "return", "$", "this", "->", "relations", "[", "'children'", "]", ";", "}", "$", "children", "=", "$", "this", "->", "getAttribute", "(", "'children'", ")", ";", "return", "$", "children", "===", "null", "?", "[", "]", ":", "$", "children", ";", "}" ]
Returns the childs of this node @return \BeeTree\Contracts\Children
[ "Returns", "the", "childs", "of", "this", "node" ]
4a68fc94ec14d5faef773b1628c9060db7bf1ce2
https://github.com/mtils/beetree/blob/4a68fc94ec14d5faef773b1628c9060db7bf1ce2/src/BeeTree/Eloquent/ActAsEloquentNode.php#L73-L82
9,626
mtils/beetree
src/BeeTree/Eloquent/ActAsEloquentNode.php
ActAsEloquentNode.getLevel
public function getLevel() { if ($this->_level !== null) { return $this->_level; } if ($this->isRoot()) { $this->_level = -1; return $this->_level; } $parents = array($this); $node = $this; while ($parent = $node->getParent()){ if (!$parent->isRoot()) { $parents[] = $parent; } $node = $parent; } $this->_level = count($parents); return $this->_level; }
php
public function getLevel() { if ($this->_level !== null) { return $this->_level; } if ($this->isRoot()) { $this->_level = -1; return $this->_level; } $parents = array($this); $node = $this; while ($parent = $node->getParent()){ if (!$parent->isRoot()) { $parents[] = $parent; } $node = $parent; } $this->_level = count($parents); return $this->_level; }
[ "public", "function", "getLevel", "(", ")", "{", "if", "(", "$", "this", "->", "_level", "!==", "null", ")", "{", "return", "$", "this", "->", "_level", ";", "}", "if", "(", "$", "this", "->", "isRoot", "(", ")", ")", "{", "$", "this", "->", "_level", "=", "-", "1", ";", "return", "$", "this", "->", "_level", ";", "}", "$", "parents", "=", "array", "(", "$", "this", ")", ";", "$", "node", "=", "$", "this", ";", "while", "(", "$", "parent", "=", "$", "node", "->", "getParent", "(", ")", ")", "{", "if", "(", "!", "$", "parent", "->", "isRoot", "(", ")", ")", "{", "$", "parents", "[", "]", "=", "$", "parent", ";", "}", "$", "node", "=", "$", "parent", ";", "}", "$", "this", "->", "_level", "=", "count", "(", "$", "parents", ")", ";", "return", "$", "this", "->", "_level", ";", "}" ]
Returns the level of this node @return int
[ "Returns", "the", "level", "of", "this", "node" ]
4a68fc94ec14d5faef773b1628c9060db7bf1ce2
https://github.com/mtils/beetree/blob/4a68fc94ec14d5faef773b1628c9060db7bf1ce2/src/BeeTree/Eloquent/ActAsEloquentNode.php#L155-L179
9,627
fluxbb/commonmark
src/DocumentParser.php
DocumentParser.convert
public function convert($markdown) { $root = new Container(); $this->inlineParser = new InlineParser($this->links, $this->titles); $parser = $this->buildParserStack(); $text = new Text($markdown); $this->prepare($text); $parser->parseBlock($text, $root); $this->inlineParser->parse(); return $root; }
php
public function convert($markdown) { $root = new Container(); $this->inlineParser = new InlineParser($this->links, $this->titles); $parser = $this->buildParserStack(); $text = new Text($markdown); $this->prepare($text); $parser->parseBlock($text, $root); $this->inlineParser->parse(); return $root; }
[ "public", "function", "convert", "(", "$", "markdown", ")", "{", "$", "root", "=", "new", "Container", "(", ")", ";", "$", "this", "->", "inlineParser", "=", "new", "InlineParser", "(", "$", "this", "->", "links", ",", "$", "this", "->", "titles", ")", ";", "$", "parser", "=", "$", "this", "->", "buildParserStack", "(", ")", ";", "$", "text", "=", "new", "Text", "(", "$", "markdown", ")", ";", "$", "this", "->", "prepare", "(", "$", "text", ")", ";", "$", "parser", "->", "parseBlock", "(", "$", "text", ",", "$", "root", ")", ";", "$", "this", "->", "inlineParser", "->", "parse", "(", ")", ";", "return", "$", "root", ";", "}" ]
Parse the given Markdown text into a document tree. @param string $markdown @return Container
[ "Parse", "the", "given", "Markdown", "text", "into", "a", "document", "tree", "." ]
a61795a074aac19d8509f5673d5ee230dca292bc
https://github.com/fluxbb/commonmark/blob/a61795a074aac19d8509f5673d5ee230dca292bc/src/DocumentParser.php#L65-L80
9,628
fluxbb/commonmark
src/DocumentParser.php
DocumentParser.prepare
protected function prepare(Text $text) { // Unify line endings $text->replaceString("\r\n", "\n"); $text->replaceString("\r", "\n"); // Replace tabs by spaces $text->replace('/(.*?)\t/', function (Text $whole, Text $string) { $tabWidth = 4; return $string . str_repeat(' ', $tabWidth - $string->getLength() % $tabWidth); }); }
php
protected function prepare(Text $text) { // Unify line endings $text->replaceString("\r\n", "\n"); $text->replaceString("\r", "\n"); // Replace tabs by spaces $text->replace('/(.*?)\t/', function (Text $whole, Text $string) { $tabWidth = 4; return $string . str_repeat(' ', $tabWidth - $string->getLength() % $tabWidth); }); }
[ "protected", "function", "prepare", "(", "Text", "$", "text", ")", "{", "// Unify line endings", "$", "text", "->", "replaceString", "(", "\"\\r\\n\"", ",", "\"\\n\"", ")", ";", "$", "text", "->", "replaceString", "(", "\"\\r\"", ",", "\"\\n\"", ")", ";", "// Replace tabs by spaces", "$", "text", "->", "replace", "(", "'/(.*?)\\t/'", ",", "function", "(", "Text", "$", "whole", ",", "Text", "$", "string", ")", "{", "$", "tabWidth", "=", "4", ";", "return", "$", "string", ".", "str_repeat", "(", "' '", ",", "$", "tabWidth", "-", "$", "string", "->", "getLength", "(", ")", "%", "$", "tabWidth", ")", ";", "}", ")", ";", "}" ]
Preprocess the text. This unifies line endings and replaces tabs by spaces. @param Text $text @return void
[ "Preprocess", "the", "text", "." ]
a61795a074aac19d8509f5673d5ee230dca292bc
https://github.com/fluxbb/commonmark/blob/a61795a074aac19d8509f5673d5ee230dca292bc/src/DocumentParser.php#L90-L101
9,629
prastowoagungwidodo/mvc
src/Transformatika/MVC/View.php
View.includeBlock
public function includeBlock($blockName) { $blockName = str_replace('/', DIRECTORY_SEPARATOR, $blockName); $blockContent = ''; $blockFile = BASE_PATH . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'share' . DIRECTORY_SEPARATOR . 'layout' . DIRECTORY_SEPARATOR . $blockName . '.' . $this->config['templateExtension']; if (file_exists($blockFile)) { $templateTmp = file_get_contents($blockFile); preg_match_all("~\{\{\s*(.*?)\s*\}\}~", $templateTmp, $block); foreach ($block[1] as $k => $v) { if ($v === 'php') { $templateTmp = str_replace('{{php}}', '<?php', $templateTmp); } elseif ($v === '/php') { $templateTmp = str_replace('{{/php}}', '?>', $templateTmp); } else { $blockTemplate = $this->includeBlock($v); $templateTmp = str_replace('{{' . $v . '}}', $blockTemplate, $templateTmp); } } $blockContent = $templateTmp; } else { $blockContent = 'FILE NOT FOUND (' . $blockFile . ')'; } return $blockContent; }
php
public function includeBlock($blockName) { $blockName = str_replace('/', DIRECTORY_SEPARATOR, $blockName); $blockContent = ''; $blockFile = BASE_PATH . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'share' . DIRECTORY_SEPARATOR . 'layout' . DIRECTORY_SEPARATOR . $blockName . '.' . $this->config['templateExtension']; if (file_exists($blockFile)) { $templateTmp = file_get_contents($blockFile); preg_match_all("~\{\{\s*(.*?)\s*\}\}~", $templateTmp, $block); foreach ($block[1] as $k => $v) { if ($v === 'php') { $templateTmp = str_replace('{{php}}', '<?php', $templateTmp); } elseif ($v === '/php') { $templateTmp = str_replace('{{/php}}', '?>', $templateTmp); } else { $blockTemplate = $this->includeBlock($v); $templateTmp = str_replace('{{' . $v . '}}', $blockTemplate, $templateTmp); } } $blockContent = $templateTmp; } else { $blockContent = 'FILE NOT FOUND (' . $blockFile . ')'; } return $blockContent; }
[ "public", "function", "includeBlock", "(", "$", "blockName", ")", "{", "$", "blockName", "=", "str_replace", "(", "'/'", ",", "DIRECTORY_SEPARATOR", ",", "$", "blockName", ")", ";", "$", "blockContent", "=", "''", ";", "$", "blockFile", "=", "BASE_PATH", ".", "DIRECTORY_SEPARATOR", ".", "'storage'", ".", "DIRECTORY_SEPARATOR", ".", "'share'", ".", "DIRECTORY_SEPARATOR", ".", "'layout'", ".", "DIRECTORY_SEPARATOR", ".", "$", "blockName", ".", "'.'", ".", "$", "this", "->", "config", "[", "'templateExtension'", "]", ";", "if", "(", "file_exists", "(", "$", "blockFile", ")", ")", "{", "$", "templateTmp", "=", "file_get_contents", "(", "$", "blockFile", ")", ";", "preg_match_all", "(", "\"~\\{\\{\\s*(.*?)\\s*\\}\\}~\"", ",", "$", "templateTmp", ",", "$", "block", ")", ";", "foreach", "(", "$", "block", "[", "1", "]", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "===", "'php'", ")", "{", "$", "templateTmp", "=", "str_replace", "(", "'{{php}}'", ",", "'<?php'", ",", "$", "templateTmp", ")", ";", "}", "elseif", "(", "$", "v", "===", "'/php'", ")", "{", "$", "templateTmp", "=", "str_replace", "(", "'{{/php}}'", ",", "'?>'", ",", "$", "templateTmp", ")", ";", "}", "else", "{", "$", "blockTemplate", "=", "$", "this", "->", "includeBlock", "(", "$", "v", ")", ";", "$", "templateTmp", "=", "str_replace", "(", "'{{'", ".", "$", "v", ".", "'}}'", ",", "$", "blockTemplate", ",", "$", "templateTmp", ")", ";", "}", "}", "$", "blockContent", "=", "$", "templateTmp", ";", "}", "else", "{", "$", "blockContent", "=", "'FILE NOT FOUND ('", ".", "$", "blockFile", ".", "')'", ";", "}", "return", "$", "blockContent", ";", "}" ]
Include Block Layout
[ "Include", "Block", "Layout" ]
56ce9d4589e5951690388e0a115466750c148adb
https://github.com/prastowoagungwidodo/mvc/blob/56ce9d4589e5951690388e0a115466750c148adb/src/Transformatika/MVC/View.php#L96-L120
9,630
prastowoagungwidodo/mvc
src/Transformatika/MVC/View.php
View.includeFile
public function includeFile($templateFile = '') { if (!empty($templateFile)) { str_replace('/', DIRECTORY_SEPARATOR, $templateFile); if (file_exists($this->appPath . DIRECTORY_SEPARATOR . $templateFile)) { require_once $this->appPath . DIRECTORY_SEPARATOR . $templateFile; } } }
php
public function includeFile($templateFile = '') { if (!empty($templateFile)) { str_replace('/', DIRECTORY_SEPARATOR, $templateFile); if (file_exists($this->appPath . DIRECTORY_SEPARATOR . $templateFile)) { require_once $this->appPath . DIRECTORY_SEPARATOR . $templateFile; } } }
[ "public", "function", "includeFile", "(", "$", "templateFile", "=", "''", ")", "{", "if", "(", "!", "empty", "(", "$", "templateFile", ")", ")", "{", "str_replace", "(", "'/'", ",", "DIRECTORY_SEPARATOR", ",", "$", "templateFile", ")", ";", "if", "(", "file_exists", "(", "$", "this", "->", "appPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "templateFile", ")", ")", "{", "require_once", "$", "this", "->", "appPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "templateFile", ";", "}", "}", "}" ]
Include other file @param string $templateFile
[ "Include", "other", "file" ]
56ce9d4589e5951690388e0a115466750c148adb
https://github.com/prastowoagungwidodo/mvc/blob/56ce9d4589e5951690388e0a115466750c148adb/src/Transformatika/MVC/View.php#L138-L146
9,631
neonbug/meexo-common
src/Providers/BaseServiceProvider.php
BaseServiceProvider.bootTraits
protected static function bootTraits() { foreach (class_uses_recursive(get_called_class()) as $trait) { if (method_exists(get_called_class(), $method = 'boot'.class_basename($trait))) { forward_static_call([get_called_class(), $method]); //$this->$method(); } } }
php
protected static function bootTraits() { foreach (class_uses_recursive(get_called_class()) as $trait) { if (method_exists(get_called_class(), $method = 'boot'.class_basename($trait))) { forward_static_call([get_called_class(), $method]); //$this->$method(); } } }
[ "protected", "static", "function", "bootTraits", "(", ")", "{", "foreach", "(", "class_uses_recursive", "(", "get_called_class", "(", ")", ")", "as", "$", "trait", ")", "{", "if", "(", "method_exists", "(", "get_called_class", "(", ")", ",", "$", "method", "=", "'boot'", ".", "class_basename", "(", "$", "trait", ")", ")", ")", "{", "forward_static_call", "(", "[", "get_called_class", "(", ")", ",", "$", "method", "]", ")", ";", "//$this->$method();\r", "}", "}", "}" ]
Boot all of the bootable traits on the ServiceProvider. @return void
[ "Boot", "all", "of", "the", "bootable", "traits", "on", "the", "ServiceProvider", "." ]
8fe9a5d1b73311c65a7c5a0ce8a4e859d39351c6
https://github.com/neonbug/meexo-common/blob/8fe9a5d1b73311c65a7c5a0ce8a4e859d39351c6/src/Providers/BaseServiceProvider.php#L37-L45
9,632
franzip/serp-fetcher
src/Fetchers/YahooFetcher.php
YahooFetcher.getPageTitles
protected function getPageTitles($SHDObject) { $titles = array(); foreach($SHDObject->find('.compTitle h3.title') as $object) { // extract and clean anchors innertext $titleText = $object->innertext; $titles[] = $this->cleanText($titleText); } // fetch only organic results return $this->normalizeResult($titles); }
php
protected function getPageTitles($SHDObject) { $titles = array(); foreach($SHDObject->find('.compTitle h3.title') as $object) { // extract and clean anchors innertext $titleText = $object->innertext; $titles[] = $this->cleanText($titleText); } // fetch only organic results return $this->normalizeResult($titles); }
[ "protected", "function", "getPageTitles", "(", "$", "SHDObject", ")", "{", "$", "titles", "=", "array", "(", ")", ";", "foreach", "(", "$", "SHDObject", "->", "find", "(", "'.compTitle h3.title'", ")", "as", "$", "object", ")", "{", "// extract and clean anchors innertext", "$", "titleText", "=", "$", "object", "->", "innertext", ";", "$", "titles", "[", "]", "=", "$", "this", "->", "cleanText", "(", "$", "titleText", ")", ";", "}", "// fetch only organic results", "return", "$", "this", "->", "normalizeResult", "(", "$", "titles", ")", ";", "}" ]
Get all titles for a given Yahoo SERP page. @param SimpleHtmlDom $SHDObject @return array
[ "Get", "all", "titles", "for", "a", "given", "Yahoo", "SERP", "page", "." ]
0554b682a8e4aec6e5d615866087b34e731e0d88
https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Fetchers/YahooFetcher.php#L42-L52
9,633
franzip/serp-fetcher
src/Fetchers/YahooFetcher.php
YahooFetcher.getPageSnippets
protected function getPageSnippets($SHDObject) { $snippets = array(); foreach ($SHDObject->find('.aAbs') as $object) { $snippetText = $this->cleanText($object->innertext); $snippets[] = $this->fixRepeatedSpace($snippetText); } // fetch only organic results return $this->normalizeResult($snippets); }
php
protected function getPageSnippets($SHDObject) { $snippets = array(); foreach ($SHDObject->find('.aAbs') as $object) { $snippetText = $this->cleanText($object->innertext); $snippets[] = $this->fixRepeatedSpace($snippetText); } // fetch only organic results return $this->normalizeResult($snippets); }
[ "protected", "function", "getPageSnippets", "(", "$", "SHDObject", ")", "{", "$", "snippets", "=", "array", "(", ")", ";", "foreach", "(", "$", "SHDObject", "->", "find", "(", "'.aAbs'", ")", "as", "$", "object", ")", "{", "$", "snippetText", "=", "$", "this", "->", "cleanText", "(", "$", "object", "->", "innertext", ")", ";", "$", "snippets", "[", "]", "=", "$", "this", "->", "fixRepeatedSpace", "(", "$", "snippetText", ")", ";", "}", "// fetch only organic results", "return", "$", "this", "->", "normalizeResult", "(", "$", "snippets", ")", ";", "}" ]
Get all snippets for a given Yahoo SERP page. @param SimpleHtmlDom $SHDObject @return array
[ "Get", "all", "snippets", "for", "a", "given", "Yahoo", "SERP", "page", "." ]
0554b682a8e4aec6e5d615866087b34e731e0d88
https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Fetchers/YahooFetcher.php#L59-L68
9,634
dlds/yii2-rels
components/Interpreter.php
Interpreter.interpretAttribute
public function interpretAttribute($attribute, $index = null) { if ($index) { $availables = $this->getInterpretations(); if (isset($availables[$index])) { return $availables[$index]->{$attribute}; } } $current = $this->getCurrentInterpretation(); if ($current) { return $current->{$attribute}; } return null; }
php
public function interpretAttribute($attribute, $index = null) { if ($index) { $availables = $this->getInterpretations(); if (isset($availables[$index])) { return $availables[$index]->{$attribute}; } } $current = $this->getCurrentInterpretation(); if ($current) { return $current->{$attribute}; } return null; }
[ "public", "function", "interpretAttribute", "(", "$", "attribute", ",", "$", "index", "=", "null", ")", "{", "if", "(", "$", "index", ")", "{", "$", "availables", "=", "$", "this", "->", "getInterpretations", "(", ")", ";", "if", "(", "isset", "(", "$", "availables", "[", "$", "index", "]", ")", ")", "{", "return", "$", "availables", "[", "$", "index", "]", "->", "{", "$", "attribute", "}", ";", "}", "}", "$", "current", "=", "$", "this", "->", "getCurrentInterpretation", "(", ")", ";", "if", "(", "$", "current", ")", "{", "return", "$", "current", "->", "{", "$", "attribute", "}", ";", "}", "return", "null", ";", "}" ]
Retrieves attribute interpretation for current hasMany relation @param string $attribute attribute name @return mixed Attribute value if interpretation exists otherwise NULL
[ "Retrieves", "attribute", "interpretation", "for", "current", "hasMany", "relation" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L111-L128
9,635
dlds/yii2-rels
components/Interpreter.php
Interpreter.getInterpretations
public function getInterpretations($data = null) { $condition = [$this->relPrimaryKey => $this->owner->primaryKey]; $restriction = $this->_getRestriction($data, $this->relSecondaryKey, false); if ($restriction) { $condition = ArrayHelper::merge($condition, $restriction); } return ArrayHelper::merge($this->viaModel->find() ->where($condition) ->andWhere(['not in', $this->relSecondaryKey, array_keys($this->_relationsToSave)]) ->indexBy($this->relSecondaryKey) ->all(), $this->_relationsToSave); }
php
public function getInterpretations($data = null) { $condition = [$this->relPrimaryKey => $this->owner->primaryKey]; $restriction = $this->_getRestriction($data, $this->relSecondaryKey, false); if ($restriction) { $condition = ArrayHelper::merge($condition, $restriction); } return ArrayHelper::merge($this->viaModel->find() ->where($condition) ->andWhere(['not in', $this->relSecondaryKey, array_keys($this->_relationsToSave)]) ->indexBy($this->relSecondaryKey) ->all(), $this->_relationsToSave); }
[ "public", "function", "getInterpretations", "(", "$", "data", "=", "null", ")", "{", "$", "condition", "=", "[", "$", "this", "->", "relPrimaryKey", "=>", "$", "this", "->", "owner", "->", "primaryKey", "]", ";", "$", "restriction", "=", "$", "this", "->", "_getRestriction", "(", "$", "data", ",", "$", "this", "->", "relSecondaryKey", ",", "false", ")", ";", "if", "(", "$", "restriction", ")", "{", "$", "condition", "=", "ArrayHelper", "::", "merge", "(", "$", "condition", ",", "$", "restriction", ")", ";", "}", "return", "ArrayHelper", "::", "merge", "(", "$", "this", "->", "viaModel", "->", "find", "(", ")", "->", "where", "(", "$", "condition", ")", "->", "andWhere", "(", "[", "'not in'", ",", "$", "this", "->", "relSecondaryKey", ",", "array_keys", "(", "$", "this", "->", "_relationsToSave", ")", "]", ")", "->", "indexBy", "(", "$", "this", "->", "relSecondaryKey", ")", "->", "all", "(", ")", ",", "$", "this", "->", "_relationsToSave", ")", ";", "}" ]
Retrieves interpretations based on gived data @param array $data
[ "Retrieves", "interpretations", "based", "on", "gived", "data" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L148-L163
9,636
dlds/yii2-rels
components/Interpreter.php
Interpreter.setInterpretations
public function setInterpretations($data) { if ($data && ArrayHelper::getValue($data, $this->viaModel->formName(), false)) { $data = $this->pushSecondaryKeys($data, $this->viaModel->formName()); $this->_relationsToSave = $this->pushMissingInterpretations($this->getInterpretations($data), $data); if ($this->_relationsToSave) { $this->viaModel->loadMultiple($this->_relationsToSave, $data, $this->viaModel->formName()); $this->_removeDisabledRelations(); } } return $this; }
php
public function setInterpretations($data) { if ($data && ArrayHelper::getValue($data, $this->viaModel->formName(), false)) { $data = $this->pushSecondaryKeys($data, $this->viaModel->formName()); $this->_relationsToSave = $this->pushMissingInterpretations($this->getInterpretations($data), $data); if ($this->_relationsToSave) { $this->viaModel->loadMultiple($this->_relationsToSave, $data, $this->viaModel->formName()); $this->_removeDisabledRelations(); } } return $this; }
[ "public", "function", "setInterpretations", "(", "$", "data", ")", "{", "if", "(", "$", "data", "&&", "ArrayHelper", "::", "getValue", "(", "$", "data", ",", "$", "this", "->", "viaModel", "->", "formName", "(", ")", ",", "false", ")", ")", "{", "$", "data", "=", "$", "this", "->", "pushSecondaryKeys", "(", "$", "data", ",", "$", "this", "->", "viaModel", "->", "formName", "(", ")", ")", ";", "$", "this", "->", "_relationsToSave", "=", "$", "this", "->", "pushMissingInterpretations", "(", "$", "this", "->", "getInterpretations", "(", "$", "data", ")", ",", "$", "data", ")", ";", "if", "(", "$", "this", "->", "_relationsToSave", ")", "{", "$", "this", "->", "viaModel", "->", "loadMultiple", "(", "$", "this", "->", "_relationsToSave", ",", "$", "data", ",", "$", "this", "->", "viaModel", "->", "formName", "(", ")", ")", ";", "$", "this", "->", "_removeDisabledRelations", "(", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Sets specific model relations attributes @param array $data relations data to be set
[ "Sets", "specific", "model", "relations", "attributes" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L169-L184
9,637
dlds/yii2-rels
components/Interpreter.php
Interpreter.getAllInterpretations
public function getAllInterpretations() { $hash = $this->_getInterpreterHash(); if (!$this->allowCache || empty($this->_allInterpretations[$hash])) { $this->_allInterpretations[$hash] = $this->pushMissingInterpretations($this->getInterpretations()); } return $this->_allInterpretations[$hash]; }
php
public function getAllInterpretations() { $hash = $this->_getInterpreterHash(); if (!$this->allowCache || empty($this->_allInterpretations[$hash])) { $this->_allInterpretations[$hash] = $this->pushMissingInterpretations($this->getInterpretations()); } return $this->_allInterpretations[$hash]; }
[ "public", "function", "getAllInterpretations", "(", ")", "{", "$", "hash", "=", "$", "this", "->", "_getInterpreterHash", "(", ")", ";", "if", "(", "!", "$", "this", "->", "allowCache", "||", "empty", "(", "$", "this", "->", "_allInterpretations", "[", "$", "hash", "]", ")", ")", "{", "$", "this", "->", "_allInterpretations", "[", "$", "hash", "]", "=", "$", "this", "->", "pushMissingInterpretations", "(", "$", "this", "->", "getInterpretations", "(", ")", ")", ";", "}", "return", "$", "this", "->", "_allInterpretations", "[", "$", "hash", "]", ";", "}" ]
Retrieves all possible hasMany relation models for owner. @return array hasMany relation models array
[ "Retrieves", "all", "possible", "hasMany", "relation", "models", "for", "owner", "." ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L201-L210
9,638
dlds/yii2-rels
components/Interpreter.php
Interpreter.setAllInterpretations
public function setAllInterpretations($data) { $model = $this->viaModel; $this->_relationsToSave = $this->getAllInterpretations(); $model::loadMultiple($this->_relationsToSave, $data); return $this; }
php
public function setAllInterpretations($data) { $model = $this->viaModel; $this->_relationsToSave = $this->getAllInterpretations(); $model::loadMultiple($this->_relationsToSave, $data); return $this; }
[ "public", "function", "setAllInterpretations", "(", "$", "data", ")", "{", "$", "model", "=", "$", "this", "->", "viaModel", ";", "$", "this", "->", "_relationsToSave", "=", "$", "this", "->", "getAllInterpretations", "(", ")", ";", "$", "model", "::", "loadMultiple", "(", "$", "this", "->", "_relationsToSave", ",", "$", "data", ")", ";", "return", "$", "this", ";", "}" ]
Sets all model relations attributes @param array $data relations data to be set
[ "Sets", "all", "model", "relations", "attributes" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L216-L225
9,639
dlds/yii2-rels
components/Interpreter.php
Interpreter.pushSecondaryKeys
protected function pushSecondaryKeys($data, $form) { if (isset($data[$form]) && is_array($data[$form])) { foreach ($data[$form] as $secondaryKey => $values) { $data[$form][$secondaryKey][$this->relSecondaryKey] = $secondaryKey; } } return $data; }
php
protected function pushSecondaryKeys($data, $form) { if (isset($data[$form]) && is_array($data[$form])) { foreach ($data[$form] as $secondaryKey => $values) { $data[$form][$secondaryKey][$this->relSecondaryKey] = $secondaryKey; } } return $data; }
[ "protected", "function", "pushSecondaryKeys", "(", "$", "data", ",", "$", "form", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "form", "]", ")", "&&", "is_array", "(", "$", "data", "[", "$", "form", "]", ")", ")", "{", "foreach", "(", "$", "data", "[", "$", "form", "]", "as", "$", "secondaryKey", "=>", "$", "values", ")", "{", "$", "data", "[", "$", "form", "]", "[", "$", "secondaryKey", "]", "[", "$", "this", "->", "relSecondaryKey", "]", "=", "$", "secondaryKey", ";", "}", "}", "return", "$", "data", ";", "}" ]
Pushes secondary keys to given data @param array $data @param string $form
[ "Pushes", "secondary", "keys", "to", "given", "data" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L286-L295
9,640
dlds/yii2-rels
components/Interpreter.php
Interpreter.pushMissingInterpretations
protected function pushMissingInterpretations($availables, $data = null) { /* @var $secondaryModel \yii\db\ActiveRecord */ $secondaryModel = new $this->relSecondary->modelClass; $queryModel = $secondaryModel->find(); $restriction = $this->_getRestriction($data, $this->_getPrimaryKeyName($secondaryModel)); $viaRestriction = ArrayHelper::remove($restriction, $this->relSecondaryKey, false); if (false !== $viaRestriction) { $restriction[$this->_getPrimaryKeyName($secondaryModel)] = $viaRestriction; } if ($restriction) { $queryModel->where($restriction); } foreach ($queryModel->all() as $secondary) { if (!isset($availables[$secondary->primaryKey])) { $availables[$secondary->primaryKey] = $this->_createInterpretation($secondary->primaryKey); } } ksort($availables); return $availables; }
php
protected function pushMissingInterpretations($availables, $data = null) { /* @var $secondaryModel \yii\db\ActiveRecord */ $secondaryModel = new $this->relSecondary->modelClass; $queryModel = $secondaryModel->find(); $restriction = $this->_getRestriction($data, $this->_getPrimaryKeyName($secondaryModel)); $viaRestriction = ArrayHelper::remove($restriction, $this->relSecondaryKey, false); if (false !== $viaRestriction) { $restriction[$this->_getPrimaryKeyName($secondaryModel)] = $viaRestriction; } if ($restriction) { $queryModel->where($restriction); } foreach ($queryModel->all() as $secondary) { if (!isset($availables[$secondary->primaryKey])) { $availables[$secondary->primaryKey] = $this->_createInterpretation($secondary->primaryKey); } } ksort($availables); return $availables; }
[ "protected", "function", "pushMissingInterpretations", "(", "$", "availables", ",", "$", "data", "=", "null", ")", "{", "/* @var $secondaryModel \\yii\\db\\ActiveRecord */", "$", "secondaryModel", "=", "new", "$", "this", "->", "relSecondary", "->", "modelClass", ";", "$", "queryModel", "=", "$", "secondaryModel", "->", "find", "(", ")", ";", "$", "restriction", "=", "$", "this", "->", "_getRestriction", "(", "$", "data", ",", "$", "this", "->", "_getPrimaryKeyName", "(", "$", "secondaryModel", ")", ")", ";", "$", "viaRestriction", "=", "ArrayHelper", "::", "remove", "(", "$", "restriction", ",", "$", "this", "->", "relSecondaryKey", ",", "false", ")", ";", "if", "(", "false", "!==", "$", "viaRestriction", ")", "{", "$", "restriction", "[", "$", "this", "->", "_getPrimaryKeyName", "(", "$", "secondaryModel", ")", "]", "=", "$", "viaRestriction", ";", "}", "if", "(", "$", "restriction", ")", "{", "$", "queryModel", "->", "where", "(", "$", "restriction", ")", ";", "}", "foreach", "(", "$", "queryModel", "->", "all", "(", ")", "as", "$", "secondary", ")", "{", "if", "(", "!", "isset", "(", "$", "availables", "[", "$", "secondary", "->", "primaryKey", "]", ")", ")", "{", "$", "availables", "[", "$", "secondary", "->", "primaryKey", "]", "=", "$", "this", "->", "_createInterpretation", "(", "$", "secondary", "->", "primaryKey", ")", ";", "}", "}", "ksort", "(", "$", "availables", ")", ";", "return", "$", "availables", ";", "}" ]
Default method for getting all owner's possible hasMany relation models. This can be overloaded and changed in owner's model class.
[ "Default", "method", "for", "getting", "all", "owner", "s", "possible", "hasMany", "relation", "models", ".", "This", "can", "be", "overloaded", "and", "changed", "in", "owner", "s", "model", "class", "." ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L301-L329
9,641
dlds/yii2-rels
components/Interpreter.php
Interpreter._getRestriction
private function _getRestriction($data, $secodaryKey, $allowGlobal = true) { $restriction = []; if ($data) { $restriction[$secodaryKey] = $this->_getSecondaryKeys($data, $this->viaModel->formName()); } if ($allowGlobal && $this->restriction) { $restriction = ArrayHelper::merge($restriction, $this->restriction); } return $restriction; }
php
private function _getRestriction($data, $secodaryKey, $allowGlobal = true) { $restriction = []; if ($data) { $restriction[$secodaryKey] = $this->_getSecondaryKeys($data, $this->viaModel->formName()); } if ($allowGlobal && $this->restriction) { $restriction = ArrayHelper::merge($restriction, $this->restriction); } return $restriction; }
[ "private", "function", "_getRestriction", "(", "$", "data", ",", "$", "secodaryKey", ",", "$", "allowGlobal", "=", "true", ")", "{", "$", "restriction", "=", "[", "]", ";", "if", "(", "$", "data", ")", "{", "$", "restriction", "[", "$", "secodaryKey", "]", "=", "$", "this", "->", "_getSecondaryKeys", "(", "$", "data", ",", "$", "this", "->", "viaModel", "->", "formName", "(", ")", ")", ";", "}", "if", "(", "$", "allowGlobal", "&&", "$", "this", "->", "restriction", ")", "{", "$", "restriction", "=", "ArrayHelper", "::", "merge", "(", "$", "restriction", ",", "$", "this", "->", "restriction", ")", ";", "}", "return", "$", "restriction", ";", "}" ]
Parses and retrieves keys from given data @param type $data
[ "Parses", "and", "retrieves", "keys", "from", "given", "data" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L335-L348
9,642
dlds/yii2-rels
components/Interpreter.php
Interpreter._getSecondaryKeys
private function _getSecondaryKeys($data, $key = null) { if ($key) { $data = ArrayHelper::getValue($data, $key, []); } return ArrayHelper::getColumn($data, $this->relSecondaryKey); }
php
private function _getSecondaryKeys($data, $key = null) { if ($key) { $data = ArrayHelper::getValue($data, $key, []); } return ArrayHelper::getColumn($data, $this->relSecondaryKey); }
[ "private", "function", "_getSecondaryKeys", "(", "$", "data", ",", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", ")", "{", "$", "data", "=", "ArrayHelper", "::", "getValue", "(", "$", "data", ",", "$", "key", ",", "[", "]", ")", ";", "}", "return", "ArrayHelper", "::", "getColumn", "(", "$", "data", ",", "$", "this", "->", "relSecondaryKey", ")", ";", "}" ]
Retrieves secondary keys @param type $data
[ "Retrieves", "secondary", "keys" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L354-L361
9,643
dlds/yii2-rels
components/Interpreter.php
Interpreter._getPrimaryKeyName
private function _getPrimaryKeyName(\yii\db\ActiveRecord $model, $composite = false) { $primaryKey = $model->primaryKey(); if (!$composite && count($primaryKey) > 1) { throw new Exception('Model has composit key which is not allowed. Relations cannot be established'); } return array_shift($primaryKey); }
php
private function _getPrimaryKeyName(\yii\db\ActiveRecord $model, $composite = false) { $primaryKey = $model->primaryKey(); if (!$composite && count($primaryKey) > 1) { throw new Exception('Model has composit key which is not allowed. Relations cannot be established'); } return array_shift($primaryKey); }
[ "private", "function", "_getPrimaryKeyName", "(", "\\", "yii", "\\", "db", "\\", "ActiveRecord", "$", "model", ",", "$", "composite", "=", "false", ")", "{", "$", "primaryKey", "=", "$", "model", "->", "primaryKey", "(", ")", ";", "if", "(", "!", "$", "composite", "&&", "count", "(", "$", "primaryKey", ")", ">", "1", ")", "{", "throw", "new", "Exception", "(", "'Model has composit key which is not allowed. Relations cannot be established'", ")", ";", "}", "return", "array_shift", "(", "$", "primaryKey", ")", ";", "}" ]
Retrieves primary key name
[ "Retrieves", "primary", "key", "name" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L366-L375
9,644
dlds/yii2-rels
components/Interpreter.php
Interpreter._createInterpretation
private function _createInterpretation($secondaryKey) { $model = new $this->viaModel; $model->{$this->relPrimaryKey} = $this->owner->primaryKey; $model->{$this->relSecondaryKey} = $secondaryKey; return $model; }
php
private function _createInterpretation($secondaryKey) { $model = new $this->viaModel; $model->{$this->relPrimaryKey} = $this->owner->primaryKey; $model->{$this->relSecondaryKey} = $secondaryKey; return $model; }
[ "private", "function", "_createInterpretation", "(", "$", "secondaryKey", ")", "{", "$", "model", "=", "new", "$", "this", "->", "viaModel", ";", "$", "model", "->", "{", "$", "this", "->", "relPrimaryKey", "}", "=", "$", "this", "->", "owner", "->", "primaryKey", ";", "$", "model", "->", "{", "$", "this", "->", "relSecondaryKey", "}", "=", "$", "secondaryKey", ";", "return", "$", "model", ";", "}" ]
Creates new interpretation and assigns it with owner @param \yii\db\ActiveRecord $secondary given secondary instance
[ "Creates", "new", "interpretation", "and", "assigns", "it", "with", "owner" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L381-L389
9,645
dlds/yii2-rels
components/Interpreter.php
Interpreter._loadInterpreterConfig
private function _loadInterpreterConfig($config) { if (count($config) < 3) { throw new \yii\base\Exception(\Yii::t('ib', 'Invalid config for interpreter. Missing required keys.')); } $this->viaModel = new $config[self::INDEX_VIA_CLASS]; if (isset($config[self::INDEX_VIA_CURRENT])) { $this->viaCurrent = $config[self::INDEX_VIA_CURRENT]; } $this->relPrimary = $this->viaModel->getRelation($config[self::INDEX_REL_PRIMARY]); $this->relSecondary = $this->viaModel->getRelation($config[self::INDEX_REL_SECONDARY]); $this->relPrimaryKey = array_pop($this->relPrimary->link); $this->relSecondaryKey = array_pop($this->relSecondary->link); }
php
private function _loadInterpreterConfig($config) { if (count($config) < 3) { throw new \yii\base\Exception(\Yii::t('ib', 'Invalid config for interpreter. Missing required keys.')); } $this->viaModel = new $config[self::INDEX_VIA_CLASS]; if (isset($config[self::INDEX_VIA_CURRENT])) { $this->viaCurrent = $config[self::INDEX_VIA_CURRENT]; } $this->relPrimary = $this->viaModel->getRelation($config[self::INDEX_REL_PRIMARY]); $this->relSecondary = $this->viaModel->getRelation($config[self::INDEX_REL_SECONDARY]); $this->relPrimaryKey = array_pop($this->relPrimary->link); $this->relSecondaryKey = array_pop($this->relSecondary->link); }
[ "private", "function", "_loadInterpreterConfig", "(", "$", "config", ")", "{", "if", "(", "count", "(", "$", "config", ")", "<", "3", ")", "{", "throw", "new", "\\", "yii", "\\", "base", "\\", "Exception", "(", "\\", "Yii", "::", "t", "(", "'ib'", ",", "'Invalid config for interpreter. Missing required keys.'", ")", ")", ";", "}", "$", "this", "->", "viaModel", "=", "new", "$", "config", "[", "self", "::", "INDEX_VIA_CLASS", "]", ";", "if", "(", "isset", "(", "$", "config", "[", "self", "::", "INDEX_VIA_CURRENT", "]", ")", ")", "{", "$", "this", "->", "viaCurrent", "=", "$", "config", "[", "self", "::", "INDEX_VIA_CURRENT", "]", ";", "}", "$", "this", "->", "relPrimary", "=", "$", "this", "->", "viaModel", "->", "getRelation", "(", "$", "config", "[", "self", "::", "INDEX_REL_PRIMARY", "]", ")", ";", "$", "this", "->", "relSecondary", "=", "$", "this", "->", "viaModel", "->", "getRelation", "(", "$", "config", "[", "self", "::", "INDEX_REL_SECONDARY", "]", ")", ";", "$", "this", "->", "relPrimaryKey", "=", "array_pop", "(", "$", "this", "->", "relPrimary", "->", "link", ")", ";", "$", "this", "->", "relSecondaryKey", "=", "array_pop", "(", "$", "this", "->", "relSecondary", "->", "link", ")", ";", "}" ]
Loads interpreter config @param string $key Given config key @throws Exception throws when confign nor exists or is invalid
[ "Loads", "interpreter", "config" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L401-L420
9,646
dlds/yii2-rels
components/Interpreter.php
Interpreter._removeDisabledRelations
private function _removeDisabledRelations() { if (!$this->attrActive) { return false; } foreach ($this->_relationsToSave as $key => $rel) { if (!isset($rel->{$this->attrActive})) { continue; } if (!$rel->validate() && !$rel->{$this->attrActive}) { ArrayHelper::remove($this->_relationsToSave, $key); } } return true; }
php
private function _removeDisabledRelations() { if (!$this->attrActive) { return false; } foreach ($this->_relationsToSave as $key => $rel) { if (!isset($rel->{$this->attrActive})) { continue; } if (!$rel->validate() && !$rel->{$this->attrActive}) { ArrayHelper::remove($this->_relationsToSave, $key); } } return true; }
[ "private", "function", "_removeDisabledRelations", "(", ")", "{", "if", "(", "!", "$", "this", "->", "attrActive", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "_relationsToSave", "as", "$", "key", "=>", "$", "rel", ")", "{", "if", "(", "!", "isset", "(", "$", "rel", "->", "{", "$", "this", "->", "attrActive", "}", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "$", "rel", "->", "validate", "(", ")", "&&", "!", "$", "rel", "->", "{", "$", "this", "->", "attrActive", "}", ")", "{", "ArrayHelper", "::", "remove", "(", "$", "this", "->", "_relationsToSave", ",", "$", "key", ")", ";", "}", "}", "return", "true", ";", "}" ]
Removed disabled relations when are not valid @return boolean
[ "Removed", "disabled", "relations", "when", "are", "not", "valid" ]
fb73064f2db98a751f9a93ab1146c0a133eba8f2
https://github.com/dlds/yii2-rels/blob/fb73064f2db98a751f9a93ab1146c0a133eba8f2/components/Interpreter.php#L426-L444
9,647
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.extractNumeroFromAdresseString
private function extractNumeroFromAdresseString($strAdresse = "") { $retour=""; for ($i=0; $i < pia_strlen($strAdresse); $i++) { if (!is_numeric(pia_substr($strAdresse, $i, 1))) { $retour.=pia_substr($strAdresse, $i, 1); } } return $retour; }
php
private function extractNumeroFromAdresseString($strAdresse = "") { $retour=""; for ($i=0; $i < pia_strlen($strAdresse); $i++) { if (!is_numeric(pia_substr($strAdresse, $i, 1))) { $retour.=pia_substr($strAdresse, $i, 1); } } return $retour; }
[ "private", "function", "extractNumeroFromAdresseString", "(", "$", "strAdresse", "=", "\"\"", ")", "{", "$", "retour", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "pia_strlen", "(", "$", "strAdresse", ")", ";", "$", "i", "++", ")", "{", "if", "(", "!", "is_numeric", "(", "pia_substr", "(", "$", "strAdresse", ",", "$", "i", ",", "1", ")", ")", ")", "{", "$", "retour", ".=", "pia_substr", "(", "$", "strAdresse", ",", "$", "i", ",", "1", ")", ";", "}", "}", "return", "$", "retour", ";", "}" ]
fonction qui renvoi enleve les numeros de rue des chaines de caracteres d'adresses
[ "fonction", "qui", "renvoi", "enleve", "les", "numeros", "de", "rue", "des", "chaines", "de", "caracteres", "d", "adresses" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L857-L870
9,648
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getUrlImageFrom
public function getUrlImageFrom($idAdresse = 0, $format = 'mini', $sqlWhere = '') { $url=""; $dateUpload = ""; $idHistoriqueImage = ""; $string = new stringObject(); /* inutile a cause de l'url rewriting switch($format) { case 'mini': $chemin = $this->getUrlImage("mini"); break; case 'moyen': $chemin = $this->getUrlImage("moyen"); break; case 'grand': $chemin = $this->getUrlImage("grand"); break; } */ $req = "SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload,ha1.idAdresse as idAdresse,ha1.numero as numero, r.nom as nomRue, sq.nom as nomSousQuartier, q.nom as nomQuartier, v.nom as nomVille, p.nom as nomPays, ha1.numero as numeroAdresse, ha1.idRue, r.prefixe as prefixeRue, IF (ha1.idSousQuartier != 0, ha1.idSousQuartier, r.idSousQuartier) AS idSousQuartier, IF (ha1.idQuartier != 0, ha1.idQuartier, sq.idQuartier) AS idQuartier, IF (ha1.idVille != 0, ha1.idVille, q.idVille) AS idVille, IF (ha1.idPays != 0, ha1.idPays, v.idPays) AS idPays FROM historiqueImage hi2, historiqueImage hi1 RIGHT JOIN _adresseEvenement ae ON ae.idAdresse = '".$idAdresse."' RIGHT JOIN _evenementEvenement ee ON ee.idEvenement = ae.idEvenement RIGHT JOIN _evenementImage ei ON ei.idEvenement = ee.idEvenementAssocie RIGHT JOIN evenements he1 ON he1.idEvenement=ee.idEvenementAssocie RIGHT JOIN evenements he2 ON he2.idEvenement = he1.idEvenement RIGHT JOIN historiqueAdresse ha1 ON ha1.idAdresse = ae.idAdresse RIGHT JOIN historiqueAdresse ha2 ON ha2.idAdresse = ha1.idAdresse LEFT JOIN rue r ON r.idRue = ha1.idRue LEFT JOIN sousQuartier sq ON sq.idSousQuartier = IF(ha1.idRue='0' and ha1.idSousQuartier!='0' ,ha1.idSousQuartier ,r.idSousQuartier ) LEFT JOIN quartier q ON q.idQuartier = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier!='0' ,ha1.idQuartier ,sq.idQuartier ) LEFT JOIN ville v ON v.idVille = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier='0' and ha1.idVille!='0' ,ha1.idVille ,q.idVille ) LEFT JOIN pays p ON p.idPays = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier='0' and ha1.idVille='0' and ha1.idPays!='0' ,ha1.idPays ,v.idPays ) WHERE hi2.idImage = hi1.idImage AND hi1.idImage = ei.idImage ".$sqlWhere." GROUP BY hi1.idImage,he1.idEvenement,ha1.idAdresse, hi1.idHistoriqueImage, ha1.idHistoriqueAdresse HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) AND ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse) LIMIT 1"; $res = $this->connexionBdd->requete($req); $url=''; $dateUpload=''; $idHistoriqueImage=0; if (mysql_num_rows($res)==1) { $fetchAdresse = mysql_fetch_assoc($res); //$url = $chemin.$fetchAdresse['dateUpload'].'/'.$fetchAdresse['idHistoriqueImage'].".jpg"; $url = 'photos-'.$string->convertStringToUrlRewrite($this->getIntituleAdresse($fetchAdresse)).'-'.$fetchAdresse['dateUpload'].'-'.$fetchAdresse['idHistoriqueImage'].'-'.$format.'.jpg'; $dateUpload = $fetchAdresse['dateUpload']; $idHistoriqueImage = $fetchAdresse['idHistoriqueImage']; } if ($url=='') { $url = $this->getUrlImage().'transparent.gif'; } return array('url'=>$url,'dateUpload'=>$dateUpload,'idHistoriqueImage'=>$idHistoriqueImage); }
php
public function getUrlImageFrom($idAdresse = 0, $format = 'mini', $sqlWhere = '') { $url=""; $dateUpload = ""; $idHistoriqueImage = ""; $string = new stringObject(); /* inutile a cause de l'url rewriting switch($format) { case 'mini': $chemin = $this->getUrlImage("mini"); break; case 'moyen': $chemin = $this->getUrlImage("moyen"); break; case 'grand': $chemin = $this->getUrlImage("grand"); break; } */ $req = "SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload,ha1.idAdresse as idAdresse,ha1.numero as numero, r.nom as nomRue, sq.nom as nomSousQuartier, q.nom as nomQuartier, v.nom as nomVille, p.nom as nomPays, ha1.numero as numeroAdresse, ha1.idRue, r.prefixe as prefixeRue, IF (ha1.idSousQuartier != 0, ha1.idSousQuartier, r.idSousQuartier) AS idSousQuartier, IF (ha1.idQuartier != 0, ha1.idQuartier, sq.idQuartier) AS idQuartier, IF (ha1.idVille != 0, ha1.idVille, q.idVille) AS idVille, IF (ha1.idPays != 0, ha1.idPays, v.idPays) AS idPays FROM historiqueImage hi2, historiqueImage hi1 RIGHT JOIN _adresseEvenement ae ON ae.idAdresse = '".$idAdresse."' RIGHT JOIN _evenementEvenement ee ON ee.idEvenement = ae.idEvenement RIGHT JOIN _evenementImage ei ON ei.idEvenement = ee.idEvenementAssocie RIGHT JOIN evenements he1 ON he1.idEvenement=ee.idEvenementAssocie RIGHT JOIN evenements he2 ON he2.idEvenement = he1.idEvenement RIGHT JOIN historiqueAdresse ha1 ON ha1.idAdresse = ae.idAdresse RIGHT JOIN historiqueAdresse ha2 ON ha2.idAdresse = ha1.idAdresse LEFT JOIN rue r ON r.idRue = ha1.idRue LEFT JOIN sousQuartier sq ON sq.idSousQuartier = IF(ha1.idRue='0' and ha1.idSousQuartier!='0' ,ha1.idSousQuartier ,r.idSousQuartier ) LEFT JOIN quartier q ON q.idQuartier = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier!='0' ,ha1.idQuartier ,sq.idQuartier ) LEFT JOIN ville v ON v.idVille = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier='0' and ha1.idVille!='0' ,ha1.idVille ,q.idVille ) LEFT JOIN pays p ON p.idPays = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier='0' and ha1.idVille='0' and ha1.idPays!='0' ,ha1.idPays ,v.idPays ) WHERE hi2.idImage = hi1.idImage AND hi1.idImage = ei.idImage ".$sqlWhere." GROUP BY hi1.idImage,he1.idEvenement,ha1.idAdresse, hi1.idHistoriqueImage, ha1.idHistoriqueAdresse HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) AND ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse) LIMIT 1"; $res = $this->connexionBdd->requete($req); $url=''; $dateUpload=''; $idHistoriqueImage=0; if (mysql_num_rows($res)==1) { $fetchAdresse = mysql_fetch_assoc($res); //$url = $chemin.$fetchAdresse['dateUpload'].'/'.$fetchAdresse['idHistoriqueImage'].".jpg"; $url = 'photos-'.$string->convertStringToUrlRewrite($this->getIntituleAdresse($fetchAdresse)).'-'.$fetchAdresse['dateUpload'].'-'.$fetchAdresse['idHistoriqueImage'].'-'.$format.'.jpg'; $dateUpload = $fetchAdresse['dateUpload']; $idHistoriqueImage = $fetchAdresse['idHistoriqueImage']; } if ($url=='') { $url = $this->getUrlImage().'transparent.gif'; } return array('url'=>$url,'dateUpload'=>$dateUpload,'idHistoriqueImage'=>$idHistoriqueImage); }
[ "public", "function", "getUrlImageFrom", "(", "$", "idAdresse", "=", "0", ",", "$", "format", "=", "'mini'", ",", "$", "sqlWhere", "=", "''", ")", "{", "$", "url", "=", "\"\"", ";", "$", "dateUpload", "=", "\"\"", ";", "$", "idHistoriqueImage", "=", "\"\"", ";", "$", "string", "=", "new", "stringObject", "(", ")", ";", "/* inutile a cause de l'url rewriting\n\t\t switch($format)\n\t\t {\n\t\tcase 'mini':\n\t\t$chemin = $this->getUrlImage(\"mini\");\n\t\tbreak;\n\t\tcase 'moyen':\n\t\t$chemin = $this->getUrlImage(\"moyen\");\n\t\tbreak;\n\t\tcase 'grand':\n\t\t$chemin = $this->getUrlImage(\"grand\");\n\t\tbreak;\n\t\t}\n\t\t*/", "$", "req", "=", "\"SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload,ha1.idAdresse as idAdresse,ha1.numero as numero,\n\n\t\t\t\tr.nom as nomRue,\n\t\t\t\tsq.nom as nomSousQuartier,\n\t\t\t\tq.nom as nomQuartier,\n\t\t\t\tv.nom as nomVille,\n\t\t\t\tp.nom as nomPays,\n\t\t\t\tha1.numero as numeroAdresse,\n\t\t\t\tha1.idRue,\n\t\t\t\tr.prefixe as prefixeRue,\n\t\t\t\tIF (ha1.idSousQuartier != 0, ha1.idSousQuartier, r.idSousQuartier) AS idSousQuartier,\n\t\t\t\tIF (ha1.idQuartier != 0, ha1.idQuartier, sq.idQuartier) AS idQuartier,\n\t\t\t\tIF (ha1.idVille != 0, ha1.idVille, q.idVille) AS idVille,\n\t\t\t\tIF (ha1.idPays != 0, ha1.idPays, v.idPays) AS idPays\n\n\t\t\t\tFROM historiqueImage hi2, historiqueImage hi1\n\t\t\t\tRIGHT JOIN _adresseEvenement ae ON ae.idAdresse = '\"", ".", "$", "idAdresse", ".", "\"'\n\t\t\t\t\t\tRIGHT JOIN _evenementEvenement ee ON ee.idEvenement = ae.idEvenement\n\t\t\t\t\t\tRIGHT JOIN _evenementImage ei ON ei.idEvenement = ee.idEvenementAssocie\n\t\t\t\t\t\tRIGHT JOIN evenements he1 ON he1.idEvenement=ee.idEvenementAssocie\n\t\t\t\t\t\tRIGHT JOIN evenements he2 ON he2.idEvenement = he1.idEvenement\n\t\t\t\t\t\tRIGHT JOIN historiqueAdresse ha1 ON ha1.idAdresse = ae.idAdresse\n\t\t\t\t\t\tRIGHT JOIN historiqueAdresse ha2 ON ha2.idAdresse = ha1.idAdresse\n\n\t\t\t\t\t\tLEFT JOIN rue r ON r.idRue = ha1.idRue\n\t\t\t\t\t\tLEFT JOIN sousQuartier sq ON sq.idSousQuartier = IF(ha1.idRue='0' and ha1.idSousQuartier!='0' ,ha1.idSousQuartier ,r.idSousQuartier )\n\t\t\t\t\t\tLEFT JOIN quartier q ON q.idQuartier = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier!='0' ,ha1.idQuartier ,sq.idQuartier )\n\t\t\t\t\t\tLEFT JOIN ville v ON v.idVille = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier='0' and ha1.idVille!='0' ,ha1.idVille ,q.idVille )\n\t\t\t\t\t\tLEFT JOIN pays p ON p.idPays = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier='0' and ha1.idVille='0' and ha1.idPays!='0' ,ha1.idPays ,v.idPays )\n\n\t\t\t\t\t\tWHERE hi2.idImage = hi1.idImage\n\t\t\t\t\t\tAND hi1.idImage = ei.idImage\n\t\t\t\t\t\t\"", ".", "$", "sqlWhere", ".", "\"\n\t\t\t\t\t\t\t\tGROUP BY hi1.idImage,he1.idEvenement,ha1.idAdresse, hi1.idHistoriqueImage, ha1.idHistoriqueAdresse\n\t\t\t\t\t\t\t\tHAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage)\n\t\t\t\t\t\t\t\tAND ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse)\n\t\t\t\t\t\t\t\tLIMIT 1\"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "$", "url", "=", "''", ";", "$", "dateUpload", "=", "''", ";", "$", "idHistoriqueImage", "=", "0", ";", "if", "(", "mysql_num_rows", "(", "$", "res", ")", "==", "1", ")", "{", "$", "fetchAdresse", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "//$url = $chemin.$fetchAdresse['dateUpload'].'/'.$fetchAdresse['idHistoriqueImage'].\".jpg\";", "$", "url", "=", "'photos-'", ".", "$", "string", "->", "convertStringToUrlRewrite", "(", "$", "this", "->", "getIntituleAdresse", "(", "$", "fetchAdresse", ")", ")", ".", "'-'", ".", "$", "fetchAdresse", "[", "'dateUpload'", "]", ".", "'-'", ".", "$", "fetchAdresse", "[", "'idHistoriqueImage'", "]", ".", "'-'", ".", "$", "format", ".", "'.jpg'", ";", "$", "dateUpload", "=", "$", "fetchAdresse", "[", "'dateUpload'", "]", ";", "$", "idHistoriqueImage", "=", "$", "fetchAdresse", "[", "'idHistoriqueImage'", "]", ";", "}", "if", "(", "$", "url", "==", "''", ")", "{", "$", "url", "=", "$", "this", "->", "getUrlImage", "(", ")", ".", "'transparent.gif'", ";", "}", "return", "array", "(", "'url'", "=>", "$", "url", ",", "'dateUpload'", "=>", "$", "dateUpload", ",", "'idHistoriqueImage'", "=>", "$", "idHistoriqueImage", ")", ";", "}" ]
fonction recuperant l'image de la demolition
[ "fonction", "recuperant", "l", "image", "de", "la", "demolition" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L2315-L2392
9,649
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getArrayAdresseFromIdAdresse
public function getArrayAdresseFromIdAdresse($idAdresse = 0) { $req = " select ha.idAdresse as idAdresse, ha.date as date, ha.description as description, ha.nom as nom, ha.idHistoriqueAdresse as idHistoriqueAdresse, ha.numero as numero, IF(ha.idIndicatif='0','',i.nom) as nomIndicatif, ha.idRue, IF (ha.idSousQuartier != 0, ha.idSousQuartier, r.idSousQuartier) AS idSousQuartier, IF (ha.idQuartier != 0, ha.idQuartier, sq.idQuartier) AS idQuartier, IF (ha.idVille != 0, ha.idVille, q.idVille) AS idVille, IF (ha.idPays != 0, ha.idPays, v.idPays) AS idPays, r.prefixe as prefixeRue, r.nom as nomRue, sq.nom as nomSousQuartier, q.nom as nomQuartier, v.nom as nomVille, p.nom as nomPays from historiqueAdresse hab, historiqueAdresse ha LEFT JOIN rue r ON r.idRue = ha.idRue LEFT JOIN sousQuartier sq ON sq.idSousQuartier = IF(ha.idRue='0' and ha.idSousQuartier!='0' ,ha.idSousQuartier ,r.idSousQuartier ) LEFT JOIN quartier q ON q.idQuartier = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier!='0' ,ha.idQuartier ,sq.idQuartier ) LEFT JOIN ville v ON v.idVille = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier='0' and ha.idVille!='0' ,ha.idVille ,q.idVille ) LEFT JOIN indicatif i ON i.idIndicatif = ha.idIndicatif LEFT JOIN pays p ON p.idPays = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier='0' and ha.idVille='0' and ha.idPays!='0' ,ha.idPays ,v.idPays ) where ha.idAdresse = '".$idAdresse."' and hab.idAdresse = ha.idAdresse group by ha.idAdresse, ha.idHistoriqueAdresse having ha.idHistoriqueAdresse = max(hab.idHistoriqueAdresse) "; $res=$this->connexionBdd->requete($req); return mysql_fetch_assoc($res); }
php
public function getArrayAdresseFromIdAdresse($idAdresse = 0) { $req = " select ha.idAdresse as idAdresse, ha.date as date, ha.description as description, ha.nom as nom, ha.idHistoriqueAdresse as idHistoriqueAdresse, ha.numero as numero, IF(ha.idIndicatif='0','',i.nom) as nomIndicatif, ha.idRue, IF (ha.idSousQuartier != 0, ha.idSousQuartier, r.idSousQuartier) AS idSousQuartier, IF (ha.idQuartier != 0, ha.idQuartier, sq.idQuartier) AS idQuartier, IF (ha.idVille != 0, ha.idVille, q.idVille) AS idVille, IF (ha.idPays != 0, ha.idPays, v.idPays) AS idPays, r.prefixe as prefixeRue, r.nom as nomRue, sq.nom as nomSousQuartier, q.nom as nomQuartier, v.nom as nomVille, p.nom as nomPays from historiqueAdresse hab, historiqueAdresse ha LEFT JOIN rue r ON r.idRue = ha.idRue LEFT JOIN sousQuartier sq ON sq.idSousQuartier = IF(ha.idRue='0' and ha.idSousQuartier!='0' ,ha.idSousQuartier ,r.idSousQuartier ) LEFT JOIN quartier q ON q.idQuartier = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier!='0' ,ha.idQuartier ,sq.idQuartier ) LEFT JOIN ville v ON v.idVille = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier='0' and ha.idVille!='0' ,ha.idVille ,q.idVille ) LEFT JOIN indicatif i ON i.idIndicatif = ha.idIndicatif LEFT JOIN pays p ON p.idPays = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier='0' and ha.idVille='0' and ha.idPays!='0' ,ha.idPays ,v.idPays ) where ha.idAdresse = '".$idAdresse."' and hab.idAdresse = ha.idAdresse group by ha.idAdresse, ha.idHistoriqueAdresse having ha.idHistoriqueAdresse = max(hab.idHistoriqueAdresse) "; $res=$this->connexionBdd->requete($req); return mysql_fetch_assoc($res); }
[ "public", "function", "getArrayAdresseFromIdAdresse", "(", "$", "idAdresse", "=", "0", ")", "{", "$", "req", "=", "\"\n\t\t\t\tselect ha.idAdresse as idAdresse,\n\t\t\t\tha.date as date,\n\t\t\t\tha.description as description,\n\t\t\t\tha.nom as nom,\n\t\t\t\tha.idHistoriqueAdresse as idHistoriqueAdresse,\n\t\t\t\tha.numero as numero,\n\t\t\t\tIF(ha.idIndicatif='0','',i.nom) as nomIndicatif,\n\t\t\t\tha.idRue,\n\t\t\t\tIF (ha.idSousQuartier != 0, ha.idSousQuartier, r.idSousQuartier) AS idSousQuartier,\n\t\t\t\tIF (ha.idQuartier != 0, ha.idQuartier, sq.idQuartier) AS idQuartier,\n\t\t\t\tIF (ha.idVille != 0, ha.idVille, q.idVille) AS idVille,\n\t\t\t\tIF (ha.idPays != 0, ha.idPays, v.idPays) AS idPays,\n\n\t\t\t\tr.prefixe as prefixeRue,\n\t\t\t\tr.nom as nomRue,\n\t\t\t\tsq.nom as nomSousQuartier,\n\t\t\t\tq.nom as nomQuartier,\n\t\t\t\tv.nom as nomVille,\n\t\t\t\tp.nom as nomPays\n\n\t\t\t\tfrom historiqueAdresse hab, historiqueAdresse ha\n\n\t\t\t\tLEFT JOIN rue r ON r.idRue = ha.idRue\n\t\t\t\tLEFT JOIN sousQuartier sq ON sq.idSousQuartier = IF(ha.idRue='0' and ha.idSousQuartier!='0' ,ha.idSousQuartier ,r.idSousQuartier )\n\t\t\t\tLEFT JOIN quartier q ON q.idQuartier = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier!='0' ,ha.idQuartier ,sq.idQuartier )\n\t\t\t\tLEFT JOIN ville v ON v.idVille = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier='0' and ha.idVille!='0' ,ha.idVille ,q.idVille )\n\t\t\t\tLEFT JOIN indicatif i ON i.idIndicatif = ha.idIndicatif\n\t\t\t\tLEFT JOIN pays p ON p.idPays = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier='0' and ha.idVille='0' and ha.idPays!='0' ,ha.idPays ,v.idPays )\n\n\t\t\t\twhere ha.idAdresse = '\"", ".", "$", "idAdresse", ".", "\"'\n\t\t\t\t\t\tand hab.idAdresse = ha.idAdresse\n\t\t\t\t\t\tgroup by ha.idAdresse, ha.idHistoriqueAdresse\n\t\t\t\t\t\thaving ha.idHistoriqueAdresse = max(hab.idHistoriqueAdresse)\n\t\t\t\t\t\t\"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "return", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "}" ]
retourne un tableau contenant les infos de l'adresse
[ "retourne", "un", "tableau", "contenant", "les", "infos", "de", "l", "adresse" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L2550-L2589
9,650
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.afficheSelectVille
public function afficheSelectVille($params = array()) { $html=""; $t=new Template('modules/archi/templates/'); $t->set_filenames((array('listeVille'=>'listeVilleSelect.tpl'))); $a = new archiAuthentification(); $u = new archiUtilisateur(); $sqlWhereVillesModerees = ""; if ($a->getIdProfil()==3) { // l'utilisateur est un moderateur , on affiche que les quartiers qu'il peut moderer suivant les villes qu'il peut moderer $arrayIdVilles = $u->getArrayVillesModereesPar($a->getIdUtilisateur()); if (count($arrayIdVilles)>0) { $sqlWhereVillesModerees = " AND idVille IN (".implode(",", $arrayIdVilles).") "; } else { $sqlWhereVillesModerees = " AND idVille =0 "; // si le moderateur n'a pas de ville a moderer on affiche aucun (sinon la requete les afficheraient tous) } } $wherePays = ""; if (isset($params['idPays']) && $params['idPays']!='') { $wherePays = " AND idPays = '".$params['idPays']."' "; } if (isset($this->variablesGet["idPays"]) && $this->variablesGet["idPays"]!='') { $wherePays=" AND idPays = '".$this->variablesGet['idPays']."' "; } $javascriptQuartier = ""; if (!isset($params['noQuartier']) || $params['noQuartier']!=true) { $javascriptQuartier = " document.getElementById('quartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('quartiers').selectedIndex=0; appelAjax('?archiAffichage=afficheSelectQuartier&noHeaderNoFooter=1&idVille='+document.getElementById('ville').value,'champQuartier'); "; } $javascriptSousQuartier = ""; if (!isset($params['noSousQuartier']) || $params['noSousQuartier']!=true) { $javascriptSousQuartier = " document.getElementById('sousQuartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('sousQuartiers').selectedIndex=0; "; } $t->assign_vars(array('javascript'=>" function onChangeListeVille() { ".$javascriptSousQuartier." ".$javascriptQuartier." } ")); // assignation du javascript pour l'ajax $t->assign_vars(array('onChangeListeVille'=>"onChangeListeVille();")); $reqVille = "SELECT idVille, nom FROM ville WHERE 1=1 and nom<>'autre' ".$sqlWhereVillesModerees." ".$wherePays; $resVille = $this->connexionBdd->requete($reqVille); while ($fetchVille = mysql_fetch_assoc($resVille)) { $selected=""; if (isset($params['idVille']) && $params['idVille']!='' && $params['idVille'] == $fetchVille['idVille']) { $selected=" selected "; } $t->assign_block_vars('villes', array( 'id' =>$fetchVille['idVille'], 'nom' =>$fetchVille['nom'], 'selected'=>$selected )); } ob_start(); $t->pparse('listeVille'); $html=ob_get_contents(); ob_end_clean(); return $html; }
php
public function afficheSelectVille($params = array()) { $html=""; $t=new Template('modules/archi/templates/'); $t->set_filenames((array('listeVille'=>'listeVilleSelect.tpl'))); $a = new archiAuthentification(); $u = new archiUtilisateur(); $sqlWhereVillesModerees = ""; if ($a->getIdProfil()==3) { // l'utilisateur est un moderateur , on affiche que les quartiers qu'il peut moderer suivant les villes qu'il peut moderer $arrayIdVilles = $u->getArrayVillesModereesPar($a->getIdUtilisateur()); if (count($arrayIdVilles)>0) { $sqlWhereVillesModerees = " AND idVille IN (".implode(",", $arrayIdVilles).") "; } else { $sqlWhereVillesModerees = " AND idVille =0 "; // si le moderateur n'a pas de ville a moderer on affiche aucun (sinon la requete les afficheraient tous) } } $wherePays = ""; if (isset($params['idPays']) && $params['idPays']!='') { $wherePays = " AND idPays = '".$params['idPays']."' "; } if (isset($this->variablesGet["idPays"]) && $this->variablesGet["idPays"]!='') { $wherePays=" AND idPays = '".$this->variablesGet['idPays']."' "; } $javascriptQuartier = ""; if (!isset($params['noQuartier']) || $params['noQuartier']!=true) { $javascriptQuartier = " document.getElementById('quartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('quartiers').selectedIndex=0; appelAjax('?archiAffichage=afficheSelectQuartier&noHeaderNoFooter=1&idVille='+document.getElementById('ville').value,'champQuartier'); "; } $javascriptSousQuartier = ""; if (!isset($params['noSousQuartier']) || $params['noSousQuartier']!=true) { $javascriptSousQuartier = " document.getElementById('sousQuartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('sousQuartiers').selectedIndex=0; "; } $t->assign_vars(array('javascript'=>" function onChangeListeVille() { ".$javascriptSousQuartier." ".$javascriptQuartier." } ")); // assignation du javascript pour l'ajax $t->assign_vars(array('onChangeListeVille'=>"onChangeListeVille();")); $reqVille = "SELECT idVille, nom FROM ville WHERE 1=1 and nom<>'autre' ".$sqlWhereVillesModerees." ".$wherePays; $resVille = $this->connexionBdd->requete($reqVille); while ($fetchVille = mysql_fetch_assoc($resVille)) { $selected=""; if (isset($params['idVille']) && $params['idVille']!='' && $params['idVille'] == $fetchVille['idVille']) { $selected=" selected "; } $t->assign_block_vars('villes', array( 'id' =>$fetchVille['idVille'], 'nom' =>$fetchVille['nom'], 'selected'=>$selected )); } ob_start(); $t->pparse('listeVille'); $html=ob_get_contents(); ob_end_clean(); return $html; }
[ "public", "function", "afficheSelectVille", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "html", "=", "\"\"", ";", "$", "t", "=", "new", "Template", "(", "'modules/archi/templates/'", ")", ";", "$", "t", "->", "set_filenames", "(", "(", "array", "(", "'listeVille'", "=>", "'listeVilleSelect.tpl'", ")", ")", ")", ";", "$", "a", "=", "new", "archiAuthentification", "(", ")", ";", "$", "u", "=", "new", "archiUtilisateur", "(", ")", ";", "$", "sqlWhereVillesModerees", "=", "\"\"", ";", "if", "(", "$", "a", "->", "getIdProfil", "(", ")", "==", "3", ")", "{", "// l'utilisateur est un moderateur , on affiche que les quartiers qu'il peut moderer suivant les villes qu'il peut moderer", "$", "arrayIdVilles", "=", "$", "u", "->", "getArrayVillesModereesPar", "(", "$", "a", "->", "getIdUtilisateur", "(", ")", ")", ";", "if", "(", "count", "(", "$", "arrayIdVilles", ")", ">", "0", ")", "{", "$", "sqlWhereVillesModerees", "=", "\" AND idVille IN (\"", ".", "implode", "(", "\",\"", ",", "$", "arrayIdVilles", ")", ".", "\") \"", ";", "}", "else", "{", "$", "sqlWhereVillesModerees", "=", "\" AND idVille =0 \"", ";", "// si le moderateur n'a pas de ville a moderer on affiche aucun (sinon la requete les afficheraient tous)", "}", "}", "$", "wherePays", "=", "\"\"", ";", "if", "(", "isset", "(", "$", "params", "[", "'idPays'", "]", ")", "&&", "$", "params", "[", "'idPays'", "]", "!=", "''", ")", "{", "$", "wherePays", "=", "\" AND idPays = '\"", ".", "$", "params", "[", "'idPays'", "]", ".", "\"' \"", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "variablesGet", "[", "\"idPays\"", "]", ")", "&&", "$", "this", "->", "variablesGet", "[", "\"idPays\"", "]", "!=", "''", ")", "{", "$", "wherePays", "=", "\" AND idPays = '\"", ".", "$", "this", "->", "variablesGet", "[", "'idPays'", "]", ".", "\"' \"", ";", "}", "$", "javascriptQuartier", "=", "\"\"", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'noQuartier'", "]", ")", "||", "$", "params", "[", "'noQuartier'", "]", "!=", "true", ")", "{", "$", "javascriptQuartier", "=", "\"\n document.getElementById('quartiers').innerHTML='<option value=0>Aucun</option>';\n document.getElementById('quartiers').selectedIndex=0;\n appelAjax('?archiAffichage=afficheSelectQuartier&noHeaderNoFooter=1&idVille='+document.getElementById('ville').value,'champQuartier');\n \"", ";", "}", "$", "javascriptSousQuartier", "=", "\"\"", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'noSousQuartier'", "]", ")", "||", "$", "params", "[", "'noSousQuartier'", "]", "!=", "true", ")", "{", "$", "javascriptSousQuartier", "=", "\"\n document.getElementById('sousQuartiers').innerHTML='<option value=0>Aucun</option>';\n document.getElementById('sousQuartiers').selectedIndex=0;\n \"", ";", "}", "$", "t", "->", "assign_vars", "(", "array", "(", "'javascript'", "=>", "\"\n function onChangeListeVille()\n {\n \"", ".", "$", "javascriptSousQuartier", ".", "\"\n \"", ".", "$", "javascriptQuartier", ".", "\"\n }\n \"", ")", ")", ";", "// assignation du javascript pour l'ajax", "$", "t", "->", "assign_vars", "(", "array", "(", "'onChangeListeVille'", "=>", "\"onChangeListeVille();\"", ")", ")", ";", "$", "reqVille", "=", "\"SELECT idVille, nom FROM ville WHERE 1=1 and nom<>'autre' \"", ".", "$", "sqlWhereVillesModerees", ".", "\" \"", ".", "$", "wherePays", ";", "$", "resVille", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "reqVille", ")", ";", "while", "(", "$", "fetchVille", "=", "mysql_fetch_assoc", "(", "$", "resVille", ")", ")", "{", "$", "selected", "=", "\"\"", ";", "if", "(", "isset", "(", "$", "params", "[", "'idVille'", "]", ")", "&&", "$", "params", "[", "'idVille'", "]", "!=", "''", "&&", "$", "params", "[", "'idVille'", "]", "==", "$", "fetchVille", "[", "'idVille'", "]", ")", "{", "$", "selected", "=", "\" selected \"", ";", "}", "$", "t", "->", "assign_block_vars", "(", "'villes'", ",", "array", "(", "'id'", "=>", "$", "fetchVille", "[", "'idVille'", "]", ",", "'nom'", "=>", "$", "fetchVille", "[", "'nom'", "]", ",", "'selected'", "=>", "$", "selected", ")", ")", ";", "}", "ob_start", "(", ")", ";", "$", "t", "->", "pparse", "(", "'listeVille'", ")", ";", "$", "html", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "return", "$", "html", ";", "}" ]
affichage de la liste des villes sous forme d'un champ select
[ "affichage", "de", "la", "liste", "des", "villes", "sous", "forme", "d", "un", "champ", "select" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L6833-L6919
9,651
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.afficheSelectPays
public function afficheSelectPays($params = array()) { $html=""; $t=new Template('modules/archi/templates/'); $t->set_filenames((array('listePays'=>'listePaysSelect.tpl'))); $a = new archiAuthentification(); $u = new archiUtilisateur(); $sqlWhereVillesModerees = ""; if ($a->getIdProfil()==3) { // l'utilisateur est un moderateur , on affiche que les quartiers qu'il peut moderer suivant les villes qu'il peut moderer $arrayIdVilles = $u->getArrayVillesModereesPar($a->getIdUtilisateur()); $arrayIdPays = array(); // recuperation des pays concernés par les villes qu'administre le moderateur $reqPaysModeres = "SELECT distinct idPays FROM ville WHERE idVille IN (".implode(",", $arrayIdVilles).") "; $resPaysModeres = $this->connexionBdd->requete($reqPaysModeres); if (mysql_num_rows($resPaysModeres)>0) { while ($fetchPaysModeres = mysql_fetch_assoc($resPaysModeres)) { $arrayIdPays[] = $fetchPaysModeres['idPays']; } $sqlWhereVillesModerees = " AND idPays IN (".implode(",", $arrayIdPays).") "; } else { $sqlWhereVillesModerees = " AND idPays = 0 "; // si le moderateur ne gere aucune ville , on rajoute ce critere pour ne pas afficher toutes les villes } } $reqPays = "SELECT nom, idPays FROM pays WHERE 1=1 ".$sqlWhereVillesModerees; $resPays = $this->connexionBdd->requete($reqPays); $javascriptVille=""; if (!isset($params['noVille']) || $params['noVille']!=true) { $javascriptVille = " document.getElementById('ville').innerHTML='<option value=0>Aucun</option>'; document.getElementById('ville').selectedIndex=0; appelAjax('?archiAffichage=afficheSelectVille&noHeaderNoFooter=1&idPays='+document.getElementById('pays').value,'champVille'); "; } $javascriptQuartier=""; if (!isset($params['noQuartier']) || $params['noQuartier']!=true) { $javascriptQuartier=" document.getElementById('quartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('quartiers').selectedIndex=0; "; } $javascriptSousQuartier=""; if (!isset($params['noSousQuartier']) || $params['noSousQuartier']!=true) { $javascriptSousQuartier=" document.getElementById('sousQuartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('sousQuartiers').selectedIndex=0; "; } $t->assign_vars(array('javascript'=>" function onChangeListePays() { ".$javascriptSousQuartier." ".$javascriptQuartier." ".$javascriptVille." } ")); // assignation du javascript pour l'ajax $t->assign_vars(array('onChangeListePays'=>"onChangeListePays();")); while ($fetchPays = mysql_fetch_assoc($resPays)) { $selected=""; if (isset($params['idPays']) && $params['idPays']!='' && $params['idPays'] == $fetchPays['idPays']) { $selected=" selected "; } $t->assign_block_vars('pays', array( 'id'=>$fetchPays['idPays'], 'nom'=>$fetchPays['nom'], 'selected'=>$selected )); } ob_start(); $t->pparse('listePays'); $html=ob_get_contents(); ob_end_clean(); return $html; }
php
public function afficheSelectPays($params = array()) { $html=""; $t=new Template('modules/archi/templates/'); $t->set_filenames((array('listePays'=>'listePaysSelect.tpl'))); $a = new archiAuthentification(); $u = new archiUtilisateur(); $sqlWhereVillesModerees = ""; if ($a->getIdProfil()==3) { // l'utilisateur est un moderateur , on affiche que les quartiers qu'il peut moderer suivant les villes qu'il peut moderer $arrayIdVilles = $u->getArrayVillesModereesPar($a->getIdUtilisateur()); $arrayIdPays = array(); // recuperation des pays concernés par les villes qu'administre le moderateur $reqPaysModeres = "SELECT distinct idPays FROM ville WHERE idVille IN (".implode(",", $arrayIdVilles).") "; $resPaysModeres = $this->connexionBdd->requete($reqPaysModeres); if (mysql_num_rows($resPaysModeres)>0) { while ($fetchPaysModeres = mysql_fetch_assoc($resPaysModeres)) { $arrayIdPays[] = $fetchPaysModeres['idPays']; } $sqlWhereVillesModerees = " AND idPays IN (".implode(",", $arrayIdPays).") "; } else { $sqlWhereVillesModerees = " AND idPays = 0 "; // si le moderateur ne gere aucune ville , on rajoute ce critere pour ne pas afficher toutes les villes } } $reqPays = "SELECT nom, idPays FROM pays WHERE 1=1 ".$sqlWhereVillesModerees; $resPays = $this->connexionBdd->requete($reqPays); $javascriptVille=""; if (!isset($params['noVille']) || $params['noVille']!=true) { $javascriptVille = " document.getElementById('ville').innerHTML='<option value=0>Aucun</option>'; document.getElementById('ville').selectedIndex=0; appelAjax('?archiAffichage=afficheSelectVille&noHeaderNoFooter=1&idPays='+document.getElementById('pays').value,'champVille'); "; } $javascriptQuartier=""; if (!isset($params['noQuartier']) || $params['noQuartier']!=true) { $javascriptQuartier=" document.getElementById('quartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('quartiers').selectedIndex=0; "; } $javascriptSousQuartier=""; if (!isset($params['noSousQuartier']) || $params['noSousQuartier']!=true) { $javascriptSousQuartier=" document.getElementById('sousQuartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('sousQuartiers').selectedIndex=0; "; } $t->assign_vars(array('javascript'=>" function onChangeListePays() { ".$javascriptSousQuartier." ".$javascriptQuartier." ".$javascriptVille." } ")); // assignation du javascript pour l'ajax $t->assign_vars(array('onChangeListePays'=>"onChangeListePays();")); while ($fetchPays = mysql_fetch_assoc($resPays)) { $selected=""; if (isset($params['idPays']) && $params['idPays']!='' && $params['idPays'] == $fetchPays['idPays']) { $selected=" selected "; } $t->assign_block_vars('pays', array( 'id'=>$fetchPays['idPays'], 'nom'=>$fetchPays['nom'], 'selected'=>$selected )); } ob_start(); $t->pparse('listePays'); $html=ob_get_contents(); ob_end_clean(); return $html; }
[ "public", "function", "afficheSelectPays", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "html", "=", "\"\"", ";", "$", "t", "=", "new", "Template", "(", "'modules/archi/templates/'", ")", ";", "$", "t", "->", "set_filenames", "(", "(", "array", "(", "'listePays'", "=>", "'listePaysSelect.tpl'", ")", ")", ")", ";", "$", "a", "=", "new", "archiAuthentification", "(", ")", ";", "$", "u", "=", "new", "archiUtilisateur", "(", ")", ";", "$", "sqlWhereVillesModerees", "=", "\"\"", ";", "if", "(", "$", "a", "->", "getIdProfil", "(", ")", "==", "3", ")", "{", "// l'utilisateur est un moderateur , on affiche que les quartiers qu'il peut moderer suivant les villes qu'il peut moderer", "$", "arrayIdVilles", "=", "$", "u", "->", "getArrayVillesModereesPar", "(", "$", "a", "->", "getIdUtilisateur", "(", ")", ")", ";", "$", "arrayIdPays", "=", "array", "(", ")", ";", "// recuperation des pays concernés par les villes qu'administre le moderateur", "$", "reqPaysModeres", "=", "\"SELECT distinct idPays FROM ville WHERE idVille IN (\"", ".", "implode", "(", "\",\"", ",", "$", "arrayIdVilles", ")", ".", "\") \"", ";", "$", "resPaysModeres", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "reqPaysModeres", ")", ";", "if", "(", "mysql_num_rows", "(", "$", "resPaysModeres", ")", ">", "0", ")", "{", "while", "(", "$", "fetchPaysModeres", "=", "mysql_fetch_assoc", "(", "$", "resPaysModeres", ")", ")", "{", "$", "arrayIdPays", "[", "]", "=", "$", "fetchPaysModeres", "[", "'idPays'", "]", ";", "}", "$", "sqlWhereVillesModerees", "=", "\" AND idPays IN (\"", ".", "implode", "(", "\",\"", ",", "$", "arrayIdPays", ")", ".", "\") \"", ";", "}", "else", "{", "$", "sqlWhereVillesModerees", "=", "\" AND idPays = 0 \"", ";", "// si le moderateur ne gere aucune ville , on rajoute ce critere pour ne pas afficher toutes les villes", "}", "}", "$", "reqPays", "=", "\"SELECT nom, idPays FROM pays WHERE 1=1 \"", ".", "$", "sqlWhereVillesModerees", ";", "$", "resPays", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "reqPays", ")", ";", "$", "javascriptVille", "=", "\"\"", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'noVille'", "]", ")", "||", "$", "params", "[", "'noVille'", "]", "!=", "true", ")", "{", "$", "javascriptVille", "=", "\"\n document.getElementById('ville').innerHTML='<option value=0>Aucun</option>';\n document.getElementById('ville').selectedIndex=0;\n appelAjax('?archiAffichage=afficheSelectVille&noHeaderNoFooter=1&idPays='+document.getElementById('pays').value,'champVille');\n \"", ";", "}", "$", "javascriptQuartier", "=", "\"\"", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'noQuartier'", "]", ")", "||", "$", "params", "[", "'noQuartier'", "]", "!=", "true", ")", "{", "$", "javascriptQuartier", "=", "\"\n document.getElementById('quartiers').innerHTML='<option value=0>Aucun</option>';\n document.getElementById('quartiers').selectedIndex=0;\n \"", ";", "}", "$", "javascriptSousQuartier", "=", "\"\"", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'noSousQuartier'", "]", ")", "||", "$", "params", "[", "'noSousQuartier'", "]", "!=", "true", ")", "{", "$", "javascriptSousQuartier", "=", "\"\n document.getElementById('sousQuartiers').innerHTML='<option value=0>Aucun</option>';\n document.getElementById('sousQuartiers').selectedIndex=0;\n \"", ";", "}", "$", "t", "->", "assign_vars", "(", "array", "(", "'javascript'", "=>", "\"\n function onChangeListePays()\n {\n \"", ".", "$", "javascriptSousQuartier", ".", "\"\n \"", ".", "$", "javascriptQuartier", ".", "\"\n \"", ".", "$", "javascriptVille", ".", "\"\n }\n \"", ")", ")", ";", "// assignation du javascript pour l'ajax", "$", "t", "->", "assign_vars", "(", "array", "(", "'onChangeListePays'", "=>", "\"onChangeListePays();\"", ")", ")", ";", "while", "(", "$", "fetchPays", "=", "mysql_fetch_assoc", "(", "$", "resPays", ")", ")", "{", "$", "selected", "=", "\"\"", ";", "if", "(", "isset", "(", "$", "params", "[", "'idPays'", "]", ")", "&&", "$", "params", "[", "'idPays'", "]", "!=", "''", "&&", "$", "params", "[", "'idPays'", "]", "==", "$", "fetchPays", "[", "'idPays'", "]", ")", "{", "$", "selected", "=", "\" selected \"", ";", "}", "$", "t", "->", "assign_block_vars", "(", "'pays'", ",", "array", "(", "'id'", "=>", "$", "fetchPays", "[", "'idPays'", "]", ",", "'nom'", "=>", "$", "fetchPays", "[", "'nom'", "]", ",", "'selected'", "=>", "$", "selected", ")", ")", ";", "}", "ob_start", "(", ")", ";", "$", "t", "->", "pparse", "(", "'listePays'", ")", ";", "$", "html", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "return", "$", "html", ";", "}" ]
affichage de la liste des pays sous forme d'un champ select
[ "affichage", "de", "la", "liste", "des", "pays", "sous", "forme", "d", "un", "champ", "select" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L6922-L7013
9,652
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getFirstImageFromEvenement
public function getFirstImageFromEvenement($idEvenement = 0) { $fetch=array(); $reqVerifTri = " SELECT ei.idImage FROM _evenementImage ei WHERE ei.idEvenement = '".$idEvenement."' AND position<>0 "; $resVerifTri = $this->connexionBdd->requete($reqVerifTri); if (mysql_num_rows($resVerifTri)>0) { // les images ont deja ete triés , on prend celle qui a la plus petite position <>0 $req = " SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload , hi1.idImage as idImage FROM historiqueImage hi2,historiqueImage hi1 RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement ='".$idEvenement."' RIGHT JOIN _evenementImage ei2 ON ei2.idEvenement = ei1.idEvenement WHERE hi1.idImage = ei1.idImage AND hi2.idImage = hi1.idImage AND ei1.position<>'0' AND ei2.position<>'0' GROUP BY hi1.idImage,ei1.position,hi1.idHistoriqueImage HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) AND ei1.position = min(ei2.position) ORDER BY ei1.position ASC "; $res = $this->connexionBdd->requete($req); $fetch = mysql_fetch_assoc($res); } else { // pas d'image de position differente de zero , on selectionne la derniere ajoutée de l'evenement $req = " SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload, hi1.idImage as idImage FROM historiqueImage hi2,historiqueImage hi1 RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement ='".$idEvenement."' WHERE hi1.idImage = ei1.idImage AND hi2.idImage = hi1.idImage GROUP BY hi1.idImage,hi1.idHistoriqueImage HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) ORDER BY hi1.idHistoriqueImage "; $res = $this->connexionBdd->requete($req); if (mysql_num_rows($res)==0) { // pas d'image pour l'evenement courant, on va en chercher une pour l'adresse courante de l'evenement ( donc dans un evenement de la meme adresse) $req = " SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload,ei1.position as position , hi1.idImage as idImage FROM historiqueImage hi2,historiqueImage hi1 RIGHT JOIN _evenementEvenement ee ON ee.idEvenementAssocie = '".$idEvenement."' LEFT JOIN _evenementEvenement ee2 ON ee2.idEvenement = ee.idEvenement RIGHT JOIN _evenementEvenement ee3 ON ee3.idEvenement = ee2.idEvenementAssocie RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement = ee3.idEvenementAssocie WHERE hi1.idImage = ei1.idImage AND hi2.idImage = hi1.idImage GROUP BY hi1.idImage,hi1.idHistoriqueImage HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) ORDER BY position, hi1.idHistoriqueImage "; $res = $this->connexionBdd->requete($req); while ($fetchImagesAdresses = mysql_fetch_assoc($res)) { if ($fetchImagesAdresses['position']=='1') { $fetch = $fetchImagesAdresses; break; } else { $fetch = $fetchImagesAdresses; } } } else { $fetch = mysql_fetch_assoc($res); } } return $fetch; }
php
public function getFirstImageFromEvenement($idEvenement = 0) { $fetch=array(); $reqVerifTri = " SELECT ei.idImage FROM _evenementImage ei WHERE ei.idEvenement = '".$idEvenement."' AND position<>0 "; $resVerifTri = $this->connexionBdd->requete($reqVerifTri); if (mysql_num_rows($resVerifTri)>0) { // les images ont deja ete triés , on prend celle qui a la plus petite position <>0 $req = " SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload , hi1.idImage as idImage FROM historiqueImage hi2,historiqueImage hi1 RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement ='".$idEvenement."' RIGHT JOIN _evenementImage ei2 ON ei2.idEvenement = ei1.idEvenement WHERE hi1.idImage = ei1.idImage AND hi2.idImage = hi1.idImage AND ei1.position<>'0' AND ei2.position<>'0' GROUP BY hi1.idImage,ei1.position,hi1.idHistoriqueImage HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) AND ei1.position = min(ei2.position) ORDER BY ei1.position ASC "; $res = $this->connexionBdd->requete($req); $fetch = mysql_fetch_assoc($res); } else { // pas d'image de position differente de zero , on selectionne la derniere ajoutée de l'evenement $req = " SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload, hi1.idImage as idImage FROM historiqueImage hi2,historiqueImage hi1 RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement ='".$idEvenement."' WHERE hi1.idImage = ei1.idImage AND hi2.idImage = hi1.idImage GROUP BY hi1.idImage,hi1.idHistoriqueImage HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) ORDER BY hi1.idHistoriqueImage "; $res = $this->connexionBdd->requete($req); if (mysql_num_rows($res)==0) { // pas d'image pour l'evenement courant, on va en chercher une pour l'adresse courante de l'evenement ( donc dans un evenement de la meme adresse) $req = " SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload,ei1.position as position , hi1.idImage as idImage FROM historiqueImage hi2,historiqueImage hi1 RIGHT JOIN _evenementEvenement ee ON ee.idEvenementAssocie = '".$idEvenement."' LEFT JOIN _evenementEvenement ee2 ON ee2.idEvenement = ee.idEvenement RIGHT JOIN _evenementEvenement ee3 ON ee3.idEvenement = ee2.idEvenementAssocie RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement = ee3.idEvenementAssocie WHERE hi1.idImage = ei1.idImage AND hi2.idImage = hi1.idImage GROUP BY hi1.idImage,hi1.idHistoriqueImage HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) ORDER BY position, hi1.idHistoriqueImage "; $res = $this->connexionBdd->requete($req); while ($fetchImagesAdresses = mysql_fetch_assoc($res)) { if ($fetchImagesAdresses['position']=='1') { $fetch = $fetchImagesAdresses; break; } else { $fetch = $fetchImagesAdresses; } } } else { $fetch = mysql_fetch_assoc($res); } } return $fetch; }
[ "public", "function", "getFirstImageFromEvenement", "(", "$", "idEvenement", "=", "0", ")", "{", "$", "fetch", "=", "array", "(", ")", ";", "$", "reqVerifTri", "=", "\"\n SELECT ei.idImage\n FROM _evenementImage ei\n WHERE ei.idEvenement = '\"", ".", "$", "idEvenement", ".", "\"'\n AND position<>0\n \"", ";", "$", "resVerifTri", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "reqVerifTri", ")", ";", "if", "(", "mysql_num_rows", "(", "$", "resVerifTri", ")", ">", "0", ")", "{", "// les images ont deja ete triés , on prend celle qui a la plus petite position <>0", "$", "req", "=", "\"\n SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload , hi1.idImage as idImage\n FROM historiqueImage hi2,historiqueImage hi1\n RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement ='\"", ".", "$", "idEvenement", ".", "\"'\n RIGHT JOIN _evenementImage ei2 ON ei2.idEvenement = ei1.idEvenement\n WHERE hi1.idImage = ei1.idImage\n AND hi2.idImage = hi1.idImage\n AND ei1.position<>'0'\n AND ei2.position<>'0'\n GROUP BY hi1.idImage,ei1.position,hi1.idHistoriqueImage\n HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) AND ei1.position = min(ei2.position)\n ORDER BY ei1.position ASC\n \"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "$", "fetch", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "}", "else", "{", "// pas d'image de position differente de zero , on selectionne la derniere ajoutée de l'evenement", "$", "req", "=", "\"\n SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload, hi1.idImage as idImage\n FROM historiqueImage hi2,historiqueImage hi1\n RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement ='\"", ".", "$", "idEvenement", ".", "\"'\n WHERE hi1.idImage = ei1.idImage\n AND hi2.idImage = hi1.idImage\n GROUP BY hi1.idImage,hi1.idHistoriqueImage\n HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage)\n ORDER BY hi1.idHistoriqueImage\n \"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "if", "(", "mysql_num_rows", "(", "$", "res", ")", "==", "0", ")", "{", "// pas d'image pour l'evenement courant, on va en chercher une pour l'adresse courante de l'evenement ( donc dans un evenement de la meme adresse)", "$", "req", "=", "\"\n SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload,ei1.position as position , hi1.idImage as idImage\n FROM historiqueImage hi2,historiqueImage hi1\n\n RIGHT JOIN _evenementEvenement ee ON ee.idEvenementAssocie = '\"", ".", "$", "idEvenement", ".", "\"'\n LEFT JOIN _evenementEvenement ee2 ON ee2.idEvenement = ee.idEvenement\n RIGHT JOIN _evenementEvenement ee3 ON ee3.idEvenement = ee2.idEvenementAssocie\n RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement = ee3.idEvenementAssocie\n\n WHERE hi1.idImage = ei1.idImage\n AND hi2.idImage = hi1.idImage\n GROUP BY hi1.idImage,hi1.idHistoriqueImage\n HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage)\n ORDER BY position, hi1.idHistoriqueImage\n \"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "while", "(", "$", "fetchImagesAdresses", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ")", "{", "if", "(", "$", "fetchImagesAdresses", "[", "'position'", "]", "==", "'1'", ")", "{", "$", "fetch", "=", "$", "fetchImagesAdresses", ";", "break", ";", "}", "else", "{", "$", "fetch", "=", "$", "fetchImagesAdresses", ";", "}", "}", "}", "else", "{", "$", "fetch", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "}", "}", "return", "$", "fetch", ";", "}" ]
recupere la premiere image d'un evenement en fonction de sa position
[ "recupere", "la", "premiere", "image", "d", "un", "evenement", "en", "fonction", "de", "sa", "position" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L9842-L9922
9,653
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getInfosVille
public function getInfosVille($idVille = 0, $params = array()) { $fieldList = " * "; if (isset($params['fieldList']) && $params['fieldList']!='') { $fieldList = $params['fieldList']; } $req = "SELECT $fieldList FROM ville v LEFT JOIN pays p ON p.idPays = v.idPays WHERE v.idVille = $idVille"; $res = $this->connexionBdd->requete($req); return mysql_fetch_assoc($res); }
php
public function getInfosVille($idVille = 0, $params = array()) { $fieldList = " * "; if (isset($params['fieldList']) && $params['fieldList']!='') { $fieldList = $params['fieldList']; } $req = "SELECT $fieldList FROM ville v LEFT JOIN pays p ON p.idPays = v.idPays WHERE v.idVille = $idVille"; $res = $this->connexionBdd->requete($req); return mysql_fetch_assoc($res); }
[ "public", "function", "getInfosVille", "(", "$", "idVille", "=", "0", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "fieldList", "=", "\" * \"", ";", "if", "(", "isset", "(", "$", "params", "[", "'fieldList'", "]", ")", "&&", "$", "params", "[", "'fieldList'", "]", "!=", "''", ")", "{", "$", "fieldList", "=", "$", "params", "[", "'fieldList'", "]", ";", "}", "$", "req", "=", "\"SELECT $fieldList\n FROM ville v\n LEFT JOIN pays p ON p.idPays = v.idPays\n WHERE v.idVille = $idVille\"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "return", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "}" ]
renvoi un tableau contenant des infos sur la ville en parametre
[ "renvoi", "un", "tableau", "contenant", "des", "infos", "sur", "la", "ville", "en", "parametre" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L11317-L11329
9,654
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getIdVilleFromNomVille
public function getIdVilleFromNomVille($nomVille = '') { $retour = 0; $req = "SELECT idVille FROM ville WHERE nom LIKE \"%".$nomVille."%\""; $res = $this->connexionBdd->requete($req); if (mysql_num_rows($res)>0) { $fetch = mysql_fetch_assoc($res); $retour = $fetch['idVille']; } return $retour; }
php
public function getIdVilleFromNomVille($nomVille = '') { $retour = 0; $req = "SELECT idVille FROM ville WHERE nom LIKE \"%".$nomVille."%\""; $res = $this->connexionBdd->requete($req); if (mysql_num_rows($res)>0) { $fetch = mysql_fetch_assoc($res); $retour = $fetch['idVille']; } return $retour; }
[ "public", "function", "getIdVilleFromNomVille", "(", "$", "nomVille", "=", "''", ")", "{", "$", "retour", "=", "0", ";", "$", "req", "=", "\"SELECT idVille FROM ville WHERE nom LIKE \\\"%\"", ".", "$", "nomVille", ".", "\"%\\\"\"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "if", "(", "mysql_num_rows", "(", "$", "res", ")", ">", "0", ")", "{", "$", "fetch", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "$", "retour", "=", "$", "fetch", "[", "'idVille'", "]", ";", "}", "return", "$", "retour", ";", "}" ]
renvoi l'idVille a partir du nom de la ville en parametre
[ "renvoi", "l", "idVille", "a", "partir", "du", "nom", "de", "la", "ville", "en", "parametre" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L11332-L11343
9,655
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.isParcoursActif
public function isParcoursActif($params = array()) { $retour = false; if (isset($params['idParcours']) && $params['idParcours']!='') { $req = "SELECT isActif FROM parcoursArt WHERE idParcours = '".$params['idParcours']."'"; $res = $this->connexionBdd->requete($req); if (mysql_num_rows($res)>0) { $fetch = mysql_fetch_assoc($res); if ($fetch['isActif']=='1') { $retour = true; } } } else { // est ce qu'un parcours est actif $req = "SELECT 0 FROM parcoursArt WHERE isActif='1'"; $res = $this->connexionBdd->requete($req); if (mysql_num_rows($res)>0) { $retour = true; } } return $retour; }
php
public function isParcoursActif($params = array()) { $retour = false; if (isset($params['idParcours']) && $params['idParcours']!='') { $req = "SELECT isActif FROM parcoursArt WHERE idParcours = '".$params['idParcours']."'"; $res = $this->connexionBdd->requete($req); if (mysql_num_rows($res)>0) { $fetch = mysql_fetch_assoc($res); if ($fetch['isActif']=='1') { $retour = true; } } } else { // est ce qu'un parcours est actif $req = "SELECT 0 FROM parcoursArt WHERE isActif='1'"; $res = $this->connexionBdd->requete($req); if (mysql_num_rows($res)>0) { $retour = true; } } return $retour; }
[ "public", "function", "isParcoursActif", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "retour", "=", "false", ";", "if", "(", "isset", "(", "$", "params", "[", "'idParcours'", "]", ")", "&&", "$", "params", "[", "'idParcours'", "]", "!=", "''", ")", "{", "$", "req", "=", "\"SELECT isActif FROM parcoursArt WHERE idParcours = '\"", ".", "$", "params", "[", "'idParcours'", "]", ".", "\"'\"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "if", "(", "mysql_num_rows", "(", "$", "res", ")", ">", "0", ")", "{", "$", "fetch", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "if", "(", "$", "fetch", "[", "'isActif'", "]", "==", "'1'", ")", "{", "$", "retour", "=", "true", ";", "}", "}", "}", "else", "{", "// est ce qu'un parcours est actif", "$", "req", "=", "\"SELECT 0 FROM parcoursArt WHERE isActif='1'\"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "if", "(", "mysql_num_rows", "(", "$", "res", ")", ">", "0", ")", "{", "$", "retour", "=", "true", ";", "}", "}", "return", "$", "retour", ";", "}" ]
si on precise un idParcours en parametre on regarde alors si ce parcours est actif
[ "si", "on", "precise", "un", "idParcours", "en", "parametre", "on", "regarde", "alors", "si", "ce", "parcours", "est", "actif" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L12607-L12631
9,656
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getPhotoFromEtape
public function getPhotoFromEtape($params = array()) { $retour = array('trouve'=>false); if (isset($params['idEtape']) && $params['idEtape']!='' && $params['idEtape']!='0') { // recuperation du groupe d'adresse de l'etape $req = "SELECT idEvenementGroupeAdresse FROM etapesParcoursArt WHERE idEtape='".$params['idEtape']."'"; $res = $this->connexionBdd->requete($req); $fetch = mysql_fetch_assoc($res); if (isset($fetch['idEvenementGroupeAdresse'])) { $i = new archiImage(); $idAdresse = $this->getIdAdresseFromIdEvenementGroupeAdresse($fetch['idEvenementGroupeAdresse']); $idEvenementGroupeAdresse = $fetch['idEvenementGroupeAdresse']; $format = 'mini'; if (isset($params['format']) && $params['format']!='') { $format = $params['format']; } $illustration = $this->getUrlImageFromAdresse($idAdresse, $format, array('idEvenementGroupeAdresse'=>$idEvenementGroupeAdresse)); $retour = $illustration; } } return $retour; }
php
public function getPhotoFromEtape($params = array()) { $retour = array('trouve'=>false); if (isset($params['idEtape']) && $params['idEtape']!='' && $params['idEtape']!='0') { // recuperation du groupe d'adresse de l'etape $req = "SELECT idEvenementGroupeAdresse FROM etapesParcoursArt WHERE idEtape='".$params['idEtape']."'"; $res = $this->connexionBdd->requete($req); $fetch = mysql_fetch_assoc($res); if (isset($fetch['idEvenementGroupeAdresse'])) { $i = new archiImage(); $idAdresse = $this->getIdAdresseFromIdEvenementGroupeAdresse($fetch['idEvenementGroupeAdresse']); $idEvenementGroupeAdresse = $fetch['idEvenementGroupeAdresse']; $format = 'mini'; if (isset($params['format']) && $params['format']!='') { $format = $params['format']; } $illustration = $this->getUrlImageFromAdresse($idAdresse, $format, array('idEvenementGroupeAdresse'=>$idEvenementGroupeAdresse)); $retour = $illustration; } } return $retour; }
[ "public", "function", "getPhotoFromEtape", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "retour", "=", "array", "(", "'trouve'", "=>", "false", ")", ";", "if", "(", "isset", "(", "$", "params", "[", "'idEtape'", "]", ")", "&&", "$", "params", "[", "'idEtape'", "]", "!=", "''", "&&", "$", "params", "[", "'idEtape'", "]", "!=", "'0'", ")", "{", "// recuperation du groupe d'adresse de l'etape", "$", "req", "=", "\"SELECT idEvenementGroupeAdresse FROM etapesParcoursArt WHERE idEtape='\"", ".", "$", "params", "[", "'idEtape'", "]", ".", "\"'\"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "$", "fetch", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "if", "(", "isset", "(", "$", "fetch", "[", "'idEvenementGroupeAdresse'", "]", ")", ")", "{", "$", "i", "=", "new", "archiImage", "(", ")", ";", "$", "idAdresse", "=", "$", "this", "->", "getIdAdresseFromIdEvenementGroupeAdresse", "(", "$", "fetch", "[", "'idEvenementGroupeAdresse'", "]", ")", ";", "$", "idEvenementGroupeAdresse", "=", "$", "fetch", "[", "'idEvenementGroupeAdresse'", "]", ";", "$", "format", "=", "'mini'", ";", "if", "(", "isset", "(", "$", "params", "[", "'format'", "]", ")", "&&", "$", "params", "[", "'format'", "]", "!=", "''", ")", "{", "$", "format", "=", "$", "params", "[", "'format'", "]", ";", "}", "$", "illustration", "=", "$", "this", "->", "getUrlImageFromAdresse", "(", "$", "idAdresse", ",", "$", "format", ",", "array", "(", "'idEvenementGroupeAdresse'", "=>", "$", "idEvenementGroupeAdresse", ")", ")", ";", "$", "retour", "=", "$", "illustration", ";", "}", "}", "return", "$", "retour", ";", "}" ]
renvoie la photo courante de l'adresse de l'etape
[ "renvoie", "la", "photo", "courante", "de", "l", "adresse", "de", "l", "etape" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L12634-L12661
9,657
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getIdSousQuartier
public function getIdSousQuartier($idRue = null) { $idSousQuartier = null; if (!isset($idRue) && $idRue != '') { echo "Error while getting sub neighborhood id, no street informations were specified for this request."; } else { $req = "SELECT idSousQuartier FROM rue WHERE idRue = ".$idRue ; $res = $this->connexionBdd->requete($req); $fetchSousQuartier = mysql_fetch_assoc($res); $idSousQuartier = $fetchSousQuartier['idSousQuartier']; } return $idSousQuartier; }
php
public function getIdSousQuartier($idRue = null) { $idSousQuartier = null; if (!isset($idRue) && $idRue != '') { echo "Error while getting sub neighborhood id, no street informations were specified for this request."; } else { $req = "SELECT idSousQuartier FROM rue WHERE idRue = ".$idRue ; $res = $this->connexionBdd->requete($req); $fetchSousQuartier = mysql_fetch_assoc($res); $idSousQuartier = $fetchSousQuartier['idSousQuartier']; } return $idSousQuartier; }
[ "public", "function", "getIdSousQuartier", "(", "$", "idRue", "=", "null", ")", "{", "$", "idSousQuartier", "=", "null", ";", "if", "(", "!", "isset", "(", "$", "idRue", ")", "&&", "$", "idRue", "!=", "''", ")", "{", "echo", "\"Error while getting sub neighborhood id, no street informations were specified for this request.\"", ";", "}", "else", "{", "$", "req", "=", "\"SELECT idSousQuartier\n \t\t\tFROM rue\n \t\t\tWHERE idRue = \"", ".", "$", "idRue", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "$", "fetchSousQuartier", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "$", "idSousQuartier", "=", "$", "fetchSousQuartier", "[", "'idSousQuartier'", "]", ";", "}", "return", "$", "idSousQuartier", ";", "}" ]
Get the id of a sub neighborhood from the id of a street @param string $idRue : id of the street @return NULL|string : id of the neighborhood
[ "Get", "the", "id", "of", "a", "sub", "neighborhood", "from", "the", "id", "of", "a", "street" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L12722-L12737
9,658
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getIdQuartier
public function getIdQuartier($idSousQuartier) { $idQuartier = null; if (!isset($idSousQuartier) && $idSousQuartier != '') { echo "Error while getting neighborhood id, no sub neighborhood informations were specified for this request."; } else { $req = " SELECT idQuartier FROM sousQuartier WHERE idSousQuartier = ".$idSousQuartier." "; $res = $this->connexionBdd->requete($req); $fetchQuartier = mysql_fetch_assoc($res); $idQuartier = $fetchQuartier['idQuartier']; } return $idQuartier; }
php
public function getIdQuartier($idSousQuartier) { $idQuartier = null; if (!isset($idSousQuartier) && $idSousQuartier != '') { echo "Error while getting neighborhood id, no sub neighborhood informations were specified for this request."; } else { $req = " SELECT idQuartier FROM sousQuartier WHERE idSousQuartier = ".$idSousQuartier." "; $res = $this->connexionBdd->requete($req); $fetchQuartier = mysql_fetch_assoc($res); $idQuartier = $fetchQuartier['idQuartier']; } return $idQuartier; }
[ "public", "function", "getIdQuartier", "(", "$", "idSousQuartier", ")", "{", "$", "idQuartier", "=", "null", ";", "if", "(", "!", "isset", "(", "$", "idSousQuartier", ")", "&&", "$", "idSousQuartier", "!=", "''", ")", "{", "echo", "\"Error while getting neighborhood id, no sub neighborhood informations were specified for this request.\"", ";", "}", "else", "{", "$", "req", "=", "\"\n \t\t\t\tSELECT idQuartier\n \t\t\t\tFROM sousQuartier\n \t\t\t\tWHERE idSousQuartier = \"", ".", "$", "idSousQuartier", ".", "\"\n \t\t\t\t\"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "$", "fetchQuartier", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "$", "idQuartier", "=", "$", "fetchQuartier", "[", "'idQuartier'", "]", ";", "}", "return", "$", "idQuartier", ";", "}" ]
Get the id of a neighborhood from the id of a street @param int $idSousQuartier : id of the sub neighborhood @return int $idQuartier : id of the neighborhood (or null if error occurs)
[ "Get", "the", "id", "of", "a", "neighborhood", "from", "the", "id", "of", "a", "street" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L12745-L12761
9,659
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getIdVille
public function getIdVille($idQuartier) { $idVille; if (!isset($idQuartier) && $idQuartier != '') { echo "Error while getting city id, no sub neighborhood informations were specified for this request."; } else { $req = " SELECT idVille FROM quartier WHERE idQuartier = ".$idQuartier." "; $res = $this->connexionBdd->requete($req); $fetch = mysql_fetch_assoc($res); $idVille = $fetch['idVille']; } return $idVille; }
php
public function getIdVille($idQuartier) { $idVille; if (!isset($idQuartier) && $idQuartier != '') { echo "Error while getting city id, no sub neighborhood informations were specified for this request."; } else { $req = " SELECT idVille FROM quartier WHERE idQuartier = ".$idQuartier." "; $res = $this->connexionBdd->requete($req); $fetch = mysql_fetch_assoc($res); $idVille = $fetch['idVille']; } return $idVille; }
[ "public", "function", "getIdVille", "(", "$", "idQuartier", ")", "{", "$", "idVille", ";", "if", "(", "!", "isset", "(", "$", "idQuartier", ")", "&&", "$", "idQuartier", "!=", "''", ")", "{", "echo", "\"Error while getting city id, no sub neighborhood informations were specified for this request.\"", ";", "}", "else", "{", "$", "req", "=", "\"\n \t\t\t\tSELECT idVille\n \t\t\t\tFROM quartier\n \t\t\t\tWHERE idQuartier = \"", ".", "$", "idQuartier", ".", "\"\n \t\t\t\t\"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "$", "fetch", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "$", "idVille", "=", "$", "fetch", "[", "'idVille'", "]", ";", "}", "return", "$", "idVille", ";", "}" ]
Get the id of the city from neighborhood id @param $idQuartier : neighborhood id @return $idVille : id of the city
[ "Get", "the", "id", "of", "the", "city", "from", "neighborhood", "id" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L12769-L12785
9,660
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getIdPays
public function getIdPays($idVille) { $idPays; if (!isset($idVille) && $idVille != '') { echo "Error while getting country id, no sub neighborhood informations were specified for this request."; } else { $req = " SELECT idPays FROM ville WHERE idVille = ".$idVille." "; $res = $this->connexionBdd->requete($req); $fetch = mysql_fetch_assoc($res); $idPays = $fetch['idPays']; } return $idPays; }
php
public function getIdPays($idVille) { $idPays; if (!isset($idVille) && $idVille != '') { echo "Error while getting country id, no sub neighborhood informations were specified for this request."; } else { $req = " SELECT idPays FROM ville WHERE idVille = ".$idVille." "; $res = $this->connexionBdd->requete($req); $fetch = mysql_fetch_assoc($res); $idPays = $fetch['idPays']; } return $idPays; }
[ "public", "function", "getIdPays", "(", "$", "idVille", ")", "{", "$", "idPays", ";", "if", "(", "!", "isset", "(", "$", "idVille", ")", "&&", "$", "idVille", "!=", "''", ")", "{", "echo", "\"Error while getting country id, no sub neighborhood informations were specified for this request.\"", ";", "}", "else", "{", "$", "req", "=", "\"\n \t\t\t\tSELECT idPays\n \t\t\t\tFROM ville\n \t\t\t\tWHERE idVille = \"", ".", "$", "idVille", ".", "\"\n \t\t\t\t\"", ";", "$", "res", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "req", ")", ";", "$", "fetch", "=", "mysql_fetch_assoc", "(", "$", "res", ")", ";", "$", "idPays", "=", "$", "fetch", "[", "'idPays'", "]", ";", "}", "return", "$", "idPays", ";", "}" ]
Get id of the country from city id @param $idVille : id of the city @return $idPays : id of the country
[ "Get", "id", "of", "the", "country", "from", "city", "id" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L12795-L12811
9,661
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.generatePaginationLinks
private function generatePaginationLinks($options = array()) { //Pagination display $nbResult = 0; $nbPages = 0; $currentPage = 0; $nextPage = 0; $previousPage = 0; $nbResultPerPage = 10; $offset=4; $url = array(); // Checking if all the parameters are set if (isset($options['nbResult'])) { $nbResult = $options['nbResult']; } if (isset($options['nbPages'])) { $nbPages= $options['nbPages']; } if (isset($options['currentPage'])) { $currentPage= $options['nbResult']; } if (isset($options['nextPage'])) { $nextPage = $options['nextPage']; } if (isset($options['previousPage'])) { $previousPage = $options['previousPage']; } if (isset($options['nbResultPerPage'])) { $nbResultPerPage= $options['nbResultPerPage']; } if (isset($options['offset'])) { $offset= $options['offset']; } //Link creation for ($i=0; $i<$nbPages; $i++) { $paramCreerUrl = $this->variablesGet; $paramCreerUrl['debut'] = $i*$nbResultPerPage; $url[]=$this->creerUrl( '', '', $paramCreerUrl ); } return $url; }
php
private function generatePaginationLinks($options = array()) { //Pagination display $nbResult = 0; $nbPages = 0; $currentPage = 0; $nextPage = 0; $previousPage = 0; $nbResultPerPage = 10; $offset=4; $url = array(); // Checking if all the parameters are set if (isset($options['nbResult'])) { $nbResult = $options['nbResult']; } if (isset($options['nbPages'])) { $nbPages= $options['nbPages']; } if (isset($options['currentPage'])) { $currentPage= $options['nbResult']; } if (isset($options['nextPage'])) { $nextPage = $options['nextPage']; } if (isset($options['previousPage'])) { $previousPage = $options['previousPage']; } if (isset($options['nbResultPerPage'])) { $nbResultPerPage= $options['nbResultPerPage']; } if (isset($options['offset'])) { $offset= $options['offset']; } //Link creation for ($i=0; $i<$nbPages; $i++) { $paramCreerUrl = $this->variablesGet; $paramCreerUrl['debut'] = $i*$nbResultPerPage; $url[]=$this->creerUrl( '', '', $paramCreerUrl ); } return $url; }
[ "private", "function", "generatePaginationLinks", "(", "$", "options", "=", "array", "(", ")", ")", "{", "//Pagination display", "$", "nbResult", "=", "0", ";", "$", "nbPages", "=", "0", ";", "$", "currentPage", "=", "0", ";", "$", "nextPage", "=", "0", ";", "$", "previousPage", "=", "0", ";", "$", "nbResultPerPage", "=", "10", ";", "$", "offset", "=", "4", ";", "$", "url", "=", "array", "(", ")", ";", "// Checking if all the parameters are set", "if", "(", "isset", "(", "$", "options", "[", "'nbResult'", "]", ")", ")", "{", "$", "nbResult", "=", "$", "options", "[", "'nbResult'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'nbPages'", "]", ")", ")", "{", "$", "nbPages", "=", "$", "options", "[", "'nbPages'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'currentPage'", "]", ")", ")", "{", "$", "currentPage", "=", "$", "options", "[", "'nbResult'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'nextPage'", "]", ")", ")", "{", "$", "nextPage", "=", "$", "options", "[", "'nextPage'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'previousPage'", "]", ")", ")", "{", "$", "previousPage", "=", "$", "options", "[", "'previousPage'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'nbResultPerPage'", "]", ")", ")", "{", "$", "nbResultPerPage", "=", "$", "options", "[", "'nbResultPerPage'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'offset'", "]", ")", ")", "{", "$", "offset", "=", "$", "options", "[", "'offset'", "]", ";", "}", "//Link creation", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "nbPages", ";", "$", "i", "++", ")", "{", "$", "paramCreerUrl", "=", "$", "this", "->", "variablesGet", ";", "$", "paramCreerUrl", "[", "'debut'", "]", "=", "$", "i", "*", "$", "nbResultPerPage", ";", "$", "url", "[", "]", "=", "$", "this", "->", "creerUrl", "(", "''", ",", "''", ",", "$", "paramCreerUrl", ")", ";", "}", "return", "$", "url", ";", "}" ]
Generate pagination links @param unknown $options @return multitype:string
[ "Generate", "pagination", "links" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L13228-L13274
9,662
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getPaginationIndex
private function getPaginationIndex($optionsPagination = array()) { $nbResult = 0; $nbPages = 0; $currentPage = 0; $nextPage = 0; $previousPage = 0; $nbResultPerPage = 10; $offset = 4; $indexToDisplay = array(); //Setting vars if (isset($optionsPagination['nbResult'])) { $nbResult =$optionsPagination['nbResult']; } if (isset($optionsPagination['nbPages'])) { $nbPages = $optionsPagination['nbPages']; } if (isset($optionsPagination['currentPage'])) { $currentPage = $optionsPagination['currentPage']; } if (isset($optionsPagination['nextPage'])) { $nextPage = $optionsPagination['nextPage']; } if (isset($optionsPagination['previousPage'])) { $previousPage = $optionsPagination['previousPage']; } if (isset($optionsPagination['nbResultPerPage'])) { $nbResultPerPage = $optionsPagination['nbResultPerPage']; } if (isset($optionsPagination['offset'])) { $offset = $optionsPagination['offset']; } //Processing firstpage index if ($nbPages<=(2*$offset+1)) { $indexToDisplay['firstPage'] = 0; $indexToDisplay['lastPage'] = $nbPages-1; } else { if (($currentPage - $offset)<= 0) { $indexToDisplay['firstPage'] = 0; } else { $indexToDisplay['firstPage'] = $currentPage - $offset - 1; } //Processing lastpage index if (($currentPage+$offset)>=$nbPages) { $indexToDisplay['lastPage'] = $nbPages-1; } else { $indexToDisplay['lastPage']=$currentPage+$offset-1; } // Adjusting first page index or last page index if nb of previous pages are not balanced compared to next ones // Adding the extra missing page to a side or another to really have 9 pages (aka 2*offset+1) if ((2*$offset+1) > ($indexToDisplay['lastPage'] - $indexToDisplay['firstPage'] )) { //Calculating the offset to add to first or last page $offsetAdd=(2*$offset+1) - ($indexToDisplay['lastPage'] - $indexToDisplay['firstPage'] ); if ($indexToDisplay['firstPage'] == 0) { $indexToDisplay['lastPage']+=$offsetAdd-1; } else { $indexToDisplay['firstPage']-=$offsetAdd-1; } } } $indexRange = array(); for ($i = $indexToDisplay['firstPage']; $i <= $indexToDisplay['lastPage']; $i++) { $indexRange[] = $i; } $indexToDisplay['range'] = $indexRange; return $indexRange; }
php
private function getPaginationIndex($optionsPagination = array()) { $nbResult = 0; $nbPages = 0; $currentPage = 0; $nextPage = 0; $previousPage = 0; $nbResultPerPage = 10; $offset = 4; $indexToDisplay = array(); //Setting vars if (isset($optionsPagination['nbResult'])) { $nbResult =$optionsPagination['nbResult']; } if (isset($optionsPagination['nbPages'])) { $nbPages = $optionsPagination['nbPages']; } if (isset($optionsPagination['currentPage'])) { $currentPage = $optionsPagination['currentPage']; } if (isset($optionsPagination['nextPage'])) { $nextPage = $optionsPagination['nextPage']; } if (isset($optionsPagination['previousPage'])) { $previousPage = $optionsPagination['previousPage']; } if (isset($optionsPagination['nbResultPerPage'])) { $nbResultPerPage = $optionsPagination['nbResultPerPage']; } if (isset($optionsPagination['offset'])) { $offset = $optionsPagination['offset']; } //Processing firstpage index if ($nbPages<=(2*$offset+1)) { $indexToDisplay['firstPage'] = 0; $indexToDisplay['lastPage'] = $nbPages-1; } else { if (($currentPage - $offset)<= 0) { $indexToDisplay['firstPage'] = 0; } else { $indexToDisplay['firstPage'] = $currentPage - $offset - 1; } //Processing lastpage index if (($currentPage+$offset)>=$nbPages) { $indexToDisplay['lastPage'] = $nbPages-1; } else { $indexToDisplay['lastPage']=$currentPage+$offset-1; } // Adjusting first page index or last page index if nb of previous pages are not balanced compared to next ones // Adding the extra missing page to a side or another to really have 9 pages (aka 2*offset+1) if ((2*$offset+1) > ($indexToDisplay['lastPage'] - $indexToDisplay['firstPage'] )) { //Calculating the offset to add to first or last page $offsetAdd=(2*$offset+1) - ($indexToDisplay['lastPage'] - $indexToDisplay['firstPage'] ); if ($indexToDisplay['firstPage'] == 0) { $indexToDisplay['lastPage']+=$offsetAdd-1; } else { $indexToDisplay['firstPage']-=$offsetAdd-1; } } } $indexRange = array(); for ($i = $indexToDisplay['firstPage']; $i <= $indexToDisplay['lastPage']; $i++) { $indexRange[] = $i; } $indexToDisplay['range'] = $indexRange; return $indexRange; }
[ "private", "function", "getPaginationIndex", "(", "$", "optionsPagination", "=", "array", "(", ")", ")", "{", "$", "nbResult", "=", "0", ";", "$", "nbPages", "=", "0", ";", "$", "currentPage", "=", "0", ";", "$", "nextPage", "=", "0", ";", "$", "previousPage", "=", "0", ";", "$", "nbResultPerPage", "=", "10", ";", "$", "offset", "=", "4", ";", "$", "indexToDisplay", "=", "array", "(", ")", ";", "//Setting vars", "if", "(", "isset", "(", "$", "optionsPagination", "[", "'nbResult'", "]", ")", ")", "{", "$", "nbResult", "=", "$", "optionsPagination", "[", "'nbResult'", "]", ";", "}", "if", "(", "isset", "(", "$", "optionsPagination", "[", "'nbPages'", "]", ")", ")", "{", "$", "nbPages", "=", "$", "optionsPagination", "[", "'nbPages'", "]", ";", "}", "if", "(", "isset", "(", "$", "optionsPagination", "[", "'currentPage'", "]", ")", ")", "{", "$", "currentPage", "=", "$", "optionsPagination", "[", "'currentPage'", "]", ";", "}", "if", "(", "isset", "(", "$", "optionsPagination", "[", "'nextPage'", "]", ")", ")", "{", "$", "nextPage", "=", "$", "optionsPagination", "[", "'nextPage'", "]", ";", "}", "if", "(", "isset", "(", "$", "optionsPagination", "[", "'previousPage'", "]", ")", ")", "{", "$", "previousPage", "=", "$", "optionsPagination", "[", "'previousPage'", "]", ";", "}", "if", "(", "isset", "(", "$", "optionsPagination", "[", "'nbResultPerPage'", "]", ")", ")", "{", "$", "nbResultPerPage", "=", "$", "optionsPagination", "[", "'nbResultPerPage'", "]", ";", "}", "if", "(", "isset", "(", "$", "optionsPagination", "[", "'offset'", "]", ")", ")", "{", "$", "offset", "=", "$", "optionsPagination", "[", "'offset'", "]", ";", "}", "//Processing firstpage index", "if", "(", "$", "nbPages", "<=", "(", "2", "*", "$", "offset", "+", "1", ")", ")", "{", "$", "indexToDisplay", "[", "'firstPage'", "]", "=", "0", ";", "$", "indexToDisplay", "[", "'lastPage'", "]", "=", "$", "nbPages", "-", "1", ";", "}", "else", "{", "if", "(", "(", "$", "currentPage", "-", "$", "offset", ")", "<=", "0", ")", "{", "$", "indexToDisplay", "[", "'firstPage'", "]", "=", "0", ";", "}", "else", "{", "$", "indexToDisplay", "[", "'firstPage'", "]", "=", "$", "currentPage", "-", "$", "offset", "-", "1", ";", "}", "//Processing lastpage index", "if", "(", "(", "$", "currentPage", "+", "$", "offset", ")", ">=", "$", "nbPages", ")", "{", "$", "indexToDisplay", "[", "'lastPage'", "]", "=", "$", "nbPages", "-", "1", ";", "}", "else", "{", "$", "indexToDisplay", "[", "'lastPage'", "]", "=", "$", "currentPage", "+", "$", "offset", "-", "1", ";", "}", "// Adjusting first page index or last page index if nb of previous pages are not balanced compared to next ones", "// Adding the extra missing page to a side or another to really have 9 pages (aka 2*offset+1)", "if", "(", "(", "2", "*", "$", "offset", "+", "1", ")", ">", "(", "$", "indexToDisplay", "[", "'lastPage'", "]", "-", "$", "indexToDisplay", "[", "'firstPage'", "]", ")", ")", "{", "//Calculating the offset to add to first or last page", "$", "offsetAdd", "=", "(", "2", "*", "$", "offset", "+", "1", ")", "-", "(", "$", "indexToDisplay", "[", "'lastPage'", "]", "-", "$", "indexToDisplay", "[", "'firstPage'", "]", ")", ";", "if", "(", "$", "indexToDisplay", "[", "'firstPage'", "]", "==", "0", ")", "{", "$", "indexToDisplay", "[", "'lastPage'", "]", "+=", "$", "offsetAdd", "-", "1", ";", "}", "else", "{", "$", "indexToDisplay", "[", "'firstPage'", "]", "-=", "$", "offsetAdd", "-", "1", ";", "}", "}", "}", "$", "indexRange", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "$", "indexToDisplay", "[", "'firstPage'", "]", ";", "$", "i", "<=", "$", "indexToDisplay", "[", "'lastPage'", "]", ";", "$", "i", "++", ")", "{", "$", "indexRange", "[", "]", "=", "$", "i", ";", "}", "$", "indexToDisplay", "[", "'range'", "]", "=", "$", "indexRange", ";", "return", "$", "indexRange", ";", "}" ]
Get pagination index @param unknown $optionsPagination : array with the info of pagination (nb results, nb results per page, current page etc) @return $indexRange = range of the index to display
[ "Get", "pagination", "index" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L13284-L13356
9,663
Archi-Strasbourg/archi-wiki
modules/archi/includes/archiAdresse.class.php
archiAdresse.getTitre
public function getTitre($idAdresse) { $requete ="SELECT e2.titre FROM evenements e1, evenements e2 LEFT JOIN _adresseEvenement ae on ae.idEvenement = e1.idEvenement WHERE ae.idAdresse = $idAdresse AND e2.idEvenement = e1.`idEvenementRecuperationTitre` "; $result = $this->connexionBdd->requete($requete); $retValue = mysql_fetch_assoc($result); return $retValue['titre']; }
php
public function getTitre($idAdresse) { $requete ="SELECT e2.titre FROM evenements e1, evenements e2 LEFT JOIN _adresseEvenement ae on ae.idEvenement = e1.idEvenement WHERE ae.idAdresse = $idAdresse AND e2.idEvenement = e1.`idEvenementRecuperationTitre` "; $result = $this->connexionBdd->requete($requete); $retValue = mysql_fetch_assoc($result); return $retValue['titre']; }
[ "public", "function", "getTitre", "(", "$", "idAdresse", ")", "{", "$", "requete", "=", "\"SELECT e2.titre\n\t\t\t\tFROM evenements e1, evenements e2\n\t\t\t\tLEFT JOIN _adresseEvenement ae on ae.idEvenement = e1.idEvenement\n\t\t\t\tWHERE ae.idAdresse = $idAdresse\n\t\t\t\tAND e2.idEvenement = e1.`idEvenementRecuperationTitre` \"", ";", "$", "result", "=", "$", "this", "->", "connexionBdd", "->", "requete", "(", "$", "requete", ")", ";", "$", "retValue", "=", "mysql_fetch_assoc", "(", "$", "result", ")", ";", "return", "$", "retValue", "[", "'titre'", "]", ";", "}" ]
Get titre of an adresse @param unknown $idAdresse @return titre
[ "Get", "titre", "of", "an", "adresse" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/modules/archi/includes/archiAdresse.class.php#L13505-L13515
9,664
zepi/turbo-base
Zepi/Web/UserInterface/src/Layout/AbstractContainer.php
AbstractContainer.getHtmlId
public function getHtmlId() { $id = ''; if (is_object($this->parent)) { $id = $this->parent->getHtmlId(); } if ($this->key !== '') { $id .= '-' . $this->key; } return $id; }
php
public function getHtmlId() { $id = ''; if (is_object($this->parent)) { $id = $this->parent->getHtmlId(); } if ($this->key !== '') { $id .= '-' . $this->key; } return $id; }
[ "public", "function", "getHtmlId", "(", ")", "{", "$", "id", "=", "''", ";", "if", "(", "is_object", "(", "$", "this", "->", "parent", ")", ")", "{", "$", "id", "=", "$", "this", "->", "parent", "->", "getHtmlId", "(", ")", ";", "}", "if", "(", "$", "this", "->", "key", "!==", "''", ")", "{", "$", "id", ".=", "'-'", ".", "$", "this", "->", "key", ";", "}", "return", "$", "id", ";", "}" ]
Returns the html id for the container. The id is built by the keys of this element and all parents. @return string
[ "Returns", "the", "html", "id", "for", "the", "container", ".", "The", "id", "is", "built", "by", "the", "keys", "of", "this", "element", "and", "all", "parents", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Layout/AbstractContainer.php#L137-L149
9,665
zepi/turbo-base
Zepi/Web/UserInterface/src/Layout/AbstractContainer.php
AbstractContainer.getPath
public function getPath(AbstractContainer $startingFrom = null) { $id = ''; if (is_object($this->parent) && $startingFrom !== $this->parent) { $id = $this->parent->getPath($startingFrom); } if ($id != '' && substr($id, -1) != '.') { $id .= '.'; } if ($this->publicKey !== '') { $id .= $this->publicKey; } return $id; }
php
public function getPath(AbstractContainer $startingFrom = null) { $id = ''; if (is_object($this->parent) && $startingFrom !== $this->parent) { $id = $this->parent->getPath($startingFrom); } if ($id != '' && substr($id, -1) != '.') { $id .= '.'; } if ($this->publicKey !== '') { $id .= $this->publicKey; } return $id; }
[ "public", "function", "getPath", "(", "AbstractContainer", "$", "startingFrom", "=", "null", ")", "{", "$", "id", "=", "''", ";", "if", "(", "is_object", "(", "$", "this", "->", "parent", ")", "&&", "$", "startingFrom", "!==", "$", "this", "->", "parent", ")", "{", "$", "id", "=", "$", "this", "->", "parent", "->", "getPath", "(", "$", "startingFrom", ")", ";", "}", "if", "(", "$", "id", "!=", "''", "&&", "substr", "(", "$", "id", ",", "-", "1", ")", "!=", "'.'", ")", "{", "$", "id", ".=", "'.'", ";", "}", "if", "(", "$", "this", "->", "publicKey", "!==", "''", ")", "{", "$", "id", ".=", "$", "this", "->", "publicKey", ";", "}", "return", "$", "id", ";", "}" ]
Returns the path for the element, starting from the given AbstractContainer @return string
[ "Returns", "the", "path", "for", "the", "element", "starting", "from", "the", "given", "AbstractContainer" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Layout/AbstractContainer.php#L157-L173
9,666
zepi/turbo-base
Zepi/Web/UserInterface/src/Layout/AbstractContainer.php
AbstractContainer.getPart
public function getPart($key) { foreach ($this->parts as $part) { if ($part->getKey() === $key) { return $part; } } return false; }
php
public function getPart($key) { foreach ($this->parts as $part) { if ($part->getKey() === $key) { return $part; } } return false; }
[ "public", "function", "getPart", "(", "$", "key", ")", "{", "foreach", "(", "$", "this", "->", "parts", "as", "$", "part", ")", "{", "if", "(", "$", "part", "->", "getKey", "(", ")", "===", "$", "key", ")", "{", "return", "$", "part", ";", "}", "}", "return", "false", ";", "}" ]
Returns the part for the given key, if there is no part with this key registred return false. @access public @return false|\Zepi\Web\UserInterface\Layout\Part
[ "Returns", "the", "part", "for", "the", "given", "key", "if", "there", "is", "no", "part", "with", "this", "key", "registred", "return", "false", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Layout/AbstractContainer.php#L194-L203
9,667
zepi/turbo-base
Zepi/Web/UserInterface/src/Layout/AbstractContainer.php
AbstractContainer.searchPartByKeyAndType
public function searchPartByKeyAndType($key, $type = '\\Zepi\\Web\\UserInterface\\Layout\\AbstractContainer') { foreach ($this->parts as $part) { if ((is_a($part, $type) || is_subclass_of($part, $type)) && $part->getKey() === $key) { return $part; } $result = $part->searchPartByKeyAndType($key, $type); if ($result !== false) { return $result; } } return false; }
php
public function searchPartByKeyAndType($key, $type = '\\Zepi\\Web\\UserInterface\\Layout\\AbstractContainer') { foreach ($this->parts as $part) { if ((is_a($part, $type) || is_subclass_of($part, $type)) && $part->getKey() === $key) { return $part; } $result = $part->searchPartByKeyAndType($key, $type); if ($result !== false) { return $result; } } return false; }
[ "public", "function", "searchPartByKeyAndType", "(", "$", "key", ",", "$", "type", "=", "'\\\\Zepi\\\\Web\\\\UserInterface\\\\Layout\\\\AbstractContainer'", ")", "{", "foreach", "(", "$", "this", "->", "parts", "as", "$", "part", ")", "{", "if", "(", "(", "is_a", "(", "$", "part", ",", "$", "type", ")", "||", "is_subclass_of", "(", "$", "part", ",", "$", "type", ")", ")", "&&", "$", "part", "->", "getKey", "(", ")", "===", "$", "key", ")", "{", "return", "$", "part", ";", "}", "$", "result", "=", "$", "part", "->", "searchPartByKeyAndType", "(", "$", "key", ",", "$", "type", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "}", "return", "false", ";", "}" ]
Returns the object for the given key and type or false if the object doesn't exists. @access public @param string $key @param string $type @return false|mixed
[ "Returns", "the", "object", "for", "the", "given", "key", "and", "type", "or", "false", "if", "the", "object", "doesn", "t", "exists", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Layout/AbstractContainer.php#L280-L294
9,668
zepi/turbo-base
Zepi/Web/UserInterface/src/Layout/AbstractContainer.php
AbstractContainer.getParentOfType
public function getParentOfType($type) { if (is_a($this, $type)) { return $this; } if ($this->parent !== null) { return $this->parent->getParentOfType($type); } return false; }
php
public function getParentOfType($type) { if (is_a($this, $type)) { return $this; } if ($this->parent !== null) { return $this->parent->getParentOfType($type); } return false; }
[ "public", "function", "getParentOfType", "(", "$", "type", ")", "{", "if", "(", "is_a", "(", "$", "this", ",", "$", "type", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "$", "this", "->", "parent", "!==", "null", ")", "{", "return", "$", "this", "->", "parent", "->", "getParentOfType", "(", "$", "type", ")", ";", "}", "return", "false", ";", "}" ]
Returns the next parent of this container for the given type If there is no type like that the function will return false @access public @param string $type @return false|mixed
[ "Returns", "the", "next", "parent", "of", "this", "container", "for", "the", "given", "type", "If", "there", "is", "no", "type", "like", "that", "the", "function", "will", "return", "false" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Layout/AbstractContainer.php#L304-L315
9,669
zepi/turbo-base
Zepi/Web/UserInterface/src/Layout/AbstractContainer.php
AbstractContainer.getChildrenByType
public function getChildrenByType($type, $recursive = true) { $results = array(); foreach ($this->parts as $part) { if (is_a($part, $type) || is_subclass_of($part, $type)) { $results[] = $part; } if ($recursive) { $results = array_merge($results, $part->getChildrenByType($type, $recursive)); } } return $results; }
php
public function getChildrenByType($type, $recursive = true) { $results = array(); foreach ($this->parts as $part) { if (is_a($part, $type) || is_subclass_of($part, $type)) { $results[] = $part; } if ($recursive) { $results = array_merge($results, $part->getChildrenByType($type, $recursive)); } } return $results; }
[ "public", "function", "getChildrenByType", "(", "$", "type", ",", "$", "recursive", "=", "true", ")", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "parts", "as", "$", "part", ")", "{", "if", "(", "is_a", "(", "$", "part", ",", "$", "type", ")", "||", "is_subclass_of", "(", "$", "part", ",", "$", "type", ")", ")", "{", "$", "results", "[", "]", "=", "$", "part", ";", "}", "if", "(", "$", "recursive", ")", "{", "$", "results", "=", "array_merge", "(", "$", "results", ",", "$", "part", "->", "getChildrenByType", "(", "$", "type", ",", "$", "recursive", ")", ")", ";", "}", "}", "return", "$", "results", ";", "}" ]
Returns all children with the given type. @access public @param string $type @param boolean $recursive @return array
[ "Returns", "all", "children", "with", "the", "given", "type", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Layout/AbstractContainer.php#L325-L340
9,670
tekkla/core-router
Core/Router/Router.php
Router.getInstance
public function getInstance(): Router { if (! isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
php
public function getInstance(): Router { if (! isset(self::$instance)) { self::$instance = new self(); } return self::$instance; }
[ "public", "function", "getInstance", "(", ")", ":", "Router", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "instance", ")", ")", "{", "self", "::", "$", "instance", "=", "new", "self", "(", ")", ";", "}", "return", "self", "::", "$", "instance", ";", "}" ]
Singleton instance factory @return Router
[ "Singleton", "instance", "factory" ]
5ee6c6e816824e92115509766afec3daed1d5a43
https://github.com/tekkla/core-router/blob/5ee6c6e816824e92115509766afec3daed1d5a43/Core/Router/Router.php#L64-L71
9,671
tekkla/core-router
Core/Router/Router.php
Router.getParam
public function getParam(string $param) { if (! empty($this->match['params'][$param])) { return $this->match['params'][$param]; } }
php
public function getParam(string $param) { if (! empty($this->match['params'][$param])) { return $this->match['params'][$param]; } }
[ "public", "function", "getParam", "(", "string", "$", "param", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "match", "[", "'params'", "]", "[", "$", "param", "]", ")", ")", "{", "return", "$", "this", "->", "match", "[", "'params'", "]", "[", "$", "param", "]", ";", "}", "}" ]
Returns a parameter value @param string $param Name of param to return value of @return mixed
[ "Returns", "a", "parameter", "value" ]
5ee6c6e816824e92115509766afec3daed1d5a43
https://github.com/tekkla/core-router/blob/5ee6c6e816824e92115509766afec3daed1d5a43/Core/Router/Router.php#L146-L151
9,672
tekkla/core-router
Core/Router/Router.php
Router.match
public function match($request_url = null, $request_method = null) { // Set Request Url if it isn't passed as parameter if ($request_url === null) { $request_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'; } $this->request_url = $request_url; // Set Request Method if it isn't passed as a parameter if ($request_method === null) { $request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; } // Is this an ajax request? if (substr($request_url, - 5) == '/ajax') { $this->ajax = true; $request_url = str_replace('/ajax', '', $request_url); } elseif (isset($_GET['ajax'])) { $this->ajax = true; } $this->match = parent::match($request_url, $request_method); if (! empty($this->match)) { // Some parameters only have control or workflow character and are no parameters for public use. // Those will be removed from the parameters array after using them to set corresponding values and/or flags // in router. $controls = [ 'ajax', 'format' ]; foreach ($controls as $key) { if (isset($this->match['params'][$key])) { switch ($key) { case 'ajax': $this->ajax = true; break; case 'format': $this->format = $this->match['params'][$key]; break; default: $this->{$key} = $this->match['params'][$key]; } break; } unset($this->match['params'][$key]); } } if (! empty($this->match['params'])) { foreach ($this->match['params'] as $key => $val) { if (empty($val)) { unset($this->match['params'][$key]); } if (in_array($key, $this->parameter_to_target)) { $this->match['target'][$key] = $val; } } } }
php
public function match($request_url = null, $request_method = null) { // Set Request Url if it isn't passed as parameter if ($request_url === null) { $request_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'; } $this->request_url = $request_url; // Set Request Method if it isn't passed as a parameter if ($request_method === null) { $request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; } // Is this an ajax request? if (substr($request_url, - 5) == '/ajax') { $this->ajax = true; $request_url = str_replace('/ajax', '', $request_url); } elseif (isset($_GET['ajax'])) { $this->ajax = true; } $this->match = parent::match($request_url, $request_method); if (! empty($this->match)) { // Some parameters only have control or workflow character and are no parameters for public use. // Those will be removed from the parameters array after using them to set corresponding values and/or flags // in router. $controls = [ 'ajax', 'format' ]; foreach ($controls as $key) { if (isset($this->match['params'][$key])) { switch ($key) { case 'ajax': $this->ajax = true; break; case 'format': $this->format = $this->match['params'][$key]; break; default: $this->{$key} = $this->match['params'][$key]; } break; } unset($this->match['params'][$key]); } } if (! empty($this->match['params'])) { foreach ($this->match['params'] as $key => $val) { if (empty($val)) { unset($this->match['params'][$key]); } if (in_array($key, $this->parameter_to_target)) { $this->match['target'][$key] = $val; } } } }
[ "public", "function", "match", "(", "$", "request_url", "=", "null", ",", "$", "request_method", "=", "null", ")", "{", "// Set Request Url if it isn't passed as parameter", "if", "(", "$", "request_url", "===", "null", ")", "{", "$", "request_url", "=", "isset", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", "?", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ":", "'/'", ";", "}", "$", "this", "->", "request_url", "=", "$", "request_url", ";", "// Set Request Method if it isn't passed as a parameter", "if", "(", "$", "request_method", "===", "null", ")", "{", "$", "request_method", "=", "isset", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ")", "?", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ":", "'GET'", ";", "}", "// Is this an ajax request?", "if", "(", "substr", "(", "$", "request_url", ",", "-", "5", ")", "==", "'/ajax'", ")", "{", "$", "this", "->", "ajax", "=", "true", ";", "$", "request_url", "=", "str_replace", "(", "'/ajax'", ",", "''", ",", "$", "request_url", ")", ";", "}", "elseif", "(", "isset", "(", "$", "_GET", "[", "'ajax'", "]", ")", ")", "{", "$", "this", "->", "ajax", "=", "true", ";", "}", "$", "this", "->", "match", "=", "parent", "::", "match", "(", "$", "request_url", ",", "$", "request_method", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "match", ")", ")", "{", "// Some parameters only have control or workflow character and are no parameters for public use.", "// Those will be removed from the parameters array after using them to set corresponding values and/or flags", "// in router.", "$", "controls", "=", "[", "'ajax'", ",", "'format'", "]", ";", "foreach", "(", "$", "controls", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "match", "[", "'params'", "]", "[", "$", "key", "]", ")", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'ajax'", ":", "$", "this", "->", "ajax", "=", "true", ";", "break", ";", "case", "'format'", ":", "$", "this", "->", "format", "=", "$", "this", "->", "match", "[", "'params'", "]", "[", "$", "key", "]", ";", "break", ";", "default", ":", "$", "this", "->", "{", "$", "key", "}", "=", "$", "this", "->", "match", "[", "'params'", "]", "[", "$", "key", "]", ";", "}", "break", ";", "}", "unset", "(", "$", "this", "->", "match", "[", "'params'", "]", "[", "$", "key", "]", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "match", "[", "'params'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "match", "[", "'params'", "]", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "empty", "(", "$", "val", ")", ")", "{", "unset", "(", "$", "this", "->", "match", "[", "'params'", "]", "[", "$", "key", "]", ")", ";", "}", "if", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "parameter_to_target", ")", ")", "{", "$", "this", "->", "match", "[", "'target'", "]", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "}", "}" ]
Match a given request url against stored routes @param string $request_url @param string $request_method @return array boolean with route information on success, false on failure (no match).
[ "Match", "a", "given", "request", "url", "against", "stored", "routes" ]
5ee6c6e816824e92115509766afec3daed1d5a43
https://github.com/tekkla/core-router/blob/5ee6c6e816824e92115509766afec3daed1d5a43/Core/Router/Router.php#L207-L275
9,673
tekkla/core-router
Core/Router/Router.php
Router.getStatus
public function getStatus(): array { return [ 'url' => $this->request_url, 'route' => $this->getCurrentRoute(), 'ajax' => $this->ajax, 'method' => $_SERVER['REQUEST_METHOD'], 'format' => $this->format, 'match' => $this->match ]; }
php
public function getStatus(): array { return [ 'url' => $this->request_url, 'route' => $this->getCurrentRoute(), 'ajax' => $this->ajax, 'method' => $_SERVER['REQUEST_METHOD'], 'format' => $this->format, 'match' => $this->match ]; }
[ "public", "function", "getStatus", "(", ")", ":", "array", "{", "return", "[", "'url'", "=>", "$", "this", "->", "request_url", ",", "'route'", "=>", "$", "this", "->", "getCurrentRoute", "(", ")", ",", "'ajax'", "=>", "$", "this", "->", "ajax", ",", "'method'", "=>", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ",", "'format'", "=>", "$", "this", "->", "format", ",", "'match'", "=>", "$", "this", "->", "match", "]", ";", "}" ]
Returns all request related data in one array @return array
[ "Returns", "all", "request", "related", "data", "in", "one", "array" ]
5ee6c6e816824e92115509766afec3daed1d5a43
https://github.com/tekkla/core-router/blob/5ee6c6e816824e92115509766afec3daed1d5a43/Core/Router/Router.php#L336-L346
9,674
tekkla/core-router
Core/Router/Router.php
Router.getTarget
public function getTarget(string $target) { if (! empty($this->match['target'][$target])) { return $this->match['target'][$target]; } }
php
public function getTarget(string $target) { if (! empty($this->match['target'][$target])) { return $this->match['target'][$target]; } }
[ "public", "function", "getTarget", "(", "string", "$", "target", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "match", "[", "'target'", "]", "[", "$", "target", "]", ")", ")", "{", "return", "$", "this", "->", "match", "[", "'target'", "]", "[", "$", "target", "]", ";", "}", "}" ]
Returns a specific target @param string $target A target can be 'app', 'controller' or 'action' @return string|null
[ "Returns", "a", "specific", "target" ]
5ee6c6e816824e92115509766afec3daed1d5a43
https://github.com/tekkla/core-router/blob/5ee6c6e816824e92115509766afec3daed1d5a43/Core/Router/Router.php#L356-L361
9,675
qunabu/silverstripe-htmlblocks
code/HTMLBlock.php
HTMLBlock.parse_shortcode
public static function parse_shortcode($attributes, $content, $parser, $shortcode) { // check the gallery exists if (isset($attributes['id']) && $gallery = HTMLBlock::get()->byID($attributes['id'])) { return HTMLBlock::get()->byID($attributes['id'])->forTemplate(); } }
php
public static function parse_shortcode($attributes, $content, $parser, $shortcode) { // check the gallery exists if (isset($attributes['id']) && $gallery = HTMLBlock::get()->byID($attributes['id'])) { return HTMLBlock::get()->byID($attributes['id'])->forTemplate(); } }
[ "public", "static", "function", "parse_shortcode", "(", "$", "attributes", ",", "$", "content", ",", "$", "parser", ",", "$", "shortcode", ")", "{", "// check the gallery exists", "if", "(", "isset", "(", "$", "attributes", "[", "'id'", "]", ")", "&&", "$", "gallery", "=", "HTMLBlock", "::", "get", "(", ")", "->", "byID", "(", "$", "attributes", "[", "'id'", "]", ")", ")", "{", "return", "HTMLBlock", "::", "get", "(", ")", "->", "byID", "(", "$", "attributes", "[", "'id'", "]", ")", "->", "forTemplate", "(", ")", ";", "}", "}" ]
Parse the shortcode and render as a string, probably with a template @param array $attributes the list of attributes of the shortcode @param string $content the shortcode content @param ShortcodeParser $parser the ShortcodeParser instance @param string $shortcode the raw shortcode being parsed @return String
[ "Parse", "the", "shortcode", "and", "render", "as", "a", "string", "probably", "with", "a", "template" ]
a38a23739d61e845b658a70af8f0a7badfd030fb
https://github.com/qunabu/silverstripe-htmlblocks/blob/a38a23739d61e845b658a70af8f0a7badfd030fb/code/HTMLBlock.php#L84-L92
9,676
jelix/php-redis-plugin
plugins/kvdb/redis_php/redis_php.kvdriver.php
redis_phpKVDriver._connect
protected function _connect() { // A host is needed if (! isset($this->_profile['host'])) { throw new jException( 'jelix~kvstore.error.no.host', $this->_profileName); } // A port is needed as well if (! isset($this->_profile['port'])) { throw new jException( 'jelix~kvstore.error.no.port', $this->_profileName); } if (isset($this->_profile['key_prefix'])) { $this->key_prefix = $this->_profile['key_prefix']; } if ($this->key_prefix && isset($this->_profile['key_prefix_flush_method'])) { if (in_array($this->_profile['key_prefix_flush_method'], array('direct', 'jkvdbredisworker', 'event'))) { $this->key_prefix_flush_method = $this->_profile['key_prefix_flush_method']; } } // OK, let's connect now $cnx = new \PhpRedis\Redis($this->_profile['host'], $this->_profile['port']); if (isset($this->_profile['db']) && intval($this->_profile['db']) != 0) { $cnx->select_db($this->_profile['db']); } return $cnx; }
php
protected function _connect() { // A host is needed if (! isset($this->_profile['host'])) { throw new jException( 'jelix~kvstore.error.no.host', $this->_profileName); } // A port is needed as well if (! isset($this->_profile['port'])) { throw new jException( 'jelix~kvstore.error.no.port', $this->_profileName); } if (isset($this->_profile['key_prefix'])) { $this->key_prefix = $this->_profile['key_prefix']; } if ($this->key_prefix && isset($this->_profile['key_prefix_flush_method'])) { if (in_array($this->_profile['key_prefix_flush_method'], array('direct', 'jkvdbredisworker', 'event'))) { $this->key_prefix_flush_method = $this->_profile['key_prefix_flush_method']; } } // OK, let's connect now $cnx = new \PhpRedis\Redis($this->_profile['host'], $this->_profile['port']); if (isset($this->_profile['db']) && intval($this->_profile['db']) != 0) { $cnx->select_db($this->_profile['db']); } return $cnx; }
[ "protected", "function", "_connect", "(", ")", "{", "// A host is needed", "if", "(", "!", "isset", "(", "$", "this", "->", "_profile", "[", "'host'", "]", ")", ")", "{", "throw", "new", "jException", "(", "'jelix~kvstore.error.no.host'", ",", "$", "this", "->", "_profileName", ")", ";", "}", "// A port is needed as well", "if", "(", "!", "isset", "(", "$", "this", "->", "_profile", "[", "'port'", "]", ")", ")", "{", "throw", "new", "jException", "(", "'jelix~kvstore.error.no.port'", ",", "$", "this", "->", "_profileName", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_profile", "[", "'key_prefix'", "]", ")", ")", "{", "$", "this", "->", "key_prefix", "=", "$", "this", "->", "_profile", "[", "'key_prefix'", "]", ";", "}", "if", "(", "$", "this", "->", "key_prefix", "&&", "isset", "(", "$", "this", "->", "_profile", "[", "'key_prefix_flush_method'", "]", ")", ")", "{", "if", "(", "in_array", "(", "$", "this", "->", "_profile", "[", "'key_prefix_flush_method'", "]", ",", "array", "(", "'direct'", ",", "'jkvdbredisworker'", ",", "'event'", ")", ")", ")", "{", "$", "this", "->", "key_prefix_flush_method", "=", "$", "this", "->", "_profile", "[", "'key_prefix_flush_method'", "]", ";", "}", "}", "// OK, let's connect now", "$", "cnx", "=", "new", "\\", "PhpRedis", "\\", "Redis", "(", "$", "this", "->", "_profile", "[", "'host'", "]", ",", "$", "this", "->", "_profile", "[", "'port'", "]", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_profile", "[", "'db'", "]", ")", "&&", "intval", "(", "$", "this", "->", "_profile", "[", "'db'", "]", ")", "!=", "0", ")", "{", "$", "cnx", "->", "select_db", "(", "$", "this", "->", "_profile", "[", "'db'", "]", ")", ";", "}", "return", "$", "cnx", ";", "}" ]
Connects to the redis server @return \PhpRedis\Redis object @throws jException
[ "Connects", "to", "the", "redis", "server" ]
bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b
https://github.com/jelix/php-redis-plugin/blob/bcb6f4a5265eeecfcfa8448f1b8571a9c336f92b/plugins/kvdb/redis_php/redis_php.kvdriver.php#L36-L68
9,677
blenderdeluxe/khipu
src/KhipuService/KhipuServiceCreatePaymentURL.php
KhipuServiceCreatePaymentURL.createUrl
public function createUrl() { $string_data = $this->dataToString(); $data_to_send = array( 'hash' => $this->doHash($string_data), ); // Adicionalmente adjuntamos el resto de los valores iniciados en $data foreach ($this->data as $name => $value) { $data_to_send[$name] = $value; } $data_to_send['agent'] = $this->agent; // Iniciamos CURL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->apiUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_to_send); $output = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); if ($info['http_code'] == 200) { return $output; } else { return FALSE; } }
php
public function createUrl() { $string_data = $this->dataToString(); $data_to_send = array( 'hash' => $this->doHash($string_data), ); // Adicionalmente adjuntamos el resto de los valores iniciados en $data foreach ($this->data as $name => $value) { $data_to_send[$name] = $value; } $data_to_send['agent'] = $this->agent; // Iniciamos CURL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->apiUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_to_send); $output = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); if ($info['http_code'] == 200) { return $output; } else { return FALSE; } }
[ "public", "function", "createUrl", "(", ")", "{", "$", "string_data", "=", "$", "this", "->", "dataToString", "(", ")", ";", "$", "data_to_send", "=", "array", "(", "'hash'", "=>", "$", "this", "->", "doHash", "(", "$", "string_data", ")", ",", ")", ";", "// Adicionalmente adjuntamos el resto de los valores iniciados en $data", "foreach", "(", "$", "this", "->", "data", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "data_to_send", "[", "$", "name", "]", "=", "$", "value", ";", "}", "$", "data_to_send", "[", "'agent'", "]", "=", "$", "this", "->", "agent", ";", "// Iniciamos CURL", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "this", "->", "apiUrl", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "TRUE", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "data_to_send", ")", ";", "$", "output", "=", "curl_exec", "(", "$", "ch", ")", ";", "$", "info", "=", "curl_getinfo", "(", "$", "ch", ")", ";", "curl_close", "(", "$", "ch", ")", ";", "if", "(", "$", "info", "[", "'http_code'", "]", "==", "200", ")", "{", "return", "$", "output", ";", "}", "else", "{", "return", "FALSE", ";", "}", "}" ]
Metodo que solicita la generacion de la url
[ "Metodo", "que", "solicita", "la", "generacion", "de", "la", "url" ]
ef78fa8ba372c7784936ce95a3d0bd46a35e0143
https://github.com/blenderdeluxe/khipu/blob/ef78fa8ba372c7784936ce95a3d0bd46a35e0143/src/KhipuService/KhipuServiceCreatePaymentURL.php#L49-L76
9,678
wigedev/simple-mvc
src/Utility/HTTPUtilities.php
HTTPUtilities.getFileExtension
public static function getFileExtension($name) { if (is_array($name)) { $name = array_pop($name); } $extension = static::splitFilename($name)[1]; if (is_string($extension)) { $extension = strtolower($extension); } return $extension; }
php
public static function getFileExtension($name) { if (is_array($name)) { $name = array_pop($name); } $extension = static::splitFilename($name)[1]; if (is_string($extension)) { $extension = strtolower($extension); } return $extension; }
[ "public", "static", "function", "getFileExtension", "(", "$", "name", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "$", "name", "=", "array_pop", "(", "$", "name", ")", ";", "}", "$", "extension", "=", "static", "::", "splitFilename", "(", "$", "name", ")", "[", "1", "]", ";", "if", "(", "is_string", "(", "$", "extension", ")", ")", "{", "$", "extension", "=", "strtolower", "(", "$", "extension", ")", ";", "}", "return", "$", "extension", ";", "}" ]
Parse the passed filename to get the extension only. If passed an array, uses the last element of the array. @param string|array $name @return string
[ "Parse", "the", "passed", "filename", "to", "get", "the", "extension", "only", ".", "If", "passed", "an", "array", "uses", "the", "last", "element", "of", "the", "array", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Utility/HTTPUtilities.php#L35-L45
9,679
wigedev/simple-mvc
src/Utility/HTTPUtilities.php
HTTPUtilities.splitFilename
private static function splitFilename($name) { if (is_array($name)) { $name = array_pop($name); } else { $name = explode('/', $name); $name = array_pop($name); } if (strrpos($name, '.') !== false) { return explode('.', $name); } else { return array($name, null); } }
php
private static function splitFilename($name) { if (is_array($name)) { $name = array_pop($name); } else { $name = explode('/', $name); $name = array_pop($name); } if (strrpos($name, '.') !== false) { return explode('.', $name); } else { return array($name, null); } }
[ "private", "static", "function", "splitFilename", "(", "$", "name", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "$", "name", "=", "array_pop", "(", "$", "name", ")", ";", "}", "else", "{", "$", "name", "=", "explode", "(", "'/'", ",", "$", "name", ")", ";", "$", "name", "=", "array_pop", "(", "$", "name", ")", ";", "}", "if", "(", "strrpos", "(", "$", "name", ",", "'.'", ")", "!==", "false", ")", "{", "return", "explode", "(", "'.'", ",", "$", "name", ")", ";", "}", "else", "{", "return", "array", "(", "$", "name", ",", "null", ")", ";", "}", "}" ]
Splits the passed filename into a name and extension and returns an array. The first element is the name, the second is the extension. @param string|array $name @return string[] The first element is the name, the second element is the extension, or null if no extension
[ "Splits", "the", "passed", "filename", "into", "a", "name", "and", "extension", "and", "returns", "an", "array", ".", "The", "first", "element", "is", "the", "name", "the", "second", "is", "the", "extension", "." ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Utility/HTTPUtilities.php#L55-L68
9,680
native5/native5-sdk-common-php
src/Native5/Core/Log/Impl/SysLogHandler.php
SysLogHandler.writeLog
public function writeLog($message, $priority='LOG_INFO') { $this->logger->addRecord( self::$_mapping[$priority], $this->_transform($message) ); }
php
public function writeLog($message, $priority='LOG_INFO') { $this->logger->addRecord( self::$_mapping[$priority], $this->_transform($message) ); }
[ "public", "function", "writeLog", "(", "$", "message", ",", "$", "priority", "=", "'LOG_INFO'", ")", "{", "$", "this", "->", "logger", "->", "addRecord", "(", "self", "::", "$", "_mapping", "[", "$", "priority", "]", ",", "$", "this", "->", "_transform", "(", "$", "message", ")", ")", ";", "}" ]
Writes log to file. @param mixed $message Message to write @param mixed $priority Priority of message to be written @access public @return void
[ "Writes", "log", "to", "file", "." ]
c8bd5b219bd05ea4d317d21ae9c0c8dddcede7fe
https://github.com/native5/native5-sdk-common-php/blob/c8bd5b219bd05ea4d317d21ae9c0c8dddcede7fe/src/Native5/Core/Log/Impl/SysLogHandler.php#L96-L103
9,681
larriereguichet/DoctrineRepositoryBundle
DependencyInjection/RepositoryCompilerPass.php
RepositoryCompilerPass.process
public function process(ContainerBuilder $container) { if (!$container->hasDefinition('lag.repository.repository_pool')) { return; } // find service with doctrine.repository tag $repositoryTags = $container->findTaggedServiceIds('doctrine.repository'); // get pool definition $poolDefinition = $container->findDefinition('lag.repository.repository_pool'); foreach ($repositoryTags as $serviceId => $tags) { // add repository to the pool $poolDefinition->addMethodCall('add', [ new Reference($serviceId), ]); } }
php
public function process(ContainerBuilder $container) { if (!$container->hasDefinition('lag.repository.repository_pool')) { return; } // find service with doctrine.repository tag $repositoryTags = $container->findTaggedServiceIds('doctrine.repository'); // get pool definition $poolDefinition = $container->findDefinition('lag.repository.repository_pool'); foreach ($repositoryTags as $serviceId => $tags) { // add repository to the pool $poolDefinition->addMethodCall('add', [ new Reference($serviceId), ]); } }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "!", "$", "container", "->", "hasDefinition", "(", "'lag.repository.repository_pool'", ")", ")", "{", "return", ";", "}", "// find service with doctrine.repository tag", "$", "repositoryTags", "=", "$", "container", "->", "findTaggedServiceIds", "(", "'doctrine.repository'", ")", ";", "// get pool definition", "$", "poolDefinition", "=", "$", "container", "->", "findDefinition", "(", "'lag.repository.repository_pool'", ")", ";", "foreach", "(", "$", "repositoryTags", "as", "$", "serviceId", "=>", "$", "tags", ")", "{", "// add repository to the pool", "$", "poolDefinition", "->", "addMethodCall", "(", "'add'", ",", "[", "new", "Reference", "(", "$", "serviceId", ")", ",", "]", ")", ";", "}", "}" ]
Load tagged repositories and add it to the repository pool @param ContainerBuilder $container
[ "Load", "tagged", "repositories", "and", "add", "it", "to", "the", "repository", "pool" ]
d98e91d115a6c9f0fe9e9fb03de92f1268b51c10
https://github.com/larriereguichet/DoctrineRepositoryBundle/blob/d98e91d115a6c9f0fe9e9fb03de92f1268b51c10/DependencyInjection/RepositoryCompilerPass.php#L19-L35
9,682
ItinerisLtd/preflight-command
src/Checkers/Traits/CompiledBlacklistAwareTrait.php
CompiledBlacklistAwareTrait.errorIfCompiledBlacklistIsEmpty
protected function errorIfCompiledBlacklistIsEmpty(Config $config): ?Error { $blacklist = $config->compileBlacklist(); return empty($blacklist) ? ResultFactory::makeError($this, 'Blacklist is empty.') : null; }
php
protected function errorIfCompiledBlacklistIsEmpty(Config $config): ?Error { $blacklist = $config->compileBlacklist(); return empty($blacklist) ? ResultFactory::makeError($this, 'Blacklist is empty.') : null; }
[ "protected", "function", "errorIfCompiledBlacklistIsEmpty", "(", "Config", "$", "config", ")", ":", "?", "Error", "{", "$", "blacklist", "=", "$", "config", "->", "compileBlacklist", "(", ")", ";", "return", "empty", "(", "$", "blacklist", ")", "?", "ResultFactory", "::", "makeError", "(", "$", "this", ",", "'Blacklist is empty.'", ")", ":", "null", ";", "}" ]
Returns error if compiled blacklist is empty. @param Config $config The config instance. @return Error|null
[ "Returns", "error", "if", "compiled", "blacklist", "is", "empty", "." ]
d1c1360ea8d7de0312b5c0c09c9c486949594049
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/Checkers/Traits/CompiledBlacklistAwareTrait.php#L19-L26
9,683
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.serialize
public function serialize() { $device = $this->getDevice(); $spec = array( 'browser_type' => $this->_browserType, 'config' => $this->_config, 'device_class' => get_class($device), 'device' => $device->serialize(), 'user_agent' => $this->getServerValue('http_user_agent'), 'http_accept' => $this->getServerValue('http_accept'), ); return serialize($spec); }
php
public function serialize() { $device = $this->getDevice(); $spec = array( 'browser_type' => $this->_browserType, 'config' => $this->_config, 'device_class' => get_class($device), 'device' => $device->serialize(), 'user_agent' => $this->getServerValue('http_user_agent'), 'http_accept' => $this->getServerValue('http_accept'), ); return serialize($spec); }
[ "public", "function", "serialize", "(", ")", "{", "$", "device", "=", "$", "this", "->", "getDevice", "(", ")", ";", "$", "spec", "=", "array", "(", "'browser_type'", "=>", "$", "this", "->", "_browserType", ",", "'config'", "=>", "$", "this", "->", "_config", ",", "'device_class'", "=>", "get_class", "(", "$", "device", ")", ",", "'device'", "=>", "$", "device", "->", "serialize", "(", ")", ",", "'user_agent'", "=>", "$", "this", "->", "getServerValue", "(", "'http_user_agent'", ")", ",", "'http_accept'", "=>", "$", "this", "->", "getServerValue", "(", "'http_accept'", ")", ",", ")", ";", "return", "serialize", "(", "$", "spec", ")", ";", "}" ]
Serialized representation of the object @return string
[ "Serialized", "representation", "of", "the", "object" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L172-L184
9,684
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.unserialize
public function unserialize($serialized) { $spec = unserialize($serialized); $this->setOptions($spec); // Determine device class and ensure the class is loaded $deviceClass = $spec['device_class']; if (!class_exists($deviceClass)) { $this->_getUserAgentDevice($this->getBrowserType()); } // Get device specification and instantiate $deviceSpec = unserialize($spec['device']); $deviceSpec['_config'] = $this->getConfig(); $deviceSpec['_server'] = $this->getServer(); $this->_device = new $deviceClass($deviceSpec); }
php
public function unserialize($serialized) { $spec = unserialize($serialized); $this->setOptions($spec); // Determine device class and ensure the class is loaded $deviceClass = $spec['device_class']; if (!class_exists($deviceClass)) { $this->_getUserAgentDevice($this->getBrowserType()); } // Get device specification and instantiate $deviceSpec = unserialize($spec['device']); $deviceSpec['_config'] = $this->getConfig(); $deviceSpec['_server'] = $this->getServer(); $this->_device = new $deviceClass($deviceSpec); }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "$", "spec", "=", "unserialize", "(", "$", "serialized", ")", ";", "$", "this", "->", "setOptions", "(", "$", "spec", ")", ";", "// Determine device class and ensure the class is loaded", "$", "deviceClass", "=", "$", "spec", "[", "'device_class'", "]", ";", "if", "(", "!", "class_exists", "(", "$", "deviceClass", ")", ")", "{", "$", "this", "->", "_getUserAgentDevice", "(", "$", "this", "->", "getBrowserType", "(", ")", ")", ";", "}", "// Get device specification and instantiate", "$", "deviceSpec", "=", "unserialize", "(", "$", "spec", "[", "'device'", "]", ")", ";", "$", "deviceSpec", "[", "'_config'", "]", "=", "$", "this", "->", "getConfig", "(", ")", ";", "$", "deviceSpec", "[", "'_server'", "]", "=", "$", "this", "->", "getServer", "(", ")", ";", "$", "this", "->", "_device", "=", "new", "$", "deviceClass", "(", "$", "deviceSpec", ")", ";", "}" ]
Unserialize a previous representation of the object @param string $serialized @return void
[ "Unserialize", "a", "previous", "representation", "of", "the", "object" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L192-L209
9,685
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent._match
protected function _match($deviceClass) { // Validate device class $r = new ReflectionClass($deviceClass); if (!$r->implementsInterface('Zend_Http_UserAgent_Device')) { throw new Zend_Http_UserAgent_Exception(sprintf( 'Invalid device class provided ("%s"); must implement Zend_Http_UserAgent_Device', $deviceClass )); } $userAgent = $this->getUserAgent(); // Call match method on device class return call_user_func( array($deviceClass, 'match'), $userAgent, $this->getServer() ); }
php
protected function _match($deviceClass) { // Validate device class $r = new ReflectionClass($deviceClass); if (!$r->implementsInterface('Zend_Http_UserAgent_Device')) { throw new Zend_Http_UserAgent_Exception(sprintf( 'Invalid device class provided ("%s"); must implement Zend_Http_UserAgent_Device', $deviceClass )); } $userAgent = $this->getUserAgent(); // Call match method on device class return call_user_func( array($deviceClass, 'match'), $userAgent, $this->getServer() ); }
[ "protected", "function", "_match", "(", "$", "deviceClass", ")", "{", "// Validate device class", "$", "r", "=", "new", "ReflectionClass", "(", "$", "deviceClass", ")", ";", "if", "(", "!", "$", "r", "->", "implementsInterface", "(", "'Zend_Http_UserAgent_Device'", ")", ")", "{", "throw", "new", "Zend_Http_UserAgent_Exception", "(", "sprintf", "(", "'Invalid device class provided (\"%s\"); must implement Zend_Http_UserAgent_Device'", ",", "$", "deviceClass", ")", ")", ";", "}", "$", "userAgent", "=", "$", "this", "->", "getUserAgent", "(", ")", ";", "// Call match method on device class", "return", "call_user_func", "(", "array", "(", "$", "deviceClass", ",", "'match'", ")", ",", "$", "userAgent", ",", "$", "this", "->", "getServer", "(", ")", ")", ";", "}" ]
Comparison of the UserAgent chain and browser signatures. The comparison is case-insensitive : the browser signatures must be in lower case @param string $deviceClass Name of class against which a match will be attempted @return bool
[ "Comparison", "of", "the", "UserAgent", "chain", "and", "browser", "signatures", "." ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L284-L303
9,686
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent._getUserAgentDevice
protected function _getUserAgentDevice($browserType) { $browserType = strtolower($browserType); if (isset($this->_browserTypeClass[$browserType])) { return $this->_browserTypeClass[$browserType]; } if (isset($this->_config[$browserType]) && isset($this->_config[$browserType]['device']) ) { $deviceConfig = $this->_config[$browserType]['device']; if (is_array($deviceConfig) && isset($deviceConfig['classname'])) { $device = (string) $deviceConfig['classname']; if (!class_exists($device)) { throw new Zend_Http_UserAgent_Exception(sprintf( 'Invalid classname "%s" provided in device configuration for browser type "%s"', $device, $browserType )); } } elseif (is_array($deviceConfig) && isset($deviceConfig['path'])) { $loader = $this->getPluginLoader('device'); $path = $deviceConfig['path']; $prefix = isset($deviceConfig['prefix']) ? $deviceConfig['prefix'] : 'Zend_Http_UserAgent'; $loader->addPrefixPath($prefix, $path); $device = $loader->load($browserType); } else { $loader = $this->getPluginLoader('device'); $device = $loader->load($browserType); } } else { $loader = $this->getPluginLoader('device'); $device = $loader->load($browserType); } $this->_browserTypeClass[$browserType] = $device; return $device; }
php
protected function _getUserAgentDevice($browserType) { $browserType = strtolower($browserType); if (isset($this->_browserTypeClass[$browserType])) { return $this->_browserTypeClass[$browserType]; } if (isset($this->_config[$browserType]) && isset($this->_config[$browserType]['device']) ) { $deviceConfig = $this->_config[$browserType]['device']; if (is_array($deviceConfig) && isset($deviceConfig['classname'])) { $device = (string) $deviceConfig['classname']; if (!class_exists($device)) { throw new Zend_Http_UserAgent_Exception(sprintf( 'Invalid classname "%s" provided in device configuration for browser type "%s"', $device, $browserType )); } } elseif (is_array($deviceConfig) && isset($deviceConfig['path'])) { $loader = $this->getPluginLoader('device'); $path = $deviceConfig['path']; $prefix = isset($deviceConfig['prefix']) ? $deviceConfig['prefix'] : 'Zend_Http_UserAgent'; $loader->addPrefixPath($prefix, $path); $device = $loader->load($browserType); } else { $loader = $this->getPluginLoader('device'); $device = $loader->load($browserType); } } else { $loader = $this->getPluginLoader('device'); $device = $loader->load($browserType); } $this->_browserTypeClass[$browserType] = $device; return $device; }
[ "protected", "function", "_getUserAgentDevice", "(", "$", "browserType", ")", "{", "$", "browserType", "=", "strtolower", "(", "$", "browserType", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_browserTypeClass", "[", "$", "browserType", "]", ")", ")", "{", "return", "$", "this", "->", "_browserTypeClass", "[", "$", "browserType", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "_config", "[", "$", "browserType", "]", ")", "&&", "isset", "(", "$", "this", "->", "_config", "[", "$", "browserType", "]", "[", "'device'", "]", ")", ")", "{", "$", "deviceConfig", "=", "$", "this", "->", "_config", "[", "$", "browserType", "]", "[", "'device'", "]", ";", "if", "(", "is_array", "(", "$", "deviceConfig", ")", "&&", "isset", "(", "$", "deviceConfig", "[", "'classname'", "]", ")", ")", "{", "$", "device", "=", "(", "string", ")", "$", "deviceConfig", "[", "'classname'", "]", ";", "if", "(", "!", "class_exists", "(", "$", "device", ")", ")", "{", "throw", "new", "Zend_Http_UserAgent_Exception", "(", "sprintf", "(", "'Invalid classname \"%s\" provided in device configuration for browser type \"%s\"'", ",", "$", "device", ",", "$", "browserType", ")", ")", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "deviceConfig", ")", "&&", "isset", "(", "$", "deviceConfig", "[", "'path'", "]", ")", ")", "{", "$", "loader", "=", "$", "this", "->", "getPluginLoader", "(", "'device'", ")", ";", "$", "path", "=", "$", "deviceConfig", "[", "'path'", "]", ";", "$", "prefix", "=", "isset", "(", "$", "deviceConfig", "[", "'prefix'", "]", ")", "?", "$", "deviceConfig", "[", "'prefix'", "]", ":", "'Zend_Http_UserAgent'", ";", "$", "loader", "->", "addPrefixPath", "(", "$", "prefix", ",", "$", "path", ")", ";", "$", "device", "=", "$", "loader", "->", "load", "(", "$", "browserType", ")", ";", "}", "else", "{", "$", "loader", "=", "$", "this", "->", "getPluginLoader", "(", "'device'", ")", ";", "$", "device", "=", "$", "loader", "->", "load", "(", "$", "browserType", ")", ";", "}", "}", "else", "{", "$", "loader", "=", "$", "this", "->", "getPluginLoader", "(", "'device'", ")", ";", "$", "device", "=", "$", "loader", "->", "load", "(", "$", "browserType", ")", ";", "}", "$", "this", "->", "_browserTypeClass", "[", "$", "browserType", "]", "=", "$", "device", ";", "return", "$", "device", ";", "}" ]
Loads class for a user agent device @param string $browserType Browser type @return string @throws Zend_Loader_PluginLoader_Exception if unable to load UA device
[ "Loads", "class", "for", "a", "user", "agent", "device" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L312-L352
9,687
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.getUserAgent
public function getUserAgent() { if (null === ($ua = $this->getServerValue('http_user_agent'))) { $ua = self::DEFAULT_HTTP_USER_AGENT; $this->setUserAgent($ua); } return $ua; }
php
public function getUserAgent() { if (null === ($ua = $this->getServerValue('http_user_agent'))) { $ua = self::DEFAULT_HTTP_USER_AGENT; $this->setUserAgent($ua); } return $ua; }
[ "public", "function", "getUserAgent", "(", ")", "{", "if", "(", "null", "===", "(", "$", "ua", "=", "$", "this", "->", "getServerValue", "(", "'http_user_agent'", ")", ")", ")", "{", "$", "ua", "=", "self", "::", "DEFAULT_HTTP_USER_AGENT", ";", "$", "this", "->", "setUserAgent", "(", "$", "ua", ")", ";", "}", "return", "$", "ua", ";", "}" ]
Returns the User Agent value If $userAgent param is null, the value of $_server['HTTP_USER_AGENT'] is returned. @return string
[ "Returns", "the", "User", "Agent", "value" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L362-L370
9,688
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.getHttpAccept
public function getHttpAccept($httpAccept = null) { if (null === ($accept = $this->getServerValue('http_accept'))) { $accept = self::DEFAULT_HTTP_ACCEPT; $this->setHttpAccept($accept); } return $accept; }
php
public function getHttpAccept($httpAccept = null) { if (null === ($accept = $this->getServerValue('http_accept'))) { $accept = self::DEFAULT_HTTP_ACCEPT; $this->setHttpAccept($accept); } return $accept; }
[ "public", "function", "getHttpAccept", "(", "$", "httpAccept", "=", "null", ")", "{", "if", "(", "null", "===", "(", "$", "accept", "=", "$", "this", "->", "getServerValue", "(", "'http_accept'", ")", ")", ")", "{", "$", "accept", "=", "self", "::", "DEFAULT_HTTP_ACCEPT", ";", "$", "this", "->", "setHttpAccept", "(", "$", "accept", ")", ";", "}", "return", "$", "accept", ";", "}" ]
Returns the HTTP Accept server param @param string $httpAccept (option) forced HTTP Accept chain @return string
[ "Returns", "the", "HTTP", "Accept", "server", "param" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L390-L397
9,689
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.setStorage
public function setStorage(Zend_Http_UserAgent_Storage $storage) { if ($this->_immutable) { throw new Zend_Http_UserAgent_Exception( 'The User-Agent device object has already been retrieved; the storage object is now immutable' ); } $this->_storage = $storage; return $this; }
php
public function setStorage(Zend_Http_UserAgent_Storage $storage) { if ($this->_immutable) { throw new Zend_Http_UserAgent_Exception( 'The User-Agent device object has already been retrieved; the storage object is now immutable' ); } $this->_storage = $storage; return $this; }
[ "public", "function", "setStorage", "(", "Zend_Http_UserAgent_Storage", "$", "storage", ")", "{", "if", "(", "$", "this", "->", "_immutable", ")", "{", "throw", "new", "Zend_Http_UserAgent_Exception", "(", "'The User-Agent device object has already been retrieved; the storage object is now immutable'", ")", ";", "}", "$", "this", "->", "_storage", "=", "$", "storage", ";", "return", "$", "this", ";", "}" ]
Sets the persistent storage handler @param Zend_Http_UserAgent_Storage $storage @return Zend_Http_UserAgent
[ "Sets", "the", "persistent", "storage", "handler" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L450-L461
9,690
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.setConfig
public function setConfig($config = array()) { if ($config instanceof Zend_Config) { $config = $config->toArray(); } // Verify that Config parameters are in an array. if (!is_array($config) && !$config instanceof Traversable) { throw new Zend_Http_UserAgent_Exception(sprintf( 'Config parameters must be in an array or a Traversable object; received "%s"', (is_object($config) ? get_class($config) : gettype($config)) )); } if ($config instanceof Traversable) { $tmp = array(); foreach ($config as $key => $value) { $tmp[$key] = $value; } $config = $tmp; unset($tmp); } $this->_config = array_merge($this->_config, $config); return $this; }
php
public function setConfig($config = array()) { if ($config instanceof Zend_Config) { $config = $config->toArray(); } // Verify that Config parameters are in an array. if (!is_array($config) && !$config instanceof Traversable) { throw new Zend_Http_UserAgent_Exception(sprintf( 'Config parameters must be in an array or a Traversable object; received "%s"', (is_object($config) ? get_class($config) : gettype($config)) )); } if ($config instanceof Traversable) { $tmp = array(); foreach ($config as $key => $value) { $tmp[$key] = $value; } $config = $tmp; unset($tmp); } $this->_config = array_merge($this->_config, $config); return $this; }
[ "public", "function", "setConfig", "(", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "$", "config", "instanceof", "Zend_Config", ")", "{", "$", "config", "=", "$", "config", "->", "toArray", "(", ")", ";", "}", "// Verify that Config parameters are in an array.", "if", "(", "!", "is_array", "(", "$", "config", ")", "&&", "!", "$", "config", "instanceof", "Traversable", ")", "{", "throw", "new", "Zend_Http_UserAgent_Exception", "(", "sprintf", "(", "'Config parameters must be in an array or a Traversable object; received \"%s\"'", ",", "(", "is_object", "(", "$", "config", ")", "?", "get_class", "(", "$", "config", ")", ":", "gettype", "(", "$", "config", ")", ")", ")", ")", ";", "}", "if", "(", "$", "config", "instanceof", "Traversable", ")", "{", "$", "tmp", "=", "array", "(", ")", ";", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "tmp", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "config", "=", "$", "tmp", ";", "unset", "(", "$", "tmp", ")", ";", "}", "$", "this", "->", "_config", "=", "array_merge", "(", "$", "this", "->", "_config", ",", "$", "config", ")", ";", "return", "$", "this", ";", "}" ]
Config parameters is an Array or a Zend_Config object The allowed parameters are : - the identification sequence (can be empty) => desktop browser type is the default browser type returned $config['identification_sequence'] : ',' separated browser types - the persistent storage adapter $config['persistent_storage_adapter'] = "Session" or "NonPersistent" - to add or replace a browser type device $config[(type)]['device']['path'] $config[(type)]['device']['classname'] - to add or replace a browser type features adapter $config[(type)]['features']['path'] $config[(type)]['features']['classname'] @param mixed $config (option) Config array @return Zend_Http_UserAgent
[ "Config", "parameters", "is", "an", "Array", "or", "a", "Zend_Config", "object" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L503-L529
9,691
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.getDevice
public function getDevice() { if (null !== $this->_device) { return $this->_device; } $userAgent = $this->getUserAgent(); // search an existing identification in the session $storage = $this->getStorage($userAgent); if (!$storage->isEmpty()) { // If the user agent and features are already existing, the // Zend_Http_UserAgent object is serialized in the session $object = $storage->read(); $this->unserialize($object); } else { // Otherwise, the identification is made and stored in the session. // Find the browser type: $this->setBrowserType($this->_matchUserAgent()); $this->_createDevice(); // put the result in storage: $this->getStorage($userAgent) ->write($this->serialize()); } // Mark the object as immutable $this->_immutable = true; // Return the device instance return $this->_device; }
php
public function getDevice() { if (null !== $this->_device) { return $this->_device; } $userAgent = $this->getUserAgent(); // search an existing identification in the session $storage = $this->getStorage($userAgent); if (!$storage->isEmpty()) { // If the user agent and features are already existing, the // Zend_Http_UserAgent object is serialized in the session $object = $storage->read(); $this->unserialize($object); } else { // Otherwise, the identification is made and stored in the session. // Find the browser type: $this->setBrowserType($this->_matchUserAgent()); $this->_createDevice(); // put the result in storage: $this->getStorage($userAgent) ->write($this->serialize()); } // Mark the object as immutable $this->_immutable = true; // Return the device instance return $this->_device; }
[ "public", "function", "getDevice", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "_device", ")", "{", "return", "$", "this", "->", "_device", ";", "}", "$", "userAgent", "=", "$", "this", "->", "getUserAgent", "(", ")", ";", "// search an existing identification in the session", "$", "storage", "=", "$", "this", "->", "getStorage", "(", "$", "userAgent", ")", ";", "if", "(", "!", "$", "storage", "->", "isEmpty", "(", ")", ")", "{", "// If the user agent and features are already existing, the", "// Zend_Http_UserAgent object is serialized in the session", "$", "object", "=", "$", "storage", "->", "read", "(", ")", ";", "$", "this", "->", "unserialize", "(", "$", "object", ")", ";", "}", "else", "{", "// Otherwise, the identification is made and stored in the session.", "// Find the browser type:", "$", "this", "->", "setBrowserType", "(", "$", "this", "->", "_matchUserAgent", "(", ")", ")", ";", "$", "this", "->", "_createDevice", "(", ")", ";", "// put the result in storage:", "$", "this", "->", "getStorage", "(", "$", "userAgent", ")", "->", "write", "(", "$", "this", "->", "serialize", "(", ")", ")", ";", "}", "// Mark the object as immutable", "$", "this", "->", "_immutable", "=", "true", ";", "// Return the device instance", "return", "$", "this", "->", "_device", ";", "}" ]
Returns the device object This is the object that will contain the various discovered device capabilities. @return Zend_Http_UserAgent_Device $device
[ "Returns", "the", "device", "object" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L539-L571
9,692
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.getServerValue
public function getServerValue($key) { $key = strtolower($key); $server = $this->getServer(); $return = null; if (isset($server[$key])) { $return = $server[$key]; } unset($server); return $return; }
php
public function getServerValue($key) { $key = strtolower($key); $server = $this->getServer(); $return = null; if (isset($server[$key])) { $return = $server[$key]; } unset($server); return $return; }
[ "public", "function", "getServerValue", "(", "$", "key", ")", "{", "$", "key", "=", "strtolower", "(", "$", "key", ")", ";", "$", "server", "=", "$", "this", "->", "getServer", "(", ")", ";", "$", "return", "=", "null", ";", "if", "(", "isset", "(", "$", "server", "[", "$", "key", "]", ")", ")", "{", "$", "return", "=", "$", "server", "[", "$", "key", "]", ";", "}", "unset", "(", "$", "server", ")", ";", "return", "$", "return", ";", "}" ]
Retrieve a server value @param string $key @return mixed
[ "Retrieve", "a", "server", "value" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L673-L683
9,693
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.setServerValue
public function setServerValue($key, $value) { if ($this->_immutable) { throw new Zend_Http_UserAgent_Exception( 'The User-Agent device object has already been retrieved; the server array is now immutable' ); } $server = $this->getServer(); // ensure it's been initialized $key = strtolower($key); $this->_server[$key] = $value; return $this; }
php
public function setServerValue($key, $value) { if ($this->_immutable) { throw new Zend_Http_UserAgent_Exception( 'The User-Agent device object has already been retrieved; the server array is now immutable' ); } $server = $this->getServer(); // ensure it's been initialized $key = strtolower($key); $this->_server[$key] = $value; return $this; }
[ "public", "function", "setServerValue", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "_immutable", ")", "{", "throw", "new", "Zend_Http_UserAgent_Exception", "(", "'The User-Agent device object has already been retrieved; the server array is now immutable'", ")", ";", "}", "$", "server", "=", "$", "this", "->", "getServer", "(", ")", ";", "// ensure it's been initialized", "$", "key", "=", "strtolower", "(", "$", "key", ")", ";", "$", "this", "->", "_server", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set a server value @param string|int|float $key @param mixed $value @return void
[ "Set", "a", "server", "value" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L692-L705
9,694
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.setPluginLoader
public function setPluginLoader($type, $loader) { $type = $this->_validateLoaderType($type); if (is_string($loader)) { if (!class_exists($loader)) { Zend_Loader::loadClass($loader); } $loader = new $loader(); } elseif (!is_object($loader)) { throw new Zend_Http_UserAgent_Exception(sprintf( 'Expected a plugin loader class or object; received %s', gettype($loader) )); } if (!$loader instanceof Zend_Loader_PluginLoader) { throw new Zend_Http_UserAgent_Exception(sprintf( 'Expected an object extending Zend_Loader_PluginLoader; received %s', get_class($loader) )); } $basePrefix = 'Zend_Http_UserAgent_'; $basePath = 'Zend/Http/UserAgent/'; switch ($type) { case 'storage': $prefix = $basePrefix . 'Storage'; $path = $basePath . 'Storage'; break; case 'device': $prefix = $basePrefix; $path = $basePath; break; } $loader->addPrefixPath($prefix, $path); $this->_loaders[$type] = $loader; return $this; }
php
public function setPluginLoader($type, $loader) { $type = $this->_validateLoaderType($type); if (is_string($loader)) { if (!class_exists($loader)) { Zend_Loader::loadClass($loader); } $loader = new $loader(); } elseif (!is_object($loader)) { throw new Zend_Http_UserAgent_Exception(sprintf( 'Expected a plugin loader class or object; received %s', gettype($loader) )); } if (!$loader instanceof Zend_Loader_PluginLoader) { throw new Zend_Http_UserAgent_Exception(sprintf( 'Expected an object extending Zend_Loader_PluginLoader; received %s', get_class($loader) )); } $basePrefix = 'Zend_Http_UserAgent_'; $basePath = 'Zend/Http/UserAgent/'; switch ($type) { case 'storage': $prefix = $basePrefix . 'Storage'; $path = $basePath . 'Storage'; break; case 'device': $prefix = $basePrefix; $path = $basePath; break; } $loader->addPrefixPath($prefix, $path); $this->_loaders[$type] = $loader; return $this; }
[ "public", "function", "setPluginLoader", "(", "$", "type", ",", "$", "loader", ")", "{", "$", "type", "=", "$", "this", "->", "_validateLoaderType", "(", "$", "type", ")", ";", "if", "(", "is_string", "(", "$", "loader", ")", ")", "{", "if", "(", "!", "class_exists", "(", "$", "loader", ")", ")", "{", "Zend_Loader", "::", "loadClass", "(", "$", "loader", ")", ";", "}", "$", "loader", "=", "new", "$", "loader", "(", ")", ";", "}", "elseif", "(", "!", "is_object", "(", "$", "loader", ")", ")", "{", "throw", "new", "Zend_Http_UserAgent_Exception", "(", "sprintf", "(", "'Expected a plugin loader class or object; received %s'", ",", "gettype", "(", "$", "loader", ")", ")", ")", ";", "}", "if", "(", "!", "$", "loader", "instanceof", "Zend_Loader_PluginLoader", ")", "{", "throw", "new", "Zend_Http_UserAgent_Exception", "(", "sprintf", "(", "'Expected an object extending Zend_Loader_PluginLoader; received %s'", ",", "get_class", "(", "$", "loader", ")", ")", ")", ";", "}", "$", "basePrefix", "=", "'Zend_Http_UserAgent_'", ";", "$", "basePath", "=", "'Zend/Http/UserAgent/'", ";", "switch", "(", "$", "type", ")", "{", "case", "'storage'", ":", "$", "prefix", "=", "$", "basePrefix", ".", "'Storage'", ";", "$", "path", "=", "$", "basePath", ".", "'Storage'", ";", "break", ";", "case", "'device'", ":", "$", "prefix", "=", "$", "basePrefix", ";", "$", "path", "=", "$", "basePath", ";", "break", ";", "}", "$", "loader", "->", "addPrefixPath", "(", "$", "prefix", ",", "$", "path", ")", ";", "$", "this", "->", "_loaders", "[", "$", "type", "]", "=", "$", "loader", ";", "return", "$", "this", ";", "}" ]
Set plugin loader @param string $type Type of plugin loader; one of 'storage', (?) @param string|Zend_Loader_PluginLoader $loader @return Zend_Http_UserAgent
[ "Set", "plugin", "loader" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L714-L754
9,695
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent.getPluginLoader
public function getPluginLoader($type) { $type = $this->_validateLoaderType($type); if (!isset($this->_loaders[$type])) { $this->setPluginLoader($type, new Zend_Loader_PluginLoader()); } return $this->_loaders[$type]; }
php
public function getPluginLoader($type) { $type = $this->_validateLoaderType($type); if (!isset($this->_loaders[$type])) { $this->setPluginLoader($type, new Zend_Loader_PluginLoader()); } return $this->_loaders[$type]; }
[ "public", "function", "getPluginLoader", "(", "$", "type", ")", "{", "$", "type", "=", "$", "this", "->", "_validateLoaderType", "(", "$", "type", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_loaders", "[", "$", "type", "]", ")", ")", "{", "$", "this", "->", "setPluginLoader", "(", "$", "type", ",", "new", "Zend_Loader_PluginLoader", "(", ")", ")", ";", "}", "return", "$", "this", "->", "_loaders", "[", "$", "type", "]", ";", "}" ]
Get a plugin loader @param string $type A valid plugin loader type; see {@link $_loaderTypes} @return Zend_Loader_PluginLoader
[ "Get", "a", "plugin", "loader" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L762-L770
9,696
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent._validateLoaderType
protected function _validateLoaderType($type) { $type = strtolower($type); if (!in_array($type, $this->_loaderTypes)) { $types = implode(', ', $this->_loaderTypes); throw new Zend_Http_UserAgent_Exception(sprintf( 'Expected one of "%s" for plugin loader type; received "%s"', $types, (string) $type )); } return $type; }
php
protected function _validateLoaderType($type) { $type = strtolower($type); if (!in_array($type, $this->_loaderTypes)) { $types = implode(', ', $this->_loaderTypes); throw new Zend_Http_UserAgent_Exception(sprintf( 'Expected one of "%s" for plugin loader type; received "%s"', $types, (string) $type )); } return $type; }
[ "protected", "function", "_validateLoaderType", "(", "$", "type", ")", "{", "$", "type", "=", "strtolower", "(", "$", "type", ")", ";", "if", "(", "!", "in_array", "(", "$", "type", ",", "$", "this", "->", "_loaderTypes", ")", ")", "{", "$", "types", "=", "implode", "(", "', '", ",", "$", "this", "->", "_loaderTypes", ")", ";", "throw", "new", "Zend_Http_UserAgent_Exception", "(", "sprintf", "(", "'Expected one of \"%s\" for plugin loader type; received \"%s\"'", ",", "$", "types", ",", "(", "string", ")", "$", "type", ")", ")", ";", "}", "return", "$", "type", ";", "}" ]
Validate a plugin loader type Verifies that it is in {@link $_loaderTypes}, and returns a normalized version of the type. @param string $type @return string @throws Zend_Http_UserAgent_Exception on invalid type
[ "Validate", "a", "plugin", "loader", "type" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L782-L795
9,697
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent._matchUserAgent
protected function _matchUserAgent() { $type = self::DEFAULT_BROWSER_TYPE; // If we have no identification sequence, just return the default type if (empty($this->_config['identification_sequence'])) { return $type; } // Get sequence against which to match $sequence = explode(',', $this->_config['identification_sequence']); // If a browser type is already configured, push that to the front of the list if (null !== ($browserType = $this->getBrowserType())) { array_unshift($sequence, $browserType); } // Append the default browser type to the list if not alread in the list if (!in_array($type, $sequence)) { $sequence[] = $type; } // Test each type until we find a match foreach ($sequence as $browserType) { $browserType = trim($browserType); $className = $this->_getUserAgentDevice($browserType); // Attempt to match this device class if ($this->_match($className)) { $type = $browserType; $this->_browserTypeClass[$type] = $className; break; } } return $type; }
php
protected function _matchUserAgent() { $type = self::DEFAULT_BROWSER_TYPE; // If we have no identification sequence, just return the default type if (empty($this->_config['identification_sequence'])) { return $type; } // Get sequence against which to match $sequence = explode(',', $this->_config['identification_sequence']); // If a browser type is already configured, push that to the front of the list if (null !== ($browserType = $this->getBrowserType())) { array_unshift($sequence, $browserType); } // Append the default browser type to the list if not alread in the list if (!in_array($type, $sequence)) { $sequence[] = $type; } // Test each type until we find a match foreach ($sequence as $browserType) { $browserType = trim($browserType); $className = $this->_getUserAgentDevice($browserType); // Attempt to match this device class if ($this->_match($className)) { $type = $browserType; $this->_browserTypeClass[$type] = $className; break; } } return $type; }
[ "protected", "function", "_matchUserAgent", "(", ")", "{", "$", "type", "=", "self", "::", "DEFAULT_BROWSER_TYPE", ";", "// If we have no identification sequence, just return the default type", "if", "(", "empty", "(", "$", "this", "->", "_config", "[", "'identification_sequence'", "]", ")", ")", "{", "return", "$", "type", ";", "}", "// Get sequence against which to match", "$", "sequence", "=", "explode", "(", "','", ",", "$", "this", "->", "_config", "[", "'identification_sequence'", "]", ")", ";", "// If a browser type is already configured, push that to the front of the list", "if", "(", "null", "!==", "(", "$", "browserType", "=", "$", "this", "->", "getBrowserType", "(", ")", ")", ")", "{", "array_unshift", "(", "$", "sequence", ",", "$", "browserType", ")", ";", "}", "// Append the default browser type to the list if not alread in the list", "if", "(", "!", "in_array", "(", "$", "type", ",", "$", "sequence", ")", ")", "{", "$", "sequence", "[", "]", "=", "$", "type", ";", "}", "// Test each type until we find a match", "foreach", "(", "$", "sequence", "as", "$", "browserType", ")", "{", "$", "browserType", "=", "trim", "(", "$", "browserType", ")", ";", "$", "className", "=", "$", "this", "->", "_getUserAgentDevice", "(", "$", "browserType", ")", ";", "// Attempt to match this device class", "if", "(", "$", "this", "->", "_match", "(", "$", "className", ")", ")", "{", "$", "type", "=", "$", "browserType", ";", "$", "this", "->", "_browserTypeClass", "[", "$", "type", "]", "=", "$", "className", ";", "break", ";", "}", "}", "return", "$", "type", ";", "}" ]
Run the identification sequence to match the right browser type according to the user agent @return Zend_Http_UserAgent_Result
[ "Run", "the", "identification", "sequence", "to", "match", "the", "right", "browser", "type", "according", "to", "the", "user", "agent" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L803-L839
9,698
joegreen88/zf1-component-http
src/Zend/Http/UserAgent.php
Zend_Http_UserAgent._createDevice
protected function _createDevice() { $browserType = $this->getBrowserType(); $classname = $this->_getUserAgentDevice($browserType); $this->_device = new $classname($this->getUserAgent(), $this->getServer(), $this->getConfig()); }
php
protected function _createDevice() { $browserType = $this->getBrowserType(); $classname = $this->_getUserAgentDevice($browserType); $this->_device = new $classname($this->getUserAgent(), $this->getServer(), $this->getConfig()); }
[ "protected", "function", "_createDevice", "(", ")", "{", "$", "browserType", "=", "$", "this", "->", "getBrowserType", "(", ")", ";", "$", "classname", "=", "$", "this", "->", "_getUserAgentDevice", "(", "$", "browserType", ")", ";", "$", "this", "->", "_device", "=", "new", "$", "classname", "(", "$", "this", "->", "getUserAgent", "(", ")", ",", "$", "this", "->", "getServer", "(", ")", ",", "$", "this", "->", "getConfig", "(", ")", ")", ";", "}" ]
Creates device object instance @return void
[ "Creates", "device", "object", "instance" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent.php#L846-L851
9,699
phunc-org/Phunc
src/Time/TimeConversion.php
TimeConversion.convertToHours
function convertToHours() { $totalMinutes = $this->minutes; $Mins = ($totalMinutes % 60); $Hours = floor(abs($totalMinutes) / 60); if ($totalMinutes < 0) { $Hours = '-' . $Hours; $Mins = substr($Mins, 1); } else { $Hours = floor($totalMinutes / 60); } $Mins = str_pad($Mins, 2, '0', STR_PAD_LEFT); $this->HM = new HM($Hours, $Mins); return $this; }
php
function convertToHours() { $totalMinutes = $this->minutes; $Mins = ($totalMinutes % 60); $Hours = floor(abs($totalMinutes) / 60); if ($totalMinutes < 0) { $Hours = '-' . $Hours; $Mins = substr($Mins, 1); } else { $Hours = floor($totalMinutes / 60); } $Mins = str_pad($Mins, 2, '0', STR_PAD_LEFT); $this->HM = new HM($Hours, $Mins); return $this; }
[ "function", "convertToHours", "(", ")", "{", "$", "totalMinutes", "=", "$", "this", "->", "minutes", ";", "$", "Mins", "=", "(", "$", "totalMinutes", "%", "60", ")", ";", "$", "Hours", "=", "floor", "(", "abs", "(", "$", "totalMinutes", ")", "/", "60", ")", ";", "if", "(", "$", "totalMinutes", "<", "0", ")", "{", "$", "Hours", "=", "'-'", ".", "$", "Hours", ";", "$", "Mins", "=", "substr", "(", "$", "Mins", ",", "1", ")", ";", "}", "else", "{", "$", "Hours", "=", "floor", "(", "$", "totalMinutes", "/", "60", ")", ";", "}", "$", "Mins", "=", "str_pad", "(", "$", "Mins", ",", "2", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "$", "this", "->", "HM", "=", "new", "HM", "(", "$", "Hours", ",", "$", "Mins", ")", ";", "return", "$", "this", ";", "}" ]
Umwandlung der Minuten in Stunden und Minuten. Z.B. 3170 Min. = 52 Std. und 50 Min. @return $this
[ "Umwandlung", "der", "Minuten", "in", "Stunden", "und", "Minuten", ".", "Z", ".", "B", ".", "3170", "Min", ".", "=", "52", "Std", ".", "und", "50", "Min", "." ]
80c69d5a63e352c8e0c3330e3b8bb1288d0a9256
https://github.com/phunc-org/Phunc/blob/80c69d5a63e352c8e0c3330e3b8bb1288d0a9256/src/Time/TimeConversion.php#L50-L65