priority = 50; $this->enabled = class_exists('AkeebaFEFHelper'); } /** * Echoes any HTML to show before the view template. We override it to load the CSS files required for FEF. * * @param string $view The current view * @param string $task The current task * * @return void */ public function preRender($view, $task) { $useReset = $this->getOption('fef_reset', true); $useFEF = $this->getOption('load_fef', true); if ($useFEF) { \AkeebaFEFHelper::load($useReset); } $this->loadCustomCss(); parent::preRender($view, $task); } /** * Opens the FEF styling wrapper element. Our component's output will be inside this wrapper. * * @param array $classes An array of additional CSS classes to add to the outer page wrapper element. * * @return void */ protected function openPageWrapper($classes) { /** * Remove wrapper classes. By default these are classes for the Joomla 3 sidebar which is not used in FEF * components anymore. */ $removeClasses = $this->getOption('remove_wrapper_classes', [ 'j-toggle-main', 'j-toggle-transition', 'row-fluid', ]); if (!is_array($removeClasses)) { $removeClasses = explode(',', $removeClasses); } $removeClasses = array_map('trim', $removeClasses); foreach ($removeClasses as $class) { $x = array_search($class, $classes); if ($x !== false) { unset($classes[$x]); } } // Add the following classes to the wrapper div $addClasses = $this->getOption('add_wrapper_classes', ''); if (!is_array($addClasses)) { $addClasses = explode(',', $addClasses); } $addClasses = array_map('trim', $addClasses); $customClasses = implode(array_unique(array_merge($classes, $addClasses)), ' '); echo <<< HTML
HTML; } /** * Close the FEF styling wrapper element. * * @return void */ protected function closePageWrapper() { echo <<< HTML
HTML; } /** * Loads the custom CSS files defined in the custom_css renderer option. */ private function loadCustomCss() { $custom_css_raw = $this->getOption('custom_css', ''); $custom_css_raw = trim($custom_css_raw); if (empty($custom_css_raw)) { return; } $files = explode(',', $custom_css_raw); $mediaVersion = $this->container->mediaVersion; foreach ($files as $file) { $file = trim($file); if (empty($file)) { continue; } $this->container->template->addCSS($file, $mediaVersion); } } }