plugin: Hide DirectPHP for RSS Feed
Written by kksou   
Tuesday, 20 May 2008

This plugin hides DirectPHP commands in your RSS feed.

If you have installed the DirectPHP plugin to run PHP commands, and you're also using the standard RSS feed generator that comes installed with Joomla 1.0 and 1.5, you will find that those PHP commands will appear in the RSS feed too! This is usually undesirable.

This plugin will automatically hide all these PHP commands so that the RSS feed appear FREE of these PHP commands.


Latest Version

v1.02 (for Joomla 1.0) and v1.52 (for Joomla 1.5).

Bug fix of a warning message of the variable $flag.

Download


How to install (Joomla 1.0.x)

  1. Download the plugin and unzip it into a folder.
  2. From the Installers menu, select mambots. In the field "Install directory", enter the folder location (where you unzipped the file) and click Install.
  3. From the Mambots menu, select Site Mambots.
  4. Make sure the plugin "Hide DirectPHP for RSS Feed" is published. If you see a cross in the Published column, just click on it. It will turn into a green tick.
  5. To use this plugin, you need to add a trigger to the RSS feed generator. In the original Joomla installation, there is no trigger during the generation of RSS feed. When there is no trigger, none of the plugin gets called. In order for Joomla to call the new plugin that we have just installed to hide the DirectPHP commands, we need to add a trigger.
  6. Note: If you've already installed the plugin "Hide DirectPHP for RSS Feed", "Hide include_content_item in RSS Feed" or "Hide jumi for RSS Feed" you can skip this step. The same trigger will trigger all these plugins.

    1. Go to the folder <Joomla root folder>/components/com_rss, you will see a file called rss.php.
    2. Open this file rss.php in your favorite editor.
    3. Go to around Line 250, and add the three lines highlighted in yellow as follows:
    4. $database->setQuery( $query, 0, $info[ 'count' ] );
      $rows = $database->loadObjectList();
      
      global $_MAMBOTS;
      $_MAMBOTS->loadBotGroup( 'content' );
      
      foreach ( $rows as $row ) {
      	// title for particular item
      	$item_title = htmlspecialchars( $row->title );
      	$item_title = html_entity_decode( $item_title );
      
      	// url link to article
      	// & used instead of & as this is converted by feed creator
      	$_Itemid	= '';
      	$itemid 	= $mainframe->getItemid( $row->id );
      	if ($itemid) {
      		$_Itemid = '&Itemid='. $itemid;
      	}
      	
      	$item_link = 'index.php?option=com_content&task=view&id='. 
      	    $row->id . $_Itemid;
      	$item_link = sefRelToAbs( $item_link );
      
      	$results = $_MAMBOTS->trigger( 'onBeforeDisplayTitle', 
      	    array( &$row, array(), 16) ); 
      
      	// removes all formating from the intro text for the description text
      	$item_description = $row->introtext;
      	$item_description = mosHTML::cleanText( $item_description );
      	$item_description = html_entity_decode( $item_description );
      
    5. Save and close this file.

  7. For 1.0.x, there's one more "bug" that we need to fix. The bug will prevent the RSS feed generator from generating the rss file properly when triggering the plugins. Go to the folder <Joomla root folder>/mambots/content. You will see a file called mossef.php. Open this file in your favorite editor. Scroll all the way to the last line. You will find that there an additional tab character after ?>. The tab character is invisible. But if you move the cursor, you will know that it's a tab. Just delete that tab character and save it.
  8. That's it! But before we generate the rss file, let us erase any previous cached version of the rss file. Go to the folder <Joomla root folder>/cache. Delete all the rss*.xml files there.
  9. You can now try generate a fresh copy of your RSS feed. It should now be clean of any DirectPHP commands!

How to install (Joomla 1.5.x)

  1. Download the plugin and unzip it into a folder.
  2. From the Extensions menu, select Install/Uninstall. In the field "Install directory", enter the folder location (where you unzipped the file) and click Install.
  3. From the Extensions menu, select Plugin Manager.
  4. Enable the plugin "Hide DirectPHP for RSS Feed" - make sure there is a green tick in the Enabled column.
  5. To use this plugin, you need to add a trigger to the RSS feed generator. In the original Joomla installation, there is no trigger during the generation of RSS feed. When there is no trigger, none of the plugin gets called. In order for Joomla to call the new plugin that we have just installed to hide the DirectPHP commands, we need to add a trigger.
  6. Note: If you've already installed the plugin "Hide DirectPHP for RSS Feed", "Hide include_content_item in RSS Feed" or "Hide jumi for RSS Feed" you can skip this step. The same trigger will trigger all these plugins.

    1. Go to the folder <Joomla root folder>/libraries/joomla/document/feed/renderer, you will see a file called rss.php.
    2. Open this file rss.php in your favorite editor.
    3. Go to around Line 110, and add the three lines highlighted in yellow as shown below:
    4. if ($data->skipDays!="") {
      	$feed.= "		<skipDays>".htmlspecialchars($data->skipDays, 
      	    ENT_COMPAT, 'UTF-8')."</skipDays>\n";
      }
      
      $dispatcher =& JDispatcher::getInstance();
      JPluginHelper::importPlugin('content');
      
      for ($i=0; $i<count($data->items); $i++)
      {
      	$results=$dispatcher->trigger('onBeforeDisplayTitle',
      	    array(&$data->items[$i], array(), 16));
      
      	$feed.= "		<item>\n";
      	$feed.= "			<title>".
      	    htmlspecialchars(strip_tags($data->items[$i]->title), 
      	    ENT_COMPAT, 'UTF-8')."</title>\n";
      	$feed.= "		<link>".$url.$data->items[$i]->link."</link>\n";
      	$feed.= "		<description><![CDATA[".
      	    $this->_relToAbs($data->items[$i]->description)."]]></description>\n";
      
      	if ($data->items[$i]->author!="") {
      	    $feed.= "		<author>".htmlspecialchars(
      		$data->items[$i]->author, ENT_COMPAT, 'UTF-8')."</author>\n";
      	}
      

    5. Save and close this file.

  7. That's it! But before we generate the rss file, let us erase any previous cached version of the rss file. Go to the folder <Joomla root folder>/cache. Delete the file rss_com_content.xml.
  8. You can now try generate a fresh copy of your RSS feed. It should now be clean of any DirectPHP commands!

Version History

  • v1.01 (for Joomla 1.0) and v1.51 (for Joomla 1.5).
  • In version 1.0/1.5, the DirectPHP commands are still visible if you have a <p> (instead of <br />) after <?php. This version fixes this.


Last Updated ( Tuesday, 20 May 2008 )
 
< Prev   Next >

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2015. kksou.com. All Rights Reserved