예제 #1
0
 /**
  *
  * @return Controller
  */
 protected function _getErrorController()
 {
     $config = Application::getConfig();
     if (class_exists($config['defaults'][self::CONFIG_KEY_ERROR_CONTROLLER_NAME])) {
         $controller = new $config['defaults'][self::CONFIG_KEY_ERROR_CONTROLLER_NAME]();
     } else {
         $controller = $this;
     }
     return $controller;
 }
 protected function getTwitterService()
 {
     if (!$this->twitterService) {
         $config = Application::getConfig();
         if (!isset($config[Twitter::CONFIG_KEY])) {
             throw new \Exception("Unable to find twitter configuration.");
         }
         $this->twitterService = new Twitter($config[Twitter::CONFIG_KEY]);
     }
     return $this->twitterService;
 }
예제 #3
0
 public static function authenticate($username, $password)
 {
     $db = Application::getDbAdapter();
     $config = Application::getConfig();
     $table = $config[self::SETUP_KEY]['table_name'];
     $username_col = $config[self::SETUP_KEY][self::IDENTITY_FIELD_KEY];
     $password_col = $config[self::SETUP_KEY][self::PASSWORD_FIELD_KEY];
     $query = "\n            SELECT {$config[self::SETUP_KEY][self::IDENTITY_ID_FIELD_KEY]} FROM {$table}\n            WHERE {$username_col} = ? AND {$password_col} = MD5(?);";
     $rowset = $db->prepareExecuteAndFetch($query, array($username, $password));
     if (count($rowset) == 1) {
         self::setAuthenticated(true, $rowset[0][$config[self::SETUP_KEY]['identity_id_field']]);
     }
 }
예제 #4
0
<?php

use Egc\Mvc\Application;
define('ROOT_PATH', realpath(dirname(__FILE__)) . '/../');
define("APPLICATION_PATH", ROOT_PATH . 'Application/');
define("LAYOUT_PATH", ROOT_PATH . 'view/layout/layout.phtml');
// Setup autoloading
require ROOT_PATH . 'init_autoloader.php';
if (session_id() == '') {
    session_start();
}
$config = array();
$config_file = ROOT_PATH . 'config/config.php';
if (file_exists($config_file)) {
    $config = (require $config_file);
}
Application::init($config);
Application::route();
Application::render();
 public function __construct()
 {
     $this->dbAdapter = Application::getDbAdapter();
 }
예제 #6
0
 public function render()
 {
     Application::disableLayoutRender(true);
     header("Content-type: application/json");
     return json_encode($this->_getVars());
 }