id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
36,900
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\"", ",", "\"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", ";", "}" ]
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
36,901
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", ")", ";", "$", "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", ";", "}" ]
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
36,902
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'", ")", ")", ";", "$", "this", "->", "writeRecursive", "(", "$", "root", ",", "$", "this", "->", "storage", ")", ";", "return", "$", "writer", "->", "write", "(", "$", "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
36,903
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", "=", "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", ")", ";", "}", "}", "}" ]
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
36,904
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
36,905
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", "=", "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", "}" ]
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
36,906
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
36,907
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", ")", ")", "return", "NULL", ";", "return", "$", "this", "->", "data", "[", "$", "key", "]", ";", "}" ]
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
36,908
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", "(", "'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", "{", "//\t\t\tif( is_string( $value ) || is_numeric( $value ) )\t\t\t\t\t\t\t\t\t\t// value is string or numeric", "//\t\t\t\tif( preg_match( '/[^\\\\\\]\"/', $value ) )\t\t\t\t\t\t\t\t\t\t\t\t// detect injection", "//\t\t\t\t\tthrow new InvalidArgumentException( 'Invalid attribute value' );\t\t\t\t// throw exception", "$", "this", "->", "attributes", "[", "$", "key", "]", "=", "$", "value", ";", "// set attribute", "}", "}" ]
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
36,909
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", "(", "$", "key", ",", "$", "value", ",", "$", "strict", ")", ";", "// set each attribute", "}" ]
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
36,910
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", "(", "'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", "}", "}" ]
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
36,911
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 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", ";", "}" ]
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
36,912
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", "=", "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", ")", ";", "}" ]
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
36,913
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'", "=>", "$", "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", ")", ";", "}" ]
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
36,914
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", ")", "{", "$", "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", ")", ";", "}" ]
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
36,915
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", "(", "'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", ")", ";", "}" ]
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
36,916
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'", "=>", "$", "value", ",", ")", ";", "return", "UI_HTML_Tag", "::", "create", "(", "\"input\"", ",", "NULL", ",", "$", "attributes", ")", ";", "}" ]
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
36,917
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", ",", "$", "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", ")", ";", "}" ]
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
36,918
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", ":", "NULL", ",", ")", ";", "return", "UI_HTML_Tag", "::", "create", "(", "\"label\"", ",", "$", "label", ",", "$", "attributes", ")", ";", "}" ]
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
36,919
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", "=", "\"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", ")", ";", "}" ]
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
36,920
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\"", "&&", "$", "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", ")", ";", "}" ]
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
36,921
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", "::", "Options", "(", "$", "options", ",", "$", "selected", ")", ";", "return", "UI_HTML_Tag", "::", "create", "(", "\"optgroup\"", ",", "$", "options", ",", "$", "attributes", ")", ";", "}" ]
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
36,922
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", "(", "(", "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", ")", ";", "}" ]
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
36,923
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", "(", "'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", ")", ";", "}" ]
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
36,924
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'", "=>", "$", "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", ")", ";", "}" ]
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
36,925
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", "$", "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", ";", "}" ]
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
36,926
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", "(", "'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", ")", ";", "}" ]
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
36,927
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", ")", "{", "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", ")", ";", "}" ]
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
36,928
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'", "=>", "$", "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", ")", ";", "}" ]
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
36,929
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'", ":", "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", ";", "}" ]
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
36,930
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", "->", "numFolders", "++", ";", "// Add folder to processed data\r", "$", "activeDir", "=", "&", "$", "this", "->", "folders", "[", "]", ";", "$", "activeDir", "[", "'name'", "]", "=", "$", "dirName", ";", "$", "activeDir", "[", "'mode'", "]", "=", "$", "fileInfo", "[", "'mode'", "]", ";", "$", "activeDir", "[", "'time'", "]", "=", "$", "fileInfo", "[", "'mtime'", "]", ";", "$", "activeDir", "[", "'user_id'", "]", "=", "$", "fileInfo", "[", "'uid'", "]", ";", "$", "activeDir", "[", "'group_id'", "]", "=", "$", "fileInfo", "[", "'gid'", "]", ";", "#\t\t$activeDir['checksum']\t= $checksum;\r", "return", "TRUE", ";", "}" ]
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
36,931
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 existing'", ")", ";", "$", "this", "->", "readTar", "(", "$", "fileName", ")", ";", "return", "TRUE", ";", "}" ]
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
36,932
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", "(", "$", "bytestring", "[", "$", "i", "]", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "8", ";", "$", "i", "++", ")", "$", "unsigned_chksum", "-=", "ord", "(", "$", "bytestring", "[", "148", "+", "$", "i", "]", ")", ";", "$", "unsigned_chksum", "+=", "ord", "(", "\" \"", ")", "*", "8", ";", "return", "$", "unsigned_chksum", ";", "}" ]
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
36,933
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", "(", "$", "information", "[", "'name'", "]", "==", "$", "fileName", ")", "return", "TRUE", ";", "}" ]
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
36,934
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", "(", "$", "information", "[", "'name'", "]", "==", "$", "dirName", ")", "return", "TRUE", ";", "}" ]
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
36,935
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", "(", "$", "information", "[", "'name'", "]", "==", "$", "fileName", ")", "return", "$", "information", ";", "}" ]
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
36,936
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", "[", "'size'", "]", ";", "return", "$", "list", ";", "}" ]
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
36,937
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", "(", "$", "information", "[", "'name'", "]", "==", "$", "dirName", ")", "return", "$", "information", ";", "}" ]
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
36,938
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 existing'", ")", ";", "$", "this", "->", "content", "=", "\"\"", ";", "$", "this", "->", "files", "=", "array", "(", ")", ";", "$", "this", "->", "folders", "=", "array", "(", ")", ";", "$", "this", "->", "numFiles", "=", "0", ";", "$", "this", "->", "numFolders", "=", "0", ";", "$", "this", "->", "fileName", "=", "$", "fileName", ";", "return", "$", "this", "->", "readTar", "(", "$", "fileName", ")", ";", "}" ]
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
36,939
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", "->", "parseTar", "(", ")", ";", "// Parse the TAR file\r", "}" ]
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
36,940
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.removeFile
public function removeFile( $fileName ) { if( !$this->numFiles ) return FALSE; foreach( $this->files as $key => $information ) { if( $information['name'] !== $fileName ) continue; $this->numFiles--; unset( $this->files[$key] ); return TRUE; } }
php
public function removeFile( $fileName ) { if( !$this->numFiles ) return FALSE; foreach( $this->files as $key => $information ) { if( $information['name'] !== $fileName ) continue; $this->numFiles--; unset( $this->files[$key] ); return TRUE; } }
[ "public", "function", "removeFile", "(", "$", "fileName", ")", "{", "if", "(", "!", "$", "this", "->", "numFiles", ")", "return", "FALSE", ";", "foreach", "(", "$", "this", "->", "files", "as", "$", "key", "=>", "$", "information", ")", "{", "if", "(", "$", "information", "[", "'name'", "]", "!==", "$", "fileName", ")", "continue", ";", "$", "this", "->", "numFiles", "--", ";", "unset", "(", "$", "this", "->", "files", "[", "$", "key", "]", ")", ";", "return", "TRUE", ";", "}", "}" ]
Removes a File from the Archive. @access public @param string $fileName Name of File to remove @return bool
[ "Removes", "a", "File", "from", "the", "Archive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L457-L469
36,941
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.removeFolder
public function removeFolder( $dirName ) { if( !$this->numFolders ) return FALSE; foreach( $this->folders as $key => $information ) { if( $information['name'] !== $dirName ) continue; $this->numFolders--; unset( $this->folders[$key] ); return TRUE; } }
php
public function removeFolder( $dirName ) { if( !$this->numFolders ) return FALSE; foreach( $this->folders as $key => $information ) { if( $information['name'] !== $dirName ) continue; $this->numFolders--; unset( $this->folders[$key] ); return TRUE; } }
[ "public", "function", "removeFolder", "(", "$", "dirName", ")", "{", "if", "(", "!", "$", "this", "->", "numFolders", ")", "return", "FALSE", ";", "foreach", "(", "$", "this", "->", "folders", "as", "$", "key", "=>", "$", "information", ")", "{", "if", "(", "$", "information", "[", "'name'", "]", "!==", "$", "dirName", ")", "continue", ";", "$", "this", "->", "numFolders", "--", ";", "unset", "(", "$", "this", "->", "folders", "[", "$", "key", "]", ")", ";", "return", "TRUE", ";", "}", "}" ]
Removes a Folder from the Archive. @access public @param string $dirName Name of Folder to remove @return bool
[ "Removes", "a", "Folder", "from", "the", "Archive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L477-L489
36,942
smasty/Neevo
src/Neevo/ResultIterator.php
ResultIterator.rewind
public function rewind(){ try{ $count = count($this); } catch(DriverException $e){ $count = -1; } if($this->row !== null && $count > 0){ try{ $this->seek(0); } catch(DriverException $e){ $clone = clone $this->result; $this->result->__destruct(); $this->result = $clone; $this->pointer = 0; $this->row = $this->result->fetch(); } } else{ $this->pointer = 0; $this->row = $this->result->fetch(); } }
php
public function rewind(){ try{ $count = count($this); } catch(DriverException $e){ $count = -1; } if($this->row !== null && $count > 0){ try{ $this->seek(0); } catch(DriverException $e){ $clone = clone $this->result; $this->result->__destruct(); $this->result = $clone; $this->pointer = 0; $this->row = $this->result->fetch(); } } else{ $this->pointer = 0; $this->row = $this->result->fetch(); } }
[ "public", "function", "rewind", "(", ")", "{", "try", "{", "$", "count", "=", "count", "(", "$", "this", ")", ";", "}", "catch", "(", "DriverException", "$", "e", ")", "{", "$", "count", "=", "-", "1", ";", "}", "if", "(", "$", "this", "->", "row", "!==", "null", "&&", "$", "count", ">", "0", ")", "{", "try", "{", "$", "this", "->", "seek", "(", "0", ")", ";", "}", "catch", "(", "DriverException", "$", "e", ")", "{", "$", "clone", "=", "clone", "$", "this", "->", "result", ";", "$", "this", "->", "result", "->", "__destruct", "(", ")", ";", "$", "this", "->", "result", "=", "$", "clone", ";", "$", "this", "->", "pointer", "=", "0", ";", "$", "this", "->", "row", "=", "$", "this", "->", "result", "->", "fetch", "(", ")", ";", "}", "}", "else", "{", "$", "this", "->", "pointer", "=", "0", ";", "$", "this", "->", "row", "=", "$", "this", "->", "result", "->", "fetch", "(", ")", ";", "}", "}" ]
Rewinds the iterator. For future iterations seeks if possible, clones otherwise.
[ "Rewinds", "the", "iterator", ".", "For", "future", "iterations", "seeks", "if", "possible", "clones", "otherwise", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/ResultIterator.php#L47-L67
36,943
smasty/Neevo
src/Neevo/ResultIterator.php
ResultIterator.seek
public function seek($offset){ try{ $this->result->seek($offset); } catch(DriverException $e){ throw $e; } catch(NeevoException $e){ throw new OutOfRangeException("Cannot seek to offset $offset.", null, $e); } $this->row = $this->result->fetch(); $this->pointer = $offset; }
php
public function seek($offset){ try{ $this->result->seek($offset); } catch(DriverException $e){ throw $e; } catch(NeevoException $e){ throw new OutOfRangeException("Cannot seek to offset $offset.", null, $e); } $this->row = $this->result->fetch(); $this->pointer = $offset; }
[ "public", "function", "seek", "(", "$", "offset", ")", "{", "try", "{", "$", "this", "->", "result", "->", "seek", "(", "$", "offset", ")", ";", "}", "catch", "(", "DriverException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "catch", "(", "NeevoException", "$", "e", ")", "{", "throw", "new", "OutOfRangeException", "(", "\"Cannot seek to offset $offset.\"", ",", "null", ",", "$", "e", ")", ";", "}", "$", "this", "->", "row", "=", "$", "this", "->", "result", "->", "fetch", "(", ")", ";", "$", "this", "->", "pointer", "=", "$", "offset", ";", "}" ]
Implementation of SeekableIterator. @param int $offset @throws OutOfRangeException|DriverException
[ "Implementation", "of", "SeekableIterator", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/ResultIterator.php#L121-L131
36,944
kdambekalns/faker
Classes/Name.php
Name.fullName
public static function fullName() { $fullName = ''; $format = static::$formats[array_rand(static::$formats)]; foreach ($format as $functionName) { $fullName .= static::$functionName() . ' '; } return trim($fullName); }
php
public static function fullName() { $fullName = ''; $format = static::$formats[array_rand(static::$formats)]; foreach ($format as $functionName) { $fullName .= static::$functionName() . ' '; } return trim($fullName); }
[ "public", "static", "function", "fullName", "(", ")", "{", "$", "fullName", "=", "''", ";", "$", "format", "=", "static", "::", "$", "formats", "[", "array_rand", "(", "static", "::", "$", "formats", ")", "]", ";", "foreach", "(", "$", "format", "as", "$", "functionName", ")", "{", "$", "fullName", ".=", "static", "::", "$", "functionName", "(", ")", ".", "' '", ";", "}", "return", "trim", "(", "$", "fullName", ")", ";", "}" ]
Return a fake name. @return string
[ "Return", "a", "fake", "name", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Name.php#L20-L30
36,945
CeusMedia/Common
src/UI/Image/Printer.php
UI_Image_Printer.save
public function save( $fileName, $type = IMAGETYPE_PNG, $quality = 100 ) { $this->saveImage( $fileName, $this->resource, $type, $quality ); }
php
public function save( $fileName, $type = IMAGETYPE_PNG, $quality = 100 ) { $this->saveImage( $fileName, $this->resource, $type, $quality ); }
[ "public", "function", "save", "(", "$", "fileName", ",", "$", "type", "=", "IMAGETYPE_PNG", ",", "$", "quality", "=", "100", ")", "{", "$", "this", "->", "saveImage", "(", "$", "fileName", ",", "$", "this", "->", "resource", ",", "$", "type", ",", "$", "quality", ")", ";", "}" ]
Writes Image to File. @access public @param string $fleName Name of target Image File @param int $type Image Type @param int $quality JPEG Quality (1-100) @return void
[ "Writes", "Image", "to", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Printer.php#L66-L69
36,946
CeusMedia/Common
src/UI/Image/Printer.php
UI_Image_Printer.saveImage
public static function saveImage( $fileName, $resource, $type = IMAGETYPE_PNG, $quality = 100 ) { switch( $type ) { case IMAGETYPE_PNG: ImagePNG( $resource, $fileName ); break; case IMAGETYPE_JPEG: ImageJPEG( $resource, $fileName, $quality ); break; case IMAGETYPE_GIF: ImageGIF( $resource, $fileName ); break; default: throw new InvalidArgumentException( 'Invalid Image Type' ); } }
php
public static function saveImage( $fileName, $resource, $type = IMAGETYPE_PNG, $quality = 100 ) { switch( $type ) { case IMAGETYPE_PNG: ImagePNG( $resource, $fileName ); break; case IMAGETYPE_JPEG: ImageJPEG( $resource, $fileName, $quality ); break; case IMAGETYPE_GIF: ImageGIF( $resource, $fileName ); break; default: throw new InvalidArgumentException( 'Invalid Image Type' ); } }
[ "public", "static", "function", "saveImage", "(", "$", "fileName", ",", "$", "resource", ",", "$", "type", "=", "IMAGETYPE_PNG", ",", "$", "quality", "=", "100", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "IMAGETYPE_PNG", ":", "ImagePNG", "(", "$", "resource", ",", "$", "fileName", ")", ";", "break", ";", "case", "IMAGETYPE_JPEG", ":", "ImageJPEG", "(", "$", "resource", ",", "$", "fileName", ",", "$", "quality", ")", ";", "break", ";", "case", "IMAGETYPE_GIF", ":", "ImageGIF", "(", "$", "resource", ",", "$", "fileName", ")", ";", "break", ";", "default", ":", "throw", "new", "InvalidArgumentException", "(", "'Invalid Image Type'", ")", ";", "}", "}" ]
Saves an Image to File statically. @access public @static @param string $fleName Name of target Image File @param resource $resource Image Resource @param int $type Image Type @param int $quality JPEG Quality (1-100) @return void
[ "Saves", "an", "Image", "to", "File", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Printer.php#L81-L97
36,947
CeusMedia/Common
src/UI/Image/Printer.php
UI_Image_Printer.show
public function show( $type = IMAGETYPE_PNG, $quality = 100, $sendHeader = TRUE ) { $this->showImage( $this->resource, $type, $quality, $sendHeader ); }
php
public function show( $type = IMAGETYPE_PNG, $quality = 100, $sendHeader = TRUE ) { $this->showImage( $this->resource, $type, $quality, $sendHeader ); }
[ "public", "function", "show", "(", "$", "type", "=", "IMAGETYPE_PNG", ",", "$", "quality", "=", "100", ",", "$", "sendHeader", "=", "TRUE", ")", "{", "$", "this", "->", "showImage", "(", "$", "this", "->", "resource", ",", "$", "type", ",", "$", "quality", ",", "$", "sendHeader", ")", ";", "}" ]
Print Image on Screen. @access public @param int $type Image Type @param int $quality JPEG Quality (1-100) @param bool $showHeader Flag: set Image MIME Type Header @return void
[ "Print", "Image", "on", "Screen", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Printer.php#L107-L110
36,948
CeusMedia/Common
src/UI/Image/Printer.php
UI_Image_Printer.showImage
public static function showImage( $resource, $type = IMAGETYPE_PNG, $quality = 100, $sendHeader = TRUE ) { switch( $type ) { case IMAGETYPE_GIF: if( $sendHeader ) header( "Content-type: image/gif" ); ImageGIF( $resource ); break; case IMAGETYPE_JPEG: if( $sendHeader ) header( "Content-type: image/jpeg" ); ImageJPEG( $resource, "", $quality ); break; case IMAGETYPE_PNG: if( $sendHeader ) header( "Content-type: image/png" ); ImagePNG( $resource ); break; default: throw new InvalidArgumentException( 'Invalid Image Type' ); } }
php
public static function showImage( $resource, $type = IMAGETYPE_PNG, $quality = 100, $sendHeader = TRUE ) { switch( $type ) { case IMAGETYPE_GIF: if( $sendHeader ) header( "Content-type: image/gif" ); ImageGIF( $resource ); break; case IMAGETYPE_JPEG: if( $sendHeader ) header( "Content-type: image/jpeg" ); ImageJPEG( $resource, "", $quality ); break; case IMAGETYPE_PNG: if( $sendHeader ) header( "Content-type: image/png" ); ImagePNG( $resource ); break; default: throw new InvalidArgumentException( 'Invalid Image Type' ); } }
[ "public", "static", "function", "showImage", "(", "$", "resource", ",", "$", "type", "=", "IMAGETYPE_PNG", ",", "$", "quality", "=", "100", ",", "$", "sendHeader", "=", "TRUE", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "IMAGETYPE_GIF", ":", "if", "(", "$", "sendHeader", ")", "header", "(", "\"Content-type: image/gif\"", ")", ";", "ImageGIF", "(", "$", "resource", ")", ";", "break", ";", "case", "IMAGETYPE_JPEG", ":", "if", "(", "$", "sendHeader", ")", "header", "(", "\"Content-type: image/jpeg\"", ")", ";", "ImageJPEG", "(", "$", "resource", ",", "\"\"", ",", "$", "quality", ")", ";", "break", ";", "case", "IMAGETYPE_PNG", ":", "if", "(", "$", "sendHeader", ")", "header", "(", "\"Content-type: image/png\"", ")", ";", "ImagePNG", "(", "$", "resource", ")", ";", "break", ";", "default", ":", "throw", "new", "InvalidArgumentException", "(", "'Invalid Image Type'", ")", ";", "}", "}" ]
Prints an Image to Screen statically. @access public @static @param resource $resource Image Resource @param int $type Image Type @param int $quality JPEG Quality (1-100) @param bool $showHeader Flag: set Image MIME Type Header @return void
[ "Prints", "an", "Image", "to", "Screen", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Printer.php#L122-L144
36,949
CeusMedia/Common
src/Net/Site/MapCreator.php
Net_Site_MapCreator.createSitemap
public function createSitemap( $url, $sitemapUri, $errorsLogUri = NULL, $urlListUri = NULL, $verbose = FALSE ) { $crawler = new Net_Site_Crawler( $url, $this->depth ); $crawler->crawl( $url, FALSE, $verbose ); $this->errors = $crawler->getErrors(); $this->links = $crawler->getLinks(); $list = array(); foreach( $this->links as $link ) $list[] = $link['url']; $writtenBytes = Net_Site_MapWriter::save( $sitemapUri, $list ); if( $errorsLogUri ) { @unlink( $errorsLogUri ); if( count( $this->errors ) ) $this->saveErrors( $errorsLogUri ); } if( $urlListUri ) $this->saveUrls( $urlListUri ); return $writtenBytes; }
php
public function createSitemap( $url, $sitemapUri, $errorsLogUri = NULL, $urlListUri = NULL, $verbose = FALSE ) { $crawler = new Net_Site_Crawler( $url, $this->depth ); $crawler->crawl( $url, FALSE, $verbose ); $this->errors = $crawler->getErrors(); $this->links = $crawler->getLinks(); $list = array(); foreach( $this->links as $link ) $list[] = $link['url']; $writtenBytes = Net_Site_MapWriter::save( $sitemapUri, $list ); if( $errorsLogUri ) { @unlink( $errorsLogUri ); if( count( $this->errors ) ) $this->saveErrors( $errorsLogUri ); } if( $urlListUri ) $this->saveUrls( $urlListUri ); return $writtenBytes; }
[ "public", "function", "createSitemap", "(", "$", "url", ",", "$", "sitemapUri", ",", "$", "errorsLogUri", "=", "NULL", ",", "$", "urlListUri", "=", "NULL", ",", "$", "verbose", "=", "FALSE", ")", "{", "$", "crawler", "=", "new", "Net_Site_Crawler", "(", "$", "url", ",", "$", "this", "->", "depth", ")", ";", "$", "crawler", "->", "crawl", "(", "$", "url", ",", "FALSE", ",", "$", "verbose", ")", ";", "$", "this", "->", "errors", "=", "$", "crawler", "->", "getErrors", "(", ")", ";", "$", "this", "->", "links", "=", "$", "crawler", "->", "getLinks", "(", ")", ";", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "links", "as", "$", "link", ")", "$", "list", "[", "]", "=", "$", "link", "[", "'url'", "]", ";", "$", "writtenBytes", "=", "Net_Site_MapWriter", "::", "save", "(", "$", "sitemapUri", ",", "$", "list", ")", ";", "if", "(", "$", "errorsLogUri", ")", "{", "@", "unlink", "(", "$", "errorsLogUri", ")", ";", "if", "(", "count", "(", "$", "this", "->", "errors", ")", ")", "$", "this", "->", "saveErrors", "(", "$", "errorsLogUri", ")", ";", "}", "if", "(", "$", "urlListUri", ")", "$", "this", "->", "saveUrls", "(", "$", "urlListUri", ")", ";", "return", "$", "writtenBytes", ";", "}" ]
Crawls a Web Site, writes Sitemap XML File, logs Errors and URLs and returns Number of written Bytes. @access public @param string $url URL of Web Site @param string $sitemapUri File Name of Sitemap XML File @param string $errorsLogUri File Name of Error Log File @param string $urlLogUri File Name of URL Log File @param boolean $verbose Flag: show crawled URLs @return int
[ "Crawls", "a", "Web", "Site", "writes", "Sitemap", "XML", "File", "logs", "Errors", "and", "URLs", "and", "returns", "Number", "of", "written", "Bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/MapCreator.php#L72-L91
36,950
CeusMedia/Common
src/Net/Site/MapCreator.php
Net_Site_MapCreator.saveUrls
public function saveUrls( $uri ) { $list = array(); foreach( $this->links as $link ) $list[] = $link['url']; $writer = new FS_File_Writer( $uri ); $writer->writeArray( $list ); }
php
public function saveUrls( $uri ) { $list = array(); foreach( $this->links as $link ) $list[] = $link['url']; $writer = new FS_File_Writer( $uri ); $writer->writeArray( $list ); }
[ "public", "function", "saveUrls", "(", "$", "uri", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "links", "as", "$", "link", ")", "$", "list", "[", "]", "=", "$", "link", "[", "'url'", "]", ";", "$", "writer", "=", "new", "FS_File_Writer", "(", "$", "uri", ")", ";", "$", "writer", "->", "writeArray", "(", "$", "list", ")", ";", "}" ]
Writes found URLs to a List File and returns Number of written Bytes. @access public @param string $uri File Name of Block Log File @return int
[ "Writes", "found", "URLs", "to", "a", "List", "File", "and", "returns", "Number", "of", "written", "Bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/MapCreator.php#L131-L138
36,951
generationtux/marketo-rest-api-client
src/Api/CampaignApi.php
CampaignApi.trigger
public function trigger($campaignId, $email, array $tokens) { $lead = $this->client->leads()->show($email); $tokens = $this->parseTokens($tokens); $response = $this->post($this->client->url . "/rest/v1/campaigns/$campaignId/trigger.json", [ 'input' => [ 'leads' => [ ['id' => $lead->id] ], 'tokens' => $tokens ] ] ); if (!$response->success) { throw new MarketoApiException('Error triggering campaign: ' . $response->errors[0]->message); } }
php
public function trigger($campaignId, $email, array $tokens) { $lead = $this->client->leads()->show($email); $tokens = $this->parseTokens($tokens); $response = $this->post($this->client->url . "/rest/v1/campaigns/$campaignId/trigger.json", [ 'input' => [ 'leads' => [ ['id' => $lead->id] ], 'tokens' => $tokens ] ] ); if (!$response->success) { throw new MarketoApiException('Error triggering campaign: ' . $response->errors[0]->message); } }
[ "public", "function", "trigger", "(", "$", "campaignId", ",", "$", "email", ",", "array", "$", "tokens", ")", "{", "$", "lead", "=", "$", "this", "->", "client", "->", "leads", "(", ")", "->", "show", "(", "$", "email", ")", ";", "$", "tokens", "=", "$", "this", "->", "parseTokens", "(", "$", "tokens", ")", ";", "$", "response", "=", "$", "this", "->", "post", "(", "$", "this", "->", "client", "->", "url", ".", "\"/rest/v1/campaigns/$campaignId/trigger.json\"", ",", "[", "'input'", "=>", "[", "'leads'", "=>", "[", "[", "'id'", "=>", "$", "lead", "->", "id", "]", "]", ",", "'tokens'", "=>", "$", "tokens", "]", "]", ")", ";", "if", "(", "!", "$", "response", "->", "success", ")", "{", "throw", "new", "MarketoApiException", "(", "'Error triggering campaign: '", ".", "$", "response", "->", "errors", "[", "0", "]", "->", "message", ")", ";", "}", "}" ]
Trigger a campaign for a lead @param $campaignId @param $email @param array $tokens @throws MarketoApiException
[ "Trigger", "a", "campaign", "for", "a", "lead" ]
a227574f6569ca2c95c2343dd963d7f9d3885afe
https://github.com/generationtux/marketo-rest-api-client/blob/a227574f6569ca2c95c2343dd963d7f9d3885afe/src/Api/CampaignApi.php#L27-L45
36,952
generationtux/marketo-rest-api-client
src/Api/CampaignApi.php
CampaignApi.parseTokens
private function parseTokens(array $tokens) { return array_map(function ($token, $key) { return ['name' => $key, 'value' => $token]; }, $tokens, array_keys($tokens)); }
php
private function parseTokens(array $tokens) { return array_map(function ($token, $key) { return ['name' => $key, 'value' => $token]; }, $tokens, array_keys($tokens)); }
[ "private", "function", "parseTokens", "(", "array", "$", "tokens", ")", "{", "return", "array_map", "(", "function", "(", "$", "token", ",", "$", "key", ")", "{", "return", "[", "'name'", "=>", "$", "key", ",", "'value'", "=>", "$", "token", "]", ";", "}", ",", "$", "tokens", ",", "array_keys", "(", "$", "tokens", ")", ")", ";", "}" ]
Parses an array of tokens and formats for sending in request @param array $tokens @return array
[ "Parses", "an", "array", "of", "tokens", "and", "formats", "for", "sending", "in", "request" ]
a227574f6569ca2c95c2343dd963d7f9d3885afe
https://github.com/generationtux/marketo-rest-api-client/blob/a227574f6569ca2c95c2343dd963d7f9d3885afe/src/Api/CampaignApi.php#L53-L58
36,953
CeusMedia/Common
src/DB/BaseConnection.php
DB_BaseConnection.connect
public function connect( $host, $user, $pass, $database ) { return $this->connectDatabase( "connect", $host, $user, $pass, $database ); }
php
public function connect( $host, $user, $pass, $database ) { return $this->connectDatabase( "connect", $host, $user, $pass, $database ); }
[ "public", "function", "connect", "(", "$", "host", ",", "$", "user", ",", "$", "pass", ",", "$", "database", ")", "{", "return", "$", "this", "->", "connectDatabase", "(", "\"connect\"", ",", "$", "host", ",", "$", "user", ",", "$", "pass", ",", "$", "database", ")", ";", "}" ]
Establishs Database Connection. @access public @param string $host Host Name @param string $user User Name @param string $pass Password @param string $database Database Name @return bool
[ "Establishs", "Database", "Connection", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/BaseConnection.php#L103-L106
36,954
CeusMedia/Common
src/DB/BaseConnection.php
DB_BaseConnection.connectPersistant
public function connectPersistant( $host, $user, $pass, $database ) { return $this->connectDatabase( "pconnect", $host, $user, $pass, $database ); }
php
public function connectPersistant( $host, $user, $pass, $database ) { return $this->connectDatabase( "pconnect", $host, $user, $pass, $database ); }
[ "public", "function", "connectPersistant", "(", "$", "host", ",", "$", "user", ",", "$", "pass", ",", "$", "database", ")", "{", "return", "$", "this", "->", "connectDatabase", "(", "\"pconnect\"", ",", "$", "host", ",", "$", "user", ",", "$", "pass", ",", "$", "database", ")", ";", "}" ]
Establishs persitant Database Connection. @access public @param string $host Host Name @param string $user User Name @param string $pass Password @param string $database Database Name @return bool
[ "Establishs", "persitant", "Database", "Connection", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/BaseConnection.php#L117-L120
36,955
CeusMedia/Common
src/DB/BaseConnection.php
DB_BaseConnection.handleError
protected function handleError( $errorCode, $errorMessage, $query ) { if( $this->errorLevel ) { $log = new \FS_File_Log_Writer( $this->logFile ); $log->note( "[".$errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")]" ); if( $this->errorLevel == 2 ) trigger_error( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")", E_USER_WARNING ); else if( $this->errorLevel == 3 ) trigger_error( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")", E_USER_ERROR ); else if( $this->errorLevel == 4 ) throw new \Exception( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")" ); } }
php
protected function handleError( $errorCode, $errorMessage, $query ) { if( $this->errorLevel ) { $log = new \FS_File_Log_Writer( $this->logFile ); $log->note( "[".$errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")]" ); if( $this->errorLevel == 2 ) trigger_error( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")", E_USER_WARNING ); else if( $this->errorLevel == 3 ) trigger_error( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")", E_USER_ERROR ); else if( $this->errorLevel == 4 ) throw new \Exception( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")" ); } }
[ "protected", "function", "handleError", "(", "$", "errorCode", ",", "$", "errorMessage", ",", "$", "query", ")", "{", "if", "(", "$", "this", "->", "errorLevel", ")", "{", "$", "log", "=", "new", "\\", "FS_File_Log_Writer", "(", "$", "this", "->", "logFile", ")", ";", "$", "log", "->", "note", "(", "\"[\"", ".", "$", "errorCode", ".", "\": \"", ".", "$", "errorMessage", ".", "\" in EXECUTE (\\\"\"", ".", "$", "query", ".", "\"\\\")]\"", ")", ";", "if", "(", "$", "this", "->", "errorLevel", "==", "2", ")", "trigger_error", "(", "$", "errorCode", ".", "\": \"", ".", "$", "errorMessage", ".", "\" in EXECUTE (\\\"\"", ".", "$", "query", ".", "\"\\\")\"", ",", "E_USER_WARNING", ")", ";", "else", "if", "(", "$", "this", "->", "errorLevel", "==", "3", ")", "trigger_error", "(", "$", "errorCode", ".", "\": \"", ".", "$", "errorMessage", ".", "\" in EXECUTE (\\\"\"", ".", "$", "query", ".", "\"\\\")\"", ",", "E_USER_ERROR", ")", ";", "else", "if", "(", "$", "this", "->", "errorLevel", "==", "4", ")", "throw", "new", "\\", "Exception", "(", "$", "errorCode", ".", "\": \"", ".", "$", "errorMessage", ".", "\" in EXECUTE (\\\"\"", ".", "$", "query", ".", "\"\\\")\"", ")", ";", "}", "}" ]
Handles Error. @access protected @param int $errorCode Error Code @param string $errorMessage Error Message @param int $query Query with Error @return void
[ "Handles", "Error", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/BaseConnection.php#L214-L227
36,956
CeusMedia/Common
src/DB/BaseConnection.php
DB_BaseConnection.setLogFile
public function setLogFile( $fileName ) { $this->logFile = $fileName; if( !file_exists( dirname( $fileName ) ) ) mkDir( dirname( $fileName ), 0700, TRUE ); }
php
public function setLogFile( $fileName ) { $this->logFile = $fileName; if( !file_exists( dirname( $fileName ) ) ) mkDir( dirname( $fileName ), 0700, TRUE ); }
[ "public", "function", "setLogFile", "(", "$", "fileName", ")", "{", "$", "this", "->", "logFile", "=", "$", "fileName", ";", "if", "(", "!", "file_exists", "(", "dirname", "(", "$", "fileName", ")", ")", ")", "mkDir", "(", "dirname", "(", "$", "fileName", ")", ",", "0700", ",", "TRUE", ")", ";", "}" ]
Sets Log File. @access public @param string $fileName File Name of Log File @return void
[ "Sets", "Log", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/BaseConnection.php#L261-L266
36,957
CeusMedia/Common
src/FS/File/VCard/Writer.php
FS_File_VCard_Writer.save
public static function save( $fileName, $card, $charsetIn = NULL, $charsetOut = NULL ) { $string = FS_File_VCard_Builder::build( $card, $charsetIn, $charsetOut ); return FS_File_Writer::save( $fileName, $string ); }
php
public static function save( $fileName, $card, $charsetIn = NULL, $charsetOut = NULL ) { $string = FS_File_VCard_Builder::build( $card, $charsetIn, $charsetOut ); return FS_File_Writer::save( $fileName, $string ); }
[ "public", "static", "function", "save", "(", "$", "fileName", ",", "$", "card", ",", "$", "charsetIn", "=", "NULL", ",", "$", "charsetOut", "=", "NULL", ")", "{", "$", "string", "=", "FS_File_VCard_Builder", "::", "build", "(", "$", "card", ",", "$", "charsetIn", ",", "$", "charsetOut", ")", ";", "return", "FS_File_Writer", "::", "save", "(", "$", "fileName", ",", "$", "string", ")", ";", "}" ]
Saves a vCard Object to a File statically and returns Number of written Bytes. @access public @static @param ADT_VCard $card vCard Object @param string $charsetIn Charset to convert from @param string $charsetOut Charset to convert to @return int
[ "Saves", "a", "vCard", "Object", "to", "a", "File", "statically", "and", "returns", "Number", "of", "written", "Bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Writer.php#L67-L71
36,958
CeusMedia/Common
src/FS/File/VCard/Writer.php
FS_File_VCard_Writer.write
public function write( $card, $charsetIn = NULL, $charsetOut = NULL ) { return $this->save( $this->fileName, $card, $charsetIn, $charsetOut ); }
php
public function write( $card, $charsetIn = NULL, $charsetOut = NULL ) { return $this->save( $this->fileName, $card, $charsetIn, $charsetOut ); }
[ "public", "function", "write", "(", "$", "card", ",", "$", "charsetIn", "=", "NULL", ",", "$", "charsetOut", "=", "NULL", ")", "{", "return", "$", "this", "->", "save", "(", "$", "this", "->", "fileName", ",", "$", "card", ",", "$", "charsetIn", ",", "$", "charsetOut", ")", ";", "}" ]
Writes a vCard Object to the set up File and returns Number of written Bytes. @access public @param ADT_VCard $card vCard Object @param string $charsetIn Charset to convert from @param string $charsetOut Charset to convert to @return int
[ "Writes", "a", "vCard", "Object", "to", "the", "set", "up", "File", "and", "returns", "Number", "of", "written", "Bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Writer.php#L81-L84
36,959
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.addProperty
public function addProperty( $key, $value, $comment = '', $state = TRUE, $section = NULL ) { if( $section && !in_array( $section, $this->sections ) ) $this->addSection( $section ); $key = ( $state ? "" : $this->signDisabled ).$key; $this->added[] = array( "key" => $key, "value" => $value, "comment" => $comment, "section" => $section, ); return is_int( $this->write() ); }
php
public function addProperty( $key, $value, $comment = '', $state = TRUE, $section = NULL ) { if( $section && !in_array( $section, $this->sections ) ) $this->addSection( $section ); $key = ( $state ? "" : $this->signDisabled ).$key; $this->added[] = array( "key" => $key, "value" => $value, "comment" => $comment, "section" => $section, ); return is_int( $this->write() ); }
[ "public", "function", "addProperty", "(", "$", "key", ",", "$", "value", ",", "$", "comment", "=", "''", ",", "$", "state", "=", "TRUE", ",", "$", "section", "=", "NULL", ")", "{", "if", "(", "$", "section", "&&", "!", "in_array", "(", "$", "section", ",", "$", "this", "->", "sections", ")", ")", "$", "this", "->", "addSection", "(", "$", "section", ")", ";", "$", "key", "=", "(", "$", "state", "?", "\"\"", ":", "$", "this", "->", "signDisabled", ")", ".", "$", "key", ";", "$", "this", "->", "added", "[", "]", "=", "array", "(", "\"key\"", "=>", "$", "key", ",", "\"value\"", "=>", "$", "value", ",", "\"comment\"", "=>", "$", "comment", ",", "\"section\"", "=>", "$", "section", ",", ")", ";", "return", "is_int", "(", "$", "this", "->", "write", "(", ")", ")", ";", "}" ]
Adds a new Property with Comment. @access public @param string $key Key of new Property @param string $value Value of new Property @param string $comment Comment of new Property @param bool $state Activity state of new Property @param string $section Section to add Property to @return bool
[ "Adds", "a", "new", "Property", "with", "Comment", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L94-L106
36,960
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.addSection
public function addSection( $sectionName ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); $lines = FS_File_Reader::loadArray( $this->fileName ); $lines[] = "[".$sectionName."]"; if( !in_array( $sectionName, $this->sections ) ) $this->sections[] = $sectionName; $result = FS_File_Writer::saveArray( $this->fileName, $lines ); $this->read(); return is_int( $result ); }
php
public function addSection( $sectionName ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); $lines = FS_File_Reader::loadArray( $this->fileName ); $lines[] = "[".$sectionName."]"; if( !in_array( $sectionName, $this->sections ) ) $this->sections[] = $sectionName; $result = FS_File_Writer::saveArray( $this->fileName, $lines ); $this->read(); return is_int( $result ); }
[ "public", "function", "addSection", "(", "$", "sectionName", ")", "{", "if", "(", "!", "$", "this", "->", "usesSections", "(", ")", ")", "throw", "new", "RuntimeException", "(", "'Sections are disabled'", ")", ";", "$", "lines", "=", "FS_File_Reader", "::", "loadArray", "(", "$", "this", "->", "fileName", ")", ";", "$", "lines", "[", "]", "=", "\"[\"", ".", "$", "sectionName", ".", "\"]\"", ";", "if", "(", "!", "in_array", "(", "$", "sectionName", ",", "$", "this", "->", "sections", ")", ")", "$", "this", "->", "sections", "[", "]", "=", "$", "sectionName", ";", "$", "result", "=", "FS_File_Writer", "::", "saveArray", "(", "$", "this", "->", "fileName", ",", "$", "lines", ")", ";", "$", "this", "->", "read", "(", ")", ";", "return", "is_int", "(", "$", "result", ")", ";", "}" ]
Adds a new Section. @access public @param string $sectionName Name of new Section @return bool
[ "Adds", "a", "new", "Section", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L114-L125
36,961
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.deactivateProperty
public function deactivateProperty( $key, $section = NULL) { if( $this->usesSections() ) { if( !$this->hasProperty( $key, $section ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in section "'.$section.'"' ); if( !$this->isActiveProperty( $key, $section ) ) throw new LogicException( 'Key "'.$key.'" is already inactive' ); $this->disabled[$section][] = $key; return is_int( $this->write() ); } else { if( !$this->hasProperty( $key ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing' ); if( !$this->isActiveProperty( $key ) ) throw new LogicException( 'Key "'.$key.'" is already inactive' ); $this->disabled[] = $key; return is_int( $this->write() ); } }
php
public function deactivateProperty( $key, $section = NULL) { if( $this->usesSections() ) { if( !$this->hasProperty( $key, $section ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in section "'.$section.'"' ); if( !$this->isActiveProperty( $key, $section ) ) throw new LogicException( 'Key "'.$key.'" is already inactive' ); $this->disabled[$section][] = $key; return is_int( $this->write() ); } else { if( !$this->hasProperty( $key ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing' ); if( !$this->isActiveProperty( $key ) ) throw new LogicException( 'Key "'.$key.'" is already inactive' ); $this->disabled[] = $key; return is_int( $this->write() ); } }
[ "public", "function", "deactivateProperty", "(", "$", "key", ",", "$", "section", "=", "NULL", ")", "{", "if", "(", "$", "this", "->", "usesSections", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "hasProperty", "(", "$", "key", ",", "$", "section", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Key \"'", ".", "$", "key", ".", "'\" is not existing in section \"'", ".", "$", "section", ".", "'\"'", ")", ";", "if", "(", "!", "$", "this", "->", "isActiveProperty", "(", "$", "key", ",", "$", "section", ")", ")", "throw", "new", "LogicException", "(", "'Key \"'", ".", "$", "key", ".", "'\" is already inactive'", ")", ";", "$", "this", "->", "disabled", "[", "$", "section", "]", "[", "]", "=", "$", "key", ";", "return", "is_int", "(", "$", "this", "->", "write", "(", ")", ")", ";", "}", "else", "{", "if", "(", "!", "$", "this", "->", "hasProperty", "(", "$", "key", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Key \"'", ".", "$", "key", ".", "'\" is not existing'", ")", ";", "if", "(", "!", "$", "this", "->", "isActiveProperty", "(", "$", "key", ")", ")", "throw", "new", "LogicException", "(", "'Key \"'", ".", "$", "key", ".", "'\" is already inactive'", ")", ";", "$", "this", "->", "disabled", "[", "]", "=", "$", "key", ";", "return", "is_int", "(", "$", "this", "->", "write", "(", ")", ")", ";", "}", "}" ]
Deactivates a Property. @access public @param string $key Key of Property @param string $value Section of Property @return bool
[ "Deactivates", "a", "Property", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L160-L180
36,962
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.removeSection
public function removeSection( $section ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); if( !$this->hasSection( $section ) ) throw new InvalidArgumentException( 'Section "'.$section.'" is not existing' ); $index = array_search( $section, $this->sections); unset( $this->sections[$index] ); return is_int( $this->write() ); }
php
public function removeSection( $section ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); if( !$this->hasSection( $section ) ) throw new InvalidArgumentException( 'Section "'.$section.'" is not existing' ); $index = array_search( $section, $this->sections); unset( $this->sections[$index] ); return is_int( $this->write() ); }
[ "public", "function", "removeSection", "(", "$", "section", ")", "{", "if", "(", "!", "$", "this", "->", "usesSections", "(", ")", ")", "throw", "new", "RuntimeException", "(", "'Sections are disabled'", ")", ";", "if", "(", "!", "$", "this", "->", "hasSection", "(", "$", "section", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Section \"'", ".", "$", "section", ".", "'\" is not existing'", ")", ";", "$", "index", "=", "array_search", "(", "$", "section", ",", "$", "this", "->", "sections", ")", ";", "unset", "(", "$", "this", "->", "sections", "[", "$", "index", "]", ")", ";", "return", "is_int", "(", "$", "this", "->", "write", "(", ")", ")", ";", "}" ]
Removes a Section @access public @param string $section Key of Section to remove @return bool
[ "Removes", "a", "Section" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L223-L232
36,963
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.renameProperty
public function renameProperty( $key, $new, $section = NULL ) { if( $this->usesSections() ) { if( !$this->hasProperty( $key, $section ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in section "'.$section.'"' ); $this->properties[$section][$new] = $this->properties[$section][$key]; if( isset( $this->disabled[$section][$key] ) ) $this->disabled [$section][$new] = $this->disabled[$section][$key]; if( isset( $this->comments[$section][$key] ) ) $this->comments [$section][$new] = $this->comments[$section][$key]; $this->renamed[$section][$key] = $new; return is_int( $this->write() ); } else { if( !$this->hasProperty( $key ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing' ); $this->properties[$new] = $this->properties[$key]; if( isset( $this->disabled[$key] ) ) $this->disabled[$new] = $this->disabled[$key]; if( isset( $this->comments[$key] ) ) $this->comments[$new] = $this->comments[$key]; $this->renamed[$key] = $new; return is_int( $this->write() ); } }
php
public function renameProperty( $key, $new, $section = NULL ) { if( $this->usesSections() ) { if( !$this->hasProperty( $key, $section ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in section "'.$section.'"' ); $this->properties[$section][$new] = $this->properties[$section][$key]; if( isset( $this->disabled[$section][$key] ) ) $this->disabled [$section][$new] = $this->disabled[$section][$key]; if( isset( $this->comments[$section][$key] ) ) $this->comments [$section][$new] = $this->comments[$section][$key]; $this->renamed[$section][$key] = $new; return is_int( $this->write() ); } else { if( !$this->hasProperty( $key ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing' ); $this->properties[$new] = $this->properties[$key]; if( isset( $this->disabled[$key] ) ) $this->disabled[$new] = $this->disabled[$key]; if( isset( $this->comments[$key] ) ) $this->comments[$new] = $this->comments[$key]; $this->renamed[$key] = $new; return is_int( $this->write() ); } }
[ "public", "function", "renameProperty", "(", "$", "key", ",", "$", "new", ",", "$", "section", "=", "NULL", ")", "{", "if", "(", "$", "this", "->", "usesSections", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "hasProperty", "(", "$", "key", ",", "$", "section", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Key \"'", ".", "$", "key", ".", "'\" is not existing in section \"'", ".", "$", "section", ".", "'\"'", ")", ";", "$", "this", "->", "properties", "[", "$", "section", "]", "[", "$", "new", "]", "=", "$", "this", "->", "properties", "[", "$", "section", "]", "[", "$", "key", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "disabled", "[", "$", "section", "]", "[", "$", "key", "]", ")", ")", "$", "this", "->", "disabled", "[", "$", "section", "]", "[", "$", "new", "]", "=", "$", "this", "->", "disabled", "[", "$", "section", "]", "[", "$", "key", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "comments", "[", "$", "section", "]", "[", "$", "key", "]", ")", ")", "$", "this", "->", "comments", "[", "$", "section", "]", "[", "$", "new", "]", "=", "$", "this", "->", "comments", "[", "$", "section", "]", "[", "$", "key", "]", ";", "$", "this", "->", "renamed", "[", "$", "section", "]", "[", "$", "key", "]", "=", "$", "new", ";", "return", "is_int", "(", "$", "this", "->", "write", "(", ")", ")", ";", "}", "else", "{", "if", "(", "!", "$", "this", "->", "hasProperty", "(", "$", "key", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Key \"'", ".", "$", "key", ".", "'\" is not existing'", ")", ";", "$", "this", "->", "properties", "[", "$", "new", "]", "=", "$", "this", "->", "properties", "[", "$", "key", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "disabled", "[", "$", "key", "]", ")", ")", "$", "this", "->", "disabled", "[", "$", "new", "]", "=", "$", "this", "->", "disabled", "[", "$", "key", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "comments", "[", "$", "key", "]", ")", ")", "$", "this", "->", "comments", "[", "$", "new", "]", "=", "$", "this", "->", "comments", "[", "$", "key", "]", ";", "$", "this", "->", "renamed", "[", "$", "key", "]", "=", "$", "new", ";", "return", "is_int", "(", "$", "this", "->", "write", "(", ")", ")", ";", "}", "}" ]
Renames a Property Key. @access public @param string $key Key of Property to rename @param string $new New Key of Property @param string $section Section of Property @return bool
[ "Renames", "a", "Property", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L242-L268
36,964
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.renameSection
public function renameSection( $oldSection, $newSection ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); $content = FS_File_Reader::load( $this->fileName ); $content = preg_replace( "/(.*)(\[".$oldSection."\])(.*)/si", "$1[".$newSection."]$3", $content ); $result = FS_File_Writer::save( $this->fileName, $content ); $this->added = array(); $this->deleted = array(); $this->renamed = array(); $this->read(); return is_int( $result ); }
php
public function renameSection( $oldSection, $newSection ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); $content = FS_File_Reader::load( $this->fileName ); $content = preg_replace( "/(.*)(\[".$oldSection."\])(.*)/si", "$1[".$newSection."]$3", $content ); $result = FS_File_Writer::save( $this->fileName, $content ); $this->added = array(); $this->deleted = array(); $this->renamed = array(); $this->read(); return is_int( $result ); }
[ "public", "function", "renameSection", "(", "$", "oldSection", ",", "$", "newSection", ")", "{", "if", "(", "!", "$", "this", "->", "usesSections", "(", ")", ")", "throw", "new", "RuntimeException", "(", "'Sections are disabled'", ")", ";", "$", "content", "=", "FS_File_Reader", "::", "load", "(", "$", "this", "->", "fileName", ")", ";", "$", "content", "=", "preg_replace", "(", "\"/(.*)(\\[\"", ".", "$", "oldSection", ".", "\"\\])(.*)/si\"", ",", "\"$1[\"", ".", "$", "newSection", ".", "\"]$3\"", ",", "$", "content", ")", ";", "$", "result", "=", "FS_File_Writer", "::", "save", "(", "$", "this", "->", "fileName", ",", "$", "content", ")", ";", "$", "this", "->", "added", "=", "array", "(", ")", ";", "$", "this", "->", "deleted", "=", "array", "(", ")", ";", "$", "this", "->", "renamed", "=", "array", "(", ")", ";", "$", "this", "->", "read", "(", ")", ";", "return", "is_int", "(", "$", "result", ")", ";", "}" ]
Renames as Section. @access public @param string $oldSection Key of Section to rename @param string $newSection New Key of Section @return bool
[ "Renames", "as", "Section", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L277-L289
36,965
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.count
public function count( $conditions = array() ) { $conditions = $this->getConditionQuery( $conditions, FALSE, TRUE, TRUE ); // render WHERE clause if needed, foreign cursored, allow functions $conditions = $conditions ? ' WHERE '.$conditions : ''; $query = 'SELECT COUNT(`%s`) as count FROM %s%s'; $query = sprintf( $query, $this->primaryKey, $this->getTableName(), $conditions ); return (int) $this->dbc->query( $query )->fetch( \PDO::FETCH_OBJ )->count; }
php
public function count( $conditions = array() ) { $conditions = $this->getConditionQuery( $conditions, FALSE, TRUE, TRUE ); // render WHERE clause if needed, foreign cursored, allow functions $conditions = $conditions ? ' WHERE '.$conditions : ''; $query = 'SELECT COUNT(`%s`) as count FROM %s%s'; $query = sprintf( $query, $this->primaryKey, $this->getTableName(), $conditions ); return (int) $this->dbc->query( $query )->fetch( \PDO::FETCH_OBJ )->count; }
[ "public", "function", "count", "(", "$", "conditions", "=", "array", "(", ")", ")", "{", "$", "conditions", "=", "$", "this", "->", "getConditionQuery", "(", "$", "conditions", ",", "FALSE", ",", "TRUE", ",", "TRUE", ")", ";", "// render WHERE clause if needed, foreign cursored, allow functions", "$", "conditions", "=", "$", "conditions", "?", "' WHERE '", ".", "$", "conditions", ":", "''", ";", "$", "query", "=", "'SELECT COUNT(`%s`) as count FROM %s%s'", ";", "$", "query", "=", "sprintf", "(", "$", "query", ",", "$", "this", "->", "primaryKey", ",", "$", "this", "->", "getTableName", "(", ")", ",", "$", "conditions", ")", ";", "return", "(", "int", ")", "$", "this", "->", "dbc", "->", "query", "(", "$", "query", ")", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_OBJ", ")", "->", "count", ";", "}" ]
Returns count of all entries of this table covered by conditions. @access public @param array $conditions Map of columns and values to filter by @return integer
[ "Returns", "count", "of", "all", "entries", "of", "this", "table", "covered", "by", "conditions", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L94-L101
36,966
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.find
public function find( $columns = array(), $conditions = array(), $orders = array(), $limits = array(), $groupings = array(), $havings = array() ){ $this->validateColumns( $columns ); $conditions = $this->getConditionQuery( $conditions, FALSE, FALSE, TRUE ); // render WHERE clause if needed, uncursored, allow functions $conditions = $conditions ? ' WHERE '.$conditions : ''; $orders = $this->getOrderCondition( $orders ); // render ORDER BY clause if needed $limits = $this->getLimitCondition( $limits ); // render LIMIT BY clause if needed $groupings = !empty( $groupings ) ? ' GROUP BY '.join( ', ', $groupings ) : ''; // render GROUP BY clause if needed $havings = !empty( $havings ) ? ' HAVING '.join( ' AND ', $havings ) : ''; // render HAVING clause if needed $columns = $this->getColumnEnumeration( $columns ); // get enumeration of masked column names $query = 'SELECT '.$columns.' FROM '.$this->getTableName(); // render base query $query = $query.$conditions.$groupings.$havings.$orders.$limits; // append rendered conditions, orders, limits, groupings and havings $resultSet = $this->dbc->query( $query ); if( $resultSet ) return $resultSet->fetchAll( $this->getFetchMode() ); return array(); }
php
public function find( $columns = array(), $conditions = array(), $orders = array(), $limits = array(), $groupings = array(), $havings = array() ){ $this->validateColumns( $columns ); $conditions = $this->getConditionQuery( $conditions, FALSE, FALSE, TRUE ); // render WHERE clause if needed, uncursored, allow functions $conditions = $conditions ? ' WHERE '.$conditions : ''; $orders = $this->getOrderCondition( $orders ); // render ORDER BY clause if needed $limits = $this->getLimitCondition( $limits ); // render LIMIT BY clause if needed $groupings = !empty( $groupings ) ? ' GROUP BY '.join( ', ', $groupings ) : ''; // render GROUP BY clause if needed $havings = !empty( $havings ) ? ' HAVING '.join( ' AND ', $havings ) : ''; // render HAVING clause if needed $columns = $this->getColumnEnumeration( $columns ); // get enumeration of masked column names $query = 'SELECT '.$columns.' FROM '.$this->getTableName(); // render base query $query = $query.$conditions.$groupings.$havings.$orders.$limits; // append rendered conditions, orders, limits, groupings and havings $resultSet = $this->dbc->query( $query ); if( $resultSet ) return $resultSet->fetchAll( $this->getFetchMode() ); return array(); }
[ "public", "function", "find", "(", "$", "columns", "=", "array", "(", ")", ",", "$", "conditions", "=", "array", "(", ")", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "limits", "=", "array", "(", ")", ",", "$", "groupings", "=", "array", "(", ")", ",", "$", "havings", "=", "array", "(", ")", ")", "{", "$", "this", "->", "validateColumns", "(", "$", "columns", ")", ";", "$", "conditions", "=", "$", "this", "->", "getConditionQuery", "(", "$", "conditions", ",", "FALSE", ",", "FALSE", ",", "TRUE", ")", ";", "// render WHERE clause if needed, uncursored, allow functions", "$", "conditions", "=", "$", "conditions", "?", "' WHERE '", ".", "$", "conditions", ":", "''", ";", "$", "orders", "=", "$", "this", "->", "getOrderCondition", "(", "$", "orders", ")", ";", "// render ORDER BY clause if needed", "$", "limits", "=", "$", "this", "->", "getLimitCondition", "(", "$", "limits", ")", ";", "// render LIMIT BY clause if needed", "$", "groupings", "=", "!", "empty", "(", "$", "groupings", ")", "?", "' GROUP BY '", ".", "join", "(", "', '", ",", "$", "groupings", ")", ":", "''", ";", "// render GROUP BY clause if needed", "$", "havings", "=", "!", "empty", "(", "$", "havings", ")", "?", "' HAVING '", ".", "join", "(", "' AND '", ",", "$", "havings", ")", ":", "''", ";", "// render HAVING clause if needed", "$", "columns", "=", "$", "this", "->", "getColumnEnumeration", "(", "$", "columns", ")", ";", "// get enumeration of masked column names", "$", "query", "=", "'SELECT '", ".", "$", "columns", ".", "' FROM '", ".", "$", "this", "->", "getTableName", "(", ")", ";", "// render base query", "$", "query", "=", "$", "query", ".", "$", "conditions", ".", "$", "groupings", ".", "$", "havings", ".", "$", "orders", ".", "$", "limits", ";", "// append rendered conditions, orders, limits, groupings and havings", "$", "resultSet", "=", "$", "this", "->", "dbc", "->", "query", "(", "$", "query", ")", ";", "if", "(", "$", "resultSet", ")", "return", "$", "resultSet", "->", "fetchAll", "(", "$", "this", "->", "getFetchMode", "(", ")", ")", ";", "return", "array", "(", ")", ";", "}" ]
Returns all entries of this table in an array. @access public @param array $columns List of columns to deliver @param array $conditions Map of condition pairs additional to focuses indices @param array $orders Map of order relations @param array $limits Array of limit conditions @param array $groupings List of columns to group by @param array $havings List of conditions to apply after grouping @return array List of fetched table rows
[ "Returns", "all", "entries", "of", "this", "table", "in", "an", "array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L148-L164
36,967
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.focusIndex
public function focusIndex( $column, $value ){ if( !in_array( $column, $this->indices ) && $column != $this->primaryKey ) // check column name throw new \InvalidArgumentException( 'Column "'.$column.'" is neither an index nor primary key and cannot be focused' ); $this->focusedIndices[$column] = $value; // set Focus }
php
public function focusIndex( $column, $value ){ if( !in_array( $column, $this->indices ) && $column != $this->primaryKey ) // check column name throw new \InvalidArgumentException( 'Column "'.$column.'" is neither an index nor primary key and cannot be focused' ); $this->focusedIndices[$column] = $value; // set Focus }
[ "public", "function", "focusIndex", "(", "$", "column", ",", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "column", ",", "$", "this", "->", "indices", ")", "&&", "$", "column", "!=", "$", "this", "->", "primaryKey", ")", "// check column name", "throw", "new", "\\", "InvalidArgumentException", "(", "'Column \"'", ".", "$", "column", ".", "'\" is neither an index nor primary key and cannot be focused'", ")", ";", "$", "this", "->", "focusedIndices", "[", "$", "column", "]", "=", "$", "value", ";", "// set Focus", "}" ]
Setting focus on an index. @access public @param string $column Index column name @param int $value Index to focus on @return void
[ "Setting", "focus", "on", "an", "index", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L218-L222
36,968
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.get
public function get( $first = TRUE, $orders = array(), $limits = array() ){ $this->validateFocus(); $data = array(); $conditions = $this->getConditionQuery( array(), TRUE, TRUE, FALSE ); // render WHERE clause if needed, cursored, without functions $orders = $this->getOrderCondition( $orders ); $limits = $this->getLimitCondition( $limits ); $columns = $this->getColumnEnumeration( $this->columns ); // get enumeration of masked column names $query = 'SELECT '.$columns.' FROM '.$this->getTableName().' WHERE '.$conditions.$orders.$limits; $resultSet = $this->dbc->query( $query ); if( !$resultSet ) return $first ? NULL : array(); $resultList = $resultSet->fetchAll( $this->getFetchMode() ); if( $first ) return $resultList ? $resultList[0] : NULL; return $resultList; }
php
public function get( $first = TRUE, $orders = array(), $limits = array() ){ $this->validateFocus(); $data = array(); $conditions = $this->getConditionQuery( array(), TRUE, TRUE, FALSE ); // render WHERE clause if needed, cursored, without functions $orders = $this->getOrderCondition( $orders ); $limits = $this->getLimitCondition( $limits ); $columns = $this->getColumnEnumeration( $this->columns ); // get enumeration of masked column names $query = 'SELECT '.$columns.' FROM '.$this->getTableName().' WHERE '.$conditions.$orders.$limits; $resultSet = $this->dbc->query( $query ); if( !$resultSet ) return $first ? NULL : array(); $resultList = $resultSet->fetchAll( $this->getFetchMode() ); if( $first ) return $resultList ? $resultList[0] : NULL; return $resultList; }
[ "public", "function", "get", "(", "$", "first", "=", "TRUE", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "limits", "=", "array", "(", ")", ")", "{", "$", "this", "->", "validateFocus", "(", ")", ";", "$", "data", "=", "array", "(", ")", ";", "$", "conditions", "=", "$", "this", "->", "getConditionQuery", "(", "array", "(", ")", ",", "TRUE", ",", "TRUE", ",", "FALSE", ")", ";", "// render WHERE clause if needed, cursored, without functions", "$", "orders", "=", "$", "this", "->", "getOrderCondition", "(", "$", "orders", ")", ";", "$", "limits", "=", "$", "this", "->", "getLimitCondition", "(", "$", "limits", ")", ";", "$", "columns", "=", "$", "this", "->", "getColumnEnumeration", "(", "$", "this", "->", "columns", ")", ";", "// get enumeration of masked column names", "$", "query", "=", "'SELECT '", ".", "$", "columns", ".", "' FROM '", ".", "$", "this", "->", "getTableName", "(", ")", ".", "' WHERE '", ".", "$", "conditions", ".", "$", "orders", ".", "$", "limits", ";", "$", "resultSet", "=", "$", "this", "->", "dbc", "->", "query", "(", "$", "query", ")", ";", "if", "(", "!", "$", "resultSet", ")", "return", "$", "first", "?", "NULL", ":", "array", "(", ")", ";", "$", "resultList", "=", "$", "resultSet", "->", "fetchAll", "(", "$", "this", "->", "getFetchMode", "(", ")", ")", ";", "if", "(", "$", "first", ")", "return", "$", "resultList", "?", "$", "resultList", "[", "0", "]", ":", "NULL", ";", "return", "$", "resultList", ";", "}" ]
Returns data of focused keys. @access public @param bool $first Extract first entry of result @param array $orders Associative array of orders @param array $limits Array of offset and limit @return array
[ "Returns", "data", "of", "focused", "keys", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L245-L261
36,969
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.getColumnEnumeration
protected function getColumnEnumeration( $columns ){ $list = array(); foreach( $columns as $column ) $list[] = $column == '*' ? $column : '`'.$column.'`'; return implode( ', ', $list ); }
php
protected function getColumnEnumeration( $columns ){ $list = array(); foreach( $columns as $column ) $list[] = $column == '*' ? $column : '`'.$column.'`'; return implode( ', ', $list ); }
[ "protected", "function", "getColumnEnumeration", "(", "$", "columns", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "$", "list", "[", "]", "=", "$", "column", "==", "'*'", "?", "$", "column", ":", "'`'", ".", "$", "column", ".", "'`'", ";", "return", "implode", "(", "', '", ",", "$", "list", ")", ";", "}" ]
Returns a list of comma separated and masked columns. @access protected @param array $columns List of columns to mask and enumerate @return string
[ "Returns", "a", "list", "of", "comma", "separated", "and", "masked", "columns", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L278-L283
36,970
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.getConditionQuery
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useIndices = TRUE, $allowFunctions = FALSE ){ $columnConditions = array(); foreach( $this->columns as $column ){ // iterate all columns if( isset( $conditions[$column] ) ){ // if condition given $columnConditions[$column] = $conditions[$column]; // note condition pair unset( $conditions[$column] ); } } $functionConditions = array(); foreach( $conditions as $key => $value ) // iterate remaining conditions if( preg_match( "/^[a-z]+\(.+\)$/i", $key ) ) // column key is a aggregate function $functionConditions[$key] = $value; if( $usePrimary && $this->isFocused( $this->primaryKey ) ){ // if using primary key & is focused primary if( !array_key_exists( $this->primaryKey, $columnConditions ) ) // if primary key is not already in conditions $columnConditions = $this->getFocus(); // note primary key pair } if( $useIndices && count( $this->focusedIndices ) ){ // if using indices foreach( $this->focusedIndices as $index => $value ) // iterate focused indices if( $index != $this->primaryKey ) // skip primary key if( !array_key_exists( $index, $columnConditions ) ) // if index column is not already in conditions $columnConditions[$index] = $value; // note index pair } $conditions = array(); // restart with fresh conditions array foreach( $columnConditions as $column => $value ){ // iterate noted column conditions if( is_array( $value ) ){ foreach( $value as $nr => $part ) $value[$nr] = $this->realizeConditionQueryPart( $column, $part ); $part = '('.implode( ' OR ', $value ).')'; } else $part = $this->realizeConditionQueryPart( $column, $value ); $conditions[] = $part; } /* -- THIS IS NEW, UNDER DEVELOPMENT, UNSECURE AND UNSTABLE -- */ if( $allowFunctions ) // function are allowed foreach( $functionConditions as $function => $value ){ // iterate noted functions $conditions[] = $this->realizeConditionQueryPart( $function, $value, FALSE ); // extend conditions } return implode( ' AND ', $conditions ); // return AND combined conditions }
php
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useIndices = TRUE, $allowFunctions = FALSE ){ $columnConditions = array(); foreach( $this->columns as $column ){ // iterate all columns if( isset( $conditions[$column] ) ){ // if condition given $columnConditions[$column] = $conditions[$column]; // note condition pair unset( $conditions[$column] ); } } $functionConditions = array(); foreach( $conditions as $key => $value ) // iterate remaining conditions if( preg_match( "/^[a-z]+\(.+\)$/i", $key ) ) // column key is a aggregate function $functionConditions[$key] = $value; if( $usePrimary && $this->isFocused( $this->primaryKey ) ){ // if using primary key & is focused primary if( !array_key_exists( $this->primaryKey, $columnConditions ) ) // if primary key is not already in conditions $columnConditions = $this->getFocus(); // note primary key pair } if( $useIndices && count( $this->focusedIndices ) ){ // if using indices foreach( $this->focusedIndices as $index => $value ) // iterate focused indices if( $index != $this->primaryKey ) // skip primary key if( !array_key_exists( $index, $columnConditions ) ) // if index column is not already in conditions $columnConditions[$index] = $value; // note index pair } $conditions = array(); // restart with fresh conditions array foreach( $columnConditions as $column => $value ){ // iterate noted column conditions if( is_array( $value ) ){ foreach( $value as $nr => $part ) $value[$nr] = $this->realizeConditionQueryPart( $column, $part ); $part = '('.implode( ' OR ', $value ).')'; } else $part = $this->realizeConditionQueryPart( $column, $value ); $conditions[] = $part; } /* -- THIS IS NEW, UNDER DEVELOPMENT, UNSECURE AND UNSTABLE -- */ if( $allowFunctions ) // function are allowed foreach( $functionConditions as $function => $value ){ // iterate noted functions $conditions[] = $this->realizeConditionQueryPart( $function, $value, FALSE ); // extend conditions } return implode( ' AND ', $conditions ); // return AND combined conditions }
[ "protected", "function", "getConditionQuery", "(", "$", "conditions", ",", "$", "usePrimary", "=", "TRUE", ",", "$", "useIndices", "=", "TRUE", ",", "$", "allowFunctions", "=", "FALSE", ")", "{", "$", "columnConditions", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "columns", "as", "$", "column", ")", "{", "// iterate all columns", "if", "(", "isset", "(", "$", "conditions", "[", "$", "column", "]", ")", ")", "{", "// if condition given", "$", "columnConditions", "[", "$", "column", "]", "=", "$", "conditions", "[", "$", "column", "]", ";", "// note condition pair", "unset", "(", "$", "conditions", "[", "$", "column", "]", ")", ";", "}", "}", "$", "functionConditions", "=", "array", "(", ")", ";", "foreach", "(", "$", "conditions", "as", "$", "key", "=>", "$", "value", ")", "// iterate remaining conditions", "if", "(", "preg_match", "(", "\"/^[a-z]+\\(.+\\)$/i\"", ",", "$", "key", ")", ")", "// column key is a aggregate function", "$", "functionConditions", "[", "$", "key", "]", "=", "$", "value", ";", "if", "(", "$", "usePrimary", "&&", "$", "this", "->", "isFocused", "(", "$", "this", "->", "primaryKey", ")", ")", "{", "// if using primary key & is focused primary", "if", "(", "!", "array_key_exists", "(", "$", "this", "->", "primaryKey", ",", "$", "columnConditions", ")", ")", "// if primary key is not already in conditions", "$", "columnConditions", "=", "$", "this", "->", "getFocus", "(", ")", ";", "// note primary key pair", "}", "if", "(", "$", "useIndices", "&&", "count", "(", "$", "this", "->", "focusedIndices", ")", ")", "{", "// if using indices", "foreach", "(", "$", "this", "->", "focusedIndices", "as", "$", "index", "=>", "$", "value", ")", "// iterate focused indices", "if", "(", "$", "index", "!=", "$", "this", "->", "primaryKey", ")", "// skip primary key", "if", "(", "!", "array_key_exists", "(", "$", "index", ",", "$", "columnConditions", ")", ")", "// if index column is not already in conditions", "$", "columnConditions", "[", "$", "index", "]", "=", "$", "value", ";", "// note index pair", "}", "$", "conditions", "=", "array", "(", ")", ";", "// restart with fresh conditions array", "foreach", "(", "$", "columnConditions", "as", "$", "column", "=>", "$", "value", ")", "{", "// iterate noted column conditions", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "nr", "=>", "$", "part", ")", "$", "value", "[", "$", "nr", "]", "=", "$", "this", "->", "realizeConditionQueryPart", "(", "$", "column", ",", "$", "part", ")", ";", "$", "part", "=", "'('", ".", "implode", "(", "' OR '", ",", "$", "value", ")", ".", "')'", ";", "}", "else", "$", "part", "=", "$", "this", "->", "realizeConditionQueryPart", "(", "$", "column", ",", "$", "value", ")", ";", "$", "conditions", "[", "]", "=", "$", "part", ";", "}", "/* -- THIS IS NEW, UNDER DEVELOPMENT, UNSECURE AND UNSTABLE -- */", "if", "(", "$", "allowFunctions", ")", "// function are allowed", "foreach", "(", "$", "functionConditions", "as", "$", "function", "=>", "$", "value", ")", "{", "// iterate noted functions", "$", "conditions", "[", "]", "=", "$", "this", "->", "realizeConditionQueryPart", "(", "$", "function", ",", "$", "value", ",", "FALSE", ")", ";", "// extend conditions", "}", "return", "implode", "(", "' AND '", ",", "$", "conditions", ")", ";", "// return AND combined conditions", "}" ]
Builds and returns WHERE statement component. @access protected @param array $conditions Array of conditions @param bool $usePrimary Flag: use focused primary key @param bool $useIndices Flag: use focused indices @return string
[ "Builds", "and", "returns", "WHERE", "statement", "component", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L293-L338
36,971
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.secureValue
protected function secureValue( $value ){ # if( !ini_get( 'magic_quotes_gpc' ) ) # $value = addslashes( $value ); # $value = htmlentities( $value ); if ( $value === NULL ) return "NULL"; $value = $this->dbc->quote( $value ); return $value; }
php
protected function secureValue( $value ){ # if( !ini_get( 'magic_quotes_gpc' ) ) # $value = addslashes( $value ); # $value = htmlentities( $value ); if ( $value === NULL ) return "NULL"; $value = $this->dbc->quote( $value ); return $value; }
[ "protected", "function", "secureValue", "(", "$", "value", ")", "{", "#\t\tif( !ini_get( 'magic_quotes_gpc' ) )", "#\t\t\t$value = addslashes( $value );", "#\t\t$value\t= htmlentities( $value );", "if", "(", "$", "value", "===", "NULL", ")", "return", "\"NULL\"", ";", "$", "value", "=", "$", "this", "->", "dbc", "->", "quote", "(", "$", "value", ")", ";", "return", "$", "value", ";", "}" ]
Secures Conditions Value by adding slashes or quoting. @access protected @param string $value String to be secured @return string
[ "Secures", "Conditions", "Value", "by", "adding", "slashes", "or", "quoting", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L490-L498
36,972
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.setColumns
public function setColumns( $columns ){ if( !( is_array( $columns ) && count( $columns ) ) ) throw new \InvalidArgumentException( 'Column array must not be empty' ); $this->columns = $columns; }
php
public function setColumns( $columns ){ if( !( is_array( $columns ) && count( $columns ) ) ) throw new \InvalidArgumentException( 'Column array must not be empty' ); $this->columns = $columns; }
[ "public", "function", "setColumns", "(", "$", "columns", ")", "{", "if", "(", "!", "(", "is_array", "(", "$", "columns", ")", "&&", "count", "(", "$", "columns", ")", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Column array must not be empty'", ")", ";", "$", "this", "->", "columns", "=", "$", "columns", ";", "}" ]
Setting all columns of the table. @access public @param array $columns List of table columns @return void @throws Exception
[ "Setting", "all", "columns", "of", "the", "table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L507-L511
36,973
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.setDbConnection
public function setDbConnection( $dbc ){ if( !is_object( $dbc ) ) throw new \InvalidArgumentException( 'Database connection resource must be an object' ); if( !is_a( $dbc, 'PDO' ) ) throw new \InvalidArgumentException( 'Database connection resource must be a direct or inherited PDO object' ); $this->dbc = $dbc; }
php
public function setDbConnection( $dbc ){ if( !is_object( $dbc ) ) throw new \InvalidArgumentException( 'Database connection resource must be an object' ); if( !is_a( $dbc, 'PDO' ) ) throw new \InvalidArgumentException( 'Database connection resource must be a direct or inherited PDO object' ); $this->dbc = $dbc; }
[ "public", "function", "setDbConnection", "(", "$", "dbc", ")", "{", "if", "(", "!", "is_object", "(", "$", "dbc", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Database connection resource must be an object'", ")", ";", "if", "(", "!", "is_a", "(", "$", "dbc", ",", "'PDO'", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Database connection resource must be a direct or inherited PDO object'", ")", ";", "$", "this", "->", "dbc", "=", "$", "dbc", ";", "}" ]
Setting a reference to a database connection. @access public @param PDO $dbc Database connection resource object @return void
[ "Setting", "a", "reference", "to", "a", "database", "connection", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L519-L525
36,974
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.setIndices
public function setIndices( $indices ) { foreach( $indices as $index ) { if( !in_array( $index, $this->columns ) ) throw new \InvalidArgumentException( 'Column "'.$index.'" is not existing in table "'.$this->tableName.'" and cannot be an index' ); if( $index === $this->primaryKey ) throw new \InvalidArgumentException( 'Column "'.$index.'" is already primary key and cannot be an index' ); } $this->indices = $indices; array_unique( $this->indices ); }
php
public function setIndices( $indices ) { foreach( $indices as $index ) { if( !in_array( $index, $this->columns ) ) throw new \InvalidArgumentException( 'Column "'.$index.'" is not existing in table "'.$this->tableName.'" and cannot be an index' ); if( $index === $this->primaryKey ) throw new \InvalidArgumentException( 'Column "'.$index.'" is already primary key and cannot be an index' ); } $this->indices = $indices; array_unique( $this->indices ); }
[ "public", "function", "setIndices", "(", "$", "indices", ")", "{", "foreach", "(", "$", "indices", "as", "$", "index", ")", "{", "if", "(", "!", "in_array", "(", "$", "index", ",", "$", "this", "->", "columns", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Column \"'", ".", "$", "index", ".", "'\" is not existing in table \"'", ".", "$", "this", "->", "tableName", ".", "'\" and cannot be an index'", ")", ";", "if", "(", "$", "index", "===", "$", "this", "->", "primaryKey", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Column \"'", ".", "$", "index", ".", "'\" is already primary key and cannot be an index'", ")", ";", "}", "$", "this", "->", "indices", "=", "$", "indices", ";", "array_unique", "(", "$", "this", "->", "indices", ")", ";", "}" ]
Setting all indices of this table. @access public @param array $indices List of table indices @return bool
[ "Setting", "all", "indices", "of", "this", "table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L546-L557
36,975
CeusMedia/Common
src/ADT/Tree/MagicNode.php
ADT_Tree_MagicNode.fromArray
public function fromArray( $array ){ foreach( $array as $key => $value ){ if( is_array( $value ) ){ $this->__set( $key, NULL ); $this->data[$key]->fromArray( $value ); } else{ $this->__set( $key, $value ); } } }
php
public function fromArray( $array ){ foreach( $array as $key => $value ){ if( is_array( $value ) ){ $this->__set( $key, NULL ); $this->data[$key]->fromArray( $value ); } else{ $this->__set( $key, $value ); } } }
[ "public", "function", "fromArray", "(", "$", "array", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "__set", "(", "$", "key", ",", "NULL", ")", ";", "$", "this", "->", "data", "[", "$", "key", "]", "->", "fromArray", "(", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "__set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}" ]
Imports array. @access public @param array $array Array to import @return void
[ "Imports", "array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/MagicNode.php#L97-L108
36,976
CeusMedia/Common
src/ADT/Tree/MagicNode.php
ADT_Tree_MagicNode.toArray
public function toArray(){ $array = array(); foreach( $this->data as $key => $node ){ if( count( $node->data ) ) $array[$key] = $node->toArray(); else $array[$key] = $node->value; } return $array; }
php
public function toArray(){ $array = array(); foreach( $this->data as $key => $node ){ if( count( $node->data ) ) $array[$key] = $node->toArray(); else $array[$key] = $node->value; } return $array; }
[ "public", "function", "toArray", "(", ")", "{", "$", "array", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "data", "as", "$", "key", "=>", "$", "node", ")", "{", "if", "(", "count", "(", "$", "node", "->", "data", ")", ")", "$", "array", "[", "$", "key", "]", "=", "$", "node", "->", "toArray", "(", ")", ";", "else", "$", "array", "[", "$", "key", "]", "=", "$", "node", "->", "value", ";", "}", "return", "$", "array", ";", "}" ]
Returns nested nodes as array. @access public @return array
[ "Returns", "nested", "nodes", "as", "array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/MagicNode.php#L125-L134
36,977
CeusMedia/Common
src/ADT/Tree/MagicNode.php
ADT_Tree_MagicNode.value
public function value( $value = NULL ){ if( is_null( $value ) ) return $this->value; $this->value = $value; }
php
public function value( $value = NULL ){ if( is_null( $value ) ) return $this->value; $this->value = $value; }
[ "public", "function", "value", "(", "$", "value", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "return", "$", "this", "->", "value", ";", "$", "this", "->", "value", "=", "$", "value", ";", "}" ]
Returns or sets value of node. Returns node value of no new value is given. Sets node value of new value is given. @access public @param mixed $value Value to set on node @return mixed|NULL
[ "Returns", "or", "sets", "value", "of", "node", ".", "Returns", "node", "value", "of", "no", "new", "value", "is", "given", ".", "Sets", "node", "value", "of", "new", "value", "is", "given", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/MagicNode.php#L153-L157
36,978
CeusMedia/Common
src/XML/DOM/GoogleSitemapWriter.php
XML_DOM_GoogleSitemapWriter.writeSitemap
public static function writeSitemap( $links, $fileName = "sitemap.xml", $baseUrl = "" ) { $xml = XML_DOM_GoogleSitemapBuilder::buildSitemap( $links, $baseUrl ); $file = new FS_File_Writer( $fileName ); return $file->writeString( $xml ); }
php
public static function writeSitemap( $links, $fileName = "sitemap.xml", $baseUrl = "" ) { $xml = XML_DOM_GoogleSitemapBuilder::buildSitemap( $links, $baseUrl ); $file = new FS_File_Writer( $fileName ); return $file->writeString( $xml ); }
[ "public", "static", "function", "writeSitemap", "(", "$", "links", ",", "$", "fileName", "=", "\"sitemap.xml\"", ",", "$", "baseUrl", "=", "\"\"", ")", "{", "$", "xml", "=", "XML_DOM_GoogleSitemapBuilder", "::", "buildSitemap", "(", "$", "links", ",", "$", "baseUrl", ")", ";", "$", "file", "=", "new", "FS_File_Writer", "(", "$", "fileName", ")", ";", "return", "$", "file", "->", "writeString", "(", "$", "xml", ")", ";", "}" ]
Builds and write XML of Sitemap. @access public @static @param string $links List of Sitemap Link @param string $fileName File Name of XML Sitemap File @param string $baseUrl Basic URL to add to every Link @return bool
[ "Builds", "and", "write", "XML", "of", "Sitemap", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/GoogleSitemapWriter.php#L81-L86
36,979
ncou/Chiron
src/Chiron/Http/Middleware/MethodOverrideMiddleware.php
MethodOverrideMiddleware.process
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // TODO : on devrait plutot utiliser un truc genre : strtoupper($request->getHeaderLine("X-Http-Method-Override")); if ($request->hasHeader('X-Http-Method-Override')) { if (! empty($request->getHeader('X-Http-Method-Override')[0])) { $request = $request->withMethod($request->getHeader('X-Http-Method-Override')[0]); } } if (strtoupper($request->getMethod()) === 'GET') { if (! empty($request->getQueryParams()['_method'])) { $method = $request->getQueryParams()['_method']; $request = $request->withMethod($method); } } if (strtoupper($request->getMethod()) === 'POST') { if (! empty($request->getParsedBody()['_method'])) { $request = $request->withMethod($request->getParsedBody()['_method']); } /* if ($request->getBody()->eof()) { $request->getBody()->rewind(); }*/ } // TODO : faire un throw HttpException 405 si la méthode override n'est pas correcte $response = $handler->handle($request); return $response; }
php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // TODO : on devrait plutot utiliser un truc genre : strtoupper($request->getHeaderLine("X-Http-Method-Override")); if ($request->hasHeader('X-Http-Method-Override')) { if (! empty($request->getHeader('X-Http-Method-Override')[0])) { $request = $request->withMethod($request->getHeader('X-Http-Method-Override')[0]); } } if (strtoupper($request->getMethod()) === 'GET') { if (! empty($request->getQueryParams()['_method'])) { $method = $request->getQueryParams()['_method']; $request = $request->withMethod($method); } } if (strtoupper($request->getMethod()) === 'POST') { if (! empty($request->getParsedBody()['_method'])) { $request = $request->withMethod($request->getParsedBody()['_method']); } /* if ($request->getBody()->eof()) { $request->getBody()->rewind(); }*/ } // TODO : faire un throw HttpException 405 si la méthode override n'est pas correcte $response = $handler->handle($request); return $response; }
[ "public", "function", "process", "(", "ServerRequestInterface", "$", "request", ",", "RequestHandlerInterface", "$", "handler", ")", ":", "ResponseInterface", "{", "// TODO : on devrait plutot utiliser un truc genre : strtoupper($request->getHeaderLine(\"X-Http-Method-Override\"));", "if", "(", "$", "request", "->", "hasHeader", "(", "'X-Http-Method-Override'", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "request", "->", "getHeader", "(", "'X-Http-Method-Override'", ")", "[", "0", "]", ")", ")", "{", "$", "request", "=", "$", "request", "->", "withMethod", "(", "$", "request", "->", "getHeader", "(", "'X-Http-Method-Override'", ")", "[", "0", "]", ")", ";", "}", "}", "if", "(", "strtoupper", "(", "$", "request", "->", "getMethod", "(", ")", ")", "===", "'GET'", ")", "{", "if", "(", "!", "empty", "(", "$", "request", "->", "getQueryParams", "(", ")", "[", "'_method'", "]", ")", ")", "{", "$", "method", "=", "$", "request", "->", "getQueryParams", "(", ")", "[", "'_method'", "]", ";", "$", "request", "=", "$", "request", "->", "withMethod", "(", "$", "method", ")", ";", "}", "}", "if", "(", "strtoupper", "(", "$", "request", "->", "getMethod", "(", ")", ")", "===", "'POST'", ")", "{", "if", "(", "!", "empty", "(", "$", "request", "->", "getParsedBody", "(", ")", "[", "'_method'", "]", ")", ")", "{", "$", "request", "=", "$", "request", "->", "withMethod", "(", "$", "request", "->", "getParsedBody", "(", ")", "[", "'_method'", "]", ")", ";", "}", "/*\n if ($request->getBody()->eof()) {\n $request->getBody()->rewind();\n }*/", "}", "// TODO : faire un throw HttpException 405 si la méthode override n'est pas correcte", "$", "response", "=", "$", "handler", "->", "handle", "(", "$", "request", ")", ";", "return", "$", "response", ";", "}" ]
Handle the middleware pipeline call. This calls the next middleware in the queue and after the rest of the middleware pipeline is done the response will be sent to the client. @param RequestInterface $request @param ResponseInterface $response @param callable $next @return ResponseInterface
[ "Handle", "the", "middleware", "pipeline", "call", ".", "This", "calls", "the", "next", "middleware", "in", "the", "queue", "and", "after", "the", "rest", "of", "the", "middleware", "pipeline", "is", "done", "the", "response", "will", "be", "sent", "to", "the", "client", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Middleware/MethodOverrideMiddleware.php#L48-L77
36,980
CeusMedia/Common
src/CLI/Application.php
CLI_Application.showError
protected function showError( $message, $abort = TRUE ){ \CLI::error( $message ); if( $abort ) die( $message ); }
php
protected function showError( $message, $abort = TRUE ){ \CLI::error( $message ); if( $abort ) die( $message ); }
[ "protected", "function", "showError", "(", "$", "message", ",", "$", "abort", "=", "TRUE", ")", "{", "\\", "CLI", "::", "error", "(", "$", "message", ")", ";", "if", "(", "$", "abort", ")", "die", "(", "$", "message", ")", ";", "}" ]
Prints Error Message to Console, to be overridden. @access protected @param string $message Error Message to print to Console @return void
[ "Prints", "Error", "Message", "to", "Console", "to", "be", "overridden", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Application.php#L77-L81
36,981
CeusMedia/Common
src/CLI/Application.php
CLI_Application.showUsage
protected function showUsage( $message = NULL ){ \CLI::out(); \CLI::out( 'Console Application' ); \CLI::out(); \CLI::out( 'Usage: ./cli_app.php a [b]' ); \CLI::out( 'Options:' ); \CLI::out( ' a Mandatory Option' ); \CLI::out( ' help show help' ); \CLI::out( ' b Optional Option' ); if( $message ) $this->showError( $message ); }
php
protected function showUsage( $message = NULL ){ \CLI::out(); \CLI::out( 'Console Application' ); \CLI::out(); \CLI::out( 'Usage: ./cli_app.php a [b]' ); \CLI::out( 'Options:' ); \CLI::out( ' a Mandatory Option' ); \CLI::out( ' help show help' ); \CLI::out( ' b Optional Option' ); if( $message ) $this->showError( $message ); }
[ "protected", "function", "showUsage", "(", "$", "message", "=", "NULL", ")", "{", "\\", "CLI", "::", "out", "(", ")", ";", "\\", "CLI", "::", "out", "(", "'Console Application'", ")", ";", "\\", "CLI", "::", "out", "(", ")", ";", "\\", "CLI", "::", "out", "(", "'Usage: ./cli_app.php a [b]'", ")", ";", "\\", "CLI", "::", "out", "(", "'Options:'", ")", ";", "\\", "CLI", "::", "out", "(", "' a\t\t\tMandatory Option'", ")", ";", "\\", "CLI", "::", "out", "(", "' help\t\tshow help'", ")", ";", "\\", "CLI", "::", "out", "(", "' b\t\t\tOptional Option'", ")", ";", "if", "(", "$", "message", ")", "$", "this", "->", "showError", "(", "$", "message", ")", ";", "}" ]
Prints Usage Message to Console and exits Script, to be overridden. @access protected @param string $message Message to show below usage lines @return void
[ "Prints", "Usage", "Message", "to", "Console", "and", "exits", "Script", "to", "be", "overridden", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Application.php#L89-L100
36,982
CeusMedia/Common
src/Net/AtomTime.php
Net_AtomTime.getTimestamp
public static function getTimestamp() { $curl = new Net_CURL( self::$url ); $result = $curl->exec(); $status = $curl->getStatus(); if( $status['http_code'] != 200 ) throw new Exception( "Service URL is not reachable." ); $parts = explode( "\n", $result ); $date = trim( $parts[2] ); $time = strtotime( $date ); return $time; }
php
public static function getTimestamp() { $curl = new Net_CURL( self::$url ); $result = $curl->exec(); $status = $curl->getStatus(); if( $status['http_code'] != 200 ) throw new Exception( "Service URL is not reachable." ); $parts = explode( "\n", $result ); $date = trim( $parts[2] ); $time = strtotime( $date ); return $time; }
[ "public", "static", "function", "getTimestamp", "(", ")", "{", "$", "curl", "=", "new", "Net_CURL", "(", "self", "::", "$", "url", ")", ";", "$", "result", "=", "$", "curl", "->", "exec", "(", ")", ";", "$", "status", "=", "$", "curl", "->", "getStatus", "(", ")", ";", "if", "(", "$", "status", "[", "'http_code'", "]", "!=", "200", ")", "throw", "new", "Exception", "(", "\"Service URL is not reachable.\"", ")", ";", "$", "parts", "=", "explode", "(", "\"\\n\"", ",", "$", "result", ")", ";", "$", "date", "=", "trim", "(", "$", "parts", "[", "2", "]", ")", ";", "$", "time", "=", "strtotime", "(", "$", "date", ")", ";", "return", "$", "time", ";", "}" ]
Returns timestamp. @access public @static @return int @link http://www.php.net/time
[ "Returns", "timestamp", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/AtomTime.php#L54-L65
36,983
CeusMedia/Common
src/FS/File/TodoLister.php
FS_File_TodoLister.getList
public function getList( $full = NULL ) { if( $full ) return $this->list; $list = array(); foreach( $this->list as $pathName => $fileData ) $list[$pathName] = $fileData['fileName']; return $list; }
php
public function getList( $full = NULL ) { if( $full ) return $this->list; $list = array(); foreach( $this->list as $pathName => $fileData ) $list[$pathName] = $fileData['fileName']; return $list; }
[ "public", "function", "getList", "(", "$", "full", "=", "NULL", ")", "{", "if", "(", "$", "full", ")", "return", "$", "this", "->", "list", ";", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "list", "as", "$", "pathName", "=>", "$", "fileData", ")", "$", "list", "[", "$", "pathName", "]", "=", "$", "fileData", "[", "'fileName'", "]", ";", "return", "$", "list", ";", "}" ]
Returns Array of numberFound Files. @access public @param bool $full Flag: Return Path Name, File Name and Content also @return array
[ "Returns", "Array", "of", "numberFound", "Files", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/TodoLister.php#L111-L119
36,984
CeusMedia/Common
src/FS/File/TodoLister.php
FS_File_TodoLister.scan
public function scan( $path ) { $this->numberFound = 0; $this->numberScanned = 0; $this->numberTodos = 0; $this->numberLines = 0; $this->list = array(); $extensions = $this->getExtensionPattern(); $pattern = $this->getExtendedPattern(); $iterator = $this->getIndexIterator( $path, $extensions ); try{ foreach( $iterator as $entry ) { $this->numberScanned++; $content = file_get_contents( $entry->getPathname() ); $lines = explode( "\n", $content ); $i = 0; $list = array(); foreach( $lines as $line ) { $this->numberLines++; $i++; if( !preg_match( $pattern, $line ) ) continue; $this->numberTodos++; $list[$i] = $line;#trim( $line ); } if( !$list ) continue; $this->numberFound++; $this->list[$entry->getPathname()] = array( 'fileName' => $entry->getFilename(), 'lines' => $list, ); } } catch( UnexpectedValueException $e ){ } catch( Exception $e ){ throw new RuntimeException( $e->getMessage(), $e->getCode(), $es ); } }
php
public function scan( $path ) { $this->numberFound = 0; $this->numberScanned = 0; $this->numberTodos = 0; $this->numberLines = 0; $this->list = array(); $extensions = $this->getExtensionPattern(); $pattern = $this->getExtendedPattern(); $iterator = $this->getIndexIterator( $path, $extensions ); try{ foreach( $iterator as $entry ) { $this->numberScanned++; $content = file_get_contents( $entry->getPathname() ); $lines = explode( "\n", $content ); $i = 0; $list = array(); foreach( $lines as $line ) { $this->numberLines++; $i++; if( !preg_match( $pattern, $line ) ) continue; $this->numberTodos++; $list[$i] = $line;#trim( $line ); } if( !$list ) continue; $this->numberFound++; $this->list[$entry->getPathname()] = array( 'fileName' => $entry->getFilename(), 'lines' => $list, ); } } catch( UnexpectedValueException $e ){ } catch( Exception $e ){ throw new RuntimeException( $e->getMessage(), $e->getCode(), $es ); } }
[ "public", "function", "scan", "(", "$", "path", ")", "{", "$", "this", "->", "numberFound", "=", "0", ";", "$", "this", "->", "numberScanned", "=", "0", ";", "$", "this", "->", "numberTodos", "=", "0", ";", "$", "this", "->", "numberLines", "=", "0", ";", "$", "this", "->", "list", "=", "array", "(", ")", ";", "$", "extensions", "=", "$", "this", "->", "getExtensionPattern", "(", ")", ";", "$", "pattern", "=", "$", "this", "->", "getExtendedPattern", "(", ")", ";", "$", "iterator", "=", "$", "this", "->", "getIndexIterator", "(", "$", "path", ",", "$", "extensions", ")", ";", "try", "{", "foreach", "(", "$", "iterator", "as", "$", "entry", ")", "{", "$", "this", "->", "numberScanned", "++", ";", "$", "content", "=", "file_get_contents", "(", "$", "entry", "->", "getPathname", "(", ")", ")", ";", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "content", ")", ";", "$", "i", "=", "0", ";", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "this", "->", "numberLines", "++", ";", "$", "i", "++", ";", "if", "(", "!", "preg_match", "(", "$", "pattern", ",", "$", "line", ")", ")", "continue", ";", "$", "this", "->", "numberTodos", "++", ";", "$", "list", "[", "$", "i", "]", "=", "$", "line", ";", "#trim( $line );", "}", "if", "(", "!", "$", "list", ")", "continue", ";", "$", "this", "->", "numberFound", "++", ";", "$", "this", "->", "list", "[", "$", "entry", "->", "getPathname", "(", ")", "]", "=", "array", "(", "'fileName'", "=>", "$", "entry", "->", "getFilename", "(", ")", ",", "'lines'", "=>", "$", "list", ",", ")", ";", "}", "}", "catch", "(", "UnexpectedValueException", "$", "e", ")", "{", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "RuntimeException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "es", ")", ";", "}", "}" ]
Scans a Path for Files with Pattern. @access public @return int
[ "Scans", "a", "Path", "for", "Files", "with", "Pattern", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/TodoLister.php#L171-L212
36,985
kdambekalns/faker
Classes/Company.php
Company.name
public static function name() { $format = static::$formats[array_rand(static::$formats)]; $parts = array(); foreach ($format['parts'] as $function) { $parts[] = call_user_func($function); } return vsprintf($format['format'], $parts); }
php
public static function name() { $format = static::$formats[array_rand(static::$formats)]; $parts = array(); foreach ($format['parts'] as $function) { $parts[] = call_user_func($function); } return vsprintf($format['format'], $parts); }
[ "public", "static", "function", "name", "(", ")", "{", "$", "format", "=", "static", "::", "$", "formats", "[", "array_rand", "(", "static", "::", "$", "formats", ")", "]", ";", "$", "parts", "=", "array", "(", ")", ";", "foreach", "(", "$", "format", "[", "'parts'", "]", "as", "$", "function", ")", "{", "$", "parts", "[", "]", "=", "call_user_func", "(", "$", "function", ")", ";", "}", "return", "vsprintf", "(", "$", "format", "[", "'format'", "]", ",", "$", "parts", ")", ";", "}" ]
Return a fake company name. @return string
[ "Return", "a", "fake", "company", "name", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Company.php#L65-L75
36,986
CeusMedia/Common
src/FS/File/List/SectionWriter.php
FS_File_List_SectionWriter.save
public static function save( $fileName, $list ) { $lines = array(); foreach( $list as $section => $data ) { if( count( $lines ) ) $lines[] = ""; $lines[] = "[".$section."]"; foreach( $data as $entry ) $lines[] = $entry; } $writer = new FS_File_Writer( $fileName, 0755 ); return $writer->writeArray( $lines ); }
php
public static function save( $fileName, $list ) { $lines = array(); foreach( $list as $section => $data ) { if( count( $lines ) ) $lines[] = ""; $lines[] = "[".$section."]"; foreach( $data as $entry ) $lines[] = $entry; } $writer = new FS_File_Writer( $fileName, 0755 ); return $writer->writeArray( $lines ); }
[ "public", "static", "function", "save", "(", "$", "fileName", ",", "$", "list", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "section", "=>", "$", "data", ")", "{", "if", "(", "count", "(", "$", "lines", ")", ")", "$", "lines", "[", "]", "=", "\"\"", ";", "$", "lines", "[", "]", "=", "\"[\"", ".", "$", "section", ".", "\"]\"", ";", "foreach", "(", "$", "data", "as", "$", "entry", ")", "$", "lines", "[", "]", "=", "$", "entry", ";", "}", "$", "writer", "=", "new", "FS_File_Writer", "(", "$", "fileName", ",", "0755", ")", ";", "return", "$", "writer", "->", "writeArray", "(", "$", "lines", ")", ";", "}" ]
Saves a Section List to a File. @access public @static @param string $fileName File Name of Section List @param array $list Section List to write @return void
[ "Saves", "a", "Section", "List", "to", "a", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/SectionWriter.php#L64-L77
36,987
CeusMedia/Common
src/Net/HTTP/Sniffer/Encoding.php
Net_HTTP_Sniffer_Encoding.getEncoding
public static function getEncoding( $allowed, $default = NULL ) { if( !$default) $default = $allowed[0]; else if( !in_array( $default, $allowed ) ) throw new InvalidArgumentException( 'Default Encoding Method must be an allowed Encoding Method.' ); $pattern = '/^([a-z]+)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i'; $accepted = getEnv( 'HTTP_ACCEPT_ENCODING' ); if( !$accepted ) return $default; $accepted = preg_split( '/,\s*/', $accepted ); $currentCode = $default; $currentQuality = 0; foreach( $accepted as $accept ) { if( !preg_match ( $pattern, $accept, $matches ) ) continue; $codeQuality = isset( $matches[2] ) ? (float) $matches[2] : 1.0; if( in_array( $matches[1], $allowed ) ) { if( $codeQuality > $currentQuality ) { $currentCode = $matches[1]; $currentQuality = $codeQuality; } } } return $currentCode; }
php
public static function getEncoding( $allowed, $default = NULL ) { if( !$default) $default = $allowed[0]; else if( !in_array( $default, $allowed ) ) throw new InvalidArgumentException( 'Default Encoding Method must be an allowed Encoding Method.' ); $pattern = '/^([a-z]+)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i'; $accepted = getEnv( 'HTTP_ACCEPT_ENCODING' ); if( !$accepted ) return $default; $accepted = preg_split( '/,\s*/', $accepted ); $currentCode = $default; $currentQuality = 0; foreach( $accepted as $accept ) { if( !preg_match ( $pattern, $accept, $matches ) ) continue; $codeQuality = isset( $matches[2] ) ? (float) $matches[2] : 1.0; if( in_array( $matches[1], $allowed ) ) { if( $codeQuality > $currentQuality ) { $currentCode = $matches[1]; $currentQuality = $codeQuality; } } } return $currentCode; }
[ "public", "static", "function", "getEncoding", "(", "$", "allowed", ",", "$", "default", "=", "NULL", ")", "{", "if", "(", "!", "$", "default", ")", "$", "default", "=", "$", "allowed", "[", "0", "]", ";", "else", "if", "(", "!", "in_array", "(", "$", "default", ",", "$", "allowed", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Default Encoding Method must be an allowed Encoding Method.'", ")", ";", "$", "pattern", "=", "'/^([a-z]+)(?:;\\s*q=(0(?:\\.[0-9]{1,3})?|1(?:\\.0{1,3})?))?$/i'", ";", "$", "accepted", "=", "getEnv", "(", "'HTTP_ACCEPT_ENCODING'", ")", ";", "if", "(", "!", "$", "accepted", ")", "return", "$", "default", ";", "$", "accepted", "=", "preg_split", "(", "'/,\\s*/'", ",", "$", "accepted", ")", ";", "$", "currentCode", "=", "$", "default", ";", "$", "currentQuality", "=", "0", ";", "foreach", "(", "$", "accepted", "as", "$", "accept", ")", "{", "if", "(", "!", "preg_match", "(", "$", "pattern", ",", "$", "accept", ",", "$", "matches", ")", ")", "continue", ";", "$", "codeQuality", "=", "isset", "(", "$", "matches", "[", "2", "]", ")", "?", "(", "float", ")", "$", "matches", "[", "2", "]", ":", "1.0", ";", "if", "(", "in_array", "(", "$", "matches", "[", "1", "]", ",", "$", "allowed", ")", ")", "{", "if", "(", "$", "codeQuality", ">", "$", "currentQuality", ")", "{", "$", "currentCode", "=", "$", "matches", "[", "1", "]", ";", "$", "currentQuality", "=", "$", "codeQuality", ";", "}", "}", "}", "return", "$", "currentCode", ";", "}" ]
Returns prefered allowed and accepted Encoding Method. @access public @static @param array $allowed Array of Encoding Methods supported and allowed by the Application @param string $default Default Encoding Methods supported and allowed by the Application @return string
[ "Returns", "prefered", "allowed", "and", "accepted", "Encoding", "Method", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Sniffer/Encoding.php#L50-L79
36,988
ncou/Chiron
src/Chiron/Handler/ErrorHandler.php
ErrorHandler.report
private function report(ServerRequestInterface $request, Throwable $e): void { if ($this->shouldntReport($e)) { return; } foreach ($this->reporters as $reporter) { if ($reporter->canReport($e)) { $reporter->report($request, $e); } } }
php
private function report(ServerRequestInterface $request, Throwable $e): void { if ($this->shouldntReport($e)) { return; } foreach ($this->reporters as $reporter) { if ($reporter->canReport($e)) { $reporter->report($request, $e); } } }
[ "private", "function", "report", "(", "ServerRequestInterface", "$", "request", ",", "Throwable", "$", "e", ")", ":", "void", "{", "if", "(", "$", "this", "->", "shouldntReport", "(", "$", "e", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "reporters", "as", "$", "reporter", ")", "{", "if", "(", "$", "reporter", "->", "canReport", "(", "$", "e", ")", ")", "{", "$", "reporter", "->", "report", "(", "$", "request", ",", "$", "e", ")", ";", "}", "}", "}" ]
Execute all the reporters in the stack. @param \Psr\Http\Message\ServerRequestInterface $request @param \Throwable $e @return \Psr\Http\Message\ResponseInterface
[ "Execute", "all", "the", "reporters", "in", "the", "stack", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/ErrorHandler.php#L191-L202
36,989
ncou/Chiron
src/Chiron/Handler/ErrorHandler.php
ErrorHandler.getFilteredFormatter
private function getFilteredFormatter(Throwable $e, ServerRequestInterface $request): FormatterInterface { $filtered = $this->formatters; foreach ($filtered as $index => $formatter) { // *** isVerbose Filter *** if (! $this->shouldBeVerbose) { if ($formatter->isVerbose()) { unset($filtered[$index]); continue; } } // *** CanFormat Filter *** if (! $formatter->canFormat($e)) { unset($filtered[$index]); continue; } // *** Content-Type Filter *** if (! $this->isAcceptableContentType($request, $formatter->contentType())) { unset($filtered[$index]); continue; } } // use a default formatter if there is none present after applying the filters. Else use the first one present in the array. // TODO : attention on devrait lever une exception si il n'y a pas de default formatter de défini par l'utilisateur, ou alors à minima on fait un rethrow de l'exception. return reset($filtered) ?: $this->defaultFormatter; }
php
private function getFilteredFormatter(Throwable $e, ServerRequestInterface $request): FormatterInterface { $filtered = $this->formatters; foreach ($filtered as $index => $formatter) { // *** isVerbose Filter *** if (! $this->shouldBeVerbose) { if ($formatter->isVerbose()) { unset($filtered[$index]); continue; } } // *** CanFormat Filter *** if (! $formatter->canFormat($e)) { unset($filtered[$index]); continue; } // *** Content-Type Filter *** if (! $this->isAcceptableContentType($request, $formatter->contentType())) { unset($filtered[$index]); continue; } } // use a default formatter if there is none present after applying the filters. Else use the first one present in the array. // TODO : attention on devrait lever une exception si il n'y a pas de default formatter de défini par l'utilisateur, ou alors à minima on fait un rethrow de l'exception. return reset($filtered) ?: $this->defaultFormatter; }
[ "private", "function", "getFilteredFormatter", "(", "Throwable", "$", "e", ",", "ServerRequestInterface", "$", "request", ")", ":", "FormatterInterface", "{", "$", "filtered", "=", "$", "this", "->", "formatters", ";", "foreach", "(", "$", "filtered", "as", "$", "index", "=>", "$", "formatter", ")", "{", "// *** isVerbose Filter ***", "if", "(", "!", "$", "this", "->", "shouldBeVerbose", ")", "{", "if", "(", "$", "formatter", "->", "isVerbose", "(", ")", ")", "{", "unset", "(", "$", "filtered", "[", "$", "index", "]", ")", ";", "continue", ";", "}", "}", "// *** CanFormat Filter ***", "if", "(", "!", "$", "formatter", "->", "canFormat", "(", "$", "e", ")", ")", "{", "unset", "(", "$", "filtered", "[", "$", "index", "]", ")", ";", "continue", ";", "}", "// *** Content-Type Filter ***", "if", "(", "!", "$", "this", "->", "isAcceptableContentType", "(", "$", "request", ",", "$", "formatter", "->", "contentType", "(", ")", ")", ")", "{", "unset", "(", "$", "filtered", "[", "$", "index", "]", ")", ";", "continue", ";", "}", "}", "// use a default formatter if there is none present after applying the filters. Else use the first one present in the array.", "// TODO : attention on devrait lever une exception si il n'y a pas de default formatter de défini par l'utilisateur, ou alors à minima on fait un rethrow de l'exception.", "return", "reset", "(", "$", "filtered", ")", "?", ":", "$", "this", "->", "defaultFormatter", ";", "}" ]
Get the filtered formatter instance. @param \Throwable $e @param ServerRequestInterface $request @return \Chiron\Exception\Formatter\FormatterInterface
[ "Get", "the", "filtered", "formatter", "instance", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/ErrorHandler.php#L212-L242
36,990
CeusMedia/Common
src/ADT/Time/Delay.php
ADT_Time_Delay.isActive
public function isActive() { $this->numberChecks++; $time = microtime( TRUE ) - $this->time; return $time < $this->seconds; }
php
public function isActive() { $this->numberChecks++; $time = microtime( TRUE ) - $this->time; return $time < $this->seconds; }
[ "public", "function", "isActive", "(", ")", "{", "$", "this", "->", "numberChecks", "++", ";", "$", "time", "=", "microtime", "(", "TRUE", ")", "-", "$", "this", "->", "time", ";", "return", "$", "time", "<", "$", "this", "->", "seconds", ";", "}" ]
Indicates whether Delay still has not passed. @access public @return bool
[ "Indicates", "whether", "Delay", "still", "has", "not", "passed", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Time/Delay.php#L96-L101
36,991
CeusMedia/Common
src/ADT/Time/Delay.php
ADT_Time_Delay.restart
public function restart( $force = FALSE ) { if( $this->isActive() && !$force ) throw RuntimeException( 'Delay is still active' ); $this->time = microtime( TRUE ); $this->numberRuns++; return $this->getStartTime(); }
php
public function restart( $force = FALSE ) { if( $this->isActive() && !$force ) throw RuntimeException( 'Delay is still active' ); $this->time = microtime( TRUE ); $this->numberRuns++; return $this->getStartTime(); }
[ "public", "function", "restart", "(", "$", "force", "=", "FALSE", ")", "{", "if", "(", "$", "this", "->", "isActive", "(", ")", "&&", "!", "$", "force", ")", "throw", "RuntimeException", "(", "'Delay is still active'", ")", ";", "$", "this", "->", "time", "=", "microtime", "(", "TRUE", ")", ";", "$", "this", "->", "numberRuns", "++", ";", "return", "$", "this", "->", "getStartTime", "(", ")", ";", "}" ]
Reset the start to 'now'. @access public @param bool $force Flag: reset also if Delay is still active @return float Timestamp of start just set
[ "Reset", "the", "start", "to", "now", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Time/Delay.php#L119-L126
36,992
CeusMedia/Common
src/FS/File/PHP/Parser/Array.php
FS_File_PHP_Parser_Array.overwriteCodeDataWithDocData
private function overwriteCodeDataWithDocData( &$codeData, $docData ) { foreach( $docData as $key => $value ) { if( !$value ) continue; if( is_string( $value ) ) { if( isset( $codeData[$key] ) && is_array( $codeData[$key] ) ) $codeData[$key][] = $value; else if( isset( $codeData[$key] ) && !$codeData[$key] ) $codeData[$key] = $value; } else if( isset( $codeData[$key] ) ) { foreach( $value as $itemKey => $itemValue ) { if( is_string( $itemValue ) ) { if( is_string( $itemKey ) ) $codeData[$key][$itemKey] = $itemValue; else if( is_int( $itemKey ) && !in_array( $itemValue, $codeData[$key] ) ) $codeData[$key][] = $itemValue; } else if( is_string( $itemKey ) && isset( $codeData[$key][$itemKey] ) ) { foreach( $itemValue as $itemItemKey => $itemItemValue ) if( !isset( $codeData[$key][$itemKey][$itemItemKey] ) ) $codeData[$key][$itemKey][$itemItemKey] = $itemItemValue; } else if( $key != "param" ) { foreach( $itemValue as $itemItemKey => $itemItemValue ) if( !isset( $codeData[$key][$itemKey][$itemItemKey] ) ) $codeData[$key][$itemKey][$itemItemKey] = $itemItemValue; } } } } }
php
private function overwriteCodeDataWithDocData( &$codeData, $docData ) { foreach( $docData as $key => $value ) { if( !$value ) continue; if( is_string( $value ) ) { if( isset( $codeData[$key] ) && is_array( $codeData[$key] ) ) $codeData[$key][] = $value; else if( isset( $codeData[$key] ) && !$codeData[$key] ) $codeData[$key] = $value; } else if( isset( $codeData[$key] ) ) { foreach( $value as $itemKey => $itemValue ) { if( is_string( $itemValue ) ) { if( is_string( $itemKey ) ) $codeData[$key][$itemKey] = $itemValue; else if( is_int( $itemKey ) && !in_array( $itemValue, $codeData[$key] ) ) $codeData[$key][] = $itemValue; } else if( is_string( $itemKey ) && isset( $codeData[$key][$itemKey] ) ) { foreach( $itemValue as $itemItemKey => $itemItemValue ) if( !isset( $codeData[$key][$itemKey][$itemItemKey] ) ) $codeData[$key][$itemKey][$itemItemKey] = $itemItemValue; } else if( $key != "param" ) { foreach( $itemValue as $itemItemKey => $itemItemValue ) if( !isset( $codeData[$key][$itemKey][$itemItemKey] ) ) $codeData[$key][$itemKey][$itemItemKey] = $itemItemValue; } } } } }
[ "private", "function", "overwriteCodeDataWithDocData", "(", "&", "$", "codeData", ",", "$", "docData", ")", "{", "foreach", "(", "$", "docData", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "value", ")", "continue", ";", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "if", "(", "isset", "(", "$", "codeData", "[", "$", "key", "]", ")", "&&", "is_array", "(", "$", "codeData", "[", "$", "key", "]", ")", ")", "$", "codeData", "[", "$", "key", "]", "[", "]", "=", "$", "value", ";", "else", "if", "(", "isset", "(", "$", "codeData", "[", "$", "key", "]", ")", "&&", "!", "$", "codeData", "[", "$", "key", "]", ")", "$", "codeData", "[", "$", "key", "]", "=", "$", "value", ";", "}", "else", "if", "(", "isset", "(", "$", "codeData", "[", "$", "key", "]", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "itemKey", "=>", "$", "itemValue", ")", "{", "if", "(", "is_string", "(", "$", "itemValue", ")", ")", "{", "if", "(", "is_string", "(", "$", "itemKey", ")", ")", "$", "codeData", "[", "$", "key", "]", "[", "$", "itemKey", "]", "=", "$", "itemValue", ";", "else", "if", "(", "is_int", "(", "$", "itemKey", ")", "&&", "!", "in_array", "(", "$", "itemValue", ",", "$", "codeData", "[", "$", "key", "]", ")", ")", "$", "codeData", "[", "$", "key", "]", "[", "]", "=", "$", "itemValue", ";", "}", "else", "if", "(", "is_string", "(", "$", "itemKey", ")", "&&", "isset", "(", "$", "codeData", "[", "$", "key", "]", "[", "$", "itemKey", "]", ")", ")", "{", "foreach", "(", "$", "itemValue", "as", "$", "itemItemKey", "=>", "$", "itemItemValue", ")", "if", "(", "!", "isset", "(", "$", "codeData", "[", "$", "key", "]", "[", "$", "itemKey", "]", "[", "$", "itemItemKey", "]", ")", ")", "$", "codeData", "[", "$", "key", "]", "[", "$", "itemKey", "]", "[", "$", "itemItemKey", "]", "=", "$", "itemItemValue", ";", "}", "else", "if", "(", "$", "key", "!=", "\"param\"", ")", "{", "foreach", "(", "$", "itemValue", "as", "$", "itemItemKey", "=>", "$", "itemItemValue", ")", "if", "(", "!", "isset", "(", "$", "codeData", "[", "$", "key", "]", "[", "$", "itemKey", "]", "[", "$", "itemItemKey", "]", ")", ")", "$", "codeData", "[", "$", "key", "]", "[", "$", "itemKey", "]", "[", "$", "itemItemKey", "]", "=", "$", "itemItemValue", ";", "}", "}", "}", "}", "}" ]
Appends all collected Documentation Information to already collected Code Information. @access private @param array $codeData Data collected by parsing Code @param string $docData Data collected by parsing Documentation @return void
[ "Appends", "all", "collected", "Documentation", "Information", "to", "already", "collected", "Code", "Information", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Parser/Array.php#L122-L161
36,993
CeusMedia/Common
src/FS/File/PHP/Parser/Array.php
FS_File_PHP_Parser_Array.parseClass
private function parseClass( $data, $matches, &$openBlocks ) { $data['abstract'] = (bool) $matches[1]; $data['final'] = (bool) $matches[2]; $data['type'] = $matches[3]; $data['name'] = $matches[4]; $data['extends'] = isset( $matches[5] ) ? $matches[6] : NULL; if( isset( $matches[7] ) ) foreach( array_slice( $matches, 8 ) as $match ) if( trim( $match ) && !preg_match( "@^,|{@", trim( $match ) ) ) $data['implements'][] = trim( $match ); if( $openBlocks ) $this->overwriteCodeDataWithDocData( $data, array_pop( $openBlocks ) ); return $data; }
php
private function parseClass( $data, $matches, &$openBlocks ) { $data['abstract'] = (bool) $matches[1]; $data['final'] = (bool) $matches[2]; $data['type'] = $matches[3]; $data['name'] = $matches[4]; $data['extends'] = isset( $matches[5] ) ? $matches[6] : NULL; if( isset( $matches[7] ) ) foreach( array_slice( $matches, 8 ) as $match ) if( trim( $match ) && !preg_match( "@^,|{@", trim( $match ) ) ) $data['implements'][] = trim( $match ); if( $openBlocks ) $this->overwriteCodeDataWithDocData( $data, array_pop( $openBlocks ) ); return $data; }
[ "private", "function", "parseClass", "(", "$", "data", ",", "$", "matches", ",", "&", "$", "openBlocks", ")", "{", "$", "data", "[", "'abstract'", "]", "=", "(", "bool", ")", "$", "matches", "[", "1", "]", ";", "$", "data", "[", "'final'", "]", "=", "(", "bool", ")", "$", "matches", "[", "2", "]", ";", "$", "data", "[", "'type'", "]", "=", "$", "matches", "[", "3", "]", ";", "$", "data", "[", "'name'", "]", "=", "$", "matches", "[", "4", "]", ";", "$", "data", "[", "'extends'", "]", "=", "isset", "(", "$", "matches", "[", "5", "]", ")", "?", "$", "matches", "[", "6", "]", ":", "NULL", ";", "if", "(", "isset", "(", "$", "matches", "[", "7", "]", ")", ")", "foreach", "(", "array_slice", "(", "$", "matches", ",", "8", ")", "as", "$", "match", ")", "if", "(", "trim", "(", "$", "match", ")", "&&", "!", "preg_match", "(", "\"@^,|{@\"", ",", "trim", "(", "$", "match", ")", ")", ")", "$", "data", "[", "'implements'", "]", "[", "]", "=", "trim", "(", "$", "match", ")", ";", "if", "(", "$", "openBlocks", ")", "$", "this", "->", "overwriteCodeDataWithDocData", "(", "$", "data", ",", "array_pop", "(", "$", "openBlocks", ")", ")", ";", "return", "$", "data", ";", "}" ]
Parses a Class Signature and returns Array of collected Information. @access private @param array $data Class Data so far @param array $matches Matches of RegEx @param array $openBlocks Doc Blocks opened before @return array
[ "Parses", "a", "Class", "Signature", "and", "returns", "Array", "of", "collected", "Information", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Parser/Array.php#L171-L185
36,994
CeusMedia/Common
src/FS/File/PHP/Parser/Array.php
FS_File_PHP_Parser_Array.parseMethod
private function parseMethod( $matches, &$openBlocks ) { $method = $this->methodData; $method['name'] = $matches[5]; $method['access'] = trim( $matches[3] ); $method['abstract'] = (bool) $matches[1]; $method['final'] = (bool) $matches[2]; $method['static'] = (bool) $matches[4]; if( trim( $matches[6] ) ) { $paramList = array(); foreach( explode( ",", $matches[6] ) as $param ) { $param = trim( $param ); if( !preg_match( $this->regexParam, $param, $matches ) ) continue; $param = array( 'cast' => $matches[2], 'reference' => $matches[4] ? TRUE : FALSE, 'name' => $matches[5], ); if( isset( $matches[6] ) ) $param['default'] = $matches[7]; $method['param'][$matches[5]] = $param; } } if( $openBlocks ) { $methodBlock = array_pop( $openBlocks ); $this->overwriteCodeDataWithDocData( $method, $methodBlock ); $openBlocks = array(); } if( !$method['access'] ) $method['access'] = "public"; return $method; }
php
private function parseMethod( $matches, &$openBlocks ) { $method = $this->methodData; $method['name'] = $matches[5]; $method['access'] = trim( $matches[3] ); $method['abstract'] = (bool) $matches[1]; $method['final'] = (bool) $matches[2]; $method['static'] = (bool) $matches[4]; if( trim( $matches[6] ) ) { $paramList = array(); foreach( explode( ",", $matches[6] ) as $param ) { $param = trim( $param ); if( !preg_match( $this->regexParam, $param, $matches ) ) continue; $param = array( 'cast' => $matches[2], 'reference' => $matches[4] ? TRUE : FALSE, 'name' => $matches[5], ); if( isset( $matches[6] ) ) $param['default'] = $matches[7]; $method['param'][$matches[5]] = $param; } } if( $openBlocks ) { $methodBlock = array_pop( $openBlocks ); $this->overwriteCodeDataWithDocData( $method, $methodBlock ); $openBlocks = array(); } if( !$method['access'] ) $method['access'] = "public"; return $method; }
[ "private", "function", "parseMethod", "(", "$", "matches", ",", "&", "$", "openBlocks", ")", "{", "$", "method", "=", "$", "this", "->", "methodData", ";", "$", "method", "[", "'name'", "]", "=", "$", "matches", "[", "5", "]", ";", "$", "method", "[", "'access'", "]", "=", "trim", "(", "$", "matches", "[", "3", "]", ")", ";", "$", "method", "[", "'abstract'", "]", "=", "(", "bool", ")", "$", "matches", "[", "1", "]", ";", "$", "method", "[", "'final'", "]", "=", "(", "bool", ")", "$", "matches", "[", "2", "]", ";", "$", "method", "[", "'static'", "]", "=", "(", "bool", ")", "$", "matches", "[", "4", "]", ";", "if", "(", "trim", "(", "$", "matches", "[", "6", "]", ")", ")", "{", "$", "paramList", "=", "array", "(", ")", ";", "foreach", "(", "explode", "(", "\",\"", ",", "$", "matches", "[", "6", "]", ")", "as", "$", "param", ")", "{", "$", "param", "=", "trim", "(", "$", "param", ")", ";", "if", "(", "!", "preg_match", "(", "$", "this", "->", "regexParam", ",", "$", "param", ",", "$", "matches", ")", ")", "continue", ";", "$", "param", "=", "array", "(", "'cast'", "=>", "$", "matches", "[", "2", "]", ",", "'reference'", "=>", "$", "matches", "[", "4", "]", "?", "TRUE", ":", "FALSE", ",", "'name'", "=>", "$", "matches", "[", "5", "]", ",", ")", ";", "if", "(", "isset", "(", "$", "matches", "[", "6", "]", ")", ")", "$", "param", "[", "'default'", "]", "=", "$", "matches", "[", "7", "]", ";", "$", "method", "[", "'param'", "]", "[", "$", "matches", "[", "5", "]", "]", "=", "$", "param", ";", "}", "}", "if", "(", "$", "openBlocks", ")", "{", "$", "methodBlock", "=", "array_pop", "(", "$", "openBlocks", ")", ";", "$", "this", "->", "overwriteCodeDataWithDocData", "(", "$", "method", ",", "$", "methodBlock", ")", ";", "$", "openBlocks", "=", "array", "(", ")", ";", "}", "if", "(", "!", "$", "method", "[", "'access'", "]", ")", "$", "method", "[", "'access'", "]", "=", "\"public\"", ";", "return", "$", "method", ";", "}" ]
Parses a Method Signature and returns Array of collected Information. @access private @param array $matches Matches of RegEx @param array $openBlocks Doc Blocks opened before @return array
[ "Parses", "a", "Method", "Signature", "and", "returns", "Array", "of", "collected", "Information", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Parser/Array.php#L421-L456
36,995
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getCount
public function getCount( $pattern = NULL ) { $count = 0; $list = $this->getList( $pattern ); foreach( $list as $entry ) $count++; return $count; }
php
public function getCount( $pattern = NULL ) { $count = 0; $list = $this->getList( $pattern ); foreach( $list as $entry ) $count++; return $count; }
[ "public", "function", "getCount", "(", "$", "pattern", "=", "NULL", ")", "{", "$", "count", "=", "0", ";", "$", "list", "=", "$", "this", "->", "getList", "(", "$", "pattern", ")", ";", "foreach", "(", "$", "list", "as", "$", "entry", ")", "$", "count", "++", ";", "return", "$", "count", ";", "}" ]
Returns Number of Files and Folders within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @return int
[ "Returns", "Number", "of", "Files", "and", "Folders", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L86-L93
36,996
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getFileCount
public function getFileCount( $pattern = NULL ) { $count = 0; foreach( $this->getFileList( $pattern ) as $entry ) $count++; return $count; }
php
public function getFileCount( $pattern = NULL ) { $count = 0; foreach( $this->getFileList( $pattern ) as $entry ) $count++; return $count; }
[ "public", "function", "getFileCount", "(", "$", "pattern", "=", "NULL", ")", "{", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "getFileList", "(", "$", "pattern", ")", "as", "$", "entry", ")", "$", "count", "++", ";", "return", "$", "count", ";", "}" ]
Returns Number of Files within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @return int
[ "Returns", "Number", "of", "Files", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L101-L107
36,997
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getFileListByExtensions
public function getFileListByExtensions( $extensions ) { $lister = new FS_Folder_Lister( $this->folderName ); $lister->setExtensions( $extensions ); $lister->showFolders( FALSE ); return $lister->getList(); }
php
public function getFileListByExtensions( $extensions ) { $lister = new FS_Folder_Lister( $this->folderName ); $lister->setExtensions( $extensions ); $lister->showFolders( FALSE ); return $lister->getList(); }
[ "public", "function", "getFileListByExtensions", "(", "$", "extensions", ")", "{", "$", "lister", "=", "new", "FS_Folder_Lister", "(", "$", "this", "->", "folderName", ")", ";", "$", "lister", "->", "setExtensions", "(", "$", "extensions", ")", ";", "$", "lister", "->", "showFolders", "(", "FALSE", ")", ";", "return", "$", "lister", "->", "getList", "(", ")", ";", "}" ]
Get List of Files with specified Extensions within current Folder. @access public @param array $extension List of allowed Extensions @return FilterIterator
[ "Get", "List", "of", "Files", "with", "specified", "Extensions", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L126-L132
36,998
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getFolderCount
public function getFolderCount( $pattern = NULL ) { $count = 0; foreach( $this->getFolderList( $pattern ) as $entry ) $count++; return $count; }
php
public function getFolderCount( $pattern = NULL ) { $count = 0; foreach( $this->getFolderList( $pattern ) as $entry ) $count++; return $count; }
[ "public", "function", "getFolderCount", "(", "$", "pattern", "=", "NULL", ")", "{", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "getFolderList", "(", "$", "pattern", ")", "as", "$", "entry", ")", "$", "count", "++", ";", "return", "$", "count", ";", "}" ]
Returns Number of Folders within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @return int
[ "Returns", "Number", "of", "Folders", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L140-L146
36,999
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getNestedCount
public function getNestedCount( $pattern = NULL ) { $count = 0; foreach( $this->getNestedList( $pattern ) as $entry ) $count++; return $count; }
php
public function getNestedCount( $pattern = NULL ) { $count = 0; foreach( $this->getNestedList( $pattern ) as $entry ) $count++; return $count; }
[ "public", "function", "getNestedCount", "(", "$", "pattern", "=", "NULL", ")", "{", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "getNestedList", "(", "$", "pattern", ")", "as", "$", "entry", ")", "$", "count", "++", ";", "return", "$", "count", ";", "}" ]
Returns Number of all nested Files and Folders within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @return int
[ "Returns", "Number", "of", "all", "nested", "Files", "and", "Folders", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L196-L202