Exemple #1
0
 /**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemple #2
0
 /** 
  * Method called by the page module to add elements before printing
  */
 public function addElements()
 {
     global $section, $db_use, $optimize_code, $url_rewrite;
     $head_tag = head_tag::getInstance();
     $collection = collection::getInstance();
     $language_handler = MainLanguageHandler::getInstance();
     $default_language = $language_handler->getDefaultLanguage();
     $language_list = $language_handler->getLanguages(false);
     // add base url tag
     $head_tag->addTag('base', array('href' => _BASEURL));
     // add mobile menu script
     if (_MOBILE_VERSION && !in_array('mobile_menu', $this->omit_elements)) {
         $collection->includeScript(collection::MOBILE_MENU);
     }
     // content meta tags
     if (!in_array('content_type', $this->omit_elements)) {
         $head_tag->addTag('meta', array('http-equiv' => 'Content-Type', 'content' => 'text/html; charset=UTF-8'));
     }
     if (!in_array('viewport', $this->omit_elements) && _MOBILE_VERSION) {
         $head_tag->addTag('meta', array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0'));
     }
     if (!in_array('language', $this->omit_elements) && _STANDARD == 'html401') {
         $head_tag->addTag('meta', array('http-equiv' => 'Content-Language', 'content' => join(', ', $language_list)));
     }
     // add other languages if required
     if (count($language_list) > 1 && $url_rewrite && class_exists('language_menu')) {
         language_menu::getInstance()->addMeta();
     }
     // robot tags
     $head_tag->addTag('meta', array('name' => 'robots', 'content' => 'index, follow'));
     $head_tag->addTag('meta', array('name' => 'googlebot', 'content' => 'index, follow'));
     $head_tag->addTag('meta', array('name' => 'rating', 'content' => 'general'));
     if ($section != 'backend' && $section != 'backend_module' && $db_use) {
         // google analytics
         if (!empty($this->settings['analytics'])) {
             $head_tag->addGoogleAnalytics($this->settings['analytics'], $this->settings['analytics_domain'], $this->settings['analytics_version']);
         }
         // google website optimizer
         if (!empty($this->settings['optimizer'])) {
             $head_tag->addGoogleSiteOptimizer($this->settings['optimizer'], $this->settings['optimizer_key'], $this->optimizer_page, $this->optimizer_show_control);
         }
         // google webmaster tools
         if (!empty($this->settings['wm_tools'])) {
             $head_tag->addTag('meta', array('name' => 'google-site-verification', 'content' => $this->settings['wm_tools']));
         }
         // bing webmaster tools
         if (!empty($this->settings['bing_wm_tools'])) {
             $head_tag->addTag('meta', array('name' => 'msvalidate.01', 'content' => $this->settings['bing_wm_tools']));
         }
         // page description
         if ($db_use) {
             if (!is_null($this->page_description)) {
                 $value = $this->page_description;
             } else {
                 $value = $this->settings['description'];
             }
         }
         $head_tag->addTag('meta', array('name' => 'description', 'content' => $value));
     }
     // copyright
     if (!in_array('copyright', $this->omit_elements) && _STANDARD == 'html401') {
         $copyright = MainLanguageHandler::getInstance()->getText('copyright');
         $copyright = strip_tags($copyright);
         $head_tag->addTag('meta', array('name' => 'copyright', 'content' => $copyright));
     }
     // favicon
     if (file_exists(_BASEPATH . '/images/favicon.png')) {
         // regular, single size favicon
         $icon_files = array('16x16' => _BASEPATH . '/images/favicon.png');
     } else {
         if (file_exists(_BASEPATH . '/images/favicon')) {
             $icon_sizes = array(16, 32, 64);
             $icon_files = array();
             foreach ($icon_sizes as $size) {
                 $file_name = _BASEPATH . '/images/favicon/' . $size . '.png';
                 if (file_exists($file_name)) {
                     $icon_files[$size . 'x' . $size] = $file_name;
                 }
             }
         } else {
             $icon_files = array('16x16' => _BASEPATH . '/images/default_icon/16.png', '32x32' => _BASEPATH . '/images/default_icon/32.png', '64x64' => _BASEPATH . '/images/default_icon/64.png');
         }
     }
     foreach ($icon_files as $sizes => $icon) {
         $head_tag->addTag('link', array('rel' => 'icon', 'type' => 'image/png', 'sizes' => $sizes, 'href' => url_GetFromFilePath($icon)));
     }
     // add default styles and script if they exists
     $collection->includeScript(collection::JQUERY);
     if ($section != 'backend') {
         $styles = array();
         $less_style = null;
         // prepare list of files without extensions
         if (_DESKTOP_VERSION) {
             $styles = array('/styles/common.css', '/styles/main.css', '/styles/header.css', '/styles/content.css', '/styles/footer.css');
             $less_style = '/styles/main.less';
         } else {
             $styles = array('/styles/common.css', '/styles/main.css', '/styles/header_mobile.css', '/styles/content_mobile.css', '/styles/footer_mobile.css');
             $less_style = '/styles/main_mobile.less';
         }
         // include styles
         foreach ($styles as $style) {
             // check for css files
             if (file_exists(_BASEPATH . $style)) {
                 $head_tag->addTag('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => url_GetFromFilePath(_BASEPATH . $style)));
             }
         }
         // add main less file if it exists
         if (file_exists(_BASEPATH . $less_style)) {
             $head_tag->addTag('link', array('rel' => 'stylesheet/less', 'type' => 'text/css', 'href' => url_GetFromFilePath(_BASEPATH . $less_style)));
             if (!$optimize_code) {
                 $collection->includeScript(collection::LESS);
             }
         }
         // add main javascript
         if (file_exists(_BASEPATH . '/scripts/main.js')) {
             $head_tag->addTag('script', array('type' => 'text/javascript', 'src' => url_GetFromFilePath(_BASEPATH . '/scripts/main.js')));
         }
     }
 }