id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
23,900
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_sqlite.php
ezcQuerySelectSqlite.buildRightJoins
private function buildRightJoins() { $resultArray = array(); foreach ( $this->rightJoins as $rJoinPart ) { $oneItemResult = ''; if ( $rJoinPart === null ) { break; // this is last empty entry so cancel adding. } // reverse lists of tables and conditions to make LEFT JOIN // that will produce result equal to original right join. $reversedTables = array_reverse( $rJoinPart['tables'] ); $reversedConditions = array_reverse( $rJoinPart['conditions'] ); // adding first table. list( $key, $val ) = each( $reversedTables ); $oneItemResult .= $val; while ( list( $key, $nextCondition ) = each( $reversedConditions ) ) { list( $key2, $nextTable ) = each( $reversedTables ); $oneItemResult .= " LEFT JOIN {$nextTable} ON {$nextCondition}"; } $resultArray[] = $oneItemResult; } return join( ', ', $resultArray ); }
php
private function buildRightJoins() { $resultArray = array(); foreach ( $this->rightJoins as $rJoinPart ) { $oneItemResult = ''; if ( $rJoinPart === null ) { break; // this is last empty entry so cancel adding. } // reverse lists of tables and conditions to make LEFT JOIN // that will produce result equal to original right join. $reversedTables = array_reverse( $rJoinPart['tables'] ); $reversedConditions = array_reverse( $rJoinPart['conditions'] ); // adding first table. list( $key, $val ) = each( $reversedTables ); $oneItemResult .= $val; while ( list( $key, $nextCondition ) = each( $reversedConditions ) ) { list( $key2, $nextTable ) = each( $reversedTables ); $oneItemResult .= " LEFT JOIN {$nextTable} ON {$nextCondition}"; } $resultArray[] = $oneItemResult; } return join( ', ', $resultArray ); }
[ "private", "function", "buildRightJoins", "(", ")", "{", "$", "resultArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "rightJoins", "as", "$", "rJoinPart", ")", "{", "$", "oneItemResult", "=", "''", ";", "if", "(", "$", "rJoinPart", "===", "null", ")", "{", "break", ";", "// this is last empty entry so cancel adding.", "}", "// reverse lists of tables and conditions to make LEFT JOIN ", "// that will produce result equal to original right join.", "$", "reversedTables", "=", "array_reverse", "(", "$", "rJoinPart", "[", "'tables'", "]", ")", ";", "$", "reversedConditions", "=", "array_reverse", "(", "$", "rJoinPart", "[", "'conditions'", "]", ")", ";", "// adding first table.", "list", "(", "$", "key", ",", "$", "val", ")", "=", "each", "(", "$", "reversedTables", ")", ";", "$", "oneItemResult", ".=", "$", "val", ";", "while", "(", "list", "(", "$", "key", ",", "$", "nextCondition", ")", "=", "each", "(", "$", "reversedConditions", ")", ")", "{", "list", "(", "$", "key2", ",", "$", "nextTable", ")", "=", "each", "(", "$", "reversedTables", ")", ";", "$", "oneItemResult", ".=", "\" LEFT JOIN {$nextTable} ON {$nextCondition}\"", ";", "}", "$", "resultArray", "[", "]", "=", "$", "oneItemResult", ";", "}", "return", "join", "(", "', '", ",", "$", "resultArray", ")", ";", "}" ]
Returns SQL string with part of FROM clause that performs right join emulation. SQLite don't support right joins directly but there is workaround. identical result could be acheived using right joins for tables in reverce order. String created from entries of $rightJoins. One entry is a complete table_reference clause of SQL FROM clause. <code> rightJoins[0][tables] = array( 'table1', 'table2', 'table3' ) rightJoins[0][conditions] = array( condition1, condition2 ) </code> forms SQL: 'table3 LEFT JOIN table2 condition2 ON LEFT JOIN table1 ON condition1'. @return string the SQL call including all right joins set in query.
[ "Returns", "SQL", "string", "with", "part", "of", "FROM", "clause", "that", "performs", "right", "join", "emulation", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/query_select_sqlite.php#L141-L171
23,901
geocoder-php/GeocoderServiceProvider
src/Geocoder/Provider/GeocoderServiceProvider.php
GeocoderServiceProvider.injectServices
protected function injectServices(Container $app) { if (isset($app['profiler'])) { $app['geocoder.logger'] = function($app) { return new \Geocoder\Logger\GeocoderLogger(); }; $app['geocoder'] = function($app) { $geocoder = new \Geocoder\LoggableGeocoder(); $geocoder->setLogger($app['geocoder.logger']); $geocoder->registerProvider($app['geocoder.provider']); return $geocoder; }; } else { $app['geocoder'] = function($app) { $geocoder = new \Geocoder\Geocoder(); $geocoder->registerProvider($app['geocoder.provider']); return $geocoder; }; } $app['geocoder.provider'] = function($app) { return new \Geocoder\Provider\FreeGeoIpProvider($app['geocoder.adapter']); }; $app['geocoder.adapter'] = function($app) { return new \Geocoder\HttpAdapter\CurlHttpAdapter(); }; }
php
protected function injectServices(Container $app) { if (isset($app['profiler'])) { $app['geocoder.logger'] = function($app) { return new \Geocoder\Logger\GeocoderLogger(); }; $app['geocoder'] = function($app) { $geocoder = new \Geocoder\LoggableGeocoder(); $geocoder->setLogger($app['geocoder.logger']); $geocoder->registerProvider($app['geocoder.provider']); return $geocoder; }; } else { $app['geocoder'] = function($app) { $geocoder = new \Geocoder\Geocoder(); $geocoder->registerProvider($app['geocoder.provider']); return $geocoder; }; } $app['geocoder.provider'] = function($app) { return new \Geocoder\Provider\FreeGeoIpProvider($app['geocoder.adapter']); }; $app['geocoder.adapter'] = function($app) { return new \Geocoder\HttpAdapter\CurlHttpAdapter(); }; }
[ "protected", "function", "injectServices", "(", "Container", "$", "app", ")", "{", "if", "(", "isset", "(", "$", "app", "[", "'profiler'", "]", ")", ")", "{", "$", "app", "[", "'geocoder.logger'", "]", "=", "function", "(", "$", "app", ")", "{", "return", "new", "\\", "Geocoder", "\\", "Logger", "\\", "GeocoderLogger", "(", ")", ";", "}", ";", "$", "app", "[", "'geocoder'", "]", "=", "function", "(", "$", "app", ")", "{", "$", "geocoder", "=", "new", "\\", "Geocoder", "\\", "LoggableGeocoder", "(", ")", ";", "$", "geocoder", "->", "setLogger", "(", "$", "app", "[", "'geocoder.logger'", "]", ")", ";", "$", "geocoder", "->", "registerProvider", "(", "$", "app", "[", "'geocoder.provider'", "]", ")", ";", "return", "$", "geocoder", ";", "}", ";", "}", "else", "{", "$", "app", "[", "'geocoder'", "]", "=", "function", "(", "$", "app", ")", "{", "$", "geocoder", "=", "new", "\\", "Geocoder", "\\", "Geocoder", "(", ")", ";", "$", "geocoder", "->", "registerProvider", "(", "$", "app", "[", "'geocoder.provider'", "]", ")", ";", "return", "$", "geocoder", ";", "}", ";", "}", "$", "app", "[", "'geocoder.provider'", "]", "=", "function", "(", "$", "app", ")", "{", "return", "new", "\\", "Geocoder", "\\", "Provider", "\\", "FreeGeoIpProvider", "(", "$", "app", "[", "'geocoder.adapter'", "]", ")", ";", "}", ";", "$", "app", "[", "'geocoder.adapter'", "]", "=", "function", "(", "$", "app", ")", "{", "return", "new", "\\", "Geocoder", "\\", "HttpAdapter", "\\", "CurlHttpAdapter", "(", ")", ";", "}", ";", "}" ]
Injects Geocoder related services in the application.
[ "Injects", "Geocoder", "related", "services", "in", "the", "application", "." ]
9bb850f5ac881b4d317d569c87e0573faa69e4bb
https://github.com/geocoder-php/GeocoderServiceProvider/blob/9bb850f5ac881b4d317d569c87e0573faa69e4bb/src/Geocoder/Provider/GeocoderServiceProvider.php#L31-L61
23,902
geocoder-php/GeocoderServiceProvider
src/Geocoder/Provider/GeocoderServiceProvider.php
GeocoderServiceProvider.injectDataCollector
protected function injectDataCollector(Container $app) { $app['data_collector.templates'] = $app->extend('data_collector.templates', function ($templates) { $templates[] = ['geocoder', '@Geocoder/Collector/geocoder.html.twig']; return $templates; }); $app['data_collectors'] = $app->extend('data_collectors', function ($dataCollectors) { $dataCollectors['geocoder'] = function ($app) { return new GeocoderDataCollector($app['geocoder.logger']); }; return $dataCollectors; }); $app['twig.loader.filesystem'] = $app->extend('twig.loader.filesystem', function ($loader, $app) { $loader->addPath($app['geocoder.templates_path'], 'Geocoder'); return $loader; }); $app['geocoder.templates_path'] = function () { $r = new \ReflectionClass('Geocoder\Provider\GeocoderServiceProvider'); return dirname(dirname($r->getFileName())).'/../../views'; }; }
php
protected function injectDataCollector(Container $app) { $app['data_collector.templates'] = $app->extend('data_collector.templates', function ($templates) { $templates[] = ['geocoder', '@Geocoder/Collector/geocoder.html.twig']; return $templates; }); $app['data_collectors'] = $app->extend('data_collectors', function ($dataCollectors) { $dataCollectors['geocoder'] = function ($app) { return new GeocoderDataCollector($app['geocoder.logger']); }; return $dataCollectors; }); $app['twig.loader.filesystem'] = $app->extend('twig.loader.filesystem', function ($loader, $app) { $loader->addPath($app['geocoder.templates_path'], 'Geocoder'); return $loader; }); $app['geocoder.templates_path'] = function () { $r = new \ReflectionClass('Geocoder\Provider\GeocoderServiceProvider'); return dirname(dirname($r->getFileName())).'/../../views'; }; }
[ "protected", "function", "injectDataCollector", "(", "Container", "$", "app", ")", "{", "$", "app", "[", "'data_collector.templates'", "]", "=", "$", "app", "->", "extend", "(", "'data_collector.templates'", ",", "function", "(", "$", "templates", ")", "{", "$", "templates", "[", "]", "=", "[", "'geocoder'", ",", "'@Geocoder/Collector/geocoder.html.twig'", "]", ";", "return", "$", "templates", ";", "}", ")", ";", "$", "app", "[", "'data_collectors'", "]", "=", "$", "app", "->", "extend", "(", "'data_collectors'", ",", "function", "(", "$", "dataCollectors", ")", "{", "$", "dataCollectors", "[", "'geocoder'", "]", "=", "function", "(", "$", "app", ")", "{", "return", "new", "GeocoderDataCollector", "(", "$", "app", "[", "'geocoder.logger'", "]", ")", ";", "}", ";", "return", "$", "dataCollectors", ";", "}", ")", ";", "$", "app", "[", "'twig.loader.filesystem'", "]", "=", "$", "app", "->", "extend", "(", "'twig.loader.filesystem'", ",", "function", "(", "$", "loader", ",", "$", "app", ")", "{", "$", "loader", "->", "addPath", "(", "$", "app", "[", "'geocoder.templates_path'", "]", ",", "'Geocoder'", ")", ";", "return", "$", "loader", ";", "}", ")", ";", "$", "app", "[", "'geocoder.templates_path'", "]", "=", "function", "(", ")", "{", "$", "r", "=", "new", "\\", "ReflectionClass", "(", "'Geocoder\\Provider\\GeocoderServiceProvider'", ")", ";", "return", "dirname", "(", "dirname", "(", "$", "r", "->", "getFileName", "(", ")", ")", ")", ".", "'/../../views'", ";", "}", ";", "}" ]
Injects Geocoder's data collector in the profiler
[ "Injects", "Geocoder", "s", "data", "collector", "in", "the", "profiler" ]
9bb850f5ac881b4d317d569c87e0573faa69e4bb
https://github.com/geocoder-php/GeocoderServiceProvider/blob/9bb850f5ac881b4d317d569c87e0573faa69e4bb/src/Geocoder/Provider/GeocoderServiceProvider.php#L66-L91
23,903
ouropencode/dachi
src/Collections.php
Collections.asArray
public static function asArray($collection, $safe = false, $eager = false) { $elements = array(); foreach($collection as $key => $element) $elements[] = $element->asArray($safe, $eager); return $elements; }
php
public static function asArray($collection, $safe = false, $eager = false) { $elements = array(); foreach($collection as $key => $element) $elements[] = $element->asArray($safe, $eager); return $elements; }
[ "public", "static", "function", "asArray", "(", "$", "collection", ",", "$", "safe", "=", "false", ",", "$", "eager", "=", "false", ")", "{", "$", "elements", "=", "array", "(", ")", ";", "foreach", "(", "$", "collection", "as", "$", "key", "=>", "$", "element", ")", "$", "elements", "[", "]", "=", "$", "element", "->", "asArray", "(", "$", "safe", ",", "$", "eager", ")", ";", "return", "$", "elements", ";", "}" ]
Retrieve all the Collections's data in an array Models should implement this method themselves and provide the required data. Models can omit this, it just means you can't use it. @param ArrayCollection $collection The collection to operate upon @param bool $safe Should we return only data we consider "publicly exposable"? @param bool $eager Should we eager load child data? @return array
[ "Retrieve", "all", "the", "Collections", "s", "data", "in", "an", "array" ]
a0e1daf269d0345afbb859ce20ef9da6decd7efe
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Collections.php#L26-L33
23,904
SporkCode/Spork
src/ServiceManager/ClassAbstractFactory.php
ClassAbstractFactory.canCreateServiceWithName
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) { $config = $serviceLocator->get('config'); $class = $this->getClass($config, $requestedName); return $class && class_exists($class); }
php
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) { $config = $serviceLocator->get('config'); $class = $this->getClass($config, $requestedName); return $class && class_exists($class); }
[ "public", "function", "canCreateServiceWithName", "(", "ServiceLocatorInterface", "$", "serviceLocator", ",", "$", "name", ",", "$", "requestedName", ")", "{", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'config'", ")", ";", "$", "class", "=", "$", "this", "->", "getClass", "(", "$", "config", ",", "$", "requestedName", ")", ";", "return", "$", "class", "&&", "class_exists", "(", "$", "class", ")", ";", "}" ]
Test if configuration exists and has class field @see \Zend\ServiceManager\AbstractFactoryInterface::canCreateServiceWithName() @param ServiceLocatorInterface $serviceLocator @param string $name @param string $requestedName @return boolean
[ "Test", "if", "configuration", "exists", "and", "has", "class", "field" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/ServiceManager/ClassAbstractFactory.php#L29-L34
23,905
SporkCode/Spork
src/ServiceManager/ClassAbstractFactory.php
ClassAbstractFactory.createServiceWithName
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) { $config = $serviceLocator->get('config'); $class = $this->getClass($config, $requestedName); return new $class($config[$requestedName]); }
php
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) { $config = $serviceLocator->get('config'); $class = $this->getClass($config, $requestedName); return new $class($config[$requestedName]); }
[ "public", "function", "createServiceWithName", "(", "ServiceLocatorInterface", "$", "serviceLocator", ",", "$", "name", ",", "$", "requestedName", ")", "{", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'config'", ")", ";", "$", "class", "=", "$", "this", "->", "getClass", "(", "$", "config", ",", "$", "requestedName", ")", ";", "return", "new", "$", "class", "(", "$", "config", "[", "$", "requestedName", "]", ")", ";", "}" ]
Create and configure class by creating new instance of class from configuration @see \Zend\ServiceManager\AbstractFactoryInterface::createServiceWithName() @param ServiceLocatorInterface $serviceLocator @param string $name @param string $requestedName @return mixed
[ "Create", "and", "configure", "class", "by", "creating", "new", "instance", "of", "class", "from", "configuration" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/ServiceManager/ClassAbstractFactory.php#L46-L51
23,906
SporkCode/Spork
src/ServiceManager/ClassAbstractFactory.php
ClassAbstractFactory.getClass
protected function getClass($config, $name) { if (array_key_exists($name, $config) && is_array($config[$name]) && array_key_exists('class', $config[$name]) && is_scalar($config[$name]['class'])) { return $config[$name]['class']; } return false; }
php
protected function getClass($config, $name) { if (array_key_exists($name, $config) && is_array($config[$name]) && array_key_exists('class', $config[$name]) && is_scalar($config[$name]['class'])) { return $config[$name]['class']; } return false; }
[ "protected", "function", "getClass", "(", "$", "config", ",", "$", "name", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "config", ")", "&&", "is_array", "(", "$", "config", "[", "$", "name", "]", ")", "&&", "array_key_exists", "(", "'class'", ",", "$", "config", "[", "$", "name", "]", ")", "&&", "is_scalar", "(", "$", "config", "[", "$", "name", "]", "[", "'class'", "]", ")", ")", "{", "return", "$", "config", "[", "$", "name", "]", "[", "'class'", "]", ";", "}", "return", "false", ";", "}" ]
Look for class name in configuration @param array $config @param string $name @return boolean
[ "Look", "for", "class", "name", "in", "configuration" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/ServiceManager/ClassAbstractFactory.php#L60-L70
23,907
sciactive/nymph-server
src/Drivers/SQLite3Driver.php
SQLite3Driver.connect
public function connect() { // Check that the SQLite3 extension is installed. if (!class_exists('SQLite3')) { throw new Exceptions\UnableToConnectException( 'SQLite3 PHP extension is not available. It probably has not '. 'been installed. Please install and configure it in order to use '. 'SQLite3.' ); } $filename = $this->config['SQLite3']['filename']; $busyTimeout = $this->config['SQLite3']['busy_timeout']; $openFlags = $this->config['SQLite3']['open_flags']; $encryptionKey = $this->config['SQLite3']['encryption_key']; // Connecting if (!$this->connected) { $this->link = new SQLite3($filename, $openFlags, $encryptionKey); if ($this->link) { $this->connected = true; $this->link->busyTimeout($busyTimeout); // Set database and connection options. $this->link->exec("PRAGMA encoding = \"UTF-8\";"); $this->link->exec("PRAGMA foreign_keys = 1;"); $this->link->exec("PRAGMA case_sensitive_like = 1;"); // Create the preg_match and regexp functions. // TODO(hperrin): Add more of these functions to get rid of post-query checks. $this->link->createFunction('preg_match', 'preg_match', 2, SQLITE3_DETERMINISTIC); $this->link->createFunction('regexp', function ($pattern, $subject) { return !!$this->posixRegexMatch($pattern, $subject); }, 2, SQLITE3_DETERMINISTIC); } else { $this->connected = false; if ($filename === ':memory:') { throw new Exceptions\NotConfiguredException(); } else { throw new Exceptions\UnableToConnectException('Could not connect.'); } } } return $this->connected; }
php
public function connect() { // Check that the SQLite3 extension is installed. if (!class_exists('SQLite3')) { throw new Exceptions\UnableToConnectException( 'SQLite3 PHP extension is not available. It probably has not '. 'been installed. Please install and configure it in order to use '. 'SQLite3.' ); } $filename = $this->config['SQLite3']['filename']; $busyTimeout = $this->config['SQLite3']['busy_timeout']; $openFlags = $this->config['SQLite3']['open_flags']; $encryptionKey = $this->config['SQLite3']['encryption_key']; // Connecting if (!$this->connected) { $this->link = new SQLite3($filename, $openFlags, $encryptionKey); if ($this->link) { $this->connected = true; $this->link->busyTimeout($busyTimeout); // Set database and connection options. $this->link->exec("PRAGMA encoding = \"UTF-8\";"); $this->link->exec("PRAGMA foreign_keys = 1;"); $this->link->exec("PRAGMA case_sensitive_like = 1;"); // Create the preg_match and regexp functions. // TODO(hperrin): Add more of these functions to get rid of post-query checks. $this->link->createFunction('preg_match', 'preg_match', 2, SQLITE3_DETERMINISTIC); $this->link->createFunction('regexp', function ($pattern, $subject) { return !!$this->posixRegexMatch($pattern, $subject); }, 2, SQLITE3_DETERMINISTIC); } else { $this->connected = false; if ($filename === ':memory:') { throw new Exceptions\NotConfiguredException(); } else { throw new Exceptions\UnableToConnectException('Could not connect.'); } } } return $this->connected; }
[ "public", "function", "connect", "(", ")", "{", "// Check that the SQLite3 extension is installed.", "if", "(", "!", "class_exists", "(", "'SQLite3'", ")", ")", "{", "throw", "new", "Exceptions", "\\", "UnableToConnectException", "(", "'SQLite3 PHP extension is not available. It probably has not '", ".", "'been installed. Please install and configure it in order to use '", ".", "'SQLite3.'", ")", ";", "}", "$", "filename", "=", "$", "this", "->", "config", "[", "'SQLite3'", "]", "[", "'filename'", "]", ";", "$", "busyTimeout", "=", "$", "this", "->", "config", "[", "'SQLite3'", "]", "[", "'busy_timeout'", "]", ";", "$", "openFlags", "=", "$", "this", "->", "config", "[", "'SQLite3'", "]", "[", "'open_flags'", "]", ";", "$", "encryptionKey", "=", "$", "this", "->", "config", "[", "'SQLite3'", "]", "[", "'encryption_key'", "]", ";", "// Connecting", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "$", "this", "->", "link", "=", "new", "SQLite3", "(", "$", "filename", ",", "$", "openFlags", ",", "$", "encryptionKey", ")", ";", "if", "(", "$", "this", "->", "link", ")", "{", "$", "this", "->", "connected", "=", "true", ";", "$", "this", "->", "link", "->", "busyTimeout", "(", "$", "busyTimeout", ")", ";", "// Set database and connection options.", "$", "this", "->", "link", "->", "exec", "(", "\"PRAGMA encoding = \\\"UTF-8\\\";\"", ")", ";", "$", "this", "->", "link", "->", "exec", "(", "\"PRAGMA foreign_keys = 1;\"", ")", ";", "$", "this", "->", "link", "->", "exec", "(", "\"PRAGMA case_sensitive_like = 1;\"", ")", ";", "// Create the preg_match and regexp functions.", "// TODO(hperrin): Add more of these functions to get rid of post-query checks.", "$", "this", "->", "link", "->", "createFunction", "(", "'preg_match'", ",", "'preg_match'", ",", "2", ",", "SQLITE3_DETERMINISTIC", ")", ";", "$", "this", "->", "link", "->", "createFunction", "(", "'regexp'", ",", "function", "(", "$", "pattern", ",", "$", "subject", ")", "{", "return", "!", "!", "$", "this", "->", "posixRegexMatch", "(", "$", "pattern", ",", "$", "subject", ")", ";", "}", ",", "2", ",", "SQLITE3_DETERMINISTIC", ")", ";", "}", "else", "{", "$", "this", "->", "connected", "=", "false", ";", "if", "(", "$", "filename", "===", "':memory:'", ")", "{", "throw", "new", "Exceptions", "\\", "NotConfiguredException", "(", ")", ";", "}", "else", "{", "throw", "new", "Exceptions", "\\", "UnableToConnectException", "(", "'Could not connect.'", ")", ";", "}", "}", "}", "return", "$", "this", "->", "connected", ";", "}" ]
Connect to the SQLite3 database. @return bool Whether this instance is connected to a SQLite3 database after the method has run.
[ "Connect", "to", "the", "SQLite3", "database", "." ]
3c18dbf45c2750d07c798e14534dba87387beeba
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/SQLite3Driver.php#L47-L86
23,908
sciactive/nymph-server
src/Drivers/SQLite3Driver.php
SQLite3Driver.disconnect
public function disconnect() { if ($this->connected) { if (is_a($this->link, 'SQLite3')) { $this->link->exec("PRAGMA optimize;"); $this->link->close(); } $this->connected = false; } return $this->connected; }
php
public function disconnect() { if ($this->connected) { if (is_a($this->link, 'SQLite3')) { $this->link->exec("PRAGMA optimize;"); $this->link->close(); } $this->connected = false; } return $this->connected; }
[ "public", "function", "disconnect", "(", ")", "{", "if", "(", "$", "this", "->", "connected", ")", "{", "if", "(", "is_a", "(", "$", "this", "->", "link", ",", "'SQLite3'", ")", ")", "{", "$", "this", "->", "link", "->", "exec", "(", "\"PRAGMA optimize;\"", ")", ";", "$", "this", "->", "link", "->", "close", "(", ")", ";", "}", "$", "this", "->", "connected", "=", "false", ";", "}", "return", "$", "this", "->", "connected", ";", "}" ]
Disconnect from the SQLite3 database. @return bool Whether this instance is connected to a SQLite3 database after the method has run.
[ "Disconnect", "from", "the", "SQLite3", "database", "." ]
3c18dbf45c2750d07c798e14534dba87387beeba
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/SQLite3Driver.php#L94-L103
23,909
surebert/surebert-framework
src/sb/Email/Reader.php
Reader.log
public function log($message) { if (!empty($this->log_file)) { //echo $message; \file_put_contents($this->log_file, "\n" . $message, \FILE_APPEND); } }
php
public function log($message) { if (!empty($this->log_file)) { //echo $message; \file_put_contents($this->log_file, "\n" . $message, \FILE_APPEND); } }
[ "public", "function", "log", "(", "$", "message", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "log_file", ")", ")", "{", "//echo $message;", "\\", "file_put_contents", "(", "$", "this", "->", "log_file", ",", "\"\\n\"", ".", "$", "message", ",", "\\", "FILE_APPEND", ")", ";", "}", "}" ]
Logs messages to a log file if it is set @param string $message
[ "Logs", "messages", "to", "a", "log", "file", "if", "it", "is", "set" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Reader.php#L160-L167
23,910
surebert/surebert-framework
src/sb/Email/Reader.php
Reader.open
public function open() { //check for mail $host = "{" . $this->host . ":" . $this->port . "/" . $this->protocol . "/notls}INBOX"; //open the mail box for reading $this->inbox = \imap_open($host, $this->address, $this->pass); if (!$this->inbox) { $this->connected = 0; } else { $this->connected = 1; } return $this->connected; }
php
public function open() { //check for mail $host = "{" . $this->host . ":" . $this->port . "/" . $this->protocol . "/notls}INBOX"; //open the mail box for reading $this->inbox = \imap_open($host, $this->address, $this->pass); if (!$this->inbox) { $this->connected = 0; } else { $this->connected = 1; } return $this->connected; }
[ "public", "function", "open", "(", ")", "{", "//check for mail", "$", "host", "=", "\"{\"", ".", "$", "this", "->", "host", ".", "\":\"", ".", "$", "this", "->", "port", ".", "\"/\"", ".", "$", "this", "->", "protocol", ".", "\"/notls}INBOX\"", ";", "//open the mail box for reading", "$", "this", "->", "inbox", "=", "\\", "imap_open", "(", "$", "host", ",", "$", "this", "->", "address", ",", "$", "this", "->", "pass", ")", ";", "if", "(", "!", "$", "this", "->", "inbox", ")", "{", "$", "this", "->", "connected", "=", "0", ";", "}", "else", "{", "$", "this", "->", "connected", "=", "1", ";", "}", "return", "$", "this", "->", "connected", ";", "}" ]
Opens the inbox and returns the connection status
[ "Opens", "the", "inbox", "and", "returns", "the", "connection", "status" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Reader.php#L173-L191
23,911
surebert/surebert-framework
src/sb/Email/Reader.php
Reader.close
public function close($expunge) { //expunge emails set to delete if delete_after_read is set if ($expunge) { \imap_close($this->inbox, CL_EXPUNGE); } else { \imap_close($this->inbox); } }
php
public function close($expunge) { //expunge emails set to delete if delete_after_read is set if ($expunge) { \imap_close($this->inbox, CL_EXPUNGE); } else { \imap_close($this->inbox); } }
[ "public", "function", "close", "(", "$", "expunge", ")", "{", "//expunge emails set to delete if delete_after_read is set", "if", "(", "$", "expunge", ")", "{", "\\", "imap_close", "(", "$", "this", "->", "inbox", ",", "CL_EXPUNGE", ")", ";", "}", "else", "{", "\\", "imap_close", "(", "$", "this", "->", "inbox", ")", ";", "}", "}" ]
Closes the inbox and expunges deleted messages if expunge is true @param boolean $expunge true expunges
[ "Closes", "the", "inbox", "and", "expunges", "deleted", "messages", "if", "expunge", "is", "true" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Reader.php#L198-L206
23,912
surebert/surebert-framework
src/sb/Email/Reader.php
Reader.parseHeaderInfo
public function parseHeaderInfo(Email &$email, $header) { //map the most useful header info to the email object itself $email->all_headers = $header; $email->subject = $header->subject; $email->to = $header->to[0]->mailbox . '@' . $header->to[0]->host; $email->from = $header->from[0]->mailbox . '@' . $header->from[0]->host; $email->reply_to = $header->reply_to[0]->mailbox . '@' . $header->reply_to[0]->host; $email->sender = $header->sender[0]->mailbox . '@' . $header->sender[0]->host; $email->size = $header->Size; $email->date = $header->date; $email->timestamp = $header->udate; $email->message_id = $header->message_id; if ($header->Deleted == 'D') { $email->deleted = 1; } //add the entire header in case we want access to custom headers later $this->headers = $header; }
php
public function parseHeaderInfo(Email &$email, $header) { //map the most useful header info to the email object itself $email->all_headers = $header; $email->subject = $header->subject; $email->to = $header->to[0]->mailbox . '@' . $header->to[0]->host; $email->from = $header->from[0]->mailbox . '@' . $header->from[0]->host; $email->reply_to = $header->reply_to[0]->mailbox . '@' . $header->reply_to[0]->host; $email->sender = $header->sender[0]->mailbox . '@' . $header->sender[0]->host; $email->size = $header->Size; $email->date = $header->date; $email->timestamp = $header->udate; $email->message_id = $header->message_id; if ($header->Deleted == 'D') { $email->deleted = 1; } //add the entire header in case we want access to custom headers later $this->headers = $header; }
[ "public", "function", "parseHeaderInfo", "(", "Email", "&", "$", "email", ",", "$", "header", ")", "{", "//map the most useful header info to the email object itself", "$", "email", "->", "all_headers", "=", "$", "header", ";", "$", "email", "->", "subject", "=", "$", "header", "->", "subject", ";", "$", "email", "->", "to", "=", "$", "header", "->", "to", "[", "0", "]", "->", "mailbox", ".", "'@'", ".", "$", "header", "->", "to", "[", "0", "]", "->", "host", ";", "$", "email", "->", "from", "=", "$", "header", "->", "from", "[", "0", "]", "->", "mailbox", ".", "'@'", ".", "$", "header", "->", "from", "[", "0", "]", "->", "host", ";", "$", "email", "->", "reply_to", "=", "$", "header", "->", "reply_to", "[", "0", "]", "->", "mailbox", ".", "'@'", ".", "$", "header", "->", "reply_to", "[", "0", "]", "->", "host", ";", "$", "email", "->", "sender", "=", "$", "header", "->", "sender", "[", "0", "]", "->", "mailbox", ".", "'@'", ".", "$", "header", "->", "sender", "[", "0", "]", "->", "host", ";", "$", "email", "->", "size", "=", "$", "header", "->", "Size", ";", "$", "email", "->", "date", "=", "$", "header", "->", "date", ";", "$", "email", "->", "timestamp", "=", "$", "header", "->", "udate", ";", "$", "email", "->", "message_id", "=", "$", "header", "->", "message_id", ";", "if", "(", "$", "header", "->", "Deleted", "==", "'D'", ")", "{", "$", "email", "->", "deleted", "=", "1", ";", "}", "//add the entire header in case we want access to custom headers later", "$", "this", "->", "headers", "=", "$", "header", ";", "}" ]
Parses header information from an email and returns it to as properties of the email object @param sb_Email $email @param object $header
[ "Parses", "header", "information", "from", "an", "email", "and", "returns", "it", "to", "as", "properties", "of", "the", "email", "object" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Reader.php#L255-L275
23,913
surebert/surebert-framework
src/sb/Email/Reader.php
Reader.examinePart
private function examinePart(&$email, $part) { //echo '<br />'.$part->part_id.' '.$part->type.' '.$part->dparameters[0]->value; //get subtype JPEG, WAV, HTML, PLAIN, etc $subtype = \strtolower($part->subtype); //get encoding 0 = 7bit, 1= 8bit, 2=binary, 3=base64, 4=quoted prinatble, 5=other $encoding = $part->encoding; switch ($subtype) { case 'plain': if (empty($email->body)) { $email->body_encoding = $encoding; $email->body = imap_fetchbody($this->inbox, $email->index, $part->part_id); } break; case 'html': $email->body_HTML = imap_fetchbody($this->inbox, $email->index, $part->part_id); break; case 'applefile': case 'gif': case 'png': case 'jpg': case 'jpeg': case 'wav': case 'mp3': case 'mp4': case 'flv': if ($part->type == 5) { $attachment = new Email_Attachment(); $attachment->sizeK = $part->bytes / 1000; $attachment->subtype = $subtype; $attachment->type = $part->type; $attachment->name = $part->dparameters[0]->value; //change jpeg into jpg $attachment->name = \str_ireplace('jpeg', 'jpg', $attachment->name); $attachment->extension = \strtolower(end(explode(".", $attachment->name))); $attachment->contents = \imap_fetchbody($this->inbox, $email->index, $part->part_id); //decode base64 contents if ($part->encoding == 3) { $attachment->contents = \imap_base64($attachment->contents); } $attachment->encoding = $part->encoding; $email->attachments[] = $attachment; } } }
php
private function examinePart(&$email, $part) { //echo '<br />'.$part->part_id.' '.$part->type.' '.$part->dparameters[0]->value; //get subtype JPEG, WAV, HTML, PLAIN, etc $subtype = \strtolower($part->subtype); //get encoding 0 = 7bit, 1= 8bit, 2=binary, 3=base64, 4=quoted prinatble, 5=other $encoding = $part->encoding; switch ($subtype) { case 'plain': if (empty($email->body)) { $email->body_encoding = $encoding; $email->body = imap_fetchbody($this->inbox, $email->index, $part->part_id); } break; case 'html': $email->body_HTML = imap_fetchbody($this->inbox, $email->index, $part->part_id); break; case 'applefile': case 'gif': case 'png': case 'jpg': case 'jpeg': case 'wav': case 'mp3': case 'mp4': case 'flv': if ($part->type == 5) { $attachment = new Email_Attachment(); $attachment->sizeK = $part->bytes / 1000; $attachment->subtype = $subtype; $attachment->type = $part->type; $attachment->name = $part->dparameters[0]->value; //change jpeg into jpg $attachment->name = \str_ireplace('jpeg', 'jpg', $attachment->name); $attachment->extension = \strtolower(end(explode(".", $attachment->name))); $attachment->contents = \imap_fetchbody($this->inbox, $email->index, $part->part_id); //decode base64 contents if ($part->encoding == 3) { $attachment->contents = \imap_base64($attachment->contents); } $attachment->encoding = $part->encoding; $email->attachments[] = $attachment; } } }
[ "private", "function", "examinePart", "(", "&", "$", "email", ",", "$", "part", ")", "{", "//echo '<br />'.$part->part_id.' '.$part->type.' '.$part->dparameters[0]->value;", "//get subtype JPEG, WAV, HTML, PLAIN, etc", "$", "subtype", "=", "\\", "strtolower", "(", "$", "part", "->", "subtype", ")", ";", "//get encoding 0 = 7bit, 1= 8bit, 2=binary, 3=base64, 4=quoted prinatble, 5=other", "$", "encoding", "=", "$", "part", "->", "encoding", ";", "switch", "(", "$", "subtype", ")", "{", "case", "'plain'", ":", "if", "(", "empty", "(", "$", "email", "->", "body", ")", ")", "{", "$", "email", "->", "body_encoding", "=", "$", "encoding", ";", "$", "email", "->", "body", "=", "imap_fetchbody", "(", "$", "this", "->", "inbox", ",", "$", "email", "->", "index", ",", "$", "part", "->", "part_id", ")", ";", "}", "break", ";", "case", "'html'", ":", "$", "email", "->", "body_HTML", "=", "imap_fetchbody", "(", "$", "this", "->", "inbox", ",", "$", "email", "->", "index", ",", "$", "part", "->", "part_id", ")", ";", "break", ";", "case", "'applefile'", ":", "case", "'gif'", ":", "case", "'png'", ":", "case", "'jpg'", ":", "case", "'jpeg'", ":", "case", "'wav'", ":", "case", "'mp3'", ":", "case", "'mp4'", ":", "case", "'flv'", ":", "if", "(", "$", "part", "->", "type", "==", "5", ")", "{", "$", "attachment", "=", "new", "Email_Attachment", "(", ")", ";", "$", "attachment", "->", "sizeK", "=", "$", "part", "->", "bytes", "/", "1000", ";", "$", "attachment", "->", "subtype", "=", "$", "subtype", ";", "$", "attachment", "->", "type", "=", "$", "part", "->", "type", ";", "$", "attachment", "->", "name", "=", "$", "part", "->", "dparameters", "[", "0", "]", "->", "value", ";", "//change jpeg into jpg", "$", "attachment", "->", "name", "=", "\\", "str_ireplace", "(", "'jpeg'", ",", "'jpg'", ",", "$", "attachment", "->", "name", ")", ";", "$", "attachment", "->", "extension", "=", "\\", "strtolower", "(", "end", "(", "explode", "(", "\".\"", ",", "$", "attachment", "->", "name", ")", ")", ")", ";", "$", "attachment", "->", "contents", "=", "\\", "imap_fetchbody", "(", "$", "this", "->", "inbox", ",", "$", "email", "->", "index", ",", "$", "part", "->", "part_id", ")", ";", "//decode base64 contents", "if", "(", "$", "part", "->", "encoding", "==", "3", ")", "{", "$", "attachment", "->", "contents", "=", "\\", "imap_base64", "(", "$", "attachment", "->", "contents", ")", ";", "}", "$", "attachment", "->", "encoding", "=", "$", "part", "->", "encoding", ";", "$", "email", "->", "attachments", "[", "]", "=", "$", "attachment", ";", "}", "}", "}" ]
Check in an email part for attachments and data @param \sb\Email $email The email being examined @param object $part The current part @param string $part_id The id of the part
[ "Check", "in", "an", "email", "part", "for", "attachments", "and", "data" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Reader.php#L284-L337
23,914
surebert/surebert-framework
src/sb/Email/Reader.php
Reader.fetchMessages
public function fetchMessages() { //count the messages $this->countMessages(); //if there are zero emails report this to the user if ($this->email_count == 0) { $this->log('There are no emails to process!'); return false; } $this->log($this->email_count . ' ' . \Strings::pluralize($this->email_count, 'email') . ' to process.'); for ($i = 1; $i < $this->email_count + 1; $i++) { $email = new Email; //set the message index in case we want to delete it later $email->index = $i; //get all the header info $this->parseHeaderInfo($email, imap_headerinfo($this->inbox, $i)); $structure = \imap_fetchstructure($this->inbox, $i); //the type of email format $email->subtype = \strtolower($structure->subtype); $email->structure = $structure; //if the email is divided into parts, html, plain, attachments, etc if (isset($structure->parts)) { $part_id = 1; foreach ($structure->parts as $part) { //get type 0 = text, 1 = multipart, 2 = message, //3 = application, 4 = audio, 5= image, 6= video, 7 = other $type = $part->type; //multipart $sub_id = 1; if ($type == 1 && isset($part->parts)) { foreach ($part->parts as $part) { $part->part_id = $part_id . '.' . $sub_id; $this->examinePart($email, $part); $sub_id++; } } else { $part->part_id = $part_id; $this->examinePart($email, $part, $part_id); } $part_id++; } } else { //it is just a plain text email $email->body = \imap_fetchbody($this->inbox, $i, 1); $email->body_encoding = $structure->encoding; } //if the body is base64 encoded, decode it if ($email->body_encoding == 3) { $email->body = \base64_decode($email->body); } $this->log(print_r($email, 1)); //store the email $this->emails[] = $email; } }
php
public function fetchMessages() { //count the messages $this->countMessages(); //if there are zero emails report this to the user if ($this->email_count == 0) { $this->log('There are no emails to process!'); return false; } $this->log($this->email_count . ' ' . \Strings::pluralize($this->email_count, 'email') . ' to process.'); for ($i = 1; $i < $this->email_count + 1; $i++) { $email = new Email; //set the message index in case we want to delete it later $email->index = $i; //get all the header info $this->parseHeaderInfo($email, imap_headerinfo($this->inbox, $i)); $structure = \imap_fetchstructure($this->inbox, $i); //the type of email format $email->subtype = \strtolower($structure->subtype); $email->structure = $structure; //if the email is divided into parts, html, plain, attachments, etc if (isset($structure->parts)) { $part_id = 1; foreach ($structure->parts as $part) { //get type 0 = text, 1 = multipart, 2 = message, //3 = application, 4 = audio, 5= image, 6= video, 7 = other $type = $part->type; //multipart $sub_id = 1; if ($type == 1 && isset($part->parts)) { foreach ($part->parts as $part) { $part->part_id = $part_id . '.' . $sub_id; $this->examinePart($email, $part); $sub_id++; } } else { $part->part_id = $part_id; $this->examinePart($email, $part, $part_id); } $part_id++; } } else { //it is just a plain text email $email->body = \imap_fetchbody($this->inbox, $i, 1); $email->body_encoding = $structure->encoding; } //if the body is base64 encoded, decode it if ($email->body_encoding == 3) { $email->body = \base64_decode($email->body); } $this->log(print_r($email, 1)); //store the email $this->emails[] = $email; } }
[ "public", "function", "fetchMessages", "(", ")", "{", "//count the messages", "$", "this", "->", "countMessages", "(", ")", ";", "//if there are zero emails report this to the user", "if", "(", "$", "this", "->", "email_count", "==", "0", ")", "{", "$", "this", "->", "log", "(", "'There are no emails to process!'", ")", ";", "return", "false", ";", "}", "$", "this", "->", "log", "(", "$", "this", "->", "email_count", ".", "' '", ".", "\\", "Strings", "::", "pluralize", "(", "$", "this", "->", "email_count", ",", "'email'", ")", ".", "' to process.'", ")", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "$", "this", "->", "email_count", "+", "1", ";", "$", "i", "++", ")", "{", "$", "email", "=", "new", "Email", ";", "//set the message index in case we want to delete it later", "$", "email", "->", "index", "=", "$", "i", ";", "//get all the header info", "$", "this", "->", "parseHeaderInfo", "(", "$", "email", ",", "imap_headerinfo", "(", "$", "this", "->", "inbox", ",", "$", "i", ")", ")", ";", "$", "structure", "=", "\\", "imap_fetchstructure", "(", "$", "this", "->", "inbox", ",", "$", "i", ")", ";", "//the type of email format", "$", "email", "->", "subtype", "=", "\\", "strtolower", "(", "$", "structure", "->", "subtype", ")", ";", "$", "email", "->", "structure", "=", "$", "structure", ";", "//if the email is divided into parts, html, plain, attachments, etc", "if", "(", "isset", "(", "$", "structure", "->", "parts", ")", ")", "{", "$", "part_id", "=", "1", ";", "foreach", "(", "$", "structure", "->", "parts", "as", "$", "part", ")", "{", "//get type 0 = text, 1 = multipart, 2 = message,", "//3 = application, 4 = audio, 5= image, 6= video, 7 = other", "$", "type", "=", "$", "part", "->", "type", ";", "//multipart", "$", "sub_id", "=", "1", ";", "if", "(", "$", "type", "==", "1", "&&", "isset", "(", "$", "part", "->", "parts", ")", ")", "{", "foreach", "(", "$", "part", "->", "parts", "as", "$", "part", ")", "{", "$", "part", "->", "part_id", "=", "$", "part_id", ".", "'.'", ".", "$", "sub_id", ";", "$", "this", "->", "examinePart", "(", "$", "email", ",", "$", "part", ")", ";", "$", "sub_id", "++", ";", "}", "}", "else", "{", "$", "part", "->", "part_id", "=", "$", "part_id", ";", "$", "this", "->", "examinePart", "(", "$", "email", ",", "$", "part", ",", "$", "part_id", ")", ";", "}", "$", "part_id", "++", ";", "}", "}", "else", "{", "//it is just a plain text email", "$", "email", "->", "body", "=", "\\", "imap_fetchbody", "(", "$", "this", "->", "inbox", ",", "$", "i", ",", "1", ")", ";", "$", "email", "->", "body_encoding", "=", "$", "structure", "->", "encoding", ";", "}", "//if the body is base64 encoded, decode it", "if", "(", "$", "email", "->", "body_encoding", "==", "3", ")", "{", "$", "email", "->", "body", "=", "\\", "base64_decode", "(", "$", "email", "->", "body", ")", ";", "}", "$", "this", "->", "log", "(", "print_r", "(", "$", "email", ",", "1", ")", ")", ";", "//store the email", "$", "this", "->", "emails", "[", "]", "=", "$", "email", ";", "}", "}" ]
Fetches all the messages in an inbox and put them in the emails array @return returns the array of all email objects found
[ "Fetches", "all", "the", "messages", "in", "an", "inbox", "and", "put", "them", "in", "the", "emails", "array" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Reader.php#L344-L421
23,915
Litecms/Team
src/Http/Controllers/TeamResourceController.php
TeamResourceController.index
public function index(TeamRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\Team\Repositories\Presenter\TeamPresenter::class) ->$function(); } $teams = $this->repository->paginate(); return $this->response->title(trans('team::team.names')) ->view('team::team.index', true) ->data(compact('teams')) ->output(); }
php
public function index(TeamRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\Team\Repositories\Presenter\TeamPresenter::class) ->$function(); } $teams = $this->repository->paginate(); return $this->response->title(trans('team::team.names')) ->view('team::team.index', true) ->data(compact('teams')) ->output(); }
[ "public", "function", "index", "(", "TeamRequest", "$", "request", ")", "{", "$", "view", "=", "$", "this", "->", "response", "->", "theme", "->", "listView", "(", ")", ";", "if", "(", "$", "this", "->", "response", "->", "typeIs", "(", "'json'", ")", ")", "{", "$", "function", "=", "camel_case", "(", "'get-'", ".", "$", "view", ")", ";", "return", "$", "this", "->", "repository", "->", "setPresenter", "(", "\\", "Litecms", "\\", "Team", "\\", "Repositories", "\\", "Presenter", "\\", "TeamPresenter", "::", "class", ")", "->", "$", "function", "(", ")", ";", "}", "$", "teams", "=", "$", "this", "->", "repository", "->", "paginate", "(", ")", ";", "return", "$", "this", "->", "response", "->", "title", "(", "trans", "(", "'team::team.names'", ")", ")", "->", "view", "(", "'team::team.index'", ",", "true", ")", "->", "data", "(", "compact", "(", "'teams'", ")", ")", "->", "output", "(", ")", ";", "}" ]
Display a list of team. @return Response
[ "Display", "a", "list", "of", "team", "." ]
a444a6a6604c969df138ac0eb57ed5f4696b0f00
https://github.com/Litecms/Team/blob/a444a6a6604c969df138ac0eb57ed5f4696b0f00/src/Http/Controllers/TeamResourceController.php#L38-L55
23,916
Litecms/Team
src/Http/Controllers/TeamResourceController.php
TeamResourceController.show
public function show(TeamRequest $request, Team $team) { if ($team->exists) { $view = 'team::team.show'; } else { $view = 'team::team.new'; } return $this->response->title(trans('app.view') . ' ' . trans('team::team.name')) ->data(compact('team')) ->view($view, true) ->output(); }
php
public function show(TeamRequest $request, Team $team) { if ($team->exists) { $view = 'team::team.show'; } else { $view = 'team::team.new'; } return $this->response->title(trans('app.view') . ' ' . trans('team::team.name')) ->data(compact('team')) ->view($view, true) ->output(); }
[ "public", "function", "show", "(", "TeamRequest", "$", "request", ",", "Team", "$", "team", ")", "{", "if", "(", "$", "team", "->", "exists", ")", "{", "$", "view", "=", "'team::team.show'", ";", "}", "else", "{", "$", "view", "=", "'team::team.new'", ";", "}", "return", "$", "this", "->", "response", "->", "title", "(", "trans", "(", "'app.view'", ")", ".", "' '", ".", "trans", "(", "'team::team.name'", ")", ")", "->", "data", "(", "compact", "(", "'team'", ")", ")", "->", "view", "(", "$", "view", ",", "true", ")", "->", "output", "(", ")", ";", "}" ]
Display team. @param Request $request @param Model $team @return Response
[ "Display", "team", "." ]
a444a6a6604c969df138ac0eb57ed5f4696b0f00
https://github.com/Litecms/Team/blob/a444a6a6604c969df138ac0eb57ed5f4696b0f00/src/Http/Controllers/TeamResourceController.php#L65-L78
23,917
Litecms/Team
src/Http/Controllers/TeamResourceController.php
TeamResourceController.edit
public function edit(TeamRequest $request, Team $team) { return $this->response->title(trans('app.edit') . ' ' . trans('team::team.name')) ->view('team::team.edit', true) ->data(compact('team')) ->output(); }
php
public function edit(TeamRequest $request, Team $team) { return $this->response->title(trans('app.edit') . ' ' . trans('team::team.name')) ->view('team::team.edit', true) ->data(compact('team')) ->output(); }
[ "public", "function", "edit", "(", "TeamRequest", "$", "request", ",", "Team", "$", "team", ")", "{", "return", "$", "this", "->", "response", "->", "title", "(", "trans", "(", "'app.edit'", ")", ".", "' '", ".", "trans", "(", "'team::team.name'", ")", ")", "->", "view", "(", "'team::team.edit'", ",", "true", ")", "->", "data", "(", "compact", "(", "'team'", ")", ")", "->", "output", "(", ")", ";", "}" ]
Show team for editing. @param Request $request @param Model $team @return Response
[ "Show", "team", "for", "editing", "." ]
a444a6a6604c969df138ac0eb57ed5f4696b0f00
https://github.com/Litecms/Team/blob/a444a6a6604c969df138ac0eb57ed5f4696b0f00/src/Http/Controllers/TeamResourceController.php#L135-L141
23,918
Litecms/Team
src/Http/Controllers/TeamResourceController.php
TeamResourceController.update
public function update(TeamRequest $request, Team $team) { try { $attributes = $request->all(); $team->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('team::team.name')])) ->code(204) ->status('success') ->url(guard_url('team/team/' . $team->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('team/team/' . $team->getRouteKey())) ->redirect(); } }
php
public function update(TeamRequest $request, Team $team) { try { $attributes = $request->all(); $team->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('team::team.name')])) ->code(204) ->status('success') ->url(guard_url('team/team/' . $team->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('team/team/' . $team->getRouteKey())) ->redirect(); } }
[ "public", "function", "update", "(", "TeamRequest", "$", "request", ",", "Team", "$", "team", ")", "{", "try", "{", "$", "attributes", "=", "$", "request", "->", "all", "(", ")", ";", "$", "team", "->", "update", "(", "$", "attributes", ")", ";", "return", "$", "this", "->", "response", "->", "message", "(", "trans", "(", "'messages.success.updated'", ",", "[", "'Module'", "=>", "trans", "(", "'team::team.name'", ")", "]", ")", ")", "->", "code", "(", "204", ")", "->", "status", "(", "'success'", ")", "->", "url", "(", "guard_url", "(", "'team/team/'", ".", "$", "team", "->", "getRouteKey", "(", ")", ")", ")", "->", "redirect", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "$", "this", "->", "response", "->", "message", "(", "$", "e", "->", "getMessage", "(", ")", ")", "->", "code", "(", "400", ")", "->", "status", "(", "'error'", ")", "->", "url", "(", "guard_url", "(", "'team/team/'", ".", "$", "team", "->", "getRouteKey", "(", ")", ")", ")", "->", "redirect", "(", ")", ";", "}", "}" ]
Update the team. @param Request $request @param Model $team @return Response
[ "Update", "the", "team", "." ]
a444a6a6604c969df138ac0eb57ed5f4696b0f00
https://github.com/Litecms/Team/blob/a444a6a6604c969df138ac0eb57ed5f4696b0f00/src/Http/Controllers/TeamResourceController.php#L151-L170
23,919
Litecms/Team
src/Http/Controllers/TeamResourceController.php
TeamResourceController.destroy
public function destroy(TeamRequest $request, Team $team) { try { $team->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('team::team.name')])) ->code(202) ->status('success') ->url(guard_url('team/team/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('team/team/' . $team->getRouteKey())) ->redirect(); } }
php
public function destroy(TeamRequest $request, Team $team) { try { $team->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('team::team.name')])) ->code(202) ->status('success') ->url(guard_url('team/team/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('team/team/' . $team->getRouteKey())) ->redirect(); } }
[ "public", "function", "destroy", "(", "TeamRequest", "$", "request", ",", "Team", "$", "team", ")", "{", "try", "{", "$", "team", "->", "delete", "(", ")", ";", "return", "$", "this", "->", "response", "->", "message", "(", "trans", "(", "'messages.success.deleted'", ",", "[", "'Module'", "=>", "trans", "(", "'team::team.name'", ")", "]", ")", ")", "->", "code", "(", "202", ")", "->", "status", "(", "'success'", ")", "->", "url", "(", "guard_url", "(", "'team/team/0'", ")", ")", "->", "redirect", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "$", "this", "->", "response", "->", "message", "(", "$", "e", "->", "getMessage", "(", ")", ")", "->", "code", "(", "400", ")", "->", "status", "(", "'error'", ")", "->", "url", "(", "guard_url", "(", "'team/team/'", ".", "$", "team", "->", "getRouteKey", "(", ")", ")", ")", "->", "redirect", "(", ")", ";", "}", "}" ]
Remove the team. @param Model $team @return Response
[ "Remove", "the", "team", "." ]
a444a6a6604c969df138ac0eb57ed5f4696b0f00
https://github.com/Litecms/Team/blob/a444a6a6604c969df138ac0eb57ed5f4696b0f00/src/Http/Controllers/TeamResourceController.php#L179-L199
23,920
chrometoasters/silverstripe-image-quality
src/Extensions/ImageQualityExtension.php
ImageQualityExtension.Quality
public function Quality($quality) { // Generate variant key $variant = $this->owner->variantName(__FUNCTION__, $quality); // Instruct the backend to search for an existing variant and use the callback to provide it if it does not exist. return $this->owner->manipulateImage($variant, function (Image_Backend $backend) use ($quality) { $backendClone = clone $backend; $backendClone->setQuality($quality); return $backendClone; }); }
php
public function Quality($quality) { // Generate variant key $variant = $this->owner->variantName(__FUNCTION__, $quality); // Instruct the backend to search for an existing variant and use the callback to provide it if it does not exist. return $this->owner->manipulateImage($variant, function (Image_Backend $backend) use ($quality) { $backendClone = clone $backend; $backendClone->setQuality($quality); return $backendClone; }); }
[ "public", "function", "Quality", "(", "$", "quality", ")", "{", "// Generate variant key", "$", "variant", "=", "$", "this", "->", "owner", "->", "variantName", "(", "__FUNCTION__", ",", "$", "quality", ")", ";", "// Instruct the backend to search for an existing variant and use the callback to provide it if it does not exist.", "return", "$", "this", "->", "owner", "->", "manipulateImage", "(", "$", "variant", ",", "function", "(", "Image_Backend", "$", "backend", ")", "use", "(", "$", "quality", ")", "{", "$", "backendClone", "=", "clone", "$", "backend", ";", "$", "backendClone", "->", "setQuality", "(", "$", "quality", ")", ";", "return", "$", "backendClone", ";", "}", ")", ";", "}" ]
This function adjusts the quality of of an image using SilverStripe 4 syntax. @param $quality @return mixed
[ "This", "function", "adjusts", "the", "quality", "of", "of", "an", "image", "using", "SilverStripe", "4", "syntax", "." ]
73947f9def3a596918059d5f472a212bc80d9fbc
https://github.com/chrometoasters/silverstripe-image-quality/blob/73947f9def3a596918059d5f472a212bc80d9fbc/src/Extensions/ImageQualityExtension.php#L19-L31
23,921
FriendsOfApi/phraseapp
src/Api/HttpApi.php
HttpApi.httpPatch
protected function httpPatch(string $path, $body, array $requestHeaders = []): ResponseInterface { $requestHeaders['Content-Type'] = 'application/json'; return $response = $this->httpClient->sendRequest( $this->requestBuilder->create('PATCH', $path, $requestHeaders, json_encode($body)) ); }
php
protected function httpPatch(string $path, $body, array $requestHeaders = []): ResponseInterface { $requestHeaders['Content-Type'] = 'application/json'; return $response = $this->httpClient->sendRequest( $this->requestBuilder->create('PATCH', $path, $requestHeaders, json_encode($body)) ); }
[ "protected", "function", "httpPatch", "(", "string", "$", "path", ",", "$", "body", ",", "array", "$", "requestHeaders", "=", "[", "]", ")", ":", "ResponseInterface", "{", "$", "requestHeaders", "[", "'Content-Type'", "]", "=", "'application/json'", ";", "return", "$", "response", "=", "$", "this", "->", "httpClient", "->", "sendRequest", "(", "$", "this", "->", "requestBuilder", "->", "create", "(", "'PATCH'", ",", "$", "path", ",", "$", "requestHeaders", ",", "json_encode", "(", "$", "body", ")", ")", ")", ";", "}" ]
Send a PATCH request with json encoded data. @param string $path Request path @param array|string $body Request body @param array $requestHeaders Request headers @return ResponseInterface
[ "Send", "a", "PATCH", "request", "with", "json", "encoded", "data", "." ]
1553bf857eb0858f9a7eb905b085864d24f80886
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Api/HttpApi.php#L151-L158
23,922
impensavel/essence
src/XML.php
XML.getCurrentNode
protected function getCurrentNode() { // Clear the libXML error buffer libxml_clear_errors(); $node = @$this->reader->expand(); $error = libxml_get_last_error(); if ($error instanceof LibXMLError) { // Only throw exceptions when the level is ERROR or FATAL if ($error->level > LIBXML_ERR_WARNING) { throw new EssenceException(sprintf('%s @ line #%d [%s]', trim($error->message), $error->line, $this->current), $error->code); } } try { return $this->doc->importNode($node, true); } catch (DOMException $e) { throw new EssenceException('Node import failed', 0, $e); } }
php
protected function getCurrentNode() { // Clear the libXML error buffer libxml_clear_errors(); $node = @$this->reader->expand(); $error = libxml_get_last_error(); if ($error instanceof LibXMLError) { // Only throw exceptions when the level is ERROR or FATAL if ($error->level > LIBXML_ERR_WARNING) { throw new EssenceException(sprintf('%s @ line #%d [%s]', trim($error->message), $error->line, $this->current), $error->code); } } try { return $this->doc->importNode($node, true); } catch (DOMException $e) { throw new EssenceException('Node import failed', 0, $e); } }
[ "protected", "function", "getCurrentNode", "(", ")", "{", "// Clear the libXML error buffer", "libxml_clear_errors", "(", ")", ";", "$", "node", "=", "@", "$", "this", "->", "reader", "->", "expand", "(", ")", ";", "$", "error", "=", "libxml_get_last_error", "(", ")", ";", "if", "(", "$", "error", "instanceof", "LibXMLError", ")", "{", "// Only throw exceptions when the level is ERROR or FATAL", "if", "(", "$", "error", "->", "level", ">", "LIBXML_ERR_WARNING", ")", "{", "throw", "new", "EssenceException", "(", "sprintf", "(", "'%s @ line #%d [%s]'", ",", "trim", "(", "$", "error", "->", "message", ")", ",", "$", "error", "->", "line", ",", "$", "this", "->", "current", ")", ",", "$", "error", "->", "code", ")", ";", "}", "}", "try", "{", "return", "$", "this", "->", "doc", "->", "importNode", "(", "$", "node", ",", "true", ")", ";", "}", "catch", "(", "DOMException", "$", "e", ")", "{", "throw", "new", "EssenceException", "(", "'Node import failed'", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Get the current node @throws EssenceException @return DOMNode
[ "Get", "the", "current", "node" ]
e74969e55ac889e8c2cab9a915f82e93a72e629e
https://github.com/impensavel/essence/blob/e74969e55ac889e8c2cab9a915f82e93a72e629e/src/XML.php#L118-L139
23,923
impensavel/essence
src/XML.php
XML.nextElement
protected function nextElement() { do { if (! $this->reader->read()) { return false; } // Pop previous levels from the stack $this->stack = array_slice($this->stack, 0, $this->reader->depth, true); // Push the current Element to the stack $this->stack[] = $this->reader->name; // Update the current Element XPath $this->current = implode('/', $this->stack); // Set skip to $this->skip = ($this->skip == $this->current) ? null : $this->skip; } while ($this->skip); return true; }
php
protected function nextElement() { do { if (! $this->reader->read()) { return false; } // Pop previous levels from the stack $this->stack = array_slice($this->stack, 0, $this->reader->depth, true); // Push the current Element to the stack $this->stack[] = $this->reader->name; // Update the current Element XPath $this->current = implode('/', $this->stack); // Set skip to $this->skip = ($this->skip == $this->current) ? null : $this->skip; } while ($this->skip); return true; }
[ "protected", "function", "nextElement", "(", ")", "{", "do", "{", "if", "(", "!", "$", "this", "->", "reader", "->", "read", "(", ")", ")", "{", "return", "false", ";", "}", "// Pop previous levels from the stack", "$", "this", "->", "stack", "=", "array_slice", "(", "$", "this", "->", "stack", ",", "0", ",", "$", "this", "->", "reader", "->", "depth", ",", "true", ")", ";", "// Push the current Element to the stack", "$", "this", "->", "stack", "[", "]", "=", "$", "this", "->", "reader", "->", "name", ";", "// Update the current Element XPath", "$", "this", "->", "current", "=", "implode", "(", "'/'", ",", "$", "this", "->", "stack", ")", ";", "// Set skip to", "$", "this", "->", "skip", "=", "(", "$", "this", "->", "skip", "==", "$", "this", "->", "current", ")", "?", "null", ":", "$", "this", "->", "skip", ";", "}", "while", "(", "$", "this", "->", "skip", ")", ";", "return", "true", ";", "}" ]
Read the next Element and handle skipping @return bool
[ "Read", "the", "next", "Element", "and", "handle", "skipping" ]
e74969e55ac889e8c2cab9a915f82e93a72e629e
https://github.com/impensavel/essence/blob/e74969e55ac889e8c2cab9a915f82e93a72e629e/src/XML.php#L146-L167
23,924
impensavel/essence
src/XML.php
XML.getData
protected function getData($xpath) { $xpath = trim($xpath, '/'); if (isset($this->data[$xpath])) { return $this->data[$xpath]; } throw new EssenceException('Unregistered Element XPath: "/'.$xpath.'"'); }
php
protected function getData($xpath) { $xpath = trim($xpath, '/'); if (isset($this->data[$xpath])) { return $this->data[$xpath]; } throw new EssenceException('Unregistered Element XPath: "/'.$xpath.'"'); }
[ "protected", "function", "getData", "(", "$", "xpath", ")", "{", "$", "xpath", "=", "trim", "(", "$", "xpath", ",", "'/'", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "xpath", "]", ")", ")", "{", "return", "$", "this", "->", "data", "[", "$", "xpath", "]", ";", "}", "throw", "new", "EssenceException", "(", "'Unregistered Element XPath: \"/'", ".", "$", "xpath", ".", "'\"'", ")", ";", "}" ]
Get registered Element data @param string $xpath Element XPath @throws EssenceException @return mixed
[ "Get", "registered", "Element", "data" ]
e74969e55ac889e8c2cab9a915f82e93a72e629e
https://github.com/impensavel/essence/blob/e74969e55ac889e8c2cab9a915f82e93a72e629e/src/XML.php#L189-L198
23,925
impensavel/essence
src/XML.php
XML.DOMNodeChildCount
protected static function DOMNodeChildCount(DOMNode $node) { $count = 0; if ($node->hasChildNodes()) { foreach ($node->childNodes as $child) { if ($child->nodeType == XML_ELEMENT_NODE) { $count++; } } } return $count; }
php
protected static function DOMNodeChildCount(DOMNode $node) { $count = 0; if ($node->hasChildNodes()) { foreach ($node->childNodes as $child) { if ($child->nodeType == XML_ELEMENT_NODE) { $count++; } } } return $count; }
[ "protected", "static", "function", "DOMNodeChildCount", "(", "DOMNode", "$", "node", ")", "{", "$", "count", "=", "0", ";", "if", "(", "$", "node", "->", "hasChildNodes", "(", ")", ")", "{", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "nodeType", "==", "XML_ELEMENT_NODE", ")", "{", "$", "count", "++", ";", "}", "}", "}", "return", "$", "count", ";", "}" ]
Count the children of a DOMNode @static @param DOMNode $node @return int
[ "Count", "the", "children", "of", "a", "DOMNode" ]
e74969e55ac889e8c2cab9a915f82e93a72e629e
https://github.com/impensavel/essence/blob/e74969e55ac889e8c2cab9a915f82e93a72e629e/src/XML.php#L254-L267
23,926
impensavel/essence
src/XML.php
XML.DOMNodeAttributes
protected static function DOMNodeAttributes(DOMNode $node) { $attributes = array(); foreach ($node->attributes as $attribute) { $attributes[$attribute->name] = $attribute->value; } return $attributes; }
php
protected static function DOMNodeAttributes(DOMNode $node) { $attributes = array(); foreach ($node->attributes as $attribute) { $attributes[$attribute->name] = $attribute->value; } return $attributes; }
[ "protected", "static", "function", "DOMNodeAttributes", "(", "DOMNode", "$", "node", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "foreach", "(", "$", "node", "->", "attributes", "as", "$", "attribute", ")", "{", "$", "attributes", "[", "$", "attribute", "->", "name", "]", "=", "$", "attribute", "->", "value", ";", "}", "return", "$", "attributes", ";", "}" ]
Get the DONNode attributes @static @param DOMNode $node @return array
[ "Get", "the", "DONNode", "attributes" ]
e74969e55ac889e8c2cab9a915f82e93a72e629e
https://github.com/impensavel/essence/blob/e74969e55ac889e8c2cab9a915f82e93a72e629e/src/XML.php#L276-L285
23,927
impensavel/essence
src/XML.php
XML.DOMNodeValue
protected static function DOMNodeValue(DOMNode $node, $associative = false, $attributes = false) { // Return the value immediately when we're dealing with a leaf // node without attributes or we simply don't want them included if (static::DOMNodeChildCount($node) == 0 && ($node->hasAttributes() === false || $attributes === false)) { return $node->nodeValue; } $children = array(); if ($node->hasAttributes() && $attributes) { $children['@'] = static::DOMNodeAttributes($node); } foreach ($node->childNodes as $child) { // Skip text nodes containing whitespace if ($child instanceof DOMText && $child->isWhitespaceInElementContent()) { continue; } if (static::DOMNodeChildCount($child) > 0) { $value = static::DOMNodeValue($child, $associative); } else { $value = $child->nodeValue; } if ($associative) { $children[$child->nodeName][] = $value; } else { $children[] = $value; } } return $children; }
php
protected static function DOMNodeValue(DOMNode $node, $associative = false, $attributes = false) { // Return the value immediately when we're dealing with a leaf // node without attributes or we simply don't want them included if (static::DOMNodeChildCount($node) == 0 && ($node->hasAttributes() === false || $attributes === false)) { return $node->nodeValue; } $children = array(); if ($node->hasAttributes() && $attributes) { $children['@'] = static::DOMNodeAttributes($node); } foreach ($node->childNodes as $child) { // Skip text nodes containing whitespace if ($child instanceof DOMText && $child->isWhitespaceInElementContent()) { continue; } if (static::DOMNodeChildCount($child) > 0) { $value = static::DOMNodeValue($child, $associative); } else { $value = $child->nodeValue; } if ($associative) { $children[$child->nodeName][] = $value; } else { $children[] = $value; } } return $children; }
[ "protected", "static", "function", "DOMNodeValue", "(", "DOMNode", "$", "node", ",", "$", "associative", "=", "false", ",", "$", "attributes", "=", "false", ")", "{", "// Return the value immediately when we're dealing with a leaf", "// node without attributes or we simply don't want them included", "if", "(", "static", "::", "DOMNodeChildCount", "(", "$", "node", ")", "==", "0", "&&", "(", "$", "node", "->", "hasAttributes", "(", ")", "===", "false", "||", "$", "attributes", "===", "false", ")", ")", "{", "return", "$", "node", "->", "nodeValue", ";", "}", "$", "children", "=", "array", "(", ")", ";", "if", "(", "$", "node", "->", "hasAttributes", "(", ")", "&&", "$", "attributes", ")", "{", "$", "children", "[", "'@'", "]", "=", "static", "::", "DOMNodeAttributes", "(", "$", "node", ")", ";", "}", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "child", ")", "{", "// Skip text nodes containing whitespace", "if", "(", "$", "child", "instanceof", "DOMText", "&&", "$", "child", "->", "isWhitespaceInElementContent", "(", ")", ")", "{", "continue", ";", "}", "if", "(", "static", "::", "DOMNodeChildCount", "(", "$", "child", ")", ">", "0", ")", "{", "$", "value", "=", "static", "::", "DOMNodeValue", "(", "$", "child", ",", "$", "associative", ")", ";", "}", "else", "{", "$", "value", "=", "$", "child", "->", "nodeValue", ";", "}", "if", "(", "$", "associative", ")", "{", "$", "children", "[", "$", "child", "->", "nodeName", "]", "[", "]", "=", "$", "value", ";", "}", "else", "{", "$", "children", "[", "]", "=", "$", "value", ";", "}", "}", "return", "$", "children", ";", "}" ]
Get the DOMNode value @static @param DOMNode $node @param bool $associative Return associative array? @param bool $attributes Include node attributes? @return mixed
[ "Get", "the", "DOMNode", "value" ]
e74969e55ac889e8c2cab9a915f82e93a72e629e
https://github.com/impensavel/essence/blob/e74969e55ac889e8c2cab9a915f82e93a72e629e/src/XML.php#L296-L330
23,928
impensavel/essence
src/XML.php
XML.DOMNodeListToArray
public static function DOMNodeListToArray(DOMNodeList $nodeList, $associative = false, $attributes = false) { $nodes = array(); foreach ($nodeList as $node) { $nodes[] = static::DOMNodeValue($node, $associative, $attributes); } return $nodes; }
php
public static function DOMNodeListToArray(DOMNodeList $nodeList, $associative = false, $attributes = false) { $nodes = array(); foreach ($nodeList as $node) { $nodes[] = static::DOMNodeValue($node, $associative, $attributes); } return $nodes; }
[ "public", "static", "function", "DOMNodeListToArray", "(", "DOMNodeList", "$", "nodeList", ",", "$", "associative", "=", "false", ",", "$", "attributes", "=", "false", ")", "{", "$", "nodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "nodeList", "as", "$", "node", ")", "{", "$", "nodes", "[", "]", "=", "static", "::", "DOMNodeValue", "(", "$", "node", ",", "$", "associative", ",", "$", "attributes", ")", ";", "}", "return", "$", "nodes", ";", "}" ]
Convert a DOMNodeList into an Array @static @param DOMNodeList $nodeList @param bool $associative Return associative array? @param bool $attributes Include node attributes? @return array
[ "Convert", "a", "DOMNodeList", "into", "an", "Array" ]
e74969e55ac889e8c2cab9a915f82e93a72e629e
https://github.com/impensavel/essence/blob/e74969e55ac889e8c2cab9a915f82e93a72e629e/src/XML.php#L341-L350
23,929
impensavel/essence
src/XML.php
XML.dump
public function dump($input, array $config = array()) { $config = array_replace_recursive(array( 'encoding' => 'UTF-8', 'options' => LIBXML_PARSEHUGE, ), $config); $this->prepare($input, $config); $paths = array(); while ($this->nextElement()) { if (! $this->reader->isEmptyElement && $this->reader->nodeType === XMLReader::ELEMENT) { $paths[] = $this->current; } } return array_count_values($paths); }
php
public function dump($input, array $config = array()) { $config = array_replace_recursive(array( 'encoding' => 'UTF-8', 'options' => LIBXML_PARSEHUGE, ), $config); $this->prepare($input, $config); $paths = array(); while ($this->nextElement()) { if (! $this->reader->isEmptyElement && $this->reader->nodeType === XMLReader::ELEMENT) { $paths[] = $this->current; } } return array_count_values($paths); }
[ "public", "function", "dump", "(", "$", "input", ",", "array", "$", "config", "=", "array", "(", ")", ")", "{", "$", "config", "=", "array_replace_recursive", "(", "array", "(", "'encoding'", "=>", "'UTF-8'", ",", "'options'", "=>", "LIBXML_PARSEHUGE", ",", ")", ",", "$", "config", ")", ";", "$", "this", "->", "prepare", "(", "$", "input", ",", "$", "config", ")", ";", "$", "paths", "=", "array", "(", ")", ";", "while", "(", "$", "this", "->", "nextElement", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "reader", "->", "isEmptyElement", "&&", "$", "this", "->", "reader", "->", "nodeType", "===", "XMLReader", "::", "ELEMENT", ")", "{", "$", "paths", "[", "]", "=", "$", "this", "->", "current", ";", "}", "}", "return", "array_count_values", "(", "$", "paths", ")", ";", "}" ]
Dump XPaths and all their occurrences @param mixed $input Input data @param array $config Configuration settings (optional) @return array
[ "Dump", "XPaths", "and", "all", "their", "occurrences" ]
e74969e55ac889e8c2cab9a915f82e93a72e629e
https://github.com/impensavel/essence/blob/e74969e55ac889e8c2cab9a915f82e93a72e629e/src/XML.php#L420-L438
23,930
mridang/magazine
lib/magento/Validator.php
Mage_Connect_Validator.validateLicenseUrl
public function validateLicenseUrl($str) { if ($str) { return ( $this->validateUrl($str) || $this->validatePackageName($str)); } return true; }
php
public function validateLicenseUrl($str) { if ($str) { return ( $this->validateUrl($str) || $this->validatePackageName($str)); } return true; }
[ "public", "function", "validateLicenseUrl", "(", "$", "str", ")", "{", "if", "(", "$", "str", ")", "{", "return", "(", "$", "this", "->", "validateUrl", "(", "$", "str", ")", "||", "$", "this", "->", "validatePackageName", "(", "$", "str", ")", ")", ";", "}", "return", "true", ";", "}" ]
Validate License url @param mixed $str @return boolean
[ "Validate", "License", "url" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Validator.php#L116-L122
23,931
mridang/magazine
lib/magento/Validator.php
Mage_Connect_Validator.validateCompatible
public function validateCompatible(array $data) { if(!count($data)) { /** * Allow empty */ return true; } $count = 0; foreach($data as $k=>$v) { foreach(array('name','channel','min','max') as $fld) { $$fld = trim($v[$fld]); } $count++; $res = $this->validateUrl($channel) && strlen($channel); if(!$res) { $this->addError("Invalid or empty channel in compat. #{$count}"); } $res = $this->validatePackageName($name) && strlen($name); if(!$res) { $this->addError("Invalid or empty name in compat. #{$count}"); } $res1 = $this->validateVersion($min); if(!$res1) { $this->addError("Invalid or empty minVersion in compat. #{$count}"); } $res2 = $this->validateVersion($max); if(!$res2) { $this->addError("Invalid or empty maxVersion in compat. #{$count}"); } if($res1 && $res2 && $this->versionLower($max, $min)) { $this->addError("Max version is lower than min in compat #{$count}"); } } return ! $this->hasErrors(); }
php
public function validateCompatible(array $data) { if(!count($data)) { /** * Allow empty */ return true; } $count = 0; foreach($data as $k=>$v) { foreach(array('name','channel','min','max') as $fld) { $$fld = trim($v[$fld]); } $count++; $res = $this->validateUrl($channel) && strlen($channel); if(!$res) { $this->addError("Invalid or empty channel in compat. #{$count}"); } $res = $this->validatePackageName($name) && strlen($name); if(!$res) { $this->addError("Invalid or empty name in compat. #{$count}"); } $res1 = $this->validateVersion($min); if(!$res1) { $this->addError("Invalid or empty minVersion in compat. #{$count}"); } $res2 = $this->validateVersion($max); if(!$res2) { $this->addError("Invalid or empty maxVersion in compat. #{$count}"); } if($res1 && $res2 && $this->versionLower($max, $min)) { $this->addError("Max version is lower than min in compat #{$count}"); } } return ! $this->hasErrors(); }
[ "public", "function", "validateCompatible", "(", "array", "$", "data", ")", "{", "if", "(", "!", "count", "(", "$", "data", ")", ")", "{", "/**\n * Allow empty\n */", "return", "true", ";", "}", "$", "count", "=", "0", ";", "foreach", "(", "$", "data", "as", "$", "k", "=>", "$", "v", ")", "{", "foreach", "(", "array", "(", "'name'", ",", "'channel'", ",", "'min'", ",", "'max'", ")", "as", "$", "fld", ")", "{", "$", "$", "fld", "=", "trim", "(", "$", "v", "[", "$", "fld", "]", ")", ";", "}", "$", "count", "++", ";", "$", "res", "=", "$", "this", "->", "validateUrl", "(", "$", "channel", ")", "&&", "strlen", "(", "$", "channel", ")", ";", "if", "(", "!", "$", "res", ")", "{", "$", "this", "->", "addError", "(", "\"Invalid or empty channel in compat. #{$count}\"", ")", ";", "}", "$", "res", "=", "$", "this", "->", "validatePackageName", "(", "$", "name", ")", "&&", "strlen", "(", "$", "name", ")", ";", "if", "(", "!", "$", "res", ")", "{", "$", "this", "->", "addError", "(", "\"Invalid or empty name in compat. #{$count}\"", ")", ";", "}", "$", "res1", "=", "$", "this", "->", "validateVersion", "(", "$", "min", ")", ";", "if", "(", "!", "$", "res1", ")", "{", "$", "this", "->", "addError", "(", "\"Invalid or empty minVersion in compat. #{$count}\"", ")", ";", "}", "$", "res2", "=", "$", "this", "->", "validateVersion", "(", "$", "max", ")", ";", "if", "(", "!", "$", "res2", ")", "{", "$", "this", "->", "addError", "(", "\"Invalid or empty maxVersion in compat. #{$count}\"", ")", ";", "}", "if", "(", "$", "res1", "&&", "$", "res2", "&&", "$", "this", "->", "versionLower", "(", "$", "max", ",", "$", "min", ")", ")", "{", "$", "this", "->", "addError", "(", "\"Max version is lower than min in compat #{$count}\"", ")", ";", "}", "}", "return", "!", "$", "this", "->", "hasErrors", "(", ")", ";", "}" ]
Validate compatible data @param array $data @return bool
[ "Validate", "compatible", "data" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Validator.php#L129-L167
23,932
mridang/magazine
lib/magento/Validator.php
Mage_Connect_Validator.validateAuthors
public function validateAuthors(array $authors) { if(!count($authors)) { $this->addError('Empty authors section'); return false; } $count = 0; foreach($authors as $k=>$v) { $count++; array_map('trim', $v); $name = $v['name']; $login = $v['user']; $email = $v['email']; $res = $this->validateMaxLen($name, 256) && strlen($name); if(!$res) { $this->addError("Invalid or empty name for author #{$count}"); } $res = $this->validatePackageName($login) && strlen($login); if(!$res) { $this->addError("Invalid or empty login for author #{$count}"); } $res = $this->validateEmail($email); if(!$res) { $this->addError("Invalid or empty email for author #{$count}"); } } return ! $this->hasErrors(); }
php
public function validateAuthors(array $authors) { if(!count($authors)) { $this->addError('Empty authors section'); return false; } $count = 0; foreach($authors as $k=>$v) { $count++; array_map('trim', $v); $name = $v['name']; $login = $v['user']; $email = $v['email']; $res = $this->validateMaxLen($name, 256) && strlen($name); if(!$res) { $this->addError("Invalid or empty name for author #{$count}"); } $res = $this->validatePackageName($login) && strlen($login); if(!$res) { $this->addError("Invalid or empty login for author #{$count}"); } $res = $this->validateEmail($email); if(!$res) { $this->addError("Invalid or empty email for author #{$count}"); } } return ! $this->hasErrors(); }
[ "public", "function", "validateAuthors", "(", "array", "$", "authors", ")", "{", "if", "(", "!", "count", "(", "$", "authors", ")", ")", "{", "$", "this", "->", "addError", "(", "'Empty authors section'", ")", ";", "return", "false", ";", "}", "$", "count", "=", "0", ";", "foreach", "(", "$", "authors", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "count", "++", ";", "array_map", "(", "'trim'", ",", "$", "v", ")", ";", "$", "name", "=", "$", "v", "[", "'name'", "]", ";", "$", "login", "=", "$", "v", "[", "'user'", "]", ";", "$", "email", "=", "$", "v", "[", "'email'", "]", ";", "$", "res", "=", "$", "this", "->", "validateMaxLen", "(", "$", "name", ",", "256", ")", "&&", "strlen", "(", "$", "name", ")", ";", "if", "(", "!", "$", "res", ")", "{", "$", "this", "->", "addError", "(", "\"Invalid or empty name for author #{$count}\"", ")", ";", "}", "$", "res", "=", "$", "this", "->", "validatePackageName", "(", "$", "login", ")", "&&", "strlen", "(", "$", "login", ")", ";", "if", "(", "!", "$", "res", ")", "{", "$", "this", "->", "addError", "(", "\"Invalid or empty login for author #{$count}\"", ")", ";", "}", "$", "res", "=", "$", "this", "->", "validateEmail", "(", "$", "email", ")", ";", "if", "(", "!", "$", "res", ")", "{", "$", "this", "->", "addError", "(", "\"Invalid or empty email for author #{$count}\"", ")", ";", "}", "}", "return", "!", "$", "this", "->", "hasErrors", "(", ")", ";", "}" ]
Validate authors of package @param array $authors @return bool
[ "Validate", "authors", "of", "package" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Validator.php#L174-L201
23,933
mridang/magazine
lib/magento/Validator.php
Mage_Connect_Validator.validateDate
public function validateDate($date) { $subs = null; $check1 = preg_match("/^([\d]{4})-([\d]{2})-([\d]{2})$/i", $date, $subs); if(!$check1) { return false; } return checkdate($subs[2], $subs[3], $subs[1]); }
php
public function validateDate($date) { $subs = null; $check1 = preg_match("/^([\d]{4})-([\d]{2})-([\d]{2})$/i", $date, $subs); if(!$check1) { return false; } return checkdate($subs[2], $subs[3], $subs[1]); }
[ "public", "function", "validateDate", "(", "$", "date", ")", "{", "$", "subs", "=", "null", ";", "$", "check1", "=", "preg_match", "(", "\"/^([\\d]{4})-([\\d]{2})-([\\d]{2})$/i\"", ",", "$", "date", ",", "$", "subs", ")", ";", "if", "(", "!", "$", "check1", ")", "{", "return", "false", ";", "}", "return", "checkdate", "(", "$", "subs", "[", "2", "]", ",", "$", "subs", "[", "3", "]", ",", "$", "subs", "[", "1", "]", ")", ";", "}" ]
Validate date format @param $date @return bool
[ "Validate", "date", "format" ]
5b3cfecc472c61fde6af63efe62690a30a267a04
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/lib/magento/Validator.php#L293-L301
23,934
nonzod/yii2-foundation
ActiveField.php
ActiveField.input
public function input($type, $options = []) { $options = array_merge($this->inputOptions, [ 'class' => 'hint-' . Html::getInputId($this->model, $this->attribute) ]); $this->adjustLabelFor($options); $this->parts['{input}'] = Html::activeInput($type, $this->model, $this->attribute, $options); return $this; }
php
public function input($type, $options = []) { $options = array_merge($this->inputOptions, [ 'class' => 'hint-' . Html::getInputId($this->model, $this->attribute) ]); $this->adjustLabelFor($options); $this->parts['{input}'] = Html::activeInput($type, $this->model, $this->attribute, $options); return $this; }
[ "public", "function", "input", "(", "$", "type", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_merge", "(", "$", "this", "->", "inputOptions", ",", "[", "'class'", "=>", "'hint-'", ".", "Html", "::", "getInputId", "(", "$", "this", "->", "model", ",", "$", "this", "->", "attribute", ")", "]", ")", ";", "$", "this", "->", "adjustLabelFor", "(", "$", "options", ")", ";", "$", "this", "->", "parts", "[", "'{input}'", "]", "=", "Html", "::", "activeInput", "(", "$", "type", ",", "$", "this", "->", "model", ",", "$", "this", "->", "attribute", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Renders an input tag. @param string $type the input type (e.g. 'text', 'password') @param array $options the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]]. @return static the field object itself
[ "Renders", "an", "input", "tag", "." ]
5df93b8a39a73a7fade2f3189693fdb6625205d2
https://github.com/nonzod/yii2-foundation/blob/5df93b8a39a73a7fade2f3189693fdb6625205d2/ActiveField.php#L94-L102
23,935
heidelpay/PhpDoc
src/phpDocumentor/Command/Helper/ConfigurationHelper.php
ConfigurationHelper.getOption
public function getOption( InputInterface $input, $name, $configPath = null, $default = null, $commaSeparated = false ) { $value = $input->getOption($name); // find value in config if ($this->valueIsEmpty($value) && $configPath !== null) { $value = $this->getConfigValueFromPath($configPath); } // use default if value is still null if ($this->valueIsEmpty($value)) { return (is_array($value) && $default === null) ? array() : $default; } return $commaSeparated ? $this->splitCommaSeparatedValues($value) : $value; }
php
public function getOption( InputInterface $input, $name, $configPath = null, $default = null, $commaSeparated = false ) { $value = $input->getOption($name); // find value in config if ($this->valueIsEmpty($value) && $configPath !== null) { $value = $this->getConfigValueFromPath($configPath); } // use default if value is still null if ($this->valueIsEmpty($value)) { return (is_array($value) && $default === null) ? array() : $default; } return $commaSeparated ? $this->splitCommaSeparatedValues($value) : $value; }
[ "public", "function", "getOption", "(", "InputInterface", "$", "input", ",", "$", "name", ",", "$", "configPath", "=", "null", ",", "$", "default", "=", "null", ",", "$", "commaSeparated", "=", "false", ")", "{", "$", "value", "=", "$", "input", "->", "getOption", "(", "$", "name", ")", ";", "// find value in config", "if", "(", "$", "this", "->", "valueIsEmpty", "(", "$", "value", ")", "&&", "$", "configPath", "!==", "null", ")", "{", "$", "value", "=", "$", "this", "->", "getConfigValueFromPath", "(", "$", "configPath", ")", ";", "}", "// use default if value is still null", "if", "(", "$", "this", "->", "valueIsEmpty", "(", "$", "value", ")", ")", "{", "return", "(", "is_array", "(", "$", "value", ")", "&&", "$", "default", "===", "null", ")", "?", "array", "(", ")", ":", "$", "default", ";", "}", "return", "$", "commaSeparated", "?", "$", "this", "->", "splitCommaSeparatedValues", "(", "$", "value", ")", ":", "$", "value", ";", "}" ]
Returns the value of an option from the command-line parameters, configuration or given default. @param InputInterface $input Input interface to query for information @param string $name Name of the option to retrieve from argv @param string|null $configPath Path to the config element(s) containing the value to be used when no option is provided. @param mixed|null $default Default value used if there is no configuration option or path set @param bool $commaSeparated Could the value be a comma separated string requiring splitting @return string|array
[ "Returns", "the", "value", "of", "an", "option", "from", "the", "command", "-", "line", "parameters", "configuration", "or", "given", "default", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Helper/ConfigurationHelper.php#L62-L84
23,936
heidelpay/PhpDoc
src/phpDocumentor/Command/Helper/ConfigurationHelper.php
ConfigurationHelper.splitCommaSeparatedValues
protected function splitCommaSeparatedValues($value) { if (!is_array($value) || (count($value) == 1) && is_string(current($value))) { $value = (array) $value; $value = explode(',', $value[0]); } return $value; }
php
protected function splitCommaSeparatedValues($value) { if (!is_array($value) || (count($value) == 1) && is_string(current($value))) { $value = (array) $value; $value = explode(',', $value[0]); } return $value; }
[ "protected", "function", "splitCommaSeparatedValues", "(", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", "||", "(", "count", "(", "$", "value", ")", "==", "1", ")", "&&", "is_string", "(", "current", "(", "$", "value", ")", ")", ")", "{", "$", "value", "=", "(", "array", ")", "$", "value", ";", "$", "value", "=", "explode", "(", "','", ",", "$", "value", "[", "0", "]", ")", ";", "}", "return", "$", "value", ";", "}" ]
Split comma separated values. @param mixed $value @return mixed
[ "Split", "comma", "separated", "values", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Helper/ConfigurationHelper.php#L93-L101
23,937
heidelpay/PhpDoc
src/phpDocumentor/Command/Helper/ConfigurationHelper.php
ConfigurationHelper.getConfigValueFromPath
public function getConfigValueFromPath($path) { /** @var Configuration $node */ $node = $this->configuration; foreach (explode('/', $path) as $nodeName) { if (!is_object($node)) { return null; } $node = $node->{'get' . ucfirst($nodeName)}(); } return $node; }
php
public function getConfigValueFromPath($path) { /** @var Configuration $node */ $node = $this->configuration; foreach (explode('/', $path) as $nodeName) { if (!is_object($node)) { return null; } $node = $node->{'get' . ucfirst($nodeName)}(); } return $node; }
[ "public", "function", "getConfigValueFromPath", "(", "$", "path", ")", "{", "/** @var Configuration $node */", "$", "node", "=", "$", "this", "->", "configuration", ";", "foreach", "(", "explode", "(", "'/'", ",", "$", "path", ")", "as", "$", "nodeName", ")", "{", "if", "(", "!", "is_object", "(", "$", "node", ")", ")", "{", "return", "null", ";", "}", "$", "node", "=", "$", "node", "->", "{", "'get'", ".", "ucfirst", "(", "$", "nodeName", ")", "}", "(", ")", ";", "}", "return", "$", "node", ";", "}" ]
Returns a value by traversing the configuration tree as if it was a file path. @param string $path Path to the config value separated by '/'. @return string|integer|boolean
[ "Returns", "a", "value", "by", "traversing", "the", "configuration", "tree", "as", "if", "it", "was", "a", "file", "path", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Helper/ConfigurationHelper.php#L123-L137
23,938
Danzabar/config-builder
src/Files/Merger.php
Merger.load
public function load(ConfigFile $master, ConfigFile $slave) { $this->master = $master; $this->slave = $slave; return $this; }
php
public function load(ConfigFile $master, ConfigFile $slave) { $this->master = $master; $this->slave = $slave; return $this; }
[ "public", "function", "load", "(", "ConfigFile", "$", "master", ",", "ConfigFile", "$", "slave", ")", "{", "$", "this", "->", "master", "=", "$", "master", ";", "$", "this", "->", "slave", "=", "$", "slave", ";", "return", "$", "this", ";", "}" ]
Loads the master and slave files @param \Danzabar\Config\Files\ConfigFile $master @param \Danzabar\Config\Files\ConfigFile $slave @return Merger @author Dan Cox
[ "Loads", "the", "master", "and", "slave", "files" ]
3b237be578172c32498bbcdfb360e69a6243739d
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/Merger.php#L72-L78
23,939
Danzabar/config-builder
src/Files/Merger.php
Merger.merge
public function merge() { if($this->saveBackupBeforeMerge) { $this->saveBackup(); } // Since the param bag has the merge functionality already, why not use it? $this->master->params()->merge($this->slave->params()->all()); if($this->autoSaveMaster) { $this->master->save(); } if($this->deleteSlaveOnMerge) { $this->slave->delete(); } }
php
public function merge() { if($this->saveBackupBeforeMerge) { $this->saveBackup(); } // Since the param bag has the merge functionality already, why not use it? $this->master->params()->merge($this->slave->params()->all()); if($this->autoSaveMaster) { $this->master->save(); } if($this->deleteSlaveOnMerge) { $this->slave->delete(); } }
[ "public", "function", "merge", "(", ")", "{", "if", "(", "$", "this", "->", "saveBackupBeforeMerge", ")", "{", "$", "this", "->", "saveBackup", "(", ")", ";", "}", "// Since the param bag has the merge functionality already, why not use it?", "$", "this", "->", "master", "->", "params", "(", ")", "->", "merge", "(", "$", "this", "->", "slave", "->", "params", "(", ")", "->", "all", "(", ")", ")", ";", "if", "(", "$", "this", "->", "autoSaveMaster", ")", "{", "$", "this", "->", "master", "->", "save", "(", ")", ";", "}", "if", "(", "$", "this", "->", "deleteSlaveOnMerge", ")", "{", "$", "this", "->", "slave", "->", "delete", "(", ")", ";", "}", "}" ]
Performs the merge action @return void @author Dan Cox
[ "Performs", "the", "merge", "action" ]
3b237be578172c32498bbcdfb360e69a6243739d
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/Merger.php#L86-L105
23,940
Danzabar/config-builder
src/Files/Merger.php
Merger.restore
public function restore() { $this->master->params()->rollback(); $this->slave->params()->rollback(); // We should also save these so we know any changes have been fully reversed $this->master->save(); $this->slave->save(); }
php
public function restore() { $this->master->params()->rollback(); $this->slave->params()->rollback(); // We should also save these so we know any changes have been fully reversed $this->master->save(); $this->slave->save(); }
[ "public", "function", "restore", "(", ")", "{", "$", "this", "->", "master", "->", "params", "(", ")", "->", "rollback", "(", ")", ";", "$", "this", "->", "slave", "->", "params", "(", ")", "->", "rollback", "(", ")", ";", "// We should also save these so we know any changes have been fully reversed", "$", "this", "->", "master", "->", "save", "(", ")", ";", "$", "this", "->", "slave", "->", "save", "(", ")", ";", "}" ]
Restores the files @return void @author Dan Cox
[ "Restores", "the", "files" ]
3b237be578172c32498bbcdfb360e69a6243739d
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/Merger.php#L125-L133
23,941
Smile-SA/EzUICronBundle
Repository/SmileEzCronRepository.php
SmileEzCronRepository.updateCron
public function updateCron(SmileEzCron $cron, $type, $value) { switch ($type) { case 'expression': if (!CronExpression::isValidExpression($value)) { throw new InvalidArgumentException( 'expression', 'cron.invalid.type' ); } $cron->setExpression($value); break; case 'arguments': if (preg_match_all('|[a-z0-9_\-]+:[a-z0-9_\-]+|', $value) === 0) { throw new InvalidArgumentException( 'arguments', 'cron.invalid.type' ); } $cron->setArguments($value); break; case 'priority': if (!ctype_digit($value)) { throw new InvalidArgumentException( 'priority', 'cron.invalid.type' ); } $cron->setPriority((int)$value); break; case 'enabled': if (!ctype_digit($value) && ((int)$value != 1 || (int)$value != 0)) { throw new InvalidArgumentException( 'enabled', 'cron.invalid.type' ); } $cron->setEnabled((int)$value); break; } $this->getEntityManager()->persist($cron); $this->getEntityManager()->flush(); }
php
public function updateCron(SmileEzCron $cron, $type, $value) { switch ($type) { case 'expression': if (!CronExpression::isValidExpression($value)) { throw new InvalidArgumentException( 'expression', 'cron.invalid.type' ); } $cron->setExpression($value); break; case 'arguments': if (preg_match_all('|[a-z0-9_\-]+:[a-z0-9_\-]+|', $value) === 0) { throw new InvalidArgumentException( 'arguments', 'cron.invalid.type' ); } $cron->setArguments($value); break; case 'priority': if (!ctype_digit($value)) { throw new InvalidArgumentException( 'priority', 'cron.invalid.type' ); } $cron->setPriority((int)$value); break; case 'enabled': if (!ctype_digit($value) && ((int)$value != 1 || (int)$value != 0)) { throw new InvalidArgumentException( 'enabled', 'cron.invalid.type' ); } $cron->setEnabled((int)$value); break; } $this->getEntityManager()->persist($cron); $this->getEntityManager()->flush(); }
[ "public", "function", "updateCron", "(", "SmileEzCron", "$", "cron", ",", "$", "type", ",", "$", "value", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'expression'", ":", "if", "(", "!", "CronExpression", "::", "isValidExpression", "(", "$", "value", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'expression'", ",", "'cron.invalid.type'", ")", ";", "}", "$", "cron", "->", "setExpression", "(", "$", "value", ")", ";", "break", ";", "case", "'arguments'", ":", "if", "(", "preg_match_all", "(", "'|[a-z0-9_\\-]+:[a-z0-9_\\-]+|'", ",", "$", "value", ")", "===", "0", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'arguments'", ",", "'cron.invalid.type'", ")", ";", "}", "$", "cron", "->", "setArguments", "(", "$", "value", ")", ";", "break", ";", "case", "'priority'", ":", "if", "(", "!", "ctype_digit", "(", "$", "value", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'priority'", ",", "'cron.invalid.type'", ")", ";", "}", "$", "cron", "->", "setPriority", "(", "(", "int", ")", "$", "value", ")", ";", "break", ";", "case", "'enabled'", ":", "if", "(", "!", "ctype_digit", "(", "$", "value", ")", "&&", "(", "(", "int", ")", "$", "value", "!=", "1", "||", "(", "int", ")", "$", "value", "!=", "0", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'enabled'", ",", "'cron.invalid.type'", ")", ";", "}", "$", "cron", "->", "setEnabled", "(", "(", "int", ")", "$", "value", ")", ";", "break", ";", "}", "$", "this", "->", "getEntityManager", "(", ")", "->", "persist", "(", "$", "cron", ")", ";", "$", "this", "->", "getEntityManager", "(", ")", "->", "flush", "(", ")", ";", "}" ]
Edit cron definition @param SmileEzCron $cron cron object @param string $type cron property identifier @param string $value cron property value @throws InvalidArgumentException
[ "Edit", "cron", "definition" ]
c62fc6a3ab0b39e3f911742d9affe4aade90cf66
https://github.com/Smile-SA/EzUICronBundle/blob/c62fc6a3ab0b39e3f911742d9affe4aade90cf66/Repository/SmileEzCronRepository.php#L39-L78
23,942
mvccore/ext-router-module
src/MvcCore/Ext/Routers/Modules/Route/PropsGettersSetters.php
PropsGettersSetters.&
public function & SetAllowedLocalizations (/* ...$allowedLocalizations */) { /** @var $this \MvcCore\Ext\Routers\Modules\IRoute */ $allowedLocalizations = func_get_args(); if (count($allowedLocalizations) === 1 && is_array($allowedLocalizations[0])) $allowedLocalizations = $allowedLocalizations[0]; $this->allowedLocalizations = array_combine($allowedLocalizations, $allowedLocalizations); return $this; }
php
public function & SetAllowedLocalizations (/* ...$allowedLocalizations */) { /** @var $this \MvcCore\Ext\Routers\Modules\IRoute */ $allowedLocalizations = func_get_args(); if (count($allowedLocalizations) === 1 && is_array($allowedLocalizations[0])) $allowedLocalizations = $allowedLocalizations[0]; $this->allowedLocalizations = array_combine($allowedLocalizations, $allowedLocalizations); return $this; }
[ "public", "function", "&", "SetAllowedLocalizations", "(", "/* ...$allowedLocalizations */", ")", "{", "/** @var $this \\MvcCore\\Ext\\Routers\\Modules\\IRoute */", "$", "allowedLocalizations", "=", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "allowedLocalizations", ")", "===", "1", "&&", "is_array", "(", "$", "allowedLocalizations", "[", "0", "]", ")", ")", "$", "allowedLocalizations", "=", "$", "allowedLocalizations", "[", "0", "]", ";", "$", "this", "->", "allowedLocalizations", "=", "array_combine", "(", "$", "allowedLocalizations", ",", "$", "allowedLocalizations", ")", ";", "return", "$", "this", ";", "}" ]
Set allowed localizations for the routed module if there is used any variant of module router with localization. @var \string[] $allowedLocalizations..., International lower case language code(s) (+ optionally dash character + upper case international locale code(s)) @return \MvcCore\Ext\Routers\Modules\Route|\MvcCore\Ext\Routers\Modules\IRoute
[ "Set", "allowed", "localizations", "for", "the", "routed", "module", "if", "there", "is", "used", "any", "variant", "of", "module", "router", "with", "localization", "." ]
7695784a451db86cca6a43c98d076803cd0a50a7
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Modules/Route/PropsGettersSetters.php#L115-L122
23,943
mvccore/ext-router-module
src/MvcCore/Ext/Routers/Modules/Route/PropsGettersSetters.php
PropsGettersSetters.trriggerUnusedMethodError
protected function trriggerUnusedMethodError ($method) { /** @var $this \MvcCore\Ext\Routers\Modules\IRoute */ $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; trigger_error("[$selfClass] The method `$method` is not used in this extended class.", E_USER_WARNING); return $this; }
php
protected function trriggerUnusedMethodError ($method) { /** @var $this \MvcCore\Ext\Routers\Modules\IRoute */ $selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__; trigger_error("[$selfClass] The method `$method` is not used in this extended class.", E_USER_WARNING); return $this; }
[ "protected", "function", "trriggerUnusedMethodError", "(", "$", "method", ")", "{", "/** @var $this \\MvcCore\\Ext\\Routers\\Modules\\IRoute */", "$", "selfClass", "=", "version_compare", "(", "PHP_VERSION", ",", "'5.5'", ",", "'>'", ")", "?", "self", "::", "class", ":", "__CLASS__", ";", "trigger_error", "(", "\"[$selfClass] The method `$method` is not used in this extended class.\"", ",", "E_USER_WARNING", ")", ";", "return", "$", "this", ";", "}" ]
Trigger `E_USER_WARNING` user error about not used method in this extended module domain route. @param string $method @return \MvcCore\Ext\Routers\Modules\IRoute
[ "Trigger", "E_USER_WARNING", "user", "error", "about", "not", "used", "method", "in", "this", "extended", "module", "domain", "route", "." ]
7695784a451db86cca6a43c98d076803cd0a50a7
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Modules/Route/PropsGettersSetters.php#L308-L313
23,944
ezsystems/ezcomments-ls-extension
classes/ezcomnotificationemailmanager.php
ezcomNotificationEmailManager.executeSending
public function executeSending( $subject, $body, $subscriber ) { $email = $subscriber->attribute( 'email' ); $parameters = array(); $parameters['content_type'] = $this->emailContentType; $parameters['from'] = $this->emailFrom; $transport = eZNotificationTransport::instance( 'ezmail' ); $result = $transport->send( array( $email ), $subject, $body, null, $parameters ); if ( $result === false ) { throw new Exception( 'Send email error! Subscriber id:' .$subscriber->attribute( 'id' ) ); } eZDebugSetting::writeNotice( 'extension-ezcomments', "An email has been sent to '$email' (subject: $subject)", __METHOD__ ); }
php
public function executeSending( $subject, $body, $subscriber ) { $email = $subscriber->attribute( 'email' ); $parameters = array(); $parameters['content_type'] = $this->emailContentType; $parameters['from'] = $this->emailFrom; $transport = eZNotificationTransport::instance( 'ezmail' ); $result = $transport->send( array( $email ), $subject, $body, null, $parameters ); if ( $result === false ) { throw new Exception( 'Send email error! Subscriber id:' .$subscriber->attribute( 'id' ) ); } eZDebugSetting::writeNotice( 'extension-ezcomments', "An email has been sent to '$email' (subject: $subject)", __METHOD__ ); }
[ "public", "function", "executeSending", "(", "$", "subject", ",", "$", "body", ",", "$", "subscriber", ")", "{", "$", "email", "=", "$", "subscriber", "->", "attribute", "(", "'email'", ")", ";", "$", "parameters", "=", "array", "(", ")", ";", "$", "parameters", "[", "'content_type'", "]", "=", "$", "this", "->", "emailContentType", ";", "$", "parameters", "[", "'from'", "]", "=", "$", "this", "->", "emailFrom", ";", "$", "transport", "=", "eZNotificationTransport", "::", "instance", "(", "'ezmail'", ")", ";", "$", "result", "=", "$", "transport", "->", "send", "(", "array", "(", "$", "email", ")", ",", "$", "subject", ",", "$", "body", ",", "null", ",", "$", "parameters", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Send email error! Subscriber id:'", ".", "$", "subscriber", "->", "attribute", "(", "'id'", ")", ")", ";", "}", "eZDebugSetting", "::", "writeNotice", "(", "'extension-ezcomments'", ",", "\"An email has been sent to '$email' (subject: $subject)\"", ",", "__METHOD__", ")", ";", "}" ]
Execute sending process in Email @see extension/ezcomments/classes/ezcomNotificationManager#executeSending($subject, $body, $subscriber)
[ "Execute", "sending", "process", "in", "Email" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomnotificationemailmanager.php#L34-L47
23,945
gedex/php-janrain-api
lib/Janrain/Api/Engage/Engage.php
Engage.setAuthProviders
public function setAuthProviders(array $params = array()) { if (!isset($params['providers'])) { throw new MissingArgumentException('providers'); } if (!is_array($params['providers'])) { throw new InvalidArgumentException('Invalid Argument: providers must be passed as array'); } $params['providers'] = json_encode(array_values($params['providers'])); return $this->post('set_auth_providers', $params); }
php
public function setAuthProviders(array $params = array()) { if (!isset($params['providers'])) { throw new MissingArgumentException('providers'); } if (!is_array($params['providers'])) { throw new InvalidArgumentException('Invalid Argument: providers must be passed as array'); } $params['providers'] = json_encode(array_values($params['providers'])); return $this->post('set_auth_providers', $params); }
[ "public", "function", "setAuthProviders", "(", "array", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'providers'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'providers'", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "params", "[", "'providers'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid Argument: providers must be passed as array'", ")", ";", "}", "$", "params", "[", "'providers'", "]", "=", "json_encode", "(", "array_values", "(", "$", "params", "[", "'providers'", "]", ")", ")", ";", "return", "$", "this", "->", "post", "(", "'set_auth_providers'", ",", "$", "params", ")", ";", "}" ]
Defines the list of identity providers provided by the Engage server to sign-in widgets. This is the same list that is managed by the dashboard. @param array $params
[ "Defines", "the", "list", "of", "identity", "providers", "provided", "by", "the", "Engage", "server", "to", "sign", "-", "in", "widgets", ".", "This", "is", "the", "same", "list", "that", "is", "managed", "by", "the", "dashboard", "." ]
6283f68454e0ad5211ac620f1d337df38cd49597
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Engage.php#L112-L125
23,946
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/query_select.php
ezcQuerySelect.selectDistinct
public function selectDistinct() { if ( $this->selectString == null ) { $this->selectString = 'SELECT DISTINCT '; } elseif ( strpos ( $this->selectString, 'DISTINCT' ) === false ) { throw new ezcQueryInvalidException( 'SELECT', 'You can\'t use selectDistinct() after using select() in the same query.' ); } // Call ezcQuerySelect::select() to do the parameter processing $args = func_get_args(); return call_user_func_array( array( $this, 'select' ), $args ); }
php
public function selectDistinct() { if ( $this->selectString == null ) { $this->selectString = 'SELECT DISTINCT '; } elseif ( strpos ( $this->selectString, 'DISTINCT' ) === false ) { throw new ezcQueryInvalidException( 'SELECT', 'You can\'t use selectDistinct() after using select() in the same query.' ); } // Call ezcQuerySelect::select() to do the parameter processing $args = func_get_args(); return call_user_func_array( array( $this, 'select' ), $args ); }
[ "public", "function", "selectDistinct", "(", ")", "{", "if", "(", "$", "this", "->", "selectString", "==", "null", ")", "{", "$", "this", "->", "selectString", "=", "'SELECT DISTINCT '", ";", "}", "elseif", "(", "strpos", "(", "$", "this", "->", "selectString", ",", "'DISTINCT'", ")", "===", "false", ")", "{", "throw", "new", "ezcQueryInvalidException", "(", "'SELECT'", ",", "'You can\\'t use selectDistinct() after using select() in the same query.'", ")", ";", "}", "// Call ezcQuerySelect::select() to do the parameter processing", "$", "args", "=", "func_get_args", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "$", "this", ",", "'select'", ")", ",", "$", "args", ")", ";", "}" ]
Opens the query and uses a distinct select on the columns you want to return with the query. selectDistinct() accepts an arbitrary number of parameters. Each parameter must contain either the name of a column or an array containing the names of the columns. Each call to selectDistinct() appends columns to the list of columns that will be used in the query. Example: <code> $q->selectDistinct( 'column1', 'column2' ); </code> The same could also be written <code> $columns[] = 'column1'; $columns[] = 'column2; $q->selectDistinct( $columns ); </code> or using several calls <code> $q->selectDistinct( 'column1' )->select( 'column2' ); </code> Each of above code produce SQL clause 'SELECT DISTINCT column1, column2' for the query. You may call select() after calling selectDistinct() which will result in the additional columns beein added. A call of selectDistinct() after select() will result in an ezcQueryInvalidException. @throws ezcQueryVariableParameterException if called with no parameters.. @throws ezcQueryInvalidException if called after select() @param string|array(string) $... Either a string with a column name or an array of column names. @return ezcQuery returns a pointer to $this.
[ "Opens", "the", "query", "and", "uses", "a", "distinct", "select", "on", "the", "columns", "you", "want", "to", "return", "with", "the", "query", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/query_select.php#L270-L290
23,947
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/query_select.php
ezcQuerySelect.getQuery
public function getQuery() { if ( $this->selectString == null ) { throw new ezcQueryInvalidException( "SELECT", "select() was not called before getQuery()." ); } $query = "{$this->selectString}"; if ( $this->fromString != null ) { $query = "{$query} {$this->fromString}"; } if ( $this->whereString != null ) { $query = "{$query} {$this->whereString}"; } if ( $this->groupString != null ) { $query = "{$query} {$this->groupString}"; } if ( $this->havingString != null ) { $query = "{$query} {$this->havingString}"; } if ( $this->orderString != null ) { $query = "{$query} {$this->orderString}"; } if ( $this->limitString != null ) { $query = "{$query} {$this->limitString}"; } return $query; }
php
public function getQuery() { if ( $this->selectString == null ) { throw new ezcQueryInvalidException( "SELECT", "select() was not called before getQuery()." ); } $query = "{$this->selectString}"; if ( $this->fromString != null ) { $query = "{$query} {$this->fromString}"; } if ( $this->whereString != null ) { $query = "{$query} {$this->whereString}"; } if ( $this->groupString != null ) { $query = "{$query} {$this->groupString}"; } if ( $this->havingString != null ) { $query = "{$query} {$this->havingString}"; } if ( $this->orderString != null ) { $query = "{$query} {$this->orderString}"; } if ( $this->limitString != null ) { $query = "{$query} {$this->limitString}"; } return $query; }
[ "public", "function", "getQuery", "(", ")", "{", "if", "(", "$", "this", "->", "selectString", "==", "null", ")", "{", "throw", "new", "ezcQueryInvalidException", "(", "\"SELECT\"", ",", "\"select() was not called before getQuery().\"", ")", ";", "}", "$", "query", "=", "\"{$this->selectString}\"", ";", "if", "(", "$", "this", "->", "fromString", "!=", "null", ")", "{", "$", "query", "=", "\"{$query} {$this->fromString}\"", ";", "}", "if", "(", "$", "this", "->", "whereString", "!=", "null", ")", "{", "$", "query", "=", "\"{$query} {$this->whereString}\"", ";", "}", "if", "(", "$", "this", "->", "groupString", "!=", "null", ")", "{", "$", "query", "=", "\"{$query} {$this->groupString}\"", ";", "}", "if", "(", "$", "this", "->", "havingString", "!=", "null", ")", "{", "$", "query", "=", "\"{$query} {$this->havingString}\"", ";", "}", "if", "(", "$", "this", "->", "orderString", "!=", "null", ")", "{", "$", "query", "=", "\"{$query} {$this->orderString}\"", ";", "}", "if", "(", "$", "this", "->", "limitString", "!=", "null", ")", "{", "$", "query", "=", "\"{$query} {$this->limitString}\"", ";", "}", "return", "$", "query", ";", "}" ]
Returns the complete select query string. This method uses the build methods to build the various parts of the select query. @todo add newlines? easier for debugging @throws ezcQueryInvalidException if it was not possible to build a valid query. @return string
[ "Returns", "the", "complete", "select", "query", "string", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/query_select.php#L864-L897
23,948
SporkCode/Spork
src/Mvc/Listener/ViewModelIdentity.php
ViewModelIdentity.injectIdentityModel
public function injectIdentityModel(MvcEvent $event) { $viewModel = $event->getViewModel(); if ($viewModel->getTemplate() == 'layout/layout') { $servies = $event->getApplication()->getServiceManager(); $appConfig = $servies->get('config'); if (isset($appConfig['view_model_identity'])) { $config = $appConfig['view_model_identity']; } else { throw new \Exception('view_model_identity key not found in configuration'); } if (!$servies->has($config['authenticationService'])) { throw new \Exception('Auththentication service not found'); } if (!$servies->has($config['identity'])) { throw new \Exception('Identity not found'); } $childViewModel = new IdentityViewModel(array( 'auth' => $servies->get($config['authenticationService']), 'identity' => $servies->get($config['identity']), )); if (isset($config['template'])) { $childViewModel->setTemplate($config['template']); } if (isset($config['captureTo'])) { $childViewModel->setCaptureTo($config['captureTo']); } $viewModel->addChild($childViewModel); } }
php
public function injectIdentityModel(MvcEvent $event) { $viewModel = $event->getViewModel(); if ($viewModel->getTemplate() == 'layout/layout') { $servies = $event->getApplication()->getServiceManager(); $appConfig = $servies->get('config'); if (isset($appConfig['view_model_identity'])) { $config = $appConfig['view_model_identity']; } else { throw new \Exception('view_model_identity key not found in configuration'); } if (!$servies->has($config['authenticationService'])) { throw new \Exception('Auththentication service not found'); } if (!$servies->has($config['identity'])) { throw new \Exception('Identity not found'); } $childViewModel = new IdentityViewModel(array( 'auth' => $servies->get($config['authenticationService']), 'identity' => $servies->get($config['identity']), )); if (isset($config['template'])) { $childViewModel->setTemplate($config['template']); } if (isset($config['captureTo'])) { $childViewModel->setCaptureTo($config['captureTo']); } $viewModel->addChild($childViewModel); } }
[ "public", "function", "injectIdentityModel", "(", "MvcEvent", "$", "event", ")", "{", "$", "viewModel", "=", "$", "event", "->", "getViewModel", "(", ")", ";", "if", "(", "$", "viewModel", "->", "getTemplate", "(", ")", "==", "'layout/layout'", ")", "{", "$", "servies", "=", "$", "event", "->", "getApplication", "(", ")", "->", "getServiceManager", "(", ")", ";", "$", "appConfig", "=", "$", "servies", "->", "get", "(", "'config'", ")", ";", "if", "(", "isset", "(", "$", "appConfig", "[", "'view_model_identity'", "]", ")", ")", "{", "$", "config", "=", "$", "appConfig", "[", "'view_model_identity'", "]", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'view_model_identity key not found in configuration'", ")", ";", "}", "if", "(", "!", "$", "servies", "->", "has", "(", "$", "config", "[", "'authenticationService'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Auththentication service not found'", ")", ";", "}", "if", "(", "!", "$", "servies", "->", "has", "(", "$", "config", "[", "'identity'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Identity not found'", ")", ";", "}", "$", "childViewModel", "=", "new", "IdentityViewModel", "(", "array", "(", "'auth'", "=>", "$", "servies", "->", "get", "(", "$", "config", "[", "'authenticationService'", "]", ")", ",", "'identity'", "=>", "$", "servies", "->", "get", "(", "$", "config", "[", "'identity'", "]", ")", ",", ")", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "'template'", "]", ")", ")", "{", "$", "childViewModel", "->", "setTemplate", "(", "$", "config", "[", "'template'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'captureTo'", "]", ")", ")", "{", "$", "childViewModel", "->", "setCaptureTo", "(", "$", "config", "[", "'captureTo'", "]", ")", ";", "}", "$", "viewModel", "->", "addChild", "(", "$", "childViewModel", ")", ";", "}", "}" ]
Inject identity view model into layout @param MvcEvent $event @throws \Exception
[ "Inject", "identity", "view", "model", "into", "layout" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/ViewModelIdentity.php#L60-L89
23,949
FriendsOfApi/phraseapp
src/Api/Key.php
Key.create
public function create(string $projectKey, string $name, array $params = []) { $params['name'] = $name; $response = $this->httpPost(sprintf('/api/v2/projects/%s/keys', $projectKey), $params); if (!$this->hydrator) { return $response; } if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { $this->handleErrors($response); } return $this->hydrator->hydrate($response, KeyCreated::class); }
php
public function create(string $projectKey, string $name, array $params = []) { $params['name'] = $name; $response = $this->httpPost(sprintf('/api/v2/projects/%s/keys', $projectKey), $params); if (!$this->hydrator) { return $response; } if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { $this->handleErrors($response); } return $this->hydrator->hydrate($response, KeyCreated::class); }
[ "public", "function", "create", "(", "string", "$", "projectKey", ",", "string", "$", "name", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "params", "[", "'name'", "]", "=", "$", "name", ";", "$", "response", "=", "$", "this", "->", "httpPost", "(", "sprintf", "(", "'/api/v2/projects/%s/keys'", ",", "$", "projectKey", ")", ",", "$", "params", ")", ";", "if", "(", "!", "$", "this", "->", "hydrator", ")", "{", "return", "$", "response", ";", "}", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "!==", "200", "&&", "$", "response", "->", "getStatusCode", "(", ")", "!==", "201", ")", "{", "$", "this", "->", "handleErrors", "(", "$", "response", ")", ";", "}", "return", "$", "this", "->", "hydrator", "->", "hydrate", "(", "$", "response", ",", "KeyCreated", "::", "class", ")", ";", "}" ]
Create a new key. @param string $projectKey @param string $localeId @param array $params @return KeyCreated|ResponseInterface
[ "Create", "a", "new", "key", "." ]
1553bf857eb0858f9a7eb905b085864d24f80886
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Api/Key.php#L30-L45
23,950
FriendsOfApi/phraseapp
src/Api/Key.php
Key.search
public function search(string $projectKey, array $params = []) { $q = ''; if (isset($params['tags'])) { $q .= 'tags:'.$params['tags'].' '; } if (isset($params['name'])) { $q .= 'name:'.$params['name'].' '; } if (isset($params['ids'])) { $q .= 'ids:'.$params['ids'].' '; } if (!empty($q)) { $params['q'] = $q; } $response = $this->httpPost(sprintf('/api/v2/projects/%s/keys/search', $projectKey), $params); if (!$this->hydrator) { return $response; } if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { $this->handleErrors($response); } return $this->hydrator->hydrate($response, KeySearchResults::class); }
php
public function search(string $projectKey, array $params = []) { $q = ''; if (isset($params['tags'])) { $q .= 'tags:'.$params['tags'].' '; } if (isset($params['name'])) { $q .= 'name:'.$params['name'].' '; } if (isset($params['ids'])) { $q .= 'ids:'.$params['ids'].' '; } if (!empty($q)) { $params['q'] = $q; } $response = $this->httpPost(sprintf('/api/v2/projects/%s/keys/search', $projectKey), $params); if (!$this->hydrator) { return $response; } if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) { $this->handleErrors($response); } return $this->hydrator->hydrate($response, KeySearchResults::class); }
[ "public", "function", "search", "(", "string", "$", "projectKey", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "q", "=", "''", ";", "if", "(", "isset", "(", "$", "params", "[", "'tags'", "]", ")", ")", "{", "$", "q", ".=", "'tags:'", ".", "$", "params", "[", "'tags'", "]", ".", "' '", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'name'", "]", ")", ")", "{", "$", "q", ".=", "'name:'", ".", "$", "params", "[", "'name'", "]", ".", "' '", ";", "}", "if", "(", "isset", "(", "$", "params", "[", "'ids'", "]", ")", ")", "{", "$", "q", ".=", "'ids:'", ".", "$", "params", "[", "'ids'", "]", ".", "' '", ";", "}", "if", "(", "!", "empty", "(", "$", "q", ")", ")", "{", "$", "params", "[", "'q'", "]", "=", "$", "q", ";", "}", "$", "response", "=", "$", "this", "->", "httpPost", "(", "sprintf", "(", "'/api/v2/projects/%s/keys/search'", ",", "$", "projectKey", ")", ",", "$", "params", ")", ";", "if", "(", "!", "$", "this", "->", "hydrator", ")", "{", "return", "$", "response", ";", "}", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "!==", "200", "&&", "$", "response", "->", "getStatusCode", "(", ")", "!==", "201", ")", "{", "$", "this", "->", "handleErrors", "(", "$", "response", ")", ";", "}", "return", "$", "this", "->", "hydrator", "->", "hydrate", "(", "$", "response", ",", "KeySearchResults", "::", "class", ")", ";", "}" ]
Search keys. @param string $projectKey @param array $params @return KeySearchResults|ResponseInterface
[ "Search", "keys", "." ]
1553bf857eb0858f9a7eb905b085864d24f80886
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Api/Key.php#L55-L86
23,951
FriendsOfApi/phraseapp
src/Api/Key.php
Key.delete
public function delete(string $projectKey, string $keyId) { $response = $this->httpDelete(sprintf('/api/v2/projects/%s/keys/%s', $projectKey, $keyId)); if (!$this->hydrator) { return $response; } if ($response->getStatusCode() !== 204) { $this->handleErrors($response); } return true; }
php
public function delete(string $projectKey, string $keyId) { $response = $this->httpDelete(sprintf('/api/v2/projects/%s/keys/%s', $projectKey, $keyId)); if (!$this->hydrator) { return $response; } if ($response->getStatusCode() !== 204) { $this->handleErrors($response); } return true; }
[ "public", "function", "delete", "(", "string", "$", "projectKey", ",", "string", "$", "keyId", ")", "{", "$", "response", "=", "$", "this", "->", "httpDelete", "(", "sprintf", "(", "'/api/v2/projects/%s/keys/%s'", ",", "$", "projectKey", ",", "$", "keyId", ")", ")", ";", "if", "(", "!", "$", "this", "->", "hydrator", ")", "{", "return", "$", "response", ";", "}", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "!==", "204", ")", "{", "$", "this", "->", "handleErrors", "(", "$", "response", ")", ";", "}", "return", "true", ";", "}" ]
Delete a key. @param string $projectKey @param string $keyId @return bool|ResponseInterface
[ "Delete", "a", "key", "." ]
1553bf857eb0858f9a7eb905b085864d24f80886
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Api/Key.php#L96-L109
23,952
phpgears/dto
src/ScalarPayloadBehaviour.php
ScalarPayloadBehaviour.setPayloadParameter
private function setPayloadParameter(string $parameter, $value): void { $this->checkParameterType($value); $this->defaultSetPayloadParameter($parameter, $value); }
php
private function setPayloadParameter(string $parameter, $value): void { $this->checkParameterType($value); $this->defaultSetPayloadParameter($parameter, $value); }
[ "private", "function", "setPayloadParameter", "(", "string", "$", "parameter", ",", "$", "value", ")", ":", "void", "{", "$", "this", "->", "checkParameterType", "(", "$", "value", ")", ";", "$", "this", "->", "defaultSetPayloadParameter", "(", "$", "parameter", ",", "$", "value", ")", ";", "}" ]
Set payload parameter. @param string $parameter @param mixed $value
[ "Set", "payload", "parameter", "." ]
404b2cdea108538b55caa261c29280062dd0e3db
https://github.com/phpgears/dto/blob/404b2cdea108538b55caa261c29280062dd0e3db/src/ScalarPayloadBehaviour.php#L33-L38
23,953
phpgears/dto
src/ScalarPayloadBehaviour.php
ScalarPayloadBehaviour.checkParameterType
final protected function checkParameterType($value): void { if (\is_array($value)) { foreach ($value as $val) { $this->checkParameterType($val); } } elseif ($value !== null && !\is_scalar($value)) { throw new InvalidScalarParameterException(\sprintf( 'Class %s can only accept scalar payload parameters, %s given', self::class, \is_object($value) ? \get_class($value) : \gettype($value) )); } }
php
final protected function checkParameterType($value): void { if (\is_array($value)) { foreach ($value as $val) { $this->checkParameterType($val); } } elseif ($value !== null && !\is_scalar($value)) { throw new InvalidScalarParameterException(\sprintf( 'Class %s can only accept scalar payload parameters, %s given', self::class, \is_object($value) ? \get_class($value) : \gettype($value) )); } }
[ "final", "protected", "function", "checkParameterType", "(", "$", "value", ")", ":", "void", "{", "if", "(", "\\", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "val", ")", "{", "$", "this", "->", "checkParameterType", "(", "$", "val", ")", ";", "}", "}", "elseif", "(", "$", "value", "!==", "null", "&&", "!", "\\", "is_scalar", "(", "$", "value", ")", ")", "{", "throw", "new", "InvalidScalarParameterException", "(", "\\", "sprintf", "(", "'Class %s can only accept scalar payload parameters, %s given'", ",", "self", "::", "class", ",", "\\", "is_object", "(", "$", "value", ")", "?", "\\", "get_class", "(", "$", "value", ")", ":", "\\", "gettype", "(", "$", "value", ")", ")", ")", ";", "}", "}" ]
Check only scalar types allowed. @param mixed $value @throws InvalidScalarParameterException
[ "Check", "only", "scalar", "types", "allowed", "." ]
404b2cdea108538b55caa261c29280062dd0e3db
https://github.com/phpgears/dto/blob/404b2cdea108538b55caa261c29280062dd0e3db/src/ScalarPayloadBehaviour.php#L47-L60
23,954
petrica/php-statsd-system
Model/Process/TopProcessParser.php
TopProcessParser.parse
public function parse() { $raw = $this->getRaw(); $count = count($raw); for ($i = 7; $i < $count; $i++) { $line = $raw[$i]; $process = new Process( $line[11], $line[0], floatval($line[8]), floatval($line[9]) ); $this->processes[] = $process; } }
php
public function parse() { $raw = $this->getRaw(); $count = count($raw); for ($i = 7; $i < $count; $i++) { $line = $raw[$i]; $process = new Process( $line[11], $line[0], floatval($line[8]), floatval($line[9]) ); $this->processes[] = $process; } }
[ "public", "function", "parse", "(", ")", "{", "$", "raw", "=", "$", "this", "->", "getRaw", "(", ")", ";", "$", "count", "=", "count", "(", "$", "raw", ")", ";", "for", "(", "$", "i", "=", "7", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "line", "=", "$", "raw", "[", "$", "i", "]", ";", "$", "process", "=", "new", "Process", "(", "$", "line", "[", "11", "]", ",", "$", "line", "[", "0", "]", ",", "floatval", "(", "$", "line", "[", "8", "]", ")", ",", "floatval", "(", "$", "line", "[", "9", "]", ")", ")", ";", "$", "this", "->", "processes", "[", "]", "=", "$", "process", ";", "}", "}" ]
Run the parsing process
[ "Run", "the", "parsing", "process" ]
c476be3514a631a605737888bb8f6eb096789c9d
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Model/Process/TopProcessParser.php#L37-L53
23,955
Daursu/xero
src/Daursu/Xero/models/Collection.php
Collection.setItems
public function setItems($items = array()) { $this->items = array(); foreach ($items as $key => $item) { if ( ! is_numeric($key) && is_array($item)) { // Check to see if the item contains many subitems if (array_key_exists('1', $item)) { $this->setItems($item); return false; } else { // This is a single item $this->push($item); } } elseif (is_array($item)) { $this->push($item); } } }
php
public function setItems($items = array()) { $this->items = array(); foreach ($items as $key => $item) { if ( ! is_numeric($key) && is_array($item)) { // Check to see if the item contains many subitems if (array_key_exists('1', $item)) { $this->setItems($item); return false; } else { // This is a single item $this->push($item); } } elseif (is_array($item)) { $this->push($item); } } }
[ "public", "function", "setItems", "(", "$", "items", "=", "array", "(", ")", ")", "{", "$", "this", "->", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "items", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "key", ")", "&&", "is_array", "(", "$", "item", ")", ")", "{", "// Check to see if the item contains many subitems", "if", "(", "array_key_exists", "(", "'1'", ",", "$", "item", ")", ")", "{", "$", "this", "->", "setItems", "(", "$", "item", ")", ";", "return", "false", ";", "}", "else", "{", "// This is a single item", "$", "this", "->", "push", "(", "$", "item", ")", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "item", ")", ")", "{", "$", "this", "->", "push", "(", "$", "item", ")", ";", "}", "}", "}" ]
Set all the items at once @param array $items
[ "Set", "all", "the", "items", "at", "once" ]
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/Collection.php#L39-L61
23,956
Daursu/xero
src/Daursu/Xero/models/Collection.php
Collection.push
public function push($item) { $full_class_name = $this->getFullClassName(); if (is_array($item)) { array_push($this->items, new $full_class_name($item)); } elseif ($item instanceof $full_class_name) { array_push($this->items, $item); } }
php
public function push($item) { $full_class_name = $this->getFullClassName(); if (is_array($item)) { array_push($this->items, new $full_class_name($item)); } elseif ($item instanceof $full_class_name) { array_push($this->items, $item); } }
[ "public", "function", "push", "(", "$", "item", ")", "{", "$", "full_class_name", "=", "$", "this", "->", "getFullClassName", "(", ")", ";", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "array_push", "(", "$", "this", "->", "items", ",", "new", "$", "full_class_name", "(", "$", "item", ")", ")", ";", "}", "elseif", "(", "$", "item", "instanceof", "$", "full_class_name", ")", "{", "array_push", "(", "$", "this", "->", "items", ",", "$", "item", ")", ";", "}", "}" ]
Add a new item to the collection @param mixed $item @return void
[ "Add", "a", "new", "item", "to", "the", "collection" ]
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/Collection.php#L69-L79
23,957
surebert/surebert-framework
src/sb/Validate/Numbers.php
Numbers.isInt
public static function isInt($int) { return (is_string($int) || is_int($int) || is_float($int)) && ctype_digit((string)$int); }
php
public static function isInt($int) { return (is_string($int) || is_int($int) || is_float($int)) && ctype_digit((string)$int); }
[ "public", "static", "function", "isInt", "(", "$", "int", ")", "{", "return", "(", "is_string", "(", "$", "int", ")", "||", "is_int", "(", "$", "int", ")", "||", "is_float", "(", "$", "int", ")", ")", "&&", "ctype_digit", "(", "(", "string", ")", "$", "int", ")", ";", "}" ]
Checks to see if str, float, or int type and represents whole number @param mixed $int @return boolean
[ "Checks", "to", "see", "if", "str", "float", "or", "int", "type", "and", "represents", "whole", "number" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Validate/Numbers.php#L16-L20
23,958
contao-community-alliance/url-builder
src/UrlBuilder.php
UrlBuilder.setQueryParameter
public function setQueryParameter($name, $value) { $this->query[(string) $name] = (string) $value; return $this; }
php
public function setQueryParameter($name, $value) { $this->query[(string) $name] = (string) $value; return $this; }
[ "public", "function", "setQueryParameter", "(", "$", "name", ",", "$", "value", ")", "{", "$", "this", "->", "query", "[", "(", "string", ")", "$", "name", "]", "=", "(", "string", ")", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set a query parameter. @param string $name The name of the query parameter. @param string $value The value of the query parameter. @return UrlBuilder
[ "Set", "a", "query", "parameter", "." ]
2d730649058f3d3af41175358ee92f0659de08a1
https://github.com/contao-community-alliance/url-builder/blob/2d730649058f3d3af41175358ee92f0659de08a1/src/UrlBuilder.php#L325-L330
23,959
contao-community-alliance/url-builder
src/UrlBuilder.php
UrlBuilder.getQueryParameter
public function getQueryParameter($name) { return isset($this->query[$name]) ? $this->query[$name] : null; }
php
public function getQueryParameter($name) { return isset($this->query[$name]) ? $this->query[$name] : null; }
[ "public", "function", "getQueryParameter", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "query", "[", "$", "name", "]", ")", "?", "$", "this", "->", "query", "[", "$", "name", "]", ":", "null", ";", "}" ]
Retrieve the value of a query parameter. @param string $name The name of the query parameter. @return string|null
[ "Retrieve", "the", "value", "of", "a", "query", "parameter", "." ]
2d730649058f3d3af41175358ee92f0659de08a1
https://github.com/contao-community-alliance/url-builder/blob/2d730649058f3d3af41175358ee92f0659de08a1/src/UrlBuilder.php#L411-L414
23,960
contao-community-alliance/url-builder
src/UrlBuilder.php
UrlBuilder.addQueryParameters
public function addQueryParameters($queryString) { $queries = preg_split('/&(amp;)?/i', $queryString); foreach ($queries as $v) { $explode = explode('=', $v); $name = $explode[0]; $value = isset($explode[1]) ? $explode[1] : ''; $rpos = strrpos($name, '?'); if ($rpos !== false) { $name = substr($name, ($rpos + 1)); } if (empty($name)) { continue; } $this->setQueryParameter($name, $value); } return $this; }
php
public function addQueryParameters($queryString) { $queries = preg_split('/&(amp;)?/i', $queryString); foreach ($queries as $v) { $explode = explode('=', $v); $name = $explode[0]; $value = isset($explode[1]) ? $explode[1] : ''; $rpos = strrpos($name, '?'); if ($rpos !== false) { $name = substr($name, ($rpos + 1)); } if (empty($name)) { continue; } $this->setQueryParameter($name, $value); } return $this; }
[ "public", "function", "addQueryParameters", "(", "$", "queryString", ")", "{", "$", "queries", "=", "preg_split", "(", "'/&(amp;)?/i'", ",", "$", "queryString", ")", ";", "foreach", "(", "$", "queries", "as", "$", "v", ")", "{", "$", "explode", "=", "explode", "(", "'='", ",", "$", "v", ")", ";", "$", "name", "=", "$", "explode", "[", "0", "]", ";", "$", "value", "=", "isset", "(", "$", "explode", "[", "1", "]", ")", "?", "$", "explode", "[", "1", "]", ":", "''", ";", "$", "rpos", "=", "strrpos", "(", "$", "name", ",", "'?'", ")", ";", "if", "(", "$", "rpos", "!==", "false", ")", "{", "$", "name", "=", "substr", "(", "$", "name", ",", "(", "$", "rpos", "+", "1", ")", ")", ";", "}", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "setQueryParameter", "(", "$", "name", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Absorb the query parameters from a query string. @param string $queryString The query string. @return UrlBuilder
[ "Absorb", "the", "query", "parameters", "from", "a", "query", "string", "." ]
2d730649058f3d3af41175358ee92f0659de08a1
https://github.com/contao-community-alliance/url-builder/blob/2d730649058f3d3af41175358ee92f0659de08a1/src/UrlBuilder.php#L423-L446
23,961
contao-community-alliance/url-builder
src/UrlBuilder.php
UrlBuilder.getBaseUrl
public function getBaseUrl() { $url = ''; if (isset($this->scheme)) { if ('' !== $this->scheme) { $url .= $this->scheme . ':'; } $url .= '//'; } if (isset($this->user)) { $url .= $this->user; if (isset($this->pass)) { $url .= ':' . $this->pass; } $url .= '@'; } $url .= $this->host; if (isset($this->port)) { $url .= ':' . $this->port; } if (isset($this->path)) { if ($url != '' && $this->path[0] !== '/') { $url .= '/'; } $url .= $this->path; } return $url; }
php
public function getBaseUrl() { $url = ''; if (isset($this->scheme)) { if ('' !== $this->scheme) { $url .= $this->scheme . ':'; } $url .= '//'; } if (isset($this->user)) { $url .= $this->user; if (isset($this->pass)) { $url .= ':' . $this->pass; } $url .= '@'; } $url .= $this->host; if (isset($this->port)) { $url .= ':' . $this->port; } if (isset($this->path)) { if ($url != '' && $this->path[0] !== '/') { $url .= '/'; } $url .= $this->path; } return $url; }
[ "public", "function", "getBaseUrl", "(", ")", "{", "$", "url", "=", "''", ";", "if", "(", "isset", "(", "$", "this", "->", "scheme", ")", ")", "{", "if", "(", "''", "!==", "$", "this", "->", "scheme", ")", "{", "$", "url", ".=", "$", "this", "->", "scheme", ".", "':'", ";", "}", "$", "url", ".=", "'//'", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "user", ")", ")", "{", "$", "url", ".=", "$", "this", "->", "user", ";", "if", "(", "isset", "(", "$", "this", "->", "pass", ")", ")", "{", "$", "url", ".=", "':'", ".", "$", "this", "->", "pass", ";", "}", "$", "url", ".=", "'@'", ";", "}", "$", "url", ".=", "$", "this", "->", "host", ";", "if", "(", "isset", "(", "$", "this", "->", "port", ")", ")", "{", "$", "url", ".=", "':'", ".", "$", "this", "->", "port", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "path", ")", ")", "{", "if", "(", "$", "url", "!=", "''", "&&", "$", "this", "->", "path", "[", "0", "]", "!==", "'/'", ")", "{", "$", "url", ".=", "'/'", ";", "}", "$", "url", ".=", "$", "this", "->", "path", ";", "}", "return", "$", "url", ";", "}" ]
Retrieve the base url. The base URL is the url without query part and fragment. @return string|null
[ "Retrieve", "the", "base", "url", "." ]
2d730649058f3d3af41175358ee92f0659de08a1
https://github.com/contao-community-alliance/url-builder/blob/2d730649058f3d3af41175358ee92f0659de08a1/src/UrlBuilder.php#L496-L531
23,962
contao-community-alliance/url-builder
src/UrlBuilder.php
UrlBuilder.getUrl
public function getUrl() { $url = $this->getBaseUrl(); if ($query = $this->getQueryString()) { if ($url) { if (!$this->path) { $url .= '/'; } $url .= '?'; } $url .= $query; } if (isset($this->fragment)) { $url .= '#' . $this->fragment; } return $url; }
php
public function getUrl() { $url = $this->getBaseUrl(); if ($query = $this->getQueryString()) { if ($url) { if (!$this->path) { $url .= '/'; } $url .= '?'; } $url .= $query; } if (isset($this->fragment)) { $url .= '#' . $this->fragment; } return $url; }
[ "public", "function", "getUrl", "(", ")", "{", "$", "url", "=", "$", "this", "->", "getBaseUrl", "(", ")", ";", "if", "(", "$", "query", "=", "$", "this", "->", "getQueryString", "(", ")", ")", "{", "if", "(", "$", "url", ")", "{", "if", "(", "!", "$", "this", "->", "path", ")", "{", "$", "url", ".=", "'/'", ";", "}", "$", "url", ".=", "'?'", ";", "}", "$", "url", ".=", "$", "query", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "fragment", ")", ")", "{", "$", "url", ".=", "'#'", ".", "$", "this", "->", "fragment", ";", "}", "return", "$", "url", ";", "}" ]
Retrieve the complete generated URL. @return string
[ "Retrieve", "the", "complete", "generated", "URL", "." ]
2d730649058f3d3af41175358ee92f0659de08a1
https://github.com/contao-community-alliance/url-builder/blob/2d730649058f3d3af41175358ee92f0659de08a1/src/UrlBuilder.php#L538-L558
23,963
contao-community-alliance/url-builder
src/UrlBuilder.php
UrlBuilder.parseUrl
private function parseUrl($url) { $parsed = parse_url($url); if ((count($parsed) === 1) && isset($parsed['path']) && (0 === strpos($parsed['path'], '?') || false !== strpos($parsed['path'], '&')) ) { $parsed = array( 'query' => $parsed['path'] ); return $parsed; } return $parsed; }
php
private function parseUrl($url) { $parsed = parse_url($url); if ((count($parsed) === 1) && isset($parsed['path']) && (0 === strpos($parsed['path'], '?') || false !== strpos($parsed['path'], '&')) ) { $parsed = array( 'query' => $parsed['path'] ); return $parsed; } return $parsed; }
[ "private", "function", "parseUrl", "(", "$", "url", ")", "{", "$", "parsed", "=", "parse_url", "(", "$", "url", ")", ";", "if", "(", "(", "count", "(", "$", "parsed", ")", "===", "1", ")", "&&", "isset", "(", "$", "parsed", "[", "'path'", "]", ")", "&&", "(", "0", "===", "strpos", "(", "$", "parsed", "[", "'path'", "]", ",", "'?'", ")", "||", "false", "!==", "strpos", "(", "$", "parsed", "[", "'path'", "]", ",", "'&'", ")", ")", ")", "{", "$", "parsed", "=", "array", "(", "'query'", "=>", "$", "parsed", "[", "'path'", "]", ")", ";", "return", "$", "parsed", ";", "}", "return", "$", "parsed", ";", "}" ]
Parse the URL and fix up if it only contains only one element to make it the query element. @param string $url The url to parse. @return array
[ "Parse", "the", "URL", "and", "fix", "up", "if", "it", "only", "contains", "only", "one", "element", "to", "make", "it", "the", "query", "element", "." ]
2d730649058f3d3af41175358ee92f0659de08a1
https://github.com/contao-community-alliance/url-builder/blob/2d730649058f3d3af41175358ee92f0659de08a1/src/UrlBuilder.php#L567-L583
23,964
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.setWidth
function setWidth($width) { if(!preg_match('!^(\d+)(.*)$!',$width,$_match)) return false; $_width = $_match[1]; $_type = $_match[2]; if($_type == '%') $this->width = $_width . '%'; else $this->width = $_width . 'px'; return true; }
php
function setWidth($width) { if(!preg_match('!^(\d+)(.*)$!',$width,$_match)) return false; $_width = $_match[1]; $_type = $_match[2]; if($_type == '%') $this->width = $_width . '%'; else $this->width = $_width . 'px'; return true; }
[ "function", "setWidth", "(", "$", "width", ")", "{", "if", "(", "!", "preg_match", "(", "'!^(\\d+)(.*)$!'", ",", "$", "width", ",", "$", "_match", ")", ")", "return", "false", ";", "$", "_width", "=", "$", "_match", "[", "1", "]", ";", "$", "_type", "=", "$", "_match", "[", "2", "]", ";", "if", "(", "$", "_type", "==", "'%'", ")", "$", "this", "->", "width", "=", "$", "_width", ".", "'%'", ";", "else", "$", "this", "->", "width", "=", "$", "_width", ".", "'px'", ";", "return", "true", ";", "}" ]
sets the width of the map @param string $width @return string|false Width or false if not a valid value
[ "sets", "the", "width", "of", "the", "map" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L679-L691
23,965
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.setHeight
function setHeight($height) { if(!preg_match('!^(\d+)(.*)$!',$height,$_match)) return false; $_height = $_match[1]; $_type = $_match[2]; if($_type == '%') $this->height = $_height . '%'; else $this->height = $_height . 'px'; return true; }
php
function setHeight($height) { if(!preg_match('!^(\d+)(.*)$!',$height,$_match)) return false; $_height = $_match[1]; $_type = $_match[2]; if($_type == '%') $this->height = $_height . '%'; else $this->height = $_height . 'px'; return true; }
[ "function", "setHeight", "(", "$", "height", ")", "{", "if", "(", "!", "preg_match", "(", "'!^(\\d+)(.*)$!'", ",", "$", "height", ",", "$", "_match", ")", ")", "return", "false", ";", "$", "_height", "=", "$", "_match", "[", "1", "]", ";", "$", "_type", "=", "$", "_match", "[", "2", "]", ";", "if", "(", "$", "_type", "==", "'%'", ")", "$", "this", "->", "height", "=", "$", "_height", ".", "'%'", ";", "else", "$", "this", "->", "height", "=", "$", "_height", ".", "'px'", ";", "return", "true", ";", "}" ]
sets the height of the map @param string $height @return string|false Height or false if not a valid value
[ "sets", "the", "height", "of", "the", "map" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L699-L711
23,966
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.setClusterOptions
function setClusterOptions($zoom="null", $gridsize="null", $styles="null"){ $this->marker_clusterer_options["maxZoom"]=$zoom; $this->marker_clusterer_options["gridSize"]=$gridsize; $this->marker_clusterer_options["styles"]=$styles; }
php
function setClusterOptions($zoom="null", $gridsize="null", $styles="null"){ $this->marker_clusterer_options["maxZoom"]=$zoom; $this->marker_clusterer_options["gridSize"]=$gridsize; $this->marker_clusterer_options["styles"]=$styles; }
[ "function", "setClusterOptions", "(", "$", "zoom", "=", "\"null\"", ",", "$", "gridsize", "=", "\"null\"", ",", "$", "styles", "=", "\"null\"", ")", "{", "$", "this", "->", "marker_clusterer_options", "[", "\"maxZoom\"", "]", "=", "$", "zoom", ";", "$", "this", "->", "marker_clusterer_options", "[", "\"gridSize\"", "]", "=", "$", "gridsize", ";", "$", "this", "->", "marker_clusterer_options", "[", "\"styles\"", "]", "=", "$", "styles", ";", "}" ]
set clustering options
[ "set", "clustering", "options" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L1180-L1184
23,967
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.addMarkerOpener
function addMarkerOpener($marker_id, $dom_id){ if($this->info_window === false || !isset($this->_markers[$marker_id])) return false; if(!isset($this->_markers[$marker_id]["openers"])) $this->_markers[$marker_id]["openers"] = array(); $this->_markers[$marker_id]["openers"][] = $dom_id; }
php
function addMarkerOpener($marker_id, $dom_id){ if($this->info_window === false || !isset($this->_markers[$marker_id])) return false; if(!isset($this->_markers[$marker_id]["openers"])) $this->_markers[$marker_id]["openers"] = array(); $this->_markers[$marker_id]["openers"][] = $dom_id; }
[ "function", "addMarkerOpener", "(", "$", "marker_id", ",", "$", "dom_id", ")", "{", "if", "(", "$", "this", "->", "info_window", "===", "false", "||", "!", "isset", "(", "$", "this", "->", "_markers", "[", "$", "marker_id", "]", ")", ")", "return", "false", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "_markers", "[", "$", "marker_id", "]", "[", "\"openers\"", "]", ")", ")", "$", "this", "->", "_markers", "[", "$", "marker_id", "]", "[", "\"openers\"", "]", "=", "array", "(", ")", ";", "$", "this", "->", "_markers", "[", "$", "marker_id", "]", "[", "\"openers\"", "]", "[", "]", "=", "$", "dom_id", ";", "}" ]
adds a DOM object ID to specified marker to open the marker's info window. Does nothing if the info windows is disabled. @param string $marker_id ID of the marker to associate to @param string $dom_id ID of the DOM object to use to open marker info window @return bool true/false status
[ "adds", "a", "DOM", "object", "ID", "to", "specified", "marker", "to", "open", "the", "marker", "s", "info", "window", ".", "Does", "nothing", "if", "the", "info", "windows", "is", "disabled", "." ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L1346-L1352
23,968
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.addPolyLineByAddress
function addPolyLineByAddress($address1,$address2,$id=false,$color='',$weight=0,$opacity=0) { if(($_geocode1 = $this->getGeocode($address1)) === false) return false; if(($_geocode2 = $this->getGeocode($address2)) === false) return false; return $this->addPolyLineByCoords($_geocode1['lon'],$_geocode1['lat'],$_geocode2['lon'],$_geocode2['lat'],$id,$color,$weight,$opacity); }
php
function addPolyLineByAddress($address1,$address2,$id=false,$color='',$weight=0,$opacity=0) { if(($_geocode1 = $this->getGeocode($address1)) === false) return false; if(($_geocode2 = $this->getGeocode($address2)) === false) return false; return $this->addPolyLineByCoords($_geocode1['lon'],$_geocode1['lat'],$_geocode2['lon'],$_geocode2['lat'],$id,$color,$weight,$opacity); }
[ "function", "addPolyLineByAddress", "(", "$", "address1", ",", "$", "address2", ",", "$", "id", "=", "false", ",", "$", "color", "=", "''", ",", "$", "weight", "=", "0", ",", "$", "opacity", "=", "0", ")", "{", "if", "(", "(", "$", "_geocode1", "=", "$", "this", "->", "getGeocode", "(", "$", "address1", ")", ")", "===", "false", ")", "return", "false", ";", "if", "(", "(", "$", "_geocode2", "=", "$", "this", "->", "getGeocode", "(", "$", "address2", ")", ")", "===", "false", ")", "return", "false", ";", "return", "$", "this", "->", "addPolyLineByCoords", "(", "$", "_geocode1", "[", "'lon'", "]", ",", "$", "_geocode1", "[", "'lat'", "]", ",", "$", "_geocode2", "[", "'lon'", "]", ",", "$", "_geocode2", "[", "'lat'", "]", ",", "$", "id", ",", "$", "color", ",", "$", "weight", ",", "$", "opacity", ")", ";", "}" ]
adds a map polyline by address if color, weight and opacity are not defined, use the google maps defaults @param string $address1 the map address to draw from @param string $address2 the map address to draw to @param string $id An array id to use to append coordinates to a line @param string $color the color of the line (format: #000000) @param string $weight the weight of the line in pixels @param string $opacity the line opacity (percentage) @return bool|int Array id of newly added point or false
[ "adds", "a", "map", "polyline", "by", "address", "if", "color", "weight", "and", "opacity", "are", "not", "defined", "use", "the", "google", "maps", "defaults" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L1424-L1430
23,969
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.addPolyLineByCoords
function addPolyLineByCoords($lon1,$lat1,$lon2,$lat2,$id=false,$color='',$weight=0,$opacity=0) { if($id !== false && isset($this->_polylines[$id]) && is_array($this->_polylines[$id])){ $_polyline = $this->_polylines[$id]; }else{ //only set color,weight,and opacity if new polyline $_polyline = array( "color"=>$color, "weight"=>$weight, "opacity"=>$opacity ); } if(!isset($_polyline['coords']) || !is_array($_polyline['coords'])){ $_polyline['coords'] = array( "0"=> array("lat"=>$lat1, "long"=>$lon1), "1"=> array("lat"=>$lat2, "long"=>$lon2) ); }else{ $last_index = sizeof($_polyline['coords'])-1; //check if lat1/lon1 point is already on polyline if($_polyline['coords'][$last_index]["lat"] != $lat1 || $_polyline['coords'][$last_index]["long"] != $lon1){ $_polyline['coords'][] = array("lat"=>$lat1, "long"=>$lon1); } $_polyline['coords'][] = array("lat"=>$lat2, "long"=>$lon2); } if($id === false){ $this->_polylines[] = $_polyline; $id = count($this->_polylines) - 1; }else{ $this->_polylines[$id] = $_polyline; } $this->adjustCenterCoords($lon1,$lat1); $this->adjustCenterCoords($lon2,$lat2); // return index of polyline return $id; }
php
function addPolyLineByCoords($lon1,$lat1,$lon2,$lat2,$id=false,$color='',$weight=0,$opacity=0) { if($id !== false && isset($this->_polylines[$id]) && is_array($this->_polylines[$id])){ $_polyline = $this->_polylines[$id]; }else{ //only set color,weight,and opacity if new polyline $_polyline = array( "color"=>$color, "weight"=>$weight, "opacity"=>$opacity ); } if(!isset($_polyline['coords']) || !is_array($_polyline['coords'])){ $_polyline['coords'] = array( "0"=> array("lat"=>$lat1, "long"=>$lon1), "1"=> array("lat"=>$lat2, "long"=>$lon2) ); }else{ $last_index = sizeof($_polyline['coords'])-1; //check if lat1/lon1 point is already on polyline if($_polyline['coords'][$last_index]["lat"] != $lat1 || $_polyline['coords'][$last_index]["long"] != $lon1){ $_polyline['coords'][] = array("lat"=>$lat1, "long"=>$lon1); } $_polyline['coords'][] = array("lat"=>$lat2, "long"=>$lon2); } if($id === false){ $this->_polylines[] = $_polyline; $id = count($this->_polylines) - 1; }else{ $this->_polylines[$id] = $_polyline; } $this->adjustCenterCoords($lon1,$lat1); $this->adjustCenterCoords($lon2,$lat2); // return index of polyline return $id; }
[ "function", "addPolyLineByCoords", "(", "$", "lon1", ",", "$", "lat1", ",", "$", "lon2", ",", "$", "lat2", ",", "$", "id", "=", "false", ",", "$", "color", "=", "''", ",", "$", "weight", "=", "0", ",", "$", "opacity", "=", "0", ")", "{", "if", "(", "$", "id", "!==", "false", "&&", "isset", "(", "$", "this", "->", "_polylines", "[", "$", "id", "]", ")", "&&", "is_array", "(", "$", "this", "->", "_polylines", "[", "$", "id", "]", ")", ")", "{", "$", "_polyline", "=", "$", "this", "->", "_polylines", "[", "$", "id", "]", ";", "}", "else", "{", "//only set color,weight,and opacity if new polyline", "$", "_polyline", "=", "array", "(", "\"color\"", "=>", "$", "color", ",", "\"weight\"", "=>", "$", "weight", ",", "\"opacity\"", "=>", "$", "opacity", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "_polyline", "[", "'coords'", "]", ")", "||", "!", "is_array", "(", "$", "_polyline", "[", "'coords'", "]", ")", ")", "{", "$", "_polyline", "[", "'coords'", "]", "=", "array", "(", "\"0\"", "=>", "array", "(", "\"lat\"", "=>", "$", "lat1", ",", "\"long\"", "=>", "$", "lon1", ")", ",", "\"1\"", "=>", "array", "(", "\"lat\"", "=>", "$", "lat2", ",", "\"long\"", "=>", "$", "lon2", ")", ")", ";", "}", "else", "{", "$", "last_index", "=", "sizeof", "(", "$", "_polyline", "[", "'coords'", "]", ")", "-", "1", ";", "//check if lat1/lon1 point is already on polyline", "if", "(", "$", "_polyline", "[", "'coords'", "]", "[", "$", "last_index", "]", "[", "\"lat\"", "]", "!=", "$", "lat1", "||", "$", "_polyline", "[", "'coords'", "]", "[", "$", "last_index", "]", "[", "\"long\"", "]", "!=", "$", "lon1", ")", "{", "$", "_polyline", "[", "'coords'", "]", "[", "]", "=", "array", "(", "\"lat\"", "=>", "$", "lat1", ",", "\"long\"", "=>", "$", "lon1", ")", ";", "}", "$", "_polyline", "[", "'coords'", "]", "[", "]", "=", "array", "(", "\"lat\"", "=>", "$", "lat2", ",", "\"long\"", "=>", "$", "lon2", ")", ";", "}", "if", "(", "$", "id", "===", "false", ")", "{", "$", "this", "->", "_polylines", "[", "]", "=", "$", "_polyline", ";", "$", "id", "=", "count", "(", "$", "this", "->", "_polylines", ")", "-", "1", ";", "}", "else", "{", "$", "this", "->", "_polylines", "[", "$", "id", "]", "=", "$", "_polyline", ";", "}", "$", "this", "->", "adjustCenterCoords", "(", "$", "lon1", ",", "$", "lat1", ")", ";", "$", "this", "->", "adjustCenterCoords", "(", "$", "lon2", ",", "$", "lat2", ")", ";", "// return index of polyline", "return", "$", "id", ";", "}" ]
adds a map polyline by map coordinates if color, weight and opacity are not defined, use the google maps defaults @param string $lon1 the map longitude to draw from @param string $lat1 the map latitude to draw from @param string $lon2 the map longitude to draw to @param string $lat2 the map latitude to draw to @param string $id An array id to use to append coordinates to a line @param string $color the color of the line (format: #000000) @param string $weight the weight of the line in pixels @param string $opacity the line opacity (percentage) @return string $id id of the created/updated polyline array
[ "adds", "a", "map", "polyline", "by", "map", "coordinates", "if", "color", "weight", "and", "opacity", "are", "not", "defined", "use", "the", "google", "maps", "defaults" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L1446-L1480
23,970
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.addPolylineElevation
function addPolylineElevation($polyline_id, $elevation_dom_id, $samples=256, $width="", $height="", $focus_color="#00ff00"){ if(isset($this->_polylines[$polyline_id])){ $this->_elevation_polylines[$polyline_id] = array( "dom_id"=>$elevation_dom_id, "samples"=>$samples, "width"=>($width!=""?$width:str_replace("px","",$this->width)), "height"=>($height!=""?$height:str_replace("px","",$this->height)/2), "focus_color"=>$focus_color ); } }
php
function addPolylineElevation($polyline_id, $elevation_dom_id, $samples=256, $width="", $height="", $focus_color="#00ff00"){ if(isset($this->_polylines[$polyline_id])){ $this->_elevation_polylines[$polyline_id] = array( "dom_id"=>$elevation_dom_id, "samples"=>$samples, "width"=>($width!=""?$width:str_replace("px","",$this->width)), "height"=>($height!=""?$height:str_replace("px","",$this->height)/2), "focus_color"=>$focus_color ); } }
[ "function", "addPolylineElevation", "(", "$", "polyline_id", ",", "$", "elevation_dom_id", ",", "$", "samples", "=", "256", ",", "$", "width", "=", "\"\"", ",", "$", "height", "=", "\"\"", ",", "$", "focus_color", "=", "\"#00ff00\"", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_polylines", "[", "$", "polyline_id", "]", ")", ")", "{", "$", "this", "->", "_elevation_polylines", "[", "$", "polyline_id", "]", "=", "array", "(", "\"dom_id\"", "=>", "$", "elevation_dom_id", ",", "\"samples\"", "=>", "$", "samples", ",", "\"width\"", "=>", "(", "$", "width", "!=", "\"\"", "?", "$", "width", ":", "str_replace", "(", "\"px\"", ",", "\"\"", ",", "$", "this", "->", "width", ")", ")", ",", "\"height\"", "=>", "(", "$", "height", "!=", "\"\"", "?", "$", "height", ":", "str_replace", "(", "\"px\"", ",", "\"\"", ",", "$", "this", "->", "height", ")", "/", "2", ")", ",", "\"focus_color\"", "=>", "$", "focus_color", ")", ";", "}", "}" ]
function to add an elevation profile for a polyline to the page
[ "function", "to", "add", "an", "elevation", "profile", "for", "a", "polyline", "to", "the", "page" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L1485-L1495
23,971
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.addOverlay
function addOverlay($bds_lat1, $bds_lon1, $bds_lat2, $bds_lon2, $img_src, $opacity = 100){ $_overlay = array( "bounds" => array( "ne"=>array( "lat"=>$bds_lat1, "long"=>$bds_lon1 ), "sw"=>array( "lat"=>$bds_lat2, "long"=>$bds_lon2 ) ), "img" => $img_src, "opacity" => $opacity/10 ); $this->adjustCenterCoords($bds_lon1,$bds_lat1); $this->adjustCenterCoords($bds_lon2,$bds_lat2); $this->_overlays[] = $_overlay; return count($this->_overlays)-1; }
php
function addOverlay($bds_lat1, $bds_lon1, $bds_lat2, $bds_lon2, $img_src, $opacity = 100){ $_overlay = array( "bounds" => array( "ne"=>array( "lat"=>$bds_lat1, "long"=>$bds_lon1 ), "sw"=>array( "lat"=>$bds_lat2, "long"=>$bds_lon2 ) ), "img" => $img_src, "opacity" => $opacity/10 ); $this->adjustCenterCoords($bds_lon1,$bds_lat1); $this->adjustCenterCoords($bds_lon2,$bds_lat2); $this->_overlays[] = $_overlay; return count($this->_overlays)-1; }
[ "function", "addOverlay", "(", "$", "bds_lat1", ",", "$", "bds_lon1", ",", "$", "bds_lat2", ",", "$", "bds_lon2", ",", "$", "img_src", ",", "$", "opacity", "=", "100", ")", "{", "$", "_overlay", "=", "array", "(", "\"bounds\"", "=>", "array", "(", "\"ne\"", "=>", "array", "(", "\"lat\"", "=>", "$", "bds_lat1", ",", "\"long\"", "=>", "$", "bds_lon1", ")", ",", "\"sw\"", "=>", "array", "(", "\"lat\"", "=>", "$", "bds_lat2", ",", "\"long\"", "=>", "$", "bds_lon2", ")", ")", ",", "\"img\"", "=>", "$", "img_src", ",", "\"opacity\"", "=>", "$", "opacity", "/", "10", ")", ";", "$", "this", "->", "adjustCenterCoords", "(", "$", "bds_lon1", ",", "$", "bds_lat1", ")", ";", "$", "this", "->", "adjustCenterCoords", "(", "$", "bds_lon2", ",", "$", "bds_lat2", ")", ";", "$", "this", "->", "_overlays", "[", "]", "=", "$", "_overlay", ";", "return", "count", "(", "$", "this", "->", "_overlays", ")", "-", "1", ";", "}" ]
function to add an overlay to the map.
[ "function", "to", "add", "an", "overlay", "to", "the", "map", "." ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L1500-L1519
23,972
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.setMarkerIconKey
function setMarkerIconKey($iconImage,$iconShadow='',$iconAnchorX = 'x',$iconAnchorY = 'x',$infoWindowAnchorX = 'x',$infoWindowAnchorY = 'x'){ $_iconKey = $this->getIconKey($iconImage,$iconShadow); if(isset($this->_marker_icons[$_iconKey])){ return $_iconKey; }else{ return $this->addIcon($iconImage,$iconShadow,$iconAnchorX,$iconAnchorY,$infoWindowAnchorX,$infoWindowAnchorY); } }
php
function setMarkerIconKey($iconImage,$iconShadow='',$iconAnchorX = 'x',$iconAnchorY = 'x',$infoWindowAnchorX = 'x',$infoWindowAnchorY = 'x'){ $_iconKey = $this->getIconKey($iconImage,$iconShadow); if(isset($this->_marker_icons[$_iconKey])){ return $_iconKey; }else{ return $this->addIcon($iconImage,$iconShadow,$iconAnchorX,$iconAnchorY,$infoWindowAnchorX,$infoWindowAnchorY); } }
[ "function", "setMarkerIconKey", "(", "$", "iconImage", ",", "$", "iconShadow", "=", "''", ",", "$", "iconAnchorX", "=", "'x'", ",", "$", "iconAnchorY", "=", "'x'", ",", "$", "infoWindowAnchorX", "=", "'x'", ",", "$", "infoWindowAnchorY", "=", "'x'", ")", "{", "$", "_iconKey", "=", "$", "this", "->", "getIconKey", "(", "$", "iconImage", ",", "$", "iconShadow", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_marker_icons", "[", "$", "_iconKey", "]", ")", ")", "{", "return", "$", "_iconKey", ";", "}", "else", "{", "return", "$", "this", "->", "addIcon", "(", "$", "iconImage", ",", "$", "iconShadow", ",", "$", "iconAnchorX", ",", "$", "iconAnchorY", ",", "$", "infoWindowAnchorX", ",", "$", "infoWindowAnchorY", ")", ";", "}", "}" ]
function to check if icon is in class "marker_iconset", if it is, returns the key, if not, creates a new array indice and returns the key @param string $iconImage URL to icon image @param string $iconShadowImage URL to shadow image @param string $iconAnchorX X coordinate for icon anchor point @param string $iconAnchorY Y coordinate for icon anchor point @param string $infoWindowAnchorX X coordinate for info window anchor point @param string $infoWindowAnchorY Y coordinate for info window anchor point @return string A marker icon key.
[ "function", "to", "check", "if", "icon", "is", "in", "class", "marker_iconset", "if", "it", "is", "returns", "the", "key", "if", "not", "creates", "a", "new", "array", "indice", "and", "returns", "the", "key" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L1645-L1652
23,973
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.addIcon
function addIcon($iconImage,$iconShadowImage = '',$iconAnchorX = 'x',$iconAnchorY = 'x',$infoWindowAnchorX = 'x',$infoWindowAnchorY = 'x') { $_iconKey = $this->getIconKey($iconImage, $iconShadowImage); $this->_marker_icons[$_iconKey] = $this->createMarkerIcon($iconImage,$iconShadowImage,$iconAnchorX,$iconAnchorY,$infoWindowAnchorX,$infoWindowAnchorY); return $_iconKey; }
php
function addIcon($iconImage,$iconShadowImage = '',$iconAnchorX = 'x',$iconAnchorY = 'x',$infoWindowAnchorX = 'x',$infoWindowAnchorY = 'x') { $_iconKey = $this->getIconKey($iconImage, $iconShadowImage); $this->_marker_icons[$_iconKey] = $this->createMarkerIcon($iconImage,$iconShadowImage,$iconAnchorX,$iconAnchorY,$infoWindowAnchorX,$infoWindowAnchorY); return $_iconKey; }
[ "function", "addIcon", "(", "$", "iconImage", ",", "$", "iconShadowImage", "=", "''", ",", "$", "iconAnchorX", "=", "'x'", ",", "$", "iconAnchorY", "=", "'x'", ",", "$", "infoWindowAnchorX", "=", "'x'", ",", "$", "infoWindowAnchorY", "=", "'x'", ")", "{", "$", "_iconKey", "=", "$", "this", "->", "getIconKey", "(", "$", "iconImage", ",", "$", "iconShadowImage", ")", ";", "$", "this", "->", "_marker_icons", "[", "$", "_iconKey", "]", "=", "$", "this", "->", "createMarkerIcon", "(", "$", "iconImage", ",", "$", "iconShadowImage", ",", "$", "iconAnchorX", ",", "$", "iconAnchorY", ",", "$", "infoWindowAnchorX", ",", "$", "infoWindowAnchorY", ")", ";", "return", "$", "_iconKey", ";", "}" ]
add an icon to "iconset" @param string $iconImage URL to marker icon image @param string $iconShadow URL to marker icon shadow image @param string $iconAnchorX X coordinate for icon anchor point @param string $iconAnchorY Y coordinate for icon anchor point @param string $infoWindowAnchorX X coordinate for info window anchor point @param string $infoWindowAnchorY Y coordinate for info window anchor point @return string Returns the icon's key.
[ "add", "an", "icon", "to", "iconset" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L1674-L1678
23,974
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.getAddMarkersJS
function getAddMarkersJS($map_id = "", $pano= false) { //defaults if($map_id == ""){ $map_id = $this->map_id; } if($pano==false){ $_prefix = "map"; }else{ $_prefix = "panorama".$this->street_view_dom_id; } $_output = ''; foreach($this->_markers as $_marker) { $iw_html = str_replace('"','\"',str_replace(array("\n", "\r"), "", $_marker['html'])); $_output .= "var point = new google.maps.LatLng(".$_marker['lat'].",".$_marker['lon'].");\n"; $_output .= sprintf('%s.push(createMarker(%s%s, point,"%s","%s", %s, %s, "%s", %s ));', (($pano==true)?$_prefix:"")."markers".$map_id, $_prefix, $map_id, str_replace('"','\"',$_marker['title']), str_replace('/','\/',$iw_html), (isset($_marker["icon_key"]))?"icon".$map_id."['".$_marker["icon_key"]."'].image":"''", (isset($_marker["icon_key"])&&isset($_marker["shadow_icon"]))?"icon".$map_id."['".$_marker["icon_key"]."'].shadow":"''", (($this->sidebar)?$this->sidebar_id:""), ((isset($_marker["openers"])&&count($_marker["openers"])>0)?json_encode($_marker["openers"]):"''") ) . "\n"; } if($this->marker_clusterer && $pano==false){//only do marker clusterer for map, not streetview $_output .= " markerClusterer".$map_id." = new MarkerClusterer(".$_prefix.$map_id.", markers".$map_id.", { maxZoom: ".$this->marker_clusterer_options["maxZoom"].", gridSize: ".$this->marker_clusterer_options["gridSize"].", styles: ".$this->marker_clusterer_options["styles"]." }); "; } return $_output; }
php
function getAddMarkersJS($map_id = "", $pano= false) { //defaults if($map_id == ""){ $map_id = $this->map_id; } if($pano==false){ $_prefix = "map"; }else{ $_prefix = "panorama".$this->street_view_dom_id; } $_output = ''; foreach($this->_markers as $_marker) { $iw_html = str_replace('"','\"',str_replace(array("\n", "\r"), "", $_marker['html'])); $_output .= "var point = new google.maps.LatLng(".$_marker['lat'].",".$_marker['lon'].");\n"; $_output .= sprintf('%s.push(createMarker(%s%s, point,"%s","%s", %s, %s, "%s", %s ));', (($pano==true)?$_prefix:"")."markers".$map_id, $_prefix, $map_id, str_replace('"','\"',$_marker['title']), str_replace('/','\/',$iw_html), (isset($_marker["icon_key"]))?"icon".$map_id."['".$_marker["icon_key"]."'].image":"''", (isset($_marker["icon_key"])&&isset($_marker["shadow_icon"]))?"icon".$map_id."['".$_marker["icon_key"]."'].shadow":"''", (($this->sidebar)?$this->sidebar_id:""), ((isset($_marker["openers"])&&count($_marker["openers"])>0)?json_encode($_marker["openers"]):"''") ) . "\n"; } if($this->marker_clusterer && $pano==false){//only do marker clusterer for map, not streetview $_output .= " markerClusterer".$map_id." = new MarkerClusterer(".$_prefix.$map_id.", markers".$map_id.", { maxZoom: ".$this->marker_clusterer_options["maxZoom"].", gridSize: ".$this->marker_clusterer_options["gridSize"].", styles: ".$this->marker_clusterer_options["styles"]." }); "; } return $_output; }
[ "function", "getAddMarkersJS", "(", "$", "map_id", "=", "\"\"", ",", "$", "pano", "=", "false", ")", "{", "//defaults", "if", "(", "$", "map_id", "==", "\"\"", ")", "{", "$", "map_id", "=", "$", "this", "->", "map_id", ";", "}", "if", "(", "$", "pano", "==", "false", ")", "{", "$", "_prefix", "=", "\"map\"", ";", "}", "else", "{", "$", "_prefix", "=", "\"panorama\"", ".", "$", "this", "->", "street_view_dom_id", ";", "}", "$", "_output", "=", "''", ";", "foreach", "(", "$", "this", "->", "_markers", "as", "$", "_marker", ")", "{", "$", "iw_html", "=", "str_replace", "(", "'\"'", ",", "'\\\"'", ",", "str_replace", "(", "array", "(", "\"\\n\"", ",", "\"\\r\"", ")", ",", "\"\"", ",", "$", "_marker", "[", "'html'", "]", ")", ")", ";", "$", "_output", ".=", "\"var point = new google.maps.LatLng(\"", ".", "$", "_marker", "[", "'lat'", "]", ".", "\",\"", ".", "$", "_marker", "[", "'lon'", "]", ".", "\");\\n\"", ";", "$", "_output", ".=", "sprintf", "(", "'%s.push(createMarker(%s%s, point,\"%s\",\"%s\", %s, %s, \"%s\", %s ));'", ",", "(", "(", "$", "pano", "==", "true", ")", "?", "$", "_prefix", ":", "\"\"", ")", ".", "\"markers\"", ".", "$", "map_id", ",", "$", "_prefix", ",", "$", "map_id", ",", "str_replace", "(", "'\"'", ",", "'\\\"'", ",", "$", "_marker", "[", "'title'", "]", ")", ",", "str_replace", "(", "'/'", ",", "'\\/'", ",", "$", "iw_html", ")", ",", "(", "isset", "(", "$", "_marker", "[", "\"icon_key\"", "]", ")", ")", "?", "\"icon\"", ".", "$", "map_id", ".", "\"['\"", ".", "$", "_marker", "[", "\"icon_key\"", "]", ".", "\"'].image\"", ":", "\"''\"", ",", "(", "isset", "(", "$", "_marker", "[", "\"icon_key\"", "]", ")", "&&", "isset", "(", "$", "_marker", "[", "\"shadow_icon\"", "]", ")", ")", "?", "\"icon\"", ".", "$", "map_id", ".", "\"['\"", ".", "$", "_marker", "[", "\"icon_key\"", "]", ".", "\"'].shadow\"", ":", "\"''\"", ",", "(", "(", "$", "this", "->", "sidebar", ")", "?", "$", "this", "->", "sidebar_id", ":", "\"\"", ")", ",", "(", "(", "isset", "(", "$", "_marker", "[", "\"openers\"", "]", ")", "&&", "count", "(", "$", "_marker", "[", "\"openers\"", "]", ")", ">", "0", ")", "?", "json_encode", "(", "$", "_marker", "[", "\"openers\"", "]", ")", ":", "\"''\"", ")", ")", ".", "\"\\n\"", ";", "}", "if", "(", "$", "this", "->", "marker_clusterer", "&&", "$", "pano", "==", "false", ")", "{", "//only do marker clusterer for map, not streetview", "$", "_output", ".=", "\"\n \t markerClusterer\"", ".", "$", "map_id", ".", "\" = new MarkerClusterer(\"", ".", "$", "_prefix", ".", "$", "map_id", ".", "\", markers\"", ".", "$", "map_id", ".", "\", {\n\t\t maxZoom: \"", ".", "$", "this", "->", "marker_clusterer_options", "[", "\"maxZoom\"", "]", ".", "\",\n\t\t gridSize: \"", ".", "$", "this", "->", "marker_clusterer_options", "[", "\"gridSize\"", "]", ".", "\",\n\t\t styles: \"", ".", "$", "this", "->", "marker_clusterer_options", "[", "\"styles\"", "]", ".", "\"\n\t\t });\n\t\t \t\n \t\"", ";", "}", "return", "$", "_output", ";", "}" ]
overridable function for generating js to add markers
[ "overridable", "function", "for", "generating", "js", "to", "add", "markers" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L2162-L2201
23,975
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.getPolylineJS
function getPolylineJS() { $_output = ''; foreach($this->_polylines as $polyline_id =>$_polyline) { $_coords_output = ""; foreach($_polyline["coords"] as $_coords){ if($_coords_output != ""){$_coords_output.=",";} $_coords_output .= " new google.maps.LatLng(".$_coords["lat"].", ".$_coords["long"].") "; } $_output .= " polylineCoords".$this->map_id."[$polyline_id] = [".$_coords_output."]; polylines".$this->map_id."[$polyline_id] = new google.maps.Polyline({ path: polylineCoords".$this->map_id."[$polyline_id] ".(($_polyline['color']!="")?", strokeColor: '".$_polyline['color']."'":"")." ".(($_polyline['opacity']!=0)?", strokeOpacity: ".$_polyline['opacity']."":"")." ".(($_polyline['weight']!=0)?", strokeWeight: ".$_polyline['weight']."":"")." }); polylines".$this->map_id."[$polyline_id].setMap(map".$this->map_id."); "; //Elevation profiles if(!empty($this->_elevation_polylines) && isset($this->_elevation_polylines[$polyline_id])){ $elevation_dom_id=$this->_elevation_polylines[$polyline_id]["dom_id"]; $width = $this->_elevation_polylines[$polyline_id]["width"]; $height = $this->_elevation_polylines[$polyline_id]["height"]; $samples = $this->_elevation_polylines[$polyline_id]["samples"]; $focus_color = $this->_elevation_polylines[$polyline_id]["focus_color"]; $_output .= " elevationPolylines".$this->map_id."[$polyline_id] = { 'selector':'$elevation_dom_id', 'chart': new google.visualization.ColumnChart(document.getElementById('$elevation_dom_id')), 'service': new google.maps.ElevationService(), 'width':$width, 'height':$height, 'focusColor':'$focus_color', 'marker':null }; elevationPolylines".$this->map_id."[$polyline_id]['service'].getElevationAlongPath({ path: polylineCoords".$this->map_id."[$polyline_id], samples: $samples }, function(results,status){plotElevation(results,status, elevationPolylines".$this->map_id."[$polyline_id], map".$this->map_id.", elevationCharts".$this->map_id.");}); "; } } return $_output; }
php
function getPolylineJS() { $_output = ''; foreach($this->_polylines as $polyline_id =>$_polyline) { $_coords_output = ""; foreach($_polyline["coords"] as $_coords){ if($_coords_output != ""){$_coords_output.=",";} $_coords_output .= " new google.maps.LatLng(".$_coords["lat"].", ".$_coords["long"].") "; } $_output .= " polylineCoords".$this->map_id."[$polyline_id] = [".$_coords_output."]; polylines".$this->map_id."[$polyline_id] = new google.maps.Polyline({ path: polylineCoords".$this->map_id."[$polyline_id] ".(($_polyline['color']!="")?", strokeColor: '".$_polyline['color']."'":"")." ".(($_polyline['opacity']!=0)?", strokeOpacity: ".$_polyline['opacity']."":"")." ".(($_polyline['weight']!=0)?", strokeWeight: ".$_polyline['weight']."":"")." }); polylines".$this->map_id."[$polyline_id].setMap(map".$this->map_id."); "; //Elevation profiles if(!empty($this->_elevation_polylines) && isset($this->_elevation_polylines[$polyline_id])){ $elevation_dom_id=$this->_elevation_polylines[$polyline_id]["dom_id"]; $width = $this->_elevation_polylines[$polyline_id]["width"]; $height = $this->_elevation_polylines[$polyline_id]["height"]; $samples = $this->_elevation_polylines[$polyline_id]["samples"]; $focus_color = $this->_elevation_polylines[$polyline_id]["focus_color"]; $_output .= " elevationPolylines".$this->map_id."[$polyline_id] = { 'selector':'$elevation_dom_id', 'chart': new google.visualization.ColumnChart(document.getElementById('$elevation_dom_id')), 'service': new google.maps.ElevationService(), 'width':$width, 'height':$height, 'focusColor':'$focus_color', 'marker':null }; elevationPolylines".$this->map_id."[$polyline_id]['service'].getElevationAlongPath({ path: polylineCoords".$this->map_id."[$polyline_id], samples: $samples }, function(results,status){plotElevation(results,status, elevationPolylines".$this->map_id."[$polyline_id], map".$this->map_id.", elevationCharts".$this->map_id.");}); "; } } return $_output; }
[ "function", "getPolylineJS", "(", ")", "{", "$", "_output", "=", "''", ";", "foreach", "(", "$", "this", "->", "_polylines", "as", "$", "polyline_id", "=>", "$", "_polyline", ")", "{", "$", "_coords_output", "=", "\"\"", ";", "foreach", "(", "$", "_polyline", "[", "\"coords\"", "]", "as", "$", "_coords", ")", "{", "if", "(", "$", "_coords_output", "!=", "\"\"", ")", "{", "$", "_coords_output", ".=", "\",\"", ";", "}", "$", "_coords_output", ".=", "\"\n \t\t new google.maps.LatLng(\"", ".", "$", "_coords", "[", "\"lat\"", "]", ".", "\", \"", ".", "$", "_coords", "[", "\"long\"", "]", ".", "\")\n \t\t\"", ";", "}", "$", "_output", ".=", "\"\n \t polylineCoords\"", ".", "$", "this", "->", "map_id", ".", "\"[$polyline_id] = [\"", ".", "$", "_coords_output", ".", "\"]; \t\n\t\t\t polylines\"", ".", "$", "this", "->", "map_id", ".", "\"[$polyline_id] = new google.maps.Polyline({\n\t\t\t\t path: polylineCoords\"", ".", "$", "this", "->", "map_id", ".", "\"[$polyline_id]\n\t\t\t\t \"", ".", "(", "(", "$", "_polyline", "[", "'color'", "]", "!=", "\"\"", ")", "?", "\", strokeColor: '\"", ".", "$", "_polyline", "[", "'color'", "]", ".", "\"'\"", ":", "\"\"", ")", ".", "\"\n\t\t\t\t \"", ".", "(", "(", "$", "_polyline", "[", "'opacity'", "]", "!=", "0", ")", "?", "\", strokeOpacity: \"", ".", "$", "_polyline", "[", "'opacity'", "]", ".", "\"\"", ":", "\"\"", ")", ".", "\"\n\t\t\t\t \"", ".", "(", "(", "$", "_polyline", "[", "'weight'", "]", "!=", "0", ")", "?", "\", strokeWeight: \"", ".", "$", "_polyline", "[", "'weight'", "]", ".", "\"\"", ":", "\"\"", ")", ".", "\"\n\t\t\t });\t\t\t\n\t\t\t polylines\"", ".", "$", "this", "->", "map_id", ".", "\"[$polyline_id].setMap(map\"", ".", "$", "this", "->", "map_id", ".", "\");\n \t\"", ";", "//Elevation profiles", "if", "(", "!", "empty", "(", "$", "this", "->", "_elevation_polylines", ")", "&&", "isset", "(", "$", "this", "->", "_elevation_polylines", "[", "$", "polyline_id", "]", ")", ")", "{", "$", "elevation_dom_id", "=", "$", "this", "->", "_elevation_polylines", "[", "$", "polyline_id", "]", "[", "\"dom_id\"", "]", ";", "$", "width", "=", "$", "this", "->", "_elevation_polylines", "[", "$", "polyline_id", "]", "[", "\"width\"", "]", ";", "$", "height", "=", "$", "this", "->", "_elevation_polylines", "[", "$", "polyline_id", "]", "[", "\"height\"", "]", ";", "$", "samples", "=", "$", "this", "->", "_elevation_polylines", "[", "$", "polyline_id", "]", "[", "\"samples\"", "]", ";", "$", "focus_color", "=", "$", "this", "->", "_elevation_polylines", "[", "$", "polyline_id", "]", "[", "\"focus_color\"", "]", ";", "$", "_output", ".=", "\"\n\t\t\t\t\televationPolylines\"", ".", "$", "this", "->", "map_id", ".", "\"[$polyline_id] = {\n\t\t\t\t\t\t'selector':'$elevation_dom_id',\n\t\t\t\t\t\t'chart': new google.visualization.ColumnChart(document.getElementById('$elevation_dom_id')),\n\t\t\t\t\t\t'service': new google.maps.ElevationService(),\n\t\t\t\t\t\t'width':$width,\n\t\t\t\t\t\t'height':$height,\n\t\t\t\t\t\t'focusColor':'$focus_color',\n\t\t\t\t\t\t'marker':null\n\t\t\t\t\t};\n\t\t\t\t\televationPolylines\"", ".", "$", "this", "->", "map_id", ".", "\"[$polyline_id]['service'].getElevationAlongPath({\n\t\t\t\t\t\tpath: polylineCoords\"", ".", "$", "this", "->", "map_id", ".", "\"[$polyline_id],\n\t\t\t\t\t\tsamples: $samples\n\t\t\t\t\t}, function(results,status){plotElevation(results,status, elevationPolylines\"", ".", "$", "this", "->", "map_id", ".", "\"[$polyline_id], map\"", ".", "$", "this", "->", "map_id", ".", "\", elevationCharts\"", ".", "$", "this", "->", "map_id", ".", "\");});\n\t\t\t\t\"", ";", "}", "}", "return", "$", "_output", ";", "}" ]
overridable function to generate polyline js - for now can only be used on a map, not a streetview
[ "overridable", "function", "to", "generate", "polyline", "js", "-", "for", "now", "can", "only", "be", "used", "on", "a", "map", "not", "a", "streetview" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L2206-L2252
23,976
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.getAddDirectionsJS
function getAddDirectionsJS(){ $_output = ""; foreach($this->_directions as $directions){ $dom_id = $directions["dom_id"]; $travelModeParams = array(); $directionsParams = ""; if($this->walking_directions==TRUE) $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.WALKING"; else if($this->biking_directions==TRUE) $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.BICYCLING"; else $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.DRIVING"; if($this->avoid_highways==TRUE) $directionsParams .= ", \n avoidHighways: true"; if($this->avoid_tollways==TRUE) $directionsParams .= ", \n avoidTolls: true"; if($this->directions_unit_system!=''){ if($this->directions_unit_system == 'METRIC'){ $directionsParams .= ", \n unitSystem: google.maps.DirectionsUnitSystem.METRIC"; }else{ $directionsParams .= ", \n unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL"; } } $_output .= " directions".$this->map_id."['$dom_id'] = { displayRenderer:new google.maps.DirectionsRenderer(), directionService:new google.maps.DirectionsService(), request:{ waypoints: [{$this->_waypoints_string}], origin: '".$directions["start"]."', destination: '".$directions["dest"]."' $directionsParams } ".(($this->elevation_directions)?", selector: '".$directions["elevation_dom_id"]."', chart: new google.visualization.ColumnChart(document.getElementById('".$directions["elevation_dom_id"]."')), service: new google.maps.ElevationService(), width:".$directions["width"].", height:".$directions["height"].", focusColor:'#00FF00', marker:null ":"")." }; directions".$this->map_id."['$dom_id'].displayRenderer.setMap(map".$this->map_id."); directions".$this->map_id."['$dom_id'].displayRenderer.setPanel(document.getElementById('$dom_id')); directions".$this->map_id."['$dom_id'].directionService.route(directions".$this->map_id."['$dom_id'].request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directions".$this->map_id."['$dom_id'].displayRenderer.setDirections(response); ".(($this->elevation_directions)?" directions".$this->map_id."['$dom_id'].service.getElevationAlongPath({ path: response.routes[0].overview_path, samples: ".$directions["elevation_samples"]." }, function(results,status){plotElevation(results,status, directions".$this->map_id."['$dom_id'], map".$this->map_id.", elevationCharts".$this->map_id.");}); ":"")." } }); "; } return $_output; }
php
function getAddDirectionsJS(){ $_output = ""; foreach($this->_directions as $directions){ $dom_id = $directions["dom_id"]; $travelModeParams = array(); $directionsParams = ""; if($this->walking_directions==TRUE) $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.WALKING"; else if($this->biking_directions==TRUE) $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.BICYCLING"; else $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.DRIVING"; if($this->avoid_highways==TRUE) $directionsParams .= ", \n avoidHighways: true"; if($this->avoid_tollways==TRUE) $directionsParams .= ", \n avoidTolls: true"; if($this->directions_unit_system!=''){ if($this->directions_unit_system == 'METRIC'){ $directionsParams .= ", \n unitSystem: google.maps.DirectionsUnitSystem.METRIC"; }else{ $directionsParams .= ", \n unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL"; } } $_output .= " directions".$this->map_id."['$dom_id'] = { displayRenderer:new google.maps.DirectionsRenderer(), directionService:new google.maps.DirectionsService(), request:{ waypoints: [{$this->_waypoints_string}], origin: '".$directions["start"]."', destination: '".$directions["dest"]."' $directionsParams } ".(($this->elevation_directions)?", selector: '".$directions["elevation_dom_id"]."', chart: new google.visualization.ColumnChart(document.getElementById('".$directions["elevation_dom_id"]."')), service: new google.maps.ElevationService(), width:".$directions["width"].", height:".$directions["height"].", focusColor:'#00FF00', marker:null ":"")." }; directions".$this->map_id."['$dom_id'].displayRenderer.setMap(map".$this->map_id."); directions".$this->map_id."['$dom_id'].displayRenderer.setPanel(document.getElementById('$dom_id')); directions".$this->map_id."['$dom_id'].directionService.route(directions".$this->map_id."['$dom_id'].request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directions".$this->map_id."['$dom_id'].displayRenderer.setDirections(response); ".(($this->elevation_directions)?" directions".$this->map_id."['$dom_id'].service.getElevationAlongPath({ path: response.routes[0].overview_path, samples: ".$directions["elevation_samples"]." }, function(results,status){plotElevation(results,status, directions".$this->map_id."['$dom_id'], map".$this->map_id.", elevationCharts".$this->map_id.");}); ":"")." } }); "; } return $_output; }
[ "function", "getAddDirectionsJS", "(", ")", "{", "$", "_output", "=", "\"\"", ";", "foreach", "(", "$", "this", "->", "_directions", "as", "$", "directions", ")", "{", "$", "dom_id", "=", "$", "directions", "[", "\"dom_id\"", "]", ";", "$", "travelModeParams", "=", "array", "(", ")", ";", "$", "directionsParams", "=", "\"\"", ";", "if", "(", "$", "this", "->", "walking_directions", "==", "TRUE", ")", "$", "directionsParams", ".=", "\", \\n travelMode:google.maps.DirectionsTravelMode.WALKING\"", ";", "else", "if", "(", "$", "this", "->", "biking_directions", "==", "TRUE", ")", "$", "directionsParams", ".=", "\", \\n travelMode:google.maps.DirectionsTravelMode.BICYCLING\"", ";", "else", "$", "directionsParams", ".=", "\", \\n travelMode:google.maps.DirectionsTravelMode.DRIVING\"", ";", "if", "(", "$", "this", "->", "avoid_highways", "==", "TRUE", ")", "$", "directionsParams", ".=", "\", \\n avoidHighways: true\"", ";", "if", "(", "$", "this", "->", "avoid_tollways", "==", "TRUE", ")", "$", "directionsParams", ".=", "\", \\n avoidTolls: true\"", ";", "if", "(", "$", "this", "->", "directions_unit_system", "!=", "''", ")", "{", "if", "(", "$", "this", "->", "directions_unit_system", "==", "'METRIC'", ")", "{", "$", "directionsParams", ".=", "\", \\n unitSystem: google.maps.DirectionsUnitSystem.METRIC\"", ";", "}", "else", "{", "$", "directionsParams", ".=", "\", \\n unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL\"", ";", "}", "}", "$", "_output", ".=", "\"\n\t\t\t directions\"", ".", "$", "this", "->", "map_id", ".", "\"['$dom_id'] = {\n\t\t\t\t\tdisplayRenderer:new google.maps.DirectionsRenderer(),\n\t\t\t\t\tdirectionService:new google.maps.DirectionsService(),\n\t\t\t\t\trequest:{\n \t\t\t\t\twaypoints: [{$this->_waypoints_string}],\n\t\t\t\t\t\torigin: '\"", ".", "$", "directions", "[", "\"start\"", "]", ".", "\"',\n\t\t\t\t\t\tdestination: '\"", ".", "$", "directions", "[", "\"dest\"", "]", ".", "\"'\n\t\t\t\t\t\t$directionsParams\n\t\t\t\t\t}\n\t\t\t\t\t\"", ".", "(", "(", "$", "this", "->", "elevation_directions", ")", "?", "\",\t\t\n\t\t\t\t\t selector: '\"", ".", "$", "directions", "[", "\"elevation_dom_id\"", "]", ".", "\"',\n\t\t\t\t\t chart: new google.visualization.ColumnChart(document.getElementById('\"", ".", "$", "directions", "[", "\"elevation_dom_id\"", "]", ".", "\"')),\n\t\t\t\t\t service: new google.maps.ElevationService(),\n\t\t\t\t\t width:\"", ".", "$", "directions", "[", "\"width\"", "]", ".", "\",\n\t\t\t\t\t height:\"", ".", "$", "directions", "[", "\"height\"", "]", ".", "\",\n\t\t\t\t\t focusColor:'#00FF00',\n\t\t\t\t\t marker:null\n\t\t\t\t \"", ":", "\"\"", ")", ".", "\"\n\t\t\t\t};\n\t\t\t\tdirections\"", ".", "$", "this", "->", "map_id", ".", "\"['$dom_id'].displayRenderer.setMap(map\"", ".", "$", "this", "->", "map_id", ".", "\");\n\t\t\t\tdirections\"", ".", "$", "this", "->", "map_id", ".", "\"['$dom_id'].displayRenderer.setPanel(document.getElementById('$dom_id'));\n\t\t\t\tdirections\"", ".", "$", "this", "->", "map_id", ".", "\"['$dom_id'].directionService.route(directions\"", ".", "$", "this", "->", "map_id", ".", "\"['$dom_id'].request, function(response, status) {\n\t\t\t\t\tif (status == google.maps.DirectionsStatus.OK) {\n\t\t\t\t\t directions\"", ".", "$", "this", "->", "map_id", ".", "\"['$dom_id'].displayRenderer.setDirections(response);\n\t\t\t\t\t \"", ".", "(", "(", "$", "this", "->", "elevation_directions", ")", "?", "\"\n\t\t\t\t\t\t directions\"", ".", "$", "this", "->", "map_id", ".", "\"['$dom_id'].service.getElevationAlongPath({\n\t\t\t\t\t\t\t path: response.routes[0].overview_path,\n\t\t\t\t\t\t\t samples: \"", ".", "$", "directions", "[", "\"elevation_samples\"", "]", ".", "\"\n\t\t\t\t\t\t }, function(results,status){plotElevation(results,status, directions\"", ".", "$", "this", "->", "map_id", ".", "\"['$dom_id'], map\"", ".", "$", "this", "->", "map_id", ".", "\", elevationCharts\"", ".", "$", "this", "->", "map_id", ".", "\");});\n\t\t\t\t\t \"", ":", "\"\"", ")", ".", "\"\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t \"", ";", "}", "return", "$", "_output", ";", "}" ]
function to render proper calls for directions - for now can only be used on a map, not a streetview
[ "function", "to", "render", "proper", "calls", "for", "directions", "-", "for", "now", "can", "only", "be", "used", "on", "a", "map", "not", "a", "streetview" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L2257-L2321
23,977
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.getAddOverlayJS
function getAddOverlayJS(){ $_output = ""; foreach($this->_overlays as $_key=>$_overlay){ $_output .= " var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(".$_overlay["bounds"]["ne"]["lat"].", ".$_overlay["bounds"]["ne"]["long"]."), new google.maps.LatLng(".$_overlay["bounds"]["sw"]["lat"].", ".$_overlay["bounds"]["sw"]["long"].")); var image = '".$_overlay["img"]."'; overlays".$this->map_id."[$_key] = new CustomOverlay(bounds, image, map".$this->map_id.", ".$_overlay["opacity"]."); "; } return $_output; }
php
function getAddOverlayJS(){ $_output = ""; foreach($this->_overlays as $_key=>$_overlay){ $_output .= " var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(".$_overlay["bounds"]["ne"]["lat"].", ".$_overlay["bounds"]["ne"]["long"]."), new google.maps.LatLng(".$_overlay["bounds"]["sw"]["lat"].", ".$_overlay["bounds"]["sw"]["long"].")); var image = '".$_overlay["img"]."'; overlays".$this->map_id."[$_key] = new CustomOverlay(bounds, image, map".$this->map_id.", ".$_overlay["opacity"]."); "; } return $_output; }
[ "function", "getAddOverlayJS", "(", ")", "{", "$", "_output", "=", "\"\"", ";", "foreach", "(", "$", "this", "->", "_overlays", "as", "$", "_key", "=>", "$", "_overlay", ")", "{", "$", "_output", ".=", "\"\n\t\t\t \t var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(\"", ".", "$", "_overlay", "[", "\"bounds\"", "]", "[", "\"ne\"", "]", "[", "\"lat\"", "]", ".", "\", \"", ".", "$", "_overlay", "[", "\"bounds\"", "]", "[", "\"ne\"", "]", "[", "\"long\"", "]", ".", "\"), new google.maps.LatLng(\"", ".", "$", "_overlay", "[", "\"bounds\"", "]", "[", "\"sw\"", "]", "[", "\"lat\"", "]", ".", "\", \"", ".", "$", "_overlay", "[", "\"bounds\"", "]", "[", "\"sw\"", "]", "[", "\"long\"", "]", ".", "\"));\n\t\t\t\t var image = '\"", ".", "$", "_overlay", "[", "\"img\"", "]", ".", "\"';\n\t\t\t overlays\"", ".", "$", "this", "->", "map_id", ".", "\"[$_key] = new CustomOverlay(bounds, image, map\"", ".", "$", "this", "->", "map_id", ".", "\", \"", ".", "$", "_overlay", "[", "\"opacity\"", "]", ".", "\");\n\t\t\t \"", ";", "}", "return", "$", "_output", ";", "}" ]
function to get overlay creation JS.
[ "function", "to", "get", "overlay", "creation", "JS", "." ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L2326-L2336
23,978
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.getCreateMarkerJS
function getCreateMarkerJS() { $_output = " function createMarker(map, point, title, html, icon, icon_shadow, sidebar_id, openers){ var marker_options = { position: point, map: map, title: title}; if(icon!=''){marker_options.icon = icon;} if(icon_shadow!=''){marker_options.shadow = icon_shadow;} //create marker var new_marker = new google.maps.Marker(marker_options); if(html!=''){ ".(($this->info_window)?" google.maps.event.addListener(new_marker, '".$this->window_trigger."', function() { infowindow.close(); infowindow.setContent(html); infowindow.open(map,new_marker); }); if(openers != ''&&!isEmpty(openers)){ for(var i in openers){ var opener = document.getElementById(openers[i]); opener.on".$this->window_trigger." = function() { infowindow.close(); infowindow.setContent(html); infowindow.open(map,new_marker); return false; }; } } ":"")." if(sidebar_id != ''){ var sidebar = document.getElementById(sidebar_id); if(sidebar!=null && sidebar!=undefined && title!=null && title!=''){ var newlink = document.createElement('a'); ".(($this->info_window)?" newlink.onclick=function(){infowindow.open(map,new_marker); return false}; ":" newlink.onclick=function(){map.setCenter(point); return false}; ")." newlink.innerHTML = title; sidebar.appendChild(newlink); } } } return new_marker; } "; return $_output; }
php
function getCreateMarkerJS() { $_output = " function createMarker(map, point, title, html, icon, icon_shadow, sidebar_id, openers){ var marker_options = { position: point, map: map, title: title}; if(icon!=''){marker_options.icon = icon;} if(icon_shadow!=''){marker_options.shadow = icon_shadow;} //create marker var new_marker = new google.maps.Marker(marker_options); if(html!=''){ ".(($this->info_window)?" google.maps.event.addListener(new_marker, '".$this->window_trigger."', function() { infowindow.close(); infowindow.setContent(html); infowindow.open(map,new_marker); }); if(openers != ''&&!isEmpty(openers)){ for(var i in openers){ var opener = document.getElementById(openers[i]); opener.on".$this->window_trigger." = function() { infowindow.close(); infowindow.setContent(html); infowindow.open(map,new_marker); return false; }; } } ":"")." if(sidebar_id != ''){ var sidebar = document.getElementById(sidebar_id); if(sidebar!=null && sidebar!=undefined && title!=null && title!=''){ var newlink = document.createElement('a'); ".(($this->info_window)?" newlink.onclick=function(){infowindow.open(map,new_marker); return false}; ":" newlink.onclick=function(){map.setCenter(point); return false}; ")." newlink.innerHTML = title; sidebar.appendChild(newlink); } } } return new_marker; } "; return $_output; }
[ "function", "getCreateMarkerJS", "(", ")", "{", "$", "_output", "=", "\"\n \t function createMarker(map, point, title, html, icon, icon_shadow, sidebar_id, openers){\n\t\t\t var marker_options = {\n\t\t\t position: point,\n\t\t\t map: map,\n\t\t\t title: title}; \n\t\t\t if(icon!=''){marker_options.icon = icon;}\n\t\t\t if(icon_shadow!=''){marker_options.shadow = icon_shadow;}\n\t\t\t \n\t\t\t //create marker\n\t\t\t var new_marker = new google.maps.Marker(marker_options);\n\t\t\t if(html!=''){\n\t\t\t\t\t\"", ".", "(", "(", "$", "this", "->", "info_window", ")", "?", "\"\n\t\t\t \n\t\t\t google.maps.event.addListener(new_marker, '\"", ".", "$", "this", "->", "window_trigger", ".", "\"', function() {\n\t\t\t \tinfowindow.close();\t\n\t\t\t \tinfowindow.setContent(html);\n\t\t\t \tinfowindow.open(map,new_marker);\n\t\t\t });\n\t\t\t \n\t\t\t\t\tif(openers != ''&&!isEmpty(openers)){\n\t\t\t for(var i in openers){\n\t\t\t var opener = document.getElementById(openers[i]);\n\t\t\t opener.on\"", ".", "$", "this", "->", "window_trigger", ".", "\" = function() { \n\t\t\t \n\t\t\t \tinfowindow.close();\n\t\t\t \tinfowindow.setContent(html);\n\t\t\t \tinfowindow.open(map,new_marker); \n\t\t\t \t\n\t\t\t \t\treturn false;\t\t\t \t\n\t\t\t };\n\t\t\t }\n\t\t\t }\n\t\t\t\t\t\"", ":", "\"\"", ")", ".", "\"\n\t\t\t if(sidebar_id != ''){\n\t\t\t var sidebar = document.getElementById(sidebar_id);\n\t\t\t\t\t\tif(sidebar!=null && sidebar!=undefined && title!=null && title!=''){\n\t\t\t\t\t\t\tvar newlink = document.createElement('a');\n\t\t\t\t\t\t\t\"", ".", "(", "(", "$", "this", "->", "info_window", ")", "?", "\"\n\t\t\t \t\tnewlink.onclick=function(){infowindow.open(map,new_marker); return false};\n\t\t\t\t\t\t\t\"", ":", "\"\n\t\t\t\t\t\t\tnewlink.onclick=function(){map.setCenter(point); return false};\n\t\t\t\t\t\t\t\"", ")", ".", "\"\n\t\t\t\t\t\t\tnewlink.innerHTML = title;\n\t\t\t\t\t\t\tsidebar.appendChild(newlink);\n\t\t\t\t\t\t}\n\t\t\t }\n }\n\t\t\t return new_marker; \n\t\t\t}\n \t\"", ";", "return", "$", "_output", ";", "}" ]
overridable function to generate the js for the js function for creating a marker.
[ "overridable", "function", "to", "generate", "the", "js", "for", "the", "js", "function", "for", "creating", "a", "marker", "." ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L2341-L2394
23,979
kossmoss/yii2-google-maps-api
src/GoogleMapAPI.php
GoogleMapAPI.geoGetDistance
function geoGetDistance($lat1,$lon1,$lat2,$lon2,$unit='M') { // calculate miles $M = 69.09 * rad2deg(acos(sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($lon1 - $lon2)))); switch(strtoupper($unit)) { case 'K': // kilometers return $M * 1.609344; break; case 'N': // nautical miles return $M * 0.868976242; break; case 'F': // feet return $M * 5280; break; case 'I': // inches return $M * 63360; break; case 'M': default: // miles return $M; break; } }
php
function geoGetDistance($lat1,$lon1,$lat2,$lon2,$unit='M') { // calculate miles $M = 69.09 * rad2deg(acos(sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($lon1 - $lon2)))); switch(strtoupper($unit)) { case 'K': // kilometers return $M * 1.609344; break; case 'N': // nautical miles return $M * 0.868976242; break; case 'F': // feet return $M * 5280; break; case 'I': // inches return $M * 63360; break; case 'M': default: // miles return $M; break; } }
[ "function", "geoGetDistance", "(", "$", "lat1", ",", "$", "lon1", ",", "$", "lat2", ",", "$", "lon2", ",", "$", "unit", "=", "'M'", ")", "{", "// calculate miles", "$", "M", "=", "69.09", "*", "rad2deg", "(", "acos", "(", "sin", "(", "deg2rad", "(", "$", "lat1", ")", ")", "*", "sin", "(", "deg2rad", "(", "$", "lat2", ")", ")", "+", "cos", "(", "deg2rad", "(", "$", "lat1", ")", ")", "*", "cos", "(", "deg2rad", "(", "$", "lat2", ")", ")", "*", "cos", "(", "deg2rad", "(", "$", "lon1", "-", "$", "lon2", ")", ")", ")", ")", ";", "switch", "(", "strtoupper", "(", "$", "unit", ")", ")", "{", "case", "'K'", ":", "// kilometers", "return", "$", "M", "*", "1.609344", ";", "break", ";", "case", "'N'", ":", "// nautical miles", "return", "$", "M", "*", "0.868976242", ";", "break", ";", "case", "'F'", ":", "// feet", "return", "$", "M", "*", "5280", ";", "break", ";", "case", "'I'", ":", "// inches", "return", "$", "M", "*", "63360", ";", "break", ";", "case", "'M'", ":", "default", ":", "// miles", "return", "$", "M", ";", "break", ";", "}", "}" ]
get distance between to geocoords using great circle distance formula @param float $lat1 @param float $lat2 @param float $lon1 @param float $lon2 @param float $unit M=miles, K=kilometers, N=nautical miles, I=inches, F=feet @return float
[ "get", "distance", "between", "to", "geocoords", "using", "great", "circle", "distance", "formula" ]
8a994c173031d7ece3cfedd30b971258616579d2
https://github.com/kossmoss/yii2-google-maps-api/blob/8a994c173031d7ece3cfedd30b971258616579d2/src/GoogleMapAPI.php#L2718-L2748
23,980
NuclearCMS/Hierarchy
src/NodeRepository.php
NodeRepository.getHome
public function getHome($track = true) { $home = PublishedNode::whereHome(1) ->firstOrFail(); $this->track($track, $home); return $home; }
php
public function getHome($track = true) { $home = PublishedNode::whereHome(1) ->firstOrFail(); $this->track($track, $home); return $home; }
[ "public", "function", "getHome", "(", "$", "track", "=", "true", ")", "{", "$", "home", "=", "PublishedNode", "::", "whereHome", "(", "1", ")", "->", "firstOrFail", "(", ")", ";", "$", "this", "->", "track", "(", "$", "track", ",", "$", "home", ")", ";", "return", "$", "home", ";", "}" ]
Returns the home node @param bool $track @return Node
[ "Returns", "the", "home", "node" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeRepository.php#L29-L37
23,981
NuclearCMS/Hierarchy
src/NodeRepository.php
NodeRepository.getNode
public function getNode($name, $track = true, $published = true) { if ($this->withPublishedOnly($published)) { $node = PublishedNode::withName($name); } else { $node = Node::withName($name); } $node = $node->firstOrFail(); $this->track($track, $node); return $node; }
php
public function getNode($name, $track = true, $published = true) { if ($this->withPublishedOnly($published)) { $node = PublishedNode::withName($name); } else { $node = Node::withName($name); } $node = $node->firstOrFail(); $this->track($track, $node); return $node; }
[ "public", "function", "getNode", "(", "$", "name", ",", "$", "track", "=", "true", ",", "$", "published", "=", "true", ")", "{", "if", "(", "$", "this", "->", "withPublishedOnly", "(", "$", "published", ")", ")", "{", "$", "node", "=", "PublishedNode", "::", "withName", "(", "$", "name", ")", ";", "}", "else", "{", "$", "node", "=", "Node", "::", "withName", "(", "$", "name", ")", ";", "}", "$", "node", "=", "$", "node", "->", "firstOrFail", "(", ")", ";", "$", "this", "->", "track", "(", "$", "track", ",", "$", "node", ")", ";", "return", "$", "node", ";", "}" ]
Returns a node by name @param string $name @param bool $track @param bool $published @return Node
[ "Returns", "a", "node", "by", "name" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeRepository.php#L47-L62
23,982
NuclearCMS/Hierarchy
src/NodeRepository.php
NodeRepository.withPublishedOnly
protected function withPublishedOnly($published) { if ($published === false) { return false; } if ($this->tokenManager->requestHasToken('preview_nodes')) { return false; } return true; }
php
protected function withPublishedOnly($published) { if ($published === false) { return false; } if ($this->tokenManager->requestHasToken('preview_nodes')) { return false; } return true; }
[ "protected", "function", "withPublishedOnly", "(", "$", "published", ")", "{", "if", "(", "$", "published", "===", "false", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "tokenManager", "->", "requestHasToken", "(", "'preview_nodes'", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checks if the request includes unpublished nodes as well @param bool $published @return bool
[ "Checks", "if", "the", "request", "includes", "unpublished", "nodes", "as", "well" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeRepository.php#L70-L83
23,983
NuclearCMS/Hierarchy
src/NodeRepository.php
NodeRepository.getNodeAndSetLocale
public function getNodeAndSetLocale($name, $track = true, $published = true) { $node = $this->getNode($name, $track, $published); $locale = $node->getLocaleForNodeName($name); set_app_locale($locale); return $node; }
php
public function getNodeAndSetLocale($name, $track = true, $published = true) { $node = $this->getNode($name, $track, $published); $locale = $node->getLocaleForNodeName($name); set_app_locale($locale); return $node; }
[ "public", "function", "getNodeAndSetLocale", "(", "$", "name", ",", "$", "track", "=", "true", ",", "$", "published", "=", "true", ")", "{", "$", "node", "=", "$", "this", "->", "getNode", "(", "$", "name", ",", "$", "track", ",", "$", "published", ")", ";", "$", "locale", "=", "$", "node", "->", "getLocaleForNodeName", "(", "$", "name", ")", ";", "set_app_locale", "(", "$", "locale", ")", ";", "return", "$", "node", ";", "}" ]
Returns a node by name and sets the locale @param string $name @param bool $track @param bool $published @return Node
[ "Returns", "a", "node", "by", "name", "and", "sets", "the", "locale" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeRepository.php#L93-L102
23,984
NuclearCMS/Hierarchy
src/NodeRepository.php
NodeRepository.getSearchNodeBuilder
public function getSearchNodeBuilder($keywords, $type = null, $limit = null, $locale = null) { // Because of the searchable trait we have to reset global scopes $builder = PublishedNode::withoutGlobalScopes() ->published() ->typeMailing() ->translatedIn($locale) ->groupBy('nodes.id'); if ($type) { $builder->withType($type); } if ($limit) { $builder->limit($limit); } $builder->search($keywords, 20, true); return $builder; }
php
public function getSearchNodeBuilder($keywords, $type = null, $limit = null, $locale = null) { // Because of the searchable trait we have to reset global scopes $builder = PublishedNode::withoutGlobalScopes() ->published() ->typeMailing() ->translatedIn($locale) ->groupBy('nodes.id'); if ($type) { $builder->withType($type); } if ($limit) { $builder->limit($limit); } $builder->search($keywords, 20, true); return $builder; }
[ "public", "function", "getSearchNodeBuilder", "(", "$", "keywords", ",", "$", "type", "=", "null", ",", "$", "limit", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "// Because of the searchable trait we have to reset global scopes", "$", "builder", "=", "PublishedNode", "::", "withoutGlobalScopes", "(", ")", "->", "published", "(", ")", "->", "typeMailing", "(", ")", "->", "translatedIn", "(", "$", "locale", ")", "->", "groupBy", "(", "'nodes.id'", ")", ";", "if", "(", "$", "type", ")", "{", "$", "builder", "->", "withType", "(", "$", "type", ")", ";", "}", "if", "(", "$", "limit", ")", "{", "$", "builder", "->", "limit", "(", "$", "limit", ")", ";", "}", "$", "builder", "->", "search", "(", "$", "keywords", ",", "20", ",", "true", ")", ";", "return", "$", "builder", ";", "}" ]
Gets node searching builder @param string $keywords @param string $type @param int $limit @param string $locale @return Builder
[ "Gets", "node", "searching", "builder" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeRepository.php#L113-L135
23,985
NuclearCMS/Hierarchy
src/NodeRepository.php
NodeRepository.searchNodes
public function searchNodes($keywords, $type = null, $limit = null, $locale = null) { return $this->getSearchNodeBuilder($keywords, $type, $limit, $locale)->get(); }
php
public function searchNodes($keywords, $type = null, $limit = null, $locale = null) { return $this->getSearchNodeBuilder($keywords, $type, $limit, $locale)->get(); }
[ "public", "function", "searchNodes", "(", "$", "keywords", ",", "$", "type", "=", "null", ",", "$", "limit", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "return", "$", "this", "->", "getSearchNodeBuilder", "(", "$", "keywords", ",", "$", "type", ",", "$", "limit", ",", "$", "locale", ")", "->", "get", "(", ")", ";", "}" ]
Searches for nodes @param string $keywords @param string $type @param int $limit @param string $locale @return Collection
[ "Searches", "for", "nodes" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeRepository.php#L146-L149
23,986
NuclearCMS/Hierarchy
src/NodeRepository.php
NodeRepository.getSortedNodesBuilder
public function getSortedNodesBuilder($key = null, $direction = null, $type = null, $limit = null, $locale = null) { $builder = PublishedNode::translatedIn($locale) ->groupBy('nodes.id'); if ($type) { $builder->withType($type); } if ($limit) { $builder->limit($limit); } return $builder->sortable($key, $direction); }
php
public function getSortedNodesBuilder($key = null, $direction = null, $type = null, $limit = null, $locale = null) { $builder = PublishedNode::translatedIn($locale) ->groupBy('nodes.id'); if ($type) { $builder->withType($type); } if ($limit) { $builder->limit($limit); } return $builder->sortable($key, $direction); }
[ "public", "function", "getSortedNodesBuilder", "(", "$", "key", "=", "null", ",", "$", "direction", "=", "null", ",", "$", "type", "=", "null", ",", "$", "limit", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "$", "builder", "=", "PublishedNode", "::", "translatedIn", "(", "$", "locale", ")", "->", "groupBy", "(", "'nodes.id'", ")", ";", "if", "(", "$", "type", ")", "{", "$", "builder", "->", "withType", "(", "$", "type", ")", ";", "}", "if", "(", "$", "limit", ")", "{", "$", "builder", "->", "limit", "(", "$", "limit", ")", ";", "}", "return", "$", "builder", "->", "sortable", "(", "$", "key", ",", "$", "direction", ")", ";", "}" ]
Gets node sortable builder @param string $key @param string $direction @param string $type @param int $limit @param string $locale @return Builder
[ "Gets", "node", "sortable", "builder" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeRepository.php#L161-L177
23,987
NuclearCMS/Hierarchy
src/NodeRepository.php
NodeRepository.getSortedNodes
public function getSortedNodes($key = null, $direction = null, $type = null, $limit = null, $locale = null) { return $this->getSortedNodesBuilder($key, $direction, $type, $limit, $locale)->paginate(); }
php
public function getSortedNodes($key = null, $direction = null, $type = null, $limit = null, $locale = null) { return $this->getSortedNodesBuilder($key, $direction, $type, $limit, $locale)->paginate(); }
[ "public", "function", "getSortedNodes", "(", "$", "key", "=", "null", ",", "$", "direction", "=", "null", ",", "$", "type", "=", "null", ",", "$", "limit", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "return", "$", "this", "->", "getSortedNodesBuilder", "(", "$", "key", ",", "$", "direction", ",", "$", "type", ",", "$", "limit", ",", "$", "locale", ")", "->", "paginate", "(", ")", ";", "}" ]
Gets sorted nodes @param string $key @param string $direction @param string $type @param int $limit @param string $locale @return Collection
[ "Gets", "sorted", "nodes" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeRepository.php#L189-L192
23,988
NuclearCMS/Hierarchy
src/NodeRepository.php
NodeRepository.getNodeById
public function getNodeById($id, $published) { return $published ? PublishedNode::find($id) : Node::find($id); }
php
public function getNodeById($id, $published) { return $published ? PublishedNode::find($id) : Node::find($id); }
[ "public", "function", "getNodeById", "(", "$", "id", ",", "$", "published", ")", "{", "return", "$", "published", "?", "PublishedNode", "::", "find", "(", "$", "id", ")", ":", "Node", "::", "find", "(", "$", "id", ")", ";", "}" ]
Returns a node by id @param int $id @param bool $published @return Node
[ "Returns", "a", "node", "by", "id" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeRepository.php#L201-L204
23,989
NuclearCMS/Hierarchy
src/NodeRepository.php
NodeRepository.getNodesByIds
public function getNodesByIds($ids, $published = true) { if (empty($ids)) { return null; } if (is_string($ids)) { $ids = json_decode($ids, true); } if (is_array($ids) && ! empty($ids)) { $placeholders = implode(',', array_fill(0, count($ids), '?')); $nodes = Node::whereIn('id', $ids) ->orderByRaw('field(id,' . $placeholders . ')', $ids); if ($published) { $nodes->published(); } $nodes = $nodes->get(); return (count($nodes) > 0) ? $nodes : null; } return null; }
php
public function getNodesByIds($ids, $published = true) { if (empty($ids)) { return null; } if (is_string($ids)) { $ids = json_decode($ids, true); } if (is_array($ids) && ! empty($ids)) { $placeholders = implode(',', array_fill(0, count($ids), '?')); $nodes = Node::whereIn('id', $ids) ->orderByRaw('field(id,' . $placeholders . ')', $ids); if ($published) { $nodes->published(); } $nodes = $nodes->get(); return (count($nodes) > 0) ? $nodes : null; } return null; }
[ "public", "function", "getNodesByIds", "(", "$", "ids", ",", "$", "published", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "ids", ")", ")", "{", "return", "null", ";", "}", "if", "(", "is_string", "(", "$", "ids", ")", ")", "{", "$", "ids", "=", "json_decode", "(", "$", "ids", ",", "true", ")", ";", "}", "if", "(", "is_array", "(", "$", "ids", ")", "&&", "!", "empty", "(", "$", "ids", ")", ")", "{", "$", "placeholders", "=", "implode", "(", "','", ",", "array_fill", "(", "0", ",", "count", "(", "$", "ids", ")", ",", "'?'", ")", ")", ";", "$", "nodes", "=", "Node", "::", "whereIn", "(", "'id'", ",", "$", "ids", ")", "->", "orderByRaw", "(", "'field(id,'", ".", "$", "placeholders", ".", "')'", ",", "$", "ids", ")", ";", "if", "(", "$", "published", ")", "{", "$", "nodes", "->", "published", "(", ")", ";", "}", "$", "nodes", "=", "$", "nodes", "->", "get", "(", ")", ";", "return", "(", "count", "(", "$", "nodes", ")", ">", "0", ")", "?", "$", "nodes", ":", "null", ";", "}", "return", "null", ";", "}" ]
Returns nodes by ids @param array|string $ids @param bool $published @return Collection
[ "Returns", "nodes", "by", "ids" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeRepository.php#L213-L243
23,990
codezero-be/curl
src/Curl.php
Curl.initialize
public function initialize() { if ($this->isInitialized()) { $this->close(); } if ( ! ($this->curl = curl_init())) { throw new CurlException('Could not initialize a cURL resource'); } return true; }
php
public function initialize() { if ($this->isInitialized()) { $this->close(); } if ( ! ($this->curl = curl_init())) { throw new CurlException('Could not initialize a cURL resource'); } return true; }
[ "public", "function", "initialize", "(", ")", "{", "if", "(", "$", "this", "->", "isInitialized", "(", ")", ")", "{", "$", "this", "->", "close", "(", ")", ";", "}", "if", "(", "!", "(", "$", "this", "->", "curl", "=", "curl_init", "(", ")", ")", ")", "{", "throw", "new", "CurlException", "(", "'Could not initialize a cURL resource'", ")", ";", "}", "return", "true", ";", "}" ]
Initialize a new cURL resource @return bool @throws CurlException
[ "Initialize", "a", "new", "cURL", "resource" ]
c1385479886662b6276c18dd9140df529959d95c
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/Curl.php#L38-L51
23,991
codezero-be/curl
src/Curl.php
Curl.setOption
public function setOption($option, $value) { $this->autoInitialize(); return curl_setopt($this->curl, $option, $value); }
php
public function setOption($option, $value) { $this->autoInitialize(); return curl_setopt($this->curl, $option, $value); }
[ "public", "function", "setOption", "(", "$", "option", ",", "$", "value", ")", "{", "$", "this", "->", "autoInitialize", "(", ")", ";", "return", "curl_setopt", "(", "$", "this", "->", "curl", ",", "$", "option", ",", "$", "value", ")", ";", "}" ]
Set cURL option @param int $option @param mixed $value @return bool @throws CurlException
[ "Set", "cURL", "option" ]
c1385479886662b6276c18dd9140df529959d95c
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/Curl.php#L72-L77
23,992
codezero-be/curl
src/Curl.php
Curl.getRequestInfo
public function getRequestInfo($key = null) { if ( ! $this->isInitialized()) { return $key ? '' : []; } return $key ? curl_getinfo($this->curl, $key) : curl_getinfo($this->curl); }
php
public function getRequestInfo($key = null) { if ( ! $this->isInitialized()) { return $key ? '' : []; } return $key ? curl_getinfo($this->curl, $key) : curl_getinfo($this->curl); }
[ "public", "function", "getRequestInfo", "(", "$", "key", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isInitialized", "(", ")", ")", "{", "return", "$", "key", "?", "''", ":", "[", "]", ";", "}", "return", "$", "key", "?", "curl_getinfo", "(", "$", "this", "->", "curl", ",", "$", "key", ")", ":", "curl_getinfo", "(", "$", "this", "->", "curl", ")", ";", "}" ]
Get additional information about the last cURL request @param string $key @return string|array
[ "Get", "additional", "information", "about", "the", "last", "cURL", "request" ]
c1385479886662b6276c18dd9140df529959d95c
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/Curl.php#L138-L146
23,993
codezero-be/curl
src/Curl.php
Curl.reset
public function reset() { if ( ! $this->isInitialized() || ! function_exists('curl_reset')) { $this->initialize(); } else { // PHP >= 5.5.0 curl_reset($this->curl); $this->response = null; } }
php
public function reset() { if ( ! $this->isInitialized() || ! function_exists('curl_reset')) { $this->initialize(); } else { // PHP >= 5.5.0 curl_reset($this->curl); $this->response = null; } }
[ "public", "function", "reset", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isInitialized", "(", ")", "||", "!", "function_exists", "(", "'curl_reset'", ")", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "}", "else", "{", "// PHP >= 5.5.0", "curl_reset", "(", "$", "this", "->", "curl", ")", ";", "$", "this", "->", "response", "=", "null", ";", "}", "}" ]
Reset all cURL options @return void @throws CurlException
[ "Reset", "all", "cURL", "options" ]
c1385479886662b6276c18dd9140df529959d95c
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/Curl.php#L216-L229
23,994
codezero-be/curl
src/Curl.php
Curl.close
public function close() { if ($this->isInitialized()) { curl_close($this->curl); $this->curl = null; $this->response = null; } }
php
public function close() { if ($this->isInitialized()) { curl_close($this->curl); $this->curl = null; $this->response = null; } }
[ "public", "function", "close", "(", ")", "{", "if", "(", "$", "this", "->", "isInitialized", "(", ")", ")", "{", "curl_close", "(", "$", "this", "->", "curl", ")", ";", "$", "this", "->", "curl", "=", "null", ";", "$", "this", "->", "response", "=", "null", ";", "}", "}" ]
Close the cURL resource @return void
[ "Close", "the", "cURL", "resource" ]
c1385479886662b6276c18dd9140df529959d95c
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/Curl.php#L236-L245
23,995
codezero-be/curl
src/Curl.php
Curl.parseUrl
private function parseUrl($string, $decode) { $this->autoInitialize(); $function = $decode ? 'curl_unescape' : 'curl_escape'; if ( ! function_exists($function)) { return $decode ? rawurldecode($string) : rawurlencode($string); } // PHP >= 5.5.0 return call_user_func($function, $this->curl, $string); }
php
private function parseUrl($string, $decode) { $this->autoInitialize(); $function = $decode ? 'curl_unescape' : 'curl_escape'; if ( ! function_exists($function)) { return $decode ? rawurldecode($string) : rawurlencode($string); } // PHP >= 5.5.0 return call_user_func($function, $this->curl, $string); }
[ "private", "function", "parseUrl", "(", "$", "string", ",", "$", "decode", ")", "{", "$", "this", "->", "autoInitialize", "(", ")", ";", "$", "function", "=", "$", "decode", "?", "'curl_unescape'", ":", "'curl_escape'", ";", "if", "(", "!", "function_exists", "(", "$", "function", ")", ")", "{", "return", "$", "decode", "?", "rawurldecode", "(", "$", "string", ")", ":", "rawurlencode", "(", "$", "string", ")", ";", "}", "// PHP >= 5.5.0", "return", "call_user_func", "(", "$", "function", ",", "$", "this", "->", "curl", ",", "$", "string", ")", ";", "}" ]
Encode or decode a URL @param string $string @param bool $decode @return bool|string
[ "Encode", "or", "decode", "a", "URL" ]
c1385479886662b6276c18dd9140df529959d95c
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/Curl.php#L286-L299
23,996
josegonzalez/cakephp-sanction
Model/Behavior/PermitBehavior.php
PermitBehavior.user
public function user(Model $Model, $result, $key = null) { if (method_exists($Model, 'user')) { return $Model->user($key, $result); } if (class_exists('AuthComponent')) { return AuthComponent::user($key); } if (class_exists('Authsome')) { return Authsome::get($key); } if (method_exists($Model, 'get')) { $className = get_class($Model); $ref = new ReflectionMethod($className, 'get'); if ($ref->isStatic()) { return $className::get($key); } } return false; }
php
public function user(Model $Model, $result, $key = null) { if (method_exists($Model, 'user')) { return $Model->user($key, $result); } if (class_exists('AuthComponent')) { return AuthComponent::user($key); } if (class_exists('Authsome')) { return Authsome::get($key); } if (method_exists($Model, 'get')) { $className = get_class($Model); $ref = new ReflectionMethod($className, 'get'); if ($ref->isStatic()) { return $className::get($key); } } return false; }
[ "public", "function", "user", "(", "Model", "$", "Model", ",", "$", "result", ",", "$", "key", "=", "null", ")", "{", "if", "(", "method_exists", "(", "$", "Model", ",", "'user'", ")", ")", "{", "return", "$", "Model", "->", "user", "(", "$", "key", ",", "$", "result", ")", ";", "}", "if", "(", "class_exists", "(", "'AuthComponent'", ")", ")", "{", "return", "AuthComponent", "::", "user", "(", "$", "key", ")", ";", "}", "if", "(", "class_exists", "(", "'Authsome'", ")", ")", "{", "return", "Authsome", "::", "get", "(", "$", "key", ")", ";", "}", "if", "(", "method_exists", "(", "$", "Model", ",", "'get'", ")", ")", "{", "$", "className", "=", "get_class", "(", "$", "Model", ")", ";", "$", "ref", "=", "new", "ReflectionMethod", "(", "$", "className", ",", "'get'", ")", ";", "if", "(", "$", "ref", "->", "isStatic", "(", ")", ")", "{", "return", "$", "className", "::", "get", "(", "$", "key", ")", ";", "}", "}", "return", "false", ";", "}" ]
Wrapper around retrieving user data Can be overriden in the Model to provide advanced control @param Model $Model Model to use to retrieve user @param array $result single Model record being authenticated against @param string $key field to retrieve. Leave null to get entire User record @return mixed User record. or null if no user is logged in.
[ "Wrapper", "around", "retrieving", "user", "data" ]
df2a8f0c0602c0ace802773db2c2ca6c89555c47
https://github.com/josegonzalez/cakephp-sanction/blob/df2a8f0c0602c0ace802773db2c2ca6c89555c47/Model/Behavior/PermitBehavior.php#L145-L167
23,997
josegonzalez/cakephp-sanction
Model/Behavior/PermitBehavior.php
PermitBehavior.permit
public function permit(Model $Model, $settings = array()) { // store existing model defaults $this->modelDefaultsPersist[$Model->alias] = $this->modelDefaults[$Model->alias]; // assign new settings $this->modelDefaults[$Model->alias] = array_merge($this->modelDefaults[$Model->alias], $settings); }
php
public function permit(Model $Model, $settings = array()) { // store existing model defaults $this->modelDefaultsPersist[$Model->alias] = $this->modelDefaults[$Model->alias]; // assign new settings $this->modelDefaults[$Model->alias] = array_merge($this->modelDefaults[$Model->alias], $settings); }
[ "public", "function", "permit", "(", "Model", "$", "Model", ",", "$", "settings", "=", "array", "(", ")", ")", "{", "// store existing model defaults", "$", "this", "->", "modelDefaultsPersist", "[", "$", "Model", "->", "alias", "]", "=", "$", "this", "->", "modelDefaults", "[", "$", "Model", "->", "alias", "]", ";", "// assign new settings", "$", "this", "->", "modelDefaults", "[", "$", "Model", "->", "alias", "]", "=", "array_merge", "(", "$", "this", "->", "modelDefaults", "[", "$", "Model", "->", "alias", "]", ",", "$", "settings", ")", ";", "}" ]
Used to dynamically assign permit settings @param Model $Model Model to dynamically assign permissions on @param array $settings same as the settings used to set-up the model, with the addition of 'persist' (boolean), which will keep the passed settings for all future model calls @return void
[ "Used", "to", "dynamically", "assign", "permit", "settings" ]
df2a8f0c0602c0ace802773db2c2ca6c89555c47
https://github.com/josegonzalez/cakephp-sanction/blob/df2a8f0c0602c0ace802773db2c2ca6c89555c47/Model/Behavior/PermitBehavior.php#L176-L181
23,998
antaresproject/notifications
src/Widgets/NotificationSender/Form/NotificationWidgetForm.php
NotificationWidgetForm.get
public function get() { $this->scripts(); return app('antares.form')->of("antares.widgets: notification-widget")->extend(function (FormGrid $form) { $form->name('Notification Tester'); $form->simple(handles('antares::notifications/widgets/send'), ['id' => 'notification-widget-form']); $form->layout('antares/notifications::widgets.forms.send_notification_form'); $form->fieldset(trans('Default Fieldset'), function (Fieldset $fieldset) { $fieldset->control('input:hidden', 'url') ->attributes(['class' => 'notification-widget-url']) ->value(handles('antares::notifications/notifications')) ->block(['class' => 'hidden']); $fieldset->control('select', 'type') ->attributes(['class' => 'notification-widget-change-type-select', 'url' => handles('antares::notifications/notifications')]) ->options($this->repository->getDecoratedNotificationTypes()) ->wrapper(['class' => 'w200']); $fieldset->control('select', 'notifications') ->attributes(['class' => 'notification-widget-notifications-select']) ->options($this->repository->getNotificationContents('email')->pluck('title', 'id')) ->wrapper(['class' => 'w300']); if (!is_null(from_route('user'))) { $fieldset->control('button', 'send') ->attributes([ 'type' => 'submit', 'class' => 'notification-widget-send-button', 'data-title' => trans('Are you sure to send notification?'), 'url' => handles('antares::notifications/widgets/send'), ])->value(trans('Send')); } $fieldset->control('button', 'test') ->attributes([ 'type' => 'submit', 'class' => 'notification-widget-test-button btn--red', 'data-title' => trans('Are you sure to test notification?'), 'url' => handles('antares::notifications/widgets/test'), ])->value(trans('Test')); }); $form->rules($this->rules); $form->ajaxable([ 'afterValidate' => $this->afterValidateInline() ]); }); }
php
public function get() { $this->scripts(); return app('antares.form')->of("antares.widgets: notification-widget")->extend(function (FormGrid $form) { $form->name('Notification Tester'); $form->simple(handles('antares::notifications/widgets/send'), ['id' => 'notification-widget-form']); $form->layout('antares/notifications::widgets.forms.send_notification_form'); $form->fieldset(trans('Default Fieldset'), function (Fieldset $fieldset) { $fieldset->control('input:hidden', 'url') ->attributes(['class' => 'notification-widget-url']) ->value(handles('antares::notifications/notifications')) ->block(['class' => 'hidden']); $fieldset->control('select', 'type') ->attributes(['class' => 'notification-widget-change-type-select', 'url' => handles('antares::notifications/notifications')]) ->options($this->repository->getDecoratedNotificationTypes()) ->wrapper(['class' => 'w200']); $fieldset->control('select', 'notifications') ->attributes(['class' => 'notification-widget-notifications-select']) ->options($this->repository->getNotificationContents('email')->pluck('title', 'id')) ->wrapper(['class' => 'w300']); if (!is_null(from_route('user'))) { $fieldset->control('button', 'send') ->attributes([ 'type' => 'submit', 'class' => 'notification-widget-send-button', 'data-title' => trans('Are you sure to send notification?'), 'url' => handles('antares::notifications/widgets/send'), ])->value(trans('Send')); } $fieldset->control('button', 'test') ->attributes([ 'type' => 'submit', 'class' => 'notification-widget-test-button btn--red', 'data-title' => trans('Are you sure to test notification?'), 'url' => handles('antares::notifications/widgets/test'), ])->value(trans('Test')); }); $form->rules($this->rules); $form->ajaxable([ 'afterValidate' => $this->afterValidateInline() ]); }); }
[ "public", "function", "get", "(", ")", "{", "$", "this", "->", "scripts", "(", ")", ";", "return", "app", "(", "'antares.form'", ")", "->", "of", "(", "\"antares.widgets: notification-widget\"", ")", "->", "extend", "(", "function", "(", "FormGrid", "$", "form", ")", "{", "$", "form", "->", "name", "(", "'Notification Tester'", ")", ";", "$", "form", "->", "simple", "(", "handles", "(", "'antares::notifications/widgets/send'", ")", ",", "[", "'id'", "=>", "'notification-widget-form'", "]", ")", ";", "$", "form", "->", "layout", "(", "'antares/notifications::widgets.forms.send_notification_form'", ")", ";", "$", "form", "->", "fieldset", "(", "trans", "(", "'Default Fieldset'", ")", ",", "function", "(", "Fieldset", "$", "fieldset", ")", "{", "$", "fieldset", "->", "control", "(", "'input:hidden'", ",", "'url'", ")", "->", "attributes", "(", "[", "'class'", "=>", "'notification-widget-url'", "]", ")", "->", "value", "(", "handles", "(", "'antares::notifications/notifications'", ")", ")", "->", "block", "(", "[", "'class'", "=>", "'hidden'", "]", ")", ";", "$", "fieldset", "->", "control", "(", "'select'", ",", "'type'", ")", "->", "attributes", "(", "[", "'class'", "=>", "'notification-widget-change-type-select'", ",", "'url'", "=>", "handles", "(", "'antares::notifications/notifications'", ")", "]", ")", "->", "options", "(", "$", "this", "->", "repository", "->", "getDecoratedNotificationTypes", "(", ")", ")", "->", "wrapper", "(", "[", "'class'", "=>", "'w200'", "]", ")", ";", "$", "fieldset", "->", "control", "(", "'select'", ",", "'notifications'", ")", "->", "attributes", "(", "[", "'class'", "=>", "'notification-widget-notifications-select'", "]", ")", "->", "options", "(", "$", "this", "->", "repository", "->", "getNotificationContents", "(", "'email'", ")", "->", "pluck", "(", "'title'", ",", "'id'", ")", ")", "->", "wrapper", "(", "[", "'class'", "=>", "'w300'", "]", ")", ";", "if", "(", "!", "is_null", "(", "from_route", "(", "'user'", ")", ")", ")", "{", "$", "fieldset", "->", "control", "(", "'button'", ",", "'send'", ")", "->", "attributes", "(", "[", "'type'", "=>", "'submit'", ",", "'class'", "=>", "'notification-widget-send-button'", ",", "'data-title'", "=>", "trans", "(", "'Are you sure to send notification?'", ")", ",", "'url'", "=>", "handles", "(", "'antares::notifications/widgets/send'", ")", ",", "]", ")", "->", "value", "(", "trans", "(", "'Send'", ")", ")", ";", "}", "$", "fieldset", "->", "control", "(", "'button'", ",", "'test'", ")", "->", "attributes", "(", "[", "'type'", "=>", "'submit'", ",", "'class'", "=>", "'notification-widget-test-button btn--red'", ",", "'data-title'", "=>", "trans", "(", "'Are you sure to test notification?'", ")", ",", "'url'", "=>", "handles", "(", "'antares::notifications/widgets/test'", ")", ",", "]", ")", "->", "value", "(", "trans", "(", "'Test'", ")", ")", ";", "}", ")", ";", "$", "form", "->", "rules", "(", "$", "this", "->", "rules", ")", ";", "$", "form", "->", "ajaxable", "(", "[", "'afterValidate'", "=>", "$", "this", "->", "afterValidateInline", "(", ")", "]", ")", ";", "}", ")", ";", "}" ]
Gets form instance @return \Antares\Html\Form\FormBuilder
[ "Gets", "form", "instance" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Widgets/NotificationSender/Form/NotificationWidgetForm.php#L71-L120
23,999
Laralum/Permissions
src/Traits/HasPermissions.php
HasPermissions.hasPermission
public function hasPermission($permission) { $permission = !is_string($permission) ?: Permission::where(['slug' => $permission])->first(); if ($permission) { foreach ($this->permissions as $p) { if ($p->id == $permission->id) { return true; } } } return false; }
php
public function hasPermission($permission) { $permission = !is_string($permission) ?: Permission::where(['slug' => $permission])->first(); if ($permission) { foreach ($this->permissions as $p) { if ($p->id == $permission->id) { return true; } } } return false; }
[ "public", "function", "hasPermission", "(", "$", "permission", ")", "{", "$", "permission", "=", "!", "is_string", "(", "$", "permission", ")", "?", ":", "Permission", "::", "where", "(", "[", "'slug'", "=>", "$", "permission", "]", ")", "->", "first", "(", ")", ";", "if", "(", "$", "permission", ")", "{", "foreach", "(", "$", "this", "->", "permissions", "as", "$", "p", ")", "{", "if", "(", "$", "p", "->", "id", "==", "$", "permission", "->", "id", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Returns if the user has a permission. @param mixed $permision @return bool
[ "Returns", "if", "the", "user", "has", "a", "permission", "." ]
79970ee7d1bff816ad4b9adee29067faead3f756
https://github.com/Laralum/Permissions/blob/79970ee7d1bff816ad4b9adee29067faead3f756/src/Traits/HasPermissions.php#L24-L37