예제 #1
0
 public function compileLess()
 {
     // check token
     WFToken::checkToken('GET') or die('RESTRICTED');
     wfimport('admin.classes.packer');
     $wf = WFEditor::getInstance();
     $files = self::getStyleSheetsList(true);
     if (!empty($files)) {
         $packer = new WFPacker(array('files' => $files, 'type' => 'css'));
         $packer->pack(false);
     }
 }
예제 #2
0
파일: document.php 프로젝트: grlf/eyedock
 /**
  * pack function for plugins
  */
 public function pack($minify = true, $gzip = false)
 {
     if (JRequest::getCmd('task') == 'pack') {
         // check token
         WFToken::checkToken('GET') or die('RESTRICTED');
         wfimport('admin.classes.packer');
         wfimport('admin.classes.language');
         $component = WFExtensionHelper::getComponent();
         $params = new WFParameter($component->params);
         $type = JRequest::getWord('type', 'javascript');
         // create packer
         $packer = new WFPacker(array('type' => $type));
         $files = array();
         switch ($type) {
             case 'javascript':
                 $data = '';
                 foreach ($this->getScripts() as $src => $type) {
                     if (strpos($src, '://') === false && strpos($src, 'index.php') === false) {
                         $src .= preg_match('/\\.js$/', $src) ? '' : '.js';
                         $files[] = $this->urlToPath($src);
                     }
                 }
                 // parse ini language files
                 $parser = new WFLanguageParser(array('plugins' => array($this->getName()), 'sections' => array('dlg', $this->getName() . '_dlg'), 'mode' => 'plugin'));
                 $data .= $parser->load();
                 // add script declarations
                 /*foreach ($this->getScriptDeclarations() as $script) {
                       $data .= $script;
                   }*/
                 $packer->setContentEnd($data);
                 break;
             case 'css':
                 foreach ($this->getStyleSheets() as $style => $type) {
                     if (strpos($style, '://') === false && strpos($style, 'index.php') === false) {
                         $style .= preg_match('/\\.css$/', $style) ? '' : '.css';
                         $files[] = $this->urlToPath($style);
                     }
                 }
                 break;
         }
         $packer->setFiles($files);
         $packer->pack($minify, $gzip);
     }
 }
예제 #3
0
 /**
  * pack function for plugins
  */
 public function pack($minify = true, $gzip = false)
 {
     if (JRequest::getCmd('task') == 'pack') {
         // check token
         WFToken::checkToken('GET') or die('RESTRICTED');
         wfimport('admin.classes.packer');
         $component = WFExtensionHelper::getComponent();
         $params = new WFParameter($component->params);
         $type = JRequest::getWord('type', 'javascript');
         // javascript
         $packer = new WFPacker(array('type' => $type));
         $files = array();
         switch ($type) {
             case 'javascript':
                 foreach ($this->getScripts() as $script => $type) {
                     $script .= preg_match('/\\.js$/', $script) ? '' : '.js';
                     $files[] = $this->urlToPath($script);
                 }
                 break;
             case 'css':
                 foreach ($this->getStyleSheets() as $style => $type) {
                     $style .= preg_match('/\\.css$/', $style) ? '' : '.css';
                     $files[] = $this->urlToPath($style);
                 }
                 break;
         }
         $packer->setFiles($files);
         $packer->pack($minify, $gzip);
     }
 }
예제 #4
0
 /**
  * Overridden pack function for plugins
  */
 public function pack()
 {
     if (JRequest::getCmd('task') == 'pack') {
         require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'parameter.php';
         require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'packer.php';
         $component =& JComponentHelper::getComponent('com_ckeditor');
         $params = new WFParameter($component->params);
         $cache = $params->get('editor.compress_cache', 0);
         $compress = $params->get('editor.compress_minify', 0);
         $gzip = $params->get('editor.compress_gzip', 0);
         $type = JRequest::getWord('type', 'javascript');
         // javascript
         $packer = new WFPacker(array('type' => $type));
         $files = array();
         switch ($type) {
             case 'javascript':
                 foreach ($this->getScripts() as $script => $type) {
                     $script .= preg_match('/\\.js$/', $script) ? '' : '.js';
                     $files[] = $this->urlToPath($script);
                 }
                 break;
             case 'css':
                 foreach ($this->getStyleSheets() as $style => $type) {
                     $style .= preg_match('/\\.css$/', $style) ? '' : '.css';
                     $files[] = $this->urlToPath($style);
                 }
                 break;
         }
         $packer->setFiles($files);
         $packer->pack($cache, $compress, $gzip);
     }
 }
예제 #5
0
 /**
  * Pack / compress editor files
  */
 public function pack()
 {
     // check token
     WFToken::checkToken('GET') or die('RESTRICTED');
     $wf = WFEditor::getInstance();
     require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . '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 ($wf->checkUser()) {
         $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();
             // Add core languages
             foreach ($languages as $language) {
                 $file = WF_EDITOR . DS . "tiny_mce/langs/" . $language . ".js";
                 if (!JFile::exists($file)) {
                     $file = WF_EDITOR . DS . "tiny_mce/langs/en.js";
                 }
                 $files[] = $file;
             }
             // Add themes
             foreach ($themes as $theme) {
                 foreach ($languages as $language) {
                     $file = WF_EDITOR . DS . "tiny_mce/themes/" . $theme . "/langs/" . $language . ".js";
                     if (!JFile::exists($file)) {
                         $file = WF_EDITOR . DS . "tiny_mce/themes/" . $theme . "/langs/en.js";
                     }
                     $files[] = $file;
                 }
             }
             // Add plugins
             foreach ($plugins as $plugin) {
                 foreach ($languages as $language) {
                     $file = WF_EDITOR . DS . "tiny_mce/plugins/" . $plugin . "/langs/" . $language . ".js";
                     if (!JFile::exists($file)) {
                         $file = WF_EDITOR . DS . "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 . DS . "tiny_mce/tiny_mce" . $suffix . ".js";
             // Add core languages
             foreach ($languages as $language) {
                 $file = WF_EDITOR . DS . "tiny_mce/langs/" . $language . ".js";
                 if (!JFile::exists($file)) {
                     $file = WF_EDITOR . DS . "tiny_mce/langs/en.js";
                 }
                 $files[] = $file;
             }
             // Add themes
             foreach ($themes as $theme) {
                 $files[] = WF_EDITOR . DS . "tiny_mce/themes/" . $theme . "/editor_template" . $suffix . ".js";
                 foreach ($languages as $language) {
                     $file = WF_EDITOR . DS . "tiny_mce/themes/" . $theme . "/langs/" . $language . ".js";
                     if (!JFile::exists($file)) {
                         $file = WF_EDITOR . DS . "tiny_mce/themes/" . $theme . "/langs/en.js";
                     }
                     $files[] = $file;
                 }
             }
             // Add plugins
             foreach ($plugins as $plugin) {
                 $files[] = WF_EDITOR . DS . "tiny_mce/plugins/" . $plugin . "/editor_plugin" . $suffix . ".js";
                 foreach ($languages as $language) {
                     $file = WF_EDITOR . DS . "tiny_mce/plugins/" . $plugin . "/langs/" . $language . ".js";
                     if (!JFile::exists($file)) {
                         $file = WF_EDITOR . DS . "tiny_mce/plugins/" . $plugin . "/langs/en.js";
                     }
                     if (JFile::exists($file)) {
                         $files[] = $file;
                     }
                 }
             }
             // add Editor file
             $files[] = WF_EDITOR . DS . 'libraries' . DS . 'js' . DS . 'editor.js';
             break;
         case 'css':
             $context = JRequest::getWord('context', 'editor');
             if ($context == 'content') {
                 $files = array();
                 $files[] = WF_EDITOR_THEMES . DS . $themes[0] . DS . 'skins' . DS . $toolbar[0] . DS . '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 . DS . $plugin . DS . 'css' . DS . 'content.css';
                     if (JFile::exists($content)) {
                         $files[] = $content;
                     }
                 }
             } else {
                 $files = array();
                 $files[] = WF_EDITOR_LIBRARIES . DS . 'css' . DS . 'editor.css';
                 $dialog = $wf->getParam('editor.dialog_theme', 'jce');
                 $files[] = WF_EDITOR_THEMES . DS . $themes[0] . DS . 'skins' . DS . $toolbar[0] . DS . 'ui.css';
                 if (isset($toolbar[1])) {
                     $files[] = WF_EDITOR_THEMES . DS . $themes[0] . DS . 'skins' . DS . $toolbar[0] . DS . 'ui_' . $toolbar[1] . '.css';
                 }
                 // get external styles from config class for each plugin
                 foreach ($plugins as $plugin) {
                     $class = WF_EDITOR_PLUGINS . DS . $plugin . DS . 'classes' . DS . '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->getContentEnd($fonts);
                 }
             }
             break;
     }
     $packer->setFiles($files);
     $packer->pack();
 }
예제 #6
0
 function compile()
 {
     WFToken::checkToken() or die('RESTRICTED ACCESS');
     wfimport('admin.classes.packer');
     $base = dirname(dirname(__FILE__));
     $editor = JRequest::getWord('editor', 'codemirror');
     $theme = JRequest::getWord('theme', 'textmate');
     switch (JRequest::getWord('type', 'base')) {
         case 'base':
             $files = array();
             $files[] = $base . DS . 'js' . DS . 'codemirror' . DS . 'base.js';
             $type = 'javsacript';
             break;
         case 'parser':
             $files = array();
             $files[] = $base . DS . 'js' . DS . 'codemirror' . DS . 'parser.js';
             // javascript
             $type = 'javsacript';
             break;
         case 'css':
             $path = $base . DS . 'css' . DS . 'codemirror';
             $files = array($path . DS . 'editor.css', $path . DS . 'theme' . DS . $theme . '.css');
             $type = 'css';
             break;
     }
     $packer = new WFPacker(array('type' => $type));
     // set files
     $packer->setFiles($files);
     // pack!
     $packer->pack(true, $this->getParam('editor.compress_gzip', 0));
 }
예제 #7
0
 /**
  * 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
             foreach ($themes as $theme) {
                 $files[] = WF_EDITOR . '/' . "tiny_mce/themes/" . $theme . "/editor_template" . $suffix . ".js";
             }
             // Add plugins
             foreach ($plugins as $plugin) {
                 $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 = 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')));
                         }
                     }
                 }
             }
             break;
     }
     $packer->setFiles($files);
     $packer->pack();
 }