Location: PHPKode > scripts > XMap > xmap/app.xnavigator.php
<?PHP

/**
  * XNavigator - a XMap Application to help visitor to find where he is
  *
  * Get name elements and print out them together a link.
  *
  * @author             Roberto Bertó, darkelder (inside) users (dot) sourceforge (dot) net
  * @version            0.1
  * @copyright          LGPL
  * @package            XMap
  * @subpackage         XNavigator
  */

class XNavigator extends XMap
{
        /**
          * define the way you will show the sitemap
          *
          * %element% will be changed by the element content according $XMap->elements and Id attribute too
          *
          * @access             public
          * @var                string                  default = '<a href="%url%">%name%</a>'
          */
        var $XNavigatorShow                     =       '<a href="%url%">%name%</a>';

        /**
          * element separator
          *
          * @access             public
          * @var                string                  default = "|"
          */
        var $XNavigatorSeparator                =       ' | ';

        /**
          * here element show
          *
          * same format of $XNavigatorShow
          *
          * @access             public
          * @var                string                  default = '<b><a href="%url%">%name%</a></b>'
          */
        var $XNavigatorHereShow         =       '<b><a href="%url%">%name%</a></b>';

        /**
          * what is the current element id?
          *
          * @access             public
          * @var                string
          */
        var $XNavigatorId                       =       '';


        /**
          * XNavigator creator
          *
          * Try use print $XMap->XNavigatorCreator();
          * @access             public
          * @return             string                  its the html code generated
          */
        function XNavigatorCreator()
        {
                // getting the ancestor in inverse order
                $sitemap = $this->Get("ancestor",$this->XNavigatorId,TRUE);

                // we will use it for join, a nice tip of day :-)
                $arraymap = array();

                foreach ($sitemap as $id => $map)
                {
                        // every element can be passed here
                        $this->XNavigatorChange($this->XNavigatorShow,$id,$map,$arraymap);
                }

                $sitemap = $this->Get("here",$this->XNavigatorId);
                $this->XNavigatorChange($this->XNavigatorHereShow,$this->XNavigatorId,$sitemap["{$this->XNavigatorId}"],$arraymap);
                return join($this->XNavigatorSeparator,$arraymap);
        }

        /**
          * Function used twince to change %elements%
          *
          * @access             private
          * @param              string                  $html                   Original html code
          * @param              string                  $id                     Current Id
          * @param              string                  $map                    Map of current Id
          * @param              array                   $arraymap               It will return on it
          */
        function XNavigatorChange($html,$id,$map,&$arraymap)
        {
                $arraymap["$id"] = $html;
                foreach ($this->elements as $element)
                {
                        // take a look!
                        $arraymap["$id"] = preg_replace("/%" . $element . "%/s",$map["$element"],$arraymap["$id"]);
                }
                // id will be parsed too
                $arraymap["$id"] = preg_replace("/%id%/s",$id,$arraymap["$id"]);

        }
}

?>
Return current item: XMap