id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
23,600
simbiosis-group/yii2-helper
models/ExcelImportForm.php
ExcelImportForm.getCellValue
public function getCellValue($value, $model, $record, $key, $isParent = true) { if ($isParent) { if(isset($model->importSafeAttributes()[$value]) && is_array($model->importSafeAttributes()[$value])) { $array = $model->importSafeAttributes()[$value]; return $array['model']::find() ->andWhere([$array['fieldName'] => $record[$key]]) ->one() ->id; } return isset($record[$key]) ? $record[$key] : ''; } if (!is_array($value)) { return $record[array_search($key, $this->header)]; } return $value['model']::find() ->andWhere([$value['fieldName'] => $record[array_search($key, $this->header)]]) ->one() ->id; }
php
public function getCellValue($value, $model, $record, $key, $isParent = true) { if ($isParent) { if(isset($model->importSafeAttributes()[$value]) && is_array($model->importSafeAttributes()[$value])) { $array = $model->importSafeAttributes()[$value]; return $array['model']::find() ->andWhere([$array['fieldName'] => $record[$key]]) ->one() ->id; } return isset($record[$key]) ? $record[$key] : ''; } if (!is_array($value)) { return $record[array_search($key, $this->header)]; } return $value['model']::find() ->andWhere([$value['fieldName'] => $record[array_search($key, $this->header)]]) ->one() ->id; }
[ "public", "function", "getCellValue", "(", "$", "value", ",", "$", "model", ",", "$", "record", ",", "$", "key", ",", "$", "isParent", "=", "true", ")", "{", "if", "(", "$", "isParent", ")", "{", "if", "(", "isset", "(", "$", "model", "->", "importSafeAttributes", "(", ")", "[", "$", "value", "]", ")", "&&", "is_array", "(", "$", "model", "->", "importSafeAttributes", "(", ")", "[", "$", "value", "]", ")", ")", "{", "$", "array", "=", "$", "model", "->", "importSafeAttributes", "(", ")", "[", "$", "value", "]", ";", "return", "$", "array", "[", "'model'", "]", "::", "find", "(", ")", "->", "andWhere", "(", "[", "$", "array", "[", "'fieldName'", "]", "=>", "$", "record", "[", "$", "key", "]", "]", ")", "->", "one", "(", ")", "->", "id", ";", "}", "return", "isset", "(", "$", "record", "[", "$", "key", "]", ")", "?", "$", "record", "[", "$", "key", "]", ":", "''", ";", "}", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "return", "$", "record", "[", "array_search", "(", "$", "key", ",", "$", "this", "->", "header", ")", "]", ";", "}", "return", "$", "value", "[", "'model'", "]", "::", "find", "(", ")", "->", "andWhere", "(", "[", "$", "value", "[", "'fieldName'", "]", "=>", "$", "record", "[", "array_search", "(", "$", "key", ",", "$", "this", "->", "header", ")", "]", "]", ")", "->", "one", "(", ")", "->", "id", ";", "}" ]
Get excel cell value. If the import safe attributes has the model declared, it will grab the id from that model instead of the cell value @param string $model The model name to save the excel rows into @param array $value The values to be assigned @param string $record The model name to save the excel rows into @param string $key The key @return Return true if all records is saved
[ "Get", "excel", "cell", "value", ".", "If", "the", "import", "safe", "attributes", "has", "the", "model", "declared", "it", "will", "grab", "the", "id", "from", "that", "model", "instead", "of", "the", "cell", "value" ]
c85c4204dd06b16e54210e75fe6deb51869d1dd9
https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/models/ExcelImportForm.php#L149-L172
23,601
TangoMan75/CallbackBundle
TwigExtension/Callback.php
Callback.callbackFunction
public function callbackFunction($route = null, $parameters = []) { if ($route === null || ! is_string($route)) { // Gets URI from current request $uri = $this->request->getUri(); } else { // Generates URI from '_route' $uri = $this->router->generate( $route, $parameters, Router::ABSOLUTE_URL ); } $result = parse_url($uri); // When uri contains query string if (isset($result['query'])) { parse_str($result['query'], $query); // Remove callback from query $query = array_diff_key($query, ['callback' => null]); } else { // Return unchanged uri return $uri; } return $result['scheme'].'://'. (isset($result['user']) ? $result['user'] : ''). (isset($result['pass']) ? ':'.$result['pass'].'@' : ''). $result['host']. (isset($result['port']) ? ':'.$result['port'] : ''). (isset($result['path']) ? $result['path'] : ''). ($query != [] ? '?'.http_build_query($query) : ''). (isset($result['fragment']) ? '#'.$result['fragment'] : ''); }
php
public function callbackFunction($route = null, $parameters = []) { if ($route === null || ! is_string($route)) { // Gets URI from current request $uri = $this->request->getUri(); } else { // Generates URI from '_route' $uri = $this->router->generate( $route, $parameters, Router::ABSOLUTE_URL ); } $result = parse_url($uri); // When uri contains query string if (isset($result['query'])) { parse_str($result['query'], $query); // Remove callback from query $query = array_diff_key($query, ['callback' => null]); } else { // Return unchanged uri return $uri; } return $result['scheme'].'://'. (isset($result['user']) ? $result['user'] : ''). (isset($result['pass']) ? ':'.$result['pass'].'@' : ''). $result['host']. (isset($result['port']) ? ':'.$result['port'] : ''). (isset($result['path']) ? $result['path'] : ''). ($query != [] ? '?'.http_build_query($query) : ''). (isset($result['fragment']) ? '#'.$result['fragment'] : ''); }
[ "public", "function", "callbackFunction", "(", "$", "route", "=", "null", ",", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "$", "route", "===", "null", "||", "!", "is_string", "(", "$", "route", ")", ")", "{", "// Gets URI from current request", "$", "uri", "=", "$", "this", "->", "request", "->", "getUri", "(", ")", ";", "}", "else", "{", "// Generates URI from '_route'", "$", "uri", "=", "$", "this", "->", "router", "->", "generate", "(", "$", "route", ",", "$", "parameters", ",", "Router", "::", "ABSOLUTE_URL", ")", ";", "}", "$", "result", "=", "parse_url", "(", "$", "uri", ")", ";", "// When uri contains query string", "if", "(", "isset", "(", "$", "result", "[", "'query'", "]", ")", ")", "{", "parse_str", "(", "$", "result", "[", "'query'", "]", ",", "$", "query", ")", ";", "// Remove callback from query", "$", "query", "=", "array_diff_key", "(", "$", "query", ",", "[", "'callback'", "=>", "null", "]", ")", ";", "}", "else", "{", "// Return unchanged uri", "return", "$", "uri", ";", "}", "return", "$", "result", "[", "'scheme'", "]", ".", "'://'", ".", "(", "isset", "(", "$", "result", "[", "'user'", "]", ")", "?", "$", "result", "[", "'user'", "]", ":", "''", ")", ".", "(", "isset", "(", "$", "result", "[", "'pass'", "]", ")", "?", "':'", ".", "$", "result", "[", "'pass'", "]", ".", "'@'", ":", "''", ")", ".", "$", "result", "[", "'host'", "]", ".", "(", "isset", "(", "$", "result", "[", "'port'", "]", ")", "?", "':'", ".", "$", "result", "[", "'port'", "]", ":", "''", ")", ".", "(", "isset", "(", "$", "result", "[", "'path'", "]", ")", "?", "$", "result", "[", "'path'", "]", ":", "''", ")", ".", "(", "$", "query", "!=", "[", "]", "?", "'?'", ".", "http_build_query", "(", "$", "query", ")", ":", "''", ")", ".", "(", "isset", "(", "$", "result", "[", "'fragment'", "]", ")", "?", "'#'", ".", "$", "result", "[", "'fragment'", "]", ":", "''", ")", ";", "}" ]
Removes callbacks from query @param string $route @param array $parameters @return string
[ "Removes", "callbacks", "from", "query" ]
a56f599c7786ee7a8134e4f7752da427036f8002
https://github.com/TangoMan75/CallbackBundle/blob/a56f599c7786ee7a8134e4f7752da427036f8002/TwigExtension/Callback.php#L72-L108
23,602
zhouyl/mellivora
Mellivora/Database/Schema/Grammars/Grammar.php
Grammar.getCommandsByName
protected function getCommandsByName(Blueprint $blueprint, $name) { return array_filter($blueprint->getCommands(), function ($value) use ($name) { return $value->name === $name; }); }
php
protected function getCommandsByName(Blueprint $blueprint, $name) { return array_filter($blueprint->getCommands(), function ($value) use ($name) { return $value->name === $name; }); }
[ "protected", "function", "getCommandsByName", "(", "Blueprint", "$", "blueprint", ",", "$", "name", ")", "{", "return", "array_filter", "(", "$", "blueprint", "->", "getCommands", "(", ")", ",", "function", "(", "$", "value", ")", "use", "(", "$", "name", ")", "{", "return", "$", "value", "->", "name", "===", "$", "name", ";", "}", ")", ";", "}" ]
Get all of the commands with a given name. @param \Mellivora\Database\Schema\Blueprint $blueprint @param string $name @return array
[ "Get", "all", "of", "the", "commands", "with", "a", "given", "name", "." ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Schema/Grammars/Grammar.php#L175-L180
23,603
CupOfTea696/WordPress-Composer
src/PluginInteractor.php
PluginInteractor.activate
public function activate(Composer $composer, IOInterface $io, $pluginName) { $plugin = $this->prepare(__FUNCTION__, $composer, $io, $pluginName); if ($plugin) { $result = $this->wp(function () use ($plugin) { wp_cache_set('plugins', [], 'plugins'); return activate_plugin($plugin); }); $this->succeeded(__FUNCTION__, $pluginName, $result === null); } }
php
public function activate(Composer $composer, IOInterface $io, $pluginName) { $plugin = $this->prepare(__FUNCTION__, $composer, $io, $pluginName); if ($plugin) { $result = $this->wp(function () use ($plugin) { wp_cache_set('plugins', [], 'plugins'); return activate_plugin($plugin); }); $this->succeeded(__FUNCTION__, $pluginName, $result === null); } }
[ "public", "function", "activate", "(", "Composer", "$", "composer", ",", "IOInterface", "$", "io", ",", "$", "pluginName", ")", "{", "$", "plugin", "=", "$", "this", "->", "prepare", "(", "__FUNCTION__", ",", "$", "composer", ",", "$", "io", ",", "$", "pluginName", ")", ";", "if", "(", "$", "plugin", ")", "{", "$", "result", "=", "$", "this", "->", "wp", "(", "function", "(", ")", "use", "(", "$", "plugin", ")", "{", "wp_cache_set", "(", "'plugins'", ",", "[", "]", ",", "'plugins'", ")", ";", "return", "activate_plugin", "(", "$", "plugin", ")", ";", "}", ")", ";", "$", "this", "->", "succeeded", "(", "__FUNCTION__", ",", "$", "pluginName", ",", "$", "result", "===", "null", ")", ";", "}", "}" ]
Activate a plugin. @param \Composer\Composer $composer @param \Composer\IO\IOInterface $io @param string $plugin @return void
[ "Activate", "a", "plugin", "." ]
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/PluginInteractor.php#L67-L80
23,604
CupOfTea696/WordPress-Composer
src/PluginInteractor.php
PluginInteractor.deactivate
public function deactivate(Composer $composer, IOInterface $io, $pluginName) { $plugin = $this->prepare(__FUNCTION__, $composer, $io, $pluginName); if ($plugin) { $result = $this->wp(function () use ($plugin) { return deactivate_plugins($plugin); }); $this->succeeded(__FUNCTION__, $pluginName, $result === null); } }
php
public function deactivate(Composer $composer, IOInterface $io, $pluginName) { $plugin = $this->prepare(__FUNCTION__, $composer, $io, $pluginName); if ($plugin) { $result = $this->wp(function () use ($plugin) { return deactivate_plugins($plugin); }); $this->succeeded(__FUNCTION__, $pluginName, $result === null); } }
[ "public", "function", "deactivate", "(", "Composer", "$", "composer", ",", "IOInterface", "$", "io", ",", "$", "pluginName", ")", "{", "$", "plugin", "=", "$", "this", "->", "prepare", "(", "__FUNCTION__", ",", "$", "composer", ",", "$", "io", ",", "$", "pluginName", ")", ";", "if", "(", "$", "plugin", ")", "{", "$", "result", "=", "$", "this", "->", "wp", "(", "function", "(", ")", "use", "(", "$", "plugin", ")", "{", "return", "deactivate_plugins", "(", "$", "plugin", ")", ";", "}", ")", ";", "$", "this", "->", "succeeded", "(", "__FUNCTION__", ",", "$", "pluginName", ",", "$", "result", "===", "null", ")", ";", "}", "}" ]
Deactivate a plugin. @param \Composer\Composer $composer @param \Composer\IO\IOInterface $io @param string $plugin @return void
[ "Deactivate", "a", "plugin", "." ]
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/PluginInteractor.php#L90-L101
23,605
CupOfTea696/WordPress-Composer
src/PluginInteractor.php
PluginInteractor.uninstall
public function uninstall(Composer $composer, IOInterface $io, $pluginName) { $plugin = $this->prepare(__FUNCTION__, $composer, $io, $pluginName); if ($plugin) { $result = $this->wp(function () use ($plugin) { return uninstall_plugin($plugin); }); $this->succeeded(__FUNCTION__, $pluginName, $result === true || $result === null); } }
php
public function uninstall(Composer $composer, IOInterface $io, $pluginName) { $plugin = $this->prepare(__FUNCTION__, $composer, $io, $pluginName); if ($plugin) { $result = $this->wp(function () use ($plugin) { return uninstall_plugin($plugin); }); $this->succeeded(__FUNCTION__, $pluginName, $result === true || $result === null); } }
[ "public", "function", "uninstall", "(", "Composer", "$", "composer", ",", "IOInterface", "$", "io", ",", "$", "pluginName", ")", "{", "$", "plugin", "=", "$", "this", "->", "prepare", "(", "__FUNCTION__", ",", "$", "composer", ",", "$", "io", ",", "$", "pluginName", ")", ";", "if", "(", "$", "plugin", ")", "{", "$", "result", "=", "$", "this", "->", "wp", "(", "function", "(", ")", "use", "(", "$", "plugin", ")", "{", "return", "uninstall_plugin", "(", "$", "plugin", ")", ";", "}", ")", ";", "$", "this", "->", "succeeded", "(", "__FUNCTION__", ",", "$", "pluginName", ",", "$", "result", "===", "true", "||", "$", "result", "===", "null", ")", ";", "}", "}" ]
Uninstall a plugin. @param \Composer\Composer $composer @param \Composer\IO\IOInterface $io @param string $plugin @return void
[ "Uninstall", "a", "plugin", "." ]
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/PluginInteractor.php#L111-L122
23,606
CupOfTea696/WordPress-Composer
src/PluginInteractor.php
PluginInteractor.prepare
protected function prepare($action, Composer $composer, IOInterface $io, $pluginName) { $this->composer = $composer; $this->io = $io; if ($this->isPluginExcluded($action, $pluginName)) { return $this->excluded($action, $pluginName) && false; } $plugin = $this->getPlugin($pluginName); if (! $plugin) { return $this->failed($action, $pluginName) && false; } $this->executing($action, $pluginName); return $plugin; }
php
protected function prepare($action, Composer $composer, IOInterface $io, $pluginName) { $this->composer = $composer; $this->io = $io; if ($this->isPluginExcluded($action, $pluginName)) { return $this->excluded($action, $pluginName) && false; } $plugin = $this->getPlugin($pluginName); if (! $plugin) { return $this->failed($action, $pluginName) && false; } $this->executing($action, $pluginName); return $plugin; }
[ "protected", "function", "prepare", "(", "$", "action", ",", "Composer", "$", "composer", ",", "IOInterface", "$", "io", ",", "$", "pluginName", ")", "{", "$", "this", "->", "composer", "=", "$", "composer", ";", "$", "this", "->", "io", "=", "$", "io", ";", "if", "(", "$", "this", "->", "isPluginExcluded", "(", "$", "action", ",", "$", "pluginName", ")", ")", "{", "return", "$", "this", "->", "excluded", "(", "$", "action", ",", "$", "pluginName", ")", "&&", "false", ";", "}", "$", "plugin", "=", "$", "this", "->", "getPlugin", "(", "$", "pluginName", ")", ";", "if", "(", "!", "$", "plugin", ")", "{", "return", "$", "this", "->", "failed", "(", "$", "action", ",", "$", "pluginName", ")", "&&", "false", ";", "}", "$", "this", "->", "executing", "(", "$", "action", ",", "$", "pluginName", ")", ";", "return", "$", "plugin", ";", "}" ]
Prepare plugin interaction. @param string $action @param \Composer\Composer $composer @param \Composer\IO\IOInterface $io @param string $pluginName @return string|false
[ "Prepare", "plugin", "interaction", "." ]
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/PluginInteractor.php#L133-L151
23,607
CupOfTea696/WordPress-Composer
src/PluginInteractor.php
PluginInteractor.getPlugin
protected function getPlugin($plugin) { $path = $this->plugin->getPublicDirectory() . '/plugins/' . $plugin; if (file_exists($path) && is_dir($path)) { $files = scandir($path); foreach ($files as $file) { $pattern = defined('HHVM_VERSION') ? '/\.(php|hh)$/' : '/\.php$/'; if (preg_match($pattern, $file)) { $content = file_get_contents($path . '/' . $file); if (preg_match('/\/\*(?!.*\*\/.*Plugin Name).*Plugin Name/si', $content)) { return $plugin . '/' . $file; } } } } if (file_exists($path . '.php')) { return $plugin . '.php'; } if (defined('HHVM_VERSION') && file_exists($path . '.hh')) { return $plugin . '.hh'; } return false; }
php
protected function getPlugin($plugin) { $path = $this->plugin->getPublicDirectory() . '/plugins/' . $plugin; if (file_exists($path) && is_dir($path)) { $files = scandir($path); foreach ($files as $file) { $pattern = defined('HHVM_VERSION') ? '/\.(php|hh)$/' : '/\.php$/'; if (preg_match($pattern, $file)) { $content = file_get_contents($path . '/' . $file); if (preg_match('/\/\*(?!.*\*\/.*Plugin Name).*Plugin Name/si', $content)) { return $plugin . '/' . $file; } } } } if (file_exists($path . '.php')) { return $plugin . '.php'; } if (defined('HHVM_VERSION') && file_exists($path . '.hh')) { return $plugin . '.hh'; } return false; }
[ "protected", "function", "getPlugin", "(", "$", "plugin", ")", "{", "$", "path", "=", "$", "this", "->", "plugin", "->", "getPublicDirectory", "(", ")", ".", "'/plugins/'", ".", "$", "plugin", ";", "if", "(", "file_exists", "(", "$", "path", ")", "&&", "is_dir", "(", "$", "path", ")", ")", "{", "$", "files", "=", "scandir", "(", "$", "path", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "pattern", "=", "defined", "(", "'HHVM_VERSION'", ")", "?", "'/\\.(php|hh)$/'", ":", "'/\\.php$/'", ";", "if", "(", "preg_match", "(", "$", "pattern", ",", "$", "file", ")", ")", "{", "$", "content", "=", "file_get_contents", "(", "$", "path", ".", "'/'", ".", "$", "file", ")", ";", "if", "(", "preg_match", "(", "'/\\/\\*(?!.*\\*\\/.*Plugin Name).*Plugin Name/si'", ",", "$", "content", ")", ")", "{", "return", "$", "plugin", ".", "'/'", ".", "$", "file", ";", "}", "}", "}", "}", "if", "(", "file_exists", "(", "$", "path", ".", "'.php'", ")", ")", "{", "return", "$", "plugin", ".", "'.php'", ";", "}", "if", "(", "defined", "(", "'HHVM_VERSION'", ")", "&&", "file_exists", "(", "$", "path", ".", "'.hh'", ")", ")", "{", "return", "$", "plugin", ".", "'.hh'", ";", "}", "return", "false", ";", "}" ]
Get the main plugin file for a plugin. @param string $plugin @return string|false
[ "Get", "the", "main", "plugin", "file", "for", "a", "plugin", "." ]
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/PluginInteractor.php#L174-L203
23,608
CupOfTea696/WordPress-Composer
src/PluginInteractor.php
PluginInteractor.executing
protected function executing($action, $plugin) { $this->io->write(' - ' . ucfirst($this->getActionExecuting($action)) . ' plugin <info>' . $plugin . '</info>'); $this->io->write(''); }
php
protected function executing($action, $plugin) { $this->io->write(' - ' . ucfirst($this->getActionExecuting($action)) . ' plugin <info>' . $plugin . '</info>'); $this->io->write(''); }
[ "protected", "function", "executing", "(", "$", "action", ",", "$", "plugin", ")", "{", "$", "this", "->", "io", "->", "write", "(", "' - '", ".", "ucfirst", "(", "$", "this", "->", "getActionExecuting", "(", "$", "action", ")", ")", ".", "' plugin <info>'", ".", "$", "plugin", ".", "'</info>'", ")", ";", "$", "this", "->", "io", "->", "write", "(", "''", ")", ";", "}" ]
Write action executing. @param string $action @param string $plugin @return void
[ "Write", "action", "executing", "." ]
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/PluginInteractor.php#L224-L228
23,609
CupOfTea696/WordPress-Composer
src/PluginInteractor.php
PluginInteractor.wp
protected function wp(Closure $cmd) { $cmd = new ReflectionFunction($cmd); $code = implode(array_slice(file($cmd->getFileName()), ($startLine = $cmd->getStartLine() - 1), $cmd->getEndLine() - $startLine)); preg_match('/\\{(.*)\\}/s', $code, $body); $vars = $cmd->getStaticVariables(); $cmd = trim(preg_replace_callback('/return(?:;|\s((?:[^;(]*(?:\(.*\))?)+);)/s', function ($matches) { if (! empty($matches[1])) { return "return print 'OUTPUT>>>' . serialize({$matches[1]});"; } return "return print 'OUTPUT>>>' . serialize(null);"; }, $body[1])); $config = [ '__host' => env('DB_HOST', 'localhost'), '__name' => env('DB_NAME', 'homestead'), '__user' => env('DB_USER', 'homestead'), '__pass' => env('DB_PASS', 'secret'), '__abspath' => $this->plugin->getPublicDirectory() . '/wp/', '__wp' => dirname(__FILE__) . '/wordpress.php', ]; $config = serialize($config); $vars = serialize($vars); $p = new PhpProcess("<?php extract(unserialize('$config')); try { \$db = new PDO('mysql:host=' . \$__host . ';dbname=' . \$__name, \$__user, \$__pass); } catch (PDOException \$e) { if (\$__host == 'localhost') { \$__host = '127.0.0.1'; } \$db = new PDO('mysql:host=' . \$__host . ';port=33060;dbname=' . \$__name, \$__user, \$__pass); \$__host = \$__host . ':33060'; } catch (PDOException \$e) { return; } define('DB_HOST', \$__host); define('ABSPATH', \$__abspath); \$_SERVER = [ 'HTTP_HOST' => 'http://mysite.com', 'SERVER_NAME' => 'http://mysite.com', 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET' ]; //require the WP bootstrap require_once ABSPATH . '/wp-admin/includes/plugin.php'; require_once ABSPATH . '/wp-load.php'; extract(unserialize('$vars')); $cmd "); $p->run(); if (preg_match('/OUTPUT>>>(.*)$/s', $p->getOutput(), $matches)) { return unserialize($matches[1]); } }
php
protected function wp(Closure $cmd) { $cmd = new ReflectionFunction($cmd); $code = implode(array_slice(file($cmd->getFileName()), ($startLine = $cmd->getStartLine() - 1), $cmd->getEndLine() - $startLine)); preg_match('/\\{(.*)\\}/s', $code, $body); $vars = $cmd->getStaticVariables(); $cmd = trim(preg_replace_callback('/return(?:;|\s((?:[^;(]*(?:\(.*\))?)+);)/s', function ($matches) { if (! empty($matches[1])) { return "return print 'OUTPUT>>>' . serialize({$matches[1]});"; } return "return print 'OUTPUT>>>' . serialize(null);"; }, $body[1])); $config = [ '__host' => env('DB_HOST', 'localhost'), '__name' => env('DB_NAME', 'homestead'), '__user' => env('DB_USER', 'homestead'), '__pass' => env('DB_PASS', 'secret'), '__abspath' => $this->plugin->getPublicDirectory() . '/wp/', '__wp' => dirname(__FILE__) . '/wordpress.php', ]; $config = serialize($config); $vars = serialize($vars); $p = new PhpProcess("<?php extract(unserialize('$config')); try { \$db = new PDO('mysql:host=' . \$__host . ';dbname=' . \$__name, \$__user, \$__pass); } catch (PDOException \$e) { if (\$__host == 'localhost') { \$__host = '127.0.0.1'; } \$db = new PDO('mysql:host=' . \$__host . ';port=33060;dbname=' . \$__name, \$__user, \$__pass); \$__host = \$__host . ':33060'; } catch (PDOException \$e) { return; } define('DB_HOST', \$__host); define('ABSPATH', \$__abspath); \$_SERVER = [ 'HTTP_HOST' => 'http://mysite.com', 'SERVER_NAME' => 'http://mysite.com', 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET' ]; //require the WP bootstrap require_once ABSPATH . '/wp-admin/includes/plugin.php'; require_once ABSPATH . '/wp-load.php'; extract(unserialize('$vars')); $cmd "); $p->run(); if (preg_match('/OUTPUT>>>(.*)$/s', $p->getOutput(), $matches)) { return unserialize($matches[1]); } }
[ "protected", "function", "wp", "(", "Closure", "$", "cmd", ")", "{", "$", "cmd", "=", "new", "ReflectionFunction", "(", "$", "cmd", ")", ";", "$", "code", "=", "implode", "(", "array_slice", "(", "file", "(", "$", "cmd", "->", "getFileName", "(", ")", ")", ",", "(", "$", "startLine", "=", "$", "cmd", "->", "getStartLine", "(", ")", "-", "1", ")", ",", "$", "cmd", "->", "getEndLine", "(", ")", "-", "$", "startLine", ")", ")", ";", "preg_match", "(", "'/\\\\{(.*)\\\\}/s'", ",", "$", "code", ",", "$", "body", ")", ";", "$", "vars", "=", "$", "cmd", "->", "getStaticVariables", "(", ")", ";", "$", "cmd", "=", "trim", "(", "preg_replace_callback", "(", "'/return(?:;|\\s((?:[^;(]*(?:\\(.*\\))?)+);)/s'", ",", "function", "(", "$", "matches", ")", "{", "if", "(", "!", "empty", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "\"return print 'OUTPUT>>>' . serialize({$matches[1]});\"", ";", "}", "return", "\"return print 'OUTPUT>>>' . serialize(null);\"", ";", "}", ",", "$", "body", "[", "1", "]", ")", ")", ";", "$", "config", "=", "[", "'__host'", "=>", "env", "(", "'DB_HOST'", ",", "'localhost'", ")", ",", "'__name'", "=>", "env", "(", "'DB_NAME'", ",", "'homestead'", ")", ",", "'__user'", "=>", "env", "(", "'DB_USER'", ",", "'homestead'", ")", ",", "'__pass'", "=>", "env", "(", "'DB_PASS'", ",", "'secret'", ")", ",", "'__abspath'", "=>", "$", "this", "->", "plugin", "->", "getPublicDirectory", "(", ")", ".", "'/wp/'", ",", "'__wp'", "=>", "dirname", "(", "__FILE__", ")", ".", "'/wordpress.php'", ",", "]", ";", "$", "config", "=", "serialize", "(", "$", "config", ")", ";", "$", "vars", "=", "serialize", "(", "$", "vars", ")", ";", "$", "p", "=", "new", "PhpProcess", "(", "\"<?php\n extract(unserialize('$config'));\n \n try {\n \\$db = new PDO('mysql:host=' . \\$__host . ';dbname=' . \\$__name, \\$__user, \\$__pass);\n } catch (PDOException \\$e) {\n if (\\$__host == 'localhost') {\n \\$__host = '127.0.0.1';\n }\n \n \\$db = new PDO('mysql:host=' . \\$__host . ';port=33060;dbname=' . \\$__name, \\$__user, \\$__pass);\n \n \\$__host = \\$__host . ':33060';\n } catch (PDOException \\$e) {\n return;\n }\n \n define('DB_HOST', \\$__host);\n define('ABSPATH', \\$__abspath);\n \n \\$_SERVER = [\n 'HTTP_HOST' => 'http://mysite.com',\n 'SERVER_NAME' => 'http://mysite.com',\n 'REQUEST_URI' => '/',\n 'REQUEST_METHOD' => 'GET'\n ];\n \n //require the WP bootstrap\n require_once ABSPATH . '/wp-admin/includes/plugin.php';\n require_once ABSPATH . '/wp-load.php';\n \n extract(unserialize('$vars'));\n $cmd\n \"", ")", ";", "$", "p", "->", "run", "(", ")", ";", "if", "(", "preg_match", "(", "'/OUTPUT>>>(.*)$/s'", ",", "$", "p", "->", "getOutput", "(", ")", ",", "$", "matches", ")", ")", "{", "return", "unserialize", "(", "$", "matches", "[", "1", "]", ")", ";", "}", "}" ]
Run a closure in the WordPress environment. @param closure $cmd @return mixed
[ "Run", "a", "closure", "in", "the", "WordPress", "environment", "." ]
8c0abc10f82b8ce1db5354f6a041c7587ad3fb90
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/PluginInteractor.php#L305-L373
23,610
GrupaZero/api
src/Gzero/Api/Controller/Admin/RouteController.php
RouteController.store
public function store($contentId) { $content = $this->repository->getById($contentId); if (!empty($content)) { $this->authorize('create', $content); $this->authorize('update', $content); if ($content->type != 'category') { $input = $this->validator->validate('create'); $route = $this->repository->createRoute($content, $input['lang_code'], $input['url']); return $this->respondWithSuccess($route, new RouteTransformer); } else { // TODO categories children route update throw new RepositoryValidationException("You can't change category url", 500); } } return $this->respondNotFound(); }
php
public function store($contentId) { $content = $this->repository->getById($contentId); if (!empty($content)) { $this->authorize('create', $content); $this->authorize('update', $content); if ($content->type != 'category') { $input = $this->validator->validate('create'); $route = $this->repository->createRoute($content, $input['lang_code'], $input['url']); return $this->respondWithSuccess($route, new RouteTransformer); } else { // TODO categories children route update throw new RepositoryValidationException("You can't change category url", 500); } } return $this->respondNotFound(); }
[ "public", "function", "store", "(", "$", "contentId", ")", "{", "$", "content", "=", "$", "this", "->", "repository", "->", "getById", "(", "$", "contentId", ")", ";", "if", "(", "!", "empty", "(", "$", "content", ")", ")", "{", "$", "this", "->", "authorize", "(", "'create'", ",", "$", "content", ")", ";", "$", "this", "->", "authorize", "(", "'update'", ",", "$", "content", ")", ";", "if", "(", "$", "content", "->", "type", "!=", "'category'", ")", "{", "$", "input", "=", "$", "this", "->", "validator", "->", "validate", "(", "'create'", ")", ";", "$", "route", "=", "$", "this", "->", "repository", "->", "createRoute", "(", "$", "content", ",", "$", "input", "[", "'lang_code'", "]", ",", "$", "input", "[", "'url'", "]", ")", ";", "return", "$", "this", "->", "respondWithSuccess", "(", "$", "route", ",", "new", "RouteTransformer", ")", ";", "}", "else", "{", "// TODO categories children route update", "throw", "new", "RepositoryValidationException", "(", "\"You can't change category url\"", ",", "500", ")", ";", "}", "}", "return", "$", "this", "->", "respondNotFound", "(", ")", ";", "}" ]
Stores newly created route for specified content entity in database. @param int $contentId Id of the content @return \Illuminate\Http\JsonResponse @throws RepositoryValidationException
[ "Stores", "newly", "created", "route", "for", "specified", "content", "entity", "in", "database", "." ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/RouteController.php#L62-L78
23,611
Eresus/EresusCMS
src/core/DB.php
Eresus_DB.lazyConnection
public static function lazyConnection($dsn, $name = false) { Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '("%s", %s)', $dsn, $name); self::$lazyConnectionDSNs[$name] = $dsn; }
php
public static function lazyConnection($dsn, $name = false) { Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '("%s", %s)', $dsn, $name); self::$lazyConnectionDSNs[$name] = $dsn; }
[ "public", "static", "function", "lazyConnection", "(", "$", "dsn", ",", "$", "name", "=", "false", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_DEBUG", ",", "'(\"%s\", %s)'", ",", "$", "dsn", ",", "$", "name", ")", ";", "self", "::", "$", "lazyConnectionDSNs", "[", "$", "name", "]", "=", "$", "dsn", ";", "}" ]
Configures lazy connection to DB @param string $dsn Connection DSN string @param string|bool $name Optional connection name @return void
[ "Configures", "lazy", "connection", "to", "DB" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/DB.php#L85-L89
23,612
Eresus/EresusCMS
src/core/DB.php
Eresus_DB.configureObject
public static function configureObject($name) { Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '(%s)', $name); if (!isset(self::$lazyConnectionDSNs[$name])) { throw new Eresus_DB_Exception('DSN for lazy connection "' . $name . '" not found'); } $dsn = self::$lazyConnectionDSNs[$name]; $db = self::connect($dsn, $name); return $db; }
php
public static function configureObject($name) { Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '(%s)', $name); if (!isset(self::$lazyConnectionDSNs[$name])) { throw new Eresus_DB_Exception('DSN for lazy connection "' . $name . '" not found'); } $dsn = self::$lazyConnectionDSNs[$name]; $db = self::connect($dsn, $name); return $db; }
[ "public", "static", "function", "configureObject", "(", "$", "name", ")", "{", "Eresus_Kernel", "::", "log", "(", "__METHOD__", ",", "LOG_DEBUG", ",", "'(%s)'", ",", "$", "name", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "lazyConnectionDSNs", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "Eresus_DB_Exception", "(", "'DSN for lazy connection \"'", ".", "$", "name", ".", "'\" not found'", ")", ";", "}", "$", "dsn", "=", "self", "::", "$", "lazyConnectionDSNs", "[", "$", "name", "]", ";", "$", "db", "=", "self", "::", "connect", "(", "$", "dsn", ",", "$", "name", ")", ";", "return", "$", "db", ";", "}" ]
eZ Components lazy init @param bool|string $name Connection name @throws Eresus_DB_Exception @return ezcDbHandler
[ "eZ", "Components", "lazy", "init" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/DB.php#L123-L136
23,613
Eresus/EresusCMS
src/core/DB.php
DBQueryInsider.subst
public function subst($query) { foreach ($this->values as $key => $value) { $query = preg_replace("/$key(\s|,|$)/", "$value$1", $query); } return $query; }
php
public function subst($query) { foreach ($this->values as $key => $value) { $query = preg_replace("/$key(\s|,|$)/", "$value$1", $query); } return $query; }
[ "public", "function", "subst", "(", "$", "query", ")", "{", "foreach", "(", "$", "this", "->", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "query", "=", "preg_replace", "(", "\"/$key(\\s|,|$)/\"", ",", "\"$value$1\"", ",", "$", "query", ")", ";", "}", "return", "$", "query", ";", "}" ]
Substitute values in query @param string $query @return string
[ "Substitute", "values", "in", "query" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/DB.php#L242-L250
23,614
surebert/surebert-framework
src/sb/Cameras/Axis/Q6035.php
Q6035.takeSnapShot
public function takeSnapShot($user_agent='Surebert Kamera', $options=Array()){ $ch = curl_init($this->url.'/jpg/1/image.jpg?timestamp='.time()); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); curl_setopt($ch, CURLOPT_USERPWD, $this->uname.':'.$this->pass); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,2); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //add any additional options passed foreach($options as $k=>$v){ curl_setopt($ch, $k, $v); } return curl_exec($ch); }
php
public function takeSnapShot($user_agent='Surebert Kamera', $options=Array()){ $ch = curl_init($this->url.'/jpg/1/image.jpg?timestamp='.time()); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); curl_setopt($ch, CURLOPT_USERPWD, $this->uname.':'.$this->pass); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,2); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //add any additional options passed foreach($options as $k=>$v){ curl_setopt($ch, $k, $v); } return curl_exec($ch); }
[ "public", "function", "takeSnapShot", "(", "$", "user_agent", "=", "'Surebert Kamera'", ",", "$", "options", "=", "Array", "(", ")", ")", "{", "$", "ch", "=", "curl_init", "(", "$", "this", "->", "url", ".", "'/jpg/1/image.jpg?timestamp='", ".", "time", "(", ")", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPAUTH", ",", "CURLAUTH_DIGEST", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_USERPWD", ",", "$", "this", "->", "uname", ".", "':'", ".", "$", "this", "->", "pass", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYHOST", ",", "2", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_USERAGENT", ",", "$", "user_agent", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_FOLLOWLOCATION", ",", "1", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CONNECTTIMEOUT", ",", "2", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "//add any additional options passed", "foreach", "(", "$", "options", "as", "$", "k", "=>", "$", "v", ")", "{", "curl_setopt", "(", "$", "ch", ",", "$", "k", ",", "$", "v", ")", ";", "}", "return", "curl_exec", "(", "$", "ch", ")", ";", "}" ]
Retrives a current snapshot @return string jpeg data
[ "Retrives", "a", "current", "snapshot" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cameras/Axis/Q6035.php#L49-L65
23,615
surebert/surebert-framework
src/sb/Cameras/Axis/Q6035.php
Q6035.saveSnapshot
public function saveSnapshot($dir){ if(!is_dir($dir)){ mkdir($dir, 0775, true); } $jpeg = $this->takeSnapShot(); $file = $dir.'/'.date('Y_m_d_H_i_s').'.jpg'; if(file_put_contents($file, $jpeg)){ return $file; } return ''; }
php
public function saveSnapshot($dir){ if(!is_dir($dir)){ mkdir($dir, 0775, true); } $jpeg = $this->takeSnapShot(); $file = $dir.'/'.date('Y_m_d_H_i_s').'.jpg'; if(file_put_contents($file, $jpeg)){ return $file; } return ''; }
[ "public", "function", "saveSnapshot", "(", "$", "dir", ")", "{", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0775", ",", "true", ")", ";", "}", "$", "jpeg", "=", "$", "this", "->", "takeSnapShot", "(", ")", ";", "$", "file", "=", "$", "dir", ".", "'/'", ".", "date", "(", "'Y_m_d_H_i_s'", ")", ".", "'.jpg'", ";", "if", "(", "file_put_contents", "(", "$", "file", ",", "$", "jpeg", ")", ")", "{", "return", "$", "file", ";", "}", "return", "''", ";", "}" ]
Retrieves and stores a snapshot by date @param type $dir @return string Path if saved, empty string if not
[ "Retrieves", "and", "stores", "a", "snapshot", "by", "date" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cameras/Axis/Q6035.php#L72-L85
23,616
Visithor/visithor
src/Visithor/Command/GoCommand.php
GoCommand.checkEnvironment
protected function checkEnvironment( InputInterface $input, OutputInterface $output ) { $env = $input ->getParameterOption( ['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev' ); if ('test' != $env) { $output->writeln('<bg=red> </bg=red> <fg=red>Warning, make sure your tests are being run against testing environments</fg=red>'); } return $this; }
php
protected function checkEnvironment( InputInterface $input, OutputInterface $output ) { $env = $input ->getParameterOption( ['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev' ); if ('test' != $env) { $output->writeln('<bg=red> </bg=red> <fg=red>Warning, make sure your tests are being run against testing environments</fg=red>'); } return $this; }
[ "protected", "function", "checkEnvironment", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "env", "=", "$", "input", "->", "getParameterOption", "(", "[", "'--env'", ",", "'-e'", "]", ",", "getenv", "(", "'SYMFONY_ENV'", ")", "?", ":", "'dev'", ")", ";", "if", "(", "'test'", "!=", "$", "env", ")", "{", "$", "output", "->", "writeln", "(", "'<bg=red> </bg=red> <fg=red>Warning, make sure your tests are being run against testing environments</fg=red>'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Check environment. If not test, add a notice @param InputInterface $input Input @param OutputInterface $output Output @return $this Self object
[ "Check", "environment", ".", "If", "not", "test", "add", "a", "notice" ]
201ba2cfc536a0875983c79226947aa20b9f4dca
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Command/GoCommand.php#L171-L186
23,617
gocom/rah_backup
src/Rah/Backup.php
Rah_Backup.sanitize
private function sanitize($filename) { $filename = preg_replace('/[^A-Za-z0-9\-\._]/', '.', (string) $filename); return trim(substr(preg_replace('/[_\.\-]{2,}/', '.', $filename), 0, 40), '._-'); }
php
private function sanitize($filename) { $filename = preg_replace('/[^A-Za-z0-9\-\._]/', '.', (string) $filename); return trim(substr(preg_replace('/[_\.\-]{2,}/', '.', $filename), 0, 40), '._-'); }
[ "private", "function", "sanitize", "(", "$", "filename", ")", "{", "$", "filename", "=", "preg_replace", "(", "'/[^A-Za-z0-9\\-\\._]/'", ",", "'.'", ",", "(", "string", ")", "$", "filename", ")", ";", "return", "trim", "(", "substr", "(", "preg_replace", "(", "'/[_\\.\\-]{2,}/'", ",", "'.'", ",", "$", "filename", ")", ",", "0", ",", "40", ")", ",", "'._-'", ")", ";", "}" ]
Sanitizes filename. @param string $filename The filename @return string A safe filename
[ "Sanitizes", "filename", "." ]
1a757c0fd569f4baf59471da8b1b487472a71390
https://github.com/gocom/rah_backup/blob/1a757c0fd569f4baf59471da8b1b487472a71390/src/Rah/Backup.php#L263-L267
23,618
gocom/rah_backup
src/Rah/Backup.php
Rah_Backup.pane
public function pane() { global $step; require_privs('rah_backup'); $steps = array( 'browser' => false, 'create' => true, 'download' => true, 'multi_edit' => true, ); if (!$step || !bouncer($step, $steps) || !has_privs('rah_backup_' . $step)) { $step = 'browser'; } $this->$step(); }
php
public function pane() { global $step; require_privs('rah_backup'); $steps = array( 'browser' => false, 'create' => true, 'download' => true, 'multi_edit' => true, ); if (!$step || !bouncer($step, $steps) || !has_privs('rah_backup_' . $step)) { $step = 'browser'; } $this->$step(); }
[ "public", "function", "pane", "(", ")", "{", "global", "$", "step", ";", "require_privs", "(", "'rah_backup'", ")", ";", "$", "steps", "=", "array", "(", "'browser'", "=>", "false", ",", "'create'", "=>", "true", ",", "'download'", "=>", "true", ",", "'multi_edit'", "=>", "true", ",", ")", ";", "if", "(", "!", "$", "step", "||", "!", "bouncer", "(", "$", "step", ",", "$", "steps", ")", "||", "!", "has_privs", "(", "'rah_backup_'", ".", "$", "step", ")", ")", "{", "$", "step", "=", "'browser'", ";", "}", "$", "this", "->", "$", "step", "(", ")", ";", "}" ]
Delivers panels.
[ "Delivers", "panels", "." ]
1a757c0fd569f4baf59471da8b1b487472a71390
https://github.com/gocom/rah_backup/blob/1a757c0fd569f4baf59471da8b1b487472a71390/src/Rah/Backup.php#L273-L291
23,619
gocom/rah_backup
src/Rah/Backup.php
Rah_Backup.head
public function head() { global $event, $theme; if ($event != 'rah_backup') { return; } gTxtScript(array( 'rah_backup_confirm_backup', )); $msg = array( 'backup' => escape_js($theme->announce_async(gTxt('rah_backup_taking'))), 'error' => escape_js($theme->announce_async(gTxt('rah_backup_task_error'))), ); $js = <<<EOF $(function () { $('.rah_backup_take').on('click', function (e) { e.preventDefault(); var obj = $(this), href, spinner; if (obj.hasClass('disabled') || !verify(textpattern.gTxt('rah_backup_confirm_backup'))) { return false; } $.globalEval('{$msg['backup']}'); spinner = $('<span> <span class="spinner"></span> </span>'); href = obj.attr('href'); obj.addClass('disabled').attr('href', '#').after(spinner); $.ajax('index.php', { data: href.substr(1) + '&app_mode=async', dataType: 'script', timeout: 1800000 }).fail(function () { $.globalEval('{$msg['error']}'); }).always(function () { obj.removeClass('disabled').attr('href', href); spinner.remove(); }); }); }); EOF; echo script_js($js); }
php
public function head() { global $event, $theme; if ($event != 'rah_backup') { return; } gTxtScript(array( 'rah_backup_confirm_backup', )); $msg = array( 'backup' => escape_js($theme->announce_async(gTxt('rah_backup_taking'))), 'error' => escape_js($theme->announce_async(gTxt('rah_backup_task_error'))), ); $js = <<<EOF $(function () { $('.rah_backup_take').on('click', function (e) { e.preventDefault(); var obj = $(this), href, spinner; if (obj.hasClass('disabled') || !verify(textpattern.gTxt('rah_backup_confirm_backup'))) { return false; } $.globalEval('{$msg['backup']}'); spinner = $('<span> <span class="spinner"></span> </span>'); href = obj.attr('href'); obj.addClass('disabled').attr('href', '#').after(spinner); $.ajax('index.php', { data: href.substr(1) + '&app_mode=async', dataType: 'script', timeout: 1800000 }).fail(function () { $.globalEval('{$msg['error']}'); }).always(function () { obj.removeClass('disabled').attr('href', href); spinner.remove(); }); }); }); EOF; echo script_js($js); }
[ "public", "function", "head", "(", ")", "{", "global", "$", "event", ",", "$", "theme", ";", "if", "(", "$", "event", "!=", "'rah_backup'", ")", "{", "return", ";", "}", "gTxtScript", "(", "array", "(", "'rah_backup_confirm_backup'", ",", ")", ")", ";", "$", "msg", "=", "array", "(", "'backup'", "=>", "escape_js", "(", "$", "theme", "->", "announce_async", "(", "gTxt", "(", "'rah_backup_taking'", ")", ")", ")", ",", "'error'", "=>", "escape_js", "(", "$", "theme", "->", "announce_async", "(", "gTxt", "(", "'rah_backup_task_error'", ")", ")", ")", ",", ")", ";", "$", "js", "=", " <<<EOF\n $(function ()\n {\n $('.rah_backup_take').on('click', function (e)\n {\n e.preventDefault();\n var obj = $(this), href, spinner;\n\n if (obj.hasClass('disabled') || !verify(textpattern.gTxt('rah_backup_confirm_backup'))) {\n return false;\n }\n\n $.globalEval('{$msg['backup']}');\n\n spinner = $('<span> <span class=\"spinner\"></span> </span>');\n href = obj.attr('href');\n obj.addClass('disabled').attr('href', '#').after(spinner);\n\n $.ajax('index.php', {\n data: href.substr(1) + '&app_mode=async',\n dataType: 'script',\n timeout: 1800000\n }).fail(function ()\n {\n $.globalEval('{$msg['error']}');\n }).always(function ()\n {\n obj.removeClass('disabled').attr('href', href);\n spinner.remove();\n });\n });\n });\nEOF", ";", "echo", "script_js", "(", "$", "js", ")", ";", "}" ]
Adds the panel's CSS and JavaScript to the &lt;head&gt;.
[ "Adds", "the", "panel", "s", "CSS", "and", "JavaScript", "to", "the", "&lt", ";", "head&gt", ";", "." ]
1a757c0fd569f4baf59471da8b1b487472a71390
https://github.com/gocom/rah_backup/blob/1a757c0fd569f4baf59471da8b1b487472a71390/src/Rah/Backup.php#L297-L349
23,620
gocom/rah_backup
src/Rah/Backup.php
Rah_Backup.create
private function create() { try { callback_event('rah_backup.backup'); } catch (Rah_Backup_Exception $e) { $this->browser(array($e->getMessage(), E_ERROR)); return; } catch (Exception $e) { $this->browser(array(txpspecialchars($e->getMessage()), E_ERROR)); return; } $this->browser(gTxt('rah_backup_done')); }
php
private function create() { try { callback_event('rah_backup.backup'); } catch (Rah_Backup_Exception $e) { $this->browser(array($e->getMessage(), E_ERROR)); return; } catch (Exception $e) { $this->browser(array(txpspecialchars($e->getMessage()), E_ERROR)); return; } $this->browser(gTxt('rah_backup_done')); }
[ "private", "function", "create", "(", ")", "{", "try", "{", "callback_event", "(", "'rah_backup.backup'", ")", ";", "}", "catch", "(", "Rah_Backup_Exception", "$", "e", ")", "{", "$", "this", "->", "browser", "(", "array", "(", "$", "e", "->", "getMessage", "(", ")", ",", "E_ERROR", ")", ")", ";", "return", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "browser", "(", "array", "(", "txpspecialchars", "(", "$", "e", "->", "getMessage", "(", ")", ")", ",", "E_ERROR", ")", ")", ";", "return", ";", "}", "$", "this", "->", "browser", "(", "gTxt", "(", "'rah_backup_done'", ")", ")", ";", "}" ]
The panel that creates new backups.
[ "The", "panel", "that", "creates", "new", "backups", "." ]
1a757c0fd569f4baf59471da8b1b487472a71390
https://github.com/gocom/rah_backup/blob/1a757c0fd569f4baf59471da8b1b487472a71390/src/Rah/Backup.php#L494-L507
23,621
gocom/rah_backup
src/Rah/Backup.php
Rah_Backup.download
private function download() { $file = (string) gps('file'); try { $backups = $this->getBackups(); } catch (Exception $e) { } if (empty($backups) || !isset($backups[$file])) { $this->browser(array(gTxt('rah_backup_can_not_download'), E_ERROR)); return; } extract($backups[$file]); @ini_set('zlib.output_compression', 'Off'); @set_time_limit(0); @ignore_user_abort(true); ob_clean(); header('Content-Description: File Download'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$name.'"; size="'.$size.'"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: private'); header('Content-Length: '.$size); ob_flush(); flush(); if ($f = fopen($path, 'rb')) { while(!feof($f) && connection_status() == 0) { echo fread($f, 1024*64); ob_flush(); flush(); } fclose($f); } exit; }
php
private function download() { $file = (string) gps('file'); try { $backups = $this->getBackups(); } catch (Exception $e) { } if (empty($backups) || !isset($backups[$file])) { $this->browser(array(gTxt('rah_backup_can_not_download'), E_ERROR)); return; } extract($backups[$file]); @ini_set('zlib.output_compression', 'Off'); @set_time_limit(0); @ignore_user_abort(true); ob_clean(); header('Content-Description: File Download'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="'.$name.'"; size="'.$size.'"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: private'); header('Content-Length: '.$size); ob_flush(); flush(); if ($f = fopen($path, 'rb')) { while(!feof($f) && connection_status() == 0) { echo fread($f, 1024*64); ob_flush(); flush(); } fclose($f); } exit; }
[ "private", "function", "download", "(", ")", "{", "$", "file", "=", "(", "string", ")", "gps", "(", "'file'", ")", ";", "try", "{", "$", "backups", "=", "$", "this", "->", "getBackups", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "}", "if", "(", "empty", "(", "$", "backups", ")", "||", "!", "isset", "(", "$", "backups", "[", "$", "file", "]", ")", ")", "{", "$", "this", "->", "browser", "(", "array", "(", "gTxt", "(", "'rah_backup_can_not_download'", ")", ",", "E_ERROR", ")", ")", ";", "return", ";", "}", "extract", "(", "$", "backups", "[", "$", "file", "]", ")", ";", "@", "ini_set", "(", "'zlib.output_compression'", ",", "'Off'", ")", ";", "@", "set_time_limit", "(", "0", ")", ";", "@", "ignore_user_abort", "(", "true", ")", ";", "ob_clean", "(", ")", ";", "header", "(", "'Content-Description: File Download'", ")", ";", "header", "(", "'Content-Type: application/octet-stream'", ")", ";", "header", "(", "'Content-Disposition: attachment; filename=\"'", ".", "$", "name", ".", "'\"; size=\"'", ".", "$", "size", ".", "'\"'", ")", ";", "header", "(", "'Content-Transfer-Encoding: binary'", ")", ";", "header", "(", "'Expires: 0'", ")", ";", "header", "(", "'Cache-Control: private'", ")", ";", "header", "(", "'Content-Length: '", ".", "$", "size", ")", ";", "ob_flush", "(", ")", ";", "flush", "(", ")", ";", "if", "(", "$", "f", "=", "fopen", "(", "$", "path", ",", "'rb'", ")", ")", "{", "while", "(", "!", "feof", "(", "$", "f", ")", "&&", "connection_status", "(", ")", "==", "0", ")", "{", "echo", "fread", "(", "$", "f", ",", "1024", "*", "64", ")", ";", "ob_flush", "(", ")", ";", "flush", "(", ")", ";", "}", "fclose", "(", "$", "f", ")", ";", "}", "exit", ";", "}" ]
Streams backups for downloading.
[ "Streams", "backups", "for", "downloading", "." ]
1a757c0fd569f4baf59471da8b1b487472a71390
https://github.com/gocom/rah_backup/blob/1a757c0fd569f4baf59471da8b1b487472a71390/src/Rah/Backup.php#L513-L555
23,622
gocom/rah_backup
src/Rah/Backup.php
Rah_Backup.multi_edit
private function multi_edit() { extract(psa(array( 'selected', 'edit_method', ))); require_privs('rah_backup_'.((string) $edit_method)); if (!is_string($edit_method) || empty($selected) || !is_array($selected)) { $this->browser(array(gTxt('rah_backup_select_something'), E_WARNING)); return; } $method = 'multi_option_' . $edit_method; if (!method_exists($this, $method)) { $method = 'browse'; } $this->$method(); }
php
private function multi_edit() { extract(psa(array( 'selected', 'edit_method', ))); require_privs('rah_backup_'.((string) $edit_method)); if (!is_string($edit_method) || empty($selected) || !is_array($selected)) { $this->browser(array(gTxt('rah_backup_select_something'), E_WARNING)); return; } $method = 'multi_option_' . $edit_method; if (!method_exists($this, $method)) { $method = 'browse'; } $this->$method(); }
[ "private", "function", "multi_edit", "(", ")", "{", "extract", "(", "psa", "(", "array", "(", "'selected'", ",", "'edit_method'", ",", ")", ")", ")", ";", "require_privs", "(", "'rah_backup_'", ".", "(", "(", "string", ")", "$", "edit_method", ")", ")", ";", "if", "(", "!", "is_string", "(", "$", "edit_method", ")", "||", "empty", "(", "$", "selected", ")", "||", "!", "is_array", "(", "$", "selected", ")", ")", "{", "$", "this", "->", "browser", "(", "array", "(", "gTxt", "(", "'rah_backup_select_something'", ")", ",", "E_WARNING", ")", ")", ";", "return", ";", "}", "$", "method", "=", "'multi_option_'", ".", "$", "edit_method", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "method", "=", "'browse'", ";", "}", "$", "this", "->", "$", "method", "(", ")", ";", "}" ]
Multi-edit handler.
[ "Multi", "-", "edit", "handler", "." ]
1a757c0fd569f4baf59471da8b1b487472a71390
https://github.com/gocom/rah_backup/blob/1a757c0fd569f4baf59471da8b1b487472a71390/src/Rah/Backup.php#L561-L582
23,623
gocom/rah_backup
src/Rah/Backup.php
Rah_Backup.multi_option_delete
private function multi_option_delete() { $selected = ps('selected'); $deleted = array(); try { foreach ($this->getBackups() as $name => $file) { if (in_array($name, $selected, true)) { $deleted[$name] = $file['path']; @unlink($file['path']); } } } catch (Exception $e) { } callback_event('rah_backup.deleted', '', 0, array( 'files' => $deleted, )); $this->browser(gTxt('rah_backup_removed')); }
php
private function multi_option_delete() { $selected = ps('selected'); $deleted = array(); try { foreach ($this->getBackups() as $name => $file) { if (in_array($name, $selected, true)) { $deleted[$name] = $file['path']; @unlink($file['path']); } } } catch (Exception $e) { } callback_event('rah_backup.deleted', '', 0, array( 'files' => $deleted, )); $this->browser(gTxt('rah_backup_removed')); }
[ "private", "function", "multi_option_delete", "(", ")", "{", "$", "selected", "=", "ps", "(", "'selected'", ")", ";", "$", "deleted", "=", "array", "(", ")", ";", "try", "{", "foreach", "(", "$", "this", "->", "getBackups", "(", ")", "as", "$", "name", "=>", "$", "file", ")", "{", "if", "(", "in_array", "(", "$", "name", ",", "$", "selected", ",", "true", ")", ")", "{", "$", "deleted", "[", "$", "name", "]", "=", "$", "file", "[", "'path'", "]", ";", "@", "unlink", "(", "$", "file", "[", "'path'", "]", ")", ";", "}", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "}", "callback_event", "(", "'rah_backup.deleted'", ",", "''", ",", "0", ",", "array", "(", "'files'", "=>", "$", "deleted", ",", ")", ")", ";", "$", "this", "->", "browser", "(", "gTxt", "(", "'rah_backup_removed'", ")", ")", ";", "}" ]
Deletes selected backups.
[ "Deletes", "selected", "backups", "." ]
1a757c0fd569f4baf59471da8b1b487472a71390
https://github.com/gocom/rah_backup/blob/1a757c0fd569f4baf59471da8b1b487472a71390/src/Rah/Backup.php#L588-L608
23,624
gocom/rah_backup
src/Rah/Backup.php
Rah_Backup.getBackups
private function getBackups($sort = 'name', $direction = 'asc', $offset = 0, $limit = null) { $directory = txpath . '/' . get_pref('rah_backup_path'); if (!get_pref('rah_backup_path') || !file_exists($directory) || !is_dir($directory) || !is_readable($directory)) { throw new Rah_Backup_Exception( gTxt('rah_backup_dir_not_readable', array('{path}' => $directory)) ); } $order = $files = array(); $sort_crit = array( 'name' => SORT_REGULAR, 'ext' => SORT_REGULAR, 'date' => SORT_NUMERIC, 'size' => SORT_NUMERIC, 'type' => SORT_NUMERIC, ); if (!is_string($sort) || !isset($sort_crit[$sort])) { $sort = 'name'; } foreach (new DirectoryIterator($directory) as $file) { if (!$file->isFile() || !preg_match('/^[a-z0-9\-_\.]+\.(sql\.gz|tar\.gz)$/i', $file->getFilename())) { continue; } $backup = array( 'path' => $file->getPathname(), 'name' => $file->getFilename(), 'ext' => $file->getExtension(), 'date' => $file->getMTime(), 'size' => $file->getSize(), 'type' => self::BACKUP_FILESYSTEM, 'readable' => $file->isReadable(), 'writable' => $file->isWritable(), ); if (preg_match('/\.sql\.gz$/i', $backup['name'])) { $backup['type'] = self::BACKUP_DATABASE; } $files[$backup['name']] = $backup; $order[$backup['name']] = $backup[$sort]; } if (!$files) { return array(); } array_multisort($order, $sort_crit[$sort], $files); if ($direction === 'desc') { $files = array_reverse($files); } return array_slice($files, $offset, $limit); }
php
private function getBackups($sort = 'name', $direction = 'asc', $offset = 0, $limit = null) { $directory = txpath . '/' . get_pref('rah_backup_path'); if (!get_pref('rah_backup_path') || !file_exists($directory) || !is_dir($directory) || !is_readable($directory)) { throw new Rah_Backup_Exception( gTxt('rah_backup_dir_not_readable', array('{path}' => $directory)) ); } $order = $files = array(); $sort_crit = array( 'name' => SORT_REGULAR, 'ext' => SORT_REGULAR, 'date' => SORT_NUMERIC, 'size' => SORT_NUMERIC, 'type' => SORT_NUMERIC, ); if (!is_string($sort) || !isset($sort_crit[$sort])) { $sort = 'name'; } foreach (new DirectoryIterator($directory) as $file) { if (!$file->isFile() || !preg_match('/^[a-z0-9\-_\.]+\.(sql\.gz|tar\.gz)$/i', $file->getFilename())) { continue; } $backup = array( 'path' => $file->getPathname(), 'name' => $file->getFilename(), 'ext' => $file->getExtension(), 'date' => $file->getMTime(), 'size' => $file->getSize(), 'type' => self::BACKUP_FILESYSTEM, 'readable' => $file->isReadable(), 'writable' => $file->isWritable(), ); if (preg_match('/\.sql\.gz$/i', $backup['name'])) { $backup['type'] = self::BACKUP_DATABASE; } $files[$backup['name']] = $backup; $order[$backup['name']] = $backup[$sort]; } if (!$files) { return array(); } array_multisort($order, $sort_crit[$sort], $files); if ($direction === 'desc') { $files = array_reverse($files); } return array_slice($files, $offset, $limit); }
[ "private", "function", "getBackups", "(", "$", "sort", "=", "'name'", ",", "$", "direction", "=", "'asc'", ",", "$", "offset", "=", "0", ",", "$", "limit", "=", "null", ")", "{", "$", "directory", "=", "txpath", ".", "'/'", ".", "get_pref", "(", "'rah_backup_path'", ")", ";", "if", "(", "!", "get_pref", "(", "'rah_backup_path'", ")", "||", "!", "file_exists", "(", "$", "directory", ")", "||", "!", "is_dir", "(", "$", "directory", ")", "||", "!", "is_readable", "(", "$", "directory", ")", ")", "{", "throw", "new", "Rah_Backup_Exception", "(", "gTxt", "(", "'rah_backup_dir_not_readable'", ",", "array", "(", "'{path}'", "=>", "$", "directory", ")", ")", ")", ";", "}", "$", "order", "=", "$", "files", "=", "array", "(", ")", ";", "$", "sort_crit", "=", "array", "(", "'name'", "=>", "SORT_REGULAR", ",", "'ext'", "=>", "SORT_REGULAR", ",", "'date'", "=>", "SORT_NUMERIC", ",", "'size'", "=>", "SORT_NUMERIC", ",", "'type'", "=>", "SORT_NUMERIC", ",", ")", ";", "if", "(", "!", "is_string", "(", "$", "sort", ")", "||", "!", "isset", "(", "$", "sort_crit", "[", "$", "sort", "]", ")", ")", "{", "$", "sort", "=", "'name'", ";", "}", "foreach", "(", "new", "DirectoryIterator", "(", "$", "directory", ")", "as", "$", "file", ")", "{", "if", "(", "!", "$", "file", "->", "isFile", "(", ")", "||", "!", "preg_match", "(", "'/^[a-z0-9\\-_\\.]+\\.(sql\\.gz|tar\\.gz)$/i'", ",", "$", "file", "->", "getFilename", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "backup", "=", "array", "(", "'path'", "=>", "$", "file", "->", "getPathname", "(", ")", ",", "'name'", "=>", "$", "file", "->", "getFilename", "(", ")", ",", "'ext'", "=>", "$", "file", "->", "getExtension", "(", ")", ",", "'date'", "=>", "$", "file", "->", "getMTime", "(", ")", ",", "'size'", "=>", "$", "file", "->", "getSize", "(", ")", ",", "'type'", "=>", "self", "::", "BACKUP_FILESYSTEM", ",", "'readable'", "=>", "$", "file", "->", "isReadable", "(", ")", ",", "'writable'", "=>", "$", "file", "->", "isWritable", "(", ")", ",", ")", ";", "if", "(", "preg_match", "(", "'/\\.sql\\.gz$/i'", ",", "$", "backup", "[", "'name'", "]", ")", ")", "{", "$", "backup", "[", "'type'", "]", "=", "self", "::", "BACKUP_DATABASE", ";", "}", "$", "files", "[", "$", "backup", "[", "'name'", "]", "]", "=", "$", "backup", ";", "$", "order", "[", "$", "backup", "[", "'name'", "]", "]", "=", "$", "backup", "[", "$", "sort", "]", ";", "}", "if", "(", "!", "$", "files", ")", "{", "return", "array", "(", ")", ";", "}", "array_multisort", "(", "$", "order", ",", "$", "sort_crit", "[", "$", "sort", "]", ",", "$", "files", ")", ";", "if", "(", "$", "direction", "===", "'desc'", ")", "{", "$", "files", "=", "array_reverse", "(", "$", "files", ")", ";", "}", "return", "array_slice", "(", "$", "files", ",", "$", "offset", ",", "$", "limit", ")", ";", "}" ]
Gets a list of backups. @param string $sort Sorting criteria, either 'name', 'ext', 'date', 'size', 'type' @param string $direction Sorting direction, either 'asc' or 'desc' @param int $offset Offset @param int $limit Limit results @return array
[ "Gets", "a", "list", "of", "backups", "." ]
1a757c0fd569f4baf59471da8b1b487472a71390
https://github.com/gocom/rah_backup/blob/1a757c0fd569f4baf59471da8b1b487472a71390/src/Rah/Backup.php#L620-L680
23,625
arndtteunissen/column-layout
Classes/Hook/LayoutPreviewHook.php
LayoutPreviewHook.injectStylesAndScripts
public function injectStylesAndScripts(array $params, PageLayoutController $ref): string { $jsCallbackFunction = null; // The translation view is shown. Disable floating elements for that view. if ($ref->MOD_SETTINGS['function'] === '2') { $jsCallbackFunction = 'function(ColumnLayout) { ColumnLayout.settings.isTranslationView = true; }'; } $ref->getModuleTemplate()->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/ColumnLayout/ColumnLayout', $jsCallbackFunction); $ref->getModuleTemplate()->getPageRenderer()->addCssFile('EXT:column_layout/Resources/Public/Css/column_layout.css'); $ref->getModuleTemplate()->getPageRenderer()->addCssInlineBlock('column-layout', implode(LF, $this->inlineStyles), true); return ''; }
php
public function injectStylesAndScripts(array $params, PageLayoutController $ref): string { $jsCallbackFunction = null; // The translation view is shown. Disable floating elements for that view. if ($ref->MOD_SETTINGS['function'] === '2') { $jsCallbackFunction = 'function(ColumnLayout) { ColumnLayout.settings.isTranslationView = true; }'; } $ref->getModuleTemplate()->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/ColumnLayout/ColumnLayout', $jsCallbackFunction); $ref->getModuleTemplate()->getPageRenderer()->addCssFile('EXT:column_layout/Resources/Public/Css/column_layout.css'); $ref->getModuleTemplate()->getPageRenderer()->addCssInlineBlock('column-layout', implode(LF, $this->inlineStyles), true); return ''; }
[ "public", "function", "injectStylesAndScripts", "(", "array", "$", "params", ",", "PageLayoutController", "$", "ref", ")", ":", "string", "{", "$", "jsCallbackFunction", "=", "null", ";", "// The translation view is shown. Disable floating elements for that view.", "if", "(", "$", "ref", "->", "MOD_SETTINGS", "[", "'function'", "]", "===", "'2'", ")", "{", "$", "jsCallbackFunction", "=", "'function(ColumnLayout) {\n ColumnLayout.settings.isTranslationView = true;\n }'", ";", "}", "$", "ref", "->", "getModuleTemplate", "(", ")", "->", "getPageRenderer", "(", ")", "->", "loadRequireJsModule", "(", "'TYPO3/CMS/ColumnLayout/ColumnLayout'", ",", "$", "jsCallbackFunction", ")", ";", "$", "ref", "->", "getModuleTemplate", "(", ")", "->", "getPageRenderer", "(", ")", "->", "addCssFile", "(", "'EXT:column_layout/Resources/Public/Css/column_layout.css'", ")", ";", "$", "ref", "->", "getModuleTemplate", "(", ")", "->", "getPageRenderer", "(", ")", "->", "addCssInlineBlock", "(", "'column-layout'", ",", "implode", "(", "LF", ",", "$", "this", "->", "inlineStyles", ")", ",", "true", ")", ";", "return", "''", ";", "}" ]
Hook for header rendering of the PageLayoutController to inject stylesheet required for custom column layout display. @see PageLayoutController::renderContent() @param array $params @param PageLayoutController $ref @return string html to be added to the page layout
[ "Hook", "for", "header", "rendering", "of", "the", "PageLayoutController", "to", "inject", "stylesheet", "required", "for", "custom", "column", "layout", "display", "." ]
ad737068eef3b084d4d0e3a48e6a3d8277af9560
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/Hook/LayoutPreviewHook.php#L38-L54
23,626
arndtteunissen/column-layout
Classes/Hook/LayoutPreviewHook.php
LayoutPreviewHook.skipRendering
protected function skipRendering(PageLayoutView &$parentObject, array $row): bool { $tsConf = $parentObject->modTSconfig['column_layout'] ?? []; return ( $tsConf['hidePreview'] ?? false // Hidden via page TSConfig || empty($row['tx_column_layout_column_config']) // Not set || $tsConf['disabled'] ?? false // Hidden for this element ); }
php
protected function skipRendering(PageLayoutView &$parentObject, array $row): bool { $tsConf = $parentObject->modTSconfig['column_layout'] ?? []; return ( $tsConf['hidePreview'] ?? false // Hidden via page TSConfig || empty($row['tx_column_layout_column_config']) // Not set || $tsConf['disabled'] ?? false // Hidden for this element ); }
[ "protected", "function", "skipRendering", "(", "PageLayoutView", "&", "$", "parentObject", ",", "array", "$", "row", ")", ":", "bool", "{", "$", "tsConf", "=", "$", "parentObject", "->", "modTSconfig", "[", "'column_layout'", "]", "??", "[", "]", ";", "return", "(", "$", "tsConf", "[", "'hidePreview'", "]", "??", "false", "// Hidden via page TSConfig", "||", "empty", "(", "$", "row", "[", "'tx_column_layout_column_config'", "]", ")", "// Not set", "||", "$", "tsConf", "[", "'disabled'", "]", "??", "false", "// Hidden for this element", ")", ";", "}" ]
Checks if the rendering of the column markup should be skipped. @param PageLayoutView $parentObject @return bool
[ "Checks", "if", "the", "rendering", "of", "the", "column", "markup", "should", "be", "skipped", "." ]
ad737068eef3b084d4d0e3a48e6a3d8277af9560
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/Hook/LayoutPreviewHook.php#L84-L93
23,627
surebert/surebert-framework
src/sb/Controller/HTTP/Proxy.php
Proxy.get
public function get() { if (!isset($this->request->args[0])) { exit; } $url = $this->request->args[0]; //add the $_GET vars to the request $query_string = http_build_query($this->request->get); $destination_url = $url . ($query_string ? '?'.$query_string : ''); //exit if onBeforeGet doesn't pass if($this->onBeforeGet($destination_url) === false){ return false; } //logs to file if enabled if($this->log_to_file){ $logger = new \sb\Logger\CommandLine(); $log_name = preg_replace("~[^\w+]~", "_", get_called_class()); $logger->{$log_name}(json_encode(["ip" => \sb\Gateway::$remote_addr, "url" => $destination_url, "get" => $query_string, "post" => $this->request->post])); } //proxy to site and return response $ch = curl_init(); //set the url to grab the data from curl_setopt($ch, CURLOPT_URL, $destination_url); //set the function to pass the headers from the destination back to the client curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'headerCallBack')); //set the agent to be used for request curl_setopt($ch, CURLOPT_USERAGENT, $this->agent); //wait 10 seconds for timeout curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout); //forward any post requests if they exist if(count($this->request->post)){ curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->request->post); } //follow any redirects curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //return the result curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //ignore ssl errors if set to true if($this->ignore_ssl_errors){ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } //set any additional curl_opts given foreach($this->curl_opts as $key=>$val){ curl_setopt($ch, $key, $val); } //display the output return curl_exec($ch); }
php
public function get() { if (!isset($this->request->args[0])) { exit; } $url = $this->request->args[0]; //add the $_GET vars to the request $query_string = http_build_query($this->request->get); $destination_url = $url . ($query_string ? '?'.$query_string : ''); //exit if onBeforeGet doesn't pass if($this->onBeforeGet($destination_url) === false){ return false; } //logs to file if enabled if($this->log_to_file){ $logger = new \sb\Logger\CommandLine(); $log_name = preg_replace("~[^\w+]~", "_", get_called_class()); $logger->{$log_name}(json_encode(["ip" => \sb\Gateway::$remote_addr, "url" => $destination_url, "get" => $query_string, "post" => $this->request->post])); } //proxy to site and return response $ch = curl_init(); //set the url to grab the data from curl_setopt($ch, CURLOPT_URL, $destination_url); //set the function to pass the headers from the destination back to the client curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'headerCallBack')); //set the agent to be used for request curl_setopt($ch, CURLOPT_USERAGENT, $this->agent); //wait 10 seconds for timeout curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout); //forward any post requests if they exist if(count($this->request->post)){ curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->request->post); } //follow any redirects curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //return the result curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //ignore ssl errors if set to true if($this->ignore_ssl_errors){ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } //set any additional curl_opts given foreach($this->curl_opts as $key=>$val){ curl_setopt($ch, $key, $val); } //display the output return curl_exec($ch); }
[ "public", "function", "get", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "request", "->", "args", "[", "0", "]", ")", ")", "{", "exit", ";", "}", "$", "url", "=", "$", "this", "->", "request", "->", "args", "[", "0", "]", ";", "//add the $_GET vars to the request", "$", "query_string", "=", "http_build_query", "(", "$", "this", "->", "request", "->", "get", ")", ";", "$", "destination_url", "=", "$", "url", ".", "(", "$", "query_string", "?", "'?'", ".", "$", "query_string", ":", "''", ")", ";", "//exit if onBeforeGet doesn't pass", "if", "(", "$", "this", "->", "onBeforeGet", "(", "$", "destination_url", ")", "===", "false", ")", "{", "return", "false", ";", "}", "//logs to file if enabled", "if", "(", "$", "this", "->", "log_to_file", ")", "{", "$", "logger", "=", "new", "\\", "sb", "\\", "Logger", "\\", "CommandLine", "(", ")", ";", "$", "log_name", "=", "preg_replace", "(", "\"~[^\\w+]~\"", ",", "\"_\"", ",", "get_called_class", "(", ")", ")", ";", "$", "logger", "->", "{", "$", "log_name", "}", "(", "json_encode", "(", "[", "\"ip\"", "=>", "\\", "sb", "\\", "Gateway", "::", "$", "remote_addr", ",", "\"url\"", "=>", "$", "destination_url", ",", "\"get\"", "=>", "$", "query_string", ",", "\"post\"", "=>", "$", "this", "->", "request", "->", "post", "]", ")", ")", ";", "}", "//proxy to site and return response", "$", "ch", "=", "curl_init", "(", ")", ";", "//set the url to grab the data from", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "destination_url", ")", ";", "//set the function to pass the headers from the destination back to the client", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HEADERFUNCTION", ",", "array", "(", "$", "this", ",", "'headerCallBack'", ")", ")", ";", "//set the agent to be used for request", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_USERAGENT", ",", "$", "this", "->", "agent", ")", ";", "//wait 10 seconds for timeout", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_TIMEOUT", ",", "$", "this", "->", "timeout", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CONNECTTIMEOUT", ",", "$", "this", "->", "timeout", ")", ";", "//forward any post requests if they exist", "if", "(", "count", "(", "$", "this", "->", "request", "->", "post", ")", ")", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "this", "->", "request", "->", "post", ")", ";", "}", "//follow any redirects", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_FOLLOWLOCATION", ",", "1", ")", ";", "//return the result", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "//ignore ssl errors if set to true", "if", "(", "$", "this", "->", "ignore_ssl_errors", ")", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYHOST", ",", "false", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "}", "//set any additional curl_opts given", "foreach", "(", "$", "this", "->", "curl_opts", "as", "$", "key", "=>", "$", "val", ")", "{", "curl_setopt", "(", "$", "ch", ",", "$", "key", ",", "$", "val", ")", ";", "}", "//display the output", "return", "curl_exec", "(", "$", "ch", ")", ";", "}" ]
proxies request and responds It will proxy both GET and POST data and return respose @servable true e.g. SITE_URL/proxy/get/http://someothersite?test=rest&ff=gg
[ "proxies", "request", "and", "responds" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/HTTP/Proxy.php#L77-L142
23,628
surebert/surebert-framework
src/sb/Controller/HTTP/Proxy.php
Proxy.headerCallBack
protected function headerCallBack($ch, $data){ if (!is_null($data)) { if (preg_match("~^HTTP/.*? 404~", $data)) { header(trim($data)); while (ob_get_level() > 0) { ob_end_flush(); } } if (preg_match("~^Content-disposition~", $data)) { header(str_replace("filename=", 'filename="', trim($data)) . '"'); while (ob_get_level() > 0) { ob_end_flush(); } } if (preg_match("~^Content-Type~i", $data)) { header(trim($data)); while (ob_get_level() > 0) { ob_end_flush(); } } } return strlen($data); //This means that we handled it, so cURL will keep processing }
php
protected function headerCallBack($ch, $data){ if (!is_null($data)) { if (preg_match("~^HTTP/.*? 404~", $data)) { header(trim($data)); while (ob_get_level() > 0) { ob_end_flush(); } } if (preg_match("~^Content-disposition~", $data)) { header(str_replace("filename=", 'filename="', trim($data)) . '"'); while (ob_get_level() > 0) { ob_end_flush(); } } if (preg_match("~^Content-Type~i", $data)) { header(trim($data)); while (ob_get_level() > 0) { ob_end_flush(); } } } return strlen($data); //This means that we handled it, so cURL will keep processing }
[ "protected", "function", "headerCallBack", "(", "$", "ch", ",", "$", "data", ")", "{", "if", "(", "!", "is_null", "(", "$", "data", ")", ")", "{", "if", "(", "preg_match", "(", "\"~^HTTP/.*? 404~\"", ",", "$", "data", ")", ")", "{", "header", "(", "trim", "(", "$", "data", ")", ")", ";", "while", "(", "ob_get_level", "(", ")", ">", "0", ")", "{", "ob_end_flush", "(", ")", ";", "}", "}", "if", "(", "preg_match", "(", "\"~^Content-disposition~\"", ",", "$", "data", ")", ")", "{", "header", "(", "str_replace", "(", "\"filename=\"", ",", "'filename=\"'", ",", "trim", "(", "$", "data", ")", ")", ".", "'\"'", ")", ";", "while", "(", "ob_get_level", "(", ")", ">", "0", ")", "{", "ob_end_flush", "(", ")", ";", "}", "}", "if", "(", "preg_match", "(", "\"~^Content-Type~i\"", ",", "$", "data", ")", ")", "{", "header", "(", "trim", "(", "$", "data", ")", ")", ";", "while", "(", "ob_get_level", "(", ")", ">", "0", ")", "{", "ob_end_flush", "(", ")", ";", "}", "}", "}", "return", "strlen", "(", "$", "data", ")", ";", "//This means that we handled it, so cURL will keep processing", "}" ]
Called to process headers from URL being proxied @param resource $ch The curl connection @param string $data The header data @return int length of the data from header
[ "Called", "to", "process", "headers", "from", "URL", "being", "proxied" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/HTTP/Proxy.php#L150-L176
23,629
eghojansu/moe
src/tools/web/OpenID.php
OpenID.auth
function auth($proxy=NULL,$attr=array(),array $reqd=NULL) { $fw=Base::instance(); $root=$fw->get('SCHEME').'://'.$fw->get('HOST'); if (empty($this->args['trust_root'])) $this->args['trust_root']=$root.$fw->get('BASE').'/'; if (empty($this->args['return_to'])) $this->args['return_to']=$root.$_SERVER['REQUEST_URI']; $this->args['mode']='checkid_setup'; if ($this->url=$this->discover($proxy)) { if ($attr) { $this->args['ns.ax']='http://openid.net/srv/ax/1.0'; $this->args['ax.mode']='fetch_request'; foreach ($attr as $key=>$val) $this->args['ax.type.'.$key]=$val; $this->args['ax.required']=is_string($reqd)? $reqd:implode(',',$reqd); } $var=array(); foreach ($this->args as $key=>$val) $var['openid.'.$key]=$val; $fw->reroute($this->url.'?'.http_build_query($var)); } return FALSE; }
php
function auth($proxy=NULL,$attr=array(),array $reqd=NULL) { $fw=Base::instance(); $root=$fw->get('SCHEME').'://'.$fw->get('HOST'); if (empty($this->args['trust_root'])) $this->args['trust_root']=$root.$fw->get('BASE').'/'; if (empty($this->args['return_to'])) $this->args['return_to']=$root.$_SERVER['REQUEST_URI']; $this->args['mode']='checkid_setup'; if ($this->url=$this->discover($proxy)) { if ($attr) { $this->args['ns.ax']='http://openid.net/srv/ax/1.0'; $this->args['ax.mode']='fetch_request'; foreach ($attr as $key=>$val) $this->args['ax.type.'.$key]=$val; $this->args['ax.required']=is_string($reqd)? $reqd:implode(',',$reqd); } $var=array(); foreach ($this->args as $key=>$val) $var['openid.'.$key]=$val; $fw->reroute($this->url.'?'.http_build_query($var)); } return FALSE; }
[ "function", "auth", "(", "$", "proxy", "=", "NULL", ",", "$", "attr", "=", "array", "(", ")", ",", "array", "$", "reqd", "=", "NULL", ")", "{", "$", "fw", "=", "Base", "::", "instance", "(", ")", ";", "$", "root", "=", "$", "fw", "->", "get", "(", "'SCHEME'", ")", ".", "'://'", ".", "$", "fw", "->", "get", "(", "'HOST'", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "args", "[", "'trust_root'", "]", ")", ")", "$", "this", "->", "args", "[", "'trust_root'", "]", "=", "$", "root", ".", "$", "fw", "->", "get", "(", "'BASE'", ")", ".", "'/'", ";", "if", "(", "empty", "(", "$", "this", "->", "args", "[", "'return_to'", "]", ")", ")", "$", "this", "->", "args", "[", "'return_to'", "]", "=", "$", "root", ".", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ";", "$", "this", "->", "args", "[", "'mode'", "]", "=", "'checkid_setup'", ";", "if", "(", "$", "this", "->", "url", "=", "$", "this", "->", "discover", "(", "$", "proxy", ")", ")", "{", "if", "(", "$", "attr", ")", "{", "$", "this", "->", "args", "[", "'ns.ax'", "]", "=", "'http://openid.net/srv/ax/1.0'", ";", "$", "this", "->", "args", "[", "'ax.mode'", "]", "=", "'fetch_request'", ";", "foreach", "(", "$", "attr", "as", "$", "key", "=>", "$", "val", ")", "$", "this", "->", "args", "[", "'ax.type.'", ".", "$", "key", "]", "=", "$", "val", ";", "$", "this", "->", "args", "[", "'ax.required'", "]", "=", "is_string", "(", "$", "reqd", ")", "?", "$", "reqd", ":", "implode", "(", "','", ",", "$", "reqd", ")", ";", "}", "$", "var", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "args", "as", "$", "key", "=>", "$", "val", ")", "$", "var", "[", "'openid.'", ".", "$", "key", "]", "=", "$", "val", ";", "$", "fw", "->", "reroute", "(", "$", "this", "->", "url", ".", "'?'", ".", "http_build_query", "(", "$", "var", ")", ")", ";", "}", "return", "FALSE", ";", "}" ]
Initiate OpenID authentication sequence; Return FALSE on failure or redirect to OpenID provider URL @return bool @param $proxy string @param $attr array @param $reqd string|array
[ "Initiate", "OpenID", "authentication", "sequence", ";", "Return", "FALSE", "on", "failure", "or", "redirect", "to", "OpenID", "provider", "URL" ]
f58ec75a3116d1a572782256e2b38bb9aab95e3c
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/web/OpenID.php#L127-L150
23,630
Isset/pushnotification
src/PushNotification/Type/Apple/AppleConnection.php
AppleConnection.send
public function send(Message $message) { /* @var AppleMessage $message */ $buildMessage = $this->buildMessage($message); $this->streamSocket->connect(); $bytesSend = $this->streamSocket->write($buildMessage); if (strlen($buildMessage) !== $bytesSend) { $this->streamSocket->disconnect(); throw new ConnectionExceptionImpl(); } usleep(self::SEND_INTERVAL); }
php
public function send(Message $message) { /* @var AppleMessage $message */ $buildMessage = $this->buildMessage($message); $this->streamSocket->connect(); $bytesSend = $this->streamSocket->write($buildMessage); if (strlen($buildMessage) !== $bytesSend) { $this->streamSocket->disconnect(); throw new ConnectionExceptionImpl(); } usleep(self::SEND_INTERVAL); }
[ "public", "function", "send", "(", "Message", "$", "message", ")", "{", "/* @var AppleMessage $message */", "$", "buildMessage", "=", "$", "this", "->", "buildMessage", "(", "$", "message", ")", ";", "$", "this", "->", "streamSocket", "->", "connect", "(", ")", ";", "$", "bytesSend", "=", "$", "this", "->", "streamSocket", "->", "write", "(", "$", "buildMessage", ")", ";", "if", "(", "strlen", "(", "$", "buildMessage", ")", "!==", "$", "bytesSend", ")", "{", "$", "this", "->", "streamSocket", "->", "disconnect", "(", ")", ";", "throw", "new", "ConnectionExceptionImpl", "(", ")", ";", "}", "usleep", "(", "self", "::", "SEND_INTERVAL", ")", ";", "}" ]
Send a message without waiting on response. @param Message $message @throws ConnectionException @throws ConnectionHandlerException
[ "Send", "a", "message", "without", "waiting", "on", "response", "." ]
5e7634dc6b1cf4f7c371d1890243a25252db0d85
https://github.com/Isset/pushnotification/blob/5e7634dc6b1cf4f7c371d1890243a25252db0d85/src/PushNotification/Type/Apple/AppleConnection.php#L112-L123
23,631
nabab/bbn
src/bbn/appui/dbsync.php
dbsync.check
public static function check(){ return ( \is_object(self::$db) && \is_object(self::$dbs) && self::$db->check() && self::$dbs->check() ); }
php
public static function check(){ return ( \is_object(self::$db) && \is_object(self::$dbs) && self::$db->check() && self::$dbs->check() ); }
[ "public", "static", "function", "check", "(", ")", "{", "return", "(", "\\", "is_object", "(", "self", "::", "$", "db", ")", "&&", "\\", "is_object", "(", "self", "::", "$", "dbs", ")", "&&", "self", "::", "$", "db", "->", "check", "(", ")", "&&", "self", "::", "$", "dbs", "->", "check", "(", ")", ")", ";", "}" ]
Checks if the initialization has been all right @return bool
[ "Checks", "if", "the", "initialization", "has", "been", "all", "right" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/dbsync.php#L154-L156
23,632
cultuurnet/deserializer
src/JSONDeserializer.php
JSONDeserializer.deserialize
public function deserialize(StringLiteral $data) { $data = json_decode($data->toNative(), $this->assoc); if (null === $data) { throw new NotWellFormedException('Invalid JSON'); } return $data; }
php
public function deserialize(StringLiteral $data) { $data = json_decode($data->toNative(), $this->assoc); if (null === $data) { throw new NotWellFormedException('Invalid JSON'); } return $data; }
[ "public", "function", "deserialize", "(", "StringLiteral", "$", "data", ")", "{", "$", "data", "=", "json_decode", "(", "$", "data", "->", "toNative", "(", ")", ",", "$", "this", "->", "assoc", ")", ";", "if", "(", "null", "===", "$", "data", ")", "{", "throw", "new", "NotWellFormedException", "(", "'Invalid JSON'", ")", ";", "}", "return", "$", "data", ";", "}" ]
Decodes a JSON string into a generic PHP object. @param StringLiteral $data @return \stdClass
[ "Decodes", "a", "JSON", "string", "into", "a", "generic", "PHP", "object", "." ]
ec7830eb860ea83f7c28c38649b0057177ade784
https://github.com/cultuurnet/deserializer/blob/ec7830eb860ea83f7c28c38649b0057177ade784/src/JSONDeserializer.php#L30-L39
23,633
GrupaZero/social
src/Gzero/Social/SocialLoginService.php
SocialLoginService.login
public function login($serviceName, AbstractUser $response) { $userId = $this->repo->getUserIdBySocialId($response->id, $serviceName); if (auth()->check()) { // user already logged and service has not been connected $user = auth()->user(); if ($userId) { // This service has already been connected session()->put('url.intended', route('connectedServices')); throw new SocialException( trans( 'gzero-social::common.service_already_connected_message', ['service_name' => title_case($serviceName)] ) ); } else { // create connection for new service $this->repo->addUserSocialAccount($user, $serviceName, $response); } } else { if ($userId) { // login user with this service $this->auth->loginUsingId($userId); } else { // create new user $user = $this->repo->createNewUser($serviceName, $response); $this->auth->login($user); session()->put('showWelcomePage', true); session()->put('url.intended', route('account.welcome', ['method' => title_case($serviceName)])); } } }
php
public function login($serviceName, AbstractUser $response) { $userId = $this->repo->getUserIdBySocialId($response->id, $serviceName); if (auth()->check()) { // user already logged and service has not been connected $user = auth()->user(); if ($userId) { // This service has already been connected session()->put('url.intended', route('connectedServices')); throw new SocialException( trans( 'gzero-social::common.service_already_connected_message', ['service_name' => title_case($serviceName)] ) ); } else { // create connection for new service $this->repo->addUserSocialAccount($user, $serviceName, $response); } } else { if ($userId) { // login user with this service $this->auth->loginUsingId($userId); } else { // create new user $user = $this->repo->createNewUser($serviceName, $response); $this->auth->login($user); session()->put('showWelcomePage', true); session()->put('url.intended', route('account.welcome', ['method' => title_case($serviceName)])); } } }
[ "public", "function", "login", "(", "$", "serviceName", ",", "AbstractUser", "$", "response", ")", "{", "$", "userId", "=", "$", "this", "->", "repo", "->", "getUserIdBySocialId", "(", "$", "response", "->", "id", ",", "$", "serviceName", ")", ";", "if", "(", "auth", "(", ")", "->", "check", "(", ")", ")", "{", "// user already logged and service has not been connected", "$", "user", "=", "auth", "(", ")", "->", "user", "(", ")", ";", "if", "(", "$", "userId", ")", "{", "// This service has already been connected", "session", "(", ")", "->", "put", "(", "'url.intended'", ",", "route", "(", "'connectedServices'", ")", ")", ";", "throw", "new", "SocialException", "(", "trans", "(", "'gzero-social::common.service_already_connected_message'", ",", "[", "'service_name'", "=>", "title_case", "(", "$", "serviceName", ")", "]", ")", ")", ";", "}", "else", "{", "// create connection for new service", "$", "this", "->", "repo", "->", "addUserSocialAccount", "(", "$", "user", ",", "$", "serviceName", ",", "$", "response", ")", ";", "}", "}", "else", "{", "if", "(", "$", "userId", ")", "{", "// login user with this service", "$", "this", "->", "auth", "->", "loginUsingId", "(", "$", "userId", ")", ";", "}", "else", "{", "// create new user", "$", "user", "=", "$", "this", "->", "repo", "->", "createNewUser", "(", "$", "serviceName", ",", "$", "response", ")", ";", "$", "this", "->", "auth", "->", "login", "(", "$", "user", ")", ";", "session", "(", ")", "->", "put", "(", "'showWelcomePage'", ",", "true", ")", ";", "session", "(", ")", "->", "put", "(", "'url.intended'", ",", "route", "(", "'account.welcome'", ",", "[", "'method'", "=>", "title_case", "(", "$", "serviceName", ")", "]", ")", ")", ";", "}", "}", "}" ]
Login using social service. @param $serviceName string social service name @param $response AbstractUser response data @throws SocialException
[ "Login", "using", "social", "service", "." ]
f7cbf50765bd228010a2c61d950f915828306cf7
https://github.com/GrupaZero/social/blob/f7cbf50765bd228010a2c61d950f915828306cf7/src/Gzero/Social/SocialLoginService.php#L50-L76
23,634
rattfieldnz/url-validation
src/RattfieldNz/UrlValidation/UrlValidation.php
UrlValidation.getUrlStatusCode
public static function getUrlStatusCode($url) { //Instantiate the EpiCurl class to be used //with checking URL HTTP status code. $epi_curl_checker = EpiCurl::getInstance(); // Add the given URL to the url checker. $url_check = $epi_curl_checker->addURL($url); //Return the HTTP status code. return $url_check->code; }
php
public static function getUrlStatusCode($url) { //Instantiate the EpiCurl class to be used //with checking URL HTTP status code. $epi_curl_checker = EpiCurl::getInstance(); // Add the given URL to the url checker. $url_check = $epi_curl_checker->addURL($url); //Return the HTTP status code. return $url_check->code; }
[ "public", "static", "function", "getUrlStatusCode", "(", "$", "url", ")", "{", "//Instantiate the EpiCurl class to be used\r", "//with checking URL HTTP status code.\r", "$", "epi_curl_checker", "=", "EpiCurl", "::", "getInstance", "(", ")", ";", "// Add the given URL to the url checker.\r", "$", "url_check", "=", "$", "epi_curl_checker", "->", "addURL", "(", "$", "url", ")", ";", "//Return the HTTP status code.\r", "return", "$", "url_check", "->", "code", ";", "}" ]
This function obtains an HTTP status code from a given URL. @param $url @uses EpiCurl::getInstance @return int
[ "This", "function", "obtains", "an", "HTTP", "status", "code", "from", "a", "given", "URL", "." ]
ff44a463a9119fa3bea9bd7fef3d44b7e6f9a44c
https://github.com/rattfieldnz/url-validation/blob/ff44a463a9119fa3bea9bd7fef3d44b7e6f9a44c/src/RattfieldNz/UrlValidation/UrlValidation.php#L53-L64
23,635
webcreate/util
src/Webcreate/Util/Cli.php
Cli.prepare
public function prepare($command, array $arguments = array()) { $commandline = $command; foreach ($arguments as $option => $value) { if (is_bool($value)) { if ($value === true) { $commandline .= ' ' . $option; } } else { $seperator = ' '; if (!is_integer($option)) { $commandline .= ' ' . $option; if (substr($option, -1, 1) == '=') { $seperator = ''; } } $commandline .= $seperator . ProcessUtils::escapeArgument($value); } } return $commandline; }
php
public function prepare($command, array $arguments = array()) { $commandline = $command; foreach ($arguments as $option => $value) { if (is_bool($value)) { if ($value === true) { $commandline .= ' ' . $option; } } else { $seperator = ' '; if (!is_integer($option)) { $commandline .= ' ' . $option; if (substr($option, -1, 1) == '=') { $seperator = ''; } } $commandline .= $seperator . ProcessUtils::escapeArgument($value); } } return $commandline; }
[ "public", "function", "prepare", "(", "$", "command", ",", "array", "$", "arguments", "=", "array", "(", ")", ")", "{", "$", "commandline", "=", "$", "command", ";", "foreach", "(", "$", "arguments", "as", "$", "option", "=>", "$", "value", ")", "{", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "if", "(", "$", "value", "===", "true", ")", "{", "$", "commandline", ".=", "' '", ".", "$", "option", ";", "}", "}", "else", "{", "$", "seperator", "=", "' '", ";", "if", "(", "!", "is_integer", "(", "$", "option", ")", ")", "{", "$", "commandline", ".=", "' '", ".", "$", "option", ";", "if", "(", "substr", "(", "$", "option", ",", "-", "1", ",", "1", ")", "==", "'='", ")", "{", "$", "seperator", "=", "''", ";", "}", "}", "$", "commandline", ".=", "$", "seperator", ".", "ProcessUtils", "::", "escapeArgument", "(", "$", "value", ")", ";", "}", "}", "return", "$", "commandline", ";", "}" ]
Prepares a commandline @param string $command @param array $arguments @return string
[ "Prepares", "a", "commandline" ]
16c53697a3d96431d0afd57f8ab9f1df6c21e976
https://github.com/webcreate/util/blob/16c53697a3d96431d0afd57f8ab9f1df6c21e976/src/Webcreate/Util/Cli.php#L53-L75
23,636
fccn/oai-pmh-core
src/schemas/ands_oai.php
ANDS_OAI.addChild
protected function addChild($mom_node, $name, $value='') { return $this->oai_pmh->addChild($mom_node, $name, $value); }
php
protected function addChild($mom_node, $name, $value='') { return $this->oai_pmh->addChild($mom_node, $name, $value); }
[ "protected", "function", "addChild", "(", "$", "mom_node", ",", "$", "name", ",", "$", "value", "=", "''", ")", "{", "return", "$", "this", "->", "oai_pmh", "->", "addChild", "(", "$", "mom_node", ",", "$", "name", ",", "$", "value", ")", ";", "}" ]
A worker function for easily adding a newly created node to current XML Doc. @param $mom_node Type: DOMElement. Node the new child will be attached to. @param $name Type: sting. The name of the child node is being added. @param $value Type: sting. The text content of the child node is being added. The default is ''. @return DOMElement. The added child node
[ "A", "worker", "function", "for", "easily", "adding", "a", "newly", "created", "node", "to", "current", "XML", "Doc", "." ]
a9c6852482c7bd7c48911a2165120325ecc27ea2
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_oai.php#L83-L86
23,637
fccn/oai-pmh-core
src/schemas/ands_oai.php
ANDS_OAI.create_regObject
protected function create_regObject($group, $key, $originatingSource) { $regObj_node = $this->addChild($this->working_node, 'registryObject'); $regObj_node->setAttribute('group', $group); $this->addChild($regObj_node, 'key', $key); $this->addChild($regObj_node, 'originatingSource', $originatingSource); $this->working_node = $regObj_node; }
php
protected function create_regObject($group, $key, $originatingSource) { $regObj_node = $this->addChild($this->working_node, 'registryObject'); $regObj_node->setAttribute('group', $group); $this->addChild($regObj_node, 'key', $key); $this->addChild($regObj_node, 'originatingSource', $originatingSource); $this->working_node = $regObj_node; }
[ "protected", "function", "create_regObject", "(", "$", "group", ",", "$", "key", ",", "$", "originatingSource", ")", "{", "$", "regObj_node", "=", "$", "this", "->", "addChild", "(", "$", "this", "->", "working_node", ",", "'registryObject'", ")", ";", "$", "regObj_node", "->", "setAttribute", "(", "'group'", ",", "$", "group", ")", ";", "$", "this", "->", "addChild", "(", "$", "regObj_node", ",", "'key'", ",", "$", "key", ")", ";", "$", "this", "->", "addChild", "(", "$", "regObj_node", ",", "'originatingSource'", ",", "$", "originatingSource", ")", ";", "$", "this", "->", "working_node", "=", "$", "regObj_node", ";", "}" ]
Create a single registryObject node. Each set has its own structure but they all have an attribute of group, a key node and an originatingSource node. The newly created node will be used as the working node. \param $group string, group attribute of the new registryObject node . \param $key string, key node, used as an identifier. \param $originatingSource string, an url of the data provider.
[ "Create", "a", "single", "registryObject", "node", ".", "Each", "set", "has", "its", "own", "structure", "but", "they", "all", "have", "an", "attribute", "of", "group", "a", "key", "node", "and", "an", "originatingSource", "node", ".", "The", "newly", "created", "node", "will", "be", "used", "as", "the", "working", "node", "." ]
a9c6852482c7bd7c48911a2165120325ecc27ea2
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_oai.php#L106-L113
23,638
fccn/oai-pmh-core
src/schemas/ands_oai.php
ANDS_OAI.create_dcs_node
protected function create_dcs_node($set_name, $set_type) { $this->working_node = $this->addChild($this->working_node, $set_name); $this->working_node->setAttribute('type', $set_type); }
php
protected function create_dcs_node($set_name, $set_type) { $this->working_node = $this->addChild($this->working_node, $set_name); $this->working_node->setAttribute('type', $set_type); }
[ "protected", "function", "create_dcs_node", "(", "$", "set_name", ",", "$", "set_type", ")", "{", "$", "this", "->", "working_node", "=", "$", "this", "->", "addChild", "(", "$", "this", "->", "working_node", ",", "$", "set_name", ")", ";", "$", "this", "->", "working_node", "->", "setAttribute", "(", "'type'", ",", "$", "set_type", ")", ";", "}" ]
RIF-CS node is the content node of RIF-CS metadata node which starts from regObjects. Each set supportted in RIF-CS has its own content model. The created node will be used as the root node of this record for following nodes will be created. \param $set_name string, the name of set. For ANDS, they are Activity, Party and Collection \param $set_type string, the type of set. For example, Activity can have project as a type.
[ "RIF", "-", "CS", "node", "is", "the", "content", "node", "of", "RIF", "-", "CS", "metadata", "node", "which", "starts", "from", "regObjects", ".", "Each", "set", "supportted", "in", "RIF", "-", "CS", "has", "its", "own", "content", "model", ".", "The", "created", "node", "will", "be", "used", "as", "the", "root", "node", "of", "this", "record", "for", "following", "nodes", "will", "be", "created", "." ]
a9c6852482c7bd7c48911a2165120325ecc27ea2
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_oai.php#L122-L126
23,639
infinity-next/sleuth
src/Detectives/ImageGDDetective.php
ImageGDDetective.leadGIF
protected function leadGIF() { $exif = exif_imagetype($this->file) === IMAGETYPE_GIF; if ($exif) { return $this->closeCase("gif", "image/gif"); } return null; }
php
protected function leadGIF() { $exif = exif_imagetype($this->file) === IMAGETYPE_GIF; if ($exif) { return $this->closeCase("gif", "image/gif"); } return null; }
[ "protected", "function", "leadGIF", "(", ")", "{", "$", "exif", "=", "exif_imagetype", "(", "$", "this", "->", "file", ")", "===", "IMAGETYPE_GIF", ";", "if", "(", "$", "exif", ")", "{", "return", "$", "this", "->", "closeCase", "(", "\"gif\"", ",", "\"image/gif\"", ")", ";", "}", "return", "null", ";", "}" ]
Checks if thise file is a GIF. @return boolean|null
[ "Checks", "if", "thise", "file", "is", "a", "GIF", "." ]
924b82e4d60f042fddd6b093b324cfa4bb885a13
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ImageGDDetective.php#L15-L25
23,640
infinity-next/sleuth
src/Detectives/ImageGDDetective.php
ImageGDDetective.leadJPG
protected function leadJPG() { $exif = exif_imagetype($this->file) === IMAGETYPE_JPEG; if ($exif) { return $this->closeCase("jpg", "image/jpg"); } return null; }
php
protected function leadJPG() { $exif = exif_imagetype($this->file) === IMAGETYPE_JPEG; if ($exif) { return $this->closeCase("jpg", "image/jpg"); } return null; }
[ "protected", "function", "leadJPG", "(", ")", "{", "$", "exif", "=", "exif_imagetype", "(", "$", "this", "->", "file", ")", "===", "IMAGETYPE_JPEG", ";", "if", "(", "$", "exif", ")", "{", "return", "$", "this", "->", "closeCase", "(", "\"jpg\"", ",", "\"image/jpg\"", ")", ";", "}", "return", "null", ";", "}" ]
Checks if thise file is a JPG. @return boolean|null
[ "Checks", "if", "thise", "file", "is", "a", "JPG", "." ]
924b82e4d60f042fddd6b093b324cfa4bb885a13
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ImageGDDetective.php#L32-L42
23,641
infinity-next/sleuth
src/Detectives/ImageGDDetective.php
ImageGDDetective.leadPNG
protected function leadPNG() { $exif = exif_imagetype($this->file) === IMAGETYPE_PNG; if ($exif) { return $this->closeCase("png", "image/png"); } return null; }
php
protected function leadPNG() { $exif = exif_imagetype($this->file) === IMAGETYPE_PNG; if ($exif) { return $this->closeCase("png", "image/png"); } return null; }
[ "protected", "function", "leadPNG", "(", ")", "{", "$", "exif", "=", "exif_imagetype", "(", "$", "this", "->", "file", ")", "===", "IMAGETYPE_PNG", ";", "if", "(", "$", "exif", ")", "{", "return", "$", "this", "->", "closeCase", "(", "\"png\"", ",", "\"image/png\"", ")", ";", "}", "return", "null", ";", "}" ]
Checks if thise file is a PNG. @return boolean|null
[ "Checks", "if", "thise", "file", "is", "a", "PNG", "." ]
924b82e4d60f042fddd6b093b324cfa4bb885a13
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ImageGDDetective.php#L49-L59
23,642
infinity-next/sleuth
src/Detectives/ImageGDDetective.php
ImageGDDetective.leadSWF
protected function leadSWF() { $exif = exif_imagetype($this->file); $flash = ($exif === IMAGETYPE_SWF || $exif === IMAGETYPE_SWC); if ($exif) { return $this->closeCase("swf", "application/x-shockwave-flash"); } return null; }
php
protected function leadSWF() { $exif = exif_imagetype($this->file); $flash = ($exif === IMAGETYPE_SWF || $exif === IMAGETYPE_SWC); if ($exif) { return $this->closeCase("swf", "application/x-shockwave-flash"); } return null; }
[ "protected", "function", "leadSWF", "(", ")", "{", "$", "exif", "=", "exif_imagetype", "(", "$", "this", "->", "file", ")", ";", "$", "flash", "=", "(", "$", "exif", "===", "IMAGETYPE_SWF", "||", "$", "exif", "===", "IMAGETYPE_SWC", ")", ";", "if", "(", "$", "exif", ")", "{", "return", "$", "this", "->", "closeCase", "(", "\"swf\"", ",", "\"application/x-shockwave-flash\"", ")", ";", "}", "return", "null", ";", "}" ]
Checks if the file is a SWF. @return boolean|null
[ "Checks", "if", "the", "file", "is", "a", "SWF", "." ]
924b82e4d60f042fddd6b093b324cfa4bb885a13
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/ImageGDDetective.php#L66-L77
23,643
accompli/chrono
src/Repository.php
Repository.getAdapter
public function getAdapter() { if ($this->repositoryAdapter instanceof AdapterInterface) { return $this->repositoryAdapter; } foreach ($this->adapters as $adapterClass) { if (class_exists($adapterClass) === false || in_array('Accompli\Chrono\Adapter\AdapterInterface', class_implements($adapterClass)) === false) { continue; } $adapter = new $adapterClass($this->repositoryUrl, $this->repositoryDirectory, $this->processExecutor); if ($adapter->supportsRepository()) { return $adapter; } } }
php
public function getAdapter() { if ($this->repositoryAdapter instanceof AdapterInterface) { return $this->repositoryAdapter; } foreach ($this->adapters as $adapterClass) { if (class_exists($adapterClass) === false || in_array('Accompli\Chrono\Adapter\AdapterInterface', class_implements($adapterClass)) === false) { continue; } $adapter = new $adapterClass($this->repositoryUrl, $this->repositoryDirectory, $this->processExecutor); if ($adapter->supportsRepository()) { return $adapter; } } }
[ "public", "function", "getAdapter", "(", ")", "{", "if", "(", "$", "this", "->", "repositoryAdapter", "instanceof", "AdapterInterface", ")", "{", "return", "$", "this", "->", "repositoryAdapter", ";", "}", "foreach", "(", "$", "this", "->", "adapters", "as", "$", "adapterClass", ")", "{", "if", "(", "class_exists", "(", "$", "adapterClass", ")", "===", "false", "||", "in_array", "(", "'Accompli\\Chrono\\Adapter\\AdapterInterface'", ",", "class_implements", "(", "$", "adapterClass", ")", ")", "===", "false", ")", "{", "continue", ";", "}", "$", "adapter", "=", "new", "$", "adapterClass", "(", "$", "this", "->", "repositoryUrl", ",", "$", "this", "->", "repositoryDirectory", ",", "$", "this", "->", "processExecutor", ")", ";", "if", "(", "$", "adapter", "->", "supportsRepository", "(", ")", ")", "{", "return", "$", "adapter", ";", "}", "}", "}" ]
Returns the supported adapter for the repository. @return AdapterInterface|null
[ "Returns", "the", "supported", "adapter", "for", "the", "repository", "." ]
5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc
https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Repository.php#L95-L111
23,644
ajgarlag/AjglSessionConcurrency
src/Http/EventListener/RefreshSessionRegistryLastUsedListener.php
RefreshSessionRegistryLastUsedListener.onKernelTerminate
public function onKernelTerminate(PostResponseEvent $event) { if (!$event->getRequest()->hasSession()) { return; } $session = $event->getRequest()->getSession(); $this->registry->refreshLastUsed($session->getId(), $session->getMetadataBag()->getLastUsed()); }
php
public function onKernelTerminate(PostResponseEvent $event) { if (!$event->getRequest()->hasSession()) { return; } $session = $event->getRequest()->getSession(); $this->registry->refreshLastUsed($session->getId(), $session->getMetadataBag()->getLastUsed()); }
[ "public", "function", "onKernelTerminate", "(", "PostResponseEvent", "$", "event", ")", "{", "if", "(", "!", "$", "event", "->", "getRequest", "(", ")", "->", "hasSession", "(", ")", ")", "{", "return", ";", "}", "$", "session", "=", "$", "event", "->", "getRequest", "(", ")", "->", "getSession", "(", ")", ";", "$", "this", "->", "registry", "->", "refreshLastUsed", "(", "$", "session", "->", "getId", "(", ")", ",", "$", "session", "->", "getMetadataBag", "(", ")", "->", "getLastUsed", "(", ")", ")", ";", "}" ]
Refresh the last used timestamp for the given session if registered. @param PostResponseEvent $event
[ "Refresh", "the", "last", "used", "timestamp", "for", "the", "given", "session", "if", "registered", "." ]
daa3b1ff3ad4951947f7192e12b2496555e135fb
https://github.com/ajgarlag/AjglSessionConcurrency/blob/daa3b1ff3ad4951947f7192e12b2496555e135fb/src/Http/EventListener/RefreshSessionRegistryLastUsedListener.php#L41-L50
23,645
surebert/surebert-framework
src/sb/SSH2/Shell.php
Shell.exec
public function exec($command, $timeout=30, $with_login_env=true) { stream_set_timeout($this->shell, $timeout); if($with_login_env){ $command = 'bash -l '.$command; } return fwrite($this->shell, $command.PHP_EOL); }
php
public function exec($command, $timeout=30, $with_login_env=true) { stream_set_timeout($this->shell, $timeout); if($with_login_env){ $command = 'bash -l '.$command; } return fwrite($this->shell, $command.PHP_EOL); }
[ "public", "function", "exec", "(", "$", "command", ",", "$", "timeout", "=", "30", ",", "$", "with_login_env", "=", "true", ")", "{", "stream_set_timeout", "(", "$", "this", "->", "shell", ",", "$", "timeout", ")", ";", "if", "(", "$", "with_login_env", ")", "{", "$", "command", "=", "'bash -l '", ".", "$", "command", ";", "}", "return", "fwrite", "(", "$", "this", "->", "shell", ",", "$", "command", ".", "PHP_EOL", ")", ";", "}" ]
Execute a command on the interactive shell @param string $command The command to exec @param boolean $with_login_env o run a shell script with all the variables that you would have when logged in interactively @return boolean
[ "Execute", "a", "command", "on", "the", "interactive", "shell" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/SSH2/Shell.php#L56-L64
23,646
oroinc/OroLayoutComponent
ExpressionLanguage/Encoder/ExpressionEncoderRegistry.php
ExpressionEncoderRegistry.get
public function get($format) { if (!array_key_exists($format, $this->encoders)) { throw new \RuntimeException( sprintf('The expression encoder for "%s" formatting was not found.', $format) ); } return $this->encoders[$format]; }
php
public function get($format) { if (!array_key_exists($format, $this->encoders)) { throw new \RuntimeException( sprintf('The expression encoder for "%s" formatting was not found.', $format) ); } return $this->encoders[$format]; }
[ "public", "function", "get", "(", "$", "format", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "format", ",", "$", "this", "->", "encoders", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'The expression encoder for \"%s\" formatting was not found.'", ",", "$", "format", ")", ")", ";", "}", "return", "$", "this", "->", "encoders", "[", "$", "format", "]", ";", "}" ]
Returns the encoder for the given format @param string $format @return ExpressionEncoderInterface @throws \RuntimeException if the appropriate encoder does not exist
[ "Returns", "the", "encoder", "for", "the", "given", "format" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ExpressionLanguage/Encoder/ExpressionEncoderRegistry.php#L27-L36
23,647
dstuecken/notify
src/Handler/SmartyHandler.php
SmartyHandler.handle
public function handle(NotificationInterface $notification, $level) { if ($notification instanceof AttributeAwareInterface) { $options = $notification->attributes(); } else { $options = []; } if ($notification instanceof TitleAwareInterface) { $options['header'] = $notification->title(); } $variable = [ 'message' => $notification->message(), 'type' => isset($this->levelMapping[$level]) ? $this->levelMapping[$level] : self::STANDARD, 'options' => $options ]; $current = $this->smarty->getTemplateVars($this->var); if (!$current) { $this->smarty->assign($this->var, [$variable]); } else { $this->smarty->append($this->var, $variable); } return true; }
php
public function handle(NotificationInterface $notification, $level) { if ($notification instanceof AttributeAwareInterface) { $options = $notification->attributes(); } else { $options = []; } if ($notification instanceof TitleAwareInterface) { $options['header'] = $notification->title(); } $variable = [ 'message' => $notification->message(), 'type' => isset($this->levelMapping[$level]) ? $this->levelMapping[$level] : self::STANDARD, 'options' => $options ]; $current = $this->smarty->getTemplateVars($this->var); if (!$current) { $this->smarty->assign($this->var, [$variable]); } else { $this->smarty->append($this->var, $variable); } return true; }
[ "public", "function", "handle", "(", "NotificationInterface", "$", "notification", ",", "$", "level", ")", "{", "if", "(", "$", "notification", "instanceof", "AttributeAwareInterface", ")", "{", "$", "options", "=", "$", "notification", "->", "attributes", "(", ")", ";", "}", "else", "{", "$", "options", "=", "[", "]", ";", "}", "if", "(", "$", "notification", "instanceof", "TitleAwareInterface", ")", "{", "$", "options", "[", "'header'", "]", "=", "$", "notification", "->", "title", "(", ")", ";", "}", "$", "variable", "=", "[", "'message'", "=>", "$", "notification", "->", "message", "(", ")", ",", "'type'", "=>", "isset", "(", "$", "this", "->", "levelMapping", "[", "$", "level", "]", ")", "?", "$", "this", "->", "levelMapping", "[", "$", "level", "]", ":", "self", "::", "STANDARD", ",", "'options'", "=>", "$", "options", "]", ";", "$", "current", "=", "$", "this", "->", "smarty", "->", "getTemplateVars", "(", "$", "this", "->", "var", ")", ";", "if", "(", "!", "$", "current", ")", "{", "$", "this", "->", "smarty", "->", "assign", "(", "$", "this", "->", "var", ",", "[", "$", "variable", "]", ")", ";", "}", "else", "{", "$", "this", "->", "smarty", "->", "append", "(", "$", "this", "->", "var", ",", "$", "variable", ")", ";", "}", "return", "true", ";", "}" ]
Handle a notification. @return boolean
[ "Handle", "a", "notification", "." ]
abccf0a6a272caf66baea74323f18e2212c6e11e
https://github.com/dstuecken/notify/blob/abccf0a6a272caf66baea74323f18e2212c6e11e/src/Handler/SmartyHandler.php#L34-L68
23,648
SporkCode/Spork
src/Filter/AbstractFilter.php
AbstractFilter.inline
public static function inline($value, $options = array()) { $filter = new static(); $filter->setOptions($options); return $filter->filter($value); }
php
public static function inline($value, $options = array()) { $filter = new static(); $filter->setOptions($options); return $filter->filter($value); }
[ "public", "static", "function", "inline", "(", "$", "value", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "filter", "=", "new", "static", "(", ")", ";", "$", "filter", "->", "setOptions", "(", "$", "options", ")", ";", "return", "$", "filter", "->", "filter", "(", "$", "value", ")", ";", "}" ]
Static function to execute filter @param int $value @param array $options @return mixed
[ "Static", "function", "to", "execute", "filter" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Filter/AbstractFilter.php#L24-L29
23,649
surebert/surebert-framework
src/sb/Strings.php
Strings.cleanFileName
public static function cleanFileName($str) { preg_match('~\.\w{1,4}$~', $str, $ext); $str = preg_replace('~\.\w{1,4}$~', '', $str); return str_replace(Array(' ', '.', '-'), "_", $str).$ext[0]; }
php
public static function cleanFileName($str) { preg_match('~\.\w{1,4}$~', $str, $ext); $str = preg_replace('~\.\w{1,4}$~', '', $str); return str_replace(Array(' ', '.', '-'), "_", $str).$ext[0]; }
[ "public", "static", "function", "cleanFileName", "(", "$", "str", ")", "{", "preg_match", "(", "'~\\.\\w{1,4}$~'", ",", "$", "str", ",", "$", "ext", ")", ";", "$", "str", "=", "preg_replace", "(", "'~\\.\\w{1,4}$~'", ",", "''", ",", "$", "str", ")", ";", "return", "str_replace", "(", "Array", "(", "' '", ",", "'.'", ",", "'-'", ")", ",", "\"_\"", ",", "$", "str", ")", ".", "$", "ext", "[", "0", "]", ";", "}" ]
Cleans up file names and removes extraneous spaces, symbols, etc @author paul.visco@roswellpark.org @param string $str @return string
[ "Cleans", "up", "file", "names", "and", "removes", "extraneous", "spaces", "symbols", "etc" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Strings.php#L46-L53
23,650
surebert/surebert-framework
src/sb/Strings.php
Strings.stripMicrosoftChars
public static function stripMicrosoftChars($str) { $chars=array( chr(133) => '...', //dot dot dot elipsis chr(145) => "'", //curly left single quotes chr(146) => "'", //curly right single quotes chr(147) => '"', //curly left double quotes chr(148) => '"', //curly right double quotes chr(149) => '*', //bullet char chr(150) => '-', //en dash chr(151) => '-', //em dash, //mac word roman charset chr(165) => '*', //bullet char chr(201) => '...', //elipsis chr(208) => '-', //en-dash chr(209) => '-', //em-dash chr(210) => '"', //curly left double quotes chr(211) => '"', //curly right double quotes chr(212) => '\'', //curly left single quote chr(213) => '\'', //curly right single quotes ); return strtr($str, $chars); }
php
public static function stripMicrosoftChars($str) { $chars=array( chr(133) => '...', //dot dot dot elipsis chr(145) => "'", //curly left single quotes chr(146) => "'", //curly right single quotes chr(147) => '"', //curly left double quotes chr(148) => '"', //curly right double quotes chr(149) => '*', //bullet char chr(150) => '-', //en dash chr(151) => '-', //em dash, //mac word roman charset chr(165) => '*', //bullet char chr(201) => '...', //elipsis chr(208) => '-', //en-dash chr(209) => '-', //em-dash chr(210) => '"', //curly left double quotes chr(211) => '"', //curly right double quotes chr(212) => '\'', //curly left single quote chr(213) => '\'', //curly right single quotes ); return strtr($str, $chars); }
[ "public", "static", "function", "stripMicrosoftChars", "(", "$", "str", ")", "{", "$", "chars", "=", "array", "(", "chr", "(", "133", ")", "=>", "'...'", ",", "//dot dot dot elipsis", "chr", "(", "145", ")", "=>", "\"'\"", ",", "//curly left single quotes", "chr", "(", "146", ")", "=>", "\"'\"", ",", "//curly right single quotes", "chr", "(", "147", ")", "=>", "'\"'", ",", "//curly left double quotes", "chr", "(", "148", ")", "=>", "'\"'", ",", "//curly right double quotes", "chr", "(", "149", ")", "=>", "'*'", ",", "//bullet char", "chr", "(", "150", ")", "=>", "'-'", ",", "//en dash", "chr", "(", "151", ")", "=>", "'-'", ",", "//em dash,", "//mac word roman charset", "chr", "(", "165", ")", "=>", "'*'", ",", "//bullet char", "chr", "(", "201", ")", "=>", "'...'", ",", "//elipsis", "chr", "(", "208", ")", "=>", "'-'", ",", "//en-dash", "chr", "(", "209", ")", "=>", "'-'", ",", "//em-dash", "chr", "(", "210", ")", "=>", "'\"'", ",", "//curly left double quotes", "chr", "(", "211", ")", "=>", "'\"'", ",", "//curly right double quotes", "chr", "(", "212", ")", "=>", "'\\''", ",", "//curly left single quote", "chr", "(", "213", ")", "=>", "'\\''", ",", "//curly right single quotes", ")", ";", "return", "strtr", "(", "$", "str", ",", "$", "chars", ")", ";", "}" ]
Removes microsoft characters and replace them with their ascii counterparts @author paul.visco@roswellpark.org @param string $str @return string
[ "Removes", "microsoft", "characters", "and", "replace", "them", "with", "their", "ascii", "counterparts" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Strings.php#L74-L101
23,651
surebert/surebert-framework
src/sb/Strings.php
Strings.truncate
public static function truncate($str, $maxlength=20) { if(strlen($str) > $maxlength){ $str = substr($str, 0, $maxlength-3).'...'; } return $str; }
php
public static function truncate($str, $maxlength=20) { if(strlen($str) > $maxlength){ $str = substr($str, 0, $maxlength-3).'...'; } return $str; }
[ "public", "static", "function", "truncate", "(", "$", "str", ",", "$", "maxlength", "=", "20", ")", "{", "if", "(", "strlen", "(", "$", "str", ")", ">", "$", "maxlength", ")", "{", "$", "str", "=", "substr", "(", "$", "str", ",", "0", ",", "$", "maxlength", "-", "3", ")", ".", "'...'", ";", "}", "return", "$", "str", ";", "}" ]
Truncates a string to a certain length and right padswith ... @param string $str @param integer $maxlength The maximum length, keep in mind that the ... counts as three chars @return string
[ "Truncates", "a", "string", "to", "a", "certain", "length", "and", "right", "padswith", "..." ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Strings.php#L142-L150
23,652
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Scrybe/Command/Manual/ToLatexCommand.php
ToLatexCommand.getConverter
protected function getConverter(InputInterface $input) { /** @var ToLatexInterface $converter */ $converter = parent::getConverter($input); $this->configureConverterFromInputOptions($converter, $input); return $converter; }
php
protected function getConverter(InputInterface $input) { /** @var ToLatexInterface $converter */ $converter = parent::getConverter($input); $this->configureConverterFromInputOptions($converter, $input); return $converter; }
[ "protected", "function", "getConverter", "(", "InputInterface", "$", "input", ")", "{", "/** @var ToLatexInterface $converter */", "$", "converter", "=", "parent", "::", "getConverter", "(", "$", "input", ")", ";", "$", "this", "->", "configureConverterFromInputOptions", "(", "$", "converter", ",", "$", "input", ")", ";", "return", "$", "converter", ";", "}" ]
Returns and configures the converter for this operation. This method overrides the parent getConverter method and invokes the configureConverterFromInputOptions() method to set the options coming from the Input object. @param InputInterface $input @see BaseConvertCommand::getConverter() for the basic functionality. @return \phpDocumentor\Plugin\Scrybe\Converter\ConverterInterface
[ "Returns", "and", "configures", "the", "converter", "for", "this", "operation", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Scrybe/Command/Manual/ToLatexCommand.php#L78-L85
23,653
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php
ezcMailPart.generateHeaders
public function generateHeaders() { // set content disposition header if ( $this->contentDisposition !== null && ( $this->contentDisposition instanceof ezcMailContentDispositionHeader ) ) { $cdHeader = $this->contentDisposition; $cd = "{$cdHeader->disposition}"; if ( $cdHeader->fileName !== null ) { $fileInfo = null; if ( $cdHeader->fileNameCharSet !== null ) { $fileInfo .= "*0*=\"{$cdHeader->fileNameCharSet}"; if ( $cdHeader->fileNameLanguage !== null ) { $fileInfo .= "'{$cdHeader->fileNameLanguage}'"; } else { // RFC 2184: the single quote delimiters MUST be present // even when one of the field values is omitted $fileInfo .= "''"; } } if ( $fileInfo !== null ) { $cd .= "; filename{$fileInfo}{$cdHeader->fileName}\""; } else { $cd .= "; filename=\"{$cdHeader->fileName}\""; } } if ( $cdHeader->creationDate !== null ) { $cd .= "; creation-date=\"{$cdHeader->creationDate}\""; } if ( $cdHeader->modificationDate !== null ) { $cd .= "; modification-date=\"{$cdHeader->modificationDate}\""; } if ( $cdHeader->readDate !== null ) { $cd .= "; read-date=\"{$cdHeader->readDate}\""; } if ( $cdHeader->size !== null ) { $cd .= "; size={$cdHeader->size}"; } foreach ( $cdHeader->additionalParameters as $addKey => $addValue ) { $cd .="; {$addKey}=\"{$addValue}\""; } $this->setHeader( 'Content-Disposition', $cd ); } // generate headers $text = ""; foreach ( $this->headers->getCaseSensitiveArray() as $header => $value ) { if ( is_array( $value ) ) { $value = $value[0]; } // here we encode every header, even the ones that we don't add to // the header set directly. We do that so that transports sill see // all the encoded headers which they then can use accordingly. $charset = $this->getHeaderCharset( $header ); switch ( strtolower( $charset ) ) { case 'us-ascii': $value = ezcMailHeaderFolder::foldAny( $value ); break; case 'iso-8859-1': case 'iso-8859-2': case 'iso-8859-3': case 'iso-8859-4': case 'iso-8859-5': case 'iso-8859-6': case 'iso-8859-7': case 'iso-8859-8': case 'iso-8859-9': case 'iso-8859-10': case 'iso-8859-11': case 'iso-8859-12': case 'iso-8859-13': case 'iso-8859-14': case 'iso-8859-15' :case 'iso-8859-16': case 'windows-1250': case 'windows-1251': case 'windows-1252': case 'utf-8': if ( strpbrk( $value, "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" ) === false ) { $value = ezcMailHeaderFolder::foldAny( $value ); break; } // break intentionally missing default: $preferences = array( 'input-charset' => $charset, 'output-charset' => $charset, 'line-length' => ezcMailHeaderFolder::getLimit(), 'scheme' => 'Q', 'line-break-chars' => ezcMailTools::lineBreak() ); $value = iconv_mime_encode( 'dummy', $value, $preferences ); $value = substr( $value, 7 ); // "dummy: " + 1 // just to keep compatibility with code which might read // the headers after generateHeaders() has been called $this->setHeader( $header, $value, $charset ); break; } if ( in_array( strtolower( $header ), $this->excludeHeaders ) === false ) { $text .= "$header: $value" . ezcMailTools::lineBreak(); } } return $text; }
php
public function generateHeaders() { // set content disposition header if ( $this->contentDisposition !== null && ( $this->contentDisposition instanceof ezcMailContentDispositionHeader ) ) { $cdHeader = $this->contentDisposition; $cd = "{$cdHeader->disposition}"; if ( $cdHeader->fileName !== null ) { $fileInfo = null; if ( $cdHeader->fileNameCharSet !== null ) { $fileInfo .= "*0*=\"{$cdHeader->fileNameCharSet}"; if ( $cdHeader->fileNameLanguage !== null ) { $fileInfo .= "'{$cdHeader->fileNameLanguage}'"; } else { // RFC 2184: the single quote delimiters MUST be present // even when one of the field values is omitted $fileInfo .= "''"; } } if ( $fileInfo !== null ) { $cd .= "; filename{$fileInfo}{$cdHeader->fileName}\""; } else { $cd .= "; filename=\"{$cdHeader->fileName}\""; } } if ( $cdHeader->creationDate !== null ) { $cd .= "; creation-date=\"{$cdHeader->creationDate}\""; } if ( $cdHeader->modificationDate !== null ) { $cd .= "; modification-date=\"{$cdHeader->modificationDate}\""; } if ( $cdHeader->readDate !== null ) { $cd .= "; read-date=\"{$cdHeader->readDate}\""; } if ( $cdHeader->size !== null ) { $cd .= "; size={$cdHeader->size}"; } foreach ( $cdHeader->additionalParameters as $addKey => $addValue ) { $cd .="; {$addKey}=\"{$addValue}\""; } $this->setHeader( 'Content-Disposition', $cd ); } // generate headers $text = ""; foreach ( $this->headers->getCaseSensitiveArray() as $header => $value ) { if ( is_array( $value ) ) { $value = $value[0]; } // here we encode every header, even the ones that we don't add to // the header set directly. We do that so that transports sill see // all the encoded headers which they then can use accordingly. $charset = $this->getHeaderCharset( $header ); switch ( strtolower( $charset ) ) { case 'us-ascii': $value = ezcMailHeaderFolder::foldAny( $value ); break; case 'iso-8859-1': case 'iso-8859-2': case 'iso-8859-3': case 'iso-8859-4': case 'iso-8859-5': case 'iso-8859-6': case 'iso-8859-7': case 'iso-8859-8': case 'iso-8859-9': case 'iso-8859-10': case 'iso-8859-11': case 'iso-8859-12': case 'iso-8859-13': case 'iso-8859-14': case 'iso-8859-15' :case 'iso-8859-16': case 'windows-1250': case 'windows-1251': case 'windows-1252': case 'utf-8': if ( strpbrk( $value, "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" ) === false ) { $value = ezcMailHeaderFolder::foldAny( $value ); break; } // break intentionally missing default: $preferences = array( 'input-charset' => $charset, 'output-charset' => $charset, 'line-length' => ezcMailHeaderFolder::getLimit(), 'scheme' => 'Q', 'line-break-chars' => ezcMailTools::lineBreak() ); $value = iconv_mime_encode( 'dummy', $value, $preferences ); $value = substr( $value, 7 ); // "dummy: " + 1 // just to keep compatibility with code which might read // the headers after generateHeaders() has been called $this->setHeader( $header, $value, $charset ); break; } if ( in_array( strtolower( $header ), $this->excludeHeaders ) === false ) { $text .= "$header: $value" . ezcMailTools::lineBreak(); } } return $text; }
[ "public", "function", "generateHeaders", "(", ")", "{", "// set content disposition header", "if", "(", "$", "this", "->", "contentDisposition", "!==", "null", "&&", "(", "$", "this", "->", "contentDisposition", "instanceof", "ezcMailContentDispositionHeader", ")", ")", "{", "$", "cdHeader", "=", "$", "this", "->", "contentDisposition", ";", "$", "cd", "=", "\"{$cdHeader->disposition}\"", ";", "if", "(", "$", "cdHeader", "->", "fileName", "!==", "null", ")", "{", "$", "fileInfo", "=", "null", ";", "if", "(", "$", "cdHeader", "->", "fileNameCharSet", "!==", "null", ")", "{", "$", "fileInfo", ".=", "\"*0*=\\\"{$cdHeader->fileNameCharSet}\"", ";", "if", "(", "$", "cdHeader", "->", "fileNameLanguage", "!==", "null", ")", "{", "$", "fileInfo", ".=", "\"'{$cdHeader->fileNameLanguage}'\"", ";", "}", "else", "{", "// RFC 2184: the single quote delimiters MUST be present", "// even when one of the field values is omitted", "$", "fileInfo", ".=", "\"''\"", ";", "}", "}", "if", "(", "$", "fileInfo", "!==", "null", ")", "{", "$", "cd", ".=", "\"; filename{$fileInfo}{$cdHeader->fileName}\\\"\"", ";", "}", "else", "{", "$", "cd", ".=", "\"; filename=\\\"{$cdHeader->fileName}\\\"\"", ";", "}", "}", "if", "(", "$", "cdHeader", "->", "creationDate", "!==", "null", ")", "{", "$", "cd", ".=", "\"; creation-date=\\\"{$cdHeader->creationDate}\\\"\"", ";", "}", "if", "(", "$", "cdHeader", "->", "modificationDate", "!==", "null", ")", "{", "$", "cd", ".=", "\"; modification-date=\\\"{$cdHeader->modificationDate}\\\"\"", ";", "}", "if", "(", "$", "cdHeader", "->", "readDate", "!==", "null", ")", "{", "$", "cd", ".=", "\"; read-date=\\\"{$cdHeader->readDate}\\\"\"", ";", "}", "if", "(", "$", "cdHeader", "->", "size", "!==", "null", ")", "{", "$", "cd", ".=", "\"; size={$cdHeader->size}\"", ";", "}", "foreach", "(", "$", "cdHeader", "->", "additionalParameters", "as", "$", "addKey", "=>", "$", "addValue", ")", "{", "$", "cd", ".=", "\"; {$addKey}=\\\"{$addValue}\\\"\"", ";", "}", "$", "this", "->", "setHeader", "(", "'Content-Disposition'", ",", "$", "cd", ")", ";", "}", "// generate headers", "$", "text", "=", "\"\"", ";", "foreach", "(", "$", "this", "->", "headers", "->", "getCaseSensitiveArray", "(", ")", "as", "$", "header", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "value", "[", "0", "]", ";", "}", "// here we encode every header, even the ones that we don't add to", "// the header set directly. We do that so that transports sill see", "// all the encoded headers which they then can use accordingly.", "$", "charset", "=", "$", "this", "->", "getHeaderCharset", "(", "$", "header", ")", ";", "switch", "(", "strtolower", "(", "$", "charset", ")", ")", "{", "case", "'us-ascii'", ":", "$", "value", "=", "ezcMailHeaderFolder", "::", "foldAny", "(", "$", "value", ")", ";", "break", ";", "case", "'iso-8859-1'", ":", "case", "'iso-8859-2'", ":", "case", "'iso-8859-3'", ":", "case", "'iso-8859-4'", ":", "case", "'iso-8859-5'", ":", "case", "'iso-8859-6'", ":", "case", "'iso-8859-7'", ":", "case", "'iso-8859-8'", ":", "case", "'iso-8859-9'", ":", "case", "'iso-8859-10'", ":", "case", "'iso-8859-11'", ":", "case", "'iso-8859-12'", ":", "case", "'iso-8859-13'", ":", "case", "'iso-8859-14'", ":", "case", "'iso-8859-15'", ":", "case", "'iso-8859-16'", ":", "case", "'windows-1250'", ":", "case", "'windows-1251'", ":", "case", "'windows-1252'", ":", "case", "'utf-8'", ":", "if", "(", "strpbrk", "(", "$", "value", ",", "\"\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b\\x9c\\x9d\\x9e\\x9f\\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\\xa8\\xa9\\xaa\\xab\\xac\\xad\\xae\\xaf\\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7\\xb8\\xb9\\xba\\xbb\\xbc\\xbd\\xbe\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff\"", ")", "===", "false", ")", "{", "$", "value", "=", "ezcMailHeaderFolder", "::", "foldAny", "(", "$", "value", ")", ";", "break", ";", "}", "// break intentionally missing", "default", ":", "$", "preferences", "=", "array", "(", "'input-charset'", "=>", "$", "charset", ",", "'output-charset'", "=>", "$", "charset", ",", "'line-length'", "=>", "ezcMailHeaderFolder", "::", "getLimit", "(", ")", ",", "'scheme'", "=>", "'Q'", ",", "'line-break-chars'", "=>", "ezcMailTools", "::", "lineBreak", "(", ")", ")", ";", "$", "value", "=", "iconv_mime_encode", "(", "'dummy'", ",", "$", "value", ",", "$", "preferences", ")", ";", "$", "value", "=", "substr", "(", "$", "value", ",", "7", ")", ";", "// \"dummy: \" + 1", "// just to keep compatibility with code which might read", "// the headers after generateHeaders() has been called", "$", "this", "->", "setHeader", "(", "$", "header", ",", "$", "value", ",", "$", "charset", ")", ";", "break", ";", "}", "if", "(", "in_array", "(", "strtolower", "(", "$", "header", ")", ",", "$", "this", "->", "excludeHeaders", ")", "===", "false", ")", "{", "$", "text", ".=", "\"$header: $value\"", ".", "ezcMailTools", "::", "lineBreak", "(", ")", ";", "}", "}", "return", "$", "text", ";", "}" ]
Returns the headers set for this part as a RFC 822 string. Each header is separated by a line break. This method does not add the required two lines of space to separate the headers from the body of the part. It also encodes the headers (with the 'Q' encoding) if the charset associated with the header is different than 'us-ascii' or if it contains characters not allowed in mail headers. This function is called automatically by generate() and subclasses can override this method if they wish to set additional headers when the mail is generated. @see setHeader() @return string
[ "Returns", "the", "headers", "set", "for", "this", "part", "as", "a", "RFC", "822", "string", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/interfaces/part.php#L278-L397
23,654
interactivesolutions/honeycomb-core
src/commands/HCCommand.php
HCCommand.deleteDirectory
public function deleteDirectory(string $path, bool $withFiles = false) { if( $path == '*' ) $this->abort('Can not delete "*", please specify folder or file.'); $files = glob($path . '/*'); foreach ( $files as $file ) { if( is_file($file) && ! $withFiles ) return; is_dir($file) ? $this->deleteDirectory($file, $withFiles) : unlink($file); } if( is_dir($path) ) try { rmdir($path); $this->info('Deleting folder: ' . $path); } catch ( \Exception $e ) { $this->comment('Can not delete ' . $path . ', it might contain hidden files, such as .gitignore'); } }
php
public function deleteDirectory(string $path, bool $withFiles = false) { if( $path == '*' ) $this->abort('Can not delete "*", please specify folder or file.'); $files = glob($path . '/*'); foreach ( $files as $file ) { if( is_file($file) && ! $withFiles ) return; is_dir($file) ? $this->deleteDirectory($file, $withFiles) : unlink($file); } if( is_dir($path) ) try { rmdir($path); $this->info('Deleting folder: ' . $path); } catch ( \Exception $e ) { $this->comment('Can not delete ' . $path . ', it might contain hidden files, such as .gitignore'); } }
[ "public", "function", "deleteDirectory", "(", "string", "$", "path", ",", "bool", "$", "withFiles", "=", "false", ")", "{", "if", "(", "$", "path", "==", "'*'", ")", "$", "this", "->", "abort", "(", "'Can not delete \"*\", please specify folder or file.'", ")", ";", "$", "files", "=", "glob", "(", "$", "path", ".", "'/*'", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "is_file", "(", "$", "file", ")", "&&", "!", "$", "withFiles", ")", "return", ";", "is_dir", "(", "$", "file", ")", "?", "$", "this", "->", "deleteDirectory", "(", "$", "file", ",", "$", "withFiles", ")", ":", "unlink", "(", "$", "file", ")", ";", "}", "if", "(", "is_dir", "(", "$", "path", ")", ")", "try", "{", "rmdir", "(", "$", "path", ")", ";", "$", "this", "->", "info", "(", "'Deleting folder: '", ".", "$", "path", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "comment", "(", "'Can not delete '", ".", "$", "path", ".", "', it might contain hidden files, such as .gitignore'", ")", ";", "}", "}" ]
Deleting existing folder @param string $path @param bool $withFiles
[ "Deleting", "existing", "folder" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L47-L65
23,655
interactivesolutions/honeycomb-core
src/commands/HCCommand.php
HCCommand.getToReplace
public function getToReplace(array $ignoreSymbols): array { if( empty($ignoreSymbols) ) return $this->toReplace; return array_diff($this->toReplace, $ignoreSymbols); }
php
public function getToReplace(array $ignoreSymbols): array { if( empty($ignoreSymbols) ) return $this->toReplace; return array_diff($this->toReplace, $ignoreSymbols); }
[ "public", "function", "getToReplace", "(", "array", "$", "ignoreSymbols", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "ignoreSymbols", ")", ")", "return", "$", "this", "->", "toReplace", ";", "return", "array_diff", "(", "$", "this", "->", "toReplace", ",", "$", "ignoreSymbols", ")", ";", "}" ]
Get replaceable symbols @param array $ignoreSymbols @return array
[ "Get", "replaceable", "symbols" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L113-L119
23,656
interactivesolutions/honeycomb-core
src/commands/HCCommand.php
HCCommand.stringWithUnderscore
protected function stringWithUnderscore(string $string, array $ignoreToReplace = []) { return str_replace($this->getToReplace($ignoreToReplace), '_', trim($string, '/')); }
php
protected function stringWithUnderscore(string $string, array $ignoreToReplace = []) { return str_replace($this->getToReplace($ignoreToReplace), '_', trim($string, '/')); }
[ "protected", "function", "stringWithUnderscore", "(", "string", "$", "string", ",", "array", "$", "ignoreToReplace", "=", "[", "]", ")", "{", "return", "str_replace", "(", "$", "this", "->", "getToReplace", "(", "$", "ignoreToReplace", ")", ",", "'_'", ",", "trim", "(", "$", "string", ",", "'/'", ")", ")", ";", "}" ]
Get string in underscore @param string $string @param array $ignoreToReplace @return mixed
[ "Get", "string", "in", "underscore" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L151-L154
23,657
interactivesolutions/honeycomb-core
src/commands/HCCommand.php
HCCommand.stringWithDash
protected function stringWithDash(string $string, array $ignoreToReplace = []) { return str_replace($this->getToReplace($ignoreToReplace), '-', trim($string, '/')); }
php
protected function stringWithDash(string $string, array $ignoreToReplace = []) { return str_replace($this->getToReplace($ignoreToReplace), '-', trim($string, '/')); }
[ "protected", "function", "stringWithDash", "(", "string", "$", "string", ",", "array", "$", "ignoreToReplace", "=", "[", "]", ")", "{", "return", "str_replace", "(", "$", "this", "->", "getToReplace", "(", "$", "ignoreToReplace", ")", ",", "'-'", ",", "trim", "(", "$", "string", ",", "'/'", ")", ")", ";", "}" ]
Get string in dash @param string $string @param array $ignoreToReplace @return mixed
[ "Get", "string", "in", "dash" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L163-L166
23,658
interactivesolutions/honeycomb-core
src/commands/HCCommand.php
HCCommand.stringOnly
protected function stringOnly(string $string, array $ignoreToReplace = []) { return str_replace($this->getToReplace($ignoreToReplace), '', trim($string, '/')); }
php
protected function stringOnly(string $string, array $ignoreToReplace = []) { return str_replace($this->getToReplace($ignoreToReplace), '', trim($string, '/')); }
[ "protected", "function", "stringOnly", "(", "string", "$", "string", ",", "array", "$", "ignoreToReplace", "=", "[", "]", ")", "{", "return", "str_replace", "(", "$", "this", "->", "getToReplace", "(", "$", "ignoreToReplace", ")", ",", "''", ",", "trim", "(", "$", "string", ",", "'/'", ")", ")", ";", "}" ]
Remove all items from string @param string $string @param array $ignoreToReplace @return mixed
[ "Remove", "all", "items", "from", "string" ]
06b8d88bb285e73a1a286e60411ca5f41863f39f
https://github.com/interactivesolutions/honeycomb-core/blob/06b8d88bb285e73a1a286e60411ca5f41863f39f/src/commands/HCCommand.php#L175-L178
23,659
heidelpay/PhpDoc
features/bootstrap/FeatureContext.php
FeatureContext.iShouldGetALogEntry
public function iShouldGetALogEntry($string) { $found = false; foreach (explode("\n", $this->getOutput()) as $line) { if (trim($line) == $string) { $found = true; } } if (!$found) { throw new \Exception( "Actual output is:\n" . $this->getOutput() ); } }
php
public function iShouldGetALogEntry($string) { $found = false; foreach (explode("\n", $this->getOutput()) as $line) { if (trim($line) == $string) { $found = true; } } if (!$found) { throw new \Exception( "Actual output is:\n" . $this->getOutput() ); } }
[ "public", "function", "iShouldGetALogEntry", "(", "$", "string", ")", "{", "$", "found", "=", "false", ";", "foreach", "(", "explode", "(", "\"\\n\"", ",", "$", "this", "->", "getOutput", "(", ")", ")", "as", "$", "line", ")", "{", "if", "(", "trim", "(", "$", "line", ")", "==", "$", "string", ")", "{", "$", "found", "=", "true", ";", "}", "}", "if", "(", "!", "$", "found", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Actual output is:\\n\"", ".", "$", "this", "->", "getOutput", "(", ")", ")", ";", "}", "}" ]
Verifies whether one of the log entries is the same as the given. Please note that this method exactly checks the given except for leading and trailing spaces and control characters; those are stripped first. @param string $string @Then /^I should get a log entry "([^"]*)"$/ @throws \Exception if the condition is not fulfilled @return void
[ "Verifies", "whether", "one", "of", "the", "log", "entries", "is", "the", "same", "as", "the", "given", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L84-L98
23,660
heidelpay/PhpDoc
features/bootstrap/FeatureContext.php
FeatureContext.iShouldGetALogEntryContaining
public function iShouldGetALogEntryContaining($string) { $found = false; foreach (explode("\n", $this->getOutput()) as $line) { if (strpos(trim($line), $string) !== false) { $found = true; } } if (!$found) { throw new \Exception( "Actual output is:\n" . $this->getOutput() ); } }
php
public function iShouldGetALogEntryContaining($string) { $found = false; foreach (explode("\n", $this->getOutput()) as $line) { if (strpos(trim($line), $string) !== false) { $found = true; } } if (!$found) { throw new \Exception( "Actual output is:\n" . $this->getOutput() ); } }
[ "public", "function", "iShouldGetALogEntryContaining", "(", "$", "string", ")", "{", "$", "found", "=", "false", ";", "foreach", "(", "explode", "(", "\"\\n\"", ",", "$", "this", "->", "getOutput", "(", ")", ")", "as", "$", "line", ")", "{", "if", "(", "strpos", "(", "trim", "(", "$", "line", ")", ",", "$", "string", ")", "!==", "false", ")", "{", "$", "found", "=", "true", ";", "}", "}", "if", "(", "!", "$", "found", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Actual output is:\\n\"", ".", "$", "this", "->", "getOutput", "(", ")", ")", ";", "}", "}" ]
Verifies whether a log entry contains the given substring. @param string $string @Then /^I should get a log entry containing "([^"]*)"$/ @throws \Exception if the condition is not fulfilled @return void
[ "Verifies", "whether", "a", "log", "entry", "contains", "the", "given", "substring", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L138-L152
23,661
heidelpay/PhpDoc
features/bootstrap/FeatureContext.php
FeatureContext.iRunPhpDocumentorAgainstTheFile
public function iRunPhpDocumentorAgainstTheFile($file_path) { $tmp = self::getTmpFolder(); $fullPath = __DIR__ . '/../../' . $file_path; $this->iRunPhpdoc("-f $fullPath -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force"); }
php
public function iRunPhpDocumentorAgainstTheFile($file_path) { $tmp = self::getTmpFolder(); $fullPath = __DIR__ . '/../../' . $file_path; $this->iRunPhpdoc("-f $fullPath -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force"); }
[ "public", "function", "iRunPhpDocumentorAgainstTheFile", "(", "$", "file_path", ")", "{", "$", "tmp", "=", "self", "::", "getTmpFolder", "(", ")", ";", "$", "fullPath", "=", "__DIR__", ".", "'/../../'", ".", "$", "file_path", ";", "$", "this", "->", "iRunPhpdoc", "(", "\"-f $fullPath -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force\"", ")", ";", "}" ]
Runs phpDocumentor with only the file that is provided in this command. The configuration is explicitly disabled to prevent tainting via the configuration. @param string $file_path @When /^I run phpDocumentor against the file "([^"]*)"$/ @return void
[ "Runs", "phpDocumentor", "with", "only", "the", "file", "that", "is", "provided", "in", "this", "command", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L276-L281
23,662
heidelpay/PhpDoc
features/bootstrap/FeatureContext.php
FeatureContext.iRunPhpDocumentorWith
public function iRunPhpDocumentorWith(PyStringNode $code, $extraParameters = '') { $tmp = self::getTmpFolder(); $file = tempnam($tmp, 'pdb'); file_put_contents($file, $code); $this->iRunPhpdoc("-f $file -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force $extraParameters"); unlink($file); }
php
public function iRunPhpDocumentorWith(PyStringNode $code, $extraParameters = '') { $tmp = self::getTmpFolder(); $file = tempnam($tmp, 'pdb'); file_put_contents($file, $code); $this->iRunPhpdoc("-f $file -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force $extraParameters"); unlink($file); }
[ "public", "function", "iRunPhpDocumentorWith", "(", "PyStringNode", "$", "code", ",", "$", "extraParameters", "=", "''", ")", "{", "$", "tmp", "=", "self", "::", "getTmpFolder", "(", ")", ";", "$", "file", "=", "tempnam", "(", "$", "tmp", ",", "'pdb'", ")", ";", "file_put_contents", "(", "$", "file", ",", "$", "code", ")", ";", "$", "this", "->", "iRunPhpdoc", "(", "\"-f $file -t $tmp --config='{$this->getTempXmlConfigurationPath()}' --force $extraParameters\"", ")", ";", "unlink", "(", "$", "file", ")", ";", "}" ]
Parses the given PHP code with phpDocumentor. @param PyStringNode $code @When /^I run phpDocumentor with:$/ @return void
[ "Parses", "the", "given", "PHP", "code", "with", "phpDocumentor", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L292-L299
23,663
heidelpay/PhpDoc
features/bootstrap/FeatureContext.php
FeatureContext.iShouldGet
public function iShouldGet(PyStringNode $string) { if ($this->getOutput() != trim($string->getRaw())) { throw new \Exception( "Actual output is:\n" . $this->getOutput() ); } }
php
public function iShouldGet(PyStringNode $string) { if ($this->getOutput() != trim($string->getRaw())) { throw new \Exception( "Actual output is:\n" . $this->getOutput() ); } }
[ "public", "function", "iShouldGet", "(", "PyStringNode", "$", "string", ")", "{", "if", "(", "$", "this", "->", "getOutput", "(", ")", "!=", "trim", "(", "$", "string", "->", "getRaw", "(", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Actual output is:\\n\"", ".", "$", "this", "->", "getOutput", "(", ")", ")", ";", "}", "}" ]
Verifies whether the output of an iRun When is equal to the given. @param PyStringNode $string @Then /^I should get:$/ @throws \Exception if the condition is not fulfilled @return void
[ "Verifies", "whether", "the", "output", "of", "an", "iRun", "When", "is", "equal", "to", "the", "given", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L355-L362
23,664
heidelpay/PhpDoc
features/bootstrap/FeatureContext.php
FeatureContext.theExitCodeShouldBeZero
public function theExitCodeShouldBeZero() { if ($this->getReturnCode() != 0) { throw new \Exception( 'Return code was ' . $this->getReturnCode() . ' with output ' .$this->getOutput() . $this->process->getOutput() ); } }
php
public function theExitCodeShouldBeZero() { if ($this->getReturnCode() != 0) { throw new \Exception( 'Return code was ' . $this->getReturnCode() . ' with output ' .$this->getOutput() . $this->process->getOutput() ); } }
[ "public", "function", "theExitCodeShouldBeZero", "(", ")", "{", "if", "(", "$", "this", "->", "getReturnCode", "(", ")", "!=", "0", ")", "{", "throw", "new", "\\", "Exception", "(", "'Return code was '", ".", "$", "this", "->", "getReturnCode", "(", ")", ".", "' with output '", ".", "$", "this", "->", "getOutput", "(", ")", ".", "$", "this", "->", "process", "->", "getOutput", "(", ")", ")", ";", "}", "}" ]
Verifies whether the return code was 0 and thus execution was a success. @Then /^the exit code should be zero$/ @throws \Exception if the condition is not fulfilled @return void
[ "Verifies", "whether", "the", "return", "code", "was", "0", "and", "thus", "execution", "was", "a", "success", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/features/bootstrap/FeatureContext.php#L373-L381
23,665
hametuha/wpametu
src/WPametu/UI/Field/TokenInputPost.php
TokenInputPost.get_required
protected function get_required( \WP_Post $post = null){ if( current_user_can('edit_posts') ){ $url = admin_url('post-new.php?post_type='.$this->post_type); $post_type_obj = get_post_type_object($this->post_type); $tip = esc_html(sprintf($this->__('Add new %s'), $post_type_obj->labels->name)); $input = <<<HTML <a href="{$url}" data-tooltip-title="{$tip}"><i class="dashicons dashicons-plus-alt"></i></a> HTML; return $input.parent::get_required($post); }else{ return parent::get_required($post); } }
php
protected function get_required( \WP_Post $post = null){ if( current_user_can('edit_posts') ){ $url = admin_url('post-new.php?post_type='.$this->post_type); $post_type_obj = get_post_type_object($this->post_type); $tip = esc_html(sprintf($this->__('Add new %s'), $post_type_obj->labels->name)); $input = <<<HTML <a href="{$url}" data-tooltip-title="{$tip}"><i class="dashicons dashicons-plus-alt"></i></a> HTML; return $input.parent::get_required($post); }else{ return parent::get_required($post); } }
[ "protected", "function", "get_required", "(", "\\", "WP_Post", "$", "post", "=", "null", ")", "{", "if", "(", "current_user_can", "(", "'edit_posts'", ")", ")", "{", "$", "url", "=", "admin_url", "(", "'post-new.php?post_type='", ".", "$", "this", "->", "post_type", ")", ";", "$", "post_type_obj", "=", "get_post_type_object", "(", "$", "this", "->", "post_type", ")", ";", "$", "tip", "=", "esc_html", "(", "sprintf", "(", "$", "this", "->", "__", "(", "'Add new %s'", ")", ",", "$", "post_type_obj", "->", "labels", "->", "name", ")", ")", ";", "$", "input", "=", " <<<HTML\n<a href=\"{$url}\" data-tooltip-title=\"{$tip}\"><i class=\"dashicons dashicons-plus-alt\"></i></a>\nHTML", ";", "return", "$", "input", ".", "parent", "::", "get_required", "(", "$", "post", ")", ";", "}", "else", "{", "return", "parent", "::", "get_required", "(", "$", "post", ")", ";", "}", "}" ]
Add button before requried @param \WP_Post $post @return string
[ "Add", "button", "before", "requried" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/TokenInputPost.php#L89-L102
23,666
hametuha/wpametu
src/WPametu/UI/Field/TokenInputPost.php
TokenInputPost.get_prepopulates
protected function get_prepopulates($data){ $json = []; foreach( $data as $post ){ $json[] = [ 'id' => $post->ID, 'name' => $post->post_title, ]; } return $json; }
php
protected function get_prepopulates($data){ $json = []; foreach( $data as $post ){ $json[] = [ 'id' => $post->ID, 'name' => $post->post_title, ]; } return $json; }
[ "protected", "function", "get_prepopulates", "(", "$", "data", ")", "{", "$", "json", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "post", ")", "{", "$", "json", "[", "]", "=", "[", "'id'", "=>", "$", "post", "->", "ID", ",", "'name'", "=>", "$", "post", "->", "post_title", ",", "]", ";", "}", "return", "$", "json", ";", "}" ]
Get prepopulated data @param array $data @return array
[ "Get", "prepopulated", "data" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/TokenInputPost.php#L110-L119
23,667
eghojansu/moe
src/tools/Web.php
Web.mime
function mime($file) { if (preg_match('/\w+$/',$file,$ext)) { $map=array( 'au'=>'audio/basic', 'avi'=>'video/avi', 'bmp'=>'image/bmp', 'bz2'=>'application/x-bzip2', 'css'=>'text/css', 'dtd'=>'application/xml-dtd', 'doc'=>'application/msword', 'gif'=>'image/gif', 'gz'=>'application/x-gzip', 'hqx'=>'application/mac-binhex40', 'html?'=>'text/html', 'jar'=>'application/java-archive', 'jpe?g'=>'image/jpeg', 'js'=>'application/x-javascript', 'midi'=>'audio/x-midi', 'mp3'=>'audio/mpeg', 'mpe?g'=>'video/mpeg', 'ogg'=>'audio/vorbis', 'pdf'=>'application/pdf', 'png'=>'image/png', 'ppt'=>'application/vnd.ms-powerpoint', 'ps'=>'application/postscript', 'qt'=>'video/quicktime', 'ram?'=>'audio/x-pn-realaudio', 'rdf'=>'application/rdf', 'rtf'=>'application/rtf', 'sgml?'=>'text/sgml', 'sit'=>'application/x-stuffit', 'svg'=>'image/svg+xml', 'swf'=>'application/x-shockwave-flash', 'tgz'=>'application/x-tar', 'tiff'=>'image/tiff', 'txt'=>'text/plain', 'wav'=>'audio/wav', 'xls'=>'application/vnd.ms-excel', 'xml'=>'application/xml', 'zip'=>'application/x-zip-compressed' ); foreach ($map as $key=>$val) if (preg_match('/'.$key.'/',strtolower($ext[0]))) return $val; } return 'application/octet-stream'; }
php
function mime($file) { if (preg_match('/\w+$/',$file,$ext)) { $map=array( 'au'=>'audio/basic', 'avi'=>'video/avi', 'bmp'=>'image/bmp', 'bz2'=>'application/x-bzip2', 'css'=>'text/css', 'dtd'=>'application/xml-dtd', 'doc'=>'application/msword', 'gif'=>'image/gif', 'gz'=>'application/x-gzip', 'hqx'=>'application/mac-binhex40', 'html?'=>'text/html', 'jar'=>'application/java-archive', 'jpe?g'=>'image/jpeg', 'js'=>'application/x-javascript', 'midi'=>'audio/x-midi', 'mp3'=>'audio/mpeg', 'mpe?g'=>'video/mpeg', 'ogg'=>'audio/vorbis', 'pdf'=>'application/pdf', 'png'=>'image/png', 'ppt'=>'application/vnd.ms-powerpoint', 'ps'=>'application/postscript', 'qt'=>'video/quicktime', 'ram?'=>'audio/x-pn-realaudio', 'rdf'=>'application/rdf', 'rtf'=>'application/rtf', 'sgml?'=>'text/sgml', 'sit'=>'application/x-stuffit', 'svg'=>'image/svg+xml', 'swf'=>'application/x-shockwave-flash', 'tgz'=>'application/x-tar', 'tiff'=>'image/tiff', 'txt'=>'text/plain', 'wav'=>'audio/wav', 'xls'=>'application/vnd.ms-excel', 'xml'=>'application/xml', 'zip'=>'application/x-zip-compressed' ); foreach ($map as $key=>$val) if (preg_match('/'.$key.'/',strtolower($ext[0]))) return $val; } return 'application/octet-stream'; }
[ "function", "mime", "(", "$", "file", ")", "{", "if", "(", "preg_match", "(", "'/\\w+$/'", ",", "$", "file", ",", "$", "ext", ")", ")", "{", "$", "map", "=", "array", "(", "'au'", "=>", "'audio/basic'", ",", "'avi'", "=>", "'video/avi'", ",", "'bmp'", "=>", "'image/bmp'", ",", "'bz2'", "=>", "'application/x-bzip2'", ",", "'css'", "=>", "'text/css'", ",", "'dtd'", "=>", "'application/xml-dtd'", ",", "'doc'", "=>", "'application/msword'", ",", "'gif'", "=>", "'image/gif'", ",", "'gz'", "=>", "'application/x-gzip'", ",", "'hqx'", "=>", "'application/mac-binhex40'", ",", "'html?'", "=>", "'text/html'", ",", "'jar'", "=>", "'application/java-archive'", ",", "'jpe?g'", "=>", "'image/jpeg'", ",", "'js'", "=>", "'application/x-javascript'", ",", "'midi'", "=>", "'audio/x-midi'", ",", "'mp3'", "=>", "'audio/mpeg'", ",", "'mpe?g'", "=>", "'video/mpeg'", ",", "'ogg'", "=>", "'audio/vorbis'", ",", "'pdf'", "=>", "'application/pdf'", ",", "'png'", "=>", "'image/png'", ",", "'ppt'", "=>", "'application/vnd.ms-powerpoint'", ",", "'ps'", "=>", "'application/postscript'", ",", "'qt'", "=>", "'video/quicktime'", ",", "'ram?'", "=>", "'audio/x-pn-realaudio'", ",", "'rdf'", "=>", "'application/rdf'", ",", "'rtf'", "=>", "'application/rtf'", ",", "'sgml?'", "=>", "'text/sgml'", ",", "'sit'", "=>", "'application/x-stuffit'", ",", "'svg'", "=>", "'image/svg+xml'", ",", "'swf'", "=>", "'application/x-shockwave-flash'", ",", "'tgz'", "=>", "'application/x-tar'", ",", "'tiff'", "=>", "'image/tiff'", ",", "'txt'", "=>", "'text/plain'", ",", "'wav'", "=>", "'audio/wav'", ",", "'xls'", "=>", "'application/vnd.ms-excel'", ",", "'xml'", "=>", "'application/xml'", ",", "'zip'", "=>", "'application/x-zip-compressed'", ")", ";", "foreach", "(", "$", "map", "as", "$", "key", "=>", "$", "val", ")", "if", "(", "preg_match", "(", "'/'", ".", "$", "key", ".", "'/'", ",", "strtolower", "(", "$", "ext", "[", "0", "]", ")", ")", ")", "return", "$", "val", ";", "}", "return", "'application/octet-stream'", ";", "}" ]
Detect MIME type using file extension @return string @param $file string
[ "Detect", "MIME", "type", "using", "file", "extension" ]
f58ec75a3116d1a572782256e2b38bb9aab95e3c
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Web.php#L26-L72
23,668
bariew/yii2-i18n-cms-module
controllers/MessageController.php
MessageController.actionIndex
public function actionIndex() { $searchModel = new MessageSearch; $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); return $this->render('index', compact('dataProvider', 'searchModel')); }
php
public function actionIndex() { $searchModel = new MessageSearch; $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); return $this->render('index', compact('dataProvider', 'searchModel')); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "searchModel", "=", "new", "MessageSearch", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", "request", "->", "getQueryParams", "(", ")", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "compact", "(", "'dataProvider'", ",", "'searchModel'", ")", ")", ";", "}" ]
Lists all Message models. @return mixed
[ "Lists", "all", "Message", "models", "." ]
18d2394565cdd8b5070a287a739c9007705ef18a
https://github.com/bariew/yii2-i18n-cms-module/blob/18d2394565cdd8b5070a287a739c9007705ef18a/controllers/MessageController.php#L29-L34
23,669
bariew/yii2-i18n-cms-module
controllers/MessageController.php
MessageController.actionFastUpdate
public function actionFastUpdate($id) { Message::updateAll( ['translation' => Yii::$app->request->post('translation')], ['id' => $id, 'language' => Yii::$app->request->post('language')] ); }
php
public function actionFastUpdate($id) { Message::updateAll( ['translation' => Yii::$app->request->post('translation')], ['id' => $id, 'language' => Yii::$app->request->post('language')] ); }
[ "public", "function", "actionFastUpdate", "(", "$", "id", ")", "{", "Message", "::", "updateAll", "(", "[", "'translation'", "=>", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'translation'", ")", "]", ",", "[", "'id'", "=>", "$", "id", ",", "'language'", "=>", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'language'", ")", "]", ")", ";", "}" ]
Fast translation update. @param int $id @return string
[ "Fast", "translation", "update", "." ]
18d2394565cdd8b5070a287a739c9007705ef18a
https://github.com/bariew/yii2-i18n-cms-module/blob/18d2394565cdd8b5070a287a739c9007705ef18a/controllers/MessageController.php#L42-L48
23,670
thienhungho/yii2-product-management
src/modules/ProductManageForCustomer/controllers/ProductController.php
ProductController.findModel
protected function findModel($id) { if (($model = Product::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(t('app', 'The requested page does not exist.')); } }
php
protected function findModel($id) { if (($model = Product::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(t('app', 'The requested page does not exist.')); } }
[ "protected", "function", "findModel", "(", "$", "id", ")", "{", "if", "(", "(", "$", "model", "=", "Product", "::", "findOne", "(", "$", "id", ")", ")", "!==", "null", ")", "{", "return", "$", "model", ";", "}", "else", "{", "throw", "new", "NotFoundHttpException", "(", "t", "(", "'app'", ",", "'The requested page does not exist.'", ")", ")", ";", "}", "}" ]
Finds the Product model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param integer $id @return Product the loaded model @throws NotFoundHttpException if the model cannot be found
[ "Finds", "the", "Product", "model", "based", "on", "its", "primary", "key", "value", ".", "If", "the", "model", "is", "not", "found", "a", "404", "HTTP", "exception", "will", "be", "thrown", "." ]
72e1237bba123faf671e44491bd93077b50adde9
https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManageForCustomer/controllers/ProductController.php#L155-L162
23,671
mothership-ec/composer
src/Composer/Repository/Pear/BaseChannelReader.php
BaseChannelReader.requestXml
protected function requestXml($origin, $path) { // http://components.ez.no/p/packages.xml is malformed. to read it we must ignore parsing errors. $xml = simplexml_load_string($this->requestContent($origin, $path), "SimpleXMLElement", LIBXML_NOERROR); if (false == $xml) { $url = rtrim($origin, '/') . '/' . ltrim($path, '/'); throw new \UnexpectedValueException(sprintf('The PEAR channel at ' . $origin . ' is broken. (Invalid XML at file `%s`)', $path)); } return $xml; }
php
protected function requestXml($origin, $path) { // http://components.ez.no/p/packages.xml is malformed. to read it we must ignore parsing errors. $xml = simplexml_load_string($this->requestContent($origin, $path), "SimpleXMLElement", LIBXML_NOERROR); if (false == $xml) { $url = rtrim($origin, '/') . '/' . ltrim($path, '/'); throw new \UnexpectedValueException(sprintf('The PEAR channel at ' . $origin . ' is broken. (Invalid XML at file `%s`)', $path)); } return $xml; }
[ "protected", "function", "requestXml", "(", "$", "origin", ",", "$", "path", ")", "{", "// http://components.ez.no/p/packages.xml is malformed. to read it we must ignore parsing errors.", "$", "xml", "=", "simplexml_load_string", "(", "$", "this", "->", "requestContent", "(", "$", "origin", ",", "$", "path", ")", ",", "\"SimpleXMLElement\"", ",", "LIBXML_NOERROR", ")", ";", "if", "(", "false", "==", "$", "xml", ")", "{", "$", "url", "=", "rtrim", "(", "$", "origin", ",", "'/'", ")", ".", "'/'", ".", "ltrim", "(", "$", "path", ",", "'/'", ")", ";", "throw", "new", "\\", "UnexpectedValueException", "(", "sprintf", "(", "'The PEAR channel at '", ".", "$", "origin", ".", "' is broken. (Invalid XML at file `%s`)'", ",", "$", "path", ")", ")", ";", "}", "return", "$", "xml", ";", "}" ]
Read xml content from remote filesystem @param $origin string server @param $path string relative path to content @throws \UnexpectedValueException @return \SimpleXMLElement
[ "Read", "xml", "content", "from", "remote", "filesystem" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/Pear/BaseChannelReader.php#L71-L82
23,672
ezsystems/ezcomments-ls-extension
classes/ezcomformtool.php
ezcomFormTool.checkVars
public function checkVars() { $http = eZHTTPTool::instance(); $user = eZUser::currentUser(); $isAnon = $user->isAnonymous(); $status = true; foreach ( $this->fields as $field => $fieldSetup ) { $fieldPostName = $fieldSetup[self::VARNAME]; $this->setFieldValue( $field, $fieldPostName ); if( !$this->isVariableRequired( $field ) ) { continue; } else { $fieldRequired = $fieldSetup[self::REQUIRED] == 'true' ? true : false; $fieldExists = $http->hasPostVariable( $fieldPostName ); if ( $fieldRequired && !$fieldExists ) { $status = false; $this->validationMessage[$field] = ezpI18n::tr( 'ezcomments/comment/add', '%1 is missing.', null, array( $field ) ); continue; } else if ( $fieldExists ) { $val = $http->postVariable( $fieldPostName ); // only check the empty value when the field is required. In other cases, still validate field if it has value if ( $fieldRequired && empty( $val ) ) { $status = false; $this->validationMessage[$field] = ezpI18n::tr( 'ezcomments/comment/add', 'The field [%1] is empty.', null, array( $field ) ); continue; } else { $validationResult = $this->validateField( $field, $val ); if ( $validationResult !== true ) { $status = false; $this->validationMessage[$field] = $validationResult; continue; } } } } } $this->validationStatus = $status; return $status; }
php
public function checkVars() { $http = eZHTTPTool::instance(); $user = eZUser::currentUser(); $isAnon = $user->isAnonymous(); $status = true; foreach ( $this->fields as $field => $fieldSetup ) { $fieldPostName = $fieldSetup[self::VARNAME]; $this->setFieldValue( $field, $fieldPostName ); if( !$this->isVariableRequired( $field ) ) { continue; } else { $fieldRequired = $fieldSetup[self::REQUIRED] == 'true' ? true : false; $fieldExists = $http->hasPostVariable( $fieldPostName ); if ( $fieldRequired && !$fieldExists ) { $status = false; $this->validationMessage[$field] = ezpI18n::tr( 'ezcomments/comment/add', '%1 is missing.', null, array( $field ) ); continue; } else if ( $fieldExists ) { $val = $http->postVariable( $fieldPostName ); // only check the empty value when the field is required. In other cases, still validate field if it has value if ( $fieldRequired && empty( $val ) ) { $status = false; $this->validationMessage[$field] = ezpI18n::tr( 'ezcomments/comment/add', 'The field [%1] is empty.', null, array( $field ) ); continue; } else { $validationResult = $this->validateField( $field, $val ); if ( $validationResult !== true ) { $status = false; $this->validationMessage[$field] = $validationResult; continue; } } } } } $this->validationStatus = $status; return $status; }
[ "public", "function", "checkVars", "(", ")", "{", "$", "http", "=", "eZHTTPTool", "::", "instance", "(", ")", ";", "$", "user", "=", "eZUser", "::", "currentUser", "(", ")", ";", "$", "isAnon", "=", "$", "user", "->", "isAnonymous", "(", ")", ";", "$", "status", "=", "true", ";", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field", "=>", "$", "fieldSetup", ")", "{", "$", "fieldPostName", "=", "$", "fieldSetup", "[", "self", "::", "VARNAME", "]", ";", "$", "this", "->", "setFieldValue", "(", "$", "field", ",", "$", "fieldPostName", ")", ";", "if", "(", "!", "$", "this", "->", "isVariableRequired", "(", "$", "field", ")", ")", "{", "continue", ";", "}", "else", "{", "$", "fieldRequired", "=", "$", "fieldSetup", "[", "self", "::", "REQUIRED", "]", "==", "'true'", "?", "true", ":", "false", ";", "$", "fieldExists", "=", "$", "http", "->", "hasPostVariable", "(", "$", "fieldPostName", ")", ";", "if", "(", "$", "fieldRequired", "&&", "!", "$", "fieldExists", ")", "{", "$", "status", "=", "false", ";", "$", "this", "->", "validationMessage", "[", "$", "field", "]", "=", "ezpI18n", "::", "tr", "(", "'ezcomments/comment/add'", ",", "'%1 is missing.'", ",", "null", ",", "array", "(", "$", "field", ")", ")", ";", "continue", ";", "}", "else", "if", "(", "$", "fieldExists", ")", "{", "$", "val", "=", "$", "http", "->", "postVariable", "(", "$", "fieldPostName", ")", ";", "// only check the empty value when the field is required. In other cases, still validate field if it has value", "if", "(", "$", "fieldRequired", "&&", "empty", "(", "$", "val", ")", ")", "{", "$", "status", "=", "false", ";", "$", "this", "->", "validationMessage", "[", "$", "field", "]", "=", "ezpI18n", "::", "tr", "(", "'ezcomments/comment/add'", ",", "'The field [%1] is empty.'", ",", "null", ",", "array", "(", "$", "field", ")", ")", ";", "continue", ";", "}", "else", "{", "$", "validationResult", "=", "$", "this", "->", "validateField", "(", "$", "field", ",", "$", "val", ")", ";", "if", "(", "$", "validationResult", "!==", "true", ")", "{", "$", "status", "=", "false", ";", "$", "this", "->", "validationMessage", "[", "$", "field", "]", "=", "$", "validationResult", ";", "continue", ";", "}", "}", "}", "}", "}", "$", "this", "->", "validationStatus", "=", "$", "status", ";", "return", "$", "status", ";", "}" ]
check variable from client
[ "check", "variable", "from", "client" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomformtool.php#L73-L130
23,673
ezsystems/ezcomments-ls-extension
classes/ezcomformtool.php
ezcomFormTool.fillObject
public function fillObject( $comment, $fieldNames = null ) { $filledFields = $this->fields; if ( !is_null( $fieldNames ) && is_array( $fieldNames ) ) { $filledFields = array(); foreach ( $fieldNames as $fieldName ) { $filledFields[$fieldName] = $this->fields[$fieldName]; } } foreach ( $filledFields as $field => $fieldSetup ) { $attributeName = $fieldSetup[self::ATTRIBUTENAME]; if ( !is_null( $attributeName ) ) { $fieldValue = $this->fieldValues[$field]; $comment->setAttribute( $attributeName, $fieldValue ); } } }
php
public function fillObject( $comment, $fieldNames = null ) { $filledFields = $this->fields; if ( !is_null( $fieldNames ) && is_array( $fieldNames ) ) { $filledFields = array(); foreach ( $fieldNames as $fieldName ) { $filledFields[$fieldName] = $this->fields[$fieldName]; } } foreach ( $filledFields as $field => $fieldSetup ) { $attributeName = $fieldSetup[self::ATTRIBUTENAME]; if ( !is_null( $attributeName ) ) { $fieldValue = $this->fieldValues[$field]; $comment->setAttribute( $attributeName, $fieldValue ); } } }
[ "public", "function", "fillObject", "(", "$", "comment", ",", "$", "fieldNames", "=", "null", ")", "{", "$", "filledFields", "=", "$", "this", "->", "fields", ";", "if", "(", "!", "is_null", "(", "$", "fieldNames", ")", "&&", "is_array", "(", "$", "fieldNames", ")", ")", "{", "$", "filledFields", "=", "array", "(", ")", ";", "foreach", "(", "$", "fieldNames", "as", "$", "fieldName", ")", "{", "$", "filledFields", "[", "$", "fieldName", "]", "=", "$", "this", "->", "fields", "[", "$", "fieldName", "]", ";", "}", "}", "foreach", "(", "$", "filledFields", "as", "$", "field", "=>", "$", "fieldSetup", ")", "{", "$", "attributeName", "=", "$", "fieldSetup", "[", "self", "::", "ATTRIBUTENAME", "]", ";", "if", "(", "!", "is_null", "(", "$", "attributeName", ")", ")", "{", "$", "fieldValue", "=", "$", "this", "->", "fieldValues", "[", "$", "field", "]", ";", "$", "comment", "->", "setAttribute", "(", "$", "attributeName", ",", "$", "fieldValue", ")", ";", "}", "}", "}" ]
Fill field to comment object @param $comment ezcomcomment persistent object @param $fieldNames field name array selected to be filled into comment @return
[ "Fill", "field", "to", "comment", "object" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomformtool.php#L138-L158
23,674
martin-helmich/flow-eventbroker
Classes/Helmich/EventBroker/Broker/EventMapping.php
EventMapping.addListenerForEvent
public function addListenerForEvent($eventClassName, $listener) { if (FALSE === array_key_exists($eventClassName, $this->eventMap)) { $this->eventMap[$eventClassName] = []; } $this->eventMap[$eventClassName][] = $listener; }
php
public function addListenerForEvent($eventClassName, $listener) { if (FALSE === array_key_exists($eventClassName, $this->eventMap)) { $this->eventMap[$eventClassName] = []; } $this->eventMap[$eventClassName][] = $listener; }
[ "public", "function", "addListenerForEvent", "(", "$", "eventClassName", ",", "$", "listener", ")", "{", "if", "(", "FALSE", "===", "array_key_exists", "(", "$", "eventClassName", ",", "$", "this", "->", "eventMap", ")", ")", "{", "$", "this", "->", "eventMap", "[", "$", "eventClassName", "]", "=", "[", "]", ";", "}", "$", "this", "->", "eventMap", "[", "$", "eventClassName", "]", "[", "]", "=", "$", "listener", ";", "}" ]
Adds a new listener for an event. @param string $eventClassName The event class name. @param callable $listener Any kind of callable. @return void
[ "Adds", "a", "new", "listener", "for", "an", "event", "." ]
a08dc966cfddbee4f8ea75d1c682320ac196352d
https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/EventMapping.php#L46-L53
23,675
martin-helmich/flow-eventbroker
Classes/Helmich/EventBroker/Broker/EventMapping.php
EventMapping.getListenersForEvent
public function getListenersForEvent($eventClassName) { if (FALSE === array_key_exists($eventClassName, $this->eventMap)) { return []; } return $this->eventMap[$eventClassName]; }
php
public function getListenersForEvent($eventClassName) { if (FALSE === array_key_exists($eventClassName, $this->eventMap)) { return []; } return $this->eventMap[$eventClassName]; }
[ "public", "function", "getListenersForEvent", "(", "$", "eventClassName", ")", "{", "if", "(", "FALSE", "===", "array_key_exists", "(", "$", "eventClassName", ",", "$", "this", "->", "eventMap", ")", ")", "{", "return", "[", "]", ";", "}", "return", "$", "this", "->", "eventMap", "[", "$", "eventClassName", "]", ";", "}" ]
Gets all listeners for an event. @param string $eventClassName The event class name. @return array An array of callables.
[ "Gets", "all", "listeners", "for", "an", "event", "." ]
a08dc966cfddbee4f8ea75d1c682320ac196352d
https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/EventMapping.php#L63-L70
23,676
jasny/controller
src/Controller/View.php
View.view
public function view($name, array $context = []) { $context += ['current_url' => $this->getRequest()->getUri()]; if (method_exists($this, 'flash')) { $context += ['flash' => $this->flash()]; } $response = $this->getViewer()->render($this->getResponse(), $name, $context); $this->setResponse($response); }
php
public function view($name, array $context = []) { $context += ['current_url' => $this->getRequest()->getUri()]; if (method_exists($this, 'flash')) { $context += ['flash' => $this->flash()]; } $response = $this->getViewer()->render($this->getResponse(), $name, $context); $this->setResponse($response); }
[ "public", "function", "view", "(", "$", "name", ",", "array", "$", "context", "=", "[", "]", ")", "{", "$", "context", "+=", "[", "'current_url'", "=>", "$", "this", "->", "getRequest", "(", ")", "->", "getUri", "(", ")", "]", ";", "if", "(", "method_exists", "(", "$", "this", ",", "'flash'", ")", ")", "{", "$", "context", "+=", "[", "'flash'", "=>", "$", "this", "->", "flash", "(", ")", "]", ";", "}", "$", "response", "=", "$", "this", "->", "getViewer", "(", ")", "->", "render", "(", "$", "this", "->", "getResponse", "(", ")", ",", "$", "name", ",", "$", "context", ")", ";", "$", "this", "->", "setResponse", "(", "$", "response", ")", ";", "}" ]
View rendered template @param string $name Template name @param array $context Template context
[ "View", "rendered", "template" ]
28edf64343f1d8218c166c0c570128e1ee6153d8
https://github.com/jasny/controller/blob/28edf64343f1d8218c166c0c570128e1ee6153d8/src/Controller/View.php#L83-L94
23,677
romainbessugesmeusy/php-datagrid
library/RBM/Datagrid/Data/Processor/ResultRow.php
ResultRow.getCellDataForColumnName
public function getCellDataForColumnName($columnName) { return Extractor::extract( $this->_data, $this->_dataGrid->getColumn($columnName)->getCellAccessor() ); }
php
public function getCellDataForColumnName($columnName) { return Extractor::extract( $this->_data, $this->_dataGrid->getColumn($columnName)->getCellAccessor() ); }
[ "public", "function", "getCellDataForColumnName", "(", "$", "columnName", ")", "{", "return", "Extractor", "::", "extract", "(", "$", "this", "->", "_data", ",", "$", "this", "->", "_dataGrid", "->", "getColumn", "(", "$", "columnName", ")", "->", "getCellAccessor", "(", ")", ")", ";", "}" ]
Get the cell accessor from the DataGridColumn and extract the data from the row @param $columnName @return mixed
[ "Get", "the", "cell", "accessor", "from", "the", "DataGridColumn", "and", "extract", "the", "data", "from", "the", "row" ]
18f7ae15845fcf61520bbfc946771242bf1091c9
https://github.com/romainbessugesmeusy/php-datagrid/blob/18f7ae15845fcf61520bbfc946771242bf1091c9/library/RBM/Datagrid/Data/Processor/ResultRow.php#L71-L77
23,678
dotkernel/dot-rbac
src/Role/RoleService.php
RoleService.matchIdentityRoles
public function matchIdentityRoles(array $roles): bool { $identityRoles = $this->getIdentityRoles(); // Too easy... if (empty($identityRoles)) { return false; } $roleNames = []; foreach ($roles as $role) { $roleNames[] = $role instanceof RoleInterface ? $role->getName() : (string)$role; } $identityRoleNames = []; foreach ($this->flattenRoles($identityRoles) as $role) { $identityRoleNames[] = $role->getName(); } return count(array_intersect($roleNames, $identityRoleNames)) > 0; }
php
public function matchIdentityRoles(array $roles): bool { $identityRoles = $this->getIdentityRoles(); // Too easy... if (empty($identityRoles)) { return false; } $roleNames = []; foreach ($roles as $role) { $roleNames[] = $role instanceof RoleInterface ? $role->getName() : (string)$role; } $identityRoleNames = []; foreach ($this->flattenRoles($identityRoles) as $role) { $identityRoleNames[] = $role->getName(); } return count(array_intersect($roleNames, $identityRoleNames)) > 0; }
[ "public", "function", "matchIdentityRoles", "(", "array", "$", "roles", ")", ":", "bool", "{", "$", "identityRoles", "=", "$", "this", "->", "getIdentityRoles", "(", ")", ";", "// Too easy...", "if", "(", "empty", "(", "$", "identityRoles", ")", ")", "{", "return", "false", ";", "}", "$", "roleNames", "=", "[", "]", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "$", "roleNames", "[", "]", "=", "$", "role", "instanceof", "RoleInterface", "?", "$", "role", "->", "getName", "(", ")", ":", "(", "string", ")", "$", "role", ";", "}", "$", "identityRoleNames", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "flattenRoles", "(", "$", "identityRoles", ")", "as", "$", "role", ")", "{", "$", "identityRoleNames", "[", "]", "=", "$", "role", "->", "getName", "(", ")", ";", "}", "return", "count", "(", "array_intersect", "(", "$", "roleNames", ",", "$", "identityRoleNames", ")", ")", ">", "0", ";", "}" ]
Check if the given roles match one of the identity roles This method is smart enough to automatically recursively extracts roles for hierarchical roles @param string[]|RoleInterface[] $roles @return bool
[ "Check", "if", "the", "given", "roles", "match", "one", "of", "the", "identity", "roles" ]
747ffadf3cf28750bb7cf81be60eb4c93b830446
https://github.com/dotkernel/dot-rbac/blob/747ffadf3cf28750bb7cf81be60eb4c93b830446/src/Role/RoleService.php#L92-L110
23,679
nabab/bbn
src/bbn/appui/project.php
project.get_root_path
public function get_root_path($repository){ if ( \is_string($repository) ){ $repository = $this->repository($repository); } if ( !empty($repository) && !empty($repository['bbn_path']) ){ $repository_path = !empty($repository['path']) ? '/' . $repository['path'] : ''; $path = self::decipher_path($repository['bbn_path'] . $repository_path) . '/'; return \bbn\str::parse_path($path); } return false; }
php
public function get_root_path($repository){ if ( \is_string($repository) ){ $repository = $this->repository($repository); } if ( !empty($repository) && !empty($repository['bbn_path']) ){ $repository_path = !empty($repository['path']) ? '/' . $repository['path'] : ''; $path = self::decipher_path($repository['bbn_path'] . $repository_path) . '/'; return \bbn\str::parse_path($path); } return false; }
[ "public", "function", "get_root_path", "(", "$", "repository", ")", "{", "if", "(", "\\", "is_string", "(", "$", "repository", ")", ")", "{", "$", "repository", "=", "$", "this", "->", "repository", "(", "$", "repository", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "repository", ")", "&&", "!", "empty", "(", "$", "repository", "[", "'bbn_path'", "]", ")", ")", "{", "$", "repository_path", "=", "!", "empty", "(", "$", "repository", "[", "'path'", "]", ")", "?", "'/'", ".", "$", "repository", "[", "'path'", "]", ":", "''", ";", "$", "path", "=", "self", "::", "decipher_path", "(", "$", "repository", "[", "'bbn_path'", "]", ".", "$", "repository_path", ")", ".", "'/'", ";", "return", "\\", "bbn", "\\", "str", "::", "parse_path", "(", "$", "path", ")", ";", "}", "return", "false", ";", "}" ]
Gets the real root path from a repository's id as recorded in the options. @param string|array $repository The repository's name (code) or the repository's configuration @return bool|string
[ "Gets", "the", "real", "root", "path", "from", "a", "repository", "s", "id", "as", "recorded", "in", "the", "options", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/project.php#L226-L236
23,680
nabab/bbn
src/bbn/appui/project.php
project.repositories
public function repositories(string $code=''){ $all = $this->options->full_soptions($this->options->from_code('PATHS', 'ide', 'appui')); $cats = []; $r = []; foreach ( $all as $a ){ if ( \defined($a['bbn_path']) ){ $k = $a['bbn_path'] . '/' . ($a['code'] === '/' ? '' : $a['code']); if ( !isset($cats[$a['id_alias']]) ){ unset($a['alias']['cfg']); $cats[$a['id_alias']] = $a['alias']; } unset($a['cfg']); unset($a['alias']); $r[$k] = $a; $r[$k]['title'] = $r[$k]['text']; $r[$k]['alias_code'] = $cats[$a['id_alias']]['code']; if ( !empty($cats[$a['id_alias']]['tabs']) ){ $r[$k]['tabs'] = $cats[$a['id_alias']]['tabs']; } else if( !empty($cats[$a['id_alias']]['extensions']) ){ $r[$k]['extensions'] = $cats[$a['id_alias']]['extensions']; } unset($r[$k]['alias']); } } if ( $code ){ return isset($r[$code]) ? $r[$code] : false; } return $r; }
php
public function repositories(string $code=''){ $all = $this->options->full_soptions($this->options->from_code('PATHS', 'ide', 'appui')); $cats = []; $r = []; foreach ( $all as $a ){ if ( \defined($a['bbn_path']) ){ $k = $a['bbn_path'] . '/' . ($a['code'] === '/' ? '' : $a['code']); if ( !isset($cats[$a['id_alias']]) ){ unset($a['alias']['cfg']); $cats[$a['id_alias']] = $a['alias']; } unset($a['cfg']); unset($a['alias']); $r[$k] = $a; $r[$k]['title'] = $r[$k]['text']; $r[$k]['alias_code'] = $cats[$a['id_alias']]['code']; if ( !empty($cats[$a['id_alias']]['tabs']) ){ $r[$k]['tabs'] = $cats[$a['id_alias']]['tabs']; } else if( !empty($cats[$a['id_alias']]['extensions']) ){ $r[$k]['extensions'] = $cats[$a['id_alias']]['extensions']; } unset($r[$k]['alias']); } } if ( $code ){ return isset($r[$code]) ? $r[$code] : false; } return $r; }
[ "public", "function", "repositories", "(", "string", "$", "code", "=", "''", ")", "{", "$", "all", "=", "$", "this", "->", "options", "->", "full_soptions", "(", "$", "this", "->", "options", "->", "from_code", "(", "'PATHS'", ",", "'ide'", ",", "'appui'", ")", ")", ";", "$", "cats", "=", "[", "]", ";", "$", "r", "=", "[", "]", ";", "foreach", "(", "$", "all", "as", "$", "a", ")", "{", "if", "(", "\\", "defined", "(", "$", "a", "[", "'bbn_path'", "]", ")", ")", "{", "$", "k", "=", "$", "a", "[", "'bbn_path'", "]", ".", "'/'", ".", "(", "$", "a", "[", "'code'", "]", "===", "'/'", "?", "''", ":", "$", "a", "[", "'code'", "]", ")", ";", "if", "(", "!", "isset", "(", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", ")", ")", "{", "unset", "(", "$", "a", "[", "'alias'", "]", "[", "'cfg'", "]", ")", ";", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "=", "$", "a", "[", "'alias'", "]", ";", "}", "unset", "(", "$", "a", "[", "'cfg'", "]", ")", ";", "unset", "(", "$", "a", "[", "'alias'", "]", ")", ";", "$", "r", "[", "$", "k", "]", "=", "$", "a", ";", "$", "r", "[", "$", "k", "]", "[", "'title'", "]", "=", "$", "r", "[", "$", "k", "]", "[", "'text'", "]", ";", "$", "r", "[", "$", "k", "]", "[", "'alias_code'", "]", "=", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "[", "'code'", "]", ";", "if", "(", "!", "empty", "(", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "[", "'tabs'", "]", ")", ")", "{", "$", "r", "[", "$", "k", "]", "[", "'tabs'", "]", "=", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "[", "'tabs'", "]", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "[", "'extensions'", "]", ")", ")", "{", "$", "r", "[", "$", "k", "]", "[", "'extensions'", "]", "=", "$", "cats", "[", "$", "a", "[", "'id_alias'", "]", "]", "[", "'extensions'", "]", ";", "}", "unset", "(", "$", "r", "[", "$", "k", "]", "[", "'alias'", "]", ")", ";", "}", "}", "if", "(", "$", "code", ")", "{", "return", "isset", "(", "$", "r", "[", "$", "code", "]", ")", "?", "$", "r", "[", "$", "code", "]", ":", "false", ";", "}", "return", "$", "r", ";", "}" ]
Makes the repositories' configurations. @param string $code The repository's name (code) @return array|bool
[ "Makes", "the", "repositories", "configurations", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/project.php#L254-L283
23,681
nabab/bbn
src/bbn/appui/project.php
project.repository_from_url
public function repository_from_url(string $url, bool $obj = false){ $repository = ''; $repositories = $this->repositories(); foreach ( $repositories as $i => $d ){ if ( (strpos($url, $i) === 0) && (\strlen($i) > \strlen($repository) ) ){ $repository = $i; } } if ( !empty($repository) ){ return empty($obj) ? $repository : $repositories[$repository]; } return false; }
php
public function repository_from_url(string $url, bool $obj = false){ $repository = ''; $repositories = $this->repositories(); foreach ( $repositories as $i => $d ){ if ( (strpos($url, $i) === 0) && (\strlen($i) > \strlen($repository) ) ){ $repository = $i; } } if ( !empty($repository) ){ return empty($obj) ? $repository : $repositories[$repository]; } return false; }
[ "public", "function", "repository_from_url", "(", "string", "$", "url", ",", "bool", "$", "obj", "=", "false", ")", "{", "$", "repository", "=", "''", ";", "$", "repositories", "=", "$", "this", "->", "repositories", "(", ")", ";", "foreach", "(", "$", "repositories", "as", "$", "i", "=>", "$", "d", ")", "{", "if", "(", "(", "strpos", "(", "$", "url", ",", "$", "i", ")", "===", "0", ")", "&&", "(", "\\", "strlen", "(", "$", "i", ")", ">", "\\", "strlen", "(", "$", "repository", ")", ")", ")", "{", "$", "repository", "=", "$", "i", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "repository", ")", ")", "{", "return", "empty", "(", "$", "obj", ")", "?", "$", "repository", ":", "$", "repositories", "[", "$", "repository", "]", ";", "}", "return", "false", ";", "}" ]
Returns the repository's name or object from an URL. @param string $url @param bool $obj @return bool|int|string
[ "Returns", "the", "repository", "s", "name", "or", "object", "from", "an", "URL", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/project.php#L292-L307
23,682
nabab/bbn
src/bbn/appui/project.php
project.real_to_url
public function real_to_url(string $file){ foreach ( $this->repositories() as $i => $d ){ if ( // Repository's root path ($root = $this->get_root_path($d)) && (strpos($file, $root) === 0) ){ $res = $i; $bits = explode('/', substr($file, \strlen($root))); // MVC if ( !empty($d['tabs']) ){ $tab_path = array_shift($bits); $fn = array_pop($bits); $ext = \bbn\str::file_ext($fn); $fn = \bbn\str::file_ext($fn, 1)[0]; $res .= implode('/', $bits); foreach ( $d['tabs'] as $k => $t ){ if ( empty($t['fixed']) && ($t['path'] === $tab_path . '/') ){ $res .= "/$fn/$t[url]"; break; } } } // Normal file else { $res .= implode('/', $bits); } return \bbn\str::parse_path($res); } } return false; }
php
public function real_to_url(string $file){ foreach ( $this->repositories() as $i => $d ){ if ( // Repository's root path ($root = $this->get_root_path($d)) && (strpos($file, $root) === 0) ){ $res = $i; $bits = explode('/', substr($file, \strlen($root))); // MVC if ( !empty($d['tabs']) ){ $tab_path = array_shift($bits); $fn = array_pop($bits); $ext = \bbn\str::file_ext($fn); $fn = \bbn\str::file_ext($fn, 1)[0]; $res .= implode('/', $bits); foreach ( $d['tabs'] as $k => $t ){ if ( empty($t['fixed']) && ($t['path'] === $tab_path . '/') ){ $res .= "/$fn/$t[url]"; break; } } } // Normal file else { $res .= implode('/', $bits); } return \bbn\str::parse_path($res); } } return false; }
[ "public", "function", "real_to_url", "(", "string", "$", "file", ")", "{", "foreach", "(", "$", "this", "->", "repositories", "(", ")", "as", "$", "i", "=>", "$", "d", ")", "{", "if", "(", "// Repository's root path", "(", "$", "root", "=", "$", "this", "->", "get_root_path", "(", "$", "d", ")", ")", "&&", "(", "strpos", "(", "$", "file", ",", "$", "root", ")", "===", "0", ")", ")", "{", "$", "res", "=", "$", "i", ";", "$", "bits", "=", "explode", "(", "'/'", ",", "substr", "(", "$", "file", ",", "\\", "strlen", "(", "$", "root", ")", ")", ")", ";", "// MVC", "if", "(", "!", "empty", "(", "$", "d", "[", "'tabs'", "]", ")", ")", "{", "$", "tab_path", "=", "array_shift", "(", "$", "bits", ")", ";", "$", "fn", "=", "array_pop", "(", "$", "bits", ")", ";", "$", "ext", "=", "\\", "bbn", "\\", "str", "::", "file_ext", "(", "$", "fn", ")", ";", "$", "fn", "=", "\\", "bbn", "\\", "str", "::", "file_ext", "(", "$", "fn", ",", "1", ")", "[", "0", "]", ";", "$", "res", ".=", "implode", "(", "'/'", ",", "$", "bits", ")", ";", "foreach", "(", "$", "d", "[", "'tabs'", "]", "as", "$", "k", "=>", "$", "t", ")", "{", "if", "(", "empty", "(", "$", "t", "[", "'fixed'", "]", ")", "&&", "(", "$", "t", "[", "'path'", "]", "===", "$", "tab_path", ".", "'/'", ")", ")", "{", "$", "res", ".=", "\"/$fn/$t[url]\"", ";", "break", ";", "}", "}", "}", "// Normal file", "else", "{", "$", "res", ".=", "implode", "(", "'/'", ",", "$", "bits", ")", ";", "}", "return", "\\", "bbn", "\\", "str", "::", "parse_path", "(", "$", "res", ")", ";", "}", "}", "return", "false", ";", "}" ]
Returns the file's URL from the real file's path. @param string $file The real file's path @return bool|string
[ "Returns", "the", "file", "s", "URL", "from", "the", "real", "file", "s", "path", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/project.php#L315-L352
23,683
bfitech/zapstore
src/RedisConn.php
RedisConn.connection__predis
private function connection__predis() { $args = []; foreach (array_keys($this->verified_params) as $key) { if ($key == 'redistype' || !$this->$key) continue; $args[substr($key, 5)] = $this->$key; } try { $this->connection = new \Predis\Client($args); $this->connection->ping(); return $this->connection_open_ok(); } catch(\Predis\Connection\ConnectionException $e) { return $this->connection_open_fail($e->getMessage()); } }
php
private function connection__predis() { $args = []; foreach (array_keys($this->verified_params) as $key) { if ($key == 'redistype' || !$this->$key) continue; $args[substr($key, 5)] = $this->$key; } try { $this->connection = new \Predis\Client($args); $this->connection->ping(); return $this->connection_open_ok(); } catch(\Predis\Connection\ConnectionException $e) { return $this->connection_open_fail($e->getMessage()); } }
[ "private", "function", "connection__predis", "(", ")", "{", "$", "args", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "verified_params", ")", "as", "$", "key", ")", "{", "if", "(", "$", "key", "==", "'redistype'", "||", "!", "$", "this", "->", "$", "key", ")", "continue", ";", "$", "args", "[", "substr", "(", "$", "key", ",", "5", ")", "]", "=", "$", "this", "->", "$", "key", ";", "}", "try", "{", "$", "this", "->", "connection", "=", "new", "\\", "Predis", "\\", "Client", "(", "$", "args", ")", ";", "$", "this", "->", "connection", "->", "ping", "(", ")", ";", "return", "$", "this", "->", "connection_open_ok", "(", ")", ";", "}", "catch", "(", "\\", "Predis", "\\", "Connection", "\\", "ConnectionException", "$", "e", ")", "{", "return", "$", "this", "->", "connection_open_fail", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Open connection with predis.
[ "Open", "connection", "with", "predis", "." ]
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L111-L125
23,684
bfitech/zapstore
src/RedisConn.php
RedisConn.connection__redis
private function connection__redis() { $this->connection = new \Redis(); # @note: This emits warning on failure instead of throwing # exception, hence the @ sign. if (!@$this->connection->connect( $this->redishost, $this->redisport, $this->redistimeout )) // @codeCoverageIgnoreStart return $this->connection_open_fail(); // @codeCoverageIgnoreEnd if ($this->redispassword || $this->redisdatabase) { try { if ($this->redispassword) $this->connection->auth($this->redispassword); if ($this->redisdatabase) $this->connection->select($this->redisdatabase); } catch(\RedisException $e) { return $this->connection_open_fail($e->getMessage()); } } try { $this->connection->ping(); } catch(\RedisException $e) { return $this->connection_open_fail($e->getMessage()); } return $this->connection_open_ok(); }
php
private function connection__redis() { $this->connection = new \Redis(); # @note: This emits warning on failure instead of throwing # exception, hence the @ sign. if (!@$this->connection->connect( $this->redishost, $this->redisport, $this->redistimeout )) // @codeCoverageIgnoreStart return $this->connection_open_fail(); // @codeCoverageIgnoreEnd if ($this->redispassword || $this->redisdatabase) { try { if ($this->redispassword) $this->connection->auth($this->redispassword); if ($this->redisdatabase) $this->connection->select($this->redisdatabase); } catch(\RedisException $e) { return $this->connection_open_fail($e->getMessage()); } } try { $this->connection->ping(); } catch(\RedisException $e) { return $this->connection_open_fail($e->getMessage()); } return $this->connection_open_ok(); }
[ "private", "function", "connection__redis", "(", ")", "{", "$", "this", "->", "connection", "=", "new", "\\", "Redis", "(", ")", ";", "# @note: This emits warning on failure instead of throwing", "# exception, hence the @ sign.", "if", "(", "!", "@", "$", "this", "->", "connection", "->", "connect", "(", "$", "this", "->", "redishost", ",", "$", "this", "->", "redisport", ",", "$", "this", "->", "redistimeout", ")", ")", "// @codeCoverageIgnoreStart", "return", "$", "this", "->", "connection_open_fail", "(", ")", ";", "// @codeCoverageIgnoreEnd", "if", "(", "$", "this", "->", "redispassword", "||", "$", "this", "->", "redisdatabase", ")", "{", "try", "{", "if", "(", "$", "this", "->", "redispassword", ")", "$", "this", "->", "connection", "->", "auth", "(", "$", "this", "->", "redispassword", ")", ";", "if", "(", "$", "this", "->", "redisdatabase", ")", "$", "this", "->", "connection", "->", "select", "(", "$", "this", "->", "redisdatabase", ")", ";", "}", "catch", "(", "\\", "RedisException", "$", "e", ")", "{", "return", "$", "this", "->", "connection_open_fail", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "try", "{", "$", "this", "->", "connection", "->", "ping", "(", ")", ";", "}", "catch", "(", "\\", "RedisException", "$", "e", ")", "{", "return", "$", "this", "->", "connection_open_fail", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "this", "->", "connection_open_ok", "(", ")", ";", "}" ]
Open connection with ext-redis.
[ "Open", "connection", "with", "ext", "-", "redis", "." ]
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L130-L157
23,685
bfitech/zapstore
src/RedisConn.php
RedisConn.connection_open_fail
private function connection_open_fail($msg='') { $logline = sprintf('Redis: %s connection failed', $this->redistype); if ($msg) $logline .= ': ' . $msg; $logline .= ' <- ' . json_encode($this->verified_params); self::$logger->error($logline); throw new RedisError(RedisError::CONNECTION_ERROR, $logline); }
php
private function connection_open_fail($msg='') { $logline = sprintf('Redis: %s connection failed', $this->redistype); if ($msg) $logline .= ': ' . $msg; $logline .= ' <- ' . json_encode($this->verified_params); self::$logger->error($logline); throw new RedisError(RedisError::CONNECTION_ERROR, $logline); }
[ "private", "function", "connection_open_fail", "(", "$", "msg", "=", "''", ")", "{", "$", "logline", "=", "sprintf", "(", "'Redis: %s connection failed'", ",", "$", "this", "->", "redistype", ")", ";", "if", "(", "$", "msg", ")", "$", "logline", ".=", "': '", ".", "$", "msg", ";", "$", "logline", ".=", "' <- '", ".", "json_encode", "(", "$", "this", "->", "verified_params", ")", ";", "self", "::", "$", "logger", "->", "error", "(", "$", "logline", ")", ";", "throw", "new", "RedisError", "(", "RedisError", "::", "CONNECTION_ERROR", ",", "$", "logline", ")", ";", "}" ]
Throw exception on failing connection.
[ "Throw", "exception", "on", "failing", "connection", "." ]
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/RedisConn.php#L162-L171
23,686
ekuiter/feature-php
FeaturePhp/Helper/PhpParser.php
PhpParser.parseString
public function parseString($str) { $parser = (new \PhpParser\ParserFactory())->create(\PhpParser\ParserFactory::PREFER_PHP7); $this->ast = $parser->parse($str); return $this; }
php
public function parseString($str) { $parser = (new \PhpParser\ParserFactory())->create(\PhpParser\ParserFactory::PREFER_PHP7); $this->ast = $parser->parse($str); return $this; }
[ "public", "function", "parseString", "(", "$", "str", ")", "{", "$", "parser", "=", "(", "new", "\\", "PhpParser", "\\", "ParserFactory", "(", ")", ")", "->", "create", "(", "\\", "PhpParser", "\\", "ParserFactory", "::", "PREFER_PHP7", ")", ";", "$", "this", "->", "ast", "=", "$", "parser", "->", "parse", "(", "$", "str", ")", ";", "return", "$", "this", ";", "}" ]
Parses a PHP string. @param string $str @return PhpParser
[ "Parses", "a", "PHP", "string", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/PhpParser.php#L29-L33
23,687
ekuiter/feature-php
FeaturePhp/Helper/PhpParser.php
PhpParser.getExactlyOneClass
public function getExactlyOneClass($fileSource) { if (count($this->ast) !== 1 || $this->ast[0]->getType() !== "Stmt_Class") throw new PhpParserException("\"$fileSource\" does not define exactly one class"); return $this->ast[0]; }
php
public function getExactlyOneClass($fileSource) { if (count($this->ast) !== 1 || $this->ast[0]->getType() !== "Stmt_Class") throw new PhpParserException("\"$fileSource\" does not define exactly one class"); return $this->ast[0]; }
[ "public", "function", "getExactlyOneClass", "(", "$", "fileSource", ")", "{", "if", "(", "count", "(", "$", "this", "->", "ast", ")", "!==", "1", "||", "$", "this", "->", "ast", "[", "0", "]", "->", "getType", "(", ")", "!==", "\"Stmt_Class\"", ")", "throw", "new", "PhpParserException", "(", "\"\\\"$fileSource\\\" does not define exactly one class\"", ")", ";", "return", "$", "this", "->", "ast", "[", "0", "]", ";", "}" ]
Asserts that the code defines one class and returns it. @param string $fileSource @return \PhpParser\Node\Stmt\Class_
[ "Asserts", "that", "the", "code", "defines", "one", "class", "and", "returns", "it", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/PhpParser.php#L60-L64
23,688
clickalicious/caching-middleware
src/Cache.php
Cache.buildResponse
protected function buildResponse($html, ResponseInterface $response) { // @codeCoverageIgnoreStart $body = new Stream('php://memory', 'w'); $body->write($html); $response = $response->withBody($body); return $response; // @codeCoverageIgnoreEnd }
php
protected function buildResponse($html, ResponseInterface $response) { // @codeCoverageIgnoreStart $body = new Stream('php://memory', 'w'); $body->write($html); $response = $response->withBody($body); return $response; // @codeCoverageIgnoreEnd }
[ "protected", "function", "buildResponse", "(", "$", "html", ",", "ResponseInterface", "$", "response", ")", "{", "// @codeCoverageIgnoreStart", "$", "body", "=", "new", "Stream", "(", "'php://memory'", ",", "'w'", ")", ";", "$", "body", "->", "write", "(", "$", "html", ")", ";", "$", "response", "=", "$", "response", "->", "withBody", "(", "$", "body", ")", ";", "return", "$", "response", ";", "// @codeCoverageIgnoreEnd", "}" ]
Builds response instance with HTML body from HTML passed in. @param string $html HTML used for response body @param \Psr\Http\Message\ResponseInterface $response Response used as base for response @author Benjamin Carl <opensource@clickalicious.de> @return \Psr\Http\Message\ResponseInterface @throws \InvalidArgumentException @throws \RuntimeException
[ "Builds", "response", "instance", "with", "HTML", "body", "from", "HTML", "passed", "in", "." ]
86ce045ec19bf3bcb48c656ca27f7cdfa03746ed
https://github.com/clickalicious/caching-middleware/blob/86ce045ec19bf3bcb48c656ca27f7cdfa03746ed/src/Cache.php#L279-L288
23,689
clickalicious/caching-middleware
src/Cache.php
Cache.cacheResponse
protected function cacheResponse(RequestInterface $request, ResponseInterface $response) { $cacheItem = $this->createCacheItem($this->createKeyFromRequest($request)); $value = $response->getBody()->__toString(); $cacheItem->set($value); $this ->getCacheItemPool() ->save($cacheItem); }
php
protected function cacheResponse(RequestInterface $request, ResponseInterface $response) { $cacheItem = $this->createCacheItem($this->createKeyFromRequest($request)); $value = $response->getBody()->__toString(); $cacheItem->set($value); $this ->getCacheItemPool() ->save($cacheItem); }
[ "protected", "function", "cacheResponse", "(", "RequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "$", "cacheItem", "=", "$", "this", "->", "createCacheItem", "(", "$", "this", "->", "createKeyFromRequest", "(", "$", "request", ")", ")", ";", "$", "value", "=", "$", "response", "->", "getBody", "(", ")", "->", "__toString", "(", ")", ";", "$", "cacheItem", "->", "set", "(", "$", "value", ")", ";", "$", "this", "->", "getCacheItemPool", "(", ")", "->", "save", "(", "$", "cacheItem", ")", ";", "}" ]
Caches a response by Request & Response. @param RequestInterface $request Request as identifier @param ResponseInterface $response Response to cache @author Benjamin Carl <opensource@clickalicious.de>
[ "Caches", "a", "response", "by", "Request", "&", "Response", "." ]
86ce045ec19bf3bcb48c656ca27f7cdfa03746ed
https://github.com/clickalicious/caching-middleware/blob/86ce045ec19bf3bcb48c656ca27f7cdfa03746ed/src/Cache.php#L330-L339
23,690
Eresus/EresusCMS
src/core/Feed/Writer/Item.php
Eresus_Feed_Writer_Item.addElementArray
public function addElementArray($elementArray) { if (!is_array($elementArray)) { return; } foreach ($elementArray as $elementName => $content) { $this->addElement($elementName, $content); } }
php
public function addElementArray($elementArray) { if (!is_array($elementArray)) { return; } foreach ($elementArray as $elementName => $content) { $this->addElement($elementName, $content); } }
[ "public", "function", "addElementArray", "(", "$", "elementArray", ")", "{", "if", "(", "!", "is_array", "(", "$", "elementArray", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "elementArray", "as", "$", "elementName", "=>", "$", "content", ")", "{", "$", "this", "->", "addElement", "(", "$", "elementName", ",", "$", "content", ")", ";", "}", "}" ]
Set multiple feed elements from an array. Elements which have attributes cannot be added by this method @param array array of elements in 'tagName' => 'tagContent' format. @return void
[ "Set", "multiple", "feed", "elements", "from", "an", "array", ".", "Elements", "which", "have", "attributes", "cannot", "be", "added", "by", "this", "method" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer/Item.php#L79-L89
23,691
Eresus/EresusCMS
src/core/Feed/Writer/Item.php
Eresus_Feed_Writer_Item.setDate
public function setDate($date) { if (!is_numeric($date)) { $date = strtotime($date); } if ($this->version == Eresus_Feed_Writer::ATOM) { $tag = 'updated'; $value = date(DATE_ATOM, $date); } elseif ($this->version == Eresus_Feed_Writer::RSS2) { $tag = 'pubDate'; $value = date(DATE_RSS, $date); } else { $tag = 'dc:date'; $value = date("Y-m-d", $date); } $this->addElement($tag, $value); }
php
public function setDate($date) { if (!is_numeric($date)) { $date = strtotime($date); } if ($this->version == Eresus_Feed_Writer::ATOM) { $tag = 'updated'; $value = date(DATE_ATOM, $date); } elseif ($this->version == Eresus_Feed_Writer::RSS2) { $tag = 'pubDate'; $value = date(DATE_RSS, $date); } else { $tag = 'dc:date'; $value = date("Y-m-d", $date); } $this->addElement($tag, $value); }
[ "public", "function", "setDate", "(", "$", "date", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "date", ")", ")", "{", "$", "date", "=", "strtotime", "(", "$", "date", ")", ";", "}", "if", "(", "$", "this", "->", "version", "==", "Eresus_Feed_Writer", "::", "ATOM", ")", "{", "$", "tag", "=", "'updated'", ";", "$", "value", "=", "date", "(", "DATE_ATOM", ",", "$", "date", ")", ";", "}", "elseif", "(", "$", "this", "->", "version", "==", "Eresus_Feed_Writer", "::", "RSS2", ")", "{", "$", "tag", "=", "'pubDate'", ";", "$", "value", "=", "date", "(", "DATE_RSS", ",", "$", "date", ")", ";", "}", "else", "{", "$", "tag", "=", "'dc:date'", ";", "$", "value", "=", "date", "(", "\"Y-m-d\"", ",", "$", "date", ")", ";", "}", "$", "this", "->", "addElement", "(", "$", "tag", ",", "$", "value", ")", ";", "}" ]
Set the 'date' element of feed item @param string $date The content of 'date' element @return void
[ "Set", "the", "date", "element", "of", "feed", "item" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer/Item.php#L130-L154
23,692
Eresus/EresusCMS
src/core/Feed/Writer/Item.php
Eresus_Feed_Writer_Item.setEncloser
public function setEncloser($url, $length, $type) { $attributes = array('url' => $url, 'length' => $length, 'type' => $type); $this->addElement('enclosure', '', $attributes); }
php
public function setEncloser($url, $length, $type) { $attributes = array('url' => $url, 'length' => $length, 'type' => $type); $this->addElement('enclosure', '', $attributes); }
[ "public", "function", "setEncloser", "(", "$", "url", ",", "$", "length", ",", "$", "type", ")", "{", "$", "attributes", "=", "array", "(", "'url'", "=>", "$", "url", ",", "'length'", "=>", "$", "length", ",", "'type'", "=>", "$", "type", ")", ";", "$", "this", "->", "addElement", "(", "'enclosure'", ",", "''", ",", "$", "attributes", ")", ";", "}" ]
Set the 'encloser' element of feed item For RSS 2.0 only @param string $url The url attribute of encloser tag @param string $length The length attribute of encloser tag @param string $type The type attribute of encloser tag @return void
[ "Set", "the", "encloser", "element", "of", "feed", "item", "For", "RSS", "2", ".", "0", "only" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Feed/Writer/Item.php#L185-L189
23,693
ezsystems/ezcomments-ls-extension
classes/ezcomnotification.php
ezcomNotification.fetchNotificationList
static function fetchNotificationList( $status = 1, $length = null, $offset = 0, $sorts = null ) { $cond = array(); if ( is_null( $status ) ) { $cond = null; } else { $cond['status'] = $status; } $limit = array(); if ( is_null( $length ) ) { $limit = null; } else { $limit['offset'] = $offset; $limit['length'] = $length; } return eZPersistentObject::fetchObjectList( self::definition(), null, $cond, $sorts, $limit ); }
php
static function fetchNotificationList( $status = 1, $length = null, $offset = 0, $sorts = null ) { $cond = array(); if ( is_null( $status ) ) { $cond = null; } else { $cond['status'] = $status; } $limit = array(); if ( is_null( $length ) ) { $limit = null; } else { $limit['offset'] = $offset; $limit['length'] = $length; } return eZPersistentObject::fetchObjectList( self::definition(), null, $cond, $sorts, $limit ); }
[ "static", "function", "fetchNotificationList", "(", "$", "status", "=", "1", ",", "$", "length", "=", "null", ",", "$", "offset", "=", "0", ",", "$", "sorts", "=", "null", ")", "{", "$", "cond", "=", "array", "(", ")", ";", "if", "(", "is_null", "(", "$", "status", ")", ")", "{", "$", "cond", "=", "null", ";", "}", "else", "{", "$", "cond", "[", "'status'", "]", "=", "$", "status", ";", "}", "$", "limit", "=", "array", "(", ")", ";", "if", "(", "is_null", "(", "$", "length", ")", ")", "{", "$", "limit", "=", "null", ";", "}", "else", "{", "$", "limit", "[", "'offset'", "]", "=", "$", "offset", ";", "$", "limit", "[", "'length'", "]", "=", "$", "length", ";", "}", "return", "eZPersistentObject", "::", "fetchObjectList", "(", "self", "::", "definition", "(", ")", ",", "null", ",", "$", "cond", ",", "$", "sorts", ",", "$", "limit", ")", ";", "}" ]
Fetch the list of notification @param $length: count of the notification to be fetched @param $status: the status of the notification @param $offset: offset @return notification list
[ "Fetch", "the", "list", "of", "notification" ]
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomnotification.php#L98-L120
23,694
neilime/zf2-tree-layout-stack
src/TreeLayoutStack/TemplatingService.php
TemplatingService.factory
public static function factory($aOptions){ if($aOptions instanceof \Traversable)$aOptions = \Zend\Stdlib\ArrayUtils::iteratorToArray($aOptions); elseif(!is_array($aOptions))throw new \InvalidArgumentException(__METHOD__.' expects an array or Traversable object; received "'.(is_object($aOptions)?get_class($aOptions):gettype($aOptions)).'"'); return new static(new \TreeLayoutStack\TemplatingConfiguration($aOptions)); }
php
public static function factory($aOptions){ if($aOptions instanceof \Traversable)$aOptions = \Zend\Stdlib\ArrayUtils::iteratorToArray($aOptions); elseif(!is_array($aOptions))throw new \InvalidArgumentException(__METHOD__.' expects an array or Traversable object; received "'.(is_object($aOptions)?get_class($aOptions):gettype($aOptions)).'"'); return new static(new \TreeLayoutStack\TemplatingConfiguration($aOptions)); }
[ "public", "static", "function", "factory", "(", "$", "aOptions", ")", "{", "if", "(", "$", "aOptions", "instanceof", "\\", "Traversable", ")", "$", "aOptions", "=", "\\", "Zend", "\\", "Stdlib", "\\", "ArrayUtils", "::", "iteratorToArray", "(", "$", "aOptions", ")", ";", "elseif", "(", "!", "is_array", "(", "$", "aOptions", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "' expects an array or Traversable object; received \"'", ".", "(", "is_object", "(", "$", "aOptions", ")", "?", "get_class", "(", "$", "aOptions", ")", ":", "gettype", "(", "$", "aOptions", ")", ")", ".", "'\"'", ")", ";", "return", "new", "static", "(", "new", "\\", "TreeLayoutStack", "\\", "TemplatingConfiguration", "(", "$", "aOptions", ")", ")", ";", "}" ]
Instantiate a Templating service @param array|Traversable $aOptions @throws \InvalidArgumentException @return \TreeLayoutStack\TemplatingService
[ "Instantiate", "a", "Templating", "service" ]
0a1431816ca1f4d4053b6f7f9ba83d8e72ad564a
https://github.com/neilime/zf2-tree-layout-stack/blob/0a1431816ca1f4d4053b6f7f9ba83d8e72ad564a/src/TreeLayoutStack/TemplatingService.php#L28-L32
23,695
neilime/zf2-tree-layout-stack
src/TreeLayoutStack/TemplatingService.php
TemplatingService.buildLayoutTemplate
public function buildLayoutTemplate(\Zend\Mvc\MvcEvent $oEvent){ $oRequest = $oEvent->getRequest(); if(!($oRequest instanceof \Zend\Http\Request) || $oRequest->isXmlHttpRequest() || ( ($oView = $oEvent->getResult()) instanceof \Zend\View\Model\ModelInterface && $oView->terminate() ))return $this; //Define current event $this->setCurrentEvent($oEvent); //Define module Name if(($oRouter = $this->getCurrentEvent()->getRouteMatch()) instanceof \Zend\Mvc\Router\RouteMatch)$sModule = current(explode('\\',$oRouter->getParam('controller'))); if(empty($sModule))$sModule = \TreeLayoutStack\TemplatingConfiguration::DEFAULT_LAYOUT_TREE; try{ //Retrieve template for module $oTemplate = $this->getConfiguration()->hasLayoutTreeForModule($sModule) ?$this->getConfiguration()->getLayoutTreeForModule($sModule) :$this->getConfiguration()->getLayoutTreeForModule(\TreeLayoutStack\TemplatingConfiguration::DEFAULT_LAYOUT_TREE); //Set layout template and add its children $sTemplate = $oTemplate->getConfiguration()->getTemplate(); if(is_callable($sTemplate))$sTemplate = $sTemplate($this->getCurrentEvent()); $oEvent->setViewModel($this->setChildrenToView( $oEvent->getViewModel()->setTemplate($sTemplate), $oTemplate->getChildren() )); } catch(\Exception $oException){ throw new \RuntimeException('Error occured during building layout template process : '.$oException->getMessage(),$oException->getCode(),$oException); } //Reset current event return $this->unsetCurrentEvent(); }
php
public function buildLayoutTemplate(\Zend\Mvc\MvcEvent $oEvent){ $oRequest = $oEvent->getRequest(); if(!($oRequest instanceof \Zend\Http\Request) || $oRequest->isXmlHttpRequest() || ( ($oView = $oEvent->getResult()) instanceof \Zend\View\Model\ModelInterface && $oView->terminate() ))return $this; //Define current event $this->setCurrentEvent($oEvent); //Define module Name if(($oRouter = $this->getCurrentEvent()->getRouteMatch()) instanceof \Zend\Mvc\Router\RouteMatch)$sModule = current(explode('\\',$oRouter->getParam('controller'))); if(empty($sModule))$sModule = \TreeLayoutStack\TemplatingConfiguration::DEFAULT_LAYOUT_TREE; try{ //Retrieve template for module $oTemplate = $this->getConfiguration()->hasLayoutTreeForModule($sModule) ?$this->getConfiguration()->getLayoutTreeForModule($sModule) :$this->getConfiguration()->getLayoutTreeForModule(\TreeLayoutStack\TemplatingConfiguration::DEFAULT_LAYOUT_TREE); //Set layout template and add its children $sTemplate = $oTemplate->getConfiguration()->getTemplate(); if(is_callable($sTemplate))$sTemplate = $sTemplate($this->getCurrentEvent()); $oEvent->setViewModel($this->setChildrenToView( $oEvent->getViewModel()->setTemplate($sTemplate), $oTemplate->getChildren() )); } catch(\Exception $oException){ throw new \RuntimeException('Error occured during building layout template process : '.$oException->getMessage(),$oException->getCode(),$oException); } //Reset current event return $this->unsetCurrentEvent(); }
[ "public", "function", "buildLayoutTemplate", "(", "\\", "Zend", "\\", "Mvc", "\\", "MvcEvent", "$", "oEvent", ")", "{", "$", "oRequest", "=", "$", "oEvent", "->", "getRequest", "(", ")", ";", "if", "(", "!", "(", "$", "oRequest", "instanceof", "\\", "Zend", "\\", "Http", "\\", "Request", ")", "||", "$", "oRequest", "->", "isXmlHttpRequest", "(", ")", "||", "(", "(", "$", "oView", "=", "$", "oEvent", "->", "getResult", "(", ")", ")", "instanceof", "\\", "Zend", "\\", "View", "\\", "Model", "\\", "ModelInterface", "&&", "$", "oView", "->", "terminate", "(", ")", ")", ")", "return", "$", "this", ";", "//Define current event", "$", "this", "->", "setCurrentEvent", "(", "$", "oEvent", ")", ";", "//Define module Name", "if", "(", "(", "$", "oRouter", "=", "$", "this", "->", "getCurrentEvent", "(", ")", "->", "getRouteMatch", "(", ")", ")", "instanceof", "\\", "Zend", "\\", "Mvc", "\\", "Router", "\\", "RouteMatch", ")", "$", "sModule", "=", "current", "(", "explode", "(", "'\\\\'", ",", "$", "oRouter", "->", "getParam", "(", "'controller'", ")", ")", ")", ";", "if", "(", "empty", "(", "$", "sModule", ")", ")", "$", "sModule", "=", "\\", "TreeLayoutStack", "\\", "TemplatingConfiguration", "::", "DEFAULT_LAYOUT_TREE", ";", "try", "{", "//Retrieve template for module", "$", "oTemplate", "=", "$", "this", "->", "getConfiguration", "(", ")", "->", "hasLayoutTreeForModule", "(", "$", "sModule", ")", "?", "$", "this", "->", "getConfiguration", "(", ")", "->", "getLayoutTreeForModule", "(", "$", "sModule", ")", ":", "$", "this", "->", "getConfiguration", "(", ")", "->", "getLayoutTreeForModule", "(", "\\", "TreeLayoutStack", "\\", "TemplatingConfiguration", "::", "DEFAULT_LAYOUT_TREE", ")", ";", "//Set layout template and add its children", "$", "sTemplate", "=", "$", "oTemplate", "->", "getConfiguration", "(", ")", "->", "getTemplate", "(", ")", ";", "if", "(", "is_callable", "(", "$", "sTemplate", ")", ")", "$", "sTemplate", "=", "$", "sTemplate", "(", "$", "this", "->", "getCurrentEvent", "(", ")", ")", ";", "$", "oEvent", "->", "setViewModel", "(", "$", "this", "->", "setChildrenToView", "(", "$", "oEvent", "->", "getViewModel", "(", ")", "->", "setTemplate", "(", "$", "sTemplate", ")", ",", "$", "oTemplate", "->", "getChildren", "(", ")", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "oException", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Error occured during building layout template process : '", ".", "$", "oException", "->", "getMessage", "(", ")", ",", "$", "oException", "->", "getCode", "(", ")", ",", "$", "oException", ")", ";", "}", "//Reset current event", "return", "$", "this", "->", "unsetCurrentEvent", "(", ")", ";", "}" ]
Define layout template @param \Zend\Mvc\MvcEvent $oEvent @throws \RuntimeException @return \TreeLayoutStack\TemplatingService
[ "Define", "layout", "template" ]
0a1431816ca1f4d4053b6f7f9ba83d8e72ad564a
https://github.com/neilime/zf2-tree-layout-stack/blob/0a1431816ca1f4d4053b6f7f9ba83d8e72ad564a/src/TreeLayoutStack/TemplatingService.php#L84-L118
23,696
expectation-php/expect
src/MatcherPackage.php
MatcherPackage.fromPackageFile
public static function fromPackageFile($composerJson) { if (file_exists($composerJson) === false) { throw new ComposerJsonNotFoundException("File {$composerJson} not found."); } $config = Config::load($composerJson); $autoload = $config->get('autoload.psr-4'); $composerJsonDirectory = dirname($composerJson); $keys = array_keys($autoload); $namespace = array_shift($keys); $values = array_values($autoload); $namespaceDirectory = array_shift($values); $namespaceDirectory = realpath($composerJsonDirectory . '/' . $namespaceDirectory); return new self($namespace, $namespaceDirectory); }
php
public static function fromPackageFile($composerJson) { if (file_exists($composerJson) === false) { throw new ComposerJsonNotFoundException("File {$composerJson} not found."); } $config = Config::load($composerJson); $autoload = $config->get('autoload.psr-4'); $composerJsonDirectory = dirname($composerJson); $keys = array_keys($autoload); $namespace = array_shift($keys); $values = array_values($autoload); $namespaceDirectory = array_shift($values); $namespaceDirectory = realpath($composerJsonDirectory . '/' . $namespaceDirectory); return new self($namespace, $namespaceDirectory); }
[ "public", "static", "function", "fromPackageFile", "(", "$", "composerJson", ")", "{", "if", "(", "file_exists", "(", "$", "composerJson", ")", "===", "false", ")", "{", "throw", "new", "ComposerJsonNotFoundException", "(", "\"File {$composerJson} not found.\"", ")", ";", "}", "$", "config", "=", "Config", "::", "load", "(", "$", "composerJson", ")", ";", "$", "autoload", "=", "$", "config", "->", "get", "(", "'autoload.psr-4'", ")", ";", "$", "composerJsonDirectory", "=", "dirname", "(", "$", "composerJson", ")", ";", "$", "keys", "=", "array_keys", "(", "$", "autoload", ")", ";", "$", "namespace", "=", "array_shift", "(", "$", "keys", ")", ";", "$", "values", "=", "array_values", "(", "$", "autoload", ")", ";", "$", "namespaceDirectory", "=", "array_shift", "(", "$", "values", ")", ";", "$", "namespaceDirectory", "=", "realpath", "(", "$", "composerJsonDirectory", ".", "'/'", ".", "$", "namespaceDirectory", ")", ";", "return", "new", "self", "(", "$", "namespace", ",", "$", "namespaceDirectory", ")", ";", "}" ]
Create a new matcher package from composer.json @param string $composerJson composer.json path @throws \expect\package\ComposerJsonNotFoundException
[ "Create", "a", "new", "matcher", "package", "from", "composer", ".", "json" ]
1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/MatcherPackage.php#L107-L126
23,697
gpupo/common-schema
src/ORM/Entity/Application/API/OAuth/Client/AccessToken.php
AccessToken.setClient
public function setClient(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client = null) { $this->client = $client; return $this; }
php
public function setClient(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client = null) { $this->client = $client; return $this; }
[ "public", "function", "setClient", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Application", "\\", "API", "\\", "OAuth", "\\", "Client", "\\", "Client", "$", "client", "=", "null", ")", "{", "$", "this", "->", "client", "=", "$", "client", ";", "return", "$", "this", ";", "}" ]
Set client. @param null|\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\Client $client @return AccessToken
[ "Set", "client", "." ]
a762d2eb3063b7317c72c69cbb463b1f95b86b0a
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Application/API/OAuth/Client/AccessToken.php#L274-L279
23,698
alevilar/ristorantino-vendor
Acl/Controller/Component/AclManagerComponent.php
AclManagerComponent.check_controller_hash_tmp_file
private function check_controller_hash_tmp_file() { if(is_writable(dirname($this->controllers_hash_file))) { App :: uses('File', 'Utility'); $file = new File($this->controllers_hash_file, true); return $file->exists(); } else { $this->Session->setFlash(sprintf(__d('acl', 'the %s directory is not writable'), dirname($this->controllers_hash_file)), 'Risto.flash_error', null, 'plugin_acl'); return false; } }
php
private function check_controller_hash_tmp_file() { if(is_writable(dirname($this->controllers_hash_file))) { App :: uses('File', 'Utility'); $file = new File($this->controllers_hash_file, true); return $file->exists(); } else { $this->Session->setFlash(sprintf(__d('acl', 'the %s directory is not writable'), dirname($this->controllers_hash_file)), 'Risto.flash_error', null, 'plugin_acl'); return false; } }
[ "private", "function", "check_controller_hash_tmp_file", "(", ")", "{", "if", "(", "is_writable", "(", "dirname", "(", "$", "this", "->", "controllers_hash_file", ")", ")", ")", "{", "App", "::", "uses", "(", "'File'", ",", "'Utility'", ")", ";", "$", "file", "=", "new", "File", "(", "$", "this", "->", "controllers_hash_file", ",", "true", ")", ";", "return", "$", "file", "->", "exists", "(", ")", ";", "}", "else", "{", "$", "this", "->", "Session", "->", "setFlash", "(", "sprintf", "(", "__d", "(", "'acl'", ",", "'the %s directory is not writable'", ")", ",", "dirname", "(", "$", "this", "->", "controllers_hash_file", ")", ")", ",", "'Risto.flash_error'", ",", "null", ",", "'plugin_acl'", ")", ";", "return", "false", ";", "}", "}" ]
Check if the file containing the stored controllers hashes can be created, and create it if it does not exist @return boolean true if the file exists or could be created
[ "Check", "if", "the", "file", "containing", "the", "stored", "controllers", "hashes", "can", "be", "created", "and", "create", "it", "if", "it", "does", "not", "exist" ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L31-L44
23,699
alevilar/ristorantino-vendor
Acl/Controller/Component/AclManagerComponent.php
AclManagerComponent.set_display_name
public function set_display_name($model_classname, $field_expression) { $model_instance = $this->get_model_instance($model_classname); $schema = $model_instance->schema(); if(array_key_exists($field_expression, $schema) || array_key_exists(str_replace($model_classname . '.', '', $field_expression), $schema) || array_key_exists($field_expression, $model_instance->virtualFields)) { /* * The field does not need to be created as it already exists in the model * as a datatable field, or a virtual field configured in the model */ /* * Eventually remove the model name */ if(strpos($field_expression, $model_classname . '.') === 0) { $field_expression = str_replace($model_classname . '.', '', $field_expression); } return $field_expression; } else { /* * The field does not exist in the model * -> create a virtual field with the given expression */ $this->controller->{$model_classname}->virtualFields['alaxos_acl_display_name'] = $field_expression; return 'alaxos_acl_display_name'; } }
php
public function set_display_name($model_classname, $field_expression) { $model_instance = $this->get_model_instance($model_classname); $schema = $model_instance->schema(); if(array_key_exists($field_expression, $schema) || array_key_exists(str_replace($model_classname . '.', '', $field_expression), $schema) || array_key_exists($field_expression, $model_instance->virtualFields)) { /* * The field does not need to be created as it already exists in the model * as a datatable field, or a virtual field configured in the model */ /* * Eventually remove the model name */ if(strpos($field_expression, $model_classname . '.') === 0) { $field_expression = str_replace($model_classname . '.', '', $field_expression); } return $field_expression; } else { /* * The field does not exist in the model * -> create a virtual field with the given expression */ $this->controller->{$model_classname}->virtualFields['alaxos_acl_display_name'] = $field_expression; return 'alaxos_acl_display_name'; } }
[ "public", "function", "set_display_name", "(", "$", "model_classname", ",", "$", "field_expression", ")", "{", "$", "model_instance", "=", "$", "this", "->", "get_model_instance", "(", "$", "model_classname", ")", ";", "$", "schema", "=", "$", "model_instance", "->", "schema", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "field_expression", ",", "$", "schema", ")", "||", "array_key_exists", "(", "str_replace", "(", "$", "model_classname", ".", "'.'", ",", "''", ",", "$", "field_expression", ")", ",", "$", "schema", ")", "||", "array_key_exists", "(", "$", "field_expression", ",", "$", "model_instance", "->", "virtualFields", ")", ")", "{", "/*\n\t * The field does not need to be created as it already exists in the model\n\t * as a datatable field, or a virtual field configured in the model\n\t */", "/*\n\t * Eventually remove the model name\n\t */", "if", "(", "strpos", "(", "$", "field_expression", ",", "$", "model_classname", ".", "'.'", ")", "===", "0", ")", "{", "$", "field_expression", "=", "str_replace", "(", "$", "model_classname", ".", "'.'", ",", "''", ",", "$", "field_expression", ")", ";", "}", "return", "$", "field_expression", ";", "}", "else", "{", "/*\n\t * The field does not exist in the model\n\t * -> create a virtual field with the given expression\n\t */", "$", "this", "->", "controller", "->", "{", "$", "model_classname", "}", "->", "virtualFields", "[", "'alaxos_acl_display_name'", "]", "=", "$", "field_expression", ";", "return", "'alaxos_acl_display_name'", ";", "}", "}" ]
Check if a given field_expression is an existing fieldname for the given model If it doesn't exist, a virtual field called 'alaxos_acl_display_name' is created with the given expression @param string $model_classname @param string $field_expression @return string The name of the field to use as display name
[ "Check", "if", "a", "given", "field_expression", "is", "an", "existing", "fieldname", "for", "the", "given", "model" ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Acl/Controller/Component/AclManagerComponent.php#L90-L128