Exemple #1
0
 /**
  * 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 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);
 }
Exemple #3
0
 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;
 }
     } else {
         $colour = $type && in_array($type, array('muted', 'warning', 'error', 'info', 'success')) ? 'text-' . $type : '';
         $statistic = '<p class="' . $colour . '"><strong>' . $stat . '</strong></p>';
     }
     //end if
     if ($link && $label) {
         $base = 'index.php?option=com_arkeditor&view=';
         $label = '<a href="' . $base . $link . '">' . $label . '</a>';
         $statistic = '<a href="' . $base . $link . '" class="badge-link">' . $statistic . '</a>';
     }
     //end if
     // RENDER STAT
     echo '<td>' . $label . '</td>';
     echo '<td>' . $statistic . '</td>';
 }
 $config = ARKHelper::getEditorPluginConfig();
 $toolbars = ARKHelper::getEditorToolbars(true);
 $plugins = ARKHelper::getEditorPlugins(true);
 $toolbars_core = JArrayHelper::getColumn($toolbars, 'iscore');
 $plugins_core = JArrayHelper::getColumn($plugins, 'iscore');
 $plugins_state = JArrayHelper::getColumn($plugins, 'published');
 echo '<div id="arkstats">';
 echo '<table class="table table-striped">';
 echo '<tr>';
 addStatistic(JText::_('COM_ARKEDITOR_STATISTIC_ALLTOOLBARS_NAME'), count($toolbars), 'info');
 addStatistic(JText::_('COM_ARKEDITOR_STATISTIC_ALLPLUGINS_NAME'), count($plugins), 'info', 'list&filter_state=*&filter_iscore=*');
 echo '</tr>';
 echo '<tr>';
 addStatistic(JText::_('COM_ARKEDITOR_STATISTIC_CORETOOLBARS_NAME'), count(array_keys($toolbars_core, 1)), 'inverse');
 addStatistic(JText::_('COM_ARKEDITOR_STATISTIC_COREPLUGINS_NAME'), count(array_keys($plugins_core, 1)), 'inverse', 'list&filter_state=*&filter_iscore=1');
 echo '</tr>';