- Timestamp:
- 04/26/10 17:08:58 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
plugins/apostrophePlugin/trunk/lib/model/doctrine/PluginaPage.class.php
r970 r1065 570 570 protected $ancestorsInfo; 571 571 572 public function getAncestorsInfo( )572 public function getAncestorsInfo($includeSelf = false) 573 573 { 574 574 if (!isset($this->ancestorsInfo)) … … 577 577 // Since our presence on an admin page implies we know about it, it's OK to include 578 578 // admin pages in the breadcrumb. It's not OK in other navigation 579 $this->ancestorsInfo = $this->getPagesInfo(false, '( p.lft < ' . $this->lft . ' AND p.rgt > ' . $this->rgt . ' )', true); 579 $less = '<'; 580 $greater = '>'; 581 if ($includeSelf) 582 { 583 $less = '<='; 584 $greater = '>='; 585 } 586 $this->ancestorsInfo = $this->getPagesInfo(false, "( p.lft $less " . $this->lft . " AND p.rgt $greater " . $this->rgt . ' )', true); 580 587 } 581 588 return $this->ancestorsInfo; … … 602 609 { 603 610 // It's the home page. Return a stub: the home page is its only peer 604 $this->peerInfo = array( array('id' => $this->id, 'title' => $this->getTitle(), 'slug' => $this->slug, 'view_is_secure' => $this->view_is_secure, 'archived' => $this->archived, 'level' => $this->level, 'lft' => $this->lft, 'rgt' => $this->rgt));611 $this->peerInfo = array($this->getInfo()); 605 612 } 606 613 else … … 615 622 } 616 623 624 // Sometimes it is useful to have an info structure describing a page object 625 // (the aNavigation classes exploit this) 626 627 public function getInfo() 628 { 629 return array('id' => $this->id, 'title' => $this->getTitle(), 'slug' => $this->slug, 'view_is_secure' => $this->view_is_secure, 'archived' => $this->archived, 'level' => $this->level, 'lft' => $this->lft, 'rgt' => $this->rgt); 630 } 631 617 632 protected $childrenInfo; 618 633 … … 709 724 // Two 710 725 726 // You can now specify the root slug, which defaults to the home page. 727 711 728 // Note that children of Two, 1a, and 1c are NOT returned. Only the siblings of 712 729 // the current page's ancestors, the current page and its siblings, and the immediate 713 730 // children of the current page are returned. For a full tree use getTreeInfo(). 714 731 715 public function getAccordionInfo($livingOnly = true, $depth = null )732 public function getAccordionInfo($livingOnly = true, $depth = null, $root = '/') 716 733 { 717 734 // As far as I can tell there is no super-elegant, single-query way to do this … … 724 741 // an accordion contro. in the first place 725 742 $ancestors = $this->getAncestorsInfo(); 743 744 // Dump ancestors we don't care about 745 for ($i = 0; ($i < count($ancestors)); $i++) 746 { 747 if ($ancestors[$i]['slug'] === $root) 748 { 749 $ancestors = array_slice($ancestors, $i); 750 break; 751 } 752 } 753 if ($i === count($ancestors)) 754 { 755 throw new sfException("Root slug $root never found among ancestors in getAccordionInfo"); 756 } 726 757 $result = array(); 727 758 // Ancestor levels

