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
34,700
nepttune/nepttune
src/Model/PushNotificationModel.php
PushNotificationModel.sendByType
public function sendByType(int $typeId, string $msg, ?string $dest = null, bool $flush = false) : void { $msg = $this->composeMsg($msg, $dest); $subscriptions = $this->subscriptionTable->findAll() ->where('subscription.active', 1) ->where('user.active', 1) ->where('user:user_subscription_type.subscription_type_id', $typeId); foreach ($subscriptions as $row) { $this->sendNotification($row, $msg, false); } if ($flush) { $this->flush(); } }
php
public function sendByType(int $typeId, string $msg, ?string $dest = null, bool $flush = false) : void { $msg = $this->composeMsg($msg, $dest); $subscriptions = $this->subscriptionTable->findAll() ->where('subscription.active', 1) ->where('user.active', 1) ->where('user:user_subscription_type.subscription_type_id', $typeId); foreach ($subscriptions as $row) { $this->sendNotification($row, $msg, false); } if ($flush) { $this->flush(); } }
[ "public", "function", "sendByType", "(", "int", "$", "typeId", ",", "string", "$", "msg", ",", "?", "string", "$", "dest", "=", "null", ",", "bool", "$", "flush", "=", "false", ")", ":", "void", "{", "$", "msg", "=", "$", "this", "->", "composeMsg", "(", "$", "msg", ",", "$", "dest", ")", ";", "$", "subscriptions", "=", "$", "this", "->", "subscriptionTable", "->", "findAll", "(", ")", "->", "where", "(", "'subscription.active'", ",", "1", ")", "->", "where", "(", "'user.active'", ",", "1", ")", "->", "where", "(", "'user:user_subscription_type.subscription_type_id'", ",", "$", "typeId", ")", ";", "foreach", "(", "$", "subscriptions", "as", "$", "row", ")", "{", "$", "this", "->", "sendNotification", "(", "$", "row", ",", "$", "msg", ",", "false", ")", ";", "}", "if", "(", "$", "flush", ")", "{", "$", "this", "->", "flush", "(", ")", ";", "}", "}" ]
Send notification to all users subscribed to specific type. @param int $typeId @param string $msg @param string $dest @param bool $flush
[ "Send", "notification", "to", "all", "users", "subscribed", "to", "specific", "type", "." ]
63b41f62e0589a0ebac698abd1b8cf65abfcb1d5
https://github.com/nepttune/nepttune/blob/63b41f62e0589a0ebac698abd1b8cf65abfcb1d5/src/Model/PushNotificationModel.php#L103-L121
34,701
nepttune/nepttune
src/Model/PushNotificationModel.php
PushNotificationModel.saveSubscription
public function saveSubscription(int $userId = null) : void { $json = \file_get_contents('php://input'); if (!$json) { return; } $data = \json_decode($json, true); if (!$data || empty($data['endpoint']) || empty($data['publicKey']) || empty($data['authToken'])) { return; } $row = $this->subscriptionTable->findActive()->where('endpoint', $data['endpoint'])->fetch(); switch ($this->request->getMethod()) { case 'POST': case 'PUT': { if ($row) { $row->update([ 'user_id' => $userId ?: $row->user_id ?: null, 'key' => $data['publicKey'], 'token' => $data['authToken'], 'encoding' => $data['contentEncoding'] ]); return; } $row = $this->subscriptionTable->insert([ 'user_id' => $userId, 'endpoint' => $data['endpoint'], 'key' => $data['publicKey'], 'token' => $data['authToken'], 'encoding' => $data['contentEncoding'] ]); $this->sendNotification($row, 'Notifications enabled!', true); return; } case 'DELETE': { if ($row) { $row->update([ 'active' => 0 ]); } return; } default: throw new \Nette\Application\BadRequestException(); } }
php
public function saveSubscription(int $userId = null) : void { $json = \file_get_contents('php://input'); if (!$json) { return; } $data = \json_decode($json, true); if (!$data || empty($data['endpoint']) || empty($data['publicKey']) || empty($data['authToken'])) { return; } $row = $this->subscriptionTable->findActive()->where('endpoint', $data['endpoint'])->fetch(); switch ($this->request->getMethod()) { case 'POST': case 'PUT': { if ($row) { $row->update([ 'user_id' => $userId ?: $row->user_id ?: null, 'key' => $data['publicKey'], 'token' => $data['authToken'], 'encoding' => $data['contentEncoding'] ]); return; } $row = $this->subscriptionTable->insert([ 'user_id' => $userId, 'endpoint' => $data['endpoint'], 'key' => $data['publicKey'], 'token' => $data['authToken'], 'encoding' => $data['contentEncoding'] ]); $this->sendNotification($row, 'Notifications enabled!', true); return; } case 'DELETE': { if ($row) { $row->update([ 'active' => 0 ]); } return; } default: throw new \Nette\Application\BadRequestException(); } }
[ "public", "function", "saveSubscription", "(", "int", "$", "userId", "=", "null", ")", ":", "void", "{", "$", "json", "=", "\\", "file_get_contents", "(", "'php://input'", ")", ";", "if", "(", "!", "$", "json", ")", "{", "return", ";", "}", "$", "data", "=", "\\", "json_decode", "(", "$", "json", ",", "true", ")", ";", "if", "(", "!", "$", "data", "||", "empty", "(", "$", "data", "[", "'endpoint'", "]", ")", "||", "empty", "(", "$", "data", "[", "'publicKey'", "]", ")", "||", "empty", "(", "$", "data", "[", "'authToken'", "]", ")", ")", "{", "return", ";", "}", "$", "row", "=", "$", "this", "->", "subscriptionTable", "->", "findActive", "(", ")", "->", "where", "(", "'endpoint'", ",", "$", "data", "[", "'endpoint'", "]", ")", "->", "fetch", "(", ")", ";", "switch", "(", "$", "this", "->", "request", "->", "getMethod", "(", ")", ")", "{", "case", "'POST'", ":", "case", "'PUT'", ":", "{", "if", "(", "$", "row", ")", "{", "$", "row", "->", "update", "(", "[", "'user_id'", "=>", "$", "userId", "?", ":", "$", "row", "->", "user_id", "?", ":", "null", ",", "'key'", "=>", "$", "data", "[", "'publicKey'", "]", ",", "'token'", "=>", "$", "data", "[", "'authToken'", "]", ",", "'encoding'", "=>", "$", "data", "[", "'contentEncoding'", "]", "]", ")", ";", "return", ";", "}", "$", "row", "=", "$", "this", "->", "subscriptionTable", "->", "insert", "(", "[", "'user_id'", "=>", "$", "userId", ",", "'endpoint'", "=>", "$", "data", "[", "'endpoint'", "]", ",", "'key'", "=>", "$", "data", "[", "'publicKey'", "]", ",", "'token'", "=>", "$", "data", "[", "'authToken'", "]", ",", "'encoding'", "=>", "$", "data", "[", "'contentEncoding'", "]", "]", ")", ";", "$", "this", "->", "sendNotification", "(", "$", "row", ",", "'Notifications enabled!'", ",", "true", ")", ";", "return", ";", "}", "case", "'DELETE'", ":", "{", "if", "(", "$", "row", ")", "{", "$", "row", "->", "update", "(", "[", "'active'", "=>", "0", "]", ")", ";", "}", "return", ";", "}", "default", ":", "throw", "new", "\\", "Nette", "\\", "Application", "\\", "BadRequestException", "(", ")", ";", "}", "}" ]
Save or update subscriber information. @throws \Nette\Application\BadRequestException @param int $userId
[ "Save", "or", "update", "subscriber", "information", "." ]
63b41f62e0589a0ebac698abd1b8cf65abfcb1d5
https://github.com/nepttune/nepttune/blob/63b41f62e0589a0ebac698abd1b8cf65abfcb1d5/src/Model/PushNotificationModel.php#L128-L188
34,702
voslartomas/WebCMS2
AdminModule/presenters/LanguagesPresenter.php
LanguagesPresenter.actionExportLanguage
public function actionExportLanguage($id) { $language = $this->em->find("WebCMS\Entity\Language", $id); $export = array( 'name' => $language->getName(), 'abbr' => $language->getAbbr(), 'translations' => array(), ); foreach ($language->getTranslations() as $translation) { if ($translation->getBackend()) { $export['translations'][] = array( 'key' => $translation->getKey(), 'translation' => $translation->getTranslation(), 'backend' => $translation->getBackend(), ); } } $export = json_encode($export); $filename = $language->getAbbr().'.json'; $response = $this->getHttpResponse(); $response->setHeader('Content-Description', 'File Transfer'); $response->setContentType('text/plain', 'UTF-8'); $response->setHeader('Content-Disposition', 'attachment; filename='.$filename); $response->setHeader('Content-Transfer-Encoding', 'binary'); $response->setHeader('Expires', 0); $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0'); $response->setHeader('Pragma', 'public'); $response->setHeader('Content-Length', strlen($export)); ob_clean(); flush(); echo $export; $this->terminate(); }
php
public function actionExportLanguage($id) { $language = $this->em->find("WebCMS\Entity\Language", $id); $export = array( 'name' => $language->getName(), 'abbr' => $language->getAbbr(), 'translations' => array(), ); foreach ($language->getTranslations() as $translation) { if ($translation->getBackend()) { $export['translations'][] = array( 'key' => $translation->getKey(), 'translation' => $translation->getTranslation(), 'backend' => $translation->getBackend(), ); } } $export = json_encode($export); $filename = $language->getAbbr().'.json'; $response = $this->getHttpResponse(); $response->setHeader('Content-Description', 'File Transfer'); $response->setContentType('text/plain', 'UTF-8'); $response->setHeader('Content-Disposition', 'attachment; filename='.$filename); $response->setHeader('Content-Transfer-Encoding', 'binary'); $response->setHeader('Expires', 0); $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0'); $response->setHeader('Pragma', 'public'); $response->setHeader('Content-Length', strlen($export)); ob_clean(); flush(); echo $export; $this->terminate(); }
[ "public", "function", "actionExportLanguage", "(", "$", "id", ")", "{", "$", "language", "=", "$", "this", "->", "em", "->", "find", "(", "\"WebCMS\\Entity\\Language\"", ",", "$", "id", ")", ";", "$", "export", "=", "array", "(", "'name'", "=>", "$", "language", "->", "getName", "(", ")", ",", "'abbr'", "=>", "$", "language", "->", "getAbbr", "(", ")", ",", "'translations'", "=>", "array", "(", ")", ",", ")", ";", "foreach", "(", "$", "language", "->", "getTranslations", "(", ")", "as", "$", "translation", ")", "{", "if", "(", "$", "translation", "->", "getBackend", "(", ")", ")", "{", "$", "export", "[", "'translations'", "]", "[", "]", "=", "array", "(", "'key'", "=>", "$", "translation", "->", "getKey", "(", ")", ",", "'translation'", "=>", "$", "translation", "->", "getTranslation", "(", ")", ",", "'backend'", "=>", "$", "translation", "->", "getBackend", "(", ")", ",", ")", ";", "}", "}", "$", "export", "=", "json_encode", "(", "$", "export", ")", ";", "$", "filename", "=", "$", "language", "->", "getAbbr", "(", ")", ".", "'.json'", ";", "$", "response", "=", "$", "this", "->", "getHttpResponse", "(", ")", ";", "$", "response", "->", "setHeader", "(", "'Content-Description'", ",", "'File Transfer'", ")", ";", "$", "response", "->", "setContentType", "(", "'text/plain'", ",", "'UTF-8'", ")", ";", "$", "response", "->", "setHeader", "(", "'Content-Disposition'", ",", "'attachment; filename='", ".", "$", "filename", ")", ";", "$", "response", "->", "setHeader", "(", "'Content-Transfer-Encoding'", ",", "'binary'", ")", ";", "$", "response", "->", "setHeader", "(", "'Expires'", ",", "0", ")", ";", "$", "response", "->", "setHeader", "(", "'Cache-Control'", ",", "'must-revalidate, post-check=0, pre-check=0'", ")", ";", "$", "response", "->", "setHeader", "(", "'Pragma'", ",", "'public'", ")", ";", "$", "response", "->", "setHeader", "(", "'Content-Length'", ",", "strlen", "(", "$", "export", ")", ")", ";", "ob_clean", "(", ")", ";", "flush", "(", ")", ";", "echo", "$", "export", ";", "$", "this", "->", "terminate", "(", ")", ";", "}" ]
Export language into JSON file and terminate response for download it. @param Int $id
[ "Export", "language", "into", "JSON", "file", "and", "terminate", "response", "for", "download", "it", "." ]
b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf
https://github.com/voslartomas/WebCMS2/blob/b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf/AdminModule/presenters/LanguagesPresenter.php#L142-L180
34,703
CESNET/perun-simplesamlphp-module
lib/DatabaseConnector.php
DatabaseConnector.getConnection
public function getConnection() { $conn = mysqli_init(); if ($this->encryption === true) { Logger::debug("Getting connection with encryption."); mysqli_ssl_set($conn, $this->sslKey, $this->sslCert, $this->sslCA, $this->sslCAPath, null); if ($this->port === null) { mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName); } else { mysqli_real_connect( $conn, $this->serverName, $this->username, $this->password, $this->databaseName, $this->port ); } } elseif ($this->port === null) { mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName); } else { mysqli_real_connect( $conn, $this->serverName, $this->username, $this->password, $this->databaseName, $this->port ); } return $conn; }
php
public function getConnection() { $conn = mysqli_init(); if ($this->encryption === true) { Logger::debug("Getting connection with encryption."); mysqli_ssl_set($conn, $this->sslKey, $this->sslCert, $this->sslCA, $this->sslCAPath, null); if ($this->port === null) { mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName); } else { mysqli_real_connect( $conn, $this->serverName, $this->username, $this->password, $this->databaseName, $this->port ); } } elseif ($this->port === null) { mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName); } else { mysqli_real_connect( $conn, $this->serverName, $this->username, $this->password, $this->databaseName, $this->port ); } return $conn; }
[ "public", "function", "getConnection", "(", ")", "{", "$", "conn", "=", "mysqli_init", "(", ")", ";", "if", "(", "$", "this", "->", "encryption", "===", "true", ")", "{", "Logger", "::", "debug", "(", "\"Getting connection with encryption.\"", ")", ";", "mysqli_ssl_set", "(", "$", "conn", ",", "$", "this", "->", "sslKey", ",", "$", "this", "->", "sslCert", ",", "$", "this", "->", "sslCA", ",", "$", "this", "->", "sslCAPath", ",", "null", ")", ";", "if", "(", "$", "this", "->", "port", "===", "null", ")", "{", "mysqli_real_connect", "(", "$", "conn", ",", "$", "this", "->", "serverName", ",", "$", "this", "->", "username", ",", "$", "this", "->", "password", ",", "$", "this", "->", "databaseName", ")", ";", "}", "else", "{", "mysqli_real_connect", "(", "$", "conn", ",", "$", "this", "->", "serverName", ",", "$", "this", "->", "username", ",", "$", "this", "->", "password", ",", "$", "this", "->", "databaseName", ",", "$", "this", "->", "port", ")", ";", "}", "}", "elseif", "(", "$", "this", "->", "port", "===", "null", ")", "{", "mysqli_real_connect", "(", "$", "conn", ",", "$", "this", "->", "serverName", ",", "$", "this", "->", "username", ",", "$", "this", "->", "password", ",", "$", "this", "->", "databaseName", ")", ";", "}", "else", "{", "mysqli_real_connect", "(", "$", "conn", ",", "$", "this", "->", "serverName", ",", "$", "this", "->", "username", ",", "$", "this", "->", "password", ",", "$", "this", "->", "databaseName", ",", "$", "this", "->", "port", ")", ";", "}", "return", "$", "conn", ";", "}" ]
Function returns the connection to db @return mysqli connection
[ "Function", "returns", "the", "connection", "to", "db" ]
f1d686f06472053a7cdb31f2b2776f9714779ee1
https://github.com/CESNET/perun-simplesamlphp-module/blob/f1d686f06472053a7cdb31f2b2776f9714779ee1/lib/DatabaseConnector.php#L63-L94
34,704
MetaModels/filter_range
src/FilterSetting/AbstractRange.php
AbstractRange.getReferencedAttributes
public function getReferencedAttributes() { $objMetaModel = $this->getMetaModel(); $objAttribute = $objMetaModel->getAttributeById($this->get('attr_id')); $objAttribute2 = $objMetaModel->getAttributeById($this->get('attr_id2')); $arrResult = []; if ($objAttribute) { $arrResult[] = $objAttribute->getColName(); } if ($objAttribute2) { $arrResult[] = $objAttribute2->getColName(); } return $arrResult; }
php
public function getReferencedAttributes() { $objMetaModel = $this->getMetaModel(); $objAttribute = $objMetaModel->getAttributeById($this->get('attr_id')); $objAttribute2 = $objMetaModel->getAttributeById($this->get('attr_id2')); $arrResult = []; if ($objAttribute) { $arrResult[] = $objAttribute->getColName(); } if ($objAttribute2) { $arrResult[] = $objAttribute2->getColName(); } return $arrResult; }
[ "public", "function", "getReferencedAttributes", "(", ")", "{", "$", "objMetaModel", "=", "$", "this", "->", "getMetaModel", "(", ")", ";", "$", "objAttribute", "=", "$", "objMetaModel", "->", "getAttributeById", "(", "$", "this", "->", "get", "(", "'attr_id'", ")", ")", ";", "$", "objAttribute2", "=", "$", "objMetaModel", "->", "getAttributeById", "(", "$", "this", "->", "get", "(", "'attr_id2'", ")", ")", ";", "$", "arrResult", "=", "[", "]", ";", "if", "(", "$", "objAttribute", ")", "{", "$", "arrResult", "[", "]", "=", "$", "objAttribute", "->", "getColName", "(", ")", ";", "}", "if", "(", "$", "objAttribute2", ")", "{", "$", "arrResult", "[", "]", "=", "$", "objAttribute2", "->", "getColName", "(", ")", ";", "}", "return", "$", "arrResult", ";", "}" ]
Retrieve the attributes that are referenced in this filter setting. @return array
[ "Retrieve", "the", "attributes", "that", "are", "referenced", "in", "this", "filter", "setting", "." ]
1875e4a2206df2c5c98f5b0a7f18feb17b34f393
https://github.com/MetaModels/filter_range/blob/1875e4a2206df2c5c98f5b0a7f18feb17b34f393/src/FilterSetting/AbstractRange.php#L102-L118
34,705
MetaModels/filter_range
src/FilterSetting/AbstractRange.php
AbstractRange.getFilterWidgetParameters
protected function getFilterWidgetParameters(IAttribute $attribute, $currentValue, $ids) { return [ 'label' => $this->prepareWidgetLabel($attribute), 'inputType' => 'multitext', 'options' => $this->prepareWidgetOptions($ids, $attribute), 'timetype' => $this->get('timetype'), 'dateformat' => $this->get('dateformat'), 'eval' => [ 'multiple' => true, 'size' => $this->get('fromfield') && $this->get('tofield') ? 2 : 1, 'urlparam' => $this->getParamName(), 'template' => $this->get('template'), 'colname' => $attribute->getColName(), ], // We need to implode to have it transported correctly in the frontend filter. 'urlvalue' => !empty($currentValue) ? implode(',', $currentValue) : '' ]; }
php
protected function getFilterWidgetParameters(IAttribute $attribute, $currentValue, $ids) { return [ 'label' => $this->prepareWidgetLabel($attribute), 'inputType' => 'multitext', 'options' => $this->prepareWidgetOptions($ids, $attribute), 'timetype' => $this->get('timetype'), 'dateformat' => $this->get('dateformat'), 'eval' => [ 'multiple' => true, 'size' => $this->get('fromfield') && $this->get('tofield') ? 2 : 1, 'urlparam' => $this->getParamName(), 'template' => $this->get('template'), 'colname' => $attribute->getColName(), ], // We need to implode to have it transported correctly in the frontend filter. 'urlvalue' => !empty($currentValue) ? implode(',', $currentValue) : '' ]; }
[ "protected", "function", "getFilterWidgetParameters", "(", "IAttribute", "$", "attribute", ",", "$", "currentValue", ",", "$", "ids", ")", "{", "return", "[", "'label'", "=>", "$", "this", "->", "prepareWidgetLabel", "(", "$", "attribute", ")", ",", "'inputType'", "=>", "'multitext'", ",", "'options'", "=>", "$", "this", "->", "prepareWidgetOptions", "(", "$", "ids", ",", "$", "attribute", ")", ",", "'timetype'", "=>", "$", "this", "->", "get", "(", "'timetype'", ")", ",", "'dateformat'", "=>", "$", "this", "->", "get", "(", "'dateformat'", ")", ",", "'eval'", "=>", "[", "'multiple'", "=>", "true", ",", "'size'", "=>", "$", "this", "->", "get", "(", "'fromfield'", ")", "&&", "$", "this", "->", "get", "(", "'tofield'", ")", "?", "2", ":", "1", ",", "'urlparam'", "=>", "$", "this", "->", "getParamName", "(", ")", ",", "'template'", "=>", "$", "this", "->", "get", "(", "'template'", ")", ",", "'colname'", "=>", "$", "attribute", "->", "getColName", "(", ")", ",", "]", ",", "// We need to implode to have it transported correctly in the frontend filter.", "'urlvalue'", "=>", "!", "empty", "(", "$", "currentValue", ")", "?", "implode", "(", "','", ",", "$", "currentValue", ")", ":", "''", "]", ";", "}" ]
Get the parameter array for configuring the widget. @param IAttribute $attribute The attribute. @param array $currentValue The current value. @param string[] $ids The list of ids. @return array
[ "Get", "the", "parameter", "array", "for", "configuring", "the", "widget", "." ]
1875e4a2206df2c5c98f5b0a7f18feb17b34f393
https://github.com/MetaModels/filter_range/blob/1875e4a2206df2c5c98f5b0a7f18feb17b34f393/src/FilterSetting/AbstractRange.php#L263-L281
34,706
Rareloop/primer-core
src/Primer/Renderable/Group.php
Group.loadPatternsInPath
public static function loadPatternsInPath($path) { $groups = array(); if ($handle = opendir($path)) { while (false !== ($entry = readdir($handle))) { $fullPath = $path . '/' . $entry; if (substr($entry, 0, 1) !== '.') { $id = trim(str_replace(Primer::$PATTERN_PATH, '', $fullPath), '/'); // Load the pattern $groups[] = new Group($id); } } closedir($handle); } return $groups; }
php
public static function loadPatternsInPath($path) { $groups = array(); if ($handle = opendir($path)) { while (false !== ($entry = readdir($handle))) { $fullPath = $path . '/' . $entry; if (substr($entry, 0, 1) !== '.') { $id = trim(str_replace(Primer::$PATTERN_PATH, '', $fullPath), '/'); // Load the pattern $groups[] = new Group($id); } } closedir($handle); } return $groups; }
[ "public", "static", "function", "loadPatternsInPath", "(", "$", "path", ")", "{", "$", "groups", "=", "array", "(", ")", ";", "if", "(", "$", "handle", "=", "opendir", "(", "$", "path", ")", ")", "{", "while", "(", "false", "!==", "(", "$", "entry", "=", "readdir", "(", "$", "handle", ")", ")", ")", "{", "$", "fullPath", "=", "$", "path", ".", "'/'", ".", "$", "entry", ";", "if", "(", "substr", "(", "$", "entry", ",", "0", ",", "1", ")", "!==", "'.'", ")", "{", "$", "id", "=", "trim", "(", "str_replace", "(", "Primer", "::", "$", "PATTERN_PATH", ",", "''", ",", "$", "fullPath", ")", ",", "'/'", ")", ";", "// Load the pattern", "$", "groups", "[", "]", "=", "new", "Group", "(", "$", "id", ")", ";", "}", "}", "closedir", "(", "$", "handle", ")", ";", "}", "return", "$", "groups", ";", "}" ]
Helper function to load all groups in a folder @param String $path The path of the directory to load from @return Array Array of all groups loaded
[ "Helper", "function", "to", "load", "all", "groups", "in", "a", "folder" ]
fe098d6794a4add368f97672397dc93d223a1786
https://github.com/Rareloop/primer-core/blob/fe098d6794a4add368f97672397dc93d223a1786/src/Primer/Renderable/Group.php#L93-L116
34,707
c4studio/chronos
src/Chronos/Scaffolding/ScaffoldingServiceProvider.php
ScaffoldingServiceProvider.registerGates
protected function registerGates($gate) { if (class_exists('Chronos\Scaffolding\Models\Permission') && Schema::hasTable('roles')) { $permissions = \Chronos\Scaffolding\Models\Permission::all(); foreach ($permissions as $permission) { $gate->define($permission->name, function ($user) use ($permission) { return $user->hasPermission($permission->name); }); } } }
php
protected function registerGates($gate) { if (class_exists('Chronos\Scaffolding\Models\Permission') && Schema::hasTable('roles')) { $permissions = \Chronos\Scaffolding\Models\Permission::all(); foreach ($permissions as $permission) { $gate->define($permission->name, function ($user) use ($permission) { return $user->hasPermission($permission->name); }); } } }
[ "protected", "function", "registerGates", "(", "$", "gate", ")", "{", "if", "(", "class_exists", "(", "'Chronos\\Scaffolding\\Models\\Permission'", ")", "&&", "Schema", "::", "hasTable", "(", "'roles'", ")", ")", "{", "$", "permissions", "=", "\\", "Chronos", "\\", "Scaffolding", "\\", "Models", "\\", "Permission", "::", "all", "(", ")", ";", "foreach", "(", "$", "permissions", "as", "$", "permission", ")", "{", "$", "gate", "->", "define", "(", "$", "permission", "->", "name", ",", "function", "(", "$", "user", ")", "use", "(", "$", "permission", ")", "{", "return", "$", "user", "->", "hasPermission", "(", "$", "permission", "->", "name", ")", ";", "}", ")", ";", "}", "}", "}" ]
Register gates.
[ "Register", "gates", "." ]
df7f3a9794afaade3bee8f6be1223c98e4936cb2
https://github.com/c4studio/chronos/blob/df7f3a9794afaade3bee8f6be1223c98e4936cb2/src/Chronos/Scaffolding/ScaffoldingServiceProvider.php#L93-L103
34,708
c4studio/chronos
src/Chronos/Scaffolding/ScaffoldingServiceProvider.php
ScaffoldingServiceProvider.registerMenu
protected function registerMenu() { \Menu::make('ChronosMenu', function($menu) { // $menu->add(trans('chronos.scaffolding::menu.Dashboard'), ['route' => 'chronos.dashboard']) // ->prepend('<span class="icon c4icon-dashboard"></span>') // ->data('order', 1)->data('permissions', ['view_dashboard']); // Users tab $users_menu = $menu->add(trans('chronos.scaffolding::menu.Users'), null) ->prepend('<span class="icon c4icon-user-3"></span>') ->data('order', 800)->data('permissions', ['view_roles', 'edit_permissions']); $users_menu->add(trans('chronos.scaffolding::menu.Roles'), ['route' => 'chronos.users.roles']) ->data('order', 810)->data('permissions', ['view_roles']); $users_menu->add(trans('chronos.scaffolding::menu.Permissions'), ['route' => 'chronos.users.permissions']) ->data('order', 820)->data('permissions', ['edit_permissions']); // Settings tab $settings_menu = $menu->add(trans('chronos.scaffolding::menu.Settings'), null) ->prepend('<span class="icon c4icon-sliders-1"></span>') ->data('order', 900)->data('permissions', ['edit_settings', 'edit_access_tokens', 'edit_image_styles']); $settings_menu->add(trans('chronos.scaffolding::menu.Access tokens'), ['route' => 'chronos.settings.access_tokens']) ->data('order', 910)->data('permissions', ['edit_access_tokens']); $settings_menu->add(trans('chronos.scaffolding::menu.Image styles'), ['route' => 'chronos.settings.image_styles']) ->data('order', 910)->data('permissions', ['view_image_styles']); }); \View::composer('*', function($view) { $view->with('chronos_menu', \Menu::get('ChronosMenu')->sortBy('order')); }); }
php
protected function registerMenu() { \Menu::make('ChronosMenu', function($menu) { // $menu->add(trans('chronos.scaffolding::menu.Dashboard'), ['route' => 'chronos.dashboard']) // ->prepend('<span class="icon c4icon-dashboard"></span>') // ->data('order', 1)->data('permissions', ['view_dashboard']); // Users tab $users_menu = $menu->add(trans('chronos.scaffolding::menu.Users'), null) ->prepend('<span class="icon c4icon-user-3"></span>') ->data('order', 800)->data('permissions', ['view_roles', 'edit_permissions']); $users_menu->add(trans('chronos.scaffolding::menu.Roles'), ['route' => 'chronos.users.roles']) ->data('order', 810)->data('permissions', ['view_roles']); $users_menu->add(trans('chronos.scaffolding::menu.Permissions'), ['route' => 'chronos.users.permissions']) ->data('order', 820)->data('permissions', ['edit_permissions']); // Settings tab $settings_menu = $menu->add(trans('chronos.scaffolding::menu.Settings'), null) ->prepend('<span class="icon c4icon-sliders-1"></span>') ->data('order', 900)->data('permissions', ['edit_settings', 'edit_access_tokens', 'edit_image_styles']); $settings_menu->add(trans('chronos.scaffolding::menu.Access tokens'), ['route' => 'chronos.settings.access_tokens']) ->data('order', 910)->data('permissions', ['edit_access_tokens']); $settings_menu->add(trans('chronos.scaffolding::menu.Image styles'), ['route' => 'chronos.settings.image_styles']) ->data('order', 910)->data('permissions', ['view_image_styles']); }); \View::composer('*', function($view) { $view->with('chronos_menu', \Menu::get('ChronosMenu')->sortBy('order')); }); }
[ "protected", "function", "registerMenu", "(", ")", "{", "\\", "Menu", "::", "make", "(", "'ChronosMenu'", ",", "function", "(", "$", "menu", ")", "{", "// $menu->add(trans('chronos.scaffolding::menu.Dashboard'), ['route' => 'chronos.dashboard'])", "// ->prepend('<span class=\"icon c4icon-dashboard\"></span>')", "// ->data('order', 1)->data('permissions', ['view_dashboard']);", "// Users tab", "$", "users_menu", "=", "$", "menu", "->", "add", "(", "trans", "(", "'chronos.scaffolding::menu.Users'", ")", ",", "null", ")", "->", "prepend", "(", "'<span class=\"icon c4icon-user-3\"></span>'", ")", "->", "data", "(", "'order'", ",", "800", ")", "->", "data", "(", "'permissions'", ",", "[", "'view_roles'", ",", "'edit_permissions'", "]", ")", ";", "$", "users_menu", "->", "add", "(", "trans", "(", "'chronos.scaffolding::menu.Roles'", ")", ",", "[", "'route'", "=>", "'chronos.users.roles'", "]", ")", "->", "data", "(", "'order'", ",", "810", ")", "->", "data", "(", "'permissions'", ",", "[", "'view_roles'", "]", ")", ";", "$", "users_menu", "->", "add", "(", "trans", "(", "'chronos.scaffolding::menu.Permissions'", ")", ",", "[", "'route'", "=>", "'chronos.users.permissions'", "]", ")", "->", "data", "(", "'order'", ",", "820", ")", "->", "data", "(", "'permissions'", ",", "[", "'edit_permissions'", "]", ")", ";", "// Settings tab", "$", "settings_menu", "=", "$", "menu", "->", "add", "(", "trans", "(", "'chronos.scaffolding::menu.Settings'", ")", ",", "null", ")", "->", "prepend", "(", "'<span class=\"icon c4icon-sliders-1\"></span>'", ")", "->", "data", "(", "'order'", ",", "900", ")", "->", "data", "(", "'permissions'", ",", "[", "'edit_settings'", ",", "'edit_access_tokens'", ",", "'edit_image_styles'", "]", ")", ";", "$", "settings_menu", "->", "add", "(", "trans", "(", "'chronos.scaffolding::menu.Access tokens'", ")", ",", "[", "'route'", "=>", "'chronos.settings.access_tokens'", "]", ")", "->", "data", "(", "'order'", ",", "910", ")", "->", "data", "(", "'permissions'", ",", "[", "'edit_access_tokens'", "]", ")", ";", "$", "settings_menu", "->", "add", "(", "trans", "(", "'chronos.scaffolding::menu.Image styles'", ")", ",", "[", "'route'", "=>", "'chronos.settings.image_styles'", "]", ")", "->", "data", "(", "'order'", ",", "910", ")", "->", "data", "(", "'permissions'", ",", "[", "'view_image_styles'", "]", ")", ";", "}", ")", ";", "\\", "View", "::", "composer", "(", "'*'", ",", "function", "(", "$", "view", ")", "{", "$", "view", "->", "with", "(", "'chronos_menu'", ",", "\\", "Menu", "::", "get", "(", "'ChronosMenu'", ")", "->", "sortBy", "(", "'order'", ")", ")", ";", "}", ")", ";", "}" ]
Register menu and share it with all views.
[ "Register", "menu", "and", "share", "it", "with", "all", "views", "." ]
df7f3a9794afaade3bee8f6be1223c98e4936cb2
https://github.com/c4studio/chronos/blob/df7f3a9794afaade3bee8f6be1223c98e4936cb2/src/Chronos/Scaffolding/ScaffoldingServiceProvider.php#L108-L138
34,709
voslartomas/WebCMS2
libs/translation/Translator.php
Translator.translate
public function translate($message, $parameters = array()) { if (count($parameters) === 0) { return $this->translations[$message]; } else { return vsprintf($this->translations[$message], $parameters); } }
php
public function translate($message, $parameters = array()) { if (count($parameters) === 0) { return $this->translations[$message]; } else { return vsprintf($this->translations[$message], $parameters); } }
[ "public", "function", "translate", "(", "$", "message", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "if", "(", "count", "(", "$", "parameters", ")", "===", "0", ")", "{", "return", "$", "this", "->", "translations", "[", "$", "message", "]", ";", "}", "else", "{", "return", "vsprintf", "(", "$", "this", "->", "translations", "[", "$", "message", "]", ",", "$", "parameters", ")", ";", "}", "}" ]
Translates given message. @param type $message @param type $parameters
[ "Translates", "given", "message", "." ]
b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf
https://github.com/voslartomas/WebCMS2/blob/b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf/libs/translation/Translator.php#L26-L33
34,710
c4studio/chronos
src/Chronos/Scaffolding/app/Services/RouteMapService.php
RouteMapService.add
public static function add($action, $type, $id = null) { if (!is_null($id)) self::$modelMap[$type][$id] = $action; else self::$typeMap[$type] = $action; }
php
public static function add($action, $type, $id = null) { if (!is_null($id)) self::$modelMap[$type][$id] = $action; else self::$typeMap[$type] = $action; }
[ "public", "static", "function", "add", "(", "$", "action", ",", "$", "type", ",", "$", "id", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "id", ")", ")", "self", "::", "$", "modelMap", "[", "$", "type", "]", "[", "$", "id", "]", "=", "$", "action", ";", "else", "self", "::", "$", "typeMap", "[", "$", "type", "]", "=", "$", "action", ";", "}" ]
Register new mapping @param $action @param $type @param null $id
[ "Register", "new", "mapping" ]
df7f3a9794afaade3bee8f6be1223c98e4936cb2
https://github.com/c4studio/chronos/blob/df7f3a9794afaade3bee8f6be1223c98e4936cb2/src/Chronos/Scaffolding/app/Services/RouteMapService.php#L17-L23
34,711
voslartomas/WebCMS2
libs/helpers/SystemHelper.php
SystemHelper.checkFileContainsStr
public static function checkFileContainsStr($filename, $needle) { if (file_exists($filename)) { $content = file_get_contents($filename); if (strstr($content, $needle)) { return true; } } return false; }
php
public static function checkFileContainsStr($filename, $needle) { if (file_exists($filename)) { $content = file_get_contents($filename); if (strstr($content, $needle)) { return true; } } return false; }
[ "public", "static", "function", "checkFileContainsStr", "(", "$", "filename", ",", "$", "needle", ")", "{", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "content", "=", "file_get_contents", "(", "$", "filename", ")", ";", "if", "(", "strstr", "(", "$", "content", ",", "$", "needle", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if given file contains given string @param String $filename @param String $needle @return Boolean
[ "Check", "if", "given", "file", "contains", "given", "string" ]
b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf
https://github.com/voslartomas/WebCMS2/blob/b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf/libs/helpers/SystemHelper.php#L107-L118
34,712
voslartomas/WebCMS2
libs/helpers/SystemHelper.php
SystemHelper.isSuperAdmin
public static function isSuperAdmin(\Nette\Security\User $user) { $roles = $user->getIdentity()->getRoles(); return in_array('superadmin', $roles); }
php
public static function isSuperAdmin(\Nette\Security\User $user) { $roles = $user->getIdentity()->getRoles(); return in_array('superadmin', $roles); }
[ "public", "static", "function", "isSuperAdmin", "(", "\\", "Nette", "\\", "Security", "\\", "User", "$", "user", ")", "{", "$", "roles", "=", "$", "user", "->", "getIdentity", "(", ")", "->", "getRoles", "(", ")", ";", "return", "in_array", "(", "'superadmin'", ",", "$", "roles", ")", ";", "}" ]
Checks whether user has role superadmin or not. @param \Nette\Security\User $user @return Boolean
[ "Checks", "whether", "user", "has", "role", "superadmin", "or", "not", "." ]
b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf
https://github.com/voslartomas/WebCMS2/blob/b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf/libs/helpers/SystemHelper.php#L149-L154
34,713
voslartomas/WebCMS2
libs/helpers/SystemHelper.php
SystemHelper.strFindAndReplaceAll
public static function strFindAndReplaceAll($vars = array(), $str) { if (array_count_values($vars) > 0){ foreach ($vars as $key => $val) { for ($i = substr_count($str, $key); $i > 0; $i--) { $str = \WebCMS\Helpers\SystemHelper::strlReplace($key, $val, $str); } } } return $str; }
php
public static function strFindAndReplaceAll($vars = array(), $str) { if (array_count_values($vars) > 0){ foreach ($vars as $key => $val) { for ($i = substr_count($str, $key); $i > 0; $i--) { $str = \WebCMS\Helpers\SystemHelper::strlReplace($key, $val, $str); } } } return $str; }
[ "public", "static", "function", "strFindAndReplaceAll", "(", "$", "vars", "=", "array", "(", ")", ",", "$", "str", ")", "{", "if", "(", "array_count_values", "(", "$", "vars", ")", ">", "0", ")", "{", "foreach", "(", "$", "vars", "as", "$", "key", "=>", "$", "val", ")", "{", "for", "(", "$", "i", "=", "substr_count", "(", "$", "str", ",", "$", "key", ")", ";", "$", "i", ">", "0", ";", "$", "i", "--", ")", "{", "$", "str", "=", "\\", "WebCMS", "\\", "Helpers", "\\", "SystemHelper", "::", "strlReplace", "(", "$", "key", ",", "$", "val", ",", "$", "str", ")", ";", "}", "}", "}", "return", "$", "str", ";", "}" ]
Replace all needles found in str with rewrites @param Array[needle, rewrite] @param string $str @return string $str
[ "Replace", "all", "needles", "found", "in", "str", "with", "rewrites" ]
b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf
https://github.com/voslartomas/WebCMS2/blob/b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf/libs/helpers/SystemHelper.php#L197-L207
34,714
voslartomas/WebCMS2
libs/helpers/SystemHelper.php
SystemHelper.relative
public static function relative($path) { // windows fix :/ $path = str_replace('\\', '/', $path); // standard working directory if (strpos($path, WWW_DIR) !== false) { return str_replace(WWW_DIR, '', $path); } // symlink $pos = strpos($path, 'upload/'); return substr($path, $pos - 1); }
php
public static function relative($path) { // windows fix :/ $path = str_replace('\\', '/', $path); // standard working directory if (strpos($path, WWW_DIR) !== false) { return str_replace(WWW_DIR, '', $path); } // symlink $pos = strpos($path, 'upload/'); return substr($path, $pos - 1); }
[ "public", "static", "function", "relative", "(", "$", "path", ")", "{", "// windows fix :/", "$", "path", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "path", ")", ";", "// standard working directory", "if", "(", "strpos", "(", "$", "path", ",", "WWW_DIR", ")", "!==", "false", ")", "{", "return", "str_replace", "(", "WWW_DIR", ",", "''", ",", "$", "path", ")", ";", "}", "// symlink", "$", "pos", "=", "strpos", "(", "$", "path", ",", "'upload/'", ")", ";", "return", "substr", "(", "$", "path", ",", "$", "pos", "-", "1", ")", ";", "}" ]
Create relative path from an absolute path. @param string $path absolute path
[ "Create", "relative", "path", "from", "an", "absolute", "path", "." ]
b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf
https://github.com/voslartomas/WebCMS2/blob/b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf/libs/helpers/SystemHelper.php#L239-L253
34,715
nails/module-cdn
src/Api/Controller/CdnObject.php
CdnObject.postCreate
public function postCreate() { // @todo (Pablo - 2017-12-18) - this should be protected using admin permissions or the token uploader $oHttpCodes = Factory::service('HttpCodes'); $oInput = Factory::service('Input'); $oCdn = Factory::service('Cdn', 'nails/module-cdn'); $aOut = []; // -------------------------------------------------------------------------- $sBucket = $oInput->post('bucket') ?: $oInput->header('X-Cdn-Bucket'); if (!$sBucket) { throw new ApiException( 'Bucket not defined', $oHttpCodes::STATUS_BAD_REQUEST ); } // -------------------------------------------------------------------------- // Attempt upload $oObject = $oCdn->objectCreate('upload', $sBucket); if (!$oObject) { throw new ApiException( $oCdn->lastError(), $oHttpCodes::STATUS_BAD_REQUEST ); } // @todo (Pablo - 2018-06-25) - Reduce the namespace here (i.e remove `object`) return Factory::factory('ApiResponse', 'nails/module-api') ->setData([ 'object' => $this->formatObject( $oObject, $this->getRequestedUrls() ), ]); }
php
public function postCreate() { // @todo (Pablo - 2017-12-18) - this should be protected using admin permissions or the token uploader $oHttpCodes = Factory::service('HttpCodes'); $oInput = Factory::service('Input'); $oCdn = Factory::service('Cdn', 'nails/module-cdn'); $aOut = []; // -------------------------------------------------------------------------- $sBucket = $oInput->post('bucket') ?: $oInput->header('X-Cdn-Bucket'); if (!$sBucket) { throw new ApiException( 'Bucket not defined', $oHttpCodes::STATUS_BAD_REQUEST ); } // -------------------------------------------------------------------------- // Attempt upload $oObject = $oCdn->objectCreate('upload', $sBucket); if (!$oObject) { throw new ApiException( $oCdn->lastError(), $oHttpCodes::STATUS_BAD_REQUEST ); } // @todo (Pablo - 2018-06-25) - Reduce the namespace here (i.e remove `object`) return Factory::factory('ApiResponse', 'nails/module-api') ->setData([ 'object' => $this->formatObject( $oObject, $this->getRequestedUrls() ), ]); }
[ "public", "function", "postCreate", "(", ")", "{", "// @todo (Pablo - 2017-12-18) - this should be protected using admin permissions or the token uploader", "$", "oHttpCodes", "=", "Factory", "::", "service", "(", "'HttpCodes'", ")", ";", "$", "oInput", "=", "Factory", "::", "service", "(", "'Input'", ")", ";", "$", "oCdn", "=", "Factory", "::", "service", "(", "'Cdn'", ",", "'nails/module-cdn'", ")", ";", "$", "aOut", "=", "[", "]", ";", "// --------------------------------------------------------------------------", "$", "sBucket", "=", "$", "oInput", "->", "post", "(", "'bucket'", ")", "?", ":", "$", "oInput", "->", "header", "(", "'X-Cdn-Bucket'", ")", ";", "if", "(", "!", "$", "sBucket", ")", "{", "throw", "new", "ApiException", "(", "'Bucket not defined'", ",", "$", "oHttpCodes", "::", "STATUS_BAD_REQUEST", ")", ";", "}", "// --------------------------------------------------------------------------", "// Attempt upload", "$", "oObject", "=", "$", "oCdn", "->", "objectCreate", "(", "'upload'", ",", "$", "sBucket", ")", ";", "if", "(", "!", "$", "oObject", ")", "{", "throw", "new", "ApiException", "(", "$", "oCdn", "->", "lastError", "(", ")", ",", "$", "oHttpCodes", "::", "STATUS_BAD_REQUEST", ")", ";", "}", "// @todo (Pablo - 2018-06-25) - Reduce the namespace here (i.e remove `object`)", "return", "Factory", "::", "factory", "(", "'ApiResponse'", ",", "'nails/module-api'", ")", "->", "setData", "(", "[", "'object'", "=>", "$", "this", "->", "formatObject", "(", "$", "oObject", ",", "$", "this", "->", "getRequestedUrls", "(", ")", ")", ",", "]", ")", ";", "}" ]
Upload a new object to the CDN @return array
[ "Upload", "a", "new", "object", "to", "the", "CDN" ]
1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef
https://github.com/nails/module-cdn/blob/1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef/src/Api/Controller/CdnObject.php#L99-L138
34,716
nails/module-cdn
src/Api/Controller/CdnObject.php
CdnObject.postDelete
public function postDelete() { $oHttpCodes = Factory::service('HttpCodes'); if (!userHasPermission('admin:cdn:manager:object:delete')) { throw new ApiException( 'You do not have permission to access this resource', $oHttpCodes::STATUS_UNAUTHORIZED ); } $oInput = Factory::service('Input'); $oCdn = Factory::service('Cdn', 'nails/module-cdn'); $iObjectId = $oInput->post('object_id'); if (empty($iObjectId)) { throw new ApiException( '`object_id` is a required field', $oHttpCodes::STATUS_BAD_REQUEST ); } $oObject = $oCdn->getObject($iObjectId); $bIsTrash = false; if (empty($oObject)) { $oObject = $oCdn->getObjectFromTrash($iObjectId); $bIsTrash = true; } if (empty($oObject)) { throw new ApiException( 'Invalid object ID', $oHttpCodes::STATUS_NOT_FOUND ); } if ($bIsTrash) { $bDelete = $oCdn->purgeTrash([$iObjectId]); } else { $bDelete = $oCdn->objectDelete($iObjectId); } if (!$bDelete) { throw new ApiException( $oCdn->lastError(), $oHttpCodes::STATUS_BAD_REQUEST ); } return Factory::factory('ApiResponse', 'nails/module-api'); }
php
public function postDelete() { $oHttpCodes = Factory::service('HttpCodes'); if (!userHasPermission('admin:cdn:manager:object:delete')) { throw new ApiException( 'You do not have permission to access this resource', $oHttpCodes::STATUS_UNAUTHORIZED ); } $oInput = Factory::service('Input'); $oCdn = Factory::service('Cdn', 'nails/module-cdn'); $iObjectId = $oInput->post('object_id'); if (empty($iObjectId)) { throw new ApiException( '`object_id` is a required field', $oHttpCodes::STATUS_BAD_REQUEST ); } $oObject = $oCdn->getObject($iObjectId); $bIsTrash = false; if (empty($oObject)) { $oObject = $oCdn->getObjectFromTrash($iObjectId); $bIsTrash = true; } if (empty($oObject)) { throw new ApiException( 'Invalid object ID', $oHttpCodes::STATUS_NOT_FOUND ); } if ($bIsTrash) { $bDelete = $oCdn->purgeTrash([$iObjectId]); } else { $bDelete = $oCdn->objectDelete($iObjectId); } if (!$bDelete) { throw new ApiException( $oCdn->lastError(), $oHttpCodes::STATUS_BAD_REQUEST ); } return Factory::factory('ApiResponse', 'nails/module-api'); }
[ "public", "function", "postDelete", "(", ")", "{", "$", "oHttpCodes", "=", "Factory", "::", "service", "(", "'HttpCodes'", ")", ";", "if", "(", "!", "userHasPermission", "(", "'admin:cdn:manager:object:delete'", ")", ")", "{", "throw", "new", "ApiException", "(", "'You do not have permission to access this resource'", ",", "$", "oHttpCodes", "::", "STATUS_UNAUTHORIZED", ")", ";", "}", "$", "oInput", "=", "Factory", "::", "service", "(", "'Input'", ")", ";", "$", "oCdn", "=", "Factory", "::", "service", "(", "'Cdn'", ",", "'nails/module-cdn'", ")", ";", "$", "iObjectId", "=", "$", "oInput", "->", "post", "(", "'object_id'", ")", ";", "if", "(", "empty", "(", "$", "iObjectId", ")", ")", "{", "throw", "new", "ApiException", "(", "'`object_id` is a required field'", ",", "$", "oHttpCodes", "::", "STATUS_BAD_REQUEST", ")", ";", "}", "$", "oObject", "=", "$", "oCdn", "->", "getObject", "(", "$", "iObjectId", ")", ";", "$", "bIsTrash", "=", "false", ";", "if", "(", "empty", "(", "$", "oObject", ")", ")", "{", "$", "oObject", "=", "$", "oCdn", "->", "getObjectFromTrash", "(", "$", "iObjectId", ")", ";", "$", "bIsTrash", "=", "true", ";", "}", "if", "(", "empty", "(", "$", "oObject", ")", ")", "{", "throw", "new", "ApiException", "(", "'Invalid object ID'", ",", "$", "oHttpCodes", "::", "STATUS_NOT_FOUND", ")", ";", "}", "if", "(", "$", "bIsTrash", ")", "{", "$", "bDelete", "=", "$", "oCdn", "->", "purgeTrash", "(", "[", "$", "iObjectId", "]", ")", ";", "}", "else", "{", "$", "bDelete", "=", "$", "oCdn", "->", "objectDelete", "(", "$", "iObjectId", ")", ";", "}", "if", "(", "!", "$", "bDelete", ")", "{", "throw", "new", "ApiException", "(", "$", "oCdn", "->", "lastError", "(", ")", ",", "$", "oHttpCodes", "::", "STATUS_BAD_REQUEST", ")", ";", "}", "return", "Factory", "::", "factory", "(", "'ApiResponse'", ",", "'nails/module-api'", ")", ";", "}" ]
Delete an object from the CDN @return array
[ "Delete", "an", "object", "from", "the", "CDN" ]
1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef
https://github.com/nails/module-cdn/blob/1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef/src/Api/Controller/CdnObject.php#L147-L197
34,717
nails/module-cdn
src/Api/Controller/CdnObject.php
CdnObject.postRestore
public function postRestore() { $oHttpCodes = Factory::service('HttpCodes'); if (!userHasPermission('admin:cdn:manager:object:restore')) { throw new ApiException( 'You do not have permission to access this resource', $oHttpCodes::STATUS_UNAUTHORIZED ); } $oInput = Factory::service('Input'); $oCdn = Factory::service('Cdn', 'nails/module-cdn'); $iObjectId = $oInput->post('object_id'); if (!$oCdn->objectRestore($iObjectId)) { throw new ApiException( $oCdn->lastError(), $oHttpCodes::STATUS_INTERNAL_SERVER_ERROR ); } return Factory::factory('ApiResponse', 'nails/module-api'); }
php
public function postRestore() { $oHttpCodes = Factory::service('HttpCodes'); if (!userHasPermission('admin:cdn:manager:object:restore')) { throw new ApiException( 'You do not have permission to access this resource', $oHttpCodes::STATUS_UNAUTHORIZED ); } $oInput = Factory::service('Input'); $oCdn = Factory::service('Cdn', 'nails/module-cdn'); $iObjectId = $oInput->post('object_id'); if (!$oCdn->objectRestore($iObjectId)) { throw new ApiException( $oCdn->lastError(), $oHttpCodes::STATUS_INTERNAL_SERVER_ERROR ); } return Factory::factory('ApiResponse', 'nails/module-api'); }
[ "public", "function", "postRestore", "(", ")", "{", "$", "oHttpCodes", "=", "Factory", "::", "service", "(", "'HttpCodes'", ")", ";", "if", "(", "!", "userHasPermission", "(", "'admin:cdn:manager:object:restore'", ")", ")", "{", "throw", "new", "ApiException", "(", "'You do not have permission to access this resource'", ",", "$", "oHttpCodes", "::", "STATUS_UNAUTHORIZED", ")", ";", "}", "$", "oInput", "=", "Factory", "::", "service", "(", "'Input'", ")", ";", "$", "oCdn", "=", "Factory", "::", "service", "(", "'Cdn'", ",", "'nails/module-cdn'", ")", ";", "$", "iObjectId", "=", "$", "oInput", "->", "post", "(", "'object_id'", ")", ";", "if", "(", "!", "$", "oCdn", "->", "objectRestore", "(", "$", "iObjectId", ")", ")", "{", "throw", "new", "ApiException", "(", "$", "oCdn", "->", "lastError", "(", ")", ",", "$", "oHttpCodes", "::", "STATUS_INTERNAL_SERVER_ERROR", ")", ";", "}", "return", "Factory", "::", "factory", "(", "'ApiResponse'", ",", "'nails/module-api'", ")", ";", "}" ]
Restore an item form the trash @return array
[ "Restore", "an", "item", "form", "the", "trash" ]
1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef
https://github.com/nails/module-cdn/blob/1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef/src/Api/Controller/CdnObject.php#L206-L229
34,718
nails/module-cdn
src/Api/Controller/CdnObject.php
CdnObject.getSearch
public function getSearch() { $oHttpCodes = Factory::service('HttpCodes'); if (!userHasPermission('admin:cdn:manager:object:browse')) { throw new ApiException( 'You do not have permission to access this resource', $oHttpCodes::STATUS_UNAUTHORIZED ); } $oInput = Factory::service('Input'); $oModel = Factory::model('Object', 'nails/module-cdn'); $sKeywords = $oInput->get('keywords'); $iPage = (int) $oInput->get('page') ?: 1; $oResult = $oModel->search( $sKeywords, $iPage, static::MAX_OBJECTS_PER_REQUEST ); $oResponse = Factory::factory('ApiResponse', 'nails/module-api'); $oResponse->setData(array_map( function ($oObj) { $oObj->is_img = isset($oObj->img); $oObj->url = (object) [ 'src' => cdnServe($oObj->id), 'preview' => isset($oObj->img) ? cdnCrop($oObj->id, 400, 400) : null, ]; return $oObj; }, $oResult->data )); return $oResponse; }
php
public function getSearch() { $oHttpCodes = Factory::service('HttpCodes'); if (!userHasPermission('admin:cdn:manager:object:browse')) { throw new ApiException( 'You do not have permission to access this resource', $oHttpCodes::STATUS_UNAUTHORIZED ); } $oInput = Factory::service('Input'); $oModel = Factory::model('Object', 'nails/module-cdn'); $sKeywords = $oInput->get('keywords'); $iPage = (int) $oInput->get('page') ?: 1; $oResult = $oModel->search( $sKeywords, $iPage, static::MAX_OBJECTS_PER_REQUEST ); $oResponse = Factory::factory('ApiResponse', 'nails/module-api'); $oResponse->setData(array_map( function ($oObj) { $oObj->is_img = isset($oObj->img); $oObj->url = (object) [ 'src' => cdnServe($oObj->id), 'preview' => isset($oObj->img) ? cdnCrop($oObj->id, 400, 400) : null, ]; return $oObj; }, $oResult->data )); return $oResponse; }
[ "public", "function", "getSearch", "(", ")", "{", "$", "oHttpCodes", "=", "Factory", "::", "service", "(", "'HttpCodes'", ")", ";", "if", "(", "!", "userHasPermission", "(", "'admin:cdn:manager:object:browse'", ")", ")", "{", "throw", "new", "ApiException", "(", "'You do not have permission to access this resource'", ",", "$", "oHttpCodes", "::", "STATUS_UNAUTHORIZED", ")", ";", "}", "$", "oInput", "=", "Factory", "::", "service", "(", "'Input'", ")", ";", "$", "oModel", "=", "Factory", "::", "model", "(", "'Object'", ",", "'nails/module-cdn'", ")", ";", "$", "sKeywords", "=", "$", "oInput", "->", "get", "(", "'keywords'", ")", ";", "$", "iPage", "=", "(", "int", ")", "$", "oInput", "->", "get", "(", "'page'", ")", "?", ":", "1", ";", "$", "oResult", "=", "$", "oModel", "->", "search", "(", "$", "sKeywords", ",", "$", "iPage", ",", "static", "::", "MAX_OBJECTS_PER_REQUEST", ")", ";", "$", "oResponse", "=", "Factory", "::", "factory", "(", "'ApiResponse'", ",", "'nails/module-api'", ")", ";", "$", "oResponse", "->", "setData", "(", "array_map", "(", "function", "(", "$", "oObj", ")", "{", "$", "oObj", "->", "is_img", "=", "isset", "(", "$", "oObj", "->", "img", ")", ";", "$", "oObj", "->", "url", "=", "(", "object", ")", "[", "'src'", "=>", "cdnServe", "(", "$", "oObj", "->", "id", ")", ",", "'preview'", "=>", "isset", "(", "$", "oObj", "->", "img", ")", "?", "cdnCrop", "(", "$", "oObj", "->", "id", ",", "400", ",", "400", ")", ":", "null", ",", "]", ";", "return", "$", "oObj", ";", "}", ",", "$", "oResult", "->", "data", ")", ")", ";", "return", "$", "oResponse", ";", "}" ]
Search across all objects @return array
[ "Search", "across", "all", "objects" ]
1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef
https://github.com/nails/module-cdn/blob/1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef/src/Api/Controller/CdnObject.php#L238-L272
34,719
nails/module-cdn
src/Api/Controller/CdnObject.php
CdnObject.getTrash
public function getTrash() { $oHttpCodes = Factory::service('HttpCodes'); if (!userHasPermission('admin:cdn:manager:object:browse')) { throw new ApiException( 'You do not have permission to access this resource', $oHttpCodes::STATUS_UNAUTHORIZED ); } $oInput = Factory::service('Input'); $oModel = Factory::model('ObjectTrash', 'nails/module-cdn'); $iPage = (int) $oInput->get('page') ?: 1; $aResults = $oModel->getAll( $iPage, static::MAX_OBJECTS_PER_REQUEST, ['sort' => [['trashed', 'desc']]] ); $oResponse = Factory::factory('ApiResponse', 'nails/module-api'); $oResponse->setData(array_map( function ($oObj) { $oObj->is_img = isset($oObj->img); $oObj->url = (object) [ 'src' => cdnServe($oObj->id), 'preview' => isset($oObj->img) ? cdnCrop($oObj->id, 400, 400) : null, ]; return $oObj; }, $aResults )); return $oResponse; }
php
public function getTrash() { $oHttpCodes = Factory::service('HttpCodes'); if (!userHasPermission('admin:cdn:manager:object:browse')) { throw new ApiException( 'You do not have permission to access this resource', $oHttpCodes::STATUS_UNAUTHORIZED ); } $oInput = Factory::service('Input'); $oModel = Factory::model('ObjectTrash', 'nails/module-cdn'); $iPage = (int) $oInput->get('page') ?: 1; $aResults = $oModel->getAll( $iPage, static::MAX_OBJECTS_PER_REQUEST, ['sort' => [['trashed', 'desc']]] ); $oResponse = Factory::factory('ApiResponse', 'nails/module-api'); $oResponse->setData(array_map( function ($oObj) { $oObj->is_img = isset($oObj->img); $oObj->url = (object) [ 'src' => cdnServe($oObj->id), 'preview' => isset($oObj->img) ? cdnCrop($oObj->id, 400, 400) : null, ]; return $oObj; }, $aResults )); return $oResponse; }
[ "public", "function", "getTrash", "(", ")", "{", "$", "oHttpCodes", "=", "Factory", "::", "service", "(", "'HttpCodes'", ")", ";", "if", "(", "!", "userHasPermission", "(", "'admin:cdn:manager:object:browse'", ")", ")", "{", "throw", "new", "ApiException", "(", "'You do not have permission to access this resource'", ",", "$", "oHttpCodes", "::", "STATUS_UNAUTHORIZED", ")", ";", "}", "$", "oInput", "=", "Factory", "::", "service", "(", "'Input'", ")", ";", "$", "oModel", "=", "Factory", "::", "model", "(", "'ObjectTrash'", ",", "'nails/module-cdn'", ")", ";", "$", "iPage", "=", "(", "int", ")", "$", "oInput", "->", "get", "(", "'page'", ")", "?", ":", "1", ";", "$", "aResults", "=", "$", "oModel", "->", "getAll", "(", "$", "iPage", ",", "static", "::", "MAX_OBJECTS_PER_REQUEST", ",", "[", "'sort'", "=>", "[", "[", "'trashed'", ",", "'desc'", "]", "]", "]", ")", ";", "$", "oResponse", "=", "Factory", "::", "factory", "(", "'ApiResponse'", ",", "'nails/module-api'", ")", ";", "$", "oResponse", "->", "setData", "(", "array_map", "(", "function", "(", "$", "oObj", ")", "{", "$", "oObj", "->", "is_img", "=", "isset", "(", "$", "oObj", "->", "img", ")", ";", "$", "oObj", "->", "url", "=", "(", "object", ")", "[", "'src'", "=>", "cdnServe", "(", "$", "oObj", "->", "id", ")", ",", "'preview'", "=>", "isset", "(", "$", "oObj", "->", "img", ")", "?", "cdnCrop", "(", "$", "oObj", "->", "id", ",", "400", ",", "400", ")", ":", "null", ",", "]", ";", "return", "$", "oObj", ";", "}", ",", "$", "aResults", ")", ")", ";", "return", "$", "oResponse", ";", "}" ]
List items in the trash @return array
[ "List", "items", "in", "the", "trash" ]
1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef
https://github.com/nails/module-cdn/blob/1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef/src/Api/Controller/CdnObject.php#L281-L314
34,720
nails/module-cdn
src/Api/Controller/CdnObject.php
CdnObject.getRequestedUrls
protected function getRequestedUrls() { $oInput = Factory::service('Input'); $sUrls = $oInput->get('urls') ?: $oInput->header('X-Cdn-Urls'); $aUrls = !is_array($sUrls) ? explode(',', $sUrls) : $sUrls; $aUrls = array_map('strtolower', $aUrls); // Filter out any which don't follow the format {digit}x{digit}-{scale|crop} || raw foreach ($aUrls as &$sDimension) { if (!is_string($sDimension)) { $sDimension = null; continue; } preg_match_all('/^(\d+?)x(\d+?)-(scale|crop)$/i', $sDimension, $aMatches); if (empty($aMatches[0])) { $sDimension = null; } else { $sDimension = [ 'width' => !empty($aMatches[1][0]) ? $aMatches[1][0] : null, 'height' => !empty($aMatches[2][0]) ? $aMatches[2][0] : null, 'type' => !empty($aMatches[3][0]) ? $aMatches[3][0] : 'crop', ]; } } return array_filter($aUrls); }
php
protected function getRequestedUrls() { $oInput = Factory::service('Input'); $sUrls = $oInput->get('urls') ?: $oInput->header('X-Cdn-Urls'); $aUrls = !is_array($sUrls) ? explode(',', $sUrls) : $sUrls; $aUrls = array_map('strtolower', $aUrls); // Filter out any which don't follow the format {digit}x{digit}-{scale|crop} || raw foreach ($aUrls as &$sDimension) { if (!is_string($sDimension)) { $sDimension = null; continue; } preg_match_all('/^(\d+?)x(\d+?)-(scale|crop)$/i', $sDimension, $aMatches); if (empty($aMatches[0])) { $sDimension = null; } else { $sDimension = [ 'width' => !empty($aMatches[1][0]) ? $aMatches[1][0] : null, 'height' => !empty($aMatches[2][0]) ? $aMatches[2][0] : null, 'type' => !empty($aMatches[3][0]) ? $aMatches[3][0] : 'crop', ]; } } return array_filter($aUrls); }
[ "protected", "function", "getRequestedUrls", "(", ")", "{", "$", "oInput", "=", "Factory", "::", "service", "(", "'Input'", ")", ";", "$", "sUrls", "=", "$", "oInput", "->", "get", "(", "'urls'", ")", "?", ":", "$", "oInput", "->", "header", "(", "'X-Cdn-Urls'", ")", ";", "$", "aUrls", "=", "!", "is_array", "(", "$", "sUrls", ")", "?", "explode", "(", "','", ",", "$", "sUrls", ")", ":", "$", "sUrls", ";", "$", "aUrls", "=", "array_map", "(", "'strtolower'", ",", "$", "aUrls", ")", ";", "// Filter out any which don't follow the format {digit}x{digit}-{scale|crop} || raw", "foreach", "(", "$", "aUrls", "as", "&", "$", "sDimension", ")", "{", "if", "(", "!", "is_string", "(", "$", "sDimension", ")", ")", "{", "$", "sDimension", "=", "null", ";", "continue", ";", "}", "preg_match_all", "(", "'/^(\\d+?)x(\\d+?)-(scale|crop)$/i'", ",", "$", "sDimension", ",", "$", "aMatches", ")", ";", "if", "(", "empty", "(", "$", "aMatches", "[", "0", "]", ")", ")", "{", "$", "sDimension", "=", "null", ";", "}", "else", "{", "$", "sDimension", "=", "[", "'width'", "=>", "!", "empty", "(", "$", "aMatches", "[", "1", "]", "[", "0", "]", ")", "?", "$", "aMatches", "[", "1", "]", "[", "0", "]", ":", "null", ",", "'height'", "=>", "!", "empty", "(", "$", "aMatches", "[", "2", "]", "[", "0", "]", ")", "?", "$", "aMatches", "[", "2", "]", "[", "0", "]", ":", "null", ",", "'type'", "=>", "!", "empty", "(", "$", "aMatches", "[", "3", "]", "[", "0", "]", ")", "?", "$", "aMatches", "[", "3", "]", "[", "0", "]", ":", "'crop'", ",", "]", ";", "}", "}", "return", "array_filter", "(", "$", "aUrls", ")", ";", "}" ]
Return an array of the requested URLs form the request @return array
[ "Return", "an", "array", "of", "the", "requested", "URLs", "form", "the", "request" ]
1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef
https://github.com/nails/module-cdn/blob/1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef/src/Api/Controller/CdnObject.php#L323-L352
34,721
nails/module-cdn
src/Api/Controller/CdnObject.php
CdnObject.formatObject
protected function formatObject($oObject, $aUrls = []) { return (object) [ 'id' => $oObject->id, 'object' => (object) [ 'name' => $oObject->file->name->human, 'mime' => $oObject->file->mime, 'size' => $oObject->file->size, ], 'bucket' => $oObject->bucket, 'is_img' => $oObject->is_img, 'img' => (object) [ 'width' => $oObject->img_width, 'height' => $oObject->img_height, 'orientation' => $oObject->img_orientation, 'is_animated' => $oObject->is_animated, ], 'created' => $oObject->created, 'modified' => $oObject->modified, 'url' => (object) $this->generateUrls($oObject, $aUrls), ]; }
php
protected function formatObject($oObject, $aUrls = []) { return (object) [ 'id' => $oObject->id, 'object' => (object) [ 'name' => $oObject->file->name->human, 'mime' => $oObject->file->mime, 'size' => $oObject->file->size, ], 'bucket' => $oObject->bucket, 'is_img' => $oObject->is_img, 'img' => (object) [ 'width' => $oObject->img_width, 'height' => $oObject->img_height, 'orientation' => $oObject->img_orientation, 'is_animated' => $oObject->is_animated, ], 'created' => $oObject->created, 'modified' => $oObject->modified, 'url' => (object) $this->generateUrls($oObject, $aUrls), ]; }
[ "protected", "function", "formatObject", "(", "$", "oObject", ",", "$", "aUrls", "=", "[", "]", ")", "{", "return", "(", "object", ")", "[", "'id'", "=>", "$", "oObject", "->", "id", ",", "'object'", "=>", "(", "object", ")", "[", "'name'", "=>", "$", "oObject", "->", "file", "->", "name", "->", "human", ",", "'mime'", "=>", "$", "oObject", "->", "file", "->", "mime", ",", "'size'", "=>", "$", "oObject", "->", "file", "->", "size", ",", "]", ",", "'bucket'", "=>", "$", "oObject", "->", "bucket", ",", "'is_img'", "=>", "$", "oObject", "->", "is_img", ",", "'img'", "=>", "(", "object", ")", "[", "'width'", "=>", "$", "oObject", "->", "img_width", ",", "'height'", "=>", "$", "oObject", "->", "img_height", ",", "'orientation'", "=>", "$", "oObject", "->", "img_orientation", ",", "'is_animated'", "=>", "$", "oObject", "->", "is_animated", ",", "]", ",", "'created'", "=>", "$", "oObject", "->", "created", ",", "'modified'", "=>", "$", "oObject", "->", "modified", ",", "'url'", "=>", "(", "object", ")", "$", "this", "->", "generateUrls", "(", "$", "oObject", ",", "$", "aUrls", ")", ",", "]", ";", "}" ]
Format an object object @param \stdClass $oObject the object to format @param array $aUrls The requested URLs @return object
[ "Format", "an", "object", "object" ]
1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef
https://github.com/nails/module-cdn/blob/1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef/src/Api/Controller/CdnObject.php#L364-L385
34,722
nails/module-cdn
src/Api/Controller/CdnObject.php
CdnObject.generateUrls
protected function generateUrls($oObject, $aUrls) { $oCdn = Factory::service('Cdn', 'nails/module-cdn'); $aOut = ['src' => $oCdn->urlServe($oObject)]; if (!empty($aUrls) && $oObject->is_img) { foreach ($aUrls as $aDimension) { $sProperty = $aDimension['width'] . 'x' . $aDimension['height'] . '-' . $aDimension['type']; switch ($aDimension['type']) { case 'crop': $aOut[$sProperty] = $oCdn->urlCrop( $oObject, $aDimension['width'], $aDimension['height'] ); break; case 'scale': $aOut[$sProperty] = $oCdn->urlScale( $oObject, $aDimension['width'], $aDimension['height'] ); break; } } } return $aOut; }
php
protected function generateUrls($oObject, $aUrls) { $oCdn = Factory::service('Cdn', 'nails/module-cdn'); $aOut = ['src' => $oCdn->urlServe($oObject)]; if (!empty($aUrls) && $oObject->is_img) { foreach ($aUrls as $aDimension) { $sProperty = $aDimension['width'] . 'x' . $aDimension['height'] . '-' . $aDimension['type']; switch ($aDimension['type']) { case 'crop': $aOut[$sProperty] = $oCdn->urlCrop( $oObject, $aDimension['width'], $aDimension['height'] ); break; case 'scale': $aOut[$sProperty] = $oCdn->urlScale( $oObject, $aDimension['width'], $aDimension['height'] ); break; } } } return $aOut; }
[ "protected", "function", "generateUrls", "(", "$", "oObject", ",", "$", "aUrls", ")", "{", "$", "oCdn", "=", "Factory", "::", "service", "(", "'Cdn'", ",", "'nails/module-cdn'", ")", ";", "$", "aOut", "=", "[", "'src'", "=>", "$", "oCdn", "->", "urlServe", "(", "$", "oObject", ")", "]", ";", "if", "(", "!", "empty", "(", "$", "aUrls", ")", "&&", "$", "oObject", "->", "is_img", ")", "{", "foreach", "(", "$", "aUrls", "as", "$", "aDimension", ")", "{", "$", "sProperty", "=", "$", "aDimension", "[", "'width'", "]", ".", "'x'", ".", "$", "aDimension", "[", "'height'", "]", ".", "'-'", ".", "$", "aDimension", "[", "'type'", "]", ";", "switch", "(", "$", "aDimension", "[", "'type'", "]", ")", "{", "case", "'crop'", ":", "$", "aOut", "[", "$", "sProperty", "]", "=", "$", "oCdn", "->", "urlCrop", "(", "$", "oObject", ",", "$", "aDimension", "[", "'width'", "]", ",", "$", "aDimension", "[", "'height'", "]", ")", ";", "break", ";", "case", "'scale'", ":", "$", "aOut", "[", "$", "sProperty", "]", "=", "$", "oCdn", "->", "urlScale", "(", "$", "oObject", ",", "$", "aDimension", "[", "'width'", "]", ",", "$", "aDimension", "[", "'height'", "]", ")", ";", "break", ";", "}", "}", "}", "return", "$", "aOut", ";", "}" ]
Generate the requested URLs @param \stdClass $oObject The object object @param array $aUrls The URLs to generate @return array
[ "Generate", "the", "requested", "URLs" ]
1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef
https://github.com/nails/module-cdn/blob/1c2ff1cbdf2aa6a7162f92c8fdbcde87c506e1ef/src/Api/Controller/CdnObject.php#L397-L428
34,723
CanalTP/NmmPortalBundle
Controller/CustomerController.php
CustomerController.findCustomerById
private function findCustomerById ($id) { $customer = $this->getDoctrine() ->getManager() ->getRepository('CanalTPNmmPortalBundle:Customer') ->find($id); return $customer; }
php
private function findCustomerById ($id) { $customer = $this->getDoctrine() ->getManager() ->getRepository('CanalTPNmmPortalBundle:Customer') ->find($id); return $customer; }
[ "private", "function", "findCustomerById", "(", "$", "id", ")", "{", "$", "customer", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "getRepository", "(", "'CanalTPNmmPortalBundle:Customer'", ")", "->", "find", "(", "$", "id", ")", ";", "return", "$", "customer", ";", "}" ]
Find a Customer by id. @param mixed $id The customer id @return CanalTP\NmmPortalBundle\Entity\Customer
[ "Find", "a", "Customer", "by", "id", "." ]
b1ad026a33897984206ea1691ad9e25db5854efb
https://github.com/CanalTP/NmmPortalBundle/blob/b1ad026a33897984206ea1691ad9e25db5854efb/Controller/CustomerController.php#L120-L127
34,724
kadet1090/KeyLighter
Parser/Rules.php
Rules.addMany
public function addMany(array $rules, $prefix = null) { foreach ($rules as $type => $rule) { $type = $this->_getName($type, $prefix); if ($rule instanceof Rule) { $this->add($type, $rule); } elseif (is_array($rule)) { $this->addMany($rule, $type); } else { throw new \LogicException('Array values has to be either arrays of rules or rules.'); } } }
php
public function addMany(array $rules, $prefix = null) { foreach ($rules as $type => $rule) { $type = $this->_getName($type, $prefix); if ($rule instanceof Rule) { $this->add($type, $rule); } elseif (is_array($rule)) { $this->addMany($rule, $type); } else { throw new \LogicException('Array values has to be either arrays of rules or rules.'); } } }
[ "public", "function", "addMany", "(", "array", "$", "rules", ",", "$", "prefix", "=", "null", ")", "{", "foreach", "(", "$", "rules", "as", "$", "type", "=>", "$", "rule", ")", "{", "$", "type", "=", "$", "this", "->", "_getName", "(", "$", "type", ",", "$", "prefix", ")", ";", "if", "(", "$", "rule", "instanceof", "Rule", ")", "{", "$", "this", "->", "add", "(", "$", "type", ",", "$", "rule", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "rule", ")", ")", "{", "$", "this", "->", "addMany", "(", "$", "rule", ",", "$", "type", ")", ";", "}", "else", "{", "throw", "new", "\\", "LogicException", "(", "'Array values has to be either arrays of rules or rules.'", ")", ";", "}", "}", "}" ]
Adds array of rules @param array $rules @param string|null $prefix @throws \LogicException
[ "Adds", "array", "of", "rules" ]
6aac402b7fe0170edf3c5afbae652009951068af
https://github.com/kadet1090/KeyLighter/blob/6aac402b7fe0170edf3c5afbae652009951068af/Parser/Rules.php#L61-L74
34,725
kadet1090/KeyLighter
Parser/Rules.php
Rules.add
public function add($type, Rule $rule) { if (!isset($this[$type])) { $this[$type] = []; } if ($rule->language === false) { $rule->language = $this->_language; } if ($rule->validator === false) { $rule->validator = $this->validator; } $rule->factory->setBase($type); if ($rule->name !== null) { if (isset($this[$type][$rule->name])) { throw new NameConflictException("Rule with '{$rule->name}' is already defined, name has to be unique!"); } $this[$type][$rule->name] = $rule; return; } $this[$type][] = $rule; }
php
public function add($type, Rule $rule) { if (!isset($this[$type])) { $this[$type] = []; } if ($rule->language === false) { $rule->language = $this->_language; } if ($rule->validator === false) { $rule->validator = $this->validator; } $rule->factory->setBase($type); if ($rule->name !== null) { if (isset($this[$type][$rule->name])) { throw new NameConflictException("Rule with '{$rule->name}' is already defined, name has to be unique!"); } $this[$type][$rule->name] = $rule; return; } $this[$type][] = $rule; }
[ "public", "function", "add", "(", "$", "type", ",", "Rule", "$", "rule", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "[", "$", "type", "]", ")", ")", "{", "$", "this", "[", "$", "type", "]", "=", "[", "]", ";", "}", "if", "(", "$", "rule", "->", "language", "===", "false", ")", "{", "$", "rule", "->", "language", "=", "$", "this", "->", "_language", ";", "}", "if", "(", "$", "rule", "->", "validator", "===", "false", ")", "{", "$", "rule", "->", "validator", "=", "$", "this", "->", "validator", ";", "}", "$", "rule", "->", "factory", "->", "setBase", "(", "$", "type", ")", ";", "if", "(", "$", "rule", "->", "name", "!==", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "[", "$", "type", "]", "[", "$", "rule", "->", "name", "]", ")", ")", "{", "throw", "new", "NameConflictException", "(", "\"Rule with '{$rule->name}' is already defined, name has to be unique!\"", ")", ";", "}", "$", "this", "[", "$", "type", "]", "[", "$", "rule", "->", "name", "]", "=", "$", "rule", ";", "return", ";", "}", "$", "this", "[", "$", "type", "]", "[", "]", "=", "$", "rule", ";", "}" ]
Adds one rule @param string $type @param Rule $rule @throws NameConflictException When there is already defined rule with given name.
[ "Adds", "one", "rule" ]
6aac402b7fe0170edf3c5afbae652009951068af
https://github.com/kadet1090/KeyLighter/blob/6aac402b7fe0170edf3c5afbae652009951068af/Parser/Rules.php#L84-L110
34,726
kadet1090/KeyLighter
Parser/Rules.php
Rules.replace
public function replace(Rule $replacement, $type, $index = 0) { $current = $this->rule($type, $index); if ($current->name !== null) { $replacement->name = $current->name; } $this[$type][$index] = $replacement; }
php
public function replace(Rule $replacement, $type, $index = 0) { $current = $this->rule($type, $index); if ($current->name !== null) { $replacement->name = $current->name; } $this[$type][$index] = $replacement; }
[ "public", "function", "replace", "(", "Rule", "$", "replacement", ",", "$", "type", ",", "$", "index", "=", "0", ")", "{", "$", "current", "=", "$", "this", "->", "rule", "(", "$", "type", ",", "$", "index", ")", ";", "if", "(", "$", "current", "->", "name", "!==", "null", ")", "{", "$", "replacement", "->", "name", "=", "$", "current", "->", "name", ";", "}", "$", "this", "[", "$", "type", "]", "[", "$", "index", "]", "=", "$", "replacement", ";", "}" ]
Replaces rule of given type and index with provided one. @param Rule $replacement @param $type @param int $index
[ "Replaces", "rule", "of", "given", "type", "and", "index", "with", "provided", "one", "." ]
6aac402b7fe0170edf3c5afbae652009951068af
https://github.com/kadet1090/KeyLighter/blob/6aac402b7fe0170edf3c5afbae652009951068af/Parser/Rules.php#L149-L157
34,727
kadet1090/KeyLighter
Parser/Rules.php
Rules.remove
public function remove($type, $index = null) { if ($index === null) { unset($this[$type]); return; } if(!isset($this[$type][$index])) { throw new NoSuchElementException("There is no rule '$type' type indexed by '$index'."); } unset($this[$type][$index]); }
php
public function remove($type, $index = null) { if ($index === null) { unset($this[$type]); return; } if(!isset($this[$type][$index])) { throw new NoSuchElementException("There is no rule '$type' type indexed by '$index'."); } unset($this[$type][$index]); }
[ "public", "function", "remove", "(", "$", "type", ",", "$", "index", "=", "null", ")", "{", "if", "(", "$", "index", "===", "null", ")", "{", "unset", "(", "$", "this", "[", "$", "type", "]", ")", ";", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "[", "$", "type", "]", "[", "$", "index", "]", ")", ")", "{", "throw", "new", "NoSuchElementException", "(", "\"There is no rule '$type' type indexed by '$index'.\"", ")", ";", "}", "unset", "(", "$", "this", "[", "$", "type", "]", "[", "$", "index", "]", ")", ";", "}" ]
Removes rule of given type and index. @param string $type @param mixed $index @throws NoSuchElementException
[ "Removes", "rule", "of", "given", "type", "and", "index", "." ]
6aac402b7fe0170edf3c5afbae652009951068af
https://github.com/kadet1090/KeyLighter/blob/6aac402b7fe0170edf3c5afbae652009951068af/Parser/Rules.php#L167-L179
34,728
Rareloop/primer-core
src/Primer/FileSystem.php
FileSystem.getDataForPattern
public static function getDataForPattern($id, $resolveAlias = false) { $data = array(); $id = Primer::cleanId($id); // Load the Patterns default data $defaultData = @file_get_contents(Primer::$PATTERN_PATH . '/' . $id . '/data.json'); if ($defaultData) { $json = json_decode($defaultData); if ($json) { // Merge in the data $data += (array)$json; } } if ($resolveAlias) { // Parent data - e.g. elements/button is the parent of elements/button~primary $parentData = array(); // Load parent data if this is inherit if (preg_match('/(.*?)~.*?/', $id, $matches)) { $parentData = FileSystem::getDataForPattern($matches[1]); } // Merge the parent and pattern data together, giving preference to the pattern data $data = array_replace_recursive((array)$parentData, (array)$data); } // Create the data structure $viewData = new ViewData($data); // Give the system a chance to mutate the data ViewData::fire($id, $viewData); // Return the data structure return $viewData; }
php
public static function getDataForPattern($id, $resolveAlias = false) { $data = array(); $id = Primer::cleanId($id); // Load the Patterns default data $defaultData = @file_get_contents(Primer::$PATTERN_PATH . '/' . $id . '/data.json'); if ($defaultData) { $json = json_decode($defaultData); if ($json) { // Merge in the data $data += (array)$json; } } if ($resolveAlias) { // Parent data - e.g. elements/button is the parent of elements/button~primary $parentData = array(); // Load parent data if this is inherit if (preg_match('/(.*?)~.*?/', $id, $matches)) { $parentData = FileSystem::getDataForPattern($matches[1]); } // Merge the parent and pattern data together, giving preference to the pattern data $data = array_replace_recursive((array)$parentData, (array)$data); } // Create the data structure $viewData = new ViewData($data); // Give the system a chance to mutate the data ViewData::fire($id, $viewData); // Return the data structure return $viewData; }
[ "public", "static", "function", "getDataForPattern", "(", "$", "id", ",", "$", "resolveAlias", "=", "false", ")", "{", "$", "data", "=", "array", "(", ")", ";", "$", "id", "=", "Primer", "::", "cleanId", "(", "$", "id", ")", ";", "// Load the Patterns default data", "$", "defaultData", "=", "@", "file_get_contents", "(", "Primer", "::", "$", "PATTERN_PATH", ".", "'/'", ".", "$", "id", ".", "'/data.json'", ")", ";", "if", "(", "$", "defaultData", ")", "{", "$", "json", "=", "json_decode", "(", "$", "defaultData", ")", ";", "if", "(", "$", "json", ")", "{", "// Merge in the data", "$", "data", "+=", "(", "array", ")", "$", "json", ";", "}", "}", "if", "(", "$", "resolveAlias", ")", "{", "// Parent data - e.g. elements/button is the parent of elements/button~primary", "$", "parentData", "=", "array", "(", ")", ";", "// Load parent data if this is inherit", "if", "(", "preg_match", "(", "'/(.*?)~.*?/'", ",", "$", "id", ",", "$", "matches", ")", ")", "{", "$", "parentData", "=", "FileSystem", "::", "getDataForPattern", "(", "$", "matches", "[", "1", "]", ")", ";", "}", "// Merge the parent and pattern data together, giving preference to the pattern data", "$", "data", "=", "array_replace_recursive", "(", "(", "array", ")", "$", "parentData", ",", "(", "array", ")", "$", "data", ")", ";", "}", "// Create the data structure", "$", "viewData", "=", "new", "ViewData", "(", "$", "data", ")", ";", "// Give the system a chance to mutate the data", "ViewData", "::", "fire", "(", "$", "id", ",", "$", "viewData", ")", ";", "// Return the data structure", "return", "$", "viewData", ";", "}" ]
Retrieve data for a patter @param String $id The id of the pattern @param Boolean $resolveAlias Whether or not to resolve data from aliased patterns (e.g. button~outline -> button) @return ViewData The decoded JSON data
[ "Retrieve", "data", "for", "a", "patter" ]
fe098d6794a4add368f97672397dc93d223a1786
https://github.com/Rareloop/primer-core/blob/fe098d6794a4add368f97672397dc93d223a1786/src/Primer/FileSystem.php#L20-L59
34,729
jon48/webtrees-lib
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php
GeoAnalysisProvider.getGeoAnalysis
public function getGeoAnalysis($id, $only_enabled = true) { $args = array ( 'gedcom_id' => $this->tree->getTreeId(), 'ga_id' => $id ); $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . ' FROM `##maj_geodispersion`' . ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; if($only_enabled) { $sql .= ' AND majgd_status = :status'; $args['status'] = 'enabled'; } $sql .= ' ORDER BY majgd_descr'; $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); if($ga_array) { return $this->loadGeoAnalysisFromRow($ga_array); } return null; }
php
public function getGeoAnalysis($id, $only_enabled = true) { $args = array ( 'gedcom_id' => $this->tree->getTreeId(), 'ga_id' => $id ); $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . ' FROM `##maj_geodispersion`' . ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; if($only_enabled) { $sql .= ' AND majgd_status = :status'; $args['status'] = 'enabled'; } $sql .= ' ORDER BY majgd_descr'; $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); if($ga_array) { return $this->loadGeoAnalysisFromRow($ga_array); } return null; }
[ "public", "function", "getGeoAnalysis", "(", "$", "id", ",", "$", "only_enabled", "=", "true", ")", "{", "$", "args", "=", "array", "(", "'gedcom_id'", "=>", "$", "this", "->", "tree", "->", "getTreeId", "(", ")", ",", "'ga_id'", "=>", "$", "id", ")", ";", "$", "sql", "=", "'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'", ".", "' FROM `##maj_geodispersion`'", ".", "' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'", ";", "if", "(", "$", "only_enabled", ")", "{", "$", "sql", ".=", "' AND majgd_status = :status'", ";", "$", "args", "[", "'status'", "]", "=", "'enabled'", ";", "}", "$", "sql", ".=", "' ORDER BY majgd_descr'", ";", "$", "ga_array", "=", "Database", "::", "prepare", "(", "$", "sql", ")", "->", "execute", "(", "$", "args", ")", "->", "fetchOneRow", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "if", "(", "$", "ga_array", ")", "{", "return", "$", "this", "->", "loadGeoAnalysisFromRow", "(", "$", "ga_array", ")", ";", "}", "return", "null", ";", "}" ]
Get a geographical analysis by its ID. The function can only search for only enabled analysis, or all. @param int $id geodispersion analysis ID @param bool $only_enabled Search for only enabled geodispersion analysis @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL
[ "Get", "a", "geographical", "analysis", "by", "its", "ID", ".", "The", "function", "can", "only", "search", "for", "only", "enabled", "analysis", "or", "all", "." ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php#L112-L134
34,730
jon48/webtrees-lib
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php
GeoAnalysisProvider.createGeoAnalysis
public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { try{ Database::beginTransaction(); Database::prepare( 'INSERT INTO `##maj_geodispersion`'. ' (majgd_file, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen)'. ' VALUES (:gedcom_id, :description, :analysis_level, :map, :map_top_level, :use_flags, :gen_details)' )->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'description' => $description, 'analysis_level' => $analysis_level, 'use_flags' => $use_flags ? 'yes' : 'no', 'gen_details' => $gen_details, 'map' => $map_file, 'map_top_level' => $map_top_level )); $id = Database::lastInsertId(); $ga = $this->getGeoAnalysis($id, false); Database::commit(); } catch(\Exception $ex) { Database::rollback(); $ga = null; Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); } return $ga; }
php
public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { try{ Database::beginTransaction(); Database::prepare( 'INSERT INTO `##maj_geodispersion`'. ' (majgd_file, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen)'. ' VALUES (:gedcom_id, :description, :analysis_level, :map, :map_top_level, :use_flags, :gen_details)' )->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'description' => $description, 'analysis_level' => $analysis_level, 'use_flags' => $use_flags ? 'yes' : 'no', 'gen_details' => $gen_details, 'map' => $map_file, 'map_top_level' => $map_top_level )); $id = Database::lastInsertId(); $ga = $this->getGeoAnalysis($id, false); Database::commit(); } catch(\Exception $ex) { Database::rollback(); $ga = null; Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); } return $ga; }
[ "public", "function", "createGeoAnalysis", "(", "$", "description", ",", "$", "analysis_level", ",", "$", "map_file", ",", "$", "map_top_level", ",", "$", "use_flags", ",", "$", "gen_details", ")", "{", "try", "{", "Database", "::", "beginTransaction", "(", ")", ";", "Database", "::", "prepare", "(", "'INSERT INTO `##maj_geodispersion`'", ".", "' (majgd_file, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen)'", ".", "' VALUES (:gedcom_id, :description, :analysis_level, :map, :map_top_level, :use_flags, :gen_details)'", ")", "->", "execute", "(", "array", "(", "'gedcom_id'", "=>", "$", "this", "->", "tree", "->", "getTreeId", "(", ")", ",", "'description'", "=>", "$", "description", ",", "'analysis_level'", "=>", "$", "analysis_level", ",", "'use_flags'", "=>", "$", "use_flags", "?", "'yes'", ":", "'no'", ",", "'gen_details'", "=>", "$", "gen_details", ",", "'map'", "=>", "$", "map_file", ",", "'map_top_level'", "=>", "$", "map_top_level", ")", ")", ";", "$", "id", "=", "Database", "::", "lastInsertId", "(", ")", ";", "$", "ga", "=", "$", "this", "->", "getGeoAnalysis", "(", "$", "id", ",", "false", ")", ";", "Database", "::", "commit", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "Database", "::", "rollback", "(", ")", ";", "$", "ga", "=", "null", ";", "Log", "::", "addErrorLog", "(", "'A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['", ".", "$", "description", ".", "', '", ".", "$", "analysis_level", ".", "','", ".", "$", "map_file", ".", "','", ".", "$", "map_top_level", ".", "','", ".", "$", "use_flags", ".", "', '", ".", "$", "gen_details", ".", "']. Exception: '", ".", "$", "ex", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "ga", ";", "}" ]
Add a new geodispersion analysis in the database, in a transactional manner. When successful, eturns the newly created GeoAnalysis object. @param string $description geodispersion analysis title @param int $analysis_level Analysis level @param string $map_file Filename of the map @param int $map_top_level Parent level of the map @param bool $use_flags Use flag in the place display @param int $gen_details Number of top places to display @return GeoAnalysis
[ "Add", "a", "new", "geodispersion", "analysis", "in", "the", "database", "in", "a", "transactional", "manner", ".", "When", "successful", "eturns", "the", "newly", "created", "GeoAnalysis", "object", "." ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php#L148-L177
34,731
jon48/webtrees-lib
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php
GeoAnalysisProvider.deleteGeoAnalysis
public function deleteGeoAnalysis(GeoAnalysis $ga) { Database::prepare( 'DELETE FROM `##maj_geodispersion`'. ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' )->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'ga_id' => $ga->getId() )); }
php
public function deleteGeoAnalysis(GeoAnalysis $ga) { Database::prepare( 'DELETE FROM `##maj_geodispersion`'. ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' )->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'ga_id' => $ga->getId() )); }
[ "public", "function", "deleteGeoAnalysis", "(", "GeoAnalysis", "$", "ga", ")", "{", "Database", "::", "prepare", "(", "'DELETE FROM `##maj_geodispersion`'", ".", "' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'", ")", "->", "execute", "(", "array", "(", "'gedcom_id'", "=>", "$", "this", "->", "tree", "->", "getTreeId", "(", ")", ",", "'ga_id'", "=>", "$", "ga", "->", "getId", "(", ")", ")", ")", ";", "}" ]
Delete a geodispersion analysis from the database. @param GeoAnalysis $ga
[ "Delete", "a", "geodispersion", "analysis", "from", "the", "database", "." ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php#L246-L254
34,732
jon48/webtrees-lib
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php
GeoAnalysisProvider.getGeoAnalysisList
public function getGeoAnalysisList(){ $res = array(); $list = Database::prepare( 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . ' FROM `##maj_geodispersion`' . ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. ' ORDER BY majgd_descr' )->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'status' => 'enabled' ))->fetchAll(\PDO::FETCH_ASSOC); foreach($list as $ga) { $res[] = $this->loadGeoAnalysisFromRow($ga); } return $res; }
php
public function getGeoAnalysisList(){ $res = array(); $list = Database::prepare( 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . ' FROM `##maj_geodispersion`' . ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. ' ORDER BY majgd_descr' )->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'status' => 'enabled' ))->fetchAll(\PDO::FETCH_ASSOC); foreach($list as $ga) { $res[] = $this->loadGeoAnalysisFromRow($ga); } return $res; }
[ "public", "function", "getGeoAnalysisList", "(", ")", "{", "$", "res", "=", "array", "(", ")", ";", "$", "list", "=", "Database", "::", "prepare", "(", "'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen'", ".", "' FROM `##maj_geodispersion`'", ".", "' WHERE majgd_file = :gedcom_id AND majgd_status = :status'", ".", "' ORDER BY majgd_descr'", ")", "->", "execute", "(", "array", "(", "'gedcom_id'", "=>", "$", "this", "->", "tree", "->", "getTreeId", "(", ")", ",", "'status'", "=>", "'enabled'", ")", ")", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "foreach", "(", "$", "list", "as", "$", "ga", ")", "{", "$", "res", "[", "]", "=", "$", "this", "->", "loadGeoAnalysisFromRow", "(", "$", "ga", ")", ";", "}", "return", "$", "res", ";", "}" ]
Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM @return array List of enabled maps
[ "Return", "the", "list", "of", "geodispersion", "analysis", "recorded", "and", "enabled", "for", "a", "specific", "GEDCOM" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php#L261-L279
34,733
jon48/webtrees-lib
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php
GeoAnalysisProvider.getFilteredGeoAnalysisList
public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ $res = array(); $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . ' FROM `##maj_geodispersion`' . ' WHERE majgd_file = :gedcom_id'; $args = array('gedcom_id'=> $this->tree->getTreeId()); if($search) { $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; $args['search'] = $search; } if ($order_by) { $sql .= ' ORDER BY '; foreach ($order_by as $key => $value) { if ($key > 0) { $sql .= ','; } switch ($value['dir']) { case 'asc': $sql .= $value['column'] . ' ASC '; break; case 'desc': $sql .= $value['column'] . ' DESC '; break; } } } else { $sql .= ' ORDER BY majgd_descr ASC'; } if ($limit) { $sql .= " LIMIT :limit OFFSET :offset"; $args['limit'] = $limit; $args['offset'] = $start; } $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); foreach($data as $ga) { $res[] = $this->loadGeoAnalysisFromRow($ga); } return $res; }
php
public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ $res = array(); $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . ' FROM `##maj_geodispersion`' . ' WHERE majgd_file = :gedcom_id'; $args = array('gedcom_id'=> $this->tree->getTreeId()); if($search) { $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; $args['search'] = $search; } if ($order_by) { $sql .= ' ORDER BY '; foreach ($order_by as $key => $value) { if ($key > 0) { $sql .= ','; } switch ($value['dir']) { case 'asc': $sql .= $value['column'] . ' ASC '; break; case 'desc': $sql .= $value['column'] . ' DESC '; break; } } } else { $sql .= ' ORDER BY majgd_descr ASC'; } if ($limit) { $sql .= " LIMIT :limit OFFSET :offset"; $args['limit'] = $limit; $args['offset'] = $start; } $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); foreach($data as $ga) { $res[] = $this->loadGeoAnalysisFromRow($ga); } return $res; }
[ "public", "function", "getFilteredGeoAnalysisList", "(", "$", "search", "=", "null", ",", "$", "order_by", "=", "null", ",", "$", "start", "=", "0", ",", "$", "limit", "=", "null", ")", "{", "$", "res", "=", "array", "(", ")", ";", "$", "sql", "=", "'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'", ".", "' FROM `##maj_geodispersion`'", ".", "' WHERE majgd_file = :gedcom_id'", ";", "$", "args", "=", "array", "(", "'gedcom_id'", "=>", "$", "this", "->", "tree", "->", "getTreeId", "(", ")", ")", ";", "if", "(", "$", "search", ")", "{", "$", "sql", ".=", "' AND majgd_descr LIKE CONCAT(\\'%\\', :search, \\'%\\')'", ";", "$", "args", "[", "'search'", "]", "=", "$", "search", ";", "}", "if", "(", "$", "order_by", ")", "{", "$", "sql", ".=", "' ORDER BY '", ";", "foreach", "(", "$", "order_by", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", ">", "0", ")", "{", "$", "sql", ".=", "','", ";", "}", "switch", "(", "$", "value", "[", "'dir'", "]", ")", "{", "case", "'asc'", ":", "$", "sql", ".=", "$", "value", "[", "'column'", "]", ".", "' ASC '", ";", "break", ";", "case", "'desc'", ":", "$", "sql", ".=", "$", "value", "[", "'column'", "]", ".", "' DESC '", ";", "break", ";", "}", "}", "}", "else", "{", "$", "sql", ".=", "' ORDER BY majgd_descr ASC'", ";", "}", "if", "(", "$", "limit", ")", "{", "$", "sql", ".=", "\" LIMIT :limit OFFSET :offset\"", ";", "$", "args", "[", "'limit'", "]", "=", "$", "limit", ";", "$", "args", "[", "'offset'", "]", "=", "$", "start", ";", "}", "$", "data", "=", "Database", "::", "prepare", "(", "$", "sql", ")", "->", "execute", "(", "$", "args", ")", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "foreach", "(", "$", "data", "as", "$", "ga", ")", "{", "$", "res", "[", "]", "=", "$", "this", "->", "loadGeoAnalysisFromRow", "(", "$", "ga", ")", ";", "}", "return", "$", "res", ";", "}" ]
Return the list of geodispersion analysis matching specified criterias. @param string $search Search criteria in analysis description @param array $order_by Columns to order by @param int $start Offset to start with (for pagination) @param int|null $limit Max number of items to return (for pagination) @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[]
[ "Return", "the", "list", "of", "geodispersion", "analysis", "matching", "specified", "criterias", "." ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php#L290-L338
34,734
jon48/webtrees-lib
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php
GeoAnalysisProvider.getPlacesHierarchyFromHeader
protected function getPlacesHierarchyFromHeader() { $head = GedcomRecord::getInstance('HEAD', $this->tree); $head_place = $head->getFirstFact('PLAC'); if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ return array_reverse(array_map('trim',explode(',', $head_place_value))); } return null; }
php
protected function getPlacesHierarchyFromHeader() { $head = GedcomRecord::getInstance('HEAD', $this->tree); $head_place = $head->getFirstFact('PLAC'); if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ return array_reverse(array_map('trim',explode(',', $head_place_value))); } return null; }
[ "protected", "function", "getPlacesHierarchyFromHeader", "(", ")", "{", "$", "head", "=", "GedcomRecord", "::", "getInstance", "(", "'HEAD'", ",", "$", "this", "->", "tree", ")", ";", "$", "head_place", "=", "$", "head", "->", "getFirstFact", "(", "'PLAC'", ")", ";", "if", "(", "$", "head_place", "&&", "$", "head_place_value", "=", "$", "head_place", "->", "getAttribute", "(", "'FORM'", ")", ")", "{", "return", "array_reverse", "(", "array_map", "(", "'trim'", ",", "explode", "(", "','", ",", "$", "head_place_value", ")", ")", ")", ";", "}", "return", "null", ";", "}" ]
Returns an array of the place hierarchy, as defined in the GEDCOM header. The places are reversed compared to normal GEDCOM structure. @return array|null
[ "Returns", "an", "array", "of", "the", "place", "hierarchy", "as", "defined", "in", "the", "GEDCOM", "header", ".", "The", "places", "are", "reversed", "compared", "to", "normal", "GEDCOM", "structure", "." ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php#L367-L374
34,735
jon48/webtrees-lib
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php
GeoAnalysisProvider.getPlacesHierarchyFromData
protected function getPlacesHierarchyFromData() { $nb_levels = 0; //Select all '2 PLAC ' tags in the file and create array $places_list=array(); $ged_data = Database::prepare( 'SELECT i_gedcom AS gedcom'. ' FROM `##individuals`'. ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. ' UNION ALL'. 'SELECT f_gedcom AS gedcom'. ' FROM `##families`'. ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' )->execute(array( 'gedcom' => '%\n2 PLAC %', 'gedcom_id' => $this->tree->getTreeId() ))->fetchOneColumn(); foreach ($ged_data as $ged_datum) { $matches = null; preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); foreach ($matches[1] as $match) { $places_list[$match]=true; } } // Unique list of places $places_list=array_keys($places_list); //sort the array, limit to unique values, and count them usort($places_list, array('I18N', 'strcasecmp')); //calculate maximum no. of levels to display $has_found_good_example = false; foreach($places_list as $place){ $levels = explode(",", $place); $parts = count($levels); if ($parts >= $nb_levels){ $nb_levels = $parts; if(!$has_found_good_example){ $random_place = $place; if(min(array_map('strlen', $levels)) > 0){ $has_found_good_example = true; } } } } return array_reverse(array_map('trim',explode(',', $random_place))); }
php
protected function getPlacesHierarchyFromData() { $nb_levels = 0; //Select all '2 PLAC ' tags in the file and create array $places_list=array(); $ged_data = Database::prepare( 'SELECT i_gedcom AS gedcom'. ' FROM `##individuals`'. ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. ' UNION ALL'. 'SELECT f_gedcom AS gedcom'. ' FROM `##families`'. ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' )->execute(array( 'gedcom' => '%\n2 PLAC %', 'gedcom_id' => $this->tree->getTreeId() ))->fetchOneColumn(); foreach ($ged_data as $ged_datum) { $matches = null; preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); foreach ($matches[1] as $match) { $places_list[$match]=true; } } // Unique list of places $places_list=array_keys($places_list); //sort the array, limit to unique values, and count them usort($places_list, array('I18N', 'strcasecmp')); //calculate maximum no. of levels to display $has_found_good_example = false; foreach($places_list as $place){ $levels = explode(",", $place); $parts = count($levels); if ($parts >= $nb_levels){ $nb_levels = $parts; if(!$has_found_good_example){ $random_place = $place; if(min(array_map('strlen', $levels)) > 0){ $has_found_good_example = true; } } } } return array_reverse(array_map('trim',explode(',', $random_place))); }
[ "protected", "function", "getPlacesHierarchyFromData", "(", ")", "{", "$", "nb_levels", "=", "0", ";", "//Select all '2 PLAC ' tags in the file and create array", "$", "places_list", "=", "array", "(", ")", ";", "$", "ged_data", "=", "Database", "::", "prepare", "(", "'SELECT i_gedcom AS gedcom'", ".", "' FROM `##individuals`'", ".", "' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'", ".", "' UNION ALL'", ".", "'SELECT f_gedcom AS gedcom'", ".", "' FROM `##families`'", ".", "' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id'", ")", "->", "execute", "(", "array", "(", "'gedcom'", "=>", "'%\\n2 PLAC %'", ",", "'gedcom_id'", "=>", "$", "this", "->", "tree", "->", "getTreeId", "(", ")", ")", ")", "->", "fetchOneColumn", "(", ")", ";", "foreach", "(", "$", "ged_data", "as", "$", "ged_datum", ")", "{", "$", "matches", "=", "null", ";", "preg_match_all", "(", "'/\\n2 PLAC (.+)/'", ",", "$", "ged_datum", ",", "$", "matches", ")", ";", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "match", ")", "{", "$", "places_list", "[", "$", "match", "]", "=", "true", ";", "}", "}", "// Unique list of places", "$", "places_list", "=", "array_keys", "(", "$", "places_list", ")", ";", "//sort the array, limit to unique values, and count them", "usort", "(", "$", "places_list", ",", "array", "(", "'I18N'", ",", "'strcasecmp'", ")", ")", ";", "//calculate maximum no. of levels to display", "$", "has_found_good_example", "=", "false", ";", "foreach", "(", "$", "places_list", "as", "$", "place", ")", "{", "$", "levels", "=", "explode", "(", "\",\"", ",", "$", "place", ")", ";", "$", "parts", "=", "count", "(", "$", "levels", ")", ";", "if", "(", "$", "parts", ">=", "$", "nb_levels", ")", "{", "$", "nb_levels", "=", "$", "parts", ";", "if", "(", "!", "$", "has_found_good_example", ")", "{", "$", "random_place", "=", "$", "place", ";", "if", "(", "min", "(", "array_map", "(", "'strlen'", ",", "$", "levels", ")", ")", ">", "0", ")", "{", "$", "has_found_good_example", "=", "true", ";", "}", "}", "}", "}", "return", "array_reverse", "(", "array_map", "(", "'trim'", ",", "explode", "(", "','", ",", "$", "random_place", ")", ")", ")", ";", "}" ]
Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. It will look for the longest hierarchy in the tree. The places are reversed compared to normal GEDCOM structure. @return array
[ "Returns", "an", "array", "of", "the", "place", "hierarchy", "based", "on", "a", "random", "example", "of", "place", "within", "the", "GEDCOM", ".", "It", "will", "look", "for", "the", "longest", "hierarchy", "in", "the", "tree", ".", "The", "places", "are", "reversed", "compared", "to", "normal", "GEDCOM", "structure", "." ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php#L383-L431
34,736
jon48/webtrees-lib
src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php
GeoAnalysisProvider.getOutlineMapsList
public function getOutlineMapsList() { $res = array(); $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; if(is_dir($root_path)){ $dir = opendir($root_path); while (($file=readdir($dir))!== false) { if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { $res[base64_encode($file)] = new OutlineMap($file, true); } } } return $res; }
php
public function getOutlineMapsList() { $res = array(); $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; if(is_dir($root_path)){ $dir = opendir($root_path); while (($file=readdir($dir))!== false) { if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { $res[base64_encode($file)] = new OutlineMap($file, true); } } } return $res; }
[ "public", "function", "getOutlineMapsList", "(", ")", "{", "$", "res", "=", "array", "(", ")", ";", "$", "root_path", "=", "WT_ROOT", ".", "WT_MODULES_DIR", ".", "Constants", "::", "MODULE_MAJ_GEODISP_NAME", ".", "'/maps/'", ";", "if", "(", "is_dir", "(", "$", "root_path", ")", ")", "{", "$", "dir", "=", "opendir", "(", "$", "root_path", ")", ";", "while", "(", "(", "$", "file", "=", "readdir", "(", "$", "dir", ")", ")", "!==", "false", ")", "{", "if", "(", "preg_match", "(", "'/^[a-zA-Z0-9_]+.xml$/'", ",", "$", "file", ")", ")", "{", "$", "res", "[", "base64_encode", "(", "$", "file", ")", "]", "=", "new", "OutlineMap", "(", "$", "file", ",", "true", ")", ";", "}", "}", "}", "return", "$", "res", ";", "}" ]
Returns the list of geodispersion maps available within the maps folder. @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[]
[ "Returns", "the", "list", "of", "geodispersion", "maps", "available", "within", "the", "maps", "folder", "." ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/GeoDispersion/Model/GeoAnalysisProvider.php#L438-L450
34,737
jon48/webtrees-lib
src/Webtrees/Module/Sosa/SosaStatsController.php
SosaStatsController.htmlAncestorDispersionG2
private function htmlAncestorDispersionG2() { $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); if(count($ancestorsDispGen2) == 0) return; $size = '600x300'; $total = array_sum($ancestorsDispGen2); $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; $father = array ( 'color' => '84beff', 'count' => $father_count, 'perc' => Functions::safeDivision($father_count, $total), 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') ); $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; $mother = array ( 'color' => 'ffd1dc', 'count' => $mother_count, 'perc' => Functions::safeDivision($mother_count, $total), 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') ); $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; $shared = array ( 'color' => '777777', 'count' => $shared_count, 'perc' => Functions::safeDivision($shared_count, $total), 'name' => I18N::translate('Shared') ); $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); $chl = $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$father['color']},{$shared['color']},{$mother['color']}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; }
php
private function htmlAncestorDispersionG2() { $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); if(count($ancestorsDispGen2) == 0) return; $size = '600x300'; $total = array_sum($ancestorsDispGen2); $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; $father = array ( 'color' => '84beff', 'count' => $father_count, 'perc' => Functions::safeDivision($father_count, $total), 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') ); $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; $mother = array ( 'color' => 'ffd1dc', 'count' => $mother_count, 'perc' => Functions::safeDivision($mother_count, $total), 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') ); $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; $shared = array ( 'color' => '777777', 'count' => $shared_count, 'perc' => Functions::safeDivision($shared_count, $total), 'name' => I18N::translate('Shared') ); $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); $chl = $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$father['color']},{$shared['color']},{$mother['color']}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; }
[ "private", "function", "htmlAncestorDispersionG2", "(", ")", "{", "$", "ancestorsDispGen2", "=", "$", "this", "->", "sosa_provider", "->", "getAncestorDispersionForGen", "(", "2", ")", ";", "if", "(", "count", "(", "$", "ancestorsDispGen2", ")", "==", "0", ")", "return", ";", "$", "size", "=", "'600x300'", ";", "$", "total", "=", "array_sum", "(", "$", "ancestorsDispGen2", ")", ";", "$", "father_count", "=", "array_key_exists", "(", "1", ",", "$", "ancestorsDispGen2", ")", "?", "$", "ancestorsDispGen2", "[", "1", "]", ":", "0", ";", "$", "father", "=", "array", "(", "'color'", "=>", "'84beff'", ",", "'count'", "=>", "$", "father_count", ",", "'perc'", "=>", "Functions", "::", "safeDivision", "(", "$", "father_count", ",", "$", "total", ")", ",", "'name'", "=>", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Functions", "\\", "Functions", "::", "getRelationshipNameFromPath", "(", "'fat'", ")", ")", ";", "$", "mother_count", "=", "array_key_exists", "(", "2", ",", "$", "ancestorsDispGen2", ")", "?", "$", "ancestorsDispGen2", "[", "2", "]", ":", "0", ";", "$", "mother", "=", "array", "(", "'color'", "=>", "'ffd1dc'", ",", "'count'", "=>", "$", "mother_count", ",", "'perc'", "=>", "Functions", "::", "safeDivision", "(", "$", "mother_count", ",", "$", "total", ")", ",", "'name'", "=>", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Functions", "\\", "Functions", "::", "getRelationshipNameFromPath", "(", "'mot'", ")", ")", ";", "$", "shared_count", "=", "array_key_exists", "(", "-", "1", ",", "$", "ancestorsDispGen2", ")", "?", "$", "ancestorsDispGen2", "[", "-", "1", "]", ":", "0", ";", "$", "shared", "=", "array", "(", "'color'", "=>", "'777777'", ",", "'count'", "=>", "$", "shared_count", ",", "'perc'", "=>", "Functions", "::", "safeDivision", "(", "$", "shared_count", ",", "$", "total", ")", ",", "'name'", "=>", "I18N", "::", "translate", "(", "'Shared'", ")", ")", ";", "$", "chd", "=", "$", "this", "->", "arrayToExtendedEncoding", "(", "array", "(", "4095", "*", "$", "father", "[", "'perc'", "]", ",", "4095", "*", "$", "shared", "[", "'perc'", "]", ",", "4095", "*", "$", "mother", "[", "'perc'", "]", ")", ")", ";", "$", "chart_title", "=", "I18N", "::", "translate", "(", "'Known Sosa ancestors\\' dispersion'", ")", ";", "$", "chl", "=", "$", "father", "[", "'name'", "]", ".", "' - '", ".", "I18N", "::", "percentage", "(", "$", "father", "[", "'perc'", "]", ",", "1", ")", ".", "'|'", ".", "$", "shared", "[", "'name'", "]", ".", "' - '", ".", "I18N", "::", "percentage", "(", "$", "shared", "[", "'perc'", "]", ",", "1", ")", ".", "'|'", ".", "$", "mother", "[", "'name'", "]", ".", "' - '", ".", "I18N", "::", "percentage", "(", "$", "mother", "[", "'perc'", "]", ",", "1", ")", ";", "return", "\"<img src=\\\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$father['color']},{$shared['color']},{$mother['color']}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\\\" alt=\\\"\"", ".", "$", "chart_title", ".", "\"\\\" title=\\\"\"", ".", "$", "chart_title", ".", "\"\\\" />\"", ";", "}" ]
Returns HTML code for a graph showing the dispersion of ancestors across father & mother @return string HTML code
[ "Returns", "HTML", "code", "for", "a", "graph", "showing", "the", "dispersion", "of", "ancestors", "across", "father", "&", "mother" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/Sosa/SosaStatsController.php#L154-L191
34,738
jon48/webtrees-lib
src/Webtrees/Module/Sosa/SosaStatsController.php
SosaStatsController.htmlAncestorDispersionG3
private function htmlAncestorDispersionG3() { $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3); $size = '700x300'; $color_motmot = 'ffd1dc'; $color_motfat = 'b998a0'; $color_fatfat = '577292'; $color_fatmot = '84beff'; $color_shared = '777777'; $total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; $total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; $chd = $this->arrayToExtendedEncoding(array( 4095 * Functions::safeDivision($total_fatfat, $total), 4095 * Functions::safeDivision($total_fatmot, $total), 4095 * Functions::safeDivision($total_sha, $total), 4095 * Functions::safeDivision($total_motfat, $total), 4095 * Functions::safeDivision($total_motmot, $total) )); $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); $chl = \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; }
php
private function htmlAncestorDispersionG3() { $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3); $size = '700x300'; $color_motmot = 'ffd1dc'; $color_motfat = 'b998a0'; $color_fatfat = '577292'; $color_fatmot = '84beff'; $color_shared = '777777'; $total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; $total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; $chd = $this->arrayToExtendedEncoding(array( 4095 * Functions::safeDivision($total_fatfat, $total), 4095 * Functions::safeDivision($total_fatmot, $total), 4095 * Functions::safeDivision($total_sha, $total), 4095 * Functions::safeDivision($total_motfat, $total), 4095 * Functions::safeDivision($total_motmot, $total) )); $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); $chl = \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; }
[ "private", "function", "htmlAncestorDispersionG3", "(", ")", "{", "$", "ancestorsDispGen2", "=", "$", "this", "->", "sosa_provider", "->", "getAncestorDispersionForGen", "(", "3", ")", ";", "$", "size", "=", "'700x300'", ";", "$", "color_motmot", "=", "'ffd1dc'", ";", "$", "color_motfat", "=", "'b998a0'", ";", "$", "color_fatfat", "=", "'577292'", ";", "$", "color_fatmot", "=", "'84beff'", ";", "$", "color_shared", "=", "'777777'", ";", "$", "total_fatfat", "=", "array_key_exists", "(", "1", ",", "$", "ancestorsDispGen2", ")", "?", "$", "ancestorsDispGen2", "[", "1", "]", ":", "0", ";", "$", "total_fatmot", "=", "array_key_exists", "(", "2", ",", "$", "ancestorsDispGen2", ")", "?", "$", "ancestorsDispGen2", "[", "2", "]", ":", "0", ";", "$", "total_motfat", "=", "array_key_exists", "(", "4", ",", "$", "ancestorsDispGen2", ")", "?", "$", "ancestorsDispGen2", "[", "4", "]", ":", "0", ";", "$", "total_motmot", "=", "array_key_exists", "(", "8", ",", "$", "ancestorsDispGen2", ")", "?", "$", "ancestorsDispGen2", "[", "8", "]", ":", "0", ";", "$", "total_sha", "=", "array_key_exists", "(", "-", "1", ",", "$", "ancestorsDispGen2", ")", "?", "$", "ancestorsDispGen2", "[", "-", "1", "]", ":", "0", ";", "$", "total", "=", "$", "total_fatfat", "+", "$", "total_fatmot", "+", "$", "total_motfat", "+", "$", "total_motmot", "+", "$", "total_sha", ";", "$", "chd", "=", "$", "this", "->", "arrayToExtendedEncoding", "(", "array", "(", "4095", "*", "Functions", "::", "safeDivision", "(", "$", "total_fatfat", ",", "$", "total", ")", ",", "4095", "*", "Functions", "::", "safeDivision", "(", "$", "total_fatmot", ",", "$", "total", ")", ",", "4095", "*", "Functions", "::", "safeDivision", "(", "$", "total_sha", ",", "$", "total", ")", ",", "4095", "*", "Functions", "::", "safeDivision", "(", "$", "total_motfat", ",", "$", "total", ")", ",", "4095", "*", "Functions", "::", "safeDivision", "(", "$", "total_motmot", ",", "$", "total", ")", ")", ")", ";", "$", "chart_title", "=", "I18N", "::", "translate", "(", "'Known Sosa ancestors\\' dispersion - G3'", ")", ";", "$", "chl", "=", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Functions", "\\", "Functions", "::", "getRelationshipNameFromPath", "(", "'fatfat'", ")", ".", "' - '", ".", "I18N", "::", "percentage", "(", "Functions", "::", "safeDivision", "(", "$", "total_fatfat", ",", "$", "total", ")", ",", "1", ")", ".", "'|'", ".", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Functions", "\\", "Functions", "::", "getRelationshipNameFromPath", "(", "'fatmot'", ")", ".", "' - '", ".", "I18N", "::", "percentage", "(", "Functions", "::", "safeDivision", "(", "$", "total_fatmot", ",", "$", "total", ")", ",", "1", ")", ".", "'|'", ".", "I18N", "::", "translate", "(", "'Shared'", ")", ".", "' - '", ".", "I18N", "::", "percentage", "(", "Functions", "::", "safeDivision", "(", "$", "total_sha", ",", "$", "total", ")", ",", "1", ")", ".", "'|'", ".", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Functions", "\\", "Functions", "::", "getRelationshipNameFromPath", "(", "'motfat'", ")", ".", "' - '", ".", "I18N", "::", "percentage", "(", "Functions", "::", "safeDivision", "(", "$", "total_motfat", ",", "$", "total", ")", ",", "1", ")", ".", "'|'", ".", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Functions", "\\", "Functions", "::", "getRelationshipNameFromPath", "(", "'motmot'", ")", ".", "' - '", ".", "I18N", "::", "percentage", "(", "Functions", "::", "safeDivision", "(", "$", "total_motmot", ",", "$", "total", ")", ",", "1", ")", ";", "return", "\"<img src=\\\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&amp;chd=e:{$chd}&amp;chs={$size}&amp;chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&amp;chf=bg,s,ffffff00&amp;chl={$chl}\\\" alt=\\\"\"", ".", "$", "chart_title", ".", "\"\\\" title=\\\"\"", ".", "$", "chart_title", ".", "\"\\\" />\"", ";", "}" ]
Returns HTML code for a graph showing the dispersion of ancestors across grand-parents @return string HTML code
[ "Returns", "HTML", "code", "for", "a", "graph", "showing", "the", "dispersion", "of", "ancestors", "across", "grand", "-", "parents" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/Sosa/SosaStatsController.php#L197-L231
34,739
jon48/webtrees-lib
src/Webtrees/Module/Sosa/SosaStatsController.php
SosaStatsController.arrayToExtendedEncoding
private function arrayToExtendedEncoding($a) { $xencoding = WT_GOOGLE_CHART_ENCODING; $encoding = ''; foreach ($a as $value) { if ($value < 0) { $value = 0; } $first = (int) ($value / 64); $second = $value % 64; $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; } return $encoding; }
php
private function arrayToExtendedEncoding($a) { $xencoding = WT_GOOGLE_CHART_ENCODING; $encoding = ''; foreach ($a as $value) { if ($value < 0) { $value = 0; } $first = (int) ($value / 64); $second = $value % 64; $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; } return $encoding; }
[ "private", "function", "arrayToExtendedEncoding", "(", "$", "a", ")", "{", "$", "xencoding", "=", "WT_GOOGLE_CHART_ENCODING", ";", "$", "encoding", "=", "''", ";", "foreach", "(", "$", "a", "as", "$", "value", ")", "{", "if", "(", "$", "value", "<", "0", ")", "{", "$", "value", "=", "0", ";", "}", "$", "first", "=", "(", "int", ")", "(", "$", "value", "/", "64", ")", ";", "$", "second", "=", "$", "value", "%", "64", ";", "$", "encoding", ".=", "$", "xencoding", "[", "(", "int", ")", "$", "first", "]", ".", "$", "xencoding", "[", "(", "int", ")", "$", "second", "]", ";", "}", "return", "$", "encoding", ";", "}" ]
Convert an array to Google Chart encoding @param arrat $a Array to encode @return string
[ "Convert", "an", "array", "to", "Google", "Chart", "encoding" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/Sosa/SosaStatsController.php#L238-L252
34,740
CESNET/perun-simplesamlphp-module
lib/Disco.php
Disco.handleRequest
public function handleRequest() { // test if user has selected an idp or idp can be deremine automatically somehow. $this->start(); // no choice possible. Show discovery service page $idpList = $this->getIdPList(); if (isset($this->originalsp['disco.addInstitutionApp']) && $this->originalsp['disco.addInstitutionApp'] === true ) { $idpList = $this->filterAddInstitutionList($idpList); } else { $idpList = $this->filterList($idpList); } $preferredIdP = $this->getRecommendedIdP(); $preferredIdP = array_key_exists($preferredIdP, $idpList) ? $preferredIdP : null; if (sizeof($idpList) === 1) { $idp = array_keys($idpList)[0]; $url = Disco::buildContinueUrl( $this->spEntityId, $this->returnURL, $this->returnIdParam, $idp ); Logger::info('perun.Disco: Only one Idp left. Redirecting automatically. IdP: ' . $idp); HTTP::redirectTrustedURL($url); } $t = new DiscoTemplate($this->config); $t->data['originalsp'] = $this->originalsp; $t->data['idplist'] = $this->idplistStructured($idpList); $t->data['preferredidp'] = $preferredIdP; $t->data['entityID'] = $this->spEntityId; $t->data['return'] = $this->returnURL; $t->data['returnIDParam'] = $this->returnIdParam; $t->data['AuthnContextClassRef'] = $this->authnContextClassRef; $t->show(); }
php
public function handleRequest() { // test if user has selected an idp or idp can be deremine automatically somehow. $this->start(); // no choice possible. Show discovery service page $idpList = $this->getIdPList(); if (isset($this->originalsp['disco.addInstitutionApp']) && $this->originalsp['disco.addInstitutionApp'] === true ) { $idpList = $this->filterAddInstitutionList($idpList); } else { $idpList = $this->filterList($idpList); } $preferredIdP = $this->getRecommendedIdP(); $preferredIdP = array_key_exists($preferredIdP, $idpList) ? $preferredIdP : null; if (sizeof($idpList) === 1) { $idp = array_keys($idpList)[0]; $url = Disco::buildContinueUrl( $this->spEntityId, $this->returnURL, $this->returnIdParam, $idp ); Logger::info('perun.Disco: Only one Idp left. Redirecting automatically. IdP: ' . $idp); HTTP::redirectTrustedURL($url); } $t = new DiscoTemplate($this->config); $t->data['originalsp'] = $this->originalsp; $t->data['idplist'] = $this->idplistStructured($idpList); $t->data['preferredidp'] = $preferredIdP; $t->data['entityID'] = $this->spEntityId; $t->data['return'] = $this->returnURL; $t->data['returnIDParam'] = $this->returnIdParam; $t->data['AuthnContextClassRef'] = $this->authnContextClassRef; $t->show(); }
[ "public", "function", "handleRequest", "(", ")", "{", "// test if user has selected an idp or idp can be deremine automatically somehow.", "$", "this", "->", "start", "(", ")", ";", "// no choice possible. Show discovery service page", "$", "idpList", "=", "$", "this", "->", "getIdPList", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "originalsp", "[", "'disco.addInstitutionApp'", "]", ")", "&&", "$", "this", "->", "originalsp", "[", "'disco.addInstitutionApp'", "]", "===", "true", ")", "{", "$", "idpList", "=", "$", "this", "->", "filterAddInstitutionList", "(", "$", "idpList", ")", ";", "}", "else", "{", "$", "idpList", "=", "$", "this", "->", "filterList", "(", "$", "idpList", ")", ";", "}", "$", "preferredIdP", "=", "$", "this", "->", "getRecommendedIdP", "(", ")", ";", "$", "preferredIdP", "=", "array_key_exists", "(", "$", "preferredIdP", ",", "$", "idpList", ")", "?", "$", "preferredIdP", ":", "null", ";", "if", "(", "sizeof", "(", "$", "idpList", ")", "===", "1", ")", "{", "$", "idp", "=", "array_keys", "(", "$", "idpList", ")", "[", "0", "]", ";", "$", "url", "=", "Disco", "::", "buildContinueUrl", "(", "$", "this", "->", "spEntityId", ",", "$", "this", "->", "returnURL", ",", "$", "this", "->", "returnIdParam", ",", "$", "idp", ")", ";", "Logger", "::", "info", "(", "'perun.Disco: Only one Idp left. Redirecting automatically. IdP: '", ".", "$", "idp", ")", ";", "HTTP", "::", "redirectTrustedURL", "(", "$", "url", ")", ";", "}", "$", "t", "=", "new", "DiscoTemplate", "(", "$", "this", "->", "config", ")", ";", "$", "t", "->", "data", "[", "'originalsp'", "]", "=", "$", "this", "->", "originalsp", ";", "$", "t", "->", "data", "[", "'idplist'", "]", "=", "$", "this", "->", "idplistStructured", "(", "$", "idpList", ")", ";", "$", "t", "->", "data", "[", "'preferredidp'", "]", "=", "$", "preferredIdP", ";", "$", "t", "->", "data", "[", "'entityID'", "]", "=", "$", "this", "->", "spEntityId", ";", "$", "t", "->", "data", "[", "'return'", "]", "=", "$", "this", "->", "returnURL", ";", "$", "t", "->", "data", "[", "'returnIDParam'", "]", "=", "$", "this", "->", "returnIdParam", ";", "$", "t", "->", "data", "[", "'AuthnContextClassRef'", "]", "=", "$", "this", "->", "authnContextClassRef", ";", "$", "t", "->", "show", "(", ")", ";", "}" ]
Handles a request to this discovery service. It is enry point of Discovery service. The IdP disco parameters should be set before calling this function.
[ "Handles", "a", "request", "to", "this", "discovery", "service", ".", "It", "is", "enry", "point", "of", "Discovery", "service", "." ]
f1d686f06472053a7cdb31f2b2776f9714779ee1
https://github.com/CESNET/perun-simplesamlphp-module/blob/f1d686f06472053a7cdb31f2b2776f9714779ee1/lib/Disco.php#L79-L119
34,741
CESNET/perun-simplesamlphp-module
lib/Disco.php
Disco.filterList
protected function filterList($list) { $conf = Configuration::getConfig(self::CONFIG_FILE_NAME); $disableWhitelisting = $conf->getBoolean(self::PROPNAME_DISABLE_WHITELISTING, false); if (!isset($this->originalsp['disco.doNotFilterIdps']) || !$this->originalsp['disco.doNotFilterIdps'] ) { $list = parent::filterList($list); $list = $this->scoping($list); if (!$disableWhitelisting) { $list = $this->whitelisting($list); } $list = $this->greylisting($list); $list = $this->greylistingPerSP($list, $this->originalsp); } if (empty($list)) { throw new Exception('All IdPs has been filtered out. And no one left.'); } return $list; }
php
protected function filterList($list) { $conf = Configuration::getConfig(self::CONFIG_FILE_NAME); $disableWhitelisting = $conf->getBoolean(self::PROPNAME_DISABLE_WHITELISTING, false); if (!isset($this->originalsp['disco.doNotFilterIdps']) || !$this->originalsp['disco.doNotFilterIdps'] ) { $list = parent::filterList($list); $list = $this->scoping($list); if (!$disableWhitelisting) { $list = $this->whitelisting($list); } $list = $this->greylisting($list); $list = $this->greylistingPerSP($list, $this->originalsp); } if (empty($list)) { throw new Exception('All IdPs has been filtered out. And no one left.'); } return $list; }
[ "protected", "function", "filterList", "(", "$", "list", ")", "{", "$", "conf", "=", "Configuration", "::", "getConfig", "(", "self", "::", "CONFIG_FILE_NAME", ")", ";", "$", "disableWhitelisting", "=", "$", "conf", "->", "getBoolean", "(", "self", "::", "PROPNAME_DISABLE_WHITELISTING", ",", "false", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "originalsp", "[", "'disco.doNotFilterIdps'", "]", ")", "||", "!", "$", "this", "->", "originalsp", "[", "'disco.doNotFilterIdps'", "]", ")", "{", "$", "list", "=", "parent", "::", "filterList", "(", "$", "list", ")", ";", "$", "list", "=", "$", "this", "->", "scoping", "(", "$", "list", ")", ";", "if", "(", "!", "$", "disableWhitelisting", ")", "{", "$", "list", "=", "$", "this", "->", "whitelisting", "(", "$", "list", ")", ";", "}", "$", "list", "=", "$", "this", "->", "greylisting", "(", "$", "list", ")", ";", "$", "list", "=", "$", "this", "->", "greylistingPerSP", "(", "$", "list", ",", "$", "this", "->", "originalsp", ")", ";", "}", "if", "(", "empty", "(", "$", "list", ")", ")", "{", "throw", "new", "Exception", "(", "'All IdPs has been filtered out. And no one left.'", ")", ";", "}", "return", "$", "list", ";", "}" ]
Filter a list of entities according to any filters defined in the parent class, plus @param array $list A map of entities to filter. @return array The list in $list after filtering entities. @throws Exception if all IdPs are filtered out and no one left.
[ "Filter", "a", "list", "of", "entities", "according", "to", "any", "filters", "defined", "in", "the", "parent", "class", "plus" ]
f1d686f06472053a7cdb31f2b2776f9714779ee1
https://github.com/CESNET/perun-simplesamlphp-module/blob/f1d686f06472053a7cdb31f2b2776f9714779ee1/lib/Disco.php#L128-L151
34,742
CESNET/perun-simplesamlphp-module
lib/Disco.php
Disco.filterAddInstitutionList
protected function filterAddInstitutionList($list) { foreach ($list as $entityId => $idp) { if (in_array($entityId, $this->whitelist)) { unset($list[$entityId]); } } if (empty($list)) { throw new Exception('All IdPs has been filtered out. And no one left.'); } return $list; }
php
protected function filterAddInstitutionList($list) { foreach ($list as $entityId => $idp) { if (in_array($entityId, $this->whitelist)) { unset($list[$entityId]); } } if (empty($list)) { throw new Exception('All IdPs has been filtered out. And no one left.'); } return $list; }
[ "protected", "function", "filterAddInstitutionList", "(", "$", "list", ")", "{", "foreach", "(", "$", "list", "as", "$", "entityId", "=>", "$", "idp", ")", "{", "if", "(", "in_array", "(", "$", "entityId", ",", "$", "this", "->", "whitelist", ")", ")", "{", "unset", "(", "$", "list", "[", "$", "entityId", "]", ")", ";", "}", "}", "if", "(", "empty", "(", "$", "list", ")", ")", "{", "throw", "new", "Exception", "(", "'All IdPs has been filtered out. And no one left.'", ")", ";", "}", "return", "$", "list", ";", "}" ]
Filter a list of entities for addInstitution app according to if entityID is whitelisted or not @param array $list A map of entities to filter. @return array The list in $list after filtering entities. @throws Exception if all IdPs are filtered out and no one left.
[ "Filter", "a", "list", "of", "entities", "for", "addInstitution", "app", "according", "to", "if", "entityID", "is", "whitelisted", "or", "not" ]
f1d686f06472053a7cdb31f2b2776f9714779ee1
https://github.com/CESNET/perun-simplesamlphp-module/blob/f1d686f06472053a7cdb31f2b2776f9714779ee1/lib/Disco.php#L160-L173
34,743
CESNET/perun-simplesamlphp-module
lib/Disco.php
Disco.removeAuthContextClassRefWithPrefix
public function removeAuthContextClassRefWithPrefix(&$state) { $conf = Configuration::getConfig(self::CONFIG_FILE_NAME); $prefix = $conf->getString(self::PROPNAME_PREFIX, null); if (is_null($prefix)) { return; } unset($state['saml:RequestedAuthnContext']['AuthnContextClassRef']); $array = array(); foreach ($this->authnContextClassRef as $value) { if (!(substr($value, 0, strlen($prefix)) === $prefix)) { array_push($array, $value); } } if (!empty($array)) { $state['saml:RequestedAuthnContext']['AuthnContextClassRef'] = $array; } }
php
public function removeAuthContextClassRefWithPrefix(&$state) { $conf = Configuration::getConfig(self::CONFIG_FILE_NAME); $prefix = $conf->getString(self::PROPNAME_PREFIX, null); if (is_null($prefix)) { return; } unset($state['saml:RequestedAuthnContext']['AuthnContextClassRef']); $array = array(); foreach ($this->authnContextClassRef as $value) { if (!(substr($value, 0, strlen($prefix)) === $prefix)) { array_push($array, $value); } } if (!empty($array)) { $state['saml:RequestedAuthnContext']['AuthnContextClassRef'] = $array; } }
[ "public", "function", "removeAuthContextClassRefWithPrefix", "(", "&", "$", "state", ")", "{", "$", "conf", "=", "Configuration", "::", "getConfig", "(", "self", "::", "CONFIG_FILE_NAME", ")", ";", "$", "prefix", "=", "$", "conf", "->", "getString", "(", "self", "::", "PROPNAME_PREFIX", ",", "null", ")", ";", "if", "(", "is_null", "(", "$", "prefix", ")", ")", "{", "return", ";", "}", "unset", "(", "$", "state", "[", "'saml:RequestedAuthnContext'", "]", "[", "'AuthnContextClassRef'", "]", ")", ";", "$", "array", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "authnContextClassRef", "as", "$", "value", ")", "{", "if", "(", "!", "(", "substr", "(", "$", "value", ",", "0", ",", "strlen", "(", "$", "prefix", ")", ")", "===", "$", "prefix", ")", ")", "{", "array_push", "(", "$", "array", ",", "$", "value", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "array", ")", ")", "{", "$", "state", "[", "'saml:RequestedAuthnContext'", "]", "[", "'AuthnContextClassRef'", "]", "=", "$", "array", ";", "}", "}" ]
This method remove all AuthnContextClassRef which start with prefix from configuration @param $state
[ "This", "method", "remove", "all", "AuthnContextClassRef", "which", "start", "with", "prefix", "from", "configuration" ]
f1d686f06472053a7cdb31f2b2776f9714779ee1
https://github.com/CESNET/perun-simplesamlphp-module/blob/f1d686f06472053a7cdb31f2b2776f9714779ee1/lib/Disco.php#L307-L326
34,744
jon48/webtrees-lib
src/Webtrees/Module/Certificates/Model/Certificate.php
Certificate.setSource
public function setSource($xref){ if($xref instanceof Source){ $this->source = $xref; } else { $this->source = Source::getInstance($xref, $this->tree); } }
php
public function setSource($xref){ if($xref instanceof Source){ $this->source = $xref; } else { $this->source = Source::getInstance($xref, $this->tree); } }
[ "public", "function", "setSource", "(", "$", "xref", ")", "{", "if", "(", "$", "xref", "instanceof", "Source", ")", "{", "$", "this", "->", "source", "=", "$", "xref", ";", "}", "else", "{", "$", "this", "->", "source", "=", "Source", "::", "getInstance", "(", "$", "xref", ",", "$", "this", "->", "tree", ")", ";", "}", "}" ]
Define a source associated with the certificate @param string|Source $xref
[ "Define", "a", "source", "associated", "with", "the", "certificate" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/Certificates/Model/Certificate.php#L156-L162
34,745
jon48/webtrees-lib
src/Webtrees/Module/Certificates/Model/Certificate.php
Certificate.fetchALinkedSource
public function fetchALinkedSource(){ $sid = null; // Try to find in individual, then families, then other types of records. We are interested in the first available value. $ged = Database::prepare( 'SELECT i_gedcom AS gedrec FROM `##individuals`'. ' WHERE i_file=:gedcom_id AND i_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); if(!$ged){ $ged = Database::prepare( 'SELECT f_gedcom AS gedrec FROM `##families`'. ' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); if(!$ged){ $ged = Database::prepare( 'SELECT o_gedcom AS gedrec FROM `##other`'. ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); } } //If a record has been found, parse it to find the source reference. if($ged){ $gedlines = explode("\n", $ged); $level = 0; $levelsource = -1; $sid_tmp=null; $sourcefound = false; foreach($gedlines as $gedline){ // Get the level $match = null; if (!$sourcefound && preg_match('~^('.WT_REGEX_INTEGER.') ~', $gedline, $match)) { $level = $match[1]; //If we are not any more within the context of a source, reset if($level <= $levelsource){ $levelsource = -1; $sid_tmp = null; } // If a source, get the level and the reference $match2 = null; if (preg_match('~^'.$level.' SOUR @('.WT_REGEX_XREF.')@$~', $gedline, $match2)) { $levelsource = $level; $sid_tmp=$match2[1]; } // If the image has be found, get the source reference and exit. $match3 = null; if($levelsource>=0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)){ $sid = $sid_tmp; $sourcefound = true; } } } } if($sid) $this->source = Source::getInstance($sid, $this->tree); return $this->source; }
php
public function fetchALinkedSource(){ $sid = null; // Try to find in individual, then families, then other types of records. We are interested in the first available value. $ged = Database::prepare( 'SELECT i_gedcom AS gedrec FROM `##individuals`'. ' WHERE i_file=:gedcom_id AND i_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); if(!$ged){ $ged = Database::prepare( 'SELECT f_gedcom AS gedrec FROM `##families`'. ' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); if(!$ged){ $ged = Database::prepare( 'SELECT o_gedcom AS gedrec FROM `##other`'. ' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom') ->execute(array( 'gedcom_id' => $this->tree->getTreeId(), 'gedcom' => '%_ACT '.$this->getFilename().'%' ))->fetchOne(); } } //If a record has been found, parse it to find the source reference. if($ged){ $gedlines = explode("\n", $ged); $level = 0; $levelsource = -1; $sid_tmp=null; $sourcefound = false; foreach($gedlines as $gedline){ // Get the level $match = null; if (!$sourcefound && preg_match('~^('.WT_REGEX_INTEGER.') ~', $gedline, $match)) { $level = $match[1]; //If we are not any more within the context of a source, reset if($level <= $levelsource){ $levelsource = -1; $sid_tmp = null; } // If a source, get the level and the reference $match2 = null; if (preg_match('~^'.$level.' SOUR @('.WT_REGEX_XREF.')@$~', $gedline, $match2)) { $levelsource = $level; $sid_tmp=$match2[1]; } // If the image has be found, get the source reference and exit. $match3 = null; if($levelsource>=0 && $sid_tmp && preg_match('~^'.$level.' _ACT '.preg_quote($this->getFilename()).'~', $gedline, $match3)){ $sid = $sid_tmp; $sourcefound = true; } } } } if($sid) $this->source = Source::getInstance($sid, $this->tree); return $this->source; }
[ "public", "function", "fetchALinkedSource", "(", ")", "{", "$", "sid", "=", "null", ";", "// Try to find in individual, then families, then other types of records. We are interested in the first available value.", "$", "ged", "=", "Database", "::", "prepare", "(", "'SELECT i_gedcom AS gedrec FROM `##individuals`'", ".", "' WHERE i_file=:gedcom_id AND i_gedcom LIKE :gedcom'", ")", "->", "execute", "(", "array", "(", "'gedcom_id'", "=>", "$", "this", "->", "tree", "->", "getTreeId", "(", ")", ",", "'gedcom'", "=>", "'%_ACT '", ".", "$", "this", "->", "getFilename", "(", ")", ".", "'%'", ")", ")", "->", "fetchOne", "(", ")", ";", "if", "(", "!", "$", "ged", ")", "{", "$", "ged", "=", "Database", "::", "prepare", "(", "'SELECT f_gedcom AS gedrec FROM `##families`'", ".", "' WHERE f_file=:gedcom_id AND f_gedcom LIKE :gedcom'", ")", "->", "execute", "(", "array", "(", "'gedcom_id'", "=>", "$", "this", "->", "tree", "->", "getTreeId", "(", ")", ",", "'gedcom'", "=>", "'%_ACT '", ".", "$", "this", "->", "getFilename", "(", ")", ".", "'%'", ")", ")", "->", "fetchOne", "(", ")", ";", "if", "(", "!", "$", "ged", ")", "{", "$", "ged", "=", "Database", "::", "prepare", "(", "'SELECT o_gedcom AS gedrec FROM `##other`'", ".", "' WHERE o_file=:gedcom_id AND o_gedcom LIKE :gedcom'", ")", "->", "execute", "(", "array", "(", "'gedcom_id'", "=>", "$", "this", "->", "tree", "->", "getTreeId", "(", ")", ",", "'gedcom'", "=>", "'%_ACT '", ".", "$", "this", "->", "getFilename", "(", ")", ".", "'%'", ")", ")", "->", "fetchOne", "(", ")", ";", "}", "}", "//If a record has been found, parse it to find the source reference.", "if", "(", "$", "ged", ")", "{", "$", "gedlines", "=", "explode", "(", "\"\\n\"", ",", "$", "ged", ")", ";", "$", "level", "=", "0", ";", "$", "levelsource", "=", "-", "1", ";", "$", "sid_tmp", "=", "null", ";", "$", "sourcefound", "=", "false", ";", "foreach", "(", "$", "gedlines", "as", "$", "gedline", ")", "{", "// Get the level", "$", "match", "=", "null", ";", "if", "(", "!", "$", "sourcefound", "&&", "preg_match", "(", "'~^('", ".", "WT_REGEX_INTEGER", ".", "') ~'", ",", "$", "gedline", ",", "$", "match", ")", ")", "{", "$", "level", "=", "$", "match", "[", "1", "]", ";", "//If we are not any more within the context of a source, reset", "if", "(", "$", "level", "<=", "$", "levelsource", ")", "{", "$", "levelsource", "=", "-", "1", ";", "$", "sid_tmp", "=", "null", ";", "}", "// If a source, get the level and the reference", "$", "match2", "=", "null", ";", "if", "(", "preg_match", "(", "'~^'", ".", "$", "level", ".", "' SOUR @('", ".", "WT_REGEX_XREF", ".", "')@$~'", ",", "$", "gedline", ",", "$", "match2", ")", ")", "{", "$", "levelsource", "=", "$", "level", ";", "$", "sid_tmp", "=", "$", "match2", "[", "1", "]", ";", "}", "// If the image has be found, get the source reference and exit.", "$", "match3", "=", "null", ";", "if", "(", "$", "levelsource", ">=", "0", "&&", "$", "sid_tmp", "&&", "preg_match", "(", "'~^'", ".", "$", "level", ".", "' _ACT '", ".", "preg_quote", "(", "$", "this", "->", "getFilename", "(", ")", ")", ".", "'~'", ",", "$", "gedline", ",", "$", "match3", ")", ")", "{", "$", "sid", "=", "$", "sid_tmp", ";", "$", "sourcefound", "=", "true", ";", "}", "}", "}", "}", "if", "(", "$", "sid", ")", "$", "this", "->", "source", "=", "Source", "::", "getInstance", "(", "$", "sid", ",", "$", "this", "->", "tree", ")", ";", "return", "$", "this", "->", "source", ";", "}" ]
Returns a unique source linked to the certificate @return Source|NULL Linked source
[ "Returns", "a", "unique", "source", "linked", "to", "the", "certificate" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Module/Certificates/Model/Certificate.php#L369-L435
34,746
c4studio/chronos
src/Chronos/Scaffolding/app/Exceptions/Handler.php
Handler.tokenMismatch
protected function tokenMismatch($request, TokenMismatchException $e) { // check if Chronos path or app if ($request && ($request->is('admin') || $request->is('admin/*'))) return response()->view("chronos::errors.token_mismatch", ['exception' => $e]); else return $this->convertExceptionToResponse($e); }
php
protected function tokenMismatch($request, TokenMismatchException $e) { // check if Chronos path or app if ($request && ($request->is('admin') || $request->is('admin/*'))) return response()->view("chronos::errors.token_mismatch", ['exception' => $e]); else return $this->convertExceptionToResponse($e); }
[ "protected", "function", "tokenMismatch", "(", "$", "request", ",", "TokenMismatchException", "$", "e", ")", "{", "// check if Chronos path or app", "if", "(", "$", "request", "&&", "(", "$", "request", "->", "is", "(", "'admin'", ")", "||", "$", "request", "->", "is", "(", "'admin/*'", ")", ")", ")", "return", "response", "(", ")", "->", "view", "(", "\"chronos::errors.token_mismatch\"", ",", "[", "'exception'", "=>", "$", "e", "]", ")", ";", "else", "return", "$", "this", "->", "convertExceptionToResponse", "(", "$", "e", ")", ";", "}" ]
Renders the token mismatch exception page. @param \Illuminate\Http\Request $request @param \Illuminate\Auth\AuthenticationException $e @return \Illuminate\Http\Response
[ "Renders", "the", "token", "mismatch", "exception", "page", "." ]
df7f3a9794afaade3bee8f6be1223c98e4936cb2
https://github.com/c4studio/chronos/blob/df7f3a9794afaade3bee8f6be1223c98e4936cb2/src/Chronos/Scaffolding/app/Exceptions/Handler.php#L107-L114
34,747
voslartomas/WebCMS2
libs/helpers/PriceFormatter.php
PriceFormatter.format
public static function format($price, $string = "%2n") { setlocale(LC_MONETARY, self::$locale); if (function_exists("money_format")) { return money_format($string, $price); } else { return $price; } }
php
public static function format($price, $string = "%2n") { setlocale(LC_MONETARY, self::$locale); if (function_exists("money_format")) { return money_format($string, $price); } else { return $price; } }
[ "public", "static", "function", "format", "(", "$", "price", ",", "$", "string", "=", "\"%2n\"", ")", "{", "setlocale", "(", "LC_MONETARY", ",", "self", "::", "$", "locale", ")", ";", "if", "(", "function_exists", "(", "\"money_format\"", ")", ")", "{", "return", "money_format", "(", "$", "string", ",", "$", "price", ")", ";", "}", "else", "{", "return", "$", "price", ";", "}", "}" ]
Format the given price. @param type $price @param type $string @return type
[ "Format", "the", "given", "price", "." ]
b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf
https://github.com/voslartomas/WebCMS2/blob/b39ea4b2fd30e87ff5e4fa81441cefa308e51fbf/libs/helpers/PriceFormatter.php#L28-L37
34,748
jon48/webtrees-lib
src/Webtrees/Functions/FunctionsPrint.php
FunctionsPrint.htmlFactPlaceIcon
public static function htmlFactPlaceIcon( \Fisharebest\Webtrees\Fact $fact, \MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider ) { $place = $fact->getPlace(); if(!$place->isEmpty()) { $iconPlace= $mapProvider->getPlaceIcon($place); if($iconPlace && strlen($iconPlace) > 0){ return '<div class="fact_flag">'. self::htmlPlaceIcon($place, $iconPlace, 50). '</div>'; } } return ''; }
php
public static function htmlFactPlaceIcon( \Fisharebest\Webtrees\Fact $fact, \MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider ) { $place = $fact->getPlace(); if(!$place->isEmpty()) { $iconPlace= $mapProvider->getPlaceIcon($place); if($iconPlace && strlen($iconPlace) > 0){ return '<div class="fact_flag">'. self::htmlPlaceIcon($place, $iconPlace, 50). '</div>'; } } return ''; }
[ "public", "static", "function", "htmlFactPlaceIcon", "(", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Fact", "$", "fact", ",", "\\", "MyArtJaub", "\\", "Webtrees", "\\", "Map", "\\", "MapProviderInterface", "$", "mapProvider", ")", "{", "$", "place", "=", "$", "fact", "->", "getPlace", "(", ")", ";", "if", "(", "!", "$", "place", "->", "isEmpty", "(", ")", ")", "{", "$", "iconPlace", "=", "$", "mapProvider", "->", "getPlaceIcon", "(", "$", "place", ")", ";", "if", "(", "$", "iconPlace", "&&", "strlen", "(", "$", "iconPlace", ")", ">", "0", ")", "{", "return", "'<div class=\"fact_flag\">'", ".", "self", "::", "htmlPlaceIcon", "(", "$", "place", ",", "$", "iconPlace", ",", "50", ")", ".", "'</div>'", ";", "}", "}", "return", "''", ";", "}" ]
Return HTML code to include a flag icon in facts description @param \Fisharebest\Webtrees\Fact $fact Fact record @param \MyArtJaub\Webtrees\Map\MapProviderInterface $mapProvider Map Provider @return string HTML code of the inserted flag
[ "Return", "HTML", "code", "to", "include", "a", "flag", "icon", "in", "facts", "description" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Functions/FunctionsPrint.php#L58-L70
34,749
jon48/webtrees-lib
src/Webtrees/Functions/FunctionsPrint.php
FunctionsPrint.htmlPlaceIcon
public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; }
php
public static function htmlPlaceIcon(\Fisharebest\Webtrees\Place $place, $icon_path , $size = 50) { return '<img class="flag_gm_h'. $size . '" src="' . $icon_path . '" title="' . $place->getGedcomName() . '" alt="' . $place->getGedcomName() . '" />'; }
[ "public", "static", "function", "htmlPlaceIcon", "(", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Place", "$", "place", ",", "$", "icon_path", ",", "$", "size", "=", "50", ")", "{", "return", "'<img class=\"flag_gm_h'", ".", "$", "size", ".", "'\" src=\"'", ".", "$", "icon_path", ".", "'\" title=\"'", ".", "$", "place", "->", "getGedcomName", "(", ")", ".", "'\" alt=\"'", ".", "$", "place", "->", "getGedcomName", "(", ")", ".", "'\" />'", ";", "}" ]
Return HTML code to include a flag icon @param \Fisharebest\Webtrees\Place $place @param string $icon_path @param number $size @return string HTML code of the inserted flag
[ "Return", "HTML", "code", "to", "include", "a", "flag", "icon" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Functions/FunctionsPrint.php#L80-L82
34,750
jon48/webtrees-lib
src/Webtrees/Functions/FunctionsPrint.php
FunctionsPrint.htmlPlacesCloud
public static function htmlPlacesCloud($places, $totals, Tree $tree) { $items = array(); foreach ($places as $place => $count) { /** var \MyArtJaub\Webtrees\Place */ $dplace = Place::getIntance($place, $tree); $items[] = array( 'text' => $dplace->htmlFormattedName('%1 (%2)'), 'count' => $count, 'url' => $dplace->getDerivedPlace()->getURL() ); } return self::htmlListCloud($items, $totals); }
php
public static function htmlPlacesCloud($places, $totals, Tree $tree) { $items = array(); foreach ($places as $place => $count) { /** var \MyArtJaub\Webtrees\Place */ $dplace = Place::getIntance($place, $tree); $items[] = array( 'text' => $dplace->htmlFormattedName('%1 (%2)'), 'count' => $count, 'url' => $dplace->getDerivedPlace()->getURL() ); } return self::htmlListCloud($items, $totals); }
[ "public", "static", "function", "htmlPlacesCloud", "(", "$", "places", ",", "$", "totals", ",", "Tree", "$", "tree", ")", "{", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "places", "as", "$", "place", "=>", "$", "count", ")", "{", "/** var \\MyArtJaub\\Webtrees\\Place */", "$", "dplace", "=", "Place", "::", "getIntance", "(", "$", "place", ",", "$", "tree", ")", ";", "$", "items", "[", "]", "=", "array", "(", "'text'", "=>", "$", "dplace", "->", "htmlFormattedName", "(", "'%1 (%2)'", ")", ",", "'count'", "=>", "$", "count", ",", "'url'", "=>", "$", "dplace", "->", "getDerivedPlace", "(", ")", "->", "getURL", "(", ")", ")", ";", "}", "return", "self", "::", "htmlListCloud", "(", "$", "items", ",", "$", "totals", ")", ";", "}" ]
Returns HTML code to include a place cloud @param array $places Array of places to display in the cloud @param bool $totals Display totals for a place @param \Fisharebest\Webtrees\Tree $tree Tree @return string Place Cloud HTML Code
[ "Returns", "HTML", "code", "to", "include", "a", "place", "cloud" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Functions/FunctionsPrint.php#L137-L151
34,751
jon48/webtrees-lib
src/Webtrees/Functions/FunctionsPrint.php
FunctionsPrint.formatFactPlaceShort
public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ $html=''; if ($fact === null) return $html; $place = $fact->getPlace(); if($place){ $dplace = new Place($place); $html .= $dplace->htmlFormattedName($format, $anchor); } return $html; }
php
public static function formatFactPlaceShort(\Fisharebest\Webtrees\Fact $fact, $format, $anchor=false){ $html=''; if ($fact === null) return $html; $place = $fact->getPlace(); if($place){ $dplace = new Place($place); $html .= $dplace->htmlFormattedName($format, $anchor); } return $html; }
[ "public", "static", "function", "formatFactPlaceShort", "(", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Fact", "$", "fact", ",", "$", "format", ",", "$", "anchor", "=", "false", ")", "{", "$", "html", "=", "''", ";", "if", "(", "$", "fact", "===", "null", ")", "return", "$", "html", ";", "$", "place", "=", "$", "fact", "->", "getPlace", "(", ")", ";", "if", "(", "$", "place", ")", "{", "$", "dplace", "=", "new", "Place", "(", "$", "place", ")", ";", "$", "html", ".=", "$", "dplace", "->", "htmlFormattedName", "(", "$", "format", ",", "$", "anchor", ")", ";", "}", "return", "$", "html", ";", "}" ]
Format fact place to display short @param \Fisharebest\Webtrees\Fact $eventObj Fact to display date @param string $format Format of the place @param boolean $anchor option to print a link to placelist @return string HTML code for short place
[ "Format", "fact", "place", "to", "display", "short" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Functions/FunctionsPrint.php#L218-L228
34,752
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.seoTitle
public function seoTitle($alternativeField = false) { if (!$alternativeField) { $alternativeField = config('gzero-cms.seo.alternative_title', 'title'); } $text = $this->removeNewLinesAndWhitespace($this->translation[$alternativeField]); // if alternative field is not empty if ($text) { return $this->translation['seo_title'] ? $this->removeNewLinesAndWhitespace($this->translation['seo_title']) : $text; } // show site name as default return option('general', 'site_name'); }
php
public function seoTitle($alternativeField = false) { if (!$alternativeField) { $alternativeField = config('gzero-cms.seo.alternative_title', 'title'); } $text = $this->removeNewLinesAndWhitespace($this->translation[$alternativeField]); // if alternative field is not empty if ($text) { return $this->translation['seo_title'] ? $this->removeNewLinesAndWhitespace($this->translation['seo_title']) : $text; } // show site name as default return option('general', 'site_name'); }
[ "public", "function", "seoTitle", "(", "$", "alternativeField", "=", "false", ")", "{", "if", "(", "!", "$", "alternativeField", ")", "{", "$", "alternativeField", "=", "config", "(", "'gzero-cms.seo.alternative_title'", ",", "'title'", ")", ";", "}", "$", "text", "=", "$", "this", "->", "removeNewLinesAndWhitespace", "(", "$", "this", "->", "translation", "[", "$", "alternativeField", "]", ")", ";", "// if alternative field is not empty", "if", "(", "$", "text", ")", "{", "return", "$", "this", "->", "translation", "[", "'seo_title'", "]", "?", "$", "this", "->", "removeNewLinesAndWhitespace", "(", "$", "this", "->", "translation", "[", "'seo_title'", "]", ")", ":", "$", "text", ";", "}", "// show site name as default", "return", "option", "(", "'general'", ",", "'site_name'", ")", ";", "}" ]
Return seoTitle of translation if exists otherwise return generated one @param mixed $alternativeField alternative field to display when seoTitle field is empty @return string
[ "Return", "seoTitle", "of", "translation", "if", "exists", "otherwise", "return", "generated", "one" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L235-L248
34,753
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.seoDescription
public function seoDescription($alternativeField = false) { $descLength = option('seo', 'desc_length', config('gzero.seo.desc_length', 160)); if (!$alternativeField) { $alternativeField = config('gzero-cms.seo.alternative_desc', 'body'); } // if SEO description is set if ($this->translation['seo_description']) { return $this->removeNewLinesAndWhitespace($this->translation['seo_description']); } $text = $this->removeNewLinesAndWhitespace($this->translation[$alternativeField]); // if alternative field is not empty if ($text) { return strlen($text) >= $descLength ? substr($text, 0, strpos($text, ' ', $descLength)) : $text; }; // show site description as default return option('general', 'site_desc'); }
php
public function seoDescription($alternativeField = false) { $descLength = option('seo', 'desc_length', config('gzero.seo.desc_length', 160)); if (!$alternativeField) { $alternativeField = config('gzero-cms.seo.alternative_desc', 'body'); } // if SEO description is set if ($this->translation['seo_description']) { return $this->removeNewLinesAndWhitespace($this->translation['seo_description']); } $text = $this->removeNewLinesAndWhitespace($this->translation[$alternativeField]); // if alternative field is not empty if ($text) { return strlen($text) >= $descLength ? substr($text, 0, strpos($text, ' ', $descLength)) : $text; }; // show site description as default return option('general', 'site_desc'); }
[ "public", "function", "seoDescription", "(", "$", "alternativeField", "=", "false", ")", "{", "$", "descLength", "=", "option", "(", "'seo'", ",", "'desc_length'", ",", "config", "(", "'gzero.seo.desc_length'", ",", "160", ")", ")", ";", "if", "(", "!", "$", "alternativeField", ")", "{", "$", "alternativeField", "=", "config", "(", "'gzero-cms.seo.alternative_desc'", ",", "'body'", ")", ";", "}", "// if SEO description is set", "if", "(", "$", "this", "->", "translation", "[", "'seo_description'", "]", ")", "{", "return", "$", "this", "->", "removeNewLinesAndWhitespace", "(", "$", "this", "->", "translation", "[", "'seo_description'", "]", ")", ";", "}", "$", "text", "=", "$", "this", "->", "removeNewLinesAndWhitespace", "(", "$", "this", "->", "translation", "[", "$", "alternativeField", "]", ")", ";", "// if alternative field is not empty", "if", "(", "$", "text", ")", "{", "return", "strlen", "(", "$", "text", ")", ">=", "$", "descLength", "?", "substr", "(", "$", "text", ",", "0", ",", "strpos", "(", "$", "text", ",", "' '", ",", "$", "descLength", ")", ")", ":", "$", "text", ";", "}", ";", "// show site description as default", "return", "option", "(", "'general'", ",", "'site_desc'", ")", ";", "}" ]
Return seoDescription of translation if exists otherwise return generated one @param mixed $alternativeField alternative field to display when seoDescription field is empty @return string
[ "Return", "seoDescription", "of", "translation", "if", "exists", "otherwise", "return", "generated", "one" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L258-L276
34,754
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.publishedAt
public function publishedAt() { $publishedAt = array_get($this->data, 'published_at', null); if ($publishedAt === null) { return trans('gzero-core::common.unknown'); } return $publishedAt; }
php
public function publishedAt() { $publishedAt = array_get($this->data, 'published_at', null); if ($publishedAt === null) { return trans('gzero-core::common.unknown'); } return $publishedAt; }
[ "public", "function", "publishedAt", "(", ")", "{", "$", "publishedAt", "=", "array_get", "(", "$", "this", "->", "data", ",", "'published_at'", ",", "null", ")", ";", "if", "(", "$", "publishedAt", "===", "null", ")", "{", "return", "trans", "(", "'gzero-core::common.unknown'", ")", ";", "}", "return", "$", "publishedAt", ";", "}" ]
This function returns formatted publish date @return string
[ "This", "function", "returns", "formatted", "publish", "date" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L291-L300
34,755
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.updatedAt
public function updatedAt() { $updatedAt = array_get($this->data, 'updated_at', null); if ($updatedAt === null) { return trans('gzero-core::common.unknown'); } return $updatedAt; }
php
public function updatedAt() { $updatedAt = array_get($this->data, 'updated_at', null); if ($updatedAt === null) { return trans('gzero-core::common.unknown'); } return $updatedAt; }
[ "public", "function", "updatedAt", "(", ")", "{", "$", "updatedAt", "=", "array_get", "(", "$", "this", "->", "data", ",", "'updated_at'", ",", "null", ")", ";", "if", "(", "$", "updatedAt", "===", "null", ")", "{", "return", "trans", "(", "'gzero-core::common.unknown'", ")", ";", "}", "return", "$", "updatedAt", ";", "}" ]
This function returns formatted updated date @return string
[ "This", "function", "returns", "formatted", "updated", "date" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L307-L316
34,756
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.firstImageUrl
public function firstImageUrl($text, $default = null) { $url = $default; if (!empty($text)) { preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $text, $matches); } if (!empty($matches) && isset($matches[1])) { $url = $matches[1]; } return $url; }
php
public function firstImageUrl($text, $default = null) { $url = $default; if (!empty($text)) { preg_match('/< *img[^>]*src *= *["\']?([^"\']*)/i', $text, $matches); } if (!empty($matches) && isset($matches[1])) { $url = $matches[1]; } return $url; }
[ "public", "function", "firstImageUrl", "(", "$", "text", ",", "$", "default", "=", "null", ")", "{", "$", "url", "=", "$", "default", ";", "if", "(", "!", "empty", "(", "$", "text", ")", ")", "{", "preg_match", "(", "'/< *img[^>]*src *= *[\"\\']?([^\"\\']*)/i'", ",", "$", "text", ",", "$", "matches", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "matches", ")", "&&", "isset", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "$", "url", "=", "$", "matches", "[", "1", "]", ";", "}", "return", "$", "url", ";", "}" ]
This function returns the first img url from provided text @param string $text text to get first image url from @param null $default default url to return if image is not found @return string first image url
[ "This", "function", "returns", "the", "first", "img", "url", "from", "provided", "text" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L347-L360
34,757
GrupaZero/cms
src/Gzero/Cms/ViewModels/ContentViewModel.php
ContentViewModel.ancestorsNames
public function ancestorsNames() { $ancestors = explode('/', array_get($this->route, 'path')); if (empty($ancestors)) { return null; } array_pop($ancestors); return array_map('ucfirst', $ancestors); }
php
public function ancestorsNames() { $ancestors = explode('/', array_get($this->route, 'path')); if (empty($ancestors)) { return null; } array_pop($ancestors); return array_map('ucfirst', $ancestors); }
[ "public", "function", "ancestorsNames", "(", ")", "{", "$", "ancestors", "=", "explode", "(", "'/'", ",", "array_get", "(", "$", "this", "->", "route", ",", "'path'", ")", ")", ";", "if", "(", "empty", "(", "$", "ancestors", ")", ")", "{", "return", "null", ";", "}", "array_pop", "(", "$", "ancestors", ")", ";", "return", "array_map", "(", "'ucfirst'", ",", "$", "ancestors", ")", ";", "}" ]
This function returns names of all ancestors based on route path @return array ancestors names
[ "This", "function", "returns", "names", "of", "all", "ancestors", "based", "on", "route", "path" ]
a7956966d2edec54fc99ebb61eeb2f01704aa2c2
https://github.com/GrupaZero/cms/blob/a7956966d2edec54fc99ebb61eeb2f01704aa2c2/src/Gzero/Cms/ViewModels/ContentViewModel.php#L367-L378
34,758
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.getIntance
public static function getIntance($xref, Tree $tree, $gedcom = null){ $indi = \Fisharebest\Webtrees\Individual::getInstance($xref, $tree, $gedcom); if($indi){ return new Individual($indi); } return null; }
php
public static function getIntance($xref, Tree $tree, $gedcom = null){ $indi = \Fisharebest\Webtrees\Individual::getInstance($xref, $tree, $gedcom); if($indi){ return new Individual($indi); } return null; }
[ "public", "static", "function", "getIntance", "(", "$", "xref", ",", "Tree", "$", "tree", ",", "$", "gedcom", "=", "null", ")", "{", "$", "indi", "=", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Individual", "::", "getInstance", "(", "$", "xref", ",", "$", "tree", ",", "$", "gedcom", ")", ";", "if", "(", "$", "indi", ")", "{", "return", "new", "Individual", "(", "$", "indi", ")", ";", "}", "return", "null", ";", "}" ]
Extend \Fisharebest\Webtrees\Individual getInstance, in order to retrieve directly a object @param string $xref @param Tree $tree @param null|string $gedcom @return null|Individual
[ "Extend", "\\", "Fisharebest", "\\", "Webtrees", "\\", "Individual", "getInstance", "in", "order", "to", "retrieve", "directly", "a", "object" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L46-L52
34,759
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.getEstimatedBirthPlace
public function getEstimatedBirthPlace($perc=false){ if($bplace = $this->gedcomrecord->getBirthPlace()){ if($perc){ return array ($bplace, 1); } else{ return $bplace; } } return null; }
php
public function getEstimatedBirthPlace($perc=false){ if($bplace = $this->gedcomrecord->getBirthPlace()){ if($perc){ return array ($bplace, 1); } else{ return $bplace; } } return null; }
[ "public", "function", "getEstimatedBirthPlace", "(", "$", "perc", "=", "false", ")", "{", "if", "(", "$", "bplace", "=", "$", "this", "->", "gedcomrecord", "->", "getBirthPlace", "(", ")", ")", "{", "if", "(", "$", "perc", ")", "{", "return", "array", "(", "$", "bplace", ",", "1", ")", ";", "}", "else", "{", "return", "$", "bplace", ";", "}", "}", "return", "null", ";", "}" ]
Returns an estimated birth place based on statistics on the base @param boolean $perc Should the coefficient of reliability be returned @return string|array Estimated birth place if found, null otherwise
[ "Returns", "an", "estimated", "birth", "place", "based", "on", "statistics", "on", "the", "base" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L97-L107
34,760
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.getSignificantPlace
public function getSignificantPlace(){ if($bplace = $this->gedcomrecord->getBirthPlace()){ return $bplace; } foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) { if ($rplace) { return $rplace; } } if($dplace = $this->gedcomrecord->getDeathPlace()){ return $dplace; } foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { foreach ($fams->getAllEventPlaces('RESI') as $rplace) { if ($rplace) { return $rplace; } } } return null; }
php
public function getSignificantPlace(){ if($bplace = $this->gedcomrecord->getBirthPlace()){ return $bplace; } foreach ($this->gedcomrecord->getAllEventPlaces('RESI') as $rplace) { if ($rplace) { return $rplace; } } if($dplace = $this->gedcomrecord->getDeathPlace()){ return $dplace; } foreach($this->gedcomrecord->getSpouseFamilies() as $fams) { foreach ($fams->getAllEventPlaces('RESI') as $rplace) { if ($rplace) { return $rplace; } } } return null; }
[ "public", "function", "getSignificantPlace", "(", ")", "{", "if", "(", "$", "bplace", "=", "$", "this", "->", "gedcomrecord", "->", "getBirthPlace", "(", ")", ")", "{", "return", "$", "bplace", ";", "}", "foreach", "(", "$", "this", "->", "gedcomrecord", "->", "getAllEventPlaces", "(", "'RESI'", ")", "as", "$", "rplace", ")", "{", "if", "(", "$", "rplace", ")", "{", "return", "$", "rplace", ";", "}", "}", "if", "(", "$", "dplace", "=", "$", "this", "->", "gedcomrecord", "->", "getDeathPlace", "(", ")", ")", "{", "return", "$", "dplace", ";", "}", "foreach", "(", "$", "this", "->", "gedcomrecord", "->", "getSpouseFamilies", "(", ")", "as", "$", "fams", ")", "{", "foreach", "(", "$", "fams", "->", "getAllEventPlaces", "(", "'RESI'", ")", "as", "$", "rplace", ")", "{", "if", "(", "$", "rplace", ")", "{", "return", "$", "rplace", ";", "}", "}", "}", "return", "null", ";", "}" ]
Returns a significant place for the individual @param boolean $perc Should the coefficient of reliability be returned @return string|array Estimated birth place if found, null otherwise
[ "Returns", "a", "significant", "place", "for", "the", "individual" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L115-L139
34,761
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.getSosaNumbers
public function getSosaNumbers(){ if($this->sosa === null) { $provider = new SosaProvider($this->gedcomrecord->getTree()); $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); } return $this->sosa; }
php
public function getSosaNumbers(){ if($this->sosa === null) { $provider = new SosaProvider($this->gedcomrecord->getTree()); $this->sosa = $provider->getSosaNumbers($this->gedcomrecord); } return $this->sosa; }
[ "public", "function", "getSosaNumbers", "(", ")", "{", "if", "(", "$", "this", "->", "sosa", "===", "null", ")", "{", "$", "provider", "=", "new", "SosaProvider", "(", "$", "this", "->", "gedcomrecord", "->", "getTree", "(", ")", ")", ";", "$", "this", "->", "sosa", "=", "$", "provider", "->", "getSosaNumbers", "(", "$", "this", "->", "gedcomrecord", ")", ";", "}", "return", "$", "this", "->", "sosa", ";", "}" ]
Get the list of Sosa numbers for this individual This list is cached. @uses \MyArtJaub\Webtrees\Functions\ModuleManager @return array List of Sosa numbers
[ "Get", "the", "list", "of", "Sosa", "numbers", "for", "this", "individual", "This", "list", "is", "cached", "." ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L157-L163
34,762
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.isBirthSourced
public function isBirthSourced(){ if($this->is_birth_sourced !== null) return $this->is_birth_sourced; $this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT); return $this->is_birth_sourced; }
php
public function isBirthSourced(){ if($this->is_birth_sourced !== null) return $this->is_birth_sourced; $this->is_birth_sourced = $this->isFactSourced(WT_EVENTS_BIRT); return $this->is_birth_sourced; }
[ "public", "function", "isBirthSourced", "(", ")", "{", "if", "(", "$", "this", "->", "is_birth_sourced", "!==", "null", ")", "return", "$", "this", "->", "is_birth_sourced", ";", "$", "this", "->", "is_birth_sourced", "=", "$", "this", "->", "isFactSourced", "(", "WT_EVENTS_BIRT", ")", ";", "return", "$", "this", "->", "is_birth_sourced", ";", "}" ]
Check if this individual's birth is sourced @return int Level of sources
[ "Check", "if", "this", "individual", "s", "birth", "is", "sourced" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L170-L174
34,763
jon48/webtrees-lib
src/Webtrees/Individual.php
Individual.isDeathSourced
public function isDeathSourced(){ if($this->is_death_sourced !== null) return $this->is_death_sourced; $this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT); return $this->is_death_sourced; }
php
public function isDeathSourced(){ if($this->is_death_sourced !== null) return $this->is_death_sourced; $this->is_death_sourced = $this->isFactSourced(WT_EVENTS_DEAT); return $this->is_death_sourced; }
[ "public", "function", "isDeathSourced", "(", ")", "{", "if", "(", "$", "this", "->", "is_death_sourced", "!==", "null", ")", "return", "$", "this", "->", "is_death_sourced", ";", "$", "this", "->", "is_death_sourced", "=", "$", "this", "->", "isFactSourced", "(", "WT_EVENTS_DEAT", ")", ";", "return", "$", "this", "->", "is_death_sourced", ";", "}" ]
Check if this individual's death is sourced @return int Level of sources
[ "Check", "if", "this", "individual", "s", "death", "is", "sourced" ]
e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7
https://github.com/jon48/webtrees-lib/blob/e8097cdfcdbb3c9e885e7e06fe7683ed39267bb7/src/Webtrees/Individual.php#L181-L185
34,764
KnpLabs/packagist-api
src/Packagist/Api/Client.php
Client.respond
protected function respond($url) { $response = $this->request($url); $response = $this->parse($response); return $this->create($response); }
php
protected function respond($url) { $response = $this->request($url); $response = $this->parse($response); return $this->create($response); }
[ "protected", "function", "respond", "(", "$", "url", ")", "{", "$", "response", "=", "$", "this", "->", "request", "(", "$", "url", ")", ";", "$", "response", "=", "$", "this", "->", "parse", "(", "$", "response", ")", ";", "return", "$", "this", "->", "create", "(", "$", "response", ")", ";", "}" ]
Execute the url request and parse the response @param string $url @return array|\Packagist\Api\Result\Package
[ "Execute", "the", "url", "request", "and", "parse", "the", "response" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Client.php#L168-L174
34,765
KnpLabs/packagist-api
src/Packagist/Api/Client.php
Client.request
protected function request($url) { if (null === $this->httpClient) { $this->httpClient = new HttpClient(); } return $this->httpClient ->get($url) ->getBody(); }
php
protected function request($url) { if (null === $this->httpClient) { $this->httpClient = new HttpClient(); } return $this->httpClient ->get($url) ->getBody(); }
[ "protected", "function", "request", "(", "$", "url", ")", "{", "if", "(", "null", "===", "$", "this", "->", "httpClient", ")", "{", "$", "this", "->", "httpClient", "=", "new", "HttpClient", "(", ")", ";", "}", "return", "$", "this", "->", "httpClient", "->", "get", "(", "$", "url", ")", "->", "getBody", "(", ")", ";", "}" ]
Execute the url request @param string $url @return \Psr\Http\Message\StreamInterface
[ "Execute", "the", "url", "request" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Client.php#L183-L192
34,766
KnpLabs/packagist-api
src/Packagist/Api/Client.php
Client.create
protected function create(array $data) { if (null === $this->resultFactory) { $this->resultFactory = new Factory(); } return $this->resultFactory->create($data); }
php
protected function create(array $data) { if (null === $this->resultFactory) { $this->resultFactory = new Factory(); } return $this->resultFactory->create($data); }
[ "protected", "function", "create", "(", "array", "$", "data", ")", "{", "if", "(", "null", "===", "$", "this", "->", "resultFactory", ")", "{", "$", "this", "->", "resultFactory", "=", "new", "Factory", "(", ")", ";", "}", "return", "$", "this", "->", "resultFactory", "->", "create", "(", "$", "data", ")", ";", "}" ]
Hydrate the knowing type depending on passed data @param array $data @return array|\Packagist\Api\Result\Package
[ "Hydrate", "the", "knowing", "type", "depending", "on", "passed", "data" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Client.php#L213-L220
34,767
KnpLabs/packagist-api
src/Packagist/Api/Result/Factory.php
Factory.create
public function create(array $data) { if (isset($data['results'])) { return $this->createSearchResults($data['results']); } elseif (isset($data['packages'])) { return $this->createSearchResults($data['packages']); } elseif (isset($data['package'])) { return $this->createPackageResults($data['package']); } elseif (isset($data['packageNames'])) { return $data['packageNames']; } throw new InvalidArgumentException('Invalid input data.'); }
php
public function create(array $data) { if (isset($data['results'])) { return $this->createSearchResults($data['results']); } elseif (isset($data['packages'])) { return $this->createSearchResults($data['packages']); } elseif (isset($data['package'])) { return $this->createPackageResults($data['package']); } elseif (isset($data['packageNames'])) { return $data['packageNames']; } throw new InvalidArgumentException('Invalid input data.'); }
[ "public", "function", "create", "(", "array", "$", "data", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'results'", "]", ")", ")", "{", "return", "$", "this", "->", "createSearchResults", "(", "$", "data", "[", "'results'", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "data", "[", "'packages'", "]", ")", ")", "{", "return", "$", "this", "->", "createSearchResults", "(", "$", "data", "[", "'packages'", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "data", "[", "'package'", "]", ")", ")", "{", "return", "$", "this", "->", "createPackageResults", "(", "$", "data", "[", "'package'", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "data", "[", "'packageNames'", "]", ")", ")", "{", "return", "$", "data", "[", "'packageNames'", "]", ";", "}", "throw", "new", "InvalidArgumentException", "(", "'Invalid input data.'", ")", ";", "}" ]
Analyse the data and transform to a known type @param array $data @throws InvalidArgumentException @return array|Package
[ "Analyse", "the", "data", "and", "transform", "to", "a", "known", "type" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Result/Factory.php#L22-L35
34,768
KnpLabs/packagist-api
src/Packagist/Api/Result/Factory.php
Factory.createSearchResults
public function createSearchResults(array $results) { $created = array(); foreach ($results as $key => $result) { $created[$key] = $this->createResult('Packagist\Api\Result\Result', $result); } return $created; }
php
public function createSearchResults(array $results) { $created = array(); foreach ($results as $key => $result) { $created[$key] = $this->createResult('Packagist\Api\Result\Result', $result); } return $created; }
[ "public", "function", "createSearchResults", "(", "array", "$", "results", ")", "{", "$", "created", "=", "array", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "key", "=>", "$", "result", ")", "{", "$", "created", "[", "$", "key", "]", "=", "$", "this", "->", "createResult", "(", "'Packagist\\Api\\Result\\Result'", ",", "$", "result", ")", ";", "}", "return", "$", "created", ";", "}" ]
Create a collection of \Packagist\Api\Result\Result @param array $results @return array
[ "Create", "a", "collection", "of", "\\", "Packagist", "\\", "Api", "\\", "Result", "\\", "Result" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Result/Factory.php#L44-L52
34,769
KnpLabs/packagist-api
src/Packagist/Api/Result/Factory.php
Factory.createPackageResults
public function createPackageResults(array $package) { $created = array(); if (isset($package['maintainers']) && $package['maintainers']) { foreach ($package['maintainers'] as $key => $maintainer) { $package['maintainers'][$key] = $this->createResult('Packagist\Api\Result\Package\Maintainer', $maintainer); } } if (isset($package['downloads']) && $package['downloads']) { $package['downloads'] = $this->createResult('Packagist\Api\Result\Package\Downloads', $package['downloads']); } foreach ($package['versions'] as $branch => $version) { if (isset($version['authors']) && $version['authors']) { foreach ($version['authors'] as $key => $author) { $version['authors'][$key] = $this->createResult('Packagist\Api\Result\Package\Author', $author); } } if ($version['source']) { $version['source'] = $this->createResult('Packagist\Api\Result\Package\Source', $version['source']); } if (isset($version['dist']) && $version['dist']) { $version['dist'] = $this->createResult('Packagist\Api\Result\Package\Dist', $version['dist']); } $package['versions'][$branch] = $this->createResult('Packagist\Api\Result\Package\Version', $version); } $created = new Package(); $created->fromArray($package); return $created; }
php
public function createPackageResults(array $package) { $created = array(); if (isset($package['maintainers']) && $package['maintainers']) { foreach ($package['maintainers'] as $key => $maintainer) { $package['maintainers'][$key] = $this->createResult('Packagist\Api\Result\Package\Maintainer', $maintainer); } } if (isset($package['downloads']) && $package['downloads']) { $package['downloads'] = $this->createResult('Packagist\Api\Result\Package\Downloads', $package['downloads']); } foreach ($package['versions'] as $branch => $version) { if (isset($version['authors']) && $version['authors']) { foreach ($version['authors'] as $key => $author) { $version['authors'][$key] = $this->createResult('Packagist\Api\Result\Package\Author', $author); } } if ($version['source']) { $version['source'] = $this->createResult('Packagist\Api\Result\Package\Source', $version['source']); } if (isset($version['dist']) && $version['dist']) { $version['dist'] = $this->createResult('Packagist\Api\Result\Package\Dist', $version['dist']); } $package['versions'][$branch] = $this->createResult('Packagist\Api\Result\Package\Version', $version); } $created = new Package(); $created->fromArray($package); return $created; }
[ "public", "function", "createPackageResults", "(", "array", "$", "package", ")", "{", "$", "created", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "package", "[", "'maintainers'", "]", ")", "&&", "$", "package", "[", "'maintainers'", "]", ")", "{", "foreach", "(", "$", "package", "[", "'maintainers'", "]", "as", "$", "key", "=>", "$", "maintainer", ")", "{", "$", "package", "[", "'maintainers'", "]", "[", "$", "key", "]", "=", "$", "this", "->", "createResult", "(", "'Packagist\\Api\\Result\\Package\\Maintainer'", ",", "$", "maintainer", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "package", "[", "'downloads'", "]", ")", "&&", "$", "package", "[", "'downloads'", "]", ")", "{", "$", "package", "[", "'downloads'", "]", "=", "$", "this", "->", "createResult", "(", "'Packagist\\Api\\Result\\Package\\Downloads'", ",", "$", "package", "[", "'downloads'", "]", ")", ";", "}", "foreach", "(", "$", "package", "[", "'versions'", "]", "as", "$", "branch", "=>", "$", "version", ")", "{", "if", "(", "isset", "(", "$", "version", "[", "'authors'", "]", ")", "&&", "$", "version", "[", "'authors'", "]", ")", "{", "foreach", "(", "$", "version", "[", "'authors'", "]", "as", "$", "key", "=>", "$", "author", ")", "{", "$", "version", "[", "'authors'", "]", "[", "$", "key", "]", "=", "$", "this", "->", "createResult", "(", "'Packagist\\Api\\Result\\Package\\Author'", ",", "$", "author", ")", ";", "}", "}", "if", "(", "$", "version", "[", "'source'", "]", ")", "{", "$", "version", "[", "'source'", "]", "=", "$", "this", "->", "createResult", "(", "'Packagist\\Api\\Result\\Package\\Source'", ",", "$", "version", "[", "'source'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "version", "[", "'dist'", "]", ")", "&&", "$", "version", "[", "'dist'", "]", ")", "{", "$", "version", "[", "'dist'", "]", "=", "$", "this", "->", "createResult", "(", "'Packagist\\Api\\Result\\Package\\Dist'", ",", "$", "version", "[", "'dist'", "]", ")", ";", "}", "$", "package", "[", "'versions'", "]", "[", "$", "branch", "]", "=", "$", "this", "->", "createResult", "(", "'Packagist\\Api\\Result\\Package\\Version'", ",", "$", "version", ")", ";", "}", "$", "created", "=", "new", "Package", "(", ")", ";", "$", "created", "->", "fromArray", "(", "$", "package", ")", ";", "return", "$", "created", ";", "}" ]
Parse array to \Packagist\Api\Result\Result @param array $package @return Package
[ "Parse", "array", "to", "\\", "Packagist", "\\", "Api", "\\", "Result", "\\", "Result" ]
74dbe93eab7cb80feb8fb9f2294f962d8d37fc71
https://github.com/KnpLabs/packagist-api/blob/74dbe93eab7cb80feb8fb9f2294f962d8d37fc71/src/Packagist/Api/Result/Factory.php#L61-L95
34,770
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Event/DaemonEvent.php
DaemonEvent.getCommandLastExceptionClassName
public function getCommandLastExceptionClassName() { $exception = $this->command->getLastException(); if (!is_null($exception)) { return get_class($exception); } return null; }
php
public function getCommandLastExceptionClassName() { $exception = $this->command->getLastException(); if (!is_null($exception)) { return get_class($exception); } return null; }
[ "public", "function", "getCommandLastExceptionClassName", "(", ")", "{", "$", "exception", "=", "$", "this", "->", "command", "->", "getLastException", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "exception", ")", ")", "{", "return", "get_class", "(", "$", "exception", ")", ";", "}", "return", "null", ";", "}" ]
Gets last exception class name. @return string|null
[ "Gets", "last", "exception", "class", "name", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Event/DaemonEvent.php#L84-L93
34,771
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.configureDaemonDefinition
private function configureDaemonDefinition(): void { $this->addOption('run-once', null, InputOption::VALUE_NONE, 'Run the command just once.'); $this->addOption('run-max', null, InputOption::VALUE_OPTIONAL, 'Run the command x time.'); $this->addOption('memory-max', null, InputOption::VALUE_OPTIONAL, 'Gracefully stop running command when given memory volume, in bytes, is reached.', 0); $this->addOption('shutdown-on-exception', null, InputOption::VALUE_NONE, 'Ask for shutdown if an exception is thrown.'); $this->addOption('show-exceptions', null, InputOption::VALUE_NONE, 'Display exception on command output.'); }
php
private function configureDaemonDefinition(): void { $this->addOption('run-once', null, InputOption::VALUE_NONE, 'Run the command just once.'); $this->addOption('run-max', null, InputOption::VALUE_OPTIONAL, 'Run the command x time.'); $this->addOption('memory-max', null, InputOption::VALUE_OPTIONAL, 'Gracefully stop running command when given memory volume, in bytes, is reached.', 0); $this->addOption('shutdown-on-exception', null, InputOption::VALUE_NONE, 'Ask for shutdown if an exception is thrown.'); $this->addOption('show-exceptions', null, InputOption::VALUE_NONE, 'Display exception on command output.'); }
[ "private", "function", "configureDaemonDefinition", "(", ")", ":", "void", "{", "$", "this", "->", "addOption", "(", "'run-once'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Run the command just once.'", ")", ";", "$", "this", "->", "addOption", "(", "'run-max'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'Run the command x time.'", ")", ";", "$", "this", "->", "addOption", "(", "'memory-max'", ",", "null", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'Gracefully stop running command when given memory volume, in bytes, is reached.'", ",", "0", ")", ";", "$", "this", "->", "addOption", "(", "'shutdown-on-exception'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Ask for shutdown if an exception is thrown.'", ")", ";", "$", "this", "->", "addOption", "(", "'show-exceptions'", ",", "null", ",", "InputOption", "::", "VALUE_NONE", ",", "'Display exception on command output.'", ")", ";", "}" ]
Add daemon options to the command definition.
[ "Add", "daemon", "options", "to", "the", "command", "definition", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L133-L140
34,772
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.configureEvents
protected function configureEvents(): self { $container = $this->getContainer(); $key = 'm6web_daemon.iterations_events'; if ($container->hasParameter($key)) { $this->iterationsEvents = $container->getParameter($key); } return $this; }
php
protected function configureEvents(): self { $container = $this->getContainer(); $key = 'm6web_daemon.iterations_events'; if ($container->hasParameter($key)) { $this->iterationsEvents = $container->getParameter($key); } return $this; }
[ "protected", "function", "configureEvents", "(", ")", ":", "self", "{", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "$", "key", "=", "'m6web_daemon.iterations_events'", ";", "if", "(", "$", "container", "->", "hasParameter", "(", "$", "key", ")", ")", "{", "$", "this", "->", "iterationsEvents", "=", "$", "container", "->", "getParameter", "(", "$", "key", ")", ";", "}", "return", "$", "this", ";", "}" ]
Retrieve configured events. @return DaemonCommand
[ "Retrieve", "configured", "events", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L258-L268
34,773
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.dispatchEvent
protected function dispatchEvent(string $eventName): self { $dispatcher = $this->getEventDispatcher(); if (!is_null($dispatcher)) { $time = !is_null($this->startTime) ? microtime(true) - $this->startTime : 0; $event = new DaemonEvent($this); $event->setExecutionTime($time); $dispatcher->dispatch($eventName, $event); } return $this; }
php
protected function dispatchEvent(string $eventName): self { $dispatcher = $this->getEventDispatcher(); if (!is_null($dispatcher)) { $time = !is_null($this->startTime) ? microtime(true) - $this->startTime : 0; $event = new DaemonEvent($this); $event->setExecutionTime($time); $dispatcher->dispatch($eventName, $event); } return $this; }
[ "protected", "function", "dispatchEvent", "(", "string", "$", "eventName", ")", ":", "self", "{", "$", "dispatcher", "=", "$", "this", "->", "getEventDispatcher", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "dispatcher", ")", ")", "{", "$", "time", "=", "!", "is_null", "(", "$", "this", "->", "startTime", ")", "?", "microtime", "(", "true", ")", "-", "$", "this", "->", "startTime", ":", "0", ";", "$", "event", "=", "new", "DaemonEvent", "(", "$", "this", ")", ";", "$", "event", "->", "setExecutionTime", "(", "$", "time", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "$", "eventName", ",", "$", "event", ")", ";", "}", "return", "$", "this", ";", "}" ]
Dispatch a daemon event. @param string $eventName @return DaemonCommand
[ "Dispatch", "a", "daemon", "event", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L276-L289
34,774
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.callIterationsIntervalCallbacks
protected function callIterationsIntervalCallbacks(InputInterface $input, OutputInterface $output) { foreach ($this->iterationsIntervalCallbacks as $iterationsIntervalCallback) { if (($this->getLoopCount() + 1) % $iterationsIntervalCallback['interval'] === 0) { call_user_func($iterationsIntervalCallback['callable'], $input, $output); } } }
php
protected function callIterationsIntervalCallbacks(InputInterface $input, OutputInterface $output) { foreach ($this->iterationsIntervalCallbacks as $iterationsIntervalCallback) { if (($this->getLoopCount() + 1) % $iterationsIntervalCallback['interval'] === 0) { call_user_func($iterationsIntervalCallback['callable'], $input, $output); } } }
[ "protected", "function", "callIterationsIntervalCallbacks", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "foreach", "(", "$", "this", "->", "iterationsIntervalCallbacks", "as", "$", "iterationsIntervalCallback", ")", "{", "if", "(", "(", "$", "this", "->", "getLoopCount", "(", ")", "+", "1", ")", "%", "$", "iterationsIntervalCallback", "[", "'interval'", "]", "===", "0", ")", "{", "call_user_func", "(", "$", "iterationsIntervalCallback", "[", "'callable'", "]", ",", "$", "input", ",", "$", "output", ")", ";", "}", "}", "}" ]
Execute callbacks after every iteration interval. @param InputInterface $input @param OutputInterface $output
[ "Execute", "callbacks", "after", "every", "iteration", "interval", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L369-L376
34,775
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.dispatchConfigurationEvents
protected function dispatchConfigurationEvents(): self { foreach ($this->iterationsEvents as $event) { if (!($this->loopCount % $event['count'])) { $this->dispatchEvent($event['name']); } } return $this; }
php
protected function dispatchConfigurationEvents(): self { foreach ($this->iterationsEvents as $event) { if (!($this->loopCount % $event['count'])) { $this->dispatchEvent($event['name']); } } return $this; }
[ "protected", "function", "dispatchConfigurationEvents", "(", ")", ":", "self", "{", "foreach", "(", "$", "this", "->", "iterationsEvents", "as", "$", "event", ")", "{", "if", "(", "!", "(", "$", "this", "->", "loopCount", "%", "$", "event", "[", "'count'", "]", ")", ")", "{", "$", "this", "->", "dispatchEvent", "(", "$", "event", "[", "'name'", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Dispatch configured events. @return DaemonCommand
[ "Dispatch", "configured", "events", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L469-L478
34,776
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.isLastLoop
protected function isLastLoop(): bool { // Count loop if (!is_null($this->getLoopMax()) && ($this->getLoopCount() >= $this->getLoopMax())) { $this->requestShutdown(); } // Memory if ($this->memoryMax > 0 && memory_get_peak_usage(true) >= $this->memoryMax) { $this->dispatchEvent(DaemonEvents::DAEMON_LOOP_MAX_MEMORY_REACHED); $this->requestShutdown(); } return $this->isShutdownRequested(); }
php
protected function isLastLoop(): bool { // Count loop if (!is_null($this->getLoopMax()) && ($this->getLoopCount() >= $this->getLoopMax())) { $this->requestShutdown(); } // Memory if ($this->memoryMax > 0 && memory_get_peak_usage(true) >= $this->memoryMax) { $this->dispatchEvent(DaemonEvents::DAEMON_LOOP_MAX_MEMORY_REACHED); $this->requestShutdown(); } return $this->isShutdownRequested(); }
[ "protected", "function", "isLastLoop", "(", ")", ":", "bool", "{", "// Count loop", "if", "(", "!", "is_null", "(", "$", "this", "->", "getLoopMax", "(", ")", ")", "&&", "(", "$", "this", "->", "getLoopCount", "(", ")", ">=", "$", "this", "->", "getLoopMax", "(", ")", ")", ")", "{", "$", "this", "->", "requestShutdown", "(", ")", ";", "}", "// Memory", "if", "(", "$", "this", "->", "memoryMax", ">", "0", "&&", "memory_get_peak_usage", "(", "true", ")", ">=", "$", "this", "->", "memoryMax", ")", "{", "$", "this", "->", "dispatchEvent", "(", "DaemonEvents", "::", "DAEMON_LOOP_MAX_MEMORY_REACHED", ")", ";", "$", "this", "->", "requestShutdown", "(", ")", ";", "}", "return", "$", "this", "->", "isShutdownRequested", "(", ")", ";", "}" ]
Return true after the last loop. @return bool
[ "Return", "true", "after", "the", "last", "loop", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L485-L499
34,777
M6Web/DaemonBundle
src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php
DaemonCommand.addIterationsIntervalCallback
public function addIterationsIntervalCallback($iterationsInterval, callable $onIterationsInterval) { if (!is_int($iterationsInterval) || ($iterationsInterval <= 0)) { throw new \InvalidArgumentException('Iteration interval must be a positive integer'); } $this->iterationsIntervalCallbacks[] = ['interval' => $iterationsInterval, 'callable' => $onIterationsInterval,]; }
php
public function addIterationsIntervalCallback($iterationsInterval, callable $onIterationsInterval) { if (!is_int($iterationsInterval) || ($iterationsInterval <= 0)) { throw new \InvalidArgumentException('Iteration interval must be a positive integer'); } $this->iterationsIntervalCallbacks[] = ['interval' => $iterationsInterval, 'callable' => $onIterationsInterval,]; }
[ "public", "function", "addIterationsIntervalCallback", "(", "$", "iterationsInterval", ",", "callable", "$", "onIterationsInterval", ")", "{", "if", "(", "!", "is_int", "(", "$", "iterationsInterval", ")", "||", "(", "$", "iterationsInterval", "<=", "0", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Iteration interval must be a positive integer'", ")", ";", "}", "$", "this", "->", "iterationsIntervalCallbacks", "[", "]", "=", "[", "'interval'", "=>", "$", "iterationsInterval", ",", "'callable'", "=>", "$", "onIterationsInterval", ",", "]", ";", "}" ]
Add your own callback after every iteration interval. @param int $iterationsInterval @param callable $onIterationsInterval
[ "Add", "your", "own", "callback", "after", "every", "iteration", "interval", "." ]
9db55b0a28802f7ef0a3041d222e74803145b194
https://github.com/M6Web/DaemonBundle/blob/9db55b0a28802f7ef0a3041d222e74803145b194/src/M6Web/Bundle/DaemonBundle/Command/DaemonCommand.php#L615-L622
34,778
TiendaNube/tiendanube-php-sdk
src/TiendaNube/Auth.php
Auth.request_access_token
public function request_access_token($code){ $params = [ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'code' => $code, 'grant_type' => 'authorization_code', ]; $response = $this->requests->post($this->auth_url, [], $params); if (!$response->success){ throw new Auth\Exception('Auth url returned with status code ' . $response->status_code); } $body = json_decode($response->body); if (isset($body->error)){ throw new Auth\Exception("[{$body->error}] {$body->error_description}"); } return [ 'store_id' => $body->user_id, 'access_token' => $body->access_token, 'scope' => $body->scope, ]; }
php
public function request_access_token($code){ $params = [ 'client_id' => $this->client_id, 'client_secret' => $this->client_secret, 'code' => $code, 'grant_type' => 'authorization_code', ]; $response = $this->requests->post($this->auth_url, [], $params); if (!$response->success){ throw new Auth\Exception('Auth url returned with status code ' . $response->status_code); } $body = json_decode($response->body); if (isset($body->error)){ throw new Auth\Exception("[{$body->error}] {$body->error_description}"); } return [ 'store_id' => $body->user_id, 'access_token' => $body->access_token, 'scope' => $body->scope, ]; }
[ "public", "function", "request_access_token", "(", "$", "code", ")", "{", "$", "params", "=", "[", "'client_id'", "=>", "$", "this", "->", "client_id", ",", "'client_secret'", "=>", "$", "this", "->", "client_secret", ",", "'code'", "=>", "$", "code", ",", "'grant_type'", "=>", "'authorization_code'", ",", "]", ";", "$", "response", "=", "$", "this", "->", "requests", "->", "post", "(", "$", "this", "->", "auth_url", ",", "[", "]", ",", "$", "params", ")", ";", "if", "(", "!", "$", "response", "->", "success", ")", "{", "throw", "new", "Auth", "\\", "Exception", "(", "'Auth url returned with status code '", ".", "$", "response", "->", "status_code", ")", ";", "}", "$", "body", "=", "json_decode", "(", "$", "response", "->", "body", ")", ";", "if", "(", "isset", "(", "$", "body", "->", "error", ")", ")", "{", "throw", "new", "Auth", "\\", "Exception", "(", "\"[{$body->error}] {$body->error_description}\"", ")", ";", "}", "return", "[", "'store_id'", "=>", "$", "body", "->", "user_id", ",", "'access_token'", "=>", "$", "body", "->", "access_token", ",", "'scope'", "=>", "$", "body", "->", "scope", ",", "]", ";", "}" ]
Obtain a permanent access token from an authorization code. @param string $code Authorization code retrieved from the redirect URI.
[ "Obtain", "a", "permanent", "access", "token", "from", "an", "authorization", "code", "." ]
7e2c025fafdc942d5ec334da133896f4c918e8e8
https://github.com/TiendaNube/tiendanube-php-sdk/blob/7e2c025fafdc942d5ec334da133896f4c918e8e8/src/TiendaNube/Auth.php#L50-L73
34,779
TiendaNube/tiendanube-php-sdk
src/TiendaNube/API.php
API.get
public function get($path, $params = null){ $url_params = ''; if (is_array($params)){ $url_params = '?' . http_build_query($params); } return $this->_call('GET', $path . $url_params); }
php
public function get($path, $params = null){ $url_params = ''; if (is_array($params)){ $url_params = '?' . http_build_query($params); } return $this->_call('GET', $path . $url_params); }
[ "public", "function", "get", "(", "$", "path", ",", "$", "params", "=", "null", ")", "{", "$", "url_params", "=", "''", ";", "if", "(", "is_array", "(", "$", "params", ")", ")", "{", "$", "url_params", "=", "'?'", ".", "http_build_query", "(", "$", "params", ")", ";", "}", "return", "$", "this", "->", "_call", "(", "'GET'", ",", "$", "path", ".", "$", "url_params", ")", ";", "}" ]
Make a GET request to the specified path. @param string $path The path to the desired resource @param array $params Optional parameters to send in the query string @return TiendaNube/API/Response
[ "Make", "a", "GET", "request", "to", "the", "specified", "path", "." ]
7e2c025fafdc942d5ec334da133896f4c918e8e8
https://github.com/TiendaNube/tiendanube-php-sdk/blob/7e2c025fafdc942d5ec334da133896f4c918e8e8/src/TiendaNube/API.php#L38-L45
34,780
TiendaNube/tiendanube-php-sdk
src/TiendaNube/API.php
API.post
public function post($path, $params = []){ $json = json_encode($params); return $this->_call('POST', $path, $json); }
php
public function post($path, $params = []){ $json = json_encode($params); return $this->_call('POST', $path, $json); }
[ "public", "function", "post", "(", "$", "path", ",", "$", "params", "=", "[", "]", ")", "{", "$", "json", "=", "json_encode", "(", "$", "params", ")", ";", "return", "$", "this", "->", "_call", "(", "'POST'", ",", "$", "path", ",", "$", "json", ")", ";", "}" ]
Make a POST request to the specified path. @param string $path The path to the desired resource @param array $params Parameters to send in the POST data @return TiendaNube/API/Response
[ "Make", "a", "POST", "request", "to", "the", "specified", "path", "." ]
7e2c025fafdc942d5ec334da133896f4c918e8e8
https://github.com/TiendaNube/tiendanube-php-sdk/blob/7e2c025fafdc942d5ec334da133896f4c918e8e8/src/TiendaNube/API.php#L54-L58
34,781
TiendaNube/tiendanube-php-sdk
src/TiendaNube/API.php
API.put
public function put($path, $params = []){ $json = json_encode($params); return $this->_call('PUT', $path, $json); }
php
public function put($path, $params = []){ $json = json_encode($params); return $this->_call('PUT', $path, $json); }
[ "public", "function", "put", "(", "$", "path", ",", "$", "params", "=", "[", "]", ")", "{", "$", "json", "=", "json_encode", "(", "$", "params", ")", ";", "return", "$", "this", "->", "_call", "(", "'PUT'", ",", "$", "path", ",", "$", "json", ")", ";", "}" ]
Make a PUT request to the specified path. @param string $path The path to the desired resource @param array $params Parameters to send in the PUT data @return TiendaNube/API/Response
[ "Make", "a", "PUT", "request", "to", "the", "specified", "path", "." ]
7e2c025fafdc942d5ec334da133896f4c918e8e8
https://github.com/TiendaNube/tiendanube-php-sdk/blob/7e2c025fafdc942d5ec334da133896f4c918e8e8/src/TiendaNube/API.php#L67-L71
34,782
teamdeeson/wardenapi
src/Api.php
Api.getPublicKey
public function getPublicKey() { if (empty($this->wardenPublicKey)) { $result = $this->request('/public-key'); $this->wardenPublicKey = base64_decode($result->getBody()); } return $this->wardenPublicKey; }
php
public function getPublicKey() { if (empty($this->wardenPublicKey)) { $result = $this->request('/public-key'); $this->wardenPublicKey = base64_decode($result->getBody()); } return $this->wardenPublicKey; }
[ "public", "function", "getPublicKey", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "wardenPublicKey", ")", ")", "{", "$", "result", "=", "$", "this", "->", "request", "(", "'/public-key'", ")", ";", "$", "this", "->", "wardenPublicKey", "=", "base64_decode", "(", "$", "result", "->", "getBody", "(", ")", ")", ";", "}", "return", "$", "this", "->", "wardenPublicKey", ";", "}" ]
Get the public key. @throws WardenBadResponseException If the response status was not 200
[ "Get", "the", "public", "key", "." ]
d93f30b3c482f27696c1371b163e9260b33a80d8
https://github.com/teamdeeson/wardenapi/blob/d93f30b3c482f27696c1371b163e9260b33a80d8/src/Api.php#L109-L117
34,783
teamdeeson/wardenapi
src/Api.php
Api.isValidWardenToken
public function isValidWardenToken($encryptedRemoteToken, $timestamp) { $envelope = json_decode(base64_decode($encryptedRemoteToken)); if (!is_object($envelope) || empty($envelope->time) || empty($envelope->signature)) { return FALSE; } $remoteTimestamp = base64_decode($envelope->time); if (!is_numeric($remoteTimestamp) || ($remoteTimestamp > $timestamp + 20) || ($remoteTimestamp < $timestamp - 20) ) { return FALSE; } $result = openssl_verify($remoteTimestamp, base64_decode($envelope->signature), $this->getPublicKey()); return $result === 1; }
php
public function isValidWardenToken($encryptedRemoteToken, $timestamp) { $envelope = json_decode(base64_decode($encryptedRemoteToken)); if (!is_object($envelope) || empty($envelope->time) || empty($envelope->signature)) { return FALSE; } $remoteTimestamp = base64_decode($envelope->time); if (!is_numeric($remoteTimestamp) || ($remoteTimestamp > $timestamp + 20) || ($remoteTimestamp < $timestamp - 20) ) { return FALSE; } $result = openssl_verify($remoteTimestamp, base64_decode($envelope->signature), $this->getPublicKey()); return $result === 1; }
[ "public", "function", "isValidWardenToken", "(", "$", "encryptedRemoteToken", ",", "$", "timestamp", ")", "{", "$", "envelope", "=", "json_decode", "(", "base64_decode", "(", "$", "encryptedRemoteToken", ")", ")", ";", "if", "(", "!", "is_object", "(", "$", "envelope", ")", "||", "empty", "(", "$", "envelope", "->", "time", ")", "||", "empty", "(", "$", "envelope", "->", "signature", ")", ")", "{", "return", "FALSE", ";", "}", "$", "remoteTimestamp", "=", "base64_decode", "(", "$", "envelope", "->", "time", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "remoteTimestamp", ")", "||", "(", "$", "remoteTimestamp", ">", "$", "timestamp", "+", "20", ")", "||", "(", "$", "remoteTimestamp", "<", "$", "timestamp", "-", "20", ")", ")", "{", "return", "FALSE", ";", "}", "$", "result", "=", "openssl_verify", "(", "$", "remoteTimestamp", ",", "base64_decode", "(", "$", "envelope", "->", "signature", ")", ",", "$", "this", "->", "getPublicKey", "(", ")", ")", ";", "return", "$", "result", "===", "1", ";", "}" ]
Check the validity of a token sent from Warden. To prove a request came from the Warden application, Warden encrypts the current timestamp using its private key which can be decrypted with its public key. Only the true Warden can produce the encrypted message. Since it is possible to reply the token, the token only lasts for 20 seconds. @param string $encryptedRemoteToken The token sent from the warden site which has been encrypted with Warden's private key. @return bool TRUE if we can trust the token.
[ "Check", "the", "validity", "of", "a", "token", "sent", "from", "Warden", "." ]
d93f30b3c482f27696c1371b163e9260b33a80d8
https://github.com/teamdeeson/wardenapi/blob/d93f30b3c482f27696c1371b163e9260b33a80d8/src/Api.php#L135-L153
34,784
teamdeeson/wardenapi
src/Api.php
Api.encrypt
public function encrypt($data) { $plaintext = json_encode($data); $public_key = $this->getPublicKey(); $result = openssl_seal($plaintext, $message, $keys, array($public_key)); if ($result === FALSE || empty($keys[0]) || empty($message) || $message === $plaintext) { throw new EncryptionException('Unable to encrypt a message: ' . openssl_error_string()); } $envelope = (object) array( 'key' => base64_encode($keys[0]), 'message' => base64_encode($message), ); return base64_encode(json_encode($envelope)); }
php
public function encrypt($data) { $plaintext = json_encode($data); $public_key = $this->getPublicKey(); $result = openssl_seal($plaintext, $message, $keys, array($public_key)); if ($result === FALSE || empty($keys[0]) || empty($message) || $message === $plaintext) { throw new EncryptionException('Unable to encrypt a message: ' . openssl_error_string()); } $envelope = (object) array( 'key' => base64_encode($keys[0]), 'message' => base64_encode($message), ); return base64_encode(json_encode($envelope)); }
[ "public", "function", "encrypt", "(", "$", "data", ")", "{", "$", "plaintext", "=", "json_encode", "(", "$", "data", ")", ";", "$", "public_key", "=", "$", "this", "->", "getPublicKey", "(", ")", ";", "$", "result", "=", "openssl_seal", "(", "$", "plaintext", ",", "$", "message", ",", "$", "keys", ",", "array", "(", "$", "public_key", ")", ")", ";", "if", "(", "$", "result", "===", "FALSE", "||", "empty", "(", "$", "keys", "[", "0", "]", ")", "||", "empty", "(", "$", "message", ")", "||", "$", "message", "===", "$", "plaintext", ")", "{", "throw", "new", "EncryptionException", "(", "'Unable to encrypt a message: '", ".", "openssl_error_string", "(", ")", ")", ";", "}", "$", "envelope", "=", "(", "object", ")", "array", "(", "'key'", "=>", "base64_encode", "(", "$", "keys", "[", "0", "]", ")", ",", "'message'", "=>", "base64_encode", "(", "$", "message", ")", ",", ")", ";", "return", "base64_encode", "(", "json_encode", "(", "$", "envelope", ")", ")", ";", "}" ]
Encrypt a plaintext message. @param mixed $data The data to encrypt for transport. @return string The encoded message @throws EncryptionException If there is a problem with the encryption process. @throws WardenBadResponseException If the response status from Warden was not 200 when retrieving the public key.
[ "Encrypt", "a", "plaintext", "message", "." ]
d93f30b3c482f27696c1371b163e9260b33a80d8
https://github.com/teamdeeson/wardenapi/blob/d93f30b3c482f27696c1371b163e9260b33a80d8/src/Api.php#L170-L187
34,785
teamdeeson/wardenapi
src/Api.php
Api.decrypt
public function decrypt($cypherText) { $envelope = json_decode(base64_decode($cypherText)); if (!is_object($envelope) || empty($envelope->key) || empty($envelope->message)) { throw new EncryptionException('Encrypted message is not understood'); } $key = base64_decode($envelope->key); $message = base64_decode($envelope->message); $decrypted = ''; $result = openssl_open($message, $decrypted, $key, $this->getPublicKey()); if ($result === FALSE) { throw new EncryptionException('Unable to decrypt a message: ' . openssl_error_string()); } return json_decode($decrypted); }
php
public function decrypt($cypherText) { $envelope = json_decode(base64_decode($cypherText)); if (!is_object($envelope) || empty($envelope->key) || empty($envelope->message)) { throw new EncryptionException('Encrypted message is not understood'); } $key = base64_decode($envelope->key); $message = base64_decode($envelope->message); $decrypted = ''; $result = openssl_open($message, $decrypted, $key, $this->getPublicKey()); if ($result === FALSE) { throw new EncryptionException('Unable to decrypt a message: ' . openssl_error_string()); } return json_decode($decrypted); }
[ "public", "function", "decrypt", "(", "$", "cypherText", ")", "{", "$", "envelope", "=", "json_decode", "(", "base64_decode", "(", "$", "cypherText", ")", ")", ";", "if", "(", "!", "is_object", "(", "$", "envelope", ")", "||", "empty", "(", "$", "envelope", "->", "key", ")", "||", "empty", "(", "$", "envelope", "->", "message", ")", ")", "{", "throw", "new", "EncryptionException", "(", "'Encrypted message is not understood'", ")", ";", "}", "$", "key", "=", "base64_decode", "(", "$", "envelope", "->", "key", ")", ";", "$", "message", "=", "base64_decode", "(", "$", "envelope", "->", "message", ")", ";", "$", "decrypted", "=", "''", ";", "$", "result", "=", "openssl_open", "(", "$", "message", ",", "$", "decrypted", ",", "$", "key", ",", "$", "this", "->", "getPublicKey", "(", ")", ")", ";", "if", "(", "$", "result", "===", "FALSE", ")", "{", "throw", "new", "EncryptionException", "(", "'Unable to decrypt a message: '", ".", "openssl_error_string", "(", ")", ")", ";", "}", "return", "json_decode", "(", "$", "decrypted", ")", ";", "}" ]
Decrypt a message which was encrypted with the Warden private key. @param string $cypherText The encrypted text @return mixed The original data @throws EncryptionException If there was a problem with the decryption process. @throws WardenBadResponseException If the response status from Warden was not 200 when retrieving the public key.
[ "Decrypt", "a", "message", "which", "was", "encrypted", "with", "the", "Warden", "private", "key", "." ]
d93f30b3c482f27696c1371b163e9260b33a80d8
https://github.com/teamdeeson/wardenapi/blob/d93f30b3c482f27696c1371b163e9260b33a80d8/src/Api.php#L203-L221
34,786
teamdeeson/wardenapi
src/Api.php
Api.request
public function request($path, $content = '') { $url = $this->getWardenUrl() . $path; $options = []; if ($this->hasBasicAuthentication()) { $options['auth'] = [ $this->getUsername(), $this->getPassword()]; } $method = 'GET'; if (!empty($content)) { $method = 'POST'; $options['body'] = $content; } if (!empty($this->hasCertificatePath())) { $options['cert'] = $this->getCertificatePath(); } $client = new Client(); $res = $client->request($method, $url, $options); if ($res->getStatusCode() !== 200) { throw new WardenBadResponseException('Unable to communicate with Warden (' . $res->getStatusCode() . ') ' . $res->getReasonPhrase()); } return $res; }
php
public function request($path, $content = '') { $url = $this->getWardenUrl() . $path; $options = []; if ($this->hasBasicAuthentication()) { $options['auth'] = [ $this->getUsername(), $this->getPassword()]; } $method = 'GET'; if (!empty($content)) { $method = 'POST'; $options['body'] = $content; } if (!empty($this->hasCertificatePath())) { $options['cert'] = $this->getCertificatePath(); } $client = new Client(); $res = $client->request($method, $url, $options); if ($res->getStatusCode() !== 200) { throw new WardenBadResponseException('Unable to communicate with Warden (' . $res->getStatusCode() . ') ' . $res->getReasonPhrase()); } return $res; }
[ "public", "function", "request", "(", "$", "path", ",", "$", "content", "=", "''", ")", "{", "$", "url", "=", "$", "this", "->", "getWardenUrl", "(", ")", ".", "$", "path", ";", "$", "options", "=", "[", "]", ";", "if", "(", "$", "this", "->", "hasBasicAuthentication", "(", ")", ")", "{", "$", "options", "[", "'auth'", "]", "=", "[", "$", "this", "->", "getUsername", "(", ")", ",", "$", "this", "->", "getPassword", "(", ")", "]", ";", "}", "$", "method", "=", "'GET'", ";", "if", "(", "!", "empty", "(", "$", "content", ")", ")", "{", "$", "method", "=", "'POST'", ";", "$", "options", "[", "'body'", "]", "=", "$", "content", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "hasCertificatePath", "(", ")", ")", ")", "{", "$", "options", "[", "'cert'", "]", "=", "$", "this", "->", "getCertificatePath", "(", ")", ";", "}", "$", "client", "=", "new", "Client", "(", ")", ";", "$", "res", "=", "$", "client", "->", "request", "(", "$", "method", ",", "$", "url", ",", "$", "options", ")", ";", "if", "(", "$", "res", "->", "getStatusCode", "(", ")", "!==", "200", ")", "{", "throw", "new", "WardenBadResponseException", "(", "'Unable to communicate with Warden ('", ".", "$", "res", "->", "getStatusCode", "(", ")", ".", "') '", ".", "$", "res", "->", "getReasonPhrase", "(", ")", ")", ";", "}", "return", "$", "res", ";", "}" ]
Send a message to warden @param string $path The query path including the leading slash (e.g. '/public-key') @param string $content The body of the request. If this is not empty, the request is a post. @return ResponseInterface The response object @throws WardenBadResponseException If the response status was not 200
[ "Send", "a", "message", "to", "warden" ]
d93f30b3c482f27696c1371b163e9260b33a80d8
https://github.com/teamdeeson/wardenapi/blob/d93f30b3c482f27696c1371b163e9260b33a80d8/src/Api.php#L250-L278
34,787
yawik/jobs
src/Entity/Job.php
Job.getCompany
public function getCompany($useOrganizationEntity = true) { if ($this->organization && $useOrganizationEntity) { return $this->organization->getOrganizationName()->getName(); } return $this->company; }
php
public function getCompany($useOrganizationEntity = true) { if ($this->organization && $useOrganizationEntity) { return $this->organization->getOrganizationName()->getName(); } return $this->company; }
[ "public", "function", "getCompany", "(", "$", "useOrganizationEntity", "=", "true", ")", "{", "if", "(", "$", "this", "->", "organization", "&&", "$", "useOrganizationEntity", ")", "{", "return", "$", "this", "->", "organization", "->", "getOrganizationName", "(", ")", "->", "getName", "(", ")", ";", "}", "return", "$", "this", "->", "company", ";", "}" ]
Gets the name oof the company. If there is an organization assigned to the job posting. Take the name of the organization. @param bool $useOrganizationEntity Get the name from the organization entity, if it is available. @see \Jobs\Entity\JobInterface::getCompany() @return string
[ "Gets", "the", "name", "oof", "the", "company", ".", "If", "there", "is", "an", "organization", "assigned", "to", "the", "job", "posting", ".", "Take", "the", "name", "of", "the", "organization", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/Job.php#L419-L426
34,788
yawik/jobs
src/Entity/Job.php
Job.changeStatus
public function changeStatus($status, $message = '[System]') { $this->setStatus($status); $status = $this->getStatus(); // ensure StatusEntity $history = new History($status, $message); $this->getHistory()->add($history); return $this; }
php
public function changeStatus($status, $message = '[System]') { $this->setStatus($status); $status = $this->getStatus(); // ensure StatusEntity $history = new History($status, $message); $this->getHistory()->add($history); return $this; }
[ "public", "function", "changeStatus", "(", "$", "status", ",", "$", "message", "=", "'[System]'", ")", "{", "$", "this", "->", "setStatus", "(", "$", "status", ")", ";", "$", "status", "=", "$", "this", "->", "getStatus", "(", ")", ";", "// ensure StatusEntity", "$", "history", "=", "new", "History", "(", "$", "status", ",", "$", "message", ")", ";", "$", "this", "->", "getHistory", "(", ")", "->", "add", "(", "$", "history", ")", ";", "return", "$", "this", ";", "}" ]
Modifies the state of an application. Creates a history entry. @param StatusInterface|string $status @param string $message @return Job
[ "Modifies", "the", "state", "of", "an", "application", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/Job.php#L705-L714
34,789
yawik/jobs
src/Entity/Job.php
Job.getLogoRef
public function getLogoRef() { /** @var $organization \Organizations\Entity\Organization */ $organization = $this->organization; if (is_object($organization) && $organization->getImage()) { $organizationImage = $organization->getImage(); return "/file/Organizations.OrganizationImage/" . $organizationImage->getId(); } return $this->logoRef; }
php
public function getLogoRef() { /** @var $organization \Organizations\Entity\Organization */ $organization = $this->organization; if (is_object($organization) && $organization->getImage()) { $organizationImage = $organization->getImage(); return "/file/Organizations.OrganizationImage/" . $organizationImage->getId(); } return $this->logoRef; }
[ "public", "function", "getLogoRef", "(", ")", "{", "/** @var $organization \\Organizations\\Entity\\Organization */", "$", "organization", "=", "$", "this", "->", "organization", ";", "if", "(", "is_object", "(", "$", "organization", ")", "&&", "$", "organization", "->", "getImage", "(", ")", ")", "{", "$", "organizationImage", "=", "$", "organization", "->", "getImage", "(", ")", ";", "return", "\"/file/Organizations.OrganizationImage/\"", ".", "$", "organizationImage", "->", "getId", "(", ")", ";", "}", "return", "$", "this", "->", "logoRef", ";", "}" ]
returns an uri to the organization logo. @return string
[ "returns", "an", "uri", "to", "the", "organization", "logo", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/Job.php#L863-L872
34,790
yawik/jobs
src/Options/ProviderOptions.php
ProviderOptions.getChannel
public function getChannel($key) { if (array_key_exists($key, $this->channels)) { return $this->channels[$key]; } return null; }
php
public function getChannel($key) { if (array_key_exists($key, $this->channels)) { return $this->channels[$key]; } return null; }
[ "public", "function", "getChannel", "(", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "channels", ")", ")", "{", "return", "$", "this", "->", "channels", "[", "$", "key", "]", ";", "}", "return", "null", ";", "}" ]
Get a channel by "key" @param string $key @return ChannelOptions
[ "Get", "a", "channel", "by", "key" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Options/ProviderOptions.php#L66-L72
34,791
yawik/jobs
src/Filter/ViewModelTemplateFilterJob.php
ViewModelTemplateFilterJob.extract
protected function extract($job) { $this->job = $job; $this->getJsonLdHelper()->setJob($job); $this->setApplyData(); $this->setOrganizationInfo(); $this->setLocation(); $this->setDescription(); $this->setTemplate(); $this->setTemplateDefaultValues(); $this->container['descriptionEditable'] = $job->getTemplateValues()->getDescription(); $this->container['benefits'] = $job->getTemplateValues()->getBenefits(); $this->container['requirements'] = $job->getTemplateValues()->getRequirements(); $this->container['qualifications'] = $job->getTemplateValues()->getQualifications(); $this->container['title'] = $job->getTemplateValues()->getTitle(); $this->container['headTitle'] = strip_tags($job->getTemplateValues()->getTitle()); $this->container['uriApply'] = $this->container['applyData']['uri']; $this->container['contactEmail'] = strip_tags($job->getContactEmail()); $this->container['html'] = $job->getTemplateValues()->getHtml(); $this->container['jobId'] = $job->getId(); $this->container['uriJob'] = $this->urlPlugin->fromRoute( 'lang/jobs/view', [], [ 'query' => [ 'id' => $job->getId() ], 'force_canonical' => true ] ); return $this; }
php
protected function extract($job) { $this->job = $job; $this->getJsonLdHelper()->setJob($job); $this->setApplyData(); $this->setOrganizationInfo(); $this->setLocation(); $this->setDescription(); $this->setTemplate(); $this->setTemplateDefaultValues(); $this->container['descriptionEditable'] = $job->getTemplateValues()->getDescription(); $this->container['benefits'] = $job->getTemplateValues()->getBenefits(); $this->container['requirements'] = $job->getTemplateValues()->getRequirements(); $this->container['qualifications'] = $job->getTemplateValues()->getQualifications(); $this->container['title'] = $job->getTemplateValues()->getTitle(); $this->container['headTitle'] = strip_tags($job->getTemplateValues()->getTitle()); $this->container['uriApply'] = $this->container['applyData']['uri']; $this->container['contactEmail'] = strip_tags($job->getContactEmail()); $this->container['html'] = $job->getTemplateValues()->getHtml(); $this->container['jobId'] = $job->getId(); $this->container['uriJob'] = $this->urlPlugin->fromRoute( 'lang/jobs/view', [], [ 'query' => [ 'id' => $job->getId() ], 'force_canonical' => true ] ); return $this; }
[ "protected", "function", "extract", "(", "$", "job", ")", "{", "$", "this", "->", "job", "=", "$", "job", ";", "$", "this", "->", "getJsonLdHelper", "(", ")", "->", "setJob", "(", "$", "job", ")", ";", "$", "this", "->", "setApplyData", "(", ")", ";", "$", "this", "->", "setOrganizationInfo", "(", ")", ";", "$", "this", "->", "setLocation", "(", ")", ";", "$", "this", "->", "setDescription", "(", ")", ";", "$", "this", "->", "setTemplate", "(", ")", ";", "$", "this", "->", "setTemplateDefaultValues", "(", ")", ";", "$", "this", "->", "container", "[", "'descriptionEditable'", "]", "=", "$", "job", "->", "getTemplateValues", "(", ")", "->", "getDescription", "(", ")", ";", "$", "this", "->", "container", "[", "'benefits'", "]", "=", "$", "job", "->", "getTemplateValues", "(", ")", "->", "getBenefits", "(", ")", ";", "$", "this", "->", "container", "[", "'requirements'", "]", "=", "$", "job", "->", "getTemplateValues", "(", ")", "->", "getRequirements", "(", ")", ";", "$", "this", "->", "container", "[", "'qualifications'", "]", "=", "$", "job", "->", "getTemplateValues", "(", ")", "->", "getQualifications", "(", ")", ";", "$", "this", "->", "container", "[", "'title'", "]", "=", "$", "job", "->", "getTemplateValues", "(", ")", "->", "getTitle", "(", ")", ";", "$", "this", "->", "container", "[", "'headTitle'", "]", "=", "strip_tags", "(", "$", "job", "->", "getTemplateValues", "(", ")", "->", "getTitle", "(", ")", ")", ";", "$", "this", "->", "container", "[", "'uriApply'", "]", "=", "$", "this", "->", "container", "[", "'applyData'", "]", "[", "'uri'", "]", ";", "$", "this", "->", "container", "[", "'contactEmail'", "]", "=", "strip_tags", "(", "$", "job", "->", "getContactEmail", "(", ")", ")", ";", "$", "this", "->", "container", "[", "'html'", "]", "=", "$", "job", "->", "getTemplateValues", "(", ")", "->", "getHtml", "(", ")", ";", "$", "this", "->", "container", "[", "'jobId'", "]", "=", "$", "job", "->", "getId", "(", ")", ";", "$", "this", "->", "container", "[", "'uriJob'", "]", "=", "$", "this", "->", "urlPlugin", "->", "fromRoute", "(", "'lang/jobs/view'", ",", "[", "]", ",", "[", "'query'", "=>", "[", "'id'", "=>", "$", "job", "->", "getId", "(", ")", "]", ",", "'force_canonical'", "=>", "true", "]", ")", ";", "return", "$", "this", ";", "}" ]
assign the form-elements to the template @param \Jobs\Entity\Job $job @return $this
[ "assign", "the", "form", "-", "elements", "to", "the", "template" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Filter/ViewModelTemplateFilterJob.php#L27-L59
34,792
yawik/jobs
src/Entity/AtsMode.php
AtsMode.setMode
public function setMode($mode) { $validModes = array( self::MODE_INTERN, self::MODE_URI, self::MODE_EMAIL, self::MODE_NONE, ); if (!in_array($mode, $validModes)) { throw new \InvalidArgumentException('Unknown value for ats mode.'); } $this->mode = $mode; return $this; }
php
public function setMode($mode) { $validModes = array( self::MODE_INTERN, self::MODE_URI, self::MODE_EMAIL, self::MODE_NONE, ); if (!in_array($mode, $validModes)) { throw new \InvalidArgumentException('Unknown value for ats mode.'); } $this->mode = $mode; return $this; }
[ "public", "function", "setMode", "(", "$", "mode", ")", "{", "$", "validModes", "=", "array", "(", "self", "::", "MODE_INTERN", ",", "self", "::", "MODE_URI", ",", "self", "::", "MODE_EMAIL", ",", "self", "::", "MODE_NONE", ",", ")", ";", "if", "(", "!", "in_array", "(", "$", "mode", ",", "$", "validModes", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unknown value for ats mode.'", ")", ";", "}", "$", "this", "->", "mode", "=", "$", "mode", ";", "return", "$", "this", ";", "}" ]
Sets the ATS mode. @throws \InvalidArgumentException
[ "Sets", "the", "ATS", "mode", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Entity/AtsMode.php#L95-L111
34,793
yawik/jobs
src/Listener/MailSender.php
MailSender.onJobCreated
public function onJobCreated(JobEvent $e) { $job = $e->getJobEntity(); $this->sendMail( $job, 'mail/job-created', /*@translate*/ 'A new job opening was created', /*adminMail*/ true ); $this->sendMail( $job, 'mail/job-pending', /*@translate*/ 'Your Job have been wrapped up for approval' ); }
php
public function onJobCreated(JobEvent $e) { $job = $e->getJobEntity(); $this->sendMail( $job, 'mail/job-created', /*@translate*/ 'A new job opening was created', /*adminMail*/ true ); $this->sendMail( $job, 'mail/job-pending', /*@translate*/ 'Your Job have been wrapped up for approval' ); }
[ "public", "function", "onJobCreated", "(", "JobEvent", "$", "e", ")", "{", "$", "job", "=", "$", "e", "->", "getJobEntity", "(", ")", ";", "$", "this", "->", "sendMail", "(", "$", "job", ",", "'mail/job-created'", ",", "/*@translate*/", "'A new job opening was created'", ",", "/*adminMail*/", "true", ")", ";", "$", "this", "->", "sendMail", "(", "$", "job", ",", "'mail/job-pending'", ",", "/*@translate*/", "'Your Job have been wrapped up for approval'", ")", ";", "}" ]
Callback for the job created event. @param JobEvent $e
[ "Callback", "for", "the", "job", "created", "event", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Listener/MailSender.php#L85-L99
34,794
yawik/jobs
src/Listener/MailSender.php
MailSender.sendMail
protected function sendMail(Job $job, $template, $subject, $adminMail = false) { $mail = $this->mailer->get('htmltemplate'); $mail->setTemplate($template) ->setSubject($subject) ->setVariables( array( 'job' => $job, 'siteName' => $this->options['siteName'], ) ); if ($adminMail) { $mail->setTo($this->options['adminEmail']); } else { if (! ($user = $job->getUser())) { return; } $userInfo = $user->getInfo(); $userEmail = $userInfo->getEmail(); $userName = $userInfo->getDisplayName(/*emailIfEmpty*/ false); $mail->setTo($userEmail, $userName); } $this->mailer->send($mail); }
php
protected function sendMail(Job $job, $template, $subject, $adminMail = false) { $mail = $this->mailer->get('htmltemplate'); $mail->setTemplate($template) ->setSubject($subject) ->setVariables( array( 'job' => $job, 'siteName' => $this->options['siteName'], ) ); if ($adminMail) { $mail->setTo($this->options['adminEmail']); } else { if (! ($user = $job->getUser())) { return; } $userInfo = $user->getInfo(); $userEmail = $userInfo->getEmail(); $userName = $userInfo->getDisplayName(/*emailIfEmpty*/ false); $mail->setTo($userEmail, $userName); } $this->mailer->send($mail); }
[ "protected", "function", "sendMail", "(", "Job", "$", "job", ",", "$", "template", ",", "$", "subject", ",", "$", "adminMail", "=", "false", ")", "{", "$", "mail", "=", "$", "this", "->", "mailer", "->", "get", "(", "'htmltemplate'", ")", ";", "$", "mail", "->", "setTemplate", "(", "$", "template", ")", "->", "setSubject", "(", "$", "subject", ")", "->", "setVariables", "(", "array", "(", "'job'", "=>", "$", "job", ",", "'siteName'", "=>", "$", "this", "->", "options", "[", "'siteName'", "]", ",", ")", ")", ";", "if", "(", "$", "adminMail", ")", "{", "$", "mail", "->", "setTo", "(", "$", "this", "->", "options", "[", "'adminEmail'", "]", ")", ";", "}", "else", "{", "if", "(", "!", "(", "$", "user", "=", "$", "job", "->", "getUser", "(", ")", ")", ")", "{", "return", ";", "}", "$", "userInfo", "=", "$", "user", "->", "getInfo", "(", ")", ";", "$", "userEmail", "=", "$", "userInfo", "->", "getEmail", "(", ")", ";", "$", "userName", "=", "$", "userInfo", "->", "getDisplayName", "(", "/*emailIfEmpty*/", "false", ")", ";", "$", "mail", "->", "setTo", "(", "$", "userEmail", ",", "$", "userName", ")", ";", "}", "$", "this", "->", "mailer", "->", "send", "(", "$", "mail", ")", ";", "}" ]
Sends a job event related mail @param Job $job @param string $template @param string $subject @param bool $adminMail if true, the mail is send to the administrator instead of to the user.
[ "Sends", "a", "job", "event", "related", "mail" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Listener/MailSender.php#L137-L163
34,795
yawik/jobs
src/Acl/WriteAssertion.php
WriteAssertion.assert
public function assert( Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null ) { if (!$role instanceof UserInterface || !$resource instanceof JobInterface || 'edit' != $privilege) { return false; } /* @var $resource \Jobs\Entity\JobInterface */ return $resource->getPermissions()->isGranted($role->getId(), Permissions::PERMISSION_CHANGE) || $this->checkOrganizationPermissions($role, $resource) || (null === $resource->getUser() && \Auth\Entity\UserInterface::ROLE_ADMIN == $role->getRole()); }
php
public function assert( Acl $acl, RoleInterface $role = null, ResourceInterface $resource = null, $privilege = null ) { if (!$role instanceof UserInterface || !$resource instanceof JobInterface || 'edit' != $privilege) { return false; } /* @var $resource \Jobs\Entity\JobInterface */ return $resource->getPermissions()->isGranted($role->getId(), Permissions::PERMISSION_CHANGE) || $this->checkOrganizationPermissions($role, $resource) || (null === $resource->getUser() && \Auth\Entity\UserInterface::ROLE_ADMIN == $role->getRole()); }
[ "public", "function", "assert", "(", "Acl", "$", "acl", ",", "RoleInterface", "$", "role", "=", "null", ",", "ResourceInterface", "$", "resource", "=", "null", ",", "$", "privilege", "=", "null", ")", "{", "if", "(", "!", "$", "role", "instanceof", "UserInterface", "||", "!", "$", "resource", "instanceof", "JobInterface", "||", "'edit'", "!=", "$", "privilege", ")", "{", "return", "false", ";", "}", "/* @var $resource \\Jobs\\Entity\\JobInterface */", "return", "$", "resource", "->", "getPermissions", "(", ")", "->", "isGranted", "(", "$", "role", "->", "getId", "(", ")", ",", "Permissions", "::", "PERMISSION_CHANGE", ")", "||", "$", "this", "->", "checkOrganizationPermissions", "(", "$", "role", ",", "$", "resource", ")", "||", "(", "null", "===", "$", "resource", "->", "getUser", "(", ")", "&&", "\\", "Auth", "\\", "Entity", "\\", "UserInterface", "::", "ROLE_ADMIN", "==", "$", "role", "->", "getRole", "(", ")", ")", ";", "}" ]
Returns true, if the user has write access to the job. {@inheritDoc} @see \Zend\Permissions\Acl\Assertion\AssertionInterface::assert()
[ "Returns", "true", "if", "the", "user", "has", "write", "access", "to", "the", "job", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Acl/WriteAssertion.php#L36-L50
34,796
yawik/jobs
src/Acl/WriteAssertion.php
WriteAssertion.checkOrganizationPermissions
protected function checkOrganizationPermissions($role, $resource) { /* @var $resource \Jobs\Entity\JobInterface */ /* @var $role \Auth\Entity\UserInterface */ $organization = $resource->getOrganization(); if (!$organization) { return false; } if ($organization->isHiringOrganization()) { $organization = $organization->getParent(); } $orgUser = $organization->getUser(); if ($orgUser && $role->getId() == $orgUser->getId()) { return true; } $employees = $organization->getEmployees(); foreach ($employees as $emp) { /* @var $emp \Organizations\Entity\EmployeeInterface */ if ($emp->getUser()->getId() == $role->getId() && $emp->getPermissions()->isAllowed(EmployeePermissionsInterface::JOBS_CHANGE) ) { return true; } } return false; }
php
protected function checkOrganizationPermissions($role, $resource) { /* @var $resource \Jobs\Entity\JobInterface */ /* @var $role \Auth\Entity\UserInterface */ $organization = $resource->getOrganization(); if (!$organization) { return false; } if ($organization->isHiringOrganization()) { $organization = $organization->getParent(); } $orgUser = $organization->getUser(); if ($orgUser && $role->getId() == $orgUser->getId()) { return true; } $employees = $organization->getEmployees(); foreach ($employees as $emp) { /* @var $emp \Organizations\Entity\EmployeeInterface */ if ($emp->getUser()->getId() == $role->getId() && $emp->getPermissions()->isAllowed(EmployeePermissionsInterface::JOBS_CHANGE) ) { return true; } } return false; }
[ "protected", "function", "checkOrganizationPermissions", "(", "$", "role", ",", "$", "resource", ")", "{", "/* @var $resource \\Jobs\\Entity\\JobInterface */", "/* @var $role \\Auth\\Entity\\UserInterface */", "$", "organization", "=", "$", "resource", "->", "getOrganization", "(", ")", ";", "if", "(", "!", "$", "organization", ")", "{", "return", "false", ";", "}", "if", "(", "$", "organization", "->", "isHiringOrganization", "(", ")", ")", "{", "$", "organization", "=", "$", "organization", "->", "getParent", "(", ")", ";", "}", "$", "orgUser", "=", "$", "organization", "->", "getUser", "(", ")", ";", "if", "(", "$", "orgUser", "&&", "$", "role", "->", "getId", "(", ")", "==", "$", "orgUser", "->", "getId", "(", ")", ")", "{", "return", "true", ";", "}", "$", "employees", "=", "$", "organization", "->", "getEmployees", "(", ")", ";", "foreach", "(", "$", "employees", "as", "$", "emp", ")", "{", "/* @var $emp \\Organizations\\Entity\\EmployeeInterface */", "if", "(", "$", "emp", "->", "getUser", "(", ")", "->", "getId", "(", ")", "==", "$", "role", "->", "getId", "(", ")", "&&", "$", "emp", "->", "getPermissions", "(", ")", "->", "isAllowed", "(", "EmployeePermissionsInterface", "::", "JOBS_CHANGE", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true, if the user has write access to the job granted from the organization. @param RoleInterface $role This must be a UserInterface instance @param ResourceInterface $resource This must be a JobInterface instance @return bool
[ "Returns", "true", "if", "the", "user", "has", "write", "access", "to", "the", "job", "granted", "from", "the", "organization", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Acl/WriteAssertion.php#L60-L91
34,797
yawik/jobs
src/Form/InputFilter/AtsMode.php
AtsMode.setData
public function setData($data) { switch ($data['mode']) { default: break; case AtsModeInterface::MODE_URI: $this->add( array( 'name' => 'uri', 'validators' => array( array( 'name' => 'uri', 'options' => array( 'allowRelative' => false, ), ), ), 'filters' => array( array('name' => 'StripTags'), ), ) ); break; case AtsModeInterface::MODE_EMAIL: $this->add( array( 'name' => 'email', 'validators' => array( array('name' => 'EmailAddress') ), ) ); break; } $this->add([ 'name' => 'oneClickApplyProfiles', 'required' => $data['mode'] == AtsModeInterface::MODE_INTERN && $data['oneClickApply'] ]); return parent::setData($data); }
php
public function setData($data) { switch ($data['mode']) { default: break; case AtsModeInterface::MODE_URI: $this->add( array( 'name' => 'uri', 'validators' => array( array( 'name' => 'uri', 'options' => array( 'allowRelative' => false, ), ), ), 'filters' => array( array('name' => 'StripTags'), ), ) ); break; case AtsModeInterface::MODE_EMAIL: $this->add( array( 'name' => 'email', 'validators' => array( array('name' => 'EmailAddress') ), ) ); break; } $this->add([ 'name' => 'oneClickApplyProfiles', 'required' => $data['mode'] == AtsModeInterface::MODE_INTERN && $data['oneClickApply'] ]); return parent::setData($data); }
[ "public", "function", "setData", "(", "$", "data", ")", "{", "switch", "(", "$", "data", "[", "'mode'", "]", ")", "{", "default", ":", "break", ";", "case", "AtsModeInterface", "::", "MODE_URI", ":", "$", "this", "->", "add", "(", "array", "(", "'name'", "=>", "'uri'", ",", "'validators'", "=>", "array", "(", "array", "(", "'name'", "=>", "'uri'", ",", "'options'", "=>", "array", "(", "'allowRelative'", "=>", "false", ",", ")", ",", ")", ",", ")", ",", "'filters'", "=>", "array", "(", "array", "(", "'name'", "=>", "'StripTags'", ")", ",", ")", ",", ")", ")", ";", "break", ";", "case", "AtsModeInterface", "::", "MODE_EMAIL", ":", "$", "this", "->", "add", "(", "array", "(", "'name'", "=>", "'email'", ",", "'validators'", "=>", "array", "(", "array", "(", "'name'", "=>", "'EmailAddress'", ")", ")", ",", ")", ")", ";", "break", ";", "}", "$", "this", "->", "add", "(", "[", "'name'", "=>", "'oneClickApplyProfiles'", ",", "'required'", "=>", "$", "data", "[", "'mode'", "]", "==", "AtsModeInterface", "::", "MODE_INTERN", "&&", "$", "data", "[", "'oneClickApply'", "]", "]", ")", ";", "return", "parent", "::", "setData", "(", "$", "data", ")", ";", "}" ]
Sets data for validating and filtering. @internal We needed to add dynamically validators, because when "mode" is "intern" or "none" we must not validate anything. When "mode" is "uri" we must not validate "email address" and we must not validate "uri" if mode is "uri". And only when the data is set we do know what has to be validated.
[ "Sets", "data", "for", "validating", "and", "filtering", "." ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Form/InputFilter/AtsMode.php#L50-L93
34,798
yawik/jobs
src/Repository/Job.php
Job.getPaginatorCursor
public function getPaginatorCursor($params) { $filter = $this->getService('filterManager')->get('Jobs/PaginationQuery'); /* @var $filter \Core\Repository\Filter\AbstractPaginationQuery */ $qb = $filter->filter($params, $this->createQueryBuilder()); return $qb->getQuery()->execute(); }
php
public function getPaginatorCursor($params) { $filter = $this->getService('filterManager')->get('Jobs/PaginationQuery'); /* @var $filter \Core\Repository\Filter\AbstractPaginationQuery */ $qb = $filter->filter($params, $this->createQueryBuilder()); return $qb->getQuery()->execute(); }
[ "public", "function", "getPaginatorCursor", "(", "$", "params", ")", "{", "$", "filter", "=", "$", "this", "->", "getService", "(", "'filterManager'", ")", "->", "get", "(", "'Jobs/PaginationQuery'", ")", ";", "/* @var $filter \\Core\\Repository\\Filter\\AbstractPaginationQuery */", "$", "qb", "=", "$", "filter", "->", "filter", "(", "$", "params", ",", "$", "this", "->", "createQueryBuilder", "(", ")", ")", ";", "return", "$", "qb", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", "}" ]
Gets a pagination cursor to the jobs collection @param $params @return mixed
[ "Gets", "a", "pagination", "cursor", "to", "the", "jobs", "collection" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Repository/Job.php#L39-L45
34,799
yawik/jobs
src/Repository/Job.php
Job.findByOrganization
public function findByOrganization($organizationId) { $criteria = $this->getIsDeletedCriteria([ 'organization' => new \MongoId($organizationId), ]); return $this->findBy($criteria); }
php
public function findByOrganization($organizationId) { $criteria = $this->getIsDeletedCriteria([ 'organization' => new \MongoId($organizationId), ]); return $this->findBy($criteria); }
[ "public", "function", "findByOrganization", "(", "$", "organizationId", ")", "{", "$", "criteria", "=", "$", "this", "->", "getIsDeletedCriteria", "(", "[", "'organization'", "=>", "new", "\\", "MongoId", "(", "$", "organizationId", ")", ",", "]", ")", ";", "return", "$", "this", "->", "findBy", "(", "$", "criteria", ")", ";", "}" ]
Selects job postings of a certain organization @param int $organizationId @return \Jobs\Entity\Job[]
[ "Selects", "job", "postings", "of", "a", "certain", "organization" ]
50c124152e9de98bd789bf7593d152019269ff7b
https://github.com/yawik/jobs/blob/50c124152e9de98bd789bf7593d152019269ff7b/src/Repository/Job.php#L119-L126