Example #1
0
 public static function __callStatic($method, $parameters)
 {
     if (in_array($method, self::$Views)) {
         PathDriver::Using(array(PathDriver::VIEWS . $method . "/" => array($method)));
         return new $method();
     }
     return false;
 }
Example #2
0
 public static function InstallTables()
 {
     PathDriver::Using(array(PathDriver::TABLES => self::$Tables));
     $installed = array();
     foreach (self::$Tables as $value) {
         $res = (new $value())->Install();
         if ($res[0]) {
             $installed[] = $value;
         } else {
             foreach ($installed as $table) {
                 (new $table())->Drop();
             }
             return array(false, "Error in '{$value}'.");
         }
     }
     return array(true);
 }
Example #3
0
<?php

PathDriver::Using(array(PathDriver::VIEWS => array("BuilderController", "")));
/**
 * Created by PhpStorm.
 * User: bohdan
 * Date: 03.09.15
 * Time: 12:10
 */
class View
{
    private $builder;
    public function __construct($class_name)
    {
        $this->builder = new BuilderController($class_name);
    }
    public function GetBuilder()
    {
        return $this->builder;
    }
    public function GetSafeString($str)
    {
        $result = stripcslashes($str);
        $result = strip_tags($result);
        $result = htmlspecialchars($result, ENT_QUOTES);
        return $result;
    }
}
Example #4
0
<?php

PathDriver::Using(array(PathDriver::VIEWS => array("View"), PathDriver::TABLES => array("TableController"), PathDriver::DRIVERS => array("BBDriver")));
class MainView extends View
{
    public function __construct()
    {
        parent::__construct(static::class);
    }
    public function Main()
    {
        $Story = TableController::StoryTable();
        $params = array();
        $params['some1'] = "Test Work";
        $params['some2'] = "Yeah its work baby!";
        return $this->GetBuilder()->Prepare("main.html", $params);
    }
    public function Save($params)
    {
        $Story = TableController::StoryTable();
        $new_story = new stdClass();
        $new_story->TestField1 = $this->GetSafeString($_POST['Field1']);
        $new_story->TestField2 = false;
        $Story->Set($new_story);
        return $this->GetBuilder()->PrepareWithMerge("save.html", $content);
    }
}
Example #5
0
<?php

include_once "Drivers/PathDriver.php";
$configuration = (include_once "config.php");
PathDriver::Using(array(PathDriver::DRIVERS => array("RouteDriver"), PathDriver::VIEWS => array("ViewController")));
echo RouteDriver::CallRoute($_GET['path']);
Example #6
0
 public static function SetBuilder($builder)
 {
     PathDriver::Using(array(PathDriver::DATABASE => array($builder)));
     self::$builder = $builder;
 }
Example #7
0
<?php

PathDriver::Using(array(PathDriver::DATABASE => array("DBController")));
PathDriver::Using(array(PathDriver::DRIVERS => array("FormBuilder")));
class Table
{
    protected $table_name;
    function __construct($class_name)
    {
        $this->table_name = str_replace("Table", "", $class_name);
    }
    public function Get()
    {
        $builder = DBController::GetBuilder();
        $stat = new $builder($builder::T_SELECT);
        $stat->SetTableName($this->table_name);
        return DBController::SelectQuery($stat->GetParams());
    }
    public function GetFilteredList($cond)
    {
        $cond->SetTableName($this->table_name);
        return DBController::SelectQuery($cond->GetParams());
    }
    public function GetById($id)
    {
        $builder = DBController::GetBuilder();
        $stat = new $builder($builder::T_SELECT_BY_ID);
        $stat->SetTableName($this->table_name)->PutId($id);
        $result = DBController::SelectQuery($stat->GetParams());
        if (count($result) > 0) {
            return DBController::SelectQuery($stat->GetParams());
Example #8
0
<?php

PathDriver::Using(array(PathDriver::UTILITIES => array("stringparser_bbcode.class")));
/**
 * Created by PhpStorm.
 * User: bohdan
 * Date: 08.09.15
 * Time: 19:34
 */
class BBDriver
{
    private static $bbcode;
    public static function ConfigureParser()
    {
        self::$bbcode = new StringParser_BBCode();
        self::$bbcode->addFilter(STRINGPARSER_FILTER_PRE, 'convertlinebreaks');
        self::$bbcode->addParser(array('block', 'inline', 'link', 'listitem'), 'htmlspecialchars');
        self::$bbcode->addParser(array('block', 'inline', 'link', 'listitem'), 'nl2br');
        self::$bbcode->addParser('list', 'bbcode_stripcontents');
        self::$bbcode->addCode('h1', 'simple_replace', null, array('start_tag' => '<h1>', 'end_tag' => '</h1>'), 'block', array('listitem', 'block', 'link'), array());
        self::$bbcode->addCode('h2', 'simple_replace', null, array('start_tag' => '<h2>', 'end_tag' => '</h2>'), 'block', array('listitem', 'block', 'link'), array());
        self::$bbcode->addCode('h3', 'simple_replace', null, array('start_tag' => '<h3>', 'end_tag' => '</h3>'), 'block', array('listitem', 'block', 'link'), array());
        self::$bbcode->addCode('h4', 'simple_replace', null, array('start_tag' => '<h4>', 'end_tag' => '</h4>'), 'block', array('listitem', 'block', 'link'), array());
        self::$bbcode->addCode('h5', 'simple_replace', null, array('start_tag' => '<h5>', 'end_tag' => '</h5>'), 'block', array('listitem', 'block', 'link'), array());
        self::$bbcode->addCode('h6', 'simple_replace', null, array('start_tag' => '<h6>', 'end_tag' => '</h6>'), 'block', array('listitem', 'block', 'link'), array());
        self::$bbcode->setCodeFlag('h1', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
        self::$bbcode->setCodeFlag('h2', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
        self::$bbcode->setCodeFlag('h3', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
        self::$bbcode->setCodeFlag('h4', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
        self::$bbcode->setCodeFlag('h5', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
        self::$bbcode->setCodeFlag('h6', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
Example #9
0
<?php

PathDriver::Using(array(PathDriver::DATABASE => array("MysqlParamsDriver")));
class DBDriverMysql
{
    private static $mysql_client;
    public static function CreateConnection($config_file)
    {
        $servername = "";
        $username = "";
        $password = "";
        $dbname = "";
        if (file_exists(PathDriver::$ROOT_DIR . PathDriver::CONFIG . $config_file)) {
            $xml = simplexml_load_file(PathDriver::$ROOT_DIR . PathDriver::CONFIG . $config_file);
            $servername = $xml->Configuration[0]["servername"];
            $username = $xml->Configuration[0]["username"];
            $password = $xml->Configuration[0]["password"];
            $dbname = $xml->Configuration[0]["dbname"];
        } else {
            die("Configuration file doesn't exist.");
        }
        if (empty(self::$mysql_client)) {
            self::$mysql_client = new mysqli($servername, $username, $password, $dbname);
            // Check connection
            if (self::$mysql_client->connect_error) {
                die("Connection failed: " . self::$mysql_client->connect_error);
            }
        }
    }
    public static function SelectQuery($params)
    {
Example #10
0
<?php

PathDriver::Using(array(PathDriver::TABLES => array("Table")));
class TestTable extends Table
{
    function __construct()
    {
        parent::__construct(__CLASS__);
    }
}
Example #11
0
<?php

include_once "Drivers/PathDriver.php";
$configuration = (include_once "config.php");
PathDriver::Using(array(PathDriver::TABLES => array("TableController")));
$res = TableController::InstallTables();
if (!$res[0]) {
    echo $res[1];
}
Example #12
0
<?php

class PathDriver
{
    const DATABASE = "DBController/";
    const DRIVERS = "Drivers/";
    const CONFIG = "config/";
    const TABLES = "DBController/Tables/";
    const PREV_DIR = "../";
    const PHP_EXT = ".php";
    const TABLES_MODEL = "DBController/Tables/TablesJSON/";
    const VIEWS = "Views/";
    const VIEW_BUILDER = "Views/ViewBuilder/";
    const UTILITIES = "utilities/";
    public static $ROOT_DIR;
    static function Using($using_classes)
    {
        foreach ($using_classes as $dir => $classes) {
            foreach ($classes as $cls) {
                if (file_exists(self::$ROOT_DIR . $dir . $cls . self::PHP_EXT)) {
                    include_once self::$ROOT_DIR . $dir . $cls . self::PHP_EXT;
                }
            }
        }
    }
}
PathDriver::$ROOT_DIR = __DIR__ . "/" . PathDriver::PREV_DIR;
Example #13
0
 public static function SetViewBuilder($builder)
 {
     self::$view_builder_name = $builder;
     PathDriver::Using(array(PathDriver::VIEW_BUILDER => array($builder)));
 }