diff --git a/oss/joomla/trunk/administrator/components/com_jce/editor.php b/oss/joomla/trunk/administrator/components/com_jce/editor.php new file mode 100644 index 00000000..3155fee0 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/editor.php @@ -0,0 +1,131 @@ +plugins) { + return $this->plugins; + } + $db = & JFactory::getDBO(); + + $query = 'SELECT name' + .' FROM #__jce_plugins' + .' WHERE type = '.$db->Quote('plugin'); + + $db->setQuery($query); + $this->plugins = $db->loadResultArray(); + } + /** + * Returns a reference to a editor object + * + * This method must be invoked as: + *
  $bridge = &JContentEditorBridge::getInstance();
+ * + * @access public + * @return The bridge object. + * @since 1.5.7 + */ + function & getInstance() + { + static $instance; + + if (!is_object($instance)) { + $instance = new JContentEditorBridge(); + } + return $instance; + } + + /** + * Returns $plugins. + * @see JContentEditorBridge::$plugins + */ + function getPlugins() + { + return $this->plugins; + } + + /** + * Sets $plugins. + * @param array $plugins + * @see JContentEditorBridge::$plugins + */ + function setPlugins($plugins) + { + $this->plugins = $plugins; + } + /** + * Check a plugin against the static list + * @return boolan + * @param string $plugin + */ + function checkPlugin($plugin) + { + return in_array($plugin, $this->getPlugins()); + } + /** + * Load Plugin files + */ + function load() + { + $task = JRequest::getCmd('task'); + if ($task) { + switch($task) { + case 'plugin': + $plugin = JRequest::getVar('plugin', 'cmd'); + if ($this->checkPlugin($plugin)) { + $file = basename(JRequest::getVar('file', 'cmd')); + $path = JCE_PLUGINS.DS.$plugin; + if (is_dir($path) && file_exists($path.DS.$file.'.php')) { + include_once $path.DS.$file.'.php'; + } else { + JError::raiseError(500, JText::_('File '.$file.' not found!')); + } + } else { + JError::raiseError(500, JText::_('Plugin not found!')); + } + exit (); + break; + case 'help': + $plugin = JRequest::getVar('plugin', 'cmd'); + if ($this->checkPlugin($plugin)) { + jimport('joomla.application.component.view'); + $help = new JView($config = array ( + 'base_path'=>JCE_LIBRARIES, + 'layout'=>'help' + )); + $help->display(); + } else { + JError::raiseError(500, JText::_('Plugin not found!')); + } + exit (); + break; + } + } else{ + JError::raiseError(500, JText::_('No Task')); + } + + } +} +$bridge = & JContentEditorBridge::getInstance(); +$bridge->load(); +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/helper.php b/oss/joomla/trunk/administrator/components/com_jce/helper.php new file mode 100644 index 00000000..56a01ea2 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/helper.php @@ -0,0 +1,120 @@ + $inputArray[$i], $orderKeyName => $i +1); + } + return $orderArray; + } + function getAccessName($id) + { + $db =& JFactory::getDBO(); + // get list of Groups for dropdown filter + $query = 'SELECT name' + . ' FROM #__core_acl_aro_groups' + . ' WHERE id = '. $id + . ' AND name != "ROOT"' + . ' AND name != "USERS"' + ; + $db->setQuery($query); + return $db->loadResult(); + } + function accessList($name, $access = '', $size = 1, $extra) + { + $db =& JFactory::getDBO(); + // get list of Groups for dropdown filter + $query = 'SELECT id AS value, name AS text' + . ' FROM #__core_acl_aro_groups' + . ' WHERE id NOT IN (28,29,30)' + ; + $db->setQuery($query); + $types[] = JHTML::_('select.option', '0', '- '. JText::_('Select Access') .' -'); + $i = '-'; + foreach ($db->loadObjectList() as $obj) { + $types[] = JHTML::_('select.option', $obj->value, $i . JText::_($obj->text)); + $i .= '-'; + } + return JHTML::_('select.genericlist', $types, $name, 'class="inputbox" size="'. $size .'"'. $extra, 'value', 'text', $access); + } + function quickiconButton($link, $image, $text, $disabled = false) + { + global $mainframe; + $lang =& JFactory::getLanguage(); + $template = $mainframe->getTemplate(); + + if ($disabled) { + $link = '#'; + } + ?> +
+
+ + + + +
+
+ getTag(); + if (file_exists(JPATH_SITE .DS. 'language' .DS. $tag .DS. $tag .'.com_jce.xml')) { + return substr($tag, 0, strpos($tag, '-')); + } + return 'en'; + } +} +class jceToolbarHelper extends JToolbarHelper +{ + function access($alt = 'Plugin Access') + { + $bar = & JToolBar::getInstance('toolbar'); + $bar->appendButton('Popup', 'lock', $alt, "index.php?option=com_jce&tmpl=component&type=plugin&task=access_popup", 400, 150); + } + function popup($alt, $icon, $type, $task, $width = 750, $height = 400) + { + $bar = & JToolBar::getInstance('toolbar'); + $bar->appendButton('Popup', $icon, $alt, "index.php?option=com_jce&tmpl=component&type=".$type."&task=".$task, $width, $height); + } + function config($alt = 'Editor Config') + { + $bar = & JToolBar::getInstance('toolbar'); + $bar->appendButton('Popup', 'config', $alt, "index.php?option=com_jce&tmpl=component&type=config&task=view", 700, 560); + } + function help($type, $alt = 'Help') + { + jimport('joomla.plugin.helper'); + $plugin = JPluginHelper::getPlugin('editors', 'jce'); + + $url = 'http://www.joomlacontenteditor.net/index.php?option=com_content&tmpl=component&view=article&task=findkey'; + + if (isset($plugin->params)) { + $params = new JParameter($plugin->params); + $url = $params->get('help', $url); + } + if(strpos($type, '.') === false){ + $type = $type . '.view'; + } + $type = $type[0]; + $bar = & JToolBar::getInstance('toolbar'); + $bar->appendButton('Popup', 'help', $alt, $url. '&lang=' .JCEHelper::getLanguage(). '&keyref=admin.' .$type, 700, 560); + } +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/index.html b/oss/joomla/trunk/administrator/components/com_jce/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/install.php b/oss/joomla/trunk/administrator/components/com_jce/install.php new file mode 100644 index 00000000..8d81bb87 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/install.php @@ -0,0 +1,229 @@ +installPlugins(true); + // Install Groups data + $updater->installGroups(true); + // Install editor plugin + + jimport('joomla.installer.installer'); + $installer = & JInstaller::getInstance(); + + $source = $installer->getPath('source'); + + $packages = $source.DS.'packages'; + // Get editor and plugin packages + if(is_dir($packages)) { + $editor = JFolder::files($packages, 'plg_jce_15\d+?\.zip', false, true); + $plugins = JFolder::files($packages, 'jce_\w+_15\d+?\.zip', false, true); + } + + $language = & JFactory::getLanguage(); + $language->load('com_jce', JPATH_ADMINISTRATOR); + + $img_path = JURI::root().'/administrator/components/com_jce/img/'; + $out = ''; + $out .= ''; + + $editor_img = 'delete.png'; + $editor_result = JText::_('Error'); + $plugin_out = ''; + + if (! empty($editor)) { + if (is_file($editor[0])) { + $config = & JFactory::getConfig(); + $tmp = $config->getValue('config.tmp_path').DS.uniqid('install_').DS.basename($editor[0], '.zip'); + + if (!JArchive::extract($editor[0], $tmp)) { + $mainframe->enqueueMessage(JText::_('EDITOR EXTRACT ERROR'), 'error'); + } else { + $query = 'SELECT id, params' + .' FROM #__components' + .' WHERE link = '.$db->Quote('option=com_jce') + ; + + $db->setQuery($query); + $component = $db->loadObject(); + + $params = explode("\n", $component->params); + + $installer = & JInstaller::getInstance(); + + $c_manifest = & $installer->getManifest(); + $c_root = & $c_manifest->document; + $version = & $c_root->getElementByPath('version'); + + $component_version = $version->data(); + + // Store Component values + $component_paths = array ( + 'source'=>$installer->getPath('source'), + 'manifest'=>$installer->getPath('manifest'), + 'extension_site'=>$installer->getPath('extension_site'), + 'extension_administrator'=>$installer->getPath('extension_administrator') + ); + + $component_vars = array ( + 'name'=>$installer->get('name'), + 'result'=>$installer->get('result'), + 'message'=>$installer->message + ); + $editor_version = preg_replace('/\D+/', '', basename($editor[0])); + + // Add JTable include path + JTable::addIncludePath(JPATH_LIBRARIES.DS.'joomla'.DS.'database'.DS.'table'); + // Editor Plugin installed proceed with plugins + if ($installer->install($tmp)) { + $manifest = & $installer->getManifest(); + $root = & $manifest->document; + $name = & $root->getElementByPath('name'); + $version = & $root->getElementByPath('version'); + $editor_version = $version->data(); + + $language->load('plg_editors_jce', JPATH_ADMINISTRATOR); + + $editor_img = 'tick.png'; + $editor_result = JText::_('Success'); + + $query = 'UPDATE #__plugins' + . ' SET name = '.$db->Quote($name->data()) + . ' WHERE folder = '.$db->Quote('editors') + . ' AND element = '.$db->Quote('jce') + ; + $db->setQuery($query); + $db->query(); + + $params[] = 'package=1'; + + // Include installer class + if (! empty($plugins)) { + require_once ($path.DS.'installer'.DS.'installer.php'); + $jce_installer = & JCEInstaller::getInstance(); + + $plugin_out = ''; + + foreach ($plugins as $plugin) { + // Create unique tmp dir name + $tmp = $config->getValue('config.tmp_path').DS.uniqid('install_').DS.basename($plugin, '.zip'); + // Extract to tmp dir + if (JArchive::extract($plugin, $tmp)) { + // Install plugin + if (!$jce_installer->install($tmp)) { + $plugin_img = 'delete.png'; + $plugin_result = JText::_('Error'); + $plugin_name = basename($plugin); + } else { + $manifest = & $jce_installer->getManifest(); + $root = & $manifest->document; + $name = & $root->getElementByPath('name'); + + $language->load('com_jce_'.trim($root->attributes('plugin'))); + + $plugin_img = 'tick.png'; + $plugin_result = JText::_('Success'); + $plugin_name = $name->data(); + } + $plugin_out .= ''; + if ($jce_installer->get('extension.message')) { + $plugin_out .= ''; + } + // Cleanup + if (is_dir($tmp)) { + @JFolder::delete($tmp); + } + } + } + } + } else { + $editor_img = 'delete.png'; + $editor_result = JText::_('Error'); + $params[] = 'package=0'; + } + $editor_message = JText::_($installer->message); + // Return Component Paths + foreach ($component_paths as $k=>$v) { + $installer->setPath($k, $v); + } + // Return Component Vars + foreach ($component_vars as $k=>$v) { + $installer->set($k, $v); + } + if (is_dir($tmp)) { + @JFolder::delete($tmp); + } + + $manifest = & $installer->getManifest(); + $root = & $manifest->document; + $version = & $root->getElementByPath('version'); + + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= $plugin_out; + $out .= '
'.JText::_('Extension').''.JText::_('Version').' 
'.JText::_('Plugin').''.JText::_('Version').' 
'.$plugin_name.''.preg_replace('/\D+/', '', basename($plugin)).''.JHTML::image($img_path.$plugin_img, $plugin_result).'
'.JText::_($jce_installer->get('extension.message')).'
'.JText::_('JCE ADMIN TITLE').''.$component_version.''.JHTML::image($img_path.'tick.png', JText::_('Success')).'
'.JText::_($installer->message).'
'.JText::_('JCE EDITOR TITLE').''.$editor_version.''.JHTML::image($img_path.$editor_img, $editor_result).'
'.$editor_message.'
'; + + $installer->set('message', JText::_('JCE INSTALL SUMMARY')); + $installer->set('extension.message', $out); + + $row = & JTable::getInstance('component'); + $row->load($component->id); + $row->params = implode("\n", $params); + $row->store(); + } + } + } + if (is_dir($packages)) { + // Delete packages folder + @JFolder::delete($packages); + } +} +/** + * Uninstall function + * @return + */ +function com_uninstall() +{ + require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_jce'.DS.'updater.php'); + + $updater = & JCEUpdater::getInstance(); + $updater->cleanupDB(); + + $params = & JComponentHelper::getParams('com_jce'); + if ($params->get('package')) { + $updater->removeEditor(); + } +} +?> diff --git a/oss/joomla/trunk/administrator/components/com_jce/jce.php b/oss/joomla/trunk/administrator/components/com_jce/jce.php new file mode 100644 index 00000000..4908526a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/jce.php @@ -0,0 +1,163 @@ +addACL('com_jce', $auth, 'users', 'super administrator'); + $acl->addACL('com_jce', $auth, 'users', 'administrator'); + $acl->addACL('com_jce', $auth, 'users', 'manager'); +} + +if (!$user->authorize('com_jce', $task)) { + $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); +} +// Variables +$type = JRequest::getCmd('type'); +// Load Helper class +require_once(dirname(__FILE__) .DS. 'helper.php'); +// Load Updater class +require_once(dirname(__FILE__) .DS. 'updater.php'); +// Create updater instance +$updater =& JCEUpdater::getInstance(); +// Repair / Purge +switch ($task) { +case 'repair': + switch ($type) { + case 'editor': + $updater->installEditor(); + break; + case 'plugins': + $updater->updatePlugins(); + break; + case 'groups': + $updater->updateGroups(); + break; + case 'update': + $updater->updateDB(); + break; + } + break; +case 'purge': + $updater->purgeDB(); + break; +} +// Check Updater +$updater->initCheck(); + +$client = JRequest::getWord('client', 'site'); +$cid = JRequest::getVar('cid', array(0), 'post', 'array'); + +JArrayHelper::toInteger($cid, array(0)); +$type = JRequest::getCmd('type'); +$task = JRequest::getCmd('task'); + +switch ($type) { +case 'plugin': + switch ($task) { + case 'install': + case 'remove': + case 'manage': + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'installer.php'); + break; + case 'view': + default: + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'plugin.php'); + break; + } + break; +case 'group': + switch ($task) { + case 'view': + default: + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'groups.php'); + break; + } + break; +case 'language': + switch ($task) { + case 'install': + case 'remove': + case 'manage': + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'installer.php'); + break; + default: + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'cpanel.php'); + break; + } + break; +case 'extension': + switch ($task) { + case 'install': + case 'remove': + case 'manage': + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'installer.php'); + break; + default: + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'plugin.php'); + break; + } + break; +case 'config': + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'config.php'); + break; +case 'install': + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'installer.php'); + break; +default: + switch ($task) { + case 'install': + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'installer.php'); + break; + default: + require_once(dirname(__FILE__) .DS. 'controller' .DS. 'cpanel.php'); + break; + } + break; +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/jce.xml b/oss/joomla/trunk/administrator/components/com_jce/jce.xml new file mode 100644 index 00000000..127b2d30 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/jce.xml @@ -0,0 +1,181 @@ + + JCE + Ryan Demmer + 14 November 2009 + (C) 2005 - 2009 Ryan Demmer. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + ryandemmer@gmail.com + www.joomlacontenteditor.net + 1.5.7 + JCE ADMIN DESC + install.php + install.php + + css/index.html + css/popup.css + index.html + jce.php + js/index.html + js/popup.js + popup.php + + + en-GB.com_jce.ini + en-GB.com_jce.xml + en-GB.com_jce_advlink.ini + en-GB.com_jce_browser.ini + en-GB.com_jce_imgmanager.ini + en-GB.com_jce_media.ini + en-GB.com_jce_paste.ini + en-GB.com_jce_spellchecker.ini + + + en-GB.com_jce.ini + en-GB.com_jce.xml + en-GB.com_jce_advlink.ini + en-GB.com_jce_browser.ini + en-GB.com_jce_imgmanager.ini + en-GB.com_jce_media.ini + en-GB.com_jce_paste.ini + en-GB.com_jce_spellchecker.ini + + + JCE + + JCE MENU CPANEL + JCE MENU CONFIG + JCE MENU GROUPS + JCE MENU PLUGINS + JCE MENU INSTALL + + + config/controller.php + config/index.html + config/views/config/index.html + config/views/config/tmpl/default.php + config/views/config/tmpl/index.html + config/views/config/view.html.php + config/views/index.html + controller/config.php + controller/cpanel.php + controller/groups.php + controller/index.html + controller/installer.php + controller/plugin.php + cpanel/controller.php + cpanel/index.html + cpanel/views/cpanel/index.html + cpanel/views/cpanel/tmpl/default.php + cpanel/views/cpanel/tmpl/index.html + cpanel/views/cpanel/view.html.php + cpanel/views/index.html + css/icons.css + css/index.html + css/layout.css + css/styles.css + editor.php + elements/uploadsize.php + groups/controller.php + groups/groups.php + groups/helper.php + groups/index.html + groups/views/group/index.html + groups/views/group/tmpl/form.php + groups/views/group/tmpl/index.html + groups/views/group/view.html.php + groups/views/groups/index.html + groups/views/groups/tmpl/default.php + groups/views/groups/tmpl/index.html + groups/views/groups/view.html.php + groups/views/index.html + groups/views/legend/index.html + groups/views/legend/tmpl/default.php + groups/views/legend/tmpl/index.html + groups/views/legend/view.html.php + groups/views/users/index.html + groups/views/users/tmpl/default.php + groups/views/users/tmpl/index.html + groups/views/users/view.html.php + helper.php + img/add.png + img/delete.png + img/icons.png + img/index.html + img/logo.png + img/tick.png + img/toolbar/icon-32-lock.png + img/toolbar/icon-32-refresh.png + img/toolbar/index.html + index.html + install.php + installer/adapters/extension.php + installer/adapters/index.html + installer/adapters/language.php + installer/adapters/plugin.php + installer/controller.php + installer/index.html + installer/installer.php + installer/models/extension.php + installer/models/extensions.php + installer/models/index.html + installer/models/install.php + installer/models/language.php + installer/models/plugin.php + installer/views/default/index.html + installer/views/default/tmpl/default_ftp.php + installer/views/default/tmpl/default_message.php + installer/views/default/tmpl/index.html + installer/views/default/view.php + installer/views/extension/index.html + installer/views/extension/tmpl/default.php + installer/views/extension/tmpl/default_item.php + installer/views/extension/tmpl/index.html + installer/views/extension/view.php + installer/views/index.html + installer/views/install/index.html + installer/views/install/tmpl/default.php + installer/views/install/tmpl/default_form.php + installer/views/install/tmpl/index.html + installer/views/install/view.php + installer/views/language/index.html + installer/views/language/tmpl/default.php + installer/views/language/tmpl/default_item.php + installer/views/language/tmpl/index.html + installer/views/language/view.php + installer/views/plugin/index.html + installer/views/plugin/tmpl/default.php + installer/views/plugin/tmpl/default_item.php + installer/views/plugin/tmpl/index.html + installer/views/plugin/view.php + jce.php + js/index.html + js/sortables.js + plugins/controller.php + plugins/extension.php + plugins/index.html + plugins/plugin.php + plugins/views/access/index.html + plugins/views/access/tmpl/default.php + plugins/views/access/tmpl/index.html + plugins/views/access/view.html.php + plugins/views/index.html + plugins/views/layout/index.html + plugins/views/layout/tmpl/default.php + plugins/views/layout/tmpl/index.html + plugins/views/layout/view.html.php + plugins/views/plugin/index.html + plugins/views/plugin/tmpl/form.php + plugins/views/plugin/tmpl/index.html + plugins/views/plugin/view.html.php + plugins/views/plugins/index.html + plugins/views/plugins/tmpl/default.php + plugins/views/plugins/tmpl/index.html + plugins/views/plugins/view.html.php + updater.php + + + en-GB.com_jce.ini + en-GB.com_jce.menu.ini + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/js/index.html b/oss/joomla/trunk/administrator/components/com_jce/js/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/js/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/js/sortables.js b/oss/joomla/trunk/administrator/components/com_jce/js/sortables.js new file mode 100644 index 00000000..18d86e69 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/js/sortables.js @@ -0,0 +1,347 @@ +/* +Script: Sortables.js + Contains Class. + +License: + MIT-style license. +*/ + +/* +Class: Sortables + Creates an interface for drag and drop sorting of a list or lists. + +Arguments: + list - required, the list or lists that will become sortable. + This argument can be an Element, or array of Elements. When a single list (or id) is passed, that list will be sortable only with itself. + To enable sorting between lists, one or more lists or id's must be passed using an array or an object. See Examples below. + options - an Object, see options and events below. + +Options: + constrain - whether or not to constrain the element being dragged to its parent element. defaults to false. + clone - whether or not to display a copy of the actual element while dragging. defaults to true with opacity of 0.7, you can refine styles using an object. + opacity - opacity of the element being dragged for sorting + handle - a selector which be used to select the element inside each item to be used as a handle for sorting that item. if no match is found, the element is used as its own handle. + revert - whether or not to use an effect to slide the element into its final location after sorting. If you pass an object it will be treated as true and used as aditional options for the revert effect. defaults to false. + +Events: + onStart - function executed when the item starts dragging + onComplete - function executed when the item ends dragging + +Example: + (start code) + var mySortables = new Sortables('list-1', { + revert: { duration: 500, transition: Fx.Transitions.Elastic.easeOut } + }); + //creates a new Sortable instance over the list with id 'list-1' with some extra options for the revert effect + + var mySortables = new Sortables(['list-1', 'list-2'], { + constrain: true, + clone: false, + revert: true + }); + //creates a new Sortable instance allowing the sorting of the lists with id's 'list-1' and 'list-2' with extra options + //since constrain was set to false, the items will not be able to be dragged from one list to the other + + var mySortables = new Sortables(['list-1', 'list-2', 'list-3']); + //creates a new Sortable instance allowing sorting between the lists with id's 'list-1', 'list-2, and 'list-3' + (end) +*/ + +var Sortables = new Class({ + getOptions : function(){ + return { + constrain : false, + clone: false, + opacity: 0.7, + handle: false, + revert: false, + onStart: Class.empty, + onComplete: Class.empty + }; + }, + + initialize: function(lists, options){ + this.setOptions(this.getOptions(), options); + this.idle = true; + this.hovering = false; + this.newInsert = false; + this.bound = { + start: [], + end: this.end.bind(this), + move: this.move.bind(this), + reset: this.reset.bind(this) + }; + if (this.options.revert){ + var revertOptions = $merge({duration: 250, wait: false}, this.options.revert); + this.effect = new Fx.Styles(this.element, revertOptions).addEvent('onComplete', this.bound.reset, true); + } + this.cloneContents = !!(this.options.clone); + + this.lists = $$($(lists) || lists); + + this.reinitialize(); + if (this.options.initialize) this.options.initialize.call(this); + }, + + /* + Property: reinitialize + Allows the sortables instance to be reinitialized after making modifications to the DOM such as adding or removing elements from any of the lists. + */ + + reinitialize: function(){ + if (this.handles) this.detach(); + + this.handles = []; + var elements = []; + + this.lists.each(function(list){ + elements.extend(list.getChildren()); + }); + + this.handles = !this.options.handle ? elements : elements.map(function(element){ + return element.getElement(this.options.handle) || element; + }.bind(this)); + + this.handles.each(function(handle, i){ + this.bound.start[i] = this.start.bindAsEventListener(this, elements[i], true); + }, this); + + this.attach(); + }, + + /* + Property: attach + Attaches the mousedown event to all the handles, enabling sorting. + */ + + attach: function(){ + this.handles.each(function(handle, i){ + handle.addEvent('mousedown', this.bound.start[i]); + }, this); + }, + + /* + Property: detach + Detaches the mousedown event from the handles, disabling sorting. + */ + + detach: function(){ + this.handles.each(function(handle, i){ + handle.removeEvent('mousedown', this.bound.start[i]); + }, this); + }, + + check: function(element, list){ + element = element.getCoordinates(); + var coords = list ? element : { + left: element.left - this.list.scrollLeft, + right: element.right - this.list.scrollLeft, + top: element.top - this.list.scrollTop, + bottom: element.bottom - this.list.scrollTop + }; + return (this.curr.x > coords.left && this.curr.x < coords.right && this.curr.y > coords.top && this.curr.y < coords.bottom); + }, + + where: function(element){ + if (this.newInsert){ + this.newInsert = false; + return 'before'; + } + var dif = {'x': this.curr.x - this.prev.x, 'y': this.curr.y - this.prev.y}; + return dif[['y', 'x'][(Math.abs(dif.x) >= Math.abs(dif.y)) + 0]] <= 0 ? 'before' : 'after'; + }, + + reposition: function(){ + if (this.list.positioned){ + this.position.y -= this.offset.list.y - this.list.scrollTop; + this.position.x -= this.offset.list.x - this.list.scrollLeft; + } else if (window.opera){ + this.position.y += this.list.scrollTop; + this.position.x += this.list.scrollLeft; + } + }, + + start: function(event, element){ + var event = new Event(event); + if (!this.idle) return; + + this.idle = false; + this.prev = {'x': event.page.x, 'y': event.page.y}; + + this.styles = element.getStyles('margin-top', 'margin-left', 'padding-top', 'padding-left', 'border-top-width', 'border-left-width', 'opacity'); + this.margin = { + 'top': this.styles['margin-top'].toInt() + this.styles['border-top-width'].toInt(), + 'left': this.styles['margin-left'].toInt() + this.styles['border-left-width'].toInt() + }; + + this.element = element; + this.list = this.element.getParent(); + this.list.hovering = this.hovering = true; + this.list.positioned = this.list.getStyle('position').test(/relative|absolute|fixed/); + + var children = this.list.getChildren(); + var bounds = children.shift().getCoordinates(); + children.each(function(element){ + var coords = element.getCoordinates(); + bounds.left = Math.min(coords.left, bounds.left); + bounds.right = Math.max(coords.right, bounds.right); + bounds.top = Math.min(coords.top, bounds.top); + bounds.bottom = Math.max(coords.bottom, bounds.bottom); + }); + this.bounds = bounds; + + this.position = this.element.getPosition([this.list]); + + this.offset = { + 'list': this.list.getPosition(), + 'element': {'x': event.page.x - this.position.x, 'y': event.page.y - this.position.y} + }; + this.reposition(); + + var clone = this.options.clone; + switch ($type(clone)){ + case 'function': this.clone = clone.call(this, this.element); break; + case 'boolean': clone = (clone) ? {'opacity': 0.7} : {'visibility': 'hidden', 'width': this.element.getStyle('width')}; + case 'object': this.clone = this.element.clone(this.cloneContents).setStyles(clone); + } + + this.clone.injectBefore(this.element.setStyles({ + 'position': 'absolute', + 'top': this.position.y - this.margin.top, + 'left': this.position.x - this.margin.left, + 'opacity': this.options.opacity + })); + + document.addEvent('mousemove', this.bound.move); + document.addEvent('mouseup', this.bound.end); + this.fireEvent('onStart', this.element); + event.stop(); + }, + + move: function(event){ + var event = new Event(event); + this.curr = {'x': event.page.x, 'y': event.page.y}; + this.position = {'x': this.curr.x - this.offset.element.x, 'y': this.curr.y - this.offset.element.y}; + + if (this.options.constrain) { + this.position.y = this.position.y.limit(this.bounds.top, this.bounds.bottom - this.element.offsetHeight); + this.position.x = this.position.x.limit(this.bounds.left, this.bounds.right - this.element.offsetWidth); + } + this.reposition(); + this.element.setStyles({ + 'top' : this.position.y - this.margin.top, + 'left' : this.position.x - this.margin.left + }); + + if (!this.options.constrain){ + var oldSize, newSize; + this.lists.each(function(list){ + if (!this.check(list, true)){ + list.hovering = false; + } else if (!list.hovering){ + this.list = list; + this.list.hovering = this.newInsert = true; + this.list.positioned = this.list.getStyle('position').test(/relative|absolute|fixed/); + oldSize = this.clone.getSize().size; + this.list.adopt(this.clone, this.element); + newSize = this.clone.getSize().size; + this.offset = { + 'list': this.list.getPosition(), + 'element': { + 'x': Math.round(newSize.x * (this.offset.element.x / oldSize.x)), + 'y': Math.round(newSize.y * (this.offset.element.y / oldSize.y)) + } + }; + } + }, this); + } + + if (this.list.hovering){ + this.list.getChildren().each(function(element){ + if (!this.check(element)){ + element.hovering = false; + } else if (!element.hovering && element != this.clone){ + element.hovering = true; + this.clone.inject(element, this.where(element)); + } + }, this); + } + + this.prev = this.curr; + event.stop(); + }, + + end: function(){ + this.prev = null; + document.removeEvent('mousemove', this.bound.move); + document.removeEvent('mouseup', this.bound.end); + + this.position = this.clone.getPosition([this.list]); + this.reposition(); + + if (!this.effect){ + this.reset(); + } else { + this.effect.element = this.element; + this.effect.start({ + 'top' : this.position.y - this.margin.top, + 'left' : this.position.x - this.margin.left, + 'opacity' : this.styles.opacity + }); + } + }, + + reset: function(){ + this.element.setStyles({ + 'position': 'static', + 'opacity': this.styles.opacity + }).injectBefore(this.clone); + this.clone.empty().remove(); + + this.fireEvent('onComplete', this.element); + this.idle = true; + }, + + /* + Property: serialize + Function to get the order of the elements in the lists of this sortables instance. + For each list, an array containing the order of the elements will be returned. + If more than one list is being used, all lists will be serialized and returned in an array. + + Arguments: + index - int or false; index of the list to serialize. Omit or pass false to serialize all lists. + modifier - function to override the default output of the sortables. See Examples below + + Examples: + (start code) + mySortables.serialize(1); + //returns the second list serialized (remember, arrays are 0 based...); + //['item_1-1', 'item_1-2', 'item_1-3'] + + mySortables.serialize(); + //returns a nested array of all lists serialized, or if only one list exists, that lists order + //[['item_1-1', 'item_1-2', 'item_1-3'], ['item_2-1', 'item_2-2', 'item_2-3'], ['item_3-1', 'item_3-2', 'item_3-3']] + + mySortables.serialize(2, function(element, index){ + return element.getProperty('id').replace('item_','') + '=' + index; + }).join('&'); + //joins the array with a '&' to return a string of the formatted ids of all the elmements in list 3 with their position + //'3-0=0&3-1=1&3-2=2' + (end) + */ + + serialize: function(index, modifier){ + var map = modifier || function(element, index){ + return element.getProperty('id'); + }.bind(this); + + var serial = this.lists.map(function(list){ + return list.getChildren().map(map, this); + }, this); + + if (this.lists.length == 1) index = 0; + return $chk(index) && index >= 0 && index < this.lists.length ? serial[index] : serial; + } + +}); +Sortables.implement(new Options, new Events); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/controller.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/controller.php new file mode 100644 index 00000000..4558c581 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/controller.php @@ -0,0 +1,219 @@ +registerTask( 'apply', 'save'); + $this->registerTask( 'unpublish', 'publish'); + $this->registerTask( 'edit' , 'display' ); + $this->registerTask( 'add' , 'display' ); + $this->registerTask( 'orderup' , 'order' ); + $this->registerTask( 'orderdown' , 'order' ); + } + + function display( ) + { + switch($this->getTask()) + { + case 'add' : + case 'edit' : + { + JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view', 'plugin' ); + } break; + } + + parent::display(); + } + + function save() + { + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('plugin', 'JCETable'); + $task = $this->getTask(); + + 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(); + + $row->reorder( 'type = '.$db->Quote($row->type).' AND ordering > -10000 AND ordering < 10000' ); + + switch ( $task ) + { + case 'apply': + $msg = JText::sprintf( 'Successfully Saved changes to Plugin', $row->title ); + $this->setRedirect( 'index.php?option=com_jce&type=plugin&view=plugin&task=edit&cid[]='. $row->id, $msg ); + break; + + case 'save': + default: + $msg = JText::sprintf( 'Successfully Saved Plugin', $row->title ); + $this->setRedirect( 'index.php?option=com_jce&type=plugin', $msg ); + break; + } + } + + function publish( ){ + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + $publish = ( $this->getTask() == 'publish' ? 1 : 0 ); + + if (count( $cid ) < 1) { + $action = $publish ? JText::_( 'publish' ) : JText::_( 'unpublish' ); + JError::raiseError(500, JText::_( 'Select a plugin to '.$action ) ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__jce_plugins SET published = '.(int) $publish + . ' WHERE id IN ( '.$cids.' )' + . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ))' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) { + $row =& JTable::getInstance('plugin', 'JCETable'); + $row->checkin( $cid[0] ); + } + + $this->setRedirect( 'index.php?option=com_jce&type=plugin' ); + } + + function cancel( ){ + $this->setRedirect( JRoute::_( 'index.php?option=com_jce', false ) ); + } + + function cancelEdit( ) + { + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('plugin', 'JCETable'); + $row->bind(JRequest::get('post')); + $row->checkin(); + + $this->setRedirect( JRoute::_( 'index.php?option=com_jce&type=plugin', false ) ); + } + + function order( ) + { + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + $uid = $cid[0]; + $inc = ( $this->getTask() == 'orderup' ? -1 : 1 ); + + $row =& JTable::getInstance('plugin', 'JCETable'); + $row->load( $uid ); + $row->move( $inc, 'name='.$db->Quote($row->name).' AND ordering > -10000 AND ordering < 10000' ); + + $this->setRedirect( 'index.php?option=com_jce&type=plugin' ); + } + + function saveorder( ) + { + // Check for request forgeries + JRequest::checkToken() or die( 'Invalid Token' ); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + $db =& JFactory::getDBO(); + $total = count( $cid ); + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + JArrayHelper::toInteger($order, array(0)); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + $row =& JTable::getInstance('plugin', 'JCETable'); + $conditions = array(); + + // update ordering values + for ( $i=0; $i < $total; $i++ ) + { + $row->load( (int) $cid[$i] ); + if ($row->ordering != $order[$i]) + { + $row->ordering = $order[$i]; + if (!$row->store()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + // remember to updateOrder this group + $condition = 'type = '.$db->Quote($row->type).' AND ordering > -10000 AND ordering < 10000'; + $found = false; + foreach ( $conditions as $cond ) + { + if ($cond[1]==$condition) { + $found = true; + break; + } + } + if (!$found) $conditions[] = array($row->id, $condition); + } + } + + // execute updateOrder for each group + foreach ( $conditions as $cond ) { + $row->load( $cond[0] ); + $row->reorder( $cond[1] ); + } + + $msg = JText::_( 'New ordering saved' ); + $this->setRedirect( 'index.php?option=com_jce&type=plugin', $msg ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/extension.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/extension.php new file mode 100644 index 00000000..40dd89f3 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/extension.php @@ -0,0 +1,70 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/index.html b/oss/joomla/trunk/administrator/components/com_jce/plugins/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/plugin.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/plugin.php new file mode 100644 index 00000000..9aed7bb0 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/plugin.php @@ -0,0 +1,145 @@ +loadArray($array['params']); + $array['params'] = $registry->toString(); + } + + return parent::bind($array, $ignore); + } +} +?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/index.html b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/tmpl/default.php new file mode 100644 index 00000000..117a6e65 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/tmpl/default.php @@ -0,0 +1,32 @@ + + +
+
+ + +
+
+ +
+
+
+ + + + + +
lists;?>
+
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/view.html.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/view.html.php new file mode 100644 index 00000000..ee84db7a --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/access/view.html.php @@ -0,0 +1,43 @@ +assignRef('lists', $lists); + + parent::display($tpl); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/index.html b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/index.html b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/tmpl/default.php new file mode 100644 index 00000000..1744ef96 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/tmpl/default.php @@ -0,0 +1,70 @@ + + + + + + +
+
+
+ + +
+
+ +
+
+
+
+
+
+
+ + + + + + + +
+ dimensions['width'] + 100; + $sortid = array(); + for( $i=0; $iitems ); $i++ ){ + $r = $i + 1; + $sortid[] = "'row". $r ."'"; + ?> +
    + items[$i] as $item ){ + $n = "row_li_". $item->id; + $path = $item->type == 'command' ? '../plugins/editors/jce/tiny_mce/themes/advanced/img/'. $item->layout .'.gif' : '../plugins/editors/jce/tiny_mce/plugins/'. $item->name .'/img/'. $item->layout .'.gif'; + ?> +
  • <?php echo $item->title;?>
  • + +
+ + +
+
+ + + + + + + +
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/view.html.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/view.html.php new file mode 100644 index 00000000..793efb9c --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/layout/view.html.php @@ -0,0 +1,71 @@ +params ); + + $num = intval( $params->get( 'layout_rows', 5 ) ); + $rows = array(); + + for($i=1; $i<=$num; $i++){ + $query = "SELECT id, title, name, type, layout, icon" + . "\n FROM #__jce_plugins" + . "\n WHERE row = ". $i ."" + . "\n AND published = 1" + . "\n AND icon != ''" + . "\n ORDER BY ordering ASC" + ; + $db->setQuery( $query ); + $rows[] = $db->loadObjectList(); + } + + $dimensions['width'] = $params->get( 'width', '600' ); + $dimensions['height'] = $params->get( 'height', '600' ); + + if ($client == 'admin') { + $client_id = 1; + } else { + $client_id = 0; + } + + $this->assignRef('dimensions', $dimensions); + $this->assignRef('client', $client_id); + $this->assignRef('items', $rows); + + parent::display($tpl); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/index.html b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/tmpl/form.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/tmpl/form.php new file mode 100644 index 00000000..c4255daa --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/tmpl/form.php @@ -0,0 +1,149 @@ + + + + +[' .JText::_('Edit'). ']', 'plugin.png' ); + JToolBarHelper::save(); + JToolBarHelper::apply(); + JToolBarHelper::cancel( 'cancelEdit', 'Close' ); + jceToolbarHelper::help( 'plugins.edit' ); +?> + +plugin, ENT_QUOTES, '' ); +?> + +plugin->nameA = ''; + if ( $this->plugin->id ) { + $row->nameA = '[ '. $this->plugin->name .' ]'; + } + $icon_disabled = $this->plugin->row == '0' ? ' disabled="disabled"' : ''; + $layout_disabled = $this->plugin->row == '0' ? ' disabled="disabled"' : ''; +?> + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ : + + lists['published']; ?> +
+ + + plugin->type; ?> +
+ + + +
+ + + />.gif +
+ + + />.gif +
+ : + + lists['row']; ?> +
+ : + + lists['ordering']; ?> +
+ : + + plugin->description ) ); ?> +
+ : + + plugin->preview );?> +
+
+
+
+ + + + + + +
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/view.html.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/view.html.php new file mode 100644 index 00000000..dc1aeeb4 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugin/view.html.php @@ -0,0 +1,126 @@ +load( $cid[0] ); + + // fail if checked out not by 'me' + + if ($row->isCheckedOut( $user->get('id') )) + { + $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The plugin' ), $row->title ); + $this->setRedirect( 'index.php?option='. $option .'&type=plugin', $msg, 'error' ); + return false; + } + $path = JPATH_PLUGINS .DS. 'editors' .DS. 'jce' .DS. 'tiny_mce' .DS. 'plugins' .DS. $row->name; + $url = $mainframe->getSiteURL(). 'plugins/editors/jce/tiny_mce/plugins/' .$row->name; + $xmlPath = $path .DS. $row->name .'.xml'; + + if ($cid[0]) + { + $row->checkout( $user->get('id') ); + + if ( $row->ordering > 0 && $row->ordering < 100 ) + { + // build the html select list for ordering + $query = 'SELECT ordering AS value, title AS text' + . ' FROM #__jce_plugins' + . ' WHERE name = "'. $row->name. '"' + . ' AND published > 0' + . ' AND ordering > 0' + . ' AND ordering < 100' + . ' ORDER BY ordering' + ; + $order = JHTML::_('list.genericordering', $query ); + $lists['ordering'] = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); + } else { + $lists['ordering'] = ''. JText::_( 'This plugin cannot be reordered' ); + } + + $lang =& JFactory::getLanguage(); + $lang->load( 'com_jce_' . trim( $row->name ), JPATH_SITE ); + + $data = JApplicationHelper::parseXMLInstallFile( $xmlPath ); + $row->description = $data['description']; + } else { + $row->type = 'plugin'; + $row->row = 4; + $row->ordering = 1; + $row->published = 1; + $row->details = 'From XML file'; + $row->icon = ''; + $row->layout = ''; + $row->params = ''; + $row->description = ''; + + $ordering = array(); + for($i=1; $i<31; $i++){ + $ordering[] = JHTML::_( 'select.option', $i, $i ); + } + $lists['ordering'] = JHTML::_('select.genericlist', $ordering, 'ordering', 'class="inputbox" size="1"', 'value', 'text', '' ); + } + + $row_list = array( + JHTML::_( 'select.option', '1','1' ), + JHTML::_( 'select.option', '2','2' ), + JHTML::_( 'select.option', '3','3' ), + JHTML::_( 'select.option', '4','4' ) + ); + if ( $row->row > 0 ){ + $lists['row'] = JHTML::_('select.genericlist', $row_list, 'row', 'class="inputbox" size="1"', 'value', 'text', intval( $row->row ) ); + }else{ + $lists['row'] = ''. JText::_( 'This plugin\'s row cannot be altered' ); + } + $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); + + $row->preview = file_exists( $path .DS. 'img' .DS. 'preview.jpg' ) ? 'Preview' : JText::_( 'No Preview Available' ); + + // get params definitions + $params = new JParameter( $row->params, $xmlPath ); + + $this->assignRef('lists', $lists); + $this->assignRef('plugin', $row); + $this->assignRef('params', $params); + + parent::display($tpl); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/index.html b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/tmpl/default.php new file mode 100644 index 00000000..36f57ab1 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/tmpl/default.php @@ -0,0 +1,153 @@ + + + + + +items; + +?> +
+ + + + + +
+ : + + + + + lists['type']; + echo $this->lists['state']; + ?> +
+ + + + + + + + + + + + + + + + + + + + + + +id ); + + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + + $ordering = ($this->lists['order'] == 'p.type'); +?> + "> + + + + + + + + + + + + + +
+ + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> +
+ pagination->getListFooter(); ?> +
+ pagination->getRowOffset( $i ); ?> + + + + user->get ('id'), $row->checked_out ) || !$row->editable ) { + echo $row->title; + } else { + ?> + + + title; ?> + + + + + row;?> + + ordering;?> + + type;?> + + name;?> + + type == 'plugin' && $row->layout ){ + echo ''. $row->name .''; + } + if( $row->type == 'command' ){ + echo ''. $row->name .''; + }?> + + id;?> +
+ + + + + + + +
\ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/tmpl/index.html b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/view.html.php b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/view.html.php new file mode 100644 index 00000000..02367866 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/plugins/views/plugins/view.html.php @@ -0,0 +1,124 @@ +getUserStateFromRequest( "$option.$type.$task.$client.filter_order", 'filter_order', 'p.type', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.$type.$task.$client.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( "$option.$type.$task.$client.filter_state", 'filter_state', '', 'word' ); + $filter_type = $mainframe->getUserStateFromRequest( "$option.$type.$task.$client.filter_type", 'filter_type', 1, 'cmd' ); + $search = $mainframe->getUserStateFromRequest( "$option.$type.$task.$client.search", 'search', '', 'string' ); + $search = JString::strtolower( $search ); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( '$option.$type.$task.$client.limitstart', 'limitstart', 0, 'int' ); + + $limitstart = isset( $limitstart->plugin ) ? $limitstart->plugin : $limitstart; + + $where = array(); + + // used by filter + if ( $filter_type != 1 ) { + $where[] = 'p.type = "'.$filter_type.'"'; + } + if ( $search ) { + $where[] = 'LOWER( p.name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'p.published = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'p.published = 0'; + } + } + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '.$filter_order .' '. $filter_order_Dir .', p.row ASC'; + + // get the total number of records + $query = 'SELECT COUNT(*)' + . ' FROM #__jce_plugins AS p' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pagination = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT p.*, u.name AS editor' + . ' FROM #__jce_plugins AS p' + . ' LEFT JOIN #__users AS u ON u.id = p.checked_out' + . $where + . ' GROUP BY p.id' + . $orderby + ; + $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + // get list of Positions for dropdown filter + $query = 'SELECT type AS value, type AS text' + . ' FROM #__jce_plugins' + . ' GROUP BY type' + . ' ORDER BY type' + ; + $types[] = JHTML::_('select.option', 1, '- '. JText::_( 'Select Type' ) .' -' ); + $db->setQuery( $query ); + $types = array_merge( $types, $db->loadObjectList() ); + $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $filter_type ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search'] = $search; + + $this->assignRef('user', JFactory::getUser()); + $this->assignRef('lists', $lists); + $this->assignRef('items', $rows); + $this->assignRef('pagination', $pagination); + + parent::display($tpl); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_jce/updater.php b/oss/joomla/trunk/administrator/components/com_jce/updater.php new file mode 100644 index 00000000..b31271b6 --- /dev/null +++ b/oss/joomla/trunk/administrator/components/com_jce/updater.php @@ -0,0 +1,1133 @@ +load('com_jce', JPATH_ADMINISTRATOR); + } + /** + * Returns a reference to a editor object + * + * This method must be invoked as: + *
  $browser = &JContentEditor::getInstance();
+ * + * @access public + * @return JCE The editor object. + * @since 1.5 + */ + function &getInstance() + { + static $instance; + + if (!is_object($instance)) { + $instance = new JCEUpdater(); + } + return $instance; + } + /** + * Check upgrade / database status + */ + function initCheck() + { + global $mainframe; + // Check Plugins DB + if (!$this->checkTable('plugins')) { + $link = JHTML::link('index.php?option=com_jce&task=repair&type=plugins', JText::_('DB CREATE RESTORE')); + return $this->redirect(JText::_('DB PLUGINS ERROR') .' - '. $link, 'error'); + } + // Check Groups DB + if (!$this->checkTable('groups')) { + $link = JHTML::link('index.php?option=com_jce&task=repair&type=groups', JText::_('DB CREATE RESTORE')); + return $this->redirect(JText::_('DB GROUPS ERROR') .' - '. $link, 'error'); + } + // Check Editor is installed + if (!$this->checkEditorFiles()) { + return $this->redirect(JText::_('EDITOR FILES ERROR'), 'error'); + } + if (!$this->checkEditor() && $this->checkEditorFiles()) { + $link = JHTML::link('index.php?option=com_jce&task=repair&type=editor', JText::_('EDITOR INSTALL')); + return $this->redirect(JText::_('EDITOR INSTALLED MANUAL ERROR') .' - '. $link, 'error'); + } + // Check Editor is installed + if (!$this->checkEditor()) { + return $this->redirect(JText::_('EDITOR INSTALLED ERROR'), 'error'); + } + // Check Editor is enabled + if (!$this->checkEditorEnabled()) { + return $this->redirect(JText::_('EDITOR ENABLED ERROR'), 'error'); + } + if (!$this->checkEditorDefault()) { + $mainframe->enqueueMessage(JText::_('EDITOR DEFAULT NOTICE'), 'notice'); + } + // Check Update + if (!$this->checkUpdate()) { + $link = JHTML::link('index.php?option=com_jce&task=repair&type=update', JText::_('DB UPDATE')); + return $this->redirect(JText::_('DB UPDATE MSG') .' - '. $link, 'error'); + } + } + /** + * Redirect with message + * @param object $msg[optional] Message to display + * @param object $state[optional] Message type + */ + function redirect($msg = '', $state = '') + { + global $mainframe; + if ($msg) { + $mainframe->enqueueMessage($msg, $state); + } + JRequest::setVar('type', 'cpanel'); + JRequest::setVar('task', ''); + + return false; + } + /** + * Backup a table by renaming to [table_name]_tmp + * @return boolean + * @param string $table Table to backup + */ + function backupTable($table) + { + $db =& JFactory::getDBO(); + + // Table must exist + if ($this->checkTable($table)) { + // Check for tmp table + if (!$this->checkTable($table . '_tmp')) { + $query = 'RENAME TABLE #__jce_'. $table .' TO #__jce_'. $table .'_tmp'; + $db->setQuery($query); + return $db->query(); + } + return true; + } else { + return $this->checkTable($table . '_tmp'); + } + return false; + } + /** + * Check whether a table exists + * @return boolean + * @param string $table Table name + */ + function checkTable($table) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT COUNT(id) FROM #__jce_'. $table; + $db->setQuery($query); + return $db->loadResult(); + } + /** + * Rename / Backup all tables + */ + function purgeDB() + { + global $mainframe; + $db =& JFactory::getDBO(); + $tables = array('plugins', 'extensions', 'groups'); + + foreach ($tables as $table) { + // Backup table to temp. Will be removed on uninstall + if (!$this->backupTable($table)) { + $msg = JText::_('DB PURGE '. strtoupper($table) .' ERROR'); + $state = 'error'; + } else { + $msg = JText::_('DB PURGE '. strtoupper($table) .' SUCCESS'); + $state = ''; + } + $mainframe->enqueueMessage($msg, $state); + } + $this->redirect(); + } + /** + * Check if all backup tables exist + * @return boolean + */ + function purgeCheck() + { + $ret = false; + $tables = array('plugins', 'extensions', 'groups'); + foreach ($tables as $table) { + $ret = $this->checkTable($table) && !$this->checkTable($table .'_tmp'); + } + return $ret; + } + /** + * Remove all backup tables + */ + function cleanupDB() + { + $db =& JFactory::getDBO(); + + $tables = array('plugins', 'groups', 'extensions'); + + foreach ($tables as $table) { + $query = 'DROP TABLE IF EXISTS #__jce_'. $table .'_tmp'; + $db->setQuery($query); + + $db->query(); + } + } + /** + * Check for earlier version to trigger update + * @return boolean + */ + function checkUpdate() + { + // Check for Readmore plugin indicates 1.5.0 + global $mainframe; + $db =& JFactory::getDBO(); + + $ret = false; + + $query = 'SELECT count(id)' + . ' FROM #__jce_plugins' + . ' WHERE name = '. $db->Quote('readmore') + ; + $db->setQuery($query); + $ret = $db->loadResult() ? false : true; + + return $ret; + } + /** + * Check whether the editor is installed + * @return boolean + */ + function checkEditor() + { + $db =& JFactory::getDBO(); + + $query = 'SELECT id' + . ' FROM #__plugins' + . ' WHERE element = '. $db->Quote('jce') + ; + $db->setQuery($query); + return $db->loadResult(); + } + /** + * Check for existence of editor files and folder + * @return boolean + */ + function checkEditorFiles() + { + $path = JPATH_PLUGINS .DS. 'editors'; + // Check for JCE plugin files + return file_exists($path .DS. 'jce.php') && file_exists($path .DS. 'jce.xml') && is_dir($path .DS. 'jce'); + } + /** + * Check if the editor is enabled + * @return boolean + */ + function checkEditorEnabled() + { + $db =& JFactory::getDBO(); + + $query = 'SELECT published FROM #__plugins' + .' WHERE element = '. $db->Quote('jce') + ; + $db->setQuery($query); + return $db->loadResult(); + } + /** + * Check if the editor is set as the default wysiwyg + * @return boolean + */ + function checkEditorDefault() + { + $conf =& JFactory::getConfig(); + if (JRequest::getVar('type', 'cpanel') == 'cpanel') { + return $conf->getValue('config.editor') == 'jce'; + } + return true; + } + /** + * Format / escape an IN / NOT IN list + * @return + * @param object $list + */ + function dbList($list) + { + if (is_array($list)) { + $ret = array(); + foreach ($list as $item) { + $ret[] = "'". $item ."'"; + } + return implode(',', $ret); + } + return $list; + } + /** + * Update the JCE Tables + * @return Redirect + * @param object $install[optional] + */ + function updateDB($install = false) + { + global $mainframe; + $db =& JFactory::getDBO(); + + // Create tmp tables + if ($this->backupTable('plugins') && $this->backupTable('groups')) { + // Update Plugins + if ($this->updatePlugins()) { + // Update Groups + if (!$this->updateGroups()) { + $mainframe->enqueueMessage(JText::_('UPDATE GROUPS ERROR'), 'error'); + } + } else { + $mainframe->enqueueMessage(JText::_('UPDATE PLUGINS ERROR'), 'error'); + } + } else { + // Unable to perform update! + $mainframe->enqueueMessage(JText::_('UPDATE ERROR'), 'error'); + } + + // Add Admin Menu options + $query = "UPDATE #__components SET `admin_menu_img` = '../administrator/components/com_jce/img/logo.png'" + . " WHERE link = " . $db->Quote('option=com_jce') + ; + + $db->setQuery($query); + if (!$db->query()) { + $mainframe->enqueueMessage(JText::_('ADMIN MENU IMAGE ERROR'), 'error'); + } + if (!$install) { + $this->redirect(); + } + } + /** + * Get an array of commands / plugins + * @return array + */ + function getButtons() + { + $buttons = array( + 'contextmenu' => array( + 'title' => 'Context Menu', + 'row' => 0 + ), + 'browser' => array( + 'title' => 'File Browser', + 'row' => 0, + 'editable' => 1 + ), + 'inlinepopups' => array( + 'title' => 'Inline Popups', + 'row' => 0 + ), + 'media' => array( + 'title' => 'Media Support', + 'row' => 0, + 'editable' => 1 + ), + 'safari' => array( + 'title' => 'Safari Browser Support', + 'row' => 0 + ), + 'help' => array( + 'title' => 'Help', + 'row' => 1 + ), + 'newdocument' => array( + 'title' => 'New Document', + 'row' => 1 + ), + 'bold' => array( + 'title' => 'Bold', + 'row' => 1 + ), + 'italic' => array( + 'title' => 'Italic', + 'row' => 1 + ), + 'underline' => array( + 'title' => 'Underline', + 'row' => 1 + ), + 'fontselect' => array( + 'title' => 'Font Select', + 'row' => 1 + ), + 'fontsizeselect' => array( + 'title' => 'Font Size Select', + 'row' => 1 + ), + 'styleselect' => array( + 'title' => 'Style Select', + 'row' => 1 + ), + 'strikethrough' => array( + 'title' => 'StrikeThrough', + 'row' => 1 + ), + 'full' => array( + 'title' => 'Justify Full', + 'row' => 1, + 'icon' => 'justifyfull', + 'layout'=> 'justifyfull' + ), + 'center' => array( + 'title' => 'Justify Center', + 'row' => 1, + 'icon' => 'justifycenter', + 'layout'=> 'justifycenter' + ), + 'left' => array( + 'title' => 'Justify Left', + 'row' => 1, + 'icon' => 'justifyleft', + 'layout'=> 'justifyleft' + ), + 'right' => array( + 'title' => 'Justify Right', + 'row' => 1, + 'icon' => 'justifyright', + 'layout'=> 'justifyright' + ), + 'formatselect' => array( + 'title' => 'Format Select', + 'row' => 1 + ), + 'paste' => array( + 'title' => 'Paste', + 'icon' => 'pasteword,pastetext', + 'row' => 2, + 'editable' => 1 + ), + 'searchreplace' => array( + 'title' => 'Search Replace', + 'icon' => 'search,replace', + 'row' => 2 + ), + 'forecolor' => array( + 'title' => 'Font ForeColour', + 'row' => 2 + ), + 'backcolor' => array( + 'title' => 'Font BackColour', + 'row' => 2 + ), + 'unlink' => array( + 'title' => 'Unlink', + 'row' => 2 + ), + 'indent' => array( + 'title' => 'Indent', + 'row' => 2 + ), + 'outdent' => array( + 'title' => 'Outdent', + 'row' => 2 + ), + 'undo' => array( + 'title' => 'Undo', + 'row' => 2 + ), + 'redo' => array( + 'title' => 'Redo', + 'row' => 2 + ), + 'html' => array( + 'title' => 'HTML', + 'icon' => 'code', + 'layout'=> 'code', + 'row' => 2 + ), + 'numlist' => array( + 'title' => 'Numbered List', + 'row' => 2 + ), + 'bullist' => array( + 'title' => 'Bullet List', + 'row' => 2 + ), + 'clipboard' => array( + 'title' => 'Clipboard Actions', + 'icon' => 'cut,copy,paste', + 'row' => 2 + ), + 'anchor' => array( + 'title' => 'Anchor', + 'row' => 2 + ), + 'image' => array( + 'title' => 'Image', + 'row' => 2 + ), + 'link' => array( + 'title' => 'Link', + 'row' => 2 + ), + 'cleanup' => array( + 'title' => 'Code Cleanup', + 'row' => 2 + ), + 'directionality' => array( + 'title' => 'Directionality', + 'icon' => 'ltr,rtl', + 'row' => 3 + ), + 'emotions' => array( + 'title' => 'Emotions', + 'row' => 3 + ), + 'fullscreen' => array( + 'title' => 'Fullscreen', + 'row' => 3 + ), + 'preview' => array( + 'title' => 'Preview', + 'row' => 3 + ), + 'table' => array( + 'title' => 'Tables', + 'icon' => 'tablecontrols', + 'layout'=> 'buttons', + 'row' => 3 + ), + 'print' => array( + 'title' => 'Print', + 'row' => 3 + ), + 'hr' => array( + 'title' => 'Horizontal Rule', + 'row' => 3 + ), + 'sub' => array( + 'title' => 'Subscript', + 'row' => 3 + ), + 'sup' => array( + 'title' => 'Superscript', + 'row' => 3 + ), + 'visualaid' => array( + 'title' => 'Visual Aid', + 'row' => 3 + ), + 'charmap' => array( + 'title' => 'Character Map', + 'row' => 3 + ), + 'removeformat' => array( + 'title' => 'Remove Format', + 'row' => 3 + ), + 'style' => array( + 'title' => 'Styles', + 'icon' => 'styleprops', + 'row' => 4 + ), + 'nonbreaking' => array( + 'title' => 'Non-Breaking', + 'row' => 4 + ), + 'visualchars' => array( + 'title' => 'Visual Characters', + 'row' => 4 + ), + 'xhtmlxtras' => array( + 'title' => 'XHTML Xtras', + 'icon' => 'cite,abbr,acronym,del,ins,attribs', + 'row' => 4 + ), + 'imgmanager' => array( + 'title' => 'Image Manager', + 'row' => 4, + 'editable' => 1 + ), + 'advlink' => array( + 'title' => 'Advanced Link', + 'row' => 4, + 'editable' => 1 + ), + 'spellchecker' => array( + 'title' => 'Spell Checker', + 'row' => 4, + 'editable' => 1 + ), + 'layer' => array( + 'title' => 'Layers', + 'icon' => 'insertlayer,moveforward,movebackward,absolute', + 'row' => 4 + ), + 'advcode' => array( + 'title' => 'Advanced Code Editor', + 'row' => 4 + ), + 'article' => array( + 'title' => 'Article Breaks', + 'icon' => 'readmore,pagebreak', + 'row' => 4 + ) + ); + return $buttons; + } + /** + * Create the Plugins table + * @return boolean + */ + function createPluginsTable() + { + global $mainframe; + $db =& JFactory::getDBO(); + + $query = "CREATE TABLE IF NOT EXISTS `#__jce_plugins` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` varchar(255) NOT NULL, + `name` varchar(255) NOT NULL, + `type` varchar(255) NOT NULL, + `icon` varchar(255) NOT NULL, + `layout` varchar(255) NOT NULL, + `row` int(11) NOT NULL, + `ordering` int(11) NOT NULL, + `published` tinyint(3) NOT NULL, + `editable` tinyint(3) NOT NULL, + `iscore` tinyint(3) NOT NULL, + `elements` varchar(255) NOT NULL, + `checked_out` int(11) NOT NULL, + `checked_out_time` datetime NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `plugin` (`name`) + );"; + $db->setQuery($query); + + if (!$db->query()) { + $mainframe->enqueueMessage(JText::_('CREATE TABLE PLUGINS ERROR'), 'error'); + return false; + } else { + return true; + } + } + /** + * Create the Plugin Extensions table + * @return boolean + */ + function createExtensionsTable() + { + global $mainframe; + $db =& JFactory::getDBO(); + + // Extensions + $query = "CREATE TABLE IF NOT EXISTS `#__jce_extensions` ( + `id` int(11) NOT NULL auto_increment, + `pid` int(11) NOT NULL, + `name` varchar(100) NOT NULL, + `extension` varchar(255) NOT NULL, + `folder` varchar(255) NOT NULL, + `published` tinyint(3) NOT NULL, + PRIMARY KEY (`id`) + )"; + $db->setQuery($query); + + if (!$db->query()) { + $mainframe->enqueueMessage(JText::_('CREATE TABLE EXTENSIONS ERROR'), 'error'); + return false; + } else { + return true; + } + } + /** + * Create the Groups table + * @return boolean + */ + function createGroupsTable() + { + global $mainframe; + $db =& JFactory::getDBO(); + + $query = "CREATE TABLE IF NOT EXISTS `#__jce_groups` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `description` varchar(255) NOT NULL, + `users` text NOT NULL, + `types` varchar(255) NOT NULL, + `components` text NOT NULL, + `rows` text NOT NULL, + `plugins` varchar(255) NOT NULL, + `published` tinyint(3) NOT NULL, + `ordering` int(11) NOT NULL, + `checked_out` tinyint(3) NOT NULL, + `checked_out_time` datetime NOT NULL, + `params` text NOT NULL, + PRIMARY KEY (`id`) + );"; + $db->setQuery($query); + + if (!$db->query()) { + $mainframe->enqueueMessage(JText::_('CREATE TABLE GROUPS ERROR'), 'error'); + return false; + } else { + return true; + } + } + /** + * Install Groups + * @return boolean + * @param object $install[optional] + */ + function installGroups($install = false) + { + global $mainframe; + $db =& JFactory::getDBO(); + + $ret = false; + + JTable::addIncludePath(JPATH_ADMINISTRATOR .DS. 'components' .DS. 'com_jce' .DS. 'groups'); + + if ($this->createGroupsTable()) { + $ret = true; + + $query = 'SELECT count(id) FROM #__jce_groups'; + $db->setQuery($query); + + $groups = array( + 'Default' => false, + 'Front End' => false + ); + + // No Groups table data + if (!$db->loadResult()) { + // Exclude these. Will be removed in 1.6 + $exclude = array('layer', 'image', 'link', 'html'); + + $query = 'SELECT id FROM #__jce_plugins' + . ' WHERE type = '. $db->Quote('plugin') + . ' AND name NOT IN ('. $this->dbList($exclude) .')' + . ' AND published = 1'; + $db->setQuery($query); + $plugins = $db->loadResultArray(); + + $rows = array(); + + $query = 'SELECT DISTINCT row FROM #__jce_plugins WHERE row > 0'; + $db->setQuery($query); + $num = $db->loadResultArray(); + + foreach ($num as $n) { + $query = 'SELECT id FROM #__jce_plugins WHERE row = '. $n .' AND name NOT IN ('. $this->dbList($exclude) .')'; + $db->setQuery($query); + $rows[] = implode(',', $db->loadResultArray()); + } + + $row =& JTable::getInstance('groups', 'JCETable'); + + $row->name = 'Default'; + $row->description = 'Default group for all users with edit access'; + $row->types = '19,20,21,23,24,25'; + $row->rows = implode(';', $rows); + $row->plugins = implode(',', $plugins); + $row->published = 1; + $row->ordering = 1; + + $groups['Default'] = $row->store(); + + // TODO : Move this out to an xml file or something + + $row =& JTable::getInstance('groups', 'JCETable'); + + $tmpl = array( + 'help,newdocument,undo,redo,bold,italic,underline,strikethrough,left,center,full,right,styleselect,formatselect', + 'sub,sup,numlist,bullist,indent,outdent,hr,charmap,visualchars,nonbreaking,searchreplace,clipboard,paste,removeformat,cleanup', + 'fullscreen,preview,print,visualaid,style,xhtmlxtras,anchor,unlink,advlink,imgmanager,spellchecker,advcode,article,contextmenu,safari,inlinepopups' + ); + + $plugins = array(); + $rows = array(); + + foreach ($tmpl as $item) { + $query = 'SELECT id FROM #__jce_plugins WHERE name IN ('. $this->dbList(explode(',', $item)) .') AND row > 0'; + $db->setQuery($query); + + $rows[] = implode(',', $db->loadResultArray()); + + $query = 'SELECT id FROM #__jce_plugins WHERE name IN ('. $this->dbList(explode(',', $item)) .') AND type = '. $db->Quote('plugin'); + $db->setQuery($query); + $plugins[] = implode(',', $db->loadResultArray()); + } + + $row->name = 'Front End'; + $row->description = 'Sample Group for Authors, Editors, Publishers'; + $row->types = '19,20,21'; + $row->rows = implode(';', $rows); + $row->plugins = implode(',', $plugins); + $row->published = 0; + $row->ordering = 2; + + $groups['Front End'] = $row->store(); + + // Print message + foreach ($groups as $k => $v) { + if (!$v) { + $mainframe->enqueueMessage(JText::_('GROUP INSTALL ERROR '). ' - '. $k, 'error'); + } + } + } + } + if (!$install) { + $this->redirect(); + } + return $ret; + } + /** + * Update Groups table + * @return boolean + */ + function updateGroups() + { + global $mainframe; + $db =& JFactory::getDBO(); + + if ($this->installGroups(true)) { + // Check for tmp tables + if ($this->checkTable('groups_tmp')) { + // empty Groups table + $query = 'TRUNCATE TABLE #__jce_groups'; + $db->setQuery($query); + $db->query() or die($db->stdErr()); + + JTable::addIncludePath(JPATH_ADMINISTRATOR .DS. 'components' .DS. 'com_jce' .DS. 'groups'); + // Get old Groups list + $query = 'SELECT * FROM #__jce_groups_tmp'; + $db->setQuery($query); + $groups = $db->loadObjectList(); + + foreach ($groups as $group) { + $rows = explode(';', $group->rows); + $items = array(); + // tmp Plugins table must exist for proper upgrade + if ($this->checkTable('plugins_tmp')) { + $query = 'SELECT a.id from #__jce_plugins AS a' + . ' INNER JOIN #__jce_plugins_tmp AS b ON a.name = b.name' + . ' WHERE b.id IN ('. $group->plugins .')' + ; + $db->setQuery($query); + $plugins = $db->loadResultArray(); + } else { + $plugins = $group->plugins; + } + + $row =& JTable::getInstance('groups', 'JCETable'); + $row->plugins = implode(',', $plugins); + // tmp Plugins table must exist for proper upgrade + if ($this->checkTable('plugins_tmp')) { + foreach ($rows as $item) { + $query = 'SELECT a.id from #__jce_plugins AS a' + . ' INNER JOIN #__jce_plugins_tmp AS b ON a.name = b.name' + . ' WHERE b.id IN ('. $item .')' + ; + $db->setQuery($query); + $items[] = implode(',', $db->loadResultArray()); + } + } else { + $items = $rows; + } + $row->rows = implode(';', $items); + + // Add additional properties + $row->name = $group->name; + $row->description = $group->description; + $row->components = $group->components; + $row->users = $group->users; + $row->types = $group->types; + $row->published = $group->published; + $row->ordering = $group->ordering; + $row->params = $group->params; + + if (!$row->store()) { + $mainframe->enqueueMessage(JText::_('GROUP UPDATE ERROR ') . $group->name, 'error'); + } + } + $this->cleanupDB(); + } + } + } + /** + * Install Plugins + * @return boolean + * @param object $install[optional] + */ + function installPlugins($install = false) + { + global $mainframe; + $db =& JFactory::getDBO(); + + $ret = false; + + JTable::addIncludePath(JPATH_ADMINISTRATOR .DS. 'components' .DS. 'com_jce' .DS. 'plugins'); + + if ($this->createPluginsTable()) { + $ret = true; + + $query = 'SELECT count(id) FROM #__jce_plugins'; + $db->setQuery($query); + + if (!$db->loadResult()) { + // Load table class + require_once(dirname(__FILE__) .DS. 'plugins' .DS. 'plugin.php'); + + // Get list from editor if installed + $plugins = array('contextmenu','directionality','emotions','fullscreen','paste','preview','table','print','searchreplace','style','layer','nonbreaking','visualchars','xhtmlxtras','imgmanager','advlink','spellchecker','help','browser','inlinepopups','media','safari','advcode','article','code','media'); + + $errors = array(); + + $r = 1; + $x = 0; + + $row =& JTable::getInstance('plugin', 'JCETable'); + + $query = 'INSERT INTO #__jce_plugins ('; + + foreach ($row as $k => $v) { + if ($k{0} != '_') { + $query .= '`'. $k . '`,'; + } + } + $query = substr($query, 0, -1) . ') VALUES '; + // Get the buttons array + $buttons = $this->getButtons(); + + foreach ($buttons as $k => $v) { + $row =& JTable::getInstance('plugin', 'JCETable'); + + $row->name = $k; + $row->published = 1; + $row->iscore = 1; + $row->editable = 0; + $row->type = in_array($k, $plugins) ? 'plugin' : 'command'; + + $row->bind($v); + + // Set Icon and Layout + if ($row->row) { + if (!isset($row->icon)) { + $row->icon = $row->name; + } + if (!isset($row->layout)) { + $row->layout = $row->name; + } + // Set ordering + if ($row->row == $r) { + $x++; + } else { + $r = $row->row; + $x = 1; + } + $row->ordering = $x; + } + $query .= '('; + foreach ($row as $k => $v) { + if ($k{0} != '_') { + $query .= "'". $v . "',"; + } + } + $query = substr($query, 0, -1) . '),'; + } + $query = substr($query, 0, -1); + + $db->setQuery($query); + if (!$db->query()) { + $mainframe->enqueueMessage(JText::_('PLUGINS INSTALL ERROR'), 'error'); + } + } + } + + if ($this->createExtensionsTable()) { + // Check for JoomlaLinks + $query = 'SELECT id FROM #__jce_extensions WHERE extension = '. $db->Quote('joomlalinks'); + $db->setQuery($query); + // JoomlaLinks is not installed + if (!$db->loadResult()) { + // Get AdvLink id + $query = 'SELECT id FROM #__jce_plugins WHERE name = '. $db->Quote('advlink'); + $db->setQuery($query); + $id = $db->loadResult(); + // If Advlink installed + if ($id) { + $row =& JTable::getInstance('extension', 'JCETable'); + + $row->pid = $id; + $row->name = 'Joomla Links for Advanced Link'; + $row->extension = 'joomlalinks'; + $row->folder = 'links'; + $row->published = 1; + + if (!$row->store()) { + $mainframe->enqueueMessage(JText::_('EXTENSIONS INSTALL ERROR'), 'error'); + } + } + } + } + + if (!$install) { + $this->redirect(); + } + return $ret; + } + /** + * Update Plugins table + * @return boolean + */ + function updatePlugins() + { + global $mainframe; + $db =& JFactory::getDBO(); + + JTable::addIncludePath(JPATH_ADMINISTRATOR .DS. 'components' .DS. 'com_jce' .DS. 'plugins'); + // Create and install Plugins tables + if ($this->installPlugins(true)) { + if ($this->checkTable('plugins_tmp')) { + // Get installed plugins + $query = 'SELECT * FROM #__jce_plugins_tmp WHERE iscore = 0'; + $db->setQuery($query); + $plugins = $db->loadObjectList(); + + foreach ($plugins as $plugin) { + $row =& JTable::getInstance('plugin', 'JCETable'); + // Pass properties to $row object + $row->title = $plugin->title; + $row->name = $plugin->name; + $row->icon = $plugin->icon; + $row->layout = $plugin->layout; + $row->row = $plugin->row; + $row->ordering = $plugin->ordering; + // Store + if (!$row->store()) { + $mainframe->enqueueMessage(JText::_('PLUGIN INSTALL ERROR '. $plugin->title), 'error'); + } + } + // Additional Extensions + $query = 'SELECT * FROM #__jce_extensions_tmp WHERE extension != '. $db->Quote('joomlalinks'); + $db->setQuery($query); + $extensions = $db->loadObjectList(); + if (!empty($extensions)) { + foreach ($extensions as $extension) { + $row =& JTable::getInstance('extension', 'JCETable'); + // Pass properties to $row object + $row->pid = $extension->pid; + $row->name = $extension->name; + $row->extension = $extension->extension; + $row->folder = $extension->folder; + // Store + if (!$row->store()) { + $mainframe->enqueueMessage(JText::_('EXTENSION INSTALL ERROR '. $extension->name), 'error'); + } + } + } + } + } + } + /** + * Install the Editor Plugin + * @return boolean + * @param object $install[optional] + */ + function installEditor($install = false) + { + global $mainframe; + $db =& JFactory::getDBO(); + $path = JPATH_PLUGINS .DS. 'editors'; + $ret = true; + if ($this->checkEditorFiles()) { + // Sourced from various Joomla! core files including the installer plugin adapter + $xml =& JFactory::getXMLParser('Simple'); + $name = 'JCE Editor 1.5.x'; + + if ($xml->loadFile($path .DS. 'jce.xml')) { + $root =& $xml->document; + // Get the element of the tag names + $name = $root->getElementByPath('name'); + $name = JFilterInput::clean($name->data(), 'string'); + } + JTable::addIncludePath(JPATH_LIBRARIES .DS. 'joomla' .DS. 'database' .DS. 'table'); + // Get Editor id if installed + $id = $this->checkEditor(); + $row =& JTable::getInstance('plugin'); + // Load editor if valid id + if($id){ + $row->load($id); + } + $row->name = $name; + $row->ordering = 0; + $row->folder = 'editors'; + $row->iscore = 0; + $row->access = 0; + $row->published = 1; + $row->client_id = 0; + $row->element = 'jce'; + if (!$row->store()) { + $mainframe->enqueueMessage(JText::_('Plugin').' '.JText::_('Install').': '.$db->stderr(true)); + $ret = false; + } + } else { + $mainframe->enqueueMessage(JText::_('EDITOR FILES MISSING'), 'error'); + $ret = false; + } + $mainframe->enqueueMessage(JText::_('EDITOR INSTALL SUCCESS')); + $ret = true; + if(!$install){ + $this->redirect(); + }else{ + return $ret; + } + } + /** + * Uninstall the editor + * @return boolean + */ + function removeEditor() + { + global $mainframe; + $db = & JFactory::getDBO(); + + jimport('joomla.filesystem.folder'); + jimport('joomla.filesystem.file'); + + $query = 'DELETE FROM #__plugins' + .' WHERE folder = '.$db->Quote('editors') + .' AND element = '.$db->Quote('jce') + ; + + $db->setQuery($query); + if (!$db->query()) { + $msg = JText::sprintf('UNINSTALLEXT', 'Editor', JText::_('Error')); + $ret = false; + } else { + $path = JPATH_PLUGINS.DS.'editors'; + + $files = array ( + $path.DS.'jce.php', + $path.DS.'jce.xml', + JPATH_SITE.DS.'language'.DS.'en-GB'.DS.'en-GB.plg_editors_jce.ini' + ); + + foreach ($files as $file) { + if (file_exists($file)) { + JFile::delete($file); + } + } + JFolder::delete($path.DS.'jce'); + $msg = JText::sprintf('UNINSTALLEXT', 'Editor', JText::_('Success')); + $ret = true; + } + $mainframe->enqueueMessage($msg); + return $ret; + } +} +?> \ No newline at end of file