/** * A JParameter object holding the parameters for the plugin * * @var A JParameter object * @access public * @since 1.5 */ function onSave($plugin, $pluginToolbarnames) { if (!$this->canDo->get('core.edit')) { $this->app->redirect(JRoute::_('index.php?option=com_arkeditor&view=list', false), JText::_('COM_ARKEDITOR_PLUGIN_PERM_NO_SAVE'), 'error'); return false; } arkimport('helper'); $toolbarnames = ARKHelper::getEditorToolbars(); $config = ARKHelper::getEditorPluginConfig(); $toolbars = $config->get('toolbars'); if (!empty($toolbarnames)) { foreach ($toolbarnames as $toolbarname) { $toolbar = $toolbars[$toolbarname]; if (in_array($toolbarname, $pluginToolbarnames)) { if (!ARKHelper::in_array($plugin->title, $toolbar)) { $toolbar[] = array($plugin->title); } } else { $key = ARKHelper::in_array($plugin->title, $toolbar); if (ARKHelper::in_array($plugin->title, $toolbar)) { foreach ($toolbar as $key => $elements) { $found = false; foreach ($elements as $k => $value) { if ($value == $plugin->title) { unset($toolbar[$key][$k]); $found = true; break; } } if ($found) { break; } } } } $toolbars[$toolbarname] = $toolbar; } $config->set('toolbars', base64_encode(json_encode($toolbars))); $row = JTable::getInstance('extension'); $row->load(array('folder' => 'editors', 'element' => 'arkeditor')); $row->bind(array('params' => $config->toArray())); if (!$row->store()) { ARKHelper::error('Failed to save Ark Editor\'s parameters'); } } //Publish or unpblish plugin $this->onPublish(array($plugin->id), (int) $plugin->published); //Checkin extension plugin $row = JTable::getInstance('extension'); $row->load(array('custom_data' => $plugin->id)); if ($row->extension_id) { if (!$row->checkin()) { ARKHelper::error('Failed to check in in extension'); } } }
function getSelectedToolbarList() { $rows = array(); arkimport('helper'); $cid = JRequest::getVar('cid', array(0), '', 'array'); JArrayHelper::toInteger($cid, array(0)); $db = JFactory::getDBO(); $sql = $db->getQuery(true); $sql->select('title')->from('#__ark_editor_plugins')->where('id = ' . $cid[0]); $title = $db->setQuery($sql)->loadResult(); if (!!$title && !is_string($title)) { ARKHelper::error($db->getErrorMsg()); } $config = ARKHelper::getEditorPluginConfig(); $toolbars = $config->get('toolbars'); foreach ($toolbars as $key => $toolbar) { if (ARKHelper::in_array($title, $toolbar)) { $row = new stdclass(); $row->text = ucfirst($key); $row->value = $key; $rows[] = $row; } } return $rows; }