static function &geTtoolbarParams($editor, $args = array()) { if (count($args) > 1) { $row = $args[1]; } if (is_a($args[0], 'JParameter')) { $params = $args[0]; } else { if ($row) { $params = new JParameter($row->params); } else { $row =& JCKHelper::getTable('toolbar'); // load the row from the db table $row->load($args[0]); //get toolbar parameter $params = new JParameter($row->params); } } $editor_params = new JParameter($editor->params); $toolbar = $params->get('toolbar', $row->name); $skins = $params->get('skin', $editor_params->def('skin', 'office2003')); $width = $params->get('wwidth', $editor_params->def('wwidth', '100%')); $editor_params->set('toolbar', $toolbar); $editor_params->set('skin', $skins); $editor_params->set('wwidth', $width); $editor_params->Set('hheight', 300); return $editor_params; }
/** * 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 = JCKHelper::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; }
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); }
function cancelEdit() { // Check for request forgeries JRequest::checkToken() or die('Invalid Token'); $row =& JCKHelper::getTable('toolbar'); $row->bind(JRequest::get('post')); $row->checkin(); $this->setRedirect('index.php?option=com_jckman&controller=toolbars'); }
function cancel() { // Check for request forgeries JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); $app = JFactory::getApplication(); $row = JCKHelper::getTable('toolbar'); $form = $app->input->get('jform', array(), 'array'); $row->bind($form); $row->checkin(); $this->setRedirect('index.php?option=com_jckman&view=toolbars'); }
function display($tpl = null) { $this->canDo = JCKHelper::getActions(); $this->app = JFactory::getApplication(); $this->user = JFactory::getUser(); $this->item = ''; $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_jckman&view=cpanel', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_CREATE'), 'error'); return false; } elseif (!$this->canDo->get('core.edit')) { $this->app->redirect(JRoute::_('index.php?option=com_jckman&view=cpanel', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_EDIT'), 'error'); return false; } //end if $lists = array(); $this->item = JCKHelper::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_JCKMAN_MSG_BEING_EDITED', JText::_('The toolbar'), $this->item->title); $this->app->redirect(JRoute::_('index.php?option=com_jckman&view=toolbars', false), $msg, 'error'); return false; } if (isset($cid[0])) { $this->item->checkout($this->user->get('id')); //now lets get default toolbars $editor = JPluginHelper::getPlugin('editors', 'jckeditor'); $params = new JRegistry($editor->params); $this->default = $params->get('toolbar', 'full'); $this->defaultFT = $params->get('toolbar_ft', 'full'); 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; $sql = $db->getQuery(true); $sql->select('p.id,p.name,p.title,p.icon,tp.row')->from('#__jckplugins p')->join('INNER', '#__jcktoolbarplugins tp ON tp.pluginid = p.id')->join('LEFT', '#__jckplugins parent on parent.id = p.parentid')->where('tp.state = 1')->where('tp.toolbarid = ' . (int) $this->item->id)->where('p.published = 1')->where('(p.parentid IS NULL OR parent.published = 1)')->order('tp.toolbarid ASC,tp.row ASC,tp.ordering ASC'); $toolbarplugins = $db->setQuery($sql)->loadObjectList(); // get the total number of core plugin records $sql = $db->getQuery(true); $sql->select('COUNT(*)')->from('#__jcktoolbarplugins tp')->join('INNER', '#__jckplugins p ON tp.pluginid = p.id')->join('LEFT', '#__jckplugins parent on parent.id = p.parentid')->where('tp.toolbarid =' . (int) $this->item->id)->where('p.iscore = 1'); $totalRows = $db->setQuery($sql)->loadResult(); if (!$totalRows) { require_once CKEDITOR_LIBRARY . DS . 'toolbar.php'; $CKfolder = CKEDITOR_LIBRARY . DS . 'toolbar'; $filename = $CKfolder . DS . $this->item->name . '.php'; require $filename; $classname = 'JCK' . ucfirst($this->item->name); $toolbar = new $classname(); $sql = $db->getQuery(true); $sql->select('p.id, p.title')->from('#__jckplugins p')->join('LEFT', '#__jckplugins parent on parent.id = p.parentid')->where('p.title != ""')->where('p.published = 1')->where('p.iscore = 1')->where('(p.parentid IS NULL OR parent.published = 1)'); $allplugins = $db->setQuery($sql)->loadObjectList(); $values = array(); //fix toolbar values or they will get wiped out $l = 1; $n = 1; $j = 1; foreach (get_object_vars($toolbar) as $k => $v) { if ($v) { $n = $n > $v ? $n : $v; } if ($l < $n) { $l = $n; $j = 1; } for ($m = 0; $m < count($allplugins); $m++) { if ($k == $allplugins[$m]->title) { $values[] = '(' . (int) $this->item->id . ',' . (int) $allplugins[$m]->id . ',' . $n . ',' . $j . ',1)'; break; } if (strpos($k, 'brk_') !== false) { $id = preg_match('/[0-9]+$/', $k); $id = $id * -1; $values[] = '(' . (int) $this->item->id . ',' . $id . ',' . $n . ',' . $j . ',1)'; $n++; break; } } $j++; } if (!empty($values)) { $query = 'INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES ' . implode(',', $values); $db->setQuery($query); if (!$db->query()) { JCKHelper::error($db->getErrorMsg()); } } } $sql = $db->getQuery(true); $sql->select('p.id,p.name,p.title,p.icon,p.row')->from('#__jckplugins p')->join('LEFT', '#__jcktoolbarplugins tp ON tp.pluginid = p.id AND tp.toolbarid = ' . (int) $this->item->id)->join('LEFT', '#__jckplugins parent on parent.id = p.parentid')->where('tp.pluginid is null')->where('p.published = 1')->where('p.title != ""')->where('p.iscore = 1')->where('(p.parentid IS NULL OR parent.published = 1)')->order('p.row ASC, p.id ASC'); $plugins = $db->setQuery($sql)->loadObjectList(); $sql = $db->getQuery(true); $sql->select('tp.pluginid AS id,p.name,p.title,p.icon,tp.row')->from('#__jcktoolbarplugins tp')->join('LEFT', '#__jckplugins p ON tp.pluginid = p.id AND p.published = 1')->join('LEFT', '#__jckplugins parent on parent.id = p.parentid AND parent.published = 1')->where('tp.state = 1')->where('tp.toolbarid = ' . (int) $this->item->id)->where('(p.parentid IS NULL OR parent.published = 1)')->order('tp.toolbarid ASC,tp.row ASC,tp.ordering ASC'); $toolbarplugins = $db->setQuery($sql)->loadObjectList(); $toolbarplugins = $this->_getSortRowToolbars($toolbarplugins); $this->assignRef('toolbarplugins', $toolbarplugins); $this->assignRef('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"); $allcomponents = $db->loadObjectList(); $lists['components'] = JHTML::_('select.genericlist', $allcomponents, 'components[]', ' size="10" multiple', 'value', 'text', $components); $this->assignRef('lists', $lists); $this->assignRef('toolbar', $this->item); $this->assignRef('total', $total); $this->addToolbar(); parent::display($tpl); }
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; }
function display($tpl = null) { $mainframe = JFactory::getApplication(); $canDo = JCKHelper::getActions(); $cid = JRequest::getVar('cid', array(0), '', 'array'); JArrayHelper::toInteger($cid, array(0)); if (!count($cid) && !$canDo->get('core.create')) { $mainframe->redirect(JRoute::_('index.php?option=com_jckman&view=cpanel', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_CREATE'), 'error'); return false; } elseif (!$canDo->get('core.edit')) { $mainframe->redirect(JRoute::_('index.php?option=com_jckman&view=cpanel', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_EDIT'), 'error'); return false; } //end if JToolBarHelper::title(JText::_('Layout Manager') . ': <small><small>[' . JText::_('Edit') . ']</small></small>', 'layout.png'); JToolBarHelper::save(); JToolBarHelper::apply(); JToolBarHelper::cancel('cancelEdit', 'Close'); $lists = array(); $user = JFactory::getUser(); $row = JCKHelper::getTable('toolbar'); // load the row from the db table $row->load($cid[0]); // fail if checked out not by 'me' if ($row->isCheckedOut($user->get('id'))) { $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The toolbar'), $row->title); $this->setRedirect('index.php?option=' . $option . '&controller=Toolbars', $msg, 'error'); return false; } if ($cid[0]) { $row->checkout($user->get('id')); //now lets get default toolbars $editor = JPluginHelper::getPlugin('editors', 'jckeditor'); $params = new JRegistry($editor->params); $this->default = $params->get('toolbar', 'full'); $this->defaultFT = $params->get('toolbar_ft', 'full'); if (strtolower($row->name) == strtolower($this->default) || strtolower($row->name) == strtolower($this->defaultFT)) { $row->default = true; } else { $row->default = false; } } else { $row->params = ''; $row->default = false; } $db = JFactory::getDBO(); //set the default total number of plugin records $total = 0; $totalRows = 0; if ($cid[0]) { $total = 1; $query = 'SELECT p.id,p.name,p.title,p.icon,tp.row' . ' FROM #__jckplugins p' . ' JOIN #__jcktoolbarplugins tp ON tp.pluginid = p.id' . ' LEFT JOIN #__jckplugins parent on parent.id = p.parentid' . ' WHERE tp.state = 1' . ' AND tp.toolbarid = ' . (int) $row->id . ' AND p.published = 1' . ' AND(p.parentid IS NULL OR parent.published = 1)' . ' ORDER BY tp.toolbarid ASC,tp.row ASC,tp.ordering ASC'; $db->setQuery($query); $toolbarplugins = $db->loadObjectList(); // get the total number of core plugin records $query = 'SELECT COUNT(*)' . ' FROM #__jcktoolbarplugins tp' . ' JOIN #__jckplugins p ON tp.pluginid = p.id' . ' WHERE tp.toolbarid =' . (int) $row->id . ' AND p.iscore = 1'; $db->setQuery($query); $totalRows = $db->loadResult(); if (!$totalRows) { require_once CKEDITOR_LIBRARY . DS . 'toolbar.php'; $CKfolder = CKEDITOR_LIBRARY . DS . 'toolbar'; $filename = $CKfolder . DS . $row->name . '.php'; require $filename; $classname = 'JCK' . ucfirst($row->name); $toolbar = new $classname(); $query = 'SELECT p.id, p.title' . ' FROM #__jckplugins p' . ' LEFT JOIN #__jckplugins parent on parent.id = p.parentid' . ' AND parent.published = 1' . ' WHERE p.title != ""' . ' AND p.published = 1' . ' AND p.iscore = 1'; $db->setQuery($query); $allplugins = $db->loadObjectList(); $values = array(); //fix toolbar values or they will get wiped out $l = 1; $n = 1; $j = 1; foreach (get_object_vars($toolbar) as $k => $v) { if ($v) { $n = $n > $v ? $n : $v; } if ($l < $n) { $l = $n; $j = 1; } for ($m = 0; $m < count($allplugins); $m++) { if ($k == $allplugins[$m]->title) { $values[] = '(' . (int) $row->id . ',' . (int) $allplugins[$m]->id . ',' . $n . ',' . $j . ',1)'; break; } if (strpos($k, 'brk_') !== false) { $id = preg_match('/[0-9]+$/', $k); $id = $id * -1; $values[] = '(' . (int) $row->id . ',' . $id . ',' . $n . ',' . $j . ',1)'; $n++; break; } } $j++; } if (!empty($values)) { $query = 'INSERT INTO #__jcktoolbarplugins(toolbarid,pluginid,row,ordering,state) VALUES ' . implode(',', $values); $db->setQuery($query); if (!$db->query()) { JError::raiseWarning(500, $db->getErrorMsg()); } } } $query = 'SELECT p.id,p.name,p.title,p.icon,p.row' . ' FROM #__jckplugins p' . ' LEFT JOIN #__jcktoolbarplugins tp ON tp.pluginid = p.id' . ' AND tp.toolbarid = ' . (int) $row->id . ' LEFT JOIN #__jckplugins parent on parent.id = p.parentid' . ' WHERE tp.pluginid is null' . ' AND p.published = 1' . ' AND p.title != ""' . ' AND(p.parentid IS NULL OR parent.published = 1)' . ' ORDER by p.row ASC, p.id ASC'; $db->setQuery($query); $plugins = $db->loadObjectList(); $query = 'SELECT tp.pluginid AS id,p.name,p.title,p.icon,tp.row' . ' FROM #__jcktoolbarplugins tp' . ' LEFT JOIN #__jckplugins p ON tp.pluginid = p.id' . ' AND p.published = 1' . ' LEFT JOIN #__jckplugins parent on parent.id = p.parentid' . ' AND parent.published = 1' . ' WHERE tp.state = 1' . ' AND tp.toolbarid = ' . (int) $row->id . ' AND(p.parentid IS NULL OR parent.published = 1)' . ' ORDER BY tp.toolbarid ASC,tp.row ASC,tp.ordering ASC'; $db->setQuery($query); $toolbarplugins = $db->loadObjectList(); $toolbarplugins = $this->_getSortRowToolbars($toolbarplugins); $this->assignRef('toolbarplugins', $toolbarplugins); $this->assignRef('plugins', $plugins); } $params = new JRegistry($row->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"); $allcomponents = $db->loadObjectList(); $lists['components'] = JHTML::_('select.genericlist', $allcomponents, 'components[]', 'style="width:150px;" size="10" multiple><option value="-1">None</option', 'value', 'text', $components); $this->assignRef('lists', $lists); $this->assignRef('toolbar', $row); $this->assignRef('total', $total); parent::display($tpl); }