silverstripe-cms/code/Controllers/CMSPagesController.php

69 lines
1.8 KiB
PHP
Raw Normal View History

2011-04-20 22:50:13 +02:00
<?php
2016-07-22 01:32:32 +02:00
namespace SilverStripe\CMS\Controllers;
use SilverStripe\ORM\DataObject;
2016-07-22 01:32:32 +02:00
use stdClass;
use Controller;
use ArrayData;
/**
* @package cms
*/
2011-04-20 22:50:13 +02:00
class CMSPagesController extends CMSMain {
2015-09-29 06:18:03 +02:00
private static $url_segment = 'pages';
private static $url_rule = '/$Action/$ID/$OtherID';
private static $url_priority = 40;
2015-09-29 06:18:03 +02:00
private static $menu_title = 'Pages';
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
2016-07-22 01:32:32 +02:00
private static $session_namespace = 'SilverStripe\\CMS\\Controllers\\CMSMain';
public function LinkPreview() {
return false;
}
/**
* @return string
*/
public function ViewState() {
return $this->getRequest()->getVar('view');
}
public function isCurrentPage(DataObject $record) {
return false;
}
2012-04-18 21:14:14 +02:00
public function Breadcrumbs($unlinked = false) {
$items = parent::Breadcrumbs($unlinked);
//special case for building the breadcrumbs when calling the listchildren Pages ListView action
if($parentID = $this->getRequest()->getVar('ParentID')) {
2016-07-22 01:32:32 +02:00
$page = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $parentID);
2012-04-18 21:14:14 +02:00
//build a reversed list of the parent tree
$pages = array();
while($page) {
array_unshift($pages, $page); //add to start of array so that array is in reverse order
$page = $page->Parent;
}
//turns the title and link of the breadcrumbs into template-friendly variables
$params = array_filter(array(
'view' => $this->getRequest()->getVar('view'),
'q' => $this->getRequest()->getVar('q')
2012-04-18 21:14:14 +02:00
));
foreach($pages as $page) {
$params['ParentID'] = $page->ID;
2016-07-22 01:32:32 +02:00
$item = new stdClass();
2012-04-18 21:14:14 +02:00
$item->Title = $page->Title;
$item->Link = Controller::join_links($this->Link(), '?' . http_build_query($params));
$items->push(new ArrayData($item));
}
}
return $items;
}
}