* '' - user have an empty token * Any other (string) value - the token * * See Dot_Auth::checkUserToken() */ $userToken = isset($_POST['userToken']) ? $_POST['userToken'] : null; /** * From this point , the control is taken by the Action specific controller * call the Action specific file, but check first if exists */ $actionControllerPath = CONTROLLERS_PATH . '/' . $registry->requestModule . '/' . $registry->requestControllerProcessed . 'Controller.php'; if (file_exists($actionControllerPath)) { $dotAuth = Dot_Auth::getInstance(); $dotAuth->checkIdentity('user'); require $actionControllerPath; } else { Dot_Route::pageNotFound(); } // set menus $tpl->setMenu(); // set SEO html tags from dots/seo.xml file $tpl->setSeoValues($pageTitle); // display message (error, warning, info) $tpl->displayMessage(); // parse the main content block $tpl->parse('MAIN_CONTENT', 'tpl_main'); // show debugbar $debug = new Dot_Debug($tpl); $debug->show(); // parse and print the output $tpl->pparse('OUTPUT', 'tpl_index');
/** * Create the pagination, based on how many data * @access public * @param array $page * @return string */ protected function paginator($page) { // get route again here, because ajax may have change it //$route = Zend_Registry::get('route'); $request = Zend_Registry::get('request'); $this->setFile('page_file', 'paginator.tpl'); $this->setVar('TOTAL_RECORDS', $page->totalItemCount); $this->setVar('TOTAL_PAGES', $page->pageCount); $this->setBlock('page_file', 'first', 'first_row'); $this->setBlock('page_file', 'last', 'last_row'); $this->setBlock('page_file', 'current_page', 'current_row'); $this->setBlock('page_file', 'other_page', 'other_row'); $this->setBlock('page_file', 'pages', 'pages_row'); if (array_key_exists('page', $request)) { unset($request['page']); } $link = Dot_Route::createCanonicalUrl() . 'page/'; if ($page->current != 1) { $this->setVar('FIRST_LINK', $link . "1"); $this->parse('first_row', 'first', true); } else { $this->parse('first_row', ''); } if ($page->current != $page->last && $page->last > $page->current) { $this->setVar('LAST_LINK', $link . $page->last); $this->parse('last_row', 'last', true); } else { $this->parse('last_row', ''); } foreach ($page->pagesInRange as $val) { $this->setVar('PAGE_NUMBER', $val); $this->parse('other_row', ''); $this->parse('current_row', ''); if ($val == $page->current) { $this->parse('current_row', 'current_page', true); } else { $this->setVar('PAGE_LINK', $link . $val); $this->parse('other_row', 'other_page', true); } $this->parse('pages_row', 'pages', true); } $this->parse('PAGINATION', 'page_file'); }
// assign Index Template file $tpl->setViewFile(); // set paths in templates $tpl->setViewPaths(); /** * each Controller must load its own specific models and views */ Dot_Settings::loadControllerFiles($registry->requestModule); /** * Load option(specific configuration file for current dot file */ $option = Dot_Settings::getOptionVariables($registry->requestModule, $registry->requestControllerProcessed); $registry->option = $option; /** * Start the variable for Page Title, this will be used as H1 tag too */ $pageTitle = 'Overwrite Me Please !'; /** * From this point , the control is taken by the Action specific controller * call the Action specific file, but check first if exists */ $actionControllerPath = CONTROLLERS_PATH . '/' . $registry->requestModule . '/' . $registry->requestControllerProcessed . 'Controller.php'; !file_exists($actionControllerPath) ? Dot_Route::pageNotFound() : (require $actionControllerPath); // set SEO html tags from dots/seo.xml file $tpl->setSeoValues($pageTitle); // dispaly message (error, warning, info) $tpl->displayMessage(); // parse the main content block $tpl->parse('MAIN_CONTENT', 'tpl_main'); // parse and print the output $tpl->pparse('OUTPUT', 'tpl_index');
/** * Get SEO options * * @static * @access public * @return array */ public static function getOption() { $registry = Zend_Registry::getInstance(); $option = Dot_Settings::getOptionVariables($registry->requestModule, 'seo'); //remove the 'option' xml atribute $option->__unset('option'); $option->__set('canonicalUrl', Dot_Route::createCanonicalUrl()); return $option; }
/** * Get the option variables from an xml file for the current dots * * Used recursively, first take default.xml values. This values are * overwritten by the xml of the current dots * * This method also stores the options in the cache, for faster access * * @param string $requestModule * @param string $requestController * @return Zend_Config */ public static function getOptionVariables($requestModule, $requestController) { $option = array(); // get the actual controller // fixes the any_inexistent_controller caching // eg: localhost/DotKernel/module/inexistent_controller/ $actualController = 'default'; if ($requestController == 'seo' || in_array($requestController, Dot_Route::getControllersForModule($requestModule))) { $actualController = $requestController; } $cacheKey = 'option_' . $requestModule . '_' . $actualController; $value = Dot_Cache::load($cacheKey); if ($value != false) { $option = $value; return $option; } else { if ('default' == $requestController) { $dirOption = CONFIGURATION_PATH . '/'; $fileOption = 'dots.xml'; } else { $dirOption = CONFIGURATION_PATH . '/dots/'; $fileOption = strtolower($requestController) . '.xml'; } $validFile = new Zend_Validate_File_Exists(); $validFile->setDirectory($dirOption); if ($validFile->isValid($fileOption)) { $xml = new Zend_Config_Xml($dirOption . $fileOption, 'dots'); $arrayOption = $xml->variable->toArray(); foreach ($arrayOption as $v) { if (in_array($v['option'], array('global', $requestModule))) { // first write global, then replace the values with the ones from $requestModule $option = array_replace_recursive($option, $v); } } } // overwritte the default options from dots.xml with the one of the current dots $option = new Zend_Config($option, true); if (Zend_Registry::isRegistered('option')) { $optionRegistered = Zend_Registry::get('option'); $optionRegistered->merge($option); $value = Dot_Cache::save($optionRegistered, $cacheKey); return $optionRegistered; } $value = Dot_Cache::save($option, $cacheKey); return $option; } }
* Any other (string) value - the token * * See Dot_Auth::checkUserToken() */ $userToken = isset($_POST['userToken']) ? $_POST['userToken'] : null; /** * From this point , the control is taken by the Action specific controller * call the Action specific file, but check first if exists */ $actionControllerPath = CONTROLLERS_PATH . '/' . $registry->requestModule . '/' . $registry->requestControllerProcessed . 'Controller.php'; if (file_exists($actionControllerPath)) { $dotAuth = Dot_Auth::getInstance(); $dotAuth->checkIdentity('admin'); require $actionControllerPath; } else { Dot_Route::pageNotFound('admin'); } // set menus $tpl->setViewMenu(); // set info bar $tpl->setInfoBar(); // set SEO html tags from dots/seo.xml file $tpl->setSeoValues($pageTitle); // dispaly message (error, warning, info) $tpl->displayMessage(); // display widgets $tpl->displayWidgets($option->widgets->content); // parse the main content block $tpl->parse('MAIN_CONTENT', 'tpl_main'); // show debugbar, only for logged in admins if (isset($_SESSION['admin']['admin'])) {
/** * Initialize the global variables * @access public * @static * @param int $startTime * @return bool $success */ public static function initialize($startTime) { // Create registry object, as read-only object to store there config, settings, and database $registry = self::_initializeRegistry(); // mark the start time $registry->startTime = $startTime; //Load configuration settings from application.ini file and store it in registry $config = new Zend_Config_Ini(CONFIGURATION_PATH . '/application.ini', APPLICATION_ENV); $registry->configuration = $config; //start the cache Dot_Cache::loadCache(); //Load routes(modules, controllers, actions) settings from router.xml file and store it in registry $registry->router = self::_loadRouter(); // load the plugin configuration $registry->pluginConfiguration = self::_loadPluginConfiguration(); //Load configuration settings from application.ini file and store it in registry $config = new Zend_Config_Ini(CONFIGURATION_PATH . '/application.ini', APPLICATION_ENV); $registry->configuration = $config; // Create connection to database, as singleton , and store it in registry $db = Zend_Db::factory('Pdo_Mysql', $config->database->params->toArray()); $registry->database = $db; //Load specific configuration settings from database, and store it in registry $settings = Dot_Settings::getSettings(); $registry->settings = $settings; //Set PHP configuration settings from application.ini file Dot_Settings::setPhpSettings($config->phpSettings->toArray()); // Extract the route from the URI Dot_Route::setRoute(); // initialize seo options $registry->seo = Dot_Route::getOption(); // initialize default options for dots that may be overwritten $option = Dot_Settings::getOptionVariables($registry->requestModule, 'default'); $registry->option = $option; return true; }
/** * Check permission based on the ACL roles * Set wanted url if user is not logged * @todo extension to check user level * @access public * @param string $who - who is checking the identity * @return bool */ public function checkIdentity($who) { $role = 'guest'; if ($this->hasIdentity()) { $user = $this->getIdentity(); if (is_object($user)) { $role = $user->role; } } $config = Zend_Registry::get('configuration'); $session = Zend_Registry::get('session'); if (!$this->acl->isAllowed($role)) { //register wanted url if (!isset($session->wantUrl)) { $session->wantUrl = Dot_Route::createCanonicalUrl(); } $option = Zend_Registry::get('option'); if (isset($option->warningMessage->userPermission)) { $session->message['txt'] = $option->warningMessage->userPermission; $session->message['type'] = 'warning'; } //create login url to which will be redirect switch ($who) { case 'admin': $loginUrl = $config->website->params->url . '/admin/admin/login'; break; default: $loginUrl = $config->website->params->url . '/' . $who . '/login'; break; } header('Location: ' . $loginUrl); exit; } //if user is allowed, redirect him to wanted url if ($role == 'admin' && isset($session->wantUrl)) { $wantUrl = $session->wantUrl; unset($session->wantUrl); header('Location: ' . $wantUrl); exit; } return true; }