Beispiel #1
0
 /**
  * Method to load the theme CSS file based on the config
  *
  * @param	String		Filename to be loaded
  * @param	Boolean		Is this a dashboard?
  */
 public static function loadThemeCss($file, $is_dashboard = false)
 {
     $document = JFactory::getDocument();
     $mainframe = JFactory::getApplication();
     $config = EasyBlogHelper::getConfig();
     $template = $mainframe->getTemplate();
     $bloggertheme = EasyBlogHelper::getBloggerTheme();
     $enableBloggerTheme = $config->get('layout_enablebloggertheme', true);
     $availableBloggerTheme = $config->get('layout_availablebloggertheme');
     if (!is_array($availableBloggerTheme)) {
         $availableBloggerTheme = explode('|', $config->get('layout_availablebloggertheme'));
     }
     if ($enableBloggerTheme && !empty($bloggertheme) && $bloggertheme != 'global' && in_array($bloggertheme, $availableBloggerTheme)) {
         $theme = $bloggertheme;
         JRequest::setVar('theme', $bloggertheme);
     } else {
         $theme = $config->get('layout_theme');
     }
     // @rule: Use Google fonts if necessary.
     $headingFont = $config->get('layout_googlefont');
     if ($headingFont != 'site') {
         // Replace the word Bold with :Bold
         $headingFont = JString::str_ireplace(' bold', ':bold', $headingFont);
         // Replace spaces with +
         $headingFont = JString::str_ireplace(' ', '+', $headingFont);
         $url = 'https://fonts.googleapis.com/css?family=' . $headingFont;
         $document->addStyleSheet($url);
     }
     $googlePlus = $config->get('main_googleone', 0);
     $socialFrontEnd = $config->get('main_googleone_frontpage', 0);
     if ($socialFrontEnd && $googlePlus) {
         $googlPlusUrl = 'https://apis.google.com/js/plusone.js';
         $document->addScript($googlPlusUrl);
     }
     $path = null;
     $direction = $document->direction;
     /**
      * for theme development purpose
      */
     $usethis = JRequest::getWord('theme');
     if (!empty($usethis)) {
         JRequest::setVar('theme', $usethis);
         $theme = $usethis;
     }
     // new in 1.1
     // load the file based on the theme's config.ini
     $themeConfig = EasyBlogHelper::getThemeInfo($theme);
     if (!$is_dashboard) {
         /**
          * Load blog theme file
          *
          * Priority level
          *
          * 1. /templates/<joomla_template>/html/com_easyblog/
          * 2. /components/com_easyblog/themes/<selected_theme>/
          * 3. /components/com_easyblog/themes/<parent_for_selected_theme>/
          * 4. /components/com_easyblog/themes/default/
          */
         $siteOverride = false;
         $overrideFile = JPATH_ROOT . '/templates/' . $template . '/html/com_easyblog/css/' . $file;
         if (JFile::exists($overrideFile)) {
             $path = rtrim(JURI::root(), '/') . '/templates/' . $template . '/html/com_easyblog/css/' . $file;
             $siteOverride = true;
         } elseif (JFile::exists(EBLOG_THEMES . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . $file)) {
             if ($themeConfig->get('parent_css')) {
                 $path = rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/' . $themeConfig->get('parent') . '/css/' . $file;
                 $document->addStylesheet($path);
             }
             $path = rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/' . $theme . '/css/' . $file;
         } else {
             $path = rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/default/css/' . $file;
         }
         // Always load the system css if template override in use as we want to allow them to
         // reuse the styling as much as possible.
         if (!$siteOverride) {
             $document->addStylesheet(rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/default/css/styles.css');
         }
         $document->addStylesheet($path);
     }
     /**
      * Load dashboard theme file
      *
      * Priority level
      *
      * 1. /templates/<joomla_template>/html/com_easyblog/dashboard/
      * 2. /components/com_easyblog/themes/<selected_theme>/dashboard/
      * 3. /components/com_easyblog/themes/dashboard/
      */
     if ($is_dashboard) {
         $dashboardTheme = JString::trim(JString::strtolower($config->get('layout_dashboard_theme')));
         $overridePath = JPATH_ROOT . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . $file;
         $themePath = JFile::exists(EBLOG_THEMES . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . $dashboardTheme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . $file);
         // Always load the base css file.
         $document->addStyleSheet(rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/dashboard/system/css/styles.css');
         if (JFile::exists($overridePath)) {
             $path = rtrim(JURI::root(), '/') . '/templates/' . $template . '/html/com_easyblog/dashboard/css/' . $file;
         } elseif ($themePath) {
             $path = rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/dashboard/' . $dashboardTheme . '/css/' . $file;
         } else {
             $path = rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/dashboard/system/' . $file;
         }
         $document->addStylesheet($path);
     }
     /**
      * Load RTL file for default theme
      */
     if ($direction == 'rtl') {
         // we need default RTL be loaded always
         $path = rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/default/css/rtl.css';
         $document->addStylesheet($path);
         // checking the template override folder
         if (JFile::exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'rtl.css')) {
             $path = rtrim(JURI::root(), '/') . '/templates/' . $template . '/html/com_easyblog/css/rtl.css';
             $document->addStylesheet($path);
         }
         // check if we need to load the parent CSS based on theme's config.ini
         // since 1.1
         if ($themeConfig->get('parent_css')) {
             // now check if the parent theme have th RTL file
             if (JFile::exists(EBLOG_THEMES . DIRECTORY_SEPARATOR . $themeConfig->get('parent') . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'rtl.css')) {
                 $path = rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/' . $themeConfig->get('parent') . '/css/rtl.css';
                 $document->addStylesheet($path);
             }
         }
         // checking the theme folder
         if (JFile::exists(EBLOG_THEMES . DIRECTORY_SEPARATOR . $theme . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'rtl.css')) {
             $path = rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/' . $theme . '/css/rtl.css';
             $document->addStylesheet($path);
         }
     }
     /**
      * Load RTL file for dashboard theme
      */
     if ($direction == 'rtl' && $is_dashboard) {
         if (JFile::exists(JPATH_ROOT . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'rtl.css')) {
             $path = rtrim(JURI::root(), '/') . '/templates/' . $template . '/html/com_easyblog/dashboard/css/rtl.css';
         } elseif (JFile::exists(EBLOG_THEMES . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'rtl.css')) {
             $path = rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/dashboard/' . $template . '/css/rtl.css';
         } else {
             $path = rtrim(JURI::root(), '/') . '/components/com_easyblog/themes/dashboard/system/css/rtl.css';
         }
         $document->addStylesheet($path);
     }
 }
Beispiel #2
0
 /**
  * Open, parse, and return the template file.
  *
  * @param $file		string	The template file name
  * @param $vars 	Array	An array of custom variables that needs to exist in the template
  */
 function fetch($file, $vars = array())
 {
     $notfound = false;
     jimport('joomla.filesystem.file');
     $mainframe = JFactory::getApplication();
     // Overrides. Browser can choose different template after load
     $override = JRequest::getWord('theme', '');
     $fileName = $file;
     if ($override) {
         $this->_theme = $override;
     }
     // load the file based on the theme's config.ini
     // @since 1.1.x
     $info = EasyBlogHelper::getThemeInfo($this->_theme);
     /**
      * Precedence in order.
      * 1. Template override
      * 2. Selected theme
      * 3. Parent theme
      * 4. Default system theme
      */
     if (!$this->dashboard) {
         $overridePath = JPATH_ROOT . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $mainframe->getTemplate() . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . $file;
         $selectedPath = EBLOG_THEMES . DIRECTORY_SEPARATOR . $this->_theme . DIRECTORY_SEPARATOR . $file;
         $parentPath = EBLOG_THEMES . DIRECTORY_SEPARATOR . $info->get('parent') . DIRECTORY_SEPARATOR . $file;
         $defaultPath = EBLOG_THEMES . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . $file;
     } else {
         $overridePath = JPATH_ROOT . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $mainframe->getTemplate() . DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . $file;
         $selectedPath = EBLOG_THEMES . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . $this->_theme . DIRECTORY_SEPARATOR . $file;
         $parentPath = EBLOG_THEMES . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . $info->get('parent') . DIRECTORY_SEPARATOR . $file;
         $defaultPath = EBLOG_THEMES . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'system' . DIRECTORY_SEPARATOR . $file;
     }
     // 1. Template overrides
     if (JFile::exists($overridePath)) {
         $file = $overridePath;
     } elseif (JFile::exists($selectedPath)) {
         $file = $selectedPath;
     } elseif (JFile::exists($parentPath)) {
         $file = $parentPath;
     } else {
         $file = $defaultPath;
     }
     if (!empty($vars)) {
         extract($vars);
     }
     if (isset($this->vars)) {
         extract($this->vars);
     }
     ob_start();
     if (!JFile::exists($file)) {
         echo JText::sprintf('Invalid template file <strong>%1s</strong>', $fileName);
         $notfound = true;
     } else {
         include $file;
     }
     $data = ob_get_contents();
     ob_end_clean();
     if ($notfound) {
         return false;
     }
     return $data;
 }