/** * Pack / compress editor files */ public function pack() { // check token WFToken::checkToken('GET') or die('RESTRICTED'); wfimport('admin.classes.packer'); wfimport('admin.classes.language'); $wf = WFEditor::getInstance(); $type = JRequest::getWord('type', 'javascript'); // javascript $packer = new WFPacker(array('type' => $type)); $themes = 'none'; $plugins = array(); $suffix = JRequest::getWord('suffix', ''); $component_id = JRequest::getInt('component_id', 0); // if a profile is set if ($this->profile) { $themes = 'advanced'; $plugins = $this->getPlugins(); } $themes = explode(',', $themes); // toolbar theme $toolbar = explode('.', $wf->getParam('editor.toolbar_theme', 'default')); switch ($type) { case 'language': $files = array(); $data = $this->loadLanguages(array(), array(), '(^dlg$|_dlg$)', true); $packer->setText($data); break; case 'javascript': $files = array(); // add core file $files[] = WF_EDITOR . "/tiny_mce/tiny_mce" . $suffix . ".js"; // Add themes in dev mode if (!self::$version) { foreach ($themes as $theme) { $files[] = WF_EDITOR . "/tiny_mce/themes/" . $theme . "/editor_template" . $suffix . ".js"; } } $core = array('autolink', 'cleanup', 'core', 'code', 'colorpicker', 'upload', 'format'); // Add plugins foreach ($plugins as $plugin) { // skip core plugins in production mode if (self::$version && in_array($plugin, $core)) { continue; } $files[] = WF_EDITOR . "/tiny_mce/plugins/" . $plugin . "/editor_plugin" . $suffix . ".js"; } // add Editor file $files[] = WF_EDITOR . '/libraries/js/editor.js'; // parse ini language files $parser = new WFLanguageParser(); $data = $parser->load(); // add to packer $packer->setContentEnd($data); break; case 'css': $context = JRequest::getWord('context', 'editor'); if ($context == 'content') { $files = array(); $files[] = WF_EDITOR_THEMES . '/' . $themes[0] . '/skins/' . $toolbar[0] . '/content.css'; // get template stylesheets $styles = self::getStyleSheetsList(true); foreach ($styles as $style) { if (JFile::exists($style)) { $files[] = $style; } } // load content styles dor each plugin if they exist foreach ($plugins as $plugin) { $content = WF_EDITOR_PLUGINS . '/' . $plugin . '/css/content.css'; if (JFile::exists($content)) { $files[] = $content; } } } else { if ($context == 'preview') { $files = array(); $files[] = WF_EDITOR_PLUGINS . '/preview/css/preview.css'; // get template stylesheets $styles = self::getStyleSheetsList(true); foreach ($styles as $style) { if (JFile::exists($style)) { $files[] = $style; } } } else { $files = array(); $files[] = WF_EDITOR_LIBRARIES . '/css/editor.css'; $dialog = $wf->getParam('editor.dialog_theme', 'jce'); $files[] = WF_EDITOR_THEMES . '/' . $themes[0] . '/skins/' . $toolbar[0] . '/ui.css'; if (isset($toolbar[1])) { $files[] = WF_EDITOR_THEMES . '/' . $themes[0] . '/skins/' . $toolbar[0] . '/ui_' . $toolbar[1] . '.css'; } // get external styles from config class for each plugin foreach ($plugins as $plugin) { $class = WF_EDITOR_PLUGINS . '/' . $plugin . '/classes/config.php'; if (JFile::exists($class)) { require_once $class; $classname = 'WF' . ucfirst($plugin) . 'PluginConfig'; if (class_exists($classname) && method_exists(new $classname(), 'getStyles')) { $files = array_merge($files, (array) call_user_func(array($classname, 'getStyles'))); } } } } } break; } $packer->setFiles($files); $packer->pack(); }
/** * Pack / compress editor files */ public function pack() { // check token WFToken::checkToken('GET') or die('RESTRICTED'); $wf = WFEditor::getInstance(); require_once JPATH_COMPONENT_ADMINISTRATOR . '/classes/packer.php'; $type = JRequest::getWord('type', 'javascript'); // javascript $packer = new WFPacker(array('type' => $type)); $themes = 'none'; $plugins = array(); $languages = $wf->getLanguage(); $suffix = JRequest::getWord('suffix', ''); $component_id = JRequest::getInt('component_id', 0); // if a profile is set if ($this->profile) { $themes = 'advanced'; $plugins = $this->getPlugins(); } $languages = explode(',', $languages); $themes = explode(',', $themes); // toolbar theme $toolbar = explode('.', $wf->getParam('editor.toolbar_theme', 'default')); switch ($type) { case 'language': $files = array(); if (WF_INI_LANG) { $data = $this->loadLanguages(array(), array(), '(^dlg$|_dlg$)', true); $packer->setText($data); } else { // Add core languages foreach ($languages as $language) { $file = WF_EDITOR . '/' . "tiny_mce/langs/" . $language . ".js"; if (!JFile::exists($file)) { $file = WF_EDITOR . '/' . "tiny_mce/langs/en.js"; } $files[] = $file; } // Add themes foreach ($themes as $theme) { foreach ($languages as $language) { $file = WF_EDITOR . '/' . "tiny_mce/themes/" . $theme . "/langs/" . $language . ".js"; if (!JFile::exists($file)) { $file = WF_EDITOR . '/' . "tiny_mce/themes/" . $theme . "/langs/en.js"; } $files[] = $file; } } // Add plugins foreach ($plugins as $plugin) { foreach ($languages as $language) { $file = WF_EDITOR . '/' . "tiny_mce/plugins/" . $plugin . "/langs/" . $language . ".js"; if (!JFile::exists($file)) { $file = WF_EDITOR . '/' . "tiny_mce/plugins/" . $plugin . "/langs/en.js"; } if (JFile::exists($file)) { $files[] = $file; } } } // reset type $type = 'javascript'; } break; case 'javascript': $files = array(); // add core file $files[] = WF_EDITOR . '/' . "tiny_mce/tiny_mce" . $suffix . ".js"; if (!WF_INI_LANG) { // Add core languages foreach ($languages as $language) { $file = WF_EDITOR . '/' . "tiny_mce/langs/" . $language . ".js"; if (!JFile::exists($file)) { $file = WF_EDITOR . '/' . "tiny_mce/langs/en.js"; } $files[] = $file; } } // Add themes foreach ($themes as $theme) { $files[] = WF_EDITOR . '/' . "tiny_mce/themes/" . $theme . "/editor_template" . $suffix . ".js"; if (!WF_INI_LANG) { foreach ($languages as $language) { $file = WF_EDITOR . '/' . "tiny_mce/themes/" . $theme . "/langs/" . $language . ".js"; if (!JFile::exists($file)) { $file = WF_EDITOR . '/' . "tiny_mce/themes/" . $theme . "/langs/en.js"; } $files[] = $file; } } } // Add plugins foreach ($plugins as $plugin) { $files[] = WF_EDITOR . '/' . "tiny_mce/plugins/" . $plugin . "/editor_plugin" . $suffix . ".js"; if (!WF_INI_LANG) { foreach ($languages as $language) { $file = WF_EDITOR . '/' . "tiny_mce/plugins/" . $plugin . "/langs/" . $language . ".js"; if (!JFile::exists($file)) { $file = WF_EDITOR . '/' . "tiny_mce/plugins/" . $plugin . "/langs/en.js"; } if (JFile::exists($file)) { $files[] = $file; } } } } // add Editor file $files[] = WF_EDITOR . '/libraries/js/editor.js'; if (WF_INI_LANG) { wfimport('admin.classes.language'); $parser = new WFLanguageParser(); $data = $parser->load(); $packer->setContentEnd($data); } break; case 'css': $context = JRequest::getWord('context', 'editor'); if ($context == 'content') { $files = array(); $files[] = WF_EDITOR_THEMES . '/' . $themes[0] . '/skins/' . $toolbar[0] . '/content.css'; // get template stylesheets $styles = explode(',', $this->getStyleSheets(true)); foreach ($styles as $style) { if (JFile::exists($style)) { $files[] = $style; } } // load content styles dor each plugin if they exist foreach ($plugins as $plugin) { $content = WF_EDITOR_PLUGINS . '/' . $plugin . '/css/content.css'; if (JFile::exists($content)) { $files[] = $content; } } } else { $files = array(); $files[] = WF_EDITOR_LIBRARIES . '/css/editor.css'; $dialog = $wf->getParam('editor.dialog_theme', 'jce'); $files[] = WF_EDITOR_THEMES . '/' . $themes[0] . '/skins/' . $toolbar[0] . '/ui.css'; if (isset($toolbar[1])) { $files[] = WF_EDITOR_THEMES . '/' . $themes[0] . '/skins/' . $toolbar[0] . '/ui_' . $toolbar[1] . '.css'; } // get external styles from config class for each plugin foreach ($plugins as $plugin) { $class = WF_EDITOR_PLUGINS . '/' . $plugin . '/classes/config.php'; if (JFile::exists($class)) { require_once $class; $classname = 'WF' . ucfirst($plugin) . 'PluginConfig'; if (class_exists($classname) && method_exists(new $classname(), 'getStyles')) { $files = array_merge($files, (array) call_user_func(array($classname, 'getStyles'))); } } } $fonts = trim(self::getCustomFonts($this->getStyleSheets(true))); if (!empty($fonts)) { $packer->setContentEnd($fonts); } } break; } $packer->setFiles($files); $packer->pack(); }