function display($tpl = null) { $this->canDo = ARKHelper::getActions(); $this->app = JFactory::getApplication(); $this->user = JFactory::getUser(); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))) { ARKHelper::error(implode("\n", $errors)); return false; } // Check if there are no matching items if (!count($this->items)) { ARKHelper::error(JText::_('COM_ARKEDITOR_LAYOUT_MANAGER_NO_TOOLBARS_FOUND')); } //now lets get default toolbars $editor = JPluginHelper::getPlugin('editors', 'arkeditor'); $params = new JRegistry($editor->params); $this->default = $params->get('toolbar', 'Publisher'); $this->defaultFT = $params->get('toolbar_ft', 'Basic'); $this->addToolbar(); parent::display($tpl); }
/** * constructor * * @access protected * @param string The event handler */ function __construct($eventHandlerName) { $eventListenerClassName = 'ARK' . JString::ucfirst($eventHandlerName) . 'ControllerListener'; if (class_exists($eventListenerClassName)) { $this->_eventHandler = new $eventListenerClassName($this); } else { ARKHelper::error('No Event listener ' . $eventListenerClassName . ' class found.'); } }
function display($tpl = null) { $this->canDo = ARKHelper::getActions(); $this->app = JFactory::getApplication(); $this->user = JFactory::getUser(); $this->state = $this->get('State'); $this->item = $this->get('Item'); $this->form = $this->get('Form'); $this->params = $this->prepareForm($this->item); if (!$this->canDo->get('core.edit')) { $this->app->redirect(JRoute::_('index.php?option=com_arkeditor&view=list', false), JText::_('COM_ARKEDITOR_PLUGIN_PERM_NO_EDIT'), 'error'); return false; } //end if //language $lang = ARKHelper::getLanguage(); $tag = $lang->getTag(); JFactory::$language = $lang; //override Joomla default language class $name = $this->item->name; $plugin = 'plg_arkeditor' . $name; $pluginOverideFile = JPATH_COMPONENT . '/language/overrides/' . $tag . '.' . $plugin . '.ini'; $pluginLangFile = JPATH_COMPONENT . '/language/' . $tag . '/' . $tag . '.' . $plugin . '.ini'; if (JFile::exists($pluginOverideFile)) { //check in language overrides to see if user has installed an override language file $lang->loadFile($pluginOverideFile, $plugin); } else { if (JFile::exists($pluginLangFile)) { //load core language file if it exists $lang->load($plugin, JPATH_COMPONENT); } else { //load english default languge if (JFile::exists(JPATH_COMPONENT . '/language/en-GB/en-GB.plg_arkeditor' . $name . '.ini')) { $lang->load($plugin, JPATH_COMPONENT, 'en-GB'); } } } $this->item->description = JText::_($this->item->description); $this->form->bind($this->item); // Check for errors. if (count($errors = $this->get('Errors'))) { ARKHelper::error(implode("\n", $errors)); return false; } $this->addToolbar(); parent::display($tpl); }
function display($tpl = null) { $this->app = JFactory::getApplication(); $this->user = JFactory::getUser(); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); // Check for errors. if (count($errors = $this->get('Errors'))) { ARKHelper::error(implode("\n", $errors)); return false; } // Check if there are no matching items if (!count($this->items)) { ARKHelper::error(JText::_('COM_ARKEDITOR_PLUGIN_NO_PLUGINS_FOUND')); } $this->addToolbar(); parent::display($tpl); }
function update($parent) { $this->install($parent); $db = JFactory::getDBO(); $dbserver = 'sqlsrv'; switch (strtolower($db->name)) { case 'mysql': case 'mysqli': $dbserver = 'mysql'; break; case 'postgresql': $dbserver = 'postgres'; break; } if (method_exists($parent, 'extension_root')) { $sqlfile = $parent->getPath('extension_root') . DS . 'sql' . DS . $dbserver . '.sql'; } else { $sqlfile = $parent->getParent()->getPath('extension_root') . DS . 'sql' . DS . $dbserver . '.sql'; } // Don't modify below this line $buffer = file_get_contents($sqlfile); if ($buffer !== false) { jimport('joomla.installer.helper'); $queries = JInstallerHelper::splitSql($buffer); if (count($queries) != 0) { foreach ($queries as $query) { $query = trim($query); if ($query != '' && $query[0] != '#') { $db->setQuery($query); if (!$db->query()) { if (!class_exists('ARKHelper')) { require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helper.php'; } ARKHelper::error(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true))); return false; } } } } } }
function checkin() { // Check for request forgeries JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); if (!$this->canDo->get('core.edit.state')) { $this->setRedirect(JRoute::_('index.php?option=com_arkeditor&view=list', false), JText::_('COM_ARKEDITOR_PLUGIN_PERM_NO_CHECK'), 'error'); return false; } //end if $db = JFactory::getDBO(); $user = JFactory::getUser(); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); $sql = $db->getQuery(true); JArrayHelper::toInteger($cid, array(0)); if (count($cid) < 1) { ARKHelper::error(JText::_('COM_ARKEDITOR_PLUGIN_NO_CHECKIN')); } //end if $cids = implode(',', $cid); $sql->update('#__ark_editor_plugins')->set(array('checked_out = 0', 'checked_out_time = ' . $db->quote($db->getNullDate())))->where('id IN ( ' . $cids . ' )')->where('checked_out = ' . (int) $user->get('id')); $db->setQuery($sql); if (!$db->query()) { ARKHelper::error($db->getErrorMsg()); } //end if $this->event_args = array('cid' => $cid, 'value' => true); $plural = count($cid) > 1 ? '(s)' : ''; ARKHelper::error(JText::sprintf('COM_ARKEDITOR_PLUGIN_CHECKIN', (int) count($cid), $plural), 'message'); $this->setRedirect(JRoute::_('index.php?option=com_arkeditor&view=list', false)); }
protected static function &_load() { static $clean; if (isset($clean)) { return $clean; } $Itemid = JRequest::getInt('Itemid'); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $lang = JFactory::getLanguage()->getTag(); $clientId = (int) $app->getClientId(); $cache = JFactory::getCache('com_modules', ''); $cacheid = md5(serialize(array('com_arkeditor', $groups, $clientId, $lang))); if (!($clean = $cache->get($cacheid))) { $db = JFactory::getDbo(); $excludes = array('-1'); $sql = $db->getQuery(true); $sql->select('count(1)'); $sql->from('#__modules'); $sql->where('module = ' . $db->Quote('mod_inlinecustom')); $db->setQuery($sql); $moduleExist = $db->loadResult(); if ($moduleExist) { $excludes[] = 'mod_arkpro'; } else { $excludes[] = 'mod_arktip'; } $query = $db->getQuery(true); //new JDatabaseQuery; $query->select('id, title, module, position, content, showtitle, params, mm.menuid'); $query->from('#__modules AS m'); $query->join('LEFT', '#__modules_menu AS mm ON mm.moduleid = m.id'); $query->where('m.published = 1'); $date = JFactory::getDate(); $now = $date->toSQL(); $nullDate = $db->getNullDate(); $query->where('(m.publish_up = ' . $db->Quote($nullDate) . ' OR m.publish_up <= ' . $db->Quote($now) . ')'); $query->where('(m.publish_down = ' . $db->Quote($nullDate) . ' OR m.publish_down >= ' . $db->Quote($now) . ')'); $query->where('m.access IN (' . $groups . ')'); $query->where('m.client_id = ' . $clientId); $query->where('(mm.menuid = ' . (int) $Itemid . ' OR (mm.menuid <= 0 OR mm.menuid IS NULL))'); //fix as this is suppose to be a LEFT JOIN!!! // Filter by language if ($app->isSite() && $app->getLanguageFilter()) { $query->where('m.language IN (' . $db->Quote($lang) . ',' . $db->Quote('*') . ')'); } $query->where('m.module NOT IN(' . $db->Quote(implode($db->Quote(','), $excludes), false) . ')'); $query->order('position, ordering'); // Set the query $db->setQuery($query); if (!($modules = $db->loadObjectList())) { ARKHelper::error(JText::sprintf('JLIB_APPLICATION_ERROR_MODULE_LOAD', $db->getErrorMsg())); return false; } // Apply negative selections and eliminate duplicates $negId = $Itemid ? -(int) $Itemid : false; $dupes = array(); $clean = array(); for ($i = 0, $n = count($modules); $i < $n; $i++) { $module =& $modules[$i]; // The module is excluded if there is an explicit prohibition, or if // the Itemid is missing or zero and the module is in exclude mode. $negHit = $negId === (int) $module->menuid || !$negId && (int) $module->menuid < 0; if (isset($dupes[$module->id])) { // If this item has been excluded, keep the duplicate flag set, // but remove any item from the cleaned array. if ($negHit) { unset($clean[$module->id]); } continue; } $dupes[$module->id] = true; // Only accept modules without explicit exclusions. if (!$negHit) { //determine if this is a custom module $file = $module->module; $custom = substr($file, 0, 4) == 'mod_' ? 0 : 1; $module->user = $custom; // Custom module name is given by the title field, otherwise strip off "com_" $module->name = $custom ? $module->title : substr($file, 4); $module->style = null; $module->position = strtolower($module->position); $clean[$module->id] = $module; } } unset($dupes); // Return to simple indexing that matches the query order. $clean = array_values($clean); $cache->store($clean, $cacheid); } return $clean; }
/** * Handles an XML parsing error * * @param integer $code XML Error Code. * @param integer $line Line on which the error happened. * @param integer $col Column on which the error happened. * * @return void * * @deprecated 12.1 * @since 11.1 * * @deprecated 12.1 Use PHP Exception */ protected function _handleError($code, $line, $col) { ARKHelper::error('XML Parsing Error at ' . $line . ':' . $col . '. Error ' . $code . ': ' . xml_error_string($code)); }
public function onInstanceCreated(&$params) { $user = JFactory::getUser(); if ($user->authorise('core.admin')) { return; } $query = $this->db->getQuery(true); $query->select('parentid,id,name,acl')->from('#__ark_editor_plugins')->where('published = 1'); $this->db->setQuery($query); $plugins = $this->db->loadObjectList(); if (!is_array($plugins)) { ARKHelper::error($this->db->getErrorMsg()); } if (empty($plugins)) { return; } $groups = $user->getAuthorisedGroups(); $js = ''; $deniedPlugins = array(); $removePlugins = array(); foreach ($plugins as $plugin) { if (is_null($plugin->acl)) { continue; } $acl = json_decode($plugin->acl); $allow = true; if (empty($acl)) { $allow = false; $deniedPlugins[] = $plugin->id; $removePlugins[] = $plugin->name; } else { if ($groups) { $allow = false; for ($n = 0, $i = count($groups); $n < $i; $n++) { if (in_array($groups[$n], $acl)) { $allow = true; break; } //end if } //end for loop if (!$allow) { $deniedPlugins[] = $plugin->id; $removePlugins[] = $plugin->name; } } //end if // check to see if parent plugin access view level is denied. If is then parent settings override if ($allow && in_array($plugin->parentid, $deniedPlugins)) { $deniedPlugins[] = $plugin->id; $removePlugins[] = $plugin->name; } } } if (empty($removePlugins)) { return; } $plugs = implode(',', $removePlugins); if ($plugs) { return "\r\n\t\t\t\t\r\n\t\t\t\teditor.on( 'configLoaded', function()\r\n\t\t\t\t{\r\n\t\t\t\t\tif(editor.config.removePlugins) \r\n\t\t\t\t\t\teditor.config.removePlugins += '," . $plugs . "';\r\n\t\t\t\t\telse \t\r\n\t\t\t\t\t\teditor.config.removePlugins += '" . $plugs . "';\r\n\t\t\t\t});"; } return null; }
function remove() { // Check for request forgeries JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); if (!$this->canDo->get('core.delete')) { $this->setRedirect(JRoute::_('index.php?option=com_arkeditor&view=toolbars', false), JText::_('COM_ARKEDITOR_PLUGIN_PERM_NO_SAVE'), 'error'); return false; } $db = JFactory::getDBO(); $app = JFactory::getApplication(); $cid = $app->input->get('cid', array(0), 'array'); JArrayHelper::toInteger($cid, array(0)); if (count($cid) < 1) { ARKHelper::error(JText::_('JWARNING_DELETE_MUST_SELECT')); } if (empty($cid)) { return ARKHelper::error(JText::_('JGLOBAL_NO_ITEM_SELECTED')); } $cids = implode(',', $cid); $editor = JPluginHelper::getPlugin('editors', 'arkeditor'); $params = new JRegistry($editor->params); $defaults = array(strtolower($params->get('toolbar', 'back')), strtolower($params->get('toolbar_ft', 'front'))); $sql = $db->getQuery(true); $sql->select('count(1)')->from('#__ark_editor_toolbars')->where('id IN (' . $cids . ')')->where('LOWER(name) IN (' . $db->quote(implode($db->quote(','), $defaults)) . ')'); $total = $db->setQuery($sql)->loadResult(); if ($msg = $db->getErrorMsg()) { return ARKHelper::error($msg); } if ($total > 0) { $this->setRedirect('index.php?option=com_arkeditor&view=toolbars'); return ARKHelper::error(JText::_('COM_ARKEDITOR_TOOLBAR_NO_DEL_DEFAULT')); } $sql = $db->getQuery(true); $sql->select('count(1)')->from('#__ark_editor_toolbars')->where('id IN (' . $cids . ')')->where('iscore = 1'); $total = $db->setQuery($sql)->loadResult(); if ($msg = $db->getErrorMsg()) { return ARKHelper::error($msg); } if ($total > 0) { $this->setRedirect('index.php?option=com_arkeditor&view=toolbars'); return ARKHelper::error(JText::_('COM_ARKEDITOR_TOOLBAR_NO_DEL_CORE')); } $sql = $db->getQuery(true); $sql->select('name')->from('#__ark_editor_toolbars')->where('id IN (' . $cids . ')'); $rows = $db->setQuery($sql)->loadColumn(); if (!$db->query()) { return ARKHelper::error($db->getErrorMsg()); } $this->event_args = array('names' => $rows); //delete toolbars $sql = $db->getQuery(true); $sql->delete('#__ark_editor_toolbars')->where('id IN (' . $cids . ')'); $db->setQuery($sql); if (!$db->query()) { ARKHelper::error($db->getErrorMsg()); } $msg = JText::sprintf('COM_ARKEDITOR_TOOLBAR_DELETE', implode(',', $rows)); $this->setRedirect('index.php?option=com_arkeditor&view=toolbars', $msg); }
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; }
function onCancel($id) { if (!$id) { //nothing to do do so bail out return; } //Checkin extension plugin $row = JTable::getInstance('extension'); $row->load(array('custom_data' => $id)); if ($row->extension_id) { if (!$row->checkin()) { ARKHelper::error('Failed to check in in extension'); } } }