コード例 #1
0
ファイル: list.php プロジェクト: enjoy2000/714water
 protected function getListQuery()
 {
     // Create a new query object.
     $hide = JCKHelper::getHiddenPlugins(true);
     $db = $this->getDbo();
     $query = $db->getQuery(true);
     $query->select($this->getState('list.select', 'p.*, u.name AS editor'));
     $query->from('#__jckplugins AS p');
     $query->join('LEFT', '#__users AS u ON u.id = p.checked_out');
     $query->where('p.type IN ("plugin","filebrowser")');
     $query->group('p.id');
     // Filter by published state
     $state = $this->getState('filter.state');
     if (is_numeric($state)) {
         $query->where('p.published = ' . (int) $state);
     } elseif ($state === '') {
         $query->where('(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');
     $orderDirn = $this->state->get('list.direction', 'DESC');
     $query->order($db->escape($orderCol . chr(32) . $orderDirn));
     //echo nl2br(str_replace('#__','jos_',$query));
     return $query;
 }
コード例 #2
0
 function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $canDo = JCKHelper::getActions();
     if (!$canDo->get('core.edit')) {
         $mainframe->redirect(JRoute::_('index.php?option=com_jckman&view=list', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_EDIT'), 'error');
         return false;
     }
     //end if
     JToolBarHelper::title(JText::_('JCK Plugin') . ': <small><small>[' . JText::_('Edit') . ']</small></small>', 'plugin.png');
     JToolBarHelper::save('save');
     JToolBarHelper::apply();
     JToolBarHelper::cancel('cancelEdit', 'Close');
     JToolBarHelper::help('screen.plugins.edit');
     $cid = JRequest::getVar('cid', array(0), '', 'array');
     JArrayHelper::toInteger($cid, array(0));
     $lists = array();
     $user = JFactory::getUser();
     $row = JCKHelper::getTable('plugin');
     // load the row from the db table
     $row->load($cid[0]);
     // Hide CK's plugin
     if (!$row || in_array($row->name, JCKHelper::getHiddenPlugins())) {
         $mainframe->redirect('index.php?option=com_jckman&view=list', 'Could Not Load Plugin.', 'error');
         return false;
     }
     // fail if checked out not by 'me'
     if ($row->isCheckedOut($user->get('id'))) {
         $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The plugin'), $row->title ? $row->title : $row->name);
         $this->setRedirect('index.php?option=' . $option . '&controller=list', $msg, 'error');
         return false;
     }
     $xmlPath = '';
     if ($row->iscore) {
         $path = JPATH_COMPONENT . DS . 'editor' . DS . plugins;
         $xmlPath = $path . DS . $row->name . '.xml';
     } else {
         $path = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $row->name;
         $xmlPath = $path . DS . $row->name . '.xml';
     }
     //AW
     if ($cid[0]) {
         $row->checkout($user->get('id'));
         if (JFile::exists($xmlPath)) {
             $data = JApplicationHelper::parseXMLInstallFile($xmlPath);
             $row->description = $data['description'];
         } else {
             $row->description = '';
         }
     } else {
         $row->type = 'plugin';
         $row->published = 1;
         $row->description = 'From XML install file';
         $row->icon = '';
         $row->params = '';
         $ordering = array();
     }
     $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published);
     // get toolbar selections
     //get Model
     $listModel = JModel::getInstance('list', 'ListModel');
     $installModel = JModel::getInstance('install', 'InstallerModel');
     $lookup = $listModel->getSelectedToolbarList();
     $selections = $installModel->getToolbarList();
     $lists['selections'] = JHTML::_('select.genericlist', $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple" style=width:182px;', 'value', 'text', $lookup, 'selections');
     if (empty($lookup)) {
         $lookup = array(JHTML::_('select.option', '0'));
         $row->pages = 'none';
     } elseif (count($lookup) == count($selections)) {
         $row->pages = 'all';
     } else {
         $row->pages = NULL;
     }
     $lists['selections'] = JHTML::_('select.genericlist', $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple" style=width:182px;', 'value', 'text', $lookup, 'selections');
     //ACL stuff
     $groups = $listModel->getUserGroupList();
     $allowedGroups = array();
     if (is_null($row->acl)) {
         //not set so everyone can see
         $allowedGroups = $groups;
     } else {
         $allowedGroups = json_decode($row->acl);
     }
     if (empty($allowedGroups)) {
         $allowedGroups = array(JHTML::_('select.option', '0'));
         $row->groups = 'special';
     } elseif (count($allowedGroups) == count($groups)) {
         $row->groups = 'all';
     } else {
         $row->groups = NULL;
     }
     $lists['groups'] = JHTML::_('select.genericlist', $groups, 'groups[]', 'class="inputbox" size="15" multiple="multiple" style=width:182px;', 'value', 'text', $allowedGroups, 'groups');
     $params = $this->prepareForm($row);
     $this->assignRef('lists', $lists);
     $this->assignRef('plugin', $row);
     $this->assignRef('params', $params);
     parent::display($tpl);
 }
コード例 #3
0
ファイル: editplugin.php プロジェクト: scarsroga/blog-soa
 public function getItem($pk = null)
 {
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $cid = $app->input->get('cid', array(), 'array');
     $id = current($cid);
     $item = JCKHelper::getTable('plugin');
     // load the row from the db table
     $item->load($id);
     // Hide CK's plugin
     if (!$item || in_array($item->name, JCKHelper::getHiddenPlugins())) {
         $app->redirect('index.php?option=com_jckman&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_JCKMAN_MSG_BEING_EDITED', JText::_('The plugin'), $item->title ?: $item->name);
         $app->redirect(JRoute::_('index.php?option=com_jckman&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 . 'jckeditor' . 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;
 }