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
partition
stringclasses
1 value
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.isPath
public function isPath( $source, $target, $hadNodes = array() ) { if( $this->isEdge( $source, $target ) ) return true; $nodes = $this->getTargetNodes( $source ); $hadNodes[] = $source->getNodeName(); foreach( $nodes as $node ) if( !in_array( $node->getNodeName(), $hadNodes ) ) if( $this->isPath( $node, $target, $hadNodes ) ) return true; return false; }
php
public function isPath( $source, $target, $hadNodes = array() ) { if( $this->isEdge( $source, $target ) ) return true; $nodes = $this->getTargetNodes( $source ); $hadNodes[] = $source->getNodeName(); foreach( $nodes as $node ) if( !in_array( $node->getNodeName(), $hadNodes ) ) if( $this->isPath( $node, $target, $hadNodes ) ) return true; return false; }
[ "public", "function", "isPath", "(", "$", "source", ",", "$", "target", ",", "$", "hadNodes", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "isEdge", "(", "$", "source", ",", "$", "target", ")", ")", "return", "true", ";", "$", ...
Ist Weg ? - ist Folge - keinen Knoten doppelt besucht @access public @param ADT_Graph_Node $source Source Node of this Edge @param ADT_Graph_Node $target Target Node of this Edge @param array $hadNodes Already visited Node. @return bool
[ "Ist", "Weg", "?", "-", "ist", "Folge", "-", "keinen", "Knoten", "doppelt", "besucht" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L463-L474
train
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.isWood
public function isWood() { if( !$this->hasCycle() ) { $nodes = $this->getNodes(); foreach( $nodes as $targetSource ) foreach( $nodes as $source ) if( $source != $targetSource ) if( $this->getEntranceGrade( $source, $targetSource ) > 1 ) return false; return true; } else return false; }
php
public function isWood() { if( !$this->hasCycle() ) { $nodes = $this->getNodes(); foreach( $nodes as $targetSource ) foreach( $nodes as $source ) if( $source != $targetSource ) if( $this->getEntranceGrade( $source, $targetSource ) > 1 ) return false; return true; } else return false; }
[ "public", "function", "isWood", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasCycle", "(", ")", ")", "{", "$", "nodes", "=", "$", "this", "->", "getNodes", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "targetSource", ")", "fore...
Ist Wald ? -> Eingangsgrad aller Knoten > 1 @access public @return bool
[ "Ist", "Wald", "?", "-", ">", "Eingangsgrad", "aller", "Knoten", ">", "1" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L481-L494
train
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.makeTransitive
public function makeTransitive() { $nodes = $this->getNodes(); foreach( $nodes as $source ) { foreach( $nodes as $target ) { if( $source != $target && $this->isEdge( $source, $target ) ) { $value1 = $this->getEdgeValue( $source, $target ); foreach( $nodes as $step ) { if( $source != $step && $target != $step && $this->isEdge( $target, $step ) ) { $value2 = $this->getEdgeValue( $target, $step ); if( $this->getEdgeValue( $source, $step ) != ( $value1 + $value2 ) ) $this->addEdge( $source, $step, $value1 + $value2 ); } } } } } }
php
public function makeTransitive() { $nodes = $this->getNodes(); foreach( $nodes as $source ) { foreach( $nodes as $target ) { if( $source != $target && $this->isEdge( $source, $target ) ) { $value1 = $this->getEdgeValue( $source, $target ); foreach( $nodes as $step ) { if( $source != $step && $target != $step && $this->isEdge( $target, $step ) ) { $value2 = $this->getEdgeValue( $target, $step ); if( $this->getEdgeValue( $source, $step ) != ( $value1 + $value2 ) ) $this->addEdge( $source, $step, $value1 + $value2 ); } } } } } }
[ "public", "function", "makeTransitive", "(", ")", "{", "$", "nodes", "=", "$", "this", "->", "getNodes", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "source", ")", "{", "foreach", "(", "$", "nodes", "as", "$", "target", ")", "{", "if", ...
Sets transitive closure with values with Warshall algorithm. @access public @return void
[ "Sets", "transitive", "closure", "with", "values", "with", "Warshall", "algorithm", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L501-L523
train
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.toList
public function toList() { $list = array(); $nodes = $this->getNodes(); foreach( $nodes as $source ) { $sublist = array(); foreach( $nodes as $target ) { if( $this->isEdge( $source, $target ) ) $sublist[$target->getNodeName()] = $this->getEdgeValue( $source, $target ); } $list [$source->getNodeName()] = $sublist; } return $list; }
php
public function toList() { $list = array(); $nodes = $this->getNodes(); foreach( $nodes as $source ) { $sublist = array(); foreach( $nodes as $target ) { if( $this->isEdge( $source, $target ) ) $sublist[$target->getNodeName()] = $this->getEdgeValue( $source, $target ); } $list [$source->getNodeName()] = $sublist; } return $list; }
[ "public", "function", "toList", "(", ")", "{", "$", "list", "=", "array", "(", ")", ";", "$", "nodes", "=", "$", "this", "->", "getNodes", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "source", ")", "{", "$", "sublist", "=", "array", ...
Returns all Nodes and Edges of this Graph as list. @access public @return array
[ "Returns", "all", "Nodes", "and", "Edges", "of", "this", "Graph", "as", "list", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L616-L631
train
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.toMatrix
public function toMatrix( $filename = false ) { if( $filename) $m = new AssocFileMatrix( $filename ); else $m = new AssocMatrix(); $nodes = $this->getNodes(); foreach( $nodes as $source ) { echo $source->getNodeName()."<br>"; foreach( $nodes as $target ) { if( $this->isEdge($source, $target ) || $this->isEdge($target, $source ) ) { $value = $this->getEdgeValue( $source, $target ); } else $value = 0; $m->addValueAssoc( $source->getNodeName(), $target->getNodeName(), $value ); } } return $m; }
php
public function toMatrix( $filename = false ) { if( $filename) $m = new AssocFileMatrix( $filename ); else $m = new AssocMatrix(); $nodes = $this->getNodes(); foreach( $nodes as $source ) { echo $source->getNodeName()."<br>"; foreach( $nodes as $target ) { if( $this->isEdge($source, $target ) || $this->isEdge($target, $source ) ) { $value = $this->getEdgeValue( $source, $target ); } else $value = 0; $m->addValueAssoc( $source->getNodeName(), $target->getNodeName(), $value ); } } return $m; }
[ "public", "function", "toMatrix", "(", "$", "filename", "=", "false", ")", "{", "if", "(", "$", "filename", ")", "$", "m", "=", "new", "AssocFileMatrix", "(", "$", "filename", ")", ";", "else", "$", "m", "=", "new", "AssocMatrix", "(", ")", ";", "$...
Returns all nodes and edges of this graph as an associative file matrix. @access public @param string $filename URI of File Matrix to write @return AssocFileMatrix @todo rebuild for KeyMatrix / MatrixWriter
[ "Returns", "all", "nodes", "and", "edges", "of", "this", "graph", "as", "an", "associative", "file", "matrix", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L640-L660
train
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.toTable
public function toTable( $showNull = false) { $heading = ""; $t = "<table class='filledframe' cellpadding=2 cellspacing=0>"; $nodes = $this->getNodes(); for( $j=0; $j<$this->getNodeSize(); $j++ ) { $target = $nodes[$j]; $heading .= "<th width=20>".$target->getNodeName()."</th>"; } $t .= "<tr><th></th>".$heading."</tr>"; for( $i=0; $i<$this->getNodeSize(); $i++ ) { $source = $nodes[$i]; $line = ""; for( $j=0; $j<$this->getNodeSize(); $j++ ) { $target = $nodes[$j]; if( $this->isEdge( $source, $target ) ) $value = $this->getEdgeValue( $source, $target ); else if( $showNull ) $value = 0; else $value = ""; $line .= "<td align=center>".$value."</td>"; } $t .= "<tr><th width=20>".$source->getNodeName()."</th>".$line."</tr>"; } $t .= "</table>"; return $t; }
php
public function toTable( $showNull = false) { $heading = ""; $t = "<table class='filledframe' cellpadding=2 cellspacing=0>"; $nodes = $this->getNodes(); for( $j=0; $j<$this->getNodeSize(); $j++ ) { $target = $nodes[$j]; $heading .= "<th width=20>".$target->getNodeName()."</th>"; } $t .= "<tr><th></th>".$heading."</tr>"; for( $i=0; $i<$this->getNodeSize(); $i++ ) { $source = $nodes[$i]; $line = ""; for( $j=0; $j<$this->getNodeSize(); $j++ ) { $target = $nodes[$j]; if( $this->isEdge( $source, $target ) ) $value = $this->getEdgeValue( $source, $target ); else if( $showNull ) $value = 0; else $value = ""; $line .= "<td align=center>".$value."</td>"; } $t .= "<tr><th width=20>".$source->getNodeName()."</th>".$line."</tr>"; } $t .= "</table>"; return $t; }
[ "public", "function", "toTable", "(", "$", "showNull", "=", "false", ")", "{", "$", "heading", "=", "\"\"", ";", "$", "t", "=", "\"<table class='filledframe' cellpadding=2 cellspacing=0>\"", ";", "$", "nodes", "=", "$", "this", "->", "getNodes", "(", ")", ";...
Returns all nodes and edges of this graph as HTML-table. @access public @param bool $showNull flag: show Zero @return string
[ "Returns", "all", "nodes", "and", "edges", "of", "this", "graph", "as", "HTML", "-", "table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L668-L699
train
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.traverseDeepth
public function traverseDeepth( $source, $queue = array(), $hadNodes = false ) { $nextnodeSet = array(); if( !$hadNodes) $hadNodes = array(); $hadNodes[] = $source->getNodeName(); array_push($queue, $source ); foreach( $this->getSourceNodes( $source) as $node ) { if( !in_array( $node->getNodeName(), $hadNodes ) ) { $hadNodes[] = $node->getNodeName(); $nextnodeSet[] = $node; } } foreach( $this->getTargetNodes( $source) as $node ) { if( !in_array( $node->getNodeName(), $hadNodes ) ) { $hadNodes[] = $node->getNodeName(); $queue = $this->traverseDeepth( $node, $queue, $hadNodes ); } } foreach( $nextnodeSet as $node ) { $queue = $this->traverseDeepth( $node, $queue, $hadNodes ); } return $queue; }
php
public function traverseDeepth( $source, $queue = array(), $hadNodes = false ) { $nextnodeSet = array(); if( !$hadNodes) $hadNodes = array(); $hadNodes[] = $source->getNodeName(); array_push($queue, $source ); foreach( $this->getSourceNodes( $source) as $node ) { if( !in_array( $node->getNodeName(), $hadNodes ) ) { $hadNodes[] = $node->getNodeName(); $nextnodeSet[] = $node; } } foreach( $this->getTargetNodes( $source) as $node ) { if( !in_array( $node->getNodeName(), $hadNodes ) ) { $hadNodes[] = $node->getNodeName(); $queue = $this->traverseDeepth( $node, $queue, $hadNodes ); } } foreach( $nextnodeSet as $node ) { $queue = $this->traverseDeepth( $node, $queue, $hadNodes ); } return $queue; }
[ "public", "function", "traverseDeepth", "(", "$", "source", ",", "$", "queue", "=", "array", "(", ")", ",", "$", "hadNodes", "=", "false", ")", "{", "$", "nextnodeSet", "=", "array", "(", ")", ";", "if", "(", "!", "$", "hadNodes", ")", "$", "hadNod...
Traverses graph in deepth and build queue of all Nodes. @access public @param ADT_Graph_Node $source Source Node @param ADT_List_Queue $queue Queue to fill with Nodes @param array $hadNodes Array of already visited Nodes @return ADT_List_Queue
[ "Traverses", "graph", "in", "deepth", "and", "build", "queue", "of", "all", "Nodes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L709-L736
train
ncou/Chiron
src/Chiron/Http/Cookie/CookiesManager.php
CookiesManager.set
public function set($name, $value) { if (! is_array($value)) { $value = ['value' => (string) $value]; } $this->responseCookies[$name] = array_replace($this->defaults, $value); }
php
public function set($name, $value) { if (! is_array($value)) { $value = ['value' => (string) $value]; } $this->responseCookies[$name] = array_replace($this->defaults, $value); }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "'value'", "=>", "(", "string", ")", "$", "value", "]", ";", "}", "$", "this", "...
Set response cookie. @param string $name Cookie name @param string|array $value Cookie value, or cookie properties
[ "Set", "response", "cookie", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Cookie/CookiesManager.php#L62-L68
train
CeusMedia/Common
src/Net/XMPP/XMPPHP/XMLStream.php
Net_XMPP_XMPPHP_XMLStream.connect
public function connect($timeout = 30, $persistent = false, $sendinit = true) { $this->sent_disconnect = false; $starttime = time(); do { $this->disconnected = false; $this->sent_disconnect = false; if($persistent) { $conflag = STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT; } else { $conflag = STREAM_CLIENT_CONNECT; } $conntype = 'tcp'; if($this->use_ssl) $conntype = 'ssl'; $this->log->log("Connecting to $conntype://{$this->host}:{$this->port}"); try { $this->socket = @stream_socket_client("$conntype://{$this->host}:{$this->port}", $errno, $errstr, $timeout, $conflag); } catch (Exception $e) { throw new Net_XMPP_XMPPHP_Exception($e->getMessage()); } if(!$this->socket) { $this->log->log("Could not connect.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); $this->disconnected = true; # Take it easy for a few seconds sleep(min($timeout, 5)); } } while (!$this->socket && (time() - $starttime) < $timeout); if ($this->socket) { stream_set_blocking($this->socket, 1); if($sendinit) $this->send($this->stream_start); } else { throw new Net_XMPP_XMPPHP_Exception("Could not connect before timeout."); } }
php
public function connect($timeout = 30, $persistent = false, $sendinit = true) { $this->sent_disconnect = false; $starttime = time(); do { $this->disconnected = false; $this->sent_disconnect = false; if($persistent) { $conflag = STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT; } else { $conflag = STREAM_CLIENT_CONNECT; } $conntype = 'tcp'; if($this->use_ssl) $conntype = 'ssl'; $this->log->log("Connecting to $conntype://{$this->host}:{$this->port}"); try { $this->socket = @stream_socket_client("$conntype://{$this->host}:{$this->port}", $errno, $errstr, $timeout, $conflag); } catch (Exception $e) { throw new Net_XMPP_XMPPHP_Exception($e->getMessage()); } if(!$this->socket) { $this->log->log("Could not connect.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); $this->disconnected = true; # Take it easy for a few seconds sleep(min($timeout, 5)); } } while (!$this->socket && (time() - $starttime) < $timeout); if ($this->socket) { stream_set_blocking($this->socket, 1); if($sendinit) $this->send($this->stream_start); } else { throw new Net_XMPP_XMPPHP_Exception("Could not connect before timeout."); } }
[ "public", "function", "connect", "(", "$", "timeout", "=", "30", ",", "$", "persistent", "=", "false", ",", "$", "sendinit", "=", "true", ")", "{", "$", "this", "->", "sent_disconnect", "=", "false", ";", "$", "starttime", "=", "time", "(", ")", ";",...
Connect to XMPP Host @param integer $timeout @param boolean $persistent @param boolean $sendinit
[ "Connect", "to", "XMPP", "Host" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/XMPPHP/XMLStream.php#L285-L319
train
CeusMedia/Common
src/Net/XMPP/XMPPHP/XMLStream.php
Net_XMPP_XMPPHP_XMLStream.doReconnect
public function doReconnect() { if(!$this->is_server) { $this->log->log("Reconnecting ($this->reconnectTimeout)...", Net_XMPP_XMPPHP_Log::LEVEL_WARNING); $this->connect($this->reconnectTimeout, false, false); $this->reset(); $this->event('reconnect'); } }
php
public function doReconnect() { if(!$this->is_server) { $this->log->log("Reconnecting ($this->reconnectTimeout)...", Net_XMPP_XMPPHP_Log::LEVEL_WARNING); $this->connect($this->reconnectTimeout, false, false); $this->reset(); $this->event('reconnect'); } }
[ "public", "function", "doReconnect", "(", ")", "{", "if", "(", "!", "$", "this", "->", "is_server", ")", "{", "$", "this", "->", "log", "->", "log", "(", "\"Reconnecting ($this->reconnectTimeout)...\"", ",", "Net_XMPP_XMPPHP_Log", "::", "LEVEL_WARNING", ")", "...
Reconnect XMPP Host
[ "Reconnect", "XMPP", "Host" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/XMPPHP/XMLStream.php#L324-L331
train
CeusMedia/Common
src/Net/XMPP/XMPPHP/XMLStream.php
Net_XMPP_XMPPHP_XMLStream.read
public function read() { $buff = @fread($this->socket, 1024); if(!$buff) { if($this->reconnect) { $this->doReconnect(); } else { fclose($this->socket); return false; } } $this->log->log("RECV: $buff", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); xml_parse($this->parser, $buff, false); }
php
public function read() { $buff = @fread($this->socket, 1024); if(!$buff) { if($this->reconnect) { $this->doReconnect(); } else { fclose($this->socket); return false; } } $this->log->log("RECV: $buff", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); xml_parse($this->parser, $buff, false); }
[ "public", "function", "read", "(", ")", "{", "$", "buff", "=", "@", "fread", "(", "$", "this", "->", "socket", ",", "1024", ")", ";", "if", "(", "!", "$", "buff", ")", "{", "if", "(", "$", "this", "->", "reconnect", ")", "{", "$", "this", "->...
Read from socket
[ "Read", "from", "socket" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/XMPPHP/XMLStream.php#L655-L667
train
CeusMedia/Common
src/Net/XMPP/XMPPHP/XMLStream.php
Net_XMPP_XMPPHP_XMLStream.send
public function send($msg, $timeout=NULL) { if (is_null($timeout)) { $secs = NULL; $usecs = NULL; } else if ($timeout == 0) { $secs = 0; $usecs = 0; } else { $maximum = $timeout * 1000000; $usecs = $maximum % 1000000; $secs = floor(($maximum - $usecs) / 1000000); } $read = array(); $write = array($this->socket); $except = array(); $select = @stream_select($read, $write, $except, $secs, $usecs); if($select === False) { $this->log->log("ERROR sending message; reconnecting."); $this->doReconnect(); # TODO: retry send here return false; } elseif ($select > 0) { $this->log->log("Socket is ready; send it.", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); } else { $this->log->log("Socket is not ready; break.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); return false; } $sentbytes = @fwrite($this->socket, $msg); $this->log->log("SENT: " . mb_substr($msg, 0, $sentbytes, '8bit'), Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); if($sentbytes === FALSE) { $this->log->log("ERROR sending message; reconnecting.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); $this->doReconnect(); return false; } $this->log->log("Successfully sent $sentbytes bytes.", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); return $sentbytes; }
php
public function send($msg, $timeout=NULL) { if (is_null($timeout)) { $secs = NULL; $usecs = NULL; } else if ($timeout == 0) { $secs = 0; $usecs = 0; } else { $maximum = $timeout * 1000000; $usecs = $maximum % 1000000; $secs = floor(($maximum - $usecs) / 1000000); } $read = array(); $write = array($this->socket); $except = array(); $select = @stream_select($read, $write, $except, $secs, $usecs); if($select === False) { $this->log->log("ERROR sending message; reconnecting."); $this->doReconnect(); # TODO: retry send here return false; } elseif ($select > 0) { $this->log->log("Socket is ready; send it.", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); } else { $this->log->log("Socket is not ready; break.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); return false; } $sentbytes = @fwrite($this->socket, $msg); $this->log->log("SENT: " . mb_substr($msg, 0, $sentbytes, '8bit'), Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); if($sentbytes === FALSE) { $this->log->log("ERROR sending message; reconnecting.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); $this->doReconnect(); return false; } $this->log->log("Successfully sent $sentbytes bytes.", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); return $sentbytes; }
[ "public", "function", "send", "(", "$", "msg", ",", "$", "timeout", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "timeout", ")", ")", "{", "$", "secs", "=", "NULL", ";", "$", "usecs", "=", "NULL", ";", "}", "else", "if", "(", "$", "...
Send to socket @param string $msg
[ "Send", "to", "socket" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/XMPPHP/XMLStream.php#L674-L714
train
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.deleteCharAt
public function deleteCharAt( $position ) { $string = ""; for( $i = 0; $i < $this->count(); $i++ ) if( $position != $i ) $string .= $this->buffer[$i]; $this->buffer = $string; if( $position == $this->pointer ) $this->pointer++; return $this->toString(); }
php
public function deleteCharAt( $position ) { $string = ""; for( $i = 0; $i < $this->count(); $i++ ) if( $position != $i ) $string .= $this->buffer[$i]; $this->buffer = $string; if( $position == $this->pointer ) $this->pointer++; return $this->toString(); }
[ "public", "function", "deleteCharAt", "(", "$", "position", ")", "{", "$", "string", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "count", "(", ")", ";", "$", "i", "++", ")", "if", "(", "$", "positi...
Deletes a Character at a given Position. @access public @param int $position Position to delete @return string
[ "Deletes", "a", "Character", "at", "a", "given", "Position", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L85-L95
train
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.getCharAt
public function getCharAt( $position ) { if($position <= $this->count() && $position >= 0 ) $character = $this->buffer[$position]; return $character; }
php
public function getCharAt( $position ) { if($position <= $this->count() && $position >= 0 ) $character = $this->buffer[$position]; return $character; }
[ "public", "function", "getCharAt", "(", "$", "position", ")", "{", "if", "(", "$", "position", "<=", "$", "this", "->", "count", "(", ")", "&&", "$", "position", ">=", "0", ")", "$", "character", "=", "$", "this", "->", "buffer", "[", "$", "positio...
Returns the Character at a given Position. @access public @param int $position Position @return string
[ "Returns", "the", "Character", "at", "a", "given", "Position", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L103-L108
train
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.getNextChar
public function getNextChar() { $character = NULL; if( $this->direction == "<" ) $this->pointer++; if( $this->pointer < $this->count() && $this->pointer >=0 ) { $this->direction = ">"; $character = $this->buffer[$this->pointer]; $this->pointer++; } return $character; }
php
public function getNextChar() { $character = NULL; if( $this->direction == "<" ) $this->pointer++; if( $this->pointer < $this->count() && $this->pointer >=0 ) { $this->direction = ">"; $character = $this->buffer[$this->pointer]; $this->pointer++; } return $character; }
[ "public", "function", "getNextChar", "(", ")", "{", "$", "character", "=", "NULL", ";", "if", "(", "$", "this", "->", "direction", "==", "\"<\"", ")", "$", "this", "->", "pointer", "++", ";", "if", "(", "$", "this", "->", "pointer", "<", "$", "this...
Returns the next Character. @access public @return string
[ "Returns", "the", "next", "Character", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L136-L148
train
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.getPrevChar
public function getPrevChar() { if( $this->direction == ">" ) $this->pointer--; if( $this->pointer <= $this->count() && $this->pointer > 0 ) { $this->direction = "<"; $this->pointer--; $character = $this->buffer[$this->pointer]; } return $character; }
php
public function getPrevChar() { if( $this->direction == ">" ) $this->pointer--; if( $this->pointer <= $this->count() && $this->pointer > 0 ) { $this->direction = "<"; $this->pointer--; $character = $this->buffer[$this->pointer]; } return $character; }
[ "public", "function", "getPrevChar", "(", ")", "{", "if", "(", "$", "this", "->", "direction", "==", "\">\"", ")", "$", "this", "->", "pointer", "--", ";", "if", "(", "$", "this", "->", "pointer", "<=", "$", "this", "->", "count", "(", ")", "&&", ...
Returns the previous Character. @access public @return string
[ "Returns", "the", "previous", "Character", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L155-L166
train
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.insert
public function insert( $position, $string ) { if( $position<= $this->count() && $position >=0 ) { if( $position < $this->pointer ) $this->pointer = $this->pointer + strlen( $string ); $left = substr( $this->toString(), 0, $position ); $right = substr( $this->toString(), $position ); $this->buffer = $left.$string.$right; } return $this->toString(); }
php
public function insert( $position, $string ) { if( $position<= $this->count() && $position >=0 ) { if( $position < $this->pointer ) $this->pointer = $this->pointer + strlen( $string ); $left = substr( $this->toString(), 0, $position ); $right = substr( $this->toString(), $position ); $this->buffer = $left.$string.$right; } return $this->toString(); }
[ "public", "function", "insert", "(", "$", "position", ",", "$", "string", ")", "{", "if", "(", "$", "position", "<=", "$", "this", "->", "count", "(", ")", "&&", "$", "position", ">=", "0", ")", "{", "if", "(", "$", "position", "<", "$", "this", ...
Inserts a String at a given Position. @access public @param int $position Position to insert to @param string $string String to insert @return string
[ "Inserts", "a", "String", "at", "a", "given", "Position", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L199-L210
train
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.setCharAt
public function setCharAt( $position, $character ) { if( $position <= $this->count() && $position >= 0 ) $this->buffer[$position] = $character; return $this->toString(); }
php
public function setCharAt( $position, $character ) { if( $position <= $this->count() && $position >= 0 ) $this->buffer[$position] = $character; return $this->toString(); }
[ "public", "function", "setCharAt", "(", "$", "position", ",", "$", "character", ")", "{", "if", "(", "$", "position", "<=", "$", "this", "->", "count", "(", ")", "&&", "$", "position", ">=", "0", ")", "$", "this", "->", "buffer", "[", "$", "positio...
Sets the Character at a given Position. @access public @param int $position Position to set to @param string $characte Character to set @return string
[ "Sets", "the", "Character", "at", "a", "given", "Position", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L242-L247
train
CeusMedia/Common
src/XML/Converter.php
XML_Converter.convertToObjectRecursive
protected static function convertToObjectRecursive( $node, $object ) { $object->children = new stdClass(); $object->attributes = new stdClass(); foreach( $node->getChildren() as $childNode ) { $childObject = new stdClass(); $nodeName = $childNode->getNodeName(); $object->children->$nodeName = $childObject; self::convertToObjectRecursive( $childNode, $childObject ); } if( $node->getAttributes() ) { foreach( $node->getAttributes() as $key => $value ) $object->attributes->$key = $value; } $object->content = $node->getContent(); }
php
protected static function convertToObjectRecursive( $node, $object ) { $object->children = new stdClass(); $object->attributes = new stdClass(); foreach( $node->getChildren() as $childNode ) { $childObject = new stdClass(); $nodeName = $childNode->getNodeName(); $object->children->$nodeName = $childObject; self::convertToObjectRecursive( $childNode, $childObject ); } if( $node->getAttributes() ) { foreach( $node->getAttributes() as $key => $value ) $object->attributes->$key = $value; } $object->content = $node->getContent(); }
[ "protected", "static", "function", "convertToObjectRecursive", "(", "$", "node", ",", "$", "object", ")", "{", "$", "object", "->", "children", "=", "new", "stdClass", "(", ")", ";", "$", "object", "->", "attributes", "=", "new", "stdClass", "(", ")", ";...
Converts DOM node to tree of objects recursively and in-situ. @static @access protected @param DOMNode $node DOM node to convert @param object $object Tree for objects @return void
[ "Converts", "DOM", "node", "to", "tree", "of", "objects", "recursively", "and", "in", "-", "situ", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Converter.php#L82-L99
train
CeusMedia/Common
src/Net/Site/MapWriter.php
Net_Site_MapWriter.save
public static function save( $fileName, $urls, $mode = 0777 ) { $builder = new Net_Site_MapBuilder(); $file = new FS_File_Writer( $fileName, $mode ); $xml = $builder->build( $urls ); return $file->writeString( $xml ); }
php
public static function save( $fileName, $urls, $mode = 0777 ) { $builder = new Net_Site_MapBuilder(); $file = new FS_File_Writer( $fileName, $mode ); $xml = $builder->build( $urls ); return $file->writeString( $xml ); }
[ "public", "static", "function", "save", "(", "$", "fileName", ",", "$", "urls", ",", "$", "mode", "=", "0777", ")", "{", "$", "builder", "=", "new", "Net_Site_MapBuilder", "(", ")", ";", "$", "file", "=", "new", "FS_File_Writer", "(", "$", "fileName", ...
Saves Sitemap for List of URLs statically. @access public @static @param string $fileName File Name of Sitemap XML File @param array $urls List of URLs for Sitemap @param int $mode Right Mode @return int
[ "Saves", "Sitemap", "for", "List", "of", "URLs", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/MapWriter.php#L79-L85
train
CeusMedia/Common
src/XML/Validator.php
XML_Validator.validate
public function validate( $xml ) { $parser = xml_parser_create(); $dummy = create_function( '', '' ); xml_set_element_handler( $parser, $dummy, $dummy ); xml_set_character_data_handler( $parser, $dummy ); if( !xml_parse( $parser, $xml ) ) { $msg = "%s at line %d"; $error = xml_error_string( xml_get_error_code( $parser ) ); $line = xml_get_current_line_number( $parser ); $this->error['message'] = sprintf( $msg, $error, $line ); $this->error['line'] = $line; $this->error['xml'] = $xml; xml_parser_free( $parser ); return FALSE; } xml_parser_free( $parser ); return TRUE; }
php
public function validate( $xml ) { $parser = xml_parser_create(); $dummy = create_function( '', '' ); xml_set_element_handler( $parser, $dummy, $dummy ); xml_set_character_data_handler( $parser, $dummy ); if( !xml_parse( $parser, $xml ) ) { $msg = "%s at line %d"; $error = xml_error_string( xml_get_error_code( $parser ) ); $line = xml_get_current_line_number( $parser ); $this->error['message'] = sprintf( $msg, $error, $line ); $this->error['line'] = $line; $this->error['xml'] = $xml; xml_parser_free( $parser ); return FALSE; } xml_parser_free( $parser ); return TRUE; }
[ "public", "function", "validate", "(", "$", "xml", ")", "{", "$", "parser", "=", "xml_parser_create", "(", ")", ";", "$", "dummy", "=", "create_function", "(", "''", ",", "''", ")", ";", "xml_set_element_handler", "(", "$", "parser", ",", "$", "dummy", ...
Validates XML File. @access public @param string $xml XML String to validate @return bool
[ "Validates", "XML", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Validator.php#L96-L115
train
CeusMedia/Common
src/Net/IMAP/Message.php
Net_IMAP_Message.getBody
protected function getBody( $type ) { $count = 0; $structure = $this->getMessageStructure(); foreach( $structure->parts as $part ) { $count++; if( $part->type !== 0 ) continue; if( $part->subtype == $type ) { $body = imap_fetchbody( $this->stream, $this->messageNumber, $count ); $body = $this->decodeBody( $body, $part->encoding ); return $body; } } }
php
protected function getBody( $type ) { $count = 0; $structure = $this->getMessageStructure(); foreach( $structure->parts as $part ) { $count++; if( $part->type !== 0 ) continue; if( $part->subtype == $type ) { $body = imap_fetchbody( $this->stream, $this->messageNumber, $count ); $body = $this->decodeBody( $body, $part->encoding ); return $body; } } }
[ "protected", "function", "getBody", "(", "$", "type", ")", "{", "$", "count", "=", "0", ";", "$", "structure", "=", "$", "this", "->", "getMessageStructure", "(", ")", ";", "foreach", "(", "$", "structure", "->", "parts", "as", "$", "part", ")", "{",...
Returns Body. @access public @param string $type Body Type (TYPE_PLAIN | TYPE_HTML) @return string
[ "Returns", "Body", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Message.php#L105-L121
train
CeusMedia/Common
src/Net/IMAP/Message.php
Net_IMAP_Message.decodeBody
protected function decodeBody( $body, $encoding ) { switch( $encoding ) { case 3: $body = base64_decode( $body ); break; case 4: $body = quoted_printable_decode( $body ); break; } return $body; }
php
protected function decodeBody( $body, $encoding ) { switch( $encoding ) { case 3: $body = base64_decode( $body ); break; case 4: $body = quoted_printable_decode( $body ); break; } return $body; }
[ "protected", "function", "decodeBody", "(", "$", "body", ",", "$", "encoding", ")", "{", "switch", "(", "$", "encoding", ")", "{", "case", "3", ":", "$", "body", "=", "base64_decode", "(", "$", "body", ")", ";", "break", ";", "case", "4", ":", "$",...
Decodes encoded Body. @access public @param string $body Body Content @param int $encoding Encoding Type @return string
[ "Decodes", "encoded", "Body", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Message.php#L130-L142
train
CeusMedia/Common
src/Net/IMAP/Message.php
Net_IMAP_Message.getHeaderInfo
public function getHeaderInfo() { if( !$this->info ) $this->info = imap_headerinfo( $this->stream, $this->messageNumber ); return $this->info; }
php
public function getHeaderInfo() { if( !$this->info ) $this->info = imap_headerinfo( $this->stream, $this->messageNumber ); return $this->info; }
[ "public", "function", "getHeaderInfo", "(", ")", "{", "if", "(", "!", "$", "this", "->", "info", ")", "$", "this", "->", "info", "=", "imap_headerinfo", "(", "$", "this", "->", "stream", ",", "$", "this", "->", "messageNumber", ")", ";", "return", "$...
Returns Information Object of Message Header. @access public @return object
[ "Returns", "Information", "Object", "of", "Message", "Header", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Message.php#L149-L154
train
CeusMedia/Common
src/Net/IMAP/Message.php
Net_IMAP_Message.getMessageStructure
public function getMessageStructure() { if( !$this->structure ) $this->structure = imap_fetchstructure( $this->stream, $this->messageNumber ); return $this->structure; }
php
public function getMessageStructure() { if( !$this->structure ) $this->structure = imap_fetchstructure( $this->stream, $this->messageNumber ); return $this->structure; }
[ "public", "function", "getMessageStructure", "(", ")", "{", "if", "(", "!", "$", "this", "->", "structure", ")", "$", "this", "->", "structure", "=", "imap_fetchstructure", "(", "$", "this", "->", "stream", ",", "$", "this", "->", "messageNumber", ")", "...
Returns Structure Object of Message. @access public @return object
[ "Returns", "Structure", "Object", "of", "Message", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Message.php#L161-L166
train
theodorejb/peachy-sql
lib/SqlServer/Statement.php
Statement.close
public function close(): void { if (!sqlsrv_free_stmt($this->stmt)) { throw new SqlException('Failed to close statement', sqlsrv_errors(), $this->query, $this->params); } }
php
public function close(): void { if (!sqlsrv_free_stmt($this->stmt)) { throw new SqlException('Failed to close statement', sqlsrv_errors(), $this->query, $this->params); } }
[ "public", "function", "close", "(", ")", ":", "void", "{", "if", "(", "!", "sqlsrv_free_stmt", "(", "$", "this", "->", "stmt", ")", ")", "{", "throw", "new", "SqlException", "(", "'Failed to close statement'", ",", "sqlsrv_errors", "(", ")", ",", "$", "t...
Frees all resources associated with the result statement. @throws SqlException if failure closing the statement
[ "Frees", "all", "resources", "associated", "with", "the", "result", "statement", "." ]
f179c6fa6c4293c2713b6b59022f3cfc90890a98
https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/SqlServer/Statement.php#L79-L84
train
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.displayImage
public function displayImage( $image, $type) { switch ($type) { case 2: //JPEG header("Content-Type: image/jpeg"); Imagejpeg( $image); break; case 3: //PNG header("Content-Type: image/png"); Imagepng( $image); break; default: $this->errorMsg="File format not supported."; } }
php
public function displayImage( $image, $type) { switch ($type) { case 2: //JPEG header("Content-Type: image/jpeg"); Imagejpeg( $image); break; case 3: //PNG header("Content-Type: image/png"); Imagepng( $image); break; default: $this->errorMsg="File format not supported."; } }
[ "public", "function", "displayImage", "(", "$", "image", ",", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "2", ":", "//JPEG\r", "header", "(", "\"Content-Type: image/jpeg\"", ")", ";", "Imagejpeg", "(", "$", "image", ")", ";", ...
send image to stdout @param resource $image image @param int $type image type (2:JPEG or 3:PNG) @return void @access protected @uses errorMsg
[ "send", "image", "to", "stdout" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L62-L77
train
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.markImage
public function markImage ( $imageResource) { if (!$this->stampImage) { $this->errorMsg="Stamp image is not set."; return(false); } $imageWidth = imagesx( $imageResource); $imageHeight = imagesy( $imageResource); //set position of logo switch ($this->stampPositionX) { case transparentWatermarkOnLeft: $leftStamp=0; break; case transparentWatermarkOnCenter: $leftStamp=($imageWidth - $this->stampWidth)/2; break; case transparentWatermarkOnRight: $leftStamp=$imageWidth - $this->stampWidth; break; default : $leftStamp=0; } switch ($this->stampPositionY) { case transparentWatermarkOnTop: $topStamp=0; break; case transparentWatermarkOnMiddle: $topStamp=($imageHeight - $this->stampHeight)/2; break; case transparentWatermarkOnBottom: $topStamp=$imageHeight - $this->stampHeight; break; default: $topStamp=0; } // for each pixel of stamp for ($x=0; $x<$this->stampWidth; $x++) { if (($x+$leftStamp<0)||($x+$leftStamp>=$imageWidth)) continue; for ($y=0; $y<$this->stampHeight; $y++) { if (($y+$topStamp<0)||($y+$topStamp>=$imageHeight)) continue; // search RGB values of stamp image pixel $indexStamp=ImageColorAt($this->stampImage, $x, $y); $rgbStamp=imagecolorsforindex ( $this->stampImage, $indexStamp); // search RGB values of image pixel $indexImage=ImageColorAt( $imageResource, $x+$leftStamp, $y+$topStamp); $rgbImage=imagecolorsforindex ( $imageResource, $indexImage); $randomizer=0; // compute new values of colors pixel $r=max( min($rgbImage["red"]+$rgbStamp["red"]-0x80, 0xFF), 0x00); $g=max( min($rgbImage["green"]+$rgbStamp["green"]-0x80, 0xFF), 0x00); $b=max( min($rgbImage["blue"]+$rgbStamp["blue"]-0x80, 0xFF), 0x00); // change image pixel imagesetpixel ( $imageResource, $x+$leftStamp, $y+$topStamp, ($r<<16)+($g<<8)+$b); } } }
php
public function markImage ( $imageResource) { if (!$this->stampImage) { $this->errorMsg="Stamp image is not set."; return(false); } $imageWidth = imagesx( $imageResource); $imageHeight = imagesy( $imageResource); //set position of logo switch ($this->stampPositionX) { case transparentWatermarkOnLeft: $leftStamp=0; break; case transparentWatermarkOnCenter: $leftStamp=($imageWidth - $this->stampWidth)/2; break; case transparentWatermarkOnRight: $leftStamp=$imageWidth - $this->stampWidth; break; default : $leftStamp=0; } switch ($this->stampPositionY) { case transparentWatermarkOnTop: $topStamp=0; break; case transparentWatermarkOnMiddle: $topStamp=($imageHeight - $this->stampHeight)/2; break; case transparentWatermarkOnBottom: $topStamp=$imageHeight - $this->stampHeight; break; default: $topStamp=0; } // for each pixel of stamp for ($x=0; $x<$this->stampWidth; $x++) { if (($x+$leftStamp<0)||($x+$leftStamp>=$imageWidth)) continue; for ($y=0; $y<$this->stampHeight; $y++) { if (($y+$topStamp<0)||($y+$topStamp>=$imageHeight)) continue; // search RGB values of stamp image pixel $indexStamp=ImageColorAt($this->stampImage, $x, $y); $rgbStamp=imagecolorsforindex ( $this->stampImage, $indexStamp); // search RGB values of image pixel $indexImage=ImageColorAt( $imageResource, $x+$leftStamp, $y+$topStamp); $rgbImage=imagecolorsforindex ( $imageResource, $indexImage); $randomizer=0; // compute new values of colors pixel $r=max( min($rgbImage["red"]+$rgbStamp["red"]-0x80, 0xFF), 0x00); $g=max( min($rgbImage["green"]+$rgbStamp["green"]-0x80, 0xFF), 0x00); $b=max( min($rgbImage["blue"]+$rgbStamp["blue"]-0x80, 0xFF), 0x00); // change image pixel imagesetpixel ( $imageResource, $x+$leftStamp, $y+$topStamp, ($r<<16)+($g<<8)+$b); } } }
[ "public", "function", "markImage", "(", "$", "imageResource", ")", "{", "if", "(", "!", "$", "this", "->", "stampImage", ")", "{", "$", "this", "->", "errorMsg", "=", "\"Stamp image is not set.\"", ";", "return", "(", "false", ")", ";", "}", "$", "imageW...
mark an image @param int $imageResource resource of image @return boolean @access public @uses stampWidth @uses stampHeight @uses stampImage @uses stampPositionX @uses stampPositionY
[ "mark", "an", "image" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L142-L204
train
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.readImage
public function readImage( $file, $type) { switch ($type) { case 2: //JPEG return(ImageCreateFromJPEG($file)); break; case 3: //PNG return(ImageCreateFromPNG($file)); break; default: $this->errorMsg="File format not supported."; return(false); } }
php
public function readImage( $file, $type) { switch ($type) { case 2: //JPEG return(ImageCreateFromJPEG($file)); break; case 3: //PNG return(ImageCreateFromPNG($file)); break; default: $this->errorMsg="File format not supported."; return(false); } }
[ "public", "function", "readImage", "(", "$", "file", ",", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "2", ":", "//JPEG\r", "return", "(", "ImageCreateFromJPEG", "(", "$", "file", ")", ")", ";", "break", ";", "case", "3", "...
read image from file @param string $file image file (JPEG or PNG) @param int $type file type (2:JPEG or 3:PNG) @return resource @access protected @uses errorMsg
[ "read", "image", "from", "file" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L215-L229
train
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.setStamp
public function setStamp( $stampFile) { $imageinfos = @getimagesize($stampFile); $width = $imageinfos[0]; $height = $imageinfos[1]; $type = $imageinfos[2]; if ($this->stampImage) imagedestroy( $this->stampImage); $this->stampImage=$this->readImage($stampFile, $type); if (!$this->stampImage) { $this->errorMsg="Error on loading '$stampFile', stamp image must be a valid PNG or JPEG file."; return(false); } else { $this->stampWidth=$width; $this->stampHeight=$height; return(true); } }
php
public function setStamp( $stampFile) { $imageinfos = @getimagesize($stampFile); $width = $imageinfos[0]; $height = $imageinfos[1]; $type = $imageinfos[2]; if ($this->stampImage) imagedestroy( $this->stampImage); $this->stampImage=$this->readImage($stampFile, $type); if (!$this->stampImage) { $this->errorMsg="Error on loading '$stampFile', stamp image must be a valid PNG or JPEG file."; return(false); } else { $this->stampWidth=$width; $this->stampHeight=$height; return(true); } }
[ "public", "function", "setStamp", "(", "$", "stampFile", ")", "{", "$", "imageinfos", "=", "@", "getimagesize", "(", "$", "stampFile", ")", ";", "$", "width", "=", "$", "imageinfos", "[", "0", "]", ";", "$", "height", "=", "$", "imageinfos", "[", "1"...
set stamp image for watermak @param string $stampFile image file (JPEG or PNG) @return boolean @access public @uses readImage() @uses stampImage @uses stampWidth @uses stampHeight @uses errorMsg
[ "set", "stamp", "image", "for", "watermak" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L243-L262
train
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.setStampPosition
public function setStampPosition ( $Xposition, $Yposition) { // set X position switch ($Xposition) { case transparentWatermarkOnLeft: case transparentWatermarkOnCenter: case transparentWatermarkOnRight: $this->stampPositionX=$Xposition; break; } // set Y position switch ($Yposition) { case transparentWatermarkOnTop: case transparentWatermarkOnMiddle: case transparentWatermarkOnBottom: $this->stampPositionY=$Yposition; break; } }
php
public function setStampPosition ( $Xposition, $Yposition) { // set X position switch ($Xposition) { case transparentWatermarkOnLeft: case transparentWatermarkOnCenter: case transparentWatermarkOnRight: $this->stampPositionX=$Xposition; break; } // set Y position switch ($Yposition) { case transparentWatermarkOnTop: case transparentWatermarkOnMiddle: case transparentWatermarkOnBottom: $this->stampPositionY=$Yposition; break; } }
[ "public", "function", "setStampPosition", "(", "$", "Xposition", ",", "$", "Yposition", ")", "{", "// set X position\r", "switch", "(", "$", "Xposition", ")", "{", "case", "transparentWatermarkOnLeft", ":", "case", "transparentWatermarkOnCenter", ":", "case", "trans...
set stamp position on image @access public @param int $Xposition x position @param int $Yposition y position @return void @uses errorMsg
[ "set", "stamp", "position", "on", "image" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L273-L290
train
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.writeImage
public function writeImage( $image, $file, $type) { switch ($type) { case 2: //JPEG Imagejpeg( $image, $file); break; case 3: //PNG Imagepng( $image, $file); break; default: $this->errorMsg="File format not supported."; } }
php
public function writeImage( $image, $file, $type) { switch ($type) { case 2: //JPEG Imagejpeg( $image, $file); break; case 3: //PNG Imagepng( $image, $file); break; default: $this->errorMsg="File format not supported."; } }
[ "public", "function", "writeImage", "(", "$", "image", ",", "$", "file", ",", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "2", ":", "//JPEG\r", "Imagejpeg", "(", "$", "image", ",", "$", "file", ")", ";", "break", ";", "ca...
write image to file @param resource $image image @param string $file image file (JPEG or PNG) @param int $type file type (2:JPEG or 3:PNG) @return void @access protected @uses errorMsg
[ "write", "image", "to", "file" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L302-L315
train
meritoo/common-library
src/Collection/Templates.php
Templates.findTemplate
public function findTemplate(string $index): Template { $template = $this->getByIndex($index); if ($template instanceof Template) { return $template; } // Oops, template not found throw TemplateNotFoundException::create($index); }
php
public function findTemplate(string $index): Template { $template = $this->getByIndex($index); if ($template instanceof Template) { return $template; } // Oops, template not found throw TemplateNotFoundException::create($index); }
[ "public", "function", "findTemplate", "(", "string", "$", "index", ")", ":", "Template", "{", "$", "template", "=", "$", "this", "->", "getByIndex", "(", "$", "index", ")", ";", "if", "(", "$", "template", "instanceof", "Template", ")", "{", "return", ...
Finds and returns template with given index @param string $index Index that contains required template @throws TemplateNotFoundException @return Template
[ "Finds", "and", "returns", "template", "with", "given", "index" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Collection/Templates.php#L31-L41
train
meritoo/common-library
src/Collection/Templates.php
Templates.fromArray
public static function fromArray(array $templates): Templates { // No templates. Nothing to do. if (empty($templates)) { return new static(); } $result = new static(); foreach ($templates as $index => $template) { $result->add(new Template($template), $index); } return $result; }
php
public static function fromArray(array $templates): Templates { // No templates. Nothing to do. if (empty($templates)) { return new static(); } $result = new static(); foreach ($templates as $index => $template) { $result->add(new Template($template), $index); } return $result; }
[ "public", "static", "function", "fromArray", "(", "array", "$", "templates", ")", ":", "Templates", "{", "// No templates. Nothing to do.", "if", "(", "empty", "(", "$", "templates", ")", ")", "{", "return", "new", "static", "(", ")", ";", "}", "$", "resul...
Creates and returns the collection from given array @param array $templates Pairs of key-value where: key - template's index, value - template's content @return Templates
[ "Creates", "and", "returns", "the", "collection", "from", "given", "array" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Collection/Templates.php#L49-L63
train
CeusMedia/Common
src/Alg/Sort/Insertion.php
Alg_Sort_Insertion.sort
public function sort( $list ) { // echo "list: ".implode (" | ", $list)."<br>"; $n = sizeof( $list ); for( $i=0; $i<$n; $i++ ) { $temp = $list[$i]; $j = $n - 1; while( $j>=0 && $this->moves < 100 ) { if( $list[$j] > $temp ) { $this->moves ++; $list = self::swap( $list, $j + 1, $j ); // echo "list[$i|$j]: ".implode (" | ", $list)."<br>"; $j--; } $this->compares ++; } } return $list; }
php
public function sort( $list ) { // echo "list: ".implode (" | ", $list)."<br>"; $n = sizeof( $list ); for( $i=0; $i<$n; $i++ ) { $temp = $list[$i]; $j = $n - 1; while( $j>=0 && $this->moves < 100 ) { if( $list[$j] > $temp ) { $this->moves ++; $list = self::swap( $list, $j + 1, $j ); // echo "list[$i|$j]: ".implode (" | ", $list)."<br>"; $j--; } $this->compares ++; } } return $list; }
[ "public", "function", "sort", "(", "$", "list", ")", "{", "//\t\techo \"list: \".implode (\" | \", $list).\"<br>\";\r", "$", "n", "=", "sizeof", "(", "$", "list", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "n", ";", "$", "i", ...
Sorts List with Insertion Sort. @access public @param array $list List to sort @return array
[ "Sorts", "List", "with", "Insertion", "Sort", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/Insertion.php#L49-L70
train
CeusMedia/Common
src/Alg/Sort/Insertion.php
Alg_Sort_Insertion.swap
protected static function swap( $list, $pos1, $pos2 ) { $memory = $list[$pos1]; $list[$pos1] = $list[$pos2]; $list[$pos2] = $memory; return $list; }
php
protected static function swap( $list, $pos1, $pos2 ) { $memory = $list[$pos1]; $list[$pos1] = $list[$pos2]; $list[$pos2] = $memory; return $list; }
[ "protected", "static", "function", "swap", "(", "$", "list", ",", "$", "pos1", ",", "$", "pos2", ")", "{", "$", "memory", "=", "$", "list", "[", "$", "pos1", "]", ";", "$", "list", "[", "$", "pos1", "]", "=", "$", "list", "[", "$", "pos2", "]...
Swaps two Elements in List. @access protected @static @param array $list List @param int $pos1 Position of first Element @param int $pos1 Position of second Element @return array
[ "Swaps", "two", "Elements", "in", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/Insertion.php#L81-L87
train
CeusMedia/Common
src/UI/SVG/Chart.php
UI_SVG_Chart.buildBarAcross
public function buildBarAcross( $options = false ) { $chart = new UI_SVG_BarAcross; $chart->chart = &$this; $this->content .= $this->buildComponent( $chart, $options ); }
php
public function buildBarAcross( $options = false ) { $chart = new UI_SVG_BarAcross; $chart->chart = &$this; $this->content .= $this->buildComponent( $chart, $options ); }
[ "public", "function", "buildBarAcross", "(", "$", "options", "=", "false", ")", "{", "$", "chart", "=", "new", "UI_SVG_BarAcross", ";", "$", "chart", "->", "chart", "=", "&", "$", "this", ";", "$", "this", "->", "content", ".=", "$", "this", "->", "b...
Builds Bar Graph and appends it to SVG Document. @access public @param array $options Options of Graph @return void
[ "Builds", "Bar", "Graph", "and", "appends", "it", "to", "SVG", "Document", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/SVG/Chart.php#L86-L91
train
CeusMedia/Common
src/UI/SVG/Chart.php
UI_SVG_Chart.buildPieGraph
public function buildPieGraph( $options = false ) { $chart = new UI_SVG_PieGraph; $chart->chart = &$this; $this->content .= $this->buildComponent( $chart, $options ); }
php
public function buildPieGraph( $options = false ) { $chart = new UI_SVG_PieGraph; $chart->chart = &$this; $this->content .= $this->buildComponent( $chart, $options ); }
[ "public", "function", "buildPieGraph", "(", "$", "options", "=", "false", ")", "{", "$", "chart", "=", "new", "UI_SVG_PieGraph", ";", "$", "chart", "->", "chart", "=", "&", "$", "this", ";", "$", "this", "->", "content", ".=", "$", "this", "->", "bui...
Builds Pie Graph and appends it to SVG Document. @access public @param array $options Options of Graph @return void
[ "Builds", "Pie", "Graph", "and", "appends", "it", "to", "SVG", "Document", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/SVG/Chart.php#L129-L134
train
CeusMedia/Common
src/UI/SVG/Chart.php
UI_SVG_Chart.getColor
public function getColor( $id ) { $color = $this->colors[$id % count( $this->colors )]; return $color; }
php
public function getColor( $id ) { $color = $this->colors[$id % count( $this->colors )]; return $color; }
[ "public", "function", "getColor", "(", "$", "id", ")", "{", "$", "color", "=", "$", "this", "->", "colors", "[", "$", "id", "%", "count", "(", "$", "this", "->", "colors", ")", "]", ";", "return", "$", "color", ";", "}" ]
This function simply returns a color from the internal coller palette. Supplied is a number. @access public @param integer The id of the color @return string color name or hexadeciaml triplet
[ "This", "function", "simply", "returns", "a", "color", "from", "the", "internal", "coller", "palette", ".", "Supplied", "is", "a", "number", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/SVG/Chart.php#L159-L163
train
CeusMedia/Common
src/UI/SVG/Chart.php
UI_SVG_Chart.save
public function save( $fileName ) { $svg = $this->encapsulate( $this->content ); $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $doc->loadXml( $svg ); $svg = $doc->saveXml(); return FS_File_Writer::save( $fileName, $svg ); }
php
public function save( $fileName ) { $svg = $this->encapsulate( $this->content ); $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $doc->loadXml( $svg ); $svg = $doc->saveXml(); return FS_File_Writer::save( $fileName, $svg ); }
[ "public", "function", "save", "(", "$", "fileName", ")", "{", "$", "svg", "=", "$", "this", "->", "encapsulate", "(", "$", "this", "->", "content", ")", ";", "$", "doc", "=", "new", "DOMDocument", "(", ")", ";", "$", "doc", "->", "preserveWhiteSpace"...
Saves SVG Graph to File. @access public @param string $fileName File to save to @return int
[ "Saves", "SVG", "Graph", "to", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/SVG/Chart.php#L227-L236
train
CeusMedia/Common
src/Alg/UnusedVariableFinder.php
Alg_UnusedVariableFinder.getUnusedVars
public function getUnusedVars( $method = NULL ) { $list = array(); if( !strlen( $method = trim( $method ) ) ) { foreach( $this->methods as $method => $data ) if( ( $vars = $this->getUnusedVars( $method ) ) ) $list[$method] = $vars; return $list; } if( !array_key_exists( $method, $this->methods ) ) throw new InvalidArgumentException( 'Method "'.$method.'" not found' ); foreach( $this->getVariables( $method ) as $var => $data ) $data ? NULL : $list[] = $var; return $list; }
php
public function getUnusedVars( $method = NULL ) { $list = array(); if( !strlen( $method = trim( $method ) ) ) { foreach( $this->methods as $method => $data ) if( ( $vars = $this->getUnusedVars( $method ) ) ) $list[$method] = $vars; return $list; } if( !array_key_exists( $method, $this->methods ) ) throw new InvalidArgumentException( 'Method "'.$method.'" not found' ); foreach( $this->getVariables( $method ) as $var => $data ) $data ? NULL : $list[] = $var; return $list; }
[ "public", "function", "getUnusedVars", "(", "$", "method", "=", "NULL", ")", "{", "$", "list", "=", "array", "(", ")", ";", "if", "(", "!", "strlen", "(", "$", "method", "=", "trim", "(", "$", "method", ")", ")", ")", "{", "foreach", "(", "$", ...
Returns an Array of Methods and their unused Variables. @access public @param string $method Optional: Method to get unused Variables for. @return array
[ "Returns", "an", "Array", "of", "Methods", "and", "their", "unused", "Variables", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/UnusedVariableFinder.php#L83-L98
train
CeusMedia/Common
src/Alg/UnusedVariableFinder.php
Alg_UnusedVariableFinder.inspectParsedMethods
private function inspectParsedMethods( $countCalls = FALSE ) { foreach( $this->methods as $method => $data ) // iterate before parsed methods { foreach( $data['lines'] as $nr => $line ) // iterate method/function lines { $pattern = "@^ *\t*[$]([a-z0-9_]+)(\t| )+=[^>].*@i"; // prepare regular expression for variable assignment if( preg_match( $pattern, $line ) ) // line contains variable assignment if( $var = trim( preg_replace( $pattern, "\\1", $line ) ) ) // extract variable name from line if( !array_key_exists( $var, $this->methods[$method]['variables'] ) ) // variable is not noted, yet $this->methods[$method]['variables'][$var] = 0; // note newly found variable foreach( $this->methods[$method]['variables'] as $name => $count ) // iterate known method/function variables { if( !$countCalls && $count ) // variable is used and count mode is off continue; // skip to next line if( preg_match( "/\(/", $name ) || preg_match( "/\)/", $name ) ) xmp( $method."::".$name.' ('.join( ",", array_keys( $this->methods ) ).')' ); $line = preg_replace( "/\$".addslashes( $name )."\s*=/", "", $line ); // remove variable assignment if found if( preg_match( '@\$'.addslashes( $name ).'[^a-z0-9_]@i', $line ) ){ // if variable is used in this line $this->methods[$method]['variables'][$name]++; // increate variable's use counter } } } } }
php
private function inspectParsedMethods( $countCalls = FALSE ) { foreach( $this->methods as $method => $data ) // iterate before parsed methods { foreach( $data['lines'] as $nr => $line ) // iterate method/function lines { $pattern = "@^ *\t*[$]([a-z0-9_]+)(\t| )+=[^>].*@i"; // prepare regular expression for variable assignment if( preg_match( $pattern, $line ) ) // line contains variable assignment if( $var = trim( preg_replace( $pattern, "\\1", $line ) ) ) // extract variable name from line if( !array_key_exists( $var, $this->methods[$method]['variables'] ) ) // variable is not noted, yet $this->methods[$method]['variables'][$var] = 0; // note newly found variable foreach( $this->methods[$method]['variables'] as $name => $count ) // iterate known method/function variables { if( !$countCalls && $count ) // variable is used and count mode is off continue; // skip to next line if( preg_match( "/\(/", $name ) || preg_match( "/\)/", $name ) ) xmp( $method."::".$name.' ('.join( ",", array_keys( $this->methods ) ).')' ); $line = preg_replace( "/\$".addslashes( $name )."\s*=/", "", $line ); // remove variable assignment if found if( preg_match( '@\$'.addslashes( $name ).'[^a-z0-9_]@i', $line ) ){ // if variable is used in this line $this->methods[$method]['variables'][$name]++; // increate variable's use counter } } } } }
[ "private", "function", "inspectParsedMethods", "(", "$", "countCalls", "=", "FALSE", ")", "{", "foreach", "(", "$", "this", "->", "methods", "as", "$", "method", "=>", "$", "data", ")", "// iterate before parsed methods\r", "{", "foreach", "(", "$", "data", ...
Inspects all before parsed methods for variables. @access public @param bool $countCalls Flag: count Number Variable uses @return void
[ "Inspects", "all", "before", "parsed", "methods", "for", "variables", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/UnusedVariableFinder.php#L121-L145
train
CeusMedia/Common
src/Alg/UnusedVariableFinder.php
Alg_UnusedVariableFinder.parseCodeForMethods
private function parseCodeForMethods( $content ) { $this->methods = array(); // reset list of found methods $open = FALSE; // initial: no method found, yet $content = preg_replace( "@/\*.*\*/@Us", "", $content ); // remove all slash-star-comments // $content = preg_replace( '@".*"@Us', "", $content ); // remove all strings $content = preg_replace( "@'.*'@Us", "", $content ); // remove all strings $content = preg_replace( "@#.+\n@U", "", $content ); // remove all hash-comments $content = preg_replace( "@\s+\n@U", "\n", $content ); // trailing white space $content = preg_replace( "@\n\n@U", "\n", $content ); // remove double line breaks $content = preg_replace( "@//\s*[\w|\s]*\n@U", "\n", $content ); // remove comment lines $matches = array(); // prepare empty matches array $count = 0; // initial: open bracket counter foreach( explode( "\n", $content ) as $nr => $line ) // iterate code lines { $line = trim( $line ); // remove leading and trailing white space if( !$open ) // if no method found, yet { $regExp = '@^(abstract )?(final )?(static )?(protected |private |public )?(static )?function ([\w]+)\((.*)\)(\s*{\s*)?;?\s*$@s'; // prepare regular expression for method/function signature if( preg_match( $regExp, $line ) ) // line is method/function signature { $regExp = "@^.*function ([^(]+) ?\((.*)\).*$@i"; // prepare regular expression for method/function name and parameters $name = preg_replace( $regExp, "\\1@@\\2", $line ); // find method/function name and parameters $parts = explode( "@@", $name ); // split name and parameters $open = trim( $parts[0] ); // note found method/function $matches[$open]['variables'] = array(); // prepare empty method/function parameter list $matches[$open]['lines'] = array(); // prepare empty method/function line list $parts[1] = preg_replace( '@\(.*\)@U', "", $parts[1] ); // remove all strings if( isset( $parts[1] ) && trim( $parts[1] ) ) // parameters are defined { $params = explode( ",", $parts[1] ); // split parameters foreach( $params as $param ) // iterate parameters { $regExp = '@^([a-z0-9_]+ )?&?\$(.+)(\s?=\s?.*)?$@Ui'; // prepare regular expression for parameter name $param = preg_replace( $regExp, "\\2", trim( $param ) ); // get clean parameter name $matches[$open]['variables'][$param] = 0; // note parameter in method variable list } } if( preg_match( "/\{$/", $line ) ) // signature line ends with opening bracket $count++; // increase open bracket counter } } else // inside method code lines { $matches[$open]['lines'][$nr] = $line; // note method code line for inspection if( preg_match( "/^\{$/", $line ) || preg_match( "/\{$/", $line ) ) // line contains opening bracket $count++; // increase open bracket counter else if( preg_match( "/^\}/", $line ) || preg_match( "/\}$/", $line ) ) // line contains closing bracket if( !( --$count ) ) // decrease open bracket counter and if all open brackets are closed $open = FALSE; // leave method code mode } } $this->methods = $matches; // note all found methods and their variables }
php
private function parseCodeForMethods( $content ) { $this->methods = array(); // reset list of found methods $open = FALSE; // initial: no method found, yet $content = preg_replace( "@/\*.*\*/@Us", "", $content ); // remove all slash-star-comments // $content = preg_replace( '@".*"@Us', "", $content ); // remove all strings $content = preg_replace( "@'.*'@Us", "", $content ); // remove all strings $content = preg_replace( "@#.+\n@U", "", $content ); // remove all hash-comments $content = preg_replace( "@\s+\n@U", "\n", $content ); // trailing white space $content = preg_replace( "@\n\n@U", "\n", $content ); // remove double line breaks $content = preg_replace( "@//\s*[\w|\s]*\n@U", "\n", $content ); // remove comment lines $matches = array(); // prepare empty matches array $count = 0; // initial: open bracket counter foreach( explode( "\n", $content ) as $nr => $line ) // iterate code lines { $line = trim( $line ); // remove leading and trailing white space if( !$open ) // if no method found, yet { $regExp = '@^(abstract )?(final )?(static )?(protected |private |public )?(static )?function ([\w]+)\((.*)\)(\s*{\s*)?;?\s*$@s'; // prepare regular expression for method/function signature if( preg_match( $regExp, $line ) ) // line is method/function signature { $regExp = "@^.*function ([^(]+) ?\((.*)\).*$@i"; // prepare regular expression for method/function name and parameters $name = preg_replace( $regExp, "\\1@@\\2", $line ); // find method/function name and parameters $parts = explode( "@@", $name ); // split name and parameters $open = trim( $parts[0] ); // note found method/function $matches[$open]['variables'] = array(); // prepare empty method/function parameter list $matches[$open]['lines'] = array(); // prepare empty method/function line list $parts[1] = preg_replace( '@\(.*\)@U', "", $parts[1] ); // remove all strings if( isset( $parts[1] ) && trim( $parts[1] ) ) // parameters are defined { $params = explode( ",", $parts[1] ); // split parameters foreach( $params as $param ) // iterate parameters { $regExp = '@^([a-z0-9_]+ )?&?\$(.+)(\s?=\s?.*)?$@Ui'; // prepare regular expression for parameter name $param = preg_replace( $regExp, "\\2", trim( $param ) ); // get clean parameter name $matches[$open]['variables'][$param] = 0; // note parameter in method variable list } } if( preg_match( "/\{$/", $line ) ) // signature line ends with opening bracket $count++; // increase open bracket counter } } else // inside method code lines { $matches[$open]['lines'][$nr] = $line; // note method code line for inspection if( preg_match( "/^\{$/", $line ) || preg_match( "/\{$/", $line ) ) // line contains opening bracket $count++; // increase open bracket counter else if( preg_match( "/^\}/", $line ) || preg_match( "/\}$/", $line ) ) // line contains closing bracket if( !( --$count ) ) // decrease open bracket counter and if all open brackets are closed $open = FALSE; // leave method code mode } } $this->methods = $matches; // note all found methods and their variables }
[ "private", "function", "parseCodeForMethods", "(", "$", "content", ")", "{", "$", "this", "->", "methods", "=", "array", "(", ")", ";", "// reset list of found methods\r", "$", "open", "=", "FALSE", ";", "// initial: no method found, yet\r", "$", "content", "=",...
Parse a Class File and collects Methods and their Parameters and Lines. @access private @param string $content PHP code string @return void
[ "Parse", "a", "Class", "File", "and", "collects", "Methods", "and", "their", "Parameters", "and", "Lines", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/UnusedVariableFinder.php#L153-L206
train
CeusMedia/Common
src/Alg/Validation/DefinitionValidator.php
Alg_Validation_DefinitionValidator.validate
public function validate( $definition, $value ) { if( !is_array( $definition ) ) throw new InvalidArgumentException( 'Definition must be an array, '.gettype( $definition ).' given' ); $errors = array(); if( !empty( $definition['syntax'] ) ) { $syntax = new ArrayObject( $definition['syntax'] ); if( !strlen( $value ) ) { if( $syntax['mandatory'] ) $errors[] = array( 'isMandatory', NULL ); return $errors; } if( $syntax['class'] ) if( !$this->validator->isClass( $value, $syntax['class'] ) ) $errors[] = array( 'isClass', $syntax['class'] ); $predicates = array( 'maxlength' => 'hasMaxLength', 'minlength' => 'hasMinLength', ); foreach( $predicates as $key => $predicate ) if( $syntax[$key] ) if( !$this->validator->validate( $value, $predicate, $syntax[$key] ) ) $errors[] = array( $predicate, $syntax[$key] ); } if( !empty( $definition['semantic'] ) ) { foreach( $definition['semantic'] as $semantic ) { $semantic = new ArrayObject( $semantic ); $param = strlen( $semantic['edge'] ) ? $semantic['edge'] : NULL; if( !$this->validator->validate( $value, $semantic['predicate'], $param ) ) $errors[] = array( $semantic['predicate'], $param ); } } return $errors; }
php
public function validate( $definition, $value ) { if( !is_array( $definition ) ) throw new InvalidArgumentException( 'Definition must be an array, '.gettype( $definition ).' given' ); $errors = array(); if( !empty( $definition['syntax'] ) ) { $syntax = new ArrayObject( $definition['syntax'] ); if( !strlen( $value ) ) { if( $syntax['mandatory'] ) $errors[] = array( 'isMandatory', NULL ); return $errors; } if( $syntax['class'] ) if( !$this->validator->isClass( $value, $syntax['class'] ) ) $errors[] = array( 'isClass', $syntax['class'] ); $predicates = array( 'maxlength' => 'hasMaxLength', 'minlength' => 'hasMinLength', ); foreach( $predicates as $key => $predicate ) if( $syntax[$key] ) if( !$this->validator->validate( $value, $predicate, $syntax[$key] ) ) $errors[] = array( $predicate, $syntax[$key] ); } if( !empty( $definition['semantic'] ) ) { foreach( $definition['semantic'] as $semantic ) { $semantic = new ArrayObject( $semantic ); $param = strlen( $semantic['edge'] ) ? $semantic['edge'] : NULL; if( !$this->validator->validate( $value, $semantic['predicate'], $param ) ) $errors[] = array( $semantic['predicate'], $param ); } } return $errors; }
[ "public", "function", "validate", "(", "$", "definition", ",", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "definition", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Definition must be an array, '", ".", "gettype", "(", "$", ...
Validates Syntax against Field Definition and generates Messages. @access public @param string $fieldKey Field Key in Definition @param string $data Field Definition @param string $value Value to validate @param string $fieldName Field Name in Form @return array
[ "Validates", "Syntax", "against", "Field", "Definition", "and", "generates", "Messages", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/DefinitionValidator.php#L67-L108
train
CeusMedia/Common
src/FS/File/CSS/Theme/Combiner.php
FS_File_CSS_Theme_Combiner.reviseStyle
protected function reviseStyle( $content ) { if( $this->protocol == self::PROTOCOL_HTTP ) { $content = str_ireplace( "https://", "http://", $content ); } else if( $this->protocol == self::PROTOCOL_HTTPS ) { $content = str_ireplace( "http://", "https://", $content ); } return $content; }
php
protected function reviseStyle( $content ) { if( $this->protocol == self::PROTOCOL_HTTP ) { $content = str_ireplace( "https://", "http://", $content ); } else if( $this->protocol == self::PROTOCOL_HTTPS ) { $content = str_ireplace( "http://", "https://", $content ); } return $content; }
[ "protected", "function", "reviseStyle", "(", "$", "content", ")", "{", "if", "(", "$", "this", "->", "protocol", "==", "self", "::", "PROTOCOL_HTTP", ")", "{", "$", "content", "=", "str_ireplace", "(", "\"https://\"", ",", "\"http://\"", ",", "$", "content...
Callback Method for additional Modifikations before Combination. @access protected @param string $content Content of Style File @return string Revised Content of Style File
[ "Callback", "Method", "for", "additional", "Modifikations", "before", "Combination", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Theme/Combiner.php#L54-L65
train
CeusMedia/Common
src/Alg/Object/Delegation.php
Alg_Object_Delegation.addClass
public function addClass( $className, $parameters = array() ) { $object = Alg_Object_Factory::createObject( $className, $parameters ); $this->addObject( $object ); }
php
public function addClass( $className, $parameters = array() ) { $object = Alg_Object_Factory::createObject( $className, $parameters ); $this->addObject( $object ); }
[ "public", "function", "addClass", "(", "$", "className", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "object", "=", "Alg_Object_Factory", "::", "createObject", "(", "$", "className", ",", "$", "parameters", ")", ";", "$", "this", "->",...
Composes an Object by its Class Name and Construction Parameters. @access public @param string $className Name of Class @param array $parameters List of Construction Parameters @return int Number of all added Objects
[ "Composes", "an", "Object", "by", "its", "Class", "Name", "and", "Construction", "Parameters", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Object/Delegation.php#L54-L58
train
CeusMedia/Common
src/Alg/Object/Delegation.php
Alg_Object_Delegation.addObject
public function addObject( $object ) { if( !is_object( $object ) ) throw new InvalidArgumentException( 'Not an object given' ); $reflection = new ReflectionObject( $object ); $methods = $reflection->getMethods(); foreach( $methods as $method ) { if( in_array( $method->name, $this->delegableMethods ) ) throw new RuntimeException( 'Method "'.$method->name.'" is already set' ); $this->delegableMethods[] = $method->name; } $this->delegableObjects[] = $object; }
php
public function addObject( $object ) { if( !is_object( $object ) ) throw new InvalidArgumentException( 'Not an object given' ); $reflection = new ReflectionObject( $object ); $methods = $reflection->getMethods(); foreach( $methods as $method ) { if( in_array( $method->name, $this->delegableMethods ) ) throw new RuntimeException( 'Method "'.$method->name.'" is already set' ); $this->delegableMethods[] = $method->name; } $this->delegableObjects[] = $object; }
[ "public", "function", "addObject", "(", "$", "object", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Not an object given'", ")", ";", "$", "reflection", "=", "new", "ReflectionObject", ...
Composes an Object. @access public @param object $object Object @return int Number of all added Objects @throws InvalidArgumentException if no object given
[ "Composes", "an", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Object/Delegation.php#L67-L80
train
CeusMedia/Common
src/FS/File/INI/Creator.php
FS_File_INI_Creator.write
public function write( $fileName ) { $lines = array(); if( $this->useSections ) { foreach( $this->data as $section => $sectionPairs ) { $lines[] = "[".$section."]"; foreach ( $sectionPairs as $key => $data ) { $value = $data['value']; $comment = $data['comment']; $lines[] = $this->buildLine( $key, $value, $comment); } $lines[] = ""; } } else { foreach( $this->data as $key => $data ) { $value = $data['value']; $comment = $data['comment']; $lines[] = $this->buildLine( $key, $value, $comment); } $lines[] = ""; } $file = new FS_File_Writer( $fileName, 0664 ); return $file->writeArray( $lines ); }
php
public function write( $fileName ) { $lines = array(); if( $this->useSections ) { foreach( $this->data as $section => $sectionPairs ) { $lines[] = "[".$section."]"; foreach ( $sectionPairs as $key => $data ) { $value = $data['value']; $comment = $data['comment']; $lines[] = $this->buildLine( $key, $value, $comment); } $lines[] = ""; } } else { foreach( $this->data as $key => $data ) { $value = $data['value']; $comment = $data['comment']; $lines[] = $this->buildLine( $key, $value, $comment); } $lines[] = ""; } $file = new FS_File_Writer( $fileName, 0664 ); return $file->writeArray( $lines ); }
[ "public", "function", "write", "(", "$", "fileName", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "useSections", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "section", "=>", "$", "sectionPai...
Creates and writes Settings to File. @access public @param string $fileName File Name of new Ini File @return bool
[ "Creates", "and", "writes", "Settings", "to", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Creator.php#L141-L170
train
CeusMedia/Common
src/FS/Folder/MethodVisibilityCheck.php
FS_Folder_MethodVisibilityCheck.scan
public function scan( $path, $extension = "php5" ) { $this->count = 0; $this->found = 0; $this->list = array(); $finder = new FS_File_RecursiveRegexFilter( $path, '@^[^_].*\.'.$extension.'$@', "@function @" ); foreach( $finder as $entry ) { $checker = new FS_File_PHP_Check_MethodVisibility( $entry->getPathname() ); if( $checker->check() ) continue; $this->found++; $this->list[$entry->getPathname()] = $checker->getMethods(); } $this->count = $finder->getNumberFound(); }
php
public function scan( $path, $extension = "php5" ) { $this->count = 0; $this->found = 0; $this->list = array(); $finder = new FS_File_RecursiveRegexFilter( $path, '@^[^_].*\.'.$extension.'$@', "@function @" ); foreach( $finder as $entry ) { $checker = new FS_File_PHP_Check_MethodVisibility( $entry->getPathname() ); if( $checker->check() ) continue; $this->found++; $this->list[$entry->getPathname()] = $checker->getMethods(); } $this->count = $finder->getNumberFound(); }
[ "public", "function", "scan", "(", "$", "path", ",", "$", "extension", "=", "\"php5\"", ")", "{", "$", "this", "->", "count", "=", "0", ";", "$", "this", "->", "found", "=", "0", ";", "$", "this", "->", "list", "=", "array", "(", ")", ";", "$",...
Scans a folder containing PHP files for methods without defined visibility. @access public @param string $path Path to Folder containing PHP Files @param string $extension Extension of PHP Files. @return void
[ "Scans", "a", "folder", "containing", "PHP", "files", "for", "methods", "without", "defined", "visibility", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/MethodVisibilityCheck.php#L55-L70
train
ncou/Chiron
src/Chiron/Routing/Strategy/Invoker.php
Invoker.bindParameters
protected function bindParameters(callable $controller, array $matched): array { if (is_array($controller)) { $reflector = new \ReflectionMethod($controller[0], $controller[1]); $controllerName = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); } elseif (is_object($controller) && ! $controller instanceof \Closure) { $reflector = (new \ReflectionObject($controller))->getMethod('__invoke'); $controllerName = get_class($controller); } else { $controllerName = ($controller instanceof \Closure) ? get_class($controller) : $controller; $reflector = new \ReflectionFunction($controller); } $parameters = $reflector->getParameters(); $bindParams = []; foreach ($parameters as $param) { // @notice \ReflectionType::getName() is not supported in PHP 7.0, that is why we use __toString() $paramType = $param->hasType() ? $param->getType()->__toString() : ''; $paramClass = $param->getClass(); if (array_key_exists($param->getName(), $matched)) { $bindParams[] = $this->transformToScalar($matched[$param->getName()], $paramType); } elseif ($paramClass && array_key_exists($paramClass->getName(), $matched)) { $bindParams[] = $matched[$paramClass->getName()]; } elseif ($param->isDefaultValueAvailable()) { $bindParams[] = $param->getDefaultValue(); //} elseif ($param->hasType() && $param->allowsNull()) { // $result[] = null; } else { // can't find the value, or the default value for the parameter => throw an error throw new InvalidArgumentException(sprintf( 'Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $controllerName, $param->getName() )); } } return $bindParams; }
php
protected function bindParameters(callable $controller, array $matched): array { if (is_array($controller)) { $reflector = new \ReflectionMethod($controller[0], $controller[1]); $controllerName = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); } elseif (is_object($controller) && ! $controller instanceof \Closure) { $reflector = (new \ReflectionObject($controller))->getMethod('__invoke'); $controllerName = get_class($controller); } else { $controllerName = ($controller instanceof \Closure) ? get_class($controller) : $controller; $reflector = new \ReflectionFunction($controller); } $parameters = $reflector->getParameters(); $bindParams = []; foreach ($parameters as $param) { // @notice \ReflectionType::getName() is not supported in PHP 7.0, that is why we use __toString() $paramType = $param->hasType() ? $param->getType()->__toString() : ''; $paramClass = $param->getClass(); if (array_key_exists($param->getName(), $matched)) { $bindParams[] = $this->transformToScalar($matched[$param->getName()], $paramType); } elseif ($paramClass && array_key_exists($paramClass->getName(), $matched)) { $bindParams[] = $matched[$paramClass->getName()]; } elseif ($param->isDefaultValueAvailable()) { $bindParams[] = $param->getDefaultValue(); //} elseif ($param->hasType() && $param->allowsNull()) { // $result[] = null; } else { // can't find the value, or the default value for the parameter => throw an error throw new InvalidArgumentException(sprintf( 'Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $controllerName, $param->getName() )); } } return $bindParams; }
[ "protected", "function", "bindParameters", "(", "callable", "$", "controller", ",", "array", "$", "matched", ")", ":", "array", "{", "if", "(", "is_array", "(", "$", "controller", ")", ")", "{", "$", "reflector", "=", "new", "\\", "ReflectionMethod", "(", ...
Bind the matched parameters from the request with the callable parameters. @param callable $controller the callable to be executed @param array $matched the parameters extracted from the uri @return array The
[ "Bind", "the", "matched", "parameters", "from", "the", "request", "with", "the", "callable", "parameters", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Strategy/Invoker.php#L35-L75
train
ncou/Chiron
src/Chiron/Routing/Strategy/Invoker.php
Invoker.transformToScalar
private function transformToScalar(string $parameter, string $type) { switch ($type) { case 'int': $parameter = (int) $parameter; break; case 'bool': //TODO : utiliser plutot ce bout de code (il faudra surement faire un lowercase en plus !!!) : \in_array(\trim($value), ['1', 'true'], true); $parameter = (bool) $parameter; break; case 'float': $parameter = (float) $parameter; break; } return $parameter; }
php
private function transformToScalar(string $parameter, string $type) { switch ($type) { case 'int': $parameter = (int) $parameter; break; case 'bool': //TODO : utiliser plutot ce bout de code (il faudra surement faire un lowercase en plus !!!) : \in_array(\trim($value), ['1', 'true'], true); $parameter = (bool) $parameter; break; case 'float': $parameter = (float) $parameter; break; } return $parameter; }
[ "private", "function", "transformToScalar", "(", "string", "$", "parameter", ",", "string", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'int'", ":", "$", "parameter", "=", "(", "int", ")", "$", "parameter", ";", "break", ";", ...
Transform parameter to scalar. We don't transform the string type. @param string $parameter the value of param @param string $type the tpe of param @return int|string|bool|float
[ "Transform", "parameter", "to", "scalar", ".", "We", "don", "t", "transform", "the", "string", "type", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Strategy/Invoker.php#L85-L104
train
CeusMedia/Common
src/Net/HTTP/Request/QueryParser.php
Net_HTTP_Request_QueryParser.toArray
public static function toArray( $query, $separatorPairs = "&", $separatorPair = "=" ) { $list = array(); $pairs = explode( $separatorPairs, $query ); // cut query into pairs foreach( $pairs as $pair ) // iterate all pairs { $pair = trim( $pair ); // remove surrounding whitespace if( !$pair ) // empty pair continue; // skip to next $key = $pair; // default, if no value attached $value = NULL; // default, if no value attached $pattern = '@^(\S+)'.$separatorPair.'(\S*)$@U'; if( preg_match( $pattern, $pair ) ) // separator sign found -> value attached { $matches = array(); // prepare matches array preg_match_all( $pattern, $pair, $matches ); // find all parts $key = $matches[1][0]; // key is first part $value = $matches[2][0]; // value is second part } if( !preg_match( '@^[^'.$separatorPair.']@', $pair ) ) // is there a key at all ? throw new InvalidArgumentException( 'Query is invalid.' ); // no, key is empty if( preg_match( "/\[\]$/", $key ) ) // key is ending on [] -> array { $key = preg_replace( "/\[\]$/", "", $key ); // remove [] from key if( !isset( $list[$key] ) ) // array for key is not yet set in list $list[$key] = array(); // set up array for key in list $list[$key][] = $value; // add value for key in array in list } else // key is just a string $list[$key] = $value; // set value for key in list } return $list; // return resulting list }
php
public static function toArray( $query, $separatorPairs = "&", $separatorPair = "=" ) { $list = array(); $pairs = explode( $separatorPairs, $query ); // cut query into pairs foreach( $pairs as $pair ) // iterate all pairs { $pair = trim( $pair ); // remove surrounding whitespace if( !$pair ) // empty pair continue; // skip to next $key = $pair; // default, if no value attached $value = NULL; // default, if no value attached $pattern = '@^(\S+)'.$separatorPair.'(\S*)$@U'; if( preg_match( $pattern, $pair ) ) // separator sign found -> value attached { $matches = array(); // prepare matches array preg_match_all( $pattern, $pair, $matches ); // find all parts $key = $matches[1][0]; // key is first part $value = $matches[2][0]; // value is second part } if( !preg_match( '@^[^'.$separatorPair.']@', $pair ) ) // is there a key at all ? throw new InvalidArgumentException( 'Query is invalid.' ); // no, key is empty if( preg_match( "/\[\]$/", $key ) ) // key is ending on [] -> array { $key = preg_replace( "/\[\]$/", "", $key ); // remove [] from key if( !isset( $list[$key] ) ) // array for key is not yet set in list $list[$key] = array(); // set up array for key in list $list[$key][] = $value; // add value for key in array in list } else // key is just a string $list[$key] = $value; // set value for key in list } return $list; // return resulting list }
[ "public", "static", "function", "toArray", "(", "$", "query", ",", "$", "separatorPairs", "=", "\"&\"", ",", "$", "separatorPair", "=", "\"=\"", ")", "{", "$", "list", "=", "array", "(", ")", ";", "$", "pairs", "=", "explode", "(", "$", "separatorPairs...
Parses Query String and returns an Array statically. @access public @static @param string $query Query String to parse, eg. a=word&b=123&c @param string $separatorPairs Separator Sign between Parameter Pairs @param string $separatorPair Separator Sign between Key and Value @return array
[ "Parses", "Query", "String", "and", "returns", "an", "Array", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Request/QueryParser.php#L51-L85
train
CeusMedia/Common
src/FS/File/CSS/Editor.php
FS_File_CSS_Editor.getProperties
public function getProperties( $selector ){ if( !$this->sheet ) throw new RuntimeException( 'No CSS sheet loaded' ); $rule = $this->sheet->getRuleBySelector( $selector ); if( !$rule ) return array(); return $rule->getProperties(); }
php
public function getProperties( $selector ){ if( !$this->sheet ) throw new RuntimeException( 'No CSS sheet loaded' ); $rule = $this->sheet->getRuleBySelector( $selector ); if( !$rule ) return array(); return $rule->getProperties(); }
[ "public", "function", "getProperties", "(", "$", "selector", ")", "{", "if", "(", "!", "$", "this", "->", "sheet", ")", "throw", "new", "RuntimeException", "(", "'No CSS sheet loaded'", ")", ";", "$", "rule", "=", "$", "this", "->", "sheet", "->", "getRu...
Returns a list of CSS property objects by a rule selector. @access public @param string $selector Rule selector @return array @throws RuntimeException if no CSS sheet is loaded, yet.
[ "Returns", "a", "list", "of", "CSS", "property", "objects", "by", "a", "rule", "selector", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Editor.php#L96-L103
train
CeusMedia/Common
src/FS/File/CSS/Editor.php
FS_File_CSS_Editor.remove
public function remove( $selector, $key = NULL ){ if( !$this->sheet ) throw new RuntimeException( 'No CSS sheet loaded' ); $result = $this->sheet->remove( $selector, $key ); $this->save(); return $result; }
php
public function remove( $selector, $key = NULL ){ if( !$this->sheet ) throw new RuntimeException( 'No CSS sheet loaded' ); $result = $this->sheet->remove( $selector, $key ); $this->save(); return $result; }
[ "public", "function", "remove", "(", "$", "selector", ",", "$", "key", "=", "NULL", ")", "{", "if", "(", "!", "$", "this", "->", "sheet", ")", "throw", "new", "RuntimeException", "(", "'No CSS sheet loaded'", ")", ";", "$", "result", "=", "$", "this", ...
Removes a rule property by rule selector and property key. @access public @param string $selector Rule selector @param string $key Property key @return boolean @throws RuntimeException if no CSS sheet is loaded, yet.
[ "Removes", "a", "rule", "property", "by", "rule", "selector", "and", "property", "key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Editor.php#L134-L140
train
CeusMedia/Common
src/FS/File/CSS/Editor.php
FS_File_CSS_Editor.save
protected function save(){ if( !$this->fileName ) throw new RuntimeException( 'No CSS file set yet' ); return FS_File_CSS_Writer::save( $this->fileName, $this->sheet ); }
php
protected function save(){ if( !$this->fileName ) throw new RuntimeException( 'No CSS file set yet' ); return FS_File_CSS_Writer::save( $this->fileName, $this->sheet ); }
[ "protected", "function", "save", "(", ")", "{", "if", "(", "!", "$", "this", "->", "fileName", ")", "throw", "new", "RuntimeException", "(", "'No CSS file set yet'", ")", ";", "return", "FS_File_CSS_Writer", "::", "save", "(", "$", "this", "->", "fileName", ...
Writes current sheet to CSS file and returns number of written bytes. @access protected @return integer Number of written bytes @throws RuntimeException if no CSS file is set, yet.
[ "Writes", "current", "sheet", "to", "CSS", "file", "and", "returns", "number", "of", "written", "bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Editor.php#L148-L152
train
celtic34fr/zf-graphic-object-templating-twig
src/OObjects/ODContained/ODDragNDrop.php
ODDragNDrop.disThumbFileName
public function disThumbFileName() { $properties = $this->getProperties(); $properties['thumbFileName'] = self::BOOLEAN_FALSE; $this->setProperties($properties); return $this; }
php
public function disThumbFileName() { $properties = $this->getProperties(); $properties['thumbFileName'] = self::BOOLEAN_FALSE; $this->setProperties($properties); return $this; }
[ "public", "function", "disThumbFileName", "(", ")", "{", "$", "properties", "=", "$", "this", "->", "getProperties", "(", ")", ";", "$", "properties", "[", "'thumbFileName'", "]", "=", "self", "::", "BOOLEAN_FALSE", ";", "$", "this", "->", "setProperties", ...
interdit l'affichage du nom de fichier sous sa miniature @return $this
[ "interdit", "l", "affichage", "du", "nom", "de", "fichier", "sous", "sa", "miniature" ]
7a354eff05d678dc225df5e778d5bc3500982768
https://github.com/celtic34fr/zf-graphic-object-templating-twig/blob/7a354eff05d678dc225df5e778d5bc3500982768/src/OObjects/ODContained/ODDragNDrop.php#L1097-L1103
train
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.get
public function get( $path, $array = NULL ) { if( $array == NULL ) $array = $this->storage; if( substr_count( $path, "." ) ) { $parts = explode( ".", $path ); $step = array_shift( $parts ); $path = implode( ".", $parts ); $array = (array) $array[$step]; return $this->get( $path, $array ); } else { if( in_array( $path, array_keys( $array ) ) ) return $array[$path]; else return NULL; } }
php
public function get( $path, $array = NULL ) { if( $array == NULL ) $array = $this->storage; if( substr_count( $path, "." ) ) { $parts = explode( ".", $path ); $step = array_shift( $parts ); $path = implode( ".", $parts ); $array = (array) $array[$step]; return $this->get( $path, $array ); } else { if( in_array( $path, array_keys( $array ) ) ) return $array[$path]; else return NULL; } }
[ "public", "function", "get", "(", "$", "path", ",", "$", "array", "=", "NULL", ")", "{", "if", "(", "$", "array", "==", "NULL", ")", "$", "array", "=", "$", "this", "->", "storage", ";", "if", "(", "substr_count", "(", "$", "path", ",", "\".\"", ...
Returns value of a Path in the Storage. @access public @param string $path Path to stored Value @param array $array current Position in Storage Array @return mixed
[ "Returns", "value", "of", "a", "Path", "in", "the", "Storage", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L77-L96
train
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.readRecursive
protected function readRecursive( $node, &$array ) { $nodeTag = $node->getNodename(); $nodeName = $node->getAttribute( 'name' ); if( $nodeTag == $this->getOption( 'tag_root' ) ) foreach( $node->getChildren() as $child ) $this->readRecursive( $child, $array ); else if( $nodeTag == $this->getOption( 'tag_level' ) ) foreach( $node->getChildren() as $child ) $this->readRecursive( $child, $array[$nodeName] ); else if( $nodeTag == $this->getOption( 'tag_pair' ) ) { $value = $node->getContent(); if( $type = $node->getAttribute( 'type' ) ) settype( $value, $type ); if( gettype( $value ) == "string" ) $array[$nodeName] = utf8_decode( $value ); else $array[$nodeName] = $value; } }
php
protected function readRecursive( $node, &$array ) { $nodeTag = $node->getNodename(); $nodeName = $node->getAttribute( 'name' ); if( $nodeTag == $this->getOption( 'tag_root' ) ) foreach( $node->getChildren() as $child ) $this->readRecursive( $child, $array ); else if( $nodeTag == $this->getOption( 'tag_level' ) ) foreach( $node->getChildren() as $child ) $this->readRecursive( $child, $array[$nodeName] ); else if( $nodeTag == $this->getOption( 'tag_pair' ) ) { $value = $node->getContent(); if( $type = $node->getAttribute( 'type' ) ) settype( $value, $type ); if( gettype( $value ) == "string" ) $array[$nodeName] = utf8_decode( $value ); else $array[$nodeName] = $value; } }
[ "protected", "function", "readRecursive", "(", "$", "node", ",", "&", "$", "array", ")", "{", "$", "nodeTag", "=", "$", "node", "->", "getNodename", "(", ")", ";", "$", "nodeName", "=", "$", "node", "->", "getAttribute", "(", "'name'", ")", ";", "if"...
Reads XML File recursive into array for Storage Operations. @access protected @param XML_DOM_Node $node Current Node to read @param array $array Current Array in Storage @return void
[ "Reads", "XML", "File", "recursive", "into", "array", "for", "Storage", "Operations", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L105-L125
train
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.remove
public function remove( $path, $write = false ) { $result = $this->removeRecursive( $path, $this->storage ); if( $write && $result ) return (bool) $this->write(); return $result; }
php
public function remove( $path, $write = false ) { $result = $this->removeRecursive( $path, $this->storage ); if( $write && $result ) return (bool) $this->write(); return $result; }
[ "public", "function", "remove", "(", "$", "path", ",", "$", "write", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "removeRecursive", "(", "$", "path", ",", "$", "this", "->", "storage", ")", ";", "if", "(", "$", "write", "&&", "...
Removes a Value from the Storage by its Path. @access public @param string $path Path to value @param bool $write Flag: write on Update @return bool
[ "Removes", "a", "Value", "from", "the", "Storage", "by", "its", "Path", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L134-L140
train
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.removeRecursive
protected function removeRecursive( $path, &$array ) { if( substr_count( $path, "." ) ) { $parts = explode( ".", $path ); $step = array_shift( $parts ); $path = implode( ".", $parts ); return $this->removeRecursive( $path, $array[$step] ); } else if( isset( $array[$path] ) ) { unset( $array[$path] ); return true; } return false; }
php
protected function removeRecursive( $path, &$array ) { if( substr_count( $path, "." ) ) { $parts = explode( ".", $path ); $step = array_shift( $parts ); $path = implode( ".", $parts ); return $this->removeRecursive( $path, $array[$step] ); } else if( isset( $array[$path] ) ) { unset( $array[$path] ); return true; } return false; }
[ "protected", "function", "removeRecursive", "(", "$", "path", ",", "&", "$", "array", ")", "{", "if", "(", "substr_count", "(", "$", "path", ",", "\".\"", ")", ")", "{", "$", "parts", "=", "explode", "(", "\".\"", ",", "$", "path", ")", ";", "$", ...
Recursive removes a Value From the Storage by its Path. @access protected @param string $path Path to value @param mixed $value Value to set at Path @param array $array Current Array in Storage @return bool
[ "Recursive", "removes", "a", "Value", "From", "the", "Storage", "by", "its", "Path", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L150-L165
train
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.set
public function set( $path, $value, $write = false ) { $type = gettype( $value ); if( !in_array( $type, array( "double", "integer", "boolean", "string" ) ) ) throw new InvalidArgumentException( "Value must be of type double, integer, boolean or string. ".ucfirst( $type )." given", E_USER_WARNING ); $result = $this->setRecursive( $path, $value, $this->storage ); if( $write && $result ) return (bool) $this->write(); return $result; }
php
public function set( $path, $value, $write = false ) { $type = gettype( $value ); if( !in_array( $type, array( "double", "integer", "boolean", "string" ) ) ) throw new InvalidArgumentException( "Value must be of type double, integer, boolean or string. ".ucfirst( $type )." given", E_USER_WARNING ); $result = $this->setRecursive( $path, $value, $this->storage ); if( $write && $result ) return (bool) $this->write(); return $result; }
[ "public", "function", "set", "(", "$", "path", ",", "$", "value", ",", "$", "write", "=", "false", ")", "{", "$", "type", "=", "gettype", "(", "$", "value", ")", ";", "if", "(", "!", "in_array", "(", "$", "type", ",", "array", "(", "\"double\"", ...
Sets a Value in the Storage by its Path. @access public @param string $path Path to value @param mixed $value Value to set at Path @param bool $write Flag: write on Update @return bool
[ "Sets", "a", "Value", "in", "the", "Storage", "by", "its", "Path", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L175-L184
train
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.setRecursive
protected function setRecursive( $path, $value, &$array ) { if( substr_count( $path, "." ) ) { $parts = explode( ".", $path ); $step = array_shift( $parts ); $path = implode( ".", $parts ); return $this->setRecursive( $path, $value, $array[$step] ); } else if( !(isset( $array[$path] ) && $array[$path] == $value ) ) { $array[$path] = $value; return true; } return false; }
php
protected function setRecursive( $path, $value, &$array ) { if( substr_count( $path, "." ) ) { $parts = explode( ".", $path ); $step = array_shift( $parts ); $path = implode( ".", $parts ); return $this->setRecursive( $path, $value, $array[$step] ); } else if( !(isset( $array[$path] ) && $array[$path] == $value ) ) { $array[$path] = $value; return true; } return false; }
[ "protected", "function", "setRecursive", "(", "$", "path", ",", "$", "value", ",", "&", "$", "array", ")", "{", "if", "(", "substr_count", "(", "$", "path", ",", "\".\"", ")", ")", "{", "$", "parts", "=", "explode", "(", "\".\"", ",", "$", "path", ...
Recursive sets a Value in the Storage by its Path. @access protected @param string $path Path to value @param mixed $value Value to set at Path @param array $array Current Array in Storage @return bool
[ "Recursive", "sets", "a", "Value", "in", "the", "Storage", "by", "its", "Path", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L194-L209
train
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.write
public function write() { $writer = new XML_DOM_FileWriter( $this->fileName ); $root = new XML_DOM_Node( $this->getOption( 'tag_root' ) ); $this->writeRecursive( $root, $this->storage ); return $writer->write( $root ); }
php
public function write() { $writer = new XML_DOM_FileWriter( $this->fileName ); $root = new XML_DOM_Node( $this->getOption( 'tag_root' ) ); $this->writeRecursive( $root, $this->storage ); return $writer->write( $root ); }
[ "public", "function", "write", "(", ")", "{", "$", "writer", "=", "new", "XML_DOM_FileWriter", "(", "$", "this", "->", "fileName", ")", ";", "$", "root", "=", "new", "XML_DOM_Node", "(", "$", "this", "->", "getOption", "(", "'tag_root'", ")", ")", ";",...
Writes XML File from Storage. @access public @return bool
[ "Writes", "XML", "File", "from", "Storage", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L216-L222
train
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.writeRecursive
protected function writeRecursive( &$node, $array ) { foreach( $array as $key => $value ) { if( is_array( $value ) ) { $child = new XML_DOM_Node( $this->getOption( 'tag_level' ) ); $child->setAttribute( 'name', $key ); $this->writeRecursive( $child, $array[$key] ); $node->addChild( $child ); } else { $child = new XML_DOM_Node( $this->getOption( 'tag_pair' ) ); $child->setAttribute( 'name', $key ); $child->setAttribute( 'type', gettype( $value ) ); $child->setContent( utf8_encode( $value ) ); $node->addChild( $child ); } } }
php
protected function writeRecursive( &$node, $array ) { foreach( $array as $key => $value ) { if( is_array( $value ) ) { $child = new XML_DOM_Node( $this->getOption( 'tag_level' ) ); $child->setAttribute( 'name', $key ); $this->writeRecursive( $child, $array[$key] ); $node->addChild( $child ); } else { $child = new XML_DOM_Node( $this->getOption( 'tag_pair' ) ); $child->setAttribute( 'name', $key ); $child->setAttribute( 'type', gettype( $value ) ); $child->setContent( utf8_encode( $value ) ); $node->addChild( $child ); } } }
[ "protected", "function", "writeRecursive", "(", "&", "$", "node", ",", "$", "array", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "child", "=...
Writes XML File recursive from Storage. @access protected @param XML_DOM_Node $node Current Node to read @param array $array Current Array in Storage @return void
[ "Writes", "XML", "File", "recursive", "from", "Storage", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L231-L251
train
CeusMedia/Common
src/UI/HTML/Tag.php
UI_HTML_Tag.build
public function build() { return $this->create( $this->name, $this->content, $this->attributes, $this->data ); }
php
public function build() { return $this->create( $this->name, $this->content, $this->attributes, $this->data ); }
[ "public", "function", "build", "(", ")", "{", "return", "$", "this", "->", "create", "(", "$", "this", "->", "name", ",", "$", "this", "->", "content", ",", "$", "this", "->", "attributes", ",", "$", "this", "->", "data", ")", ";", "}" ]
Builds HTML tags as string. @access public @return string
[ "Builds", "HTML", "tags", "as", "string", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tag.php#L96-L99
train
CeusMedia/Common
src/UI/HTML/Tag.php
UI_HTML_Tag.create
public static function create( $name, $content = NULL, $attributes = array(), $data = array() ) { if( !strlen( $name = trim( $name ) ) ) throw new InvalidArgumentException( 'Missing tag name' ); $name = strtolower( $name ); try{ $attributes = self::renderAttributes( $attributes ); $data = self::renderData( $data ); } catch( InvalidArgumentException $e ) { if( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) throw new RuntimeException( 'Invalid attributes', NULL, $e ); // throw exception and transport inner exception throw new RuntimeException( 'Invalid attributes', NULL ); // throw exception } if( $content === NULL || $content === FALSE ) // no node content defined, not even an empty string if( !in_array( $name, self::$shortTagExcludes ) ) // node name is allowed to be a short tag return "<".$name.$attributes.$data."/>"; // build and return short tag if( is_array( $content ) ) // content is an array, may be nested $content = self::flattenArray( $content, '' ); if( is_numeric( $content ) ) $content = (string) $content; if( is_object( $content ) ){ if( !method_exists( $content, '__toString' ) ){ // content is not a renderable object $message = 'Object of class "'.get_class( $content ).'" cannot be rendered'; // prepare message about not renderable object throw new InvalidArgumentException( $message ); // break with error message } $content = (string) $content; // render object to string } if( !is_null( $content ) && !is_string( $content ) ){ // content is neither NULL nor string so far $message = 'Content type "'.gettype( $content ).'" is not supported'; // prepare message about wrong content data type throw new InvalidArgumentException( $message ); // break with error message } return "<".$name.$attributes.$data.">".$content."</".$name.">"; // build and return full tag }
php
public static function create( $name, $content = NULL, $attributes = array(), $data = array() ) { if( !strlen( $name = trim( $name ) ) ) throw new InvalidArgumentException( 'Missing tag name' ); $name = strtolower( $name ); try{ $attributes = self::renderAttributes( $attributes ); $data = self::renderData( $data ); } catch( InvalidArgumentException $e ) { if( version_compare( PHP_VERSION, '5.3.0', '>=' ) ) throw new RuntimeException( 'Invalid attributes', NULL, $e ); // throw exception and transport inner exception throw new RuntimeException( 'Invalid attributes', NULL ); // throw exception } if( $content === NULL || $content === FALSE ) // no node content defined, not even an empty string if( !in_array( $name, self::$shortTagExcludes ) ) // node name is allowed to be a short tag return "<".$name.$attributes.$data."/>"; // build and return short tag if( is_array( $content ) ) // content is an array, may be nested $content = self::flattenArray( $content, '' ); if( is_numeric( $content ) ) $content = (string) $content; if( is_object( $content ) ){ if( !method_exists( $content, '__toString' ) ){ // content is not a renderable object $message = 'Object of class "'.get_class( $content ).'" cannot be rendered'; // prepare message about not renderable object throw new InvalidArgumentException( $message ); // break with error message } $content = (string) $content; // render object to string } if( !is_null( $content ) && !is_string( $content ) ){ // content is neither NULL nor string so far $message = 'Content type "'.gettype( $content ).'" is not supported'; // prepare message about wrong content data type throw new InvalidArgumentException( $message ); // break with error message } return "<".$name.$attributes.$data.">".$content."</".$name.">"; // build and return full tag }
[ "public", "static", "function", "create", "(", "$", "name", ",", "$", "content", "=", "NULL", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "data", "=", "array", "(", ")", ")", "{", "if", "(", "!", "strlen", "(", "$", "name", "=", "...
Creates Tag statically. @access public @static @param string $name Node name of tag @param string $content Content of tag @param array $attributes Attributes of tag @param array $data Data attributes of tag @return void
[ "Creates", "Tag", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tag.php#L111-L144
train
CeusMedia/Common
src/UI/HTML/Tag.php
UI_HTML_Tag.getAttribute
public function getAttribute( $key ){ if( !array_key_exists( $key, $this->attributes ) ) return NULL; return $this->attributes[$key]; }
php
public function getAttribute( $key ){ if( !array_key_exists( $key, $this->attributes ) ) return NULL; return $this->attributes[$key]; }
[ "public", "function", "getAttribute", "(", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "attributes", ")", ")", "return", "NULL", ";", "return", "$", "this", "->", "attributes", "[", "$", "key", "...
Returns value of tag attribute if set. @access public @param string $key Key of attribute to get @return mixed|NULL
[ "Returns", "value", "of", "tag", "attribute", "if", "set", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tag.php#L160-L164
train
CeusMedia/Common
src/UI/HTML/Tag.php
UI_HTML_Tag.getData
public function getData( $key = NULL ){ if( is_null( $key ) ) return $this->data ; if( !array_key_exists( $key, $this->data ) ) return NULL; return $this->data[$key]; }
php
public function getData( $key = NULL ){ if( is_null( $key ) ) return $this->data ; if( !array_key_exists( $key, $this->data ) ) return NULL; return $this->data[$key]; }
[ "public", "function", "getData", "(", "$", "key", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "return", "$", "this", "->", "data", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "data...
Returns value of tag data if set or map of all data if not key is set. @access public @param string $key Key of data to get @return mixed|array|NULL
[ "Returns", "value", "of", "tag", "data", "if", "set", "or", "map", "of", "all", "data", "if", "not", "key", "is", "set", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tag.php#L181-L187
train
CeusMedia/Common
src/UI/HTML/Tag.php
UI_HTML_Tag.setAttribute
public function setAttribute( $key, $value = NULL, $strict = TRUE ) { if( empty( $key ) ) // no valid attribute key defined throw new InvalidArgumentException( 'Key must have content' ); // throw exception $key = strtolower( $key ); if( array_key_exists( $key, $this->attributes ) && $strict ) // attribute key already has a value throw new RuntimeException( 'Attribute "'.$key.'" is already set' ); // throw exception if( !preg_match( '/^[a-z0-9:_-]+$/', $key ) ) // key is invalid throw new InvalidArgumentException( 'Invalid attribute key "'.$key.'"' ); // throw exception if( $value === NULL || $value === FALSE ){ // no value available if( array_key_exists( $key, $this->attributes ) ) // attribute exists unset( $this->attributes[$key] ); // remove attribute } else { // if( is_string( $value ) || is_numeric( $value ) ) // value is string or numeric // if( preg_match( '/[^\\\]"/', $value ) ) // detect injection // throw new InvalidArgumentException( 'Invalid attribute value' ); // throw exception $this->attributes[$key] = $value; // set attribute } }
php
public function setAttribute( $key, $value = NULL, $strict = TRUE ) { if( empty( $key ) ) // no valid attribute key defined throw new InvalidArgumentException( 'Key must have content' ); // throw exception $key = strtolower( $key ); if( array_key_exists( $key, $this->attributes ) && $strict ) // attribute key already has a value throw new RuntimeException( 'Attribute "'.$key.'" is already set' ); // throw exception if( !preg_match( '/^[a-z0-9:_-]+$/', $key ) ) // key is invalid throw new InvalidArgumentException( 'Invalid attribute key "'.$key.'"' ); // throw exception if( $value === NULL || $value === FALSE ){ // no value available if( array_key_exists( $key, $this->attributes ) ) // attribute exists unset( $this->attributes[$key] ); // remove attribute } else { // if( is_string( $value ) || is_numeric( $value ) ) // value is string or numeric // if( preg_match( '/[^\\\]"/', $value ) ) // detect injection // throw new InvalidArgumentException( 'Invalid attribute value' ); // throw exception $this->attributes[$key] = $value; // set attribute } }
[ "public", "function", "setAttribute", "(", "$", "key", ",", "$", "value", "=", "NULL", ",", "$", "strict", "=", "TRUE", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "// no valid attribute key defined", "throw", "new", "InvalidArgumentException",...
Sets attribute of tag. @access public @param string $key Key of attribute @param string $value Value of attribute @param boolean $strict Flag: deny to override attribute @return void
[ "Sets", "attribute", "of", "tag", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tag.php#L246-L267
train
CeusMedia/Common
src/UI/HTML/Tag.php
UI_HTML_Tag.setAttributes
public function setAttributes( $attributes, $strict = TRUE ) { foreach( $attributes as $key => $value ) // iterate attributes map $this->setAttribute( $key, $value, $strict ); // set each attribute }
php
public function setAttributes( $attributes, $strict = TRUE ) { foreach( $attributes as $key => $value ) // iterate attributes map $this->setAttribute( $key, $value, $strict ); // set each attribute }
[ "public", "function", "setAttributes", "(", "$", "attributes", ",", "$", "strict", "=", "TRUE", ")", "{", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "// iterate attributes map", "$", "this", "->", "setAttribute", "(", "$...
Sets multiple attributes of tag. @access public @param array $attributes Map of attributes to set @param boolean $strict Flag: deny to override attribute @return void
[ "Sets", "multiple", "attributes", "of", "tag", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tag.php#L276-L280
train
CeusMedia/Common
src/UI/HTML/Tag.php
UI_HTML_Tag.setData
public function setData( $key, $value = NULL, $strict = TRUE ){ if( empty( $key ) ) // no valid data key defined throw new InvalidArgumentException( 'Data key is required' ); // throw exception if( array_key_exists( $key, $this->data ) && $strict ) // data key already has a value throw new RuntimeException( 'Data attribute "'.$key.'" is already set' ); // throw exception if( !preg_match( '/^[a-z0-9:_-]+$/i', $key ) ) // key is invalid throw new InvalidArgumentException( 'Invalid data key "'.$key.'"' ); // throw exception if( $value === NULL || $value === FALSE ){ // no value available if( array_key_exists( $key, $this->data ) ) // data exists unset( $this->data[$key] ); // remove attribute } else { if( is_string( $value ) || is_numeric( $value ) ) // value is string or numeric if( preg_match( '/[^\\\]"/', $value ) ) // detect injection throw new InvalidArgumentException( 'Invalid data attribute value' ); // throw exception $this->attributes[$key] = $value; // set attribute } }
php
public function setData( $key, $value = NULL, $strict = TRUE ){ if( empty( $key ) ) // no valid data key defined throw new InvalidArgumentException( 'Data key is required' ); // throw exception if( array_key_exists( $key, $this->data ) && $strict ) // data key already has a value throw new RuntimeException( 'Data attribute "'.$key.'" is already set' ); // throw exception if( !preg_match( '/^[a-z0-9:_-]+$/i', $key ) ) // key is invalid throw new InvalidArgumentException( 'Invalid data key "'.$key.'"' ); // throw exception if( $value === NULL || $value === FALSE ){ // no value available if( array_key_exists( $key, $this->data ) ) // data exists unset( $this->data[$key] ); // remove attribute } else { if( is_string( $value ) || is_numeric( $value ) ) // value is string or numeric if( preg_match( '/[^\\\]"/', $value ) ) // detect injection throw new InvalidArgumentException( 'Invalid data attribute value' ); // throw exception $this->attributes[$key] = $value; // set attribute } }
[ "public", "function", "setData", "(", "$", "key", ",", "$", "value", "=", "NULL", ",", "$", "strict", "=", "TRUE", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "// no valid data key defined", "throw", "new", "InvalidArgumentException", "(", ...
Sets data attribute of tag. @access public @param string $key Key of data attribute @param string $value Value of data attribute @param boolean $strict Flag: deny to override data @return void
[ "Sets", "data", "attribute", "of", "tag", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tag.php#L290-L309
train
CeusMedia/Common
src/UI/HTML/Tag.php
UI_HTML_Tag.setContent
public function setContent( $content = NULL ) { if( is_object( $content ) ){ if( !method_exists( $content, '__toString' ) ){ // content is not a renderable object $message = 'Object of class "'.get_class( $content ).'" cannot be rendered'; // prepare message about not renderable object throw new InvalidArgumentException( $message ); // break with error message } $content = (string) $content; // render object to string } $this->content = $content; }
php
public function setContent( $content = NULL ) { if( is_object( $content ) ){ if( !method_exists( $content, '__toString' ) ){ // content is not a renderable object $message = 'Object of class "'.get_class( $content ).'" cannot be rendered'; // prepare message about not renderable object throw new InvalidArgumentException( $message ); // break with error message } $content = (string) $content; // render object to string } $this->content = $content; }
[ "public", "function", "setContent", "(", "$", "content", "=", "NULL", ")", "{", "if", "(", "is_object", "(", "$", "content", ")", ")", "{", "if", "(", "!", "method_exists", "(", "$", "content", ",", "'__toString'", ")", ")", "{", "// content is not a re...
Sets Content of Tag. @access public @param string|object $content Content of Tag or stringable object @return void @throws InvalidArgumentException if given object has no __toString method
[ "Sets", "Content", "of", "Tag", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tag.php#L318-L328
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Button
public static function Button( $name, $label, $class = NULL, $confirm = NULL, $disabled = NULL, $title = NULL ) { $attributes = array( 'type' => "submit", 'name' => $name, 'value' => 1, 'class' => $class, 'onclick' => $confirm ? "return confirm('".$confirm."');" : NULL, 'title' => $title, ); if( $disabled ) self::addDisabledAttributes( $attributes, $disabled ); return UI_HTML_Tag::create( "button", UI_HTML_Tag::create( "span", (string) $label ), $attributes ); }
php
public static function Button( $name, $label, $class = NULL, $confirm = NULL, $disabled = NULL, $title = NULL ) { $attributes = array( 'type' => "submit", 'name' => $name, 'value' => 1, 'class' => $class, 'onclick' => $confirm ? "return confirm('".$confirm."');" : NULL, 'title' => $title, ); if( $disabled ) self::addDisabledAttributes( $attributes, $disabled ); return UI_HTML_Tag::create( "button", UI_HTML_Tag::create( "span", (string) $label ), $attributes ); }
[ "public", "static", "function", "Button", "(", "$", "name", ",", "$", "label", ",", "$", "class", "=", "NULL", ",", "$", "confirm", "=", "NULL", ",", "$", "disabled", "=", "NULL", ",", "$", "title", "=", "NULL", ")", "{", "$", "attributes", "=", ...
Builds HTML Code for a Button to submit a Form. @access public @static @param string $name Button Name @param string $label Button Label @param string $class CSS Class @param string $confirm Confirmation Message @param mixed $disabled Button is not pressable, JavaScript Alert if String is given @param string $title Titel text on mouse hover @return string
[ "Builds", "HTML", "Code", "for", "a", "Button", "to", "submit", "a", "Form", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L86-L99
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Checkbox
public static function Checkbox( $name, $value, $checked = NULL, $class = NULL, $readOnly = NULL ) { $attributes = array( 'id' => $name, 'type' => "checkbox", 'name' => $name, 'value' => $value, 'class' => $class, 'checked' => $checked ? "checked" : NULL, 'disabled' => $readOnly && !is_string( $readOnly ) ? "disabled" : NULL, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
php
public static function Checkbox( $name, $value, $checked = NULL, $class = NULL, $readOnly = NULL ) { $attributes = array( 'id' => $name, 'type' => "checkbox", 'name' => $name, 'value' => $value, 'class' => $class, 'checked' => $checked ? "checked" : NULL, 'disabled' => $readOnly && !is_string( $readOnly ) ? "disabled" : NULL, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
[ "public", "static", "function", "Checkbox", "(", "$", "name", ",", "$", "value", ",", "$", "checked", "=", "NULL", ",", "$", "class", "=", "NULL", ",", "$", "readOnly", "=", "NULL", ")", "{", "$", "attributes", "=", "array", "(", "'id'", "=>", "$",...
Builds HTML Code for a Checkbox. @access public @static @param string $name Field Name @param string $value Field Value if checked @param bool $checked Field State @param string $class CSS Class @param mixed $readOnly Field is not writable, JavaScript Alert if String is given @return string
[ "Builds", "HTML", "Code", "for", "a", "Checkbox", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L112-L126
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.File
public static function File( $name, $value = "", $class = NULL, $readOnly = NULL, $tabIndex = NULL, $maxLength = NULL ) { $attributes = array( 'id' => $name, 'type' => "file", 'name' => $name, 'value' => $value, 'class' => $class, 'tabindex' => $tabIndex, 'maxlength' => $maxLength, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
php
public static function File( $name, $value = "", $class = NULL, $readOnly = NULL, $tabIndex = NULL, $maxLength = NULL ) { $attributes = array( 'id' => $name, 'type' => "file", 'name' => $name, 'value' => $value, 'class' => $class, 'tabindex' => $tabIndex, 'maxlength' => $maxLength, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
[ "public", "static", "function", "File", "(", "$", "name", ",", "$", "value", "=", "\"\"", ",", "$", "class", "=", "NULL", ",", "$", "readOnly", "=", "NULL", ",", "$", "tabIndex", "=", "NULL", ",", "$", "maxLength", "=", "NULL", ")", "{", "$", "at...
Builds HTML Code for a File Upload Field. @access public @static @param string $name Field Name @param string $class CSS Class (xl|l|m|s|xs) @param mixed $readOnly Field is not writable, JavaScript Alert if String is given @param int $tabIndex Tabbing Order @param int $maxLength Maximum Length @return string
[ "Builds", "HTML", "Code", "for", "a", "File", "Upload", "Field", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L139-L153
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Form
public static function Form( $name = NULL, $action = NULL, $target = NULL, $enctype = NULL, $onSubmit = NULL ) { $attributes = array( 'id' => $name ? "form_".$name : NULL, 'name' => $name, 'action' => $action ? str_replace( "&", "&amp;", $action ) : NULL, 'target' => $target, 'method' => "post", 'enctype' => $enctype, 'onsubmit' => $onSubmit, ); $form = UI_HTML_Tag::create( "form", NULL, $attributes ); return preg_replace( "@/>$@", ">", $form ); }
php
public static function Form( $name = NULL, $action = NULL, $target = NULL, $enctype = NULL, $onSubmit = NULL ) { $attributes = array( 'id' => $name ? "form_".$name : NULL, 'name' => $name, 'action' => $action ? str_replace( "&", "&amp;", $action ) : NULL, 'target' => $target, 'method' => "post", 'enctype' => $enctype, 'onsubmit' => $onSubmit, ); $form = UI_HTML_Tag::create( "form", NULL, $attributes ); return preg_replace( "@/>$@", ">", $form ); }
[ "public", "static", "function", "Form", "(", "$", "name", "=", "NULL", ",", "$", "action", "=", "NULL", ",", "$", "target", "=", "NULL", ",", "$", "enctype", "=", "NULL", ",", "$", "onSubmit", "=", "NULL", ")", "{", "$", "attributes", "=", "array",...
Builds HTML Code for a Form using POST. @access public @static @param string $name Form Name, also used for ID with Prefix 'form_' @param string $action Form Action, mostly an URL @param string $target Target Frage of Action @param string $enctype Encryption Type, needs to be 'multipart/form-data' for File Uploads @param string $onSubmit JavaScript to execute before Form is submitted, Validation is possible @return string
[ "Builds", "HTML", "Code", "for", "a", "Form", "using", "POST", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L166-L179
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.HiddenField
public static function HiddenField( $name, $value ) { $attributes = array( 'id' => $name, 'type' => "hidden", 'name' => $name, 'value' => $value, ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
php
public static function HiddenField( $name, $value ) { $attributes = array( 'id' => $name, 'type' => "hidden", 'name' => $name, 'value' => $value, ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
[ "public", "static", "function", "HiddenField", "(", "$", "name", ",", "$", "value", ")", "{", "$", "attributes", "=", "array", "(", "'id'", "=>", "$", "name", ",", "'type'", "=>", "\"hidden\"", ",", "'name'", "=>", "$", "name", ",", "'value'", "=>", ...
Builds HTML Code for a hidden Input Field. It is not advised to work with hidden Fields. @access public @static @param string $name Field Name @param string $value Field Value @return string
[ "Builds", "HTML", "Code", "for", "a", "hidden", "Input", "Field", ".", "It", "is", "not", "advised", "to", "work", "with", "hidden", "Fields", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L189-L198
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Input
public static function Input( $name, $value = NULL, $class = NULL, $readOnly = NULL, $tabIndex = NULL, $maxLength = NULL, $validator = NULL ) { $attributes = array( 'id' => $name, 'type' => "text", 'name' => $name, 'value' => $value, 'class' => $class, 'tabindex' => $tabIndex, 'maxlength' => $maxLength, 'onkeyup' => $validator ? "allowOnly(this,'".$validator."');" : NULL, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
php
public static function Input( $name, $value = NULL, $class = NULL, $readOnly = NULL, $tabIndex = NULL, $maxLength = NULL, $validator = NULL ) { $attributes = array( 'id' => $name, 'type' => "text", 'name' => $name, 'value' => $value, 'class' => $class, 'tabindex' => $tabIndex, 'maxlength' => $maxLength, 'onkeyup' => $validator ? "allowOnly(this,'".$validator."');" : NULL, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
[ "public", "static", "function", "Input", "(", "$", "name", ",", "$", "value", "=", "NULL", ",", "$", "class", "=", "NULL", ",", "$", "readOnly", "=", "NULL", ",", "$", "tabIndex", "=", "NULL", ",", "$", "maxLength", "=", "NULL", ",", "$", "validato...
Builds HTML Code for an Input Field. Validation is possible using Validator Classes from UI.validateInput.js. @access public @static @param string $name Field Name @param string $value Field Value @param string $class CSS Class (xl|l|m|s|xs) @param mixed $readOnly Field is not writable, JavaScript Alert if String is given @param int $tabIndex Tabbing Order @param int $maxLength Maximum Length @param string $validator Validator Class (using UI.validateInput.js) @return string
[ "Builds", "HTML", "Code", "for", "an", "Input", "Field", ".", "Validation", "is", "possible", "using", "Validator", "Classes", "from", "UI", ".", "validateInput", ".", "js", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L213-L228
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Label
public static function Label( $id, $label, $class = NULL ) { $attributes = array( 'for' => $id, 'class' => $class ? $class : NULL, ); return UI_HTML_Tag::create( "label", $label, $attributes ); }
php
public static function Label( $id, $label, $class = NULL ) { $attributes = array( 'for' => $id, 'class' => $class ? $class : NULL, ); return UI_HTML_Tag::create( "label", $label, $attributes ); }
[ "public", "static", "function", "Label", "(", "$", "id", ",", "$", "label", ",", "$", "class", "=", "NULL", ")", "{", "$", "attributes", "=", "array", "(", "'for'", "=>", "$", "id", ",", "'class'", "=>", "$", "class", "?", "$", "class", ":", "NUL...
Builds HTML Code for a Field Label. @access public @static @param string $id ID of Field to reference @param string $label Label Text @param string $class CSS Class @return string
[ "Builds", "HTML", "Code", "for", "a", "Field", "Label", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L239-L246
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.LinkButton
public static function LinkButton( $url, $label, $class = NULL, $confirm = NULL, $disabled = NULL, $title = NULL ) { $action = "document.location.href='".$url."';"; $attributes = array( 'id' => "button_".md5( $label ), 'type' => "button", 'class' => $class, 'onclick' => $confirm ? "if(confirm('".$confirm."')){".$action."};" : $action, 'title' => $title, ); if( $disabled ) self::addDisabledAttributes( $attributes, $disabled ); return UI_HTML_Tag::create( "button", UI_HTML_Tag::create( "span", $label ), $attributes ); }
php
public static function LinkButton( $url, $label, $class = NULL, $confirm = NULL, $disabled = NULL, $title = NULL ) { $action = "document.location.href='".$url."';"; $attributes = array( 'id' => "button_".md5( $label ), 'type' => "button", 'class' => $class, 'onclick' => $confirm ? "if(confirm('".$confirm."')){".$action."};" : $action, 'title' => $title, ); if( $disabled ) self::addDisabledAttributes( $attributes, $disabled ); return UI_HTML_Tag::create( "button", UI_HTML_Tag::create( "span", $label ), $attributes ); }
[ "public", "static", "function", "LinkButton", "(", "$", "url", ",", "$", "label", ",", "$", "class", "=", "NULL", ",", "$", "confirm", "=", "NULL", ",", "$", "disabled", "=", "NULL", ",", "$", "title", "=", "NULL", ")", "{", "$", "action", "=", "...
Builds HTML Code for a Button behaving like a Link. @access public @static @param string $label Button Label, also used for ID with Prefix 'button_' and MD5 Hash @param string $url URL to request @param string $class CSS Class @param string $confirm Confirmation Message @param mixed $disabled Button is not pressable, JavaScript Alert if String is given @param string $title Title text on mouse hove @return string
[ "Builds", "HTML", "Code", "for", "a", "Button", "behaving", "like", "a", "Link", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L260-L273
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Option
public static function Option( $value, $label, $selected = NULL, $disabled = NULL, $class = NULL ) { if( !( $value != "_selected" && $value != "_groupname" ) ) return ""; $attributes = array( 'value' => $value, 'selected' => $selected ? "selected" : NULL, 'disabled' => $disabled ? "disabled" : NULL, 'class' => $class, ); return UI_HTML_Tag::create( "option", htmlspecialchars( $label ), $attributes ); }
php
public static function Option( $value, $label, $selected = NULL, $disabled = NULL, $class = NULL ) { if( !( $value != "_selected" && $value != "_groupname" ) ) return ""; $attributes = array( 'value' => $value, 'selected' => $selected ? "selected" : NULL, 'disabled' => $disabled ? "disabled" : NULL, 'class' => $class, ); return UI_HTML_Tag::create( "option", htmlspecialchars( $label ), $attributes ); }
[ "public", "static", "function", "Option", "(", "$", "value", ",", "$", "label", ",", "$", "selected", "=", "NULL", ",", "$", "disabled", "=", "NULL", ",", "$", "class", "=", "NULL", ")", "{", "if", "(", "!", "(", "$", "value", "!=", "\"_selected\""...
Builds HTML Code for an Option for a Select. @access public @static @param string $value Option Value @param string $label Option Label @param bool $selected Option State @param string $disabled Option is not selectable @param string $class CSS Class @return string
[ "Builds", "HTML", "Code", "for", "an", "Option", "for", "a", "Select", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L286-L297
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.OptionGroup
public static function OptionGroup( $label, $options, $selected = NULL ) { $attributes = array( 'label' => $label ); $options = self::Options( $options, $selected ); return UI_HTML_Tag::create( "optgroup", $options, $attributes ); }
php
public static function OptionGroup( $label, $options, $selected = NULL ) { $attributes = array( 'label' => $label ); $options = self::Options( $options, $selected ); return UI_HTML_Tag::create( "optgroup", $options, $attributes ); }
[ "public", "static", "function", "OptionGroup", "(", "$", "label", ",", "$", "options", ",", "$", "selected", "=", "NULL", ")", "{", "$", "attributes", "=", "array", "(", "'label'", "=>", "$", "label", ")", ";", "$", "options", "=", "self", "::", "Opt...
Builds HTML Code for an Option Group for a Select. @access public @static @param string $label Group Label @param string $options Array of Options @param string $selected Value of selected Option @return string
[ "Builds", "HTML", "Code", "for", "an", "Option", "Group", "for", "a", "Select", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L308-L313
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Options
public static function Options( $options, $selected = NULL ) { $list = array(); foreach( $options as $key => $value) { if( (string) $key != "_selected" && is_array( $value ) ) { foreach( $options as $groupLabel => $groupOptions ) { if( !is_array( $groupOptions ) ) continue; if( (string) $groupLabel == "_selected" ) continue; $groupName = isset( $groupOptions['_groupname'] ) ? $groupOptions['_groupname'] : $groupLabel; $select = isset( $options['_selected'] ) ? $options['_selected'] : $selected; $list[] = self::OptionGroup( $groupName, $groupOptions, $select ); } return implode( "", $list ); } } foreach( $options as $value => $label ) { $value = (string) $value; $isSelected = is_array( $selected ) ? in_array( $value, $selected ) : (string) $selected == (string) $value; $list[] = self::Option( $value, $label, $isSelected ); } return implode( "", $list ); }
php
public static function Options( $options, $selected = NULL ) { $list = array(); foreach( $options as $key => $value) { if( (string) $key != "_selected" && is_array( $value ) ) { foreach( $options as $groupLabel => $groupOptions ) { if( !is_array( $groupOptions ) ) continue; if( (string) $groupLabel == "_selected" ) continue; $groupName = isset( $groupOptions['_groupname'] ) ? $groupOptions['_groupname'] : $groupLabel; $select = isset( $options['_selected'] ) ? $options['_selected'] : $selected; $list[] = self::OptionGroup( $groupName, $groupOptions, $select ); } return implode( "", $list ); } } foreach( $options as $value => $label ) { $value = (string) $value; $isSelected = is_array( $selected ) ? in_array( $value, $selected ) : (string) $selected == (string) $value; $list[] = self::Option( $value, $label, $isSelected ); } return implode( "", $list ); }
[ "public", "static", "function", "Options", "(", "$", "options", ",", "$", "selected", "=", "NULL", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "(",...
Builds HTML Code for Options for a Select. @access public @static @param array $options Array of Options @param string $selected Value of selected Option @return string
[ "Builds", "HTML", "Code", "for", "Options", "for", "a", "Select", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L323-L350
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Password
public static function Password( $name, $class = NULL, $readOnly = NULL, $tabIndex = NULL, $maxLength = NULL ) { $attributes = array( 'id' => $name, 'type' => "password", 'name' => $name, 'class' => $class, 'tabindex' => $tabIndex, 'maxlength' => $maxLength, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
php
public static function Password( $name, $class = NULL, $readOnly = NULL, $tabIndex = NULL, $maxLength = NULL ) { $attributes = array( 'id' => $name, 'type' => "password", 'name' => $name, 'class' => $class, 'tabindex' => $tabIndex, 'maxlength' => $maxLength, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
[ "public", "static", "function", "Password", "(", "$", "name", ",", "$", "class", "=", "NULL", ",", "$", "readOnly", "=", "NULL", ",", "$", "tabIndex", "=", "NULL", ",", "$", "maxLength", "=", "NULL", ")", "{", "$", "attributes", "=", "array", "(", ...
Builds HTML Code for a Password Field. @access public @static @param string $name Field Name @param string $class CSS Class (xl|l|m|s|xs) @param mixed $readOnly Field is not writable, JavaScript Alert if String is given @param int $tabIndex Tabbing Order @param int $maxLength Maximum Length @return string
[ "Builds", "HTML", "Code", "for", "a", "Password", "Field", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L363-L376
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Radio
public static function Radio( $name, $value, $checked = NULL, $class = NULL, $readOnly = NULL ) { $attributes = array( 'id' => $name.'_'.$value, 'type' => "radio", 'name' => $name, 'value' => $value, 'class' => $class, 'checked' => $checked ? "checked" : NULL, 'disabled' => $readOnly ? "disabled" : NULL, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
php
public static function Radio( $name, $value, $checked = NULL, $class = NULL, $readOnly = NULL ) { $attributes = array( 'id' => $name.'_'.$value, 'type' => "radio", 'name' => $name, 'value' => $value, 'class' => $class, 'checked' => $checked ? "checked" : NULL, 'disabled' => $readOnly ? "disabled" : NULL, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "input", NULL, $attributes ); }
[ "public", "static", "function", "Radio", "(", "$", "name", ",", "$", "value", ",", "$", "checked", "=", "NULL", ",", "$", "class", "=", "NULL", ",", "$", "readOnly", "=", "NULL", ")", "{", "$", "attributes", "=", "array", "(", "'id'", "=>", "$", ...
Builds HTML Code for Radio Buttons. @access public @static @param string $name Field Name @param string $value Field Value if checked @param string $checked Field State @param string $class CSS Class @param mixed $readOnly Field is not writable, JavaScript Alert if String is given @return string
[ "Builds", "HTML", "Code", "for", "Radio", "Buttons", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L389-L403
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.RadioGroup
public static function RadioGroup( $name, $options, $class = NULL, $readOnly = NULL ) { $radios = array(); foreach( $options as $value => $label ) { if( (string) $value == '_selected' ) continue; $selected = isset( $options['_selected'] ) ? (string) $value == (string) $options['_selected'] : NULL; $radio = self::Radio( $name, $value, $selected, $class, $readOnly ); $spanRadio = UI_HTML_Tag::create( "span", $radio, array( 'class' => 'radio' ) ); $label = UI_HTML_Tag::create( "label", $label, array( 'for' => $name."_".$value ) ); $spanLabel = UI_HTML_Tag::create( "span", $label, array( 'class' => 'label' ) ); $content = UI_HTML_Tag::create( "span", $spanRadio.$spanLabel, array( 'class' => 'radiolabel' ) ); $radios[] = $content; } $group = implode( "", $radios ); return $group; }
php
public static function RadioGroup( $name, $options, $class = NULL, $readOnly = NULL ) { $radios = array(); foreach( $options as $value => $label ) { if( (string) $value == '_selected' ) continue; $selected = isset( $options['_selected'] ) ? (string) $value == (string) $options['_selected'] : NULL; $radio = self::Radio( $name, $value, $selected, $class, $readOnly ); $spanRadio = UI_HTML_Tag::create( "span", $radio, array( 'class' => 'radio' ) ); $label = UI_HTML_Tag::create( "label", $label, array( 'for' => $name."_".$value ) ); $spanLabel = UI_HTML_Tag::create( "span", $label, array( 'class' => 'label' ) ); $content = UI_HTML_Tag::create( "span", $spanRadio.$spanLabel, array( 'class' => 'radiolabel' ) ); $radios[] = $content; } $group = implode( "", $radios ); return $group; }
[ "public", "static", "function", "RadioGroup", "(", "$", "name", ",", "$", "options", ",", "$", "class", "=", "NULL", ",", "$", "readOnly", "=", "NULL", ")", "{", "$", "radios", "=", "array", "(", ")", ";", "foreach", "(", "$", "options", "as", "$",...
Builds HTML for a Group of Radio Buttons, behaving like a Select. @access public @static @param string $name Field Name @param array $options Array of Options @param string $class CSS Class @param mixed $readOnly Field is not writable, JavaScript Alert if String is given @return string
[ "Builds", "HTML", "for", "a", "Group", "of", "Radio", "Buttons", "behaving", "like", "a", "Select", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L415-L432
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.ResetButton
public static function ResetButton( $label, $class = NULL, $confirm = NULL, $disabled = NULL, $title = NULL ) { $attributes = array( 'type' => "reset", 'class' => $class, 'onclick' => $confirm ? "return confirm('".$confirm."');" : NULL, 'title' => $title, ); if( $disabled ) self::addReadonlyAttributes( $attributes, $disabled ); return UI_HTML_Tag::create( "button", $label, $attributes ); }
php
public static function ResetButton( $label, $class = NULL, $confirm = NULL, $disabled = NULL, $title = NULL ) { $attributes = array( 'type' => "reset", 'class' => $class, 'onclick' => $confirm ? "return confirm('".$confirm."');" : NULL, 'title' => $title, ); if( $disabled ) self::addReadonlyAttributes( $attributes, $disabled ); return UI_HTML_Tag::create( "button", $label, $attributes ); }
[ "public", "static", "function", "ResetButton", "(", "$", "label", ",", "$", "class", "=", "NULL", ",", "$", "confirm", "=", "NULL", ",", "$", "disabled", "=", "NULL", ",", "$", "title", "=", "NULL", ")", "{", "$", "attributes", "=", "array", "(", "...
Builds HTML Code for a Button to reset the current Form. @access public @static @param string $label Button Label @param string $class CSS Class @param string $confirm Confirmation Message @param mixed $disabled Button is not pressable, JavaScript Alert if String is given @param string $title Title text on mouse hover @return string
[ "Builds", "HTML", "Code", "for", "a", "Button", "to", "reset", "the", "current", "Form", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L445-L456
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Select
public static function Select( $name, $options, $class = NULL, $readOnly = NULL, $submit = NULL, $focus = NULL, $change = NULL ) { if( is_array( $options ) ) { $selected = isset( $options['_selected'] ) ? $options['_selected'] : NULL; $options = self::Options( $options, $selected ); } $focus = $focus ? "document.getElementById('".$focus."').focus();" : NULL; $submit = $submit ? "document.getElementById('form_".$submit."').submit();" : NULL; $attributes = array( 'id' => str_replace( "[]", "", $name ), 'name' => $name, 'class' => $class, 'multiple' => substr( trim( $name ), -2 ) == "[]" ? "multiple" : NULL, 'onchange' => $focus.$submit.$change ? $focus.$submit.$change : NULL, ); if( $readOnly ){ $attributes['readonly'] = "readonly"; if( is_string( $readOnly ) && strlen( trim( $readOnly ) ) ) $attributes['onmousedown'] = "alert('".htmlentities( $readOnly, ENT_QUOTES, 'UTF-8' )."'); return false;"; else self::addDisabledAttributes( $attributes, TRUE ); } return UI_HTML_Tag::create( "select", $options, $attributes ); }
php
public static function Select( $name, $options, $class = NULL, $readOnly = NULL, $submit = NULL, $focus = NULL, $change = NULL ) { if( is_array( $options ) ) { $selected = isset( $options['_selected'] ) ? $options['_selected'] : NULL; $options = self::Options( $options, $selected ); } $focus = $focus ? "document.getElementById('".$focus."').focus();" : NULL; $submit = $submit ? "document.getElementById('form_".$submit."').submit();" : NULL; $attributes = array( 'id' => str_replace( "[]", "", $name ), 'name' => $name, 'class' => $class, 'multiple' => substr( trim( $name ), -2 ) == "[]" ? "multiple" : NULL, 'onchange' => $focus.$submit.$change ? $focus.$submit.$change : NULL, ); if( $readOnly ){ $attributes['readonly'] = "readonly"; if( is_string( $readOnly ) && strlen( trim( $readOnly ) ) ) $attributes['onmousedown'] = "alert('".htmlentities( $readOnly, ENT_QUOTES, 'UTF-8' )."'); return false;"; else self::addDisabledAttributes( $attributes, TRUE ); } return UI_HTML_Tag::create( "select", $options, $attributes ); }
[ "public", "static", "function", "Select", "(", "$", "name", ",", "$", "options", ",", "$", "class", "=", "NULL", ",", "$", "readOnly", "=", "NULL", ",", "$", "submit", "=", "NULL", ",", "$", "focus", "=", "NULL", ",", "$", "change", "=", "NULL", ...
Builds HTML Code for a Select. @access public @static @param string $name Field Name @param mixed $options Array of String of Options @param string $class CSS Class (xl|l|m|s|xs) @param mixed $readOnly Field is not writable, JavaScript Alert if String is given @param string $submit ID of Form to submit on Change @param string $focus ID of Element to focus on Change @param string $change JavaScript to execute on Change @return string
[ "Builds", "HTML", "Code", "for", "a", "Select", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L471-L495
train
CeusMedia/Common
src/UI/HTML/FormElements.php
UI_HTML_FormElements.Textarea
public static function Textarea( $name, $content, $class = NULL, $readOnly = NULL, $validator = NULL ) { $attributes = array( 'id' => $name, 'name' => $name, 'class' => $class, 'onkeyup' => $validator ? "allowOnly(this,'".$validator."');" : NULL, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "textarea", (string) $content, $attributes ); }
php
public static function Textarea( $name, $content, $class = NULL, $readOnly = NULL, $validator = NULL ) { $attributes = array( 'id' => $name, 'name' => $name, 'class' => $class, 'onkeyup' => $validator ? "allowOnly(this,'".$validator."');" : NULL, ); if( $readOnly ) self::addReadonlyAttributes( $attributes, $readOnly ); return UI_HTML_Tag::create( "textarea", (string) $content, $attributes ); }
[ "public", "static", "function", "Textarea", "(", "$", "name", ",", "$", "content", ",", "$", "class", "=", "NULL", ",", "$", "readOnly", "=", "NULL", ",", "$", "validator", "=", "NULL", ")", "{", "$", "attributes", "=", "array", "(", "'id'", "=>", ...
Builds HTML Code for a Textarea. @access public @static @param string $name Field Name @param string $content Field Content @param string $class CSS Class (ll|lm|ls|ml|mm|ms|sl|sm|ss) @param mixed $readOnly Field is not writable, JavaScript Alert if String is given @param string $validator Validator Class (using UI.validateInput.js) @return string
[ "Builds", "HTML", "Code", "for", "a", "Textarea", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/FormElements.php#L508-L519
train
elifesciences/api-sdk-php
src/Serializer/ArticleVersionNormalizer.php
ArticleVersionNormalizer.articleClass
public static function articleClass(string $type, string $status = null) { switch ($type) { case 'correction': case 'editorial': case 'feature': case 'insight': case 'research-advance': case 'research-article': case 'research-communication': case 'retraction': case 'registered-report': case 'replication-study': case 'scientific-correspondence': case 'short-report': case 'tools-resources': if ('poa' === $status) { $class = ArticlePoA::class; } else { $class = ArticleVoR::class; } return $class; } return null; }
php
public static function articleClass(string $type, string $status = null) { switch ($type) { case 'correction': case 'editorial': case 'feature': case 'insight': case 'research-advance': case 'research-article': case 'research-communication': case 'retraction': case 'registered-report': case 'replication-study': case 'scientific-correspondence': case 'short-report': case 'tools-resources': if ('poa' === $status) { $class = ArticlePoA::class; } else { $class = ArticleVoR::class; } return $class; } return null; }
[ "public", "static", "function", "articleClass", "(", "string", "$", "type", ",", "string", "$", "status", "=", "null", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'correction'", ":", "case", "'editorial'", ":", "case", "'feature'", ":", "cas...
Selects the Model class from the 'type' and 'status' fields. @return string|null
[ "Selects", "the", "Model", "class", "from", "the", "type", "and", "status", "fields", "." ]
05138ffe3d2a50a9f68174f157e9dbd9f51e3f30
https://github.com/elifesciences/api-sdk-php/blob/05138ffe3d2a50a9f68174f157e9dbd9f51e3f30/src/Serializer/ArticleVersionNormalizer.php#L69-L95
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.addFolder
public function addFolder( $dirName ) { if( !file_exists( $dirName ) ) return FALSE; $fileInfo = stat( $dirName ); // Get folder information $this->numFolders++; // Add folder to processed data $activeDir = &$this->folders[]; $activeDir['name'] = $dirName; $activeDir['mode'] = $fileInfo['mode']; $activeDir['time'] = $fileInfo['mtime']; $activeDir['user_id'] = $fileInfo['uid']; $activeDir['group_id'] = $fileInfo['gid']; # $activeDir['checksum'] = $checksum; return TRUE; }
php
public function addFolder( $dirName ) { if( !file_exists( $dirName ) ) return FALSE; $fileInfo = stat( $dirName ); // Get folder information $this->numFolders++; // Add folder to processed data $activeDir = &$this->folders[]; $activeDir['name'] = $dirName; $activeDir['mode'] = $fileInfo['mode']; $activeDir['time'] = $fileInfo['mtime']; $activeDir['user_id'] = $fileInfo['uid']; $activeDir['group_id'] = $fileInfo['gid']; # $activeDir['checksum'] = $checksum; return TRUE; }
[ "public", "function", "addFolder", "(", "$", "dirName", ")", "{", "if", "(", "!", "file_exists", "(", "$", "dirName", ")", ")", "return", "FALSE", ";", "$", "fileInfo", "=", "stat", "(", "$", "dirName", ")", ";", "// Get folder information\r", "$", "this...
Adds a Folder to this TAR Archive. @access public @param string $dirName Path of Folder to add @return bool
[ "Adds", "a", "Folder", "to", "this", "TAR", "Archive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L103-L117
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.appendTar
public function appendTar( $fileName ) { if( !file_exists( $fileName ) ) // If the tar file doesn't exist... throw new Exception( 'TAR File "'.$fileName.'" is not existing' ); $this->readTar( $fileName ); return TRUE; }
php
public function appendTar( $fileName ) { if( !file_exists( $fileName ) ) // If the tar file doesn't exist... throw new Exception( 'TAR File "'.$fileName.'" is not existing' ); $this->readTar( $fileName ); return TRUE; }
[ "public", "function", "appendTar", "(", "$", "fileName", ")", "{", "if", "(", "!", "file_exists", "(", "$", "fileName", ")", ")", "// If the tar file doesn't exist...\r", "throw", "new", "Exception", "(", "'TAR File \"'", ".", "$", "fileName", ".", "'\" is not e...
Appends a TAR File to the end of the currently opened TAR File. @access public @param string $fileName TAR File to add to current TAR File @return bool
[ "Appends", "a", "TAR", "File", "to", "the", "end", "of", "the", "currently", "opened", "TAR", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L125-L131
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.computeUnsignedChecksum
private function computeUnsignedChecksum( $bytestring ) { $unsigned_chksum = 0; for( $i=0; $i<512; $i++ ) $unsigned_chksum += ord( $bytestring[$i] ); for( $i=0; $i<8; $i++ ) $unsigned_chksum -= ord( $bytestring[148 + $i]) ; $unsigned_chksum += ord( " " ) * 8; return $unsigned_chksum; }
php
private function computeUnsignedChecksum( $bytestring ) { $unsigned_chksum = 0; for( $i=0; $i<512; $i++ ) $unsigned_chksum += ord( $bytestring[$i] ); for( $i=0; $i<8; $i++ ) $unsigned_chksum -= ord( $bytestring[148 + $i]) ; $unsigned_chksum += ord( " " ) * 8; return $unsigned_chksum; }
[ "private", "function", "computeUnsignedChecksum", "(", "$", "bytestring", ")", "{", "$", "unsigned_chksum", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "512", ";", "$", "i", "++", ")", "$", "unsigned_chksum", "+=", "ord", "(", ...
Computes the unsigned Checksum of a File's header to try to ensure valid File. @access private @param string $bytestring String of Bytes @return string
[ "Computes", "the", "unsigned", "Checksum", "of", "a", "File", "s", "header", "to", "try", "to", "ensure", "valid", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L139-L148
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.containsFile
public function containsFile( $fileName ) { if( !$this->numFiles ) return FALSE; foreach( $this->files as $key => $information ) if( $information['name'] == $fileName ) return TRUE; }
php
public function containsFile( $fileName ) { if( !$this->numFiles ) return FALSE; foreach( $this->files as $key => $information ) if( $information['name'] == $fileName ) return TRUE; }
[ "public", "function", "containsFile", "(", "$", "fileName", ")", "{", "if", "(", "!", "$", "this", "->", "numFiles", ")", "return", "FALSE", ";", "foreach", "(", "$", "this", "->", "files", "as", "$", "key", "=>", "$", "information", ")", "if", "(", ...
Checks whether this Archive contains a specific File. @access public @param string $fileName Name of File to check @return bool
[ "Checks", "whether", "this", "Archive", "contains", "a", "specific", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L156-L163
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.containsFolder
public function containsFolder( $dirName ) { if( !$this->numFolders ) return FALSE; foreach( $this->folders as $key => $information ) if( $information['name'] == $dirName ) return TRUE; }
php
public function containsFolder( $dirName ) { if( !$this->numFolders ) return FALSE; foreach( $this->folders as $key => $information ) if( $information['name'] == $dirName ) return TRUE; }
[ "public", "function", "containsFolder", "(", "$", "dirName", ")", "{", "if", "(", "!", "$", "this", "->", "numFolders", ")", "return", "FALSE", ";", "foreach", "(", "$", "this", "->", "folders", "as", "$", "key", "=>", "$", "information", ")", "if", ...
Checks whether this Archive contains a specific Folder. @access public @param string $dirName Name of Folder to check @return bool
[ "Checks", "whether", "this", "Archive", "contains", "a", "specific", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L171-L178
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.getFile
public function getFile( $fileName ) { if( !$this->numFiles ) return NULL; foreach( $this->files as $key => $information ) if( $information['name'] == $fileName ) return $information; }
php
public function getFile( $fileName ) { if( !$this->numFiles ) return NULL; foreach( $this->files as $key => $information ) if( $information['name'] == $fileName ) return $information; }
[ "public", "function", "getFile", "(", "$", "fileName", ")", "{", "if", "(", "!", "$", "this", "->", "numFiles", ")", "return", "NULL", ";", "foreach", "(", "$", "this", "->", "files", "as", "$", "key", "=>", "$", "information", ")", "if", "(", "$",...
Retrieves information about a File in the current TAR Archive. @access public @param string $fileName File Name to get Information for @return array
[ "Retrieves", "information", "about", "a", "File", "in", "the", "current", "TAR", "Archive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L293-L300
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.getFileList
public function getFileList() { $list = array(); foreach( $this->files as $file ) $list[$file['name']] = $file['size']; return $list; }
php
public function getFileList() { $list = array(); foreach( $this->files as $file ) $list[$file['name']] = $file['size']; return $list; }
[ "public", "function", "getFileList", "(", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "files", "as", "$", "file", ")", "$", "list", "[", "$", "file", "[", "'name'", "]", "]", "=", "$", "file", "[", "'s...
Returns a List of Files within Archive. @access public @return array
[ "Returns", "a", "List", "of", "Files", "within", "Archive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L307-L313
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.getFolder
public function getFolder( $dirName ) { if( !$this->numFolders ) return NULL; foreach( $this->folders as $key => $information ) if( $information['name'] == $dirName ) return $information; }
php
public function getFolder( $dirName ) { if( !$this->numFolders ) return NULL; foreach( $this->folders as $key => $information ) if( $information['name'] == $dirName ) return $information; }
[ "public", "function", "getFolder", "(", "$", "dirName", ")", "{", "if", "(", "!", "$", "this", "->", "numFolders", ")", "return", "NULL", ";", "foreach", "(", "$", "this", "->", "folders", "as", "$", "key", "=>", "$", "information", ")", "if", "(", ...
Retrieves information about a Folder in the current TAR Archive. @access public @param string $dirName Folder Name to get Information for @return array
[ "Retrieves", "information", "about", "a", "Folder", "in", "the", "current", "TAR", "Archive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L321-L328
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.open
public function open( $fileName ) { if( !file_exists( $fileName ) ) // If the tar file doesn't exist... throw new Exception( 'TAR File "'.$fileName.'" is not existing' ); $this->content = ""; $this->files = array(); $this->folders = array(); $this->numFiles = 0; $this->numFolders = 0; $this->fileName = $fileName; return $this->readTar( $fileName ); }
php
public function open( $fileName ) { if( !file_exists( $fileName ) ) // If the tar file doesn't exist... throw new Exception( 'TAR File "'.$fileName.'" is not existing' ); $this->content = ""; $this->files = array(); $this->folders = array(); $this->numFiles = 0; $this->numFolders = 0; $this->fileName = $fileName; return $this->readTar( $fileName ); }
[ "public", "function", "open", "(", "$", "fileName", ")", "{", "if", "(", "!", "file_exists", "(", "$", "fileName", ")", ")", "// If the tar file doesn't exist...\r", "throw", "new", "Exception", "(", "'TAR File \"'", ".", "$", "fileName", ".", "'\" is not existi...
Opens and reads a TAR File. @access public @param string $fileName File Name of TAR Archive @return bool
[ "Opens", "and", "reads", "a", "TAR", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L349-L360
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.readTar
protected function readTar( $fileName ) { $file = new FS_File_Reader( $fileName ); $this->content = $file->readString(); return $this->parseTar(); // Parse the TAR file }
php
protected function readTar( $fileName ) { $file = new FS_File_Reader( $fileName ); $this->content = $file->readString(); return $this->parseTar(); // Parse the TAR file }
[ "protected", "function", "readTar", "(", "$", "fileName", ")", "{", "$", "file", "=", "new", "FS_File_Reader", "(", "$", "fileName", ")", ";", "$", "this", "->", "content", "=", "$", "file", "->", "readString", "(", ")", ";", "return", "$", "this", "...
Read a non gzipped TAR File in for processing. @access protected @param string $fileName Reads TAR Archive @return bool
[ "Read", "a", "non", "gzipped", "TAR", "File", "in", "for", "processing", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L444-L449
train