91 lines
3.1 KiB
PHP
91 lines
3.1 KiB
PHP
<?php
|
|
class Application_Controller_Plugin_Theme extends Zend_Controller_Plugin_Abstract
|
|
{
|
|
public function routeShutdown(Zend_Controller_Request_Abstract $request)
|
|
{
|
|
$auth = Zend_Auth::getInstance();
|
|
$theme = 'default';
|
|
if ( $auth->hasIdentity() ) {
|
|
$theme = !empty($auth->getIdentity()->theme) ?
|
|
$auth->getIdentity()->theme : 'default';
|
|
}
|
|
|
|
//Sauvegarde des paramètres du themes pour gérer les scripts et styles à utiliser
|
|
$paramsTheme = new stdClass();
|
|
$paramsTheme->name = $theme;
|
|
$paramsTheme->pathStyle = '/themes/'.$theme.'/styles';
|
|
$paramsTheme->pathScript = '/themes/'.$theme.'/scripts';
|
|
Zend_Registry::set('theme', $paramsTheme);
|
|
|
|
//Module default de l'application
|
|
$layoutPath = APPLICATION_PATH . '/views/' . $theme;
|
|
$viewPath = APPLICATION_PATH . '/views/' . $theme;
|
|
|
|
//Surcharge des chemins de la vue et du layout
|
|
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
|
|
$view = $bootstrap->bootstrap('View')->getResource('View');
|
|
$view->setBasePath($viewPath);
|
|
|
|
$layout = $bootstrap->bootstrap('Layout')->getResource('Layout');
|
|
$layout->setLayout('main');
|
|
$layout->setLayoutPath($layoutPath);
|
|
|
|
//Définition des fichiers suivant le theme
|
|
switch ( $theme )
|
|
{
|
|
default:
|
|
case 'default':
|
|
|
|
$view->doctype('XHTML1_STRICT');
|
|
|
|
$view->headMeta()
|
|
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
|
|
->appendHttpEquiv('Content-Language', 'fr-FR');
|
|
|
|
$view->headLink()
|
|
->headLink(array('rel' => 'favicon', 'type' => 'image/png', 'href' => '/favicon.png'));
|
|
$view->headLink()
|
|
->headLink(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => '/favicon.ico'));
|
|
|
|
//Style
|
|
$view->headLink()
|
|
->appendStylesheet($paramsTheme->pathStyle.'/main.css', 'all')
|
|
->appendStylesheet($paramsTheme->pathStyle.'/ie6.css', 'all', 'lte IE 6')
|
|
->appendStylesheet('/libs/ui/themes/smoothness/jquery-ui.css', 'all')
|
|
->appendStylesheet('/libs/qtip/jquery.qtip.css', 'all');
|
|
|
|
//JavaScript
|
|
$view->headScript()
|
|
->appendFile('/libs/jquery/jquery.js', 'text/javascript')
|
|
->appendFile('/libs/jquery/jquery.bgiframe.js', 'text/javascript')
|
|
->appendFile('/libs/ui/jquery-ui.js', 'text/javascript')
|
|
->appendFile('/libs/ui/jquery-ui-i18n.js', 'text/javascript')
|
|
->appendFile('/libs/qtip/jquery.qtip.js', 'text/javascript')
|
|
->appendFile($paramsTheme->pathScript.'/script.js', 'text/javascript');
|
|
|
|
break;
|
|
|
|
case 'mobile':
|
|
|
|
$view->doctype('HTML5');
|
|
|
|
$view->headMeta()
|
|
->appendName('charset', 'utf-8')
|
|
->appendName('viewport', 'width=device-width, initial-scale=1');
|
|
|
|
//Style
|
|
$view->headLink()
|
|
//->appendStylesheet('/main.css', 'all')
|
|
->appendStylesheet('/libs/mobile/jquery.mobile.css', 'all');
|
|
|
|
//JavaScript
|
|
$view->headScript()
|
|
->appendFile('/libs/jquery/jquery.js')
|
|
->appendFile($paramsTheme->pathScript.'/script.js', 'text/javascript')
|
|
->appendFile('/libs/mobile/jquery.mobile.js');
|
|
|
|
break;
|
|
}
|
|
|
|
}
|
|
} |