Пример #1
0
 public static function total($user_id, $total)
 {
     $database = Framework\Registry::get("database");
     $totalPoints = $database->query()->from("points", array("SUM(unit)" => "points"))->where("user_id=?", $user_id)->all();
     $points = isset($totalPoints[0]["points"]) ? round($totalPoints[0]["points"]) : 0;
     return $points > $total ? $total : $points;
 }
Пример #2
0
 public function sync($model)
 {
     $this->willRenderLayoutView = false;
     $this->willRenderActionView = false;
     $db = Framework\Registry::get("database");
     $db->sync(new $model());
 }
Пример #3
0
 function check_login()
 {
     $session = Framework\Registry::get('session');
     if ($session->get('user_id') != null) {
         return true;
     } else {
         return false;
     }
 }
Пример #4
0
 function base_url($uri = '')
 {
     $config = Framework\Registry::get('config');
     $config = $config->parse('constant');
     $url = $config['constant']['base_url'];
     $url = rtrim($url, '/');
     $uri = trim($uri, '/');
     return $url . '/' . $uri;
 }
Пример #5
0
 public function index()
 {
     $this->getLayoutView()->set("seo", Framework\Registry::get("seo"));
     $view = $this->getActionView();
     $limit = RequestMethods::get("limit", 10);
     $page = RequestMethods::get("page", 1);
     $items = Campaign::all(array("live = ?" => true), array("id", "live", "image", "title", "description"), "created", "desc", $limit, $page);
     $count = Campaign::count(array("live = ?" => true));
     $view->set("items", $items)->set("count", $count)->set("limit", $limit)->set("page", $page);
 }
Пример #6
0
 function set_value($field = '', $default = '')
 {
     $input = Framework\Registry::get('input');
     if (!empty($input->post($field))) {
         $str = $input->post($field);
     } else {
         $str = $default;
     }
     $str = htmlspecialchars($str);
     return $str;
 }
Пример #7
0
    unset($cache);
    unset($session);
    unset($router);
    unset($httpRequest);
} catch (Exception $e) {
    // list exceptions
    $exceptions = array("500" => array("Framework\\Cache\\Exception", "Framework\\Cache\\Exception\\Argument", "Framework\\Cache\\Exception\\Implementation", "Framework\\Cache\\Exception\\Service", "Framework\\Configuration\\Exception", "Framework\\Configuration\\Exception\\Argument", "Framework\\Configuration\\Exception\\Implementation", "Framework\\Configuration\\Exception\\Syntax", "Framework\\Controller\\Exception", "Framework\\Controller\\Exception\\Argument", "Framework\\Controller\\Exception\\Implementation", "Framework\\Core\\Exception", "Framework\\Core\\Exception\\Argument", "Framework\\Core\\Exception\\Implementation", "Framework\\Core\\Exception\\Property", "Framework\\Core\\Exception\\ReadOnly", "Framework\\Core\\Exception\\WriteOnly", "Framework\\Database\\Exception", "Framework\\Database\\Exception\\Argument", "Framework\\Database\\Exception\\Implementation", "Framework\\Database\\Exception\\Service", "Framework\\Database\\Exception\\Sql", "Framework\\Model\\Exception", "Framework\\Model\\Exception\\Argument", "Framework\\Model\\Exception\\Connector", "Framework\\Model\\Exception\\Implementation", "Framework\\Model\\Exception\\Primary", "Framework\\Model\\Exception\\Type", "Framework\\Model\\Exception\\Validation", "Framework\\Request\\Exception", "Framework\\Request\\Exception\\Argument", "Framework\\Request\\Exception\\Implementation", "Framework\\Request\\Exception\\Response", "Framework\\Router\\Exception", "Framework\\Router\\Exception\\Argument", "Framework\\Router\\Exception\\Implementation", "Framework\\Session\\Exception", "Framework\\Session\\Exception\\Argument", "Framework\\Session\\Exception\\Implementation", "Framework\\Template\\Exception", "Framework\\Template\\Exception\\Argument", "Framework\\Template\\Exception\\Implementation", "Framework\\Template\\Exception\\Parser", "Framework\\View\\Exception", "Framework\\View\\Exception\\Argument", "Framework\\View\\Exception\\Data", "Framework\\View\\Exception\\Implementation", "Framework\\View\\Exception\\Renderer", "Framework\\View\\Exception\\Syntax"), "404" => array("Framework\\Router\\Exception\\Action", "Framework\\Router\\Exception\\Controller"));
    $exception = get_class($e);
    // attempt to find the approapriate template, and render
    foreach ($exceptions as $template => $classes) {
        foreach ($classes as $class) {
            if ($class == $exception) {
                if ($template == '404') {
                    Framework\Registry::get('httpRequest')->setResponseCode(\Framework\HttpRequest::HTTP_RESPONSE_NOT_FOUND)->createRequestHeader();
                } else {
                    Framework\Registry::get('httpRequest')->setResponseCode(\Framework\HttpRequest::HTTP_RESPONSE_INTERNAL_SERVER_ERROR)->createRequestHeader();
                }
                if (isset($logger_error)) {
                    $logger_error->log("[Exception] Code:" . $e->getCode() . ' Message:' . $e->getMessage());
                }
                include APP_PATH . "/application/views/errors/{$template}.php";
                exit;
            }
        }
    }
    // render fallback template
    if (isset($logger_error)) {
        $logger_error->log("[Exception] Code:" . $e->getCode() . ' Message' . $e->getMessage());
    }
    echo "An error occurred." . $e->getMessage();
    include APP_PATH . "/application/views/errors/error.php";
Пример #8
0
 public function index()
 {
     $this->getLayoutView()->set("seo", Framework\Registry::get("seo"));
 }
Пример #9
0
$config = new Framework\Config(array('type' => 'ini'));
Framework\Registry::set('config', $config->initialize());
unset($config);
// load functions
$functions = new Framework\Functions();
Framework\Registry::set('functions', $functions->initialize());
unset($functions);
// load session
$session = new Framework\Session();
Framework\Registry::set('session', $session);
unset($session);
// load cookie
$cookie = new Framework\Cookie();
Framework\Registry::set('cookie', $cookie);
unset($cookie);
$input = new Framework\Input();
Framework\Registry::set('input', $input);
unset($input);
$validator = new Framework\Validator();
Framework\Registry::set('validator', $validator);
unset($validator);
// load database
$database = new Framework\Database();
Framework\Registry::set('database', $database->initialize());
unset($database);
// load router
$router = new Framework\Router();
Framework\Registry::set('router', $router);
unset($router);
Framework\Registry::get('router')->dispatch();
Пример #10
0
 public function sync($model)
 {
     $this->noview();
     $db = Framework\Registry::get('database');
     $db->sync(new $model());
 }