#3 docu page, fixed errorhandler & page interfaces
This commit is contained in:
parent
f2d7596be5
commit
65155aa4fc
@ -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);
|
||||
}
|
||||
@ -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
|
||||
*
|
||||
|
||||
@ -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
|
||||
*
|
||||
|
||||
38
page/DefaultPage.php
Normal file
38
page/DefaultPage.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\PAGE
|
||||
*/
|
||||
namespace SYSTEM\PAGE;
|
||||
|
||||
/**
|
||||
* DefaultPage Interface provided by System to describe default page functions.
|
||||
*/
|
||||
interface DefaultPage {
|
||||
/**
|
||||
* Html content of the page
|
||||
*
|
||||
* @return string Returns html of the page.
|
||||
*/
|
||||
public function html();
|
||||
|
||||
/**
|
||||
* Js files to be loaded for this page
|
||||
*
|
||||
* @return array Returns array with filepaths of js to be loaded.
|
||||
*/
|
||||
public static function js();
|
||||
|
||||
/**
|
||||
* Css files to be loaded for this page
|
||||
*
|
||||
* @return array Returns array with filepaths of css to be loaded.
|
||||
*/
|
||||
public static function css();
|
||||
}
|
||||
@ -1,11 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\PAGE
|
||||
*/
|
||||
namespace SYSTEM\PAGE;
|
||||
|
||||
abstract class Page {
|
||||
abstract public function html();
|
||||
//abstract public function js();
|
||||
//abstract public function css();
|
||||
//abstract public function title();
|
||||
//abstract public function meta();
|
||||
/**
|
||||
* Page Interface provided by System to describe page functions.
|
||||
*/
|
||||
interface Page {
|
||||
/**
|
||||
* Html content of the page
|
||||
*
|
||||
* @return string Returns html of the page.
|
||||
*/
|
||||
public function html();
|
||||
|
||||
/**
|
||||
* Js files to be loaded for this page
|
||||
*
|
||||
* @return array Returns array with filepaths of js to be loaded.
|
||||
*/
|
||||
public static function js();
|
||||
|
||||
/**
|
||||
* Css files to be loaded for this page
|
||||
*
|
||||
* @return array Returns array with filepaths of css to be loaded.
|
||||
*/
|
||||
public static function css();
|
||||
|
||||
/**
|
||||
* Tile of the page
|
||||
*
|
||||
* @return string Returns the title for the page.
|
||||
*/
|
||||
public static function title();
|
||||
|
||||
/**
|
||||
* Meta of the page
|
||||
* Array Key is used as Meta to be written. The string is Split by the last
|
||||
* "_". meta_samplepage_description will resolve to meta['description']
|
||||
*
|
||||
* @return array Returns array with metastrings for the page.
|
||||
*/
|
||||
public static function meta();
|
||||
}
|
||||
105
page/ParensParser.php
Normal file
105
page/ParensParser.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\PAGE
|
||||
*/
|
||||
namespace SYSTEM\PAGE;
|
||||
|
||||
/**
|
||||
* ParensParser Class provided by System to parse Statestring.
|
||||
*/
|
||||
class ParensParser
|
||||
{
|
||||
/** something to keep track of parens nesting */
|
||||
protected $stack = null;
|
||||
/** current level */
|
||||
protected $current = null;
|
||||
/** input string to parse */
|
||||
protected $string = null;
|
||||
/** current character offset in string */
|
||||
protected $position = null;
|
||||
/** start of text-buffer */
|
||||
protected $buffer_start = null;
|
||||
|
||||
/**
|
||||
* Parse the given string and split by () brackets and |
|
||||
*
|
||||
* @param string $string String to be parsed
|
||||
* @return array Returns array with split strings.
|
||||
*/
|
||||
public function parse($string)
|
||||
{
|
||||
if (!$string) {
|
||||
// no string, no data
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($string[0] == '(') {
|
||||
// killer outer parens, as they're unnecessary
|
||||
$string = substr($string, 1, -1);
|
||||
}
|
||||
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
}
|
||||
125
page/State.php
125
page/State.php
@ -1,6 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\PAGE
|
||||
*/
|
||||
namespace SYSTEM\PAGE;
|
||||
|
||||
/**
|
||||
* State Class provided by System to get State information.
|
||||
*/
|
||||
class State {
|
||||
/**
|
||||
* Get a State
|
||||
*
|
||||
* @param int $group Group ID of the State requested.
|
||||
* @param string $state Name of the state(including all substates and params.
|
||||
* @param bool $returnasjson Return the result as Json or Array
|
||||
* @return json Returns JSON or array with stateinfos.
|
||||
*/
|
||||
public static function get($group,$state,$returnasjson=true){
|
||||
//seperate state from vars
|
||||
$state_vars = \explode(';', $state);
|
||||
@ -60,9 +82,26 @@ class State {
|
||||
}
|
||||
return $returnasjson ? \SYSTEM\LOG\JsonResult::toString($result) : $result;
|
||||
}
|
||||
public static function parse_substate($substate){
|
||||
return (new ParensParser())->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;$i<count($substate);$i++){
|
||||
if($row['name'] == $state_name){
|
||||
@ -78,84 +117,4 @@ class State {
|
||||
}
|
||||
return $row['type'] == 0 ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
class ParensParser
|
||||
{
|
||||
// something to keep track of parens nesting
|
||||
protected $stack = null;
|
||||
// current level
|
||||
protected $current = null;
|
||||
|
||||
// input string to parse
|
||||
protected $string = null;
|
||||
// current character offset in string
|
||||
protected $position = null;
|
||||
// start of text-buffer
|
||||
protected $buffer_start = null;
|
||||
|
||||
public function parse($string)
|
||||
{
|
||||
if (!$string) {
|
||||
// no string, no data
|
||||
return array();
|
||||
}
|
||||
|
||||
if ($string[0] == '(') {
|
||||
// killer outer parens, as they're unnecessary
|
||||
$string = substr($string, 1, -1);
|
||||
}
|
||||
|
||||
$this->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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get all State Data for given group and statename
|
||||
*/
|
||||
class SYS_PAGE_GROUP extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pgsql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to delete a text by id and language
|
||||
*/
|
||||
class SYS_TEXT_DELETE extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to delete tags of a certain text
|
||||
*/
|
||||
class SYS_TEXT_DELETE_TAGS extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get a text by id and language
|
||||
*/
|
||||
class SYS_TEXT_GET_ID extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pgsql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get advanced result for a text by id and language
|
||||
*/
|
||||
class SYS_TEXT_GET_ID_ADV extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get amount of texts by id
|
||||
*/
|
||||
class SYS_TEXT_GET_ID_COUNT extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get tags of text by id
|
||||
*/
|
||||
class SYS_TEXT_GET_ID_TAGS extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pgsql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get latest texts by tag and limit
|
||||
*/
|
||||
class SYS_TEXT_GET_LATEST extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get texts by tag and language
|
||||
*/
|
||||
class SYS_TEXT_GET_TAG extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pgsql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get tags by textid and limit
|
||||
*/
|
||||
class SYS_TEXT_GET_TAGS extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function pgsql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to get text and tags including usernames by tag and language
|
||||
*/
|
||||
class SYS_TEXT_GET_TAG_ADV extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to rename a text
|
||||
*/
|
||||
class SYS_TEXT_RENAME extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to rename tags-text-id of a text
|
||||
*/
|
||||
class SYS_TEXT_RENAME_TAGS extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to save a text
|
||||
*/
|
||||
class SYS_TEXT_SAVE extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to save a tag for a text
|
||||
*/
|
||||
class SYS_TEXT_SAVE_TAG extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\SQL
|
||||
*/
|
||||
namespace SYSTEM\SQL;
|
||||
|
||||
/**
|
||||
* QQ to search for texts with tag and given searchstring
|
||||
*/
|
||||
class SYS_TEXT_SEARCH_TAG extends \SYSTEM\DB\QP {
|
||||
public static function get_class(){return \get_class();}
|
||||
public static function mysql(){return
|
||||
|
||||
@ -1,6 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\PAGE
|
||||
*/
|
||||
namespace SYSTEM\PAGE;
|
||||
|
||||
/**
|
||||
* Replace Class provided by System to replace placeholders in text and files ${placeholder}.
|
||||
*/
|
||||
class replace {
|
||||
/**
|
||||
* Replace all placeholders in a text.
|
||||
* 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 $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);}
|
||||
}
|
||||
@ -1,10 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* System - PHP Framework
|
||||
*
|
||||
* PHP Version 5.6
|
||||
*
|
||||
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link https://github.com/webcraftmedia/system
|
||||
* @package SYSTEM\PAGE
|
||||
*/
|
||||
namespace SYSTEM\PAGE;
|
||||
|
||||
/**
|
||||
* Text Class provided by System to get Texts from the Database.
|
||||
*/
|
||||
class text {
|
||||
/** Entry of a new text temporary used */
|
||||
const NEW_ENTRY = 'new_text_entry';
|
||||
|
||||
/**
|
||||
* Get the tags of a textid
|
||||
*
|
||||
* @param string $id textid to be checked upon
|
||||
* @return array Returns array with tags for that textid.
|
||||
*/
|
||||
public static function id_tags($id){
|
||||
return \SYSTEM\SQL\SYS_TEXT_GET_ID_TAGS::QA(array($id));}
|
||||
//return all text values with certain tag and lang - array(id => 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;}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace SYSTEM\SAI;
|
||||
class default_page extends \SYSTEM\PAGE\Page {
|
||||
class default_page implements \SYSTEM\PAGE\DefaultPage {
|
||||
private static function menu_sys(){
|
||||
$result = '';
|
||||
$mods = \SYSTEM\SAI\sai::getSysModules();
|
||||
@ -30,7 +30,7 @@ class default_page extends \SYSTEM\PAGE\Page {
|
||||
return \call_user_func(array($mod, 'html_li_menu'));}
|
||||
throw new \SYSTEM\LOG\ERROR('Your SAI-Start-Module haz a Problem - either it does not exist or it is not public - which is required!');}
|
||||
|
||||
private static function css(){
|
||||
public static function css(){
|
||||
return \SYSTEM\HTML\html::link(\LIB\lib_bootstrap::css()->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()).
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
namespace SYSTEM\SAI;
|
||||
class saigui extends \SYSTEM\PAGE\Page {
|
||||
class saigui {
|
||||
const SAI_MOD_POSTFIELD = 'sai_mod';
|
||||
|
||||
public function html(){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user