hasIdentity() ) { $theme = !empty($auth->getIdentity()->theme) ? $auth->getIdentity()->theme : 'default'; } $module = $request->getModuleName(); $controller = $request->getControllerName(); $action = $request->getActionName(); //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'; $paramsTheme->pathImg = '/themes/'.$theme.'/images'; Zend_Registry::set('theme', $paramsTheme); //Load bootstrap $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap'); //Get useragent and device informations $userAgent = $bootstrap->getResource('useragent'); $device = $userAgent->getDevice(); //Module default de l'application $layoutPath = APPLICATION_PATH . '/layouts/' . $theme; $helperPath = APPLICATION_PATH . '/layouts/helpers'; $viewPath = APPLICATION_PATH . '/modules/'.$module.'/views/' . $theme; //Override path for view and layout $view = $bootstrap->bootstrap('View')->getResource('View'); $view->setBasePath($viewPath); $view->setHelperPath($vi); $layout = $bootstrap->bootstrap('Layout')->getResource('Layout'); $layout->setLayout('layout'); $layout->setLayoutPath($layoutPath); //Load default style and javascript files for the selected theme switch ( $theme ) { case 'default': default: $view->doctype('HTML5'); $view->headMeta() ->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8') ->appendHttpEquiv('Content-Language', 'fr-FR'); //Favicon - Touch icon for iOS 2.0+ and Android 2.1+ $view->headLink()->headLink(array( 'rel' => 'apple-touch-icon-precomposed', 'href' => '/favicon-152.png' )); //Favicon - targeted to any additional png size $view->headLink()->headLink(array( 'rel' => 'icon', 'type' => 'image/png', 'href' => '/favicon-32.png' )); $view->headLink()->headLink(array( 'rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => '/favicon.ico') ); $UserLogin = false; if ( $controller == 'user' && ( $action == 'login' || $action == 'logout' ) ) { $UserLogin = true; } if ( $controller == 'auth' ) { $UserLogin = true; } /** * Detect IE */ $isIE6 = false; if ( $device->getFeature('browser_name')=='Internet Explorer' && $device->getFeature('browser_version')=='6.0' ) { $isIE6 = true; } /** * ===> Standard Styles */ if ( $UserLogin ) { $view->headLink() ->appendStylesheet('/libs/bootstrap-3.3.4/css/bootstrap.min.css', 'all') ->appendStylesheet('/themes/default/styles/user-login.css', 'all'); } else { $view->headLink()->appendStylesheet($paramsTheme->pathStyle.'/main.css', 'all'); } if ($isIE6) { //Old CSS for IE6 $view->headLink() ->appendStylesheet($paramsTheme->pathStyle.'/ie6.css', 'all') ->appendStylesheet('/libs/ui-1.9.2/themes/smoothness/jquery-ui.css', 'all'); } else { $view->headLink() ->appendStylesheet('/libs/ui-1.10.4/themes/smoothness/jquery-ui.min.css', 'all'); } $view->headLink() ->appendStylesheet('/libs/qtip/jquery.qtip.min.css', 'all') ->appendStylesheet('/libs/font-awesome-4.3.0/css/font-awesome.min.css', 'all'); /** * ===> Standard Javascript */ if ( $UserLogin ) { $view->headScript() ->appendFile('/libs/html5shiv.min.js', 'text/javascript', array('conditional' => 'lt IE 9')) ->appendFile('/libs/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9')) ->appendFile('/libs/jquery/jquery-1.11.3.min.js', 'text/javascript') ->appendFile('/libs/jquery/jquery.placeholder.js', 'text/javascript') ->appendFile('/libs/bootstrap-3.3.4/js/bootstrap.min.js', 'text/javascript'); } else { $view->headScript() ->appendFile('/libs/jquery/jquery-1.11.3.min.js', 'text/javascript'); } if ($isIE6) { //Old JQuery version for IE6 $view->headScript() ->appendFile('/libs/jquery/jquery.bgiframe.js', 'text/javascript') ->appendFile('/libs/ui-1.9.2/jquery-ui.min.js', 'text/javascript') ->appendFile('/libs/ui-1.9.2/jquery-ui-i18n.min.js', 'text/javascript'); } else { $view->headScript() ->appendFile('/libs/ui-1.10.4/jquery-ui.min.js', 'text/javascript') ->appendFile('/libs/ui-1.10.4/jquery-ui-i18n.min.js', 'text/javascript'); } if ( ! $UserLogin ) { $view->headScript() ->appendFile('/libs/qtip/jquery.qtip.min.js', 'text/javascript') ->appendFile($paramsTheme->pathScript.'/script.js', 'text/javascript'); } break; case 'mobile': //@todo $view->doctype('HTML5'); $view->headMeta() ->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8') ->appendHttpEquiv('Content-Language', 'fr-FR') ->appendName('viewport', 'width=device-width, initial-scale=1'); //Favicon - Touch icon for iOS 2.0+ and Android 2.1+ $view->headLink()->headLink(array( 'rel' => 'apple-touch-icon-precomposed', 'href' => '/favicon-152.png' )); //Favicon - targeted to any additional png size $view->headLink()->headLink(array( 'rel' => 'icon', 'type' => 'image/png', 'href' => '/favicon-32.png' )); $view->headLink()->headLink(array( 'rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => '/favicon.ico') ); //Style $view->headLink() ->appendStylesheet('/libs/mobile/1.4.2/jquery.mobile-1.4.2.min.css', 'all'); //JavaScript $view->headScript() ->appendFile('/libs/jquery/jquery-2.1.0.min.js', 'text/javascript') ->appendFile('/libs/mobile/1.4.2/jquery.mobile-1.4.2.min.js', 'text/javascript') ->appendFile($paramsTheme->pathScript.'/script.js', 'text/javascript'); break; } } }