Example #1
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');
         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);
     }
 }
Example #2
0
    public function execute() {
        WFToken::checkToken() or die('Access to this resource is restricted');

        // JSON request or upload action
        if ($this->isRequest()) {
            $request = WFRequest::getInstance();
            $request->process();
        } else {
            $wf = WFEditor::getInstance();

            $version = $this->getVersion();
            $name = $this->getName();

            // process javascript languages
            if (JRequest::getWord('task') == 'loadlanguages') {
                wfimport('admin.classes.language');

                $parser = new WFLanguageParser(array(
                            'plugins' => array($name),
                            'sections' => array('dlg', $name . '_dlg', 'colorpicker'),
                            'mode' => 'plugin'
                        ));

                $data = $parser->load();
                $parser->output($data);
            }

            // load core language
            WFLanguage::load('com_jce', JPATH_ADMINISTRATOR);
            // Load Plugin language
            WFLanguage::load('com_jce_' . trim($this->getName()));
            
            // set default plugin version
            $plugin_version = $this->getPluginVersion();

            // add plugin version
            if ($plugin_version && $plugin_version != $version) {
                $version .= '-' . $plugin_version;
            }

            // create the document
            $document = WFDocument::getInstance(array(
                'version'   => $version,
                'title'     => WFText::_('WF_' . strtoupper($this->getName() . '_TITLE')),
                'name'      => $name,
                'language'  => WFLanguage::getTag(),
                'direction' => WFLanguage::getDir(),
                'compress_javascript' => $this->getParam('editor.compress_javascript', 0),
                'compress_css' => $this->getParam('editor.compress_css', 0)
            ));

            // set standalone mode
            $document->set('standalone', JRequest::getInt('standalone', 0));

            // create display
            $this->display();

            // ini language
            $document->addScript(array('index.php?option=com_jce&view=editor&' . $document->getQueryString(array('task' => 'loadlanguages', 'lang' => WFLanguage::getCode()))), 'joomla');

            // pack assets if required
            $document->pack(true, $this->getParam('editor.compress_gzip', 0));

            // get the view
            $view = $this->getView();

            // set body output
            $document->setBody($view->loadTemplate());

            // render document		
            $document->render();
        }
    }
 public function loadLanguages()
 {
     // check token
     WFToken::checkToken('GET') or die('RESTRICTED');
     wfimport('admin.classes.language');
     $parser = new WFLanguageParser(array('plugins' => $this->getPlugins()));
     $data = $parser->load();
     $parser->output($data);
 }
Example #4
0
 public function loadLanguages()
 {
     wfimport('admin.classes.language');
     $parser = new WFLanguageParser();
     $data = $parser->load();
     $parser->output($data);
 }
Example #5
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);
                 }
                 if (WF_INI_LANG) {
                     wfimport('admin.classes.language');
                     $parser = new WFLanguageParser(array('plugins' => array($this->getName()), 'sections' => array('dlg', $this->getName() . '_dlg'), 'mode' => 'plugin'));
                     $data = $parser->load();
                     $packer->setContentEnd($data);
                 }
                 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);
     }
 }
Example #6
0
 public function execute()
 {
     WFToken::checkToken() or die('RESTRICTED ACCESS');
     // JSON request or upload action
     if ($this->isRequest()) {
         $request = WFRequest::getInstance();
         $request->process();
     } else {
         $version = $this->getVersion();
         $name = $this->getName();
         // process javascript languages
         if (JRequest::getWord('task') == 'loadlanguages') {
             wfimport('admin.classes.language');
             $parser = new WFLanguageParser(array('plugins' => array($name), 'sections' => array('dlg', $name . '_dlg'), 'mode' => 'plugin'));
             $data = $parser->load();
             $parser->output($data);
         }
         $this->loadLanguage('com_jce', JPATH_ADMINISTRATOR);
         // Load Plugin language
         $this->loadPluginLanguage();
         $xml = WFXMLHelper::parseInstallManifest(WF_EDITOR_PLUGIN . '/' . $name . '.xml');
         if (isset($xml['version'])) {
             $version = $xml['version'];
         }
         // create the document
         $document = WFDocument::getInstance(array('version' => $version, 'title' => WFText::_('WF_' . strtoupper($this->getName() . '_TITLE')), 'name' => $name, 'language' => $this->getLanguageTag(), 'direction' => $this->getLanguageDir(), 'compress_javascript' => $this->getParam('editor.compress_javascript', 0), 'compress_css' => $this->getParam('editor.compress_css', 0)));
         // set standalone mode
         $document->set('standalone', JRequest::getInt('standalone', 0));
         // create display
         $this->display();
         if (WF_INI_LANG) {
             // ini language
             $document->addScript(array('index.php?option=com_jce&view=editor&' . $document->getQueryString(array('task' => 'loadlanguages'))), 'joomla');
         }
         // pack assets if required
         $document->pack(true, $this->getParam('editor.compress_gzip', 0));
         // get the view
         $view = $this->getView();
         // set body output
         $document->setBody($view->loadTemplate());
         // render document
         $document->render();
     }
 }