PHP Classes

File: breadCrumbs.php

Recommend this page to a friend!
  Classes of Tofeeq ur Rehman   Bread crumbs   breadCrumbs.php   Download  
File: breadCrumbs.php
Role: Class source
Content type: text/plain
Description: generate breadcrumbs for seo sites
Class: Bread crumbs
Generate breadcrumb links from page URI
Author: By
Last change: more flexible to adopt
Date: 15 years ago
Size: 1,673 bytes
 

Contents

Class file image Download
<?php
/*
@Taufeeq ur Rehman
@Sat Feb 16 11:52:10 PST 2008 11:52:10
@Class:breadcrumbs to keep track of what user has been visited.
@A facility which will show the customer what steps they have
    taken to get to their current location
*/
class breadCrumbs{
    var
$site_root;
    var
$site_name;
    var
$css_class;
   
#constructor
   
function breadCrumbs($site_root,$site_name,$css_class){
       
$this->site_root = $site_root;
       
$this->site_name = $site_name;
       
$this->css_class = $css_class;
    }
   
#~desctructor
   
function _breadCrumbs(){
        unset(
$this->site_root,$this->site_name,$this->css_class);
    }
   
    function
getBreadCrumbs(){
        if(
strpos($_SERVER['REQUEST_URI'],".php"))return false;
        if(
$this->site_name != '/')
           
$uri = str_replace("/".$this->site_name."/","",$_SERVER['REQUEST_URI']);
        else
           
$uri = ltrim($_SERVER['REQUEST_URI'],"/");
       
       
$uri = split("\?",$uri);
       
$args = $uri[1];
       
$uri = $uri[0];
       
       
$pos = strpos($uri,".html");
       
$slash="";
        if(
substr($uri,strlen($uri)-1,strlen($uri)) == '/')
       
$slash = '/';
       
       
$uri = explode("/",rtrim($uri,"/"));
       
//echo '<p><pre>'; var_export($uri);echo '</pre></p>';
       
$url = '<a class="'.$this->css_class.'" href="'.$this->site_root.'">Home</a> > ';
       
$href = "";
        for(
$i=0; $i<count($uri); $i++){
           
$s = "";
            if(
$i == (count($uri)-1)) $s = $slash;
            else if((
strpos($uri[$i+1],".html") === false)) $s = '/';
            if(
strpos($uri[$i],".html") !== false) $href.="/";
           
$href.=$uri[$i].$s;
           
$url.= '<a href="'.$this->site_root.$href.'" class="'.$this->css_class.'">'.trim($uri[$i],"/").'</a> > ';
        }
       
$url = substr($url,0,(strlen($url)-3));
        return
$url;
    }
}
?>