function cleanText($text) { if (version_compare(JVERSION, '2.5.0', 'ge')) { $text = JComponentHelper::filterText($text); } else { if (version_compare(JVERSION, '2.5.0', 'lt') && version_compare(JVERSION, '1.6.0', 'ge')) { JLoader::register('ContentHelper', JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'helpers' . DS . 'content.php'); $text = ContentHelper::filterText($text); } else { $config = JComponentHelper::getParams('com_content'); $user = JFactory::getUser(); $gid = $user->get('gid'); $filterGroups = $config->get('filter_groups'); // convert to array if one group selected if (!is_array($filterGroups) && (int) $filterGroups > 0) { $filterGroups = array($filterGroups); } if (is_array($filterGroups) && in_array($gid, $filterGroups)) { $filterType = $config->get('filter_type'); $filterTags = preg_split('#[,\\s]+#', trim($config->get('filter_tags'))); $filterAttrs = preg_split('#[,\\s]+#', trim($config->get('filter_attritbutes'))); switch ($filterType) { case 'NH': $filter = new JFilterInput(); break; case 'WL': $filter = new JFilterInput($filterTags, $filterAttrs, 0, 0, 0); break; case 'BL': default: $filter = new JFilterInput($filterTags, $filterAttrs, 1, 1); break; } $text = $filter->clean($text); } elseif (empty($filterGroups) && $gid != '25') { // no default filtering for super admin (gid=25) $filter = new JFilterInput(array(), array(), 1, 1); $text = $filter->clean($text); } } } return $text; }
/** * Apply Joomla text filters based on the user's groups * * @param string $string The string to clean * * @return string The cleaned string */ public function applyTextFilters($string) { // Apply the textfilters (let's reuse Joomla's ContentHelper class) if (!class_exists('ContentHelper')) { require_once JPATH_SITE . '/administrator/components/com_content/helpers/content.php'; } return ContentHelper::filterText((string) $string); }
/** * Saves the catefory after an edit form submit * @param database A database connector object * @param string The name of the category section */ function saveSection($option, $scope, $task) { global $mainframe; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'helper.php'; // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $db =& JFactory::getDBO(); $menu = JRequest::getVar('menu', 'mainmenu', 'post', 'menutype'); $menuid = JRequest::getVar('menuid', 0, 'post', 'int'); $oldtitle = JRequest::getVar('oldtitle', '', '', 'post', 'string'); $post = JRequest::get('post'); // fix up special html fields $post['description'] = ContentHelper::filterText(JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW)); $row =& JTable::getInstance('section'); if (!$row->bind($post)) { JError::raiseError(500, $row->getError()); } if (!$row->check()) { JError::raiseError(500, $row->getError()); } if ($oldtitle) { if ($oldtitle != $row->title) { $query = 'UPDATE #__menu' . ' SET name = ' . $db->Quote($row->title) . ' WHERE name = ' . $db->Quote($oldtitle) . ' AND type = "content_section"'; $db->setQuery($query); $db->query(); } } // if new item order last in appropriate group if (!$row->id) { $row->ordering = $row->getNextOrder(); } if (!$row->store()) { JError::raiseError(500, $row->getError()); } $row->checkin(); switch ($task) { case 'go2menu': $mainframe->redirect('index.php?option=com_menus&menutype=' . $menu); break; case 'go2menuitem': $mainframe->redirect('index.php?option=com_menus&menutype=' . $menu . '&task=edit&id=' . $menuid); break; case 'apply': $msg = JText::_('Changes to Section saved'); $mainframe->redirect('index.php?option=' . $option . '&scope=' . $scope . '&task=edit&cid[]=' . $row->id, $msg); break; case 'save': default: $msg = JText::_('Section saved'); $mainframe->redirect('index.php?option=' . $option . '&scope=' . $scope, $msg); break; } }