2011-04-20 22:50:13 +02:00
|
|
|
<?php
|
2011-08-19 02:32:31 +02:00
|
|
|
|
2016-07-22 01:32:32 +02:00
|
|
|
namespace SilverStripe\CMS\Controllers;
|
|
|
|
|
2016-08-10 06:08:39 +02:00
|
|
|
use SilverStripe\CMS\Model\SiteTree;
|
2016-08-23 04:36:06 +02:00
|
|
|
use SilverStripe\Control\Controller;
|
2016-06-16 06:57:19 +02:00
|
|
|
use SilverStripe\ORM\DataObject;
|
2016-08-23 04:36:06 +02:00
|
|
|
use SilverStripe\View\ArrayData;
|
2016-07-22 01:32:32 +02:00
|
|
|
use stdClass;
|
2016-06-16 06:57:19 +02:00
|
|
|
|
2011-04-20 22:50:13 +02:00
|
|
|
class CMSPagesController extends CMSMain {
|
2015-09-29 06:18:03 +02:00
|
|
|
|
2013-03-18 11:47:15 +01:00
|
|
|
private static $url_segment = 'pages';
|
2016-08-10 06:08:39 +02:00
|
|
|
|
2013-03-18 11:47:15 +01:00
|
|
|
private static $url_rule = '/$Action/$ID/$OtherID';
|
2016-08-10 06:08:39 +02:00
|
|
|
|
2013-03-18 11:47:15 +01:00
|
|
|
private static $url_priority = 40;
|
2016-08-10 06:08:39 +02:00
|
|
|
|
2015-09-29 06:18:03 +02:00
|
|
|
private static $menu_title = 'Pages';
|
2016-08-10 06:08:39 +02:00
|
|
|
|
2013-03-18 11:47:15 +01:00
|
|
|
private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
|
2012-04-17 22:27:47 +02:00
|
|
|
|
2012-09-19 12:07:46 +02:00
|
|
|
public function LinkPreview() {
|
2011-10-29 19:13:19 +02:00
|
|
|
return false;
|
|
|
|
}
|
2012-02-14 16:00:48 +01:00
|
|
|
|
2012-05-30 16:04:51 +02:00
|
|
|
/**
|
2015-09-28 11:31:31 +02:00
|
|
|
* @return string
|
2012-05-30 16:04:51 +02:00
|
|
|
*/
|
|
|
|
public function ViewState() {
|
2015-04-30 01:04:02 +02:00
|
|
|
return $this->getRequest()->getVar('view');
|
2012-05-30 16:04:51 +02:00
|
|
|
}
|
|
|
|
|
2012-04-17 22:27:47 +02:00
|
|
|
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
|
2015-04-30 01:04:02 +02:00
|
|
|
if($parentID = $this->getRequest()->getVar('ParentID')) {
|
2016-08-10 06:08:39 +02:00
|
|
|
$page = SiteTree::get()->byID($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(
|
2015-04-30 01:04:02 +02:00
|
|
|
'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;
|
|
|
|
|
|
|
|
}
|
2012-04-12 09:23:20 +02:00
|
|
|
}
|