本文整理汇总了PHP中ContentHelper::filterText方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentHelper::filterText方法的具体用法?PHP ContentHelper::filterText怎么用?PHP ContentHelper::filterText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentHelper
的用法示例。
在下文中一共展示了ContentHelper::filterText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanText
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;
}
示例2: applyTextFilters
/**
* 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);
}
示例3: saveSection
/**
* 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;
}
}