test
Viewing 4 posts - 16 through 19 (of 19 total)
  • Author
    Posts
  • Arvind Chauhan Moderator
    #325391

    Try looking at this thread. http://www.joomlart.com/forums/showpost.php?p=154170&postcount=5

    it has edited xmap file.

    Arvind

    brunus Friend
    #327178

    <em>@korb 154058 wrote:</em><blockquote>Hey mate,
    Where is the code you added to mek it work? I want to test it on my localhost with my x-map version.

    Thanks</blockquote>

    The code provided a few post above is not compatible with the last xmap release.
    This last xmap release deals with a caracter encoding problem, displaying correctly ” caracters for exemple, but when inserting the pacth provided in this thread, it’s breaking the initiale correction in xmap.htpl.php from the last release.

    Will try to provide a nex patch.

    brunus Friend
    #327266

    This is working with the last Xmap (please check the date in the first comment in the code) release and also, it takes care about special caracters in sections, categories and articles titles (also for virtuemart products). I’m not an experimented php coder, then, I’m can’t say this code will work in any case…

    The initial code is coming from the last Xmap release, Xmap 1.2.5.

    Comparing with the last patch provided in this thread, I only added this to avoid problems with special caracters :
    (line 74) $finalvalueretrievedtoday = htmlspecialchars_decode($finalvalueretrievedtoday);

    <?php
    /**
    * $Id: xmap.html.php 66 2009-11-26 18:54:14Z guilleva $
    * $LastChangedDate: 2009-11-26 12:54:14 -0600 (Thu, 26 Nov 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);
    $testavaluetoday = htmlspecialchars($node->name);
    $returnedvaluetoday = strpos($testavaluetoday,"[");
    if ($returnedvaluetoday != 0){
    $finalvalueretrievedtoday = substr($testavaluetoday,0,$returnedvaluetoday);
    }
    else{
    $finalvalueretrievedtoday = htmlspecialchars($node->name);
    }
    $finalvalueretrievedtoday = htmlspecialchars_decode($finalvalueretrievedtoday);
    switch( $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" />';
    }
    $out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'" target="_blank">'. $finalvalueretrievedtoday . $ext_image .'</a>';
    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" />';
    }
    $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>";
    break;

    case 3: // no link
    $out .= '<span>'. $finalvalueretrievedtoday .'</span>';
    break;

    default: // open url in parent window
    $out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'">'. $finalvalueretrievedtoday .'</a>';
    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: Advertisement

    echo "</div>";
    echo "</div>n";
    }

    function startMenu(&$menu) {
    // Initialize them on each menu
    $this->_parent_children=array();
    $this->_last_child=array();
    $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";
    }

    }
    }
    }

    viet4777 Friend
    #328161

    This is a modify for /components/com_xmap/xmap.php ($Id: xmap.php 85 2010-01-01 12:05:05Z), I just update the latest X-map component.

    Hope this help.

    Here is the full code and demo at http://viet4777.vatlieu.us/sitemap.html

    From line 367: add these lines
    //Parse title and remove the options & description which configure for mega menu.
    $title = $node->name;
    $title = str_replace (array('\[','\]'), array('%open%', '%close%'), $title);
    $regex = '/([^[]*)[([^]]*)](.*)$/';
    if (preg_match ($regex, $title, $matches)) {
    $title = $matches[1];
    } else {
    $title = $title;
    }
    $title = str_replace (array('%open%', '%close%'), array('[',']'), $title);
    $node->name = $title;

    <em>@brunus 157730 wrote:</em><blockquote>This is working with the last Xmap (please check the date in the first comment in the code) release and also, it takes care about special caracters in sections, categories and articles titles (also for virtuemart products). I’m not an experimented php coder, then, I’m can’t say this code will work in any case…

    The initial code is coming from the last Xmap release, Xmap 1.2.5.

    Comparing with the last patch provided in this thread, I only added this to avoid problems with special caracters :
    (line 74) $finalvalueretrievedtoday = htmlspecialchars_decode($finalvalueretrievedtoday);

    <?php
    /**
    * $Id: xmap.html.php 66 2009-11-26 18:54:14Z guilleva $
    * $LastChangedDate: 2009-11-26 12:54:14 -0600 (Thu, 26 Nov 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);
    $testavaluetoday = htmlspecialchars($node->name);
    $returnedvaluetoday = strpos($testavaluetoday,"[");
    if ($returnedvaluetoday != 0){
    $finalvalueretrievedtoday = substr($testavaluetoday,0,$returnedvaluetoday);
    }
    else{
    $finalvalueretrievedtoday = htmlspecialchars($node->name);
    }
    $finalvalueretrievedtoday = htmlspecialchars_decode($finalvalueretrievedtoday);
    switch( $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" />';
    }
    $out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'" target="_blank">'. $finalvalueretrievedtoday . $ext_image .'</a>';
    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" />';
    }
    $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>";
    break;

    case 3: // no link
    $out .= '<span>'. $finalvalueretrievedtoday .'</span>';
    break;

    default: // open url in parent window
    $out .= '<a href="'. $link .'" title="'. $finalvalueretrievedtoday .'">'. $finalvalueretrievedtoday .'</a>';
    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: Advertisement

    echo "</div>";
    echo "</div>n";
    }

    function startMenu(&$menu) {
    // Initialize them on each menu
    $this->_parent_children=array();
    $this->_last_child=array();
    $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";
    }

    }
    }
    }

    </blockquote>


    1. xmap-viet4777.zip
Viewing 4 posts - 16 through 19 (of 19 total)

This topic contains 19 replies, has 6 voices, and was last updated by  viet4777 14 years, 11 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum