function cancel() { // Check for request forgeries JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $form = $app->input->get('jform', array(), 'array'); $row = ARKHelper::getTable('plugin'); $row->bind($form); $row->checkin(); $this->event_args = array('id' => $row->id); $this->setRedirect(JRoute::_('index.php?option=com_arkeditor&view=list', false)); }
/** * Method to get the field options. * * @return array The field option objects. * * @since 11.1 */ protected function getOptions() { // Initialize variables. $values = array(); $this->_texts = array(); if (empty($this->value)) { foreach ($this->element->children() as $option) { // Only add <option /> elements. if ($option->getName() != 'option') { continue; } // Create a new option object based on the <option /> element. $tmp = JHtml::_('select.option', (string) $option, (string) $option, 'value', 'text', false); // Add the option object to the result set. $this->_texts[] = $tmp; $tmp = JHtml::_('select.option', (string) $option['value'], (string) $option['value'], 'value', 'text', false); // Add the option object to the result set. $values[] = $tmp; } } else { $name = (string) $this->element['name']; $plugin = ARKHelper::getTable('plugin'); $cid = JRequest::getVar('cid', array(0)); $plugin->load($cid[0]); $registry = new JRegistry($plugin->params); $texts = $registry->get($name . '_text'); foreach ($this->value as $key => $value) { //lets split option into array of text and value $text = $texts[$key]; if (!$text) { $text = $value; } $tmp = JHTML::_('select.option', $text, $text, 'value', 'text', false); // Add the option object to the result set. $this->_texts[] = $tmp; $tmp = JHTML::_('select.option', $value, $value, 'value', 'text', false); // Add the option object to the result set. $values[] = $tmp; } } reset($this->_texts); reset($values); return $values; }
public function getItem($pk = null) { $user = JFactory::getUser(); $app = JFactory::getApplication(); $cid = $app->input->get('cid', array(), 'array'); $id = current($cid); $item = ARKHelper::getTable('plugin'); // load the row from the db table $item->load($id); // Hide CK's plugin if (!$item || in_array($item->name, ARKHelper::getHiddenPlugins())) { $app->redirect('index.php?option=com_arkeditor&view=list', 'Could Not Load Plugin.', 'error'); return false; } // fail if checked out not by 'me' if ($item->isCheckedOut($user->get('id'))) { $msg = JText::sprintf('COM_ARKEDITOR_MSG_BEING_EDITED', JText::_('The plugin'), $item->title ?: $item->name); $app->redirect(JRoute::_('index.php?option=com_arkeditor&view=list', false), $msg, 'error'); return false; } // TOOLBARS $toolbars = $this->getToolbarList(); $item->selections = $this->getSelectedToolbarList(); if (!$item->selections) { $item->toolbars = 'none'; } elseif (count($item->selections) == count($toolbars)) { $item->toolbars = 'all'; } else { $item->toolbars = 'select'; } // GROUPS $groups = $this->getUserGroupList(); $allowedGroups = array(); // re-order groups to match acl col foreach ($groups as $group) { $allowedGroups[] = $group->value; } if (!is_null($item->acl)) { $allowedGroups = json_decode($item->acl); } if ($item->acl == '[]') { $item->group = 'special'; } elseif (count($allowedGroups) == count($groups)) { $item->group = 'all'; } else { $item->group = 'select'; } $item->groups = $allowedGroups; $xmlPath = ''; if ($item->iscore) { $path = JPATH_COMPONENT . DS . 'editor' . DS . 'plugins'; $xmlPath = $path . DS . $item->name . '.xml'; } else { $path = JPATH_PLUGINS . DS . 'editors' . DS . 'arkeditor' . DS . 'plugins' . DS . $item->name; $xmlPath = $path . DS . $item->name . '.xml'; } if ($id) { $item->checkout($user->get('id')); if (JFile::exists($xmlPath)) { $data = simplexml_load_file($xmlPath); $item->description = (string) $data->description; } else { $item->description = ''; } } else { $item->type = 'plugin'; $item->published = 1; $item->description = 'From XML install file'; $item->icon = ''; $item->params = ''; } $this->item = $item; return $this->item; }
function display($tpl = null) { $this->canDo = ARKHelper::getActions(); $this->app = JFactory::getApplication(); $this->user = JFactory::getUser(); $this->item = ''; $this->getForm(); $cid = $this->app->input->get('cid', array(), 'array'); JArrayHelper::toInteger($cid, array(0)); if (!count($cid) && !$this->canDo->get('core.create')) { $this->app->redirect(JRoute::_('index.php?option=com_arkeditor&view=cpanel', false), JText::_('COM_ARKEDITOR_PLUGIN_PERM_NO_CREATE'), 'error'); return false; } elseif (!$this->canDo->get('core.edit')) { $this->app->redirect(JRoute::_('index.php?option=com_arkeditor&view=cpanel', false), JText::_('COM_ARKEDITOR_PLUGIN_PERM_NO_EDIT'), 'error'); return false; } //end if $lists = array(); $this->item = ARKHelper::getTable('toolbar'); // load the row from the db table $this->item->load(isset($cid[0]) ? $cid[0] : 0); // fail if checked out not by 'me' if ($this->item->isCheckedOut($this->user->get('id'))) { $msg = JText::sprintf('COM_ARKEDITOR_MSG_BEING_EDITED', JText::_('The toolbar'), $this->item->title); $this->app->redirect(JRoute::_('index.php?option=com_arkeditor&view=toolbars', false), $msg, 'error'); return false; } if (isset($cid[0])) { $this->item->checkout($this->user->get('id')); //now lets get default toolbars $params = ARKHelper::getEditorPluginConfig(); $this->default = $params->get('toolbar', 'back'); $this->defaultFT = $params->get('toolbar_ft', 'front'); $this->item->params = new JRegistry($this->item->params); $this->form->bind($this->item->params); //bind params options to form if (strtolower($this->item->name) == strtolower($this->default) || strtolower($this->item->name) == strtolower($this->defaultFT)) { $this->item->default = true; } else { $this->item->default = false; } } else { $this->item->params = ''; $this->item->default = false; } $db = JFactory::getDBO(); //set the default total number of plugin records $total = 0; $totalRows = 0; if (isset($cid[0])) { $total = 1; $config = ARKHelper::getEditorPluginConfig(); $toolbars = $config->get('toolbars'); if ($toolbars) { $toolbar = array(); $toolbar = $toolbars[$this->item->name]; $it = array(); if (!empty($toolbar)) { $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($toolbar)); } $pluginTitles = "'0',"; foreach ($it as $v) { $pluginTitles .= $db->quote($v) . ","; } $pluginTitles = rtrim($pluginTitles, ","); $sql = $db->getQuery(true); $sql->select('p.id,p.title,p.icon,p.row,p.name')->from('#__ark_editor_plugins p')->join('LEFT', '#__ark_editor_plugins parent on parent.id = p.parentid')->where('p.title NOT IN (' . $pluginTitles . ')')->where('p.published = 1')->where('p.title <> ' . $db->quote(''))->where('(p.parentid IS NULL OR parent.published = 1)')->where('p.name <> ' . $db->quote('imagemanager'))->where('p.name <> ' . $db->quote('treelink'))->where('p.name <> ' . $db->quote('styles'))->where('p.name <> ' . $db->quote('arkabout'))->order('p.row ASC, p.id ASC'); $plugins = $db->setQuery($sql)->loadObjectList(); $sql = $db->getQuery(true); $sql->select('p.title')->from('#__ark_editor_plugins p')->join('LEFT', '#__ark_editor_plugins parent on parent.id = p.parentid AND parent.published = 1')->where('p.title IN (' . $pluginTitles . ')')->where('p.published = 1')->where('p.name <> ' . $db->quote('styles'))->where('p.name <> ' . $db->quote('arkabout'))->order('p.id ASC'); $keys = $db->setQuery($sql)->loadColumn(); $sql = $db->getQuery(true); $sql->select('p.title,p.icon,p.name')->from('#__ark_editor_plugins p')->join('LEFT', '#__ark_editor_plugins parent on parent.id = p.parentid AND parent.published = 1')->where('p.title IN (' . $pluginTitles . ')')->where('p.published = 1')->where('p.name <> ' . $db->quote('styles'))->where('p.name <> ' . $db->quote('arkabout'))->order('p.id ASC'); $values = $db->setQuery($sql)->loadObjectList(); $items = array_combine($keys, $values); $this->items = $items; $this->toolbarplugins = $this->_getSortRowToolbars($toolbar); $this->assign('plugins', $plugins); } } $params = new JRegistry($this->item->params); $components = $params->get('components', array()); $db->setQuery("SELECT element as value, REPLACE(element,'com_','') as text FROM #__extensions WHERE type = 'component' ORDER BY element ASC"); $query = $db->getQuery(true); $query->select('element AS value, element AS text')->from('#__extensions')->where($db->quoteName('type') . ' = ' . $db->quote('component'))->order('element ASC'); $allcomponents = $db->loadObjectList(); foreach ($allcomponents as $component) { $component->text = str_replace('com_', '', $component->text); } $lists['components'] = JHTML::_('select.genericlist', $allcomponents, 'components[]', ' size="10" multiple', 'value', 'text', $components); $this->assign('lists', $lists); $this->assign('toolbar', $this->item); $this->assign('total', $total); //$this->assignRef('total', $total); $this->addToolbar(); parent::display($tpl); }
function cancel() { // Check for request forgeries JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $row = ARKHelper::getTable('toolbar'); $form = $app->input->get('jform', array(), 'array'); $row->bind($form); $row->checkin(); $this->setRedirect('index.php?option=com_arkeditor&view=toolbars'); }