/** * Change style of USVN * * @param string template name * @throw USVN_Exception */ public static function setTemplate($template) { if (in_array($template, USVN_Template::listTemplate())) { $config = new USVN_Config_Ini(USVN_CONFIG_FILE, USVN_CONFIG_SECTION); $config->template->name = $template; $config->save(); } else { throw new USVN_Exception(T_("Invalid template")); } }
/** * Return available templates * * @todo check if it is a valid template directory * @return array */ public static function listTemplate() { $res = array(); $list = USVN_DirectoryUtils::listDirectory(USVN_Template::$locale_directory); foreach ($list as $filename) { if (USVN_Template::isValidTemplateDirectory(USVN_Template::$locale_directory . '/' . $filename)) { $res[] = $filename; } } return $res; }
public function printAction() { $this->css_directory = $this->_request->getBaseUrl() . '/medias/usvn/stylesheets'; $this->images_directory = $this->_request->getBaseUrl() . '/medias/usvn/images'; header('Cache-Control: max-age=3600, must-revalidate'); header("Content-type: {$this->_mimetype}"); include USVN_MEDIAS_DIR . '/' . USVN_Template::getTemplate() . '/stylesheets/new.css'; include USVN_MEDIAS_DIR . '/' . USVN_Template::getTemplate() . '/stylesheets/bubblerights.css'; include USVN_MEDIAS_DIR . '/' . USVN_Template::getTemplate() . '/stylesheets/completion.css'; include USVN_MEDIAS_DIR . '/' . USVN_Template::getTemplate() . '/stylesheets/timeline.css'; }
public function indexAction() { //directories for medias and images $this->images_directory = $this->_request->getBaseUrl() . '/medias/' . USVN_Template::getTemplate() . '/images'; //directories for javascript $this->js_default_directory = $this->_request->getBaseUrl() . '/medias/' . USVN_Template::getTemplate() . '/js'; $this->js_directory = $this->_request->getBaseUrl() . '/medias/' . USVN_Template::getTemplate() . '/js'; //javascript files to load: the firts required and the second for templates header('Cache-Control: max-age=3600, must-revalidate'); header("Content-type: {$this->_mimetype}"); include USVN_MEDIAS_DIR . '/' . USVN_Template::getTemplate() . '/js/usvn.js'; include USVN_MEDIAS_DIR . '/' . USVN_Template::getTemplate() . '/script.js'; include USVN_MEDIAS_DIR . '/' . USVN_Template::getTemplate() . '/js/tools/sortable.js'; }
public function test_isValidTemplateDirectory() { $this->assertTrue(USVN_Template::isValidTemplateDirectory('public/usvn/default')); $this->assertFalse(USVN_Template::isValidTemplateDirectory('public/usvn/.svn')); $this->assertFalse(USVN_Template::isValidTemplateDirectory('.htaccess')); }
/** * @param Path to thie image without medias/TEMPLATE/images/ * @param Alternative text (empty by default) */ public function img($path, $alt = "", $extra = null, $vertical = true) { $ctrl = Zend_Controller_Front::getInstance(); return '<img src="' . $ctrl->getBaseUrl() . '/medias/' . USVN_Template::getTemplate() . '/images/' . $path . '" alt="' . $alt . '" ' . ($vertical === true ? 'style="vertical-align: middle;"' : '') . ' ' . $extra . ' />'; }
} if ($config->version != USVN_CONFIG_VERSION) { USVN_Update::runUpdate(); } } catch (Exception $e) { header('Location: install.php'); // echo '<pre>' . "\n"; // echo $e; // echo '</pre>' . "\n"; // exit(0); } /* USVN Configuration */ date_default_timezone_set($config->timezone); USVN_ConsoleUtils::setLocale($config->system->locale); USVN_Translation::initTranslation($config->translation->locale, USVN_LOCALE_DIR); USVN_Template::initTemplate($config->template->name, USVN_MEDIAS_DIR); /* Zend Configuration */ Zend_Registry::set('config', $config); Zend_Db_Table::setDefaultAdapter(Zend_Db::factory($config->database->adapterName, $config->database->options->toArray())); if (isset($config->database->prefix)) { USVN_Db_Table::$prefix = $config->database->prefix; } $front = Zend_Controller_Front::getInstance(); Zend_Layout::startMvc(array('layoutPath' => USVN_LAYOUTS_DIR)); $front->setRequest(new USVN_Controller_Request_Http()); $front->throwExceptions(true); $front->setBaseUrl($config->url->base); /* Initialize router */ $router = new Zend_Controller_Router_Rewrite(); $routes_config = new USVN_Config_Ini(USVN_ROUTES_CONFIG_FILE, USVN_CONFIG_SECTION); $router->addConfig($routes_config, 'routes');