/** * Returns the singleton object for this class * @return QFrame_Config */ public static function instance() { if (self::$instance === null) { self::$instance = new QFrame_Config(); } return self::$instance; }
/* * Register the logging and sanity checking plugins with the front controller */ $front->registerPlugin(new QFrame_Controller_Plugin_Log()); /* * Register the EzcExecution plugin with the front controller */ $front->registerPlugin(new QFrame_Controller_Plugin_EzcExecution()); /* * Set up a QFrame_View object, add the path to the helper directory, and set it up * as the default view object */ $view = new QFrame_View(); $view->addHelperPath(implode(DIRECTORY_SEPARATOR, array(APPLICATION_PATH, 'views', 'helpers'))); $view->addHelperPath(implode(DIRECTORY_SEPARATOR, array(LIBRARY_PATH, 'Zend', 'View', 'Helper')), 'Zend_View_Helper'); $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view); $viewRenderer->setViewSuffix('haml')->setViewScriptPathSpec('scripts/:controller/:action.:suffix'); Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); /* * Finally, we are going to actually add some routes... */ $router = $front->getRouter(); $router->addRoute('default', new Zend_Controller_Router_Route(':controller/:action/:id', array('controller' => 'index', 'action' => 'index', 'id' => 0))); /* * Set up the base url before dispatching */ $front->setBaseUrl(QFrame_Config::instance()->base_url); /* * And last of all dispatch the front controller */ $front->dispatch();
/** * Build the list of tabs (at the top of the window) * * @return string */ protected function buildPages() { $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName(); $pages[] = array('label' => 'Questions', 'url' => $this->view->url(array('controller' => 'index'), null, true), 'current' => !($this instanceof QFrame_Controller_Admin || $this instanceof CompareController), 'external' => false); if ($this->_user !== null && $this->_user->hasAccess('administer')) { $pages[] = array('label' => 'Administration', 'url' => $this->view->url(array('controller' => 'admin'), null, true), 'current' => $this instanceof QFrame_Controller_Admin, 'external' => false); } if ($this->_user !== null && $this->_user->hasAccess('compare')) { $pages[] = array('label' => 'Compare', 'url' => $this->view->url(array('controller' => 'compare'), null, true), 'current' => $this instanceof CompareController, 'external' => false); } if (isset(QFrame_Config::instance()->help_url)) { $pages[] = array('label' => 'Online Help', 'url' => QFrame_Config::instance()->help_url, 'current' => false, 'external' => true); } return $pages; }
<?php /** * This file is part of the CSI QFrame. * * The CSI QFrame is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * The CSI QFrame is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @copyright Copyright (c) 2007 Collaborative Software Initiative (CSI) * @license http://www.gnu.org/licenses/ GNU General Public License v3 */ /* * Get a reference to the configuration object */ $config = QFrame_Config::instance(); /* * Set any paths that depend on configuration options */ $data_path = preg_replace('/\\/|\\\\/', DIRECTORY_SEPARATOR, $config->data_path); define('DATA_PATH', _path(PROJECT_PATH, $data_path));
/** * Renders a template or returns the rendered template from cache (if appropriate) * * @param string name of the template to render * @param bool whether or not the template name is relative * @return string */ private function renderTemplate($name, $relative = true) { $name = $relative ? $name : substr($name, strlen($this->_base) + 1); if (QFrame_Config::instance()->cache_templates) { $cache_path = $this->_base . DIRECTORY_SEPARATOR . 'cache'; $cache_file = $cache_path . DIRECTORY_SEPARATOR . preg_replace('/\\.haml$/', '.php', $name); $template_file = $this->_base . DIRECTORY_SEPARATOR . $name; if (file_exists($cache_file) && filemtime($cache_file) > filemtime($template_file)) { $rendered = file_get_contents($cache_file); } else { $rendered = $this->renderHamlTemplate($name); if (!file_exists(dirname($cache_file))) { mkdir(dirname($cache_file), 0775, true); } file_put_contents($cache_file, $rendered); } } return isset($rendered) ? $rendered : $this->renderHamlTemplate($name); }