Exemplo n.º 1
0
 /**
  * Custom Constructor
  */
 function __construct($default = array())
 {
     parent::__construct($default);
     $view = JRequest::getWord('view', 'cpanel');
     $this->registerTask('apply', 'save');
     $this->registerTask('unpublish', 'publish');
     // load classes
     wfimport('admin.classes.installer');
     // load helpers
     wfimport('admin.helpers.parameter');
     wfimport('admin.helpers.extension');
     wfimport('admin.helpers.xml');
     $document = JFactory::getDocument();
     $document->setTitle(WFText::_('WF_ADMINISTRATION') . ' :: ' . WFText::_('WF_' . strtoupper($view)));
     $language = JFactory::getLanguage();
     $language->load('com_jce', JPATH_ADMINISTRATOR);
     $model = $this->getModel($view);
     // jquery versions
     $document->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/jquery/jquery-' . WF_JQUERY . '.min.js?version=' . $model->getVersion());
     $document->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/jquery/jquery-ui-' . WF_JQUERYUI . '.custom.min.js?version=' . $model->getVersion());
     // jQuery noConflict
     $document->addScriptDeclaration('jQuery.noConflict();');
     $scripts = array();
     switch ($view) {
         case 'help':
             $scripts[] = 'help.js';
             break;
         default:
             // load Joomla! core javascript
             if (method_exists('JHtml', 'core')) {
                 JHtml::core();
             }
             require_once JPATH_ADMINISTRATOR . DS . 'includes' . DS . 'toolbar.php';
             JToolBarHelper::title(WFText::_('WF_ADMINISTRATION') . ' ›› ' . WFText::_('WF_' . strtoupper($view)), 'logo.png');
             $params = WFParameterHelper::getComponentParams();
             $theme = $params->get('preferences.theme', 'jce');
             $scripts = array_merge(array('tips.js', 'html5.js'));
             // Load admin scripts
             $document->addScript(JURI::root(true) . '/administrator/components/com_jce/media/js/jce.js?version=' . $model->getVersion());
             $options = array('labels' => array('ok' => WFText::_('WF_LABEL_OK'), 'cancel' => WFText::_('WF_LABEL_CANCEL'), 'select' => WFText::_('WF_LABEL_SELECT'), 'save' => WFText::_('WF_LABEL_SAVE'), 'saveclose' => WFText::_('WF_LABEL_SAVECLOSE'), 'alert' => WFText::_('WF_LABEL_ALERT'), 'required' => WFText::_('WF_MESSAGE_REQUIRED')));
             $document->addScriptDeclaration('jQuery(document).ready(function($){$.jce.init(' . json_encode($options) . ');});');
             $installer = WFInstaller::getInstance();
             $installer->check();
             break;
     }
     // Load site scripts
     foreach ($scripts as $script) {
         $document->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/' . $script . '?version=' . $model->getVersion());
     }
     require_once dirname(__FILE__) . DS . 'helpers' . DS . 'system.php';
     $app = JFactory::getApplication();
     $app->registerEvent('onAfterRender', 'WFSystemHelper');
 }
 /**
  * Create the View. 
  * This is an overloaded function of JController::getView 
  * and includes addition of the JDocument Object with required scripts and styles
  * @return object
  */
 public function getView($name = '', $type = '', $prefix = '', $config = array())
 {
     $language = JFactory::getLanguage();
     $language->load('com_jce', JPATH_ADMINISTRATOR);
     $document = JFactory::getDocument();
     if (!$name) {
         $name = JRequest::getWord('view', 'cpanel');
     }
     if (!$type) {
         $type = $document->getType();
     }
     if (empty($config)) {
         $config = array('base_path' => dirname(__FILE__));
     }
     $view = parent::getView($name, $type, $prefix, $config);
     $document = JFactory::getDocument();
     $document->setTitle(WFText::_('WF_ADMINISTRATION') . ' :: ' . WFText::_('WF_' . strtoupper($name)));
     $model = $this->getModel($name);
     // jquery versions
     $document->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/jquery/jquery-' . WF_JQUERY . '.min.js?version=' . $model->getVersion());
     $document->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/jquery/jquery-ui-' . WF_JQUERYUI . '.custom.min.js?version=' . $model->getVersion());
     // jQuery noConflict
     $document->addScriptDeclaration('jQuery.noConflict();');
     $scripts = array();
     switch ($name) {
         case 'help':
             $scripts[] = 'help.js';
             break;
         default:
             // load Joomla! core javascript
             if (method_exists('JHtml', 'core')) {
                 JHtml::core();
             }
             require_once JPATH_ADMINISTRATOR . DS . 'includes' . DS . 'toolbar.php';
             JToolBarHelper::title(WFText::_('WF_ADMINISTRATION') . ' ›› ' . WFText::_('WF_' . strtoupper($name)), 'logo.png');
             $params = WFParameterHelper::getComponentParams();
             $theme = $params->get('preferences.theme', 'jce');
             $scripts = array_merge(array('tips.js', 'html5.js'));
             // Load admin scripts
             $document->addScript(JURI::root(true) . '/administrator/components/com_jce/media/js/jce.js?version=' . $model->getVersion());
             $options = array('labels' => array('ok' => WFText::_('WF_LABEL_OK'), 'cancel' => WFText::_('WF_LABEL_CANCEL'), 'select' => WFText::_('WF_LABEL_SELECT'), 'save' => WFText::_('WF_LABEL_SAVE'), 'saveclose' => WFText::_('WF_LABEL_SAVECLOSE'), 'alert' => WFText::_('WF_LABEL_ALERT'), 'required' => WFText::_('WF_MESSAGE_REQUIRED')));
             $document->addScriptDeclaration('jQuery(document).ready(function($){$.jce.init(' . json_encode($options) . ');});');
             $view->addHelperPath(dirname(__FILE__) . DS . 'helpers');
             $this->addModelPath(dirname(__FILE__) . DS . 'models');
             $view->loadHelper('toolbar');
             $view->loadHelper('tools');
             $view->loadHelper('xml');
             $view->loadHelper($name);
             $this->loadMenu();
             break;
     }
     if ($model = $this->getModel($name)) {
         $view->setModel($model, true);
     }
     // Load site scripts
     foreach ($scripts as $script) {
         $document->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/' . $script . '?version=' . $model->getVersion());
     }
     require_once dirname(__FILE__) . DS . 'helpers' . DS . 'system.php';
     $app = JFactory::getApplication();
     $app->registerEvent('onAfterRender', 'WFSystemHelper');
     $view->assignRef('document', $document);
     return $view;
 }
Exemplo n.º 3
0
 function save()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('RESTRICTED');
     $db = JFactory::getDBO();
     $row = JTable::getInstance('profiles', 'WFTable');
     $task = $this->getTask();
     // get components
     $components = JRequest::getVar('components', array(), 'post', 'array');
     // get usertypes
     $types = JRequest::getVar('types', array(), 'post', 'array');
     // get users
     $users = JRequest::getVar('users', array(), 'post', 'array');
     if (!$row->bind(JRequest::get('post'))) {
         JError::raiseError(500, $row->getError());
     }
     $row->types = implode(',', $types);
     $row->components = implode(',', $components);
     $row->users = implode(',', $users);
     $data = new StdClass();
     // get params array
     $params = JRequest::getVar('params', array(), 'POST', 'array');
     if (isset($params['editor'])) {
         $data->editor = WFParameterHelper::toObject($params['editor']);
     }
     $plugins = explode(',', $row->plugins);
     foreach ($plugins as $plugin) {
         // add plugin params to array
         if (isset($params[$plugin])) {
             $data->{$plugin} = WFParameterHelper::toObject($params[$plugin]);
         }
     }
     $row->params = json_encode($data);
     if (!$row->check()) {
         JError::raiseError(500, $row->getError());
     }
     if (!$row->store()) {
         JError::raiseError(500, $row->getError());
     }
     $row->checkin();
     switch ($task) {
         case 'apply':
             $msg = JText::sprintf('WF_PROFILES_SAVED_CHANGES', $row->name);
             $this->setRedirect('index.php?option=com_jce&view=profiles&task=edit&cid[]=' . $row->id, $msg);
             break;
         case 'save':
         default:
             $msg = JText::sprintf('WF_PROFILES_SAVED', $row->name);
             $this->setRedirect('index.php?option=com_jce&view=profiles', $msg);
             break;
     }
 }
Exemplo n.º 4
0
 /**
  * Upgrade database tables and remove legacy folders
  * @return Boolean
  */
 private static function upgrade($version)
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     $admin = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jce';
     $site = JPATH_SITE . DS . 'components' . DS . 'com_jce';
     require_once $admin . DS . 'helpers' . DS . 'parameter.php';
     // add tables path
     JTable::addIncludePath($admin . DS . 'tables');
     // upgrade from 1.5.x to 2.0.0 (only in Joomla! 1.5)
     if (version_compare($version, '2.0.0', '<') && !defined('JPATH_PLATFORM')) {
         // check for groups table / data
         if (self::checkTable('#__jce_groups') && self::checkTableContents('#__jce_groups')) {
             jimport('joomla.plugin.helper');
             // get plugin
             $plugin = JPluginHelper::getPlugin('editors', 'jce');
             // get JCE component
             $table = JTable::getInstance('component');
             $table->loadByOption('com_jce');
             // process params to JSON string
             $params = WFParameterHelper::toObject($table->params);
             // set params
             $table->params = json_encode(array('editor' => $params));
             // store
             $table->store();
             // get all groups data
             $query = 'SELECT * FROM #__jce_groups';
             $db->setQuery($query);
             $groups = $db->loadObjectList();
             // get all plugin data
             $query = 'SELECT id, name, icon FROM #__jce_plugins';
             $db->setQuery($query);
             $plugins = $db->loadAssocList('id');
             $map = array('advlink' => 'link', 'advcode' => 'source', 'tablecontrols' => 'table', 'styleprops' => 'style');
             if (self::createProfilesTable()) {
                 foreach ($groups as $group) {
                     $row = JTable::getInstance('profiles', 'WFTable');
                     $rows = array();
                     // transfer row ids to names
                     foreach (explode(';', $group->rows) as $item) {
                         $icons = array();
                         foreach (explode(',', $item) as $id) {
                             // spacer
                             if ($id == '00') {
                                 $icon = 'spacer';
                             } else {
                                 if (isset($plugins[$id])) {
                                     $icon = $plugins[$id]['icon'];
                                     // map old icon names to new
                                     if (isset($map[$icon])) {
                                         $icon = $map[$icon];
                                     }
                                 }
                             }
                             $icons[] = $icon;
                         }
                         $rows[] = str_replace(array('cite,abbr,acronym,del,ins,attribs', 'search,replace', 'ltr,rtl', 'readmore,pagebreak', 'cut,copy,paste'), array('xhtmlxtras', 'searchreplace', 'directionality', 'article', 'paste'), implode(',', $icons));
                     }
                     // re-assign rows
                     $row->rows = implode(';', $rows);
                     $names = array('anchor');
                     // transfer plugin ids to names
                     foreach (explode(',', $group->plugins) as $id) {
                         if (isset($plugins[$id])) {
                             $name = $plugins[$id]['name'];
                             // map old icon names to new
                             if (isset($map[$name])) {
                                 $name = $map[$name];
                             }
                             $names[] = $name;
                         }
                     }
                     // re-assign plugins
                     $row->plugins = implode(',', $names);
                     // convert params to JSON
                     $params = WFParameterHelper::toObject($group->params);
                     $data = new StdClass();
                     foreach ($params as $key => $value) {
                         $parts = explode('_', $key);
                         $node = array_shift($parts);
                         // special consideration for imgmanager_ext!!
                         if (strpos($key, 'imgmanager_ext_') !== false) {
                             $node = $node . '_' . array_shift($parts);
                         }
                         // convert some nodes
                         if (isset($map[$node])) {
                             $node = $map[$node];
                         }
                         $key = implode('_', $parts);
                         if ($value !== '') {
                             if (!isset($data->{$node}) || !is_object($data->{$node})) {
                                 $data->{$node} = new StdClass();
                             }
                             // convert Link parameters
                             if ($node == 'link' && $key != 'target') {
                                 $sub = $key;
                                 $key = 'links';
                                 if (!isset($data->{$node}->{$key})) {
                                     $data->{$node}->{$key} = new StdClass();
                                 }
                                 if (preg_match('#^(content|contacts|static|weblinks|menu)$#', $sub)) {
                                     if (!isset($data->{$node}->{$key}->joomlalinks)) {
                                         $data->{$node}->{$key}->joomlalinks = new StdClass();
                                         $data->{$node}->{$key}->joomlalinks->enable = 1;
                                     }
                                     $data->{$node}->{$key}->joomlalinks->{$sub} = $value;
                                 } else {
                                     $data->{$node}->{$key}->{$sub} = new StdClass();
                                     $data->{$node}->{$key}->{$sub}->enable = 1;
                                 }
                             } else {
                                 $data->{$node}->{$key} = $value;
                             }
                         }
                     }
                     // re-assign params
                     $row->params = json_encode($data);
                     // re-assign other values
                     $row->name = $group->name;
                     $row->description = $group->description;
                     $row->users = $group->users;
                     $row->types = $group->types;
                     $row->components = $group->components;
                     $row->published = $group->published;
                     $row->ordering = $group->ordering;
                     // add area data
                     if ($row->name == 'Default') {
                         $row->area = 0;
                     }
                     if ($row->name == 'Front End') {
                         $row->area = 1;
                     }
                     if (self::checkTable('#__wf_profiles')) {
                         $name = $row->name;
                         // check for existing profile
                         $query = 'SELECT id FROM #__wf_profiles' . ' WHERE name = ' . $db->Quote($name);
                         $db->setQuery($query);
                         // create name copy if exists
                         while ($db->loadResult()) {
                             $name = JText::sprintf('WF_PROFILES_COPY_OF', $name);
                             $query = 'SELECT id FROM #__wf_profiles' . ' WHERE name = ' . $db->Quote($name);
                             $db->setQuery($query);
                         }
                         // set name
                         $row->name = $name;
                     }
                     if (!$row->store()) {
                         $app->enqueueMessage('Conversion of group data failed : ' . $row->name, 'error');
                     } else {
                         $app->enqueueMessage('Conversion of group data successful : ' . $row->name);
                     }
                     unset($row);
                 }
                 // Drop tables
                 $query = 'DROP TABLE IF EXISTS #__jce_groups';
                 $db->setQuery($query);
                 $db->query();
                 // If profiles table empty due to error, install profiles data
                 if (!self::checkTableContents('#__wf_profiles')) {
                     self::installProfiles();
                 }
             } else {
                 return false;
             }
             // Install profiles
         } else {
             self::installProfiles();
         }
         // Drop tables
         $query = 'DROP TABLE IF EXISTS #__jce_plugins';
         $db->setQuery($query);
         $db->query();
         // Drop tables
         $query = 'DROP TABLE IF EXISTS #__jce_extensions';
         $db->setQuery($query);
         $db->query();
         // Remove Plugins menu item
         $query = 'DELETE FROM #__components' . ' WHERE admin_menu_link = ' . $db->Quote('option=com_jce&type=plugins');
         $db->setQuery($query);
         $db->query();
         // Update Component Name
         $query = 'UPDATE #__components' . ' SET name = ' . $db->Quote('COM_JCE') . ' WHERE ' . $db->Quote('option') . '=' . $db->Quote('com_jce') . ' AND parent = 0';
         $db->setQuery($query);
         $db->query();
         // Fix links for other views and edit names
         $menus = array('install' => 'installer', 'group' => 'profiles', 'groups' => 'profiles', 'config' => 'config');
         $row = JTable::getInstance('component');
         foreach ($menus as $k => $v) {
             $query = 'SELECT id FROM #__components' . ' WHERE admin_menu_link = ' . $db->Quote('option=com_jce&type=' . $k);
             $db->setQuery($query);
             $id = $db->loadObject();
             if ($id) {
                 $row->load($id);
                 $row->name = $v;
                 $row->admin_menu_link = 'option=com_jce&view=' . $v;
                 if (!$row->store()) {
                     $mainframe->enqueueMessage('Unable to update Component Links for view : ' . strtoupper($v), 'error');
                 }
             }
         }
         // remove old admin language files
         $folders = JFolder::folders(JPATH_ADMINISTRATOR . DS . 'language', '.', false, true, array('.svn', 'CVS', 'en-GB'));
         foreach ($folders as $folder) {
             $name = basename($folder);
             $files = array($name . '.com_jce.ini', $name . '.com_jce.menu.ini', $name . '.com_jce.xml');
             foreach ($files as $file) {
                 if (is_file($folder . DS . $file)) {
                     @JFile::delete($folder . DS . $file);
                 }
             }
         }
         // remove old site language files
         $folders = JFolder::folders(JPATH_SITE . DS . 'language', '.', false, true, array('.svn', 'CVS', 'en-GB'));
         foreach ($folders as $folder) {
             $files = JFolder::files($folder, '^' . basename($folder) . '\\.com_jce([_a-z0-9]+)?\\.(ini|xml)$', false, true);
             @JFile::delete($files);
         }
         // remove legacy admin folders
         $folders = array('cpanel', 'config', 'css', 'groups', 'plugins', 'img', 'installer', 'js');
         foreach ($folders as $folder) {
             if (is_dir($admin . DS . $folder)) {
                 @JFolder::delete($admin . DS . $folder);
             }
         }
         // remove legacy admin files
         $files = array('editor.php', 'helper.php', 'updater.php');
         foreach ($files as $file) {
             if (is_file($admin . DS . $file)) {
                 @JFile::delete($admin . DS . $file);
             }
         }
         // remove legacy admin folders
         $folders = array('controller', 'css', 'js');
         foreach ($folders as $folder) {
             if (is_dir($site . DS . $folder)) {
                 @JFolder::delete($site . DS . $folder);
             }
         }
         // remove legacy admin files
         $files = array('popup.php');
         foreach ($files as $file) {
             if (is_file($site . DS . $file)) {
                 @JFile::delete($site . DS . $file);
             }
         }
         if (!defined('JPATH_PLATFORM')) {
             // remove old plugin folder
             $path = JPATH_PLUGINS . DS . 'editors';
             if (is_dir($path . DS . 'jce')) {
                 @JFolder::delete($path . DS . 'jce');
             }
         }
         return true;
     }
     // end JCE 1.5 upgrade
     // cleanup javascript and css files moved to site
     if (version_compare($version, '2.0.10', '<')) {
         $path = $admin . DS . 'media';
         $scripts = array('colorpicker.js', 'help.js', 'html5.js', 'select.js', 'tips.js');
         foreach ($scripts as $script) {
             if (is_file($path . DS . 'js' . DS . $script)) {
                 @JFile::delete($path . DS . 'js' . DS . $script);
             }
         }
         if (is_dir($path . DS . 'js' . DS . 'jquery')) {
             @JFolder::delete($path . DS . 'js' . DS . 'jquery');
         }
         $styles = array('help.css', 'select.css', 'tips.css');
         foreach ($styles as $style) {
             if (is_file($path . DS . 'css' . DS . $style)) {
                 @JFile::delete($path . DS . 'css' . DS . $style);
             }
         }
         // delete jquery
         if (is_dir($path . DS . 'css' . DS . 'jquery')) {
             @JFolder::delete($path . DS . 'css' . DS . 'jquery');
         }
         // remove popup controller
         if (is_dir($site . DS . 'controller')) {
             @JFolder::delete($site . DS . 'controller');
         }
     }
     // delete error.php file
     if (version_compare($version, '2.0.12', '<')) {
         if (is_file($site . DS . 'editor' . DS . 'libraries' . DS . 'classes' . DS . 'error.php')) {
             @JFile::delete($site . DS . 'editor' . DS . 'libraries' . DS . 'classes' . DS . 'error.php');
         }
     }
     // remove old jQuery and jQuery UI versions
     if (version_compare($version, '2.0.20', '<')) {
         $path = $site . DS . 'editor' . DS . 'libraries' . DS . 'js' . DS . 'jquery';
         $files = array('jquery-1.7.1.min.js', 'jquery-ui-1.8.17.custom.min.js', 'jquery-ui-layout.js');
         foreach ($files as $file) {
             if (is_file($path . DS . $file)) {
                 @JFile::delete($path . DS . $file);
             }
         }
     }
     if (version_compare($version, '2.1', '<')) {
         if (is_dir($admin . DS . 'plugin')) {
             @JFolder::delete($admin . DS . 'plugin');
         }
         // Add Visualblocks plugin
         $query = 'SELECT id FROM #__wf_profiles';
         $db->setQuery($query);
         $profiles = $db->loadObjectList();
         $profile = JTable::getInstance('Profiles', 'WFTable');
         if (!empty($profiles)) {
             foreach ($profiles as $item) {
                 $profile->load($item->id);
                 if (strpos($profile->rows, 'visualblocks') === false) {
                     $profile->rows = str_replace('visualchars', 'visualchars,visualblocks', $profile->rows);
                 }
                 if (strpos($profile->plugins, 'visualblocks') === false) {
                     $profile->plugins = str_replace('visualchars', 'visualchars,visualblocks', $profile->plugins);
                 }
                 $profile->store();
             }
         }
     }
     if (version_compare($version, '2.1.1', '<')) {
         @JFile::delete($admin . DS . 'classes' . DS . 'installer.php');
         // Add Visualblocks plugin
         $query = 'SELECT id FROM #__wf_profiles';
         $db->setQuery($query);
         $profiles = $db->loadObjectList();
         $profile = JTable::getInstance('Profiles', 'WFTable');
         if (!empty($profiles)) {
             foreach ($profiles as $item) {
                 $profile->load($item->id);
                 // add anchor to end of plugins list
                 if (strpos($profile->rows, 'anchor') !== false) {
                     $profile->plugins .= ',anchor';
                 }
                 $profile->store();
             }
         }
         // delete old anchor stuff
         $theme = $site . DS . 'editor' . DS . 'tiny_mce' . DS . 'themes' . DS . 'advanced';
         foreach (array('css/anchor.css', 'js/anchor.js', 'tmpl/anchor.php', 'skins/default/img/items.gif') as $item) {
             if (JFile::exists($theme . DS . $item)) {
                 @JFile::delete($theme . DS . $item);
             }
         }
         // delete popup.php
         if (is_file($site . DS . 'popup.php')) {
             @JFile::delete($site . DS . 'popup.php');
         }
     }
     return true;
 }
Exemplo n.º 5
0
 /**
  * Create the View. 
  * This is an overloaded function of JController::getView 
  * and includes addition of the JDocument Object with required scripts and styles
  * @return object
  */
 public function getView($name = '', $type = '', $prefix = '', $config = array())
 {
     $language = JFactory::getLanguage();
     $language->load('com_jce', JPATH_ADMINISTRATOR);
     $document = JFactory::getDocument();
     if (!$name) {
         $name = JRequest::getWord('view', 'cpanel');
     }
     if (!$type) {
         $type = $document->getType();
     }
     if (empty($config)) {
         $config = array('base_path' => dirname(__FILE__));
     }
     $model = $this->getModel($name);
     $view = parent::getView($name, $type, $prefix, $config);
     $document = JFactory::getDocument();
     $bootstrap = class_exists('JHtmlBootstrap');
     $jquery = class_exists('JHtmlJquery');
     $view->addStyleSheet(JURI::root(true) . '/administrator/components/com_jce/media/css/global.css?version=' . $model->getVersion());
     // using JUI...
     if (!$bootstrap || !$jquery) {
         // set device-width meta
         $document->setMetaData('meta', 'width=device-width, initial-scale=1.0');
         $view->addStyleSheet(JURI::root(true) . '/administrator/components/com_jce/media/css/styles-ui.css?version=' . $model->getVersion());
         // JQuery UI
         $view->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/jquery/js/jquery-' . WF_JQUERY . '.min.js?version=' . $model->getVersion());
         // jQuery noConflict
         $view->addScriptDeclaration('jQuery.noConflict();');
     }
     // JQuery UI
     $view->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/jquery/js/jquery-ui-' . WF_JQUERYUI . '.custom.min.js?version=' . $model->getVersion());
     // JQuery Touch Punch
     $view->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/jquery/js/jquery.ui.touch-punch.min.js?version=' . $model->getVersion());
     $scripts = array();
     switch ($name) {
         case 'help':
             $view->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/help.js?version=' . $model->getVersion());
             break;
         default:
             // load Joomla! core javascript
             if (method_exists('JHtml', 'core')) {
                 JHtml::core();
             }
             require_once JPATH_ADMINISTRATOR . '/includes/toolbar.php';
             JToolBarHelper::title(WFText::_('WF_ADMINISTRATION') . ' &rsaquo;&rsaquo; ' . WFText::_('WF_' . strtoupper($name)), 'logo.png');
             $params = WFParameterHelper::getComponentParams();
             $theme = $params->get('preferences.theme', 'jce');
             $view->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/tips.js');
             $view->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/html5.js');
             $view->addScript(JURI::root(true) . '/administrator/components/com_jce/media/js/jce.js');
             $options = array('labels' => array('ok' => WFText::_('WF_LABEL_OK'), 'cancel' => WFText::_('WF_LABEL_CANCEL'), 'select' => WFText::_('WF_LABEL_SELECT'), 'save' => WFText::_('WF_LABEL_SAVE'), 'saveclose' => WFText::_('WF_LABEL_SAVECLOSE'), 'alert' => WFText::_('WF_LABEL_ALERT'), 'required' => WFText::_('WF_MESSAGE_REQUIRED')), 'bootstrap' => $bootstrap);
             $view->addScriptDeclaration('jQuery(document).ready(function($){$.jce.init(' . json_encode($options) . ');});');
             //$document->addCustomTag('<script type="text/javascript">jQuery(document).ready(function($){$.jce.init(' . json_encode($options) . ');});</script>');
             $view->addHelperPath(dirname(__FILE__) . '/helpers');
             $this->addModelPath(dirname(__FILE__) . '/models');
             $view->loadHelper('toolbar');
             $view->loadHelper('tools');
             $view->loadHelper('xml');
             $view->loadHelper($name);
             $this->loadMenu();
             break;
     }
     if ($model = $this->getModel($name)) {
         $view->setModel($model, true);
     }
     $view->assignRef('document', $document);
     return $view;
 }
Exemplo n.º 6
0
 /**
  * Upgrade database tables and remove legacy folders
  * @return Boolean
  */
 function upgrade($version)
 {
     $mainframe = JFactory::getApplication();
     $db = JFactory::getDBO();
     wfimport('admin.helpers.parameter');
     wfimport('admin.helpers.xml');
     $base = dirname(dirname(__FILE__));
     // cleanup javascript and css files moved to site
     if (version_compare($version, '2.0.10', '<')) {
         $path = dirname(dirname(__FILE__)) . DS . 'media';
         $scripts = array('colorpicker.js', 'help.js', 'html5.js', 'select.js', 'tips.js');
         foreach ($scripts as $script) {
             if (is_file($path . DS . 'js' . DS . $script)) {
                 @JFile::delete($path . DS . 'js' . DS . $script);
             }
         }
         if (is_dir($path . DS . 'js' . DS . 'jquery')) {
             @JFolder::delete($path . DS . 'js' . DS . 'jquery');
         }
         $styles = array('help.css', 'select.css', 'tips.css');
         foreach ($styles as $style) {
             if (is_file($path . DS . 'css' . DS . $style)) {
                 @JFile::delete($path . DS . 'css' . DS . $style);
             }
         }
         // delete jquery
         if (is_dir($path . DS . 'css' . DS . 'jquery')) {
             @JFolder::delete($path . DS . 'css' . DS . 'jquery');
         }
         // remove popup controller
         if (is_dir(JPATH_SITE . DS . 'components' . DS . 'com_jce' . DS . 'controller')) {
             @JFolder::delete(JPATH_SITE . DS . 'components' . DS . 'com_jce' . DS . 'controller');
         }
     }
     if (version_compare($version, '2.0.0beta2', '<')) {
         if ($this->checkTable('#__jce_profiles')) {
             // get all groups data
             $query = 'SELECT * FROM #__jce_profiles';
             $db->setQuery($query);
             $profiles = $db->loadObjectList();
             if ($this->createProfilesTable()) {
                 $row = JTable::getInstance('profiles', 'WFTable');
                 foreach ($profiles as $profile) {
                     $row->bind($profile);
                     $row->store();
                 }
             }
             // Drop tables
             $query = 'DROP TABLE IF EXISTS #__jce_profiles';
             $db->setQuery($query);
             $db->query();
         }
     }
     // upgrade from 1.5.x to 2.0.0 (only in Joomla! 1.5)
     if (version_compare($version, '2.0.0', '<') && WF_JOOMLA15) {
         // check for groups table / data
         if ($this->checkTable('#__jce_groups') && $this->checkTableContents('#__jce_groups')) {
             // get plugin
             $plugin = JPluginHelper::getPlugin('editors', 'jce');
             // get JCE component
             $table = JTable::getInstance('component');
             $table->loadByOption('com_jce');
             // process params to JSON string
             $params = WFParameterHelper::toObject($table->params);
             // set params
             $table->params = json_encode(array('editor' => $params));
             // store
             $table->store();
             // get all groups data
             $query = 'SELECT * FROM #__jce_groups';
             $db->setQuery($query);
             $groups = $db->loadObjectList();
             // get all plugin data
             $query = 'SELECT id, name, icon FROM #__jce_plugins';
             $db->setQuery($query);
             $plugins = $db->loadAssocList('id');
             if ($this->createProfilesTable()) {
                 foreach ($groups as $group) {
                     $row = JTable::getInstance('profiles', 'WFTable');
                     // transfer row ids to names
                     foreach (explode(';', $group->rows) as $item) {
                         $icons = array();
                         foreach (explode(',', $item) as $id) {
                             // spacer
                             if ($id == '00') {
                                 $icons[] = 'spacer';
                             } else {
                                 if (isset($plugins[$id])) {
                                     $icons[] = $plugins[$id]['icon'];
                                 }
                             }
                         }
                         $rows[] = implode(',', $icons);
                     }
                     $group->rows = implode(';', $rows);
                     $names = array();
                     // transfer plugin ids to names
                     foreach (explode(',', $group->plugins) as $id) {
                         if (isset($plugins[$id])) {
                             $items[] = $plugins[$id]['name'];
                         }
                     }
                     $group->plugins = implode(',', $names);
                     // convert params to JSON
                     $params = WFParameterHelper::toObject($group->params);
                     $data = new StdClass();
                     foreach ($params as $key => $value) {
                         $parts = explode('_', $key);
                         $node = array_shift($parts);
                         // special consideration for imgmanager_ext!!
                         if (strpos($key, 'imgmanager_ext_') !== false) {
                             $node = $node . '_' . array_shift($parts);
                         }
                         // convert some keys
                         if ($key == 'advlink') {
                             $key = 'link';
                         }
                         $key = implode('_', $parts);
                         if ($value !== '') {
                             if (isset($data->{$node}) && is_object($data->{$node})) {
                                 $data->{$node}->{$key} = $value;
                             } else {
                                 $data->{$node} = new StdClass();
                                 $data->{$node}->{$key} = $value;
                             }
                         }
                     }
                     $group->params = json_encode($data);
                     // bind data
                     $row->bind($group);
                     // add area data
                     if ($row->name == 'Default') {
                         $row->area = 0;
                     }
                     if ($row->name == 'Front End') {
                         $row->area = 1;
                     }
                     if (!$row->store()) {
                         $mainframe->enqueueMessage('Conversion of group data failed : ' . $row->name, 'error');
                     }
                 }
                 // Drop tables
                 $query = 'DROP TABLE IF EXISTS #__jce_groups';
                 $db->setQuery($query);
                 $db->query();
                 // If profiles table empty due to error, install profiles data
                 if (!$this->checkTableContents('#__wf_profiles')) {
                     $this->installProfiles(true);
                 }
             } else {
                 return false;
             }
             // Install profiles
         } else {
             $this->installProfiles(true);
         }
         // Drop tables
         $query = 'DROP TABLE IF EXISTS #__jce_plugins';
         $db->setQuery($query);
         $db->query();
         // Drop tables
         $query = 'DROP TABLE IF EXISTS #__jce_extensions';
         $db->setQuery($query);
         $db->query();
         // Remove Plugins menu item
         $query = 'DELETE FROM #__components' . ' WHERE admin_menu_link = ' . $db->Quote('option=com_jce&type=plugins');
         $db->setQuery($query);
         $db->query();
         // Update Component Name
         $query = 'UPDATE #__components' . ' SET name = ' . $db->Quote('COM_JCE') . ' WHERE ' . $db->Quote('option') . '=' . $db->Quote('com_jce') . ' AND parent = 0';
         $db->setQuery($query);
         $db->query();
         // Fix links for other views and edit names
         $menus = array('install' => 'installer', 'group' => 'profiles', 'groups' => 'profiles', 'config' => 'config');
         $row = JTable::getInstance('component');
         foreach ($menus as $k => $v) {
             $query = 'SELECT id FROM #__components' . ' WHERE admin_menu_link = ' . $db->Quote('option=com_jce&type=' . $k);
             $db->setQuery($query);
             $id = $db->loadObject();
             if ($id) {
                 $row->load($id);
                 $row->name = $v;
                 $row->admin_menu_link = 'option=com_jce&view=' . $v;
                 if (!$row->store()) {
                     $mainframe->enqueueMessage('Unable to update Component Links for view : ' . strtoupper($v), 'error');
                 }
             }
         }
         $folders = JFolder::folders(JPATH_ADMINISTRATOR . DS . 'language', '.', false, true, array('.svn', 'CVS', 'en-GB'));
         // remove old admin language files
         foreach ($folders as $folder) {
             $name = basename($folder);
             $files = array($name . '.com_jce.ini', $name . '.com_jce.menu.ini', $name . '.com_jce.xml');
             foreach ($files as $file) {
                 if (is_file($folder . DS . $file)) {
                     @JFile::delete($folder . DS . $file);
                 }
             }
         }
         $folders = JFolder::folders(JPATH_SITE . DS . 'language', '.', false, true, array('.svn', 'CVS', 'en-GB'));
         // remove old site language files
         foreach ($folders as $folder) {
             $files = JFolder::files($folder, '^' . basename($folder) . '\\.com_jce([_a-z0-9]+)?\\.(ini|xml)$', false, true);
             @JFile::delete($files);
         }
     }
     // end JCE 1.5 upgrade
     return true;
 }
Exemplo n.º 7
0
 /**
  * Create the View. 
  * This is an overloaded function of JController::getView 
  * and includes addition of the JDocument Object with required scripts and styles
  * @return object
  */
 public function getView($name = '', $type = '', $prefix = '', $config = array())
 {
     $language = JFactory::getLanguage();
     $language->load('com_jce', JPATH_ADMINISTRATOR);
     $document = JFactory::getDocument();
     if (!$name) {
         $name = JRequest::getWord('view', 'cpanel');
     }
     if (!$type) {
         $type = $document->getType();
     }
     if (empty($config)) {
         $config = array('base_path' => dirname(__FILE__));
     }
     $model = $this->getModel($name);
     $view = parent::getView($name, $type, $prefix, $config);
     $document = JFactory::getDocument();
     // set device-width meta
     $document->setMetaData('meta', 'width=device-width, initial-scale=1.0');
     $version = new JVersion();
     if ($version->isCompatible('3.0')) {
         // Include jQuery
         JHtml::_('jquery.framework');
     } else {
         // JQuery
         $view->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/jquery/js/jquery.min.js');
         // jQuery noConflict
         $view->addScriptDeclaration('jQuery.noConflict();');
     }
     // JQuery UI
     $view->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/jquery/js/jquery-ui.min.js');
     $scripts = array();
     switch ($name) {
         case 'help':
             $view->addScript(JURI::root(true) . '/components/com_jce/editor/libraries/js/help.js');
             break;
         default:
             $view->addStyleSheet(JURI::root(true) . '/administrator/components/com_jce/media/css/global.css');
             // load Joomla! core javascript
             if (method_exists('JHtml', 'core')) {
                 JHtml::core();
             }
             require_once JPATH_ADMINISTRATOR . '/includes/toolbar.php';
             JToolBarHelper::title(WFText::_('WF_ADMINISTRATION') . ' :: ' . WFText::_('WF_' . strtoupper($name)), 'logo.png');
             $params = WFParameterHelper::getComponentParams();
             $theme = $params->get('preferences.theme', 'jce');
             $view->addScript(JURI::root(true) . '/administrator/components/com_jce/media/js/core.js');
             $options = array('labels' => array('ok' => WFText::_('WF_LABEL_OK'), 'cancel' => WFText::_('WF_LABEL_CANCEL'), 'select' => WFText::_('WF_LABEL_SELECT'), 'save' => WFText::_('WF_LABEL_SAVE'), 'saveclose' => WFText::_('WF_LABEL_SAVECLOSE'), 'alert' => WFText::_('WF_LABEL_ALERT'), 'required' => WFText::_('WF_MESSAGE_REQUIRED')));
             $view->addScriptDeclaration('jQuery.jce.options = ' . json_encode($options) . ';');
             $view->addHelperPath(dirname(__FILE__) . '/helpers');
             $this->addModelPath(dirname(__FILE__) . '/models');
             $view->loadHelper('toolbar');
             $view->loadHelper('xml');
             $view->loadHelper($name);
             $this->loadMenu();
             break;
     }
     if ($model = $this->getModel($name)) {
         $view->setModel($model, true);
     }
     $view->assignRef('document', $document);
     return $view;
 }