diff --git a/log/error_handler/error_handler.php b/log/error_handler/error_handler.php index 70e03ea..9e7c81e 100644 --- a/log/error_handler/error_handler.php +++ b/log/error_handler/error_handler.php @@ -12,9 +12,9 @@ namespace SYSTEM\LOG; /** - * Error handler Class provided by System to derive your own loghandlers from. + * Error handler Interface provided by System to derive your own loghandlers from. */ -class error_handler { +interface error_handler { /** * Call function to handle exceptions * @@ -22,5 +22,5 @@ class error_handler { * @param bool $thrown Was the Exception thrown? * @return bool Returns true or false. */ - public static function CALL(\Exception $E, $thrown){} + static function CALL(\Exception $E, $thrown); } \ No newline at end of file diff --git a/log/error_handler/error_handler_dbwriter.php b/log/error_handler/error_handler_dbwriter.php index b78d31f..dff752f 100644 --- a/log/error_handler/error_handler_dbwriter.php +++ b/log/error_handler/error_handler_dbwriter.php @@ -15,7 +15,7 @@ namespace SYSTEM\LOG; * Error handler Class provided by System to log to the database. * Register this before every other handler, cuz this will need to handle every single error. */ -class error_handler_dbwriter extends \SYSTEM\LOG\error_handler { +class error_handler_dbwriter implements \SYSTEM\LOG\error_handler { /** * Call function to handle exceptions * diff --git a/log/error_handler/error_handler_jsonoutput.php b/log/error_handler/error_handler_jsonoutput.php index 98f236e..acbe324 100644 --- a/log/error_handler/error_handler_jsonoutput.php +++ b/log/error_handler/error_handler_jsonoutput.php @@ -15,7 +15,7 @@ namespace SYSTEM\LOG; * Error handler Class provided by System to return the Error as JSON. * Register this Handler as last one */ -class error_handler_jsonoutput extends \SYSTEM\LOG\error_handler { +class error_handler_jsonoutput implements \SYSTEM\LOG\error_handler { /** * Call function to handle exceptions * diff --git a/page/DefaultPage.php b/page/DefaultPage.php new file mode 100644 index 0000000..a4d6ec7 --- /dev/null +++ b/page/DefaultPage.php @@ -0,0 +1,38 @@ +current = array(); + $this->stack = array(); + + $this->string = $string; + $this->length = strlen($this->string); + // look at each character + for ($this->position=0; $this->position < $this->length; $this->position++) { + switch ($this->string[$this->position]) { + case '(': + $this->push(); + // push current scope to the stack an begin a new scope + array_push($this->stack, $this->current); + $this->current = array(); + break; + + case ')': + $this->push(); + // save current scope + $t = $this->current; + // get the last scope from stack + $this->current = array_pop($this->stack); + // add just saved scope to current scope + $this->current[count($this->current)-1]['sub'] = $t; + break; + case '|': + // make each word its own token + $this->push(); + break; + default: + // remember the offset to do a string capture later + // could've also done $buffer .= $string[$position] + // but that would just be wasting resources… + if ($this->buffer_start === null) { + $this->buffer_start = $this->position; + } + } + } + $this->push(); + return $this->current; + } + + /** + * Internal Function to push onto the stack + * + * @return null Returns null. + */ + protected function push() + { + if ($this->buffer_start !== null) { + // extract string from buffer start to current position + $buffer = substr($this->string, $this->buffer_start, $this->position - $this->buffer_start); + // clean buffer + $this->buffer_start = null; + // throw token into current scope + $this->current[] = array('name' => $buffer); + } + } +} \ No newline at end of file diff --git a/page/State.php b/page/State.php index 50b3408..099f949 100644 --- a/page/State.php +++ b/page/State.php @@ -1,6 +1,28 @@ parse($substate); - } + + /** + * Get Substates out of State string + * + * @param string $substate Substate string. + * @return array Returns array with substates. + */ + private static function parse_substate($substate){ + return (new \SYSTEM\PAGE\ParensParser())->parse($substate);} + + /** + * Is the substate loaded alrdy(for result set) + * (recursive) + * + * @param array $row Substate Database row. + * @param array $substate Array with substates + * @param string $state_name Name of the main state + * @param int $parent_id Id of parent + * @return bool Returns true or false. + */ private static function is_loaded($row,&$substate,$state_name,$parent_id = -1){ for($i=0;$icurrent = array(); - $this->stack = array(); - - $this->string = $string; - $this->length = strlen($this->string); - // look at each character - for ($this->position=0; $this->position < $this->length; $this->position++) { - switch ($this->string[$this->position]) { - case '(': - $this->push(); - // push current scope to the stack an begin a new scope - array_push($this->stack, $this->current); - $this->current = array(); - break; - - case ')': - $this->push(); - // save current scope - $t = $this->current; - // get the last scope from stack - $this->current = array_pop($this->stack); - // add just saved scope to current scope - $this->current[count($this->current)-1]['sub'] = $t; - break; - case '|': - // make each word its own token - $this->push(); - break; - default: - // remember the offset to do a string capture later - // could've also done $buffer .= $string[$position] - // but that would just be wasting resources… - if ($this->buffer_start === null) { - $this->buffer_start = $this->position; - } - } - } - $this->push(); - return $this->current; - } - - protected function push() - { - if ($this->buffer_start !== null) { - // extract string from buffer start to current position - $buffer = substr($this->string, $this->buffer_start, $this->position - $this->buffer_start); - // clean buffer - $this->buffer_start = null; - // throw token into current scope - $this->current[] = array('name' => $buffer); - } - } } \ No newline at end of file diff --git a/page/qq/SYS_PAGE_GROUP.php b/page/qq/SYS_PAGE_GROUP.php index ac059f9..3e4d1ca 100644 --- a/page/qq/SYS_PAGE_GROUP.php +++ b/page/qq/SYS_PAGE_GROUP.php @@ -1,5 +1,19 @@ 'test') + * resolves to: "Text test" + * + * @param string $text text to be subject of replacements + * @param array $vars Array with Placeholders. + * @return string Returns string of the text with replaced placeholder. + */ public static function replace($text, $vars = array()){ if(!$vars){ $vars = array();} @@ -14,11 +41,30 @@ class replace { } return @preg_replace($search, $replace, $text); } + /** + * Replace all placeholders in a file. + * Array Key of Placeholders represents the name of the placeholder. + * The value to the key is filled in. + * + * "Text ${textplaceholder}" + * array('textplaceholder' => 'test') + * resolves to: "Text test" + * + * @param string $path Filepath of file to be subject of replacements + * @param array $vars Array with Placeholders. + * @return string Returns string of the text with replaced placeholder. + */ public static function replaceFile($path, $vars = array()){ $buffer = file_get_contents($path); return self::replace($buffer, $vars);} - //removes all Variable Handles + /** + * Replace all placeholders in a text with null. + * Effectively removing all Placeholders + * + * @param string $text text to be subject of replacements + * @return string Returns string of the text with all placeholders removed. + */ public static function clean($text){ return preg_replace('/\${.*?}/', '', $text);} } \ No newline at end of file diff --git a/page/text.php b/page/text.php index 19c5031..c13d84e 100644 --- a/page/text.php +++ b/page/text.php @@ -1,10 +1,40 @@ text) + + /** + * Get the texts with certain tag and language + * + * @param string $tag tag to be checked upon + * @param string $lang Language for the requested texts + * @param bool $fallback Fallback to default language if certain id is not found for the specified language. + * @return array Returns array with texts for requested tag. + */ public static function tag($tag, $lang = NULL,$fallback = true) { if($lang == NULL){ $lang = \SYSTEM\locale::get();} @@ -28,6 +58,15 @@ class text { } return $result; } + + /** + * Get the texts with certain tag and language plus creation user info etc + * + * @param string $tag tag to be checked upon + * @param string $lang Language for the requested texts + * @param bool $fallback Fallback to default language if certain id is not found for the specified language. + * @return array Returns array with texts for requested tag including usernames etc for the texts + */ public static function tag_adv($tag, $lang = NULL,$fallback = true) { if($lang == NULL){ $lang = \SYSTEM\locale::get();} @@ -51,7 +90,14 @@ class text { } return $result; } - //return textstring with certain id and lang + /** + * Get a text with certain id and language + * + * @param string $id Id of the text requested + * @param string $lang Language for the requested text + * @param bool $fallback Fallback to default language if textid is not found for the specified language. + * @return string Returns the text if found empty string if not. + */ public static function get($id, $lang = NULL,$fallback = true) { if($lang == NULL){ $lang = \SYSTEM\locale::get();} @@ -65,6 +111,15 @@ class text { return self::get($id, \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG));} return $res ? $res['text'] : ''; } + + /** + * Get a text with certain id and language plus creation user info etc + * + * @param string $id Id of the text requested + * @param string $lang Language for the requested text + * @param bool $fallback Fallback to default language if textid is not found for the specified language. + * @return Databaseresult Returns Database Result to loop over. + */ public static function get_adv($id, $lang = NULL,$fallback = true) { if($lang == NULL){ $lang = \SYSTEM\locale::get();} @@ -78,16 +133,49 @@ class text { return self::get_adv($id, \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_DEFAULT_LANG));} return $res; } + + /** + * Get a tags of a text with certain id and limit the results + * + * @param string $id Id of the text requested + * @param int $limit Amount of Tags to be requested + * @return array Returns array with tags for given text id + */ public static function get_tags($id,$limit){ return \SYSTEM\SQL\SYS_TEXT_GET_TAGS::QA(array($id,$limit));} + /** + * Get latest texts from database by tag and limit + * + * @param string $tag Id of the tag requested + * @param int $limit Amount of Texts to be requested + * @return array Returns array with texts for given tag ordered by time + */ public static function get_latest($tag, $limit){ return \SYSTEM\SQL\SYS_TEXT_GET_LATEST::QA(array($tag, $limit)); } + + /** + * Search with content of texts with given tag + * + * @param string $search Searchstring "%" are added inside + * @param string $tag Search only texts with given tag + * @return array Returns array with texts for given searchstring and tag + */ public static function search($search,$tag/*=null*/){ $search = '%'.$search.'%'; return \SYSTEM\SQL\SYS_TEXT_SEARCH_TAG::QA(array($tag,$search,$search,$search));} + /** + * Save a text into the Database. Works like rename + * + * @param string $id Id of the text + * @param string $new_id New Id of the text + * @param string $lang Language of the text + * @param array $tags Array with tags for that text + * @param string $text Text to be saved + * @return bool Returns true or false + */ public static function save($id, $new_id, $lang, $tags, $text){ if($new_id == self::NEW_ENTRY){ return false;} @@ -105,6 +193,13 @@ class text { return true; } + /** + * Delete a text from the Database. + * + * @param string $id Id of the text + * @param string $lang Language of the text + * @return bool Returns true or false + */ public static function delete($id, $lang = null){ if(!\SYSTEM\SQL\SYS_TEXT_DELETE::QI(array($id,$lang))){ return false;} diff --git a/sai/page/default_page.php b/sai/page/default_page.php index 6ecc663..ece2490 100644 --- a/sai/page/default_page.php +++ b/sai/page/default_page.php @@ -1,6 +1,6 @@ WEBPATH(false)). \SYSTEM\HTML\html::link(\LIB\lib_tablesorter::css()->WEBPATH(false)). \SYSTEM\HTML\html::link(\SYSTEM\CACHE\cache_css::url( @@ -39,7 +39,7 @@ class default_page extends \SYSTEM\PAGE\Page { new \SYSTEM\PSAI('page/css/sai.css')))); } - private static function js(){ + public static function js(){ return \SYSTEM\HTML\html::script(\LIB\lib_jquery::js()->WEBPATH()). \SYSTEM\HTML\html::script(\LIB\lib_bootstrap::js()->WEBPATH()). \SYSTEM\HTML\html::script(\LIB\lib_tablesorter::js()->WEBPATH()). diff --git a/sai/sai/saigui.php b/sai/sai/saigui.php index d8d8197..5f1190a 100644 --- a/sai/sai/saigui.php +++ b/sai/sai/saigui.php @@ -1,6 +1,6 @@