Esempio n. 1
0
 public function section()
 {
     $ajax = FD::ajax();
     // TODO: Exact section copy. Refactor.
     $location = JRequest::getCmd('location');
     $name = JRequest::getCmd('name');
     $override = JRequest::getBool('override', false);
     $section = JRequest::getVar('section');
     // Get stylesheet
     $stylesheet = FD::stylesheet($location, $name, $override);
     $theme = FD::themes();
     $theme->set('location', $location);
     $theme->set('name', $name);
     // TODO: Find a proper way to do this
     $theme->set('element', ucwords(str_ireplace('_', ' ', str_ireplace('mod_easysocial_', '', $name))));
     $theme->set('override', $override);
     $theme->set('section', $section);
     $theme->set('stylesheet', $stylesheet);
     // Also pass in server memory limit.
     $memory_limit = ini_get('memory_limit');
     $memory_limit = FD::math()->convertBytes($memory_limit) / 1024 / 1024;
     $theme->set('memory_limit', $memory_limit);
     $html = $theme->output('admin/themes/compiler/section');
     /* Exact section copy */
     $ajax->resolve($html);
     $ajax->send();
 }
Esempio n. 2
0
 /**
  * Initializes all the stylesheet that needs to load on the page
  *
  * @since	1.0
  * @access	public
  * @return
  */
 public function initStylesheets()
 {
     static $profiles = array();
     if (isset(self::$options['processStylesheets']) && self::$options['processStylesheets'] == false) {
         self::$loaded = true;
         return;
     }
     if (self::$stylesheetsLoaded) {
         return;
     }
     // Build theme styles
     $location = $this->app->isAdmin() ? 'admin' : 'site';
     $theme = strtolower($this->config->get('theme.' . $location));
     // Build theme styles
     $stylesheet = FD::stylesheet($location, $theme);
     $stylesheet->attach();
     // Site location
     if ($location == 'site') {
         $profile = FD::user()->getProfile();
         if ($profile && !isset($profiles[$profile->id])) {
             $params = $profile->getParams();
             $override = $params->get('theme');
             if ($override) {
                 $theme = $override;
             }
             $profiles[$profile->id] = $theme;
         }
         if ($profile && isset($profiles[$profile->id])) {
             $theme = $profiles[$profile->id];
         }
         // Check if custom.css exists on the site as template overrides
         $file = JPATH_ROOT . '/templates/' . $this->app->getTemplate() . '/html/com_easysocial/css/custom.css';
         if (JFile::exists($file)) {
             $customCssFile = rtrim(JURI::root(), '/') . '/templates/' . $this->app->getTemplate() . '/html/com_easysocial/css/custom.css';
             $this->doc->addStylesheet($customCssFile);
         }
     }
     // @TODO: Make this part of ATS in the future
     // If this is RTL, load RTL specific styles
     $direction = $this->doc->getDirection();
     if ($direction == 'rtl') {
         if ($theme == 'wireframe' || $theme == 'frosty') {
             $rtlStylesheet = rtrim(JURI::root(), '/') . '/components/com_easysocial/themes/' . $theme . '/styles/rtl.css';
             $this->doc->addStylesheet($rtlStylesheet);
         }
     }
     self::$stylesheetsLoaded = true;
 }
Esempio n. 3
0
 /**
  * Initializes all the stylesheet that needs to load on the page
  *
  * @since	1.0
  * @access	public
  * @return
  */
 public function initStylesheets()
 {
     static $profiles = array();
     if (isset(self::$options['processStylesheets']) && self::$options['processStylesheets'] == false) {
         self::$loaded = true;
         return;
     }
     if (self::$stylesheetsLoaded) {
         return;
     }
     $app = JFactory::getApplication();
     $config = FD::config();
     $doc = JFactory::getDocument();
     // Build theme styles
     $location = $app->isAdmin() ? 'admin' : 'site';
     $theme = strtolower($config->get('theme.' . $location));
     if ($location == 'site') {
         $profile = FD::user()->getProfile();
         if ($profile && !isset($profiles[$profile->id])) {
             $params = $profile->getParams();
             $override = $params->get('theme');
             if ($override) {
                 $theme = $override;
             }
             $profiles[$profile->id] = $theme;
         }
         if ($profile && isset($profiles[$profile->id])) {
             $theme = $profiles[$profile->id];
         }
     }
     $stylesheet = FD::stylesheet($location, $theme);
     $stylesheet->attach();
     // @TODO: Make this part of ATS in the future
     // If this is RTL, load RTL specific styles
     $direction = $doc->getDirection();
     if ($direction == 'rtl') {
         $rtlStylesheet = rtrim(JURI::root(), '/') . '/components/com_easysocial/themes/wireframe/styles/rtl.css';
         $doc->addStylesheet($rtlStylesheet);
     }
     self::$stylesheetsLoaded = true;
 }
Esempio n. 4
0
 /**
  * Purges the less cache files on the site
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function clearCache()
 {
     // Check for request forgeries
     FD::checkToken();
     // Get the current view
     $view = $this->getCurrentView();
     $purgeJS = JRequest::getBool('script-cache');
     if ($purgeJS) {
         // Clear javascript files
         $configuration = FD::getInstance('Configuration');
         $configuration->purge();
         $compiler = FD::getInstance('Compiler');
         $compiler->purgeResources();
     }
     $purgeLess = JRequest::getBool('stylesheet-cache');
     if ($purgeLess) {
         // Compile site themes
         $templates = JFolder::folders(EASYSOCIAL_SITE_THEMES);
         foreach ($templates as $template) {
             $task = FD::stylesheet('site', $template)->purge();
         }
         // Compile admin themes
         $templates = JFolder::folders(EASYSOCIAL_ADMIN_THEMES);
         foreach ($templates as $template) {
             $task = FD::stylesheet('admin', $template)->purge();
         }
         // Compile modules
         $modules = FD::stylesheet('module')->modules();
         foreach ($modules as $module) {
             $task = FD::stylesheet('module', $module)->purge();
         }
     }
     $message = JText::sprintf('COM_EASYSOCIAL_CACHE_PURGED_FROM_SITE');
     $view->setMessage($message, SOCIAL_MSG_SUCCESS);
     return $view->call(__FUNCTION__);
 }
Esempio n. 5
0
 public function compiler()
 {
     $this->setHeading('COM_EASYSOCIAL_TOOLBAR_TITLE_THEMES_COMPILER');
     $this->setDescription('COM_EASYSOCIAL_DESCRIPTION_THEMES_CUSTOMIZE');
     // Master set of stylesheets
     $stylesheets = array();
     // Site themes
     $model = FD::model('Themes');
     $site_themes = $model->getThemes();
     $stylesheets[] = (object) array('title' => JText::_('COM_EASYSOCIAL_THEMES_LOCATION_SITE'), 'location' => 'site', 'override' => false, 'themes' => $site_themes);
     // Site overrides
     $elements = FD::stylesheet('site')->overrides();
     $site_overrides = array();
     // Emulate results from $model->getThemes();
     // TODO: Find a proper way to do this.
     foreach ($elements as $element) {
         $site_overrides[] = (object) array('name' => ucwords($element), 'element' => $element);
     }
     $stylesheets[] = (object) array('title' => JText::_('COM_EASYSOCIAL_THEMES_LOCATION_SITE_OVERRIDE'), 'location' => 'site', 'override' => true, 'themes' => $site_overrides);
     $super = FD::config()->get('general.super');
     if ($super) {
         // Admin themes
         // TODO: Model to retrieve admin themes
         $stylesheets[] = (object) array('title' => JText::_('COM_EASYSOCIAL_THEMES_LOCATION_ADMIN'), 'location' => 'admin', 'override' => false, 'themes' => array((object) array('name' => 'Default', 'element' => 'default')));
         // Admin overrides
         // TODO: This is strangely retrieving site overrides.
         $elements = FD::stylesheet('admin')->overrides();
         $admin_overrides = array();
         // Emulate results from $model->getThemes();
         // TODO: Find a proper way to do this.
         foreach ($elements as $element) {
             $admin_overrides[] = (object) array('name' => ucwords($element), 'element' => $element);
         }
         $stylesheets[] = (object) array('title' => JText::_('COM_EASYSOCIAL_THEMES_LOCATION_ADMIN_OVERRIDE'), 'location' => 'admin', 'override' => false, 'themes' => $admin_overrides);
     }
     // Modules
     $elements = FD::stylesheet('module')->modules();
     $modules = array();
     // Emulate results from $model->getThemes();
     // TODO: Find a proper way to do this.
     foreach ($elements as $element) {
         $modules[] = (object) array('name' => ucwords(str_ireplace('_', ' ', str_ireplace('mod_easysocial_', '', $element))), 'element' => $element);
     }
     $stylesheets[] = (object) array('title' => JText::_('COM_EASYSOCIAL_THEMES_LOCATION_MODULE'), 'location' => 'module', 'override' => false, 'themes' => $modules);
     // Get url params
     // Defaults to site/wireframe.
     $location = JRequest::getCmd('location', 'site');
     $name = JRequest::getCmd('name', 'wireframe');
     $override = JRequest::getBool('override', false);
     // Get active stylesheet
     $stylesheet = FD::stylesheet($location, $name, $override);
     $uuid = uniqid();
     // For admin/themes/compiler
     $this->set('stylesheets', $stylesheets);
     // For admin/themes/compiler/form
     $this->set('uuid', $uuid);
     $this->set('location', $location);
     $this->set('name', $name);
     // TODO: Find a proper way to do this
     $this->set('element', ucwords(str_ireplace('_', ' ', str_ireplace('mod_easysocial_', '', $name))));
     $this->set('override', $override);
     $this->set('stylesheet', $stylesheet);
     $this->set('type', $stylesheet->type());
     $this->set('manifest', $stylesheet->manifest());
     // Also pass in server memory limit.
     $memory_limit = ini_get('memory_limit');
     $memory_limit = FD::math()->convertBytes($memory_limit) / 1024 / 1024;
     $this->set('memory_limit', $memory_limit);
     parent::display('admin/themes/compiler');
 }
Esempio n. 6
0
 /**
  * Purges the less cache files on the site
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function clearCache()
 {
     // Check for request forgeries
     FD::checkToken();
     // Determines if we should purge all javascripts.
     $purgeScripts = $this->input->get('script-cache', false, 'bool');
     // Clear javascript files
     if ($purgeScripts) {
         FD::purgeJavascriptResources();
     }
     // Determines if we should purge the cached less stylesheets
     $purgeCssCache = $this->input->get('stylesheet-cache', false, 'bool');
     if ($purgeCssCache) {
         $templates = JFolder::folders(EASYSOCIAL_SITE_THEMES);
         foreach ($templates as $template) {
             $task = FD::stylesheet('site', $template)->purge();
         }
         // Compile admin themes
         $templates = JFolder::folders(EASYSOCIAL_ADMIN_THEMES);
         foreach ($templates as $template) {
             $task = FD::stylesheet('admin', $template)->purge();
         }
         // Compile modules
         $modules = FD::stylesheet('module')->modules();
         foreach ($modules as $module) {
             $task = FD::stylesheet('module', $module)->purge();
         }
     }
     $message = JText::sprintf('COM_EASYSOCIAL_CACHE_PURGED_FROM_SITE');
     $this->view->setMessage($message, SOCIAL_MSG_SUCCESS);
     return $this->view->call(__FUNCTION__);
 }
Esempio n. 7
0
 public function purge()
 {
     $location = JRequest::getCmd('location');
     $name = JRequest::getCmd('name');
     $override = JRequest::getBool('override', false);
     $view = $this->getCurrentView();
     $stylesheet = FD::stylesheet($location, $name, $override);
     $task = $stylesheet->purge();
     return $view->call(__FUNCTION__, $task);
 }
Esempio n. 8
0
 /**
  * Builds the css for the module
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function css()
 {
     $stylesheet = FD::stylesheet('module', $this->name);
     $stylesheet->attach();
 }