| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: helper.php 18162 2010-07-16 07:00:47Z ian $ 4 * @package Joomla 5 * @subpackage Content 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant to the 9 * GNU General Public License, and as distributed it includes or is derivative 10 * of works licensed under the GNU General Public License or other free or open 11 * source software licenses. See COPYRIGHT.php for copyright notices and 12 * details. 13 */ 14 15 /** 16 * Content Component Helper 17 * 18 * @static 19 * @package Joomla 20 * @subpackage Content 21 * @since 1.5 22 */ 23 class ContentHelper 24 { 25 function saveContentPrep( &$row ) 26 { 27 // Get submitted text from the request variables 28 $text = JRequest::getVar( 'text', '', 'post', 'string', JREQUEST_ALLOWRAW ); 29 30 // Clean text for xhtml transitional compliance 31 $text = str_replace( '<br>', '<br />', $text ); 32 33 // Search for the {readmore} tag and split the text up accordingly. 34 $pattern = '#<hr\s+id=("|\')system-readmore("|\')\s*\/*>#i'; 35 $tagPos = preg_match($pattern, $text); 36 37 if ( $tagPos == 0 ) 38 { 39 $row->introtext = $text; 40 } else 41 { 42 list($row->introtext, $row->fulltext) = preg_split($pattern, $text, 2); 43 } 44 45 // Filter settings 46 jimport( 'joomla.application.component.helper' ); 47 $config = JComponentHelper::getParams( 'com_content' ); 48 $user = &JFactory::getUser(); 49 $gid = $user->get( 'gid' ); 50 51 $filterGroups = $config->get( 'filter_groups' ); 52 53 // convert to array if one group selected 54 if ( (!is_array($filterGroups) && (int) $filterGroups > 0) ) { 55 $filterGroups = array($filterGroups); 56 } 57 58 if (is_array($filterGroups) && in_array( $gid, $filterGroups )) 59 { 60 $filterType = $config->get( 'filter_type' ); 61 $filterTags = preg_split( '#[,\s]+#', trim( $config->get( 'filter_tags' ) ) ); 62 $filterAttrs = preg_split( '#[,\s]+#', trim( $config->get( 'filter_attritbutes' ) ) ); 63 switch ($filterType) 64 { 65 case 'NH': 66 $filter = new JFilterInput(); 67 break; 68 case 'WL': 69 $filter = new JFilterInput( $filterTags, $filterAttrs, 0, 0, 0); // turn off xss auto clean 70 break; 71 case 'BL': 72 default: 73 $filter = new JFilterInput( $filterTags, $filterAttrs, 1, 1 ); 74 break; 75 } 76 $row->introtext = $filter->clean( $row->introtext ); 77 $row->fulltext = $filter->clean( $row->fulltext ); 78 } elseif(empty($filterGroups) && $gid != '25') { // no default filtering for super admin (gid=25) 79 $filter = new JFilterInput( array(), array(), 1, 1 ); 80 $row->introtext = $filter->clean( $row->introtext ); 81 $row->fulltext = $filter->clean( $row->fulltext ); 82 } 83 return true; 84 } 85 86 /** 87 * Applies the content tag filters to arbitrary text as per settings for current user group 88 * @param text The string to filter 89 * @return string The filtered string 90 */ 91 function filterText( $text ) 92 { 93 // Filter settings 94 jimport( 'joomla.application.component.helper' ); 95 $config = JComponentHelper::getParams( 'com_content' ); 96 $user = &JFactory::getUser(); 97 $gid = $user->get( 'gid' ); 98 99 $filterGroups = $config->get( 'filter_groups' ); 100 101 // convert to array if one group selected 102 if ( (!is_array($filterGroups) && (int) $filterGroups > 0) ) { 103 $filterGroups = array($filterGroups); 104 } 105 106 if (is_array($filterGroups) && in_array( $gid, $filterGroups )) 107 { 108 $filterType = $config->get( 'filter_type' ); 109 $filterTags = preg_split( '#[,\s]+#', trim( $config->get( 'filter_tags' ) ) ); 110 $filterAttrs = preg_split( '#[,\s]+#', trim( $config->get( 'filter_attritbutes' ) ) ); 111 switch ($filterType) 112 { 113 case 'NH': 114 $filter = new JFilterInput(); 115 break; 116 case 'WL': 117 $filter = new JFilterInput( $filterTags, $filterAttrs, 0, 0, 0); // turn off xss auto clean 118 break; 119 case 'BL': 120 default: 121 $filter = new JFilterInput( $filterTags, $filterAttrs, 1, 1 ); 122 break; 123 } 124 $text = $filter->clean( $text ); 125 } elseif(empty($filterGroups) && $gid != '25') { // no default filtering for super admin (gid=25) 126 $filter = new JFilterInput( array(), array(), 1, 1 ); 127 $text = $filter->clean( $text ); 128 } 129 return $text; 130 } 131 132 133 134 /** 135 * Function to reset Hit count of an article 136 * 137 */ 138 function resetHits($redirect, $id) 139 { 140 global $mainframe; 141 142 // Initialize variables 143 $db = & JFactory::getDBO(); 144 145 // Instantiate and load an article table 146 $row = & JTable::getInstance('content'); 147 $row->Load($id); 148 $row->hits = 0; 149 $row->store(); 150 $row->checkin(); 151 152 $msg = JText::_('Successfully Reset Hit count'); 153 $mainframe->redirect('index.php?option=com_content§ionid='.$redirect.'&task=edit&id='.$id, $msg); 154 } 155 156 function filterCategory($query, $active = NULL) 157 { 158 // Initialize variables 159 $db = & JFactory::getDBO(); 160 161 $categories[] = JHTML::_('select.option', '0', '- '.JText::_('Select Category').' -'); 162 $db->setQuery($query); 163 $categories = array_merge($categories, $db->loadObjectList()); 164 165 $category = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $active); 166 167 return $category; 168 } 169 170 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |