Exemple #1
0
 protected function getListQuery()
 {
     // Create a new query object.
     $hide = ARKHelper::getHiddenPlugins(true);
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $query->select($this->getState('list.select', 'p.id,p.name,p.title,p.icon, u.name AS editor,p.editable,p.checked_out,p.checked_out_time, p.iscore, CASE WHEN ext.extension_id IS NULL THEN p.published ELSE ext.enabled END AS published'));
     $query->from('#__ark_editor_plugins AS p');
     $query->join('LEFT', '#__users AS u ON u.id = p.checked_out');
     $query->join('LEFT', '#__extensions AS ext ON ext.custom_data = p.id AND folder = ' . $db->quote('arkeditor'));
     $query->where('p.type = ' . $db->quote('plugin'));
     $query->group('p.id');
     // Filter by published state
     $state = $this->getState('filter.state');
     if (is_numeric($state)) {
         $query->where('(ext.enabled = ' . (int) $state . ' OR ext.extension_id IS NULL AND p.published = ' . (int) $state . ')');
     } elseif ($state === '') {
         $query->where('(ext.enabled IN (0, 1) OR ext.extension_id IS NULL AND p.published IN (0, 1))');
     }
     // Filter by is core plugin
     $iscore = $this->getState('filter.iscore');
     if ($iscore != '') {
         $query->where('p.iscore = ' . (int) $iscore);
     }
     // Filter by search in title
     $search = $this->getState('filter.search');
     if (!empty($search)) {
         if (stripos($search, 'id:') === 0) {
             $query->where('p.id = ' . (int) substr($search, 3));
         } else {
             $search = $db->Quote('%' . $db->escape($search, true) . '%');
             $query->where('p.name LIKE ' . $search . ' OR p.title LIKE ' . $search);
         }
     }
     // Hide CK's plugin
     $query->where('p.name NOT IN ( ' . $hide . ' )');
     // Add the list ordering clause.
     $orderCol = $this->state->get('list.ordering', 'p.id');
     if ($orderCol == 'p.published') {
         $orderCol == 'CASE WHEN ext.extension_id IS NULL THEN p.published ELSE ext.enabled END';
     }
     $orderDirn = $this->state->get('list.direction', 'DESC');
     $query->order($db->escape($orderCol . chr(32) . $orderDirn));
     return $query;
 }
Exemple #2
0
 static function getEditorPlugins($all = false)
 {
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query->select($all ? 'p.id,p.name,p.title,p.icon, u.name AS editor,p.editable,p.checked_out,p.checked_out_time, p.iscore, CASE WHEN ext.extension_id IS NULL THEN p.published ELSE ext.enabled END AS published' : 'p.name');
     $query->from('#__ark_editor_plugins AS p');
     $query->join('LEFT', '#__users AS u ON u.id = p.checked_out');
     $query->join('LEFT', '#__extensions AS ext ON ext.custom_data = p.id AND element = ' . $db->quote('arkeditor'));
     $query->where('p.type = ' . $db->quote('plugin'));
     $query->where('p.name NOT IN ( ' . ARKHelper::getHiddenPlugins(true) . ' )');
     $query->group('p.id');
     $db->setQuery($query);
     return $all ? $db->loadObjectList() : $db->loadColumn();
 }
 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;
 }