setupAll(); $self->startSession(); $self->setupFrontController(); } public function setupAll() { ## set include paths $this->setIncludePath(); ## include global functions include_once( 'functions.php' ); ## init database connection $this->initDatabase(); ## define application variables require_once 'bootstrap.php'; ## init view object (Smarty) $this->initView(); MyZend_Site::usePrototype(false); MyZend_Site::addJS('jquery-1.4.4.min.js'); MyZend_Site::addJS( 'common.js' ); MyZend_Site::addCSS( 'base.css' ); MyZend_Site::addCSS( 'style.css' ); } public function setIncludePath() { set_include_path( LIBS . PATH_SEPARATOR . LIBS_EXT . PATH_SEPARATOR . CONFIGS . PATH_SEPARATOR . INCLUDES . PATH_SEPARATOR . get_include_path() ); return $this; } public function initDatabase() { ## get database config file preg_match( '~^(.*)\@~Ui', $_SERVER['SERVER_ADMIN'], $section ); $section = $section[1] != 'webmaster' ? $section[1] : 'default'; $config = new Zend_Config_Ini( 'database.ini', $section ); ######### CONNECT TO DB $db = new Zend_Db_Adapter_Pdo_Mysql( $config ); Zend_Db_Table::setDefaultAdapter($db); Zend_Db_Table_Abstract::setDefaultMetadataCache( Zend_Cache::factory('Core', 'Memcached', array('automatic_serialization' => true, 'logging' => false, 'lifetime' => 3600), array( 'servers' => array( array( 'host' => 'localhost', 'port' => 11211, 'persistent' => true, ), array( 'host' => '192.168.1.111', 'port' => 11211, 'persistent' => true, ) ), 'compression' => 1, 'compatibility' => 1 ))); $db->getProfiler()->setEnabled(true); Zend_Registry::set('db', $db); return $this; } public function initView() { $view = new Zend_View(); $view->doctype()->setDoctype( Zend_View_Helper_Doctype::XHTML1_STRICT ); Zend_Registry::set('view', $view); return $this; } public function startSession() { require_once 'Zend/Session.php'; if ( USE_DB_FOR_SESSION_STORAGE ) { require_once 'MyZend/Session/SaveHandler/Session.php'; Zend_Session::setSaveHandler( new MyZend_Session_SaveHandler_Session() ); } Zend_Session::start(); $_SESSION['log'] = array(); $_SESSION['cache'] = array(); } protected function setupFrontController(&$response = null) { ## init routes $router = new Zend_Controller_Router_Rewrite(); require_once 'routes/system.php'; $request = new Zend_Controller_Request_Http(); $front = Zend_Controller_Front::getInstance(); $front->setRouter( $router ); $front->setRequest( $request ); $front->returnResponse( DEBUG_MODE ? true : false ); $front->throwExceptions(false); $front->setParams( array( 'noViewRenderer' => true, //'noErrorHandler' => true, ) ); $this->__setupLangUri(); Zend_Loader::loadClass( 'Plugins_LoginFormSelector' ); $front->registerPlugin( new Plugins_LoginFormSelector(), 1 ); // initialize different login objects Zend_Loader::loadClass( 'Plugins_CheckAdminLogged' ); $front->registerPlugin( new Plugins_CheckAdminLogged(), 2 ); Zend_Loader::loadClass( 'Plugins_Meta' ); $front->registerPlugin( new Plugins_Meta(), 3 ); Zend_Loader::loadClass( 'Plugins_Standalone' ); $front->registerPlugin( new Plugins_Standalone( $request ), 4 ); Zend_Loader::loadClass( 'Plugins_Editors' ); $front->registerPlugin( new Plugins_Editors( $request ), 5 ); $front->setControllerDirectory( array( 'default' => CONTROLLERS . '/default', 'ajax' => CONTROLLERS . '/ajax', 'admin' => CONTROLLERS . '/admin', 'parser' => CONTROLLERS . '/parser' ) ); $response = $front->dispatch(); return $request; } public function setExpireHeader( $time = '+7 Days' ) { #header("Expires: " . date("D, d M Y H:i:s", strtotime($time))); MyZend_Site::noCache(); return $this; } protected function __setupLangUri() { //MyZend_Controller_Request_Lang::run(); define('LANG', ''); define('LANG_ID', 1); MyZend_Site::setRoot( MyZend_Site::$ROOT ); define( 'ROOT', MyZend_Site::$ROOT ); define( 'ADMIN', MyZend_Site::$ADMIN ); } public static function install() { $self = new Core(); $self->setupAll(); $config = new Zend_Config_Ini( 'database.ini', 'endi' ); $config = $config->toArray(); $application = new MyZend_Application( array( 'dbConfig' => $config, MyZend_Application::OVERWRITE_MODELS => false ) ); //$application->install(); $application->buildModels(); die('ok'); } }