id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
37,200
CeusMedia/Common
src/UI/Image/Graph/Builder.php
UI_Image_Graph_Builder.setUpGrid
protected static function setUpGrid( $graph, $config, $data ) { $gridDepth = self::getConfigValue( $config, "grid.depth", DEPTH_BACK ); $graph->setGridDepth( $gridDepth ); UI_Image_Graph_Components::setGrid( $graph->xgrid, self::getSubConfig( $config, 'x.grid.' ), $data ); UI_Image_Graph_Components::setGrid( $graph->ygrid, self::getSubConfig( $config, 'y.grid.' ), $data ); }
php
protected static function setUpGrid( $graph, $config, $data ) { $gridDepth = self::getConfigValue( $config, "grid.depth", DEPTH_BACK ); $graph->setGridDepth( $gridDepth ); UI_Image_Graph_Components::setGrid( $graph->xgrid, self::getSubConfig( $config, 'x.grid.' ), $data ); UI_Image_Graph_Components::setGrid( $graph->ygrid, self::getSubConfig( $config, 'y.grid.' ), $data ); }
[ "protected", "static", "function", "setUpGrid", "(", "$", "graph", ",", "$", "config", ",", "$", "data", ")", "{", "$", "gridDepth", "=", "self", "::", "getConfigValue", "(", "$", "config", ",", "\"grid.depth\"", ",", "DEPTH_BACK", ")", ";", "$", "graph", "->", "setGridDepth", "(", "$", "gridDepth", ")", ";", "UI_Image_Graph_Components", "::", "setGrid", "(", "$", "graph", "->", "xgrid", ",", "self", "::", "getSubConfig", "(", "$", "config", ",", "'x.grid.'", ")", ",", "$", "data", ")", ";", "UI_Image_Graph_Components", "::", "setGrid", "(", "$", "graph", "->", "ygrid", ",", "self", "::", "getSubConfig", "(", "$", "config", ",", "'y.grid.'", ")", ",", "$", "data", ")", ";", "}" ]
Adds a Grid to Graph. @access protected @static @param Graph $graph Graph Object to work on @param array $config Configuration Data @param array $data Graph Data @return void
[ "Adds", "a", "Grid", "to", "Graph", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L153-L159
37,201
CeusMedia/Common
src/UI/Image/Graph/Builder.php
UI_Image_Graph_Builder.setUpMargin
protected static function setUpMargin( $graph, $config ) { $marginLeft = self::getConfigValue( $config, 'margin.left', 0 ); $marginRight = self::getConfigValue( $config, 'margin.right', 0 ); $marginTop = self::getConfigValue( $config, 'margin.top', 0 ); $marginBottom = self::getConfigValue( $config, 'margin.bottom', 0 ); $marginColor = self::getConfigValue( $config, 'margin.color' ); $graph->setMargin( $marginLeft, $marginRight, $marginTop, $marginBottom ); if( $marginColor ) $graph->setMarginColor( $marginColor ); }
php
protected static function setUpMargin( $graph, $config ) { $marginLeft = self::getConfigValue( $config, 'margin.left', 0 ); $marginRight = self::getConfigValue( $config, 'margin.right', 0 ); $marginTop = self::getConfigValue( $config, 'margin.top', 0 ); $marginBottom = self::getConfigValue( $config, 'margin.bottom', 0 ); $marginColor = self::getConfigValue( $config, 'margin.color' ); $graph->setMargin( $marginLeft, $marginRight, $marginTop, $marginBottom ); if( $marginColor ) $graph->setMarginColor( $marginColor ); }
[ "protected", "static", "function", "setUpMargin", "(", "$", "graph", ",", "$", "config", ")", "{", "$", "marginLeft", "=", "self", "::", "getConfigValue", "(", "$", "config", ",", "'margin.left'", ",", "0", ")", ";", "$", "marginRight", "=", "self", "::", "getConfigValue", "(", "$", "config", ",", "'margin.right'", ",", "0", ")", ";", "$", "marginTop", "=", "self", "::", "getConfigValue", "(", "$", "config", ",", "'margin.top'", ",", "0", ")", ";", "$", "marginBottom", "=", "self", "::", "getConfigValue", "(", "$", "config", ",", "'margin.bottom'", ",", "0", ")", ";", "$", "marginColor", "=", "self", "::", "getConfigValue", "(", "$", "config", ",", "'margin.color'", ")", ";", "$", "graph", "->", "setMargin", "(", "$", "marginLeft", ",", "$", "marginRight", ",", "$", "marginTop", ",", "$", "marginBottom", ")", ";", "if", "(", "$", "marginColor", ")", "$", "graph", "->", "setMarginColor", "(", "$", "marginColor", ")", ";", "}" ]
Adds Margin to Graph. @access protected @static @param Graph $graph Graph Object to work on @param array $config Configuration Data @return void
[ "Adds", "Margin", "to", "Graph", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L169-L179
37,202
CeusMedia/Common
src/UI/Image/Graph/Builder.php
UI_Image_Graph_Builder.setUpPlots
protected static function setUpPlots( $graph, $config, $data ) { // -- CREATE PLOTS -- // $plots = array( 'y2' => array(), 'y1' => array(), ); $nr = 1; while( 1 ) { $prefix = 'y1.'.$nr++.'.'; if( !isset( $config[$prefix.'type'] ) ) break; if( $plot = self::createPlot( $config, $data, $prefix ) ) array_unshift( $plots['y1'], $plot ); } $scaleY2 = self::getConfigValue( $config, "y2.scale" ); if( $scaleY2 ) { $graph->setY2Scale( $scaleY2 ); UI_Image_Graph_Components::setAxis( $graph->y2axis, self::getSubConfig( $config, 'y2.axis.' ), $data ); $nr = 1; while( 1 ) { $prefix = 'y2.'.$nr++.'.'; if( !isset( $config[$prefix.'type'] ) ) break; if( $plot = self::createPlot( $config, $prefix ) ) array_unshift( $plots['y2'], $plot ); } } foreach( $plots as $axis => $axisPlots ) foreach( $axisPlots as $plot ) ( $axis == 'y2' ) ? $graph->addY2( $plot ) : $graph->add( $plot ); }
php
protected static function setUpPlots( $graph, $config, $data ) { // -- CREATE PLOTS -- // $plots = array( 'y2' => array(), 'y1' => array(), ); $nr = 1; while( 1 ) { $prefix = 'y1.'.$nr++.'.'; if( !isset( $config[$prefix.'type'] ) ) break; if( $plot = self::createPlot( $config, $data, $prefix ) ) array_unshift( $plots['y1'], $plot ); } $scaleY2 = self::getConfigValue( $config, "y2.scale" ); if( $scaleY2 ) { $graph->setY2Scale( $scaleY2 ); UI_Image_Graph_Components::setAxis( $graph->y2axis, self::getSubConfig( $config, 'y2.axis.' ), $data ); $nr = 1; while( 1 ) { $prefix = 'y2.'.$nr++.'.'; if( !isset( $config[$prefix.'type'] ) ) break; if( $plot = self::createPlot( $config, $prefix ) ) array_unshift( $plots['y2'], $plot ); } } foreach( $plots as $axis => $axisPlots ) foreach( $axisPlots as $plot ) ( $axis == 'y2' ) ? $graph->addY2( $plot ) : $graph->add( $plot ); }
[ "protected", "static", "function", "setUpPlots", "(", "$", "graph", ",", "$", "config", ",", "$", "data", ")", "{", "// -- CREATE PLOTS -- //", "$", "plots", "=", "array", "(", "'y2'", "=>", "array", "(", ")", ",", "'y1'", "=>", "array", "(", ")", ",", ")", ";", "$", "nr", "=", "1", ";", "while", "(", "1", ")", "{", "$", "prefix", "=", "'y1.'", ".", "$", "nr", "++", ".", "'.'", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "$", "prefix", ".", "'type'", "]", ")", ")", "break", ";", "if", "(", "$", "plot", "=", "self", "::", "createPlot", "(", "$", "config", ",", "$", "data", ",", "$", "prefix", ")", ")", "array_unshift", "(", "$", "plots", "[", "'y1'", "]", ",", "$", "plot", ")", ";", "}", "$", "scaleY2", "=", "self", "::", "getConfigValue", "(", "$", "config", ",", "\"y2.scale\"", ")", ";", "if", "(", "$", "scaleY2", ")", "{", "$", "graph", "->", "setY2Scale", "(", "$", "scaleY2", ")", ";", "UI_Image_Graph_Components", "::", "setAxis", "(", "$", "graph", "->", "y2axis", ",", "self", "::", "getSubConfig", "(", "$", "config", ",", "'y2.axis.'", ")", ",", "$", "data", ")", ";", "$", "nr", "=", "1", ";", "while", "(", "1", ")", "{", "$", "prefix", "=", "'y2.'", ".", "$", "nr", "++", ".", "'.'", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "$", "prefix", ".", "'type'", "]", ")", ")", "break", ";", "if", "(", "$", "plot", "=", "self", "::", "createPlot", "(", "$", "config", ",", "$", "prefix", ")", ")", "array_unshift", "(", "$", "plots", "[", "'y2'", "]", ",", "$", "plot", ")", ";", "}", "}", "foreach", "(", "$", "plots", "as", "$", "axis", "=>", "$", "axisPlots", ")", "foreach", "(", "$", "axisPlots", "as", "$", "plot", ")", "(", "$", "axis", "==", "'y2'", ")", "?", "$", "graph", "->", "addY2", "(", "$", "plot", ")", ":", "$", "graph", "->", "add", "(", "$", "plot", ")", ";", "}" ]
Adds Plots to Graph. @access protected @static @param Graph $graph Graph Object to work on @param array $config Configuration Data @param array $data Graph Data @return void
[ "Adds", "Plots", "to", "Graph", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L190-L225
37,203
CeusMedia/Common
src/Net/HTTP/PageRank.php
Net_HTTP_PageRank.calculateChecksum
private static function calculateChecksum( $url ) { $length = sizeof( $url ); $a = $b = 0x9E3779B9; $c = GOOGLE_MAGIC; $k = 0; $len = $length; while( $len >= 12 ) { $a += ( $url[$k+0] + ( $url[$k+1] <<8 ) + ( $url[$k+2] << 16 ) + ( $url[$k+3] << 24 ) ); $b += ( $url[$k+4] + ( $url[$k+5] <<8 ) + ( $url[$k+6] << 16 ) + ( $url[$k+7] << 24 ) ); $c += ( $url[$k+8] + ( $url[$k+9] <<8 ) + ( $url[$k+10] << 16 )+ ( $url[$k+11] << 24 ) ); $mix = self::mix( $a, $b, $c); $a = $mix[0]; $b = $mix[1]; $c = $mix[2]; $k += 12; $len -= 12; } $c += $length; switch( $len ) { case 11: $c +=( $url[$k+10] << 24 ); case 10: $c +=( $url[$k+9] << 16 ); case 9 : $c +=( $url[$k+8] << 8 ); /* the first byte of c is reserved for the length */ case 8 : $b +=( $url[$k+7] << 24 ); case 7 : $b +=( $url[$k+6] << 16 ); case 6 : $b +=( $url[$k+5] << 8 ); case 5 : $b +=( $url[$k+4]); case 4 : $a +=( $url[$k+3] << 24 ); case 3 : $a +=( $url[$k+2] << 16 ); case 2 : $a +=( $url[$k+1] << 8 ); case 1 : $a +=( $url[$k+0] ); } $mix = self::mix( $a, $b, $c ); return $mix[2]; }
php
private static function calculateChecksum( $url ) { $length = sizeof( $url ); $a = $b = 0x9E3779B9; $c = GOOGLE_MAGIC; $k = 0; $len = $length; while( $len >= 12 ) { $a += ( $url[$k+0] + ( $url[$k+1] <<8 ) + ( $url[$k+2] << 16 ) + ( $url[$k+3] << 24 ) ); $b += ( $url[$k+4] + ( $url[$k+5] <<8 ) + ( $url[$k+6] << 16 ) + ( $url[$k+7] << 24 ) ); $c += ( $url[$k+8] + ( $url[$k+9] <<8 ) + ( $url[$k+10] << 16 )+ ( $url[$k+11] << 24 ) ); $mix = self::mix( $a, $b, $c); $a = $mix[0]; $b = $mix[1]; $c = $mix[2]; $k += 12; $len -= 12; } $c += $length; switch( $len ) { case 11: $c +=( $url[$k+10] << 24 ); case 10: $c +=( $url[$k+9] << 16 ); case 9 : $c +=( $url[$k+8] << 8 ); /* the first byte of c is reserved for the length */ case 8 : $b +=( $url[$k+7] << 24 ); case 7 : $b +=( $url[$k+6] << 16 ); case 6 : $b +=( $url[$k+5] << 8 ); case 5 : $b +=( $url[$k+4]); case 4 : $a +=( $url[$k+3] << 24 ); case 3 : $a +=( $url[$k+2] << 16 ); case 2 : $a +=( $url[$k+1] << 8 ); case 1 : $a +=( $url[$k+0] ); } $mix = self::mix( $a, $b, $c ); return $mix[2]; }
[ "private", "static", "function", "calculateChecksum", "(", "$", "url", ")", "{", "$", "length", "=", "sizeof", "(", "$", "url", ")", ";", "$", "a", "=", "$", "b", "=", "0x9E3779B9", ";", "$", "c", "=", "GOOGLE_MAGIC", ";", "$", "k", "=", "0", ";", "$", "len", "=", "$", "length", ";", "while", "(", "$", "len", ">=", "12", ")", "{", "$", "a", "+=", "(", "$", "url", "[", "$", "k", "+", "0", "]", "+", "(", "$", "url", "[", "$", "k", "+", "1", "]", "<<", "8", ")", "+", "(", "$", "url", "[", "$", "k", "+", "2", "]", "<<", "16", ")", "+", "(", "$", "url", "[", "$", "k", "+", "3", "]", "<<", "24", ")", ")", ";", "$", "b", "+=", "(", "$", "url", "[", "$", "k", "+", "4", "]", "+", "(", "$", "url", "[", "$", "k", "+", "5", "]", "<<", "8", ")", "+", "(", "$", "url", "[", "$", "k", "+", "6", "]", "<<", "16", ")", "+", "(", "$", "url", "[", "$", "k", "+", "7", "]", "<<", "24", ")", ")", ";", "$", "c", "+=", "(", "$", "url", "[", "$", "k", "+", "8", "]", "+", "(", "$", "url", "[", "$", "k", "+", "9", "]", "<<", "8", ")", "+", "(", "$", "url", "[", "$", "k", "+", "10", "]", "<<", "16", ")", "+", "(", "$", "url", "[", "$", "k", "+", "11", "]", "<<", "24", ")", ")", ";", "$", "mix", "=", "self", "::", "mix", "(", "$", "a", ",", "$", "b", ",", "$", "c", ")", ";", "$", "a", "=", "$", "mix", "[", "0", "]", ";", "$", "b", "=", "$", "mix", "[", "1", "]", ";", "$", "c", "=", "$", "mix", "[", "2", "]", ";", "$", "k", "+=", "12", ";", "$", "len", "-=", "12", ";", "}", "$", "c", "+=", "$", "length", ";", "switch", "(", "$", "len", ")", "{", "case", "11", ":", "$", "c", "+=", "(", "$", "url", "[", "$", "k", "+", "10", "]", "<<", "24", ")", ";", "case", "10", ":", "$", "c", "+=", "(", "$", "url", "[", "$", "k", "+", "9", "]", "<<", "16", ")", ";", "case", "9", ":", "$", "c", "+=", "(", "$", "url", "[", "$", "k", "+", "8", "]", "<<", "8", ")", ";", "/* the first byte of c is reserved for the length */", "case", "8", ":", "$", "b", "+=", "(", "$", "url", "[", "$", "k", "+", "7", "]", "<<", "24", ")", ";", "case", "7", ":", "$", "b", "+=", "(", "$", "url", "[", "$", "k", "+", "6", "]", "<<", "16", ")", ";", "case", "6", ":", "$", "b", "+=", "(", "$", "url", "[", "$", "k", "+", "5", "]", "<<", "8", ")", ";", "case", "5", ":", "$", "b", "+=", "(", "$", "url", "[", "$", "k", "+", "4", "]", ")", ";", "case", "4", ":", "$", "a", "+=", "(", "$", "url", "[", "$", "k", "+", "3", "]", "<<", "24", ")", ";", "case", "3", ":", "$", "a", "+=", "(", "$", "url", "[", "$", "k", "+", "2", "]", "<<", "16", ")", ";", "case", "2", ":", "$", "a", "+=", "(", "$", "url", "[", "$", "k", "+", "1", "]", "<<", "8", ")", ";", "case", "1", ":", "$", "a", "+=", "(", "$", "url", "[", "$", "k", "+", "0", "]", ")", ";", "}", "$", "mix", "=", "self", "::", "mix", "(", "$", "a", ",", "$", "b", ",", "$", "c", ")", ";", "return", "$", "mix", "[", "2", "]", ";", "}" ]
Calculates Checksum of URL for Google Request @access private @static @param array $url URL as numeric Array @return string
[ "Calculates", "Checksum", "of", "URL", "for", "Google", "Request" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PageRank.php#L53-L90
37,204
CeusMedia/Common
src/Net/HTTP/PageRank.php
Net_HTTP_PageRank.get
public static function get( $url ) { $checksum = "6".self::calculateChecksum( self::strord( "info:".$url ) ); $googleUrl = "www.google.com/search?client=navclient-auto&ch=".$checksum."&features=Rank&q=info:".$url; $curl = new Net_CURL( $googleUrl ); $response = $curl->exec(); $position = strpos( $response, "Rank_" ); if( $position === FALSE ) throw new Exception( 'Response does not contain Rank.' ); $pagerank = substr( $response, $position + 9 ); return (int) $pagerank; }
php
public static function get( $url ) { $checksum = "6".self::calculateChecksum( self::strord( "info:".$url ) ); $googleUrl = "www.google.com/search?client=navclient-auto&ch=".$checksum."&features=Rank&q=info:".$url; $curl = new Net_CURL( $googleUrl ); $response = $curl->exec(); $position = strpos( $response, "Rank_" ); if( $position === FALSE ) throw new Exception( 'Response does not contain Rank.' ); $pagerank = substr( $response, $position + 9 ); return (int) $pagerank; }
[ "public", "static", "function", "get", "(", "$", "url", ")", "{", "$", "checksum", "=", "\"6\"", ".", "self", "::", "calculateChecksum", "(", "self", "::", "strord", "(", "\"info:\"", ".", "$", "url", ")", ")", ";", "$", "googleUrl", "=", "\"www.google.com/search?client=navclient-auto&ch=\"", ".", "$", "checksum", ".", "\"&features=Rank&q=info:\"", ".", "$", "url", ";", "$", "curl", "=", "new", "Net_CURL", "(", "$", "googleUrl", ")", ";", "$", "response", "=", "$", "curl", "->", "exec", "(", ")", ";", "$", "position", "=", "strpos", "(", "$", "response", ",", "\"Rank_\"", ")", ";", "if", "(", "$", "position", "===", "FALSE", ")", "throw", "new", "Exception", "(", "'Response does not contain Rank.'", ")", ";", "$", "pagerank", "=", "substr", "(", "$", "response", ",", "$", "position", "+", "9", ")", ";", "return", "(", "int", ")", "$", "pagerank", ";", "}" ]
Returns Google PageRank. @access public @static @param string $url URL to check (e.G. www.domain.com) @return int
[ "Returns", "Google", "PageRank", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PageRank.php#L99-L110
37,205
CeusMedia/Common
src/Net/HTTP/PageRank.php
Net_HTTP_PageRank.strord
private static function strord( $string ) { for( $i=0; $i<strlen( $string ); $i++ ) { $result[$i] = ord( $string{$i} ); } return $result; }
php
private static function strord( $string ) { for( $i=0; $i<strlen( $string ); $i++ ) { $result[$i] = ord( $string{$i} ); } return $result; }
[ "private", "static", "function", "strord", "(", "$", "string", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "string", ")", ";", "$", "i", "++", ")", "{", "$", "result", "[", "$", "i", "]", "=", "ord", "(", "$", "string", "{", "$", "i", "}", ")", ";", "}", "return", "$", "result", ";", "}" ]
Converts a String into an Array of Integers containing the numeric Values of the Characters. @access private @static @param string $string String to convert @return array
[ "Converts", "a", "String", "into", "an", "Array", "of", "Integers", "containing", "the", "numeric", "Values", "of", "the", "Characters", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PageRank.php#L133-L140
37,206
AOEpeople/Aoe_ExtendedFilter
app/code/community/Aoe/ExtendedFilter/Model/Core.php
Aoe_ExtendedFilter_Model_Core._amplifyModifiers
protected function _amplifyModifiers($value, $modifiers) { /** @var $helper Aoe_ExtendedFilter_Helper_Data */ $helper = Mage::helper('Aoe_ExtendedFilter'); foreach (explode('|', $modifiers) as $part) { if (empty($part)) { continue; } $params = explode(':', $part); $modifier = array_shift($params); $callback = $helper->getModifier($modifier); // Legacy modifiers if (!is_callable($callback) && isset($this->_modifiers[$modifier])) { $callback = $this->_modifiers[$modifier]; if (!$callback) { $callback = $modifier; } } if (is_callable($callback)) { array_unshift($params, $value); $value = call_user_func_array($callback, $params); } } return $value; }
php
protected function _amplifyModifiers($value, $modifiers) { /** @var $helper Aoe_ExtendedFilter_Helper_Data */ $helper = Mage::helper('Aoe_ExtendedFilter'); foreach (explode('|', $modifiers) as $part) { if (empty($part)) { continue; } $params = explode(':', $part); $modifier = array_shift($params); $callback = $helper->getModifier($modifier); // Legacy modifiers if (!is_callable($callback) && isset($this->_modifiers[$modifier])) { $callback = $this->_modifiers[$modifier]; if (!$callback) { $callback = $modifier; } } if (is_callable($callback)) { array_unshift($params, $value); $value = call_user_func_array($callback, $params); } } return $value; }
[ "protected", "function", "_amplifyModifiers", "(", "$", "value", ",", "$", "modifiers", ")", "{", "/** @var $helper Aoe_ExtendedFilter_Helper_Data */", "$", "helper", "=", "Mage", "::", "helper", "(", "'Aoe_ExtendedFilter'", ")", ";", "foreach", "(", "explode", "(", "'|'", ",", "$", "modifiers", ")", "as", "$", "part", ")", "{", "if", "(", "empty", "(", "$", "part", ")", ")", "{", "continue", ";", "}", "$", "params", "=", "explode", "(", "':'", ",", "$", "part", ")", ";", "$", "modifier", "=", "array_shift", "(", "$", "params", ")", ";", "$", "callback", "=", "$", "helper", "->", "getModifier", "(", "$", "modifier", ")", ";", "// Legacy modifiers", "if", "(", "!", "is_callable", "(", "$", "callback", ")", "&&", "isset", "(", "$", "this", "->", "_modifiers", "[", "$", "modifier", "]", ")", ")", "{", "$", "callback", "=", "$", "this", "->", "_modifiers", "[", "$", "modifier", "]", ";", "if", "(", "!", "$", "callback", ")", "{", "$", "callback", "=", "$", "modifier", ";", "}", "}", "if", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "array_unshift", "(", "$", "params", ",", "$", "value", ")", ";", "$", "value", "=", "call_user_func_array", "(", "$", "callback", ",", "$", "params", ")", ";", "}", "}", "return", "$", "value", ";", "}" ]
Apply modifiers one by one, with specified params Modifier syntax: modifier1[:param1:param2:...][|modifier2:...] @param string $value @param string $modifiers @return string
[ "Apply", "modifiers", "one", "by", "one", "with", "specified", "params" ]
46c95b8167472c7a1ead51d2e92336e2a58fea13
https://github.com/AOEpeople/Aoe_ExtendedFilter/blob/46c95b8167472c7a1ead51d2e92336e2a58fea13/app/code/community/Aoe/ExtendedFilter/Model/Core.php#L84-L111
37,207
CeusMedia/Common
src/Alg/Math/FormulaSum.php
Alg_Math_FormulaSum.calculate
public function calculate() { $sum = 0; $arguments = func_get_args(); for( $i=$this->interval->getStart(); $i<=$this->interval->getEnd(); $i++ ) { $params = array( $i ); foreach( $arguments as $argument ) $params[] = $argument; $value = call_user_func_array( array( &$this->formula, 'getValue' ), $params ); $sum += $value; } return $sum; }
php
public function calculate() { $sum = 0; $arguments = func_get_args(); for( $i=$this->interval->getStart(); $i<=$this->interval->getEnd(); $i++ ) { $params = array( $i ); foreach( $arguments as $argument ) $params[] = $argument; $value = call_user_func_array( array( &$this->formula, 'getValue' ), $params ); $sum += $value; } return $sum; }
[ "public", "function", "calculate", "(", ")", "{", "$", "sum", "=", "0", ";", "$", "arguments", "=", "func_get_args", "(", ")", ";", "for", "(", "$", "i", "=", "$", "this", "->", "interval", "->", "getStart", "(", ")", ";", "$", "i", "<=", "$", "this", "->", "interval", "->", "getEnd", "(", ")", ";", "$", "i", "++", ")", "{", "$", "params", "=", "array", "(", "$", "i", ")", ";", "foreach", "(", "$", "arguments", "as", "$", "argument", ")", "$", "params", "[", "]", "=", "$", "argument", ";", "$", "value", "=", "call_user_func_array", "(", "array", "(", "&", "$", "this", "->", "formula", ",", "'getValue'", ")", ",", "$", "params", ")", ";", "$", "sum", "+=", "$", "value", ";", "}", "return", "$", "sum", ";", "}" ]
Calculates Sum of given Formula within given compact Interval and Parameters. @access public @return mixed
[ "Calculates", "Sum", "of", "given", "Formula", "within", "given", "compact", "Interval", "and", "Parameters", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/FormulaSum.php#L77-L90
37,208
CeusMedia/Common
src/DB/PDO/TableWriter.php
DB_PDO_TableWriter.delete
public function delete(){ $this->validateFocus(); $conditions = $this->getConditionQuery( array() ); $query = 'DELETE FROM '.$this->getTableName().' WHERE '.$conditions; # $has = $this->get( FALSE ); # if( !$has ) # throw new \InvalidArgumentException( 'Focused Indices are not existing.' ); return $this->dbc->exec( $query ); }
php
public function delete(){ $this->validateFocus(); $conditions = $this->getConditionQuery( array() ); $query = 'DELETE FROM '.$this->getTableName().' WHERE '.$conditions; # $has = $this->get( FALSE ); # if( !$has ) # throw new \InvalidArgumentException( 'Focused Indices are not existing.' ); return $this->dbc->exec( $query ); }
[ "public", "function", "delete", "(", ")", "{", "$", "this", "->", "validateFocus", "(", ")", ";", "$", "conditions", "=", "$", "this", "->", "getConditionQuery", "(", "array", "(", ")", ")", ";", "$", "query", "=", "'DELETE FROM '", ".", "$", "this", "->", "getTableName", "(", ")", ".", "' WHERE '", ".", "$", "conditions", ";", "#\t\t$has\t= $this->get( FALSE );", "#\t\tif( !$has )", "#\t\t\tthrow new \\InvalidArgumentException( 'Focused Indices are not existing.' );", "return", "$", "this", "->", "dbc", "->", "exec", "(", "$", "query", ")", ";", "}" ]
Deletes focused Rows in this Table and returns number of affected Rows. @access public @return int
[ "Deletes", "focused", "Rows", "in", "this", "Table", "and", "returns", "number", "of", "affected", "Rows", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableWriter.php#L46-L54
37,209
CeusMedia/Common
src/DB/PDO/TableWriter.php
DB_PDO_TableWriter.deleteByConditions
public function deleteByConditions( $where = array() ){ $conditions = $this->getConditionQuery( $where, FALSE, FALSE, FALSE ); // render WHERE conditions, uncursored, without functions $query = 'DELETE FROM '.$this->getTableName().' WHERE '.$conditions; $result = $this->dbc->exec( $query ); $this->defocus(); return $result; }
php
public function deleteByConditions( $where = array() ){ $conditions = $this->getConditionQuery( $where, FALSE, FALSE, FALSE ); // render WHERE conditions, uncursored, without functions $query = 'DELETE FROM '.$this->getTableName().' WHERE '.$conditions; $result = $this->dbc->exec( $query ); $this->defocus(); return $result; }
[ "public", "function", "deleteByConditions", "(", "$", "where", "=", "array", "(", ")", ")", "{", "$", "conditions", "=", "$", "this", "->", "getConditionQuery", "(", "$", "where", ",", "FALSE", ",", "FALSE", ",", "FALSE", ")", ";", "// render WHERE conditions, uncursored, without functions", "$", "query", "=", "'DELETE FROM '", ".", "$", "this", "->", "getTableName", "(", ")", ".", "' WHERE '", ".", "$", "conditions", ";", "$", "result", "=", "$", "this", "->", "dbc", "->", "exec", "(", "$", "query", ")", ";", "$", "this", "->", "defocus", "(", ")", ";", "return", "$", "result", ";", "}" ]
Deletes data by given conditions. @access public @param array $where associative Array of Condition Strings @return bool
[ "Deletes", "data", "by", "given", "conditions", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableWriter.php#L62-L68
37,210
CeusMedia/Common
src/DB/PDO/TableWriter.php
DB_PDO_TableWriter.insert
public function insert( $data = array(), $stripTags = TRUE ){ $columns = array(); $values = array(); foreach( $this->columns as $column ){ // iterate Columns if( !isset( $data[$column] ) ) // no Data given for Column continue; $value = $data[$column]; if( $stripTags ) $value = strip_tags( $value ); $columns[$column] = $column; $values[$column] = $this->secureValue( $value ); } if( $this->isFocused() ){ // add focused indices to data foreach( $this->focusedIndices as $index => $value ){ // iterate focused indices if( isset( $columns[$index] ) ) // Column is already set continue; if( $index == $this->primaryKey ) // skip primary key continue; $columns[$index] = $index; // add key $values[$index] = $this->secureValue( $value ); // add value } } $columns = $this->getColumnEnumeration( $columns ); // get enumeration of masked column names $values = implode( ', ', array_values( $values ) ); $query = 'INSERT INTO '.$this->getTableName().' ('.$columns.') VALUES ('.$values.')'; $this->dbc->exec( $query ); return $this->dbc->lastInsertId(); }
php
public function insert( $data = array(), $stripTags = TRUE ){ $columns = array(); $values = array(); foreach( $this->columns as $column ){ // iterate Columns if( !isset( $data[$column] ) ) // no Data given for Column continue; $value = $data[$column]; if( $stripTags ) $value = strip_tags( $value ); $columns[$column] = $column; $values[$column] = $this->secureValue( $value ); } if( $this->isFocused() ){ // add focused indices to data foreach( $this->focusedIndices as $index => $value ){ // iterate focused indices if( isset( $columns[$index] ) ) // Column is already set continue; if( $index == $this->primaryKey ) // skip primary key continue; $columns[$index] = $index; // add key $values[$index] = $this->secureValue( $value ); // add value } } $columns = $this->getColumnEnumeration( $columns ); // get enumeration of masked column names $values = implode( ', ', array_values( $values ) ); $query = 'INSERT INTO '.$this->getTableName().' ('.$columns.') VALUES ('.$values.')'; $this->dbc->exec( $query ); return $this->dbc->lastInsertId(); }
[ "public", "function", "insert", "(", "$", "data", "=", "array", "(", ")", ",", "$", "stripTags", "=", "TRUE", ")", "{", "$", "columns", "=", "array", "(", ")", ";", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "columns", "as", "$", "column", ")", "{", "// iterate Columns", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "column", "]", ")", ")", "// no Data given for Column", "continue", ";", "$", "value", "=", "$", "data", "[", "$", "column", "]", ";", "if", "(", "$", "stripTags", ")", "$", "value", "=", "strip_tags", "(", "$", "value", ")", ";", "$", "columns", "[", "$", "column", "]", "=", "$", "column", ";", "$", "values", "[", "$", "column", "]", "=", "$", "this", "->", "secureValue", "(", "$", "value", ")", ";", "}", "if", "(", "$", "this", "->", "isFocused", "(", ")", ")", "{", "// add focused indices to data", "foreach", "(", "$", "this", "->", "focusedIndices", "as", "$", "index", "=>", "$", "value", ")", "{", "// iterate focused indices", "if", "(", "isset", "(", "$", "columns", "[", "$", "index", "]", ")", ")", "// Column is already set", "continue", ";", "if", "(", "$", "index", "==", "$", "this", "->", "primaryKey", ")", "// skip primary key", "continue", ";", "$", "columns", "[", "$", "index", "]", "=", "$", "index", ";", "// add key", "$", "values", "[", "$", "index", "]", "=", "$", "this", "->", "secureValue", "(", "$", "value", ")", ";", "// add value", "}", "}", "$", "columns", "=", "$", "this", "->", "getColumnEnumeration", "(", "$", "columns", ")", ";", "// get enumeration of masked column names", "$", "values", "=", "implode", "(", "', '", ",", "array_values", "(", "$", "values", ")", ")", ";", "$", "query", "=", "'INSERT INTO '", ".", "$", "this", "->", "getTableName", "(", ")", ".", "' ('", ".", "$", "columns", ".", "') VALUES ('", ".", "$", "values", ".", "')'", ";", "$", "this", "->", "dbc", "->", "exec", "(", "$", "query", ")", ";", "return", "$", "this", "->", "dbc", "->", "lastInsertId", "(", ")", ";", "}" ]
Inserts data into this table and returns ID. @access public @param array $data associative array of data to store @param bool $stripTags Flag: strip HTML Tags from values @return int ID of inserted row
[ "Inserts", "data", "into", "this", "table", "and", "returns", "ID", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableWriter.php#L77-L104
37,211
CeusMedia/Common
src/DB/PDO/TableWriter.php
DB_PDO_TableWriter.updateByConditions
public function updateByConditions( $data = array(), $conditions = array(), $stripTags = FALSE ){ if( !( is_array( $data ) && $data ) ) throw new \InvalidArgumentException( 'Data for update must be an array and have atleast 1 pair' ); if( !( is_array( $conditions ) && $conditions ) ) throw new \InvalidArgumentException( 'Conditions for update must be an array and have atleast 1 pair' ); $updates = array(); $conditions = $this->getConditionQuery( $conditions, FALSE, FALSE, FALSE ); // render WHERE conditions, uncursored, without functions foreach( $this->columns as $column ){ if( isset( $data[$column] ) ){ if( $stripTags ) $data[$column] = strip_tags( $data[$column] ); if( $data[$column] == 'on' ) $data[$column] = 1; $data[$column] = $this->secureValue( $data[$column] ); $updates[] = '`'.$column.'`='.$data[$column]; } } if( sizeof( $updates ) ){ $updates = implode( ', ', $updates ); $query = 'UPDATE '.$this->getTableName().' SET '.$updates.' WHERE '.$conditions; $result = $this->dbc->exec( $query ); return $result; } }
php
public function updateByConditions( $data = array(), $conditions = array(), $stripTags = FALSE ){ if( !( is_array( $data ) && $data ) ) throw new \InvalidArgumentException( 'Data for update must be an array and have atleast 1 pair' ); if( !( is_array( $conditions ) && $conditions ) ) throw new \InvalidArgumentException( 'Conditions for update must be an array and have atleast 1 pair' ); $updates = array(); $conditions = $this->getConditionQuery( $conditions, FALSE, FALSE, FALSE ); // render WHERE conditions, uncursored, without functions foreach( $this->columns as $column ){ if( isset( $data[$column] ) ){ if( $stripTags ) $data[$column] = strip_tags( $data[$column] ); if( $data[$column] == 'on' ) $data[$column] = 1; $data[$column] = $this->secureValue( $data[$column] ); $updates[] = '`'.$column.'`='.$data[$column]; } } if( sizeof( $updates ) ){ $updates = implode( ', ', $updates ); $query = 'UPDATE '.$this->getTableName().' SET '.$updates.' WHERE '.$conditions; $result = $this->dbc->exec( $query ); return $result; } }
[ "public", "function", "updateByConditions", "(", "$", "data", "=", "array", "(", ")", ",", "$", "conditions", "=", "array", "(", ")", ",", "$", "stripTags", "=", "FALSE", ")", "{", "if", "(", "!", "(", "is_array", "(", "$", "data", ")", "&&", "$", "data", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Data for update must be an array and have atleast 1 pair'", ")", ";", "if", "(", "!", "(", "is_array", "(", "$", "conditions", ")", "&&", "$", "conditions", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Conditions for update must be an array and have atleast 1 pair'", ")", ";", "$", "updates", "=", "array", "(", ")", ";", "$", "conditions", "=", "$", "this", "->", "getConditionQuery", "(", "$", "conditions", ",", "FALSE", ",", "FALSE", ",", "FALSE", ")", ";", "// render WHERE conditions, uncursored, without functions", "foreach", "(", "$", "this", "->", "columns", "as", "$", "column", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "$", "column", "]", ")", ")", "{", "if", "(", "$", "stripTags", ")", "$", "data", "[", "$", "column", "]", "=", "strip_tags", "(", "$", "data", "[", "$", "column", "]", ")", ";", "if", "(", "$", "data", "[", "$", "column", "]", "==", "'on'", ")", "$", "data", "[", "$", "column", "]", "=", "1", ";", "$", "data", "[", "$", "column", "]", "=", "$", "this", "->", "secureValue", "(", "$", "data", "[", "$", "column", "]", ")", ";", "$", "updates", "[", "]", "=", "'`'", ".", "$", "column", ".", "'`='", ".", "$", "data", "[", "$", "column", "]", ";", "}", "}", "if", "(", "sizeof", "(", "$", "updates", ")", ")", "{", "$", "updates", "=", "implode", "(", "', '", ",", "$", "updates", ")", ";", "$", "query", "=", "'UPDATE '", ".", "$", "this", "->", "getTableName", "(", ")", ".", "' SET '", ".", "$", "updates", ".", "' WHERE '", ".", "$", "conditions", ";", "$", "result", "=", "$", "this", "->", "dbc", "->", "exec", "(", "$", "query", ")", ";", "return", "$", "result", ";", "}", "}" ]
Updates data in table where conditions are given for. @access public @param array $data Array of data to store @param array $conditions Array of condition pairs @param bool $stripTags Flag: strip HTML tags from values @return bool
[ "Updates", "data", "in", "table", "where", "conditions", "are", "given", "for", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableWriter.php#L146-L170
37,212
CeusMedia/Common
src/UI/HTML/Tree/VariableDump.php
UI_HTML_Tree_VariableDump.buildTree
public static function buildTree( $mixed, $key = NULL, $closed = FALSE, $level = 0 ) { if( $level === 0 ) self::$count = 0; $type = gettype( $mixed ); $children = array(); $keyLabel = ( $key !== NULL ) ? htmlentities( $key, ENT_QUOTES, 'UTF-8' )." -> " : ""; $event = NULL; self::$count++; switch( $type ) { case 'array': self::$count--; foreach( $mixed as $childKey => $childValue ) $children[] = self::buildTree( $childValue, $childKey, $closed, $level + 1 ); if( $key === NULL ) $keyLabel = self::$noteOpen."Array".self::$noteClose; $mixed = ""; $event = '$(this).parent().toggleClass(\'closed\'); return false;'; break; case 'object': self::$count--; $vars = get_object_vars( $mixed ); foreach( $vars as $childKey => $childValue ) $children[] = self::buildTree( $childValue, $childKey, $closed, $level + 1 ); $keyLabel = self::$noteOpen.get_class( $mixed ).self::$noteClose; $mixed = ""; $event = '$(this).parent().toggleClass(\'closed\'); return false;'; break; case 'bool': $mixed = self::$noteOpen.( $mixed ? "TRUE" : "FALSE" ).self::$noteClose; break; case 'NULL': if( $mixed === NULL ) $mixed = self::$noteOpen."NULL".self::$noteClose; break; case 'unknown type': throw new RuntimeException( 'Unknown type' ); default: if( preg_match( "/pass(w(or)?d)?/", $key ) ) $mixed = str_repeat( '*', 8 ); break; } $children = $children ? "\n".UI_HTML_Elements::unorderedList( $children, $level + 2 ) : ""; $pair = $keyLabel.htmlentities( $mixed, ENT_QUOTES, 'UTF-8' ); $label = UI_HTML_Tag::create( 'span', $pair, array( 'onclick' => $event ) ); $classes = array( $type ); if( $closed ) $classes[] = "closed"; return UI_HTML_Elements::ListItem( $label.$children, $level + 1, array( 'class' => implode( " ", $classes ) ) ); }
php
public static function buildTree( $mixed, $key = NULL, $closed = FALSE, $level = 0 ) { if( $level === 0 ) self::$count = 0; $type = gettype( $mixed ); $children = array(); $keyLabel = ( $key !== NULL ) ? htmlentities( $key, ENT_QUOTES, 'UTF-8' )." -> " : ""; $event = NULL; self::$count++; switch( $type ) { case 'array': self::$count--; foreach( $mixed as $childKey => $childValue ) $children[] = self::buildTree( $childValue, $childKey, $closed, $level + 1 ); if( $key === NULL ) $keyLabel = self::$noteOpen."Array".self::$noteClose; $mixed = ""; $event = '$(this).parent().toggleClass(\'closed\'); return false;'; break; case 'object': self::$count--; $vars = get_object_vars( $mixed ); foreach( $vars as $childKey => $childValue ) $children[] = self::buildTree( $childValue, $childKey, $closed, $level + 1 ); $keyLabel = self::$noteOpen.get_class( $mixed ).self::$noteClose; $mixed = ""; $event = '$(this).parent().toggleClass(\'closed\'); return false;'; break; case 'bool': $mixed = self::$noteOpen.( $mixed ? "TRUE" : "FALSE" ).self::$noteClose; break; case 'NULL': if( $mixed === NULL ) $mixed = self::$noteOpen."NULL".self::$noteClose; break; case 'unknown type': throw new RuntimeException( 'Unknown type' ); default: if( preg_match( "/pass(w(or)?d)?/", $key ) ) $mixed = str_repeat( '*', 8 ); break; } $children = $children ? "\n".UI_HTML_Elements::unorderedList( $children, $level + 2 ) : ""; $pair = $keyLabel.htmlentities( $mixed, ENT_QUOTES, 'UTF-8' ); $label = UI_HTML_Tag::create( 'span', $pair, array( 'onclick' => $event ) ); $classes = array( $type ); if( $closed ) $classes[] = "closed"; return UI_HTML_Elements::ListItem( $label.$children, $level + 1, array( 'class' => implode( " ", $classes ) ) ); }
[ "public", "static", "function", "buildTree", "(", "$", "mixed", ",", "$", "key", "=", "NULL", ",", "$", "closed", "=", "FALSE", ",", "$", "level", "=", "0", ")", "{", "if", "(", "$", "level", "===", "0", ")", "self", "::", "$", "count", "=", "0", ";", "$", "type", "=", "gettype", "(", "$", "mixed", ")", ";", "$", "children", "=", "array", "(", ")", ";", "$", "keyLabel", "=", "(", "$", "key", "!==", "NULL", ")", "?", "htmlentities", "(", "$", "key", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ".", "\" -> \"", ":", "\"\"", ";", "$", "event", "=", "NULL", ";", "self", "::", "$", "count", "++", ";", "switch", "(", "$", "type", ")", "{", "case", "'array'", ":", "self", "::", "$", "count", "--", ";", "foreach", "(", "$", "mixed", "as", "$", "childKey", "=>", "$", "childValue", ")", "$", "children", "[", "]", "=", "self", "::", "buildTree", "(", "$", "childValue", ",", "$", "childKey", ",", "$", "closed", ",", "$", "level", "+", "1", ")", ";", "if", "(", "$", "key", "===", "NULL", ")", "$", "keyLabel", "=", "self", "::", "$", "noteOpen", ".", "\"Array\"", ".", "self", "::", "$", "noteClose", ";", "$", "mixed", "=", "\"\"", ";", "$", "event", "=", "'$(this).parent().toggleClass(\\'closed\\'); return false;'", ";", "break", ";", "case", "'object'", ":", "self", "::", "$", "count", "--", ";", "$", "vars", "=", "get_object_vars", "(", "$", "mixed", ")", ";", "foreach", "(", "$", "vars", "as", "$", "childKey", "=>", "$", "childValue", ")", "$", "children", "[", "]", "=", "self", "::", "buildTree", "(", "$", "childValue", ",", "$", "childKey", ",", "$", "closed", ",", "$", "level", "+", "1", ")", ";", "$", "keyLabel", "=", "self", "::", "$", "noteOpen", ".", "get_class", "(", "$", "mixed", ")", ".", "self", "::", "$", "noteClose", ";", "$", "mixed", "=", "\"\"", ";", "$", "event", "=", "'$(this).parent().toggleClass(\\'closed\\'); return false;'", ";", "break", ";", "case", "'bool'", ":", "$", "mixed", "=", "self", "::", "$", "noteOpen", ".", "(", "$", "mixed", "?", "\"TRUE\"", ":", "\"FALSE\"", ")", ".", "self", "::", "$", "noteClose", ";", "break", ";", "case", "'NULL'", ":", "if", "(", "$", "mixed", "===", "NULL", ")", "$", "mixed", "=", "self", "::", "$", "noteOpen", ".", "\"NULL\"", ".", "self", "::", "$", "noteClose", ";", "break", ";", "case", "'unknown type'", ":", "throw", "new", "RuntimeException", "(", "'Unknown type'", ")", ";", "default", ":", "if", "(", "preg_match", "(", "\"/pass(w(or)?d)?/\"", ",", "$", "key", ")", ")", "$", "mixed", "=", "str_repeat", "(", "'*'", ",", "8", ")", ";", "break", ";", "}", "$", "children", "=", "$", "children", "?", "\"\\n\"", ".", "UI_HTML_Elements", "::", "unorderedList", "(", "$", "children", ",", "$", "level", "+", "2", ")", ":", "\"\"", ";", "$", "pair", "=", "$", "keyLabel", ".", "htmlentities", "(", "$", "mixed", ",", "ENT_QUOTES", ",", "'UTF-8'", ")", ";", "$", "label", "=", "UI_HTML_Tag", "::", "create", "(", "'span'", ",", "$", "pair", ",", "array", "(", "'onclick'", "=>", "$", "event", ")", ")", ";", "$", "classes", "=", "array", "(", "$", "type", ")", ";", "if", "(", "$", "closed", ")", "$", "classes", "[", "]", "=", "\"closed\"", ";", "return", "UI_HTML_Elements", "::", "ListItem", "(", "$", "label", ".", "$", "children", ",", "$", "level", "+", "1", ",", "array", "(", "'class'", "=>", "implode", "(", "\" \"", ",", "$", "classes", ")", ")", ")", ";", "}" ]
Builds and returns a Tree Display of a Variable, recursively. @access public @static @param mixed $mixed Variable of every Type to build Tree for @param string $key Variable Name @param string $closed Flag: start with closed Nodes @param int $level Depth Level @return void
[ "Builds", "and", "returns", "a", "Tree", "Display", "of", "a", "Variable", "recursively", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tree/VariableDump.php#L57-L107
37,213
CeusMedia/Common
src/UI/Template.php
UI_Template.add
public function add( $elements, $overwrite = FALSE ) { if( !is_array( $elements ) ) return 0; $number = 0; foreach( $elements as $key => $value ) { if( !( is_string( $key ) || is_int( $key ) || is_float( $key ) ) ) throw new InvalidArgumentException( 'Invalid key type "'.gettype( $key ).'"' ); if( !strlen( trim( $key ) ) ) throw new InvalidArgumentException( 'Key cannot be empty' ); $isListObject = $value instanceof ArrayObject || $value instanceof ADT_List_Dictionary; $isPrimitive = is_string( $value ) || is_int( $value ) || is_float( $value ) || is_bool( $value ); $isTemplate = $value instanceof $this->className; if( is_null( $value ) ) continue; else if( is_array( $value ) || $isListObject ) $number += $this->addArrayRecursive( $key, $value, array(), $overwrite ); else if( $isPrimitive || $isTemplate ) { // if( $overwrite == TRUE ) // $this->elements[$key] = array(); // $this->elements[$key][] = $value; $this->elements[$key] = $value; $number ++; } else if( is_object( $value ) ) $this->addObject( $key, $value, array(), $overwrite ); else throw new InvalidArgumentException( 'Unsupported type '.gettype( $value ).' for "'.$key.'"' ); } return $number; }
php
public function add( $elements, $overwrite = FALSE ) { if( !is_array( $elements ) ) return 0; $number = 0; foreach( $elements as $key => $value ) { if( !( is_string( $key ) || is_int( $key ) || is_float( $key ) ) ) throw new InvalidArgumentException( 'Invalid key type "'.gettype( $key ).'"' ); if( !strlen( trim( $key ) ) ) throw new InvalidArgumentException( 'Key cannot be empty' ); $isListObject = $value instanceof ArrayObject || $value instanceof ADT_List_Dictionary; $isPrimitive = is_string( $value ) || is_int( $value ) || is_float( $value ) || is_bool( $value ); $isTemplate = $value instanceof $this->className; if( is_null( $value ) ) continue; else if( is_array( $value ) || $isListObject ) $number += $this->addArrayRecursive( $key, $value, array(), $overwrite ); else if( $isPrimitive || $isTemplate ) { // if( $overwrite == TRUE ) // $this->elements[$key] = array(); // $this->elements[$key][] = $value; $this->elements[$key] = $value; $number ++; } else if( is_object( $value ) ) $this->addObject( $key, $value, array(), $overwrite ); else throw new InvalidArgumentException( 'Unsupported type '.gettype( $value ).' for "'.$key.'"' ); } return $number; }
[ "public", "function", "add", "(", "$", "elements", ",", "$", "overwrite", "=", "FALSE", ")", "{", "if", "(", "!", "is_array", "(", "$", "elements", ")", ")", "return", "0", ";", "$", "number", "=", "0", ";", "foreach", "(", "$", "elements", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "(", "is_string", "(", "$", "key", ")", "||", "is_int", "(", "$", "key", ")", "||", "is_float", "(", "$", "key", ")", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Invalid key type \"'", ".", "gettype", "(", "$", "key", ")", ".", "'\"'", ")", ";", "if", "(", "!", "strlen", "(", "trim", "(", "$", "key", ")", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Key cannot be empty'", ")", ";", "$", "isListObject", "=", "$", "value", "instanceof", "ArrayObject", "||", "$", "value", "instanceof", "ADT_List_Dictionary", ";", "$", "isPrimitive", "=", "is_string", "(", "$", "value", ")", "||", "is_int", "(", "$", "value", ")", "||", "is_float", "(", "$", "value", ")", "||", "is_bool", "(", "$", "value", ")", ";", "$", "isTemplate", "=", "$", "value", "instanceof", "$", "this", "->", "className", ";", "if", "(", "is_null", "(", "$", "value", ")", ")", "continue", ";", "else", "if", "(", "is_array", "(", "$", "value", ")", "||", "$", "isListObject", ")", "$", "number", "+=", "$", "this", "->", "addArrayRecursive", "(", "$", "key", ",", "$", "value", ",", "array", "(", ")", ",", "$", "overwrite", ")", ";", "else", "if", "(", "$", "isPrimitive", "||", "$", "isTemplate", ")", "{", "//\t\t\t\tif( $overwrite == TRUE )", "//\t\t\t\t\t$this->elements[$key] = array();", "//\t\t\t\t$this->elements[$key][] = $value;", "$", "this", "->", "elements", "[", "$", "key", "]", "=", "$", "value", ";", "$", "number", "++", ";", "}", "else", "if", "(", "is_object", "(", "$", "value", ")", ")", "$", "this", "->", "addObject", "(", "$", "key", ",", "$", "value", ",", "array", "(", ")", ",", "$", "overwrite", ")", ";", "else", "throw", "new", "InvalidArgumentException", "(", "'Unsupported type '", ".", "gettype", "(", "$", "value", ")", ".", "' for \"'", ".", "$", "key", ".", "'\"'", ")", ";", "}", "return", "$", "number", ";", "}" ]
Adds an associative array with labels and elements to the template and returns number of added elements. @param array Array where the <b>key</b> can be a string, integer or float and is the <b>label</b>. The <b>value</b> can be a string, integer, float or a template object and represents the element to add. @param boolean if TRUE an a tag is already used, it will overwrite it @return integer
[ "Adds", "an", "associative", "array", "with", "labels", "and", "elements", "to", "the", "template", "and", "returns", "number", "of", "added", "elements", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L109-L142
37,214
CeusMedia/Common
src/UI/Template.php
UI_Template.addArrayRecursive
public function addArrayRecursive( $name, $data, $steps = array(), $overwrite = FALSE ) { $number = 0; $steps[] = $name; foreach( $data as $key => $value ) { $isListObject = $value instanceof ArrayObject || $value instanceof ADT_List_Dictionary; if( is_array( $value ) || $isListObject ) { $number += $this->addArrayRecursive( $key, $value, $steps ); } else { $key = implode( ".", $steps ).".".$key; $this->addElement( $key, $value ); $number ++; } } return $number; }
php
public function addArrayRecursive( $name, $data, $steps = array(), $overwrite = FALSE ) { $number = 0; $steps[] = $name; foreach( $data as $key => $value ) { $isListObject = $value instanceof ArrayObject || $value instanceof ADT_List_Dictionary; if( is_array( $value ) || $isListObject ) { $number += $this->addArrayRecursive( $key, $value, $steps ); } else { $key = implode( ".", $steps ).".".$key; $this->addElement( $key, $value ); $number ++; } } return $number; }
[ "public", "function", "addArrayRecursive", "(", "$", "name", ",", "$", "data", ",", "$", "steps", "=", "array", "(", ")", ",", "$", "overwrite", "=", "FALSE", ")", "{", "$", "number", "=", "0", ";", "$", "steps", "[", "]", "=", "$", "name", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "isListObject", "=", "$", "value", "instanceof", "ArrayObject", "||", "$", "value", "instanceof", "ADT_List_Dictionary", ";", "if", "(", "is_array", "(", "$", "value", ")", "||", "$", "isListObject", ")", "{", "$", "number", "+=", "$", "this", "->", "addArrayRecursive", "(", "$", "key", ",", "$", "value", ",", "$", "steps", ")", ";", "}", "else", "{", "$", "key", "=", "implode", "(", "\".\"", ",", "$", "steps", ")", ".", "\".\"", ".", "$", "key", ";", "$", "this", "->", "addElement", "(", "$", "key", ",", "$", "value", ")", ";", "$", "number", "++", ";", "}", "}", "return", "$", "number", ";", "}" ]
Adds an array recursive and returns number of added elements. @access public @param string $name Key of array @param mixed $data Values of array @param array $steps Steps within recursion @param bool $overwrite Flag: overwrite existing tag @return int
[ "Adds", "an", "array", "recursive", "and", "returns", "number", "of", "added", "elements", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L153-L172
37,215
CeusMedia/Common
src/UI/Template.php
UI_Template.addElement
public function addElement( $tag, $element, $overwrite = FALSE ) { $this->add( array( $tag => $element ), $overwrite ); }
php
public function addElement( $tag, $element, $overwrite = FALSE ) { $this->add( array( $tag => $element ), $overwrite ); }
[ "public", "function", "addElement", "(", "$", "tag", ",", "$", "element", ",", "$", "overwrite", "=", "FALSE", ")", "{", "$", "this", "->", "add", "(", "array", "(", "$", "tag", "=>", "$", "element", ")", ",", "$", "overwrite", ")", ";", "}" ]
Adds one Element. @param string $tag Tag name @param string|integer|float|UI_Template @param boolean if set to TRUE, it will overwrite an existing element with the same label @return void
[ "Adds", "one", "Element", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L181-L184
37,216
CeusMedia/Common
src/UI/Template.php
UI_Template.addTemplate
public function addTemplate( $tag, $fileName, $element = NULL, $overwrite = FALSE ) { $this->addElement( $tag, new self( $fileName, $element ), $overwrite ); }
php
public function addTemplate( $tag, $fileName, $element = NULL, $overwrite = FALSE ) { $this->addElement( $tag, new self( $fileName, $element ), $overwrite ); }
[ "public", "function", "addTemplate", "(", "$", "tag", ",", "$", "fileName", ",", "$", "element", "=", "NULL", ",", "$", "overwrite", "=", "FALSE", ")", "{", "$", "this", "->", "addElement", "(", "$", "tag", ",", "new", "self", "(", "$", "fileName", ",", "$", "element", ")", ",", "$", "overwrite", ")", ";", "}" ]
Adds another Template. @param string tagname @param string template file @param array array containing elements {@link add()} @param boolean if set to TRUE, it will overwrite an existing element with the same label @return void
[ "Adds", "another", "Template", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L216-L219
37,217
CeusMedia/Common
src/UI/Template.php
UI_Template.create
public function create() { $out = $this->template; // local copy of set template $out = $this->loadNestedTemplates( $out ); // search for nested templates and load them foreach( $this->plugins as $plugin ) if( $plugin->type == 'pre' ) $out = $plugin->work( $out ); $out = preg_replace( '/<%--.*--%>/sU', '', $out ); // remove template engine style comments if( self::$removeComments ) // HTML comments should be removed $out = preg_replace( '/<!--.+-->/sU', '', $out ); // find and remove all HTML comments if( self::$removeOptional ) // optional parts should be removed $out = preg_replace( '/<%\?--.+--%>/sU', '', $out ); // find and remove optional parts else // otherwise $out = preg_replace( '/<%\?--(.+)--%>/sU', '\\1', $out ); // find, remove markup but keep content foreach( $this->elements as $label => $element ) // iterate over all registered element containers { $tmp = ''; // if( is_object( $element ) ) // element is an object { if( !( $element instanceof $this->className ) ) // object is not an template of this template engine continue; // skip this one $element = $element->create(); // render template before concat } $tmp .= $element; $out = preg_replace( '/<%(\?)?' . preg_quote( $label, '/' ) . '%>/', $tmp, $out ); // find placeholder and set in content } $out = preg_replace( '/<%\?.*%>/U', '', $out ); // remove left over optional placeholders # $out = preg_replace( '/\n\s+\n/', "\n", $out ); // remove double line breaks foreach( $this->plugins as $plugin ) if( $plugin->type == 'post' ) $out = $plugin->work( $out ); $tags = array(); // create container for left over placeholders if( preg_match_all( '/<%.*%>/U', $out, $tags ) === 0 ) // no more placeholders left over return $out; // return final result $tags = array_shift( $tags ); // foreach( $tags as $key => $value ) $tags[$key] = preg_replace( '@(<%\??)|%>@', "", $value ); if( $this->fileName ) throw new Exception_Template( Exception_Template::FILE_LABELS_MISSING, $this->fileName, $tags ); throw new Exception_Template( Exception_Template::LABELS_MISSING, NULL, $tags ); }
php
public function create() { $out = $this->template; // local copy of set template $out = $this->loadNestedTemplates( $out ); // search for nested templates and load them foreach( $this->plugins as $plugin ) if( $plugin->type == 'pre' ) $out = $plugin->work( $out ); $out = preg_replace( '/<%--.*--%>/sU', '', $out ); // remove template engine style comments if( self::$removeComments ) // HTML comments should be removed $out = preg_replace( '/<!--.+-->/sU', '', $out ); // find and remove all HTML comments if( self::$removeOptional ) // optional parts should be removed $out = preg_replace( '/<%\?--.+--%>/sU', '', $out ); // find and remove optional parts else // otherwise $out = preg_replace( '/<%\?--(.+)--%>/sU', '\\1', $out ); // find, remove markup but keep content foreach( $this->elements as $label => $element ) // iterate over all registered element containers { $tmp = ''; // if( is_object( $element ) ) // element is an object { if( !( $element instanceof $this->className ) ) // object is not an template of this template engine continue; // skip this one $element = $element->create(); // render template before concat } $tmp .= $element; $out = preg_replace( '/<%(\?)?' . preg_quote( $label, '/' ) . '%>/', $tmp, $out ); // find placeholder and set in content } $out = preg_replace( '/<%\?.*%>/U', '', $out ); // remove left over optional placeholders # $out = preg_replace( '/\n\s+\n/', "\n", $out ); // remove double line breaks foreach( $this->plugins as $plugin ) if( $plugin->type == 'post' ) $out = $plugin->work( $out ); $tags = array(); // create container for left over placeholders if( preg_match_all( '/<%.*%>/U', $out, $tags ) === 0 ) // no more placeholders left over return $out; // return final result $tags = array_shift( $tags ); // foreach( $tags as $key => $value ) $tags[$key] = preg_replace( '@(<%\??)|%>@', "", $value ); if( $this->fileName ) throw new Exception_Template( Exception_Template::FILE_LABELS_MISSING, $this->fileName, $tags ); throw new Exception_Template( Exception_Template::LABELS_MISSING, NULL, $tags ); }
[ "public", "function", "create", "(", ")", "{", "$", "out", "=", "$", "this", "->", "template", ";", "// local copy of set template", "$", "out", "=", "$", "this", "->", "loadNestedTemplates", "(", "$", "out", ")", ";", "// search for nested templates and load them", "foreach", "(", "$", "this", "->", "plugins", "as", "$", "plugin", ")", "if", "(", "$", "plugin", "->", "type", "==", "'pre'", ")", "$", "out", "=", "$", "plugin", "->", "work", "(", "$", "out", ")", ";", "$", "out", "=", "preg_replace", "(", "'/<%--.*--%>/sU'", ",", "''", ",", "$", "out", ")", ";", "// remove template engine style comments", "if", "(", "self", "::", "$", "removeComments", ")", "// HTML comments should be removed", "$", "out", "=", "preg_replace", "(", "'/<!--.+-->/sU'", ",", "''", ",", "$", "out", ")", ";", "// find and remove all HTML comments ", "if", "(", "self", "::", "$", "removeOptional", ")", "// optional parts should be removed", "$", "out", "=", "preg_replace", "(", "'/<%\\?--.+--%>/sU'", ",", "''", ",", "$", "out", ")", ";", "// find and remove optional parts", "else", "// otherwise", "$", "out", "=", "preg_replace", "(", "'/<%\\?--(.+)--%>/sU'", ",", "'\\\\1'", ",", "$", "out", ")", ";", "// find, remove markup but keep content", "foreach", "(", "$", "this", "->", "elements", "as", "$", "label", "=>", "$", "element", ")", "// iterate over all registered element containers", "{", "$", "tmp", "=", "''", ";", "// ", "if", "(", "is_object", "(", "$", "element", ")", ")", "// element is an object", "{", "if", "(", "!", "(", "$", "element", "instanceof", "$", "this", "->", "className", ")", ")", "// object is not an template of this template engine", "continue", ";", "// skip this one", "$", "element", "=", "$", "element", "->", "create", "(", ")", ";", "// render template before concat", "}", "$", "tmp", ".=", "$", "element", ";", "$", "out", "=", "preg_replace", "(", "'/<%(\\?)?'", ".", "preg_quote", "(", "$", "label", ",", "'/'", ")", ".", "'%>/'", ",", "$", "tmp", ",", "$", "out", ")", ";", "// find placeholder and set in content", "}", "$", "out", "=", "preg_replace", "(", "'/<%\\?.*%>/U'", ",", "''", ",", "$", "out", ")", ";", "// remove left over optional placeholders", "# $out = preg_replace( '/\\n\\s+\\n/', \"\\n\", $out );\t\t\t\t\t\t\t\t\t\t\t\t// remove double line breaks", "foreach", "(", "$", "this", "->", "plugins", "as", "$", "plugin", ")", "if", "(", "$", "plugin", "->", "type", "==", "'post'", ")", "$", "out", "=", "$", "plugin", "->", "work", "(", "$", "out", ")", ";", "$", "tags", "=", "array", "(", ")", ";", "// create container for left over placeholders", "if", "(", "preg_match_all", "(", "'/<%.*%>/U'", ",", "$", "out", ",", "$", "tags", ")", "===", "0", ")", "// no more placeholders left over", "return", "$", "out", ";", "// return final result", "$", "tags", "=", "array_shift", "(", "$", "tags", ")", ";", "// ", "foreach", "(", "$", "tags", "as", "$", "key", "=>", "$", "value", ")", "$", "tags", "[", "$", "key", "]", "=", "preg_replace", "(", "'@(<%\\??)|%>@'", ",", "\"\"", ",", "$", "value", ")", ";", "if", "(", "$", "this", "->", "fileName", ")", "throw", "new", "Exception_Template", "(", "Exception_Template", "::", "FILE_LABELS_MISSING", ",", "$", "this", "->", "fileName", ",", "$", "tags", ")", ";", "throw", "new", "Exception_Template", "(", "Exception_Template", "::", "LABELS_MISSING", ",", "NULL", ",", "$", "tags", ")", ";", "}" ]
Creates an output string from the templatefile where all labels will be replaced with apropriate elements. If a non optional label wasn't specified, the method will throw a Template Exception @access public @return string
[ "Creates", "an", "output", "string", "from", "the", "templatefile", "where", "all", "labels", "will", "be", "replaced", "with", "apropriate", "elements", ".", "If", "a", "non", "optional", "label", "wasn", "t", "specified", "the", "method", "will", "throw", "a", "Template", "Exception" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L227-L273
37,218
CeusMedia/Common
src/UI/Template.php
UI_Template.getElementsFromComment
public function getElementsFromComment( $comment, $unique = TRUE ) { $content = $this->getTaggedComment( $comment ); if( !isset( $content ) ) return NULL; $list = array(); $content = explode( "\n", $content ); foreach( $content as $row ) { if( preg_match( '/\s*@(\S+)?\s+(.*)/', $row, $out ) ) { if( $unique ) $list[$out[1]] = $out[2]; else $list[$out[1]][] = $out[2]; } } return $list; }
php
public function getElementsFromComment( $comment, $unique = TRUE ) { $content = $this->getTaggedComment( $comment ); if( !isset( $content ) ) return NULL; $list = array(); $content = explode( "\n", $content ); foreach( $content as $row ) { if( preg_match( '/\s*@(\S+)?\s+(.*)/', $row, $out ) ) { if( $unique ) $list[$out[1]] = $out[2]; else $list[$out[1]][] = $out[2]; } } return $list; }
[ "public", "function", "getElementsFromComment", "(", "$", "comment", ",", "$", "unique", "=", "TRUE", ")", "{", "$", "content", "=", "$", "this", "->", "getTaggedComment", "(", "$", "comment", ")", ";", "if", "(", "!", "isset", "(", "$", "content", ")", ")", "return", "NULL", ";", "$", "list", "=", "array", "(", ")", ";", "$", "content", "=", "explode", "(", "\"\\n\"", ",", "$", "content", ")", ";", "foreach", "(", "$", "content", "as", "$", "row", ")", "{", "if", "(", "preg_match", "(", "'/\\s*@(\\S+)?\\s+(.*)/'", ",", "$", "row", ",", "$", "out", ")", ")", "{", "if", "(", "$", "unique", ")", "$", "list", "[", "$", "out", "[", "1", "]", "]", "=", "$", "out", "[", "2", "]", ";", "else", "$", "list", "[", "$", "out", "[", "1", "]", "]", "[", "]", "=", "$", "out", "[", "2", "]", ";", "}", "}", "return", "$", "list", ";", "}" ]
Returns all marked elements from a comment. @param string $comment Comment Tag @param boolean $unique Flag: unique Keys only @return array containing Elements or empty
[ "Returns", "all", "marked", "elements", "from", "a", "comment", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L291-L310
37,219
CeusMedia/Common
src/UI/Template.php
UI_Template.getLabels
public function getLabels( $type = 0, $xml = TRUE ) { $content = preg_replace( '/<%\??--.*--%>/sU', '', $this->template ); switch( $type ) { case 2: preg_match_all( '/<%(\?.*)%>/U', $content, $tags ); break; case 1: preg_match_all( '/<%([^-?].*)%>/U', $content, $tags ); break; default: preg_match_all( '/<%([^-].*)%>/U', $content, $tags ); } return $xml ? $tags[0] : $tags[1]; }
php
public function getLabels( $type = 0, $xml = TRUE ) { $content = preg_replace( '/<%\??--.*--%>/sU', '', $this->template ); switch( $type ) { case 2: preg_match_all( '/<%(\?.*)%>/U', $content, $tags ); break; case 1: preg_match_all( '/<%([^-?].*)%>/U', $content, $tags ); break; default: preg_match_all( '/<%([^-].*)%>/U', $content, $tags ); } return $xml ? $tags[0] : $tags[1]; }
[ "public", "function", "getLabels", "(", "$", "type", "=", "0", ",", "$", "xml", "=", "TRUE", ")", "{", "$", "content", "=", "preg_replace", "(", "'/<%\\??--.*--%>/sU'", ",", "''", ",", "$", "this", "->", "template", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "2", ":", "preg_match_all", "(", "'/<%(\\?.*)%>/U'", ",", "$", "content", ",", "$", "tags", ")", ";", "break", ";", "case", "1", ":", "preg_match_all", "(", "'/<%([^-?].*)%>/U'", ",", "$", "content", ",", "$", "tags", ")", ";", "break", ";", "default", ":", "preg_match_all", "(", "'/<%([^-].*)%>/U'", ",", "$", "content", ",", "$", "tags", ")", ";", "}", "return", "$", "xml", "?", "$", "tags", "[", "0", "]", ":", "$", "tags", "[", "1", "]", ";", "}" ]
Returns all defined labels. @param int $type Label Type: 0=all, 1=mandatory, 2=optional @param boolean $xml Flag: with or without delimiter @return array Array of Labels
[ "Returns", "all", "defined", "labels", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L318-L333
37,220
CeusMedia/Common
src/UI/Template.php
UI_Template.getTaggedComment
public function getTaggedComment( $tag, $xml = TRUE ) { if( preg_match( '/<%--'.$tag.'(.*)--%>/sU', $this->template, $tag ) ) return $xml ? $tag[0] : $tag[1]; return NULL; }
php
public function getTaggedComment( $tag, $xml = TRUE ) { if( preg_match( '/<%--'.$tag.'(.*)--%>/sU', $this->template, $tag ) ) return $xml ? $tag[0] : $tag[1]; return NULL; }
[ "public", "function", "getTaggedComment", "(", "$", "tag", ",", "$", "xml", "=", "TRUE", ")", "{", "if", "(", "preg_match", "(", "'/<%--'", ".", "$", "tag", ".", "'(.*)--%>/sU'", ",", "$", "this", "->", "template", ",", "$", "tag", ")", ")", "return", "$", "xml", "?", "$", "tag", "[", "0", "]", ":", "$", "tag", "[", "1", "]", ";", "return", "NULL", ";", "}" ]
Returns a tagged comment. @param string $tag Comment Tag @param boolean $xml Flag: with or without Delimiter @return string Comment or NULL @todo quote specialchars in tagname
[ "Returns", "a", "tagged", "comment", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L342-L347
37,221
CeusMedia/Common
src/UI/Template.php
UI_Template.renderString
public static function renderString( $string, $elements = array() ) { $template = new self(); $template->template = $string; $template->add( $elements ); return $template->create(); }
php
public static function renderString( $string, $elements = array() ) { $template = new self(); $template->template = $string; $template->add( $elements ); return $template->create(); }
[ "public", "static", "function", "renderString", "(", "$", "string", ",", "$", "elements", "=", "array", "(", ")", ")", "{", "$", "template", "=", "new", "self", "(", ")", ";", "$", "template", "->", "template", "=", "$", "string", ";", "$", "template", "->", "add", "(", "$", "elements", ")", ";", "return", "$", "template", "->", "create", "(", ")", ";", "}" ]
Renders a Template String with given Elements statically. @access public @static @param string $string Template String @param array $elements Map of Elements for Template String @return string
[ "Renders", "a", "Template", "String", "with", "given", "Elements", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L402-L408
37,222
CeusMedia/Common
src/UI/Template.php
UI_Template.setTemplate
public function setTemplate( $fileName ) { if( empty( $fileName ) ) return FALSE; if( !file_exists( $fileName ) ) throw new Exception_Template( Exception_Template::FILE_NOT_FOUND, $fileName ); $this->fileName = $fileName; $this->template = file_get_contents( $fileName ); return TRUE; }
php
public function setTemplate( $fileName ) { if( empty( $fileName ) ) return FALSE; if( !file_exists( $fileName ) ) throw new Exception_Template( Exception_Template::FILE_NOT_FOUND, $fileName ); $this->fileName = $fileName; $this->template = file_get_contents( $fileName ); return TRUE; }
[ "public", "function", "setTemplate", "(", "$", "fileName", ")", "{", "if", "(", "empty", "(", "$", "fileName", ")", ")", "return", "FALSE", ";", "if", "(", "!", "file_exists", "(", "$", "fileName", ")", ")", "throw", "new", "Exception_Template", "(", "Exception_Template", "::", "FILE_NOT_FOUND", ",", "$", "fileName", ")", ";", "$", "this", "->", "fileName", "=", "$", "fileName", ";", "$", "this", "->", "template", "=", "file_get_contents", "(", "$", "fileName", ")", ";", "return", "TRUE", ";", "}" ]
Loads a new template file if it exists. Otherwise it will throw an Exception. @param string $fileName File Name of Template @return boolean
[ "Loads", "a", "new", "template", "file", "if", "it", "exists", ".", "Otherwise", "it", "will", "throw", "an", "Exception", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L415-L426
37,223
FriendsOfSilverStripe/backendmessages
src/Message.php
Message.warning
public static function warning($message = null, $name = null) { return self::generic($message, WarningMessage::$CSSClass, $name); }
php
public static function warning($message = null, $name = null) { return self::generic($message, WarningMessage::$CSSClass, $name); }
[ "public", "static", "function", "warning", "(", "$", "message", "=", "null", ",", "$", "name", "=", "null", ")", "{", "return", "self", "::", "generic", "(", "$", "message", ",", "WarningMessage", "::", "$", "CSSClass", ",", "$", "name", ")", ";", "}" ]
Creates a warning message. @param string $message @param string $name (optional) @return MessageBoxField
[ "Creates", "a", "warning", "message", "." ]
6733fd84162fb2b722dcc31ece01f5b36f2f84a4
https://github.com/FriendsOfSilverStripe/backendmessages/blob/6733fd84162fb2b722dcc31ece01f5b36f2f84a4/src/Message.php#L69-L72
37,224
FriendsOfSilverStripe/backendmessages
src/Message.php
Message.success
public static function success($message = null, $name = null) { return self::generic($message, SuccessMessage::$CSSClass, $name); }
php
public static function success($message = null, $name = null) { return self::generic($message, SuccessMessage::$CSSClass, $name); }
[ "public", "static", "function", "success", "(", "$", "message", "=", "null", ",", "$", "name", "=", "null", ")", "{", "return", "self", "::", "generic", "(", "$", "message", ",", "SuccessMessage", "::", "$", "CSSClass", ",", "$", "name", ")", ";", "}" ]
Creates a success message. @param string $message @param string $name (optional) @return MessageBoxField
[ "Creates", "a", "success", "message", "." ]
6733fd84162fb2b722dcc31ece01f5b36f2f84a4
https://github.com/FriendsOfSilverStripe/backendmessages/blob/6733fd84162fb2b722dcc31ece01f5b36f2f84a4/src/Message.php#L82-L85
37,225
FriendsOfSilverStripe/backendmessages
src/Message.php
Message.notice
public static function notice($message = null, $name = null) { return self::generic($message, NoticeMessage::$CSSClass, $name); }
php
public static function notice($message = null, $name = null) { return self::generic($message, NoticeMessage::$CSSClass, $name); }
[ "public", "static", "function", "notice", "(", "$", "message", "=", "null", ",", "$", "name", "=", "null", ")", "{", "return", "self", "::", "generic", "(", "$", "message", ",", "NoticeMessage", "::", "$", "CSSClass", ",", "$", "name", ")", ";", "}" ]
Creates a notice message. @param string $message @param string $name (optional) @return MessageBoxField
[ "Creates", "a", "notice", "message", "." ]
6733fd84162fb2b722dcc31ece01f5b36f2f84a4
https://github.com/FriendsOfSilverStripe/backendmessages/blob/6733fd84162fb2b722dcc31ece01f5b36f2f84a4/src/Message.php#L95-L98
37,226
Assasz/yggdrasil
src/Yggdrasil/Core/Configuration/AbstractConfiguration.php
AbstractConfiguration.loadDrivers
public function loadDrivers(): DriverCollection { $drivers = new DriverCollection($this); foreach ($this->drivers as $name => $driver) { $drivers->add($name, $driver); } return $drivers; }
php
public function loadDrivers(): DriverCollection { $drivers = new DriverCollection($this); foreach ($this->drivers as $name => $driver) { $drivers->add($name, $driver); } return $drivers; }
[ "public", "function", "loadDrivers", "(", ")", ":", "DriverCollection", "{", "$", "drivers", "=", "new", "DriverCollection", "(", "$", "this", ")", ";", "foreach", "(", "$", "this", "->", "drivers", "as", "$", "name", "=>", "$", "driver", ")", "{", "$", "drivers", "->", "add", "(", "$", "name", ",", "$", "driver", ")", ";", "}", "return", "$", "drivers", ";", "}" ]
Returns collection of registered application drivers @return DriverCollection
[ "Returns", "collection", "of", "registered", "application", "drivers" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Configuration/AbstractConfiguration.php#L49-L58
37,227
Assasz/yggdrasil
src/Yggdrasil/Core/Configuration/AbstractConfiguration.php
AbstractConfiguration.loadDriver
public function loadDriver(string $key): DriverInterface { if (!$this->hasDriver($key)) { throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.'); } return $this->drivers[$key]::install($this); }
php
public function loadDriver(string $key): DriverInterface { if (!$this->hasDriver($key)) { throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.'); } return $this->drivers[$key]::install($this); }
[ "public", "function", "loadDriver", "(", "string", "$", "key", ")", ":", "DriverInterface", "{", "if", "(", "!", "$", "this", "->", "hasDriver", "(", "$", "key", ")", ")", "{", "throw", "new", "DriverNotFoundException", "(", "'Driver you are looking for doesn\\'t exist. Make sure that '", ".", "$", "key", ".", "' driver is properly configured.'", ")", ";", "}", "return", "$", "this", "->", "drivers", "[", "$", "key", "]", "::", "install", "(", "$", "this", ")", ";", "}" ]
Returns configured instance of given driver @param string $key Name of driver @return DriverInterface @throws DriverNotFoundException if given driver doesn't exist
[ "Returns", "configured", "instance", "of", "given", "driver" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Configuration/AbstractConfiguration.php#L67-L74
37,228
Assasz/yggdrasil
src/Yggdrasil/Core/Configuration/AbstractConfiguration.php
AbstractConfiguration.isConfigured
public function isConfigured(array $keys, string $section): bool { if (!array_key_exists($section, $this->configuration)) { return false; } return !array_diff_key(array_flip($keys), $this->configuration[$section]); }
php
public function isConfigured(array $keys, string $section): bool { if (!array_key_exists($section, $this->configuration)) { return false; } return !array_diff_key(array_flip($keys), $this->configuration[$section]); }
[ "public", "function", "isConfigured", "(", "array", "$", "keys", ",", "string", "$", "section", ")", ":", "bool", "{", "if", "(", "!", "array_key_exists", "(", "$", "section", ",", "$", "this", "->", "configuration", ")", ")", "{", "return", "false", ";", "}", "return", "!", "array_diff_key", "(", "array_flip", "(", "$", "keys", ")", ",", "$", "this", "->", "configuration", "[", "$", "section", "]", ")", ";", "}" ]
Checks if given parameters exist in configuration @param array $keys Set of parameters keys to check @param string $section Name of configuration file section, in which given parameters should exist @return bool
[ "Checks", "if", "given", "parameters", "exist", "in", "configuration" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Configuration/AbstractConfiguration.php#L104-L111
37,229
Assasz/yggdrasil
src/Yggdrasil/Core/Configuration/AbstractConfiguration.php
AbstractConfiguration.parseConfiguration
private function parseConfiguration(): void { $configFilePath = dirname(__DIR__, 7) . '/src/' . $this->getConfigPath() . '/config.ini'; if (!file_exists($configFilePath)) { throw new ConfigurationNotFoundException('Configuration file in ' . $configFilePath . ' not found.'); } $this->configuration = parse_ini_file($configFilePath, true); if (!$this->isConfigured(['root_namespace', 'env'], 'framework')) { throw new MissingConfigurationException(['root_namespace', 'env'], 'framework'); } }
php
private function parseConfiguration(): void { $configFilePath = dirname(__DIR__, 7) . '/src/' . $this->getConfigPath() . '/config.ini'; if (!file_exists($configFilePath)) { throw new ConfigurationNotFoundException('Configuration file in ' . $configFilePath . ' not found.'); } $this->configuration = parse_ini_file($configFilePath, true); if (!$this->isConfigured(['root_namespace', 'env'], 'framework')) { throw new MissingConfigurationException(['root_namespace', 'env'], 'framework'); } }
[ "private", "function", "parseConfiguration", "(", ")", ":", "void", "{", "$", "configFilePath", "=", "dirname", "(", "__DIR__", ",", "7", ")", ".", "'/src/'", ".", "$", "this", "->", "getConfigPath", "(", ")", ".", "'/config.ini'", ";", "if", "(", "!", "file_exists", "(", "$", "configFilePath", ")", ")", "{", "throw", "new", "ConfigurationNotFoundException", "(", "'Configuration file in '", ".", "$", "configFilePath", ".", "' not found.'", ")", ";", "}", "$", "this", "->", "configuration", "=", "parse_ini_file", "(", "$", "configFilePath", ",", "true", ")", ";", "if", "(", "!", "$", "this", "->", "isConfigured", "(", "[", "'root_namespace'", ",", "'env'", "]", ",", "'framework'", ")", ")", "{", "throw", "new", "MissingConfigurationException", "(", "[", "'root_namespace'", ",", "'env'", "]", ",", "'framework'", ")", ";", "}", "}" ]
Parses config.ini file into configuration array @throws ConfigurationNotFoundException if config.ini file doesn't exist in specified path @throws MissingConfigurationException if root_namespace or env is not configured
[ "Parses", "config", ".", "ini", "file", "into", "configuration", "array" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Configuration/AbstractConfiguration.php#L119-L132
37,230
CeusMedia/Common
src/Alg/Object/EventHandler.php
Alg_Object_EventHandler.handleEvent
public function handleEvent( $eventName ) { $counter = 0; if( !array_key_exists( $eventName, $this->callbacks ) ) return $counter; foreach( $this->callbacks[$eventName] as $callback ) { extract( $callback ); $factory = new Alg_Object_MethodFactory; // build a new Method Factory $factory->callObjectMethod( $object, $methodName, $methodParameters ); $counter++; // increase Callback Counter $this->counter++; // increase total Callback Counter } return $counter; }
php
public function handleEvent( $eventName ) { $counter = 0; if( !array_key_exists( $eventName, $this->callbacks ) ) return $counter; foreach( $this->callbacks[$eventName] as $callback ) { extract( $callback ); $factory = new Alg_Object_MethodFactory; // build a new Method Factory $factory->callObjectMethod( $object, $methodName, $methodParameters ); $counter++; // increase Callback Counter $this->counter++; // increase total Callback Counter } return $counter; }
[ "public", "function", "handleEvent", "(", "$", "eventName", ")", "{", "$", "counter", "=", "0", ";", "if", "(", "!", "array_key_exists", "(", "$", "eventName", ",", "$", "this", "->", "callbacks", ")", ")", "return", "$", "counter", ";", "foreach", "(", "$", "this", "->", "callbacks", "[", "$", "eventName", "]", "as", "$", "callback", ")", "{", "extract", "(", "$", "callback", ")", ";", "$", "factory", "=", "new", "Alg_Object_MethodFactory", ";", "// build a new Method Factory", "$", "factory", "->", "callObjectMethod", "(", "$", "object", ",", "$", "methodName", ",", "$", "methodParameters", ")", ";", "$", "counter", "++", ";", "// increase Callback Counter", "$", "this", "->", "counter", "++", ";", "// increase total Callback Counter", "}", "return", "$", "counter", ";", "}" ]
Trigger all registered Callbacks for an Event. @access public @public string $eventName Name of Event to trigger @return int Number of handled Callbacks
[ "Trigger", "all", "registered", "Callbacks", "for", "an", "Event", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Object/EventHandler.php#L119-L133
37,231
CeusMedia/Common
src/FS/File/PHP/Encoder.php
FS_File_PHP_Encoder.decode
public function decode( $php ) { $code = substr( $php, strlen( $this->outcodePrefix) , -strlen( $this->outcodeSuffix ) ); $php = $this->decodeHash( $code ); return $php; }
php
public function decode( $php ) { $code = substr( $php, strlen( $this->outcodePrefix) , -strlen( $this->outcodeSuffix ) ); $php = $this->decodeHash( $code ); return $php; }
[ "public", "function", "decode", "(", "$", "php", ")", "{", "$", "code", "=", "substr", "(", "$", "php", ",", "strlen", "(", "$", "this", "->", "outcodePrefix", ")", ",", "-", "strlen", "(", "$", "this", "->", "outcodeSuffix", ")", ")", ";", "$", "php", "=", "$", "this", "->", "decodeHash", "(", "$", "code", ")", ";", "return", "$", "php", ";", "}" ]
Returns decoded and stripped PHP Content. @access public @param string $php Encoded PHP Content @return string
[ "Returns", "decoded", "and", "stripped", "PHP", "Content", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L76-L81
37,232
CeusMedia/Common
src/FS/File/PHP/Encoder.php
FS_File_PHP_Encoder.decodeFile
public function decodeFile( $fileName, $overwrite = FALSE ) { if( file_exists( $fileName ) ) { if( $this->isEncoded( $fileName ) ) { $file = new FS_File_Editor( $fileName ); $php = $file->readString(); $code = $this->encode( $php ); $dirname = dirname( $fileName ); $basename = basename( $fileName ); $target = $dirname."/".substr( $basename, strlen( $this->filePrefix) , -strlen( $this->fileSuffix ) ); if( $fileName == $target && !$overwrite ) throw new RuntimeException( 'File cannot be overwritten, use Parameter "overwrite".' ); $file->writeString( $code ); return TRUE; } } return FALSE; }
php
public function decodeFile( $fileName, $overwrite = FALSE ) { if( file_exists( $fileName ) ) { if( $this->isEncoded( $fileName ) ) { $file = new FS_File_Editor( $fileName ); $php = $file->readString(); $code = $this->encode( $php ); $dirname = dirname( $fileName ); $basename = basename( $fileName ); $target = $dirname."/".substr( $basename, strlen( $this->filePrefix) , -strlen( $this->fileSuffix ) ); if( $fileName == $target && !$overwrite ) throw new RuntimeException( 'File cannot be overwritten, use Parameter "overwrite".' ); $file->writeString( $code ); return TRUE; } } return FALSE; }
[ "public", "function", "decodeFile", "(", "$", "fileName", ",", "$", "overwrite", "=", "FALSE", ")", "{", "if", "(", "file_exists", "(", "$", "fileName", ")", ")", "{", "if", "(", "$", "this", "->", "isEncoded", "(", "$", "fileName", ")", ")", "{", "$", "file", "=", "new", "FS_File_Editor", "(", "$", "fileName", ")", ";", "$", "php", "=", "$", "file", "->", "readString", "(", ")", ";", "$", "code", "=", "$", "this", "->", "encode", "(", "$", "php", ")", ";", "$", "dirname", "=", "dirname", "(", "$", "fileName", ")", ";", "$", "basename", "=", "basename", "(", "$", "fileName", ")", ";", "$", "target", "=", "$", "dirname", ".", "\"/\"", ".", "substr", "(", "$", "basename", ",", "strlen", "(", "$", "this", "->", "filePrefix", ")", ",", "-", "strlen", "(", "$", "this", "->", "fileSuffix", ")", ")", ";", "if", "(", "$", "fileName", "==", "$", "target", "&&", "!", "$", "overwrite", ")", "throw", "new", "RuntimeException", "(", "'File cannot be overwritten, use Parameter \"overwrite\".'", ")", ";", "$", "file", "->", "writeString", "(", "$", "code", ")", ";", "return", "TRUE", ";", "}", "}", "return", "FALSE", ";", "}" ]
Decodes an encoded PHP File. @access public @return void
[ "Decodes", "an", "encoded", "PHP", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L88-L107
37,233
CeusMedia/Common
src/FS/File/PHP/Encoder.php
FS_File_PHP_Encoder.decodeHash
protected function decodeHash( $code ) { $php = gzinflate( base64_decode( $code ) ); $php = substr( $php, strlen( $this->incodePrefix) , -strlen( $this->incodeSuffix ) ); return $php; }
php
protected function decodeHash( $code ) { $php = gzinflate( base64_decode( $code ) ); $php = substr( $php, strlen( $this->incodePrefix) , -strlen( $this->incodeSuffix ) ); return $php; }
[ "protected", "function", "decodeHash", "(", "$", "code", ")", "{", "$", "php", "=", "gzinflate", "(", "base64_decode", "(", "$", "code", ")", ")", ";", "$", "php", "=", "substr", "(", "$", "php", ",", "strlen", "(", "$", "this", "->", "incodePrefix", ")", ",", "-", "strlen", "(", "$", "this", "->", "incodeSuffix", ")", ")", ";", "return", "$", "php", ";", "}" ]
Returns Hash decoded PHP Content. @access protected @param string $php Encoded PHP Content @return string
[ "Returns", "Hash", "decoded", "PHP", "Content", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L115-L120
37,234
CeusMedia/Common
src/FS/File/PHP/Encoder.php
FS_File_PHP_Encoder.encode
public function encode( $php ) { $code = $this->encodeHash( $php ); $php = $this->outcodePrefix.$code.$this->outcodeSuffix; return $php; }
php
public function encode( $php ) { $code = $this->encodeHash( $php ); $php = $this->outcodePrefix.$code.$this->outcodeSuffix; return $php; }
[ "public", "function", "encode", "(", "$", "php", ")", "{", "$", "code", "=", "$", "this", "->", "encodeHash", "(", "$", "php", ")", ";", "$", "php", "=", "$", "this", "->", "outcodePrefix", ".", "$", "code", ".", "$", "this", "->", "outcodeSuffix", ";", "return", "$", "php", ";", "}" ]
Returns encoded and wrapped PHP Content. @access public @param string $php Encoded PHP Content @return string
[ "Returns", "encoded", "and", "wrapped", "PHP", "Content", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L128-L133
37,235
CeusMedia/Common
src/FS/File/PHP/Encoder.php
FS_File_PHP_Encoder.encodeFile
public function encodeFile( $fileName, $overwrite = FALSE ) { if( !file_exists( $fileName ) ) return FALSE; if( $this->isEncoded( $fileName ) ) return TRUE; $php = FS_File_Reader::load( $fileName ); $code = $this->encode( $php ); $dirname = dirname( $fileName ); $basename = basename( $fileName ); $target = $dirname."/".$this->filePrefix.$basename.$this->fileSuffix; if( $fileName == $target && !$overwrite ) throw new RuntimeException( 'File cannot be overwritten, use Parameter "overwrite".' ); // copy( $fileName, "#".$fileName ); return (bool) FS_File_Writer::save( $target, $code ); }
php
public function encodeFile( $fileName, $overwrite = FALSE ) { if( !file_exists( $fileName ) ) return FALSE; if( $this->isEncoded( $fileName ) ) return TRUE; $php = FS_File_Reader::load( $fileName ); $code = $this->encode( $php ); $dirname = dirname( $fileName ); $basename = basename( $fileName ); $target = $dirname."/".$this->filePrefix.$basename.$this->fileSuffix; if( $fileName == $target && !$overwrite ) throw new RuntimeException( 'File cannot be overwritten, use Parameter "overwrite".' ); // copy( $fileName, "#".$fileName ); return (bool) FS_File_Writer::save( $target, $code ); }
[ "public", "function", "encodeFile", "(", "$", "fileName", ",", "$", "overwrite", "=", "FALSE", ")", "{", "if", "(", "!", "file_exists", "(", "$", "fileName", ")", ")", "return", "FALSE", ";", "if", "(", "$", "this", "->", "isEncoded", "(", "$", "fileName", ")", ")", "return", "TRUE", ";", "$", "php", "=", "FS_File_Reader", "::", "load", "(", "$", "fileName", ")", ";", "$", "code", "=", "$", "this", "->", "encode", "(", "$", "php", ")", ";", "$", "dirname", "=", "dirname", "(", "$", "fileName", ")", ";", "$", "basename", "=", "basename", "(", "$", "fileName", ")", ";", "$", "target", "=", "$", "dirname", ".", "\"/\"", ".", "$", "this", "->", "filePrefix", ".", "$", "basename", ".", "$", "this", "->", "fileSuffix", ";", "if", "(", "$", "fileName", "==", "$", "target", "&&", "!", "$", "overwrite", ")", "throw", "new", "RuntimeException", "(", "'File cannot be overwritten, use Parameter \"overwrite\".'", ")", ";", "//\t\tcopy( $fileName, \"#\".$fileName );\r", "return", "(", "bool", ")", "FS_File_Writer", "::", "save", "(", "$", "target", ",", "$", "code", ")", ";", "}" ]
Encodes a PHP File. @access public @return void
[ "Encodes", "a", "PHP", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L140-L155
37,236
CeusMedia/Common
src/FS/File/PHP/Encoder.php
FS_File_PHP_Encoder.isEncoded
public function isEncoded( $fileName ) { if( file_exists( $fileName ) ) { $fp = fopen( $fileName, "r" ); $code = fgets( $fp, strlen( $this->outcodePrefix ) ); if( $code == $this->outcodePrefix ) return TRUE; } return FALSE; }
php
public function isEncoded( $fileName ) { if( file_exists( $fileName ) ) { $fp = fopen( $fileName, "r" ); $code = fgets( $fp, strlen( $this->outcodePrefix ) ); if( $code == $this->outcodePrefix ) return TRUE; } return FALSE; }
[ "public", "function", "isEncoded", "(", "$", "fileName", ")", "{", "if", "(", "file_exists", "(", "$", "fileName", ")", ")", "{", "$", "fp", "=", "fopen", "(", "$", "fileName", ",", "\"r\"", ")", ";", "$", "code", "=", "fgets", "(", "$", "fp", ",", "strlen", "(", "$", "this", "->", "outcodePrefix", ")", ")", ";", "if", "(", "$", "code", "==", "$", "this", "->", "outcodePrefix", ")", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
Indicated whether a PHP File ist encoded. @access public @param string $fileName File Name of PHP File to be checked @return bool
[ "Indicated", "whether", "a", "PHP", "File", "ist", "encoded", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L174-L184
37,237
smasty/Neevo
src/Neevo/Drivers/pgsql.php
PgSQLDriver.getInsertId
public function getInsertId(){ $result = $this->runQuery("SELECT LASTVAL()"); if(!$result) return false; $r = $this->fetch($result); return is_array($r) ? reset($r) : false; }
php
public function getInsertId(){ $result = $this->runQuery("SELECT LASTVAL()"); if(!$result) return false; $r = $this->fetch($result); return is_array($r) ? reset($r) : false; }
[ "public", "function", "getInsertId", "(", ")", "{", "$", "result", "=", "$", "this", "->", "runQuery", "(", "\"SELECT LASTVAL()\"", ")", ";", "if", "(", "!", "$", "result", ")", "return", "false", ";", "$", "r", "=", "$", "this", "->", "fetch", "(", "$", "result", ")", ";", "return", "is_array", "(", "$", "r", ")", "?", "reset", "(", "$", "r", ")", ":", "false", ";", "}" ]
Returns the ID generated in the INSERT statement. @return int
[ "Returns", "the", "ID", "generated", "in", "the", "INSERT", "statement", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Drivers/pgsql.php#L195-L202
37,238
generationtux/marketo-rest-api-client
src/Api/CustomActivitiesApi.php
CustomActivitiesApi.create
public function create(array $fields) { $url = $this->client->url . "/rest/v1/activities/external.json"; $response = $this->post($url, ['input' => $fields]); if (!$response->success) { throw new MarketoApiException('Error creating custom activity: ' . $response->errors[0]->message); } }
php
public function create(array $fields) { $url = $this->client->url . "/rest/v1/activities/external.json"; $response = $this->post($url, ['input' => $fields]); if (!$response->success) { throw new MarketoApiException('Error creating custom activity: ' . $response->errors[0]->message); } }
[ "public", "function", "create", "(", "array", "$", "fields", ")", "{", "$", "url", "=", "$", "this", "->", "client", "->", "url", ".", "\"/rest/v1/activities/external.json\"", ";", "$", "response", "=", "$", "this", "->", "post", "(", "$", "url", ",", "[", "'input'", "=>", "$", "fields", "]", ")", ";", "if", "(", "!", "$", "response", "->", "success", ")", "{", "throw", "new", "MarketoApiException", "(", "'Error creating custom activity: '", ".", "$", "response", "->", "errors", "[", "0", "]", "->", "message", ")", ";", "}", "}" ]
Create a new custom activity @param array $fields @throws MarketoApiException @see http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Activities/addCustomActivityUsingPOST
[ "Create", "a", "new", "custom", "activity" ]
a227574f6569ca2c95c2343dd963d7f9d3885afe
https://github.com/generationtux/marketo-rest-api-client/blob/a227574f6569ca2c95c2343dd963d7f9d3885afe/src/Api/CustomActivitiesApi.php#L18-L26
37,239
CeusMedia/Common
src/FS/File/YAML/Writer.php
FS_File_YAML_Writer.save
public static function save( $fileName, $data ) { $yaml = FS_File_YAML_Spyc::YAMLDump( $data ); return FS_File_Writer::save( $fileName, $yaml ); }
php
public static function save( $fileName, $data ) { $yaml = FS_File_YAML_Spyc::YAMLDump( $data ); return FS_File_Writer::save( $fileName, $yaml ); }
[ "public", "static", "function", "save", "(", "$", "fileName", ",", "$", "data", ")", "{", "$", "yaml", "=", "FS_File_YAML_Spyc", "::", "YAMLDump", "(", "$", "data", ")", ";", "return", "FS_File_Writer", "::", "save", "(", "$", "fileName", ",", "$", "yaml", ")", ";", "}" ]
Writes Data into YAML File statically. @access public @static @param string $fileName File Name of YAML File. @param array $data Array to write into YAML File @return bool
[ "Writes", "Data", "into", "YAML", "File", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/YAML/Writer.php#L66-L70
37,240
CeusMedia/Common
src/XML/Namespaces.php
XML_Namespaces.detectNamespacesFromXml
public function detectNamespacesFromXml( $xml ) { $namespaces = self::getNamespacesFromXml( $xml ); $this->namespaces = array_merge( $this->namespaces, $namespaces ); return count( $namespaces ); }
php
public function detectNamespacesFromXml( $xml ) { $namespaces = self::getNamespacesFromXml( $xml ); $this->namespaces = array_merge( $this->namespaces, $namespaces ); return count( $namespaces ); }
[ "public", "function", "detectNamespacesFromXml", "(", "$", "xml", ")", "{", "$", "namespaces", "=", "self", "::", "getNamespacesFromXml", "(", "$", "xml", ")", ";", "$", "this", "->", "namespaces", "=", "array_merge", "(", "$", "this", "->", "namespaces", ",", "$", "namespaces", ")", ";", "return", "count", "(", "$", "namespaces", ")", ";", "}" ]
Detects Namespaces from a XML File and returns Number of found Namespaces. @access public @param DOMDocument $doc DOM Document of XML File @return void
[ "Detects", "Namespaces", "from", "a", "XML", "File", "and", "returns", "Number", "of", "found", "Namespaces", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Namespaces.php#L87-L92
37,241
CeusMedia/Common
src/Net/Mail/Body.php
Net_Mail_Body.getMimeType
public function getMimeType() { $field = $this->headers->getField( 'Content-Type' ); $parts = explode( ';', $field->getValue() ); return $parts[0]; }
php
public function getMimeType() { $field = $this->headers->getField( 'Content-Type' ); $parts = explode( ';', $field->getValue() ); return $parts[0]; }
[ "public", "function", "getMimeType", "(", ")", "{", "$", "field", "=", "$", "this", "->", "headers", "->", "getField", "(", "'Content-Type'", ")", ";", "$", "parts", "=", "explode", "(", "';'", ",", "$", "field", "->", "getValue", "(", ")", ")", ";", "return", "$", "parts", "[", "0", "]", ";", "}" ]
Returns mail part MIME type. @access public @return string
[ "Returns", "mail", "part", "MIME", "type", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Body.php#L110-L115
37,242
CeusMedia/Common
src/Net/Mail/Body.php
Net_Mail_Body.render
public function render() { return $this->headers->toString().Net_Mail::$delimiter.Net_Mail::$delimiter.$this->content/*.PHP_EOL*/; }
php
public function render() { return $this->headers->toString().Net_Mail::$delimiter.Net_Mail::$delimiter.$this->content/*.PHP_EOL*/; }
[ "public", "function", "render", "(", ")", "{", "return", "$", "this", "->", "headers", "->", "toString", "(", ")", ".", "Net_Mail", "::", "$", "delimiter", ".", "Net_Mail", "::", "$", "delimiter", ".", "$", "this", "->", "content", "/*.PHP_EOL*/", ";", "}" ]
Returns rendered Mail Part of Body, containing Header Fields and Body Content. @access public @return string
[ "Returns", "rendered", "Mail", "Part", "of", "Body", "containing", "Header", "Fields", "and", "Body", "Content", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Body.php#L122-L125
37,243
CeusMedia/Common
src/XML/DOM/ObjectFileDeserializer.php
XML_DOM_ObjectFileDeserializer.deserialize
public static function deserialize( $fileName ) { $reader = new FS_File_Reader( $fileName ); $xml = $reader->readString( $fileName ); return parent::deserialize( $xml ); }
php
public static function deserialize( $fileName ) { $reader = new FS_File_Reader( $fileName ); $xml = $reader->readString( $fileName ); return parent::deserialize( $xml ); }
[ "public", "static", "function", "deserialize", "(", "$", "fileName", ")", "{", "$", "reader", "=", "new", "FS_File_Reader", "(", "$", "fileName", ")", ";", "$", "xml", "=", "$", "reader", "->", "readString", "(", "$", "fileName", ")", ";", "return", "parent", "::", "deserialize", "(", "$", "xml", ")", ";", "}" ]
Builds Object from XML File of a serialized Object. @access public @static @param string $fileName XML File of a serialized Object @return Object
[ "Builds", "Object", "from", "XML", "File", "of", "a", "serialized", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/ObjectFileDeserializer.php#L51-L56
37,244
CeusMedia/Common
src/Net/Reader.php
Net_Reader.getHeader
public function getHeader( $key = NULL ) { if( !$this->info ) throw new RuntimeException( "No Request has been sent, yet." ); if( !$key ) return $this->headers; if( !array_key_exists( $key, $this->headers ) ) throw new InvalidArgumentException( 'Header Key "'.$key.'" is invalid.' ); return $this->headers[$key]; }
php
public function getHeader( $key = NULL ) { if( !$this->info ) throw new RuntimeException( "No Request has been sent, yet." ); if( !$key ) return $this->headers; if( !array_key_exists( $key, $this->headers ) ) throw new InvalidArgumentException( 'Header Key "'.$key.'" is invalid.' ); return $this->headers[$key]; }
[ "public", "function", "getHeader", "(", "$", "key", "=", "NULL", ")", "{", "if", "(", "!", "$", "this", "->", "info", ")", "throw", "new", "RuntimeException", "(", "\"No Request has been sent, yet.\"", ")", ";", "if", "(", "!", "$", "key", ")", "return", "$", "this", "->", "headers", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "headers", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Header Key \"'", ".", "$", "key", ".", "'\" is invalid.'", ")", ";", "return", "$", "this", "->", "headers", "[", "$", "key", "]", ";", "}" ]
Returns Headers Array or a specified header from last request. @access public @param string $key Header key @return mixed
[ "Returns", "Headers", "Array", "or", "a", "specified", "header", "from", "last", "request", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Reader.php#L95-L104
37,245
CeusMedia/Common
src/Net/Reader.php
Net_Reader.getInfo
public function getInfo( $key = NULL ) { if( !$this->info ) throw new RuntimeException( "No Request has been sent, yet." ); if( !$key ) return $this->info; if( !array_key_exists( $key, $this->info ) ) throw new InvalidArgumentException( 'Status Key "'.$key.'" is invalid.' ); return $this->info[$key]; }
php
public function getInfo( $key = NULL ) { if( !$this->info ) throw new RuntimeException( "No Request has been sent, yet." ); if( !$key ) return $this->info; if( !array_key_exists( $key, $this->info ) ) throw new InvalidArgumentException( 'Status Key "'.$key.'" is invalid.' ); return $this->info[$key]; }
[ "public", "function", "getInfo", "(", "$", "key", "=", "NULL", ")", "{", "if", "(", "!", "$", "this", "->", "info", ")", "throw", "new", "RuntimeException", "(", "\"No Request has been sent, yet.\"", ")", ";", "if", "(", "!", "$", "key", ")", "return", "$", "this", "->", "info", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "info", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Status Key \"'", ".", "$", "key", ".", "'\" is invalid.'", ")", ";", "return", "$", "this", "->", "info", "[", "$", "key", "]", ";", "}" ]
Returns information map or single information from last request. @access public @param string $key Information key @return mixed
[ "Returns", "information", "map", "or", "single", "information", "from", "last", "request", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Reader.php#L116-L125
37,246
CeusMedia/Common
src/Net/Reader.php
Net_Reader.read
public function read( $curlOptions = array() ) { $curl = new Net_CURL( $this->url ); $curl->setOption( CURLOPT_SSL_VERIFYHOST, $this->verifyHost ); $curl->setOption( CURLOPT_SSL_VERIFYPEER, $this->verifyPeer ); $curl->setOption( CURLOPT_FOLLOWLOCATION, !ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ); $curl->setOption( CURLOPT_HEADER, TRUE ); if( self::$userAgent ) $curl->setOption( CURLOPT_USERAGENT, self::$userAgent ); if( $this->username ) $curl->setOption( CURLOPT_USERPWD, $this->username.":".$this->password ); if( $this->proxyAddress ){ $curl->setOption( CURLOPT_HTTPPROXYTUNNEL, TRUE); $curl->setOption( CURLOPT_PROXY, $this->proxyAddress ); $curl->setOption( CURLOPT_PROXYTYPE, $this->proxyType ); if( $this->proxyAuth ) $curl->setOption( CURLOPT_PROXYUSERPWD, $this->proxyAuth ); } foreach( $curlOptions as $key => $value ) { if( is_string( $key ) ) { if( !( preg_match( "@^CURLOPT_@", $key ) && defined( $key ) ) ) throw new InvalidArgumentException( 'Invalid option constant key "'.$key.'"' ); $key = constant( $key ); } if( !is_int( $key ) ) throw new InvalidArgumentException( 'Option must be given as integer or string' ); $curl->setOption( $key, $value ); } $result = $curl->exec( TRUE, FALSE ); $response = Net_HTTP_Response_Parser::fromString( $result ); $this->body = $response->getBody(); $this->headers = $response->getHeaders(); $this->info = $curl->getInfo(); $code = $curl->getInfo( Net_CURL::INFO_HTTP_CODE ); $error = $curl->getInfo( Net_CURL::INFO_ERROR ); $errno = $curl->getInfo( Net_CURL::INFO_ERRNO ); if( $errno ) throw new Exception_IO( 'HTTP request failed: '.$error, $errno, $this->url ); if( !in_array( $code, array( '200', '301', '303', '304', '307' ) ) ) throw new Exception_IO( 'HTTP request failed', $code, $this->url ); return $this->body; }
php
public function read( $curlOptions = array() ) { $curl = new Net_CURL( $this->url ); $curl->setOption( CURLOPT_SSL_VERIFYHOST, $this->verifyHost ); $curl->setOption( CURLOPT_SSL_VERIFYPEER, $this->verifyPeer ); $curl->setOption( CURLOPT_FOLLOWLOCATION, !ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) ); $curl->setOption( CURLOPT_HEADER, TRUE ); if( self::$userAgent ) $curl->setOption( CURLOPT_USERAGENT, self::$userAgent ); if( $this->username ) $curl->setOption( CURLOPT_USERPWD, $this->username.":".$this->password ); if( $this->proxyAddress ){ $curl->setOption( CURLOPT_HTTPPROXYTUNNEL, TRUE); $curl->setOption( CURLOPT_PROXY, $this->proxyAddress ); $curl->setOption( CURLOPT_PROXYTYPE, $this->proxyType ); if( $this->proxyAuth ) $curl->setOption( CURLOPT_PROXYUSERPWD, $this->proxyAuth ); } foreach( $curlOptions as $key => $value ) { if( is_string( $key ) ) { if( !( preg_match( "@^CURLOPT_@", $key ) && defined( $key ) ) ) throw new InvalidArgumentException( 'Invalid option constant key "'.$key.'"' ); $key = constant( $key ); } if( !is_int( $key ) ) throw new InvalidArgumentException( 'Option must be given as integer or string' ); $curl->setOption( $key, $value ); } $result = $curl->exec( TRUE, FALSE ); $response = Net_HTTP_Response_Parser::fromString( $result ); $this->body = $response->getBody(); $this->headers = $response->getHeaders(); $this->info = $curl->getInfo(); $code = $curl->getInfo( Net_CURL::INFO_HTTP_CODE ); $error = $curl->getInfo( Net_CURL::INFO_ERROR ); $errno = $curl->getInfo( Net_CURL::INFO_ERRNO ); if( $errno ) throw new Exception_IO( 'HTTP request failed: '.$error, $errno, $this->url ); if( !in_array( $code, array( '200', '301', '303', '304', '307' ) ) ) throw new Exception_IO( 'HTTP request failed', $code, $this->url ); return $this->body; }
[ "public", "function", "read", "(", "$", "curlOptions", "=", "array", "(", ")", ")", "{", "$", "curl", "=", "new", "Net_CURL", "(", "$", "this", "->", "url", ")", ";", "$", "curl", "->", "setOption", "(", "CURLOPT_SSL_VERIFYHOST", ",", "$", "this", "->", "verifyHost", ")", ";", "$", "curl", "->", "setOption", "(", "CURLOPT_SSL_VERIFYPEER", ",", "$", "this", "->", "verifyPeer", ")", ";", "$", "curl", "->", "setOption", "(", "CURLOPT_FOLLOWLOCATION", ",", "!", "ini_get", "(", "'safe_mode'", ")", "&&", "!", "ini_get", "(", "'open_basedir'", ")", ")", ";", "$", "curl", "->", "setOption", "(", "CURLOPT_HEADER", ",", "TRUE", ")", ";", "if", "(", "self", "::", "$", "userAgent", ")", "$", "curl", "->", "setOption", "(", "CURLOPT_USERAGENT", ",", "self", "::", "$", "userAgent", ")", ";", "if", "(", "$", "this", "->", "username", ")", "$", "curl", "->", "setOption", "(", "CURLOPT_USERPWD", ",", "$", "this", "->", "username", ".", "\":\"", ".", "$", "this", "->", "password", ")", ";", "if", "(", "$", "this", "->", "proxyAddress", ")", "{", "$", "curl", "->", "setOption", "(", "CURLOPT_HTTPPROXYTUNNEL", ",", "TRUE", ")", ";", "$", "curl", "->", "setOption", "(", "CURLOPT_PROXY", ",", "$", "this", "->", "proxyAddress", ")", ";", "$", "curl", "->", "setOption", "(", "CURLOPT_PROXYTYPE", ",", "$", "this", "->", "proxyType", ")", ";", "if", "(", "$", "this", "->", "proxyAuth", ")", "$", "curl", "->", "setOption", "(", "CURLOPT_PROXYUSERPWD", ",", "$", "this", "->", "proxyAuth", ")", ";", "}", "foreach", "(", "$", "curlOptions", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "if", "(", "!", "(", "preg_match", "(", "\"@^CURLOPT_@\"", ",", "$", "key", ")", "&&", "defined", "(", "$", "key", ")", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Invalid option constant key \"'", ".", "$", "key", ".", "'\"'", ")", ";", "$", "key", "=", "constant", "(", "$", "key", ")", ";", "}", "if", "(", "!", "is_int", "(", "$", "key", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Option must be given as integer or string'", ")", ";", "$", "curl", "->", "setOption", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "result", "=", "$", "curl", "->", "exec", "(", "TRUE", ",", "FALSE", ")", ";", "$", "response", "=", "Net_HTTP_Response_Parser", "::", "fromString", "(", "$", "result", ")", ";", "$", "this", "->", "body", "=", "$", "response", "->", "getBody", "(", ")", ";", "$", "this", "->", "headers", "=", "$", "response", "->", "getHeaders", "(", ")", ";", "$", "this", "->", "info", "=", "$", "curl", "->", "getInfo", "(", ")", ";", "$", "code", "=", "$", "curl", "->", "getInfo", "(", "Net_CURL", "::", "INFO_HTTP_CODE", ")", ";", "$", "error", "=", "$", "curl", "->", "getInfo", "(", "Net_CURL", "::", "INFO_ERROR", ")", ";", "$", "errno", "=", "$", "curl", "->", "getInfo", "(", "Net_CURL", "::", "INFO_ERRNO", ")", ";", "if", "(", "$", "errno", ")", "throw", "new", "Exception_IO", "(", "'HTTP request failed: '", ".", "$", "error", ",", "$", "errno", ",", "$", "this", "->", "url", ")", ";", "if", "(", "!", "in_array", "(", "$", "code", ",", "array", "(", "'200'", ",", "'301'", ",", "'303'", ",", "'304'", ",", "'307'", ")", ")", ")", "throw", "new", "Exception_IO", "(", "'HTTP request failed'", ",", "$", "code", ",", "$", "this", "->", "url", ")", ";", "return", "$", "this", "->", "body", ";", "}" ]
Requests set URL and returns response. @access public @return string $curlOptions Map of cURL options @todo Auth
[ "Requests", "set", "URL", "and", "returns", "response", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Reader.php#L153-L199
37,247
CeusMedia/Common
src/UI/HTML/Panel.php
UI_HTML_Panel.build
public function build( $id, $theme = "default" ) { return $this->create( $id, $this->content, $this->header, $this->abstract, $this->footer, $theme, $this->attributes ); }
php
public function build( $id, $theme = "default" ) { return $this->create( $id, $this->content, $this->header, $this->abstract, $this->footer, $theme, $this->attributes ); }
[ "public", "function", "build", "(", "$", "id", ",", "$", "theme", "=", "\"default\"", ")", "{", "return", "$", "this", "->", "create", "(", "$", "id", ",", "$", "this", "->", "content", ",", "$", "this", "->", "header", ",", "$", "this", "->", "abstract", ",", "$", "this", "->", "footer", ",", "$", "theme", ",", "$", "this", "->", "attributes", ")", ";", "}" ]
Builds HTML Code of Panel after settings Contents using the set methods. @param string $id Tag ID of Panel @param string $theme Theme / additional CSS Class of Panel @return string
[ "Builds", "HTML", "Code", "of", "Panel", "after", "settings", "Contents", "using", "the", "set", "methods", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Panel.php#L78-L81
37,248
CeusMedia/Common
src/UI/HTML/Panel.php
UI_HTML_Panel.create
public static function create( $id, $content, $header, $abstract = NULL, $footer = NULL, $theme= "default", $attributes = array() ) { $divContInner = self::wrap( (string) $content, self::$classContentInner ); $divCont = self::wrap( $divContInner, self::$classContent ); $divAbstract = ""; $divHead = ""; $divFoot = ""; if( !is_null( $abstract ) ) { $divAbstractInner = self::wrap( $abstract, self::$classAbstractInner ); $divAbstract = self::wrap( $divAbstractInner, self::$classAbstract ); } if( !is_null( $footer ) ) { $divFootInner = self::wrap( $footer, self::$classFooterInner ); $divFoot = self::wrap( $divFootInner, self::$classFooter ); } if( !is_null( $header ) ) { $divHeadInner = self::wrap( $header, self::$classHeaderInner ); $divHead = self::wrap( $divHeadInner, self::$classHeader ); } $classes = $theme ? self::$classPanel." ".$theme : self::$classPanel; $attributes = array_merge( array( "id" => $id ), $attributes ); $divPanel = self::wrap( $divHead.$divAbstract.$divCont.$divFoot, $classes, $attributes ); return $divPanel; }
php
public static function create( $id, $content, $header, $abstract = NULL, $footer = NULL, $theme= "default", $attributes = array() ) { $divContInner = self::wrap( (string) $content, self::$classContentInner ); $divCont = self::wrap( $divContInner, self::$classContent ); $divAbstract = ""; $divHead = ""; $divFoot = ""; if( !is_null( $abstract ) ) { $divAbstractInner = self::wrap( $abstract, self::$classAbstractInner ); $divAbstract = self::wrap( $divAbstractInner, self::$classAbstract ); } if( !is_null( $footer ) ) { $divFootInner = self::wrap( $footer, self::$classFooterInner ); $divFoot = self::wrap( $divFootInner, self::$classFooter ); } if( !is_null( $header ) ) { $divHeadInner = self::wrap( $header, self::$classHeaderInner ); $divHead = self::wrap( $divHeadInner, self::$classHeader ); } $classes = $theme ? self::$classPanel." ".$theme : self::$classPanel; $attributes = array_merge( array( "id" => $id ), $attributes ); $divPanel = self::wrap( $divHead.$divAbstract.$divCont.$divFoot, $classes, $attributes ); return $divPanel; }
[ "public", "static", "function", "create", "(", "$", "id", ",", "$", "content", ",", "$", "header", ",", "$", "abstract", "=", "NULL", ",", "$", "footer", "=", "NULL", ",", "$", "theme", "=", "\"default\"", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "divContInner", "=", "self", "::", "wrap", "(", "(", "string", ")", "$", "content", ",", "self", "::", "$", "classContentInner", ")", ";", "$", "divCont", "=", "self", "::", "wrap", "(", "$", "divContInner", ",", "self", "::", "$", "classContent", ")", ";", "$", "divAbstract", "=", "\"\"", ";", "$", "divHead", "=", "\"\"", ";", "$", "divFoot", "=", "\"\"", ";", "if", "(", "!", "is_null", "(", "$", "abstract", ")", ")", "{", "$", "divAbstractInner", "=", "self", "::", "wrap", "(", "$", "abstract", ",", "self", "::", "$", "classAbstractInner", ")", ";", "$", "divAbstract", "=", "self", "::", "wrap", "(", "$", "divAbstractInner", ",", "self", "::", "$", "classAbstract", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "footer", ")", ")", "{", "$", "divFootInner", "=", "self", "::", "wrap", "(", "$", "footer", ",", "self", "::", "$", "classFooterInner", ")", ";", "$", "divFoot", "=", "self", "::", "wrap", "(", "$", "divFootInner", ",", "self", "::", "$", "classFooter", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "header", ")", ")", "{", "$", "divHeadInner", "=", "self", "::", "wrap", "(", "$", "header", ",", "self", "::", "$", "classHeaderInner", ")", ";", "$", "divHead", "=", "self", "::", "wrap", "(", "$", "divHeadInner", ",", "self", "::", "$", "classHeader", ")", ";", "}", "$", "classes", "=", "$", "theme", "?", "self", "::", "$", "classPanel", ".", "\" \"", ".", "$", "theme", ":", "self", "::", "$", "classPanel", ";", "$", "attributes", "=", "array_merge", "(", "array", "(", "\"id\"", "=>", "$", "id", ")", ",", "$", "attributes", ")", ";", "$", "divPanel", "=", "self", "::", "wrap", "(", "$", "divHead", ".", "$", "divAbstract", ".", "$", "divCont", ".", "$", "divFoot", ",", "$", "classes", ",", "$", "attributes", ")", ";", "return", "$", "divPanel", ";", "}" ]
Builds HTML Code of Panel statically. @access public @static @param string $id Tag ID of Panel @param string $content Content of Panel @param string $header Content of Header @param string $abstract Content of Abstract @param string $footer Content of Footer @param string $theme Theme / additional CSS Class of Panel @param array $attributes Map of Attributes of Panel DIV @return string
[ "Builds", "HTML", "Code", "of", "Panel", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Panel.php#L96-L124
37,249
CeusMedia/Common
src/UI/HTML/Panel.php
UI_HTML_Panel.wrap
protected static function wrap( $content, $class, $attributes = array() ) { $attributes = array_merge( $attributes, array( 'class' => $class ) ); return UI_HTML_Tag::create( "div", $content, $attributes ); }
php
protected static function wrap( $content, $class, $attributes = array() ) { $attributes = array_merge( $attributes, array( 'class' => $class ) ); return UI_HTML_Tag::create( "div", $content, $attributes ); }
[ "protected", "static", "function", "wrap", "(", "$", "content", ",", "$", "class", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "attributes", "=", "array_merge", "(", "$", "attributes", ",", "array", "(", "'class'", "=>", "$", "class", ")", ")", ";", "return", "UI_HTML_Tag", "::", "create", "(", "\"div\"", ",", "$", "content", ",", "$", "attributes", ")", ";", "}" ]
Wraps Content in DIV. @access protected @static @param string $content ... @param string $class CSS Class of DIV @param array $attributes Array of Attributes @return string
[ "Wraps", "Content", "in", "DIV", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Panel.php#L203-L207
37,250
CeusMedia/Common
src/FS/File/ICal/Builder.php
FS_File_Ical_Builder.build
public function build( $tree ) { $lines = array(); $children = $tree->getChildren(); foreach( $children as $child ) foreach( self::buildRecursive( $child ) as $line ) $lines[] = $line; return implode( self::$lineBreak, $lines ); }
php
public function build( $tree ) { $lines = array(); $children = $tree->getChildren(); foreach( $children as $child ) foreach( self::buildRecursive( $child ) as $line ) $lines[] = $line; return implode( self::$lineBreak, $lines ); }
[ "public", "function", "build", "(", "$", "tree", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "$", "children", "=", "$", "tree", "->", "getChildren", "(", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "foreach", "(", "self", "::", "buildRecursive", "(", "$", "child", ")", "as", "$", "line", ")", "$", "lines", "[", "]", "=", "$", "line", ";", "return", "implode", "(", "self", "::", "$", "lineBreak", ",", "$", "lines", ")", ";", "}" ]
Builds Array of iCal Lines from XML Tree. @access public @param XML_DOM_Node $tree XML Tree @return array
[ "Builds", "Array", "of", "iCal", "Lines", "from", "XML", "Tree", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/ICal/Builder.php#L66-L74
37,251
CeusMedia/Common
src/FS/File/ICal/Builder.php
FS_File_Ical_Builder.buildLine
protected static function buildLine( $name, $param, $content ) { $params = array(); foreach( $param as $key => $value ) $params[] = strtoupper( trim( $key ) )."=".$value; $param = implode( ",", $params ); if( $param ) { $param = " ;".$param; if( strlen( $param ) > 75 ) { $rest = $param; $param = ""; while( strlen( $rest ) > 75 ) { $param .= substr( $rest, 0, 74 ).self::$lineBreak; $rest = " ".substr( $rest, 74 ); } } $param = self::$lineBreak.$param; } $content = ":".$content; if( strlen( $content ) > 75 ) { $rest = $content; $content = ""; while( strlen( $rest ) > 75 ) { $content .= substr( $rest, 0, 74 ).self::$lineBreak; $rest = " ".substr( $rest, 74 ); } } $line = strtoupper( $name ).$param.$content; $line = $line; return $line; }
php
protected static function buildLine( $name, $param, $content ) { $params = array(); foreach( $param as $key => $value ) $params[] = strtoupper( trim( $key ) )."=".$value; $param = implode( ",", $params ); if( $param ) { $param = " ;".$param; if( strlen( $param ) > 75 ) { $rest = $param; $param = ""; while( strlen( $rest ) > 75 ) { $param .= substr( $rest, 0, 74 ).self::$lineBreak; $rest = " ".substr( $rest, 74 ); } } $param = self::$lineBreak.$param; } $content = ":".$content; if( strlen( $content ) > 75 ) { $rest = $content; $content = ""; while( strlen( $rest ) > 75 ) { $content .= substr( $rest, 0, 74 ).self::$lineBreak; $rest = " ".substr( $rest, 74 ); } } $line = strtoupper( $name ).$param.$content; $line = $line; return $line; }
[ "protected", "static", "function", "buildLine", "(", "$", "name", ",", "$", "param", ",", "$", "content", ")", "{", "$", "params", "=", "array", "(", ")", ";", "foreach", "(", "$", "param", "as", "$", "key", "=>", "$", "value", ")", "$", "params", "[", "]", "=", "strtoupper", "(", "trim", "(", "$", "key", ")", ")", ".", "\"=\"", ".", "$", "value", ";", "$", "param", "=", "implode", "(", "\",\"", ",", "$", "params", ")", ";", "if", "(", "$", "param", ")", "{", "$", "param", "=", "\" ;\"", ".", "$", "param", ";", "if", "(", "strlen", "(", "$", "param", ")", ">", "75", ")", "{", "$", "rest", "=", "$", "param", ";", "$", "param", "=", "\"\"", ";", "while", "(", "strlen", "(", "$", "rest", ")", ">", "75", ")", "{", "$", "param", ".=", "substr", "(", "$", "rest", ",", "0", ",", "74", ")", ".", "self", "::", "$", "lineBreak", ";", "$", "rest", "=", "\" \"", ".", "substr", "(", "$", "rest", ",", "74", ")", ";", "}", "}", "$", "param", "=", "self", "::", "$", "lineBreak", ".", "$", "param", ";", "}", "$", "content", "=", "\":\"", ".", "$", "content", ";", "if", "(", "strlen", "(", "$", "content", ")", ">", "75", ")", "{", "$", "rest", "=", "$", "content", ";", "$", "content", "=", "\"\"", ";", "while", "(", "strlen", "(", "$", "rest", ")", ">", "75", ")", "{", "$", "content", ".=", "substr", "(", "$", "rest", ",", "0", ",", "74", ")", ".", "self", "::", "$", "lineBreak", ";", "$", "rest", "=", "\" \"", ".", "substr", "(", "$", "rest", ",", "74", ")", ";", "}", "}", "$", "line", "=", "strtoupper", "(", "$", "name", ")", ".", "$", "param", ".", "$", "content", ";", "$", "line", "=", "$", "line", ";", "return", "$", "line", ";", "}" ]
Builds iCal Line. @access protected @static @param string name Line Name @param array param Line Parameters @param string content Line Value @return string
[ "Builds", "iCal", "Line", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/ICal/Builder.php#L85-L122
37,252
CeusMedia/Common
src/FS/File/ICal/Builder.php
FS_File_Ical_Builder.buildRecursive
protected static function buildRecursive( $node ) { $lines = array(); $name = $node->getNodeName(); $value = $node->getContent(); $param = $node->getAttributes(); if( NULL === $value ) { $lines[] = "BEGIN:".strtoupper( $name ); $children = $node->getChildren(); foreach( $children as $child ) foreach( self::buildRecursive( $child ) as $line ) $lines[] = $line; $lines[] = "END:".strtoupper( $name ); } else $lines[] = self::buildLine( $name, $param, $value ); return $lines; }
php
protected static function buildRecursive( $node ) { $lines = array(); $name = $node->getNodeName(); $value = $node->getContent(); $param = $node->getAttributes(); if( NULL === $value ) { $lines[] = "BEGIN:".strtoupper( $name ); $children = $node->getChildren(); foreach( $children as $child ) foreach( self::buildRecursive( $child ) as $line ) $lines[] = $line; $lines[] = "END:".strtoupper( $name ); } else $lines[] = self::buildLine( $name, $param, $value ); return $lines; }
[ "protected", "static", "function", "buildRecursive", "(", "$", "node", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "$", "name", "=", "$", "node", "->", "getNodeName", "(", ")", ";", "$", "value", "=", "$", "node", "->", "getContent", "(", ")", ";", "$", "param", "=", "$", "node", "->", "getAttributes", "(", ")", ";", "if", "(", "NULL", "===", "$", "value", ")", "{", "$", "lines", "[", "]", "=", "\"BEGIN:\"", ".", "strtoupper", "(", "$", "name", ")", ";", "$", "children", "=", "$", "node", "->", "getChildren", "(", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "foreach", "(", "self", "::", "buildRecursive", "(", "$", "child", ")", "as", "$", "line", ")", "$", "lines", "[", "]", "=", "$", "line", ";", "$", "lines", "[", "]", "=", "\"END:\"", ".", "strtoupper", "(", "$", "name", ")", ";", "}", "else", "$", "lines", "[", "]", "=", "self", "::", "buildLine", "(", "$", "name", ",", "$", "param", ",", "$", "value", ")", ";", "return", "$", "lines", ";", "}" ]
Builds Array of iCal Lines from XML Tree recursive. @access protected @static @param XML_DOM_Node node XML Node @return array
[ "Builds", "Array", "of", "iCal", "Lines", "from", "XML", "Tree", "recursive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/ICal/Builder.php#L131-L149
37,253
meritoo/common-library
src/Utilities/Uri.php
Uri.getFullUri
public static function getFullUri($withoutHost = false) { $requestedUrl = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'REQUEST_URI'); /* * Unknown requested url? * Nothing to do */ if (empty($requestedUrl)) { return ''; } /* * Without host / server name? * All is done */ if ($withoutHost) { return $requestedUrl; } return self::getServerNameOrIp(true) . $requestedUrl; }
php
public static function getFullUri($withoutHost = false) { $requestedUrl = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'REQUEST_URI'); /* * Unknown requested url? * Nothing to do */ if (empty($requestedUrl)) { return ''; } /* * Without host / server name? * All is done */ if ($withoutHost) { return $requestedUrl; } return self::getServerNameOrIp(true) . $requestedUrl; }
[ "public", "static", "function", "getFullUri", "(", "$", "withoutHost", "=", "false", ")", "{", "$", "requestedUrl", "=", "Miscellaneous", "::", "getSafelyGlobalVariable", "(", "INPUT_SERVER", ",", "'REQUEST_URI'", ")", ";", "/*\n * Unknown requested url?\n * Nothing to do\n */", "if", "(", "empty", "(", "$", "requestedUrl", ")", ")", "{", "return", "''", ";", "}", "/*\n * Without host / server name?\n * All is done\n */", "if", "(", "$", "withoutHost", ")", "{", "return", "$", "requestedUrl", ";", "}", "return", "self", "::", "getServerNameOrIp", "(", "true", ")", ".", "$", "requestedUrl", ";", "}" ]
Returns full uri string @param bool $withoutHost (optional) If is set to true, means that host / server name is omitted @return string
[ "Returns", "full", "uri", "string" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L25-L46
37,254
meritoo/common-library
src/Utilities/Uri.php
Uri.getServerNameOrIp
public static function getServerNameOrIp($withProtocol = false) { $host = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'HTTP_HOST'); /* * Unknown host / server? * Nothing to do */ if (empty($host)) { return ''; } /* * With protocol? * Let's include the protocol */ if ($withProtocol) { return sprintf('%s://%s', self::getProtocolName(), $host); } return $host; }
php
public static function getServerNameOrIp($withProtocol = false) { $host = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'HTTP_HOST'); /* * Unknown host / server? * Nothing to do */ if (empty($host)) { return ''; } /* * With protocol? * Let's include the protocol */ if ($withProtocol) { return sprintf('%s://%s', self::getProtocolName(), $host); } return $host; }
[ "public", "static", "function", "getServerNameOrIp", "(", "$", "withProtocol", "=", "false", ")", "{", "$", "host", "=", "Miscellaneous", "::", "getSafelyGlobalVariable", "(", "INPUT_SERVER", ",", "'HTTP_HOST'", ")", ";", "/*\n * Unknown host / server?\n * Nothing to do\n */", "if", "(", "empty", "(", "$", "host", ")", ")", "{", "return", "''", ";", "}", "/*\n * With protocol?\n * Let's include the protocol\n */", "if", "(", "$", "withProtocol", ")", "{", "return", "sprintf", "(", "'%s://%s'", ",", "self", "::", "getProtocolName", "(", ")", ",", "$", "host", ")", ";", "}", "return", "$", "host", ";", "}" ]
Returns server name or IP address @param bool $withProtocol (optional) If is set to true, protocol name is included. Otherwise isn't. @return string
[ "Returns", "server", "name", "or", "IP", "address" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L54-L75
37,255
meritoo/common-library
src/Utilities/Uri.php
Uri.getProtocolName
public static function getProtocolName() { $matches = []; $protocolData = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'SERVER_PROTOCOL'); // e.g. HTTP/1.1 $matchCount = preg_match('|(.+)\/(.+)|', $protocolData, $matches); /* * $matches[1] - protocol name, e.g. HTTP * $matches[2] - protocol version, e.g. 1.1 */ // Oops, cannot match protocol if (0 === $matchCount) { return ''; } return strtolower($matches[1]); }
php
public static function getProtocolName() { $matches = []; $protocolData = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'SERVER_PROTOCOL'); // e.g. HTTP/1.1 $matchCount = preg_match('|(.+)\/(.+)|', $protocolData, $matches); /* * $matches[1] - protocol name, e.g. HTTP * $matches[2] - protocol version, e.g. 1.1 */ // Oops, cannot match protocol if (0 === $matchCount) { return ''; } return strtolower($matches[1]); }
[ "public", "static", "function", "getProtocolName", "(", ")", "{", "$", "matches", "=", "[", "]", ";", "$", "protocolData", "=", "Miscellaneous", "::", "getSafelyGlobalVariable", "(", "INPUT_SERVER", ",", "'SERVER_PROTOCOL'", ")", ";", "// e.g. HTTP/1.1", "$", "matchCount", "=", "preg_match", "(", "'|(.+)\\/(.+)|'", ",", "$", "protocolData", ",", "$", "matches", ")", ";", "/*\n * $matches[1] - protocol name, e.g. HTTP\n * $matches[2] - protocol version, e.g. 1.1\n */", "// Oops, cannot match protocol", "if", "(", "0", "===", "$", "matchCount", ")", "{", "return", "''", ";", "}", "return", "strtolower", "(", "$", "matches", "[", "1", "]", ")", ";", "}" ]
Returns protocol name @return string
[ "Returns", "protocol", "name" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L82-L99
37,256
meritoo/common-library
src/Utilities/Uri.php
Uri.getUserWebBrowserName
public static function getUserWebBrowserName($withVersion = false) { $info = self::getUserWebBrowserInfo(); $knownBrowsers = [ 'Firefox/([\d\.]+)$' => 'Mozilla Firefox', 'OPR/([\d\.]+)$' => 'Opera', 'Chrome/([\d\.]+)$' => 'Google Chrome', 'Safari/([\d\.]+)$' => 'Apple Safari', ]; foreach ($knownBrowsers as $pattern => $browserName) { $matches = []; $matchCount = preg_match(sprintf('|%s|', $pattern), $info, $matches); if ($matchCount > 0) { if ($withVersion) { $version = $matches[1]; return sprintf('%s %s', $browserName, $version); } return $browserName; } } return ''; }
php
public static function getUserWebBrowserName($withVersion = false) { $info = self::getUserWebBrowserInfo(); $knownBrowsers = [ 'Firefox/([\d\.]+)$' => 'Mozilla Firefox', 'OPR/([\d\.]+)$' => 'Opera', 'Chrome/([\d\.]+)$' => 'Google Chrome', 'Safari/([\d\.]+)$' => 'Apple Safari', ]; foreach ($knownBrowsers as $pattern => $browserName) { $matches = []; $matchCount = preg_match(sprintf('|%s|', $pattern), $info, $matches); if ($matchCount > 0) { if ($withVersion) { $version = $matches[1]; return sprintf('%s %s', $browserName, $version); } return $browserName; } } return ''; }
[ "public", "static", "function", "getUserWebBrowserName", "(", "$", "withVersion", "=", "false", ")", "{", "$", "info", "=", "self", "::", "getUserWebBrowserInfo", "(", ")", ";", "$", "knownBrowsers", "=", "[", "'Firefox/([\\d\\.]+)$'", "=>", "'Mozilla Firefox'", ",", "'OPR/([\\d\\.]+)$'", "=>", "'Opera'", ",", "'Chrome/([\\d\\.]+)$'", "=>", "'Google Chrome'", ",", "'Safari/([\\d\\.]+)$'", "=>", "'Apple Safari'", ",", "]", ";", "foreach", "(", "$", "knownBrowsers", "as", "$", "pattern", "=>", "$", "browserName", ")", "{", "$", "matches", "=", "[", "]", ";", "$", "matchCount", "=", "preg_match", "(", "sprintf", "(", "'|%s|'", ",", "$", "pattern", ")", ",", "$", "info", ",", "$", "matches", ")", ";", "if", "(", "$", "matchCount", ">", "0", ")", "{", "if", "(", "$", "withVersion", ")", "{", "$", "version", "=", "$", "matches", "[", "1", "]", ";", "return", "sprintf", "(", "'%s %s'", ",", "$", "browserName", ",", "$", "version", ")", ";", "}", "return", "$", "browserName", ";", "}", "}", "return", "''", ";", "}" ]
Returns name and version of user's web browser @param bool $withVersion (optional) If is set to true, version of the browser is returned too. Otherwise - name only. @return string
[ "Returns", "name", "and", "version", "of", "user", "s", "web", "browser" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L128-L155
37,257
meritoo/common-library
src/Utilities/Uri.php
Uri.getUserOperatingSystemName
public static function getUserOperatingSystemName() { $info = self::getUserWebBrowserInfo(); $knownSystems = [ 'Linux' => 'Linux', 'Win' => 'Windows', 'Mac' => 'Mac OS', ]; foreach ($knownSystems as $pattern => $systemName) { $matches = []; $matchCount = preg_match(sprintf('|%s|', $pattern), $info, $matches); if ($matchCount > 0) { return $systemName; } } return ''; }
php
public static function getUserOperatingSystemName() { $info = self::getUserWebBrowserInfo(); $knownSystems = [ 'Linux' => 'Linux', 'Win' => 'Windows', 'Mac' => 'Mac OS', ]; foreach ($knownSystems as $pattern => $systemName) { $matches = []; $matchCount = preg_match(sprintf('|%s|', $pattern), $info, $matches); if ($matchCount > 0) { return $systemName; } } return ''; }
[ "public", "static", "function", "getUserOperatingSystemName", "(", ")", "{", "$", "info", "=", "self", "::", "getUserWebBrowserInfo", "(", ")", ";", "$", "knownSystems", "=", "[", "'Linux'", "=>", "'Linux'", ",", "'Win'", "=>", "'Windows'", ",", "'Mac'", "=>", "'Mac OS'", ",", "]", ";", "foreach", "(", "$", "knownSystems", "as", "$", "pattern", "=>", "$", "systemName", ")", "{", "$", "matches", "=", "[", "]", ";", "$", "matchCount", "=", "preg_match", "(", "sprintf", "(", "'|%s|'", ",", "$", "pattern", ")", ",", "$", "info", ",", "$", "matches", ")", ";", "if", "(", "$", "matchCount", ">", "0", ")", "{", "return", "$", "systemName", ";", "}", "}", "return", "''", ";", "}" ]
Returns name of user's operating system @return string
[ "Returns", "name", "of", "user", "s", "operating", "system" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L188-L208
37,258
meritoo/common-library
src/Utilities/Uri.php
Uri.replenishProtocol
public static function replenishProtocol($url, $protocol = '') { // Let's trim the url if (is_string($url)) { $url = trim($url); } /* * Url is not provided? * Nothing to do */ if (empty($url)) { return ''; } /* * It's a valid url? * Let's return it */ if (Regex::isValidUrl($url, true)) { return $url; } // Protocol is not provided? if (empty($protocol)) { $protocol = self::getProtocolName(); } return sprintf('%s://%s', $protocol, $url); }
php
public static function replenishProtocol($url, $protocol = '') { // Let's trim the url if (is_string($url)) { $url = trim($url); } /* * Url is not provided? * Nothing to do */ if (empty($url)) { return ''; } /* * It's a valid url? * Let's return it */ if (Regex::isValidUrl($url, true)) { return $url; } // Protocol is not provided? if (empty($protocol)) { $protocol = self::getProtocolName(); } return sprintf('%s://%s', $protocol, $url); }
[ "public", "static", "function", "replenishProtocol", "(", "$", "url", ",", "$", "protocol", "=", "''", ")", "{", "// Let's trim the url", "if", "(", "is_string", "(", "$", "url", ")", ")", "{", "$", "url", "=", "trim", "(", "$", "url", ")", ";", "}", "/*\n * Url is not provided?\n * Nothing to do\n */", "if", "(", "empty", "(", "$", "url", ")", ")", "{", "return", "''", ";", "}", "/*\n * It's a valid url?\n * Let's return it\n */", "if", "(", "Regex", "::", "isValidUrl", "(", "$", "url", ",", "true", ")", ")", "{", "return", "$", "url", ";", "}", "// Protocol is not provided?", "if", "(", "empty", "(", "$", "protocol", ")", ")", "{", "$", "protocol", "=", "self", "::", "getProtocolName", "(", ")", ";", "}", "return", "sprintf", "(", "'%s://%s'", ",", "$", "protocol", ",", "$", "url", ")", ";", "}" ]
Replenishes protocol in the given url @param string $url The url to check and replenish @param string $protocol (optional) The protocol which is replenished. If is empty, protocol of current request is used. @return string
[ "Replenishes", "protocol", "in", "the", "given", "url" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L271-L300
37,259
meritoo/common-library
src/Utilities/Uri.php
Uri.getSecuredUrl
public static function getSecuredUrl($url, $user = '', $password = '') { /* * Url is not provided? * Nothing to do */ if (empty($url)) { return ''; } $protocol = self::getProtocolName(); $host = self::getServerNameOrIp(); if (!Regex::startsWith($url, '/')) { $url = sprintf('/%s', $url); } $url = $host . $url; if (!empty($user) && !empty($password)) { $url = sprintf('%s:%s@%s', $user, $password, $url); } return sprintf('%s://%s', $protocol, $url); }
php
public static function getSecuredUrl($url, $user = '', $password = '') { /* * Url is not provided? * Nothing to do */ if (empty($url)) { return ''; } $protocol = self::getProtocolName(); $host = self::getServerNameOrIp(); if (!Regex::startsWith($url, '/')) { $url = sprintf('/%s', $url); } $url = $host . $url; if (!empty($user) && !empty($password)) { $url = sprintf('%s:%s@%s', $user, $password, $url); } return sprintf('%s://%s', $protocol, $url); }
[ "public", "static", "function", "getSecuredUrl", "(", "$", "url", ",", "$", "user", "=", "''", ",", "$", "password", "=", "''", ")", "{", "/*\n * Url is not provided?\n * Nothing to do\n */", "if", "(", "empty", "(", "$", "url", ")", ")", "{", "return", "''", ";", "}", "$", "protocol", "=", "self", "::", "getProtocolName", "(", ")", ";", "$", "host", "=", "self", "::", "getServerNameOrIp", "(", ")", ";", "if", "(", "!", "Regex", "::", "startsWith", "(", "$", "url", ",", "'/'", ")", ")", "{", "$", "url", "=", "sprintf", "(", "'/%s'", ",", "$", "url", ")", ";", "}", "$", "url", "=", "$", "host", ".", "$", "url", ";", "if", "(", "!", "empty", "(", "$", "user", ")", "&&", "!", "empty", "(", "$", "password", ")", ")", "{", "$", "url", "=", "sprintf", "(", "'%s:%s@%s'", ",", "$", "user", ",", "$", "password", ",", "$", "url", ")", ";", "}", "return", "sprintf", "(", "'%s://%s'", ",", "$", "protocol", ",", "$", "url", ")", ";", "}" ]
Returns url to resource secured by given htpasswd login and password @param string $url A path / url to some resource, e.g. page, image, css file @param string $user (optional) User name used to log in @param string $password (optional) User password used to log in @return string
[ "Returns", "url", "to", "resource", "secured", "by", "given", "htpasswd", "login", "and", "password" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L310-L334
37,260
meritoo/common-library
src/Utilities/Uri.php
Uri.addProtocolToUrl
public static function addProtocolToUrl($url, $protocol = 'http') { $pattern = sprintf('/^%s.*/', $protocol); if ((bool)preg_match($pattern, $url)) { return $url; } return sprintf('%s://%s', $protocol, $url); }
php
public static function addProtocolToUrl($url, $protocol = 'http') { $pattern = sprintf('/^%s.*/', $protocol); if ((bool)preg_match($pattern, $url)) { return $url; } return sprintf('%s://%s', $protocol, $url); }
[ "public", "static", "function", "addProtocolToUrl", "(", "$", "url", ",", "$", "protocol", "=", "'http'", ")", "{", "$", "pattern", "=", "sprintf", "(", "'/^%s.*/'", ",", "$", "protocol", ")", ";", "if", "(", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "$", "url", ")", ")", "{", "return", "$", "url", ";", "}", "return", "sprintf", "(", "'%s://%s'", ",", "$", "protocol", ",", "$", "url", ")", ";", "}" ]
Adds protocol to given url, if the url does not contain given protocol. Returns the new url. @param string $url Url string @param string $protocol (optional) Protocol string @return string
[ "Adds", "protocol", "to", "given", "url", "if", "the", "url", "does", "not", "contain", "given", "protocol", ".", "Returns", "the", "new", "url", "." ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L344-L353
37,261
CeusMedia/Common
src/XML/RPC/Client.php
XML_RPC_Client.call
public function call( $method, $parameters ){ $params = array(); foreach( $parameters as $parameter ) $params[] = '<param>'.self::encodeXmlParameter( $parameter ).'</param>'; $method = '<methodName>'.$method.'</methodName>'; $params = '<params>'.join( $params ).'</params>'; $call = '<methodCall>'.$method.$params.'</methodCall>'; return self::parseResponse( Net_HTTP_Post::sendData( $this->url, $call ) ); }
php
public function call( $method, $parameters ){ $params = array(); foreach( $parameters as $parameter ) $params[] = '<param>'.self::encodeXmlParameter( $parameter ).'</param>'; $method = '<methodName>'.$method.'</methodName>'; $params = '<params>'.join( $params ).'</params>'; $call = '<methodCall>'.$method.$params.'</methodCall>'; return self::parseResponse( Net_HTTP_Post::sendData( $this->url, $call ) ); }
[ "public", "function", "call", "(", "$", "method", ",", "$", "parameters", ")", "{", "$", "params", "=", "array", "(", ")", ";", "foreach", "(", "$", "parameters", "as", "$", "parameter", ")", "$", "params", "[", "]", "=", "'<param>'", ".", "self", "::", "encodeXmlParameter", "(", "$", "parameter", ")", ".", "'</param>'", ";", "$", "method", "=", "'<methodName>'", ".", "$", "method", ".", "'</methodName>'", ";", "$", "params", "=", "'<params>'", ".", "join", "(", "$", "params", ")", ".", "'</params>'", ";", "$", "call", "=", "'<methodCall>'", ".", "$", "method", ".", "$", "params", ".", "'</methodCall>'", ";", "return", "self", "::", "parseResponse", "(", "Net_HTTP_Post", "::", "sendData", "(", "$", "this", "->", "url", ",", "$", "call", ")", ")", ";", "}" ]
Calls XML-RPC method with parameters and returns resulting answer data. @access public @param string $method Method XML-RPC @param array $parameters List of method parameters @return mixed
[ "Calls", "XML", "-", "RPC", "method", "with", "parameters", "and", "returns", "resulting", "answer", "data", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/RPC/Client.php#L65-L73
37,262
CeusMedia/Common
src/UI/Image/EvolutionGraph.php
UI_Image_EvolutionGraph.addGraph
public function addGraph( $legend, $color, $data ) { $position = count( $this->graphs ); $this->graphs[$position] = array( 'legend' => $legend, 'color' => $color, 'values' => $data, ); }
php
public function addGraph( $legend, $color, $data ) { $position = count( $this->graphs ); $this->graphs[$position] = array( 'legend' => $legend, 'color' => $color, 'values' => $data, ); }
[ "public", "function", "addGraph", "(", "$", "legend", ",", "$", "color", ",", "$", "data", ")", "{", "$", "position", "=", "count", "(", "$", "this", "->", "graphs", ")", ";", "$", "this", "->", "graphs", "[", "$", "position", "]", "=", "array", "(", "'legend'", "=>", "$", "legend", ",", "'color'", "=>", "$", "color", ",", "'values'", "=>", "$", "data", ",", ")", ";", "}" ]
Adds another Graph with Legend, Line Color and Values. @access public @param string $legend Legend Label of Graph @param array $color Array of RGB-Values @param array $data Array of Values of Graph @return void
[ "Adds", "another", "Graph", "with", "Legend", "Line", "Color", "and", "Values", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/EvolutionGraph.php#L93-L101
37,263
Assasz/yggdrasil
src/Yggdrasil/Core/Driver/DriverCollection.php
DriverCollection.add
public function add(string $key, string $driver): void { if (!in_array(DriverInterface::class, class_implements($driver))) { throw new NotDriverProvidedException($key . ' is not a driver.'); } $this->drivers[$key] = $driver; }
php
public function add(string $key, string $driver): void { if (!in_array(DriverInterface::class, class_implements($driver))) { throw new NotDriverProvidedException($key . ' is not a driver.'); } $this->drivers[$key] = $driver; }
[ "public", "function", "add", "(", "string", "$", "key", ",", "string", "$", "driver", ")", ":", "void", "{", "if", "(", "!", "in_array", "(", "DriverInterface", "::", "class", ",", "class_implements", "(", "$", "driver", ")", ")", ")", "{", "throw", "new", "NotDriverProvidedException", "(", "$", "key", ".", "' is not a driver.'", ")", ";", "}", "$", "this", "->", "drivers", "[", "$", "key", "]", "=", "$", "driver", ";", "}" ]
Adds driver to collection @param string $key Name of driver @param string $driver @throws NotDriverProvidedException if given object is of another instance than DriverInterface
[ "Adds", "driver", "to", "collection" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Driver/DriverCollection.php#L61-L68
37,264
Assasz/yggdrasil
src/Yggdrasil/Core/Driver/DriverCollection.php
DriverCollection.get
public function get(string $key): DriverInterface { if (!$this->has($key)) { throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.'); } return $this->drivers[$key]::install($this->appConfiguration); }
php
public function get(string $key): DriverInterface { if (!$this->has($key)) { throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.'); } return $this->drivers[$key]::install($this->appConfiguration); }
[ "public", "function", "get", "(", "string", "$", "key", ")", ":", "DriverInterface", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "throw", "new", "DriverNotFoundException", "(", "'Driver you are looking for doesn\\'t exist. Make sure that '", ".", "$", "key", ".", "' driver is properly configured.'", ")", ";", "}", "return", "$", "this", "->", "drivers", "[", "$", "key", "]", "::", "install", "(", "$", "this", "->", "appConfiguration", ")", ";", "}" ]
Returns configured driver instance This method in fact 'installs' driver in application @param string $key Name of driver @return DriverInterface @throws DriverNotFoundException if requested driver doesn't exist
[ "Returns", "configured", "driver", "instance", "This", "method", "in", "fact", "installs", "driver", "in", "application" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Driver/DriverCollection.php#L78-L85
37,265
Assasz/yggdrasil
src/Yggdrasil/Core/Driver/DriverCollection.php
DriverCollection.remove
public function remove(string $key): void { if (!$this->has($key)) { throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.'); } unset($this->drivers[$key]); }
php
public function remove(string $key): void { if (!$this->has($key)) { throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.'); } unset($this->drivers[$key]); }
[ "public", "function", "remove", "(", "string", "$", "key", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "throw", "new", "DriverNotFoundException", "(", "'Driver you are looking for doesn\\'t exist. Make sure that '", ".", "$", "key", ".", "' driver is properly configured.'", ")", ";", "}", "unset", "(", "$", "this", "->", "drivers", "[", "$", "key", "]", ")", ";", "}" ]
Removes given driver from collection Better way to do that is removing driver from AppConfiguration registry, but it was easy to implement @param string $key Name of driver @throws DriverNotFoundException if requested driver doesn't exist
[ "Removes", "given", "driver", "from", "collection", "Better", "way", "to", "do", "that", "is", "removing", "driver", "from", "AppConfiguration", "registry", "but", "it", "was", "easy", "to", "implement" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Driver/DriverCollection.php#L105-L112
37,266
CeusMedia/Common
src/UI/HTML/Tree/Menu.php
UI_HTML_Tree_Menu.buildMenuRecursive
protected function buildMenuRecursive( ADT_Tree_Menu_List $tree, $level = 1 ) { $list = array(); foreach( $tree->getChildren() as $child ) { $class = $child->getAttributes()->get( 'class' ); $label = $child->label; if( !empty( $child->url ) ) $label = UI_HTML_Elements::Link( $child->url, $child->label, $class, $this->target ); else $label = UI_HTML_Tag::create( 'span', $child->label ); $sublist = ""; if( $child->hasChildren() ) $sublist = "\n".$this->buildMenuRecursive( $child, $level+1 ); $classes = array( 'level-'.$level ); if( $child->hasChildren() ) $classes[] = "parent"; $class = implode( " ", $classes ); $list[] = UI_HTML_Elements::ListItem( $label.$sublist, $level, array( 'class' => $class ) ); } $list = UI_HTML_Elements::unorderedList( $list, $level ); return $list; }
php
protected function buildMenuRecursive( ADT_Tree_Menu_List $tree, $level = 1 ) { $list = array(); foreach( $tree->getChildren() as $child ) { $class = $child->getAttributes()->get( 'class' ); $label = $child->label; if( !empty( $child->url ) ) $label = UI_HTML_Elements::Link( $child->url, $child->label, $class, $this->target ); else $label = UI_HTML_Tag::create( 'span', $child->label ); $sublist = ""; if( $child->hasChildren() ) $sublist = "\n".$this->buildMenuRecursive( $child, $level+1 ); $classes = array( 'level-'.$level ); if( $child->hasChildren() ) $classes[] = "parent"; $class = implode( " ", $classes ); $list[] = UI_HTML_Elements::ListItem( $label.$sublist, $level, array( 'class' => $class ) ); } $list = UI_HTML_Elements::unorderedList( $list, $level ); return $list; }
[ "protected", "function", "buildMenuRecursive", "(", "ADT_Tree_Menu_List", "$", "tree", ",", "$", "level", "=", "1", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "tree", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "$", "class", "=", "$", "child", "->", "getAttributes", "(", ")", "->", "get", "(", "'class'", ")", ";", "$", "label", "=", "$", "child", "->", "label", ";", "if", "(", "!", "empty", "(", "$", "child", "->", "url", ")", ")", "$", "label", "=", "UI_HTML_Elements", "::", "Link", "(", "$", "child", "->", "url", ",", "$", "child", "->", "label", ",", "$", "class", ",", "$", "this", "->", "target", ")", ";", "else", "$", "label", "=", "UI_HTML_Tag", "::", "create", "(", "'span'", ",", "$", "child", "->", "label", ")", ";", "$", "sublist", "=", "\"\"", ";", "if", "(", "$", "child", "->", "hasChildren", "(", ")", ")", "$", "sublist", "=", "\"\\n\"", ".", "$", "this", "->", "buildMenuRecursive", "(", "$", "child", ",", "$", "level", "+", "1", ")", ";", "$", "classes", "=", "array", "(", "'level-'", ".", "$", "level", ")", ";", "if", "(", "$", "child", "->", "hasChildren", "(", ")", ")", "$", "classes", "[", "]", "=", "\"parent\"", ";", "$", "class", "=", "implode", "(", "\" \"", ",", "$", "classes", ")", ";", "$", "list", "[", "]", "=", "UI_HTML_Elements", "::", "ListItem", "(", "$", "label", ".", "$", "sublist", ",", "$", "level", ",", "array", "(", "'class'", "=>", "$", "class", ")", ")", ";", "}", "$", "list", "=", "UI_HTML_Elements", "::", "unorderedList", "(", "$", "list", ",", "$", "level", ")", ";", "return", "$", "list", ";", "}" ]
Builds Tree Menu from Tree Menu Structure. @access protected @static @param ADT_Tree_Menu_List $list Tree Menu Structure @param string $parent ID of parent Node @param array $steps List of Steps in Tree @param int $level Depth Level of Tree @return string
[ "Builds", "Tree", "Menu", "from", "Tree", "Menu", "Structure", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tree/Menu.php#L107-L130
37,267
CeusMedia/Common
src/UI/HTML/Pagination.php
UI_HTML_Pagination.buildItem
protected function buildItem( $text, $class = NULL ) { $list = array(); if( $class ) $list[] = $class; $item = UI_HTML_Elements::ListItem( $text, 0, array( 'class' => $class ) ); return $item; }
php
protected function buildItem( $text, $class = NULL ) { $list = array(); if( $class ) $list[] = $class; $item = UI_HTML_Elements::ListItem( $text, 0, array( 'class' => $class ) ); return $item; }
[ "protected", "function", "buildItem", "(", "$", "text", ",", "$", "class", "=", "NULL", ")", "{", "$", "list", "=", "array", "(", ")", ";", "if", "(", "$", "class", ")", "$", "list", "[", "]", "=", "$", "class", ";", "$", "item", "=", "UI_HTML_Elements", "::", "ListItem", "(", "$", "text", ",", "0", ",", "array", "(", "'class'", "=>", "$", "class", ")", ")", ";", "return", "$", "item", ";", "}" ]
Builds List Item of Pagination Link. @access protected @param string $text Text or HTML of Paging Button Span @param string $class Additive Style Class of Paging Button Span @return string
[ "Builds", "List", "Item", "of", "Pagination", "Link", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Pagination.php#L226-L233
37,268
CeusMedia/Common
src/UI/HTML/Pagination.php
UI_HTML_Pagination.buildLinkUrl
protected function buildLinkUrl( $offset ) { $param = $this->getOption( 'param' ); $param[$this->getOption( 'keyOffset' )] = $offset; $list = array(); foreach( $param as $key => $value ) $list[] = $key.$this->getOption( 'keyAssign' ).$value; $param = implode( $this->getOption( 'keyParam' ), $list ); $link = $this->getOption( 'uri' ).$this->getOption( 'keyRequest' ).$param; return $link; }
php
protected function buildLinkUrl( $offset ) { $param = $this->getOption( 'param' ); $param[$this->getOption( 'keyOffset' )] = $offset; $list = array(); foreach( $param as $key => $value ) $list[] = $key.$this->getOption( 'keyAssign' ).$value; $param = implode( $this->getOption( 'keyParam' ), $list ); $link = $this->getOption( 'uri' ).$this->getOption( 'keyRequest' ).$param; return $link; }
[ "protected", "function", "buildLinkUrl", "(", "$", "offset", ")", "{", "$", "param", "=", "$", "this", "->", "getOption", "(", "'param'", ")", ";", "$", "param", "[", "$", "this", "->", "getOption", "(", "'keyOffset'", ")", "]", "=", "$", "offset", ";", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "param", "as", "$", "key", "=>", "$", "value", ")", "$", "list", "[", "]", "=", "$", "key", ".", "$", "this", "->", "getOption", "(", "'keyAssign'", ")", ".", "$", "value", ";", "$", "param", "=", "implode", "(", "$", "this", "->", "getOption", "(", "'keyParam'", ")", ",", "$", "list", ")", ";", "$", "link", "=", "$", "this", "->", "getOption", "(", "'uri'", ")", ".", "$", "this", "->", "getOption", "(", "'keyRequest'", ")", ".", "$", "param", ";", "return", "$", "link", ";", "}" ]
Builds Link URL of Paging Button. @access protected @param int $offset Currently offset entries @return string
[ "Builds", "Link", "URL", "of", "Paging", "Button", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Pagination.php#L241-L251
37,269
CeusMedia/Common
src/ADT/Tree/Menu/Item.php
ADT_Tree_Menu_Item.toArray
public function toArray() { $array = array( 'url' => $this->url, 'label' => $this->label, 'classLink' => $this->attributes->get( 'classLink' ), 'classItem' => $this->attributes->get( 'classItem' ), 'classList' => $this->attributes->get( 'classList' ), 'children' => parent::toArray() ); return $array; }
php
public function toArray() { $array = array( 'url' => $this->url, 'label' => $this->label, 'classLink' => $this->attributes->get( 'classLink' ), 'classItem' => $this->attributes->get( 'classItem' ), 'classList' => $this->attributes->get( 'classList' ), 'children' => parent::toArray() ); return $array; }
[ "public", "function", "toArray", "(", ")", "{", "$", "array", "=", "array", "(", "'url'", "=>", "$", "this", "->", "url", ",", "'label'", "=>", "$", "this", "->", "label", ",", "'classLink'", "=>", "$", "this", "->", "attributes", "->", "get", "(", "'classLink'", ")", ",", "'classItem'", "=>", "$", "this", "->", "attributes", "->", "get", "(", "'classItem'", ")", ",", "'classList'", "=>", "$", "this", "->", "attributes", "->", "get", "(", "'classList'", ")", ",", "'children'", "=>", "parent", "::", "toArray", "(", ")", ")", ";", "return", "$", "array", ";", "}" ]
Returns recursive Array Structure of this Item and its nested Tree Menu Items. @access public @return array
[ "Returns", "recursive", "Array", "Structure", "of", "this", "Item", "and", "its", "nested", "Tree", "Menu", "Items", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/Menu/Item.php#L87-L98
37,270
CeusMedia/Common
src/ADT/OptionObject.php
ADT_OptionObject.declareOptions
public function declareOptions( $optionKeys = array() ) { if( !is_array( $optionKeys ) ) throw new InvalidArgumentException( 'Option Keys must be an Array.' ); foreach( $optionKeys as $key ) { if( !is_string( $key ) ) throw new InvalidArgumentException( 'Option Keys must be an Array List of Strings.' ); $this->options[$key] = NULL; } }
php
public function declareOptions( $optionKeys = array() ) { if( !is_array( $optionKeys ) ) throw new InvalidArgumentException( 'Option Keys must be an Array.' ); foreach( $optionKeys as $key ) { if( !is_string( $key ) ) throw new InvalidArgumentException( 'Option Keys must be an Array List of Strings.' ); $this->options[$key] = NULL; } }
[ "public", "function", "declareOptions", "(", "$", "optionKeys", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "optionKeys", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Option Keys must be an Array.'", ")", ";", "foreach", "(", "$", "optionKeys", "as", "$", "key", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Option Keys must be an Array List of Strings.'", ")", ";", "$", "this", "->", "options", "[", "$", "key", "]", "=", "NULL", ";", "}", "}" ]
Declares a Set of Options. @access public @param array $optionKeys List of Option Keys @return void
[ "Declares", "a", "Set", "of", "Options", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/OptionObject.php#L103-L113
37,271
CeusMedia/Common
src/ADT/OptionObject.php
ADT_OptionObject.getOption
public function getOption( $key, $throwException = TRUE ) { if( !$this->hasOption( $key ) ) { if( $throwException ) throw new OutOfRangeException( 'Option "'.$key.'" is not defined' ); return NULL; } return $this->options[$key]; }
php
public function getOption( $key, $throwException = TRUE ) { if( !$this->hasOption( $key ) ) { if( $throwException ) throw new OutOfRangeException( 'Option "'.$key.'" is not defined' ); return NULL; } return $this->options[$key]; }
[ "public", "function", "getOption", "(", "$", "key", ",", "$", "throwException", "=", "TRUE", ")", "{", "if", "(", "!", "$", "this", "->", "hasOption", "(", "$", "key", ")", ")", "{", "if", "(", "$", "throwException", ")", "throw", "new", "OutOfRangeException", "(", "'Option \"'", ".", "$", "key", ".", "'\" is not defined'", ")", ";", "return", "NULL", ";", "}", "return", "$", "this", "->", "options", "[", "$", "key", "]", ";", "}" ]
Returns an Option Value by Option Key. @access public @param string $key Option Key @param bool $throwException Flag: throw Exception is key is not set, NULL otherwise @throws OutOfRangeException if key is not set and $throwException is true @return mixed
[ "Returns", "an", "Option", "Value", "by", "Option", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/OptionObject.php#L123-L132
37,272
CeusMedia/Common
src/ADT/OptionObject.php
ADT_OptionObject.removeOption
public function removeOption( $key ) { if( !$this->hasOption( $key ) ) return FALSE; unset( $this->options[$key] ); return TRUE; }
php
public function removeOption( $key ) { if( !$this->hasOption( $key ) ) return FALSE; unset( $this->options[$key] ); return TRUE; }
[ "public", "function", "removeOption", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "hasOption", "(", "$", "key", ")", ")", "return", "FALSE", ";", "unset", "(", "$", "this", "->", "options", "[", "$", "key", "]", ")", ";", "return", "TRUE", ";", "}" ]
Removes an option by its key. @access public @param string $key Option Key @return bool
[ "Removes", "an", "option", "by", "its", "key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/OptionObject.php#L206-L212
37,273
CeusMedia/Common
src/ADT/OptionObject.php
ADT_OptionObject.setOption
public function setOption( $key, $value ) { if( isset( $this->options[$key] ) && $this->options[$key] === $value ) return FALSE; $this->options[$key] = $value; return TRUE; }
php
public function setOption( $key, $value ) { if( isset( $this->options[$key] ) && $this->options[$key] === $value ) return FALSE; $this->options[$key] = $value; return TRUE; }
[ "public", "function", "setOption", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "$", "key", "]", ")", "&&", "$", "this", "->", "options", "[", "$", "key", "]", "===", "$", "value", ")", "return", "FALSE", ";", "$", "this", "->", "options", "[", "$", "key", "]", "=", "$", "value", ";", "return", "TRUE", ";", "}" ]
Sets an options. @access public @param string $key Option Key @param mixed $value Option Value @return bool
[ "Sets", "an", "options", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/OptionObject.php#L221-L227
37,274
meritoo/common-library
src/Utilities/Regex.php
Regex.isValidEmail
public static function isValidEmail($email) { /* * Not a string? * Nothing to do */ if (!is_string($email)) { return false; } $pattern = self::getEmailPattern(); return (bool)preg_match($pattern, $email); }
php
public static function isValidEmail($email) { /* * Not a string? * Nothing to do */ if (!is_string($email)) { return false; } $pattern = self::getEmailPattern(); return (bool)preg_match($pattern, $email); }
[ "public", "static", "function", "isValidEmail", "(", "$", "email", ")", "{", "/*\n * Not a string?\n * Nothing to do\n */", "if", "(", "!", "is_string", "(", "$", "email", ")", ")", "{", "return", "false", ";", "}", "$", "pattern", "=", "self", "::", "getEmailPattern", "(", ")", ";", "return", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "$", "email", ")", ";", "}" ]
Returns information if given e-mail address is valid @param string $email E-mail address to validate / verify @return bool Examples: a) valid e-mails: - ni@g-m.pl - ni@gm.pl - ni@g_m.pl b) invalid e-mails: - ni@g-m.p - n@g-m.pl
[ "Returns", "information", "if", "given", "e", "-", "mail", "address", "is", "valid" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L72-L85
37,275
meritoo/common-library
src/Utilities/Regex.php
Regex.isValidUrl
public static function isValidUrl($url, $requireProtocol = false) { /* * Not a string? * Nothing to do */ if (!is_string($url)) { return false; } $pattern = self::getUrlPattern($requireProtocol); return (bool)preg_match($pattern, $url); }
php
public static function isValidUrl($url, $requireProtocol = false) { /* * Not a string? * Nothing to do */ if (!is_string($url)) { return false; } $pattern = self::getUrlPattern($requireProtocol); return (bool)preg_match($pattern, $url); }
[ "public", "static", "function", "isValidUrl", "(", "$", "url", ",", "$", "requireProtocol", "=", "false", ")", "{", "/*\n * Not a string?\n * Nothing to do\n */", "if", "(", "!", "is_string", "(", "$", "url", ")", ")", "{", "return", "false", ";", "}", "$", "pattern", "=", "self", "::", "getUrlPattern", "(", "$", "requireProtocol", ")", ";", "return", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "$", "url", ")", ";", "}" ]
Returns information if given url address is valid @param string $url The url to validate / verify @param bool $requireProtocol (optional) If is set to true, the protocol is required to be passed in the url. Otherwise - not. @return bool
[ "Returns", "information", "if", "given", "url", "address", "is", "valid" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L155-L168
37,276
meritoo/common-library
src/Utilities/Regex.php
Regex.isValidPhoneNumber
public static function isValidPhoneNumber($phoneNumber) { /* * Not a string? * Nothing to do */ if (!is_string($phoneNumber)) { return false; } $pattern = self::getPhoneNumberPattern(); return (bool)preg_match($pattern, trim($phoneNumber)); }
php
public static function isValidPhoneNumber($phoneNumber) { /* * Not a string? * Nothing to do */ if (!is_string($phoneNumber)) { return false; } $pattern = self::getPhoneNumberPattern(); return (bool)preg_match($pattern, trim($phoneNumber)); }
[ "public", "static", "function", "isValidPhoneNumber", "(", "$", "phoneNumber", ")", "{", "/*\n * Not a string?\n * Nothing to do\n */", "if", "(", "!", "is_string", "(", "$", "phoneNumber", ")", ")", "{", "return", "false", ";", "}", "$", "pattern", "=", "self", "::", "getPhoneNumberPattern", "(", ")", ";", "return", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "trim", "(", "$", "phoneNumber", ")", ")", ";", "}" ]
Returns information if given phone number is valid @param string $phoneNumber The phone number to validate / verify @return bool
[ "Returns", "information", "if", "given", "phone", "number", "is", "valid" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L176-L189
37,277
meritoo/common-library
src/Utilities/Regex.php
Regex.arrayFilter
public static function arrayFilter($array, $arrayColumnKey, $filterExpression, $itsRegularExpression = false) { /* * No elements? * Nothing to do */ if (empty($array)) { return []; } $effect = $array; foreach ($effect as $key => &$item) { if (!isset($item[$arrayColumnKey])) { continue; } $value = $item[$arrayColumnKey]; if ($itsRegularExpression) { $matchesCount = preg_match($filterExpression, $value); $remove = 0 === $matchesCount; } else { if (is_string($value)) { $value = sprintf('\'%s\'', $value); } elseif (is_bool($value)) { if (true === $value) { $value = 'true'; } else { $value = 'false'; } } eval(sprintf('$isEqual = %s%s;', $value, $filterExpression)); /** @var bool $isEqual */ $remove = !$isEqual; } if ($remove) { unset($effect[$key]); } } return $effect; }
php
public static function arrayFilter($array, $arrayColumnKey, $filterExpression, $itsRegularExpression = false) { /* * No elements? * Nothing to do */ if (empty($array)) { return []; } $effect = $array; foreach ($effect as $key => &$item) { if (!isset($item[$arrayColumnKey])) { continue; } $value = $item[$arrayColumnKey]; if ($itsRegularExpression) { $matchesCount = preg_match($filterExpression, $value); $remove = 0 === $matchesCount; } else { if (is_string($value)) { $value = sprintf('\'%s\'', $value); } elseif (is_bool($value)) { if (true === $value) { $value = 'true'; } else { $value = 'false'; } } eval(sprintf('$isEqual = %s%s;', $value, $filterExpression)); /** @var bool $isEqual */ $remove = !$isEqual; } if ($remove) { unset($effect[$key]); } } return $effect; }
[ "public", "static", "function", "arrayFilter", "(", "$", "array", ",", "$", "arrayColumnKey", ",", "$", "filterExpression", ",", "$", "itsRegularExpression", "=", "false", ")", "{", "/*\n * No elements?\n * Nothing to do\n */", "if", "(", "empty", "(", "$", "array", ")", ")", "{", "return", "[", "]", ";", "}", "$", "effect", "=", "$", "array", ";", "foreach", "(", "$", "effect", "as", "$", "key", "=>", "&", "$", "item", ")", "{", "if", "(", "!", "isset", "(", "$", "item", "[", "$", "arrayColumnKey", "]", ")", ")", "{", "continue", ";", "}", "$", "value", "=", "$", "item", "[", "$", "arrayColumnKey", "]", ";", "if", "(", "$", "itsRegularExpression", ")", "{", "$", "matchesCount", "=", "preg_match", "(", "$", "filterExpression", ",", "$", "value", ")", ";", "$", "remove", "=", "0", "===", "$", "matchesCount", ";", "}", "else", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "sprintf", "(", "'\\'%s\\''", ",", "$", "value", ")", ";", "}", "elseif", "(", "is_bool", "(", "$", "value", ")", ")", "{", "if", "(", "true", "===", "$", "value", ")", "{", "$", "value", "=", "'true'", ";", "}", "else", "{", "$", "value", "=", "'false'", ";", "}", "}", "eval", "(", "sprintf", "(", "'$isEqual = %s%s;'", ",", "$", "value", ",", "$", "filterExpression", ")", ")", ";", "/** @var bool $isEqual */", "$", "remove", "=", "!", "$", "isEqual", ";", "}", "if", "(", "$", "remove", ")", "{", "unset", "(", "$", "effect", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "effect", ";", "}" ]
Filters array by given expression and column Expression can be simple compare expression, like " == 2", or regular expression. Returns filtered array. @param array $array The 2-dimensional array that should be filtered @param string $arrayColumnKey Column name @param string $filterExpression Simple filter expression (e.g. "== 2" or "!= \'home\'") or regular expression (e.g. "/\d+/" or "/[a-z]+[,;]{2,}/") @param bool $itsRegularExpression (optional) If is set to true, means that filter expression is a regular expression. Otherwise - not (default behaviour). @return array
[ "Filters", "array", "by", "given", "expression", "and", "column" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L239-L284
37,278
meritoo/common-library
src/Utilities/Regex.php
Regex.isLetterOrDigit
public static function isLetterOrDigit($char) { $pattern = self::getLetterOrDigitPattern(); return is_scalar($char) && (bool)preg_match($pattern, $char); }
php
public static function isLetterOrDigit($char) { $pattern = self::getLetterOrDigitPattern(); return is_scalar($char) && (bool)preg_match($pattern, $char); }
[ "public", "static", "function", "isLetterOrDigit", "(", "$", "char", ")", "{", "$", "pattern", "=", "self", "::", "getLetterOrDigitPattern", "(", ")", ";", "return", "is_scalar", "(", "$", "char", ")", "&&", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "$", "char", ")", ";", "}" ]
Returns information if given character is a letter or digit @param string $char Character to check @return bool
[ "Returns", "information", "if", "given", "character", "is", "a", "letter", "or", "digit" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L491-L496
37,279
meritoo/common-library
src/Utilities/Regex.php
Regex.startsWithDirectorySeparator
public static function startsWithDirectorySeparator($string, $separator = '') { if (empty($separator)) { $separator = DIRECTORY_SEPARATOR; } return self::startsWith($string, $separator); }
php
public static function startsWithDirectorySeparator($string, $separator = '') { if (empty($separator)) { $separator = DIRECTORY_SEPARATOR; } return self::startsWith($string, $separator); }
[ "public", "static", "function", "startsWithDirectorySeparator", "(", "$", "string", ",", "$", "separator", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "separator", ")", ")", "{", "$", "separator", "=", "DIRECTORY_SEPARATOR", ";", "}", "return", "self", "::", "startsWith", "(", "$", "string", ",", "$", "separator", ")", ";", "}" ]
Returns information if the string starts with directory's separator @param string $string String that may contain a directory's separator at the start / beginning @param string $separator (optional) The directory's separator, e.g. "/". If is empty (not provided), system's separator is used. @return bool
[ "Returns", "information", "if", "the", "string", "starts", "with", "directory", "s", "separator" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L544-L551
37,280
meritoo/common-library
src/Utilities/Regex.php
Regex.endsWithDirectorySeparator
public static function endsWithDirectorySeparator($text, $separator = '') { if (empty($separator)) { $separator = DIRECTORY_SEPARATOR; } return self::endsWith($text, $separator); }
php
public static function endsWithDirectorySeparator($text, $separator = '') { if (empty($separator)) { $separator = DIRECTORY_SEPARATOR; } return self::endsWith($text, $separator); }
[ "public", "static", "function", "endsWithDirectorySeparator", "(", "$", "text", ",", "$", "separator", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "separator", ")", ")", "{", "$", "separator", "=", "DIRECTORY_SEPARATOR", ";", "}", "return", "self", "::", "endsWith", "(", "$", "text", ",", "$", "separator", ")", ";", "}" ]
Returns information if the string ends with directory's separator @param string $text String that may contain a directory's separator at the end @param string $separator (optional) The directory's separator, e.g. "/". If is empty (not provided), system's separator is used. @return string
[ "Returns", "information", "if", "the", "string", "ends", "with", "directory", "s", "separator" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L561-L568
37,281
meritoo/common-library
src/Utilities/Regex.php
Regex.contains
public static function contains($haystack, $needle) { if (1 === strlen($needle) && !self::isLetterOrDigit($needle)) { $needle = '\\' . $needle; } return (bool)preg_match('|.*' . $needle . '.*|', $haystack); }
php
public static function contains($haystack, $needle) { if (1 === strlen($needle) && !self::isLetterOrDigit($needle)) { $needle = '\\' . $needle; } return (bool)preg_match('|.*' . $needle . '.*|', $haystack); }
[ "public", "static", "function", "contains", "(", "$", "haystack", ",", "$", "needle", ")", "{", "if", "(", "1", "===", "strlen", "(", "$", "needle", ")", "&&", "!", "self", "::", "isLetterOrDigit", "(", "$", "needle", ")", ")", "{", "$", "needle", "=", "'\\\\'", ".", "$", "needle", ";", "}", "return", "(", "bool", ")", "preg_match", "(", "'|.*'", ".", "$", "needle", ".", "'.*|'", ",", "$", "haystack", ")", ";", "}" ]
Returns information if one string contains another string @param string $haystack The string to search in @param string $needle The string to be search for @return bool
[ "Returns", "information", "if", "one", "string", "contains", "another", "string" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L612-L619
37,282
meritoo/common-library
src/Utilities/Regex.php
Regex.isValidNip
public static function isValidNip($nip) { $nip = preg_replace('/[\D]/', '', $nip); $invalidNips = [ '1234567890', '0000000000', ]; if (!preg_match('/^[\d]{10}$/', $nip) || in_array($nip, $invalidNips, true)) { return false; } $sum = 0; $weights = [ 6, 5, 7, 2, 3, 4, 5, 6, 7, ]; for ($i = 0; $i < 9; ++$i) { $sum += $weights[$i] * $nip[$i]; } $modulo = $sum % 11; $numberControl = (10 === $modulo) ? 0 : $modulo; return $numberControl === (int)$nip[9]; }
php
public static function isValidNip($nip) { $nip = preg_replace('/[\D]/', '', $nip); $invalidNips = [ '1234567890', '0000000000', ]; if (!preg_match('/^[\d]{10}$/', $nip) || in_array($nip, $invalidNips, true)) { return false; } $sum = 0; $weights = [ 6, 5, 7, 2, 3, 4, 5, 6, 7, ]; for ($i = 0; $i < 9; ++$i) { $sum += $weights[$i] * $nip[$i]; } $modulo = $sum % 11; $numberControl = (10 === $modulo) ? 0 : $modulo; return $numberControl === (int)$nip[9]; }
[ "public", "static", "function", "isValidNip", "(", "$", "nip", ")", "{", "$", "nip", "=", "preg_replace", "(", "'/[\\D]/'", ",", "''", ",", "$", "nip", ")", ";", "$", "invalidNips", "=", "[", "'1234567890'", ",", "'0000000000'", ",", "]", ";", "if", "(", "!", "preg_match", "(", "'/^[\\d]{10}$/'", ",", "$", "nip", ")", "||", "in_array", "(", "$", "nip", ",", "$", "invalidNips", ",", "true", ")", ")", "{", "return", "false", ";", "}", "$", "sum", "=", "0", ";", "$", "weights", "=", "[", "6", ",", "5", ",", "7", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "9", ";", "++", "$", "i", ")", "{", "$", "sum", "+=", "$", "weights", "[", "$", "i", "]", "*", "$", "nip", "[", "$", "i", "]", ";", "}", "$", "modulo", "=", "$", "sum", "%", "11", ";", "$", "numberControl", "=", "(", "10", "===", "$", "modulo", ")", "?", "0", ":", "$", "modulo", ";", "return", "$", "numberControl", "===", "(", "int", ")", "$", "nip", "[", "9", "]", ";", "}" ]
Returns information if given NIP number is valid @param string $nip A given NIP number @return bool @see https://pl.wikipedia.org/wiki/NIP#Znaczenie_numeru
[ "Returns", "information", "if", "given", "NIP", "number", "is", "valid" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L699-L733
37,283
meritoo/common-library
src/Utilities/Regex.php
Regex.isValidMoneyValue
public static function isValidMoneyValue($value) { /* * Not a scalar value? * Nothing to do */ if (!is_scalar($value)) { return false; } $pattern = self::getMoneyPattern(); return (bool)preg_match($pattern, $value); }
php
public static function isValidMoneyValue($value) { /* * Not a scalar value? * Nothing to do */ if (!is_scalar($value)) { return false; } $pattern = self::getMoneyPattern(); return (bool)preg_match($pattern, $value); }
[ "public", "static", "function", "isValidMoneyValue", "(", "$", "value", ")", "{", "/*\n * Not a scalar value?\n * Nothing to do\n */", "if", "(", "!", "is_scalar", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "$", "pattern", "=", "self", "::", "getMoneyPattern", "(", ")", ";", "return", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "$", "value", ")", ";", "}" ]
Returns information if given value is valid money-related value @param mixed $value Value to verify @return bool
[ "Returns", "information", "if", "given", "value", "is", "valid", "money", "-", "related", "value" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L751-L764
37,284
meritoo/common-library
src/Utilities/Regex.php
Regex.getValidColorHexValue
public static function getValidColorHexValue($color, $throwException = true) { /* * Not a scalar value? * Nothing to do */ if (!is_scalar($color)) { return false; } $color = Miscellaneous::replace($color, '/#/', ''); $length = strlen($color); /* * Color is not 3 or 6 characters long? * Nothing to do */ if (3 !== $length && 6 !== $length) { if ($throwException) { throw new IncorrectColorHexLengthException($color); } return false; } /* * Color is 3 characters long? * Let's make it 6 characters long */ if (3 === $length) { $color = Miscellaneous::replace($color, '/(.)(.)(.)/', '$1$1$2$2$3$3'); } $pattern = self::$patterns['color']; $match = (bool)preg_match($pattern, $color); /* * It's valid color * Nothing to do more */ if ($match) { return strtolower($color); } if ($throwException) { throw new InvalidColorHexValueException($color); } return false; }
php
public static function getValidColorHexValue($color, $throwException = true) { /* * Not a scalar value? * Nothing to do */ if (!is_scalar($color)) { return false; } $color = Miscellaneous::replace($color, '/#/', ''); $length = strlen($color); /* * Color is not 3 or 6 characters long? * Nothing to do */ if (3 !== $length && 6 !== $length) { if ($throwException) { throw new IncorrectColorHexLengthException($color); } return false; } /* * Color is 3 characters long? * Let's make it 6 characters long */ if (3 === $length) { $color = Miscellaneous::replace($color, '/(.)(.)(.)/', '$1$1$2$2$3$3'); } $pattern = self::$patterns['color']; $match = (bool)preg_match($pattern, $color); /* * It's valid color * Nothing to do more */ if ($match) { return strtolower($color); } if ($throwException) { throw new InvalidColorHexValueException($color); } return false; }
[ "public", "static", "function", "getValidColorHexValue", "(", "$", "color", ",", "$", "throwException", "=", "true", ")", "{", "/*\n * Not a scalar value?\n * Nothing to do\n */", "if", "(", "!", "is_scalar", "(", "$", "color", ")", ")", "{", "return", "false", ";", "}", "$", "color", "=", "Miscellaneous", "::", "replace", "(", "$", "color", ",", "'/#/'", ",", "''", ")", ";", "$", "length", "=", "strlen", "(", "$", "color", ")", ";", "/*\n * Color is not 3 or 6 characters long?\n * Nothing to do\n */", "if", "(", "3", "!==", "$", "length", "&&", "6", "!==", "$", "length", ")", "{", "if", "(", "$", "throwException", ")", "{", "throw", "new", "IncorrectColorHexLengthException", "(", "$", "color", ")", ";", "}", "return", "false", ";", "}", "/*\n * Color is 3 characters long?\n * Let's make it 6 characters long\n */", "if", "(", "3", "===", "$", "length", ")", "{", "$", "color", "=", "Miscellaneous", "::", "replace", "(", "$", "color", ",", "'/(.)(.)(.)/'", ",", "'$1$1$2$2$3$3'", ")", ";", "}", "$", "pattern", "=", "self", "::", "$", "patterns", "[", "'color'", "]", ";", "$", "match", "=", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "$", "color", ")", ";", "/*\n * It's valid color\n * Nothing to do more\n */", "if", "(", "$", "match", ")", "{", "return", "strtolower", "(", "$", "color", ")", ";", "}", "if", "(", "$", "throwException", ")", "{", "throw", "new", "InvalidColorHexValueException", "(", "$", "color", ")", ";", "}", "return", "false", ";", "}" ]
Returns valid given hexadecimal value of color. If the value is invalid, throws an exception or returns false. @param string $color Color to verify @param bool $throwException (optional) If is set to true, throws an exception if given color is invalid (default behaviour). Otherwise - not. @throws IncorrectColorHexLengthException @throws InvalidColorHexValueException @return bool|string
[ "Returns", "valid", "given", "hexadecimal", "value", "of", "color", ".", "If", "the", "value", "is", "invalid", "throws", "an", "exception", "or", "returns", "false", "." ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L777-L826
37,285
meritoo/common-library
src/Utilities/Regex.php
Regex.isValidBundleName
public static function isValidBundleName($bundleName) { /* * Not a string? * Nothing to do */ if (!is_string($bundleName)) { return false; } $pattern = self::getBundleNamePattern(); return (bool)preg_match($pattern, $bundleName); }
php
public static function isValidBundleName($bundleName) { /* * Not a string? * Nothing to do */ if (!is_string($bundleName)) { return false; } $pattern = self::getBundleNamePattern(); return (bool)preg_match($pattern, $bundleName); }
[ "public", "static", "function", "isValidBundleName", "(", "$", "bundleName", ")", "{", "/*\n * Not a string?\n * Nothing to do\n */", "if", "(", "!", "is_string", "(", "$", "bundleName", ")", ")", "{", "return", "false", ";", "}", "$", "pattern", "=", "self", "::", "getBundleNamePattern", "(", ")", ";", "return", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "$", "bundleName", ")", ";", "}" ]
Returns information if given name of bundle is valid @param string $bundleName Full name of bundle to verify, e.g. "MyExtraBundle" @return bool
[ "Returns", "information", "if", "given", "name", "of", "bundle", "is", "valid" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L834-L847
37,286
meritoo/common-library
src/Utilities/Regex.php
Regex.isValidHtmlAttribute
public static function isValidHtmlAttribute($htmlAttribute) { /* * Not a string? * Nothing to do */ if (!is_string($htmlAttribute)) { return false; } $pattern = self::getHtmlAttributePattern(); return (bool)preg_match($pattern, $htmlAttribute); }
php
public static function isValidHtmlAttribute($htmlAttribute) { /* * Not a string? * Nothing to do */ if (!is_string($htmlAttribute)) { return false; } $pattern = self::getHtmlAttributePattern(); return (bool)preg_match($pattern, $htmlAttribute); }
[ "public", "static", "function", "isValidHtmlAttribute", "(", "$", "htmlAttribute", ")", "{", "/*\n * Not a string?\n * Nothing to do\n */", "if", "(", "!", "is_string", "(", "$", "htmlAttribute", ")", ")", "{", "return", "false", ";", "}", "$", "pattern", "=", "self", "::", "getHtmlAttributePattern", "(", ")", ";", "return", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "$", "htmlAttribute", ")", ";", "}" ]
Returns information if given html attribute is valid @param string $htmlAttribute The html attribute to verify @return bool
[ "Returns", "information", "if", "given", "html", "attribute", "is", "valid" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L875-L888
37,287
meritoo/common-library
src/Utilities/Regex.php
Regex.areValidHtmlAttributes
public static function areValidHtmlAttributes($htmlAttributes) { /* * Not a string? * Nothing to do */ if (!is_string($htmlAttributes)) { return false; } $pattern = self::getHtmlAttributePattern(); return (bool)preg_match_all($pattern, $htmlAttributes); }
php
public static function areValidHtmlAttributes($htmlAttributes) { /* * Not a string? * Nothing to do */ if (!is_string($htmlAttributes)) { return false; } $pattern = self::getHtmlAttributePattern(); return (bool)preg_match_all($pattern, $htmlAttributes); }
[ "public", "static", "function", "areValidHtmlAttributes", "(", "$", "htmlAttributes", ")", "{", "/*\n * Not a string?\n * Nothing to do\n */", "if", "(", "!", "is_string", "(", "$", "htmlAttributes", ")", ")", "{", "return", "false", ";", "}", "$", "pattern", "=", "self", "::", "getHtmlAttributePattern", "(", ")", ";", "return", "(", "bool", ")", "preg_match_all", "(", "$", "pattern", ",", "$", "htmlAttributes", ")", ";", "}" ]
Returns information if given html attributes are valid @param string $htmlAttributes The html attributes to verify @return bool
[ "Returns", "information", "if", "given", "html", "attributes", "are", "valid" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L896-L909
37,288
meritoo/common-library
src/Utilities/Regex.php
Regex.isBinaryValue
public static function isBinaryValue($value) { /* * Not a string? * Nothing to do */ if (!is_string($value)) { return false; } $pattern = self::$patterns['binaryValue']; return (bool)preg_match($pattern, $value); }
php
public static function isBinaryValue($value) { /* * Not a string? * Nothing to do */ if (!is_string($value)) { return false; } $pattern = self::$patterns['binaryValue']; return (bool)preg_match($pattern, $value); }
[ "public", "static", "function", "isBinaryValue", "(", "$", "value", ")", "{", "/*\n * Not a string?\n * Nothing to do\n */", "if", "(", "!", "is_string", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "$", "pattern", "=", "self", "::", "$", "patterns", "[", "'binaryValue'", "]", ";", "return", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "$", "value", ")", ";", "}" ]
Returns information if given value is a binary value @param string $value Value to verify @return bool
[ "Returns", "information", "if", "given", "value", "is", "a", "binary", "value" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L917-L930
37,289
meritoo/common-library
src/Utilities/Regex.php
Regex.isSizeValue
public static function isSizeValue($value, $separator = ' x ') { /* * Not a string? * Nothing to do */ if (!is_string($value)) { return false; } $pattern = self::getSizePattern($separator); return (bool)preg_match($pattern, $value); }
php
public static function isSizeValue($value, $separator = ' x ') { /* * Not a string? * Nothing to do */ if (!is_string($value)) { return false; } $pattern = self::getSizePattern($separator); return (bool)preg_match($pattern, $value); }
[ "public", "static", "function", "isSizeValue", "(", "$", "value", ",", "$", "separator", "=", "' x '", ")", "{", "/*\n * Not a string?\n * Nothing to do\n */", "if", "(", "!", "is_string", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "$", "pattern", "=", "self", "::", "getSizePattern", "(", "$", "separator", ")", ";", "return", "(", "bool", ")", "preg_match", "(", "$", "pattern", ",", "$", "value", ")", ";", "}" ]
Returns information if given value is a size value @param string $value Value to verify @param string $separator (optional) Separator used to split width and height. Default: " x ". @return bool
[ "Returns", "information", "if", "given", "value", "is", "a", "size", "value" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L967-L980
37,290
meritoo/common-library
src/Utilities/Regex.php
Regex.createSlug
public static function createSlug($value) { /* * Not a scalar value? * Nothing to do */ if (!is_scalar($value)) { return false; } /* * It's an empty string? * Nothing to do */ if ('' === $value) { return ''; } $id = 'Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();'; $transliterator = \Transliterator::create($id); $cleanValue = trim($value); $result = $transliterator->transliterate($cleanValue); return preg_replace('/[-\s]+/', '-', $result); }
php
public static function createSlug($value) { /* * Not a scalar value? * Nothing to do */ if (!is_scalar($value)) { return false; } /* * It's an empty string? * Nothing to do */ if ('' === $value) { return ''; } $id = 'Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();'; $transliterator = \Transliterator::create($id); $cleanValue = trim($value); $result = $transliterator->transliterate($cleanValue); return preg_replace('/[-\s]+/', '-', $result); }
[ "public", "static", "function", "createSlug", "(", "$", "value", ")", "{", "/*\n * Not a scalar value?\n * Nothing to do\n */", "if", "(", "!", "is_scalar", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "/*\n * It's an empty string?\n * Nothing to do\n */", "if", "(", "''", "===", "$", "value", ")", "{", "return", "''", ";", "}", "$", "id", "=", "'Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();'", ";", "$", "transliterator", "=", "\\", "Transliterator", "::", "create", "(", "$", "id", ")", ";", "$", "cleanValue", "=", "trim", "(", "$", "value", ")", ";", "$", "result", "=", "$", "transliterator", "->", "transliterate", "(", "$", "cleanValue", ")", ";", "return", "preg_replace", "(", "'/[-\\s]+/'", ",", "'-'", ",", "$", "result", ")", ";", "}" ]
Returns slug for given value @param string $value Value that should be transformed to slug @return bool|string
[ "Returns", "slug", "for", "given", "value" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L988-L1013
37,291
CeusMedia/Common
src/FS/File/CSV/IteratorReader.php
FS_File_CSV_IteratorReader.toArray
public function toArray( $useHeaders = false ) { $list = array(); if( $useHeaders ) { $headers = $this->iterator->next(); while( $data = $this->iterator->next() ) { $list[] = array_combine( $headers, $data ); } } else { while( $list[] = $this->iterator->next() ); } return $list; }
php
public function toArray( $useHeaders = false ) { $list = array(); if( $useHeaders ) { $headers = $this->iterator->next(); while( $data = $this->iterator->next() ) { $list[] = array_combine( $headers, $data ); } } else { while( $list[] = $this->iterator->next() ); } return $list; }
[ "public", "function", "toArray", "(", "$", "useHeaders", "=", "false", ")", "{", "$", "list", "=", "array", "(", ")", ";", "if", "(", "$", "useHeaders", ")", "{", "$", "headers", "=", "$", "this", "->", "iterator", "->", "next", "(", ")", ";", "while", "(", "$", "data", "=", "$", "this", "->", "iterator", "->", "next", "(", ")", ")", "{", "$", "list", "[", "]", "=", "array_combine", "(", "$", "headers", ",", "$", "data", ")", ";", "}", "}", "else", "{", "while", "(", "$", "list", "[", "]", "=", "$", "this", "->", "iterator", "->", "next", "(", ")", ")", ";", "}", "return", "$", "list", ";", "}" ]
Returns CSV Data as Array or associative Array. @access public @param bool $useHeaders Flag: use first Line as Headers and return associative Array @return array
[ "Returns", "CSV", "Data", "as", "Array", "or", "associative", "Array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/IteratorReader.php#L61-L77
37,292
ncou/Chiron
src/Chiron/Handler/Formatter/HtmlFormatter.php
HtmlFormatter.arrayToHtml
private function arrayToHtml(array $data): string { $html = file_get_contents($this->path); foreach ($data as $key => $val) { $html = str_replace("{{ $$key }}", $val, $html); } return $html; }
php
private function arrayToHtml(array $data): string { $html = file_get_contents($this->path); foreach ($data as $key => $val) { $html = str_replace("{{ $$key }}", $val, $html); } return $html; }
[ "private", "function", "arrayToHtml", "(", "array", "$", "data", ")", ":", "string", "{", "$", "html", "=", "file_get_contents", "(", "$", "this", "->", "path", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "html", "=", "str_replace", "(", "\"{{ $$key }}\"", ",", "$", "val", ",", "$", "html", ")", ";", "}", "return", "$", "html", ";", "}" ]
Render the page with given data. @param array $data @return string
[ "Render", "the", "page", "with", "given", "data", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/Formatter/HtmlFormatter.php#L47-L56
37,293
CeusMedia/Common
src/FS/File/List/Writer.php
FS_File_List_Writer.add
public function add( $item, $force = FALSE ) { if( in_array( $item, $this->list ) && !$force ) throw new DomainException( 'Item "'.$item.'" is already existing. See Option "force".' ); $this->list[] = $item; return $this->write(); }
php
public function add( $item, $force = FALSE ) { if( in_array( $item, $this->list ) && !$force ) throw new DomainException( 'Item "'.$item.'" is already existing. See Option "force".' ); $this->list[] = $item; return $this->write(); }
[ "public", "function", "add", "(", "$", "item", ",", "$", "force", "=", "FALSE", ")", "{", "if", "(", "in_array", "(", "$", "item", ",", "$", "this", "->", "list", ")", "&&", "!", "$", "force", ")", "throw", "new", "DomainException", "(", "'Item \"'", ".", "$", "item", ".", "'\" is already existing. See Option \"force\".'", ")", ";", "$", "this", "->", "list", "[", "]", "=", "$", "item", ";", "return", "$", "this", "->", "write", "(", ")", ";", "}" ]
Adds an Item to the current List. @access public @param string $item Item to add @param bool $force Flag: force overwriting @return void
[ "Adds", "an", "Item", "to", "the", "current", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Writer.php#L64-L70
37,294
CeusMedia/Common
src/FS/File/List/Writer.php
FS_File_List_Writer.removeIndex
public function removeIndex( $index ) { if( !isset( $this->list[$index] ) ) throw new DomainException( 'Item with Index '.$index.' is not existing.' ); unset( $this->list[$index] ); return $this->write(); }
php
public function removeIndex( $index ) { if( !isset( $this->list[$index] ) ) throw new DomainException( 'Item with Index '.$index.' is not existing.' ); unset( $this->list[$index] ); return $this->write(); }
[ "public", "function", "removeIndex", "(", "$", "index", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "list", "[", "$", "index", "]", ")", ")", "throw", "new", "DomainException", "(", "'Item with Index '", ".", "$", "index", ".", "' is not existing.'", ")", ";", "unset", "(", "$", "this", "->", "list", "[", "$", "index", "]", ")", ";", "return", "$", "this", "->", "write", "(", ")", ";", "}" ]
Removes an Item from current List by its Index. @access public @param int $index Index of Item @return bool
[ "Removes", "an", "Item", "from", "current", "List", "by", "its", "Index", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Writer.php#L93-L99
37,295
CeusMedia/Common
src/FS/File/List/Writer.php
FS_File_List_Writer.save
public static function save( $fileName, $list, $mode = 0755, $user = NULL, $group = NULL ) { $file = new FS_File_Writer( $fileName, $mode, $user, $group ); return $file->writeArray( $list ) !== FALSE; }
php
public static function save( $fileName, $list, $mode = 0755, $user = NULL, $group = NULL ) { $file = new FS_File_Writer( $fileName, $mode, $user, $group ); return $file->writeArray( $list ) !== FALSE; }
[ "public", "static", "function", "save", "(", "$", "fileName", ",", "$", "list", ",", "$", "mode", "=", "0755", ",", "$", "user", "=", "NULL", ",", "$", "group", "=", "NULL", ")", "{", "$", "file", "=", "new", "FS_File_Writer", "(", "$", "fileName", ",", "$", "mode", ",", "$", "user", ",", "$", "group", ")", ";", "return", "$", "file", "->", "writeArray", "(", "$", "list", ")", "!==", "FALSE", ";", "}" ]
Saves a List to File. @access public @static @param string $fileName File Name of List, absolute or relative URI @param array $list List to save @param string $mode UNIX rights for chmod() @param string $user User Name for chown() @param string $group Group Name for chgrp() @return bool
[ "Saves", "a", "List", "to", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Writer.php#L112-L116
37,296
CeusMedia/Common
src/FS/File/List/Writer.php
FS_File_List_Writer.write
protected function write( $mode = 0755, $user = NULL, $group = NULL ) { return $this->save( $this->fileName, $this->list, $mode, $user, $group ); }
php
protected function write( $mode = 0755, $user = NULL, $group = NULL ) { return $this->save( $this->fileName, $this->list, $mode, $user, $group ); }
[ "protected", "function", "write", "(", "$", "mode", "=", "0755", ",", "$", "user", "=", "NULL", ",", "$", "group", "=", "NULL", ")", "{", "return", "$", "this", "->", "save", "(", "$", "this", "->", "fileName", ",", "$", "this", "->", "list", ",", "$", "mode", ",", "$", "user", ",", "$", "group", ")", ";", "}" ]
Writes the current List to File. @access protected @param string $mode UNIX rights for chmod() @param string $user User Name for chown() @param string $group Group Name for chgrp() @return bool
[ "Writes", "the", "current", "List", "to", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Writer.php#L126-L129
37,297
theodorejb/peachy-sql
lib/BaseStatement.php
BaseStatement.getFirst
public function getFirst() { $row = $this->getIterator()->current(); if ($row !== null) { $this->close(); // don't leave the SQL statement open } return $row; }
php
public function getFirst() { $row = $this->getIterator()->current(); if ($row !== null) { $this->close(); // don't leave the SQL statement open } return $row; }
[ "public", "function", "getFirst", "(", ")", "{", "$", "row", "=", "$", "this", "->", "getIterator", "(", ")", "->", "current", "(", ")", ";", "if", "(", "$", "row", "!==", "null", ")", "{", "$", "this", "->", "close", "(", ")", ";", "// don't leave the SQL statement open", "}", "return", "$", "row", ";", "}" ]
Returns the first selected row, or null if zero rows were returned @return array|null
[ "Returns", "the", "first", "selected", "row", "or", "null", "if", "zero", "rows", "were", "returned" ]
f179c6fa6c4293c2713b6b59022f3cfc90890a98
https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/BaseStatement.php#L52-L61
37,298
CeusMedia/Common
src/XML/Element.php
XML_Element.addAttribute
public function addAttribute( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL ) { $key = $nsPrefix ? $nsPrefix.':'.$name : $name; if( $nsPrefix ) { $namespaces = $this->getDocNamespaces(); $key = $nsPrefix ? $nsPrefix.':'.$name : $name; if( $this->hasAttribute( $name, $nsPrefix ) ) throw new RuntimeException( 'Attribute "'.$key.'" is already set' ); if( array_key_exists( $nsPrefix, $namespaces ) ) return parent::addAttribute( $key, $value, $namespaces[$nsPrefix] ); if( $nsURI ) return parent::addAttribute( $key, $value, $nsURI ); throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' ); } if( $this->hasAttribute( $name ) ) throw new RuntimeException( 'Attribute "'.$name.'" is already set' ); parent::addAttribute( $name, $value ); }
php
public function addAttribute( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL ) { $key = $nsPrefix ? $nsPrefix.':'.$name : $name; if( $nsPrefix ) { $namespaces = $this->getDocNamespaces(); $key = $nsPrefix ? $nsPrefix.':'.$name : $name; if( $this->hasAttribute( $name, $nsPrefix ) ) throw new RuntimeException( 'Attribute "'.$key.'" is already set' ); if( array_key_exists( $nsPrefix, $namespaces ) ) return parent::addAttribute( $key, $value, $namespaces[$nsPrefix] ); if( $nsURI ) return parent::addAttribute( $key, $value, $nsURI ); throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' ); } if( $this->hasAttribute( $name ) ) throw new RuntimeException( 'Attribute "'.$name.'" is already set' ); parent::addAttribute( $name, $value ); }
[ "public", "function", "addAttribute", "(", "$", "name", ",", "$", "value", "=", "NULL", ",", "$", "nsPrefix", "=", "NULL", ",", "$", "nsURI", "=", "NULL", ")", "{", "$", "key", "=", "$", "nsPrefix", "?", "$", "nsPrefix", ".", "':'", ".", "$", "name", ":", "$", "name", ";", "if", "(", "$", "nsPrefix", ")", "{", "$", "namespaces", "=", "$", "this", "->", "getDocNamespaces", "(", ")", ";", "$", "key", "=", "$", "nsPrefix", "?", "$", "nsPrefix", ".", "':'", ".", "$", "name", ":", "$", "name", ";", "if", "(", "$", "this", "->", "hasAttribute", "(", "$", "name", ",", "$", "nsPrefix", ")", ")", "throw", "new", "RuntimeException", "(", "'Attribute \"'", ".", "$", "key", ".", "'\" is already set'", ")", ";", "if", "(", "array_key_exists", "(", "$", "nsPrefix", ",", "$", "namespaces", ")", ")", "return", "parent", "::", "addAttribute", "(", "$", "key", ",", "$", "value", ",", "$", "namespaces", "[", "$", "nsPrefix", "]", ")", ";", "if", "(", "$", "nsURI", ")", "return", "parent", "::", "addAttribute", "(", "$", "key", ",", "$", "value", ",", "$", "nsURI", ")", ";", "throw", "new", "RuntimeException", "(", "'Namespace prefix is not registered and namespace URI is missing'", ")", ";", "}", "if", "(", "$", "this", "->", "hasAttribute", "(", "$", "name", ")", ")", "throw", "new", "RuntimeException", "(", "'Attribute \"'", ".", "$", "name", ".", "'\" is already set'", ")", ";", "parent", "::", "addAttribute", "(", "$", "name", ",", "$", "value", ")", ";", "}" ]
Adds an attributes. @access public @param string $name Name of attribute @param string $value Value of attribute @param string $nsPrefix Namespace prefix of attribute @param string $nsURI Namespace URI of attribute @return void @throws RuntimeException if attribute is already set @throws RuntimeException if namespace prefix is neither registered nor given
[ "Adds", "an", "attributes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L56-L74
37,299
CeusMedia/Common
src/XML/Element.php
XML_Element.addChild
public function addChild( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL ) { $child = NULL; if( $nsPrefix ) { $namespaces = $this->getDocNamespaces(); $key = $nsPrefix ? $nsPrefix.':'.$name : $name; if( array_key_exists( $nsPrefix, $namespaces ) ) $child = parent::addChild( $name, NULL, $namespaces[$nsPrefix] ); else if( $nsURI ) $child = parent::addChild( $key, NULL, $nsURI ); else throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' ); } else $child = parent::addChild( $name ); if( $value !== NULL ) $child->setValue( $value ); return $child; }
php
public function addChild( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL ) { $child = NULL; if( $nsPrefix ) { $namespaces = $this->getDocNamespaces(); $key = $nsPrefix ? $nsPrefix.':'.$name : $name; if( array_key_exists( $nsPrefix, $namespaces ) ) $child = parent::addChild( $name, NULL, $namespaces[$nsPrefix] ); else if( $nsURI ) $child = parent::addChild( $key, NULL, $nsURI ); else throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' ); } else $child = parent::addChild( $name ); if( $value !== NULL ) $child->setValue( $value ); return $child; }
[ "public", "function", "addChild", "(", "$", "name", ",", "$", "value", "=", "NULL", ",", "$", "nsPrefix", "=", "NULL", ",", "$", "nsURI", "=", "NULL", ")", "{", "$", "child", "=", "NULL", ";", "if", "(", "$", "nsPrefix", ")", "{", "$", "namespaces", "=", "$", "this", "->", "getDocNamespaces", "(", ")", ";", "$", "key", "=", "$", "nsPrefix", "?", "$", "nsPrefix", ".", "':'", ".", "$", "name", ":", "$", "name", ";", "if", "(", "array_key_exists", "(", "$", "nsPrefix", ",", "$", "namespaces", ")", ")", "$", "child", "=", "parent", "::", "addChild", "(", "$", "name", ",", "NULL", ",", "$", "namespaces", "[", "$", "nsPrefix", "]", ")", ";", "else", "if", "(", "$", "nsURI", ")", "$", "child", "=", "parent", "::", "addChild", "(", "$", "key", ",", "NULL", ",", "$", "nsURI", ")", ";", "else", "throw", "new", "RuntimeException", "(", "'Namespace prefix is not registered and namespace URI is missing'", ")", ";", "}", "else", "$", "child", "=", "parent", "::", "addChild", "(", "$", "name", ")", ";", "if", "(", "$", "value", "!==", "NULL", ")", "$", "child", "->", "setValue", "(", "$", "value", ")", ";", "return", "$", "child", ";", "}" ]
Adds a child element. Sets node content as CDATA section if necessary. @access public @param string $name Name of child element @param string $value Value of child element @param string $nsPrefix Namespace prefix of child element @param string $nsURI Namespace URI of child element @return XML_Element @throws RuntimeException if namespace prefix is neither registered nor given
[ "Adds", "a", "child", "element", ".", "Sets", "node", "content", "as", "CDATA", "section", "if", "necessary", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L97-L116