Lançado Adianti Framework 7.6!
Clique aqui para saber mais
menu

Adianti Solutions

API

Adianti, Framework, PHP, MVC, Active record, Front controller, IDE, RAD, Web, multiplataforma, geração de código, desenvolvimento rápido, relatórios, formulários, listagens, datagrids, gráficos, banco de dados, padrões de projeto, design patterns API do Adianti Framework.
API Docs
code
Selecione a classe

Source for file TBreadCrumb.php

Documentation is available at TBreadCrumb.php

  1. <?php
  2. namespace Adianti\Widget\Util;
  3.  
  4. use Adianti\Widget\Base\TElement;
  5.  
  6. /**
  7.  * BreadCrumb
  8.  *
  9.  * @version    7.4
  10.  * @package    widget
  11.  * @subpackage util
  12.  * @author     Pablo Dall'Oglio
  13.  * @author     Nataniel Rabaioli
  14.  * @copyright  Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
  15.  * @license    http://www.adianti.com.br/framework-license
  16.  */
  17. class TBreadCrumb extends TElement
  18. {
  19.     protected static $homeController;
  20.     protected $container;
  21.     protected $items;
  22.     
  23.     /**
  24.      * Handle paths from a XML file
  25.      * @param $xml_file path for the file
  26.      */
  27.     public function __construct()
  28.     {
  29.         parent::__construct('div');
  30.         $this->{'id''div_breadcrumbs';
  31.         
  32.         $this->container = new TElement('ol');
  33.         $this->container->{'class''tbreadcrumb';
  34.         parent::add$this->container );
  35.     }
  36.     
  37.     /**
  38.      * Static constructor
  39.      */
  40.     public static function create$options$home true)
  41.     {
  42.         $breadcrumb new TBreadCrumb;
  43.         if ($home)
  44.         {
  45.             $breadcrumb->addHome();
  46.         }
  47.         foreach ($options as $option)
  48.         {
  49.             $breadcrumb->addItem$option );
  50.         }
  51.         return $breadcrumb;
  52.     }
  53.     
  54.     /**
  55.      * Add the home icon
  56.      */
  57.     public function addHome()
  58.     {
  59.         $li new TElement('li');
  60.         $li->{'class''home';
  61.         $a new TElement('a');
  62.         $a->generator 'adianti';
  63.         
  64.         if (self::$homeController)
  65.         {
  66.             $a->{'href''engine.php?class='.self::$homeController;
  67.         }
  68.         else
  69.         {
  70.             $a->{'href''engine.php';
  71.         }
  72.         
  73.         $a->{'title''Home';
  74.         
  75.         $li->add$a );
  76.         $this->container->add$li );
  77.     }
  78.     
  79.     /**
  80.      * Add an item
  81.      * @param $path Path to be shown
  82.      * @param $last If the item is the last one
  83.      */
  84.     public function addItem($path$last FALSE)
  85.     {
  86.         $li new TElement('li');
  87.         $this->container->add$li );
  88.         
  89.         $span new TElement('span');
  90.         $span->add$path );
  91.         
  92.         $this->items[$path$span;
  93.         if$last )
  94.         {
  95.             $li->add$span );
  96.         }
  97.         else
  98.         {
  99.             $a new TElement('a');
  100.             
  101.             $li->add$a );
  102.             $a->add$span );
  103.         }
  104.             
  105.     }
  106.     
  107.     /**
  108.      * Mark one breadcrumb item as selected
  109.      */
  110.     public function select($path)
  111.     {
  112.         foreach ($this->items as $key => $span)
  113.         {
  114.             if ($key == $path)
  115.             {
  116.                 $span->{'class''selected';
  117.             }
  118.             else
  119.             {
  120.                 $span->{'class''';
  121.             }
  122.         }
  123.     }
  124.     
  125.     /**
  126.      * Define the home controller
  127.      * @param $class Home controller class
  128.      */
  129.     public static function setHomeController($className)
  130.     {
  131.         self::$homeController $className;
  132.     }
  133. }