id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
5,700
PushmanPHP/pushman_php_library
src/Pushman.php
Pushman.channels
public function channels() { $url = $this->getURL('channels'); $headers = [ 'body' => [ 'private' => $this->privateKey ] ]; $response = $this->processRequest($url, $headers, 'get'); return $response; }
php
public function channels() { $url = $this->getURL('channels'); $headers = [ 'body' => [ 'private' => $this->privateKey ] ]; $response = $this->processRequest($url, $headers, 'get'); return $response; }
[ "public", "function", "channels", "(", ")", "{", "$", "url", "=", "$", "this", "->", "getURL", "(", "'channels'", ")", ";", "$", "headers", "=", "[", "'body'", "=>", "[", "'private'", "=>", "$", "this", "->", "privateKey", "]", "]", ";", "$", "response", "=", "$", "this", "->", "processRequest", "(", "$", "url", ",", "$", "headers", ",", "'get'", ")", ";", "return", "$", "response", ";", "}" ]
Get an array of channels in the site.
[ "Get", "an", "array", "of", "channels", "in", "the", "site", "." ]
27eea27e7042a65bd1eef0955a9d8537f737701f
https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L337-L350
5,701
PushmanPHP/pushman_php_library
src/Pushman.php
Pushman.buildChannel
public function buildChannel($channel, $max = 3, $refreshes = 'no') { $channels = $this->validateChannel($channel); $url = $this->getURL('channel'); $headers = [ 'body' => [ 'private' => $this->privateKey, 'channel' => $channels, 'max' => $max, 'refreshes' => $refreshes ] ]; $response = $this->processRequest($url, $headers, 'post'); return $response; }
php
public function buildChannel($channel, $max = 3, $refreshes = 'no') { $channels = $this->validateChannel($channel); $url = $this->getURL('channel'); $headers = [ 'body' => [ 'private' => $this->privateKey, 'channel' => $channels, 'max' => $max, 'refreshes' => $refreshes ] ]; $response = $this->processRequest($url, $headers, 'post'); return $response; }
[ "public", "function", "buildChannel", "(", "$", "channel", ",", "$", "max", "=", "3", ",", "$", "refreshes", "=", "'no'", ")", "{", "$", "channels", "=", "$", "this", "->", "validateChannel", "(", "$", "channel", ")", ";", "$", "url", "=", "$", "this", "->", "getURL", "(", "'channel'", ")", ";", "$", "headers", "=", "[", "'body'", "=>", "[", "'private'", "=>", "$", "this", "->", "privateKey", ",", "'channel'", "=>", "$", "channels", ",", "'max'", "=>", "$", "max", ",", "'refreshes'", "=>", "$", "refreshes", "]", "]", ";", "$", "response", "=", "$", "this", "->", "processRequest", "(", "$", "url", ",", "$", "headers", ",", "'post'", ")", ";", "return", "$", "response", ";", "}" ]
Build a new channel or set of channels. @param $channel @return string @throws \Pushman\PHPLib\Exceptions\InvalidChannelException
[ "Build", "a", "new", "channel", "or", "set", "of", "channels", "." ]
27eea27e7042a65bd1eef0955a9d8537f737701f
https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L359-L377
5,702
PushmanPHP/pushman_php_library
src/Pushman.php
Pushman.destroyChannel
public function destroyChannel($channel) { $channels = $this->validateChannel($channel); $arrayOfChannels = json_decode($channels, true); if (in_array('public', $arrayOfChannels)) { throw new InvalidDeleteRequestException('You cannot delete the public channel.'); } $url = $this->getURL('channel'); $headers = [ 'body' => [ 'private' => $this->privateKey, 'channel' => $channels ] ]; $response = $this->processRequest($url, $headers, 'delete'); return $response; }
php
public function destroyChannel($channel) { $channels = $this->validateChannel($channel); $arrayOfChannels = json_decode($channels, true); if (in_array('public', $arrayOfChannels)) { throw new InvalidDeleteRequestException('You cannot delete the public channel.'); } $url = $this->getURL('channel'); $headers = [ 'body' => [ 'private' => $this->privateKey, 'channel' => $channels ] ]; $response = $this->processRequest($url, $headers, 'delete'); return $response; }
[ "public", "function", "destroyChannel", "(", "$", "channel", ")", "{", "$", "channels", "=", "$", "this", "->", "validateChannel", "(", "$", "channel", ")", ";", "$", "arrayOfChannels", "=", "json_decode", "(", "$", "channels", ",", "true", ")", ";", "if", "(", "in_array", "(", "'public'", ",", "$", "arrayOfChannels", ")", ")", "{", "throw", "new", "InvalidDeleteRequestException", "(", "'You cannot delete the public channel.'", ")", ";", "}", "$", "url", "=", "$", "this", "->", "getURL", "(", "'channel'", ")", ";", "$", "headers", "=", "[", "'body'", "=>", "[", "'private'", "=>", "$", "this", "->", "privateKey", ",", "'channel'", "=>", "$", "channels", "]", "]", ";", "$", "response", "=", "$", "this", "->", "processRequest", "(", "$", "url", ",", "$", "headers", ",", "'delete'", ")", ";", "return", "$", "response", ";", "}" ]
Destroy a channel or set of channels. @param $channel @return string @throws InvalidChannelException @throws InvalidDeleteRequestException
[ "Destroy", "a", "channel", "or", "set", "of", "channels", "." ]
27eea27e7042a65bd1eef0955a9d8537f737701f
https://github.com/PushmanPHP/pushman_php_library/blob/27eea27e7042a65bd1eef0955a9d8537f737701f/src/Pushman.php#L387-L408
5,703
koinephp/Http
lib/Koine/Http/Headers.php
Headers.send
public function send() { if ($this->sent()) { throw new Exceptions\HeadersAlreadySentException( "Headers already sent" ); } $this->sent = true; foreach ($this as $header) { $header->send(); } return $this; }
php
public function send() { if ($this->sent()) { throw new Exceptions\HeadersAlreadySentException( "Headers already sent" ); } $this->sent = true; foreach ($this as $header) { $header->send(); } return $this; }
[ "public", "function", "send", "(", ")", "{", "if", "(", "$", "this", "->", "sent", "(", ")", ")", "{", "throw", "new", "Exceptions", "\\", "HeadersAlreadySentException", "(", "\"Headers already sent\"", ")", ";", "}", "$", "this", "->", "sent", "=", "true", ";", "foreach", "(", "$", "this", "as", "$", "header", ")", "{", "$", "header", "->", "send", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Send the headers @return self
[ "Send", "the", "headers" ]
90a777d779f326d691e1092de6e1936a94764691
https://github.com/koinephp/Http/blob/90a777d779f326d691e1092de6e1936a94764691/lib/Koine/Http/Headers.php#L32-L47
5,704
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/BlockCipher.php
BlockCipher.setVector
public function setVector($vector) { try { $this->blockCipher->setSalt($vector); } catch (CryptException\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException($e->getMessage()); } $this->encryption['vector'] = $vector; return $this; }
php
public function setVector($vector) { try { $this->blockCipher->setSalt($vector); } catch (CryptException\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException($e->getMessage()); } $this->encryption['vector'] = $vector; return $this; }
[ "public", "function", "setVector", "(", "$", "vector", ")", "{", "try", "{", "$", "this", "->", "blockCipher", "->", "setSalt", "(", "$", "vector", ")", ";", "}", "catch", "(", "CryptException", "\\", "InvalidArgumentException", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "this", "->", "encryption", "[", "'vector'", "]", "=", "$", "vector", ";", "return", "$", "this", ";", "}" ]
Set the inizialization vector @param string $vector @return self @throws Exception\InvalidArgumentException
[ "Set", "the", "inizialization", "vector" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/BlockCipher.php#L168-L177
5,705
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/BlockCipher.php
BlockCipher.setKey
public function setKey($key) { try { $this->blockCipher->setKey($key); } catch (CryptException\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException($e->getMessage()); } $this->encryption['key'] = $key; return $this; }
php
public function setKey($key) { try { $this->blockCipher->setKey($key); } catch (CryptException\InvalidArgumentException $e) { throw new Exception\InvalidArgumentException($e->getMessage()); } $this->encryption['key'] = $key; return $this; }
[ "public", "function", "setKey", "(", "$", "key", ")", "{", "try", "{", "$", "this", "->", "blockCipher", "->", "setKey", "(", "$", "key", ")", ";", "}", "catch", "(", "CryptException", "\\", "InvalidArgumentException", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "this", "->", "encryption", "[", "'key'", "]", "=", "$", "key", ";", "return", "$", "this", ";", "}" ]
Set the encryption key @param string $key @return self @throws Exception\InvalidArgumentException
[ "Set", "the", "encryption", "key" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/BlockCipher.php#L186-L195
5,706
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/BlockCipher.php
BlockCipher.setCompression
public function setCompression($compression) { if (is_string($this->compression)) { $compression = ['adapter' => $compression]; } $this->compression = $compression; return $this; }
php
public function setCompression($compression) { if (is_string($this->compression)) { $compression = ['adapter' => $compression]; } $this->compression = $compression; return $this; }
[ "public", "function", "setCompression", "(", "$", "compression", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "compression", ")", ")", "{", "$", "compression", "=", "[", "'adapter'", "=>", "$", "compression", "]", ";", "}", "$", "this", "->", "compression", "=", "$", "compression", ";", "return", "$", "this", ";", "}" ]
Sets an internal compression for values to encrypt @param string|array $compression @return self
[ "Sets", "an", "internal", "compression", "for", "values", "to", "encrypt" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/BlockCipher.php#L223-L231
5,707
dzegarra/jsonrpcsmd
src/Greplab/Jsonrpcsmd/Smd.php
Smd.toArray
public function toArray() { $target = $this->getTarget(); if (empty($target)) throw new \Exception('The target is not defined'); $map = []; foreach ($this->services as $service) { $map = array_merge($map, $service->toArray()); } return $this->formatRespond($map); }
php
public function toArray() { $target = $this->getTarget(); if (empty($target)) throw new \Exception('The target is not defined'); $map = []; foreach ($this->services as $service) { $map = array_merge($map, $service->toArray()); } return $this->formatRespond($map); }
[ "public", "function", "toArray", "(", ")", "{", "$", "target", "=", "$", "this", "->", "getTarget", "(", ")", ";", "if", "(", "empty", "(", "$", "target", ")", ")", "throw", "new", "\\", "Exception", "(", "'The target is not defined'", ")", ";", "$", "map", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "services", "as", "$", "service", ")", "{", "$", "map", "=", "array_merge", "(", "$", "map", ",", "$", "service", "->", "toArray", "(", ")", ")", ";", "}", "return", "$", "this", "->", "formatRespond", "(", "$", "map", ")", ";", "}" ]
Return the service map as an associative array. @throws \Exception Is the target is not defined yet @return array
[ "Return", "the", "service", "map", "as", "an", "associative", "array", "." ]
2f423b575d34d9ef2370495b89b9efd96f0cd30b
https://github.com/dzegarra/jsonrpcsmd/blob/2f423b575d34d9ef2370495b89b9efd96f0cd30b/src/Greplab/Jsonrpcsmd/Smd.php#L198-L208
5,708
dzegarra/jsonrpcsmd
src/Greplab/Jsonrpcsmd/Smd.php
Smd.formatRespond
protected function formatRespond($map) { $envelope = \App::make('Greplab\Jsonrpcsmd\Envelope\\' . $this->envelope, array($this)); return $envelope->build($map); }
php
protected function formatRespond($map) { $envelope = \App::make('Greplab\Jsonrpcsmd\Envelope\\' . $this->envelope, array($this)); return $envelope->build($map); }
[ "protected", "function", "formatRespond", "(", "$", "map", ")", "{", "$", "envelope", "=", "\\", "App", "::", "make", "(", "'Greplab\\Jsonrpcsmd\\Envelope\\\\'", ".", "$", "this", "->", "envelope", ",", "array", "(", "$", "this", ")", ")", ";", "return", "$", "envelope", "->", "build", "(", "$", "map", ")", ";", "}" ]
Format the response including the map. @param array $map @return array
[ "Format", "the", "response", "including", "the", "map", "." ]
2f423b575d34d9ef2370495b89b9efd96f0cd30b
https://github.com/dzegarra/jsonrpcsmd/blob/2f423b575d34d9ef2370495b89b9efd96f0cd30b/src/Greplab/Jsonrpcsmd/Smd.php#L215-L218
5,709
jmpantoja/planb-utils
src/Beautifier/Parser/Parser.php
Parser.format
public function format(FormatInterface $format): string { $template = $format->getTemplate(); $replacements = $format->getReplacements(); return $this->parse($template, $replacements); }
php
public function format(FormatInterface $format): string { $template = $format->getTemplate(); $replacements = $format->getReplacements(); return $this->parse($template, $replacements); }
[ "public", "function", "format", "(", "FormatInterface", "$", "format", ")", ":", "string", "{", "$", "template", "=", "$", "format", "->", "getTemplate", "(", ")", ";", "$", "replacements", "=", "$", "format", "->", "getReplacements", "(", ")", ";", "return", "$", "this", "->", "parse", "(", "$", "template", ",", "$", "replacements", ")", ";", "}" ]
Devuelve un dumper parseado @param \PlanB\Beautifier\Format\FormatInterface $format @return string
[ "Devuelve", "un", "dumper", "parseado" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Parser/Parser.php#L97-L104
5,710
jmpantoja/planb-utils
src/Beautifier/Parser/Parser.php
Parser.decorate
public function decorate(Token $token): string { $style = $token->style(); $value = $token->value(); foreach ($this->decorators as $decorator) { $value = $decorator->decorate($style, $value); } return $value; }
php
public function decorate(Token $token): string { $style = $token->style(); $value = $token->value(); foreach ($this->decorators as $decorator) { $value = $decorator->decorate($style, $value); } return $value; }
[ "public", "function", "decorate", "(", "Token", "$", "token", ")", ":", "string", "{", "$", "style", "=", "$", "token", "->", "style", "(", ")", ";", "$", "value", "=", "$", "token", "->", "value", "(", ")", ";", "foreach", "(", "$", "this", "->", "decorators", "as", "$", "decorator", ")", "{", "$", "value", "=", "$", "decorator", "->", "decorate", "(", "$", "style", ",", "$", "value", ")", ";", "}", "return", "$", "value", ";", "}" ]
Devuelve un token parseado @param \PlanB\Beautifier\Template\Token $token @return string
[ "Devuelve", "un", "token", "parseado" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Parser/Parser.php#L113-L123
5,711
vpg/titon.common
src/Titon/Common/Augment/ConfigAugment.php
ConfigAugment.set
public function set($key, $value = null) { if (($default = Hash::extract($this->_defaults, $key)) !== null) { if (is_float($default)) { $value = (float) $value; } else if (is_numeric($default)) { $value = (int) $value; } else if (is_bool($default)) { $value = (bool) $value; } else if (is_string($default)) { $value = (string) $value; } else if (is_array($default)) { $value = (array) $value; } } $this->_data = Hash::insert($this->_data, $key, $value); return $this; }
php
public function set($key, $value = null) { if (($default = Hash::extract($this->_defaults, $key)) !== null) { if (is_float($default)) { $value = (float) $value; } else if (is_numeric($default)) { $value = (int) $value; } else if (is_bool($default)) { $value = (bool) $value; } else if (is_string($default)) { $value = (string) $value; } else if (is_array($default)) { $value = (array) $value; } } $this->_data = Hash::insert($this->_data, $key, $value); return $this; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "(", "$", "default", "=", "Hash", "::", "extract", "(", "$", "this", "->", "_defaults", ",", "$", "key", ")", ")", "!==", "null", ")", "{", "if", "(", "is_float", "(", "$", "default", ")", ")", "{", "$", "value", "=", "(", "float", ")", "$", "value", ";", "}", "else", "if", "(", "is_numeric", "(", "$", "default", ")", ")", "{", "$", "value", "=", "(", "int", ")", "$", "value", ";", "}", "else", "if", "(", "is_bool", "(", "$", "default", ")", ")", "{", "$", "value", "=", "(", "bool", ")", "$", "value", ";", "}", "else", "if", "(", "is_string", "(", "$", "default", ")", ")", "{", "$", "value", "=", "(", "string", ")", "$", "value", ";", "}", "else", "if", "(", "is_array", "(", "$", "default", ")", ")", "{", "$", "value", "=", "(", "array", ")", "$", "value", ";", "}", "}", "$", "this", "->", "_data", "=", "Hash", "::", "insert", "(", "$", "this", "->", "_data", ",", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Set a configuration by key. Autobox the value if a default exists. @uses Titon\Utility\Hash @param string $key @param mixed $value @return $this
[ "Set", "a", "configuration", "by", "key", ".", "Autobox", "the", "value", "if", "a", "default", "exists", "." ]
41fe62bd5134bf76db3ff9caa16f280d9d534ef9
https://github.com/vpg/titon.common/blob/41fe62bd5134bf76db3ff9caa16f280d9d534ef9/src/Titon/Common/Augment/ConfigAugment.php#L51-L73
5,712
dlin-me/geocoder
src/Dlin/Geocoder/Geocoding/BingGeocoding.php
BingGeocoding._parseComponent
private function _parseComponent($components) { $address = new GeoAddress(); $address->geoCoding = $this->name; if(array_key_exists('address', $components)){ $addressData = $components['address']; $address->addressLine1 = array_key_exists('addressLine', $addressData) ? $addressData['addressLine']: ""; $address->state = array_key_exists('adminDistrict', $addressData) ? $addressData['adminDistrict']: ""; $address->country = array_key_exists('countryRegion', $addressData) ? $addressData['countryRegion']: ""; if(array_key_exists('formattedAddress', $addressData)){ $address->formattedAddress = $addressData['formattedAddress'].', '.$address->country; } $address->suburb = array_key_exists('locality', $addressData) ? $addressData['locality']: ""; $address->postcode = array_key_exists('postalCode', $addressData) ? $addressData['postalCode']: ""; } if(array_key_exists('confidence', $components)){ $address->partial = $components['confidence'] != 'High'; } if(array_key_exists('point', $components)){ $address->latitude = strval($components['point']['coordinates'][0]); $address->longitude = strval($components['point']['coordinates'][1]); } return $address; }
php
private function _parseComponent($components) { $address = new GeoAddress(); $address->geoCoding = $this->name; if(array_key_exists('address', $components)){ $addressData = $components['address']; $address->addressLine1 = array_key_exists('addressLine', $addressData) ? $addressData['addressLine']: ""; $address->state = array_key_exists('adminDistrict', $addressData) ? $addressData['adminDistrict']: ""; $address->country = array_key_exists('countryRegion', $addressData) ? $addressData['countryRegion']: ""; if(array_key_exists('formattedAddress', $addressData)){ $address->formattedAddress = $addressData['formattedAddress'].', '.$address->country; } $address->suburb = array_key_exists('locality', $addressData) ? $addressData['locality']: ""; $address->postcode = array_key_exists('postalCode', $addressData) ? $addressData['postalCode']: ""; } if(array_key_exists('confidence', $components)){ $address->partial = $components['confidence'] != 'High'; } if(array_key_exists('point', $components)){ $address->latitude = strval($components['point']['coordinates'][0]); $address->longitude = strval($components['point']['coordinates'][1]); } return $address; }
[ "private", "function", "_parseComponent", "(", "$", "components", ")", "{", "$", "address", "=", "new", "GeoAddress", "(", ")", ";", "$", "address", "->", "geoCoding", "=", "$", "this", "->", "name", ";", "if", "(", "array_key_exists", "(", "'address'", ",", "$", "components", ")", ")", "{", "$", "addressData", "=", "$", "components", "[", "'address'", "]", ";", "$", "address", "->", "addressLine1", "=", "array_key_exists", "(", "'addressLine'", ",", "$", "addressData", ")", "?", "$", "addressData", "[", "'addressLine'", "]", ":", "\"\"", ";", "$", "address", "->", "state", "=", "array_key_exists", "(", "'adminDistrict'", ",", "$", "addressData", ")", "?", "$", "addressData", "[", "'adminDistrict'", "]", ":", "\"\"", ";", "$", "address", "->", "country", "=", "array_key_exists", "(", "'countryRegion'", ",", "$", "addressData", ")", "?", "$", "addressData", "[", "'countryRegion'", "]", ":", "\"\"", ";", "if", "(", "array_key_exists", "(", "'formattedAddress'", ",", "$", "addressData", ")", ")", "{", "$", "address", "->", "formattedAddress", "=", "$", "addressData", "[", "'formattedAddress'", "]", ".", "', '", ".", "$", "address", "->", "country", ";", "}", "$", "address", "->", "suburb", "=", "array_key_exists", "(", "'locality'", ",", "$", "addressData", ")", "?", "$", "addressData", "[", "'locality'", "]", ":", "\"\"", ";", "$", "address", "->", "postcode", "=", "array_key_exists", "(", "'postalCode'", ",", "$", "addressData", ")", "?", "$", "addressData", "[", "'postalCode'", "]", ":", "\"\"", ";", "}", "if", "(", "array_key_exists", "(", "'confidence'", ",", "$", "components", ")", ")", "{", "$", "address", "->", "partial", "=", "$", "components", "[", "'confidence'", "]", "!=", "'High'", ";", "}", "if", "(", "array_key_exists", "(", "'point'", ",", "$", "components", ")", ")", "{", "$", "address", "->", "latitude", "=", "strval", "(", "$", "components", "[", "'point'", "]", "[", "'coordinates'", "]", "[", "0", "]", ")", ";", "$", "address", "->", "longitude", "=", "strval", "(", "$", "components", "[", "'point'", "]", "[", "'coordinates'", "]", "[", "1", "]", ")", ";", "}", "return", "$", "address", ";", "}" ]
This function use to parse the return components from google bing api @param $components @return GeoAddress
[ "This", "function", "use", "to", "parse", "the", "return", "components", "from", "google", "bing", "api" ]
50596ff3dcaccd95034e5799ae02fd1c753b5cd2
https://github.com/dlin-me/geocoder/blob/50596ff3dcaccd95034e5799ae02fd1c753b5cd2/src/Dlin/Geocoder/Geocoding/BingGeocoding.php#L45-L72
5,713
unyx/diagnostics
debug/Inspector.php
Inspector.getTrace
public function getTrace() : Trace { // No need for further magic if we've already instantiated a Trace Sequence. if ($this->trace !== null) { return $this->trace; } // Instantiate a new Trace Sequence and cache it locally. return $this->trace = new Trace($this->getFrames()); }
php
public function getTrace() : Trace { // No need for further magic if we've already instantiated a Trace Sequence. if ($this->trace !== null) { return $this->trace; } // Instantiate a new Trace Sequence and cache it locally. return $this->trace = new Trace($this->getFrames()); }
[ "public", "function", "getTrace", "(", ")", ":", "Trace", "{", "// No need for further magic if we've already instantiated a Trace Sequence.", "if", "(", "$", "this", "->", "trace", "!==", "null", ")", "{", "return", "$", "this", "->", "trace", ";", "}", "// Instantiate a new Trace Sequence and cache it locally.", "return", "$", "this", "->", "trace", "=", "new", "Trace", "(", "$", "this", "->", "getFrames", "(", ")", ")", ";", "}" ]
Returns a Trace instance representing the stack trace of the inspected Throwable. If the trace contains a handlers\Error entry (indicating the Throwable is the result of an internal error -> exception conversion), that frame will be removed. If it does not, a frame for the actual Throwable will be prepended to the frame stack instead, to make it easier to iterate over the causality chain. @return Trace
[ "Returns", "a", "Trace", "instance", "representing", "the", "stack", "trace", "of", "the", "inspected", "Throwable", "." ]
024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e
https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/Inspector.php#L78-L87
5,714
unyx/diagnostics
debug/Inspector.php
Inspector.getFrames
protected function getFrames() : array { $frames = $this->throwable->getTrace(); if (!$this->throwable instanceof \ErrorException) { // Make sure the first frame in the trace actually points to the Throwable we're inspecting. array_unshift($frames, diagnostics\Debug::throwableToArray($this->throwable)); return $frames; } // We're going to determine if the exception in fact stems from an irrecoverable fatal error. $fatal = false; // Note: E_RECOVERABLE_ERROR and E_PARSE should as of PHP7 be entirely converted to Throwables // so they should be caught by an Exception Handler directly instead of first going through an Error Handler // and being converted to an Error Exception, let alone a FatalError Exception. We still keep // them here for edge cases, however. switch ($this->throwable->getSeverity()) { case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: case E_RECOVERABLE_ERROR: case E_PARSE: $fatal = true; break; } // Without XDebug we don't actually have any means to determine the stacktrace of a fatal error. if (!$fatal || !extension_loaded('xdebug') || !xdebug_is_enabled()) { // Our error handler will be the first frame in the trace since it's the one which converted // the error to an exception. We're gonna copy over the context and remove // Remove our (error) handler from the stack trace (it's otherwise always going to occlude // the actual exception). // $frames[1]['args'] = $frames[0]['args']; array_shift($frames); return $frames; } // Remove our internal handling logic from the stack trace so it doesn't occlude the actual trace. $frames = array_diff_key(array_reverse(xdebug_get_function_stack()), debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)); // Handle some potential inconsistencies between XDebug and the way we want to handle things. foreach ($frames as &$frame) { if ('dynamic' === $frame['type']) { $frame['type'] = '->'; } elseif ('static' === $frame['type']) { $frame['type'] = '::'; } // XDebug uses a different key for the args array. if (isset($frame['params']) && !isset($frame['args'])) { $frame['args'] = $frame['params']; unset($frame['params']); } } return $frames; }
php
protected function getFrames() : array { $frames = $this->throwable->getTrace(); if (!$this->throwable instanceof \ErrorException) { // Make sure the first frame in the trace actually points to the Throwable we're inspecting. array_unshift($frames, diagnostics\Debug::throwableToArray($this->throwable)); return $frames; } // We're going to determine if the exception in fact stems from an irrecoverable fatal error. $fatal = false; // Note: E_RECOVERABLE_ERROR and E_PARSE should as of PHP7 be entirely converted to Throwables // so they should be caught by an Exception Handler directly instead of first going through an Error Handler // and being converted to an Error Exception, let alone a FatalError Exception. We still keep // them here for edge cases, however. switch ($this->throwable->getSeverity()) { case E_ERROR: case E_CORE_ERROR: case E_COMPILE_ERROR: case E_USER_ERROR: case E_RECOVERABLE_ERROR: case E_PARSE: $fatal = true; break; } // Without XDebug we don't actually have any means to determine the stacktrace of a fatal error. if (!$fatal || !extension_loaded('xdebug') || !xdebug_is_enabled()) { // Our error handler will be the first frame in the trace since it's the one which converted // the error to an exception. We're gonna copy over the context and remove // Remove our (error) handler from the stack trace (it's otherwise always going to occlude // the actual exception). // $frames[1]['args'] = $frames[0]['args']; array_shift($frames); return $frames; } // Remove our internal handling logic from the stack trace so it doesn't occlude the actual trace. $frames = array_diff_key(array_reverse(xdebug_get_function_stack()), debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)); // Handle some potential inconsistencies between XDebug and the way we want to handle things. foreach ($frames as &$frame) { if ('dynamic' === $frame['type']) { $frame['type'] = '->'; } elseif ('static' === $frame['type']) { $frame['type'] = '::'; } // XDebug uses a different key for the args array. if (isset($frame['params']) && !isset($frame['args'])) { $frame['args'] = $frame['params']; unset($frame['params']); } } return $frames; }
[ "protected", "function", "getFrames", "(", ")", ":", "array", "{", "$", "frames", "=", "$", "this", "->", "throwable", "->", "getTrace", "(", ")", ";", "if", "(", "!", "$", "this", "->", "throwable", "instanceof", "\\", "ErrorException", ")", "{", "// Make sure the first frame in the trace actually points to the Throwable we're inspecting.", "array_unshift", "(", "$", "frames", ",", "diagnostics", "\\", "Debug", "::", "throwableToArray", "(", "$", "this", "->", "throwable", ")", ")", ";", "return", "$", "frames", ";", "}", "// We're going to determine if the exception in fact stems from an irrecoverable fatal error.", "$", "fatal", "=", "false", ";", "// Note: E_RECOVERABLE_ERROR and E_PARSE should as of PHP7 be entirely converted to Throwables", "// so they should be caught by an Exception Handler directly instead of first going through an Error Handler", "// and being converted to an Error Exception, let alone a FatalError Exception. We still keep", "// them here for edge cases, however.", "switch", "(", "$", "this", "->", "throwable", "->", "getSeverity", "(", ")", ")", "{", "case", "E_ERROR", ":", "case", "E_CORE_ERROR", ":", "case", "E_COMPILE_ERROR", ":", "case", "E_USER_ERROR", ":", "case", "E_RECOVERABLE_ERROR", ":", "case", "E_PARSE", ":", "$", "fatal", "=", "true", ";", "break", ";", "}", "// Without XDebug we don't actually have any means to determine the stacktrace of a fatal error.", "if", "(", "!", "$", "fatal", "||", "!", "extension_loaded", "(", "'xdebug'", ")", "||", "!", "xdebug_is_enabled", "(", ")", ")", "{", "// Our error handler will be the first frame in the trace since it's the one which converted", "// the error to an exception. We're gonna copy over the context and remove", "// Remove our (error) handler from the stack trace (it's otherwise always going to occlude", "// the actual exception).", "// $frames[1]['args'] = $frames[0]['args'];", "array_shift", "(", "$", "frames", ")", ";", "return", "$", "frames", ";", "}", "// Remove our internal handling logic from the stack trace so it doesn't occlude the actual trace.", "$", "frames", "=", "array_diff_key", "(", "array_reverse", "(", "xdebug_get_function_stack", "(", ")", ")", ",", "debug_backtrace", "(", "DEBUG_BACKTRACE_IGNORE_ARGS", ")", ")", ";", "// Handle some potential inconsistencies between XDebug and the way we want to handle things.", "foreach", "(", "$", "frames", "as", "&", "$", "frame", ")", "{", "if", "(", "'dynamic'", "===", "$", "frame", "[", "'type'", "]", ")", "{", "$", "frame", "[", "'type'", "]", "=", "'->'", ";", "}", "elseif", "(", "'static'", "===", "$", "frame", "[", "'type'", "]", ")", "{", "$", "frame", "[", "'type'", "]", "=", "'::'", ";", "}", "// XDebug uses a different key for the args array.", "if", "(", "isset", "(", "$", "frame", "[", "'params'", "]", ")", "&&", "!", "isset", "(", "$", "frame", "[", "'args'", "]", ")", ")", "{", "$", "frame", "[", "'args'", "]", "=", "$", "frame", "[", "'params'", "]", ";", "unset", "(", "$", "frame", "[", "'params'", "]", ")", ";", "}", "}", "return", "$", "frames", ";", "}" ]
Returns the traced frames from the inspected Throwable.. @return array
[ "Returns", "the", "traced", "frames", "from", "the", "inspected", "Throwable", ".." ]
024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e
https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/Inspector.php#L94-L156
5,715
wearenolte/wp-utils
src/Meta/Collection.php
Collection.get_all_collection_meta
public static function get_all_collection_meta( $lead_post ) { $title = self::get_collection_title( $lead_post->post_type ); $tags = [ [ 'name' => 'description', 'content' => Post::get_post_meta_description( $lead_post ) ], [ 'property' => 'og:locale', 'content' => get_locale() ], [ 'property' => 'og:type', 'content' => 'summary' ], [ 'property' => 'og:title', 'content' => $title ], [ 'property' => 'og:description', 'content' => Post::get_post_og_description( $lead_post ) ], [ 'property' => 'og:url', 'content' => get_permalink( $lead_post->ID ) ], [ 'property' => 'og:site_name', 'content' => get_bloginfo( 'title' ) ], [ 'name' => 'twitter:card', 'content' => 'summary' ], [ 'name' => 'twitter:title', 'content' => $title ], [ 'name' => 'twitter:description', 'content' => Post::get_post_twitter_description( $lead_post ) ], ]; $tags = array_merge( $tags, Site::webmaster_tools() ); return [ 'title' => $title, 'tags' => $tags, ]; }
php
public static function get_all_collection_meta( $lead_post ) { $title = self::get_collection_title( $lead_post->post_type ); $tags = [ [ 'name' => 'description', 'content' => Post::get_post_meta_description( $lead_post ) ], [ 'property' => 'og:locale', 'content' => get_locale() ], [ 'property' => 'og:type', 'content' => 'summary' ], [ 'property' => 'og:title', 'content' => $title ], [ 'property' => 'og:description', 'content' => Post::get_post_og_description( $lead_post ) ], [ 'property' => 'og:url', 'content' => get_permalink( $lead_post->ID ) ], [ 'property' => 'og:site_name', 'content' => get_bloginfo( 'title' ) ], [ 'name' => 'twitter:card', 'content' => 'summary' ], [ 'name' => 'twitter:title', 'content' => $title ], [ 'name' => 'twitter:description', 'content' => Post::get_post_twitter_description( $lead_post ) ], ]; $tags = array_merge( $tags, Site::webmaster_tools() ); return [ 'title' => $title, 'tags' => $tags, ]; }
[ "public", "static", "function", "get_all_collection_meta", "(", "$", "lead_post", ")", "{", "$", "title", "=", "self", "::", "get_collection_title", "(", "$", "lead_post", "->", "post_type", ")", ";", "$", "tags", "=", "[", "[", "'name'", "=>", "'description'", ",", "'content'", "=>", "Post", "::", "get_post_meta_description", "(", "$", "lead_post", ")", "]", ",", "[", "'property'", "=>", "'og:locale'", ",", "'content'", "=>", "get_locale", "(", ")", "]", ",", "[", "'property'", "=>", "'og:type'", ",", "'content'", "=>", "'summary'", "]", ",", "[", "'property'", "=>", "'og:title'", ",", "'content'", "=>", "$", "title", "]", ",", "[", "'property'", "=>", "'og:description'", ",", "'content'", "=>", "Post", "::", "get_post_og_description", "(", "$", "lead_post", ")", "]", ",", "[", "'property'", "=>", "'og:url'", ",", "'content'", "=>", "get_permalink", "(", "$", "lead_post", "->", "ID", ")", "]", ",", "[", "'property'", "=>", "'og:site_name'", ",", "'content'", "=>", "get_bloginfo", "(", "'title'", ")", "]", ",", "[", "'name'", "=>", "'twitter:card'", ",", "'content'", "=>", "'summary'", "]", ",", "[", "'name'", "=>", "'twitter:title'", ",", "'content'", "=>", "$", "title", "]", ",", "[", "'name'", "=>", "'twitter:description'", ",", "'content'", "=>", "Post", "::", "get_post_twitter_description", "(", "$", "lead_post", ")", "]", ",", "]", ";", "$", "tags", "=", "array_merge", "(", "$", "tags", ",", "Site", "::", "webmaster_tools", "(", ")", ")", ";", "return", "[", "'title'", "=>", "$", "title", ",", "'tags'", "=>", "$", "tags", ",", "]", ";", "}" ]
Get all metadata for a collection. @param \WP_Post $lead_post The lead post from which to take the metadata. @return array
[ "Get", "all", "metadata", "for", "a", "collection", "." ]
f0ba691ee7c678784f6b01ff154fab150ffb409b
https://github.com/wearenolte/wp-utils/blob/f0ba691ee7c678784f6b01ff154fab150ffb409b/src/Meta/Collection.php#L21-L40
5,716
wearenolte/wp-utils
src/Meta/Collection.php
Collection.get_collection_title
public static function get_collection_title( $post_type ) { $post_type_name = 'Blog'; if ( 'post' !== $post_type ) { $type = get_post_type_object( $post_type ); $post_type_name = $type->labels->name; } $filter_name = sprintf( self::TITLE_FILTER, is_string( $post_type ) ? $post_type : $post_type_name ); $collection_title = sprintf( '%s - %s', $post_type_name, get_bloginfo( 'title' ) ); return apply_filters( $filter_name, $collection_title ); }
php
public static function get_collection_title( $post_type ) { $post_type_name = 'Blog'; if ( 'post' !== $post_type ) { $type = get_post_type_object( $post_type ); $post_type_name = $type->labels->name; } $filter_name = sprintf( self::TITLE_FILTER, is_string( $post_type ) ? $post_type : $post_type_name ); $collection_title = sprintf( '%s - %s', $post_type_name, get_bloginfo( 'title' ) ); return apply_filters( $filter_name, $collection_title ); }
[ "public", "static", "function", "get_collection_title", "(", "$", "post_type", ")", "{", "$", "post_type_name", "=", "'Blog'", ";", "if", "(", "'post'", "!==", "$", "post_type", ")", "{", "$", "type", "=", "get_post_type_object", "(", "$", "post_type", ")", ";", "$", "post_type_name", "=", "$", "type", "->", "labels", "->", "name", ";", "}", "$", "filter_name", "=", "sprintf", "(", "self", "::", "TITLE_FILTER", ",", "is_string", "(", "$", "post_type", ")", "?", "$", "post_type", ":", "$", "post_type_name", ")", ";", "$", "collection_title", "=", "sprintf", "(", "'%s - %s'", ",", "$", "post_type_name", ",", "get_bloginfo", "(", "'title'", ")", ")", ";", "return", "apply_filters", "(", "$", "filter_name", ",", "$", "collection_title", ")", ";", "}" ]
Get the title for a collection. @param string $post_type The post type. @return mixed
[ "Get", "the", "title", "for", "a", "collection", "." ]
f0ba691ee7c678784f6b01ff154fab150ffb409b
https://github.com/wearenolte/wp-utils/blob/f0ba691ee7c678784f6b01ff154fab150ffb409b/src/Meta/Collection.php#L48-L65
5,717
NuclearCMS/Users
src/User.php
User.create
public static function create(array $attributes = []) { $user = new static($attributes); $user->setPassword($attributes['password']); $user->save(); return $user; }
php
public static function create(array $attributes = []) { $user = new static($attributes); $user->setPassword($attributes['password']); $user->save(); return $user; }
[ "public", "static", "function", "create", "(", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "user", "=", "new", "static", "(", "$", "attributes", ")", ";", "$", "user", "->", "setPassword", "(", "$", "attributes", "[", "'password'", "]", ")", ";", "$", "user", "->", "save", "(", ")", ";", "return", "$", "user", ";", "}" ]
Static constructor for User @param array $attributes @return static
[ "Static", "constructor", "for", "User" ]
c1536f5da9e4e29394c97510b2497e9a4fad6fc6
https://github.com/NuclearCMS/Users/blob/c1536f5da9e4e29394c97510b2497e9a4fad6fc6/src/User.php#L102-L111
5,718
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/DataUnitFormatter.php
DataUnitFormatter.getPrefixes
protected function getPrefixes() { $prefixes = $this->options['prefixes']; if ($prefixes) { return $prefixes; } return self::$standardizedPrefixes[$this->getMode()]; }
php
protected function getPrefixes() { $prefixes = $this->options['prefixes']; if ($prefixes) { return $prefixes; } return self::$standardizedPrefixes[$this->getMode()]; }
[ "protected", "function", "getPrefixes", "(", ")", "{", "$", "prefixes", "=", "$", "this", "->", "options", "[", "'prefixes'", "]", ";", "if", "(", "$", "prefixes", ")", "{", "return", "$", "prefixes", ";", "}", "return", "self", "::", "$", "standardizedPrefixes", "[", "$", "this", "->", "getMode", "(", ")", "]", ";", "}" ]
Get the predefined prefixes or use the build-in standardized lists of prefixes. @return array
[ "Get", "the", "predefined", "prefixes", "or", "use", "the", "build", "-", "in", "standardized", "lists", "of", "prefixes", "." ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/DataUnitFormatter.php#L174-L182
5,719
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/DataUnitFormatter.php
DataUnitFormatter.getPrefixAt
protected function getPrefixAt($index) { $prefixes = $this->getPrefixes(); return isset($prefixes[$index]) ? $prefixes[$index] : null; }
php
protected function getPrefixAt($index) { $prefixes = $this->getPrefixes(); return isset($prefixes[$index]) ? $prefixes[$index] : null; }
[ "protected", "function", "getPrefixAt", "(", "$", "index", ")", "{", "$", "prefixes", "=", "$", "this", "->", "getPrefixes", "(", ")", ";", "return", "isset", "(", "$", "prefixes", "[", "$", "index", "]", ")", "?", "$", "prefixes", "[", "$", "index", "]", ":", "null", ";", "}" ]
Find the prefix at a specific location in the prefixes array. @param $index @return string|null
[ "Find", "the", "prefix", "at", "a", "specific", "location", "in", "the", "prefixes", "array", "." ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/DataUnitFormatter.php#L191-L195
5,720
helsingborg-stad/attachment-revisions
source/php/App.php
App.replaceMedia
public function replaceMedia($postId) { if (empty($_POST['media-replacer-replace-with']) || !is_numeric($_POST['media-replacer-replace-with'])) { return; } $uploadDir = wp_upload_dir(); $filename = $uploadDir['basedir'] . '/' . get_post_meta($postId, '_wp_attached_file', true); $file = pathinfo($filename); $replacementFile = $uploadDir['basedir'] . '/' . get_post_meta($_POST['media-replacer-replace-with'], '_wp_attached_file', true); $backup = $this->createBackup($filename); $replaced = $this->replaceFile($filename, $replacementFile); if ($replaced) { unlink($replacementFile); } // Update attachment metadata $meta = wp_generate_attachment_metadata($postId, $filename); wp_update_attachment_metadata($postId, $meta); // Update revision meta $revisions = get_post_meta($postId, self::$revisionMetaKey, true); if (!$revisions) { $revisions = array(); } $revisions[time()] = $backup; update_post_meta($postId, self::$revisionMetaKey, $revisions); // Remove replacement attachment post $this->removeAttachment($_POST['media-replacer-replace-with']); }
php
public function replaceMedia($postId) { if (empty($_POST['media-replacer-replace-with']) || !is_numeric($_POST['media-replacer-replace-with'])) { return; } $uploadDir = wp_upload_dir(); $filename = $uploadDir['basedir'] . '/' . get_post_meta($postId, '_wp_attached_file', true); $file = pathinfo($filename); $replacementFile = $uploadDir['basedir'] . '/' . get_post_meta($_POST['media-replacer-replace-with'], '_wp_attached_file', true); $backup = $this->createBackup($filename); $replaced = $this->replaceFile($filename, $replacementFile); if ($replaced) { unlink($replacementFile); } // Update attachment metadata $meta = wp_generate_attachment_metadata($postId, $filename); wp_update_attachment_metadata($postId, $meta); // Update revision meta $revisions = get_post_meta($postId, self::$revisionMetaKey, true); if (!$revisions) { $revisions = array(); } $revisions[time()] = $backup; update_post_meta($postId, self::$revisionMetaKey, $revisions); // Remove replacement attachment post $this->removeAttachment($_POST['media-replacer-replace-with']); }
[ "public", "function", "replaceMedia", "(", "$", "postId", ")", "{", "if", "(", "empty", "(", "$", "_POST", "[", "'media-replacer-replace-with'", "]", ")", "||", "!", "is_numeric", "(", "$", "_POST", "[", "'media-replacer-replace-with'", "]", ")", ")", "{", "return", ";", "}", "$", "uploadDir", "=", "wp_upload_dir", "(", ")", ";", "$", "filename", "=", "$", "uploadDir", "[", "'basedir'", "]", ".", "'/'", ".", "get_post_meta", "(", "$", "postId", ",", "'_wp_attached_file'", ",", "true", ")", ";", "$", "file", "=", "pathinfo", "(", "$", "filename", ")", ";", "$", "replacementFile", "=", "$", "uploadDir", "[", "'basedir'", "]", ".", "'/'", ".", "get_post_meta", "(", "$", "_POST", "[", "'media-replacer-replace-with'", "]", ",", "'_wp_attached_file'", ",", "true", ")", ";", "$", "backup", "=", "$", "this", "->", "createBackup", "(", "$", "filename", ")", ";", "$", "replaced", "=", "$", "this", "->", "replaceFile", "(", "$", "filename", ",", "$", "replacementFile", ")", ";", "if", "(", "$", "replaced", ")", "{", "unlink", "(", "$", "replacementFile", ")", ";", "}", "// Update attachment metadata", "$", "meta", "=", "wp_generate_attachment_metadata", "(", "$", "postId", ",", "$", "filename", ")", ";", "wp_update_attachment_metadata", "(", "$", "postId", ",", "$", "meta", ")", ";", "// Update revision meta", "$", "revisions", "=", "get_post_meta", "(", "$", "postId", ",", "self", "::", "$", "revisionMetaKey", ",", "true", ")", ";", "if", "(", "!", "$", "revisions", ")", "{", "$", "revisions", "=", "array", "(", ")", ";", "}", "$", "revisions", "[", "time", "(", ")", "]", "=", "$", "backup", ";", "update_post_meta", "(", "$", "postId", ",", "self", "::", "$", "revisionMetaKey", ",", "$", "revisions", ")", ";", "// Remove replacement attachment post", "$", "this", "->", "removeAttachment", "(", "$", "_POST", "[", "'media-replacer-replace-with'", "]", ")", ";", "}" ]
Replaces the media file @return void
[ "Replaces", "the", "media", "file" ]
761792963febb2a5eb8422f0765d7ae20368ef82
https://github.com/helsingborg-stad/attachment-revisions/blob/761792963febb2a5eb8422f0765d7ae20368ef82/source/php/App.php#L71-L105
5,721
helsingborg-stad/attachment-revisions
source/php/App.php
App.replaceFile
public function replaceFile($original, $replacement) { $this->removeThumbnails($original); if (copy($replacement, $original)) { return $original; } return false; }
php
public function replaceFile($original, $replacement) { $this->removeThumbnails($original); if (copy($replacement, $original)) { return $original; } return false; }
[ "public", "function", "replaceFile", "(", "$", "original", ",", "$", "replacement", ")", "{", "$", "this", "->", "removeThumbnails", "(", "$", "original", ")", ";", "if", "(", "copy", "(", "$", "replacement", ",", "$", "original", ")", ")", "{", "return", "$", "original", ";", "}", "return", "false", ";", "}" ]
Replaces a file @param string $original Path to original @param string $replacement Path to replacement @return string|boolean
[ "Replaces", "a", "file" ]
761792963febb2a5eb8422f0765d7ae20368ef82
https://github.com/helsingborg-stad/attachment-revisions/blob/761792963febb2a5eb8422f0765d7ae20368ef82/source/php/App.php#L113-L122
5,722
helsingborg-stad/attachment-revisions
source/php/App.php
App.removeThumbnails
public function removeThumbnails($filename) { $file = pathinfo($filename); // Regexp pattern to find thumbs $pattern = '/' . $file['filename'] . '-([0-9]+)x([0-9]+)\.' . $file['extension'] . '/'; $remove = (array) glob($file['dirname'] . '/*.' . $file['extension']); $remove = array_filter($remove, function ($item) use ($pattern) { return preg_match($pattern, $item); }); array_map('unlink', $remove); return true; }
php
public function removeThumbnails($filename) { $file = pathinfo($filename); // Regexp pattern to find thumbs $pattern = '/' . $file['filename'] . '-([0-9]+)x([0-9]+)\.' . $file['extension'] . '/'; $remove = (array) glob($file['dirname'] . '/*.' . $file['extension']); $remove = array_filter($remove, function ($item) use ($pattern) { return preg_match($pattern, $item); }); array_map('unlink', $remove); return true; }
[ "public", "function", "removeThumbnails", "(", "$", "filename", ")", "{", "$", "file", "=", "pathinfo", "(", "$", "filename", ")", ";", "// Regexp pattern to find thumbs", "$", "pattern", "=", "'/'", ".", "$", "file", "[", "'filename'", "]", ".", "'-([0-9]+)x([0-9]+)\\.'", ".", "$", "file", "[", "'extension'", "]", ".", "'/'", ";", "$", "remove", "=", "(", "array", ")", "glob", "(", "$", "file", "[", "'dirname'", "]", ".", "'/*.'", ".", "$", "file", "[", "'extension'", "]", ")", ";", "$", "remove", "=", "array_filter", "(", "$", "remove", ",", "function", "(", "$", "item", ")", "use", "(", "$", "pattern", ")", "{", "return", "preg_match", "(", "$", "pattern", ",", "$", "item", ")", ";", "}", ")", ";", "array_map", "(", "'unlink'", ",", "$", "remove", ")", ";", "return", "true", ";", "}" ]
Remove thumbnails for a image @param string $filename Path to original file @return boolean
[ "Remove", "thumbnails", "for", "a", "image" ]
761792963febb2a5eb8422f0765d7ae20368ef82
https://github.com/helsingborg-stad/attachment-revisions/blob/761792963febb2a5eb8422f0765d7ae20368ef82/source/php/App.php#L129-L144
5,723
helsingborg-stad/attachment-revisions
source/php/App.php
App.createBackup
public function createBackup($originalPath) { // Bail if file does not exist if (!file_exists($originalPath)) { return false; } $pathinfo = pathinfo($originalPath); $backupPrefered = $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '.' . $pathinfo['extension'] . '.bkp'; $backupFile = $backupPrefered; $i = 0; while (file_exists($backupFile)) { $i++; $backupFile = $backupPrefered . $i; } if (copy($originalPath, $backupFile)) { return $backupFile; } return false; }
php
public function createBackup($originalPath) { // Bail if file does not exist if (!file_exists($originalPath)) { return false; } $pathinfo = pathinfo($originalPath); $backupPrefered = $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '.' . $pathinfo['extension'] . '.bkp'; $backupFile = $backupPrefered; $i = 0; while (file_exists($backupFile)) { $i++; $backupFile = $backupPrefered . $i; } if (copy($originalPath, $backupFile)) { return $backupFile; } return false; }
[ "public", "function", "createBackup", "(", "$", "originalPath", ")", "{", "// Bail if file does not exist", "if", "(", "!", "file_exists", "(", "$", "originalPath", ")", ")", "{", "return", "false", ";", "}", "$", "pathinfo", "=", "pathinfo", "(", "$", "originalPath", ")", ";", "$", "backupPrefered", "=", "$", "pathinfo", "[", "'dirname'", "]", ".", "'/'", ".", "$", "pathinfo", "[", "'filename'", "]", ".", "'.'", ".", "$", "pathinfo", "[", "'extension'", "]", ".", "'.bkp'", ";", "$", "backupFile", "=", "$", "backupPrefered", ";", "$", "i", "=", "0", ";", "while", "(", "file_exists", "(", "$", "backupFile", ")", ")", "{", "$", "i", "++", ";", "$", "backupFile", "=", "$", "backupPrefered", ".", "$", "i", ";", "}", "if", "(", "copy", "(", "$", "originalPath", ",", "$", "backupFile", ")", ")", "{", "return", "$", "backupFile", ";", "}", "return", "false", ";", "}" ]
Creates a backup of a media file @param string $originalPath The original file path @return [type] [description]
[ "Creates", "a", "backup", "of", "a", "media", "file" ]
761792963febb2a5eb8422f0765d7ae20368ef82
https://github.com/helsingborg-stad/attachment-revisions/blob/761792963febb2a5eb8422f0765d7ae20368ef82/source/php/App.php#L151-L174
5,724
helsingborg-stad/attachment-revisions
source/php/App.php
App.formFields
public function formFields($fields, $post) { // Bail if its not edit attachment page if (!isset($_GET['post']) || $post->post_type !== 'attachment') { return $fields; } add_thickbox(); wp_enqueue_media(); $uploadDir = wp_upload_dir(); $mime = mime_content_type($uploadDir['basedir'] . '/' . get_post_meta(get_the_id(), '_wp_attached_file', true)); // Media replace button $html = '<button type="button" class="button-secondary button-large" data-action="media-replacer-replace" data-mime="' . $mime . '" data-edit-link="' . get_edit_post_link($post->ID) . '">' . __('Replace media', 'media-replacer') . '</button> <input type="hidden" name="media-replacer-replace-with">'; // Revision button $revisions = get_post_meta($post->ID, self::$revisionMetaKey, true); if (!is_array($revisions)) { $revisions = array(); } $revisions = array_reverse($revisions, true); if (count($revisions) > 0) { $html .= '<a href="#TB_inline?width=600&height=550&inlineId=media-replace-revisions-thickbox-' . $post->ID . '" class="thickbox button-secondary button-large" data-action="media-replacer-revisions" data-edit-link="' . get_edit_post_link($post->ID) . '">' . __('Media revisions', 'media-replacer') . '</a>'; $html .= '<div id="media-replace-revisions-thickbox-' . $post->ID . '" style="display:none;"><ul class="media-replace-revisions">'; } foreach ($revisions as $time => $path) { if (!file_exists($path)) { continue; } $url = str_replace($uploadDir['basedir'], $uploadDir['baseurl'], $path); $date = mysql2date('Y-m-d H:i', date('Y-m-d H:i:s', $time)); $html .= '<li data-restore="' . $path . '">'; if (explode('/', mime_content_type($path))[0] === 'image') { $html .= '<div class="media-replace-revision-thumb" style="background-image:url(' . $url . ')"></div>'; } $html .= '<time>' . $date . '</time>'; $html .= '</li>'; } if (count($revisions)) { $html .= '</ul> <div class="media-replace-revision-footer"> <button type="button" class="button button-large" data-action="media-replace-close-thickbox">' . __('Cancel') . '</button> <button type="button" class="button button-large button-primary" data-action="media-replace-close-thickbox">' . __('Ok') . '</button> </div> </div><input type="hidden" name="media-replace-restore">'; } $fields['media_replacer'] = array( 'label' => '', 'input' => 'html', 'html' => $html ); return $fields; }
php
public function formFields($fields, $post) { // Bail if its not edit attachment page if (!isset($_GET['post']) || $post->post_type !== 'attachment') { return $fields; } add_thickbox(); wp_enqueue_media(); $uploadDir = wp_upload_dir(); $mime = mime_content_type($uploadDir['basedir'] . '/' . get_post_meta(get_the_id(), '_wp_attached_file', true)); // Media replace button $html = '<button type="button" class="button-secondary button-large" data-action="media-replacer-replace" data-mime="' . $mime . '" data-edit-link="' . get_edit_post_link($post->ID) . '">' . __('Replace media', 'media-replacer') . '</button> <input type="hidden" name="media-replacer-replace-with">'; // Revision button $revisions = get_post_meta($post->ID, self::$revisionMetaKey, true); if (!is_array($revisions)) { $revisions = array(); } $revisions = array_reverse($revisions, true); if (count($revisions) > 0) { $html .= '<a href="#TB_inline?width=600&height=550&inlineId=media-replace-revisions-thickbox-' . $post->ID . '" class="thickbox button-secondary button-large" data-action="media-replacer-revisions" data-edit-link="' . get_edit_post_link($post->ID) . '">' . __('Media revisions', 'media-replacer') . '</a>'; $html .= '<div id="media-replace-revisions-thickbox-' . $post->ID . '" style="display:none;"><ul class="media-replace-revisions">'; } foreach ($revisions as $time => $path) { if (!file_exists($path)) { continue; } $url = str_replace($uploadDir['basedir'], $uploadDir['baseurl'], $path); $date = mysql2date('Y-m-d H:i', date('Y-m-d H:i:s', $time)); $html .= '<li data-restore="' . $path . '">'; if (explode('/', mime_content_type($path))[0] === 'image') { $html .= '<div class="media-replace-revision-thumb" style="background-image:url(' . $url . ')"></div>'; } $html .= '<time>' . $date . '</time>'; $html .= '</li>'; } if (count($revisions)) { $html .= '</ul> <div class="media-replace-revision-footer"> <button type="button" class="button button-large" data-action="media-replace-close-thickbox">' . __('Cancel') . '</button> <button type="button" class="button button-large button-primary" data-action="media-replace-close-thickbox">' . __('Ok') . '</button> </div> </div><input type="hidden" name="media-replace-restore">'; } $fields['media_replacer'] = array( 'label' => '', 'input' => 'html', 'html' => $html ); return $fields; }
[ "public", "function", "formFields", "(", "$", "fields", ",", "$", "post", ")", "{", "// Bail if its not edit attachment page", "if", "(", "!", "isset", "(", "$", "_GET", "[", "'post'", "]", ")", "||", "$", "post", "->", "post_type", "!==", "'attachment'", ")", "{", "return", "$", "fields", ";", "}", "add_thickbox", "(", ")", ";", "wp_enqueue_media", "(", ")", ";", "$", "uploadDir", "=", "wp_upload_dir", "(", ")", ";", "$", "mime", "=", "mime_content_type", "(", "$", "uploadDir", "[", "'basedir'", "]", ".", "'/'", ".", "get_post_meta", "(", "get_the_id", "(", ")", ",", "'_wp_attached_file'", ",", "true", ")", ")", ";", "// Media replace button", "$", "html", "=", "'<button type=\"button\" class=\"button-secondary button-large\" data-action=\"media-replacer-replace\" data-mime=\"'", ".", "$", "mime", ".", "'\" data-edit-link=\"'", ".", "get_edit_post_link", "(", "$", "post", "->", "ID", ")", ".", "'\">'", ".", "__", "(", "'Replace media'", ",", "'media-replacer'", ")", ".", "'</button>\n <input type=\"hidden\" name=\"media-replacer-replace-with\">'", ";", "// Revision button", "$", "revisions", "=", "get_post_meta", "(", "$", "post", "->", "ID", ",", "self", "::", "$", "revisionMetaKey", ",", "true", ")", ";", "if", "(", "!", "is_array", "(", "$", "revisions", ")", ")", "{", "$", "revisions", "=", "array", "(", ")", ";", "}", "$", "revisions", "=", "array_reverse", "(", "$", "revisions", ",", "true", ")", ";", "if", "(", "count", "(", "$", "revisions", ")", ">", "0", ")", "{", "$", "html", ".=", "'<a href=\"#TB_inline?width=600&height=550&inlineId=media-replace-revisions-thickbox-'", ".", "$", "post", "->", "ID", ".", "'\" class=\"thickbox button-secondary button-large\" data-action=\"media-replacer-revisions\" data-edit-link=\"'", ".", "get_edit_post_link", "(", "$", "post", "->", "ID", ")", ".", "'\">'", ".", "__", "(", "'Media revisions'", ",", "'media-replacer'", ")", ".", "'</a>'", ";", "$", "html", ".=", "'<div id=\"media-replace-revisions-thickbox-'", ".", "$", "post", "->", "ID", ".", "'\" style=\"display:none;\"><ul class=\"media-replace-revisions\">'", ";", "}", "foreach", "(", "$", "revisions", "as", "$", "time", "=>", "$", "path", ")", "{", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "continue", ";", "}", "$", "url", "=", "str_replace", "(", "$", "uploadDir", "[", "'basedir'", "]", ",", "$", "uploadDir", "[", "'baseurl'", "]", ",", "$", "path", ")", ";", "$", "date", "=", "mysql2date", "(", "'Y-m-d H:i'", ",", "date", "(", "'Y-m-d H:i:s'", ",", "$", "time", ")", ")", ";", "$", "html", ".=", "'<li data-restore=\"'", ".", "$", "path", ".", "'\">'", ";", "if", "(", "explode", "(", "'/'", ",", "mime_content_type", "(", "$", "path", ")", ")", "[", "0", "]", "===", "'image'", ")", "{", "$", "html", ".=", "'<div class=\"media-replace-revision-thumb\" style=\"background-image:url('", ".", "$", "url", ".", "')\"></div>'", ";", "}", "$", "html", ".=", "'<time>'", ".", "$", "date", ".", "'</time>'", ";", "$", "html", ".=", "'</li>'", ";", "}", "if", "(", "count", "(", "$", "revisions", ")", ")", "{", "$", "html", ".=", "'</ul>\n <div class=\"media-replace-revision-footer\">\n <button type=\"button\" class=\"button button-large\" data-action=\"media-replace-close-thickbox\">'", ".", "__", "(", "'Cancel'", ")", ".", "'</button>\n <button type=\"button\" class=\"button button-large button-primary\" data-action=\"media-replace-close-thickbox\">'", ".", "__", "(", "'Ok'", ")", ".", "'</button>\n </div>\n </div><input type=\"hidden\" name=\"media-replace-restore\">'", ";", "}", "$", "fields", "[", "'media_replacer'", "]", "=", "array", "(", "'label'", "=>", "''", ",", "'input'", "=>", "'html'", ",", "'html'", "=>", "$", "html", ")", ";", "return", "$", "fields", ";", "}" ]
Adds replacer field to the edit attachment form @param array $fields Original fields @return array Fields to use
[ "Adds", "replacer", "field", "to", "the", "edit", "attachment", "form" ]
761792963febb2a5eb8422f0765d7ae20368ef82
https://github.com/helsingborg-stad/attachment-revisions/blob/761792963febb2a5eb8422f0765d7ae20368ef82/source/php/App.php#L181-L245
5,725
try-php/predict-output
src/PredictOutputTrait.php
PredictOutputTrait.predictOutput
public function predictOutput(callable $capture, string $content) { ob_start(); call_user_func($capture); $clearedOutput = trim(stripControlCharacters(stripColorCharacters(ob_get_clean()))); if ($clearedOutput !== $content) { throw new \Exception('The predicted output did not match the actual one.'); } }
php
public function predictOutput(callable $capture, string $content) { ob_start(); call_user_func($capture); $clearedOutput = trim(stripControlCharacters(stripColorCharacters(ob_get_clean()))); if ($clearedOutput !== $content) { throw new \Exception('The predicted output did not match the actual one.'); } }
[ "public", "function", "predictOutput", "(", "callable", "$", "capture", ",", "string", "$", "content", ")", "{", "ob_start", "(", ")", ";", "call_user_func", "(", "$", "capture", ")", ";", "$", "clearedOutput", "=", "trim", "(", "stripControlCharacters", "(", "stripColorCharacters", "(", "ob_get_clean", "(", ")", ")", ")", ")", ";", "if", "(", "$", "clearedOutput", "!==", "$", "content", ")", "{", "throw", "new", "\\", "Exception", "(", "'The predicted output did not match the actual one.'", ")", ";", "}", "}" ]
Method to check if an function or method echo output matches the expected result @param callable $capture @param string $content @throws \Exception
[ "Method", "to", "check", "if", "an", "function", "or", "method", "echo", "output", "matches", "the", "expected", "result" ]
66116f0c8bdb310ef91952615f4735acbf903b0b
https://github.com/try-php/predict-output/blob/66116f0c8bdb310ef91952615f4735acbf903b0b/src/PredictOutputTrait.php#L14-L23
5,726
FelixOnline/Core
migrations/20131222204549_article_searchable.php
ArticleSearchable.up
public function up() { $table = $this->table('article'); $table->addColumn('searchable', 'boolean', array( 'comment' => 'Should web crawlers index this?', 'null' => false, 'after' => 'hidden', 'default' => 1, )) ->addIndex(array('searchable')) ->save(); $this->execute('UPDATE `article` SET searchable = 0 WHERE `id` IN (1378, 1450)'); }
php
public function up() { $table = $this->table('article'); $table->addColumn('searchable', 'boolean', array( 'comment' => 'Should web crawlers index this?', 'null' => false, 'after' => 'hidden', 'default' => 1, )) ->addIndex(array('searchable')) ->save(); $this->execute('UPDATE `article` SET searchable = 0 WHERE `id` IN (1378, 1450)'); }
[ "public", "function", "up", "(", ")", "{", "$", "table", "=", "$", "this", "->", "table", "(", "'article'", ")", ";", "$", "table", "->", "addColumn", "(", "'searchable'", ",", "'boolean'", ",", "array", "(", "'comment'", "=>", "'Should web crawlers index this?'", ",", "'null'", "=>", "false", ",", "'after'", "=>", "'hidden'", ",", "'default'", "=>", "1", ",", ")", ")", "->", "addIndex", "(", "array", "(", "'searchable'", ")", ")", "->", "save", "(", ")", ";", "$", "this", "->", "execute", "(", "'UPDATE `article` SET searchable = 0 WHERE `id` IN (1378, 1450)'", ")", ";", "}" ]
Up Method.
[ "Up", "Method", "." ]
b29f50cd96cee73da83968ee1eb88d8b3ab1c430
https://github.com/FelixOnline/Core/blob/b29f50cd96cee73da83968ee1eb88d8b3ab1c430/migrations/20131222204549_article_searchable.php#L10-L23
5,727
pablodip/PablodipModuleBundle
OptionBag.php
OptionBag.get
public function get($name) { if (!array_key_exists($name, $this->options)) { throw new \InvalidArgumentException(sprintf('The option "%s" does not exist.', $name)); } return $this->options[$name]; }
php
public function get($name) { if (!array_key_exists($name, $this->options)) { throw new \InvalidArgumentException(sprintf('The option "%s" does not exist.', $name)); } return $this->options[$name]; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "options", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The option \"%s\" does not exist.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "options", "[", "$", "name", "]", ";", "}" ]
Returns a option by name. @param string $name The name. @return mixed The option value. @throws \InvalidArgumentException If the option does not exist.
[ "Returns", "a", "option", "by", "name", "." ]
6d26df909fa4c57b8b3337d58f8cbecd7781c6ef
https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/OptionBag.php#L118-L125
5,728
phpffcms/ffcms-ckeditor
src/Ffcms/Apps/Api/Ckeditor/Editor.php
Editor.before
public function before() { parent::before(); // check if user have permission to access there if (!App::$User->isAuth() || !App::$User->identity()->role->can('global/file')) throw new NativeException('Permission denied'); App::$Translate->append(__DIR__ . '/Translation/' . App::$Request->getLanguage() . '.php'); }
php
public function before() { parent::before(); // check if user have permission to access there if (!App::$User->isAuth() || !App::$User->identity()->role->can('global/file')) throw new NativeException('Permission denied'); App::$Translate->append(__DIR__ . '/Translation/' . App::$Request->getLanguage() . '.php'); }
[ "public", "function", "before", "(", ")", "{", "parent", "::", "before", "(", ")", ";", "// check if user have permission to access there", "if", "(", "!", "App", "::", "$", "User", "->", "isAuth", "(", ")", "||", "!", "App", "::", "$", "User", "->", "identity", "(", ")", "->", "role", "->", "can", "(", "'global/file'", ")", ")", "throw", "new", "NativeException", "(", "'Permission denied'", ")", ";", "App", "::", "$", "Translate", "->", "append", "(", "__DIR__", ".", "'/Translation/'", ".", "App", "::", "$", "Request", "->", "getLanguage", "(", ")", ".", "'.php'", ")", ";", "}" ]
Append translation file ;) @throws NativeException
[ "Append", "translation", "file", ";", ")" ]
ed07f750dbb9567f7e7390ed5f00b005890128b2
https://github.com/phpffcms/ffcms-ckeditor/blob/ed07f750dbb9567f7e7390ed5f00b005890128b2/src/Ffcms/Apps/Api/Ckeditor/Editor.php#L32-L40
5,729
phpffcms/ffcms-ckeditor
src/Ffcms/Apps/Api/Ckeditor/Editor.php
Editor.actionBrowse
public function actionBrowse($type) { $files = null; $relative = null; // check if request type is defined if ($this->allowedExt[$type] === null || !Any::isArray($this->allowedExt[$type])) { throw new NativeException('Hack attempt'); } // list files in directory $files = File::listFiles('/upload/' . $type, $this->allowedExt[$type]); // absolute path to relative URI foreach ($files as $file) { $newName = Str::sub($file, Str::length(root)+1); $relative[] = trim(Str::replace(DIRECTORY_SEPARATOR, '/', $newName), '/'); } // generate response return App::$View->render('editor/browse', [ 'callbackName' => App::$Security->strip_tags(App::$Request->query->get('CKEditor')), 'callbackId' => (int)App::$Request->query->get('CKEditorFuncNum'), 'files' => $relative, 'type' => $type ], __DIR__); }
php
public function actionBrowse($type) { $files = null; $relative = null; // check if request type is defined if ($this->allowedExt[$type] === null || !Any::isArray($this->allowedExt[$type])) { throw new NativeException('Hack attempt'); } // list files in directory $files = File::listFiles('/upload/' . $type, $this->allowedExt[$type]); // absolute path to relative URI foreach ($files as $file) { $newName = Str::sub($file, Str::length(root)+1); $relative[] = trim(Str::replace(DIRECTORY_SEPARATOR, '/', $newName), '/'); } // generate response return App::$View->render('editor/browse', [ 'callbackName' => App::$Security->strip_tags(App::$Request->query->get('CKEditor')), 'callbackId' => (int)App::$Request->query->get('CKEditorFuncNum'), 'files' => $relative, 'type' => $type ], __DIR__); }
[ "public", "function", "actionBrowse", "(", "$", "type", ")", "{", "$", "files", "=", "null", ";", "$", "relative", "=", "null", ";", "// check if request type is defined", "if", "(", "$", "this", "->", "allowedExt", "[", "$", "type", "]", "===", "null", "||", "!", "Any", "::", "isArray", "(", "$", "this", "->", "allowedExt", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "NativeException", "(", "'Hack attempt'", ")", ";", "}", "// list files in directory", "$", "files", "=", "File", "::", "listFiles", "(", "'/upload/'", ".", "$", "type", ",", "$", "this", "->", "allowedExt", "[", "$", "type", "]", ")", ";", "// absolute path to relative URI", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "newName", "=", "Str", "::", "sub", "(", "$", "file", ",", "Str", "::", "length", "(", "root", ")", "+", "1", ")", ";", "$", "relative", "[", "]", "=", "trim", "(", "Str", "::", "replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "newName", ")", ",", "'/'", ")", ";", "}", "// generate response", "return", "App", "::", "$", "View", "->", "render", "(", "'editor/browse'", ",", "[", "'callbackName'", "=>", "App", "::", "$", "Security", "->", "strip_tags", "(", "App", "::", "$", "Request", "->", "query", "->", "get", "(", "'CKEditor'", ")", ")", ",", "'callbackId'", "=>", "(", "int", ")", "App", "::", "$", "Request", "->", "query", "->", "get", "(", "'CKEditorFuncNum'", ")", ",", "'files'", "=>", "$", "relative", ",", "'type'", "=>", "$", "type", "]", ",", "__DIR__", ")", ";", "}" ]
Browse files from ckeditor @param string $type @throws NativeException @throws \Ffcms\Core\Exception\SyntaxException @return string
[ "Browse", "files", "from", "ckeditor" ]
ed07f750dbb9567f7e7390ed5f00b005890128b2
https://github.com/phpffcms/ffcms-ckeditor/blob/ed07f750dbb9567f7e7390ed5f00b005890128b2/src/Ffcms/Apps/Api/Ckeditor/Editor.php#L49-L73
5,730
phpffcms/ffcms-ckeditor
src/Ffcms/Apps/Api/Ckeditor/Editor.php
Editor.actionUpload
public function actionUpload($type) { /** @var $loadFile \Symfony\Component\HttpFoundation\File\UploadedFile */ $loadFile = App::$Request->files->get('upload'); if ($loadFile === null || $loadFile->getError() !== 0) return $this->errorResponse(__('File upload failed')); // get file extension $fileExt = '.' . $loadFile->guessExtension(); // check if this request type is allowed if ($this->allowedExt[$type] === null || !Any::isArray($this->allowedExt[$type])) throw new NativeException('Hack attempt'); // check if this file extension is allowed to upload if (!Arr::in($fileExt, $this->allowedExt[$type])) { return $this->errorResponse(__('This file type is not allowed to upload')); } $date = Date::convertToDatetime(time(), 'd-m-Y'); // create file hash based on name-size $fileNewName = App::$Security->simpleHash($loadFile->getFilename() . $loadFile->getSize()) . $fileExt; $savePath = Normalize::diskFullPath('/upload/' . $type . '/' . $date); // save file from tmp to regular $loadFile->move($savePath, $fileNewName); // generate URI of uploaded file $url = '/upload/' . $type . '/' . $date . '/' . $fileNewName; return App::$View->render('editor/load_success', [ 'callbackId' => (int)App::$Request->query->get('CKEditorFuncNum'), 'url' => $url ], __DIR__); }
php
public function actionUpload($type) { /** @var $loadFile \Symfony\Component\HttpFoundation\File\UploadedFile */ $loadFile = App::$Request->files->get('upload'); if ($loadFile === null || $loadFile->getError() !== 0) return $this->errorResponse(__('File upload failed')); // get file extension $fileExt = '.' . $loadFile->guessExtension(); // check if this request type is allowed if ($this->allowedExt[$type] === null || !Any::isArray($this->allowedExt[$type])) throw new NativeException('Hack attempt'); // check if this file extension is allowed to upload if (!Arr::in($fileExt, $this->allowedExt[$type])) { return $this->errorResponse(__('This file type is not allowed to upload')); } $date = Date::convertToDatetime(time(), 'd-m-Y'); // create file hash based on name-size $fileNewName = App::$Security->simpleHash($loadFile->getFilename() . $loadFile->getSize()) . $fileExt; $savePath = Normalize::diskFullPath('/upload/' . $type . '/' . $date); // save file from tmp to regular $loadFile->move($savePath, $fileNewName); // generate URI of uploaded file $url = '/upload/' . $type . '/' . $date . '/' . $fileNewName; return App::$View->render('editor/load_success', [ 'callbackId' => (int)App::$Request->query->get('CKEditorFuncNum'), 'url' => $url ], __DIR__); }
[ "public", "function", "actionUpload", "(", "$", "type", ")", "{", "/** @var $loadFile \\Symfony\\Component\\HttpFoundation\\File\\UploadedFile */", "$", "loadFile", "=", "App", "::", "$", "Request", "->", "files", "->", "get", "(", "'upload'", ")", ";", "if", "(", "$", "loadFile", "===", "null", "||", "$", "loadFile", "->", "getError", "(", ")", "!==", "0", ")", "return", "$", "this", "->", "errorResponse", "(", "__", "(", "'File upload failed'", ")", ")", ";", "// get file extension", "$", "fileExt", "=", "'.'", ".", "$", "loadFile", "->", "guessExtension", "(", ")", ";", "// check if this request type is allowed", "if", "(", "$", "this", "->", "allowedExt", "[", "$", "type", "]", "===", "null", "||", "!", "Any", "::", "isArray", "(", "$", "this", "->", "allowedExt", "[", "$", "type", "]", ")", ")", "throw", "new", "NativeException", "(", "'Hack attempt'", ")", ";", "// check if this file extension is allowed to upload", "if", "(", "!", "Arr", "::", "in", "(", "$", "fileExt", ",", "$", "this", "->", "allowedExt", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "errorResponse", "(", "__", "(", "'This file type is not allowed to upload'", ")", ")", ";", "}", "$", "date", "=", "Date", "::", "convertToDatetime", "(", "time", "(", ")", ",", "'d-m-Y'", ")", ";", "// create file hash based on name-size", "$", "fileNewName", "=", "App", "::", "$", "Security", "->", "simpleHash", "(", "$", "loadFile", "->", "getFilename", "(", ")", ".", "$", "loadFile", "->", "getSize", "(", ")", ")", ".", "$", "fileExt", ";", "$", "savePath", "=", "Normalize", "::", "diskFullPath", "(", "'/upload/'", ".", "$", "type", ".", "'/'", ".", "$", "date", ")", ";", "// save file from tmp to regular", "$", "loadFile", "->", "move", "(", "$", "savePath", ",", "$", "fileNewName", ")", ";", "// generate URI of uploaded file", "$", "url", "=", "'/upload/'", ".", "$", "type", ".", "'/'", ".", "$", "date", ".", "'/'", ".", "$", "fileNewName", ";", "return", "App", "::", "$", "View", "->", "render", "(", "'editor/load_success'", ",", "[", "'callbackId'", "=>", "(", "int", ")", "App", "::", "$", "Request", "->", "query", "->", "get", "(", "'CKEditorFuncNum'", ")", ",", "'url'", "=>", "$", "url", "]", ",", "__DIR__", ")", ";", "}" ]
Upload files from ckeditor @param string $type @return string @throws NativeException @throws \Ffcms\Core\Exception\SyntaxException
[ "Upload", "files", "from", "ckeditor" ]
ed07f750dbb9567f7e7390ed5f00b005890128b2
https://github.com/phpffcms/ffcms-ckeditor/blob/ed07f750dbb9567f7e7390ed5f00b005890128b2/src/Ffcms/Apps/Api/Ckeditor/Editor.php#L82-L117
5,731
phpffcms/ffcms-ckeditor
src/Ffcms/Apps/Api/Ckeditor/Editor.php
Editor.errorResponse
private function errorResponse($message = null) { if ($message === null) $message = 'Unknown error'; return App::$View->render('editor/load_error', [ 'callbackId' => (int)App::$Request->query->get('CKEditorFuncNum'), 'message' => $message ],__DIR__); }
php
private function errorResponse($message = null) { if ($message === null) $message = 'Unknown error'; return App::$View->render('editor/load_error', [ 'callbackId' => (int)App::$Request->query->get('CKEditorFuncNum'), 'message' => $message ],__DIR__); }
[ "private", "function", "errorResponse", "(", "$", "message", "=", "null", ")", "{", "if", "(", "$", "message", "===", "null", ")", "$", "message", "=", "'Unknown error'", ";", "return", "App", "::", "$", "View", "->", "render", "(", "'editor/load_error'", ",", "[", "'callbackId'", "=>", "(", "int", ")", "App", "::", "$", "Request", "->", "query", "->", "get", "(", "'CKEditorFuncNum'", ")", ",", "'message'", "=>", "$", "message", "]", ",", "__DIR__", ")", ";", "}" ]
Return error message for ckeditor API @param string|null $message @return string @throws \Ffcms\Core\Exception\SyntaxException @return string
[ "Return", "error", "message", "for", "ckeditor", "API" ]
ed07f750dbb9567f7e7390ed5f00b005890128b2
https://github.com/phpffcms/ffcms-ckeditor/blob/ed07f750dbb9567f7e7390ed5f00b005890128b2/src/Ffcms/Apps/Api/Ckeditor/Editor.php#L126-L135
5,732
agentmedia/phine-forms
src/Forms/Modules/Frontend/Base/FieldModule.php
FieldModule.Value
protected function Value($fieldName, $defaultValue) { $form = Form::Current(); if (!$form) { return $defaultValue; } return $form->GetValue($fieldName, $defaultValue); }
php
protected function Value($fieldName, $defaultValue) { $form = Form::Current(); if (!$form) { return $defaultValue; } return $form->GetValue($fieldName, $defaultValue); }
[ "protected", "function", "Value", "(", "$", "fieldName", ",", "$", "defaultValue", ")", "{", "$", "form", "=", "Form", "::", "Current", "(", ")", ";", "if", "(", "!", "$", "form", ")", "{", "return", "$", "defaultValue", ";", "}", "return", "$", "form", "->", "GetValue", "(", "$", "fieldName", ",", "$", "defaultValue", ")", ";", "}" ]
Gets the submitted value or the default value if nothing submitted @param string $fieldName The field name @param string $defaultValue @return string Returns the submitted value or the defaut value if form not yet triggered
[ "Gets", "the", "submitted", "value", "or", "the", "default", "value", "if", "nothing", "submitted" ]
cd7a92ea443756bef5885a9e8f59ad6b8d2771fc
https://github.com/agentmedia/phine-forms/blob/cd7a92ea443756bef5885a9e8f59ad6b8d2771fc/src/Forms/Modules/Frontend/Base/FieldModule.php#L67-L73
5,733
headzoo/core
src/Headzoo/Core/Exceptions/PHPException.php
PHPException.factory
public static function factory($message, $code, $file, $line, \Exception $prev = null) { $exception = null; switch($code) { case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_CORE_WARNING: $exception = PHPWarningException::class; break; case E_NOTICE: case E_USER_NOTICE: $exception = PHPNoticeException::class; break; case E_DEPRECATED: case E_USER_DEPRECATED: $exception = PHPDepreciatedException::class; break; case E_STRICT: $exception = PHPStrictException::class; break; case E_PARSE: $exception = PHPParseException::class; break; default: $exception = PHPErrorException::class; break; } return new $exception( $message, $code, $file, $line, $prev ); }
php
public static function factory($message, $code, $file, $line, \Exception $prev = null) { $exception = null; switch($code) { case E_WARNING: case E_USER_WARNING: case E_COMPILE_WARNING: case E_CORE_WARNING: $exception = PHPWarningException::class; break; case E_NOTICE: case E_USER_NOTICE: $exception = PHPNoticeException::class; break; case E_DEPRECATED: case E_USER_DEPRECATED: $exception = PHPDepreciatedException::class; break; case E_STRICT: $exception = PHPStrictException::class; break; case E_PARSE: $exception = PHPParseException::class; break; default: $exception = PHPErrorException::class; break; } return new $exception( $message, $code, $file, $line, $prev ); }
[ "public", "static", "function", "factory", "(", "$", "message", ",", "$", "code", ",", "$", "file", ",", "$", "line", ",", "\\", "Exception", "$", "prev", "=", "null", ")", "{", "$", "exception", "=", "null", ";", "switch", "(", "$", "code", ")", "{", "case", "E_WARNING", ":", "case", "E_USER_WARNING", ":", "case", "E_COMPILE_WARNING", ":", "case", "E_CORE_WARNING", ":", "$", "exception", "=", "PHPWarningException", "::", "class", ";", "break", ";", "case", "E_NOTICE", ":", "case", "E_USER_NOTICE", ":", "$", "exception", "=", "PHPNoticeException", "::", "class", ";", "break", ";", "case", "E_DEPRECATED", ":", "case", "E_USER_DEPRECATED", ":", "$", "exception", "=", "PHPDepreciatedException", "::", "class", ";", "break", ";", "case", "E_STRICT", ":", "$", "exception", "=", "PHPStrictException", "::", "class", ";", "break", ";", "case", "E_PARSE", ":", "$", "exception", "=", "PHPParseException", "::", "class", ";", "break", ";", "default", ":", "$", "exception", "=", "PHPErrorException", "::", "class", ";", "break", ";", "}", "return", "new", "$", "exception", "(", "$", "message", ",", "$", "code", ",", "$", "file", ",", "$", "line", ",", "$", "prev", ")", ";", "}" ]
Returns an exception for the given code The value of $code should be one of the E_ERROR constants. This method will return the correct PHPException instance for that code. For example, if $code == E_WARNING, an instance of PHPWarningException is returned. @param string $message The error message @param int $code The error code @param string $file The file where the error occurred @param int $line The line in the file where the error occurred @param \Exception $prev The previous exception @return PHPException
[ "Returns", "an", "exception", "for", "the", "given", "code" ]
1e574813e197aa827b3e952f8caa81be31a8b5b5
https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/Exceptions/PHPException.php#L25-L61
5,734
phlexible/phlexible
src/Phlexible/Bundle/DashboardBundle/Controller/PortletController.php
PortletController.portletsAction
public function portletsAction() { $securityContext = $this->get('security.context'); $data = []; foreach ($this->get('phlexible_dashboard.portlets')->all() as $portlet) { if ($portlet->hasRole() && !$securityContext->isGranted($portlet->getRole())) { continue; } $data[] = $portlet->toArray(); } return new JsonResponse($data); }
php
public function portletsAction() { $securityContext = $this->get('security.context'); $data = []; foreach ($this->get('phlexible_dashboard.portlets')->all() as $portlet) { if ($portlet->hasRole() && !$securityContext->isGranted($portlet->getRole())) { continue; } $data[] = $portlet->toArray(); } return new JsonResponse($data); }
[ "public", "function", "portletsAction", "(", ")", "{", "$", "securityContext", "=", "$", "this", "->", "get", "(", "'security.context'", ")", ";", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "get", "(", "'phlexible_dashboard.portlets'", ")", "->", "all", "(", ")", "as", "$", "portlet", ")", "{", "if", "(", "$", "portlet", "->", "hasRole", "(", ")", "&&", "!", "$", "securityContext", "->", "isGranted", "(", "$", "portlet", "->", "getRole", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "data", "[", "]", "=", "$", "portlet", "->", "toArray", "(", ")", ";", "}", "return", "new", "JsonResponse", "(", "$", "data", ")", ";", "}" ]
Return portlets. @return JsonResponse @Route("", name="dashboard_portlets") @Method("GET") @ApiDoc( description="Returns a list of user portlets" )
[ "Return", "portlets", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/DashboardBundle/Controller/PortletController.php#L40-L54
5,735
phlexible/phlexible
src/Phlexible/Bundle/DashboardBundle/Controller/PortletController.php
PortletController.saveAction
public function saveAction(Request $request) { $portlets = $request->request->get('portlets'); $portlets = json_decode($portlets, true); if (!is_array($portlets)) { return new ResultResponse(false, 'Portlets data invalid.'); } $user = $this->getUser(); $user->setProperty('portlets', json_encode($portlets)); $this->get('phlexible_user.user_manager')->updateUser($user); return new ResultResponse(true, 'Portlets saved.'); }
php
public function saveAction(Request $request) { $portlets = $request->request->get('portlets'); $portlets = json_decode($portlets, true); if (!is_array($portlets)) { return new ResultResponse(false, 'Portlets data invalid.'); } $user = $this->getUser(); $user->setProperty('portlets', json_encode($portlets)); $this->get('phlexible_user.user_manager')->updateUser($user); return new ResultResponse(true, 'Portlets saved.'); }
[ "public", "function", "saveAction", "(", "Request", "$", "request", ")", "{", "$", "portlets", "=", "$", "request", "->", "request", "->", "get", "(", "'portlets'", ")", ";", "$", "portlets", "=", "json_decode", "(", "$", "portlets", ",", "true", ")", ";", "if", "(", "!", "is_array", "(", "$", "portlets", ")", ")", "{", "return", "new", "ResultResponse", "(", "false", ",", "'Portlets data invalid.'", ")", ";", "}", "$", "user", "=", "$", "this", "->", "getUser", "(", ")", ";", "$", "user", "->", "setProperty", "(", "'portlets'", ",", "json_encode", "(", "$", "portlets", ")", ")", ";", "$", "this", "->", "get", "(", "'phlexible_user.user_manager'", ")", "->", "updateUser", "(", "$", "user", ")", ";", "return", "new", "ResultResponse", "(", "true", ",", "'Portlets saved.'", ")", ";", "}" ]
Save portlets. @param Request $request @return ResultResponse @Route("/save", name="dashboard_portlets_save") @Method("POST") @ApiDoc( description="Save user portlets", parameters={ {"name"="portlets", "dataType"="array", "required"=true, "description"="Portlet data"} } )
[ "Save", "portlets", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/DashboardBundle/Controller/PortletController.php#L71-L86
5,736
bugotech/http
src/Controller.php
Controller.validate
protected function validate(array $rules, $values = null, array $customAttrs = []) { // Se os valores forem nulos, buscar no request if (is_null($values)) { $values = request()->all(); } // Validar valores pela regra return Validator::validate($values, $rules, $customAttrs); }
php
protected function validate(array $rules, $values = null, array $customAttrs = []) { // Se os valores forem nulos, buscar no request if (is_null($values)) { $values = request()->all(); } // Validar valores pela regra return Validator::validate($values, $rules, $customAttrs); }
[ "protected", "function", "validate", "(", "array", "$", "rules", ",", "$", "values", "=", "null", ",", "array", "$", "customAttrs", "=", "[", "]", ")", "{", "// Se os valores forem nulos, buscar no request", "if", "(", "is_null", "(", "$", "values", ")", ")", "{", "$", "values", "=", "request", "(", ")", "->", "all", "(", ")", ";", "}", "// Validar valores pela regra", "return", "Validator", "::", "validate", "(", "$", "values", ",", "$", "rules", ",", "$", "customAttrs", ")", ";", "}" ]
Validar valores pela regra. @param array $rules @param array|null $values @param array $customAttrs @return bool
[ "Validar", "valores", "pela", "regra", "." ]
68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486
https://github.com/bugotech/http/blob/68c2e8a28eaa2e53f98a55d2f2ec0e33c83fd486/src/Controller.php#L82-L91
5,737
devbr/tools
Config/Devbr/Cli/Optimizer.php
Optimizer.save
function save(string $file = null) { if ($file == null) { $file = static::$configFile; } $a = null; foreach ($this as $k => $v) { $a[$k] = $v; } return file_put_contents($file, json_encode($a, JSON_PRETTY_PRINT)); }
php
function save(string $file = null) { if ($file == null) { $file = static::$configFile; } $a = null; foreach ($this as $k => $v) { $a[$k] = $v; } return file_put_contents($file, json_encode($a, JSON_PRETTY_PRINT)); }
[ "function", "save", "(", "string", "$", "file", "=", "null", ")", "{", "if", "(", "$", "file", "==", "null", ")", "{", "$", "file", "=", "static", "::", "$", "configFile", ";", "}", "$", "a", "=", "null", ";", "foreach", "(", "$", "this", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "a", "[", "$", "k", "]", "=", "$", "v", ";", "}", "return", "file_put_contents", "(", "$", "file", ",", "json_encode", "(", "$", "a", ",", "JSON_PRETTY_PRINT", ")", ")", ";", "}" ]
Save to Json config file @param string|null $file path to save @return bool|number number of bytes saved in file or FALSE.
[ "Save", "to", "Json", "config", "file" ]
f23f35172143b4ab2f45db37274fcc94d32e20e8
https://github.com/devbr/tools/blob/f23f35172143b4ab2f45db37274fcc94d32e20e8/Config/Devbr/Cli/Optimizer.php#L105-L116
5,738
devbr/tools
Config/Devbr/Cli/Optimizer.php
Optimizer.load
function load(string $file = null) { if ($file == null) { $file = static::$configFile; } if (!file_exists($file)) { return false; } $a = json_decode(file_get_contents($file)); if (isset($a->css)) { $this->css = $a->css; } if (isset($a->js)) { $this->js = $a->js; } if (isset($a->jss)) { $this->jss = $a->jss; } return true; }
php
function load(string $file = null) { if ($file == null) { $file = static::$configFile; } if (!file_exists($file)) { return false; } $a = json_decode(file_get_contents($file)); if (isset($a->css)) { $this->css = $a->css; } if (isset($a->js)) { $this->js = $a->js; } if (isset($a->jss)) { $this->jss = $a->jss; } return true; }
[ "function", "load", "(", "string", "$", "file", "=", "null", ")", "{", "if", "(", "$", "file", "==", "null", ")", "{", "$", "file", "=", "static", "::", "$", "configFile", ";", "}", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "return", "false", ";", "}", "$", "a", "=", "json_decode", "(", "file_get_contents", "(", "$", "file", ")", ")", ";", "if", "(", "isset", "(", "$", "a", "->", "css", ")", ")", "{", "$", "this", "->", "css", "=", "$", "a", "->", "css", ";", "}", "if", "(", "isset", "(", "$", "a", "->", "js", ")", ")", "{", "$", "this", "->", "js", "=", "$", "a", "->", "js", ";", "}", "if", "(", "isset", "(", "$", "a", "->", "jss", ")", ")", "{", "$", "this", "->", "jss", "=", "$", "a", "->", "jss", ";", "}", "return", "true", ";", "}" ]
Load configuration json file @param string|null $file path and filename @return bool success (treu/false)
[ "Load", "configuration", "json", "file" ]
f23f35172143b4ab2f45db37274fcc94d32e20e8
https://github.com/devbr/tools/blob/f23f35172143b4ab2f45db37274fcc94d32e20e8/Config/Devbr/Cli/Optimizer.php#L123-L147
5,739
xinc-develop/xinc-core
src/Plugin/Schedule/Sensor.php
Sensor.getNextBuildTime
public function getNextBuildTime(BuildInterface $lastJob = null) { if (file_exists($this->file)) { unlink($this->file); return time(); } return null; }
php
public function getNextBuildTime(BuildInterface $lastJob = null) { if (file_exists($this->file)) { unlink($this->file); return time(); } return null; }
[ "public", "function", "getNextBuildTime", "(", "BuildInterface", "$", "lastJob", "=", "null", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "file", ")", ")", "{", "unlink", "(", "$", "this", "->", "file", ")", ";", "return", "time", "(", ")", ";", "}", "return", "null", ";", "}" ]
Calculates the real next job runtime dependend on lastJob. @param Xinc::Core::Build::BuildInterface $lastJob @return int next job runtime as timestamp
[ "Calculates", "the", "real", "next", "job", "runtime", "dependend", "on", "lastJob", "." ]
4bb69a6afe19e1186950a3122cbfe0989823e0d6
https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Plugin/Schedule/Sensor.php#L105-L114
5,740
atelierspierrot/library
src/Library/HttpFundamental/ContentType.php
ContentType.prepareResponse
public function prepareResponse(Response $response) { $cto = $this->getContentTypeObject(); if (!empty($cto)) { $ctt_type = $cto->getContentType(); } else { $ctt_type = $this->getContentType(); } $response->setContentType($ctt_type); }
php
public function prepareResponse(Response $response) { $cto = $this->getContentTypeObject(); if (!empty($cto)) { $ctt_type = $cto->getContentType(); } else { $ctt_type = $this->getContentType(); } $response->setContentType($ctt_type); }
[ "public", "function", "prepareResponse", "(", "Response", "$", "response", ")", "{", "$", "cto", "=", "$", "this", "->", "getContentTypeObject", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "cto", ")", ")", "{", "$", "ctt_type", "=", "$", "cto", "->", "getContentType", "(", ")", ";", "}", "else", "{", "$", "ctt_type", "=", "$", "this", "->", "getContentType", "(", ")", ";", "}", "$", "response", "->", "setContentType", "(", "$", "ctt_type", ")", ";", "}" ]
Prepare the content of the response before to send it to client @param \Library\HttpFundamental\Response $response @return void
[ "Prepare", "the", "content", "of", "the", "response", "before", "to", "send", "it", "to", "client" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/HttpFundamental/ContentType.php#L169-L178
5,741
atelierspierrot/library
src/Library/HttpFundamental/ContentType.php
ContentType.parseContent
public function parseContent($content) { $cto = $this->getContentTypeObject(); if (!empty($cto)) { return $cto->parseContent($content); } else { return $content; } }
php
public function parseContent($content) { $cto = $this->getContentTypeObject(); if (!empty($cto)) { return $cto->parseContent($content); } else { return $content; } }
[ "public", "function", "parseContent", "(", "$", "content", ")", "{", "$", "cto", "=", "$", "this", "->", "getContentTypeObject", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "cto", ")", ")", "{", "return", "$", "cto", "->", "parseContent", "(", "$", "content", ")", ";", "}", "else", "{", "return", "$", "content", ";", "}", "}" ]
Parse an input content @param string $content @return mixed
[ "Parse", "an", "input", "content" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/HttpFundamental/ContentType.php#L186-L194
5,742
wigedev/simple-mvc
src/Renderer/ViewHelper/ViewHelperCollection.php
ViewHelperCollection.valid
public function valid() : bool { if ($this->pointer >= 0 && $this->pointer < count($this->members)) { return true; } return false; }
php
public function valid() : bool { if ($this->pointer >= 0 && $this->pointer < count($this->members)) { return true; } return false; }
[ "public", "function", "valid", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "pointer", ">=", "0", "&&", "$", "this", "->", "pointer", "<", "count", "(", "$", "this", "->", "members", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if the current position of the pointer is valid @return bool True if the pointer position is valid
[ "Check", "if", "the", "current", "position", "of", "the", "pointer", "is", "valid" ]
b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94
https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Renderer/ViewHelper/ViewHelperCollection.php#L111-L117
5,743
Stratadox/HydrationMapping
src/Property/Type/BooleanValue.php
BooleanValue.inProperty
public static function inProperty( string $name, array $truths = [true, 1, '1'], array $falsehoods = [false, 0, '0'] ): ExposesDataKey { $instance = parent::inProperty($name); assert($instance instanceof BooleanValue); $instance->truths = $truths; $instance->falsehoods = $falsehoods; return $instance; }
php
public static function inProperty( string $name, array $truths = [true, 1, '1'], array $falsehoods = [false, 0, '0'] ): ExposesDataKey { $instance = parent::inProperty($name); assert($instance instanceof BooleanValue); $instance->truths = $truths; $instance->falsehoods = $falsehoods; return $instance; }
[ "public", "static", "function", "inProperty", "(", "string", "$", "name", ",", "array", "$", "truths", "=", "[", "true", ",", "1", ",", "'1'", "]", ",", "array", "$", "falsehoods", "=", "[", "false", ",", "0", ",", "'0'", "]", ")", ":", "ExposesDataKey", "{", "$", "instance", "=", "parent", "::", "inProperty", "(", "$", "name", ")", ";", "assert", "(", "$", "instance", "instanceof", "BooleanValue", ")", ";", "$", "instance", "->", "truths", "=", "$", "truths", ";", "$", "instance", "->", "falsehoods", "=", "$", "falsehoods", ";", "return", "$", "instance", ";", "}" ]
Creates a new mapping for the boolean type object property. @param string $name The name of both the key and the property. @param array $truths The values that should be considered true. @param array $falsehoods The values that should be considered false. @return ExposesDataKey The boolean mapping object.
[ "Creates", "a", "new", "mapping", "for", "the", "boolean", "type", "object", "property", "." ]
b145deaaf76ab8c8060f0cba1a8c6f73da375982
https://github.com/Stratadox/HydrationMapping/blob/b145deaaf76ab8c8060f0cba1a8c6f73da375982/src/Property/Type/BooleanValue.php#L30-L42
5,744
Stratadox/HydrationMapping
src/Property/Type/BooleanValue.php
BooleanValue.inPropertyWithDifferentKey
public static function inPropertyWithDifferentKey( string $name, string $key, array $truths = [true, 1, '1'], array $falsehoods = [false, 0, '0'] ): ExposesDataKey { $instance = parent::inPropertyWithDifferentKey($name, $key); assert($instance instanceof BooleanValue); $instance->truths = $truths; $instance->falsehoods = $falsehoods; return $instance; }
php
public static function inPropertyWithDifferentKey( string $name, string $key, array $truths = [true, 1, '1'], array $falsehoods = [false, 0, '0'] ): ExposesDataKey { $instance = parent::inPropertyWithDifferentKey($name, $key); assert($instance instanceof BooleanValue); $instance->truths = $truths; $instance->falsehoods = $falsehoods; return $instance; }
[ "public", "static", "function", "inPropertyWithDifferentKey", "(", "string", "$", "name", ",", "string", "$", "key", ",", "array", "$", "truths", "=", "[", "true", ",", "1", ",", "'1'", "]", ",", "array", "$", "falsehoods", "=", "[", "false", ",", "0", ",", "'0'", "]", ")", ":", "ExposesDataKey", "{", "$", "instance", "=", "parent", "::", "inPropertyWithDifferentKey", "(", "$", "name", ",", "$", "key", ")", ";", "assert", "(", "$", "instance", "instanceof", "BooleanValue", ")", ";", "$", "instance", "->", "truths", "=", "$", "truths", ";", "$", "instance", "->", "falsehoods", "=", "$", "falsehoods", ";", "return", "$", "instance", ";", "}" ]
Creates a new mapping for the boolean type object property, using the data from a specific key. @param string $name The name of the property. @param string $key The array key to use. @param array $truths The values that should be considered true. @param array $falsehoods The values that should be considered false. @return ExposesDataKey The boolean mapping object.
[ "Creates", "a", "new", "mapping", "for", "the", "boolean", "type", "object", "property", "using", "the", "data", "from", "a", "specific", "key", "." ]
b145deaaf76ab8c8060f0cba1a8c6f73da375982
https://github.com/Stratadox/HydrationMapping/blob/b145deaaf76ab8c8060f0cba1a8c6f73da375982/src/Property/Type/BooleanValue.php#L54-L67
5,745
vphantom/pyritephp
src/Pyrite/Core/Filters.php
Filters.protectEmail
public static function protectEmail($email) { $chunks = explode('@', $email); $chunks[0] = substr($chunks[0], 0, 2) . '****'; return implode('@', $chunks); }
php
public static function protectEmail($email) { $chunks = explode('@', $email); $chunks[0] = substr($chunks[0], 0, 2) . '****'; return implode('@', $chunks); }
[ "public", "static", "function", "protectEmail", "(", "$", "email", ")", "{", "$", "chunks", "=", "explode", "(", "'@'", ",", "$", "email", ")", ";", "$", "chunks", "[", "0", "]", "=", "substr", "(", "$", "chunks", "[", "0", "]", ",", "0", ",", "2", ")", ".", "'****'", ";", "return", "implode", "(", "'@'", ",", "$", "chunks", ")", ";", "}" ]
Hide most of the user part of an e-mail address @param string $email String to filter @return string
[ "Hide", "most", "of", "the", "user", "part", "of", "an", "e", "-", "mail", "address" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/Filters.php#L106-L111
5,746
vphantom/pyritephp
src/Pyrite/Core/Filters.php
Filters.html2text
public static function html2text($html) { libxml_use_internal_errors(true); $doc = new \DOMDocument(); // Hack to force UTF-8 processing on incomplete documents // From: http://php.net/manual/en/domdocument.loadhtml.php#95251 $doc->loadHTML('<?xml encoding="UTF-8">' . $html, LIBXML_NOERROR | LIBXML_NOWARNING); foreach ($doc->childNodes as $item) { if ($item->nodeType == XML_PI_NODE) { $doc->removeChild($item); // Remove the hack we inserted above break; // We know there is only one }; }; $doc->encoding = 'UTF-8'; // Proper way to set encoding return self::_dom2text($doc); }
php
public static function html2text($html) { libxml_use_internal_errors(true); $doc = new \DOMDocument(); // Hack to force UTF-8 processing on incomplete documents // From: http://php.net/manual/en/domdocument.loadhtml.php#95251 $doc->loadHTML('<?xml encoding="UTF-8">' . $html, LIBXML_NOERROR | LIBXML_NOWARNING); foreach ($doc->childNodes as $item) { if ($item->nodeType == XML_PI_NODE) { $doc->removeChild($item); // Remove the hack we inserted above break; // We know there is only one }; }; $doc->encoding = 'UTF-8'; // Proper way to set encoding return self::_dom2text($doc); }
[ "public", "static", "function", "html2text", "(", "$", "html", ")", "{", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "doc", "=", "new", "\\", "DOMDocument", "(", ")", ";", "// Hack to force UTF-8 processing on incomplete documents", "// From: http://php.net/manual/en/domdocument.loadhtml.php#95251", "$", "doc", "->", "loadHTML", "(", "'<?xml encoding=\"UTF-8\">'", ".", "$", "html", ",", "LIBXML_NOERROR", "|", "LIBXML_NOWARNING", ")", ";", "foreach", "(", "$", "doc", "->", "childNodes", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "nodeType", "==", "XML_PI_NODE", ")", "{", "$", "doc", "->", "removeChild", "(", "$", "item", ")", ";", "// Remove the hack we inserted above", "break", ";", "// We know there is only one", "}", ";", "}", ";", "$", "doc", "->", "encoding", "=", "'UTF-8'", ";", "// Proper way to set encoding", "return", "self", "::", "_dom2text", "(", "$", "doc", ")", ";", "}" ]
Convert an HTML string to a plain text approximation This is a quick and dirty hack for the purpose of creating text/plain alternatives to text/html E-mail messages. There are a lot of edge cases which are not handled well or at all. @param string $html Source HTML document (with or without HTML/HEAD/BODY) @return string
[ "Convert", "an", "HTML", "string", "to", "a", "plain", "text", "approximation" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Core/Filters.php#L124-L141
5,747
chrisenytc/livcommander
src/Commander/MessageManager.php
MessageManager.fileReader
private function fileReader($filename) { //Check if the path is defined if(empty($this->message_path)) { $this->message_path = __DIR__.DIRECTORY_SEPARATOR.'messages'.DIRECTORY_SEPARATOR; } //Read message file and return content $message = file_get_contents($this->message_path.$filename.'.livia'); //Return the message return $message; }
php
private function fileReader($filename) { //Check if the path is defined if(empty($this->message_path)) { $this->message_path = __DIR__.DIRECTORY_SEPARATOR.'messages'.DIRECTORY_SEPARATOR; } //Read message file and return content $message = file_get_contents($this->message_path.$filename.'.livia'); //Return the message return $message; }
[ "private", "function", "fileReader", "(", "$", "filename", ")", "{", "//Check if the path is defined", "if", "(", "empty", "(", "$", "this", "->", "message_path", ")", ")", "{", "$", "this", "->", "message_path", "=", "__DIR__", ".", "DIRECTORY_SEPARATOR", ".", "'messages'", ".", "DIRECTORY_SEPARATOR", ";", "}", "//Read message file and return content", "$", "message", "=", "file_get_contents", "(", "$", "this", "->", "message_path", ".", "$", "filename", ".", "'.livia'", ")", ";", "//Return the message", "return", "$", "message", ";", "}" ]
Provide a FileReader. @param string $filename @return string
[ "Provide", "a", "FileReader", "." ]
8cf6ad3111ea4500fb714481bab2ca9793b1b1bc
https://github.com/chrisenytc/livcommander/blob/8cf6ad3111ea4500fb714481bab2ca9793b1b1bc/src/Commander/MessageManager.php#L73-L85
5,748
chrisenytc/livcommander
src/Commander/MessageManager.php
MessageManager.getNotification
protected function getNotification($name, $status = FALSE) { //If $status is FALSE show primary notification if($status === FALSE) { //Generate a message if($this->commandExists('notify-send')) { shell_exec('notify-send "'.$this->getAppName().' Tasks" "Running '.$name.'..." -i dialog-information'); } //Show required message echo "\n"; echo "\t", $this->colorize('Running '.$name.'...', 'info'); echo "\n"; } else { //If $status is TRUE show success notification //Generate a message if($this->commandExists('notify-send')) { shell_exec('notify-send "'.$this->getAppName().' Tasks" "'.$name.' Task Completed!" -i dialog-ok'); } //Show required message echo "\n"; echo "\t", $this->colorize($name.' Task Completed!', 'success'); echo "\n"; } }
php
protected function getNotification($name, $status = FALSE) { //If $status is FALSE show primary notification if($status === FALSE) { //Generate a message if($this->commandExists('notify-send')) { shell_exec('notify-send "'.$this->getAppName().' Tasks" "Running '.$name.'..." -i dialog-information'); } //Show required message echo "\n"; echo "\t", $this->colorize('Running '.$name.'...', 'info'); echo "\n"; } else { //If $status is TRUE show success notification //Generate a message if($this->commandExists('notify-send')) { shell_exec('notify-send "'.$this->getAppName().' Tasks" "'.$name.' Task Completed!" -i dialog-ok'); } //Show required message echo "\n"; echo "\t", $this->colorize($name.' Task Completed!', 'success'); echo "\n"; } }
[ "protected", "function", "getNotification", "(", "$", "name", ",", "$", "status", "=", "FALSE", ")", "{", "//If $status is FALSE show primary notification", "if", "(", "$", "status", "===", "FALSE", ")", "{", "//Generate a message", "if", "(", "$", "this", "->", "commandExists", "(", "'notify-send'", ")", ")", "{", "shell_exec", "(", "'notify-send \"'", ".", "$", "this", "->", "getAppName", "(", ")", ".", "' Tasks\" \"Running '", ".", "$", "name", ".", "'...\" -i dialog-information'", ")", ";", "}", "//Show required message", "echo", "\"\\n\"", ";", "echo", "\"\\t\"", ",", "$", "this", "->", "colorize", "(", "'Running '", ".", "$", "name", ".", "'...'", ",", "'info'", ")", ";", "echo", "\"\\n\"", ";", "}", "else", "{", "//If $status is TRUE show success notification", "//Generate a message", "if", "(", "$", "this", "->", "commandExists", "(", "'notify-send'", ")", ")", "{", "shell_exec", "(", "'notify-send \"'", ".", "$", "this", "->", "getAppName", "(", ")", ".", "' Tasks\" \"'", ".", "$", "name", ".", "' Task Completed!\" -i dialog-ok'", ")", ";", "}", "//Show required message", "echo", "\"\\n\"", ";", "echo", "\"\\t\"", ",", "$", "this", "->", "colorize", "(", "$", "name", ".", "' Task Completed!'", ",", "'success'", ")", ";", "echo", "\"\\n\"", ";", "}", "}" ]
Provide a NotificationManager. @param string $name @param boolean $status @return string
[ "Provide", "a", "NotificationManager", "." ]
8cf6ad3111ea4500fb714481bab2ca9793b1b1bc
https://github.com/chrisenytc/livcommander/blob/8cf6ad3111ea4500fb714481bab2ca9793b1b1bc/src/Commander/MessageManager.php#L159-L187
5,749
chrisenytc/livcommander
src/Commander/MessageManager.php
MessageManager.ask
public function ask($question) { //Show required message echo "\n"; echo "\t", $this->colorize($question, 'info'); echo "\n"; //Get user input echo "\t"; $response = trim(fgets(STDIN)); return $response; }
php
public function ask($question) { //Show required message echo "\n"; echo "\t", $this->colorize($question, 'info'); echo "\n"; //Get user input echo "\t"; $response = trim(fgets(STDIN)); return $response; }
[ "public", "function", "ask", "(", "$", "question", ")", "{", "//Show required message", "echo", "\"\\n\"", ";", "echo", "\"\\t\"", ",", "$", "this", "->", "colorize", "(", "$", "question", ",", "'info'", ")", ";", "echo", "\"\\n\"", ";", "//Get user input", "echo", "\"\\t\"", ";", "$", "response", "=", "trim", "(", "fgets", "(", "STDIN", ")", ")", ";", "return", "$", "response", ";", "}" ]
Provide a AskManager. @param string $question @return string
[ "Provide", "a", "AskManager", "." ]
8cf6ad3111ea4500fb714481bab2ca9793b1b1bc
https://github.com/chrisenytc/livcommander/blob/8cf6ad3111ea4500fb714481bab2ca9793b1b1bc/src/Commander/MessageManager.php#L210-L220
5,750
chrisenytc/livcommander
src/Commander/MessageManager.php
MessageManager.confirm
public function confirm($question, $default = 'yes') { //Show required message echo "\n"; echo "\t", $this->colorize($question." [$default] ", 'info'); echo " "; //Get user input $response = trim(fgets(STDIN)); //Check if $response is yes or not if($response == 'yes' || $response == 'no') { //If is yes or not return the response return $response; } else if(empty($response)) { //If response is empty return default value return $default; } else { //If not passed argument, repeat confirmation. $this->confirm($question, $default); } }
php
public function confirm($question, $default = 'yes') { //Show required message echo "\n"; echo "\t", $this->colorize($question." [$default] ", 'info'); echo " "; //Get user input $response = trim(fgets(STDIN)); //Check if $response is yes or not if($response == 'yes' || $response == 'no') { //If is yes or not return the response return $response; } else if(empty($response)) { //If response is empty return default value return $default; } else { //If not passed argument, repeat confirmation. $this->confirm($question, $default); } }
[ "public", "function", "confirm", "(", "$", "question", ",", "$", "default", "=", "'yes'", ")", "{", "//Show required message", "echo", "\"\\n\"", ";", "echo", "\"\\t\"", ",", "$", "this", "->", "colorize", "(", "$", "question", ".", "\" [$default] \"", ",", "'info'", ")", ";", "echo", "\" \"", ";", "//Get user input", "$", "response", "=", "trim", "(", "fgets", "(", "STDIN", ")", ")", ";", "//Check if $response is yes or not", "if", "(", "$", "response", "==", "'yes'", "||", "$", "response", "==", "'no'", ")", "{", "//If is yes or not return the response", "return", "$", "response", ";", "}", "else", "if", "(", "empty", "(", "$", "response", ")", ")", "{", "//If response is empty return default value", "return", "$", "default", ";", "}", "else", "{", "//If not passed argument, repeat confirmation.", "$", "this", "->", "confirm", "(", "$", "question", ",", "$", "default", ")", ";", "}", "}" ]
Provide a ConfirmManager. @param string $question @return string
[ "Provide", "a", "ConfirmManager", "." ]
8cf6ad3111ea4500fb714481bab2ca9793b1b1bc
https://github.com/chrisenytc/livcommander/blob/8cf6ad3111ea4500fb714481bab2ca9793b1b1bc/src/Commander/MessageManager.php#L228-L251
5,751
mszewcz/php-light-framework
src/Session/Handler.php
Handler.register
public static function register(): bool { static::init(); if (!\array_key_exists(static::$backend, static::$invokableClasses)) { throw new InvalidArgumentException('Unsupported session backend: '.static::$backend); } $handler = new static::$invokableClasses[static::$backend]; \session_save_path(static::$savePath); return \session_set_save_handler($handler, true); }
php
public static function register(): bool { static::init(); if (!\array_key_exists(static::$backend, static::$invokableClasses)) { throw new InvalidArgumentException('Unsupported session backend: '.static::$backend); } $handler = new static::$invokableClasses[static::$backend]; \session_save_path(static::$savePath); return \session_set_save_handler($handler, true); }
[ "public", "static", "function", "register", "(", ")", ":", "bool", "{", "static", "::", "init", "(", ")", ";", "if", "(", "!", "\\", "array_key_exists", "(", "static", "::", "$", "backend", ",", "static", "::", "$", "invokableClasses", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Unsupported session backend: '", ".", "static", "::", "$", "backend", ")", ";", "}", "$", "handler", "=", "new", "static", "::", "$", "invokableClasses", "[", "static", "::", "$", "backend", "]", ";", "\\", "session_save_path", "(", "static", "::", "$", "savePath", ")", ";", "return", "\\", "session_set_save_handler", "(", "$", "handler", ",", "true", ")", ";", "}" ]
Registers session handler @return bool
[ "Registers", "session", "handler" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Session/Handler.php#L54-L64
5,752
bishopb/vanilla
plugins/ProfileExtender/class.profileextender.plugin.php
ProfileExtenderPlugin.EntryController_RegisterBeforePassword_Handler
public function EntryController_RegisterBeforePassword_Handler($Sender) { $ProfileFields = $this->GetProfileFields(); $Sender->RegistrationFields = array(); foreach ($ProfileFields as $Name => $Field) { if (GetValue('OnRegister', $Field)) $Sender->RegistrationFields[$Name] = $Field; } include($this->GetView('registrationfields.php')); }
php
public function EntryController_RegisterBeforePassword_Handler($Sender) { $ProfileFields = $this->GetProfileFields(); $Sender->RegistrationFields = array(); foreach ($ProfileFields as $Name => $Field) { if (GetValue('OnRegister', $Field)) $Sender->RegistrationFields[$Name] = $Field; } include($this->GetView('registrationfields.php')); }
[ "public", "function", "EntryController_RegisterBeforePassword_Handler", "(", "$", "Sender", ")", "{", "$", "ProfileFields", "=", "$", "this", "->", "GetProfileFields", "(", ")", ";", "$", "Sender", "->", "RegistrationFields", "=", "array", "(", ")", ";", "foreach", "(", "$", "ProfileFields", "as", "$", "Name", "=>", "$", "Field", ")", "{", "if", "(", "GetValue", "(", "'OnRegister'", ",", "$", "Field", ")", ")", "$", "Sender", "->", "RegistrationFields", "[", "$", "Name", "]", "=", "$", "Field", ";", "}", "include", "(", "$", "this", "->", "GetView", "(", "'registrationfields.php'", ")", ")", ";", "}" ]
Add fields to registration forms.
[ "Add", "fields", "to", "registration", "forms", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/ProfileExtender/class.profileextender.plugin.php#L75-L83
5,753
bishopb/vanilla
plugins/ProfileExtender/class.profileextender.plugin.php
ProfileExtenderPlugin.EntryController_RegisterValidation_Handler
public function EntryController_RegisterValidation_Handler($Sender) { // Require new fields $ProfileFields = $this->GetProfileFields(); foreach ($ProfileFields as $Name => $Field) { // Check both so you can't break register form by requiring omitted field if (GetValue('Required', $Field) && GetValue('OnRegister', $Field)) $Sender->UserModel->Validation->ApplyRule($Name, 'Required', $Field['Label']." is required."); } }
php
public function EntryController_RegisterValidation_Handler($Sender) { // Require new fields $ProfileFields = $this->GetProfileFields(); foreach ($ProfileFields as $Name => $Field) { // Check both so you can't break register form by requiring omitted field if (GetValue('Required', $Field) && GetValue('OnRegister', $Field)) $Sender->UserModel->Validation->ApplyRule($Name, 'Required', $Field['Label']." is required."); } }
[ "public", "function", "EntryController_RegisterValidation_Handler", "(", "$", "Sender", ")", "{", "// Require new fields", "$", "ProfileFields", "=", "$", "this", "->", "GetProfileFields", "(", ")", ";", "foreach", "(", "$", "ProfileFields", "as", "$", "Name", "=>", "$", "Field", ")", "{", "// Check both so you can't break register form by requiring omitted field", "if", "(", "GetValue", "(", "'Required'", ",", "$", "Field", ")", "&&", "GetValue", "(", "'OnRegister'", ",", "$", "Field", ")", ")", "$", "Sender", "->", "UserModel", "->", "Validation", "->", "ApplyRule", "(", "$", "Name", ",", "'Required'", ",", "$", "Field", "[", "'Label'", "]", ".", "\" is required.\"", ")", ";", "}", "}" ]
Required fields on registration forms.
[ "Required", "fields", "on", "registration", "forms", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/ProfileExtender/class.profileextender.plugin.php#L88-L96
5,754
bishopb/vanilla
plugins/ProfileExtender/class.profileextender.plugin.php
ProfileExtenderPlugin.ParseSpecialFields
public function ParseSpecialFields($Fields = array()) { if (!is_array($Fields)) return $Fields; foreach ($Fields as $Label => $Value) { switch ($Label) { case 'Twitter': $Fields['Twitter'] = Anchor('@'.$Value, 'http://twitter.com/'.$Value); break; case 'Facebook': $Fields['Facebook'] = Anchor($Value, 'http://facebook.com/'.$Value); break; case 'LinkedIn': $Fields['LinkedIn'] = Anchor($Value, 'http://www.linkedin.com/in/'.$Value); break; case 'Google': $Fields['Google'] = Anchor('Google+', $Value, '', array('rel' => 'me')); break; case 'Website': $Fields['Website'] = Anchor($Value, $Value); break; case 'Real Name': $Fields['Real Name'] = Wrap(htmlspecialchars($Value), 'span', array('itemprop' => 'name')); break; } } return $Fields; }
php
public function ParseSpecialFields($Fields = array()) { if (!is_array($Fields)) return $Fields; foreach ($Fields as $Label => $Value) { switch ($Label) { case 'Twitter': $Fields['Twitter'] = Anchor('@'.$Value, 'http://twitter.com/'.$Value); break; case 'Facebook': $Fields['Facebook'] = Anchor($Value, 'http://facebook.com/'.$Value); break; case 'LinkedIn': $Fields['LinkedIn'] = Anchor($Value, 'http://www.linkedin.com/in/'.$Value); break; case 'Google': $Fields['Google'] = Anchor('Google+', $Value, '', array('rel' => 'me')); break; case 'Website': $Fields['Website'] = Anchor($Value, $Value); break; case 'Real Name': $Fields['Real Name'] = Wrap(htmlspecialchars($Value), 'span', array('itemprop' => 'name')); break; } } return $Fields; }
[ "public", "function", "ParseSpecialFields", "(", "$", "Fields", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "Fields", ")", ")", "return", "$", "Fields", ";", "foreach", "(", "$", "Fields", "as", "$", "Label", "=>", "$", "Value", ")", "{", "switch", "(", "$", "Label", ")", "{", "case", "'Twitter'", ":", "$", "Fields", "[", "'Twitter'", "]", "=", "Anchor", "(", "'@'", ".", "$", "Value", ",", "'http://twitter.com/'", ".", "$", "Value", ")", ";", "break", ";", "case", "'Facebook'", ":", "$", "Fields", "[", "'Facebook'", "]", "=", "Anchor", "(", "$", "Value", ",", "'http://facebook.com/'", ".", "$", "Value", ")", ";", "break", ";", "case", "'LinkedIn'", ":", "$", "Fields", "[", "'LinkedIn'", "]", "=", "Anchor", "(", "$", "Value", ",", "'http://www.linkedin.com/in/'", ".", "$", "Value", ")", ";", "break", ";", "case", "'Google'", ":", "$", "Fields", "[", "'Google'", "]", "=", "Anchor", "(", "'Google+'", ",", "$", "Value", ",", "''", ",", "array", "(", "'rel'", "=>", "'me'", ")", ")", ";", "break", ";", "case", "'Website'", ":", "$", "Fields", "[", "'Website'", "]", "=", "Anchor", "(", "$", "Value", ",", "$", "Value", ")", ";", "break", ";", "case", "'Real Name'", ":", "$", "Fields", "[", "'Real Name'", "]", "=", "Wrap", "(", "htmlspecialchars", "(", "$", "Value", ")", ",", "'span'", ",", "array", "(", "'itemprop'", "=>", "'name'", ")", ")", ";", "break", ";", "}", "}", "return", "$", "Fields", ";", "}" ]
Special manipulations.
[ "Special", "manipulations", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/ProfileExtender/class.profileextender.plugin.php#L101-L129
5,755
bishopb/vanilla
plugins/ProfileExtender/class.profileextender.plugin.php
ProfileExtenderPlugin.GetProfileFields
private function GetProfileFields() { $Fields = C('ProfileExtender.Fields', array()); if (!is_array($Fields)) $Fields = array(); // Data checks foreach ($Fields as $Name => $Field) { // Require an array for each field if (!is_array($Field) || strlen($Name) < 1) { unset($Fields[$Name]); //RemoveFromConfig('ProfileExtender.Fields.'.$Name); } // Verify field form type if (!isset($Field['FormType'])) $Fields[$Name]['FormType'] = 'TextBox'; elseif (!array_key_exists($Field['FormType'], $this->FormTypes)) unset($this->ProfileFields[$Name]); } return $Fields; }
php
private function GetProfileFields() { $Fields = C('ProfileExtender.Fields', array()); if (!is_array($Fields)) $Fields = array(); // Data checks foreach ($Fields as $Name => $Field) { // Require an array for each field if (!is_array($Field) || strlen($Name) < 1) { unset($Fields[$Name]); //RemoveFromConfig('ProfileExtender.Fields.'.$Name); } // Verify field form type if (!isset($Field['FormType'])) $Fields[$Name]['FormType'] = 'TextBox'; elseif (!array_key_exists($Field['FormType'], $this->FormTypes)) unset($this->ProfileFields[$Name]); } return $Fields; }
[ "private", "function", "GetProfileFields", "(", ")", "{", "$", "Fields", "=", "C", "(", "'ProfileExtender.Fields'", ",", "array", "(", ")", ")", ";", "if", "(", "!", "is_array", "(", "$", "Fields", ")", ")", "$", "Fields", "=", "array", "(", ")", ";", "// Data checks", "foreach", "(", "$", "Fields", "as", "$", "Name", "=>", "$", "Field", ")", "{", "// Require an array for each field", "if", "(", "!", "is_array", "(", "$", "Field", ")", "||", "strlen", "(", "$", "Name", ")", "<", "1", ")", "{", "unset", "(", "$", "Fields", "[", "$", "Name", "]", ")", ";", "//RemoveFromConfig('ProfileExtender.Fields.'.$Name);", "}", "// Verify field form type", "if", "(", "!", "isset", "(", "$", "Field", "[", "'FormType'", "]", ")", ")", "$", "Fields", "[", "$", "Name", "]", "[", "'FormType'", "]", "=", "'TextBox'", ";", "elseif", "(", "!", "array_key_exists", "(", "$", "Field", "[", "'FormType'", "]", ",", "$", "this", "->", "FormTypes", ")", ")", "unset", "(", "$", "this", "->", "ProfileFields", "[", "$", "Name", "]", ")", ";", "}", "return", "$", "Fields", ";", "}" ]
Get custom profile fields. @return array
[ "Get", "custom", "profile", "fields", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/ProfileExtender/class.profileextender.plugin.php#L151-L173
5,756
bishopb/vanilla
plugins/ProfileExtender/class.profileextender.plugin.php
ProfileExtenderPlugin.ProfileFields
private function ProfileFields($Sender) { // Retrieve user's existing profile fields $this->ProfileFields = $this->GetProfileFields(); // Get user-specific data $this->UserFields = Gdn::UserModel()->GetMeta($Sender->Data("User.UserID"), 'Profile.%', 'Profile.'); // Fill in user data on form foreach ($this->UserFields as $Field => $Value) { $Sender->Form->SetValue($Field, $Value); } include($this->GetView('profilefields.php')); }
php
private function ProfileFields($Sender) { // Retrieve user's existing profile fields $this->ProfileFields = $this->GetProfileFields(); // Get user-specific data $this->UserFields = Gdn::UserModel()->GetMeta($Sender->Data("User.UserID"), 'Profile.%', 'Profile.'); // Fill in user data on form foreach ($this->UserFields as $Field => $Value) { $Sender->Form->SetValue($Field, $Value); } include($this->GetView('profilefields.php')); }
[ "private", "function", "ProfileFields", "(", "$", "Sender", ")", "{", "// Retrieve user's existing profile fields", "$", "this", "->", "ProfileFields", "=", "$", "this", "->", "GetProfileFields", "(", ")", ";", "// Get user-specific data", "$", "this", "->", "UserFields", "=", "Gdn", "::", "UserModel", "(", ")", "->", "GetMeta", "(", "$", "Sender", "->", "Data", "(", "\"User.UserID\"", ")", ",", "'Profile.%'", ",", "'Profile.'", ")", ";", "// Fill in user data on form", "foreach", "(", "$", "this", "->", "UserFields", "as", "$", "Field", "=>", "$", "Value", ")", "{", "$", "Sender", "->", "Form", "->", "SetValue", "(", "$", "Field", ",", "$", "Value", ")", ";", "}", "include", "(", "$", "this", "->", "GetView", "(", "'profilefields.php'", ")", ")", ";", "}" ]
Display custom profile fields on form. @access private
[ "Display", "custom", "profile", "fields", "on", "form", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/ProfileExtender/class.profileextender.plugin.php#L193-L206
5,757
bishopb/vanilla
plugins/ProfileExtender/class.profileextender.plugin.php
ProfileExtenderPlugin.SettingsController_ProfileExtender_Create
public function SettingsController_ProfileExtender_Create($Sender) { $Sender->Permission('Garden.Settings.Manage'); // Detect if we need to upgrade settings if (!C('ProfileExtender.Fields')) $this->Setup(); // Set data $Data = $this->GetProfileFields(); $Sender->SetData('ExtendedFields', $Data); $Sender->AddSideMenu('settings/profileextender'); $Sender->SetData('Title', T('Profile Fields')); $Sender->Render('settings', '', 'plugins/ProfileExtender'); }
php
public function SettingsController_ProfileExtender_Create($Sender) { $Sender->Permission('Garden.Settings.Manage'); // Detect if we need to upgrade settings if (!C('ProfileExtender.Fields')) $this->Setup(); // Set data $Data = $this->GetProfileFields(); $Sender->SetData('ExtendedFields', $Data); $Sender->AddSideMenu('settings/profileextender'); $Sender->SetData('Title', T('Profile Fields')); $Sender->Render('settings', '', 'plugins/ProfileExtender'); }
[ "public", "function", "SettingsController_ProfileExtender_Create", "(", "$", "Sender", ")", "{", "$", "Sender", "->", "Permission", "(", "'Garden.Settings.Manage'", ")", ";", "// Detect if we need to upgrade settings", "if", "(", "!", "C", "(", "'ProfileExtender.Fields'", ")", ")", "$", "this", "->", "Setup", "(", ")", ";", "// Set data", "$", "Data", "=", "$", "this", "->", "GetProfileFields", "(", ")", ";", "$", "Sender", "->", "SetData", "(", "'ExtendedFields'", ",", "$", "Data", ")", ";", "$", "Sender", "->", "AddSideMenu", "(", "'settings/profileextender'", ")", ";", "$", "Sender", "->", "SetData", "(", "'Title'", ",", "T", "(", "'Profile Fields'", ")", ")", ";", "$", "Sender", "->", "Render", "(", "'settings'", ",", "''", ",", "'plugins/ProfileExtender'", ")", ";", "}" ]
Settings page.
[ "Settings", "page", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/ProfileExtender/class.profileextender.plugin.php#L211-L224
5,758
bishopb/vanilla
plugins/ProfileExtender/class.profileextender.plugin.php
ProfileExtenderPlugin.SettingsController_ProfileFieldDelete_Create
public function SettingsController_ProfileFieldDelete_Create($Sender, $Args) { $Sender->Permission('Garden.Settings.Manage'); $Sender->SetData('Title', 'Delete Field'); if (isset($Args[0])) { if ($Sender->Form->IsPostBack()) { RemoveFromConfig('ProfileExtender.Fields.'.$Args[0]); $Sender->RedirectUrl = Url('/settings/profileextender'); } else $Sender->SetData('Field', $this->GetProfileField($Args[0])); } $Sender->Render('delete', '', 'plugins/ProfileExtender'); }
php
public function SettingsController_ProfileFieldDelete_Create($Sender, $Args) { $Sender->Permission('Garden.Settings.Manage'); $Sender->SetData('Title', 'Delete Field'); if (isset($Args[0])) { if ($Sender->Form->IsPostBack()) { RemoveFromConfig('ProfileExtender.Fields.'.$Args[0]); $Sender->RedirectUrl = Url('/settings/profileextender'); } else $Sender->SetData('Field', $this->GetProfileField($Args[0])); } $Sender->Render('delete', '', 'plugins/ProfileExtender'); }
[ "public", "function", "SettingsController_ProfileFieldDelete_Create", "(", "$", "Sender", ",", "$", "Args", ")", "{", "$", "Sender", "->", "Permission", "(", "'Garden.Settings.Manage'", ")", ";", "$", "Sender", "->", "SetData", "(", "'Title'", ",", "'Delete Field'", ")", ";", "if", "(", "isset", "(", "$", "Args", "[", "0", "]", ")", ")", "{", "if", "(", "$", "Sender", "->", "Form", "->", "IsPostBack", "(", ")", ")", "{", "RemoveFromConfig", "(", "'ProfileExtender.Fields.'", ".", "$", "Args", "[", "0", "]", ")", ";", "$", "Sender", "->", "RedirectUrl", "=", "Url", "(", "'/settings/profileextender'", ")", ";", "}", "else", "$", "Sender", "->", "SetData", "(", "'Field'", ",", "$", "this", "->", "GetProfileField", "(", "$", "Args", "[", "0", "]", ")", ")", ";", "}", "$", "Sender", "->", "Render", "(", "'delete'", ",", "''", ",", "'plugins/ProfileExtender'", ")", ";", "}" ]
Delete a field.
[ "Delete", "a", "field", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/ProfileExtender/class.profileextender.plugin.php#L295-L307
5,759
bishopb/vanilla
plugins/ProfileExtender/class.profileextender.plugin.php
ProfileExtenderPlugin.UserInfoModule_OnBasicInfo_Handler
public function UserInfoModule_OnBasicInfo_Handler($Sender) { try { // Get the custom fields $ProfileFields = Gdn::UserModel()->GetMeta($Sender->User->UserID, 'Profile.%', 'Profile.'); // Import from CustomProfileFields if available if (!count($ProfileFields) && is_object($Sender->User) && C('Plugins.CustomProfileFields.SuggestedFields', FALSE)) { $ProfileFields = Gdn::UserModel()->GetAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE); if ($ProfileFields) { // Migrate to UserMeta & delete original Gdn::UserModel()->SetMeta($Sender->User->UserID, $ProfileFields, 'Profile.'); Gdn::UserModel()->SaveAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE); } } // Send them off for magic formatting $ProfileFields = $this->ParseSpecialFields($ProfileFields); // Get all field data, error check $AllFields = $this->GetProfileFields(); if (!is_array($AllFields) || !is_array($ProfileFields)) return; // Display all non-hidden fields $ProfileFields = array_reverse($ProfileFields); foreach ($ProfileFields as $Name => $Value) { if (!$Value) continue; if (!GetValue('OnProfile', $AllFields[$Name])) continue; if (!in_array($Name, $this->MagicLabels)) $Value = Gdn_Format::Links(htmlspecialchars($Value)); echo ' <dt class="ProfileExtend Profile'.Gdn_Format::AlphaNumeric($Name).'">'.Gdn_Format::Text($AllFields[$Name]['Label']).'</dt> '; echo ' <dd class="ProfileExtend Profile'.Gdn_Format::AlphaNumeric($Name).'">'.$Value.'</dd> '; } } catch (Exception $ex) { // No errors } }
php
public function UserInfoModule_OnBasicInfo_Handler($Sender) { try { // Get the custom fields $ProfileFields = Gdn::UserModel()->GetMeta($Sender->User->UserID, 'Profile.%', 'Profile.'); // Import from CustomProfileFields if available if (!count($ProfileFields) && is_object($Sender->User) && C('Plugins.CustomProfileFields.SuggestedFields', FALSE)) { $ProfileFields = Gdn::UserModel()->GetAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE); if ($ProfileFields) { // Migrate to UserMeta & delete original Gdn::UserModel()->SetMeta($Sender->User->UserID, $ProfileFields, 'Profile.'); Gdn::UserModel()->SaveAttribute($Sender->User->UserID, 'CustomProfileFields', FALSE); } } // Send them off for magic formatting $ProfileFields = $this->ParseSpecialFields($ProfileFields); // Get all field data, error check $AllFields = $this->GetProfileFields(); if (!is_array($AllFields) || !is_array($ProfileFields)) return; // Display all non-hidden fields $ProfileFields = array_reverse($ProfileFields); foreach ($ProfileFields as $Name => $Value) { if (!$Value) continue; if (!GetValue('OnProfile', $AllFields[$Name])) continue; if (!in_array($Name, $this->MagicLabels)) $Value = Gdn_Format::Links(htmlspecialchars($Value)); echo ' <dt class="ProfileExtend Profile'.Gdn_Format::AlphaNumeric($Name).'">'.Gdn_Format::Text($AllFields[$Name]['Label']).'</dt> '; echo ' <dd class="ProfileExtend Profile'.Gdn_Format::AlphaNumeric($Name).'">'.$Value.'</dd> '; } } catch (Exception $ex) { // No errors } }
[ "public", "function", "UserInfoModule_OnBasicInfo_Handler", "(", "$", "Sender", ")", "{", "try", "{", "// Get the custom fields", "$", "ProfileFields", "=", "Gdn", "::", "UserModel", "(", ")", "->", "GetMeta", "(", "$", "Sender", "->", "User", "->", "UserID", ",", "'Profile.%'", ",", "'Profile.'", ")", ";", "// Import from CustomProfileFields if available", "if", "(", "!", "count", "(", "$", "ProfileFields", ")", "&&", "is_object", "(", "$", "Sender", "->", "User", ")", "&&", "C", "(", "'Plugins.CustomProfileFields.SuggestedFields'", ",", "FALSE", ")", ")", "{", "$", "ProfileFields", "=", "Gdn", "::", "UserModel", "(", ")", "->", "GetAttribute", "(", "$", "Sender", "->", "User", "->", "UserID", ",", "'CustomProfileFields'", ",", "FALSE", ")", ";", "if", "(", "$", "ProfileFields", ")", "{", "// Migrate to UserMeta & delete original", "Gdn", "::", "UserModel", "(", ")", "->", "SetMeta", "(", "$", "Sender", "->", "User", "->", "UserID", ",", "$", "ProfileFields", ",", "'Profile.'", ")", ";", "Gdn", "::", "UserModel", "(", ")", "->", "SaveAttribute", "(", "$", "Sender", "->", "User", "->", "UserID", ",", "'CustomProfileFields'", ",", "FALSE", ")", ";", "}", "}", "// Send them off for magic formatting", "$", "ProfileFields", "=", "$", "this", "->", "ParseSpecialFields", "(", "$", "ProfileFields", ")", ";", "// Get all field data, error check", "$", "AllFields", "=", "$", "this", "->", "GetProfileFields", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "AllFields", ")", "||", "!", "is_array", "(", "$", "ProfileFields", ")", ")", "return", ";", "// Display all non-hidden fields", "$", "ProfileFields", "=", "array_reverse", "(", "$", "ProfileFields", ")", ";", "foreach", "(", "$", "ProfileFields", "as", "$", "Name", "=>", "$", "Value", ")", "{", "if", "(", "!", "$", "Value", ")", "continue", ";", "if", "(", "!", "GetValue", "(", "'OnProfile'", ",", "$", "AllFields", "[", "$", "Name", "]", ")", ")", "continue", ";", "if", "(", "!", "in_array", "(", "$", "Name", ",", "$", "this", "->", "MagicLabels", ")", ")", "$", "Value", "=", "Gdn_Format", "::", "Links", "(", "htmlspecialchars", "(", "$", "Value", ")", ")", ";", "echo", "' <dt class=\"ProfileExtend Profile'", ".", "Gdn_Format", "::", "AlphaNumeric", "(", "$", "Name", ")", ".", "'\">'", ".", "Gdn_Format", "::", "Text", "(", "$", "AllFields", "[", "$", "Name", "]", "[", "'Label'", "]", ")", ".", "'</dt> '", ";", "echo", "' <dd class=\"ProfileExtend Profile'", ".", "Gdn_Format", "::", "AlphaNumeric", "(", "$", "Name", ")", ".", "'\">'", ".", "$", "Value", ".", "'</dd> '", ";", "}", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "// No errors", "}", "}" ]
Display custom fields on Profile.
[ "Display", "custom", "fields", "on", "Profile", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/ProfileExtender/class.profileextender.plugin.php#L321-L359
5,760
bishopb/vanilla
plugins/ProfileExtender/class.profileextender.plugin.php
ProfileExtenderPlugin.UserModel_AfterSave_Handler
public function UserModel_AfterSave_Handler($Sender) { // Confirm we have submitted form values $FormPostValues = GetValue('FormPostValues', $Sender->EventArguments); if (is_array($FormPostValues)) { $UserID = GetValue('UserID', $Sender->EventArguments); $AllowedFields = $this->GetProfileFields(); $Columns = Gdn::SQL()->FetchColumns('User'); foreach ($FormPostValues as $Name => $Field) { // Whitelist if (!array_key_exists($Name, $AllowedFields)) unset($FormPostValues[$Name]); // Don't allow duplicates on User table if (in_array($Name, $Columns)) unset($FormPostValues[$Name]); } // Update UserMeta if any made it thru if (count($FormPostValues)) Gdn::UserModel()->SetMeta($UserID, $FormPostValues, 'Profile.'); } }
php
public function UserModel_AfterSave_Handler($Sender) { // Confirm we have submitted form values $FormPostValues = GetValue('FormPostValues', $Sender->EventArguments); if (is_array($FormPostValues)) { $UserID = GetValue('UserID', $Sender->EventArguments); $AllowedFields = $this->GetProfileFields(); $Columns = Gdn::SQL()->FetchColumns('User'); foreach ($FormPostValues as $Name => $Field) { // Whitelist if (!array_key_exists($Name, $AllowedFields)) unset($FormPostValues[$Name]); // Don't allow duplicates on User table if (in_array($Name, $Columns)) unset($FormPostValues[$Name]); } // Update UserMeta if any made it thru if (count($FormPostValues)) Gdn::UserModel()->SetMeta($UserID, $FormPostValues, 'Profile.'); } }
[ "public", "function", "UserModel_AfterSave_Handler", "(", "$", "Sender", ")", "{", "// Confirm we have submitted form values", "$", "FormPostValues", "=", "GetValue", "(", "'FormPostValues'", ",", "$", "Sender", "->", "EventArguments", ")", ";", "if", "(", "is_array", "(", "$", "FormPostValues", ")", ")", "{", "$", "UserID", "=", "GetValue", "(", "'UserID'", ",", "$", "Sender", "->", "EventArguments", ")", ";", "$", "AllowedFields", "=", "$", "this", "->", "GetProfileFields", "(", ")", ";", "$", "Columns", "=", "Gdn", "::", "SQL", "(", ")", "->", "FetchColumns", "(", "'User'", ")", ";", "foreach", "(", "$", "FormPostValues", "as", "$", "Name", "=>", "$", "Field", ")", "{", "// Whitelist", "if", "(", "!", "array_key_exists", "(", "$", "Name", ",", "$", "AllowedFields", ")", ")", "unset", "(", "$", "FormPostValues", "[", "$", "Name", "]", ")", ";", "// Don't allow duplicates on User table", "if", "(", "in_array", "(", "$", "Name", ",", "$", "Columns", ")", ")", "unset", "(", "$", "FormPostValues", "[", "$", "Name", "]", ")", ";", "}", "// Update UserMeta if any made it thru", "if", "(", "count", "(", "$", "FormPostValues", ")", ")", "Gdn", "::", "UserModel", "(", ")", "->", "SetMeta", "(", "$", "UserID", ",", "$", "FormPostValues", ",", "'Profile.'", ")", ";", "}", "}" ]
Save custom profile fields when saving the user.
[ "Save", "custom", "profile", "fields", "when", "saving", "the", "user", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/ProfileExtender/class.profileextender.plugin.php#L364-L387
5,761
bishopb/vanilla
plugins/ProfileExtender/class.profileextender.plugin.php
ProfileExtenderPlugin.Setup
public function Setup() { if ($Fields = C('Plugins.ProfileExtender.ProfileFields', C('Plugins.CustomProfileFields.SuggestedFields'))) { // Get defaults $Hidden = C('Plugins.ProfileExtender.HideFields', C('Plugins.CustomProfileFields.HideFields')); $OnRegister = C('Plugins.ProfileExtender.RegistrationFields'); $Length = C('Plugins.ProfileExtender.TextMaxLength', C('Plugins.CustomProfileFields.ValueLength')); // Convert to arrays $Fields = array_filter((array)explode(',', $Fields)); $Hidden = array_filter((array)explode(',', $Hidden)); $OnRegister = array_filter((array)explode(',', $OnRegister)); // Assign new data structure $NewData = array(); foreach ($Fields as $Field) { // Make unique slug $Name = $TestSlug = preg_replace('`[^0-9a-zA-Z]`', '', $Field); $i = 1; while (array_key_exists($Name, $NewData) || in_array($Name, $this->ReservedNames)) { $Name = $TestSlug.$i++; } // Convert $NewData[$Name] = array( 'Label' => $Field, 'Length' => $Length, 'FormType' => 'TextBox', 'OnProfile' => (in_array($Field, $Hidden)) ? 0 : 1, 'OnRegister' => (in_array($Field, $OnRegister)) ? 1 : 0, 'OnDiscussion' => 0, 'Required' => 0, 'Locked' => 0, 'Sort' => 0 ); } SaveToConfig('ProfileExtender.Fields', $NewData); } }
php
public function Setup() { if ($Fields = C('Plugins.ProfileExtender.ProfileFields', C('Plugins.CustomProfileFields.SuggestedFields'))) { // Get defaults $Hidden = C('Plugins.ProfileExtender.HideFields', C('Plugins.CustomProfileFields.HideFields')); $OnRegister = C('Plugins.ProfileExtender.RegistrationFields'); $Length = C('Plugins.ProfileExtender.TextMaxLength', C('Plugins.CustomProfileFields.ValueLength')); // Convert to arrays $Fields = array_filter((array)explode(',', $Fields)); $Hidden = array_filter((array)explode(',', $Hidden)); $OnRegister = array_filter((array)explode(',', $OnRegister)); // Assign new data structure $NewData = array(); foreach ($Fields as $Field) { // Make unique slug $Name = $TestSlug = preg_replace('`[^0-9a-zA-Z]`', '', $Field); $i = 1; while (array_key_exists($Name, $NewData) || in_array($Name, $this->ReservedNames)) { $Name = $TestSlug.$i++; } // Convert $NewData[$Name] = array( 'Label' => $Field, 'Length' => $Length, 'FormType' => 'TextBox', 'OnProfile' => (in_array($Field, $Hidden)) ? 0 : 1, 'OnRegister' => (in_array($Field, $OnRegister)) ? 1 : 0, 'OnDiscussion' => 0, 'Required' => 0, 'Locked' => 0, 'Sort' => 0 ); } SaveToConfig('ProfileExtender.Fields', $NewData); } }
[ "public", "function", "Setup", "(", ")", "{", "if", "(", "$", "Fields", "=", "C", "(", "'Plugins.ProfileExtender.ProfileFields'", ",", "C", "(", "'Plugins.CustomProfileFields.SuggestedFields'", ")", ")", ")", "{", "// Get defaults", "$", "Hidden", "=", "C", "(", "'Plugins.ProfileExtender.HideFields'", ",", "C", "(", "'Plugins.CustomProfileFields.HideFields'", ")", ")", ";", "$", "OnRegister", "=", "C", "(", "'Plugins.ProfileExtender.RegistrationFields'", ")", ";", "$", "Length", "=", "C", "(", "'Plugins.ProfileExtender.TextMaxLength'", ",", "C", "(", "'Plugins.CustomProfileFields.ValueLength'", ")", ")", ";", "// Convert to arrays", "$", "Fields", "=", "array_filter", "(", "(", "array", ")", "explode", "(", "','", ",", "$", "Fields", ")", ")", ";", "$", "Hidden", "=", "array_filter", "(", "(", "array", ")", "explode", "(", "','", ",", "$", "Hidden", ")", ")", ";", "$", "OnRegister", "=", "array_filter", "(", "(", "array", ")", "explode", "(", "','", ",", "$", "OnRegister", ")", ")", ";", "// Assign new data structure", "$", "NewData", "=", "array", "(", ")", ";", "foreach", "(", "$", "Fields", "as", "$", "Field", ")", "{", "// Make unique slug", "$", "Name", "=", "$", "TestSlug", "=", "preg_replace", "(", "'`[^0-9a-zA-Z]`'", ",", "''", ",", "$", "Field", ")", ";", "$", "i", "=", "1", ";", "while", "(", "array_key_exists", "(", "$", "Name", ",", "$", "NewData", ")", "||", "in_array", "(", "$", "Name", ",", "$", "this", "->", "ReservedNames", ")", ")", "{", "$", "Name", "=", "$", "TestSlug", ".", "$", "i", "++", ";", "}", "// Convert", "$", "NewData", "[", "$", "Name", "]", "=", "array", "(", "'Label'", "=>", "$", "Field", ",", "'Length'", "=>", "$", "Length", ",", "'FormType'", "=>", "'TextBox'", ",", "'OnProfile'", "=>", "(", "in_array", "(", "$", "Field", ",", "$", "Hidden", ")", ")", "?", "0", ":", "1", ",", "'OnRegister'", "=>", "(", "in_array", "(", "$", "Field", ",", "$", "OnRegister", ")", ")", "?", "1", ":", "0", ",", "'OnDiscussion'", "=>", "0", ",", "'Required'", "=>", "0", ",", "'Locked'", "=>", "0", ",", "'Sort'", "=>", "0", ")", ";", "}", "SaveToConfig", "(", "'ProfileExtender.Fields'", ",", "$", "NewData", ")", ";", "}", "}" ]
Import from CustomProfileFields or upgrade from ProfileExtender 2.0.
[ "Import", "from", "CustomProfileFields", "or", "upgrade", "from", "ProfileExtender", "2", ".", "0", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/plugins/ProfileExtender/class.profileextender.plugin.php#L392-L429
5,762
Trellmor/php-framework
Application/Uri.php
Uri.currentPage
public static function currentPage() { $uri = static::to(static::detectPath()); foreach ($_GET as $k => $v) { $uri->param($k, $v); } return $uri; }
php
public static function currentPage() { $uri = static::to(static::detectPath()); foreach ($_GET as $k => $v) { $uri->param($k, $v); } return $uri; }
[ "public", "static", "function", "currentPage", "(", ")", "{", "$", "uri", "=", "static", "::", "to", "(", "static", "::", "detectPath", "(", ")", ")", ";", "foreach", "(", "$", "_GET", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "uri", "->", "param", "(", "$", "k", ",", "$", "v", ")", ";", "}", "return", "$", "uri", ";", "}" ]
Create new URI instance to the current page @return Uri instance
[ "Create", "new", "URI", "instance", "to", "the", "current", "page" ]
5fda0dd52e0bc3ac4e0ed3b26125739904b2201e
https://github.com/Trellmor/php-framework/blob/5fda0dd52e0bc3ac4e0ed3b26125739904b2201e/Application/Uri.php#L54-L61
5,763
Trellmor/php-framework
Application/Uri.php
Uri.path
public function path($path) { $path = explode('/', $path); for ($i = 0; $i < count($path); $i++) { $path[$i] = urlencode($path[$i]); } $this->path = implode('/', $path); return $this; }
php
public function path($path) { $path = explode('/', $path); for ($i = 0; $i < count($path); $i++) { $path[$i] = urlencode($path[$i]); } $this->path = implode('/', $path); return $this; }
[ "public", "function", "path", "(", "$", "path", ")", "{", "$", "path", "=", "explode", "(", "'/'", ",", "$", "path", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "path", ")", ";", "$", "i", "++", ")", "{", "$", "path", "[", "$", "i", "]", "=", "urlencode", "(", "$", "path", "[", "$", "i", "]", ")", ";", "}", "$", "this", "->", "path", "=", "implode", "(", "'/'", ",", "$", "path", ")", ";", "return", "$", "this", ";", "}" ]
Set the URI path @param string $path @return Uri instance
[ "Set", "the", "URI", "path" ]
5fda0dd52e0bc3ac4e0ed3b26125739904b2201e
https://github.com/Trellmor/php-framework/blob/5fda0dd52e0bc3ac4e0ed3b26125739904b2201e/Application/Uri.php#L69-L77
5,764
Trellmor/php-framework
Application/Uri.php
Uri.param
public function param($param, $value) { if ($value !== null) { $param = rawurlencode($param); $value = rawurlencode($value); $this->params[$param] = $value; } else { if (isset($this->params[$param])) { unset($this->params[$param]); } } return $this; }
php
public function param($param, $value) { if ($value !== null) { $param = rawurlencode($param); $value = rawurlencode($value); $this->params[$param] = $value; } else { if (isset($this->params[$param])) { unset($this->params[$param]); } } return $this; }
[ "public", "function", "param", "(", "$", "param", ",", "$", "value", ")", "{", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "param", "=", "rawurlencode", "(", "$", "param", ")", ";", "$", "value", "=", "rawurlencode", "(", "$", "value", ")", ";", "$", "this", "->", "params", "[", "$", "param", "]", "=", "$", "value", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "this", "->", "params", "[", "$", "param", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "params", "[", "$", "param", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set a query param Name and value will be url encoded with rawurlencode @param string $param Param name @param string $value
[ "Set", "a", "query", "param" ]
5fda0dd52e0bc3ac4e0ed3b26125739904b2201e
https://github.com/Trellmor/php-framework/blob/5fda0dd52e0bc3ac4e0ed3b26125739904b2201e/Application/Uri.php#L97-L108
5,765
Trellmor/php-framework
Application/Uri.php
Uri.parse
public static function parse($uri) { $uri = static::to(static::detectPathFrom(parse_url($uri, PHP_URL_PATH))); $query = array (); parse_str(parse_url($uri, PHP_URL_QUERY), $query); foreach ($query as $k => $v) { $uri->param($k, $v); } return $uri; }
php
public static function parse($uri) { $uri = static::to(static::detectPathFrom(parse_url($uri, PHP_URL_PATH))); $query = array (); parse_str(parse_url($uri, PHP_URL_QUERY), $query); foreach ($query as $k => $v) { $uri->param($k, $v); } return $uri; }
[ "public", "static", "function", "parse", "(", "$", "uri", ")", "{", "$", "uri", "=", "static", "::", "to", "(", "static", "::", "detectPathFrom", "(", "parse_url", "(", "$", "uri", ",", "PHP_URL_PATH", ")", ")", ")", ";", "$", "query", "=", "array", "(", ")", ";", "parse_str", "(", "parse_url", "(", "$", "uri", ",", "PHP_URL_QUERY", ")", ",", "$", "query", ")", ";", "foreach", "(", "$", "query", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "uri", "->", "param", "(", "$", "k", ",", "$", "v", ")", ";", "}", "return", "$", "uri", ";", "}" ]
Parse an URI string @param string $uri @return Uri instance
[ "Parse", "an", "URI", "string" ]
5fda0dd52e0bc3ac4e0ed3b26125739904b2201e
https://github.com/Trellmor/php-framework/blob/5fda0dd52e0bc3ac4e0ed3b26125739904b2201e/Application/Uri.php#L179-L188
5,766
ionutmilica/ionix-framework
src/Routing/Route.php
Route.getWhere
protected function getWhere($name) { if (isset($this->wheres[$name])) { return $this->wheres[$name]; } if (isset(self::$patterns[$name])) { return self::$patterns[$name]; } return false; }
php
protected function getWhere($name) { if (isset($this->wheres[$name])) { return $this->wheres[$name]; } if (isset(self::$patterns[$name])) { return self::$patterns[$name]; } return false; }
[ "protected", "function", "getWhere", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "wheres", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "wheres", "[", "$", "name", "]", ";", "}", "if", "(", "isset", "(", "self", "::", "$", "patterns", "[", "$", "name", "]", ")", ")", "{", "return", "self", "::", "$", "patterns", "[", "$", "name", "]", ";", "}", "return", "false", ";", "}" ]
Get conditional pattern for route variables @param $name @return bool
[ "Get", "conditional", "pattern", "for", "route", "variables" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Routing/Route.php#L78-L89
5,767
ionutmilica/ionix-framework
src/Routing/Route.php
Route.matches
public function matches($requestUri) { $requestUri = $this->normalizeUri($requestUri); $regex = $this->compile(); if (preg_match('#^'.$regex.'$#i', $requestUri, $out)) { $this->data = $this->getOnlyStringKeys($out); return true; } return false; }
php
public function matches($requestUri) { $requestUri = $this->normalizeUri($requestUri); $regex = $this->compile(); if (preg_match('#^'.$regex.'$#i', $requestUri, $out)) { $this->data = $this->getOnlyStringKeys($out); return true; } return false; }
[ "public", "function", "matches", "(", "$", "requestUri", ")", "{", "$", "requestUri", "=", "$", "this", "->", "normalizeUri", "(", "$", "requestUri", ")", ";", "$", "regex", "=", "$", "this", "->", "compile", "(", ")", ";", "if", "(", "preg_match", "(", "'#^'", ".", "$", "regex", ".", "'$#i'", ",", "$", "requestUri", ",", "$", "out", ")", ")", "{", "$", "this", "->", "data", "=", "$", "this", "->", "getOnlyStringKeys", "(", "$", "out", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if a route matches a given url @param $requestUri @return bool
[ "Check", "if", "a", "route", "matches", "a", "given", "url" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Routing/Route.php#L122-L133
5,768
ionutmilica/ionix-framework
src/Routing/Route.php
Route.normalizeUri
protected function normalizeUri($requestUri) { $len = strlen($requestUri); if ($len == 0) { return '/'; } if ($len == 1) { return $requestUri; } return trim($requestUri, '/'); }
php
protected function normalizeUri($requestUri) { $len = strlen($requestUri); if ($len == 0) { return '/'; } if ($len == 1) { return $requestUri; } return trim($requestUri, '/'); }
[ "protected", "function", "normalizeUri", "(", "$", "requestUri", ")", "{", "$", "len", "=", "strlen", "(", "$", "requestUri", ")", ";", "if", "(", "$", "len", "==", "0", ")", "{", "return", "'/'", ";", "}", "if", "(", "$", "len", "==", "1", ")", "{", "return", "$", "requestUri", ";", "}", "return", "trim", "(", "$", "requestUri", ",", "'/'", ")", ";", "}" ]
Prepare uri for regex match @param $requestUri @return string
[ "Prepare", "uri", "for", "regex", "match" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Routing/Route.php#L141-L154
5,769
ionutmilica/ionix-framework
src/Routing/Route.php
Route.getOnlyStringKeys
protected function getOnlyStringKeys(array $array) { $allowed = array_filter(array_keys($array), function ($key) { return ! is_int($key); }); return array_intersect_key($array, array_flip($allowed)); }
php
protected function getOnlyStringKeys(array $array) { $allowed = array_filter(array_keys($array), function ($key) { return ! is_int($key); }); return array_intersect_key($array, array_flip($allowed)); }
[ "protected", "function", "getOnlyStringKeys", "(", "array", "$", "array", ")", "{", "$", "allowed", "=", "array_filter", "(", "array_keys", "(", "$", "array", ")", ",", "function", "(", "$", "key", ")", "{", "return", "!", "is_int", "(", "$", "key", ")", ";", "}", ")", ";", "return", "array_intersect_key", "(", "$", "array", ",", "array_flip", "(", "$", "allowed", ")", ")", ";", "}" ]
Get arrays elements that contains only associative keys @param array $array @return array
[ "Get", "arrays", "elements", "that", "contains", "only", "associative", "keys" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Routing/Route.php#L162-L170
5,770
sunshinephp/ssp-contact
src/SspContact/Service/ContactService.php
ContactService.saveContact
public function saveContact(Contact $contactMessage) { /* @var $mapper \SspContact\Mapper\Contact */ $mapper = $this->getServiceLocator()->get('contact_mapper'); $mapper->insert($contactMessage); }
php
public function saveContact(Contact $contactMessage) { /* @var $mapper \SspContact\Mapper\Contact */ $mapper = $this->getServiceLocator()->get('contact_mapper'); $mapper->insert($contactMessage); }
[ "public", "function", "saveContact", "(", "Contact", "$", "contactMessage", ")", "{", "/* @var $mapper \\SspContact\\Mapper\\Contact */", "$", "mapper", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'contact_mapper'", ")", ";", "$", "mapper", "->", "insert", "(", "$", "contactMessage", ")", ";", "}" ]
Saves the contact message to the database for later administration @param Contact $contactMessage
[ "Saves", "the", "contact", "message", "to", "the", "database", "for", "later", "administration" ]
ee892748b1c8b7d906787440d6bdc7125306de7d
https://github.com/sunshinephp/ssp-contact/blob/ee892748b1c8b7d906787440d6bdc7125306de7d/src/SspContact/Service/ContactService.php#L31-L36
5,771
sunshinephp/ssp-contact
src/SspContact/Service/ContactService.php
ContactService.sendMessage
public function sendMessage(Contact $contactMessage) { $serverName = ($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']); // PREPARE THE EMAIL MESSAGE $message = new Message(); $message->addFrom(new Address($contactMessage->getEmail(), $contactMessage->getFirstName() . ' ' . $contactMessage->getLastName())); $message->setSubject($contactMessage->getSubject()); $body = <<<MSG New Message \n From: {$contactMessage->getFirstName()} {$contactMessage->getLastName()} \n Subject: [$serverName contact] {$contactMessage->getSubject()} \n Message: {$contactMessage->getMessage()} \n MSG; $message->setBody($body); // SEND THE EMAIL return $this->getServiceLocator()->get('transport')->send($message); }
php
public function sendMessage(Contact $contactMessage) { $serverName = ($_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']); // PREPARE THE EMAIL MESSAGE $message = new Message(); $message->addFrom(new Address($contactMessage->getEmail(), $contactMessage->getFirstName() . ' ' . $contactMessage->getLastName())); $message->setSubject($contactMessage->getSubject()); $body = <<<MSG New Message \n From: {$contactMessage->getFirstName()} {$contactMessage->getLastName()} \n Subject: [$serverName contact] {$contactMessage->getSubject()} \n Message: {$contactMessage->getMessage()} \n MSG; $message->setBody($body); // SEND THE EMAIL return $this->getServiceLocator()->get('transport')->send($message); }
[ "public", "function", "sendMessage", "(", "Contact", "$", "contactMessage", ")", "{", "$", "serverName", "=", "(", "$", "_SERVER", "[", "'HTTP_HOST'", "]", "?", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ":", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ")", ";", "// PREPARE THE EMAIL MESSAGE", "$", "message", "=", "new", "Message", "(", ")", ";", "$", "message", "->", "addFrom", "(", "new", "Address", "(", "$", "contactMessage", "->", "getEmail", "(", ")", ",", "$", "contactMessage", "->", "getFirstName", "(", ")", ".", "' '", ".", "$", "contactMessage", "->", "getLastName", "(", ")", ")", ")", ";", "$", "message", "->", "setSubject", "(", "$", "contactMessage", "->", "getSubject", "(", ")", ")", ";", "$", "body", "=", " <<<MSG\nNew Message \\n\nFrom: {$contactMessage->getFirstName()} {$contactMessage->getLastName()} \\n\nSubject: [$serverName contact] {$contactMessage->getSubject()} \\n\nMessage: {$contactMessage->getMessage()} \\n\nMSG", ";", "$", "message", "->", "setBody", "(", "$", "body", ")", ";", "// SEND THE EMAIL", "return", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'transport'", ")", "->", "send", "(", "$", "message", ")", ";", "}" ]
Composes & sends the email from a contact message @param Contact $contactMessage @return mixed
[ "Composes", "&", "sends", "the", "email", "from", "a", "contact", "message" ]
ee892748b1c8b7d906787440d6bdc7125306de7d
https://github.com/sunshinephp/ssp-contact/blob/ee892748b1c8b7d906787440d6bdc7125306de7d/src/SspContact/Service/ContactService.php#L43-L63
5,772
ciims/cii
widgets/input/CiiInput.php
CiiInput.processHtmlOptions
protected function processHtmlOptions() { if (isset($this->htmlOptions['prepend'])) { $this->prependText = $this->htmlOptions['prepend']; unset($this->htmlOptions['prepend']); } if (isset($this->htmlOptions['append'])) { $this->appendText = $this->htmlOptions['append']; unset($this->htmlOptions['append']); } if (isset($this->htmlOptions['hint'])) { $this->hintText = $this->htmlOptions['hint']; unset($this->htmlOptions['hint']); } if (isset($this->htmlOptions['labelOptions'])) { $this->labelOptions = $this->htmlOptions['labelOptions']; unset($this->htmlOptions['labelOptions']); } if (isset($this->htmlOptions['prependOptions'])) { $this->prependOptions = $this->htmlOptions['prependOptions']; unset($this->htmlOptions['prependOptions']); } if (isset($this->htmlOptions['appendOptions'])) { $this->appendOptions = $this->htmlOptions['appendOptions']; unset($this->htmlOptions['appendOptions']); } if (isset($this->htmlOptions['hintOptions'])) { $this->hintOptions = $this->htmlOptions['hintOptions']; unset($this->htmlOptions['hintOptions']); } if (isset($this->htmlOptions['errorOptions'])) { $this->errorOptions = $this->htmlOptions['errorOptions']; unset($this->htmlOptions['errorOptions']); } if (isset($this->htmlOptions['captchaOptions'])) { $this->captchaOptions = $this->htmlOptions['captchaOptions']; unset($this->htmlOptions['captchaOptions']); } }
php
protected function processHtmlOptions() { if (isset($this->htmlOptions['prepend'])) { $this->prependText = $this->htmlOptions['prepend']; unset($this->htmlOptions['prepend']); } if (isset($this->htmlOptions['append'])) { $this->appendText = $this->htmlOptions['append']; unset($this->htmlOptions['append']); } if (isset($this->htmlOptions['hint'])) { $this->hintText = $this->htmlOptions['hint']; unset($this->htmlOptions['hint']); } if (isset($this->htmlOptions['labelOptions'])) { $this->labelOptions = $this->htmlOptions['labelOptions']; unset($this->htmlOptions['labelOptions']); } if (isset($this->htmlOptions['prependOptions'])) { $this->prependOptions = $this->htmlOptions['prependOptions']; unset($this->htmlOptions['prependOptions']); } if (isset($this->htmlOptions['appendOptions'])) { $this->appendOptions = $this->htmlOptions['appendOptions']; unset($this->htmlOptions['appendOptions']); } if (isset($this->htmlOptions['hintOptions'])) { $this->hintOptions = $this->htmlOptions['hintOptions']; unset($this->htmlOptions['hintOptions']); } if (isset($this->htmlOptions['errorOptions'])) { $this->errorOptions = $this->htmlOptions['errorOptions']; unset($this->htmlOptions['errorOptions']); } if (isset($this->htmlOptions['captchaOptions'])) { $this->captchaOptions = $this->htmlOptions['captchaOptions']; unset($this->htmlOptions['captchaOptions']); } }
[ "protected", "function", "processHtmlOptions", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'prepend'", "]", ")", ")", "{", "$", "this", "->", "prependText", "=", "$", "this", "->", "htmlOptions", "[", "'prepend'", "]", ";", "unset", "(", "$", "this", "->", "htmlOptions", "[", "'prepend'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'append'", "]", ")", ")", "{", "$", "this", "->", "appendText", "=", "$", "this", "->", "htmlOptions", "[", "'append'", "]", ";", "unset", "(", "$", "this", "->", "htmlOptions", "[", "'append'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'hint'", "]", ")", ")", "{", "$", "this", "->", "hintText", "=", "$", "this", "->", "htmlOptions", "[", "'hint'", "]", ";", "unset", "(", "$", "this", "->", "htmlOptions", "[", "'hint'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'labelOptions'", "]", ")", ")", "{", "$", "this", "->", "labelOptions", "=", "$", "this", "->", "htmlOptions", "[", "'labelOptions'", "]", ";", "unset", "(", "$", "this", "->", "htmlOptions", "[", "'labelOptions'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'prependOptions'", "]", ")", ")", "{", "$", "this", "->", "prependOptions", "=", "$", "this", "->", "htmlOptions", "[", "'prependOptions'", "]", ";", "unset", "(", "$", "this", "->", "htmlOptions", "[", "'prependOptions'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'appendOptions'", "]", ")", ")", "{", "$", "this", "->", "appendOptions", "=", "$", "this", "->", "htmlOptions", "[", "'appendOptions'", "]", ";", "unset", "(", "$", "this", "->", "htmlOptions", "[", "'appendOptions'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'hintOptions'", "]", ")", ")", "{", "$", "this", "->", "hintOptions", "=", "$", "this", "->", "htmlOptions", "[", "'hintOptions'", "]", ";", "unset", "(", "$", "this", "->", "htmlOptions", "[", "'hintOptions'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'errorOptions'", "]", ")", ")", "{", "$", "this", "->", "errorOptions", "=", "$", "this", "->", "htmlOptions", "[", "'errorOptions'", "]", ";", "unset", "(", "$", "this", "->", "htmlOptions", "[", "'errorOptions'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'captchaOptions'", "]", ")", ")", "{", "$", "this", "->", "captchaOptions", "=", "$", "this", "->", "htmlOptions", "[", "'captchaOptions'", "]", ";", "unset", "(", "$", "this", "->", "htmlOptions", "[", "'captchaOptions'", "]", ")", ";", "}", "}" ]
Processes the html options.
[ "Processes", "the", "html", "options", "." ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/input/CiiInput.php#L126-L182
5,773
ciims/cii
widgets/input/CiiInput.php
CiiInput.getAppend
protected function getAppend() { if ($this->hasAddOn()) { $htmlOptions = $this->appendOptions; if (isset($htmlOptions['class'])) $htmlOptions['class'] .= ' add-on'; else $htmlOptions['class'] = 'add-on'; ob_start(); if (isset($this->appendText)) echo CHtml::tag('span', $htmlOptions, $this->appendText); echo '</div>'; return ob_get_clean(); } else return ''; }
php
protected function getAppend() { if ($this->hasAddOn()) { $htmlOptions = $this->appendOptions; if (isset($htmlOptions['class'])) $htmlOptions['class'] .= ' add-on'; else $htmlOptions['class'] = 'add-on'; ob_start(); if (isset($this->appendText)) echo CHtml::tag('span', $htmlOptions, $this->appendText); echo '</div>'; return ob_get_clean(); } else return ''; }
[ "protected", "function", "getAppend", "(", ")", "{", "if", "(", "$", "this", "->", "hasAddOn", "(", ")", ")", "{", "$", "htmlOptions", "=", "$", "this", "->", "appendOptions", ";", "if", "(", "isset", "(", "$", "htmlOptions", "[", "'class'", "]", ")", ")", "$", "htmlOptions", "[", "'class'", "]", ".=", "' add-on'", ";", "else", "$", "htmlOptions", "[", "'class'", "]", "=", "'add-on'", ";", "ob_start", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "appendText", ")", ")", "echo", "CHtml", "::", "tag", "(", "'span'", ",", "$", "htmlOptions", ",", "$", "this", "->", "appendText", ")", ";", "echo", "'</div>'", ";", "return", "ob_get_clean", "(", ")", ";", "}", "else", "return", "''", ";", "}" ]
Returns the append element for the input. @return string the element
[ "Returns", "the", "append", "element", "for", "the", "input", "." ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/input/CiiInput.php#L337-L356
5,774
ciims/cii
widgets/input/CiiInput.php
CiiInput.getError
protected function getError() { return $this->form->error($this->model, $this->attribute, $this->errorOptions); }
php
protected function getError() { return $this->form->error($this->model, $this->attribute, $this->errorOptions); }
[ "protected", "function", "getError", "(", ")", "{", "return", "$", "this", "->", "form", "->", "error", "(", "$", "this", "->", "model", ",", "$", "this", "->", "attribute", ",", "$", "this", "->", "errorOptions", ")", ";", "}" ]
Returns the error text for the input. @return string the error text
[ "Returns", "the", "error", "text", "for", "the", "input", "." ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/input/CiiInput.php#L374-L377
5,775
ciims/cii
widgets/input/CiiInput.php
CiiInput.getHint
protected function getHint() { if (isset($this->hintText)) { $htmlOptions = $this->hintOptions; if (isset($htmlOptions['class'])) $htmlOptions['class'] .= ' help-block'; else $htmlOptions['class'] = 'help-block'; return CHtml::tag('p', $htmlOptions, $this->hintText); } else return ''; }
php
protected function getHint() { if (isset($this->hintText)) { $htmlOptions = $this->hintOptions; if (isset($htmlOptions['class'])) $htmlOptions['class'] .= ' help-block'; else $htmlOptions['class'] = 'help-block'; return CHtml::tag('p', $htmlOptions, $this->hintText); } else return ''; }
[ "protected", "function", "getHint", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "hintText", ")", ")", "{", "$", "htmlOptions", "=", "$", "this", "->", "hintOptions", ";", "if", "(", "isset", "(", "$", "htmlOptions", "[", "'class'", "]", ")", ")", "$", "htmlOptions", "[", "'class'", "]", ".=", "' help-block'", ";", "else", "$", "htmlOptions", "[", "'class'", "]", "=", "'help-block'", ";", "return", "CHtml", "::", "tag", "(", "'p'", ",", "$", "htmlOptions", ",", "$", "this", "->", "hintText", ")", ";", "}", "else", "return", "''", ";", "}" ]
Returns the hint text for the input. @return string the hint text
[ "Returns", "the", "hint", "text", "for", "the", "input", "." ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/input/CiiInput.php#L383-L397
5,776
ciims/cii
widgets/input/CiiInput.php
CiiInput.getContainerCssClass
protected function getContainerCssClass() { $attribute = $this->attribute; return $this->model->hasErrors(CHtml::resolveName($this->model, $attribute)) ? CHtml::$errorCss : ''; }
php
protected function getContainerCssClass() { $attribute = $this->attribute; return $this->model->hasErrors(CHtml::resolveName($this->model, $attribute)) ? CHtml::$errorCss : ''; }
[ "protected", "function", "getContainerCssClass", "(", ")", "{", "$", "attribute", "=", "$", "this", "->", "attribute", ";", "return", "$", "this", "->", "model", "->", "hasErrors", "(", "CHtml", "::", "resolveName", "(", "$", "this", "->", "model", ",", "$", "attribute", ")", ")", "?", "CHtml", "::", "$", "errorCss", ":", "''", ";", "}" ]
Returns the container CSS class for the input. @return string the CSS class
[ "Returns", "the", "container", "CSS", "class", "for", "the", "input", "." ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/input/CiiInput.php#L403-L407
5,777
ciims/cii
widgets/input/CiiInput.php
CiiInput.getAddonCssClass
protected function getAddonCssClass() { $classes = array(); if (isset($this->prependText)) $classes[] = 'input-prepend'; if (isset($this->appendText)) $classes[] = 'input-append'; return implode(' ', $classes); }
php
protected function getAddonCssClass() { $classes = array(); if (isset($this->prependText)) $classes[] = 'input-prepend'; if (isset($this->appendText)) $classes[] = 'input-append'; return implode(' ', $classes); }
[ "protected", "function", "getAddonCssClass", "(", ")", "{", "$", "classes", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "prependText", ")", ")", "$", "classes", "[", "]", "=", "'input-prepend'", ";", "if", "(", "isset", "(", "$", "this", "->", "appendText", ")", ")", "$", "classes", "[", "]", "=", "'input-append'", ";", "return", "implode", "(", "' '", ",", "$", "classes", ")", ";", "}" ]
Returns the input container CSS classes. @return string the CSS class
[ "Returns", "the", "input", "container", "CSS", "classes", "." ]
cc8550b9a3a6a0bf0214554679de8743d50dc9ef
https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/widgets/input/CiiInput.php#L413-L422
5,778
HeroicTeam/m
Http/Response.php
Response.pass
public function pass($key, $value) { if (!isset($this->_session)) throw new \Exception('m\Http\Response: No session object available to flash "'.$key.'" to.'); $this->_session->flash($key, $value); return $this; }
php
public function pass($key, $value) { if (!isset($this->_session)) throw new \Exception('m\Http\Response: No session object available to flash "'.$key.'" to.'); $this->_session->flash($key, $value); return $this; }
[ "public", "function", "pass", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_session", ")", ")", "throw", "new", "\\", "Exception", "(", "'m\\Http\\Response: No session object available to flash \"'", ".", "$", "key", ".", "'\" to.'", ")", ";", "$", "this", "->", "_session", "->", "flash", "(", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Pass flash data to the next page. @param string $key @param mixed $value @return \m\Http\Response @throws \Exception
[ "Pass", "flash", "data", "to", "the", "next", "page", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Http/Response.php#L137-L145
5,779
HeroicTeam/m
Http/Response.php
Response.passMany
public function passMany(array $data) { if (!isset($this->_session)) throw new \Exception('m\Http\Response: No session object available to flash "'.$key.'" to.'); $this->_session->flashMany($data); return $this; }
php
public function passMany(array $data) { if (!isset($this->_session)) throw new \Exception('m\Http\Response: No session object available to flash "'.$key.'" to.'); $this->_session->flashMany($data); return $this; }
[ "public", "function", "passMany", "(", "array", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_session", ")", ")", "throw", "new", "\\", "Exception", "(", "'m\\Http\\Response: No session object available to flash \"'", ".", "$", "key", ".", "'\" to.'", ")", ";", "$", "this", "->", "_session", "->", "flashMany", "(", "$", "data", ")", ";", "return", "$", "this", ";", "}" ]
Add an array of data to pass to the next page. @param array $data @return \m\Http\Response @throws \Exception
[ "Add", "an", "array", "of", "data", "to", "pass", "to", "the", "next", "page", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Http/Response.php#L154-L162
5,780
HeroicTeam/m
Http/Response.php
Response.getHeader
public function getHeader($key) { return isset($this->_headers[$key]) ? $this->_headers[$key] : null; }
php
public function getHeader($key) { return isset($this->_headers[$key]) ? $this->_headers[$key] : null; }
[ "public", "function", "getHeader", "(", "$", "key", ")", "{", "return", "isset", "(", "$", "this", "->", "_headers", "[", "$", "key", "]", ")", "?", "$", "this", "->", "_headers", "[", "$", "key", "]", ":", "null", ";", "}" ]
Returns the value of the requested header or null if it does not exist. @param string $key @return mixed|null
[ "Returns", "the", "value", "of", "the", "requested", "header", "or", "null", "if", "it", "does", "not", "exist", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Http/Response.php#L207-L210
5,781
HeroicTeam/m
Http/Response.php
Response.redirect
public function redirect($url, $status = 302) { $this->_headers['Location'] = (string) $url; $this->_status = (integer) $status; return $this; }
php
public function redirect($url, $status = 302) { $this->_headers['Location'] = (string) $url; $this->_status = (integer) $status; return $this; }
[ "public", "function", "redirect", "(", "$", "url", ",", "$", "status", "=", "302", ")", "{", "$", "this", "->", "_headers", "[", "'Location'", "]", "=", "(", "string", ")", "$", "url", ";", "$", "this", "->", "_status", "=", "(", "integer", ")", "$", "status", ";", "return", "$", "this", ";", "}" ]
Automatically sets the response headers and status for a redirect. @param string $url @param int $status @return \m\Http\Response
[ "Automatically", "sets", "the", "response", "headers", "and", "status", "for", "a", "redirect", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Http/Response.php#L302-L308
5,782
HeroicTeam/m
Http/Response.php
Response.cache
public function cache($expires) { if ($expires === false) { $this->_headers['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT'; $this->_headers['Cache-Control'] = array( 'no-store, no-cache, must-revalidate', 'post-check=0, pre-check=0', 'max-age=0' ); $this->_headers['Pragma'] = 'no-cache'; } else { $expires = is_string($expires) ? strtotime($expires) : $expires; $this->_headers['Expires'] = gmdate('D, d M Y H:i:s', $expires).' GMT'; $this->_headers['Cache-Control'] = 'max-age='.($expires - time()); } return $this; }
php
public function cache($expires) { if ($expires === false) { $this->_headers['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT'; $this->_headers['Cache-Control'] = array( 'no-store, no-cache, must-revalidate', 'post-check=0, pre-check=0', 'max-age=0' ); $this->_headers['Pragma'] = 'no-cache'; } else { $expires = is_string($expires) ? strtotime($expires) : $expires; $this->_headers['Expires'] = gmdate('D, d M Y H:i:s', $expires).' GMT'; $this->_headers['Cache-Control'] = 'max-age='.($expires - time()); } return $this; }
[ "public", "function", "cache", "(", "$", "expires", ")", "{", "if", "(", "$", "expires", "===", "false", ")", "{", "$", "this", "->", "_headers", "[", "'Expires'", "]", "=", "'Mon, 26 Jul 1997 05:00:00 GMT'", ";", "$", "this", "->", "_headers", "[", "'Cache-Control'", "]", "=", "array", "(", "'no-store, no-cache, must-revalidate'", ",", "'post-check=0, pre-check=0'", ",", "'max-age=0'", ")", ";", "$", "this", "->", "_headers", "[", "'Pragma'", "]", "=", "'no-cache'", ";", "}", "else", "{", "$", "expires", "=", "is_string", "(", "$", "expires", ")", "?", "strtotime", "(", "$", "expires", ")", ":", "$", "expires", ";", "$", "this", "->", "_headers", "[", "'Expires'", "]", "=", "gmdate", "(", "'D, d M Y H:i:s'", ",", "$", "expires", ")", ".", "' GMT'", ";", "$", "this", "->", "_headers", "[", "'Cache-Control'", "]", "=", "'max-age='", ".", "(", "$", "expires", "-", "time", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the caching headers for the response. @param string|int|false $expires @return \m\Http\Response
[ "Sets", "the", "caching", "headers", "for", "the", "response", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Http/Response.php#L316-L332
5,783
HeroicTeam/m
Http/Response.php
Response.sendStatus
public function sendStatus($protocol = null) { if (null === $protocol) { $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; } header($protocol.' '.$this->_status.' '.$this->getStatusMessage($this->_status)); return $this; }
php
public function sendStatus($protocol = null) { if (null === $protocol) { $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; } header($protocol.' '.$this->_status.' '.$this->getStatusMessage($this->_status)); return $this; }
[ "public", "function", "sendStatus", "(", "$", "protocol", "=", "null", ")", "{", "if", "(", "null", "===", "$", "protocol", ")", "{", "$", "protocol", "=", "isset", "(", "$", "_SERVER", "[", "'SERVER_PROTOCOL'", "]", ")", "?", "$", "_SERVER", "[", "'SERVER_PROTOCOL'", "]", ":", "'HTTP/1.1'", ";", "}", "header", "(", "$", "protocol", ".", "' '", ".", "$", "this", "->", "_status", ".", "' '", ".", "$", "this", "->", "getStatusMessage", "(", "$", "this", "->", "_status", ")", ")", ";", "return", "$", "this", ";", "}" ]
Sends the HTTP status header. @param string|null $protocol @return \m\Http\Response
[ "Sends", "the", "HTTP", "status", "header", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Http/Response.php#L362-L370
5,784
HeroicTeam/m
Http/Response.php
Response.sendHeaders
public function sendHeaders() { foreach ($this->_headers as $key => $value) { if (is_array($value)) { foreach ($value as $v) { header($key.': '.$v, false); } } else { header($key.': '.$value); } } return $this; }
php
public function sendHeaders() { foreach ($this->_headers as $key => $value) { if (is_array($value)) { foreach ($value as $v) { header($key.': '.$v, false); } } else { header($key.': '.$value); } } return $this; }
[ "public", "function", "sendHeaders", "(", ")", "{", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "v", ")", "{", "header", "(", "$", "key", ".", "': '", ".", "$", "v", ",", "false", ")", ";", "}", "}", "else", "{", "header", "(", "$", "key", ".", "': '", ".", "$", "value", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Sends all of the set HTTP headers. @return \m\Http\Response
[ "Sends", "all", "of", "the", "set", "HTTP", "headers", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Http/Response.php#L377-L390
5,785
HeroicTeam/m
Http/Response.php
Response.send
public function send($protocol = null) { // Clean up any open buffers if (ob_get_length() > 0) { ob_end_clean(); } // Send the status code and headers if (!headers_sent()) $this->sendStatus($protocol)->sendHeaders(); // Send the body echo $this->_body; // Kill the script exit; }
php
public function send($protocol = null) { // Clean up any open buffers if (ob_get_length() > 0) { ob_end_clean(); } // Send the status code and headers if (!headers_sent()) $this->sendStatus($protocol)->sendHeaders(); // Send the body echo $this->_body; // Kill the script exit; }
[ "public", "function", "send", "(", "$", "protocol", "=", "null", ")", "{", "// Clean up any open buffers", "if", "(", "ob_get_length", "(", ")", ">", "0", ")", "{", "ob_end_clean", "(", ")", ";", "}", "// Send the status code and headers", "if", "(", "!", "headers_sent", "(", ")", ")", "$", "this", "->", "sendStatus", "(", "$", "protocol", ")", "->", "sendHeaders", "(", ")", ";", "// Send the body", "echo", "$", "this", "->", "_body", ";", "// Kill the script", "exit", ";", "}" ]
Sends the response and ends the application. @param string|null $protocol
[ "Sends", "the", "response", "and", "ends", "the", "application", "." ]
daa6d5956ee6c989379fe5fae39feccc59cf4add
https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Http/Response.php#L397-L414
5,786
Markei/silex-website-framework
src/Markei/SilexWebsiteFramework/Application.php
Application.validateConfiguration
protected function validateConfiguration($config) { $requiredFields = $this->getRequiredConfigurationFields(); $missingFields = []; foreach ($requiredFields as $requiredField) { if (array_key_exists($requiredField, $config) === false) { $missingFields[] = $requiredField; } } if (count($missingFields) > 0) { throw new \RuntimeException('Some fields are not configured: ' . implode(', ', $missingFields)); } }
php
protected function validateConfiguration($config) { $requiredFields = $this->getRequiredConfigurationFields(); $missingFields = []; foreach ($requiredFields as $requiredField) { if (array_key_exists($requiredField, $config) === false) { $missingFields[] = $requiredField; } } if (count($missingFields) > 0) { throw new \RuntimeException('Some fields are not configured: ' . implode(', ', $missingFields)); } }
[ "protected", "function", "validateConfiguration", "(", "$", "config", ")", "{", "$", "requiredFields", "=", "$", "this", "->", "getRequiredConfigurationFields", "(", ")", ";", "$", "missingFields", "=", "[", "]", ";", "foreach", "(", "$", "requiredFields", "as", "$", "requiredField", ")", "{", "if", "(", "array_key_exists", "(", "$", "requiredField", ",", "$", "config", ")", "===", "false", ")", "{", "$", "missingFields", "[", "]", "=", "$", "requiredField", ";", "}", "}", "if", "(", "count", "(", "$", "missingFields", ")", ">", "0", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Some fields are not configured: '", ".", "implode", "(", "', '", ",", "$", "missingFields", ")", ")", ";", "}", "}" ]
Validates the configuration Checks if all the fields are present @param array $config
[ "Validates", "the", "configuration", "Checks", "if", "all", "the", "fields", "are", "present" ]
f1993ec18969bb19721e02033bc0587b1c9f2a64
https://github.com/Markei/silex-website-framework/blob/f1993ec18969bb19721e02033bc0587b1c9f2a64/src/Markei/SilexWebsiteFramework/Application.php#L39-L51
5,787
Markei/silex-website-framework
src/Markei/SilexWebsiteFramework/Application.php
Application.bootTwig
protected function bootTwig() { $options = $this->getTwigOptions(); $options['twig.path'][] = __DIR__ . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'views'; if ($this['debug'] === false) { $options['twig.options']['cache'] = $this['app.cache'] . DIRECTORY_SEPARATOR . 'twig'; } $this->register(new TwigServiceProvider(), $options); // patch for SF 3.4 break / https://github.com/silexphp/Silex/issues/1579 $this->extend('twig.runtimes', function ($runtimes, $app) { return array_merge($runtimes, [ FormRenderer::class => 'twig.form.renderer', ]); }); $this->extend('twig', function (\Twig_Environment $twig, Application $app) { $twig->addExtension(new ImagineExtension($app)); $twig->addExtension(new ConfigExtension($app)); return $twig; }); }
php
protected function bootTwig() { $options = $this->getTwigOptions(); $options['twig.path'][] = __DIR__ . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'views'; if ($this['debug'] === false) { $options['twig.options']['cache'] = $this['app.cache'] . DIRECTORY_SEPARATOR . 'twig'; } $this->register(new TwigServiceProvider(), $options); // patch for SF 3.4 break / https://github.com/silexphp/Silex/issues/1579 $this->extend('twig.runtimes', function ($runtimes, $app) { return array_merge($runtimes, [ FormRenderer::class => 'twig.form.renderer', ]); }); $this->extend('twig', function (\Twig_Environment $twig, Application $app) { $twig->addExtension(new ImagineExtension($app)); $twig->addExtension(new ConfigExtension($app)); return $twig; }); }
[ "protected", "function", "bootTwig", "(", ")", "{", "$", "options", "=", "$", "this", "->", "getTwigOptions", "(", ")", ";", "$", "options", "[", "'twig.path'", "]", "[", "]", "=", "__DIR__", ".", "DIRECTORY_SEPARATOR", ".", "'Resources'", ".", "DIRECTORY_SEPARATOR", ".", "'views'", ";", "if", "(", "$", "this", "[", "'debug'", "]", "===", "false", ")", "{", "$", "options", "[", "'twig.options'", "]", "[", "'cache'", "]", "=", "$", "this", "[", "'app.cache'", "]", ".", "DIRECTORY_SEPARATOR", ".", "'twig'", ";", "}", "$", "this", "->", "register", "(", "new", "TwigServiceProvider", "(", ")", ",", "$", "options", ")", ";", "// patch for SF 3.4 break / https://github.com/silexphp/Silex/issues/1579\r", "$", "this", "->", "extend", "(", "'twig.runtimes'", ",", "function", "(", "$", "runtimes", ",", "$", "app", ")", "{", "return", "array_merge", "(", "$", "runtimes", ",", "[", "FormRenderer", "::", "class", "=>", "'twig.form.renderer'", ",", "]", ")", ";", "}", ")", ";", "$", "this", "->", "extend", "(", "'twig'", ",", "function", "(", "\\", "Twig_Environment", "$", "twig", ",", "Application", "$", "app", ")", "{", "$", "twig", "->", "addExtension", "(", "new", "ImagineExtension", "(", "$", "app", ")", ")", ";", "$", "twig", "->", "addExtension", "(", "new", "ConfigExtension", "(", "$", "app", ")", ")", ";", "return", "$", "twig", ";", "}", ")", ";", "}" ]
Boots the Twig Service Provider
[ "Boots", "the", "Twig", "Service", "Provider" ]
f1993ec18969bb19721e02033bc0587b1c9f2a64
https://github.com/Markei/silex-website-framework/blob/f1993ec18969bb19721e02033bc0587b1c9f2a64/src/Markei/SilexWebsiteFramework/Application.php#L98-L117
5,788
Markei/silex-website-framework
src/Markei/SilexWebsiteFramework/Application.php
Application.bootForm
protected function bootForm() { $this->register(new FormServiceProvider(), array('form.secret' => $this['form.secret'])); $this->register(new ValidatorServiceProvider(), array()); $this->register(new CsrfServiceProvider()); }
php
protected function bootForm() { $this->register(new FormServiceProvider(), array('form.secret' => $this['form.secret'])); $this->register(new ValidatorServiceProvider(), array()); $this->register(new CsrfServiceProvider()); }
[ "protected", "function", "bootForm", "(", ")", "{", "$", "this", "->", "register", "(", "new", "FormServiceProvider", "(", ")", ",", "array", "(", "'form.secret'", "=>", "$", "this", "[", "'form.secret'", "]", ")", ")", ";", "$", "this", "->", "register", "(", "new", "ValidatorServiceProvider", "(", ")", ",", "array", "(", ")", ")", ";", "$", "this", "->", "register", "(", "new", "CsrfServiceProvider", "(", ")", ")", ";", "}" ]
Boots the Form Service Provider and Validator Service Provider
[ "Boots", "the", "Form", "Service", "Provider", "and", "Validator", "Service", "Provider" ]
f1993ec18969bb19721e02033bc0587b1c9f2a64
https://github.com/Markei/silex-website-framework/blob/f1993ec18969bb19721e02033bc0587b1c9f2a64/src/Markei/SilexWebsiteFramework/Application.php#L122-L127
5,789
Markei/silex-website-framework
src/Markei/SilexWebsiteFramework/Application.php
Application.bootSwiftmailer
protected function bootSwiftmailer() { $this->register(new \Silex\Provider\SwiftmailerServiceProvider(), array( 'swiftmailer.use_spool' => false, 'swiftmailer.options' => array( 'host' => $this['smtp.host'], 'port' => $this['smtp.port'], 'username' => $this['smtp.username'], 'password' => $this['smtp.password'], 'encryption' => $this['smtp.encryption'], 'auth_mode' => $this['smtp.auth_mode'] ) )); }
php
protected function bootSwiftmailer() { $this->register(new \Silex\Provider\SwiftmailerServiceProvider(), array( 'swiftmailer.use_spool' => false, 'swiftmailer.options' => array( 'host' => $this['smtp.host'], 'port' => $this['smtp.port'], 'username' => $this['smtp.username'], 'password' => $this['smtp.password'], 'encryption' => $this['smtp.encryption'], 'auth_mode' => $this['smtp.auth_mode'] ) )); }
[ "protected", "function", "bootSwiftmailer", "(", ")", "{", "$", "this", "->", "register", "(", "new", "\\", "Silex", "\\", "Provider", "\\", "SwiftmailerServiceProvider", "(", ")", ",", "array", "(", "'swiftmailer.use_spool'", "=>", "false", ",", "'swiftmailer.options'", "=>", "array", "(", "'host'", "=>", "$", "this", "[", "'smtp.host'", "]", ",", "'port'", "=>", "$", "this", "[", "'smtp.port'", "]", ",", "'username'", "=>", "$", "this", "[", "'smtp.username'", "]", ",", "'password'", "=>", "$", "this", "[", "'smtp.password'", "]", ",", "'encryption'", "=>", "$", "this", "[", "'smtp.encryption'", "]", ",", "'auth_mode'", "=>", "$", "this", "[", "'smtp.auth_mode'", "]", ")", ")", ")", ";", "}" ]
Boots the Swiftmailer Service Provider
[ "Boots", "the", "Swiftmailer", "Service", "Provider" ]
f1993ec18969bb19721e02033bc0587b1c9f2a64
https://github.com/Markei/silex-website-framework/blob/f1993ec18969bb19721e02033bc0587b1c9f2a64/src/Markei/SilexWebsiteFramework/Application.php#L140-L153
5,790
Markei/silex-website-framework
src/Markei/SilexWebsiteFramework/Application.php
Application.registerControllers
protected function registerControllers() { $this['controllers.page'] = function ($app) { return new PageController($app); }; $this['controllers.imagine'] = function ($app) { return new ImagineController($app); }; $this['controllers.error'] = function ($app) { return new ErrorController($app); }; }
php
protected function registerControllers() { $this['controllers.page'] = function ($app) { return new PageController($app); }; $this['controllers.imagine'] = function ($app) { return new ImagineController($app); }; $this['controllers.error'] = function ($app) { return new ErrorController($app); }; }
[ "protected", "function", "registerControllers", "(", ")", "{", "$", "this", "[", "'controllers.page'", "]", "=", "function", "(", "$", "app", ")", "{", "return", "new", "PageController", "(", "$", "app", ")", ";", "}", ";", "$", "this", "[", "'controllers.imagine'", "]", "=", "function", "(", "$", "app", ")", "{", "return", "new", "ImagineController", "(", "$", "app", ")", ";", "}", ";", "$", "this", "[", "'controllers.error'", "]", "=", "function", "(", "$", "app", ")", "{", "return", "new", "ErrorController", "(", "$", "app", ")", ";", "}", ";", "}" ]
Register the controllers in the container
[ "Register", "the", "controllers", "in", "the", "container" ]
f1993ec18969bb19721e02033bc0587b1c9f2a64
https://github.com/Markei/silex-website-framework/blob/f1993ec18969bb19721e02033bc0587b1c9f2a64/src/Markei/SilexWebsiteFramework/Application.php#L180-L185
5,791
Markei/silex-website-framework
src/Markei/SilexWebsiteFramework/Application.php
Application.registerRoutes
protected function registerRoutes() { $this->get($this['imagine.thumbnail_url'] . '{size}/{checksum}/{path}', function (Application $app, Request $request, $path, $size, $checksum) { return $app['controllers.imagine']->resizeImageAction($request, $path, $size, $checksum); })->assert('path', '.+'); $this->get('', function (Application $app, Request $request) { return $app['controllers.page']->showHomePageAction($request); }); $this->error(function (NotFoundHttpException $e, $code) { return $this['controllers.error']->notFoundAction($e); }); $this->error(function (\Exception $e, $code) { return $this['controllers.error']->internalServerErrorAction($e); }); }
php
protected function registerRoutes() { $this->get($this['imagine.thumbnail_url'] . '{size}/{checksum}/{path}', function (Application $app, Request $request, $path, $size, $checksum) { return $app['controllers.imagine']->resizeImageAction($request, $path, $size, $checksum); })->assert('path', '.+'); $this->get('', function (Application $app, Request $request) { return $app['controllers.page']->showHomePageAction($request); }); $this->error(function (NotFoundHttpException $e, $code) { return $this['controllers.error']->notFoundAction($e); }); $this->error(function (\Exception $e, $code) { return $this['controllers.error']->internalServerErrorAction($e); }); }
[ "protected", "function", "registerRoutes", "(", ")", "{", "$", "this", "->", "get", "(", "$", "this", "[", "'imagine.thumbnail_url'", "]", ".", "'{size}/{checksum}/{path}'", ",", "function", "(", "Application", "$", "app", ",", "Request", "$", "request", ",", "$", "path", ",", "$", "size", ",", "$", "checksum", ")", "{", "return", "$", "app", "[", "'controllers.imagine'", "]", "->", "resizeImageAction", "(", "$", "request", ",", "$", "path", ",", "$", "size", ",", "$", "checksum", ")", ";", "}", ")", "->", "assert", "(", "'path'", ",", "'.+'", ")", ";", "$", "this", "->", "get", "(", "''", ",", "function", "(", "Application", "$", "app", ",", "Request", "$", "request", ")", "{", "return", "$", "app", "[", "'controllers.page'", "]", "->", "showHomePageAction", "(", "$", "request", ")", ";", "}", ")", ";", "$", "this", "->", "error", "(", "function", "(", "NotFoundHttpException", "$", "e", ",", "$", "code", ")", "{", "return", "$", "this", "[", "'controllers.error'", "]", "->", "notFoundAction", "(", "$", "e", ")", ";", "}", ")", ";", "$", "this", "->", "error", "(", "function", "(", "\\", "Exception", "$", "e", ",", "$", "code", ")", "{", "return", "$", "this", "[", "'controllers.error'", "]", "->", "internalServerErrorAction", "(", "$", "e", ")", ";", "}", ")", ";", "}" ]
Register the routes and link them to the controller actions
[ "Register", "the", "routes", "and", "link", "them", "to", "the", "controller", "actions" ]
f1993ec18969bb19721e02033bc0587b1c9f2a64
https://github.com/Markei/silex-website-framework/blob/f1993ec18969bb19721e02033bc0587b1c9f2a64/src/Markei/SilexWebsiteFramework/Application.php#L190-L196
5,792
liftkit/core
src/Application/Hook/Event.php
Event.trigger
public function trigger ($args = array(), $precedence = null) { if (is_null($precedence)) { $functions = array(); ksort($this->hooks); foreach ($this->hooks as $function_set) { foreach ($function_set as $function) { $functions[] = $function; } } $return = array(); foreach ($functions as $function) { $return[] = call_user_func_array($function, $args); } return $return; } else { $return = array(); if (isset($this->hooks[$precedence]) && is_array($this->hooks[$precedence])) { foreach ($this->hooks[$precedence] as $function) { $return[] = call_user_func_array($function, $args); } } return $return; } }
php
public function trigger ($args = array(), $precedence = null) { if (is_null($precedence)) { $functions = array(); ksort($this->hooks); foreach ($this->hooks as $function_set) { foreach ($function_set as $function) { $functions[] = $function; } } $return = array(); foreach ($functions as $function) { $return[] = call_user_func_array($function, $args); } return $return; } else { $return = array(); if (isset($this->hooks[$precedence]) && is_array($this->hooks[$precedence])) { foreach ($this->hooks[$precedence] as $function) { $return[] = call_user_func_array($function, $args); } } return $return; } }
[ "public", "function", "trigger", "(", "$", "args", "=", "array", "(", ")", ",", "$", "precedence", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "precedence", ")", ")", "{", "$", "functions", "=", "array", "(", ")", ";", "ksort", "(", "$", "this", "->", "hooks", ")", ";", "foreach", "(", "$", "this", "->", "hooks", "as", "$", "function_set", ")", "{", "foreach", "(", "$", "function_set", "as", "$", "function", ")", "{", "$", "functions", "[", "]", "=", "$", "function", ";", "}", "}", "$", "return", "=", "array", "(", ")", ";", "foreach", "(", "$", "functions", "as", "$", "function", ")", "{", "$", "return", "[", "]", "=", "call_user_func_array", "(", "$", "function", ",", "$", "args", ")", ";", "}", "return", "$", "return", ";", "}", "else", "{", "$", "return", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "hooks", "[", "$", "precedence", "]", ")", "&&", "is_array", "(", "$", "this", "->", "hooks", "[", "$", "precedence", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "hooks", "[", "$", "precedence", "]", "as", "$", "function", ")", "{", "$", "return", "[", "]", "=", "call_user_func_array", "(", "$", "function", ",", "$", "args", ")", ";", "}", "}", "return", "$", "return", ";", "}", "}" ]
Invokes all callback attached to the event If null precedence is provided, invokes all hooks for a given event, regardless of precedence. @api @param array $args An array of parameters to be passed to each hook. @param mixed $precedence (default: null) If provided, this hook will only execute the callbacks of the supplied precedence. @return array
[ "Invokes", "all", "callback", "attached", "to", "the", "event" ]
c98dcffa65450bd11332dbffe2064650c3a72aae
https://github.com/liftkit/core/blob/c98dcffa65450bd11332dbffe2064650c3a72aae/src/Application/Hook/Event.php#L36-L67
5,793
lembarek/auth
src/Controllers/PasswordController.php
PasswordController.sendToEmail
public function sendToEmail(Request $request, UserMailer $userMailer) { $this->validate($request, [ 'email' => 'required|email' ]); $request = $request->only('email'); $request['token'] = str_random(40); $this->resetPasswordRepo->create($request); $userMailer->sendResetPasswordEmailTo($request); return redirect()->route('core::home'); }
php
public function sendToEmail(Request $request, UserMailer $userMailer) { $this->validate($request, [ 'email' => 'required|email' ]); $request = $request->only('email'); $request['token'] = str_random(40); $this->resetPasswordRepo->create($request); $userMailer->sendResetPasswordEmailTo($request); return redirect()->route('core::home'); }
[ "public", "function", "sendToEmail", "(", "Request", "$", "request", ",", "UserMailer", "$", "userMailer", ")", "{", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'email'", "=>", "'required|email'", "]", ")", ";", "$", "request", "=", "$", "request", "->", "only", "(", "'email'", ")", ";", "$", "request", "[", "'token'", "]", "=", "str_random", "(", "40", ")", ";", "$", "this", "->", "resetPasswordRepo", "->", "create", "(", "$", "request", ")", ";", "$", "userMailer", "->", "sendResetPasswordEmailTo", "(", "$", "request", ")", ";", "return", "redirect", "(", ")", "->", "route", "(", "'core::home'", ")", ";", "}" ]
send a message to the email of the user @return Reponse
[ "send", "a", "message", "to", "the", "email", "of", "the", "user" ]
783aad2bcde9d8014be34092ba0cbe38b2bbc60a
https://github.com/lembarek/auth/blob/783aad2bcde9d8014be34092ba0cbe38b2bbc60a/src/Controllers/PasswordController.php#L40-L50
5,794
lembarek/auth
src/Controllers/PasswordController.php
PasswordController.resetPassword
public function resetPassword(Request $request) { $this->validate($request, [ 'password' => 'required|confirmed', 'token' => 'required' ]); $record= $this->resetPasswordRepo->where('token', $request['token']); $email = $record->first()->email; $record->delete(); $user = $this->userRepo->where('email', $email)->update(['password' => $request['password']]); return redirect()->route('core::home'); }
php
public function resetPassword(Request $request) { $this->validate($request, [ 'password' => 'required|confirmed', 'token' => 'required' ]); $record= $this->resetPasswordRepo->where('token', $request['token']); $email = $record->first()->email; $record->delete(); $user = $this->userRepo->where('email', $email)->update(['password' => $request['password']]); return redirect()->route('core::home'); }
[ "public", "function", "resetPassword", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'password'", "=>", "'required|confirmed'", ",", "'token'", "=>", "'required'", "]", ")", ";", "$", "record", "=", "$", "this", "->", "resetPasswordRepo", "->", "where", "(", "'token'", ",", "$", "request", "[", "'token'", "]", ")", ";", "$", "email", "=", "$", "record", "->", "first", "(", ")", "->", "email", ";", "$", "record", "->", "delete", "(", ")", ";", "$", "user", "=", "$", "this", "->", "userRepo", "->", "where", "(", "'email'", ",", "$", "email", ")", "->", "update", "(", "[", "'password'", "=>", "$", "request", "[", "'password'", "]", "]", ")", ";", "return", "redirect", "(", ")", "->", "route", "(", "'core::home'", ")", ";", "}" ]
to save then new password @return Response
[ "to", "save", "then", "new", "password" ]
783aad2bcde9d8014be34092ba0cbe38b2bbc60a
https://github.com/lembarek/auth/blob/783aad2bcde9d8014be34092ba0cbe38b2bbc60a/src/Controllers/PasswordController.php#L69-L82
5,795
apnet/AsseticImporterBundle
src/Apnet/AsseticImporterBundle/Factory/AssetMapper.php
AssetMapper.map
public function map($sourcePath, $targetPath) { if (file_exists($sourcePath)) { $items = array(); if (is_file($sourcePath)) { $items[$targetPath] = $sourcePath; } elseif (is_dir($sourcePath)) { $finder = new Finder\Finder(); foreach ($finder->in($sourcePath)->files() as $file) { /* @var $file Finder\SplFileInfo */ $fileTargetPath = $targetPath . "/" . $file->getRelativePathname(); $items[$fileTargetPath] = $file->getPathname(); } } foreach ($items as $target => $source) { $formulae = new AssetFormulae(); $formulae->setInputs( array($source) ); $formulae->setOptions( array("output" => $target) ); $this->append($formulae); } } }
php
public function map($sourcePath, $targetPath) { if (file_exists($sourcePath)) { $items = array(); if (is_file($sourcePath)) { $items[$targetPath] = $sourcePath; } elseif (is_dir($sourcePath)) { $finder = new Finder\Finder(); foreach ($finder->in($sourcePath)->files() as $file) { /* @var $file Finder\SplFileInfo */ $fileTargetPath = $targetPath . "/" . $file->getRelativePathname(); $items[$fileTargetPath] = $file->getPathname(); } } foreach ($items as $target => $source) { $formulae = new AssetFormulae(); $formulae->setInputs( array($source) ); $formulae->setOptions( array("output" => $target) ); $this->append($formulae); } } }
[ "public", "function", "map", "(", "$", "sourcePath", ",", "$", "targetPath", ")", "{", "if", "(", "file_exists", "(", "$", "sourcePath", ")", ")", "{", "$", "items", "=", "array", "(", ")", ";", "if", "(", "is_file", "(", "$", "sourcePath", ")", ")", "{", "$", "items", "[", "$", "targetPath", "]", "=", "$", "sourcePath", ";", "}", "elseif", "(", "is_dir", "(", "$", "sourcePath", ")", ")", "{", "$", "finder", "=", "new", "Finder", "\\", "Finder", "(", ")", ";", "foreach", "(", "$", "finder", "->", "in", "(", "$", "sourcePath", ")", "->", "files", "(", ")", "as", "$", "file", ")", "{", "/* @var $file Finder\\SplFileInfo */", "$", "fileTargetPath", "=", "$", "targetPath", ".", "\"/\"", ".", "$", "file", "->", "getRelativePathname", "(", ")", ";", "$", "items", "[", "$", "fileTargetPath", "]", "=", "$", "file", "->", "getPathname", "(", ")", ";", "}", "}", "foreach", "(", "$", "items", "as", "$", "target", "=>", "$", "source", ")", "{", "$", "formulae", "=", "new", "AssetFormulae", "(", ")", ";", "$", "formulae", "->", "setInputs", "(", "array", "(", "$", "source", ")", ")", ";", "$", "formulae", "->", "setOptions", "(", "array", "(", "\"output\"", "=>", "$", "target", ")", ")", ";", "$", "this", "->", "append", "(", "$", "formulae", ")", ";", "}", "}", "}" ]
Map files from source to target path @param string $sourcePath Source path @param string $targetPath Target path @return null
[ "Map", "files", "from", "source", "to", "target", "path" ]
104ad3593795c016a5b89ecc8c240d4d96d3de45
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticImporterBundle/Factory/AssetMapper.php#L54-L81
5,796
apnet/AsseticImporterBundle
src/Apnet/AsseticImporterBundle/Factory/AssetMapper.php
AssetMapper.item
public function item($offset) { if (isset($this->formulae[$offset])) { $item = $this->formulae[$offset]; } else { $item = null; } return $item; }
php
public function item($offset) { if (isset($this->formulae[$offset])) { $item = $this->formulae[$offset]; } else { $item = null; } return $item; }
[ "public", "function", "item", "(", "$", "offset", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "formulae", "[", "$", "offset", "]", ")", ")", "{", "$", "item", "=", "$", "this", "->", "formulae", "[", "$", "offset", "]", ";", "}", "else", "{", "$", "item", "=", "null", ";", "}", "return", "$", "item", ";", "}" ]
Return paths relation @param integer $offset Item offset @return AssetFormulae|null
[ "Return", "paths", "relation" ]
104ad3593795c016a5b89ecc8c240d4d96d3de45
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticImporterBundle/Factory/AssetMapper.php#L100-L108
5,797
fratily/http-message
src/Stream.php
Stream.attach
public function attach($resource){ if(!is_resource($resource) || "stream" !== get_resource_type($resource)){ throw new \InvalidArgumentException( "Argument must be of the type stream resource, " . gettype($resource) . " given." ); } $this->resource = $resource; }
php
public function attach($resource){ if(!is_resource($resource) || "stream" !== get_resource_type($resource)){ throw new \InvalidArgumentException( "Argument must be of the type stream resource, " . gettype($resource) . " given." ); } $this->resource = $resource; }
[ "public", "function", "attach", "(", "$", "resource", ")", "{", "if", "(", "!", "is_resource", "(", "$", "resource", ")", "||", "\"stream\"", "!==", "get_resource_type", "(", "$", "resource", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Argument must be of the type stream resource, \"", ".", "gettype", "(", "$", "resource", ")", ".", "\" given.\"", ")", ";", "}", "$", "this", "->", "resource", "=", "$", "resource", ";", "}" ]
Attach resource. @param resource $resource @return void
[ "Attach", "resource", "." ]
2005d2f2126527438af8eecdab0eebfec68dd0c1
https://github.com/fratily/http-message/blob/2005d2f2126527438af8eecdab0eebfec68dd0c1/src/Stream.php#L65-L73
5,798
sellerlabs/nucleus
src/SellerLabs/Nucleus/Support/Str.php
Str.beginsWith
public static function beginsWith($subject, $prefix, $encoding = null) { return Rope::of($subject, $encoding)->beginsWith($prefix); }
php
public static function beginsWith($subject, $prefix, $encoding = null) { return Rope::of($subject, $encoding)->beginsWith($prefix); }
[ "public", "static", "function", "beginsWith", "(", "$", "subject", ",", "$", "prefix", ",", "$", "encoding", "=", "null", ")", "{", "return", "Rope", "::", "of", "(", "$", "subject", ",", "$", "encoding", ")", "->", "beginsWith", "(", "$", "prefix", ")", ";", "}" ]
Return whether or not the provided subject beings with the prefix. @param string $subject @param string $prefix @param null|string $encoding @return bool
[ "Return", "whether", "or", "not", "the", "provided", "subject", "beings", "with", "the", "prefix", "." ]
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Str.php#L123-L126
5,799
sellerlabs/nucleus
src/SellerLabs/Nucleus/Support/Str.php
Str.endsWith
public static function endsWith($subject, $suffix, $encoding = null) { return Rope::of($subject, $encoding)->endsWith($suffix); }
php
public static function endsWith($subject, $suffix, $encoding = null) { return Rope::of($subject, $encoding)->endsWith($suffix); }
[ "public", "static", "function", "endsWith", "(", "$", "subject", ",", "$", "suffix", ",", "$", "encoding", "=", "null", ")", "{", "return", "Rope", "::", "of", "(", "$", "subject", ",", "$", "encoding", ")", "->", "endsWith", "(", "$", "suffix", ")", ";", "}" ]
Return whether or not the provided subject ends with suffix. @param string $subject @param string $suffix @param null|string $encoding @return bool @throws InvalidArgumentException
[ "Return", "whether", "or", "not", "the", "provided", "subject", "ends", "with", "suffix", "." ]
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Str.php#L138-L141