diff --git a/phpxpress/examples/breadcrumb.php b/phpxpress/examples/breadcrumb.php new file mode 100644 index 0000000..e2eca44 --- /dev/null +++ b/phpxpress/examples/breadcrumb.php @@ -0,0 +1,20 @@ + + + Card example + + + setDataSource($links); + $breadcrumb->draw(); + + ?> + + \ No newline at end of file diff --git a/phpxpress/phpxpress/breadcrumb.php b/phpxpress/phpxpress/breadcrumb.php new file mode 100644 index 0000000..fe8cfd3 --- /dev/null +++ b/phpxpress/phpxpress/breadcrumb.php @@ -0,0 +1,94 @@ + "xyz.com/home" , "Starred" => "xyz.com/home/starred", "Reading" => "xyz.com/home/starred/reading"); + ** Will produce: + ** Home / Starred / Reading + */ + function setDataSource($dataSource){ + if(!is_array($dataSource)) + throw new InvalidArgumentException('Parameter dataSource must be an array.'); + + foreach($dataSource as $caption => $link){ + $this->addElement($caption, $link); + } + } + + /* + ** Adds an element at the end of the Breadcrumb + */ + function addElement($caption, $link){ + + if(isset($this->locations)) + $this->locations[$caption] = $link; + + else + $this->locations = array($caption => $link); + + $this->activeLocation = $caption; + } + + /* + ** You can specify either a scalar (the (n-1)th to be activated) + ** or a string (the caption to be activated) + */ + function setActiveLocation($activeLocation){ + + if(!is_scalar($activeLocation) && !is_string($activeLocation)) + throw new InvalidArgumentException('Parameter activeLocation can be either an int or a string. None of these provided.'); + + $this->activeLocation = $activeLocation; + } + + function setDivider($divider){ + $this->divider = $divider; + } + + function draw(){ + + $iterator = 0; + + if(!isset($this->divider)) + echo '