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
32,600
gocom/textpattern-installer
src/Textpattern/Composer/Installer/Textpattern/Validate.php
Validate.isValidConfig
public function isValidConfig() { $missing = []; foreach ($this->required as $required) { if (!array_key_exists($required, $this->txpcfg)) { $missing[] = $required; } } if ($missing) { throw new \InvalidArgumentException( 'Textpattern installation missing config values: '.implode(', ', $missing) ); } }
php
public function isValidConfig() { $missing = []; foreach ($this->required as $required) { if (!array_key_exists($required, $this->txpcfg)) { $missing[] = $required; } } if ($missing) { throw new \InvalidArgumentException( 'Textpattern installation missing config values: '.implode(', ', $missing) ); } }
[ "public", "function", "isValidConfig", "(", ")", "{", "$", "missing", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "required", "as", "$", "required", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "required", ",", "$", "this", "->", "txpcfg", ")", ")", "{", "$", "missing", "[", "]", "=", "$", "required", ";", "}", "}", "if", "(", "$", "missing", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Textpattern installation missing config values: '", ".", "implode", "(", "', '", ",", "$", "missing", ")", ")", ";", "}", "}" ]
Checks that the config contains all needed options. @throws \InvalidArgumentException
[ "Checks", "that", "the", "config", "contains", "all", "needed", "options", "." ]
804271de54177ebd294a4a19d409ae7fc2317935
https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Textpattern/Validate.php#L72-L87
32,601
gocom/textpattern-installer
src/Textpattern/Composer/Installer/Textpattern/Validate.php
Validate.hasDatabase
public function hasDatabase() { try { $pdo = new \PDO( 'mysql:host='.$this->txpcfg['host'].';dbname='.$this->txpcfg['db'], $this->txpcfg['user'], $this->txpcfg['pass'] ); } catch (\PDOException $e) { $pdo = false; } if ($pdo === false) { throw new \InvalidArgumentException( 'Unable connect to Textpattern database: '.$this->txpcfg['db'].'@'.$this->txpcfg['host'] ); } if (!$pdo->prepare('SHOW TABLES LIKE ?')->execute(array($this->txpcfg['table_prefix'] . 'textpattern'))) { throw new \InvalidArgumentException('Textpattern is not installed'); } }
php
public function hasDatabase() { try { $pdo = new \PDO( 'mysql:host='.$this->txpcfg['host'].';dbname='.$this->txpcfg['db'], $this->txpcfg['user'], $this->txpcfg['pass'] ); } catch (\PDOException $e) { $pdo = false; } if ($pdo === false) { throw new \InvalidArgumentException( 'Unable connect to Textpattern database: '.$this->txpcfg['db'].'@'.$this->txpcfg['host'] ); } if (!$pdo->prepare('SHOW TABLES LIKE ?')->execute(array($this->txpcfg['table_prefix'] . 'textpattern'))) { throw new \InvalidArgumentException('Textpattern is not installed'); } }
[ "public", "function", "hasDatabase", "(", ")", "{", "try", "{", "$", "pdo", "=", "new", "\\", "PDO", "(", "'mysql:host='", ".", "$", "this", "->", "txpcfg", "[", "'host'", "]", ".", "';dbname='", ".", "$", "this", "->", "txpcfg", "[", "'db'", "]", ",", "$", "this", "->", "txpcfg", "[", "'user'", "]", ",", "$", "this", "->", "txpcfg", "[", "'pass'", "]", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "$", "pdo", "=", "false", ";", "}", "if", "(", "$", "pdo", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unable connect to Textpattern database: '", ".", "$", "this", "->", "txpcfg", "[", "'db'", "]", ".", "'@'", ".", "$", "this", "->", "txpcfg", "[", "'host'", "]", ")", ";", "}", "if", "(", "!", "$", "pdo", "->", "prepare", "(", "'SHOW TABLES LIKE ?'", ")", "->", "execute", "(", "array", "(", "$", "this", "->", "txpcfg", "[", "'table_prefix'", "]", ".", "'textpattern'", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Textpattern is not installed'", ")", ";", "}", "}" ]
Checks if the database exists. @throws \InvalidArgumentException
[ "Checks", "if", "the", "database", "exists", "." ]
804271de54177ebd294a4a19d409ae7fc2317935
https://github.com/gocom/textpattern-installer/blob/804271de54177ebd294a4a19d409ae7fc2317935/src/Textpattern/Composer/Installer/Textpattern/Validate.php#L94-L115
32,602
Vectorface/cache
src/MCCache.php
MCCache.set
public function set($key, $value, $ttl = false) { return $this->mc->set($key, $value, null, (int)$ttl); }
php
public function set($key, $value, $ttl = false) { return $this->mc->set($key, $value, null, (int)$ttl); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "false", ")", "{", "return", "$", "this", "->", "mc", "->", "set", "(", "$", "key", ",", "$", "value", ",", "null", ",", "(", "int", ")", "$", "ttl", ")", ";", "}" ]
Place an item into the cache @param string $key The cache key. @param mixed $value The value to be stored. (Warning: Caches cannot store items of type resource.) @param int $ttl The time to live, in seconds. The time before the object should expire. @return bool True if successful, false otherwise.
[ "Place", "an", "item", "into", "the", "cache" ]
159f4aeaf639da7a1f7e1d4e5e719a279442658b
https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/MCCache.php#L64-L67
32,603
flipboxfactory/craft-ember
src/queries/ActiveQuery.php
ActiveQuery.requireAll
public function requireAll($db = null) { $records = $this->all($db); if (empty($records)) { throw new RecordNotFoundException( sprintf( "Records not found." ) ); } return $records; }
php
public function requireAll($db = null) { $records = $this->all($db); if (empty($records)) { throw new RecordNotFoundException( sprintf( "Records not found." ) ); } return $records; }
[ "public", "function", "requireAll", "(", "$", "db", "=", "null", ")", "{", "$", "records", "=", "$", "this", "->", "all", "(", "$", "db", ")", ";", "if", "(", "empty", "(", "$", "records", ")", ")", "{", "throw", "new", "RecordNotFoundException", "(", "sprintf", "(", "\"Records not found.\"", ")", ")", ";", "}", "return", "$", "records", ";", "}" ]
Executes query and returns all results as an array. If results are not found, an exception is thrown as we explicitly expect results. @param Connection $db the DB connection used to create the DB command. If null, the DB connection returned by [[modelClass]] will be used. @return array|ActiveRecord[] the query results. If the query results in nothing, an empty array will be returned. @throws RecordNotFoundException
[ "Executes", "query", "and", "returns", "all", "results", "as", "an", "array", ".", "If", "results", "are", "not", "found", "an", "exception", "is", "thrown", "as", "we", "explicitly", "expect", "results", "." ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/queries/ActiveQuery.php#L57-L70
32,604
flipboxfactory/craft-ember
src/queries/ActiveQuery.php
ActiveQuery.requireOne
public function requireOne($db = null) { if (null === ($record = $this->one($db))) { throw new RecordNotFoundException( sprintf( "Record not found." ) ); } return $record; }
php
public function requireOne($db = null) { if (null === ($record = $this->one($db))) { throw new RecordNotFoundException( sprintf( "Record not found." ) ); } return $record; }
[ "public", "function", "requireOne", "(", "$", "db", "=", "null", ")", "{", "if", "(", "null", "===", "(", "$", "record", "=", "$", "this", "->", "one", "(", "$", "db", ")", ")", ")", "{", "throw", "new", "RecordNotFoundException", "(", "sprintf", "(", "\"Record not found.\"", ")", ")", ";", "}", "return", "$", "record", ";", "}" ]
Executes query and returns a single result. If a result is not found, an exception is thrown as we explicitly expect a result. @param Connection|null $db the DB connection used to create the DB command. If `null`, the DB connection returned by [[modelClass]] will be used. @return ActiveRecord|array a single row of query result. Depending on the setting of [[asArray]], the query result may be either an array or an ActiveRecord object. `null` will be returned if the query results in nothing. @throws RecordNotFoundException
[ "Executes", "query", "and", "returns", "a", "single", "result", ".", "If", "a", "result", "is", "not", "found", "an", "exception", "is", "thrown", "as", "we", "explicitly", "expect", "a", "result", "." ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/queries/ActiveQuery.php#L83-L94
32,605
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.getOne
public function getOne($hail_object) { $uri = $hail_object::$object_endpoint . '/' . $hail_object->HailID; return $this->get($uri); }
php
public function getOne($hail_object) { $uri = $hail_object::$object_endpoint . '/' . $hail_object->HailID; return $this->get($uri); }
[ "public", "function", "getOne", "(", "$", "hail_object", ")", "{", "$", "uri", "=", "$", "hail_object", "::", "$", "object_endpoint", ".", "'/'", ".", "$", "hail_object", "->", "HailID", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ")", ";", "}" ]
Get one Hail object from the API @param mixed $hail_object Object to retrieve @return array Reply from Hail @throws
[ "Get", "one", "Hail", "object", "from", "the", "API" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L110-L115
32,606
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.fetchAccessToken
public function fetchAccessToken($redirect_code) { $http = $this->getHTTPClient(); $post_data = [ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'grant_type' => 'authorization_code', 'code' => $redirect_code, 'redirect_uri' => $this->getRedirectURL(), ]; // Request access token try { $response = $http->request('POST', 'oauth/access_token', [ 'form_params' => $post_data ]); $responseBody = $response->getBody(); $responseArr = json_decode($responseBody, true); //Set new data into the config and update the current instance $this->setAccessToken($responseArr['access_token']); $this->setAccessTokenExpire($responseArr['expires_in']); $this->setRefreshToken($responseArr['refresh_token']); } catch (\Exception $exception) { $this->handleException($exception); } }
php
public function fetchAccessToken($redirect_code) { $http = $this->getHTTPClient(); $post_data = [ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'grant_type' => 'authorization_code', 'code' => $redirect_code, 'redirect_uri' => $this->getRedirectURL(), ]; // Request access token try { $response = $http->request('POST', 'oauth/access_token', [ 'form_params' => $post_data ]); $responseBody = $response->getBody(); $responseArr = json_decode($responseBody, true); //Set new data into the config and update the current instance $this->setAccessToken($responseArr['access_token']); $this->setAccessTokenExpire($responseArr['expires_in']); $this->setRefreshToken($responseArr['refresh_token']); } catch (\Exception $exception) { $this->handleException($exception); } }
[ "public", "function", "fetchAccessToken", "(", "$", "redirect_code", ")", "{", "$", "http", "=", "$", "this", "->", "getHTTPClient", "(", ")", ";", "$", "post_data", "=", "[", "'client_id'", "=>", "$", "this", "->", "client_id", ",", "'client_secret'", "=>", "$", "this", "->", "client_secret", ",", "'grant_type'", "=>", "'authorization_code'", ",", "'code'", "=>", "$", "redirect_code", ",", "'redirect_uri'", "=>", "$", "this", "->", "getRedirectURL", "(", ")", ",", "]", ";", "// Request access token\r", "try", "{", "$", "response", "=", "$", "http", "->", "request", "(", "'POST'", ",", "'oauth/access_token'", ",", "[", "'form_params'", "=>", "$", "post_data", "]", ")", ";", "$", "responseBody", "=", "$", "response", "->", "getBody", "(", ")", ";", "$", "responseArr", "=", "json_decode", "(", "$", "responseBody", ",", "true", ")", ";", "//Set new data into the config and update the current instance\r", "$", "this", "->", "setAccessToken", "(", "$", "responseArr", "[", "'access_token'", "]", ")", ";", "$", "this", "->", "setAccessTokenExpire", "(", "$", "responseArr", "[", "'expires_in'", "]", ")", ";", "$", "this", "->", "setRefreshToken", "(", "$", "responseArr", "[", "'refresh_token'", "]", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "this", "->", "handleException", "(", "$", "exception", ")", ";", "}", "}" ]
Fetch OAuth Access token from the HAil API @param string $redirect_code @throws
[ "Fetch", "OAuth", "Access", "token", "from", "the", "HAil", "API" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L124-L150
32,607
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.setAccessTokenExpire
public function setAccessTokenExpire($access_token_expire) { //Store expiry date as unix timestamp (now + expires in) $access_token_expire = time() + $access_token_expire; $this->access_token_expire = $access_token_expire; $config = SiteConfig::current_site_config(); $config->HailAccessTokenExpire = $access_token_expire; $config->write(); }
php
public function setAccessTokenExpire($access_token_expire) { //Store expiry date as unix timestamp (now + expires in) $access_token_expire = time() + $access_token_expire; $this->access_token_expire = $access_token_expire; $config = SiteConfig::current_site_config(); $config->HailAccessTokenExpire = $access_token_expire; $config->write(); }
[ "public", "function", "setAccessTokenExpire", "(", "$", "access_token_expire", ")", "{", "//Store expiry date as unix timestamp (now + expires in)\r", "$", "access_token_expire", "=", "time", "(", ")", "+", "$", "access_token_expire", ";", "$", "this", "->", "access_token_expire", "=", "$", "access_token_expire", ";", "$", "config", "=", "SiteConfig", "::", "current_site_config", "(", ")", ";", "$", "config", "->", "HailAccessTokenExpire", "=", "$", "access_token_expire", ";", "$", "config", "->", "write", "(", ")", ";", "}" ]
Set Hail API OAuth access token expiry time in current SiteConfig @param string $access_token_expire @throws
[ "Set", "Hail", "API", "OAuth", "access", "token", "expiry", "time", "in", "current", "SiteConfig" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L188-L196
32,608
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.setRefreshToken
public function setRefreshToken($refresh_token) { $config = SiteConfig::current_site_config(); $config->HailRefreshToken = $refresh_token; $this->refresh_token = $refresh_token; $config->write(); }
php
public function setRefreshToken($refresh_token) { $config = SiteConfig::current_site_config(); $config->HailRefreshToken = $refresh_token; $this->refresh_token = $refresh_token; $config->write(); }
[ "public", "function", "setRefreshToken", "(", "$", "refresh_token", ")", "{", "$", "config", "=", "SiteConfig", "::", "current_site_config", "(", ")", ";", "$", "config", "->", "HailRefreshToken", "=", "$", "refresh_token", ";", "$", "this", "->", "refresh_token", "=", "$", "refresh_token", ";", "$", "config", "->", "write", "(", ")", ";", "}" ]
Set Hail API OAuth refresh token in current SiteConfig @param string $refresh_token @throws
[ "Set", "Hail", "API", "OAuth", "refresh", "token", "in", "current", "SiteConfig" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L203-L209
32,609
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.handleException
public function handleException($exception) { //Log the error Injector::inst()->get(LoggerInterface::class)->debug($exception->getMessage()); $request = Injector::inst()->get(HTTPRequest::class); $request->getSession()->set('notice', true); $request->getSession()->set('noticeType', 'bad'); $message = $exception->getMessage(); if ($exception->hasResponse()) { $response = json_decode($exception->getResponse()->getBody(), true); if (isset($response['error']) && isset($response['error']['message'])) { $message = $response['error']['message']; } } $request->getSession()->set('noticeText', $message); }
php
public function handleException($exception) { //Log the error Injector::inst()->get(LoggerInterface::class)->debug($exception->getMessage()); $request = Injector::inst()->get(HTTPRequest::class); $request->getSession()->set('notice', true); $request->getSession()->set('noticeType', 'bad'); $message = $exception->getMessage(); if ($exception->hasResponse()) { $response = json_decode($exception->getResponse()->getBody(), true); if (isset($response['error']) && isset($response['error']['message'])) { $message = $response['error']['message']; } } $request->getSession()->set('noticeText', $message); }
[ "public", "function", "handleException", "(", "$", "exception", ")", "{", "//Log the error\r", "Injector", "::", "inst", "(", ")", "->", "get", "(", "LoggerInterface", "::", "class", ")", "->", "debug", "(", "$", "exception", "->", "getMessage", "(", ")", ")", ";", "$", "request", "=", "Injector", "::", "inst", "(", ")", "->", "get", "(", "HTTPRequest", "::", "class", ")", ";", "$", "request", "->", "getSession", "(", ")", "->", "set", "(", "'notice'", ",", "true", ")", ";", "$", "request", "->", "getSession", "(", ")", "->", "set", "(", "'noticeType'", ",", "'bad'", ")", ";", "$", "message", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "if", "(", "$", "exception", "->", "hasResponse", "(", ")", ")", "{", "$", "response", "=", "json_decode", "(", "$", "exception", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "response", "[", "'error'", "]", ")", "&&", "isset", "(", "$", "response", "[", "'error'", "]", "[", "'message'", "]", ")", ")", "{", "$", "message", "=", "$", "response", "[", "'error'", "]", "[", "'message'", "]", ";", "}", "}", "$", "request", "->", "getSession", "(", ")", "->", "set", "(", "'noticeText'", ",", "$", "message", ")", ";", "}" ]
Silently handle Hail API HTTP Exception to avoid CMS crashes Stores error message in a session variable for CMS display @param \Exception $exception
[ "Silently", "handle", "Hail", "API", "HTTP", "Exception", "to", "avoid", "CMS", "crashes", "Stores", "error", "message", "in", "a", "session", "variable", "for", "CMS", "display" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L217-L232
32,610
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.getAuthorizationURL
public function getAuthorizationURL() { $url = Config::inst()->get(self::class, 'AuthorizationUrl'); $params = [ 'client_id' => $this->client_id, 'redirect_uri' => $this->getRedirectURL(), 'response_type' => "code", 'scope' => $this->scopes, ]; return $url . "?" . http_build_query($params); }
php
public function getAuthorizationURL() { $url = Config::inst()->get(self::class, 'AuthorizationUrl'); $params = [ 'client_id' => $this->client_id, 'redirect_uri' => $this->getRedirectURL(), 'response_type' => "code", 'scope' => $this->scopes, ]; return $url . "?" . http_build_query($params); }
[ "public", "function", "getAuthorizationURL", "(", ")", "{", "$", "url", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "self", "::", "class", ",", "'AuthorizationUrl'", ")", ";", "$", "params", "=", "[", "'client_id'", "=>", "$", "this", "->", "client_id", ",", "'redirect_uri'", "=>", "$", "this", "->", "getRedirectURL", "(", ")", ",", "'response_type'", "=>", "\"code\"", ",", "'scope'", "=>", "$", "this", "->", "scopes", ",", "]", ";", "return", "$", "url", ".", "\"?\"", ".", "http_build_query", "(", "$", "params", ")", ";", "}" ]
Build Hail API Authorization URL @return string
[ "Build", "Hail", "API", "Authorization", "URL" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L239-L250
32,611
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.setUserID
public function setUserID() { $response = $this->get("me"); $config = SiteConfig::current_site_config(); $config->HailUserID = $response['id']; $this->user_id = $response['id']; $config->write(); }
php
public function setUserID() { $response = $this->get("me"); $config = SiteConfig::current_site_config(); $config->HailUserID = $response['id']; $this->user_id = $response['id']; $config->write(); }
[ "public", "function", "setUserID", "(", ")", "{", "$", "response", "=", "$", "this", "->", "get", "(", "\"me\"", ")", ";", "$", "config", "=", "SiteConfig", "::", "current_site_config", "(", ")", ";", "$", "config", "->", "HailUserID", "=", "$", "response", "[", "'id'", "]", ";", "$", "this", "->", "user_id", "=", "$", "response", "[", "'id'", "]", ";", "$", "config", "->", "write", "(", ")", ";", "}" ]
Get Hail User ID from the API and set it in the current SiteConfig @throws
[ "Get", "Hail", "User", "ID", "from", "the", "API", "and", "set", "it", "in", "the", "current", "SiteConfig" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L257-L264
32,612
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.getAccessToken
public function getAccessToken() { //Check if AccessToken needs to be refreshed $now = time(); $time = time(); $difference = $this->access_token_expire - $time; if ($difference < strtotime('15 minutes', 0)) { $this->refreshAccessToken(); } return $this->access_token; }
php
public function getAccessToken() { //Check if AccessToken needs to be refreshed $now = time(); $time = time(); $difference = $this->access_token_expire - $time; if ($difference < strtotime('15 minutes', 0)) { $this->refreshAccessToken(); } return $this->access_token; }
[ "public", "function", "getAccessToken", "(", ")", "{", "//Check if AccessToken needs to be refreshed\r", "$", "now", "=", "time", "(", ")", ";", "$", "time", "=", "time", "(", ")", ";", "$", "difference", "=", "$", "this", "->", "access_token_expire", "-", "$", "time", ";", "if", "(", "$", "difference", "<", "strtotime", "(", "'15 minutes'", ",", "0", ")", ")", "{", "$", "this", "->", "refreshAccessToken", "(", ")", ";", "}", "return", "$", "this", "->", "access_token", ";", "}" ]
Get current Hail API OAuth Access token Will refresh the token from the API if it has expired @return string
[ "Get", "current", "Hail", "API", "OAuth", "Access", "token", "Will", "refresh", "the", "token", "from", "the", "API", "if", "it", "has", "expired" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L272-L283
32,613
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.setAccessToken
public function setAccessToken($access_token) { $this->access_token = $access_token; $config = SiteConfig::current_site_config(); $config->HailAccessToken = $access_token; $config->write(); }
php
public function setAccessToken($access_token) { $this->access_token = $access_token; $config = SiteConfig::current_site_config(); $config->HailAccessToken = $access_token; $config->write(); }
[ "public", "function", "setAccessToken", "(", "$", "access_token", ")", "{", "$", "this", "->", "access_token", "=", "$", "access_token", ";", "$", "config", "=", "SiteConfig", "::", "current_site_config", "(", ")", ";", "$", "config", "->", "HailAccessToken", "=", "$", "access_token", ";", "$", "config", "->", "write", "(", ")", ";", "}" ]
Set Hail API OAuth token in the current SiteConfig @throws
[ "Set", "Hail", "API", "OAuth", "token", "in", "the", "current", "SiteConfig" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L290-L296
32,614
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.refreshAccessToken
public function refreshAccessToken() { $http = $this->getHTTPClient(); $post_data = [ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'grant_type' => 'refresh_token', 'refresh_token' => $this->refresh_token, ]; // Refresh access token try { $response = $http->request('POST', 'oauth/access_token', [ 'form_params' => $post_data ]); $responseBody = $response->getBody(); $responseArr = json_decode($responseBody, true); //Set new data into the config and update the current instance $this->setAccessToken($responseArr['access_token']); $this->setAccessTokenExpire($responseArr['expires_in']); $this->setRefreshToken($responseArr['refresh_token']); } catch (\Exception $exception) { $this->handleException($exception); } }
php
public function refreshAccessToken() { $http = $this->getHTTPClient(); $post_data = [ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'grant_type' => 'refresh_token', 'refresh_token' => $this->refresh_token, ]; // Refresh access token try { $response = $http->request('POST', 'oauth/access_token', [ 'form_params' => $post_data ]); $responseBody = $response->getBody(); $responseArr = json_decode($responseBody, true); //Set new data into the config and update the current instance $this->setAccessToken($responseArr['access_token']); $this->setAccessTokenExpire($responseArr['expires_in']); $this->setRefreshToken($responseArr['refresh_token']); } catch (\Exception $exception) { $this->handleException($exception); } }
[ "public", "function", "refreshAccessToken", "(", ")", "{", "$", "http", "=", "$", "this", "->", "getHTTPClient", "(", ")", ";", "$", "post_data", "=", "[", "'client_id'", "=>", "$", "this", "->", "client_id", ",", "'client_secret'", "=>", "$", "this", "->", "client_secret", ",", "'grant_type'", "=>", "'refresh_token'", ",", "'refresh_token'", "=>", "$", "this", "->", "refresh_token", ",", "]", ";", "// Refresh access token\r", "try", "{", "$", "response", "=", "$", "http", "->", "request", "(", "'POST'", ",", "'oauth/access_token'", ",", "[", "'form_params'", "=>", "$", "post_data", "]", ")", ";", "$", "responseBody", "=", "$", "response", "->", "getBody", "(", ")", ";", "$", "responseArr", "=", "json_decode", "(", "$", "responseBody", ",", "true", ")", ";", "//Set new data into the config and update the current instance\r", "$", "this", "->", "setAccessToken", "(", "$", "responseArr", "[", "'access_token'", "]", ")", ";", "$", "this", "->", "setAccessTokenExpire", "(", "$", "responseArr", "[", "'expires_in'", "]", ")", ";", "$", "this", "->", "setRefreshToken", "(", "$", "responseArr", "[", "'refresh_token'", "]", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "this", "->", "handleException", "(", "$", "exception", ")", ";", "}", "}" ]
Refresh Hail API OAuth Access token from the API @throws
[ "Refresh", "Hail", "API", "OAuth", "Access", "token", "from", "the", "API" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L303-L329
32,615
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.getAvailableOrganisations
public function getAvailableOrganisations($as_simple_array = false) { $organisations = $this->get('users/' . $this->user_id . '/organisations'); //If simple array is true, we send back an array with [id] => [name] instead of the full list if ($as_simple_array) { $temp = []; foreach ($organisations as $org) { $temp[$org['id']] = $org['name']; } $organisations = $temp; } asort($organisations); return $organisations; }
php
public function getAvailableOrganisations($as_simple_array = false) { $organisations = $this->get('users/' . $this->user_id . '/organisations'); //If simple array is true, we send back an array with [id] => [name] instead of the full list if ($as_simple_array) { $temp = []; foreach ($organisations as $org) { $temp[$org['id']] = $org['name']; } $organisations = $temp; } asort($organisations); return $organisations; }
[ "public", "function", "getAvailableOrganisations", "(", "$", "as_simple_array", "=", "false", ")", "{", "$", "organisations", "=", "$", "this", "->", "get", "(", "'users/'", ".", "$", "this", "->", "user_id", ".", "'/organisations'", ")", ";", "//If simple array is true, we send back an array with [id] => [name] instead of the full list\r", "if", "(", "$", "as_simple_array", ")", "{", "$", "temp", "=", "[", "]", ";", "foreach", "(", "$", "organisations", "as", "$", "org", ")", "{", "$", "temp", "[", "$", "org", "[", "'id'", "]", "]", "=", "$", "org", "[", "'name'", "]", ";", "}", "$", "organisations", "=", "$", "temp", ";", "}", "asort", "(", "$", "organisations", ")", ";", "return", "$", "organisations", ";", "}" ]
Get all available Hail Organisation the configured client has access to @param boolean $as_simple_array Return a simple associative array (ID => Tile )instead of the full objects @return array @throws
[ "Get", "all", "available", "Hail", "Organisation", "the", "configured", "client", "has", "access", "to" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L359-L373
32,616
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.getAvailablePrivateTags
public function getAvailablePrivateTags($organisations = null, $as_simple_array = false) { $orgs_ids = $organisations ? array_keys($organisations) : json_decode($this->orgs_ids); if (!$orgs_ids) { //No organisations configured $this->handleException(new \Exception("You need at least 1 Hail Organisation configured to be able to fetch private tags")); return false; } $tag_list = []; foreach ($orgs_ids as $org_id) { //Get Org Name if ($organisations) { $org_name = isset($organisations[$org_id]) ? $organisations[$org_id] : ''; } else { $org = DataObject::get_one(Organisation::class, ['HailID' => $org_id]); $org_name = $org ? $org->Title : ""; } $results = $this->get('organisations/' . $org_id . '/private-tags'); //If simple array is true, we send back an array with [id] => [name] instead of the full list if ($as_simple_array) { foreach ($results as $result) { $tag_title = $result['name']; //Add organisation name on tag title if more than 1 org if (count($orgs_ids) > 1) { $tag_title = $org_name . " - " . $tag_title; } $tag_list[$result['id']] = $tag_title; } } else { $tag_list = array_merge($results, $tag_list); } } asort($tag_list); return $tag_list; }
php
public function getAvailablePrivateTags($organisations = null, $as_simple_array = false) { $orgs_ids = $organisations ? array_keys($organisations) : json_decode($this->orgs_ids); if (!$orgs_ids) { //No organisations configured $this->handleException(new \Exception("You need at least 1 Hail Organisation configured to be able to fetch private tags")); return false; } $tag_list = []; foreach ($orgs_ids as $org_id) { //Get Org Name if ($organisations) { $org_name = isset($organisations[$org_id]) ? $organisations[$org_id] : ''; } else { $org = DataObject::get_one(Organisation::class, ['HailID' => $org_id]); $org_name = $org ? $org->Title : ""; } $results = $this->get('organisations/' . $org_id . '/private-tags'); //If simple array is true, we send back an array with [id] => [name] instead of the full list if ($as_simple_array) { foreach ($results as $result) { $tag_title = $result['name']; //Add organisation name on tag title if more than 1 org if (count($orgs_ids) > 1) { $tag_title = $org_name . " - " . $tag_title; } $tag_list[$result['id']] = $tag_title; } } else { $tag_list = array_merge($results, $tag_list); } } asort($tag_list); return $tag_list; }
[ "public", "function", "getAvailablePrivateTags", "(", "$", "organisations", "=", "null", ",", "$", "as_simple_array", "=", "false", ")", "{", "$", "orgs_ids", "=", "$", "organisations", "?", "array_keys", "(", "$", "organisations", ")", ":", "json_decode", "(", "$", "this", "->", "orgs_ids", ")", ";", "if", "(", "!", "$", "orgs_ids", ")", "{", "//No organisations configured\r", "$", "this", "->", "handleException", "(", "new", "\\", "Exception", "(", "\"You need at least 1 Hail Organisation configured to be able to fetch private tags\"", ")", ")", ";", "return", "false", ";", "}", "$", "tag_list", "=", "[", "]", ";", "foreach", "(", "$", "orgs_ids", "as", "$", "org_id", ")", "{", "//Get Org Name\r", "if", "(", "$", "organisations", ")", "{", "$", "org_name", "=", "isset", "(", "$", "organisations", "[", "$", "org_id", "]", ")", "?", "$", "organisations", "[", "$", "org_id", "]", ":", "''", ";", "}", "else", "{", "$", "org", "=", "DataObject", "::", "get_one", "(", "Organisation", "::", "class", ",", "[", "'HailID'", "=>", "$", "org_id", "]", ")", ";", "$", "org_name", "=", "$", "org", "?", "$", "org", "->", "Title", ":", "\"\"", ";", "}", "$", "results", "=", "$", "this", "->", "get", "(", "'organisations/'", ".", "$", "org_id", ".", "'/private-tags'", ")", ";", "//If simple array is true, we send back an array with [id] => [name] instead of the full list\r", "if", "(", "$", "as_simple_array", ")", "{", "foreach", "(", "$", "results", "as", "$", "result", ")", "{", "$", "tag_title", "=", "$", "result", "[", "'name'", "]", ";", "//Add organisation name on tag title if more than 1 org\r", "if", "(", "count", "(", "$", "orgs_ids", ")", ">", "1", ")", "{", "$", "tag_title", "=", "$", "org_name", ".", "\" - \"", ".", "$", "tag_title", ";", "}", "$", "tag_list", "[", "$", "result", "[", "'id'", "]", "]", "=", "$", "tag_title", ";", "}", "}", "else", "{", "$", "tag_list", "=", "array_merge", "(", "$", "results", ",", "$", "tag_list", ")", ";", "}", "}", "asort", "(", "$", "tag_list", ")", ";", "return", "$", "tag_list", ";", "}" ]
Get all available Private Tags from the Hail API Will get all tags from all configured organisations unless specified otherwise @param array|null $organisations Pass an array of organisations (HailID => Organisation Name) to get the tag for, if null will get all configured organisation @param boolean $as_simple_array Return a simple associative array (ID => Tile )instead of the full objects @return array|boolean @throws
[ "Get", "all", "available", "Private", "Tags", "from", "the", "Hail", "API", "Will", "get", "all", "tags", "from", "all", "configured", "organisations", "unless", "specified", "otherwise" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L385-L421
32,617
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.getImagesByArticles
public function getImagesByArticles($id) { $uri = Article::$object_endpoint . '/' . $id . '/' . Image::$object_endpoint; return $this->get($uri); }
php
public function getImagesByArticles($id) { $uri = Article::$object_endpoint . '/' . $id . '/' . Image::$object_endpoint; return $this->get($uri); }
[ "public", "function", "getImagesByArticles", "(", "$", "id", ")", "{", "$", "uri", "=", "Article", "::", "$", "object_endpoint", ".", "'/'", ".", "$", "id", ".", "'/'", ".", "Image", "::", "$", "object_endpoint", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ")", ";", "}" ]
Retrieve a list of images for a given article. @param string $id ID of the article in Hail @return array @throws
[ "Retrieve", "a", "list", "of", "images", "for", "a", "given", "article", "." ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L491-L495
32,618
firebrandhq/silverstripe-hail
src/Api/Client.php
Client.getVideosByArticles
public function getVideosByArticles($id) { $uri = Article::$object_endpoint . '/' . $id . '/' . Video::$object_endpoint; return $this->get($uri); }
php
public function getVideosByArticles($id) { $uri = Article::$object_endpoint . '/' . $id . '/' . Video::$object_endpoint; return $this->get($uri); }
[ "public", "function", "getVideosByArticles", "(", "$", "id", ")", "{", "$", "uri", "=", "Article", "::", "$", "object_endpoint", ".", "'/'", ".", "$", "id", ".", "'/'", ".", "Video", "::", "$", "object_endpoint", ";", "return", "$", "this", "->", "get", "(", "$", "uri", ")", ";", "}" ]
Retrieve a list of videos for a given article. @param string $id ID of the article in Hail @return array @throws
[ "Retrieve", "a", "list", "of", "videos", "for", "a", "given", "article", "." ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Api/Client.php#L505-L509
32,619
CradlePHP/cradle-system
src/Schema/Validator.php
Validator.getCreateErrors
public static function getCreateErrors(array $data, array $errors = []) { if (!isset($data['singular']) || empty($data['singular'])) { $errors['singular'] = 'Singular is required'; } if (!isset($data['plural']) || empty($data['plural'])) { $errors['plural'] = 'Plural is required'; } if (!isset($data['name']) || empty($data['name'])) { $errors['name'] = 'Keyword is required'; } if (!isset($data['fields']) || empty($data['fields'])) { $errors['fields'] = 'Fields is required'; } if (isset($data['name'])) { $exists = false; try { $exists = Schema::i($data['name'])->getAll(); } catch (Exception $e) { } if ($exists) { $errors['name'] = 'Schema already exists'; } } return self::getOptionalErrors($data, $errors); }
php
public static function getCreateErrors(array $data, array $errors = []) { if (!isset($data['singular']) || empty($data['singular'])) { $errors['singular'] = 'Singular is required'; } if (!isset($data['plural']) || empty($data['plural'])) { $errors['plural'] = 'Plural is required'; } if (!isset($data['name']) || empty($data['name'])) { $errors['name'] = 'Keyword is required'; } if (!isset($data['fields']) || empty($data['fields'])) { $errors['fields'] = 'Fields is required'; } if (isset($data['name'])) { $exists = false; try { $exists = Schema::i($data['name'])->getAll(); } catch (Exception $e) { } if ($exists) { $errors['name'] = 'Schema already exists'; } } return self::getOptionalErrors($data, $errors); }
[ "public", "static", "function", "getCreateErrors", "(", "array", "$", "data", ",", "array", "$", "errors", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "'singular'", "]", ")", "||", "empty", "(", "$", "data", "[", "'singular'", "]", ")", ")", "{", "$", "errors", "[", "'singular'", "]", "=", "'Singular is required'", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "[", "'plural'", "]", ")", "||", "empty", "(", "$", "data", "[", "'plural'", "]", ")", ")", "{", "$", "errors", "[", "'plural'", "]", "=", "'Plural is required'", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "[", "'name'", "]", ")", "||", "empty", "(", "$", "data", "[", "'name'", "]", ")", ")", "{", "$", "errors", "[", "'name'", "]", "=", "'Keyword is required'", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "[", "'fields'", "]", ")", "||", "empty", "(", "$", "data", "[", "'fields'", "]", ")", ")", "{", "$", "errors", "[", "'fields'", "]", "=", "'Fields is required'", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'name'", "]", ")", ")", "{", "$", "exists", "=", "false", ";", "try", "{", "$", "exists", "=", "Schema", "::", "i", "(", "$", "data", "[", "'name'", "]", ")", "->", "getAll", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "}", "if", "(", "$", "exists", ")", "{", "$", "errors", "[", "'name'", "]", "=", "'Schema already exists'", ";", "}", "}", "return", "self", "::", "getOptionalErrors", "(", "$", "data", ",", "$", "errors", ")", ";", "}" ]
Returns Table Create Errors @param *array $data @param array $errors @return array
[ "Returns", "Table", "Create", "Errors" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema/Validator.php#L31-L62
32,620
CradlePHP/cradle-system
src/Schema/Validator.php
Validator.getOptionalErrors
public static function getOptionalErrors(array $data, array $errors = []) { //validations if (isset($data['singular']) && strlen($data['singular']) <= 2) { $errors['singular'] = 'Singular should be longer than 2 characters'; } if (isset($data['singular']) && strlen($data['singular']) >= 255) { $errors['singular'] = 'Singular should be less than 255 characters'; } if (isset($data['plural']) && strlen($data['plural']) <= 2) { $errors['plural'] = 'Plural should be longer than 2 characters'; } if (isset($data['plural']) && strlen($data['plural']) >= 255) { $errors['plural'] = 'Plural should be less than 255 characters'; } if (isset($data['name']) && !preg_match('#^[a-zA-Z0-9\-_]+$#', $data['name'])) { $errors['name'] = 'Keyword must only have letters, numbers, dashes'; } if (isset($data['relations'])) { $relations = []; foreach ($data['relations'] as $i => $relation) { if (in_array($relation['name'], $relations)) { $errors['relations'] = 'Duplicate Relations'; break; } if (!trim($relation['name'])) { $errors['relations'] = 'Empty relation name'; break; } $relations[] = $relation['name']; } } return $errors; }
php
public static function getOptionalErrors(array $data, array $errors = []) { //validations if (isset($data['singular']) && strlen($data['singular']) <= 2) { $errors['singular'] = 'Singular should be longer than 2 characters'; } if (isset($data['singular']) && strlen($data['singular']) >= 255) { $errors['singular'] = 'Singular should be less than 255 characters'; } if (isset($data['plural']) && strlen($data['plural']) <= 2) { $errors['plural'] = 'Plural should be longer than 2 characters'; } if (isset($data['plural']) && strlen($data['plural']) >= 255) { $errors['plural'] = 'Plural should be less than 255 characters'; } if (isset($data['name']) && !preg_match('#^[a-zA-Z0-9\-_]+$#', $data['name'])) { $errors['name'] = 'Keyword must only have letters, numbers, dashes'; } if (isset($data['relations'])) { $relations = []; foreach ($data['relations'] as $i => $relation) { if (in_array($relation['name'], $relations)) { $errors['relations'] = 'Duplicate Relations'; break; } if (!trim($relation['name'])) { $errors['relations'] = 'Empty relation name'; break; } $relations[] = $relation['name']; } } return $errors; }
[ "public", "static", "function", "getOptionalErrors", "(", "array", "$", "data", ",", "array", "$", "errors", "=", "[", "]", ")", "{", "//validations", "if", "(", "isset", "(", "$", "data", "[", "'singular'", "]", ")", "&&", "strlen", "(", "$", "data", "[", "'singular'", "]", ")", "<=", "2", ")", "{", "$", "errors", "[", "'singular'", "]", "=", "'Singular should be longer than 2 characters'", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'singular'", "]", ")", "&&", "strlen", "(", "$", "data", "[", "'singular'", "]", ")", ">=", "255", ")", "{", "$", "errors", "[", "'singular'", "]", "=", "'Singular should be less than 255 characters'", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'plural'", "]", ")", "&&", "strlen", "(", "$", "data", "[", "'plural'", "]", ")", "<=", "2", ")", "{", "$", "errors", "[", "'plural'", "]", "=", "'Plural should be longer than 2 characters'", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'plural'", "]", ")", "&&", "strlen", "(", "$", "data", "[", "'plural'", "]", ")", ">=", "255", ")", "{", "$", "errors", "[", "'plural'", "]", "=", "'Plural should be less than 255 characters'", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'name'", "]", ")", "&&", "!", "preg_match", "(", "'#^[a-zA-Z0-9\\-_]+$#'", ",", "$", "data", "[", "'name'", "]", ")", ")", "{", "$", "errors", "[", "'name'", "]", "=", "'Keyword must only have letters, numbers, dashes'", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'relations'", "]", ")", ")", "{", "$", "relations", "=", "[", "]", ";", "foreach", "(", "$", "data", "[", "'relations'", "]", "as", "$", "i", "=>", "$", "relation", ")", "{", "if", "(", "in_array", "(", "$", "relation", "[", "'name'", "]", ",", "$", "relations", ")", ")", "{", "$", "errors", "[", "'relations'", "]", "=", "'Duplicate Relations'", ";", "break", ";", "}", "if", "(", "!", "trim", "(", "$", "relation", "[", "'name'", "]", ")", ")", "{", "$", "errors", "[", "'relations'", "]", "=", "'Empty relation name'", ";", "break", ";", "}", "$", "relations", "[", "]", "=", "$", "relation", "[", "'name'", "]", ";", "}", "}", "return", "$", "errors", ";", "}" ]
Returns Table Optional Errors @param *array $data @param array $errors @return array
[ "Returns", "Table", "Optional", "Errors" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema/Validator.php#L101-L143
32,621
CradlePHP/cradle-system
src/Schema.php
Schema.getRelations
public function getRelations($many = -1) { $results = []; if (!isset($this->data['relations']) || empty($this->data['relations']) ) { return $results; } $table = $this->getName(); $primary = $this->getPrimaryFieldName(); foreach ($this->data['relations'] as $relation) { if (is_numeric($many) && $many != -1 && $many != $relation['many']) { continue; } //case for getting a specific relation if (!is_numeric($many) && $relation['name'] !== $many) { continue; } $name = $table . '_' . $relation['name']; $results[$name] = []; try { $results[$name] = Schema::i($relation['name'])->getAll(false); } catch (Exception $e) { //this is not a registered schema //lets make a best guess $results[$name]['name'] = $relation['name']; $results[$name]['singular'] = ucfirst($relation['name']); $results[$name]['plural'] = $results[$name]['singular'] . 's'; $results[$name]['primary'] = $relation['name'] . '_id'; } $results[$name]['table'] = $name; $results[$name]['primary1'] = $primary; $results[$name]['primary2'] = $results[$name]['primary']; $results[$name]['many'] = $relation['many']; $results[$name]['source'] = $this->getAll(false); //case for relating to itself ie. post_post if ($table === $relation['name']) { $results[$name]['primary1'] .= '_1'; $results[$name]['primary2'] .= '_2'; } //case for getting a specific relation if (!is_numeric($many) && $relation['name'] === $many) { return $results[$name]; } } return $results; }
php
public function getRelations($many = -1) { $results = []; if (!isset($this->data['relations']) || empty($this->data['relations']) ) { return $results; } $table = $this->getName(); $primary = $this->getPrimaryFieldName(); foreach ($this->data['relations'] as $relation) { if (is_numeric($many) && $many != -1 && $many != $relation['many']) { continue; } //case for getting a specific relation if (!is_numeric($many) && $relation['name'] !== $many) { continue; } $name = $table . '_' . $relation['name']; $results[$name] = []; try { $results[$name] = Schema::i($relation['name'])->getAll(false); } catch (Exception $e) { //this is not a registered schema //lets make a best guess $results[$name]['name'] = $relation['name']; $results[$name]['singular'] = ucfirst($relation['name']); $results[$name]['plural'] = $results[$name]['singular'] . 's'; $results[$name]['primary'] = $relation['name'] . '_id'; } $results[$name]['table'] = $name; $results[$name]['primary1'] = $primary; $results[$name]['primary2'] = $results[$name]['primary']; $results[$name]['many'] = $relation['many']; $results[$name]['source'] = $this->getAll(false); //case for relating to itself ie. post_post if ($table === $relation['name']) { $results[$name]['primary1'] .= '_1'; $results[$name]['primary2'] .= '_2'; } //case for getting a specific relation if (!is_numeric($many) && $relation['name'] === $many) { return $results[$name]; } } return $results; }
[ "public", "function", "getRelations", "(", "$", "many", "=", "-", "1", ")", "{", "$", "results", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'relations'", "]", ")", "||", "empty", "(", "$", "this", "->", "data", "[", "'relations'", "]", ")", ")", "{", "return", "$", "results", ";", "}", "$", "table", "=", "$", "this", "->", "getName", "(", ")", ";", "$", "primary", "=", "$", "this", "->", "getPrimaryFieldName", "(", ")", ";", "foreach", "(", "$", "this", "->", "data", "[", "'relations'", "]", "as", "$", "relation", ")", "{", "if", "(", "is_numeric", "(", "$", "many", ")", "&&", "$", "many", "!=", "-", "1", "&&", "$", "many", "!=", "$", "relation", "[", "'many'", "]", ")", "{", "continue", ";", "}", "//case for getting a specific relation", "if", "(", "!", "is_numeric", "(", "$", "many", ")", "&&", "$", "relation", "[", "'name'", "]", "!==", "$", "many", ")", "{", "continue", ";", "}", "$", "name", "=", "$", "table", ".", "'_'", ".", "$", "relation", "[", "'name'", "]", ";", "$", "results", "[", "$", "name", "]", "=", "[", "]", ";", "try", "{", "$", "results", "[", "$", "name", "]", "=", "Schema", "::", "i", "(", "$", "relation", "[", "'name'", "]", ")", "->", "getAll", "(", "false", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "//this is not a registered schema", "//lets make a best guess", "$", "results", "[", "$", "name", "]", "[", "'name'", "]", "=", "$", "relation", "[", "'name'", "]", ";", "$", "results", "[", "$", "name", "]", "[", "'singular'", "]", "=", "ucfirst", "(", "$", "relation", "[", "'name'", "]", ")", ";", "$", "results", "[", "$", "name", "]", "[", "'plural'", "]", "=", "$", "results", "[", "$", "name", "]", "[", "'singular'", "]", ".", "'s'", ";", "$", "results", "[", "$", "name", "]", "[", "'primary'", "]", "=", "$", "relation", "[", "'name'", "]", ".", "'_id'", ";", "}", "$", "results", "[", "$", "name", "]", "[", "'table'", "]", "=", "$", "name", ";", "$", "results", "[", "$", "name", "]", "[", "'primary1'", "]", "=", "$", "primary", ";", "$", "results", "[", "$", "name", "]", "[", "'primary2'", "]", "=", "$", "results", "[", "$", "name", "]", "[", "'primary'", "]", ";", "$", "results", "[", "$", "name", "]", "[", "'many'", "]", "=", "$", "relation", "[", "'many'", "]", ";", "$", "results", "[", "$", "name", "]", "[", "'source'", "]", "=", "$", "this", "->", "getAll", "(", "false", ")", ";", "//case for relating to itself ie. post_post", "if", "(", "$", "table", "===", "$", "relation", "[", "'name'", "]", ")", "{", "$", "results", "[", "$", "name", "]", "[", "'primary1'", "]", ".=", "'_1'", ";", "$", "results", "[", "$", "name", "]", "[", "'primary2'", "]", ".=", "'_2'", ";", "}", "//case for getting a specific relation", "if", "(", "!", "is_numeric", "(", "$", "many", ")", "&&", "$", "relation", "[", "'name'", "]", "===", "$", "many", ")", "{", "return", "$", "results", "[", "$", "name", "]", ";", "}", "}", "return", "$", "results", ";", "}" ]
Returns relational data @param int $many @return array
[ "Returns", "relational", "data" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema.php#L190-L246
32,622
CradlePHP/cradle-system
src/Schema.php
Schema.getReverseRelations
public function getReverseRelations($many = -1) { $results = []; $name = $this->getName(); $payload = cradle()->makePayload(); cradle()->trigger( 'system-schema-search', $payload['request'], $payload['response'] ); $rows = $payload['response']->getResults('rows'); if (empty($rows)) { return $results; } foreach ($rows as $row) { $schema = Schema::i($row['name']); $table = $row['name'] . '_' . $name; $relations = $schema->getRelations(); if (!isset($relations[$table]['many']) || ( $many != -1 && $many != $relations[$table]['many'] ) ) { continue; } $results[$table] = $relations[$table]; $results[$table]['source'] = $schema->getAll(false); } return $results; }
php
public function getReverseRelations($many = -1) { $results = []; $name = $this->getName(); $payload = cradle()->makePayload(); cradle()->trigger( 'system-schema-search', $payload['request'], $payload['response'] ); $rows = $payload['response']->getResults('rows'); if (empty($rows)) { return $results; } foreach ($rows as $row) { $schema = Schema::i($row['name']); $table = $row['name'] . '_' . $name; $relations = $schema->getRelations(); if (!isset($relations[$table]['many']) || ( $many != -1 && $many != $relations[$table]['many'] ) ) { continue; } $results[$table] = $relations[$table]; $results[$table]['source'] = $schema->getAll(false); } return $results; }
[ "public", "function", "getReverseRelations", "(", "$", "many", "=", "-", "1", ")", "{", "$", "results", "=", "[", "]", ";", "$", "name", "=", "$", "this", "->", "getName", "(", ")", ";", "$", "payload", "=", "cradle", "(", ")", "->", "makePayload", "(", ")", ";", "cradle", "(", ")", "->", "trigger", "(", "'system-schema-search'", ",", "$", "payload", "[", "'request'", "]", ",", "$", "payload", "[", "'response'", "]", ")", ";", "$", "rows", "=", "$", "payload", "[", "'response'", "]", "->", "getResults", "(", "'rows'", ")", ";", "if", "(", "empty", "(", "$", "rows", ")", ")", "{", "return", "$", "results", ";", "}", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "schema", "=", "Schema", "::", "i", "(", "$", "row", "[", "'name'", "]", ")", ";", "$", "table", "=", "$", "row", "[", "'name'", "]", ".", "'_'", ".", "$", "name", ";", "$", "relations", "=", "$", "schema", "->", "getRelations", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "relations", "[", "$", "table", "]", "[", "'many'", "]", ")", "||", "(", "$", "many", "!=", "-", "1", "&&", "$", "many", "!=", "$", "relations", "[", "$", "table", "]", "[", "'many'", "]", ")", ")", "{", "continue", ";", "}", "$", "results", "[", "$", "table", "]", "=", "$", "relations", "[", "$", "table", "]", ";", "$", "results", "[", "$", "table", "]", "[", "'source'", "]", "=", "$", "schema", "->", "getAll", "(", "false", ")", ";", "}", "return", "$", "results", ";", "}" ]
Returns reverse relational data @param int $many @return array
[ "Returns", "reverse", "relational", "data" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema.php#L255-L293
32,623
CradlePHP/cradle-system
src/Schema.php
Schema.getSuggestionFormat
public function getSuggestionFormat(array $data) { //if no suggestion format if (!isset($this->data['suggestion']) || !trim($this->data['suggestion'])) { //use best guess $suggestion = null; foreach ($data as $key => $value) { if (is_numeric($value) || ( isset($value[0]) && is_numeric($value[0]) ) ) { continue; } $suggestion = $value; break; } //if still no suggestion if (is_null($suggestion)) { //just get the first one, i guess. foreach ($data as $key => $value) { $suggestion = $value; break; } } return $suggestion; } $template = cradle('global')->handlebars()->compile($this->data['suggestion']); return $template($data); }
php
public function getSuggestionFormat(array $data) { //if no suggestion format if (!isset($this->data['suggestion']) || !trim($this->data['suggestion'])) { //use best guess $suggestion = null; foreach ($data as $key => $value) { if (is_numeric($value) || ( isset($value[0]) && is_numeric($value[0]) ) ) { continue; } $suggestion = $value; break; } //if still no suggestion if (is_null($suggestion)) { //just get the first one, i guess. foreach ($data as $key => $value) { $suggestion = $value; break; } } return $suggestion; } $template = cradle('global')->handlebars()->compile($this->data['suggestion']); return $template($data); }
[ "public", "function", "getSuggestionFormat", "(", "array", "$", "data", ")", "{", "//if no suggestion format", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'suggestion'", "]", ")", "||", "!", "trim", "(", "$", "this", "->", "data", "[", "'suggestion'", "]", ")", ")", "{", "//use best guess", "$", "suggestion", "=", "null", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_numeric", "(", "$", "value", ")", "||", "(", "isset", "(", "$", "value", "[", "0", "]", ")", "&&", "is_numeric", "(", "$", "value", "[", "0", "]", ")", ")", ")", "{", "continue", ";", "}", "$", "suggestion", "=", "$", "value", ";", "break", ";", "}", "//if still no suggestion", "if", "(", "is_null", "(", "$", "suggestion", ")", ")", "{", "//just get the first one, i guess.", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "suggestion", "=", "$", "value", ";", "break", ";", "}", "}", "return", "$", "suggestion", ";", "}", "$", "template", "=", "cradle", "(", "'global'", ")", "->", "handlebars", "(", ")", "->", "compile", "(", "$", "this", "->", "data", "[", "'suggestion'", "]", ")", ";", "return", "$", "template", "(", "$", "data", ")", ";", "}" ]
Based on the data will generate a suggestion format @param array @return string
[ "Based", "on", "the", "data", "will", "generate", "a", "suggestion", "format" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema.php#L325-L360
32,624
CradlePHP/cradle-system
src/Schema.php
Schema.getUpdatedFieldName
public function getUpdatedFieldName() { if (!isset($this->data['fields']) || empty($this->data['fields'])) { return false; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { if ($field['name'] === 'updated') { return $table . '_' . $field['name']; } } return false; }
php
public function getUpdatedFieldName() { if (!isset($this->data['fields']) || empty($this->data['fields'])) { return false; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { if ($field['name'] === 'updated') { return $table . '_' . $field['name']; } } return false; }
[ "public", "function", "getUpdatedFieldName", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", "||", "empty", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", ")", "{", "return", "false", ";", "}", "$", "table", "=", "$", "this", "->", "data", "[", "'name'", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'fields'", "]", "as", "$", "field", ")", "{", "if", "(", "$", "field", "[", "'name'", "]", "===", "'updated'", ")", "{", "return", "$", "table", ".", "'_'", ".", "$", "field", "[", "'name'", "]", ";", "}", "}", "return", "false", ";", "}" ]
Returns updated field @return string|false
[ "Returns", "updated", "field" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Schema.php#L390-L404
32,625
CradlePHP/cradle-system
src/Model/Service/SqlService.php
SqlService.create
public function create(array $data) { if (is_null($this->schema)) { throw SystemException::forNoSchema(); } $table = $this->schema->getName(); $created = $this->schema->getCreatedFieldName(); $updated = $this->schema->getUpdatedFieldName(); $ipaddress = $this->schema->getIPAddressFieldName(); if ($created) { $data[$created] = date('Y-m-d H:i:s'); } if ($updated) { $data[$updated] = date('Y-m-d H:i:s'); } if ($ipaddress && isset($_SERVER['REMOTE_ADDR'])) { $data[$ipaddress] = $_SERVER['REMOTE_ADDR']; } $uuids = $this->schema->getUuidFieldNames(); foreach($uuids as $uuid) { $data[$uuid] = sha1(uniqid()); } return $this ->resource ->model($data) ->save($table) ->get(); }
php
public function create(array $data) { if (is_null($this->schema)) { throw SystemException::forNoSchema(); } $table = $this->schema->getName(); $created = $this->schema->getCreatedFieldName(); $updated = $this->schema->getUpdatedFieldName(); $ipaddress = $this->schema->getIPAddressFieldName(); if ($created) { $data[$created] = date('Y-m-d H:i:s'); } if ($updated) { $data[$updated] = date('Y-m-d H:i:s'); } if ($ipaddress && isset($_SERVER['REMOTE_ADDR'])) { $data[$ipaddress] = $_SERVER['REMOTE_ADDR']; } $uuids = $this->schema->getUuidFieldNames(); foreach($uuids as $uuid) { $data[$uuid] = sha1(uniqid()); } return $this ->resource ->model($data) ->save($table) ->get(); }
[ "public", "function", "create", "(", "array", "$", "data", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "schema", ")", ")", "{", "throw", "SystemException", "::", "forNoSchema", "(", ")", ";", "}", "$", "table", "=", "$", "this", "->", "schema", "->", "getName", "(", ")", ";", "$", "created", "=", "$", "this", "->", "schema", "->", "getCreatedFieldName", "(", ")", ";", "$", "updated", "=", "$", "this", "->", "schema", "->", "getUpdatedFieldName", "(", ")", ";", "$", "ipaddress", "=", "$", "this", "->", "schema", "->", "getIPAddressFieldName", "(", ")", ";", "if", "(", "$", "created", ")", "{", "$", "data", "[", "$", "created", "]", "=", "date", "(", "'Y-m-d H:i:s'", ")", ";", "}", "if", "(", "$", "updated", ")", "{", "$", "data", "[", "$", "updated", "]", "=", "date", "(", "'Y-m-d H:i:s'", ")", ";", "}", "if", "(", "$", "ipaddress", "&&", "isset", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", ")", "{", "$", "data", "[", "$", "ipaddress", "]", "=", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "}", "$", "uuids", "=", "$", "this", "->", "schema", "->", "getUuidFieldNames", "(", ")", ";", "foreach", "(", "$", "uuids", "as", "$", "uuid", ")", "{", "$", "data", "[", "$", "uuid", "]", "=", "sha1", "(", "uniqid", "(", ")", ")", ";", "}", "return", "$", "this", "->", "resource", "->", "model", "(", "$", "data", ")", "->", "save", "(", "$", "table", ")", "->", "get", "(", ")", ";", "}" ]
Create in database @param *array $object @param *array $data @return array
[ "Create", "in", "database" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Model/Service/SqlService.php#L58-L92
32,626
CradlePHP/cradle-system
src/Model/Service/SqlService.php
SqlService.exists
public function exists($key, $value) { if (is_null($this->schema)) { throw SystemException::forNoSchema(); } $search = $this ->resource ->search($this->schema->getName()) ->addFilter($key . ' = %s', $value); return !!$search->getRow(); }
php
public function exists($key, $value) { if (is_null($this->schema)) { throw SystemException::forNoSchema(); } $search = $this ->resource ->search($this->schema->getName()) ->addFilter($key . ' = %s', $value); return !!$search->getRow(); }
[ "public", "function", "exists", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "schema", ")", ")", "{", "throw", "SystemException", "::", "forNoSchema", "(", ")", ";", "}", "$", "search", "=", "$", "this", "->", "resource", "->", "search", "(", "$", "this", "->", "schema", "->", "getName", "(", ")", ")", "->", "addFilter", "(", "$", "key", ".", "' = %s'", ",", "$", "value", ")", ";", "return", "!", "!", "$", "search", "->", "getRow", "(", ")", ";", "}" ]
Checks to see if unique.0 already exists @param *string $objectKey @return bool
[ "Checks", "to", "see", "if", "unique", ".", "0", "already", "exists" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Model/Service/SqlService.php#L101-L113
32,627
CradlePHP/cradle-system
src/Model/Service/SqlService.php
SqlService.remove
public function remove($id) { if (is_null($this->schema)) { throw SystemException::forNoSchema(); } $table = $this->schema->getName(); $primary = $this->schema->getPrimaryFieldName(); //please rely on SQL CASCADING ON DELETE $model = $this->resource->model(); $model[$primary] = $id; return $model->remove($table); }
php
public function remove($id) { if (is_null($this->schema)) { throw SystemException::forNoSchema(); } $table = $this->schema->getName(); $primary = $this->schema->getPrimaryFieldName(); //please rely on SQL CASCADING ON DELETE $model = $this->resource->model(); $model[$primary] = $id; return $model->remove($table); }
[ "public", "function", "remove", "(", "$", "id", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "schema", ")", ")", "{", "throw", "SystemException", "::", "forNoSchema", "(", ")", ";", "}", "$", "table", "=", "$", "this", "->", "schema", "->", "getName", "(", ")", ";", "$", "primary", "=", "$", "this", "->", "schema", "->", "getPrimaryFieldName", "(", ")", ";", "//please rely on SQL CASCADING ON DELETE", "$", "model", "=", "$", "this", "->", "resource", "->", "model", "(", ")", ";", "$", "model", "[", "$", "primary", "]", "=", "$", "id", ";", "return", "$", "model", "->", "remove", "(", "$", "table", ")", ";", "}" ]
Remove from database PLEASE BECAREFUL USING THIS !!! It's here for clean up scripts @param *array $object @param *int $id
[ "Remove", "from", "database", "PLEASE", "BECAREFUL", "USING", "THIS", "!!!", "It", "s", "here", "for", "clean", "up", "scripts" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Model/Service/SqlService.php#L371-L383
32,628
CradlePHP/cradle-system
src/Model/Service/SqlService.php
SqlService.unlink
public function unlink($relation, $primary1, $primary2) { if (is_null($this->schema)) { throw SystemException::forNoSchema(); } $name = $this->schema->getName(); $relations = $this->schema->getRelations(); $table = $name . '_' . $relation; if (!isset($relations[$table])) { throw SystemException::forNoRelation($name, $relation); } $relation = $relations[$table]; $model = $this->resource->model(); $model[$relation['primary1']] = $primary1; $model[$relation['primary2']] = $primary2; return $model->remove($table); }
php
public function unlink($relation, $primary1, $primary2) { if (is_null($this->schema)) { throw SystemException::forNoSchema(); } $name = $this->schema->getName(); $relations = $this->schema->getRelations(); $table = $name . '_' . $relation; if (!isset($relations[$table])) { throw SystemException::forNoRelation($name, $relation); } $relation = $relations[$table]; $model = $this->resource->model(); $model[$relation['primary1']] = $primary1; $model[$relation['primary2']] = $primary2; return $model->remove($table); }
[ "public", "function", "unlink", "(", "$", "relation", ",", "$", "primary1", ",", "$", "primary2", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "schema", ")", ")", "{", "throw", "SystemException", "::", "forNoSchema", "(", ")", ";", "}", "$", "name", "=", "$", "this", "->", "schema", "->", "getName", "(", ")", ";", "$", "relations", "=", "$", "this", "->", "schema", "->", "getRelations", "(", ")", ";", "$", "table", "=", "$", "name", ".", "'_'", ".", "$", "relation", ";", "if", "(", "!", "isset", "(", "$", "relations", "[", "$", "table", "]", ")", ")", "{", "throw", "SystemException", "::", "forNoRelation", "(", "$", "name", ",", "$", "relation", ")", ";", "}", "$", "relation", "=", "$", "relations", "[", "$", "table", "]", ";", "$", "model", "=", "$", "this", "->", "resource", "->", "model", "(", ")", ";", "$", "model", "[", "$", "relation", "[", "'primary1'", "]", "]", "=", "$", "primary1", ";", "$", "model", "[", "$", "relation", "[", "'primary2'", "]", "]", "=", "$", "primary2", ";", "return", "$", "model", "->", "remove", "(", "$", "table", ")", ";", "}" ]
Unlinks table to another table @param *string $relation @param *int $primary1 @param *int $primary2 @return array
[ "Unlinks", "table", "to", "another", "table" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Model/Service/SqlService.php#L822-L843
32,629
CradlePHP/cradle-system
src/Model/Service/SqlService.php
SqlService.unlinkAll
public function unlinkAll($relation, $primary) { if (is_null($this->schema)) { throw SystemException::forNoSchema(); } $name = $this->schema->getName(); $relations = $this->schema->getRelations(); $table = $name . '_' . $relation; if (!isset($relations[$table])) { throw SystemException::forNoRelation($name, $relation); } $relation = $relations[$table]; $filter = sprintf('%s = %%s', $relation['primary1']); return $this ->resource ->search($table) ->addFilter($filter, $primary) ->getCollection() ->each(function ($i, $model) use (&$table) { $model->remove($table); }) ->get(); }
php
public function unlinkAll($relation, $primary) { if (is_null($this->schema)) { throw SystemException::forNoSchema(); } $name = $this->schema->getName(); $relations = $this->schema->getRelations(); $table = $name . '_' . $relation; if (!isset($relations[$table])) { throw SystemException::forNoRelation($name, $relation); } $relation = $relations[$table]; $filter = sprintf('%s = %%s', $relation['primary1']); return $this ->resource ->search($table) ->addFilter($filter, $primary) ->getCollection() ->each(function ($i, $model) use (&$table) { $model->remove($table); }) ->get(); }
[ "public", "function", "unlinkAll", "(", "$", "relation", ",", "$", "primary", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "schema", ")", ")", "{", "throw", "SystemException", "::", "forNoSchema", "(", ")", ";", "}", "$", "name", "=", "$", "this", "->", "schema", "->", "getName", "(", ")", ";", "$", "relations", "=", "$", "this", "->", "schema", "->", "getRelations", "(", ")", ";", "$", "table", "=", "$", "name", ".", "'_'", ".", "$", "relation", ";", "if", "(", "!", "isset", "(", "$", "relations", "[", "$", "table", "]", ")", ")", "{", "throw", "SystemException", "::", "forNoRelation", "(", "$", "name", ",", "$", "relation", ")", ";", "}", "$", "relation", "=", "$", "relations", "[", "$", "table", "]", ";", "$", "filter", "=", "sprintf", "(", "'%s = %%s'", ",", "$", "relation", "[", "'primary1'", "]", ")", ";", "return", "$", "this", "->", "resource", "->", "search", "(", "$", "table", ")", "->", "addFilter", "(", "$", "filter", ",", "$", "primary", ")", "->", "getCollection", "(", ")", "->", "each", "(", "function", "(", "$", "i", ",", "$", "model", ")", "use", "(", "&", "$", "table", ")", "{", "$", "model", "->", "remove", "(", "$", "table", ")", ";", "}", ")", "->", "get", "(", ")", ";", "}" ]
Unlinks all references in a table from another table @param *string $relation @param *int $primary @return array
[ "Unlinks", "all", "references", "in", "a", "table", "from", "another", "table" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Model/Service/SqlService.php#L853-L880
32,630
firebrandhq/silverstripe-hail
src/Lists/HailList.php
HailList.getOrganisations
public function getOrganisations() { $config = SiteConfig::current_site_config(); //Filter out Organisation that are not setup in the config $organisations = Organisation::get()->filter(['HailID' => json_decode($config->HailOrgsIDs)]); return $organisations->sort('Title')->map('HailID', 'Title')->toArray(); }
php
public function getOrganisations() { $config = SiteConfig::current_site_config(); //Filter out Organisation that are not setup in the config $organisations = Organisation::get()->filter(['HailID' => json_decode($config->HailOrgsIDs)]); return $organisations->sort('Title')->map('HailID', 'Title')->toArray(); }
[ "public", "function", "getOrganisations", "(", ")", "{", "$", "config", "=", "SiteConfig", "::", "current_site_config", "(", ")", ";", "//Filter out Organisation that are not setup in the config\r", "$", "organisations", "=", "Organisation", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID'", "=>", "json_decode", "(", "$", "config", "->", "HailOrgsIDs", ")", "]", ")", ";", "return", "$", "organisations", "->", "sort", "(", "'Title'", ")", "->", "map", "(", "'HailID'", ",", "'Title'", ")", "->", "toArray", "(", ")", ";", "}" ]
Get currently configured Hail Organisations @return array
[ "Get", "currently", "configured", "Hail", "Organisations" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Lists/HailList.php#L107-L114
32,631
firebrandhq/silverstripe-hail
src/Lists/HailList.php
HailList.getPrivateTagsList
public function getPrivateTagsList() { $config = SiteConfig::current_site_config(); //Filter out global excluded tags and non configured Organisations $pri_tags = PrivateTag::get()->filter(['HailID:not' => json_decode($config->HailExcludePrivateTagsIDs), 'HailOrgID' => json_decode($config->HailOrgsIDs)]); return $pri_tags->sort(['HailOrgName ASC', 'Name ASC'])->map('HailID', 'FullName')->toArray(); }
php
public function getPrivateTagsList() { $config = SiteConfig::current_site_config(); //Filter out global excluded tags and non configured Organisations $pri_tags = PrivateTag::get()->filter(['HailID:not' => json_decode($config->HailExcludePrivateTagsIDs), 'HailOrgID' => json_decode($config->HailOrgsIDs)]); return $pri_tags->sort(['HailOrgName ASC', 'Name ASC'])->map('HailID', 'FullName')->toArray(); }
[ "public", "function", "getPrivateTagsList", "(", ")", "{", "$", "config", "=", "SiteConfig", "::", "current_site_config", "(", ")", ";", "//Filter out global excluded tags and non configured Organisations\r", "$", "pri_tags", "=", "PrivateTag", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID:not'", "=>", "json_decode", "(", "$", "config", "->", "HailExcludePrivateTagsIDs", ")", ",", "'HailOrgID'", "=>", "json_decode", "(", "$", "config", "->", "HailOrgsIDs", ")", "]", ")", ";", "return", "$", "pri_tags", "->", "sort", "(", "[", "'HailOrgName ASC'", ",", "'Name ASC'", "]", ")", "->", "map", "(", "'HailID'", ",", "'FullName'", ")", "->", "toArray", "(", ")", ";", "}" ]
Get currently available Hail Private Tags @return array
[ "Get", "currently", "available", "Hail", "Private", "Tags" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Lists/HailList.php#L121-L128
32,632
firebrandhq/silverstripe-hail
src/Lists/HailList.php
HailList.getPublicTagsList
public function getPublicTagsList() { $config = SiteConfig::current_site_config(); //Filter out global excluded tags and non configured Organisations $pub_tags = PublicTag::get()->filter(['HailID:not' => json_decode($config->HailExcludePublicTagsIDs), 'HailOrgID' => json_decode($config->HailOrgsIDs)]); return $pub_tags->sort(['HailOrgName ASC', 'Name ASC'])->map('HailID', 'FullName')->toArray(); }
php
public function getPublicTagsList() { $config = SiteConfig::current_site_config(); //Filter out global excluded tags and non configured Organisations $pub_tags = PublicTag::get()->filter(['HailID:not' => json_decode($config->HailExcludePublicTagsIDs), 'HailOrgID' => json_decode($config->HailOrgsIDs)]); return $pub_tags->sort(['HailOrgName ASC', 'Name ASC'])->map('HailID', 'FullName')->toArray(); }
[ "public", "function", "getPublicTagsList", "(", ")", "{", "$", "config", "=", "SiteConfig", "::", "current_site_config", "(", ")", ";", "//Filter out global excluded tags and non configured Organisations\r", "$", "pub_tags", "=", "PublicTag", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID:not'", "=>", "json_decode", "(", "$", "config", "->", "HailExcludePublicTagsIDs", ")", ",", "'HailOrgID'", "=>", "json_decode", "(", "$", "config", "->", "HailOrgsIDs", ")", "]", ")", ";", "return", "$", "pub_tags", "->", "sort", "(", "[", "'HailOrgName ASC'", ",", "'Name ASC'", "]", ")", "->", "map", "(", "'HailID'", ",", "'FullName'", ")", "->", "toArray", "(", ")", ";", "}" ]
Get currently available Hail Public Tags @return array
[ "Get", "currently", "available", "Hail", "Public", "Tags" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Lists/HailList.php#L135-L142
32,633
firebrandhq/silverstripe-hail
src/Pages/HailPage.php
HailPage.getCurrentArticle
public function getCurrentArticle() { if ($this->current_article instanceof Article || $this->current_article === null) { return $this->current_article; } $params = Controller::curr()->getRequest()->params(); if(empty($params['ID'])){ $this->current_article = null; } else { $this->current_article = Article::get()->filter(['HailID' => $params['ID']])->first(); } return $this->current_article; }
php
public function getCurrentArticle() { if ($this->current_article instanceof Article || $this->current_article === null) { return $this->current_article; } $params = Controller::curr()->getRequest()->params(); if(empty($params['ID'])){ $this->current_article = null; } else { $this->current_article = Article::get()->filter(['HailID' => $params['ID']])->first(); } return $this->current_article; }
[ "public", "function", "getCurrentArticle", "(", ")", "{", "if", "(", "$", "this", "->", "current_article", "instanceof", "Article", "||", "$", "this", "->", "current_article", "===", "null", ")", "{", "return", "$", "this", "->", "current_article", ";", "}", "$", "params", "=", "Controller", "::", "curr", "(", ")", "->", "getRequest", "(", ")", "->", "params", "(", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "'ID'", "]", ")", ")", "{", "$", "this", "->", "current_article", "=", "null", ";", "}", "else", "{", "$", "this", "->", "current_article", "=", "Article", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID'", "=>", "$", "params", "[", "'ID'", "]", "]", ")", "->", "first", "(", ")", ";", "}", "return", "$", "this", "->", "current_article", ";", "}" ]
Get article accessed in current request @return Article|null
[ "Get", "article", "accessed", "in", "current", "request" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Pages/HailPage.php#L132-L146
32,634
firebrandhq/silverstripe-hail
src/Pages/HailPage.php
HailPage.MetaTags
public function MetaTags($includeTitle = true) { $tags = parent::MetaTags($includeTitle); $params = Controller::curr()->getRequest()->params(); if ($article = $this->getCurrentArticle()) { $tags .= "<link rel=\"canonical\" href=\"{$article->AbsoluteLink()}\" />\n"; if ($article->Lead || $article->Content) { $tags = explode("\n", $tags); //Replace description meta tag with article lead foreach ($tags as $index => $tag) { if (strpos($tag, "name=\"description\"")) { $description = $article->Lead ? $article->Lead : $article->Content; $description = mb_strimwidth($description, 0, 300, '...'); $tags[$index] = "<meta name=\"description\" content=\"$article->Lead\">\n"; } } $tags = implode("\n", $tags); } } return $tags; }
php
public function MetaTags($includeTitle = true) { $tags = parent::MetaTags($includeTitle); $params = Controller::curr()->getRequest()->params(); if ($article = $this->getCurrentArticle()) { $tags .= "<link rel=\"canonical\" href=\"{$article->AbsoluteLink()}\" />\n"; if ($article->Lead || $article->Content) { $tags = explode("\n", $tags); //Replace description meta tag with article lead foreach ($tags as $index => $tag) { if (strpos($tag, "name=\"description\"")) { $description = $article->Lead ? $article->Lead : $article->Content; $description = mb_strimwidth($description, 0, 300, '...'); $tags[$index] = "<meta name=\"description\" content=\"$article->Lead\">\n"; } } $tags = implode("\n", $tags); } } return $tags; }
[ "public", "function", "MetaTags", "(", "$", "includeTitle", "=", "true", ")", "{", "$", "tags", "=", "parent", "::", "MetaTags", "(", "$", "includeTitle", ")", ";", "$", "params", "=", "Controller", "::", "curr", "(", ")", "->", "getRequest", "(", ")", "->", "params", "(", ")", ";", "if", "(", "$", "article", "=", "$", "this", "->", "getCurrentArticle", "(", ")", ")", "{", "$", "tags", ".=", "\"<link rel=\\\"canonical\\\" href=\\\"{$article->AbsoluteLink()}\\\" />\\n\"", ";", "if", "(", "$", "article", "->", "Lead", "||", "$", "article", "->", "Content", ")", "{", "$", "tags", "=", "explode", "(", "\"\\n\"", ",", "$", "tags", ")", ";", "//Replace description meta tag with article lead\r", "foreach", "(", "$", "tags", "as", "$", "index", "=>", "$", "tag", ")", "{", "if", "(", "strpos", "(", "$", "tag", ",", "\"name=\\\"description\\\"\"", ")", ")", "{", "$", "description", "=", "$", "article", "->", "Lead", "?", "$", "article", "->", "Lead", ":", "$", "article", "->", "Content", ";", "$", "description", "=", "mb_strimwidth", "(", "$", "description", ",", "0", ",", "300", ",", "'...'", ")", ";", "$", "tags", "[", "$", "index", "]", "=", "\"<meta name=\\\"description\\\" content=\\\"$article->Lead\\\">\\n\"", ";", "}", "}", "$", "tags", "=", "implode", "(", "\"\\n\"", ",", "$", "tags", ")", ";", "}", "}", "return", "$", "tags", ";", "}" ]
Add a canonical link meta tag Replace description meta tag with Article description when necessary @param boolean $includeTitle Show default <title>-tag, set to false for custom templating @return string The XHTML metatags
[ "Add", "a", "canonical", "link", "meta", "tag", "Replace", "description", "meta", "tag", "with", "Article", "description", "when", "necessary" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Pages/HailPage.php#L155-L176
32,635
firebrandhq/silverstripe-hail
src/Pages/HailPage.php
HailPage.getTitle
public function getTitle() { $article = $this->getCurrentArticle(); if ($article instanceof Article) { return $article->Title; } return parent::getTitle(); }
php
public function getTitle() { $article = $this->getCurrentArticle(); if ($article instanceof Article) { return $article->Title; } return parent::getTitle(); }
[ "public", "function", "getTitle", "(", ")", "{", "$", "article", "=", "$", "this", "->", "getCurrentArticle", "(", ")", ";", "if", "(", "$", "article", "instanceof", "Article", ")", "{", "return", "$", "article", "->", "Title", ";", "}", "return", "parent", "::", "getTitle", "(", ")", ";", "}" ]
Get page or article title @return string
[ "Get", "page", "or", "article", "title" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Pages/HailPage.php#L183-L191
32,636
firebrandhq/silverstripe-hail
src/Controllers/HailController.php
HailController.progress
public function progress(HTTPRequest $request) { if (!Security::getCurrentUser()) { return $this->makeJsonReponse(401, [ 'message' => 'Unauthorized.' ])->setStatusDescription('Unauthorized.'); } $latest_job = FetchJob::get()->filter('ErrorShown', 0)->sort('Created DESC')->first(); if ($latest_job) { $map = $latest_job->toMap(); if ($latest_job->Status === "Error") { $latest_job->ErrorShown = 1; $latest_job->write(); } return $this->makeJsonReponse(200, $map); } return $this->makeJsonReponse(200, [ 'message' => 'No hail job found.', 'Status' => 'Done' ]); }
php
public function progress(HTTPRequest $request) { if (!Security::getCurrentUser()) { return $this->makeJsonReponse(401, [ 'message' => 'Unauthorized.' ])->setStatusDescription('Unauthorized.'); } $latest_job = FetchJob::get()->filter('ErrorShown', 0)->sort('Created DESC')->first(); if ($latest_job) { $map = $latest_job->toMap(); if ($latest_job->Status === "Error") { $latest_job->ErrorShown = 1; $latest_job->write(); } return $this->makeJsonReponse(200, $map); } return $this->makeJsonReponse(200, [ 'message' => 'No hail job found.', 'Status' => 'Done' ]); }
[ "public", "function", "progress", "(", "HTTPRequest", "$", "request", ")", "{", "if", "(", "!", "Security", "::", "getCurrentUser", "(", ")", ")", "{", "return", "$", "this", "->", "makeJsonReponse", "(", "401", ",", "[", "'message'", "=>", "'Unauthorized.'", "]", ")", "->", "setStatusDescription", "(", "'Unauthorized.'", ")", ";", "}", "$", "latest_job", "=", "FetchJob", "::", "get", "(", ")", "->", "filter", "(", "'ErrorShown'", ",", "0", ")", "->", "sort", "(", "'Created DESC'", ")", "->", "first", "(", ")", ";", "if", "(", "$", "latest_job", ")", "{", "$", "map", "=", "$", "latest_job", "->", "toMap", "(", ")", ";", "if", "(", "$", "latest_job", "->", "Status", "===", "\"Error\"", ")", "{", "$", "latest_job", "->", "ErrorShown", "=", "1", ";", "$", "latest_job", "->", "write", "(", ")", ";", "}", "return", "$", "this", "->", "makeJsonReponse", "(", "200", ",", "$", "map", ")", ";", "}", "return", "$", "this", "->", "makeJsonReponse", "(", "200", ",", "[", "'message'", "=>", "'No hail job found.'", ",", "'Status'", "=>", "'Done'", "]", ")", ";", "}" ]
Get the progress on the current fetch job running @param HTTPRequest $request Current request @return HTTPResponse JSON response @throws
[ "Get", "the", "progress", "on", "the", "current", "fetch", "job", "running" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Controllers/HailController.php#L120-L145
32,637
firebrandhq/silverstripe-hail
src/Controllers/HailController.php
HailController.fetchOneSync
public function fetchOneSync(HTTPRequest $request) { if (!Security::getCurrentUser()) { return $this->makeJsonReponse(401, [ 'message' => 'Unauthorized.' ])->setStatusDescription('Unauthorized.'); } $params = $request->params(); if (empty($params['Class']) || empty($params['HailID'])) { return $this->makeJsonReponse(400, [ 'message' => 'Invalid request.' ]); } $class_name = str_replace("-", "\\", $params['Class']); if (!class_exists($class_name)) { return $this->makeJsonReponse(400, [ 'message' => 'Invalid request.' ]); } $object = DataObject::get($class_name)->filter(['HailID' => $params['HailID']])->first(); if (!$object) { return $this->makeJsonReponse(404, [ 'message' => 'Object does not exist.' ]); } //Refresh from Hail API $object->refresh(); return $this->makeJsonReponse(200, [ 'message' => 'Success' ]); }
php
public function fetchOneSync(HTTPRequest $request) { if (!Security::getCurrentUser()) { return $this->makeJsonReponse(401, [ 'message' => 'Unauthorized.' ])->setStatusDescription('Unauthorized.'); } $params = $request->params(); if (empty($params['Class']) || empty($params['HailID'])) { return $this->makeJsonReponse(400, [ 'message' => 'Invalid request.' ]); } $class_name = str_replace("-", "\\", $params['Class']); if (!class_exists($class_name)) { return $this->makeJsonReponse(400, [ 'message' => 'Invalid request.' ]); } $object = DataObject::get($class_name)->filter(['HailID' => $params['HailID']])->first(); if (!$object) { return $this->makeJsonReponse(404, [ 'message' => 'Object does not exist.' ]); } //Refresh from Hail API $object->refresh(); return $this->makeJsonReponse(200, [ 'message' => 'Success' ]); }
[ "public", "function", "fetchOneSync", "(", "HTTPRequest", "$", "request", ")", "{", "if", "(", "!", "Security", "::", "getCurrentUser", "(", ")", ")", "{", "return", "$", "this", "->", "makeJsonReponse", "(", "401", ",", "[", "'message'", "=>", "'Unauthorized.'", "]", ")", "->", "setStatusDescription", "(", "'Unauthorized.'", ")", ";", "}", "$", "params", "=", "$", "request", "->", "params", "(", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "'Class'", "]", ")", "||", "empty", "(", "$", "params", "[", "'HailID'", "]", ")", ")", "{", "return", "$", "this", "->", "makeJsonReponse", "(", "400", ",", "[", "'message'", "=>", "'Invalid request.'", "]", ")", ";", "}", "$", "class_name", "=", "str_replace", "(", "\"-\"", ",", "\"\\\\\"", ",", "$", "params", "[", "'Class'", "]", ")", ";", "if", "(", "!", "class_exists", "(", "$", "class_name", ")", ")", "{", "return", "$", "this", "->", "makeJsonReponse", "(", "400", ",", "[", "'message'", "=>", "'Invalid request.'", "]", ")", ";", "}", "$", "object", "=", "DataObject", "::", "get", "(", "$", "class_name", ")", "->", "filter", "(", "[", "'HailID'", "=>", "$", "params", "[", "'HailID'", "]", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "object", ")", "{", "return", "$", "this", "->", "makeJsonReponse", "(", "404", ",", "[", "'message'", "=>", "'Object does not exist.'", "]", ")", ";", "}", "//Refresh from Hail API\r", "$", "object", "->", "refresh", "(", ")", ";", "return", "$", "this", "->", "makeJsonReponse", "(", "200", ",", "[", "'message'", "=>", "'Success'", "]", ")", ";", "}" ]
Fetch one specific Hail object synchronously and update its database record The object to fetch is specified in the URL e.g.: /hail/fetchOne/[CLASS]/[HAILID] Example: /hail/fetchOne/Firebrand-Hail-Models-Article/l1KjRUP will fetch and update the article with HailID=l1KjRUP @param HTTPRequest $request Current request @return HTTPResponse JSON response @throws
[ "Fetch", "one", "specific", "Hail", "object", "synchronously", "and", "update", "its", "database", "record" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Controllers/HailController.php#L159-L193
32,638
firebrandhq/silverstripe-hail
src/Controllers/HailController.php
HailController.articles
public function articles(HTTPRequest $request) { if (!Security::getCurrentUser()) { return $this->makeJsonReponse(401, [ 'message' => 'Unauthorized.' ])->setStatusDescription('Unauthorized.'); } $pages = HailPage::get(); $articles = [['text' => 'Select an article']]; foreach ($pages as $page) { $list = $page->getFullHailList(); foreach ($list as $item) { $link = $item->getLinkForPage($page); if ($item->getType() === 'article') { $link = Director::absoluteURL($link); } $create_at = isset($item->Date) ? $item->Date : $item->DueDate; $date = new \DateTime($create_at); $name = $date->format('d/m/Y') . ' - ' . $page->Title . ' - ' . $item->Title; $articles[] = [ 'text' => $name, 'value' => $link ]; } } return $this->makeJsonReponse(200, $articles); }
php
public function articles(HTTPRequest $request) { if (!Security::getCurrentUser()) { return $this->makeJsonReponse(401, [ 'message' => 'Unauthorized.' ])->setStatusDescription('Unauthorized.'); } $pages = HailPage::get(); $articles = [['text' => 'Select an article']]; foreach ($pages as $page) { $list = $page->getFullHailList(); foreach ($list as $item) { $link = $item->getLinkForPage($page); if ($item->getType() === 'article') { $link = Director::absoluteURL($link); } $create_at = isset($item->Date) ? $item->Date : $item->DueDate; $date = new \DateTime($create_at); $name = $date->format('d/m/Y') . ' - ' . $page->Title . ' - ' . $item->Title; $articles[] = [ 'text' => $name, 'value' => $link ]; } } return $this->makeJsonReponse(200, $articles); }
[ "public", "function", "articles", "(", "HTTPRequest", "$", "request", ")", "{", "if", "(", "!", "Security", "::", "getCurrentUser", "(", ")", ")", "{", "return", "$", "this", "->", "makeJsonReponse", "(", "401", ",", "[", "'message'", "=>", "'Unauthorized.'", "]", ")", "->", "setStatusDescription", "(", "'Unauthorized.'", ")", ";", "}", "$", "pages", "=", "HailPage", "::", "get", "(", ")", ";", "$", "articles", "=", "[", "[", "'text'", "=>", "'Select an article'", "]", "]", ";", "foreach", "(", "$", "pages", "as", "$", "page", ")", "{", "$", "list", "=", "$", "page", "->", "getFullHailList", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "item", ")", "{", "$", "link", "=", "$", "item", "->", "getLinkForPage", "(", "$", "page", ")", ";", "if", "(", "$", "item", "->", "getType", "(", ")", "===", "'article'", ")", "{", "$", "link", "=", "Director", "::", "absoluteURL", "(", "$", "link", ")", ";", "}", "$", "create_at", "=", "isset", "(", "$", "item", "->", "Date", ")", "?", "$", "item", "->", "Date", ":", "$", "item", "->", "DueDate", ";", "$", "date", "=", "new", "\\", "DateTime", "(", "$", "create_at", ")", ";", "$", "name", "=", "$", "date", "->", "format", "(", "'d/m/Y'", ")", ".", "' - '", ".", "$", "page", "->", "Title", ".", "' - '", ".", "$", "item", "->", "Title", ";", "$", "articles", "[", "]", "=", "[", "'text'", "=>", "$", "name", ",", "'value'", "=>", "$", "link", "]", ";", "}", "}", "return", "$", "this", "->", "makeJsonReponse", "(", "200", ",", "$", "articles", ")", ";", "}" ]
Retrieve a list of articles from the database Only used by the Hail TinyMCE plugin to add article links to any HTML content @param HTTPRequest $request Current request @return HTTPResponse JSON response @throws
[ "Retrieve", "a", "list", "of", "articles", "from", "the", "database" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Controllers/HailController.php#L205-L233
32,639
firebrandhq/silverstripe-hail
src/Controllers/HailController.php
HailController.makeJsonReponse
public function makeJsonReponse($status_code, $body) { $this->getResponse()->setBody(json_encode($body, JSON_UNESCAPED_SLASHES)); $this->getResponse()->setStatusCode($status_code); $this->getResponse()->addHeader("Content-type", "application/json"); return $this->getResponse(); }
php
public function makeJsonReponse($status_code, $body) { $this->getResponse()->setBody(json_encode($body, JSON_UNESCAPED_SLASHES)); $this->getResponse()->setStatusCode($status_code); $this->getResponse()->addHeader("Content-type", "application/json"); return $this->getResponse(); }
[ "public", "function", "makeJsonReponse", "(", "$", "status_code", ",", "$", "body", ")", "{", "$", "this", "->", "getResponse", "(", ")", "->", "setBody", "(", "json_encode", "(", "$", "body", ",", "JSON_UNESCAPED_SLASHES", ")", ")", ";", "$", "this", "->", "getResponse", "(", ")", "->", "setStatusCode", "(", "$", "status_code", ")", ";", "$", "this", "->", "getResponse", "(", ")", "->", "addHeader", "(", "\"Content-type\"", ",", "\"application/json\"", ")", ";", "return", "$", "this", "->", "getResponse", "(", ")", ";", "}" ]
Make the JSON response @param int $status_code HTTP status code to return @param array|null $body JSON body of the request @return HTTPResponse JSON response
[ "Make", "the", "JSON", "response" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Controllers/HailController.php#L243-L250
32,640
CradlePHP/cradle-system
src/Helpers.php
Helpers.getFieldset
public static function getFieldset($name) { if (!isset(self::$fieldsets[$name])) { try { self::$fieldsets[$name] = Fieldset::i($name); } catch (Exception $e) { return false; } } return self::$fieldsets[$name]; }
php
public static function getFieldset($name) { if (!isset(self::$fieldsets[$name])) { try { self::$fieldsets[$name] = Fieldset::i($name); } catch (Exception $e) { return false; } } return self::$fieldsets[$name]; }
[ "public", "static", "function", "getFieldset", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "fieldsets", "[", "$", "name", "]", ")", ")", "{", "try", "{", "self", "::", "$", "fieldsets", "[", "$", "name", "]", "=", "Fieldset", "::", "i", "(", "$", "name", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "}", "return", "self", "::", "$", "fieldsets", "[", "$", "name", "]", ";", "}" ]
Returns a cached fieldset @param *string $name @return Fieldset|false
[ "Returns", "a", "cached", "fieldset" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Helpers.php#L46-L56
32,641
CradlePHP/cradle-system
src/Helpers.php
Helpers.getSchema
public static function getSchema($name) { if (!isset(self::$schemas[$name])) { try { self::$schemas[$name] = Schema::i($name); } catch (Exception $e) { return false; } } return self::$schemas[$name]; }
php
public static function getSchema($name) { if (!isset(self::$schemas[$name])) { try { self::$schemas[$name] = Schema::i($name); } catch (Exception $e) { return false; } } return self::$schemas[$name]; }
[ "public", "static", "function", "getSchema", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "schemas", "[", "$", "name", "]", ")", ")", "{", "try", "{", "self", "::", "$", "schemas", "[", "$", "name", "]", "=", "Schema", "::", "i", "(", "$", "name", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "}", "return", "self", "::", "$", "schemas", "[", "$", "name", "]", ";", "}" ]
Returns a cached schema @param *string $name @return Schema
[ "Returns", "a", "cached", "schema" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Helpers.php#L65-L75
32,642
CradlePHP/cradle-system
src/Helpers.php
Helpers.getFormatTemplate
public static function getFormatTemplate($name) { $file = sprintf( '%s/Model/template/format/%s.html', __DIR__, $name ); if (!file_exists($file)) { return null; } if (!isset(self::$templates[$name])) { self::$templates[$name] = file_get_contents($file); } return self::$templates[$name]; }
php
public static function getFormatTemplate($name) { $file = sprintf( '%s/Model/template/format/%s.html', __DIR__, $name ); if (!file_exists($file)) { return null; } if (!isset(self::$templates[$name])) { self::$templates[$name] = file_get_contents($file); } return self::$templates[$name]; }
[ "public", "static", "function", "getFormatTemplate", "(", "$", "name", ")", "{", "$", "file", "=", "sprintf", "(", "'%s/Model/template/format/%s.html'", ",", "__DIR__", ",", "$", "name", ")", ";", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "return", "null", ";", "}", "if", "(", "!", "isset", "(", "self", "::", "$", "templates", "[", "$", "name", "]", ")", ")", "{", "self", "::", "$", "templates", "[", "$", "name", "]", "=", "file_get_contents", "(", "$", "file", ")", ";", "}", "return", "self", "::", "$", "templates", "[", "$", "name", "]", ";", "}" ]
Returns a format template @param *string $name @return Schema
[ "Returns", "a", "format", "template" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Helpers.php#L84-L100
32,643
oasmobile/php-http
src/SilexKernel.php
SilexKernel.isGranted
public function isGranted($attributes, $object = null) { if (!$this->offsetExists('security.authorization_checker')) { return false; } $checker = $this['security.authorization_checker']; if ($checker instanceof AuthorizationCheckerInterface) { try { return $checker->isGranted($attributes, $object); } catch (AuthenticationCredentialsNotFoundException $e) { // authentication not found is considered not granted, // there is no need to throw an exception out in this case mdebug("Authentication credential not found, isGranted will return false. msg = %s", $e->getMessage()); return false; } } else { return false; } }
php
public function isGranted($attributes, $object = null) { if (!$this->offsetExists('security.authorization_checker')) { return false; } $checker = $this['security.authorization_checker']; if ($checker instanceof AuthorizationCheckerInterface) { try { return $checker->isGranted($attributes, $object); } catch (AuthenticationCredentialsNotFoundException $e) { // authentication not found is considered not granted, // there is no need to throw an exception out in this case mdebug("Authentication credential not found, isGranted will return false. msg = %s", $e->getMessage()); return false; } } else { return false; } }
[ "public", "function", "isGranted", "(", "$", "attributes", ",", "$", "object", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "'security.authorization_checker'", ")", ")", "{", "return", "false", ";", "}", "$", "checker", "=", "$", "this", "[", "'security.authorization_checker'", "]", ";", "if", "(", "$", "checker", "instanceof", "AuthorizationCheckerInterface", ")", "{", "try", "{", "return", "$", "checker", "->", "isGranted", "(", "$", "attributes", ",", "$", "object", ")", ";", "}", "catch", "(", "AuthenticationCredentialsNotFoundException", "$", "e", ")", "{", "// authentication not found is considered not granted,", "// there is no need to throw an exception out in this case", "mdebug", "(", "\"Authentication credential not found, isGranted will return false. msg = %s\"", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "return", "false", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
Checks if the attributes are granted against the current authentication token and optionally supplied object. @param mixed $attributes @param mixed $object @return bool
[ "Checks", "if", "the", "attributes", "are", "granted", "against", "the", "current", "authentication", "token", "and", "optionally", "supplied", "object", "." ]
a7570893742286c30222c393891aeb6857064f37
https://github.com/oasmobile/php-http/blob/a7570893742286c30222c393891aeb6857064f37/src/SilexKernel.php#L512-L533
32,644
firebrandhq/silverstripe-hail
src/Models/Publication.php
Publication.processFeaturedArticle
private function processFeaturedArticle($articleData) { if ($articleData) { $article = Article::get()->filter(['HailID' => $articleData['id']])->first(); if (!$article) { $article = new Article(); $article->importHailData($articleData); } $heroImage = $article->HeroImageID; $heroVideo = $article->HeroVideoID; $article = $article->ID; } else { $article = null; } $this->FeaturedArticleID = $article; if (isset($heroImage) && $heroImage) { $this->HeroImageID = $heroImage; } if (isset($heroVideo) && $heroVideo) { $this->HeroVideoID = $heroVideo; } }
php
private function processFeaturedArticle($articleData) { if ($articleData) { $article = Article::get()->filter(['HailID' => $articleData['id']])->first(); if (!$article) { $article = new Article(); $article->importHailData($articleData); } $heroImage = $article->HeroImageID; $heroVideo = $article->HeroVideoID; $article = $article->ID; } else { $article = null; } $this->FeaturedArticleID = $article; if (isset($heroImage) && $heroImage) { $this->HeroImageID = $heroImage; } if (isset($heroVideo) && $heroVideo) { $this->HeroVideoID = $heroVideo; } }
[ "private", "function", "processFeaturedArticle", "(", "$", "articleData", ")", "{", "if", "(", "$", "articleData", ")", "{", "$", "article", "=", "Article", "::", "get", "(", ")", "->", "filter", "(", "[", "'HailID'", "=>", "$", "articleData", "[", "'id'", "]", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "article", ")", "{", "$", "article", "=", "new", "Article", "(", ")", ";", "$", "article", "->", "importHailData", "(", "$", "articleData", ")", ";", "}", "$", "heroImage", "=", "$", "article", "->", "HeroImageID", ";", "$", "heroVideo", "=", "$", "article", "->", "HeroVideoID", ";", "$", "article", "=", "$", "article", "->", "ID", ";", "}", "else", "{", "$", "article", "=", "null", ";", "}", "$", "this", "->", "FeaturedArticleID", "=", "$", "article", ";", "if", "(", "isset", "(", "$", "heroImage", ")", "&&", "$", "heroImage", ")", "{", "$", "this", "->", "HeroImageID", "=", "$", "heroImage", ";", "}", "if", "(", "isset", "(", "$", "heroVideo", ")", "&&", "$", "heroVideo", ")", "{", "$", "this", "->", "HeroVideoID", "=", "$", "heroVideo", ";", "}", "}" ]
Attach the featured article to this publication if there is one @param array $articleData
[ "Attach", "the", "featured", "article", "to", "this", "publication", "if", "there", "is", "one" ]
fd655b7a568f8d5f6a8f888f39368618596f794e
https://github.com/firebrandhq/silverstripe-hail/blob/fd655b7a568f8d5f6a8f888f39368618596f794e/src/Models/Publication.php#L143-L170
32,645
flipboxfactory/craft-ember
src/records/SortableTrait.php
SortableTrait.ensureSortOrder
protected function ensureSortOrder( array $sortOrderCondition = [], string $sortOrderAttribute = 'sortOrder' ) { if ($this->getAttribute($sortOrderAttribute) === null) { $this->setAttribute( $sortOrderAttribute, $this->nextSortOrder( $sortOrderCondition, $sortOrderAttribute ) ); } }
php
protected function ensureSortOrder( array $sortOrderCondition = [], string $sortOrderAttribute = 'sortOrder' ) { if ($this->getAttribute($sortOrderAttribute) === null) { $this->setAttribute( $sortOrderAttribute, $this->nextSortOrder( $sortOrderCondition, $sortOrderAttribute ) ); } }
[ "protected", "function", "ensureSortOrder", "(", "array", "$", "sortOrderCondition", "=", "[", "]", ",", "string", "$", "sortOrderAttribute", "=", "'sortOrder'", ")", "{", "if", "(", "$", "this", "->", "getAttribute", "(", "$", "sortOrderAttribute", ")", "===", "null", ")", "{", "$", "this", "->", "setAttribute", "(", "$", "sortOrderAttribute", ",", "$", "this", "->", "nextSortOrder", "(", "$", "sortOrderCondition", ",", "$", "sortOrderAttribute", ")", ")", ";", "}", "}" ]
Ensure a sort order is set. If a sort order is not provided, it will be added to the end. @param array $sortOrderCondition @param string $sortOrderAttribute
[ "Ensure", "a", "sort", "order", "is", "set", ".", "If", "a", "sort", "order", "is", "not", "provided", "it", "will", "be", "added", "to", "the", "end", "." ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/records/SortableTrait.php#L105-L118
32,646
flipboxfactory/craft-ember
src/records/SortableTrait.php
SortableTrait.nextSortOrder
protected function nextSortOrder( array $sortOrderCondition = [], string $sortOrderAttribute = 'sortOrder' ): int { $maxSortOrder = $this->sortOrderQuery( $sortOrderCondition, $sortOrderAttribute )->max('[[' . $sortOrderAttribute . ']]'); return ++$maxSortOrder; }
php
protected function nextSortOrder( array $sortOrderCondition = [], string $sortOrderAttribute = 'sortOrder' ): int { $maxSortOrder = $this->sortOrderQuery( $sortOrderCondition, $sortOrderAttribute )->max('[[' . $sortOrderAttribute . ']]'); return ++$maxSortOrder; }
[ "protected", "function", "nextSortOrder", "(", "array", "$", "sortOrderCondition", "=", "[", "]", ",", "string", "$", "sortOrderAttribute", "=", "'sortOrder'", ")", ":", "int", "{", "$", "maxSortOrder", "=", "$", "this", "->", "sortOrderQuery", "(", "$", "sortOrderCondition", ",", "$", "sortOrderAttribute", ")", "->", "max", "(", "'[['", ".", "$", "sortOrderAttribute", ".", "']]'", ")", ";", "return", "++", "$", "maxSortOrder", ";", "}" ]
Get the next available sort order available @param array $sortOrderCondition @param string $sortOrderAttribute @return int
[ "Get", "the", "next", "available", "sort", "order", "available" ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/records/SortableTrait.php#L200-L210
32,647
flipboxfactory/craft-ember
src/records/SortableTrait.php
SortableTrait.sortOrderQuery
protected function sortOrderQuery( array $sortOrderCondition = [], string $sortOrderAttribute = 'sortOrder' ): ActiveQuery { return static::find() ->andWhere($sortOrderCondition) ->orderBy([ $sortOrderAttribute => SORT_ASC, 'dateUpdated' => SORT_DESC ]); }
php
protected function sortOrderQuery( array $sortOrderCondition = [], string $sortOrderAttribute = 'sortOrder' ): ActiveQuery { return static::find() ->andWhere($sortOrderCondition) ->orderBy([ $sortOrderAttribute => SORT_ASC, 'dateUpdated' => SORT_DESC ]); }
[ "protected", "function", "sortOrderQuery", "(", "array", "$", "sortOrderCondition", "=", "[", "]", ",", "string", "$", "sortOrderAttribute", "=", "'sortOrder'", ")", ":", "ActiveQuery", "{", "return", "static", "::", "find", "(", ")", "->", "andWhere", "(", "$", "sortOrderCondition", ")", "->", "orderBy", "(", "[", "$", "sortOrderAttribute", "=>", "SORT_ASC", ",", "'dateUpdated'", "=>", "SORT_DESC", "]", ")", ";", "}" ]
Creates a sort order query which will display all siblings ordered by their sort order @param array $sortOrderCondition @param string $sortOrderAttribute @return ActiveQuery
[ "Creates", "a", "sort", "order", "query", "which", "will", "display", "all", "siblings", "ordered", "by", "their", "sort", "order" ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/records/SortableTrait.php#L220-L230
32,648
flipboxfactory/craft-ember
src/records/SortableTrait.php
SortableTrait.saveNewOrder
protected function saveNewOrder( array $sortOrder, string $targetAttribute, array $sortOrderCondition = [], string $sortOrderAttribute = 'sortOrder' ): bool { foreach ($sortOrder as $target => $order) { Craft::$app->getDb()->createCommand() ->update( static::tableName(), [$sortOrderAttribute => $order], array_merge( $sortOrderCondition, [ $targetAttribute => $target ] ) ) ->execute(); } return true; }
php
protected function saveNewOrder( array $sortOrder, string $targetAttribute, array $sortOrderCondition = [], string $sortOrderAttribute = 'sortOrder' ): bool { foreach ($sortOrder as $target => $order) { Craft::$app->getDb()->createCommand() ->update( static::tableName(), [$sortOrderAttribute => $order], array_merge( $sortOrderCondition, [ $targetAttribute => $target ] ) ) ->execute(); } return true; }
[ "protected", "function", "saveNewOrder", "(", "array", "$", "sortOrder", ",", "string", "$", "targetAttribute", ",", "array", "$", "sortOrderCondition", "=", "[", "]", ",", "string", "$", "sortOrderAttribute", "=", "'sortOrder'", ")", ":", "bool", "{", "foreach", "(", "$", "sortOrder", "as", "$", "target", "=>", "$", "order", ")", "{", "Craft", "::", "$", "app", "->", "getDb", "(", ")", "->", "createCommand", "(", ")", "->", "update", "(", "static", "::", "tableName", "(", ")", ",", "[", "$", "sortOrderAttribute", "=>", "$", "order", "]", ",", "array_merge", "(", "$", "sortOrderCondition", ",", "[", "$", "targetAttribute", "=>", "$", "target", "]", ")", ")", "->", "execute", "(", ")", ";", "}", "return", "true", ";", "}" ]
Saves a new sort order. @param array $sortOrder The new sort order that needs to be saved. The 'key' represents the target value and the 'value' represent the sort order. @param string $targetAttribute The target attribute that the new order is keyed on. @param array $sortOrderCondition Additional condition params used to accurately identify the sort order that need to be changed. For example, some sort orders may be site specific, therefore passing a 'siteId' condition would only apply the re-ordering to the specified site. @param string $sortOrderAttribute The sort order attribute that needs to be updated @return bool @throws \yii\db\Exception
[ "Saves", "a", "new", "sort", "order", "." ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/records/SortableTrait.php#L245-L267
32,649
flipboxfactory/craft-ember
src/helpers/QueryHelper.php
QueryHelper.parseBaseParam
public static function parseBaseParam(&$value, &$join): bool { // Force array if (!is_array($value)) { $value = [$value]; } // Get join type ('and' , 'or') $join = self::getJoinType($value, $join); // Check for object array (via 'id' key) if ($id = self::findIdFromObjectArray($value)) { $value = [$id]; return true; } return false; }
php
public static function parseBaseParam(&$value, &$join): bool { // Force array if (!is_array($value)) { $value = [$value]; } // Get join type ('and' , 'or') $join = self::getJoinType($value, $join); // Check for object array (via 'id' key) if ($id = self::findIdFromObjectArray($value)) { $value = [$id]; return true; } return false; }
[ "public", "static", "function", "parseBaseParam", "(", "&", "$", "value", ",", "&", "$", "join", ")", ":", "bool", "{", "// Force array", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "$", "value", "]", ";", "}", "// Get join type ('and' , 'or')", "$", "join", "=", "self", "::", "getJoinType", "(", "$", "value", ",", "$", "join", ")", ";", "// Check for object array (via 'id' key)", "if", "(", "$", "id", "=", "self", "::", "findIdFromObjectArray", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "$", "id", "]", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Standard param parsing. @param $value @param $join @return bool @deprecated
[ "Standard", "param", "parsing", "." ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/helpers/QueryHelper.php#L185-L202
32,650
flipboxfactory/craft-ember
src/helpers/QueryHelper.php
QueryHelper.prependOperator
private static function prependOperator($value, $operator = null) { if ($operator) { $operator = StringHelper::toLowerCase($operator); if (in_array($operator, static::$operators) || $operator === 'not') { if (is_array($value)) { $values = []; foreach ($value as $v) { $values[] = $operator . ($operator === 'not' ? ' ' : '') . $v; } return $values; } return $operator . ($operator === 'not' ? ' ' : '') . $value; } } return $value; }
php
private static function prependOperator($value, $operator = null) { if ($operator) { $operator = StringHelper::toLowerCase($operator); if (in_array($operator, static::$operators) || $operator === 'not') { if (is_array($value)) { $values = []; foreach ($value as $v) { $values[] = $operator . ($operator === 'not' ? ' ' : '') . $v; } return $values; } return $operator . ($operator === 'not' ? ' ' : '') . $value; } } return $value; }
[ "private", "static", "function", "prependOperator", "(", "$", "value", ",", "$", "operator", "=", "null", ")", "{", "if", "(", "$", "operator", ")", "{", "$", "operator", "=", "StringHelper", "::", "toLowerCase", "(", "$", "operator", ")", ";", "if", "(", "in_array", "(", "$", "operator", ",", "static", "::", "$", "operators", ")", "||", "$", "operator", "===", "'not'", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "value", "as", "$", "v", ")", "{", "$", "values", "[", "]", "=", "$", "operator", ".", "(", "$", "operator", "===", "'not'", "?", "' '", ":", "''", ")", ".", "$", "v", ";", "}", "return", "$", "values", ";", "}", "return", "$", "operator", ".", "(", "$", "operator", "===", "'not'", "?", "' '", ":", "''", ")", ".", "$", "value", ";", "}", "}", "return", "$", "value", ";", "}" ]
Prepend the operator to a value @param $value @param null $operator @return string|array @deprecated
[ "Prepend", "the", "operator", "to", "a", "value" ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/helpers/QueryHelper.php#L354-L376
32,651
flipboxfactory/craft-ember
src/helpers/QueryHelper.php
QueryHelper.parseParamOperator
private static function parseParamOperator(&$value) { foreach (static::$operators as $testOperator) { // Does the value start with this operator? $operatorLength = strlen($testOperator); if (strncmp( StringHelper::toLowerCase($value), $testOperator, $operatorLength ) == 0 ) { $value = mb_substr($value, $operatorLength); if ($testOperator == 'not ') { return 'not'; } else { return $testOperator; } } } return ''; }
php
private static function parseParamOperator(&$value) { foreach (static::$operators as $testOperator) { // Does the value start with this operator? $operatorLength = strlen($testOperator); if (strncmp( StringHelper::toLowerCase($value), $testOperator, $operatorLength ) == 0 ) { $value = mb_substr($value, $operatorLength); if ($testOperator == 'not ') { return 'not'; } else { return $testOperator; } } } return ''; }
[ "private", "static", "function", "parseParamOperator", "(", "&", "$", "value", ")", "{", "foreach", "(", "static", "::", "$", "operators", "as", "$", "testOperator", ")", "{", "// Does the value start with this operator?", "$", "operatorLength", "=", "strlen", "(", "$", "testOperator", ")", ";", "if", "(", "strncmp", "(", "StringHelper", "::", "toLowerCase", "(", "$", "value", ")", ",", "$", "testOperator", ",", "$", "operatorLength", ")", "==", "0", ")", "{", "$", "value", "=", "mb_substr", "(", "$", "value", ",", "$", "operatorLength", ")", ";", "if", "(", "$", "testOperator", "==", "'not '", ")", "{", "return", "'not'", ";", "}", "else", "{", "return", "$", "testOperator", ";", "}", "}", "}", "return", "''", ";", "}" ]
Extracts the operator from a DB param and returns it. @param string &$value Te param value. @return string The operator. @deprecated
[ "Extracts", "the", "operator", "from", "a", "DB", "param", "and", "returns", "it", "." ]
9185b885b404b1cb272a0983023eb7c6c0df61c8
https://github.com/flipboxfactory/craft-ember/blob/9185b885b404b1cb272a0983023eb7c6c0df61c8/src/helpers/QueryHelper.php#L405-L428
32,652
Vectorface/cache
src/CacheHelper.php
CacheHelper.fetch
public static function fetch(Cache $cache, $key, $callback, $args, $ttl = 300) { if (!(is_string($key))) { throw new \Exception('Cache key must be a string'); } $item = $cache->get($key); if ($item === false) { $item = static::runCallback($callback, $args); if (isset($item)) { $cache->set($key, $item, $ttl); } } return $item; }
php
public static function fetch(Cache $cache, $key, $callback, $args, $ttl = 300) { if (!(is_string($key))) { throw new \Exception('Cache key must be a string'); } $item = $cache->get($key); if ($item === false) { $item = static::runCallback($callback, $args); if (isset($item)) { $cache->set($key, $item, $ttl); } } return $item; }
[ "public", "static", "function", "fetch", "(", "Cache", "$", "cache", ",", "$", "key", ",", "$", "callback", ",", "$", "args", ",", "$", "ttl", "=", "300", ")", "{", "if", "(", "!", "(", "is_string", "(", "$", "key", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Cache key must be a string'", ")", ";", "}", "$", "item", "=", "$", "cache", "->", "get", "(", "$", "key", ")", ";", "if", "(", "$", "item", "===", "false", ")", "{", "$", "item", "=", "static", "::", "runCallback", "(", "$", "callback", ",", "$", "args", ")", ";", "if", "(", "isset", "(", "$", "item", ")", ")", "{", "$", "cache", "->", "set", "(", "$", "key", ",", "$", "item", ",", "$", "ttl", ")", ";", "}", "}", "return", "$", "item", ";", "}" ]
Implement the mechanics of caching the result of a heavy function call. For example, if one has a function like so: public static function getLargeDatasetFromDB($arg1, $arg2) { // Lots of SQL/compute return $giantDataSet; } One could cache this by adding cache calls to the top/bottom. CacheHelper::fetch can automatate this: function getLargeDataset($arg1, $arg2) { $key = "SomeClass::LargeDataset($arg1,$arg2)"; $cache = new APCCache(); return CacheHelper::fetch($cache, $key, [SomeClass, 'getLargeDatasetFromDB'], [$arg1, $arg2], 600); } @param Cache $cache The cache from/to which the values should be retrieved/set. @param string $key The cache key which should store the value. @param callable $callback A callable which is expected to return a value to be cached. @param mixed[] $args The arguments to be passed to the callback, if it needs to be called. @param int $ttl If a value is to be set in the cache, set this expiry time (in seconds). @return mixed The value stored in the cache, or returned by the callback.
[ "Implement", "the", "mechanics", "of", "caching", "the", "result", "of", "a", "heavy", "function", "call", "." ]
159f4aeaf639da7a1f7e1d4e5e719a279442658b
https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/CacheHelper.php#L34-L49
32,653
Vectorface/cache
src/CacheHelper.php
CacheHelper.runCallback
protected static function runCallback($callback, $args) { if (!is_array($args)) { $args = isset($args) ? array($args) : array(); } return call_user_func_array($callback, $args); }
php
protected static function runCallback($callback, $args) { if (!is_array($args)) { $args = isset($args) ? array($args) : array(); } return call_user_func_array($callback, $args); }
[ "protected", "static", "function", "runCallback", "(", "$", "callback", ",", "$", "args", ")", "{", "if", "(", "!", "is_array", "(", "$", "args", ")", ")", "{", "$", "args", "=", "isset", "(", "$", "args", ")", "?", "array", "(", "$", "args", ")", ":", "array", "(", ")", ";", "}", "return", "call_user_func_array", "(", "$", "callback", ",", "$", "args", ")", ";", "}" ]
Run the callback, normalizing the arguments. @param callable $callback The callable to be executed to fetch the value the cache. @param mixed[] $args The argument(s) to the callback function. @return mixed The value returned by the callback.
[ "Run", "the", "callback", "normalizing", "the", "arguments", "." ]
159f4aeaf639da7a1f7e1d4e5e719a279442658b
https://github.com/Vectorface/cache/blob/159f4aeaf639da7a1f7e1d4e5e719a279442658b/src/CacheHelper.php#L58-L64
32,654
JanDC/css-from-html-extractor
src/Css/Rule/Processor.php
Processor.splitIntoSeparateMediaQueries
public function splitIntoSeparateMediaQueries($rulesString) { // Intelligently break up rules, preserving mediaquery context and such $mediaQuerySelector = '/@media[^{]+\{([\s\S]+?\})\s*\}/'; $mediaQueryMatches = []; preg_match_all($mediaQuerySelector, $rulesString, $mediaQueryMatches); $remainingRuleSet = $rulesString; $queryParts = []; foreach (reset($mediaQueryMatches) as $mediaQueryMatch) { $tokenisedRules = explode($mediaQueryMatch, $remainingRuleSet); $queryParts[] = reset($tokenisedRules); $queryParts[] = $mediaQueryMatch; if (count($tokenisedRules) === 2) { $remainingRuleSet = end($tokenisedRules); } else { $remainingRuleSet = ''; } } if (!empty($remainingRuleSet)) { $queryParts[] = $remainingRuleSet; } $indexedRules = []; foreach ($queryParts as $part) { if (strpos($part, '@media') === false) { $indexedRules[][''] = (array)explode('}', $part); continue; } $mediaQueryString = substr($part, 0, strpos($part, '{')); // No need for print css if (trim($mediaQueryString) === '@media print') { continue; } $mediaQueryRules = substr($part, strpos($part, '{') + 1); $mediaQueryRules = substr($mediaQueryRules, 0, -1); $indexedRules[][$mediaQueryString] = (array)explode('}', $mediaQueryRules); } return $indexedRules; }
php
public function splitIntoSeparateMediaQueries($rulesString) { // Intelligently break up rules, preserving mediaquery context and such $mediaQuerySelector = '/@media[^{]+\{([\s\S]+?\})\s*\}/'; $mediaQueryMatches = []; preg_match_all($mediaQuerySelector, $rulesString, $mediaQueryMatches); $remainingRuleSet = $rulesString; $queryParts = []; foreach (reset($mediaQueryMatches) as $mediaQueryMatch) { $tokenisedRules = explode($mediaQueryMatch, $remainingRuleSet); $queryParts[] = reset($tokenisedRules); $queryParts[] = $mediaQueryMatch; if (count($tokenisedRules) === 2) { $remainingRuleSet = end($tokenisedRules); } else { $remainingRuleSet = ''; } } if (!empty($remainingRuleSet)) { $queryParts[] = $remainingRuleSet; } $indexedRules = []; foreach ($queryParts as $part) { if (strpos($part, '@media') === false) { $indexedRules[][''] = (array)explode('}', $part); continue; } $mediaQueryString = substr($part, 0, strpos($part, '{')); // No need for print css if (trim($mediaQueryString) === '@media print') { continue; } $mediaQueryRules = substr($part, strpos($part, '{') + 1); $mediaQueryRules = substr($mediaQueryRules, 0, -1); $indexedRules[][$mediaQueryString] = (array)explode('}', $mediaQueryRules); } return $indexedRules; }
[ "public", "function", "splitIntoSeparateMediaQueries", "(", "$", "rulesString", ")", "{", "// Intelligently break up rules, preserving mediaquery context and such", "$", "mediaQuerySelector", "=", "'/@media[^{]+\\{([\\s\\S]+?\\})\\s*\\}/'", ";", "$", "mediaQueryMatches", "=", "[", "]", ";", "preg_match_all", "(", "$", "mediaQuerySelector", ",", "$", "rulesString", ",", "$", "mediaQueryMatches", ")", ";", "$", "remainingRuleSet", "=", "$", "rulesString", ";", "$", "queryParts", "=", "[", "]", ";", "foreach", "(", "reset", "(", "$", "mediaQueryMatches", ")", "as", "$", "mediaQueryMatch", ")", "{", "$", "tokenisedRules", "=", "explode", "(", "$", "mediaQueryMatch", ",", "$", "remainingRuleSet", ")", ";", "$", "queryParts", "[", "]", "=", "reset", "(", "$", "tokenisedRules", ")", ";", "$", "queryParts", "[", "]", "=", "$", "mediaQueryMatch", ";", "if", "(", "count", "(", "$", "tokenisedRules", ")", "===", "2", ")", "{", "$", "remainingRuleSet", "=", "end", "(", "$", "tokenisedRules", ")", ";", "}", "else", "{", "$", "remainingRuleSet", "=", "''", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "remainingRuleSet", ")", ")", "{", "$", "queryParts", "[", "]", "=", "$", "remainingRuleSet", ";", "}", "$", "indexedRules", "=", "[", "]", ";", "foreach", "(", "$", "queryParts", "as", "$", "part", ")", "{", "if", "(", "strpos", "(", "$", "part", ",", "'@media'", ")", "===", "false", ")", "{", "$", "indexedRules", "[", "]", "[", "''", "]", "=", "(", "array", ")", "explode", "(", "'}'", ",", "$", "part", ")", ";", "continue", ";", "}", "$", "mediaQueryString", "=", "substr", "(", "$", "part", ",", "0", ",", "strpos", "(", "$", "part", ",", "'{'", ")", ")", ";", "// No need for print css", "if", "(", "trim", "(", "$", "mediaQueryString", ")", "===", "'@media print'", ")", "{", "continue", ";", "}", "$", "mediaQueryRules", "=", "substr", "(", "$", "part", ",", "strpos", "(", "$", "part", ",", "'{'", ")", "+", "1", ")", ";", "$", "mediaQueryRules", "=", "substr", "(", "$", "mediaQueryRules", ",", "0", ",", "-", "1", ")", ";", "$", "indexedRules", "[", "]", "[", "$", "mediaQueryString", "]", "=", "(", "array", ")", "explode", "(", "'}'", ",", "$", "mediaQueryRules", ")", ";", "}", "return", "$", "indexedRules", ";", "}" ]
Split a string into seperate rules @param string $rulesString @return array
[ "Split", "a", "string", "into", "seperate", "rules" ]
e471a1e9ea00f800cb20e014079050cb2d9ad57c
https://github.com/JanDC/css-from-html-extractor/blob/e471a1e9ea00f800cb20e014079050cb2d9ad57c/src/Css/Rule/Processor.php#L19-L71
32,655
JanDC/css-from-html-extractor
src/Css/Rule/Processor.php
Processor.convertToObjects
public function convertToObjects($media, $rule, $originalOrder) { $rule = $this->cleanup($rule); $chunks = explode('{', $rule); $selectorIdentifier = 0; $ruleIdentifier = 1; if (!isset($chunks[$ruleIdentifier])) { return []; } $propertiesProcessor = new PropertyProcessor(); $rules = []; $selectors = (array)explode(',', trim($chunks[$selectorIdentifier])); $properties = $propertiesProcessor->splitIntoSeparateProperties($chunks[$ruleIdentifier]); foreach ($selectors as $selector) { $selector = trim($selector); $specificity = $this->calculateSpecificityBasedOnASelector($selector); $rules[] = new Rule( $media, $selector, $propertiesProcessor->convertArrayToObjects($properties, $specificity), $specificity, $originalOrder ); } return $rules; }
php
public function convertToObjects($media, $rule, $originalOrder) { $rule = $this->cleanup($rule); $chunks = explode('{', $rule); $selectorIdentifier = 0; $ruleIdentifier = 1; if (!isset($chunks[$ruleIdentifier])) { return []; } $propertiesProcessor = new PropertyProcessor(); $rules = []; $selectors = (array)explode(',', trim($chunks[$selectorIdentifier])); $properties = $propertiesProcessor->splitIntoSeparateProperties($chunks[$ruleIdentifier]); foreach ($selectors as $selector) { $selector = trim($selector); $specificity = $this->calculateSpecificityBasedOnASelector($selector); $rules[] = new Rule( $media, $selector, $propertiesProcessor->convertArrayToObjects($properties, $specificity), $specificity, $originalOrder ); } return $rules; }
[ "public", "function", "convertToObjects", "(", "$", "media", ",", "$", "rule", ",", "$", "originalOrder", ")", "{", "$", "rule", "=", "$", "this", "->", "cleanup", "(", "$", "rule", ")", ";", "$", "chunks", "=", "explode", "(", "'{'", ",", "$", "rule", ")", ";", "$", "selectorIdentifier", "=", "0", ";", "$", "ruleIdentifier", "=", "1", ";", "if", "(", "!", "isset", "(", "$", "chunks", "[", "$", "ruleIdentifier", "]", ")", ")", "{", "return", "[", "]", ";", "}", "$", "propertiesProcessor", "=", "new", "PropertyProcessor", "(", ")", ";", "$", "rules", "=", "[", "]", ";", "$", "selectors", "=", "(", "array", ")", "explode", "(", "','", ",", "trim", "(", "$", "chunks", "[", "$", "selectorIdentifier", "]", ")", ")", ";", "$", "properties", "=", "$", "propertiesProcessor", "->", "splitIntoSeparateProperties", "(", "$", "chunks", "[", "$", "ruleIdentifier", "]", ")", ";", "foreach", "(", "$", "selectors", "as", "$", "selector", ")", "{", "$", "selector", "=", "trim", "(", "$", "selector", ")", ";", "$", "specificity", "=", "$", "this", "->", "calculateSpecificityBasedOnASelector", "(", "$", "selector", ")", ";", "$", "rules", "[", "]", "=", "new", "Rule", "(", "$", "media", ",", "$", "selector", ",", "$", "propertiesProcessor", "->", "convertArrayToObjects", "(", "$", "properties", ",", "$", "specificity", ")", ",", "$", "specificity", ",", "$", "originalOrder", ")", ";", "}", "return", "$", "rules", ";", "}" ]
Convert a rule-string into an object @param string $media @param string $rule @param int $originalOrder @return array
[ "Convert", "a", "rule", "-", "string", "into", "an", "object" ]
e471a1e9ea00f800cb20e014079050cb2d9ad57c
https://github.com/JanDC/css-from-html-extractor/blob/e471a1e9ea00f800cb20e014079050cb2d9ad57c/src/Css/Rule/Processor.php#L98-L129
32,656
appaydin/pd-mailer
SwiftMailer/SendListener.php
SendListener.logCreate
private function logCreate(\Swift_Mime_SimpleMessage $message, $status, $templateID, $language) { // Check Message if (null === $message->getId() || empty($message->getId())) { return false; } // Create Log $class = $this->bag->get('pd_mailer.mail_log_class'); $this->log = new $class; $this->log->setMailId($message->getId()); $this->log->setFrom($message->getFrom()); $this->log->setTo($message->getTo()); $this->log->setSubject($message->getSubject()); $this->log->setBody($message->getBody()); $this->log->setContentType($message->getContentType()); $this->log->setDate($message->getDate()); $this->log->setHeader($message->getHeaders()->toString()); $this->log->setReplyTo($message->getReplyTo()); $this->log->setStatus($status); $this->log->setTemplateId($templateID); $this->log->setLanguage($language); // Save $this->entityManager->persist($this->log); $this->entityManager->flush(); return true; }
php
private function logCreate(\Swift_Mime_SimpleMessage $message, $status, $templateID, $language) { // Check Message if (null === $message->getId() || empty($message->getId())) { return false; } // Create Log $class = $this->bag->get('pd_mailer.mail_log_class'); $this->log = new $class; $this->log->setMailId($message->getId()); $this->log->setFrom($message->getFrom()); $this->log->setTo($message->getTo()); $this->log->setSubject($message->getSubject()); $this->log->setBody($message->getBody()); $this->log->setContentType($message->getContentType()); $this->log->setDate($message->getDate()); $this->log->setHeader($message->getHeaders()->toString()); $this->log->setReplyTo($message->getReplyTo()); $this->log->setStatus($status); $this->log->setTemplateId($templateID); $this->log->setLanguage($language); // Save $this->entityManager->persist($this->log); $this->entityManager->flush(); return true; }
[ "private", "function", "logCreate", "(", "\\", "Swift_Mime_SimpleMessage", "$", "message", ",", "$", "status", ",", "$", "templateID", ",", "$", "language", ")", "{", "// Check Message", "if", "(", "null", "===", "$", "message", "->", "getId", "(", ")", "||", "empty", "(", "$", "message", "->", "getId", "(", ")", ")", ")", "{", "return", "false", ";", "}", "// Create Log", "$", "class", "=", "$", "this", "->", "bag", "->", "get", "(", "'pd_mailer.mail_log_class'", ")", ";", "$", "this", "->", "log", "=", "new", "$", "class", ";", "$", "this", "->", "log", "->", "setMailId", "(", "$", "message", "->", "getId", "(", ")", ")", ";", "$", "this", "->", "log", "->", "setFrom", "(", "$", "message", "->", "getFrom", "(", ")", ")", ";", "$", "this", "->", "log", "->", "setTo", "(", "$", "message", "->", "getTo", "(", ")", ")", ";", "$", "this", "->", "log", "->", "setSubject", "(", "$", "message", "->", "getSubject", "(", ")", ")", ";", "$", "this", "->", "log", "->", "setBody", "(", "$", "message", "->", "getBody", "(", ")", ")", ";", "$", "this", "->", "log", "->", "setContentType", "(", "$", "message", "->", "getContentType", "(", ")", ")", ";", "$", "this", "->", "log", "->", "setDate", "(", "$", "message", "->", "getDate", "(", ")", ")", ";", "$", "this", "->", "log", "->", "setHeader", "(", "$", "message", "->", "getHeaders", "(", ")", "->", "toString", "(", ")", ")", ";", "$", "this", "->", "log", "->", "setReplyTo", "(", "$", "message", "->", "getReplyTo", "(", ")", ")", ";", "$", "this", "->", "log", "->", "setStatus", "(", "$", "status", ")", ";", "$", "this", "->", "log", "->", "setTemplateId", "(", "$", "templateID", ")", ";", "$", "this", "->", "log", "->", "setLanguage", "(", "$", "language", ")", ";", "// Save", "$", "this", "->", "entityManager", "->", "persist", "(", "$", "this", "->", "log", ")", ";", "$", "this", "->", "entityManager", "->", "flush", "(", ")", ";", "return", "true", ";", "}" ]
Create Mail Log. @param \Swift_Mime_SimpleMessage $message @param $status @param $templateID @param $language @return bool
[ "Create", "Mail", "Log", "." ]
c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f
https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/SwiftMailer/SendListener.php#L161-L189
32,657
appaydin/pd-mailer
SwiftMailer/SendListener.php
SendListener.logUpdate
private function logUpdate(\Swift_Mime_SimpleMessage $message, $status) { // Check Message if (null === $message->getId() || empty($message->getId())) { return false; } // Update Data $this->log->setStatus($status); $this->log->setDate($message->getDate()); // Save || Update $this->entityManager->persist($this->log); $this->entityManager->flush(); return true; }
php
private function logUpdate(\Swift_Mime_SimpleMessage $message, $status) { // Check Message if (null === $message->getId() || empty($message->getId())) { return false; } // Update Data $this->log->setStatus($status); $this->log->setDate($message->getDate()); // Save || Update $this->entityManager->persist($this->log); $this->entityManager->flush(); return true; }
[ "private", "function", "logUpdate", "(", "\\", "Swift_Mime_SimpleMessage", "$", "message", ",", "$", "status", ")", "{", "// Check Message", "if", "(", "null", "===", "$", "message", "->", "getId", "(", ")", "||", "empty", "(", "$", "message", "->", "getId", "(", ")", ")", ")", "{", "return", "false", ";", "}", "// Update Data", "$", "this", "->", "log", "->", "setStatus", "(", "$", "status", ")", ";", "$", "this", "->", "log", "->", "setDate", "(", "$", "message", "->", "getDate", "(", ")", ")", ";", "// Save || Update", "$", "this", "->", "entityManager", "->", "persist", "(", "$", "this", "->", "log", ")", ";", "$", "this", "->", "entityManager", "->", "flush", "(", ")", ";", "return", "true", ";", "}" ]
Update Log Status & Date. @param \Swift_Mime_SimpleMessage $message @param $status @return bool
[ "Update", "Log", "Status", "&", "Date", "." ]
c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f
https://github.com/appaydin/pd-mailer/blob/c701cf6778e9c8991ae4b74dbf5e7d3d77310c0f/SwiftMailer/SendListener.php#L199-L215
32,658
CradlePHP/cradle-system
src/Fieldset.php
Fieldset.getFields
public function getFields() { $results = []; if (!isset($this->data['fields']) || empty($this->data['fields']) ) { return $results; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { $name = $table . '_' . $field['name']; $results[$name] = $field; } return $results; }
php
public function getFields() { $results = []; if (!isset($this->data['fields']) || empty($this->data['fields']) ) { return $results; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { $name = $table . '_' . $field['name']; $results[$name] = $field; } return $results; }
[ "public", "function", "getFields", "(", ")", "{", "$", "results", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", "||", "empty", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", ")", "{", "return", "$", "results", ";", "}", "$", "table", "=", "$", "this", "->", "data", "[", "'name'", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'fields'", "]", "as", "$", "field", ")", "{", "$", "name", "=", "$", "table", ".", "'_'", ".", "$", "field", "[", "'name'", "]", ";", "$", "results", "[", "$", "name", "]", "=", "$", "field", ";", "}", "return", "$", "results", ";", "}" ]
Returns All fields @return array
[ "Returns", "All", "fields" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset.php#L104-L120
32,659
CradlePHP/cradle-system
src/Fieldset.php
Fieldset.getFileFieldNames
public function getFileFieldNames() { $results = []; if (!isset($this->data['fields']) || empty($this->data['fields']) ) { return $results; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { $name = $table . '_' . $field['name']; if (in_array( $field['field']['type'], [ 'file', 'image', 'filelist', 'imagelist' ] ) ) { $results[] = $name; } } return $results; }
php
public function getFileFieldNames() { $results = []; if (!isset($this->data['fields']) || empty($this->data['fields']) ) { return $results; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { $name = $table . '_' . $field['name']; if (in_array( $field['field']['type'], [ 'file', 'image', 'filelist', 'imagelist' ] ) ) { $results[] = $name; } } return $results; }
[ "public", "function", "getFileFieldNames", "(", ")", "{", "$", "results", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", "||", "empty", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", ")", "{", "return", "$", "results", ";", "}", "$", "table", "=", "$", "this", "->", "data", "[", "'name'", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'fields'", "]", "as", "$", "field", ")", "{", "$", "name", "=", "$", "table", ".", "'_'", ".", "$", "field", "[", "'name'", "]", ";", "if", "(", "in_array", "(", "$", "field", "[", "'field'", "]", "[", "'type'", "]", ",", "[", "'file'", ",", "'image'", ",", "'filelist'", ",", "'imagelist'", "]", ")", ")", "{", "$", "results", "[", "]", "=", "$", "name", ";", "}", "}", "return", "$", "results", ";", "}" ]
Returns All files @return array
[ "Returns", "All", "files" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset.php#L127-L155
32,660
CradlePHP/cradle-system
src/Fieldset.php
Fieldset.getRequiredFieldNames
public function getRequiredFieldNames() { $results = []; if (!isset($this->data['fields']) || empty($this->data['fields'])) { return $results; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { $name = $table . '_' . $field['name']; if (!isset($field['validation'])) { continue; } foreach ($field['validation'] as $validation) { if ($validation['method'] === 'required') { $results[] = $name; break; } } } return $results; }
php
public function getRequiredFieldNames() { $results = []; if (!isset($this->data['fields']) || empty($this->data['fields'])) { return $results; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { $name = $table . '_' . $field['name']; if (!isset($field['validation'])) { continue; } foreach ($field['validation'] as $validation) { if ($validation['method'] === 'required') { $results[] = $name; break; } } } return $results; }
[ "public", "function", "getRequiredFieldNames", "(", ")", "{", "$", "results", "=", "[", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", "||", "empty", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", ")", "{", "return", "$", "results", ";", "}", "$", "table", "=", "$", "this", "->", "data", "[", "'name'", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'fields'", "]", "as", "$", "field", ")", "{", "$", "name", "=", "$", "table", ".", "'_'", ".", "$", "field", "[", "'name'", "]", ";", "if", "(", "!", "isset", "(", "$", "field", "[", "'validation'", "]", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "field", "[", "'validation'", "]", "as", "$", "validation", ")", "{", "if", "(", "$", "validation", "[", "'method'", "]", "===", "'required'", ")", "{", "$", "results", "[", "]", "=", "$", "name", ";", "break", ";", "}", "}", "}", "return", "$", "results", ";", "}" ]
Returns a list of required fields @return array
[ "Returns", "a", "list", "of", "required", "fields" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset.php#L231-L254
32,661
CradlePHP/cradle-system
src/Fieldset.php
Fieldset.getSlugableFieldNames
public function getSlugableFieldNames($primary = false) { $results = []; if ($primary) { $results[] = $primary; } if (!isset($this->data['fields']) || empty($this->data['fields'])) { return $results; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { $name = $table . '_' . $field['name']; if (isset($field['type'])) { if ($field['type'] === 'slug') { $results[] = $name; } } } return $results; }
php
public function getSlugableFieldNames($primary = false) { $results = []; if ($primary) { $results[] = $primary; } if (!isset($this->data['fields']) || empty($this->data['fields'])) { return $results; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { $name = $table . '_' . $field['name']; if (isset($field['type'])) { if ($field['type'] === 'slug') { $results[] = $name; } } } return $results; }
[ "public", "function", "getSlugableFieldNames", "(", "$", "primary", "=", "false", ")", "{", "$", "results", "=", "[", "]", ";", "if", "(", "$", "primary", ")", "{", "$", "results", "[", "]", "=", "$", "primary", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", "||", "empty", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", ")", "{", "return", "$", "results", ";", "}", "$", "table", "=", "$", "this", "->", "data", "[", "'name'", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'fields'", "]", "as", "$", "field", ")", "{", "$", "name", "=", "$", "table", ".", "'_'", ".", "$", "field", "[", "'name'", "]", ";", "if", "(", "isset", "(", "$", "field", "[", "'type'", "]", ")", ")", "{", "if", "(", "$", "field", "[", "'type'", "]", "===", "'slug'", ")", "{", "$", "results", "[", "]", "=", "$", "name", ";", "}", "}", "}", "return", "$", "results", ";", "}" ]
Returns slug fields @param string|false $primary @return array
[ "Returns", "slug", "fields" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset.php#L263-L285
32,662
CradlePHP/cradle-system
src/Fieldset.php
Fieldset.getUniqueFieldNames
public function getUniqueFieldNames() { $results = [ $this->getPrimaryFieldName() ]; if (!isset($this->data['fields']) || empty($this->data['fields'])) { return $results; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { $name = $table . '_' . $field['name']; if ($field['field']['type'] === 'uuid') { $results[] = $name; continue; } if (!isset($field['validation'])) { continue; } foreach ($field['validation'] as $validation) { if ($validation['method'] === 'unique') { $results[] = $name; } } } return $results; }
php
public function getUniqueFieldNames() { $results = [ $this->getPrimaryFieldName() ]; if (!isset($this->data['fields']) || empty($this->data['fields'])) { return $results; } $table = $this->data['name']; foreach ($this->data['fields'] as $field) { $name = $table . '_' . $field['name']; if ($field['field']['type'] === 'uuid') { $results[] = $name; continue; } if (!isset($field['validation'])) { continue; } foreach ($field['validation'] as $validation) { if ($validation['method'] === 'unique') { $results[] = $name; } } } return $results; }
[ "public", "function", "getUniqueFieldNames", "(", ")", "{", "$", "results", "=", "[", "$", "this", "->", "getPrimaryFieldName", "(", ")", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", "||", "empty", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", ")", "{", "return", "$", "results", ";", "}", "$", "table", "=", "$", "this", "->", "data", "[", "'name'", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'fields'", "]", "as", "$", "field", ")", "{", "$", "name", "=", "$", "table", ".", "'_'", ".", "$", "field", "[", "'name'", "]", ";", "if", "(", "$", "field", "[", "'field'", "]", "[", "'type'", "]", "===", "'uuid'", ")", "{", "$", "results", "[", "]", "=", "$", "name", ";", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "field", "[", "'validation'", "]", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "field", "[", "'validation'", "]", "as", "$", "validation", ")", "{", "if", "(", "$", "validation", "[", "'method'", "]", "===", "'unique'", ")", "{", "$", "results", "[", "]", "=", "$", "name", ";", "}", "}", "}", "return", "$", "results", ";", "}" ]
Returns a list of unique fields @return array
[ "Returns", "a", "list", "of", "unique", "fields" ]
3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c
https://github.com/CradlePHP/cradle-system/blob/3dda31fbc7e4523fdcc87e18a7ab852116cbdc6c/src/Fieldset.php#L292-L320
32,663
ahand/mobileesp
PHP/mdetect.php
uagent_info.uagent_info
function uagent_info() { $this->useragent = isset($_SERVER['HTTP_USER_AGENT'])?strtolower($_SERVER['HTTP_USER_AGENT']):''; $this->httpaccept = isset($_SERVER['HTTP_ACCEPT'])?strtolower($_SERVER['HTTP_ACCEPT']):''; //Let's initialize some values to save cycles later. $this->InitDeviceScan(); }
php
function uagent_info() { $this->useragent = isset($_SERVER['HTTP_USER_AGENT'])?strtolower($_SERVER['HTTP_USER_AGENT']):''; $this->httpaccept = isset($_SERVER['HTTP_ACCEPT'])?strtolower($_SERVER['HTTP_ACCEPT']):''; //Let's initialize some values to save cycles later. $this->InitDeviceScan(); }
[ "function", "uagent_info", "(", ")", "{", "$", "this", "->", "useragent", "=", "isset", "(", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", "?", "strtolower", "(", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", ":", "''", ";", "$", "this", "->", "httpaccept", "=", "isset", "(", "$", "_SERVER", "[", "'HTTP_ACCEPT'", "]", ")", "?", "strtolower", "(", "$", "_SERVER", "[", "'HTTP_ACCEPT'", "]", ")", ":", "''", ";", "//Let's initialize some values to save cycles later.\r", "$", "this", "->", "InitDeviceScan", "(", ")", ";", "}" ]
The object initializer. Initializes several default variables.
[ "The", "object", "initializer", ".", "Initializes", "several", "default", "variables", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L225-L232
32,664
ahand/mobileesp
PHP/mdetect.php
uagent_info.InitDeviceScan
function InitDeviceScan() { //Save these properties to speed processing global $isWebkit, $isIphone, $isAndroid, $isAndroidPhone; $this->isWebkit = $this->DetectWebkit(); $this->isIphone = $this->DetectIphone(); $this->isAndroid = $this->DetectAndroid(); $this->isAndroidPhone = $this->DetectAndroidPhone(); //These tiers are the most useful for web development global $isMobilePhone, $isTierTablet, $isTierIphone; $this->isMobilePhone = $this->DetectMobileQuick(); $this->isTierIphone = $this->DetectTierIphone(); $this->isTierTablet = $this->DetectTierTablet(); //Optional: Comment these out if you NEVER use them. global $isTierRichCss, $isTierGenericMobile; $this->isTierRichCss = $this->DetectTierRichCss(); $this->isTierGenericMobile = $this->DetectTierOtherPhones(); $this->initCompleted = $this->true; }
php
function InitDeviceScan() { //Save these properties to speed processing global $isWebkit, $isIphone, $isAndroid, $isAndroidPhone; $this->isWebkit = $this->DetectWebkit(); $this->isIphone = $this->DetectIphone(); $this->isAndroid = $this->DetectAndroid(); $this->isAndroidPhone = $this->DetectAndroidPhone(); //These tiers are the most useful for web development global $isMobilePhone, $isTierTablet, $isTierIphone; $this->isMobilePhone = $this->DetectMobileQuick(); $this->isTierIphone = $this->DetectTierIphone(); $this->isTierTablet = $this->DetectTierTablet(); //Optional: Comment these out if you NEVER use them. global $isTierRichCss, $isTierGenericMobile; $this->isTierRichCss = $this->DetectTierRichCss(); $this->isTierGenericMobile = $this->DetectTierOtherPhones(); $this->initCompleted = $this->true; }
[ "function", "InitDeviceScan", "(", ")", "{", "//Save these properties to speed processing\r", "global", "$", "isWebkit", ",", "$", "isIphone", ",", "$", "isAndroid", ",", "$", "isAndroidPhone", ";", "$", "this", "->", "isWebkit", "=", "$", "this", "->", "DetectWebkit", "(", ")", ";", "$", "this", "->", "isIphone", "=", "$", "this", "->", "DetectIphone", "(", ")", ";", "$", "this", "->", "isAndroid", "=", "$", "this", "->", "DetectAndroid", "(", ")", ";", "$", "this", "->", "isAndroidPhone", "=", "$", "this", "->", "DetectAndroidPhone", "(", ")", ";", "//These tiers are the most useful for web development\r", "global", "$", "isMobilePhone", ",", "$", "isTierTablet", ",", "$", "isTierIphone", ";", "$", "this", "->", "isMobilePhone", "=", "$", "this", "->", "DetectMobileQuick", "(", ")", ";", "$", "this", "->", "isTierIphone", "=", "$", "this", "->", "DetectTierIphone", "(", ")", ";", "$", "this", "->", "isTierTablet", "=", "$", "this", "->", "DetectTierTablet", "(", ")", ";", "//Optional: Comment these out if you NEVER use them.\r", "global", "$", "isTierRichCss", ",", "$", "isTierGenericMobile", ";", "$", "this", "->", "isTierRichCss", "=", "$", "this", "->", "DetectTierRichCss", "(", ")", ";", "$", "this", "->", "isTierGenericMobile", "=", "$", "this", "->", "DetectTierOtherPhones", "(", ")", ";", "$", "this", "->", "initCompleted", "=", "$", "this", "->", "true", ";", "}" ]
Initialize Key Stored Values.
[ "Initialize", "Key", "Stored", "Values", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L236-L257
32,665
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectIphone
function DetectIphone() { if ($this->initCompleted == $this->true || $this->isIphone == $this->true) return $this->isIphone; if (stripos($this->useragent, $this->deviceIphone) > -1) { //The iPad and iPod Touch say they're an iPhone. So let's disambiguate. if ($this->DetectIpad() == $this->true || $this->DetectIpod() == $this->true) return $this->false; //Yay! It's an iPhone! else return $this->true; } else return $this->false; }
php
function DetectIphone() { if ($this->initCompleted == $this->true || $this->isIphone == $this->true) return $this->isIphone; if (stripos($this->useragent, $this->deviceIphone) > -1) { //The iPad and iPod Touch say they're an iPhone. So let's disambiguate. if ($this->DetectIpad() == $this->true || $this->DetectIpod() == $this->true) return $this->false; //Yay! It's an iPhone! else return $this->true; } else return $this->false; }
[ "function", "DetectIphone", "(", ")", "{", "if", "(", "$", "this", "->", "initCompleted", "==", "$", "this", "->", "true", "||", "$", "this", "->", "isIphone", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "isIphone", ";", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceIphone", ")", ">", "-", "1", ")", "{", "//The iPad and iPod Touch say they're an iPhone. So let's disambiguate.\r", "if", "(", "$", "this", "->", "DetectIpad", "(", ")", "==", "$", "this", "->", "true", "||", "$", "this", "->", "DetectIpod", "(", ")", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "false", ";", "//Yay! It's an iPhone!\r", "else", "return", "$", "this", "->", "true", ";", "}", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current device is an iPhone.
[ "Detects", "if", "the", "current", "device", "is", "an", "iPhone", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L280-L298
32,666
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectIpod
function DetectIpod() { if (stripos($this->useragent, $this->deviceIpod) > -1) return $this->true; else return $this->false; }
php
function DetectIpod() { if (stripos($this->useragent, $this->deviceIpod) > -1) return $this->true; else return $this->false; }
[ "function", "DetectIpod", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceIpod", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current device is an iPod Touch.
[ "Detects", "if", "the", "current", "device", "is", "an", "iPod", "Touch", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L302-L308
32,667
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectIpad
function DetectIpad() { if (stripos($this->useragent, $this->deviceIpad) > -1 && $this->DetectWebkit() == $this->true) return $this->true; else return $this->false; }
php
function DetectIpad() { if (stripos($this->useragent, $this->deviceIpad) > -1 && $this->DetectWebkit() == $this->true) return $this->true; else return $this->false; }
[ "function", "DetectIpad", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceIpad", ")", ">", "-", "1", "&&", "$", "this", "->", "DetectWebkit", "(", ")", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current device is an iPad tablet.
[ "Detects", "if", "the", "current", "device", "is", "an", "iPad", "tablet", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L312-L319
32,668
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectIphoneOrIpod
function DetectIphoneOrIpod() { //We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay. if ($this->DetectIphone() == $this->true || $this->DetectIpod() == $this->true) return $this->true; else return $this->false; }
php
function DetectIphoneOrIpod() { //We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay. if ($this->DetectIphone() == $this->true || $this->DetectIpod() == $this->true) return $this->true; else return $this->false; }
[ "function", "DetectIphoneOrIpod", "(", ")", "{", "//We repeat the searches here because some iPods may report themselves as an iPhone, which would be okay.\r", "if", "(", "$", "this", "->", "DetectIphone", "(", ")", "==", "$", "this", "->", "true", "||", "$", "this", "->", "DetectIpod", "(", ")", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current device is an iPhone or iPod Touch.
[ "Detects", "if", "the", "current", "device", "is", "an", "iPhone", "or", "iPod", "Touch", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L323-L331
32,669
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectAndroid
function DetectAndroid() { if ($this->initCompleted == $this->true || $this->isAndroid == $this->true) return $this->isAndroid; if ((stripos($this->useragent, $this->deviceAndroid) > -1) || ($this->DetectGoogleTV() == $this->true)) return $this->true; return $this->false; }
php
function DetectAndroid() { if ($this->initCompleted == $this->true || $this->isAndroid == $this->true) return $this->isAndroid; if ((stripos($this->useragent, $this->deviceAndroid) > -1) || ($this->DetectGoogleTV() == $this->true)) return $this->true; return $this->false; }
[ "function", "DetectAndroid", "(", ")", "{", "if", "(", "$", "this", "->", "initCompleted", "==", "$", "this", "->", "true", "||", "$", "this", "->", "isAndroid", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "isAndroid", ";", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceAndroid", ")", ">", "-", "1", ")", "||", "(", "$", "this", "->", "DetectGoogleTV", "(", ")", "==", "$", "this", "->", "true", ")", ")", "return", "$", "this", "->", "true", ";", "return", "$", "this", "->", "false", ";", "}" ]
Also detects Google TV.
[ "Also", "detects", "Google", "TV", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L348-L359
32,670
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectAndroidTablet
function DetectAndroidTablet() { //First, let's make sure we're on an Android device. if ($this->DetectAndroid() == $this->false) return $this->false; //Special check for Android devices with Opera Mobile/Mini. They should NOT report here. if ($this->DetectOperaMobile() == $this->true) return $this->false; //Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet. if (stripos($this->useragent, $this->mobile) > -1) return $this->false; else return $this->true; }
php
function DetectAndroidTablet() { //First, let's make sure we're on an Android device. if ($this->DetectAndroid() == $this->false) return $this->false; //Special check for Android devices with Opera Mobile/Mini. They should NOT report here. if ($this->DetectOperaMobile() == $this->true) return $this->false; //Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet. if (stripos($this->useragent, $this->mobile) > -1) return $this->false; else return $this->true; }
[ "function", "DetectAndroidTablet", "(", ")", "{", "//First, let's make sure we're on an Android device.\r", "if", "(", "$", "this", "->", "DetectAndroid", "(", ")", "==", "$", "this", "->", "false", ")", "return", "$", "this", "->", "false", ";", "//Special check for Android devices with Opera Mobile/Mini. They should NOT report here.\r", "if", "(", "$", "this", "->", "DetectOperaMobile", "(", ")", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "false", ";", "//Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet.\r", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "mobile", ")", ">", "-", "1", ")", "return", "$", "this", "->", "false", ";", "else", "return", "$", "this", "->", "true", ";", "}" ]
Google says these devices will have 'Android' and NOT 'mobile' in their user agent.
[ "Google", "says", "these", "devices", "will", "have", "Android", "and", "NOT", "mobile", "in", "their", "user", "agent", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L390-L405
32,671
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectAndroidWebKit
function DetectAndroidWebKit() { if (($this->DetectAndroid() == $this->true) && ($this->DetectWebkit() == $this->true)) return $this->true; else return $this->false; }
php
function DetectAndroidWebKit() { if (($this->DetectAndroid() == $this->true) && ($this->DetectWebkit() == $this->true)) return $this->true; else return $this->false; }
[ "function", "DetectAndroidWebKit", "(", ")", "{", "if", "(", "(", "$", "this", "->", "DetectAndroid", "(", ")", "==", "$", "this", "->", "true", ")", "&&", "(", "$", "this", "->", "DetectWebkit", "(", ")", "==", "$", "this", "->", "true", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
the browser is based on WebKit.
[ "the", "browser", "is", "based", "on", "WebKit", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L410-L417
32,672
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectGoogleTV
function DetectGoogleTV() { if (stripos($this->useragent, $this->deviceGoogleTV) > -1) return $this->true; else return $this->false; }
php
function DetectGoogleTV() { if (stripos($this->useragent, $this->deviceGoogleTV) > -1) return $this->true; else return $this->false; }
[ "function", "DetectGoogleTV", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceGoogleTV", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current device is a GoogleTV.
[ "Detects", "if", "the", "current", "device", "is", "a", "GoogleTV", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L421-L427
32,673
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectWebkit
function DetectWebkit() { if ($this->initCompleted == $this->true || $this->isWebkit == $this->true) return $this->isWebkit; if (stripos($this->useragent, $this->engineWebKit) > -1) return $this->true; else return $this->false; }
php
function DetectWebkit() { if ($this->initCompleted == $this->true || $this->isWebkit == $this->true) return $this->isWebkit; if (stripos($this->useragent, $this->engineWebKit) > -1) return $this->true; else return $this->false; }
[ "function", "DetectWebkit", "(", ")", "{", "if", "(", "$", "this", "->", "initCompleted", "==", "$", "this", "->", "true", "||", "$", "this", "->", "isWebkit", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "isWebkit", ";", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "engineWebKit", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current browser is based on WebKit.
[ "Detects", "if", "the", "current", "browser", "is", "based", "on", "WebKit", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L431-L441
32,674
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectWindowsPhone
function DetectWindowsPhone() { if (($this->DetectWindowsPhone7() == $this->true) || ($this->DetectWindowsPhone8() == $this->true) || ($this->DetectWindowsPhone10() == $this->true)) return $this->true; else return $this->false; }
php
function DetectWindowsPhone() { if (($this->DetectWindowsPhone7() == $this->true) || ($this->DetectWindowsPhone8() == $this->true) || ($this->DetectWindowsPhone10() == $this->true)) return $this->true; else return $this->false; }
[ "function", "DetectWindowsPhone", "(", ")", "{", "if", "(", "(", "$", "this", "->", "DetectWindowsPhone7", "(", ")", "==", "$", "this", "->", "true", ")", "||", "(", "$", "this", "->", "DetectWindowsPhone8", "(", ")", "==", "$", "this", "->", "true", ")", "||", "(", "$", "this", "->", "DetectWindowsPhone10", "(", ")", "==", "$", "this", "->", "true", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Windows Phone 7, 8, or 10 device.
[ "Windows", "Phone", "7", "8", "or", "10", "device", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L447-L455
32,675
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectWindowsMobile
function DetectWindowsMobile() { if ($this->DetectWindowsPhone() == $this->true) return $this->false; //Most devices use 'Windows CE', but some report 'iemobile' // and some older ones report as 'PIE' for Pocket IE. if (stripos($this->useragent, $this->deviceWinMob) > -1 || stripos($this->useragent, $this->deviceIeMob) > -1 || stripos($this->useragent, $this->enginePie) > -1) return $this->true; //Test for Windows Mobile PPC but not old Macintosh PowerPC. if (stripos($this->useragent, $this->devicePpc) > -1 && !(stripos($this->useragent, $this->deviceMacPpc) > 1)) return $this->true; //Test for certain Windwos Mobile-based HTC devices. if (stripos($this->useragent, $this->manuHtc) > -1 && stripos($this->useragent, $this->deviceWindows) > -1) return $this->true; if ($this->DetectWapWml() == $this->true && stripos($this->useragent, $this->deviceWindows) > -1) return $this->true; else return $this->false; }
php
function DetectWindowsMobile() { if ($this->DetectWindowsPhone() == $this->true) return $this->false; //Most devices use 'Windows CE', but some report 'iemobile' // and some older ones report as 'PIE' for Pocket IE. if (stripos($this->useragent, $this->deviceWinMob) > -1 || stripos($this->useragent, $this->deviceIeMob) > -1 || stripos($this->useragent, $this->enginePie) > -1) return $this->true; //Test for Windows Mobile PPC but not old Macintosh PowerPC. if (stripos($this->useragent, $this->devicePpc) > -1 && !(stripos($this->useragent, $this->deviceMacPpc) > 1)) return $this->true; //Test for certain Windwos Mobile-based HTC devices. if (stripos($this->useragent, $this->manuHtc) > -1 && stripos($this->useragent, $this->deviceWindows) > -1) return $this->true; if ($this->DetectWapWml() == $this->true && stripos($this->useragent, $this->deviceWindows) > -1) return $this->true; else return $this->false; }
[ "function", "DetectWindowsMobile", "(", ")", "{", "if", "(", "$", "this", "->", "DetectWindowsPhone", "(", ")", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "false", ";", "//Most devices use 'Windows CE', but some report 'iemobile' \r", "// and some older ones report as 'PIE' for Pocket IE. \r", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceWinMob", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceIeMob", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "enginePie", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "//Test for Windows Mobile PPC but not old Macintosh PowerPC.\r", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "devicePpc", ")", ">", "-", "1", "&&", "!", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceMacPpc", ")", ">", "1", ")", ")", "return", "$", "this", "->", "true", ";", "//Test for certain Windwos Mobile-based HTC devices.\r", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "manuHtc", ")", ">", "-", "1", "&&", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceWindows", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "if", "(", "$", "this", "->", "DetectWapWml", "(", ")", "==", "$", "this", "->", "true", "&&", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceWindows", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Focuses on Windows Mobile 6.xx and earlier.
[ "Focuses", "on", "Windows", "Mobile", "6", ".", "xx", "and", "earlier", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L491-L515
32,676
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectBlackBerry
function DetectBlackBerry() { if ((stripos($this->useragent, $this->deviceBB) > -1) || (stripos($this->httpaccept, $this->vndRIM) > -1)) return $this->true; if ($this->DetectBlackBerry10Phone() == $this->true) return $this->true; else return $this->false; }
php
function DetectBlackBerry() { if ((stripos($this->useragent, $this->deviceBB) > -1) || (stripos($this->httpaccept, $this->vndRIM) > -1)) return $this->true; if ($this->DetectBlackBerry10Phone() == $this->true) return $this->true; else return $this->false; }
[ "function", "DetectBlackBerry", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceBB", ")", ">", "-", "1", ")", "||", "(", "stripos", "(", "$", "this", "->", "httpaccept", ",", "$", "this", "->", "vndRIM", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "if", "(", "$", "this", "->", "DetectBlackBerry10Phone", "(", ")", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Includes BB10 OS, but excludes the PlayBook.
[ "Includes", "BB10", "OS", "but", "excludes", "the", "PlayBook", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L520-L529
32,677
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectBlackBerry10Phone
function DetectBlackBerry10Phone() { if ((stripos($this->useragent, $this->deviceBB10) > -1) && (stripos($this->useragent, $this->mobile) > -1)) return $this->true; else return $this->false; }
php
function DetectBlackBerry10Phone() { if ((stripos($this->useragent, $this->deviceBB10) > -1) && (stripos($this->useragent, $this->mobile) > -1)) return $this->true; else return $this->false; }
[ "function", "DetectBlackBerry10Phone", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceBB10", ")", ">", "-", "1", ")", "&&", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "mobile", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Excludes tablets.
[ "Excludes", "tablets", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L534-L541
32,678
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectBlackBerryTouch
function DetectBlackBerryTouch() { if ((stripos($this->useragent, $this->deviceBBStorm) > -1) || (stripos($this->useragent, $this->deviceBBTorch) > -1) || (stripos($this->useragent, $this->deviceBBBoldTouch) > -1) || (stripos($this->useragent, $this->deviceBBCurveTouch) > -1)) return $this->true; else return $this->false; }
php
function DetectBlackBerryTouch() { if ((stripos($this->useragent, $this->deviceBBStorm) > -1) || (stripos($this->useragent, $this->deviceBBTorch) > -1) || (stripos($this->useragent, $this->deviceBBBoldTouch) > -1) || (stripos($this->useragent, $this->deviceBBCurveTouch) > -1)) return $this->true; else return $this->false; }
[ "function", "DetectBlackBerryTouch", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceBBStorm", ")", ">", "-", "1", ")", "||", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceBBTorch", ")", ">", "-", "1", ")", "||", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceBBBoldTouch", ")", ">", "-", "1", ")", "||", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceBBCurveTouch", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
a large screen, such as the Storm, Torch, and Bold Touch. Excludes the Playbook.
[ "a", "large", "screen", "such", "as", "the", "Storm", "Torch", "and", "Bold", "Touch", ".", "Excludes", "the", "Playbook", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L570-L579
32,679
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectBlackBerryHigh
function DetectBlackBerryHigh() { //Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser if ($this->DetectBlackBerryWebKit() == $this->true) return $this->false; if ($this->DetectBlackBerry() == $this->true) { if (($this->DetectBlackBerryTouch() == $this->true) || stripos($this->useragent, $this->deviceBBBold) > -1 || stripos($this->useragent, $this->deviceBBTour) > -1 || stripos($this->useragent, $this->deviceBBCurve) > -1) { return $this->true; } else return $this->false; } else return $this->false; }
php
function DetectBlackBerryHigh() { //Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser if ($this->DetectBlackBerryWebKit() == $this->true) return $this->false; if ($this->DetectBlackBerry() == $this->true) { if (($this->DetectBlackBerryTouch() == $this->true) || stripos($this->useragent, $this->deviceBBBold) > -1 || stripos($this->useragent, $this->deviceBBTour) > -1 || stripos($this->useragent, $this->deviceBBCurve) > -1) { return $this->true; } else return $this->false; } else return $this->false; }
[ "function", "DetectBlackBerryHigh", "(", ")", "{", "//Disambiguate for BlackBerry OS 6 or 7 (WebKit) browser\r", "if", "(", "$", "this", "->", "DetectBlackBerryWebKit", "(", ")", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "false", ";", "if", "(", "$", "this", "->", "DetectBlackBerry", "(", ")", "==", "$", "this", "->", "true", ")", "{", "if", "(", "(", "$", "this", "->", "DetectBlackBerryTouch", "(", ")", "==", "$", "this", "->", "true", ")", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceBBBold", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceBBTour", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceBBCurve", ")", ">", "-", "1", ")", "{", "return", "$", "this", "->", "true", ";", "}", "else", "return", "$", "this", "->", "false", ";", "}", "else", "return", "$", "this", "->", "false", ";", "}" ]
Excludes the new BlackBerry OS 6 and 7 browser!!
[ "Excludes", "the", "new", "BlackBerry", "OS", "6", "and", "7", "browser!!" ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L586-L605
32,680
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectS60OssBrowser
function DetectS60OssBrowser() { //First, test for WebKit, then make sure it's either Symbian or S60. if ($this->DetectWebkit() == $this->true) { if (stripos($this->useragent, $this->deviceSymbian) > -1 || stripos($this->useragent, $this->deviceS60) > -1) { return $this->true; } else return $this->false; } else return $this->false; }
php
function DetectS60OssBrowser() { //First, test for WebKit, then make sure it's either Symbian or S60. if ($this->DetectWebkit() == $this->true) { if (stripos($this->useragent, $this->deviceSymbian) > -1 || stripos($this->useragent, $this->deviceS60) > -1) { return $this->true; } else return $this->false; } else return $this->false; }
[ "function", "DetectS60OssBrowser", "(", ")", "{", "//First, test for WebKit, then make sure it's either Symbian or S60.\r", "if", "(", "$", "this", "->", "DetectWebkit", "(", ")", "==", "$", "this", "->", "true", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceSymbian", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceS60", ")", ">", "-", "1", ")", "{", "return", "$", "this", "->", "true", ";", "}", "else", "return", "$", "this", "->", "false", ";", "}", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current browser is the Nokia S60 Open Source Browser.
[ "Detects", "if", "the", "current", "browser", "is", "the", "Nokia", "S60", "Open", "Source", "Browser", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L629-L644
32,681
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectSymbianOS
function DetectSymbianOS() { if (stripos($this->useragent, $this->deviceSymbian) > -1 || stripos($this->useragent, $this->deviceS60) > -1 || stripos($this->useragent, $this->deviceS70) > -1 || stripos($this->useragent, $this->deviceS80) > -1 || stripos($this->useragent, $this->deviceS90) > -1) return $this->true; else return $this->false; }
php
function DetectSymbianOS() { if (stripos($this->useragent, $this->deviceSymbian) > -1 || stripos($this->useragent, $this->deviceS60) > -1 || stripos($this->useragent, $this->deviceS70) > -1 || stripos($this->useragent, $this->deviceS80) > -1 || stripos($this->useragent, $this->deviceS90) > -1) return $this->true; else return $this->false; }
[ "function", "DetectSymbianOS", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceSymbian", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceS60", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceS70", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceS80", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceS90", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
or other browsers running on these devices.
[ "or", "other", "browsers", "running", "on", "these", "devices", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L650-L660
32,682
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectPalmOS
function DetectPalmOS() { //Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino. if (stripos($this->useragent, $this->devicePalm) > -1 || stripos($this->useragent, $this->engineBlazer) > -1 || stripos($this->useragent, $this->engineXiino) > -1) { //Make sure it's not WebOS first if ($this->DetectPalmWebOS() == $this->true) return $this->false; else return $this->true; } else return $this->false; }
php
function DetectPalmOS() { //Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino. if (stripos($this->useragent, $this->devicePalm) > -1 || stripos($this->useragent, $this->engineBlazer) > -1 || stripos($this->useragent, $this->engineXiino) > -1) { //Make sure it's not WebOS first if ($this->DetectPalmWebOS() == $this->true) return $this->false; else return $this->true; } else return $this->false; }
[ "function", "DetectPalmOS", "(", ")", "{", "//Most devices nowadays report as 'Palm', but some older ones reported as Blazer or Xiino.\r", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "devicePalm", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "engineBlazer", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "engineXiino", ")", ">", "-", "1", ")", "{", "//Make sure it's not WebOS first\r", "if", "(", "$", "this", "->", "DetectPalmWebOS", "(", ")", "==", "$", "this", "->", "true", ")", "return", "$", "this", "->", "false", ";", "else", "return", "$", "this", "->", "true", ";", "}", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current browser is on a PalmOS device.
[ "Detects", "if", "the", "current", "browser", "is", "on", "a", "PalmOS", "device", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L665-L680
32,683
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectPalmWebOS
function DetectPalmWebOS() { if (stripos($this->useragent, $this->deviceWebOS) > -1) return $this->true; else return $this->false; }
php
function DetectPalmWebOS() { if (stripos($this->useragent, $this->deviceWebOS) > -1) return $this->true; else return $this->false; }
[ "function", "DetectPalmWebOS", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceWebOS", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
running the new WebOS.
[ "running", "the", "new", "WebOS", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L686-L692
32,684
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectWebOSTablet
function DetectWebOSTablet() { if ((stripos($this->useragent, $this->deviceWebOShp) > -1) && (stripos($this->useragent, $this->deviceTablet) > -1)) return $this->true; else return $this->false; }
php
function DetectWebOSTablet() { if ((stripos($this->useragent, $this->deviceWebOShp) > -1) && (stripos($this->useragent, $this->deviceTablet) > -1)) return $this->true; else return $this->false; }
[ "function", "DetectWebOSTablet", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceWebOShp", ")", ">", "-", "1", ")", "&&", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceTablet", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current browser is on an HP tablet running WebOS.
[ "Detects", "if", "the", "current", "browser", "is", "on", "an", "HP", "tablet", "running", "WebOS", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L696-L703
32,685
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectWebOSTV
function DetectWebOSTV() { if ((stripos($this->useragent, $this->deviceWebOStv) > -1) && (stripos($this->useragent, $this->smartTV2) > -1)) return $this->true; else return $this->false; }
php
function DetectWebOSTV() { if ((stripos($this->useragent, $this->deviceWebOStv) > -1) && (stripos($this->useragent, $this->smartTV2) > -1)) return $this->true; else return $this->false; }
[ "function", "DetectWebOSTV", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceWebOStv", ")", ">", "-", "1", ")", "&&", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "smartTV2", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current browser is on a WebOS smart TV.
[ "Detects", "if", "the", "current", "browser", "is", "on", "a", "WebOS", "smart", "TV", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L707-L714
32,686
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectOperaMobile
function DetectOperaMobile() { if ((stripos($this->useragent, $this->engineOpera) > -1) && ((stripos($this->useragent, $this->mini) > -1) || (stripos($this->useragent, $this->mobi) > -1))) return $this->true; return $this->false; }
php
function DetectOperaMobile() { if ((stripos($this->useragent, $this->engineOpera) > -1) && ((stripos($this->useragent, $this->mini) > -1) || (stripos($this->useragent, $this->mobi) > -1))) return $this->true; return $this->false; }
[ "function", "DetectOperaMobile", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "engineOpera", ")", ">", "-", "1", ")", "&&", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "mini", ")", ">", "-", "1", ")", "||", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "mobi", ")", ">", "-", "1", ")", ")", ")", "return", "$", "this", "->", "true", ";", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current browser is Opera Mobile or Mini.
[ "Detects", "if", "the", "current", "browser", "is", "Opera", "Mobile", "or", "Mini", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L719-L727
32,687
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectGarminNuvifone
function DetectGarminNuvifone() { if (stripos($this->useragent, $this->deviceNuvifone) > -1) return $this->true; else return $this->false; }
php
function DetectGarminNuvifone() { if (stripos($this->useragent, $this->deviceNuvifone) > -1) return $this->true; else return $this->false; }
[ "function", "DetectGarminNuvifone", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceNuvifone", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if a Garmin Nuvifone device.
[ "Detects", "if", "a", "Garmin", "Nuvifone", "device", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L754-L760
32,688
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectBada
function DetectBada() { if (stripos($this->useragent, $this->deviceBada) > -1) return $this->true; else return $this->false; }
php
function DetectBada() { if (stripos($this->useragent, $this->deviceBada) > -1) return $this->true; else return $this->false; }
[ "function", "DetectBada", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceBada", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects a device running the Bada OS from Samsung.
[ "Detects", "a", "device", "running", "the", "Bada", "OS", "from", "Samsung", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L764-L770
32,689
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectTizen
function DetectTizen() { if ((stripos($this->useragent, $this->deviceTizen) > -1) && (stripos($this->useragent, $this->mobile) > -1)) return $this->true; else return $this->false; }
php
function DetectTizen() { if ((stripos($this->useragent, $this->deviceTizen) > -1) && (stripos($this->useragent, $this->mobile) > -1)) return $this->true; else return $this->false; }
[ "function", "DetectTizen", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceTizen", ")", ">", "-", "1", ")", "&&", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "mobile", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects a device running the Tizen smartphone OS.
[ "Detects", "a", "device", "running", "the", "Tizen", "smartphone", "OS", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L774-L781
32,690
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectTizenTV
function DetectTizenTV() { if ((stripos($this->useragent, $this->deviceTizen) > -1) && (stripos($this->useragent, $this->smartTV1) > -1)) return $this->true; else return $this->false; }
php
function DetectTizenTV() { if ((stripos($this->useragent, $this->deviceTizen) > -1) && (stripos($this->useragent, $this->smartTV1) > -1)) return $this->true; else return $this->false; }
[ "function", "DetectTizenTV", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceTizen", ")", ">", "-", "1", ")", "&&", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "smartTV1", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current browser is on a Tizen smart TV.
[ "Detects", "if", "the", "current", "browser", "is", "on", "a", "Tizen", "smart", "TV", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L785-L792
32,691
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectMeego
function DetectMeego() { if (stripos($this->useragent, $this->deviceMeego) > -1) return $this->true; else return $this->false; }
php
function DetectMeego() { if (stripos($this->useragent, $this->deviceMeego) > -1) return $this->true; else return $this->false; }
[ "function", "DetectMeego", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceMeego", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects a device running the Meego OS.
[ "Detects", "a", "device", "running", "the", "Meego", "OS", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L796-L802
32,692
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectMeegoPhone
function DetectMeegoPhone() { if ((stripos($this->useragent, $this->deviceMeego) > -1) && (stripos($this->useragent, $this->mobi) > -1)) return $this->true; else return $this->false; }
php
function DetectMeegoPhone() { if ((stripos($this->useragent, $this->deviceMeego) > -1) && (stripos($this->useragent, $this->mobi) > -1)) return $this->true; else return $this->false; }
[ "function", "DetectMeegoPhone", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceMeego", ")", ">", "-", "1", ")", "&&", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "mobi", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects a phone running the Meego OS.
[ "Detects", "a", "phone", "running", "the", "Meego", "OS", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L806-L813
32,693
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectSailfish
function DetectSailfish() { if (stripos($this->useragent, $this->deviceSailfish) > -1) return $this->true; else return $this->false; }
php
function DetectSailfish() { if (stripos($this->useragent, $this->deviceSailfish) > -1) return $this->true; else return $this->false; }
[ "function", "DetectSailfish", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceSailfish", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects a device running the Sailfish OS.
[ "Detects", "a", "device", "running", "the", "Sailfish", "OS", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L862-L868
32,694
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectSailfishPhone
function DetectSailfishPhone() { if (($this->DetectSailfish() == $this->true) && (stripos($this->useragent, $this->mobile) > -1)) return $this->true; return $this->false; }
php
function DetectSailfishPhone() { if (($this->DetectSailfish() == $this->true) && (stripos($this->useragent, $this->mobile) > -1)) return $this->true; return $this->false; }
[ "function", "DetectSailfishPhone", "(", ")", "{", "if", "(", "(", "$", "this", "->", "DetectSailfish", "(", ")", "==", "$", "this", "->", "true", ")", "&&", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "mobile", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "return", "$", "this", "->", "false", ";", "}" ]
Detects a phone running the Sailfish OS.
[ "Detects", "a", "phone", "running", "the", "Sailfish", "OS", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L872-L879
32,695
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectUbuntu
function DetectUbuntu() { if (($this->DetectUbuntuPhone() == $this->true) || ($this->DetectUbuntuTablet() == $this->true)) return $this->true; else return $this->false; }
php
function DetectUbuntu() { if (($this->DetectUbuntuPhone() == $this->true) || ($this->DetectUbuntuTablet() == $this->true)) return $this->true; else return $this->false; }
[ "function", "DetectUbuntu", "(", ")", "{", "if", "(", "(", "$", "this", "->", "DetectUbuntuPhone", "(", ")", "==", "$", "this", "->", "true", ")", "||", "(", "$", "this", "->", "DetectUbuntuTablet", "(", ")", "==", "$", "this", "->", "true", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects a mobile device running the Ubuntu Mobile OS.
[ "Detects", "a", "mobile", "device", "running", "the", "Ubuntu", "Mobile", "OS", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L883-L890
32,696
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectUbuntuPhone
function DetectUbuntuPhone() { if ((stripos($this->useragent, $this->deviceUbuntu) > -1) && (stripos($this->useragent, $this->mobile) > -1)) return $this->true; return $this->false; }
php
function DetectUbuntuPhone() { if ((stripos($this->useragent, $this->deviceUbuntu) > -1) && (stripos($this->useragent, $this->mobile) > -1)) return $this->true; return $this->false; }
[ "function", "DetectUbuntuPhone", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceUbuntu", ")", ">", "-", "1", ")", "&&", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "mobile", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "return", "$", "this", "->", "false", ";", "}" ]
Detects a phone running the Ubuntu Mobile OS.
[ "Detects", "a", "phone", "running", "the", "Ubuntu", "Mobile", "OS", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L894-L901
32,697
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectUbuntuTablet
function DetectUbuntuTablet() { if ((stripos($this->useragent, $this->deviceUbuntu) > -1) && (stripos($this->useragent, $this->deviceTablet) > -1)) return $this->true; return $this->false; }
php
function DetectUbuntuTablet() { if ((stripos($this->useragent, $this->deviceUbuntu) > -1) && (stripos($this->useragent, $this->deviceTablet) > -1)) return $this->true; return $this->false; }
[ "function", "DetectUbuntuTablet", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceUbuntu", ")", ">", "-", "1", ")", "&&", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceTablet", ")", ">", "-", "1", ")", ")", "return", "$", "this", "->", "true", ";", "return", "$", "this", "->", "false", ";", "}" ]
Detects a tablet running the Ubuntu Mobile OS.
[ "Detects", "a", "tablet", "running", "the", "Ubuntu", "Mobile", "OS", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L905-L912
32,698
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectDangerHiptop
function DetectDangerHiptop() { if (stripos($this->useragent, $this->deviceDanger) > -1 || stripos($this->useragent, $this->deviceHiptop) > -1) return $this->true; else return $this->false; }
php
function DetectDangerHiptop() { if (stripos($this->useragent, $this->deviceDanger) > -1 || stripos($this->useragent, $this->deviceHiptop) > -1) return $this->true; else return $this->false; }
[ "function", "DetectDangerHiptop", "(", ")", "{", "if", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceDanger", ")", ">", "-", "1", "||", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "deviceHiptop", ")", ">", "-", "1", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects the Danger Hiptop device.
[ "Detects", "the", "Danger", "Hiptop", "device", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L916-L923
32,699
ahand/mobileesp
PHP/mdetect.php
uagent_info.DetectSonyMylo
function DetectSonyMylo() { if ((stripos($this->useragent, $this->manuSony) > -1) && ((stripos($this->useragent, $this->qtembedded) > -1) || (stripos($this->useragent, $this->mylocom2) > -1))) return $this->true; else return $this->false; }
php
function DetectSonyMylo() { if ((stripos($this->useragent, $this->manuSony) > -1) && ((stripos($this->useragent, $this->qtembedded) > -1) || (stripos($this->useragent, $this->mylocom2) > -1))) return $this->true; else return $this->false; }
[ "function", "DetectSonyMylo", "(", ")", "{", "if", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "manuSony", ")", ">", "-", "1", ")", "&&", "(", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "qtembedded", ")", ">", "-", "1", ")", "||", "(", "stripos", "(", "$", "this", "->", "useragent", ",", "$", "this", "->", "mylocom2", ")", ">", "-", "1", ")", ")", ")", "return", "$", "this", "->", "true", ";", "else", "return", "$", "this", "->", "false", ";", "}" ]
Detects if the current browser is a Sony Mylo device.
[ "Detects", "if", "the", "current", "browser", "is", "a", "Sony", "Mylo", "device", "." ]
c02055dbe9baee63aab11438f4d7b5d25075d347
https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L927-L935