Пример #1
0
 public function start()
 {
     $controller_name = $this->config['default_controller'];
     $action_name = "invoke";
     if (!empty($_GET['controller'])) {
         $controller_name = $_GET['controller'];
     }
     if (!empty($_GET['action'])) {
         $action_name = $_GET['action'];
     }
     $controller_file = "controller_" . strtolower($controller_name) . '.php';
     $controller_path = "controllers/" . $controller_file;
     if (file_exists($controller_path)) {
         include "controllers/" . $controller_file;
     } else {
         Lithium::ErrorPage404();
     }
     $controller = new $controller_name();
     $action = $action_name;
     if (method_exists($controller, $action)) {
         $controller->{$action}();
     } else {
         Lithium::ErrorPage404();
     }
 }
Пример #2
0
 /**
  * Singletone instance getter
  *
  * @return Lithium
  */
 public static function getInstance()
 {
     if (null === self::$oInstance) {
         self::$oInstance = new self();
     }
     return self::$oInstance;
 }
Пример #3
0
 public static function tryCreate($sLogin)
 {
     $oLithium = Lithium::getInstance();
     $aUsers = $oLithium->getConfig('users');
     if ($aUsers == null || $aUsers[$sLogin] == null) {
         return null;
     }
     return new Model_User($sLogin, $aUsers[$sLogin]);
 }
Пример #4
0
 /**
  * Driver name getter
  *
  * @return string 	- driver name
  */
 protected function getDriverName()
 {
     // check if such driver exists
     $sDriverPath = $this->oLithium->findFile(ucfirst($this->aConfig['type']), 'Driver');
     if ($sDriverPath === false) {
         throw new Lithium_Exception_Database('database.error_driver_not_found');
     }
     return 'Driver_' . ucfirst($this->aConfig['type']);
 }
Пример #5
0
 /**
  * Return landuage strings
  * 
  * @param string $sKey - key name
  * @param array $aParams - values that will be used in language string
  * @return string
  */
 protected function getLang($sKey, $aParams = array())
 {
     // check do we have dot in key name
     if (strpos($sKey, '.') === false) {
         // add class name to searched key name
         $sKey = substr(get_class($this), 11) . '.' . $sKey;
     }
     return $this->oLithium->getLang($sKey, $aParams);
 }
Пример #6
0
 private static function loadCollection($type, $name)
 {
     $data = $type == "css" ? "<style>" : "<script>";
     $collection = Lithium::getConfiguration($type . "_libraries")[$name];
     foreach ($collection as $element) {
         $data .= file_get_contents("views/" . $element);
         $data .= PHP_EOL;
     }
     $data .= $type == "css" ? "</style>" : "</script>";
     return $data;
 }
 public function invoke()
 {
     $data = array();
     $data[0] = Lithium::isAuthComplete();
     $this->view->generate('view_main.php', 'view_template.php', $data);
 }
Пример #8
0
<?php

defined('SYSPATH') or die('No direct access!');
if (IN_PRODUCTION) {
    error_reporting(E_ALL ^ E_NOTICE);
} else {
    error_reporting(E_ALL);
}
define('EXT', '.php');
define('DOCROOT', realpath(getcwd() . DIRECTORY_SEPARATOR . SYSPATH) . DIRECTORY_SEPARATOR);
include SYSPATH . 'Lithium/Loader' . EXT;
Loader::registerAutoload();
$oLithium = Lithium::getInstance();
$oConfig = new Config($aConfig);
$oLithium->setConfig($oConfig);
$oLithium->setRouter(new Router($oConfig));
// let a magic happen :)
$oLithium->Dispatch();
// display warnings
if (!IN_PRODUCTION && !empty($aLithiumWarnings)) {
    echo implode('<br />', $aLithiumWarnings);
}
Пример #9
0
 /**
  * Lithium raiseWarrning wrapper method
  * 
  * @param string $sMessage
  * @param int $iWarningLevel
  */
 protected function raiseWarrning($sMessage, $iWarningLevel = 0)
 {
     self::$oLithium->riseWarning($sMessage, $iWarningLevel);
 }
Пример #10
0
<?php

require_once 'lithium/Lithium.php';
$lithium = Lithium::create();
$lithium->start();