Esempio n. 1
0
 function display($tpl = null)
 {
     wfimport('admin.models.updates');
     $mainframe = JFactory::getApplication();
     $model = $this->getModel();
     $version = $model->getVersion();
     $component = WFExtensionHelper::getComponent();
     // get params definitions
     $params = new WFParameter($component->params, '', 'preferences');
     $canUpdate = WFModelUpdates::canUpdate() && $model->authorize('installer');
     $options = array('feed' => (int) $params->get('feed', 0), 'updates' => (int) $params->get('updates', $canUpdate ? 1 : 0), 'labels' => array('feed' => WFText::_('WF_CPANEL_FEED_LOAD'), 'updates' => WFText::_('WF_UPDATES'), 'updates_available' => WFText::_('WF_UPDATES_AVAILABLE')));
     $this->document->addScript('components/com_jce/media/js/cpanel.js?version=' . $model->getVersion());
     $this->document->addScriptDeclaration('jQuery(document).ready(function($){$.jce.CPanel.init(' . json_encode($options) . ')});');
     if ($model->authorize('preferences')) {
         WFToolbarHelper::preferences();
     }
     if ($model->authorize('installer')) {
         WFToolbarHelper::updates($canUpdate);
     }
     WFToolbarHelper::help('cpanel.about');
     $this->assignRef('icons', $icons);
     $this->assignRef('model', $model);
     $this->assignRef('installer', $installer);
     $this->assignRef('params', $params);
     $this->assignRef('version', $version);
     parent::display($tpl);
 }
Esempio n. 2
0
 function getStyles()
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     wfimport('admin.helpers.extension');
     $view = JRequest::getCmd('view', 'cpanel');
     $component = WFExtensionHelper::getComponent();
     $params = new WFParameter($component->params);
     $theme = $params->get('preferences.theme', 'jce');
     $site_path = JPATH_COMPONENT_SITE . DS . 'editor' . DS . 'libraries' . DS . 'css';
     $admin_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'media' . DS . 'css';
     // Load styles
     $styles = array();
     if (!JFolder::exists($site_path . DS . 'jquery' . DS . $theme)) {
         $theme = 'jce';
     }
     if (JFolder::exists($site_path . DS . 'jquery' . DS . $theme)) {
         $files = JFolder::files($site_path . DS . 'jquery' . DS . $theme, '\\.css');
         foreach ($files as $file) {
             $styles[] = 'components/com_jce/editor/libraries/css/jquery/' . $theme . '/' . $file;
         }
     }
     // admin global css
     $styles = array_merge($styles, array('administrator/components/com_jce/media/css/global.css'));
     if (JFile::exists($admin_path . DS . $view . '.css')) {
         $styles[] = 'administrator/components/com_jce/media/css/' . $view . '.css';
     }
     return $styles;
 }
Esempio n. 3
0
 public function fetchElement($name, $value, &$node, $control_name)
 {
     jimport('joomla.plugin.helper');
     wfimport('admin.helpers.extension');
     $language = JFactory::getLanguage();
     $plugins = JPluginHelper::getPlugin('search');
     // use tested defaults
     if (!$value) {
         $value = array('categories', 'contacts', 'content', 'newsfeeds', 'weblinks');
     } else {
         $value = (array) $value;
     }
     //$html  = '<span style="display:inline-block;"><input class="checkbox-list-toggle-all" type="checkbox"'. $checked .' /><label>'. WFText::_('WF_PROFILES_TOGGLE_ALL') . '</label>';
     $html = '<span style="display:inline-block;" data-parent="' . preg_replace(array('#^params#', '#([^\\w]+)#'), '', $control_name) . $node->attributes()->parent . '"><ul class="checkbox-list">';
     foreach ($plugins as $item) {
         $plugin = WFExtensionHelper::getPlugin(null, $item->name, 'search');
         $extension = 'plg_' . $plugin->folder . '_' . $plugin->element;
         $language->load($extension) || $language->load($extension, JPATH_ADMINISTRATOR);
         $language->load($extension . '.sys') || $language->load($extension . '.sys', JPATH_ADMINISTRATOR);
         $checked = in_array($plugin->element, $value) ? ' checked="checked"' : '';
         $html .= '<li><input type="checkbox" name="' . $control_name . '[' . $name . '][]" value="' . $plugin->element . '"' . $checked . ' /><label>' . JText::_($plugin->name) . '</label></li>';
     }
     $html .= '</ul></span>';
     return $html;
 }
Esempio n. 4
0
 function display($tpl = null)
 {
     wfimport('admin.models.updates');
     $mainframe = JFactory::getApplication();
     $model = $this->getModel();
     $version = $model->getVersion();
     $component = WFExtensionHelper::getComponent();
     // get params definitions
     $params = new WFParameter($component->params, '', 'preferences');
     $canUpdate = WFModelUpdates::canUpdate() && WFModel::authorize('installer');
     $options = array('feed' => (int) $params->get('feed', 0), 'updates' => (int) $params->get('updates', $canUpdate ? 1 : 0), 'labels' => array('feed' => WFText::_('WF_CPANEL_FEED_LOAD'), 'updates' => WFText::_('WF_UPDATES'), 'updates_available' => WFText::_('WF_UPDATES_AVAILABLE')));
     JHtml::_('behavior.modal');
     $this->addScript('components/com_jce/media/js/cpanel.js');
     $this->addScriptDeclaration('jQuery.jce.Cpanel.options = ' . json_encode($options) . ';');
     // load styles
     $this->addStyleSheet(JURI::root(true) . '/administrator/components/com_jce/media/css/cpanel.css');
     if (WFModel::authorize('preferences')) {
         WFToolbarHelper::preferences();
     }
     if (WFModel::authorize('installer')) {
         WFToolbarHelper::updates($canUpdate);
     }
     WFToolbarHelper::help('cpanel.about');
     $views = array('config', 'profiles', 'installer', 'browser', 'mediabox');
     $icons = array();
     foreach ($views as $view) {
         // check if its allowed...
         if (WFModel::authorize($view) === false) {
             continue;
         }
         $attribs = array('target="_self"');
         $title = 'WF_' . strtoupper($view);
         $description = 'WF_' . strtoupper($view) . '_DESC';
         $link = 'index.php?option=com_jce&amp;view=' . $view;
         if ($view == 'browser') {
             $link = WFModel::getBrowserLink();
             $component = WFExtensionHelper::getComponent();
             // get params definitions
             $params = new WFParameter($component->params, '', 'preferences');
             $width = (int) $params->get('browser_width', 790);
             $height = (int) $params->get('browser_height', 560);
             if (empty($link)) {
                 continue;
             }
             $attribs = array('target="_blank"', 'class="browser"', 'onclick="Joomla.modal(this, \'' . $link . '\', ' . $width . ', ' . $height . ');return false;"');
             $title = 'WF_' . strtoupper($view) . '_TITLE';
             $description = 'WF_CPANEL_' . strtoupper($view);
         }
         // if its mediabox, check the plugin is installed and enabled
         if ($view == 'mediabox' && !JPluginHelper::isEnabled('system', 'jcemediabox')) {
             continue;
         }
         $icons[] = '<li class="cpanel-icon wf-tooltip" title="' . WFText::_($title) . '::' . WFText::_($description) . '"><a id="wf-browser-link" href="' . $link . '"' . implode(' ', $attribs) . '><span class="' . $view . '"></span>' . WFText::_($title) . '</a></li>';
     }
     $this->assign('icons', $icons);
     $this->assign('model', $model);
     $this->assign('params', $params);
     $this->assign('version', $version);
     parent::display($tpl);
 }
 function display($tpl = null)
 {
     wfimport('admin.models.updates');
     $mainframe = JFactory::getApplication();
     $model = $this->getModel();
     $installer = WFInstaller::getInstance();
     $version = $model->getVersion();
     // Check Groups DB
     if (!$installer->profiles) {
         $link = JHTML::link('index.php?option=com_jce&amp;task=repair&amp;table=profiles', WFText::_('WF_DB_CREATE_RESTORE'));
         $mainframe->enqueueMessage(WFText::_('WF_DB_PROFILES_ERROR') . ' - ' . $link, 'error');
     }
     $component = WFExtensionHelper::getComponent();
     // get params definitions
     $params = new WFParameter($component->params, '', 'preferences');
     $canUpdate = WFModelUpdates::canUpdate();
     $options = array('feed' => (int) $params->get('feed', 0), 'updates' => (int) $params->get('updates', $canUpdate ? 1 : 0), 'labels' => array('feed' => WFText::_('WF_CPANEL_FEED_LOAD'), 'updates' => WFText::_('WF_UPDATES'), 'updates_available' => WFText::_('WF_UPDATES_AVAILABLE')));
     $this->document->addScript('components/com_jce/media/js/cpanel.js?version=' . $model->getVersion());
     $this->document->addScriptDeclaration('jQuery(document).ready(function($){$.jce.CPanel.init(' . json_encode($options) . ')});');
     WFToolbarHelper::preferences();
     WFToolbarHelper::updates($canUpdate);
     WFToolbarHelper::help('cpanel.about');
     $this->assignRef('icons', $icons);
     $this->assignRef('model', $model);
     $this->assignRef('installer', $installer);
     $this->assignRef('params', $params);
     $this->assignRef('version', $version);
     parent::display($tpl);
 }
Esempio n. 6
0
 public function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('RESTRICTED');
     $row = WFExtensionHelper::getPlugin(null, 'jcemediabox', 'system');
     $task = $this->getTask();
     // remove id for Joomla! 2.5+
     if ($row->extension_id) {
         unset($row->id);
     }
     if (!$row->bind(JRequest::get('post'))) {
         JError::raiseError(500, $row->getError());
     }
     if (!$row->check()) {
         JError::raiseError(500, $row->getError());
     }
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
     }
     $row->checkin();
     $msg = JText::sprintf('WF_MEDIABOX_SAVED');
     switch ($task) {
         case 'apply':
             $this->setRedirect('index.php?option=com_jce&view=mediabox', $msg);
             break;
         case 'save':
         default:
             $this->setRedirect('index.php?option=com_jce&view=cpanel', $msg);
             break;
     }
 }
Esempio n. 7
0
 /**
  * Check for extension updates
  * @return String JSON string of updates
  */
 public function check()
 {
     $result = false;
     // Get all extensions and version numbers
     $data = array('task' => 'check', 'jversion' => WF_JOOMLA15 ? '1.5' : '2.5');
     wfimport('admin.helpers.extension');
     $component = WFExtensionHelper::getComponent();
     $params = new WFParameter($component->params, '', 'preferences');
     // get update key
     $key = $params->get('updates_key', '');
     $type = $params->get('updates_type', '');
     // encode it
     if (!empty($key)) {
         $data['key'] = urlencode($key);
     }
     if ($type) {
         $data['type'] = $type;
     }
     $req = array();
     // create request data
     foreach ($this->getVersions() as $type => $extension) {
         foreach ($extension as $item => $value) {
             $data[$type . '[' . urlencode($item) . ']'] = urlencode($value);
         }
     }
     foreach ($data as $key => $value) {
         $req[] = $key . '=' . urlencode($value);
     }
     // connect
     $result = $this->connect(self::$updateURL, implode('&', $req));
     return $result;
 }
Esempio n. 8
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     $client = JRequest::getWord('client', 'admin');
     $model = $this->getModel();
     $this->document->setTitle(WFText::_('WF_PREFERENCES_TITLE'));
     $this->document->addStyleSheet('templates/system/css/system.css');
     $component = WFExtensionHelper::getComponent();
     $xml = JPATH_COMPONENT . '/models/preferences.xml';
     // get params definitions
     $params = new WFParameter($component->params, $xml, 'preferences');
     $params->addElementPath(JPATH_COMPONENT . '/elements');
     if (WFModel::authorize('admin')) {
         $form = $model->getForm('permissions');
     } else {
         $form = null;
     }
     $this->assign('params', $params);
     $this->assign('permissons', $form);
     $this->addStyleSheet('components/com_jce/media/css/preferences.css');
     $this->addScript('components/com_jce/media/js/preferences.js');
     if (JRequest::getInt('close') == 1) {
         $this->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Preferences.close();});');
     } else {
         $this->addScriptDeclaration('jQuery(document).ready(function($){$.jce.Preferences.init();});');
     }
     parent::display($tpl);
 }
Esempio n. 9
0
 function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('RESTRICTED');
     $db = JFactory::getDBO();
     $task = $this->getTask();
     $client = JRequest::getWord('client', 'site');
     // get params
     $component = WFExtensionHelper::getComponent();
     // create params object from json string
     $params = json_decode($component->params);
     $registry = new JRegistry();
     $registry->loadArray(JRequest::getVar('params', '', 'POST', 'ARRAY'));
     // set preference object
     $params->editor = $registry->toObject();
     // set params as JSON string
     $component->params = json_encode($params);
     if (!$component->check()) {
         JError::raiseError(500, $component->getError());
     }
     if (!$component->store()) {
         JError::raiseError(500, $component->getError());
     }
     $component->checkin();
     $msg = JText::sprintf('WF_CONFIG_SAVED');
     switch ($task) {
         case 'apply':
             $this->setRedirect('index.php?option=com_jce&view=config', $msg);
             break;
         case 'save':
         default:
             $this->setRedirect('index.php?option=com_jce&view=cpanel', $msg);
             break;
     }
 }
Esempio n. 10
0
 public function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('RESTRICTED');
     $db = JFactory::getDBO();
     $post = JRequest::getVar('params', '', 'POST', 'ARRAY');
     $registry = new JRegistry();
     $registry->loadArray($post);
     // get params
     $component = WFExtensionHelper::getComponent();
     // set preferences object
     $preferences = $registry->toObject();
     if (isset($preferences->rules)) {
         $preferences->access = $preferences->rules;
         unset($preferences->rules);
     }
     // set params as JSON string
     $component->params = json_encode($preferences);
     if (!$component->check()) {
         JError::raiseError(500, $row->getError());
     }
     if (!$component->store()) {
         JError::raiseError(500, $row->getError());
     }
     $component->checkin();
     $close = 0;
     if ($this->getTask() == 'save') {
         $close = 1;
     }
     $this->setRedirect('index.php?option=com_jce&view=preferences&tmpl=component&close=' . $close, WFText::_('WF_PREFERENCES_SAVED'));
 }
Esempio n. 11
0
 function display($tpl = null)
 {
     $language = JFactory::getLanguage();
     $language->load('plg_editors_jce', JPATH_ADMINISTRATOR);
     $client = JRequest::getWord('client', 'site');
     $model = $this->getModel();
     $plugin = WFExtensionHelper::getPlugin();
     $xml = WF_EDITOR_LIBRARIES . '/xml/config/editor.xml';
     $data = null;
     // get params from editor plugin
     if ($plugin->params && $plugin->params !== "{}") {
         $data = json_decode($plugin->params);
     } else {
         $component = WFExtensionHelper::getComponent();
         // get params from component "params" field (legacy)
         if ($component->params) {
             $data = json_decode($component->params);
         }
     }
     // get params definitions
     $params = new WFParameter($data, $xml, 'editor');
     $params->addElementPath(JPATH_COMPONENT . '/elements');
     $this->assign('model', $model);
     $this->assign('params', $params);
     $this->assign('client', $client);
     WFToolbarHelper::apply();
     WFToolbarHelper::save();
     WFToolbarHelper::help('config.about');
     parent::display($tpl);
 }
Esempio n. 12
0
 /**
  * Display Preview content
  * @return void
  */
 public function showPreview()
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $dispatcher = JDispatcher::getInstance();
     $language = JFactory::getLanguage();
     // reset document type
     $document =& JFactory::getDocument();
     $document->setType('html');
     // required by module loadposition
     jimport('joomla.application.module.helper');
     wfimport('admin.helpers.extension');
     // Get variables
     $component_id = JRequest::getInt('component_id');
     // get post data
     $data = JRequest::getVar('data', '', 'POST', 'STRING', JREQUEST_ALLOWRAW);
     // cleanup data
     $data = preg_replace(array('#<!DOCTYPE([^>]+)>#i', '#<(head|title|meta)([^>]*)>([\\w\\W]+)<\\/1>#i', '#<\\/?(html|body)([^>]*)>#i'), '', rawurldecode($data));
     $component = WFExtensionHelper::getComponent($component_id);
     $params = new JParameter($component->params);
     $article = JTable::getInstance('content');
     $article->id = 0;
     $article->created_by = $user->get('id');
     $article->parameters = new JParameter('');
     $article->text = $data;
     $limitstart = 0;
     JPluginHelper::importPlugin('content');
     require_once JPATH_SITE . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'route.php';
     // set error reporting to error only
     error_reporting(E_ERROR);
     $dispatcher->trigger('onPrepareContent', array(&$article, &$params, $limitstart));
     $this->processURLS($article);
     return $article->text;
 }
Esempio n. 13
0
 public function getForm($group = null)
 {
     jimport('joomla.form.form');
     if (class_exists('JForm')) {
         JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_jce');
         $form = JForm::getInstance('com_jce.component', 'config', array('control' => 'params'), false, '/config');
         if ($group) {
             return $form->getFieldset($group);
         }
         return $form;
     } else {
         $component = WFExtensionHelper::getComponent();
         // get params definitions
         $params = json_decode($component->params);
         $rules = isset($params->access) ? $params->access : null;
         // Build the form control.
         $curLevel = 0;
         $actions = $this->getActions();
         $groups = $this->getUserGroups();
         $tabs = array('<ul class="nav nav-tabs">');
         $content = array('<div class="tabs-content">');
         foreach ($groups as $group) {
             $difLevel = $group->level - $curLevel;
             $html = array();
             $item = new StdClass();
             $id = $curLevel;
             $tabs[] = '<li><a href="#permission-' . $id . '">' . str_repeat('<span> &rsaquo; </span> ', $curLevel = $group->level) . $group->text . '</a></li>';
             $content[] = '<div id="permission-' . $id . '" class="tab-pane">';
             $content[] = '<table border="0" cellspacing="1" class="table table-striped">';
             $content[] = '<thead>';
             $content[] = '<tr>';
             $content[] = '<th><span>' . WFText::_('WF_RULES_ACTION') . '</span></th>';
             $content[] = '<th><span>' . WFText::_('WF_RULES_SELECT_SETTING') . '</span></th>';
             $content[] = '</tr>';
             $content[] = '</thead>';
             $content[] = '<tbody>';
             foreach ($actions as $action) {
                 $content[] = '<tr>';
                 $content[] = '<td><label class="tooltip" for="' . $action->name . '_' . $group->value . '" title="' . htmlspecialchars(WFText::_($action->title) . '::' . WFText::_($action->description), ENT_COMPAT, 'UTF-8') . '">' . WFText::_($action->title) . '</label></td>';
                 $content[] = '<td>';
                 $content[] = '<select name="params[rules][' . $action->name . '][' . $group->value . ']" id="' . $action->name . '_' . $group->value . '" title="' . WFText::sprintf('WF_RULES_SELECT_ALLOW_DENY_GROUP', WFText::_($action->title), trim($group->text)) . '">';
                 $assetRule = $this->checkRule($rules, $action->name, $group->value);
                 $content[] = '<option value="1"' . ($assetRule === true ? ' selected="selected"' : '') . '>' . WFText::_('WF_RULES_ALLOWED') . '</option>';
                 $content[] = '<option value="0"' . ($assetRule === false ? ' selected="selected"' : '') . '>' . WFText::_('WF_RULES_DENIED') . '</option>';
                 $content[] = '</select>&#160; ';
                 $content[] = '</td>';
                 $content[] = '</tr>';
             }
             $content[] = '</tbody>';
             $content[] = '</table>';
             $content[] = '</div>';
         }
         $tabs[] = '</ul>';
         $content[] = '</div>';
         return implode('', array_merge($tabs, $content));
     }
     return null;
 }
Esempio n. 14
0
 public function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('RESTRICTED');
     $db = JFactory::getDBO();
     $post = JRequest::getVar('params', '', 'POST', 'ARRAY');
     $registry = new JRegistry();
     $registry->loadArray($post);
     // get params
     $component = WFExtensionHelper::getComponent();
     // create params object from json string
     $params = json_decode($component->params);
     // set preferences object
     $preferences = $registry->toObject();
     if (isset($preferences->rules)) {
         jimport('joomla.access.rules');
         if (class_exists('JRules')) {
             $data = $this->filter($post);
             $rules = new JRules($data['rules']);
             $asset = JTable::getInstance('asset');
             $option = JRequest::getCmd('option');
             if (!$asset->loadByName($option)) {
                 $root = JTable::getInstance('asset');
                 $root->loadByName('root.1');
                 $asset->name = $option;
                 $asset->title = $option;
                 $asset->setLocation($root->id, 'last-child');
             }
             $asset->rules = (string) $rules;
             if (!$asset->check() || !$asset->store()) {
                 JError::raiseError(500, $asset->getError());
                 return false;
             }
             // Joomla! 1.5
         } else {
             $params->access = $preferences->rules;
         }
     }
     if (isset($preferences->preferences)) {
         $params->preferences = $preferences->preferences;
         // set params as JSON string
         $component->params = json_encode($params);
         if (!$component->check()) {
             JError::raiseError(500, $row->getError());
         }
         if (!$component->store()) {
             JError::raiseError(500, $row->getError());
         }
         $component->checkin();
     }
     $close = 0;
     if ($this->getTask() == 'save') {
         $close = 1;
     }
     $this->setRedirect('index.php?option=com_jce&view=preferences&tmpl=component&close=' . $close, WFText::_('WF_PREFERENCES_SAVED'));
 }
Esempio n. 15
0
 /**
  * Display Preview content
  * @return void
  */
 public function showPreview()
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $dispatcher = JDispatcher::getInstance();
     $language = JFactory::getLanguage();
     // reset document type
     $document =& JFactory::getDocument();
     $document->setType('html');
     // required by module loadposition
     jimport('joomla.application.module.helper');
     // load paramter class
     jimport('joomla.html.parameter');
     wfimport('admin.helpers.extension');
     // Get variables
     $component_id = JRequest::getInt('component_id');
     // get post data
     $data = JRequest::getVar('data', '', 'POST', 'STRING', JREQUEST_ALLOWRAW);
     // cleanup data
     $data = preg_replace(array('#<!DOCTYPE([^>]+)>#i', '#<(head|title|meta)([^>]*)>([\\w\\W]+)<\\/1>#i', '#<\\/?(html|body)([^>]*)>#i'), '', rawurldecode($data));
     $component = WFExtensionHelper::getComponent($component_id);
     // create params registry object
     $params = new JRegistry();
     // create empty params string
     if (!isset($component->params)) {
         $component->params = '';
     }
     // process attribs (com_content etc.)
     if ($component->attribs) {
         $params->loadString($component->attribs);
     } else {
         if (class_exists('JParameter')) {
             $params = new JParameter($component->params);
         } else {
             $params->loadString($component->params);
         }
     }
     $article = JTable::getInstance('content');
     $article->id = 0;
     $article->created_by = $user->get('id');
     $article->parameters = new JRegistry();
     $article->text = $data;
     // allow this to be skipped as some plugins can cause FATAL errors.
     if ((bool) $this->getParam('process_content', 1)) {
         $limitstart = 0;
         JPluginHelper::importPlugin('content');
         require_once JPATH_SITE . '/components/com_content/helpers/route.php';
         // set error reporting to error only
         error_reporting(E_ERROR);
         $dispatcher->trigger('onPrepareContent', array(&$article, &$params, $limitstart));
     }
     $this->processURLS($article);
     return $article->text;
 }
Esempio n. 16
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     $attributes = array();
     foreach ($node->attributes() as $k => $v) {
         if ($v != '') {
             $attributes[$k] = (string) $v;
         }
     }
     /*
      * Required to avoid a cycle of encoding &
      * html_entity_decode was used in place of htmlspecialchars_decode because
      * htmlspecialchars_decode is not compatible with PHP 4
      */
     $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES), ENT_QUOTES);
     $attributes['class'] = (string) $node->attributes()->class ? (string) $node->attributes()->class . ' text_area' : 'text_area';
     $control = $control_name . '[' . $name . ']';
     $html = '';
     $attributes['value'] = $value;
     $attributes['type'] = 'text';
     $attributes['name'] = $control;
     $attributes['id'] = preg_replace('#[^a-z0-9_-]#i', '', $control_name . $name);
     // pattern data attribute for editable select input box
     if ((string) $node->attributes()->parent) {
         $prefix = preg_replace(array('#^params#', '#([^\\w]+)#'), '', $control_name);
         $items = array();
         foreach (explode(';', (string) $node->attributes()->parent) as $item) {
             $items[] = $prefix . $item;
         }
         $attributes['data-parent'] = implode(';', $items);
     }
     $filter = isset($attributes['data-filter']) ? $attributes['data-filter'] : '';
     $html .= '<input';
     foreach ($attributes as $k => $v) {
         if (!in_array($k, array('default', 'label', 'description'))) {
             $html .= ' ' . $k . ' = "' . $v . '"';
         }
     }
     $html .= ' />';
     $component = WFExtensionHelper::getComponent();
     // get params definitions
     $params = new WFParameter($component->params, '', 'preferences');
     $width = (int) $params->get('browser_width', 780);
     $height = (int) $params->get('browser_height', 560);
     wfimport('admin.models.model');
     $model = new WFModel();
     $link = $model->getBrowserLink($attributes['id'], $filter);
     $html .= '<a href="' . $link . '" id="' . $attributes['id'] . '_browser' . '" class="browser" target="_blank" onclick="Joomla.modal(this, \'' . $link . '\', ' . $width . ', ' . $height . ');return false;" title="' . WFText::_('WF_BROWSER_TITLE') . '"><span class="browser"></span></a>';
     return $html;
 }
Esempio n. 17
0
 function display($tpl = null)
 {
     $db = JFactory::getDBO();
     $language = JFactory::getLanguage();
     $language->load('plg_editors_jce', JPATH_ADMINISTRATOR);
     $client = JRequest::getWord('client', 'site');
     $model = $this->getModel();
     $lists = array();
     $component = WFExtensionHelper::getComponent();
     $xml = WF_EDITOR_LIBRARIES . DS . 'xml' . DS . 'config' . DS . 'editor.xml';
     // get params definitions
     $params = new WFParameter($component->params, $xml, 'editor');
     $params->addElementPath(JPATH_COMPONENT . DS . 'elements');
     $this->assignRef('model', $model);
     $this->assignRef('params', $params);
     $this->assignRef('client', $client);
     WFToolbarHelper::save();
     WFToolbarHelper::apply();
     WFToolbarHelper::help('config.about');
     parent::display($tpl);
 }
Esempio n. 18
0
 public static function getPlugin($id = null, $element = 'jce', $folder = 'editors')
 {
     if (!isset(self::$plugin)) {
         self::$plugin = array();
     }
     $options = array($element, $folder);
     if (isset($id)) {
         $options[] = $id;
     }
     $signature = serialize($options);
     if (!isset(self::$plugin[$signature])) {
         if (defined('JPATH_PLATFORM')) {
             // get component table
             $plugin = JTable::getInstance('extension');
             if (!$id) {
                 $id = $plugin->find(array('type' => 'plugin', 'folder' => $folder, 'element' => $element));
             }
             $plugin->load($id);
             // map extension_id to id
             $plugin->id = $plugin->extension_id;
             // store result
             self::$plugin[$signature] = $plugin;
         } else {
             $plugin = JTable::getInstance('plugin');
             if (!$id) {
                 $db = JFactory::getDBO();
                 $query = 'SELECT id FROM #__plugins' . ' WHERE folder = ' . $db->Quote($folder) . ' AND element = ' . $db->Quote($element);
                 $db->setQuery($query);
                 $id = $db->loadResult();
             }
             $plugin->load($id);
             // store result
             self::$plugin[$signature] = $plugin;
         }
     }
     return self::$plugin[$signature];
 }
Esempio n. 19
0
 public function fetchElement($name, $value, &$node, $control_name)
 {
     jimport('joomla.plugin.helper');
     wfimport('admin.helpers.extension');
     $language = JFactory::getLanguage();
     $plugins = JPluginHelper::getPlugin('search');
     if (!$value) {
         $value = array();
     } else {
         $value = (array) $value;
     }
     //$html  = '<span style="display:inline-block;"><input class="checkbox-list-toggle-all" type="checkbox"'. $checked .' /><label>'. WFText::_('WF_PROFILES_TOGGLE_ALL') . '</label>';
     $html = '<span><ul class="checkbox-list">';
     foreach ($plugins as $item) {
         $plugin = WFExtensionHelper::getPlugin(null, $item->name, 'search');
         $extension = 'plg_' . $plugin->folder . '_' . $plugin->element;
         $language->load($extension) || $language->load($extension, JPATH_ADMINISTRATOR);
         $language->load($extension . '.sys') || $language->load($extension . '.sys', JPATH_ADMINISTRATOR);
         $checked = in_array($plugin->element, $value) || empty($value) ? ' checked="checked"' : '';
         $html .= '<li><input type="checkbox" name="' . $control_name . '[' . $name . '][]" value="' . $plugin->element . '"' . $checked . ' /><label>' . JText::_($plugin->name) . '</label></li>';
     }
     $html .= '</ul></span>';
     return $html;
 }
Esempio n. 20
0
 public function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('RESTRICTED');
     $db = JFactory::getDBO();
     $task = $this->getTask();
     // get params
     $component = WFExtensionHelper::getComponent();
     // create params array from json string
     $params = json_decode($component->params, true);
     // get params data
     $data = JRequest::getVar('params', '', 'POST', 'ARRAY');
     // clean input data
     $data = $this->cleanInput($data);
     // set editor params
     $params['editor'] = $data;
     // set params as JSON string
     $component->params = json_encode($params);
     if (!$component->check()) {
         JError::raiseError(500, $component->getError());
     }
     if (!$component->store()) {
         JError::raiseError(500, $component->getError());
     }
     $component->checkin();
     $msg = JText::sprintf('WF_CONFIG_SAVED');
     switch ($task) {
         case 'apply':
             $this->setRedirect('index.php?option=com_jce&view=config', $msg);
             break;
         case 'save':
         default:
             $this->setRedirect('index.php?option=com_jce&view=cpanel', $msg);
             break;
     }
 }
Esempio n. 21
0
 public function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('RESTRICTED');
     $db = JFactory::getDBO();
     $task = $this->getTask();
     // get plugin
     $plugin = WFExtensionHelper::getPlugin();
     // get params data
     $data = JRequest::getVar('params', '', 'POST', 'ARRAY');
     // clean input data
     $data = $this->cleanInput($data);
     // store data
     $plugin->params = json_encode($data);
     // remove "id"
     if (isset($plugin->extension_id)) {
         unset($plugin->id);
     }
     if (!$plugin->check()) {
         JError::raiseError(500, $plugin->getError());
     }
     if (!$plugin->store()) {
         JError::raiseError(500, $plugin->getError());
     }
     $plugin->checkin();
     $msg = JText::sprintf('WF_CONFIG_SAVED');
     switch ($task) {
         case 'apply':
             $this->setRedirect('index.php?option=com_jce&view=config', $msg);
             break;
         case 'save':
         default:
             $this->setRedirect('index.php?option=com_jce&view=cpanel', $msg);
             break;
     }
 }
Esempio n. 22
0
 /**
  * Get editor parameters
  * @access  public
  * @param 	array $options
  * @return 	object
  */
 public function getParams($options = array())
 {
     if (!isset(self::$params)) {
         self::$params = array();
     }
     // set blank key if not set
     if (!isset($options['key'])) {
         $options['key'] = '';
     }
     // set blank path if not set
     if (!isset($options['path'])) {
         $options['path'] = '';
     }
     $plugin = JRequest::getCmd('plugin');
     if ($plugin) {
         $options['plugin'] = $plugin;
     }
     $signature = serialize($options);
     if (empty(self::$params[$signature])) {
         wfimport('admin.helpers.extension');
         // get component
         $component = WFExtensionHelper::getComponent();
         // get params data for this profile
         $profile = $this->getProfile($plugin);
         $profile_params = array();
         $component_params = array();
         if (!empty($component->params)) {
             $component_params = json_decode($component->params, true);
             // set null as array
             if (!$component_params) {
                 $component_params = array();
             }
         }
         if ($profile) {
             $profile_params = json_decode($profile->params, true);
             // set null as array
             if (!$profile_params) {
                 $profile_params = array();
             }
         }
         // merge data and convert to json string
         $data = WFParameter::mergeParams($component_params, $profile_params);
         self::$params[$signature] = new WFParameter($data, $options['path'], $options['key']);
     }
     return self::$params[$signature];
 }
Esempio n. 23
0
 /**
  * Download update
  * @return String JSON string
  */
 public function download()
 {
     $app = JFactory::getApplication();
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     wfimport('admin.helpers.extension');
     $component = WFExtensionHelper::getComponent();
     $params = new WFParameter($component->params, '', 'preferences');
     $config = JFactory::getConfig();
     $result = array('error' => WFText::_('WF_UPDATES_DOWNLOAD_ERROR'));
     $id = JRequest::getInt('id');
     $key = $params->get('updates_key', '');
     $data = $this->connect(self::$updateURL . '&task=download&id=' . $id . '&key=' . urlencode($key));
     if ($data) {
         $data = json_decode($data);
         if (isset($data->error)) {
             return json_encode(array('error' => $data->error));
         }
         // get update file
         if ($data->name && $data->url && $data->hash) {
             // create path for package file
             $path = $app->getCfg('tmp_path') . '/' . basename($data->name);
             // download file
             if ($this->connect($data->url, null, $path)) {
                 if (JFile::exists($path) && @filesize($path) > 0) {
                     // check hash and file type
                     if ($data->hash == md5(md5_file($path)) && preg_match('/\\.(zip|tar|gz)$/', $path)) {
                         $result = array('file' => basename($path), 'hash' => $data->hash, 'installer' => $data->installer, 'type' => isset($data->type) ? $data->type : '');
                     } else {
                         // fail and delete file
                         $result = array('error' => WFText::_('WF_UPDATES_ERROR_FILE_VERIFICATION_FAIL'));
                         if (JFile::exists($path)) {
                             @JFile::delete($path);
                         }
                     }
                 } else {
                     $result = array('error' => WFText::_('WF_UPDATES_ERROR_FILE_MISSING_OR_INVALID'));
                 }
             } else {
                 $result = array('error' => WFText::_('WF_UPDATES_DOWNLOAD_ERROR_DATA_TRANSFER'));
             }
         } else {
             $result = array('error' => WFText::_('WF_UPDATES_DOWNLOAD_ERROR_MISSING_DATA'));
         }
     }
     return json_encode($result);
 }
Esempio n. 24
0
 /**
  * Get editor parameters
  * @access  public
  * @param 	array $options
  * @return 	object
  */
 public function getParams($options = array())
 {
     if (!isset(self::$params)) {
         self::$params = array();
     }
     // set blank key if not set
     if (!isset($options['key'])) {
         $options['key'] = '';
     }
     // set blank path if not set
     if (!isset($options['path'])) {
         $options['path'] = '';
     }
     $plugin = JRequest::getCmd('plugin');
     if ($plugin) {
         $options['plugin'] = $plugin;
     }
     $signature = serialize($options);
     if (empty(self::$params[$signature])) {
         wfimport('admin.helpers.extension');
         // get plugin
         $editor_plugin = WFExtensionHelper::getPlugin();
         // get params data for this profile
         $profile = $this->getProfile($plugin);
         $profile_params = array();
         $editor_params = array();
         // get params from editor plugin
         if ($editor_plugin->params && $editor_plugin->params !== "{}") {
             $editor_params['editor'] = json_decode($editor_plugin->params, true);
         } else {
             // get component
             $component = WFExtensionHelper::getComponent();
             // get params from component "params" field (legacy)
             if ($component->params && $component->params !== "{}") {
                 $data = json_decode($component->params, true);
                 if (isset($data['editor'])) {
                     $editor_params['editor'] = $data['editor'];
                 }
             }
         }
         if ($profile) {
             $profile_params = json_decode($profile->params, true);
         }
         // make sure we have an empty array if null or false
         if (empty($editor_params)) {
             $editor_params = array();
         }
         // make sure we have an empty array if null or false
         if (empty($profile_params)) {
             $profile_params = array();
         }
         // merge data and convert to json string
         $data = WFParameter::mergeParams($editor_params, $profile_params, true, false);
         self::$params[$signature] = new WFParameter($data, $options['path'], $options['key']);
     }
     return self::$params[$signature];
 }
Esempio n. 25
0
 public function buildEditor()
 {
     // get document
     $document = JFactory::getDocument();
     $wf = WFEditor::getInstance();
     // get current component
     $option = JRequest::getCmd('option');
     $component = WFExtensionHelper::getComponent(null, $option);
     // get default settings
     $settings = $this->getEditorSettings();
     // set default component id
     $component_id = 0;
     $component_id = isset($component->extension_id) ? $component->extension_id : ($component->id ? $component->id : 0);
     $version = $this->getVersion();
     // settings array for jce, tinymce etc
     $init = array();
     $profile = $wf->getProfile();
     if ($profile) {
         // get jqueryui theme
         $dialog_theme = $wf->getParam('editor.dialog_theme', 'jce');
         $dialog_theme_css = JFolder::files(WF_EDITOR_LIBRARIES . DS . 'css' . DS . 'jquery' . DS . $dialog_theme, '\\.css$');
         $settings = array_merge($settings, array('theme' => 'advanced', 'component_id' => $component_id, 'plugins' => $this->getPlugins()), $this->getToolbar($profile->rows));
         // Theme and skins
         $theme = array('toolbar_location' => array('top', 'top', 'string'), 'toolbar_align' => array('left', 'left', 'string'), 'statusbar_location' => array('bottom', 'bottom', 'string'), 'path' => array(1, 1, 'boolean'), 'resizing' => array(1, 0, 'boolean'), 'resize_horizontal' => array(1, 1, 'boolean'), 'resizing_use_cookie' => array(1, 1, 'boolean'));
         foreach ($theme as $k => $v) {
             $settings['theme_advanced_' . $k] = $wf->getParam('editor.' . $k, $v[0], $v[1], $v[2]);
         }
         if (!$wf->getParam('editor.use_cookies', 1)) {
             $settings['theme_advanced_resizing_use_cookie'] = false;
         }
         $settings['width'] = $wf->getParam('editor.width');
         $settings['height'] = $wf->getParam('editor.height');
         // 'Look & Feel'
         $settings['jquery_ui'] = JURI::root(true) . '/components/com_jce/editor/libraries/css/jquery/' . $dialog_theme . '/' . basename($dialog_theme_css[0]);
         $skin = explode('.', $wf->getParam('editor.toolbar_theme', 'default', 'default'));
         $settings['skin'] = $skin[0];
         $settings['skin_variant'] = isset($skin[1]) ? $skin[1] : '';
         $settings['body_class'] = $wf->getParam('editor.content_style_reset', $wf->getParam('editor.highcontrast', 0)) == 1 ? 'mceContentReset' : '';
         $settings['body_id'] = $wf->getParam('editor.body_id', '');
         $settings['content_css'] = $this->getStyleSheets();
         // Editor Toggle
         $settings['toggle'] = $wf->getParam('editor.toggle', 1, 1);
         $settings['toggle_label'] = htmlspecialchars($wf->getParam('editor.toggle_label', '[Toggle Editor]', '[Toggle Editor]'));
         $settings['toggle_state'] = $wf->getParam('editor.toggle_state', 1, 1);
     }
     // end profile
     //Other - user specified
     $userParams = $wf->getParam('editor.custom_config', '');
     $baseParams = array('mode', 'cleanup_callback', 'save_callback', 'file_browser_callback', 'urlconverter_callback', 'onpageload', 'oninit', 'editor_selector');
     if ($userParams) {
         $userParams = explode(';', $userParams);
         foreach ($userParams as $userParam) {
             $keys = explode(':', $userParam);
             if (!in_array(trim($keys[0]), $baseParams)) {
                 $settings[trim($keys[0])] = count($keys) > 1 ? trim($keys[1]) : '';
             }
         }
     }
     // set compression states
     $compress = array('javascript' => intval($wf->getParam('editor.compress_javascript', 0)), 'css' => intval($wf->getParam('editor.compress_css', 0)));
     // create token
     $token = WFToken::getToken();
     $query = array('component_id' => $component_id, 'version' => $version);
     $query[$token] = 1;
     // set compression
     if ($compress['javascript']) {
         $document->addScript(JURI::base(true) . '/index.php?option=com_jce&view=editor&layout=editor&task=pack&component_id=' . $component_id . '&' . $token . '=1&version=' . $version);
     } else {
         $document->addScript($this->getURL(true) . '/tiny_mce/tiny_mce.js?version=' . $version);
         // Editor
         $document->addScript($this->getURL(true) . '/libraries/js/editor.js?version=' . $version);
         // languages TODO
         //$document->addScript(JURI::base(true) . '/index.php?option=com_jce&view=editor&layout=editor&task=pack&type=language&component_id=' . $component_id . '&' . $token . '=1&version=' . $version);
     }
     // set compression
     if ($compress['css']) {
         $document->addStyleSheet(JURI::base(true) . '/index.php?option=com_jce&view=editor&layout=editor&task=pack&type=css&component_id=' . $component_id . '&' . $token . '=1&version=' . $version);
     } else {
         // CSS
         $document->addStyleSheet($this->getURL(true) . '/libraries/css/editor.css?version=' . $version);
         // get plugin styles
         $this->getPluginStyles($settings);
         // get font-face and google fonts
         $fonts = trim(self::getCustomFonts($this->getStyleSheets(true)));
         if (!empty($fonts)) {
             $document->addStyleDeclaration($fonts);
         }
     }
     // Get all optional plugin configuration options
     $this->getPluginConfig($settings);
     // pass compresison states to settings
     $settings['compress'] = json_encode($compress);
     $output = "";
     $i = 1;
     foreach ($settings as $k => $v) {
         // If the value is an array, implode!
         if (is_array($v)) {
             $v = ltrim(implode(',', $v), ',');
         }
         // Value must be set
         if ($v !== '') {
             // objects or arrays or functions or regular expression
             if (preg_match('/(\\[[^\\]*]\\]|\\{[^\\}]*\\}|function\\([^\\}]*\\}|^#(.*)#$)/', $v)) {
                 // replace hash delimiters with / for javascript regular expression
                 $v = preg_replace('@^#(.*)#$@', '/$1/', $v);
             } else {
                 if (is_bool($v)) {
                     $v = $v ? 'true' : 'false';
                 } else {
                     if (!is_numeric($v)) {
                         if (strpos($v, '"') === 0) {
                             $v = '"' . trim($v, '"') . '"';
                         } else {
                             $v = '"' . str_replace('"', '\\"', $v) . '"';
                         }
                     }
                 }
             }
             $output .= "\t\t\t" . $k . ": " . $v . "";
             if ($i < count($settings)) {
                 $output .= ",\n";
             }
         }
         // Must have 3 rows, even if 2 are blank!
         if (preg_match('/theme_advanced_buttons([1-3])/', $k) && $v == '') {
             $output .= "\t\t\t" . $k . ": \"\"";
             if ($i < count($settings)) {
                 $output .= ",\n";
             }
         }
         $i++;
     }
     $tinymce = "{\n";
     $tinymce .= preg_replace('/,?\\n?$/', '', $output) . "\n        }";
     $init[] = $tinymce;
     $document->addScriptDeclaration("\t\ttry{WFEditor.init(" . implode(',', $init) . ");}catch(e){}");
     if ($profile) {
         if ($wf->getParam('editor.callback_file')) {
             $document->addScript(JURI::root(true) . '/' . $wf->getParam('editor.callback_file'));
         }
     }
 }
Esempio n. 26
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);
     }
 }
Esempio n. 27
0
 /**
  * Overridden JTable::store to encrypt parameters
  *
  * @param   boolean  $updateNulls  True to update fields even if they are null.
  *
  * @return  boolean  True on success.
  *
  * @since   2.4
  */
 public function store($updateNulls = false)
 {
     if ($this->id && $this->params) {
         $component = WFExtensionHelper::getComponent();
         // get params definitions
         $params = new WFParameter($component->params, '', 'preferences');
         if ($params->get('secureparams', 0)) {
             $this->params = WFEncryptHelper::encrypt($this->params);
         }
     }
     return parent::store($updateNulls);
 }
Esempio n. 28
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);
     }
 }
Esempio n. 29
0
 public function buildEditor()
 {
     // get document
     $document = JFactory::getDocument();
     // get an editor instance
     $wf = WFEditor::getInstance();
     // create token
     $token = WFToken::getToken();
     // get current component
     $option = JRequest::getCmd('option');
     $component = WFExtensionHelper::getComponent(null, $option);
     // get default settings
     $settings = $this->getEditorSettings();
     // set default component id
     $component_id = 0;
     $component_id = isset($component->extension_id) ? $component->extension_id : ($component->id ? $component->id : 0);
     $version = self::getVersion();
     // settings array for jce, tinymce etc
     $init = array();
     // if a profile is set
     if (is_object($this->profile)) {
         jimport('joomla.filesystem.folder');
         $settings = array_merge($settings, array('theme' => 'advanced', 'component_id' => $component_id, 'plugins' => $this->getPlugins()), $this->getToolbar());
         // Theme and skins
         $theme = array('toolbar_location' => array('top', 'top', 'string'), 'toolbar_align' => array('left', 'left', 'string'), 'statusbar_location' => array('bottom', 'bottom', 'string'), 'path' => array(1, 1, 'boolean'), 'resizing' => array(1, 0, 'boolean'), 'resize_horizontal' => array(1, 1, 'boolean'), 'resizing_use_cookie' => array(1, 1, 'boolean'));
         // set rows key to pass to plugin config
         $settings['rows'] = $this->profile->rows;
         foreach ($theme as $k => $v) {
             $settings['theme_advanced_' . $k] = $wf->getParam('editor.' . $k, $v[0], $v[1], $v[2]);
         }
         if (!$wf->getParam('editor.use_cookies', 1)) {
             $settings['theme_advanced_resizing_use_cookie'] = false;
         }
         $settings['width'] = $wf->getParam('editor.width');
         $settings['height'] = $wf->getParam('editor.height');
         // 'Look & Feel'
         $skin = explode('.', $wf->getParam('editor.toolbar_theme', 'default', 'default'));
         $settings['skin'] = $skin[0];
         $settings['skin_variant'] = isset($skin[1]) ? $skin[1] : '';
         // get body class if any
         $body_class = $wf->getParam('editor.body_class', '');
         // check for editor reset
         $content_reset = $wf->getParam('editor.content_style_reset', $wf->getParam('editor.highcontrast', 0)) == 1 ? 'mceContentReset' : '';
         // combine body class and reset
         $settings['body_class'] = trim($body_class . ' ' . $content_reset);
         // set body id
         $settings['body_id'] = $wf->getParam('editor.body_id', '');
         // get stylesheets
         $stylesheets = (array) self::getStyleSheets();
         // set stylesheets as string
         $settings['content_css'] = implode(',', $stylesheets);
         // Editor Toggle
         $settings['toggle'] = $wf->getParam('editor.toggle', 1, 1);
         $settings['toggle_label'] = htmlspecialchars($wf->getParam('editor.toggle_label', '[Toggle Editor]', '[Toggle Editor]'));
         $settings['toggle_state'] = $wf->getParam('editor.toggle_state', 1, 1);
     }
     // end profile
     // check for joomla debug mode
     $config = JFactory::getConfig();
     if (defined('JPATH_PLATFORM')) {
         $debug = $config->get('debug');
     } else {
         $debug = $config->getValue('config.debug');
     }
     $compress = array('javascript' => false, 'css' => false);
     // set compression states
     if ((int) $debug === 0) {
         $compress = array('javascript' => (int) $wf->getParam('editor.compress_javascript', 0), 'css' => (int) $wf->getParam('editor.compress_css', 0));
     }
     // set compression
     if ($compress['css']) {
         $this->addStyleSheet(JURI::base(true) . '/index.php?option=com_jce&view=editor&layout=editor&task=pack&type=css&component_id=' . $component_id . '&' . $token . '=1');
     } else {
         // CSS
         $this->addStyleSheet($this->getURL(true) . '/libraries/css/editor.css');
         // get plugin styles
         $this->getPluginStyles($settings);
     }
     // set compression
     if ($compress['javascript']) {
         $this->addScript(JURI::base(true) . '/index.php?option=com_jce&view=editor&layout=editor&task=pack&component_id=' . $component_id . '&' . $token . '=1');
     } else {
         $this->addScript($this->getURL(true) . '/tiny_mce/tiny_mce.js');
         // Editor
         $this->addScript($this->getURL(true) . '/libraries/js/editor.js');
         if (array_key_exists('language_load', $settings)) {
             // language
             $this->addScript(JURI::base(true) . '/index.php?option=com_jce&view=editor&layout=editor&task=loadlanguages&lang=' . $this->language . '&component_id=' . $component_id . '&' . $token . '=1');
         }
     }
     // Get all optional plugin configuration options
     $this->getPluginConfig($settings);
     // remove 'rows' key from $settings
     unset($settings['rows']);
     // pass compresison states to settings
     $settings['compress'] = json_encode($compress);
     //Other - user specified
     $userParams = $wf->getParam('editor.custom_config', '');
     $baseParams = array('mode', 'cleanup_callback', 'save_callback', 'file_browser_callback', 'urlconverter_callback', 'onpageload', 'oninit', 'editor_selector');
     if ($userParams) {
         $userParams = explode(';', $userParams);
         foreach ($userParams as $userParam) {
             $keys = explode(':', $userParam);
             if (!in_array(trim($keys[0]), $baseParams)) {
                 $settings[trim($keys[0])] = count($keys) > 1 ? trim($keys[1]) : '';
             }
         }
     }
     // check for language files
     $this->checkLanguages($settings);
     $output = "";
     $i = 1;
     foreach ($settings as $k => $v) {
         // If the value is an array, implode!
         if (is_array($v)) {
             $v = ltrim(implode(',', $v), ',');
         }
         // Value must be set
         if ($v !== '') {
             // objects or arrays or functions or regular expression
             if (preg_match('/(\\[[^\\]*]\\]|\\{[^\\}]*\\}|function\\([^\\}]*\\}|^#(.*)#$)/', $v)) {
                 // replace hash delimiters with / for javascript regular expression
                 $v = preg_replace('@^#(.*)#$@', '/$1/', $v);
             } else {
                 if (is_bool($v) === true) {
                     $v = $v ? 'true' : 'false';
                 } else {
                     if ($v === "true" || $v === "false") {
                         $v = $v === "true" ? 'true' : 'false';
                     } else {
                         if (!is_numeric($v)) {
                             if (strpos($v, '"') === 0) {
                                 $v = '"' . trim($v, '"') . '"';
                             } else {
                                 $v = '"' . str_replace('"', '\\"', $v) . '"';
                             }
                         }
                     }
                 }
             }
             $output .= "\t\t\t" . $k . ": " . $v . "";
             if ($i < count($settings)) {
                 $output .= ",\n";
             }
         }
         // Must have 3 rows, even if 2 are blank!
         if (preg_match('/theme_advanced_buttons([1-3])/', $k) && $v == '') {
             $output .= "\t\t\t" . $k . ": \"\"";
             if ($i < count($settings)) {
                 $output .= ",\n";
             }
         }
         $i++;
     }
     $tinymce = "{\n";
     $tinymce .= preg_replace('/,?\\n?$/', '', $output) . "\n        }";
     $init[] = $tinymce;
     $this->addScriptDeclaration("\n\t\ttry{WFEditor.init(" . implode(',', $init) . ");}catch(e){console.debug(e);}\n");
     if (is_object($this->profile)) {
         if ($wf->getParam('editor.callback_file')) {
             $this->addScript(JURI::root(true) . '/' . $wf->getParam('editor.callback_file'));
         }
         // add callback file if exists
         if (is_file(JPATH_SITE . '/media/jce/js/editor.js')) {
             $this->addScript(JURI::root(true) . '/media/jce/js/editor.js');
         }
         // add custom editor.css if exists
         if (is_file(JPATH_SITE . '/media/jce/css/editor.css')) {
             $this->addStyleSheet(JURI::root(true) . '/media/jce/css/editor.css');
         }
     }
     return $this->getOutput();
 }
Esempio n. 30
0
 /**
  * Text area with WYSIWYG
  * 
  * @param type $element
  * 
  * @return type
  */
 static function tiny_mce($element)
 {
     // Load js and style sheet for frontend
     $base = JUri::root();
     $jCfg = JFactory::getConfig();
     $language = JFactory::getLanguage();
     $text_direction = 'data-direction="ltr"';
     if ($language->isRTL()) {
         $text_direction = 'data-direction="rtl"';
     }
     $urlbase = 'data-url=' . $base;
     if (file_exists(JPATH_ROOT . "/media/editors/tinymce/langs/" . $language->getTag() . ".js")) {
         $langPrefix = $language->getTag();
     } elseif (file_exists(JPATH_ROOT . "/media/editors/tinymce/langs/" . substr($language->getTag(), 0, strpos($language->getTag(), '-')) . ".js")) {
         $langPrefix = substr($language->getTag(), 0, strpos($language->getTag(), '-'));
     } else {
         $langPrefix = "en";
     }
     $langPrefix = "data-lang=" . $langPrefix;
     $jceData = "";
     if (file_exists(JPATH_ROOT . '/media/editors/tinymce/tinymce.min.js') && $jCfg->get('editor') != 'jce') {
         if ($jCfg->get('editor') != 'tinymce') {
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/tinymce.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/plugins/table/plugin.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/plugins/link/plugin.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/plugins/image/plugin.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/plugins/code/plugin.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/plugins/hr/plugin.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/plugins/charmap/plugin.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/plugins/autolink/plugin.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/plugins/lists/plugin.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/plugins/importcss/plugin.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/themes/modern/theme.min.js', 'js');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/skins/lightgray/content.inline.min.css', 'css');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/skins/lightgray/content.min.css', 'css');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/skins/lightgray/skin.min.css', 'css');
             JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'media/editors/tinymce/skins/lightgray/skin.ie7.min.css', 'css');
         }
         $editor = 'tinymce';
     } elseif ($jCfg->get('editor') == 'jce') {
         include_once JPATH_ROOT . "/administrator/components/com_jce/includes/loader.php";
         include_once JPATH_ROOT . "/administrator/components/com_jce/models/editor.php";
         include_once JPATH_ROOT . "/components/com_jce/editor/libraries/classes/token.php";
         // create token
         $token = WFToken::getToken();
         $jceData .= " data-token=" . $token;
         // etag - version
         $editor = new WFModelEditor();
         $setting = $editor->getEditorSettings();
         $etag = $setting['etag'];
         $jceData .= " data-etag=" . $etag;
         // get current component
         $option = JFactory::getApplication()->input->get('option');
         $component = WFExtensionHelper::getComponent(null, $option);
         // set default component id
         $component_id = 0;
         $component_id = isset($component->extension_id) ? $component->extension_id : ($component->id ? $component->id : 0);
         $jceData .= " data-component_id=" . $component_id;
         $editor = 'jce';
     } else {
         JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'plugins/system/jsnframework/assets/3rd-party/jquery-jwysiwyg/jquery.wysiwyg.js', 'js');
         JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'plugins/system/jsnframework/assets/3rd-party/jquery-jwysiwyg/jquery.wysiwyg.css', 'css');
         JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'plugins/system/jsnframework/assets/3rd-party/jquery-jwysiwyg/jquery.wysiwyg-0.9.js', 'js');
         JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'plugins/system/jsnframework/assets/3rd-party/jquery-jwysiwyg/jquery.wysiwyg-0.9.css', 'css');
         JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'plugins/system/jsnframework/assets/3rd-party/jquery-jwysiwyg/controls/wysiwyg.colorpicker.js', 'js');
         JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'plugins/system/jsnframework/assets/3rd-party/jquery-jwysiwyg/controls/wysiwyg.table.js', 'js');
         JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'plugins/system/jsnframework/assets/3rd-party/jquery-jwysiwyg/controls/wysiwyg.cssWrap.js', 'js');
         JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'plugins/system/jsnframework/assets/3rd-party/jquery-jwysiwyg/controls/wysiwyg.image.js', 'js');
         JSNPagebuilderHelpersFunctions::print_asset_tag($base . 'administrator/components/com_pagebuilder/assets/js/jquery-jwysiwyg/controls/wysiwyg.link.js', 'js');
         JSNPagebuilderHelpersFunctions::print_asset_tag(JSNPB_ASSETS_URL . 'css/jwysiwyg.css', 'css');
     }
     $element = self::get_extra_info($element);
     $label = self::get_label($element);
     $type = !empty($element["input-type"]) ? $element["input-type"] : "text";
     $role = isset($element['role']) ? "role_{$element['role']}" : '';
     $role2 = isset($element['role_2']) ? 'data-role="title"' : '';
     $output = "<textarea type='{$type}' class='{$element['class']} jsn_tiny_mce {$role} {$editor}' id='{$element['id']}' name='{$element['id']}' {$role2} {$text_direction} {$urlbase} {$langPrefix} {$jceData} DATA_INFO>{$element['std']}</textarea>";
     return self::final_element($element, $output, $label);
 }