-
AuthorPosts
-
prakash Friend
prakash
- Join date:
- October 2008
- Posts:
- 439
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 146 times in 115 posts
November 22, 2009 at 9:29 am #146262Hi,
Recently JA launched MEGA MENU. Now if you installed X-MAP then it generated not only the menu name but also the variables associated with JA Mega Menu (because the variables are passed within the menu name. I have coded a fix to this problem but do not know if it is the right solution or if it has any effect on its performance.
Do let me know if you have any better solution.
This would be the new xmap.html.php file found in componentscom_xmap<?php
/**
* $Id: xmap.html.php 24 2009-03-13 15:05:30Z guilleva $
* $LastChangedDate: 2009-03-13 09:05:30 -0600 (Fri, 13 Mar 2009) $
* $LastChangedBy: guilleva $
* Xmap by Guillermo Vargas
* A Sitemap component for Joomla! CMS (http://www.joomla.org)
* Author Website: http://joomla.vargas.co.cr
* Project License: GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/defined('_JEXEC') or die('Direct Access to this location is not allowed.');
/** Wraps HTML output */
class XmapHtml extends Xmap {
var $level = -1;
var $_openList = '';
var $_closeList = '';
var $_closeItem = '';
var $_childs;
var $_width;
var $_isAdmin = 0;function XmapHtml (&$config, &$sitemap) {
$this->view = 'html';
Xmap::Xmap($config, $sitemap);
$this->_parent_children=array();
$this->_last_child=array();
}/**
* Print one node of the sitemap
*/
function printNode( &$node ) {
global $Itemid;$out = '';
if ($this->sitemap->isExcluded($node->id,$node->uid) && !$this->_isAdmin) {
return FALSE;
}// To avoid duplicate children in the same parent
if ( !empty($this->_parent_children[$this->level][$node->uid]) ) {
return FALSE;
}//var_dump($this->_parent_children[$this->level]);
$this->_parent_children[$this->level][$node->uid] = true;$out .= $this->_closeItem;
$out .= $this->_openList;
$this->_openList = "";if ( $Itemid == $node->id )
$out .= '<li class="active">';
else
$out .= '<li>';$link = Xmap::getItemLink($node);
if( !isset($node->browserNav) )
$node->browserNav = 0;$node->name = htmlspecialchars($node->name);
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$testavaluetoday = htmlspecialchars($node->name);
$returnedvaluetoday = strpos($testavaluetoday,"[");
if ($returnedvaluetoday != 0){
$finalvalueretrievedtoday = substr($testavaluetoday,0,$returnedvaluetoday-1);
}
else{
$finalvalueretrievedtoday = htmlspecialchars($node->name);
}
//end of code modified by : Prakash R Balgeswitch( $node->browserNav ) {
case 1: // open url in new window
$ext_image = '';
if ( $this->sitemap->exlinks ) {
$ext_image = ' <img src="'. $this->live_site .'/components/com_xmap/images/'. $this->sitemap->ext_image .'" alt="' . _XMAP_SHOW_AS_EXTERN_ALT . '" title="' . _XMAP_SHOW_AS_EXTERN_ALT . '" border="0" />';
}
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'" target="_blank">'. $finalvalueretrievedtoday . $ext_image .'</a>';
//end of code modified by : Prakash R Balge
break;case 2: // open url in javascript popup window
$ext_image = '';
if( $this->sitemap->exlinks ) {
$ext_image = ' <img src="'. $this->live_site .'/components/com_xmap/images/'. $this->sitemap->ext_image .'" alt="' . _XMAP_SHOW_AS_EXTERN_ALT . '" title="' . _XMAP_SHOW_AS_EXTERN_ALT . '" border="0" />';
}
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'" target="_blank" '. "onClick="javascript: window.open('". $link ."', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false;">". $finalvalueretrievedtoday . $ext_image."</a>";
//end of code modified by : Prakash R Balge
break;case 3: // no link
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$out .= '<span>'. $finalvalueretrievedtoday .'</span>';
//end of code modified by : Prakash R Balge
break;default: // open url in parent window
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'">'. $finalvalueretrievedtoday .'</a>';
//end of code modified by : Prakash R Balge
break;
}$this->_closeItem = "</li>n";
$this->_childs[$this->level]++;
echo $out;if ($this->_isAdmin) {
if ( $this->sitemap->isExcluded($node->id,$node->uid) ) {
$img = '<img src="'.$this->live_site.'/administrator/images/publish_x.png" alt="'._XMAP_EXT_PUBLISHED.'" title="'._XMAP_EXT_UNPUBLISHED.'">';
$class= 'xmapexclon';
} else {
$img = '<img src="'.$this->live_site.'/administrator/images/tick.png" alt="'._XMAP_EXT_PUBLISHED.'" title="'._XMAP_EXT_PUBLISHED.'" />';
$class= 'xmapexcloff';
}
echo ' <a href= "#" class="xmapexcl '.$class.'" rel="{uid:''.$node->uid.'',itemid:'.$node->id.'}">'.$img.'</a>';
# echo ' <a href= "#" class="xmapoptions" rel="{uid:''.$node->uid.'',itemid:'.$node->id.'}"><img src="'.$this->live_site.'/components/com_xmap/images/options.gif" border="0" alt="Options" title="Options" /></a>';
}
//echo $this->_last_child[$this->level-1] . ' ' . $this->_parent_children[$this->level]['parent'];
$this->count++;$this->_last_child[$this->level] = $node->uid;
return TRUE;
}/**
* Moves sitemap level up or down
*/
function changeLevel( $level ) {
if ( $level > 0 ) {
# We do not print start ul here to avoid empty list, it's printed at the first child
$this->level += $level;
$this->_childs[$this->level]=0;
$this->_openList = "n<ul class="level_".$this->level."">n";
$this->_closeItem = '';// If we are moving up, then lets clean the children of this level
// because for sure this is a new set of links
if ( empty ($this->_last_child[$this->level-1]) || empty ($this->_parent_children[$this->level]['parent']) || $this->_parent_children[$this->level]['parent'] != $this->_last_child[$this->level-1] ) {
$this->_parent_children[$this->level]=array();
$this->_parent_children[$this->level]['parent'] = @$this->_last_child[$this->level-1];
}
} else {
if ($this->_childs[$this->level]){
echo $this->_closeItem."</ul>n";
}
$this->_closeItem ='</li>';
$this->_openList = '';
$this->level += $level;
}
}/** Print component heading, etc. Then call getHtmlList() to print list */
function startOutput(&$menus,&$config) {
global $database, $Itemid;
$sitemap = &$this->sitemap;
$this->live_site = substr_replace(JURI::root(), "", -1, 1);$user = &JFactory::getUser();
if ($this->_isAdmin) {
JHTML::_('behavior.mootools');
$live_site = JURI::root();
$ajaxurl = "$live_site/index.php?option=com_xmap&tmpl=component&task=editElement&action=toggleElement";$css = '.xmapexcl img{ border:0px; }'."n";
$css .= '.xmapexcloff { text-decoration:line-through; }';
//$css .= "n.".$this->sitemap->classname .' li {float:left;}';$js = "
window.addEvent('domready',function (){
$$('.xmapexcl').each(function(el){
el.onclick = function(){
if (this && this.rel) {
options = Json.evaluate(this.rel);
this.onComplete = checkExcludeResult
var myAjax = new Ajax('{$ajaxurl}&sitemap={$this->sitemap->id}&uid='+options.uid+'&itemid='+options.itemid,{
onComplete: checkExcludeResult.bind(this)
}).request();
}
return false;
};});
});
checkExcludeResult = function (txtresponse,xmlresponse) {
//this.set('class','xmapexcl xmapexcloff');
var imgs = this.getElementsByTagName('img');
var response = xmlresponse.getElementsByTagName('response')[0];
var result = response.getElementsByTagName('result')[0].firstChild.nodeValue;
if (result == 'OK') {
var state = response.getElementsByTagName('state')[0].firstChild.nodeValue;
if (state==0) {
imgs[0].src='{$live_site}administrator/images/publish_x.png';
} else {
imgs[0].src='{$live_site}administrator/images/tick.png';
}
} else {
alert('The element couldn\'t be published or upublished!');
}
}";$doc = JFactory::getDocument();
$doc->addStyleDeclaration ($css);
$doc->addScriptDeclaration ($js);
}$menu = &JTable::getInstance('Menu');
$menu->load( $Itemid ); // Load params for the Xmap menu-item
$params = new JParameter($menu->params);
$title = $params->get('page_title',$menu->name);$exlink[0] = $sitemap->exlinks; // image to mark popup links
$exlink[1] = $sitemap->ext_image;if( $sitemap->columns > 1 ) { // calculate column widths
$total = count($menus);
$columns = $total < $sitemap->columns ? $total : $sitemap->columns;
$this->_width = (100 / $columns) - 1;
}
echo '<div class="'. $sitemap->classname .'">';if ( $params->get( 'show_page_title' ) ) {
echo '<div class="componentheading">'.$title.'</div>';
}
echo '<div class="contentpaneopen"'. ($sitemap->columns > 1 ? ' style="float:left;width:100%;"' : '') .'>';}
/** Print component heading, etc. Then call getHtmlList() to print list */
function endOutput(&$menus) {
global $database, $Itemid;
$sitemap = &$this->sitemap;echo '<div style="clear:left"></div>';
//BEGIN: Advertisement
if( $sitemap->includelink ) {
echo "<div style="text-align:center;"><a href="http://joomla.vargas.co.cr" style="font-size:10px;">Powered by Xmap!</a></div>";
}
//END: Advertisementecho "</div>";
echo "</div>n";
}function startMenu(&$menu) {
$sitemap=&$this->sitemap;
if( $sitemap->columns > 1 ) // use columns
echo '<div style="float:left;width:'.$this->_width.'%;">';
if( $sitemap->show_menutitle ) // show menu titles
echo '<h2 class="menutitle">'.$menu->name.'</h2>';
}function endMenu(&$menu) {
$sitemap=&$this->sitemap;
$this->_closeItem='';
if( $sitemap->show_menutitle || $sitemap->columns > 1 ) { // each menu gets a separate list
if( $sitemap->columns > 1 ) {
echo "</div>n";
}}
}
}Other solution is to modify the xmap.php file. Then you do not have to modify anything in the xmap.html.php file.
in that case, this would be your new xmap.php file found in componentscom_xmap<?php
/**
* $Id: xmap.php 42 2009-08-01 19:09:42Z guilleva $
* $LastChangedDate: 2009-08-01 13:09:42 -0600 (Sat, 01 Aug 2009) $
* $LastChangedBy: guilleva $
* Xmap by Guillermo Vargas
* a sitemap component for Joomla! CMS (http://www.joomla.org)
* Author Website: http://joomla.vargas.co.cr
* Project License: GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/#ini_set('display_errors', 1);
#error_reporting(E_ALL);defined('_JEXEC') or die('Direct Access to this location is not allowed.');
// load Xmap language file
$view = JRequest::getVar('view', 'html' ,"REQUEST");
$task = JRequest::getVar('task', '' ,"REQUEST");
$news = JRequest::getInt('news', 0 ,"REQUEST");if ($view == 'xslfile' || $view == 'xsladminfile') {
header('Content-Type: application/xml; charset="utf-8"');
header('Content-Disposition: inline');
if ($view == 'xslfile') {
header('Content-Length: ' . filesize(JPATH_COMPONENT_SITE.DS.'gss.xsl'));
readfile(JPATH_COMPONENT_SITE.DS.'gss.xsl');
} else {
header('Content-Length: ' . filesize(JPATH_COMPONENT_SITE.DS.'gssadmin.xsl'));
readfile(JPATH_COMPONENT_SITE.DS.'gssadmin.xsl');
}
exit;
}$lang =& JFactory::getLanguage();
$language = $lang->getBackwardLang();
$LangPath = JPATH_COMPONENT_ADMINISTRATOR.DS.'language'.DS;
if( file_exists( $LangPath . $language . '.php') ) {
require_once( $LangPath . $language. '.php' );
} else {
require_once( $LangPath . 'english.php' );
}require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'classes'.DS.'XmapConfig.php' );
require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'classes'.DS.'XmapSitemap.php' );
require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'classes'.DS.'XmapPlugins.php' );
require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'classes'.DS.'XmapCache.php' );$user =& JFactory::getUser();
// This is an AJAX request to modify a item of the sitemap
if ($task == 'editElement') {if ($user->get('gid') != "25") {
die('Invalid request!');
}
$sitemapid=JRequest::getInt( 'sitemap',0);
if ($sitemapid) {
$sitemap = new XmapSitemap($database);
if ( $sitemap->load($sitemapid) ) {
$action = JRequest::getCmd('action','');
$uid = JRequest::getCmd('uid','');
$itemid = JRequest::getInt('itemid','');
switch ( $action ) {
case 'toggleElement':
if ($uid && $itemid) {
$state = $sitemap->toggleItem($uid,$itemid);
}
break;
case 'changeProperty':
$uid = JRequest::getCmd('uid','');
$property = JRequest::getCmd('property','');
$value = JRequest::getCmd('value','');
if ( $uid && $itemid && $uid && $property ) {
$state = $sitemap->chageItemPropery($uid,$itemid,'xml',$property,$value);
}
break;
}
}
}header('Content-Type: text/xml');
echo "<?xml version="1.0" encoding="UTF-8"?>n";
echo "<response>n";
echo " <result>OK</result>n";
echo " <state>".$state."</state>n";
echo "</response>n";
exit;
}global $xSitemap,$xConfig;
$xConfig = new XmapConfig;
$xConfig->load();$Itemid = intval(JRequest::getVar('Itemid', '' ,"REQUEST"));
$sitemapid = '';// Firts lets try to get the sitemap's id from the menu's params
if ( $Itemid ) {
$menu = JTable::getInstance('Menu');
$menu->load( $Itemid );
$params = new JParameter($menu->params );
$sitemapid=intval($params->get( 'sitemap','' ));
}if (!$sitemapid) { //If the is no sitemap id specificated
$sitemapid = intval(JRequest::getVar('sitemap','',"REQUEST"));
}if ( !$sitemapid && $xConfig->sitemap_default ) {
$sitemapid = $xConfig->sitemap_default;
}
$database= &JFactory::getDBO();
$xSitemap = new XmapSitemap($database);
$xSitemap->load($sitemapid);//$database->setQuery('alter table #__xmap_sitemap add excluded_items text');
//$database->query();if (!$xSitemap->id) {
echo _XMAP_MSG_NO_SITEMAP;
return;
}
if ( $view=='xml' ) {
Header("Content-type: text/xml; charset=UTF-8");
Header("Content-encoding: UTF-8");
}global $xmap;
$xmapCache = XmapCache::getCache($xSitemap);
$excluded_items = $xSitemap->getExcludedItems();
if ($xSitemap->usecache) {
$lang = JFactory::getLanguage();
$xmapCache->call('xmapCallShowSitemap',$view,$xSitemap->id,$excluded_items,$lang->getName(),$mainframe->getCfg('sef'),$user->get('id'),$news); // call plugin's handler function
} else {
xmapCallShowSitemap($view,$xSitemap->id,$excluded_items);
}switch ($view) {
case 'html':
$xSitemap->views_html++;
$xSitemap->lastvisit_html = time();
$xSitemap->save();
break;case 'xml':
$xSitemap->views_xml++;
$xSitemap->lastvisit_xml = time();
$xSitemap->save();$scriptname = basename($_SERVER['SCRIPT_NAME']);
$no_html = intval(JRequest::getVar('no_html', '0',"REQUEST"));
if ($view=='xml' && $scriptname != 'index2.php' || $no_html != 1) {
die();
}
break;
}/**
* Function called to generate and generate the tree. Created specially to
* use with the cache call method
* The params locale and sef are only for cache purppses
*/
function xmapCallShowSitemap($view,$sitemapid,$excluded_items,$locale='',$sef='',$userid=0,$news=0) {
global $xmapCache,$xSitemap,$xConfig;$xSitemap->loadItems($view);
$live_site = substr_replace(JURI::root(), "", -1, 1);
switch( $view ) {
case 'xml': // XML Sitemaps output
// Turn off all error reporting
ini_set('display_errors','Off');
// Set a high time limit to avoid problems. I think 600 seconds should be enough
set_time_limit(600);require_once(JPATH_COMPONENT_SITE .'/xmap.xml.php' );
$xmap = new XmapXML( $xConfig, $xSitemap );
$xmap->generateSitemap($view,$xConfig,$xmapCache);
$xSitemap->count_xml = $xmap->count;
break;
default: // Html output
global $mainframe;
require_once( $mainframe->getPath('front_html') );
if (!$xConfig->exclude_css) {
$mainframe->addCustomHeadTag( '<link rel="stylesheet" type="text/css" media="all" href="' . $live_site . '/components/com_xmap/css/xmap.css" />' );
}
$xmap = new XmapHtml( $xConfig, $xSitemap );
$xmap->generateSitemap($view,$xConfig,$xmapCache);
$xSitemap->count_html = $xmap->count;
break;
}
}class Xmap {
/** @var XmapConfig Configuration settings */
var $config;
/** @var XmapSitemap Configuration settings */
var $sitemap;
/** @var integer The current user's access level */
var $gid;
/** @var boolean Is authentication disabled for this website? */
var $noauth;
/** @var string Current time as a ready to use SQL timeval */
var $now;
/** @var object Access restrictions for user */
var $access;
/** @var string Type of sitemap to be generated */
var $view;
/** @var string count of links on sitemap */
var $count=0;/** Default constructor, requires the config as parameter. */
function Xmap( &$config, &$sitemap ) {
global $mainframe;jimport('joomla.utilities.date');
$user =& JFactory::getUser();
$access = new stdClass();
$access->canEdit = $user->authorize('com_content', 'edit', 'content', 'all');
$access->canEditOwn = $user->authorize('com_content', 'edit', 'content', 'own');
$access->canPublish = $user->authorize('com_content', 'publish', 'content', 'all');
$this->access = &$access;$date = new JDate();
$this->noauth = $mainframe->getCfg( 'shownoauth' );
$this->gid = $user->gid;
$this->now = $date->toUnix();
$this->config = &$config;
$this->sitemap = &$sitemap;
$this->isNews = false;
$this->_isAdmin = ($user->gid == "25");
}/** Generate a full website tree */
function generateSitemap( $type,&$config, &$cache ) {
$menus = $this->sitemap->getMenus();
$extensions = XmapPlugins::loadAvailablePlugins();
$root = array();
$this->startOutput($menus,$config);
foreach ( $menus as $menutype => $menu ) {
if ( ($type == 'html' && !$menu->show) || ($type == 'xml' && !$menu->showXML ) ) {
continue;
}$node = new stdclass();
$menu->id = 0;
$menu->menutype = $menutype;$node->uid = $menu->uid = "menu".$menu->id;
$node->menutype = $menutype;
$node->ordering = $menu->ordering;
$node->priority = $menu->priority;
$node->changefreq = $menu->changefreq;
$node->browserNav = 3;
$node->type = 'separator';
$node->name = $this->getMenuTitle($menutype,@$menu->module); // get the mod_mainmenu title from modules table$this->startMenu($node);
$this->printMenuTree($menu,$cache,$extensions);
$this->endMenu($node);
}
$this->endOutput($menus);
return true;
}/** Get a Menu's tree
* Get the complete list of menu entries where the menu is in $menutype.
* If the component, that is linked to the menuentry, has a registered handler,
* this function will call the handler routine and add the complete tree.
* A tree with subtrees for each menuentry is returned.
*/
function printMenuTree( &$menu, &$cache, $extensions) {
$database = &JFactory::getDBO();if( strlen($menu->menutype) == 0 ) {
$result = null;
return $result;
}$menuExluded = explode( ',', $this->sitemap->exclmenus ); // by mic: fill array with excluded menu IDs
/* * noauth is true:
- Will show links to registered content, even if the client is not logged in.
- The user will need to login to see the item in full.
* noauth is false:
- Will show only links to content for which the logged in client has access.
*/
$sql = "SELECT m.id, m.name, m.parent, m.link, m.type, m.browserNav, m.menutype, m.ordering, m.params, m.componentid,m.home, c.name AS component"
. "n FROM #__menu AS m"
. "n LEFT JOIN #__components AS c ON m.type='components' AND c.id=m.componentid"
. "n WHERE m.published='1' AND m.parent=".$menu->id." AND m.menutype = '".$menu->menutype."'"
. ( $this->noauth ? '' : "n AND m.access <= '". $this->gid ."'" )
. "n ORDER BY m.menutype,m.parent,m.ordering";// Load all menuentries
$database->setQuery( $sql );
$items = $database->loadObjectList();if( count($items) <= 0) { //ignore empty menus
$result = null;
return $result;
}$this->changeLevel(1);
foreach ( $items as $i => $item ) { // Add each menu entry to the root tree.
$item->priority = $menu->priority;
$item->changefreq = $menu->changefreq;
if( in_array( $item->id, $menuExluded ) ) { // ignore exluded menu-items
continue;
}$node = new stdclass;
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$testavaluetoday = htmlspecialchars($item->name);
$returnedvaluetoday = strpos($testavaluetoday,"[");
if ($returnedvaluetoday != 0){
$finalvalueretrievedtoday = substr($testavaluetoday,0,$returnedvaluetoday-1);
}
else{
$finalvalueretrievedtoday = htmlspecialchars($item->name);
}
//end of code modified by : Prakash R Balge$node->id = $item->id;
$node->uid = "itemid".$item->id;
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$node->name = $finalvalueretrievedtoday; // displayed name of node
//end of code modified by : Prakash R Balge
$node->parent = $item->parent; // id of parent node
$node->browserNav = $item->browserNav; // how to open link
$node->ordering = isset( $item->ordering ) ? $item->ordering : $i; // display-order of the menuentry
$node->priority = $item->priority;
$node->changefreq = $item->changefreq;
$node->type = $item->type; // menuentry-type
$node->menutype = $item->menutype; // menuentry-type
$node->home = $item->home; // menuentry-type
$node->link = isset( $item->link ) ? htmlspecialchars( $item->link ) : '';if ( $node->type == 'separator') {
$node->browserNav=3;
}XmapPlugins::prepareMenuItem($node,$extensions); // Let's see if the extension wants to do somenthing with this node before it's printed
if ( $node->home ) {
$node->link = JURI::base();
} elseif (substr($item->link,0,9) == 'index.php' && $item->type != 'url' ) {
if ($item->type == 'menulink') {// For Joomla 1.5 SEF compatibility
$params = new JParameter($item->params);
$node->link = 'index.php?Itemid=' . $params->get('menu_item');
} elseif ( strpos($node->link,'Itemid=') === FALSE ){
$node->link = 'index.php?Itemid=' . $node->id;
}
}$this->printNode($node);
if ( preg_match('/option=(com_+)/i',$item->link,$matches ) ) {
// Set the uid of the node to the component uid after print it
// so its children dont use a wrong uid
# echo $node->uid = $matches[1];
}
$this->printMenuTree($node,$cache,$extensions);
XmapPlugins::printTree( $this, $item, $cache, $extensions ); // Determine the menu entry's type and call it's handler
}
$this->changeLevel(-1);
}/** Look up the title for the module that links to $menutype */
function getMenuTitle($menutype,$module='mod_mainmenu') {
$database = &JFactory::getDBO();
$query = "SELECT * FROM #__modules WHERE published='1' AND module ='$module' AND params LIKE '%menutype=". $menutype ."%'";
$database->setQuery( $query );
if( !$row = $database->loadObject() )
return '';
return $row->title;
}function getItemLink (&$node) {
static $live_site;
if (!isset($live_site)) {
$juri = &JURI::getInstance();
$live_site = $juri->getScheme().'://'.$juri->getHost();
if ($juri->getPort() != NULL)
$live_site = $live_site.':'.$juri->getPort();}
$link = $node->link;
if ( isset($node->id) ) {
switch( @$node->type ) {
case 'separator':
break;
case 'url':
if ( preg_match( "#^/?index.php?#", $link ) ) {
if ( strpos( $link, 'Itemid=') === FALSE ) {
if (strpos( $link, '?') === FALSE ) {
$link .= '?Itemid='.$node->id;
} else {
$link .= '&Itemid='.$node->id;
}
}
}
break;
default:
if ( !@$node->home && (strpos( $link, 'Itemid=' ) === FALSE) ) {
$link .= '&Itemid='.$node->id;
}
break;
}
}
if( strcasecmp( substr( $link, 0, 4), 'http' ) ){
if (strcasecmp( substr( $link, 0, 9), 'index.php' ) === 0 ) {
$link = JRoute::_($link); // apply SEF transformation
if ( strcasecmp( substr($link,0,4), 'http' ) && $this->view=='xml') { // XML sitemap requires full path URL's
$link = $live_site. (substr($link,0,1) == '/'? '' : '/').$link;
}
} else { // Case for internal links not starting with index.php
if (substr($link, 0, 1) == '/')
$link = $live_site.$link;
else
$link = $live_site. '/' .$link;
}
}return $link;
}/** called with usort to sort menus */
function sort_ordering( &$a, &$b) {
if( $a->ordering == $b->ordering )
return 0;
return $a->ordering < $b->ordering ? -1 : 1;
}function &getParam($arr, $name, $def) {
$var = JArrayHelper::getValue( $arr, $name, $def, '' );
return $var;
}
}
Please let me know which would perform better or if there is a better solution to this problem.
1 user says Thank You to prakash for this useful post
Arvind Chauhan ModeratorArvind Chauhan
- Join date:
- September 2014
- Posts:
- 3835
- Downloads:
- 74
- Uploads:
- 92
- Thanks:
- 1240
- Thanked:
- 1334 times in 848 posts
November 22, 2009 at 6:15 pm #324603Dear prbalge,
A solution to such similar problem was provided by JA Developer in another thread. Here is the link >> http://www.joomlart.com/forums/showpost.php?p=154170&postcount=5 . May be you can check it out and let us know if this helps.
Arvind
1 user says Thank You to Arvind Chauhan for this useful post
prakash Friendprakash
- Join date:
- October 2008
- Posts:
- 439
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 146 times in 115 posts
November 23, 2009 at 2:24 am #324640Hi Arvind,
Yes the solution is quite similar but JA Developer did not post it earlier. Hence, based on my knowledge about PHP (which is quite limited) I created a function to remove the extra info.
With regards the solution that has been provided by JA Developer, I would like to point out that in case of his solution there is an extra space which is printed along with the text.
If you see my solution – you get for example ‘Typography’ while in case of JA Developers result you get ‘Typography ‘ . Hence he will need to fix that error.
Rest of the result seems similar to the result I have achieved.1 user says Thank You to prakash for this useful post
prakash Friendprakash
- Join date:
- October 2008
- Posts:
- 439
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 146 times in 115 posts
November 25, 2009 at 6:51 am #324879Hello everyone,
My solution for XMAP with JA Mega Menu was also found on the XMAP forum and a user brenden has suggested a small fix through which you can get the complete titile
In my solution if you wrote Before Quote After Quote then the answer would be Before Quote. But after applying the fix that brenden has suggested you can get complete title like Before Quote After Quote
Here is the complete xmap.html.php file
<?php
/**
* $Id: xmap.html.php 24 2009-03-13 15:05:30Z guilleva $
* $LastChangedDate: 2009-03-13 09:05:30 -0600 (Fri, 13 Mar 2009) $
* $LastChangedBy: guilleva $
* Xmap by Guillermo Vargas
* A Sitemap component for Joomla! CMS (http://www.joomla.org)
* Author Website: http://joomla.vargas.co.cr
* Project License: GNU/GPL http://www.gnu.org/copyleft/gpl.html
*/defined('_JEXEC') or die('Direct Access to this location is not allowed.');
/** Wraps HTML output */
class XmapHtml extends Xmap {
var $level = -1;
var $_openList = '';
var $_closeList = '';
var $_closeItem = '';
var $_childs;
var $_width;
var $_isAdmin = 0;function XmapHtml (&$config, &$sitemap) {
$this->view = 'html';
Xmap::Xmap($config, $sitemap);
$this->_parent_children=array();
$this->_last_child=array();
}/**
* Print one node of the sitemap
*/
function printNode( &$node ) {
global $Itemid;$out = '';
if ($this->sitemap->isExcluded($node->id,$node->uid) && !$this->_isAdmin) {
return FALSE;
}// To avoid duplicate children in the same parent
if ( !empty($this->_parent_children[$this->level][$node->uid]) ) {
return FALSE;
}//var_dump($this->_parent_children[$this->level]);
$this->_parent_children[$this->level][$node->uid] = true;$out .= $this->_closeItem;
$out .= $this->_openList;
$this->_openList = "";if ( $Itemid == $node->id )
$out .= '<li class="active">';
else
$out .= '<li>';$link = Xmap::getItemLink($node);
if( !isset($node->browserNav) )
$node->browserNav = 0;$node->name = htmlspecialchars($node->name);
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$testavaluetoday = htmlspecialchars($node->name);
$returnedvaluetoday = strpos($testavaluetoday,"[");
$returnedvalueendday = strpos($testavaluetoday, "]");
if ($returnedvaluetoday != 0){
if($returnedvalueendday == (strlen($testavaluetoday)-1)) {
$finalvalueretrievedtoday = substr($testavaluetoday,0,$returnedvaluetoday-1);
} else {
$menunamestart = substr($testavaluetoday,0,$returnedvaluetoday-1);
$menunameend = substr($testavaluetoday,$returnedvalueendday+1,(strlen($testavaluetoday)-$returnedvalueendday));
$finalvalueretrievedtoday = $menunamestart." ".$menunameend;
}}
else{
$finalvalueretrievedtoday = htmlspecialchars($node->name);
}
//end of code modified by : Prakash R Balgeswitch( $node->browserNav ) {
case 1: // open url in new window
$ext_image = '';
if ( $this->sitemap->exlinks ) {
$ext_image = ' <img src="'. $this->live_site .'/components/com_xmap/images/'. $this->sitemap->ext_image .'" alt="' . _XMAP_SHOW_AS_EXTERN_ALT . '" title="' . _XMAP_SHOW_AS_EXTERN_ALT . '" border="0" />';
}
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'" target="_blank">'. $finalvalueretrievedtoday . $ext_image .'</a>';
//end of code modified by : Prakash R Balge
break;case 2: // open url in javascript popup window
$ext_image = '';
if( $this->sitemap->exlinks ) {
$ext_image = ' <img src="'. $this->live_site .'/components/com_xmap/images/'. $this->sitemap->ext_image .'" alt="' . _XMAP_SHOW_AS_EXTERN_ALT . '" title="' . _XMAP_SHOW_AS_EXTERN_ALT . '" border="0" />';
}
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'" target="_blank" '. "onClick="javascript: window.open('". $link ."', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false;">". $finalvalueretrievedtoday . $ext_image."</a>";
//end of code modified by : Prakash R Balge
break;case 3: // no link
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$out .= '<span>'. $finalvalueretrievedtoday .'</span>';
//end of code modified by : Prakash R Balge
break;default: // open url in parent window
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com
$out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'">'. $finalvalueretrievedtoday .'</a>';
//end of code modified by : Prakash R Balge
break;
}$this->_closeItem = "</li>n";
$this->_childs[$this->level]++;
echo $out;if ($this->_isAdmin) {
if ( $this->sitemap->isExcluded($node->id,$node->uid) ) {
$img = '<img src="'.$this->live_site.'/administrator/images/publish_x.png" alt="'._XMAP_EXT_PUBLISHED.'" title="'._XMAP_EXT_UNPUBLISHED.'">';
$class= 'xmapexclon';
} else {
$img = '<img src="'.$this->live_site.'/administrator/images/tick.png" alt="'._XMAP_EXT_PUBLISHED.'" title="'._XMAP_EXT_PUBLISHED.'" />';
$class= 'xmapexcloff';
}
echo ' <a href= "#" class="xmapexcl '.$class.'" rel="{uid:''.$node->uid.'',itemid:'.$node->id.'}">'.$img.'</a>';
# echo ' <a href= "#" class="xmapoptions" rel="{uid:''.$node->uid.'',itemid:'.$node->id.'}"><img src="'.$this->live_site.'/components/com_xmap/images/options.gif" border="0" alt="Options" title="Options" /></a>';
}
//echo $this->_last_child[$this->level-1] . ' ' . $this->_parent_children[$this->level]['parent'];
$this->count++;$this->_last_child[$this->level] = $node->uid;
return TRUE;
}/**
* Moves sitemap level up or down
*/
function changeLevel( $level ) {
if ( $level > 0 ) {
# We do not print start ul here to avoid empty list, it's printed at the first child
$this->level += $level;
$this->_childs[$this->level]=0;
$this->_openList = "n<ul class="level_".$this->level."">n";
$this->_closeItem = '';// If we are moving up, then lets clean the children of this level
// because for sure this is a new set of links
if ( empty ($this->_last_child[$this->level-1]) || empty ($this->_parent_children[$this->level]['parent']) || $this->_parent_children[$this->level]['parent'] != $this->_last_child[$this->level-1] ) {
$this->_parent_children[$this->level]=array();
$this->_parent_children[$this->level]['parent'] = @$this->_last_child[$this->level-1];
}
} else {
if ($this->_childs[$this->level]){
echo $this->_closeItem."</ul>n";
}
$this->_closeItem ='</li>';
$this->_openList = '';
$this->level += $level;
}
}/** Print component heading, etc. Then call getHtmlList() to print list */
function startOutput(&$menus,&$config) {
global $database, $Itemid;
$sitemap = &$this->sitemap;
$this->live_site = substr_replace(JURI::root(), "", -1, 1);$user = &JFactory::getUser();
if ($this->_isAdmin) {
JHTML::_('behavior.mootools');
$live_site = JURI::root();
$ajaxurl = "$live_site/index.php?option=com_xmap&tmpl=component&task=editElement&action=toggleElement";$css = '.xmapexcl img{ border:0px; }'."n";
$css .= '.xmapexcloff { text-decoration:line-through; }';
//$css .= "n.".$this->sitemap->classname .' li {float:left;}';$js = "
window.addEvent('domready',function (){
$$('.xmapexcl').each(function(el){
el.onclick = function(){
if (this && this.rel) {
options = Json.evaluate(this.rel);
this.onComplete = checkExcludeResult
var myAjax = new Ajax('{$ajaxurl}&sitemap={$this->sitemap->id}&uid='+options.uid+'&itemid='+options.itemid,{
onComplete: checkExcludeResult.bind(this)
}).request();
}
return false;
};});
});
checkExcludeResult = function (txtresponse,xmlresponse) {
//this.set('class','xmapexcl xmapexcloff');
var imgs = this.getElementsByTagName('img');
var response = xmlresponse.getElementsByTagName('response')[0];
var result = response.getElementsByTagName('result')[0].firstChild.nodeValue;
if (result == 'OK') {
var state = response.getElementsByTagName('state')[0].firstChild.nodeValue;
if (state==0) {
imgs[0].src='{$live_site}administrator/images/publish_x.png';
} else {
imgs[0].src='{$live_site}administrator/images/tick.png';
}
} else {
alert('The element couldn\'t be published or upublished!');
}
}";$doc = JFactory::getDocument();
$doc->addStyleDeclaration ($css);
$doc->addScriptDeclaration ($js);
}$menu = &JTable::getInstance('Menu');
$menu->load( $Itemid ); // Load params for the Xmap menu-item
$params = new JParameter($menu->params);
$title = $params->get('page_title',$menu->name);$exlink[0] = $sitemap->exlinks; // image to mark popup links
$exlink[1] = $sitemap->ext_image;if( $sitemap->columns > 1 ) { // calculate column widths
$total = count($menus);
$columns = $total < $sitemap->columns ? $total : $sitemap->columns;
$this->_width = (100 / $columns) - 1;
}
echo '<div class="'. $sitemap->classname .'">';if ( $params->get( 'show_page_title' ) ) {
echo '<div class="componentheading">'.$title.'</div>';
}
echo '<div class="contentpaneopen"'. ($sitemap->columns > 1 ? ' style="float:left;width:100%;"' : '') .'>';}
/** Print component heading, etc. Then call getHtmlList() to print list */
function endOutput(&$menus) {
global $database, $Itemid;
$sitemap = &$this->sitemap;echo '<div style="clear:left"></div>';
//BEGIN: Advertisement
if( $sitemap->includelink ) {
echo "<div style="text-align:center;"><a href="http://joomla.vargas.co.cr" style="font-size:10px;">Powered by Xmap!</a></div>";
}
//END: Advertisementecho "</div>";
echo "</div>n";
}function startMenu(&$menu) {
$sitemap=&$this->sitemap;
if( $sitemap->columns > 1 ) // use columns
echo '<div style="float:left;width:'.$this->_width.'%;">';
if( $sitemap->show_menutitle ) // show menu titles
echo '<h2 class="menutitle">'.$menu->name.'</h2>';
}function endMenu(&$menu) {
$sitemap=&$this->sitemap;
$this->_closeItem='';
if( $sitemap->show_menutitle || $sitemap->columns > 1 ) { // each menu gets a separate list
if( $sitemap->columns > 1 ) {
echo "</div>n";
}}
}
}
nigelmaine Friendnigelmaine
- Join date:
- September 2008
- Posts:
- 71
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 38
- Thanked:
- 3 times in 1 posts
November 25, 2009 at 8:07 am #324902Hi prbalge
The problem I have is that my page title is showing “Home [ ]PFT’s Home Page” as well as showing the same title on the Xmap site map.
I’m also using sh404sef.
Do you know if this will ammend/correct the home page title as well?
Thanks in advance
Nigel
prakash Friendprakash
- Join date:
- October 2008
- Posts:
- 439
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 146 times in 115 posts
November 25, 2009 at 8:58 am #324914Hi,
If it is showing only for the home page then a simple fix would be
Open admin panel > components>sh404sef>view/edit sef urls>
to the right top you will see Home Page Meta
click there > on new screen you will get first line Title Tag write the title you want here and save it…Let me know if that fixes your problem or if you need for all pages…
nigelmaine Friendnigelmaine
- Join date:
- September 2008
- Posts:
- 71
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 38
- Thanked:
- 3 times in 1 posts
November 25, 2009 at 9:14 am #324918Hi prbalge
Thanks for replying so quickly.
As you mentioned, it is a problem on all pages.
I have edited the Home Meta and its fine. But I still get the [ ] on the Xmap (I haven’t changed the PHP code just yet), however, will your original solution simply display the main title and not the additional description on xmap?
Regards
Nigel
prakash Friendprakash
- Join date:
- October 2008
- Posts:
- 439
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 146 times in 115 posts
November 25, 2009 at 9:22 am #324919Ok I will have a look at the page title generated via sh404 and if possible provide a fix for the same.
with regards my solution for xmap – with the first solution it will display the text before the [] and not the description. The fix is limited to XMAP only and only on the sitemap the title would be displayed without the []. It would not have any effect on page titles as of now.
prakash Friendprakash
- Join date:
- October 2008
- Posts:
- 439
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 146 times in 115 posts
November 25, 2009 at 9:59 am #324934Hi Nigel,
I have tried out a fix (this would be on as is where is basis because I have done limited testing)
Please take a backup of your existing file and test, so that just in case something goes wrong it still can be fixed 🙂
I have tested it locally and it does work, not tested on live server.
To fix : open this file….componentscom_sh404sefshPageRewrite.php
find this text>
function shCleanUpTitle( $title) {
return trim(trim(stripslashes(html_entity_decode($title))), '"');
}and replace with this>
function shCleanUpTitle( $title) {
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com$testavaluetoday = htmlspecialchars($title);
$returnedvaluetoday = strpos($testavaluetoday,"[");
if ($returnedvaluetoday != 0){
$finalvalueretrievedtoday = substr($testavaluetoday,0,$returnedvaluetoday-1);
}
else{
$finalvalueretrievedtoday = htmlspecialchars($node->name);
}//end of code modified by : Prakash R Balge
return trim(trim(stripslashes(html_entity_decode($finalvalueretrievedtoday))), '"');
}
In case of any issues > please copy and paste your shpagerewrite.php code here and I will send you the modified file (this is mainly because I donot know which sh404 version you have
<em>@nigelmaine 154562 wrote:</em><blockquote>Hi prbalge
Thanks for replying so quickly.
As you mentioned, it is a problem on all pages.
I have edited the Home Meta and its fine. But I still get the [ ] on the Xmap (I haven’t changed the PHP code just yet), however, will your original solution simply display the main title and not the additional description on xmap?
Regards
Nigel</blockquote>
nigelmaine Friendnigelmaine
- Join date:
- September 2008
- Posts:
- 71
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 38
- Thanked:
- 3 times in 1 posts
November 25, 2009 at 1:07 pm #324962Hi
Thanks for you help on this.
I changed the php code as suggested and unfortunately it has not changed anything on the site map, however.
1. When the Xmap siet map is displayed, the page url is the site name – correct
2. On all other pages though, the page name display now matches the full url, i.e. http://www.clearvoice.co.uk/marketing
3. I tried to change the Home Meta name and this also does not work. ooops.I have another site with the JA Kayanite II template and it has the same problem on the site map display. But I did ammend the Home Meta name successfully.
Many thanks for your time on this, I do appreciate it.
Regards
Nigel
prakash Friendprakash
- Join date:
- October 2008
- Posts:
- 439
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 146 times in 115 posts
November 25, 2009 at 2:39 pm #324972Hi,
I did check your site, and in the title nothing comes up and hence you are seeing the URL.
I think you have not updated the shPageRewrite.php page correctly.
What I suggest is that you update your previous shPageRewrite.php file and paste the entire code (the old file before modifications) here under the code tag.
That way I can have a look at it and send you the updated file.
Thanks
nigelmaine Friendnigelmaine
- Join date:
- September 2008
- Posts:
- 71
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 38
- Thanked:
- 3 times in 1 posts
November 25, 2009 at 3:24 pm #324977<?php
/**
* shCustomTags Joomla module : php module
* Copyright (C) 2006-2007 Yannick Gaultier (shumisha). All rights reserved.
* Released under the http://www.gnu.org/copyleft/gpl.html GNU/GPL, doc/license and credits.txt
* This is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
// V 1.2.4.t check if sh404SEF is running
if (function_exists('shLoadPluginlanguage')) {
// support for improved TITLE, DESCRIPTION, KEYWORDS and ROBOTS head tag
global $shCustomTitleTag, $shCustomDescriptionTag, $shCustomKeywordsTag,
$shCustomRobotsTag, $shCustomLangTag;
// these variables can be set throughout your php code in components, bots or other modules
// the last one wins !
function shCleanUpTitle( $title) {
return JString::trim(JString::trim(stripslashes(html_entity_decode($title))), '"');
}
function shCleanUpDesc( $desc) {
$desc = stripslashes(html_entity_decode(strip_tags($desc, '<br><br /><p></p>'), ENT_NOQUOTES));
$desc = str_replace('<br>',' - ', $desc); // otherwise, one word<br >another becomes onewordanother
$desc = str_replace('<br />',' - ', $desc);
$desc = str_replace('<p>',' - ', $desc);
$desc = str_replace('</p>',' - ', $desc);
while (strpos($desc, ' - - ') !== false) {
$desc = str_replace(' - - ', ' - ', $desc);
}
$desc = str_replace("'",''', $desc);
$desc = str_replace("'",''', $desc);
$desc = str_replace('"', ''', $desc);
$desc = str_replace("r",'', $desc);
$desc = str_replace("n",'', $desc);
return JString::substr( JString::trim($desc), 0, 512);
}
// utility function to insert data into an html buffer, after, instead or before
// one or more instances of a tag. If last parameter is 'first', then only the
// first occurence of the tag is replaced, or the new value is inserted only
// after or before the first occurence of the tag
function shInsertCustomTagInBuffer( $buffer, $tag, $where, $value, $firstOnly) {
if (!$buffer || !$tag || !$value) return $buffer;
$bits = explode($tag, $buffer);
if (count($bits) < 2) return $buffer;
$result = $bits[0];
$maxCount = count($bits)-1;
switch ($where) {
case 'instead' :
for ($i=0; $i < $maxCount; $i++) {
$result .= ($firstOnly == 'first' ? ($i==0 ? $value:$tag):$value).$bits[$i+1];
}
break;
case 'after' :
for ($i=0; $i < $maxCount; $i++) {
$result .= $tag.($firstOnly == 'first' ? ($i==0 ? $value:$tag):$value).$bits[$i+1];
}
break;
default :
for ($i=0; $i < $maxCount; $i++) {
$result .= ($firstOnly == 'first' ? ($i==0 ? $value:$tag):$value).$tag.$bits[$i+1];
}
break;
}
return $result;
}
function shDoLinkReadMoreCallback($matches) {
if (count($matches) != 3) return empty($matches) ? '' : $matches[0];
$mask = '<td class="contentheading" width="100%">%%shM1%%title="%%shTitle%%" class="readon">%%shM2%% [%%shTitle%%]</a>';
$result = str_replace('%%shM2%%', $matches[2], $mask);
// we may have captured more than we want, if there are several articles, but only the last one has
// a Read more link (first ones may be intro-only articles). Need to make sure we are fetching the right title
$otherArticles = explode( '<td class="contentheading" width="100%">', $matches[1]);
$articlesCount = count ($otherArticles);
$matches[1] = $otherArticles[$articlesCount-1];
unset($otherArticles[$articlesCount-1]);
$bits = explode ('class="contentpagetitle">', $matches[1]);
if (count ($bits) > 1) { // there is a linked title
$titleBits = array();
preg_match('/(.*)(<script|</a>)/isU', $bits[1], $titleBits); // extract title-may still have <h1> tags
$title = shCleanUpTitle( JString::trim($titleBits[1]));
} else { // title is not linked
$titleBits = array();
preg_match('/(.*)(<script|<as*href=|</td>)/isU', $matches[1], $titleBits); // extract title-may still have <h1> tags
$title = str_replace('<h1>', '', $titleBits[1]);
$title = str_replace('</h1>', '', $title);
$title = shCleanUpTitle( JString::trim($title));
}
$result = str_replace('%%shTitle%%', $title, $result);
// restore possible additionnal articles
$articles = implode( '<td class="contentheading" width="100%">', $otherArticles);
$matches[1] = (empty($articles) ? '': $articles . '<td class="contentheading" width="100%">') . $matches[1];
$result = str_replace('%%shM1%%', $matches[1], $result);
$result = str_replace('%%shM2%%', $matches[2], $result);
$result = str_replace( 'class="contentpagetitle">', 'title="'.$title.'" class="contentpagetitle">', $result);
return $result;
}
function shDoRedirectOutboundLinksCallback($matches) {
if (count($matches) != 2) return empty($matches) ? '' : $matches[0];
if (strpos($matches[1], $GLOBALS['shConfigLiveSite']) === false){
$mask = '<a href="'.$GLOBALS['shConfigLiveSite'].'/index.php?option=com_sh404sef&shtask=redirect&shtarget=%%shM1%%"';
$result = str_replace('%%shM1%%', $matches[1], $mask);
} else $result = $matches[0];
return $result;
}
function shDoInsertOutboundLinksImageCallback($matches) {
//if (count($matches) != 2 && count($matches) != 3) return empty($matches) ? '' : $matches[0];
$orig = $matches[0];
$bits = explode('href=', $orig);
$part2 = $bits[1]; // 2nd part, after the href=
$sep = substr($part2, 0, 1); // " or ' ?
$link = JString::trim($part2, $sep); // remove first " or '
if (empty($sep)) { // this should not happen, but it happens (Fireboard)
$result = $matches[0];
return $result;
}
$link = explode($sep, $link);
$link = $link[0]; // keep only the link
$shPageInfo = & shRouter::shPageInfo();
$sefConfig = & shRouter::shGetConfig();
if ( substr($link, 0, strlen($GLOBALS['shConfigLiveSite'])) != $GLOBALS['shConfigLiveSite']
&& substr($link, 0, 7) == 'http://'
&& substr($link, 0, strlen($shPageInfo->base)) != $shPageInfo->base){
$mask = '%%shM1%%href="%%shM2%%" %%shM3%% >%%shM4%%<img border="0" alt="%%shM5%%" src="'
.$GLOBALS['shConfigLiveSite'].'/components/com_sh404sef/images/'
.$sefConfig->shImageForOutboundLinks
.'"/></a>';
$result = str_replace('%%shM1%%', $bits[0], $mask);
$result = str_replace('%%shM2%%', $link, $result);
$m3 = str_replace($sep.$link.$sep, '', str_replace('</a>', '', $part2)); // remove link from part 2
$bits2 = explode('>', $m3);
$m3 = $bits2[0];
$result = str_replace('%%shM3%%', $m3, $result);
array_shift($bits2); // remove first bit
$m4 = implode($bits2, '>');
$result = str_replace('%%shM4%%', $m4, $result);
$m5 = strip_tags($m4);
$result = str_replace('%%shM5%%', $m5, $result);
} else $result = $matches[0];
return $result;
}
function shDoTitleTags( &$buffer) {
// Replace TITLE and DESCRIPTION and KEYWORDS
if (empty($buffer)) return;
global $shCustomTitleTag, $shCustomDescriptionTag, $shCustomKeywordsTag,
$shCustomRobotsTag, $shCustomLangTag, $shHomeLink,
$shMosConfig_lang, $shMosConfig_locale;
$database = & JFactory::getDBO();
$sefConfig = & shRouter::shGetConfig();
$shPageInfo = & shRouter::shPageInfo(); // get page details gathered by system plugin
// V 1.2.4.t protect against error if using shCustomtags without sh404SEF activated
// this should not happen, so we simply do nothing
if (!isset($sefConfig) || empty( $shPageInfo->shCurrentPageNonSef)) {
return;
}
// fix bug in Joomla search
//$shUri = null;
//$shOriginalUri = null;
//$buffer = str_replace( 'action="index.php"', 'action="'.shSefRelToabs('index.php', '', $shUri, $shUri, $shOriginalUri).'"', $buffer);
// check if there is a manually created set of tags from tags file
// need to get them from DB
if ($sefConfig->shMetaManagementActivated) {
// get header data set through Joomla
$document = & JFactory::getDocument();
$joomlaHead = $document->getHeadData();
$joomlaMetaData = $joomlaHead['metaTags']['standard'];
// plugin system to automatically build title and description tags on a component per component basis
$option = JRequest::getVar( 'option');
$shDoNotOverride = in_array( str_replace('com_', '', $option), $sefConfig->shDoNotOverrideOwnSef);
if ((file_exists(sh404SEF_ABS_PATH.'components/'.$option.'/meta_ext/'.$option.'.php'))
&& ($shDoNotOverride // and param said do not override
|| (!$shDoNotOverride // or param said override, but we don't have a plugin
&& !file_exists(sh404SEF_ABS_PATH.'components/com_sh404sef/meta_ext/'.$option.'.php')) )) {
_log('Loading component own meta plugin'); // Load the plug-in file
include(sh404SEF_ABS_PATH.'components/'.$option.'/meta_ext/'.$option.'.php');
} // then look for sh404SEF own plugin
else if (file_exists(sh404SEF_ABS_PATH.'components/com_sh404sef/meta_ext/'.$option.'.php')) {
_log('Loading built-in meta plugin');
include(sh404SEF_ABS_PATH.'components/com_sh404sef/meta_ext/'.$option.'.php');
}
// now read manually setup tags
if (shSortUrl($shPageInfo->shCurrentPageNonSef) == shCleanUpAnchor($shHomeLink)) { // V 1.2.4.t homepage custom tags
$sql = 'SELECT id, metadesc, metakey, metatitle, metalang, metarobots FROM #__sh404SEF_meta WHERE newurl = ''.sh404SEF_HOMEPAGE_CODE.''';
} else {
// V 1.2.4.t make sure we have lang info and properly sorted params
if (!preg_match( '/(&|?)lang={2,3}/iU', $shPageInfo->shCurrentPageNonSef)) { // no lang string, let's add default
$shTemp = explode( '_', $GLOBALS['shMosConfig_locale']);
$shLangTemp = $shTemp[0] ? $shTemp[0] : 'en';
$shPageInfo->shCurrentPageNonSef .= '&lang='.$shLangTemp;
}
$shPageInfo->shCurrentPageNonSef = shSortUrl($shPageInfo->shCurrentPageNonSef);
$sql = 'SELECT id, metadesc, metakey, metatitle, metalang, metarobots FROM #__sh404SEF_meta WHERE newurl = ''.ltrim($shPageInfo->shCurrentPageNonSef, '/').''';
}
$shCustomTags = null;
$database->setQuery($sql);
$shCustomTags = $database->loadObject();
if ( !empty($shCustomTags)) {
$shCustomTitleTag = !empty($shCustomTags->metatitle) ? $shCustomTags->metatitle : $shCustomTitleTag;
$shCustomDescriptionTag = !empty($shCustomTags->metadesc) ? $shCustomTags->metadesc : $shCustomDescriptionTag;
$shCustomKeywordsTag = !empty($shCustomTags->metakey) ? $shCustomTags->metakey : $shCustomKeywordsTag;
$shCustomRobotsTag = !empty($shCustomTags->metarobots) ? $shCustomTags->metarobots : $shCustomRobotsTag;
$shCustomLangTag = !empty($shCustomTags->metalang) ? $shCustomTags->metalang : $shCustomLangTag;
}
// then insert them in page
if (!is_null($shCustomTitleTag)) {
$buffer = preg_replace( '/<s*titles*>.*<s*/titles*>/isU', '<title>'
.shCleanUpTitle($sefConfig->prependToPageTitle.$shCustomTitleTag.$sefConfig->appendToPageTitle).'</title>', $buffer);
$buffer = preg_replace( '/<s*metas+names*=s*"title.*/>/isU', '', $buffer); // remove Joomla title meta
}
if (!is_null($shCustomDescriptionTag)) {
$buffer = preg_replace( '/<s*metas+names*=s*"description.*/>/isU', '<meta name="description" content="'
.shCleanUpDesc($shCustomDescriptionTag).'" />', $buffer);
}
if (!is_null($shCustomKeywordsTag)) {
$buffer = preg_replace( '/<s*metas+names*=s*"keywords.*/>/isU', '<meta name="keywords" content="'
.shCleanUpDesc($shCustomKeywordsTag).'" />', $buffer);
}
if (!is_null($shCustomRobotsTag)) {
if (strpos($buffer, '<meta name="robots" content="') !== false) {
$buffer = preg_replace( '/<s*metas+names*=s*"robots.*/>/isU', '<meta name="robots" content="'
.$shCustomRobotsTag.'" />', $buffer);
}
else if (!empty($shCustomRobotsTag)) {
$buffer = shInsertCustomTagInBuffer( $buffer, '</head>', 'before', '<meta name="robots" content="'
.$shCustomRobotsTag.'" />', 'first');
}
}
if (!is_null($shCustomLangTag)) {
$shLang = $shCustomLangTag;
}
else {
$shLang = $shMosConfig_locale;
}
if (strpos($buffer, '<meta http-equiv="Content-Language"') !== false) {
$buffer = preg_replace( '/<s*metas+http-equivs*=s*"Content-Language".*/>/isU', '<meta http-equiv="Content-Language" content="'.$shLang.'" />', $buffer);
}
else if (!empty($shCustomLangTag)) {
$buffer = shInsertCustomTagInBuffer( $buffer, '</head>', 'before', '<meta http-equiv="Content-Language" content="'.$shLang.'" />', 'first');
}
// remove Generator tag
if ($sefConfig->shRemoveGeneratorTag) {
$buffer = preg_replace( '/<metas*name="Generator"s*content=".*/>/isU','', $buffer);
}
// version x : add title to read on link
if ($sefConfig->shInsertReadMorePageTitle) {
if (strpos( $buffer, 'class="readon"') !== false) {
$buffer = preg_replace_callback( '/<td class="contentheading" width="100%">(.*)class="readon">(.*)</a>/isU',
'shDoLinkReadMoreCallback', $buffer);
}
}
// put <h1> tags around content elements titles
if ($sefConfig->shPutH1Tags) {
if (strpos($buffer, 'class="componentheading') !== false) {
$buffer = preg_replace( '/<div class="componentheading([^>]*)>s*(.*)s*</div>/isU',
'<div class="componentheading$1><h1>$2</h1></div>', $buffer);
$buffer = preg_replace( '/<td class="contentheading([^>]*)>s*(.*)s*</td>/isU',
'<td class="contentheading$1><h2>$2</h2></td>', $buffer);
} else { // replace contentheading by h1
$buffer = preg_replace( '/<td class="contentheading([^>]*)>s*(.*)s*</td>/isU',
'<td class="contentheading$1><h1>$2</h1></td>', $buffer);
}
}
// version x : if multiple h1 headings, replace them by h2
if ($sefConfig->shMultipleH1ToH2 && substr_count( JString::strtolower($buffer), '<h1>') > 1) {
$buffer = str_replace( '<h1>', '<h2>', $buffer);
$buffer = str_replace( '<H1>', '<h2>', $buffer);
$buffer = str_replace( '</h1>', '</h2>', $buffer);
$buffer = str_replace( '</H1>', '</h2>', $buffer);
}
// V 1.3.1 : replace outbounds links by internal redirects
if (sh404SEF_REDIRECT_OUTBOUND_LINKS) {
$buffer = preg_replace_callback( '/<s*as*hrefs*=s*"(.*)"/isU',
'shDoRedirectOutboundLinksCallback', $buffer);
}
// V 1.3.1 : add symbol to outbounds links
if ($sefConfig->shInsertOutboundLinksImage) {
$buffer = preg_replace_callback( "/<s*as*hrefs*=s*("|').*("|')s*>.*</a>/isU",
'shDoInsertOutboundLinksImageCallback', $buffer);
}
// all done
return $buffer;
}
}
// begin main output --------------------------------------------------------
// check we are outputting document for real
$document = &JFactory::getDocument();
if ($document->getType() == 'html') {
$shPage = JResponse::getBody();
// do TITLE and DESCRIPTION and KEYWORDS and ROBOTS tags replacement
shDoTitleTags( $shPage);
if (SH_SHOW_CACHE_STATS)
$shPage .= shShowCacheStats();
JResponse::setBody($shPage);
}
// }
}
?>
prakash Friendprakash
- Join date:
- October 2008
- Posts:
- 439
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 146 times in 115 posts
November 26, 2009 at 3:38 am #325023Hi,
This would be your final shPageRewrite.php file
<?php
/**
* shCustomTags Joomla module : php module
* Copyright (C) 2006-2007 Yannick Gaultier (shumisha). All rights reserved.
* Released under the http://www.gnu.org/copyleft/gpl.html GNU/GPL, doc/license and credits.txt
* This is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
// V 1.2.4.t check if sh404SEF is running
if (function_exists('shLoadPluginlanguage')) {
// support for improved TITLE, DESCRIPTION, KEYWORDS and ROBOTS head tag
global $shCustomTitleTag, $shCustomDescriptionTag, $shCustomKeywordsTag,
$shCustomRobotsTag, $shCustomLangTag;
// these variables can be set throughout your php code in components, bots or other modules
// the last one wins !
function shCleanUpTitle( $title) {
//code modified by : Prakash R Balge.
//Author Website : http://www.classifiedsnext.com$testavaluetoday = htmlspecialchars($title);
$returnedvaluetoday = strpos($testavaluetoday,"[");
if ($returnedvaluetoday != 0){
$finalvalueretrievedtoday = substr($testavaluetoday,0,$returnedvaluetoday-1);
}
else{
$finalvalueretrievedtoday = htmlspecialchars($title);
}//end of code modified by : Prakash R Balge
return JString::trim(JString::trim(stripslashes(html_entity_decode($finalvalueretrievedtoday))), '"');}
function shCleanUpDesc( $desc) {
$desc = stripslashes(html_entity_decode(strip_tags($desc, '<br><br /><p></p>'), ENT_NOQUOTES));
$desc = str_replace('<br>',' - ', $desc); // otherwise, one word<br >another becomes onewordanother
$desc = str_replace('<br />',' - ', $desc);
$desc = str_replace('<p>',' - ', $desc);
$desc = str_replace('</p>',' - ', $desc);
while (strpos($desc, ' - - ') !== false) {
$desc = str_replace(' - - ', ' - ', $desc);
}
$desc = str_replace("'",''', $desc);
$desc = str_replace("'",''', $desc);
$desc = str_replace('"', ''', $desc);
$desc = str_replace("r",'', $desc);
$desc = str_replace("n",'', $desc);
return JString::substr( JString::trim($desc), 0, 512);
}
// utility function to insert data into an html buffer, after, instead or before
// one or more instances of a tag. If last parameter is 'first', then only the
// first occurence of the tag is replaced, or the new value is inserted only
// after or before the first occurence of the tag
function shInsertCustomTagInBuffer( $buffer, $tag, $where, $value, $firstOnly) {
if (!$buffer || !$tag || !$value) return $buffer;
$bits = explode($tag, $buffer);
if (count($bits) < 2) return $buffer;
$result = $bits[0];
$maxCount = count($bits)-1;
switch ($where) {
case 'instead' :
for ($i=0; $i < $maxCount; $i++) {
$result .= ($firstOnly == 'first' ? ($i==0 ? $value:$tag):$value).$bits[$i+1];
}
break;
case 'after' :
for ($i=0; $i < $maxCount; $i++) {
$result .= $tag.($firstOnly == 'first' ? ($i==0 ? $value:$tag):$value).$bits[$i+1];
}
break;
default :
for ($i=0; $i < $maxCount; $i++) {
$result .= ($firstOnly == 'first' ? ($i==0 ? $value:$tag):$value).$tag.$bits[$i+1];
}
break;
}
return $result;
}
function shDoLinkReadMoreCallback($matches) {
if (count($matches) != 3) return empty($matches) ? '' : $matches[0];
$mask = '<td class="contentheading" width="100%">%%shM1%%title="%%shTitle%%" class="readon">%%shM2%% [%%shTitle%%]</a>';
$result = str_replace('%%shM2%%', $matches[2], $mask);
// we may have captured more than we want, if there are several articles, but only the last one has
// a Read more link (first ones may be intro-only articles). Need to make sure we are fetching the right title
$otherArticles = explode( '<td class="contentheading" width="100%">', $matches[1]);
$articlesCount = count ($otherArticles);
$matches[1] = $otherArticles[$articlesCount-1];
unset($otherArticles[$articlesCount-1]);
$bits = explode ('class="contentpagetitle">', $matches[1]);
if (count ($bits) > 1) { // there is a linked title
$titleBits = array();
preg_match('/(.*)(<script|</a>)/isU', $bits[1], $titleBits); // extract title-may still have <h1> tags
$title = shCleanUpTitle( JString::trim($titleBits[1]));
} else { // title is not linked
$titleBits = array();
preg_match('/(.*)(<script|<as*href=|</td>)/isU', $matches[1], $titleBits); // extract title-may still have <h1> tags
$title = str_replace('<h1>', '', $titleBits[1]);
$title = str_replace('</h1>', '', $title);
$title = shCleanUpTitle( JString::trim($title));
}
$result = str_replace('%%shTitle%%', $title, $result);
// restore possible additionnal articles
$articles = implode( '<td class="contentheading" width="100%">', $otherArticles);
$matches[1] = (empty($articles) ? '': $articles . '<td class="contentheading" width="100%">') . $matches[1];
$result = str_replace('%%shM1%%', $matches[1], $result);
$result = str_replace('%%shM2%%', $matches[2], $result);
$result = str_replace( 'class="contentpagetitle">', 'title="'.$title.'" class="contentpagetitle">', $result);
return $result;
}
function shDoRedirectOutboundLinksCallback($matches) {
if (count($matches) != 2) return empty($matches) ? '' : $matches[0];
if (strpos($matches[1], $GLOBALS['shConfigLiveSite']) === false){
$mask = '<a href="'.$GLOBALS['shConfigLiveSite'].'/index.php?option=com_sh404sef&shtask=redirect&shtarget=%%shM1%%"';
$result = str_replace('%%shM1%%', $matches[1], $mask);
} else $result = $matches[0];
return $result;
}
function shDoInsertOutboundLinksImageCallback($matches) {
//if (count($matches) != 2 && count($matches) != 3) return empty($matches) ? '' : $matches[0];
$orig = $matches[0];
$bits = explode('href=', $orig);
$part2 = $bits[1]; // 2nd part, after the href=
$sep = substr($part2, 0, 1); // " or ' ?
$link = JString::trim($part2, $sep); // remove first " or '
if (empty($sep)) { // this should not happen, but it happens (Fireboard)
$result = $matches[0];
return $result;
}
$link = explode($sep, $link);
$link = $link[0]; // keep only the link
$shPageInfo = & shRouter::shPageInfo();
$sefConfig = & shRouter::shGetConfig();
if ( substr($link, 0, strlen($GLOBALS['shConfigLiveSite'])) != $GLOBALS['shConfigLiveSite']
&& substr($link, 0, 7) == 'http://'
&& substr($link, 0, strlen($shPageInfo->base)) != $shPageInfo->base){
$mask = '%%shM1%%href="%%shM2%%" %%shM3%% >%%shM4%%<img border="0" alt="%%shM5%%" src="'
.$GLOBALS['shConfigLiveSite'].'/components/com_sh404sef/images/'
.$sefConfig->shImageForOutboundLinks
.'"/></a>';
$result = str_replace('%%shM1%%', $bits[0], $mask);
$result = str_replace('%%shM2%%', $link, $result);
$m3 = str_replace($sep.$link.$sep, '', str_replace('</a>', '', $part2)); // remove link from part 2
$bits2 = explode('>', $m3);
$m3 = $bits2[0];
$result = str_replace('%%shM3%%', $m3, $result);
array_shift($bits2); // remove first bit
$m4 = implode($bits2, '>');
$result = str_replace('%%shM4%%', $m4, $result);
$m5 = strip_tags($m4);
$result = str_replace('%%shM5%%', $m5, $result);
} else $result = $matches[0];
return $result;
}
function shDoTitleTags( &$buffer) {
// Replace TITLE and DESCRIPTION and KEYWORDS
if (empty($buffer)) return;
global $shCustomTitleTag, $shCustomDescriptionTag, $shCustomKeywordsTag,
$shCustomRobotsTag, $shCustomLangTag, $shHomeLink,
$shMosConfig_lang, $shMosConfig_locale;
$database = & JFactory::getDBO();
$sefConfig = & shRouter::shGetConfig();
$shPageInfo = & shRouter::shPageInfo(); // get page details gathered by system plugin
// V 1.2.4.t protect against error if using shCustomtags without sh404SEF activated
// this should not happen, so we simply do nothing
if (!isset($sefConfig) || empty( $shPageInfo->shCurrentPageNonSef)) {
return;
}
// fix bug in Joomla search
//$shUri = null;
//$shOriginalUri = null;
//$buffer = str_replace( 'action="index.php"', 'action="'.shSefRelToabs('index.php', '', $shUri, $shUri, $shOriginalUri).'"', $buffer);
// check if there is a manually created set of tags from tags file
// need to get them from DB
if ($sefConfig->shMetaManagementActivated) {
// get header data set through Joomla
$document = & JFactory::getDocument();
$joomlaHead = $document->getHeadData();
$joomlaMetaData = $joomlaHead['metaTags']['standard'];
// plugin system to automatically build title and description tags on a component per component basis
$option = JRequest::getVar( 'option');
$shDoNotOverride = in_array( str_replace('com_', '', $option), $sefConfig->shDoNotOverrideOwnSef);
if ((file_exists(sh404SEF_ABS_PATH.'components/'.$option.'/meta_ext/'.$option.'.php'))
&& ($shDoNotOverride // and param said do not override
|| (!$shDoNotOverride // or param said override, but we don't have a plugin
&& !file_exists(sh404SEF_ABS_PATH.'components/com_sh404sef/meta_ext/'.$option.'.php')) )) {
_log('Loading component own meta plugin'); // Load the plug-in file
include(sh404SEF_ABS_PATH.'components/'.$option.'/meta_ext/'.$option.'.php');
} // then look for sh404SEF own plugin
else if (file_exists(sh404SEF_ABS_PATH.'components/com_sh404sef/meta_ext/'.$option.'.php')) {
_log('Loading built-in meta plugin');
include(sh404SEF_ABS_PATH.'components/com_sh404sef/meta_ext/'.$option.'.php');
}
// now read manually setup tags
if (shSortUrl($shPageInfo->shCurrentPageNonSef) == shCleanUpAnchor($shHomeLink)) { // V 1.2.4.t homepage custom tags
$sql = 'SELECT id, metadesc, metakey, metatitle, metalang, metarobots FROM #__sh404SEF_meta WHERE newurl = ''.sh404SEF_HOMEPAGE_CODE.''';
} else {
// V 1.2.4.t make sure we have lang info and properly sorted params
if (!preg_match( '/(&|?)lang={2,3}/iU', $shPageInfo->shCurrentPageNonSef)) { // no lang string, let's add default
$shTemp = explode( '_', $GLOBALS['shMosConfig_locale']);
$shLangTemp = $shTemp[0] ? $shTemp[0] : 'en';
$shPageInfo->shCurrentPageNonSef .= '&lang='.$shLangTemp;
}
$shPageInfo->shCurrentPageNonSef = shSortUrl($shPageInfo->shCurrentPageNonSef);
$sql = 'SELECT id, metadesc, metakey, metatitle, metalang, metarobots FROM #__sh404SEF_meta WHERE newurl = ''.ltrim($shPageInfo->shCurrentPageNonSef, '/').''';
}
$shCustomTags = null;
$database->setQuery($sql);
$shCustomTags = $database->loadObject();
if ( !empty($shCustomTags)) {
$shCustomTitleTag = !empty($shCustomTags->metatitle) ? $shCustomTags->metatitle : $shCustomTitleTag;
$shCustomDescriptionTag = !empty($shCustomTags->metadesc) ? $shCustomTags->metadesc : $shCustomDescriptionTag;
$shCustomKeywordsTag = !empty($shCustomTags->metakey) ? $shCustomTags->metakey : $shCustomKeywordsTag;
$shCustomRobotsTag = !empty($shCustomTags->metarobots) ? $shCustomTags->metarobots : $shCustomRobotsTag;
$shCustomLangTag = !empty($shCustomTags->metalang) ? $shCustomTags->metalang : $shCustomLangTag;
}
// then insert them in page
if (!is_null($shCustomTitleTag)) {
$buffer = preg_replace( '/<s*titles*>.*<s*/titles*>/isU', '<title>'
.shCleanUpTitle($sefConfig->prependToPageTitle.$shCustomTitleTag.$sefConfig->appendToPageTitle).'</title>', $buffer);
$buffer = preg_replace( '/<s*metas+names*=s*"title.*/>/isU', '', $buffer); // remove Joomla title meta
}
if (!is_null($shCustomDescriptionTag)) {
$buffer = preg_replace( '/<s*metas+names*=s*"description.*/>/isU', '<meta name="description" content="'
.shCleanUpDesc($shCustomDescriptionTag).'" />', $buffer);
}
if (!is_null($shCustomKeywordsTag)) {
$buffer = preg_replace( '/<s*metas+names*=s*"keywords.*/>/isU', '<meta name="keywords" content="'
.shCleanUpDesc($shCustomKeywordsTag).'" />', $buffer);
}
if (!is_null($shCustomRobotsTag)) {
if (strpos($buffer, '<meta name="robots" content="') !== false) {
$buffer = preg_replace( '/<s*metas+names*=s*"robots.*/>/isU', '<meta name="robots" content="'
.$shCustomRobotsTag.'" />', $buffer);
}
else if (!empty($shCustomRobotsTag)) {
$buffer = shInsertCustomTagInBuffer( $buffer, '</head>', 'before', '<meta name="robots" content="'
.$shCustomRobotsTag.'" />', 'first');
}
}
if (!is_null($shCustomLangTag)) {
$shLang = $shCustomLangTag;
}
else {
$shLang = $shMosConfig_locale;
}
if (strpos($buffer, '<meta http-equiv="Content-Language"') !== false) {
$buffer = preg_replace( '/<s*metas+http-equivs*=s*"Content-Language".*/>/isU', '<meta http-equiv="Content-Language" content="'.$shLang.'" />', $buffer);
}
else if (!empty($shCustomLangTag)) {
$buffer = shInsertCustomTagInBuffer( $buffer, '</head>', 'before', '<meta http-equiv="Content-Language" content="'.$shLang.'" />', 'first');
}
// remove Generator tag
if ($sefConfig->shRemoveGeneratorTag) {
$buffer = preg_replace( '/<metas*name="Generator"s*content=".*/>/isU','', $buffer);
}
// version x : add title to read on link
if ($sefConfig->shInsertReadMorePageTitle) {
if (strpos( $buffer, 'class="readon"') !== false) {
$buffer = preg_replace_callback( '/<td class="contentheading" width="100%">(.*)class="readon">(.*)</a>/isU',
'shDoLinkReadMoreCallback', $buffer);
}
}
// put <h1> tags around content elements titles
if ($sefConfig->shPutH1Tags) {
if (strpos($buffer, 'class="componentheading') !== false) {
$buffer = preg_replace( '/<div class="componentheading([^>]*)>s*(.*)s*</div>/isU',
'<div class="componentheading$1><h1>$2</h1></div>', $buffer);
$buffer = preg_replace( '/<td class="contentheading([^>]*)>s*(.*)s*</td>/isU',
'<td class="contentheading$1><h2>$2</h2></td>', $buffer);
} else { // replace contentheading by h1
$buffer = preg_replace( '/<td class="contentheading([^>]*)>s*(.*)s*</td>/isU',
'<td class="contentheading$1><h1>$2</h1></td>', $buffer);
}
}
// version x : if multiple h1 headings, replace them by h2
if ($sefConfig->shMultipleH1ToH2 && substr_count( JString::strtolower($buffer), '<h1>') > 1) {
$buffer = str_replace( '<h1>', '<h2>', $buffer);
$buffer = str_replace( '<H1>', '<h2>', $buffer);
$buffer = str_replace( '</h1>', '</h2>', $buffer);
$buffer = str_replace( '</H1>', '</h2>', $buffer);
}
// V 1.3.1 : replace outbounds links by internal redirects
if (sh404SEF_REDIRECT_OUTBOUND_LINKS) {
$buffer = preg_replace_callback( '/<s*as*hrefs*=s*"(.*)"/isU',
'shDoRedirectOutboundLinksCallback', $buffer);
}
// V 1.3.1 : add symbol to outbounds links
if ($sefConfig->shInsertOutboundLinksImage) {
$buffer = preg_replace_callback( "/<s*as*hrefs*=s*("|').*("|')s*>.*</a>/isU",
'shDoInsertOutboundLinksImageCallback', $buffer);
}
// all done
return $buffer;
}
}
// begin main output --------------------------------------------------------
// check we are outputting document for real
$document = &JFactory::getDocument();
if ($document->getType() == 'html') {
$shPage = JResponse::getBody();
// do TITLE and DESCRIPTION and KEYWORDS and ROBOTS tags replacement
shDoTitleTags( $shPage);
if (SH_SHOW_CACHE_STATS)
$shPage .= shShowCacheStats();
JResponse::setBody($shPage);
}
// }
}
?>
1 user says Thank You to prakash for this useful post
nigelmaine Friendnigelmaine
- Join date:
- September 2008
- Posts:
- 71
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 38
- Thanked:
- 3 times in 1 posts
November 27, 2009 at 9:43 am #325119Hi
You are a star.
Many, many thanks for all your help.
It is all working now. One last question though. Is there any way of omitting the word “Module” before the menu name on the Xmap?
Once again, thank you for your efforts, you’re very kind.
Regards
Nigel Maine
prakash Friendprakash
- Join date:
- October 2008
- Posts:
- 439
- Downloads:
- 0
- Uploads:
- 1
- Thanks:
- 2
- Thanked:
- 146 times in 115 posts
November 27, 2009 at 9:53 am #325120Hi
Great to know that it worked fine.
I did not get your query regarding – “Module” before menu name?
Can you please explain possibly via a screen shot or live url?
Thanks
-
AuthorPosts
This topic contains 19 replies, has 4 voices, and was last updated by socoweb 14 years, 10 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum