API CHANGE Combined "Pages" and "Edit Page" into a single menu entry

ENHANCEMENT Namespaced tree search parameters in CMSMain, in order to detect more reliably if a filter has been applied. Changing page search form to standard pushState behaviour, same as ModelAdmin (for both tree and list view).
MINOR Refactored list view loading
This commit is contained in:
Ingo Schommer 2012-04-16 15:55:19 +02:00
parent dcdb0b4731
commit 6aeac37906
22 changed files with 314 additions and 312 deletions

View File

@ -37,6 +37,7 @@ ShortcodeParser::get('default')->register('sitetree_link', array('SiteTree', 'li
Object::add_extension('File', 'SiteTreeFileExtension'); Object::add_extension('File', 'SiteTreeFileExtension');
// TODO Remove once we can configure CMSMenu through static, nested configuration files // TODO Remove once we can configure CMSMenu through static, nested configuration files
CMSMenu::remove_menu_item('CMSMain');
CMSMenu::remove_menu_item('CMSPageEditController'); CMSMenu::remove_menu_item('CMSPageEditController');
CMSMenu::remove_menu_item('CMSPageSettingsController'); CMSMenu::remove_menu_item('CMSPageSettingsController');
CMSMenu::remove_menu_item('CMSPageHistoryController'); CMSMenu::remove_menu_item('CMSPageHistoryController');

View File

@ -11,13 +11,13 @@
*/ */
class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider { class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider {
static $url_segment = 'page'; static $url_segment = 'pages';
static $url_rule = '/$Action/$ID/$OtherID'; static $url_rule = '/$Action/$ID/$OtherID';
// Maintain a lower priority than other administration sections // Maintain a lower priority than other administration sections
// so that Director does not think they are actions of CMSMain // so that Director does not think they are actions of CMSMain
static $url_priority = 40; static $url_priority = 39;
static $menu_title = 'Edit Page'; static $menu_title = 'Edit Page';
@ -43,9 +43,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'SiteTreeAsUL', 'SiteTreeAsUL',
'getshowdeletedsubtree', 'getshowdeletedsubtree',
'batchactions', 'batchactions',
'ListView', 'treeview',
'getListView', 'listview',
'listchildren', 'ListViewForm',
); );
public function init() { public function init() {
@ -79,6 +79,23 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
CMSBatchActionHandler::register('deletefromlive', 'CMSBatchAction_DeleteFromLive'); CMSBatchActionHandler::register('deletefromlive', 'CMSBatchAction_DeleteFromLive');
} }
function index($request) {
// In case we're not showing a specific record, explicitly remove any session state,
// to avoid it being highlighted in the tree, and causing an edit form to show.
if(!$request->param('Action')) $this->setCurrentPageId(null);
return parent::index($request);
}
protected function getResponseNegotiator() {
$negotiator = parent::getResponseNegotiator();
$controller = $this;
$negotiator->setCallback('ListViewForm', function() use(&$controller) {
return $controller->ListViewForm()->forTemplate();
});
return $negotiator;
}
/** /**
* If this is set to true, the "switchView" context in the * If this is set to true, the "switchView" context in the
* template is shown, with links to the staging and publish site. * template is shown, with links to the staging and publish site.
@ -124,6 +141,62 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
); );
} }
public function LinkPages() {
return singleton('CMSPagesController')->Link();
}
public function LinkTreeView() {
return $this->LinkWithSearch(singleton('CMSMain')->Link('treeview'));
}
public function LinkListView() {
return $this->LinkWithSearch(singleton('CMSMain')->Link('listview'));
}
public function LinkGalleryView() {
return $this->LinkWithSearch(singleton('CMSMain')->Link('galleryview'));
}
public function LinkPageEdit() {
if($id = $this->currentPageID()) {
return $this->LinkWithSearch(
Controller::join_links(singleton('CMSPageEditController')->Link('show'), $id)
);
}
}
public function LinkPageSettings() {
if($id = $this->currentPageID()) {
return $this->LinkWithSearch(
Controller::join_links(singleton('CMSPageSettingsController')->Link('show'), $id)
);
}
}
public function LinkPageHistory() {
if($id = $this->currentPageID()) {
return $this->LinkWithSearch(
Controller::join_links(singleton('CMSPageHistoryController')->Link('show'), $id)
);
}
}
protected function LinkWithSearch($link) {
// Whitelist to avoid side effects
$params = array(
'q' => (array)$this->request->getVar('q'),
'ParentID' => $this->request->getVar('ParentID')
);
return Controller::join_links(
$link,
array_filter(array_values($params)) ? '?' . http_build_query($params) : null
);
}
function LinkPageAdd() {
return singleton("CMSPageAddController")->Link();
}
/** /**
* @return string * @return string
*/ */
@ -156,6 +229,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return $html; return $html;
} }
/**
* @return boolean
*/
public function TreeIsFiltered() {
return $this->request->getVar('q');
}
function SearchForm() { function SearchForm() {
// get all page types in a dropdown-compatible format // get all page types in a dropdown-compatible format
$pageTypes = SiteTree::page_type_classes(); $pageTypes = SiteTree::page_type_classes();
@ -177,19 +257,19 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
); );
$fields = new FieldList( $fields = new FieldList(
new TextField('Term', _t('CMSSearch.FILTERLABELTEXT', 'Content')), new TextField('q[Term]', _t('CMSSearch.FILTERLABELTEXT', 'Content')),
$dateGroup = new FieldGroup( $dateGroup = new FieldGroup(
new HeaderField('Date', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4), new HeaderField('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4),
$dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FILTERDATEFROM', 'From')), $dateFrom = new DateField('q[LastEditedFrom]', _t('CMSSearch.FILTERDATEFROM', 'From')),
$dateTo = new DateField('LastEditedTo', _t('CMSSearch.FILTERDATETO', 'To')) $dateTo = new DateField('q[LastEditedTo]', _t('CMSSearch.FILTERDATETO', 'To'))
), ),
new DropdownField( new DropdownField(
'FilterClass', 'q[FilterClass]',
_t('CMSMain.PAGES', 'Pages'), _t('CMSMain.PAGES', 'Pages'),
$filterMap $filterMap
), ),
new DropdownField( new DropdownField(
'ClassName', 'q[ClassName]',
_t('CMSMain.PAGETYPEOPT','Page Type', 'Dropdown for limiting search to a page type'), _t('CMSMain.PAGETYPEOPT','Page Type', 'Dropdown for limiting search to a page type'),
$pageTypes, $pageTypes,
null, null,
@ -211,10 +291,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// Use <button> to allow full jQuery UI styling // Use <button> to allow full jQuery UI styling
foreach($actions->dataFields() as $action) $action->setUseButtonTag(true); foreach($actions->dataFields() as $action) $action->setUseButtonTag(true);
$form = new Form($this, 'SearchForm', $fields, $actions); $form = Form::create($this, 'SearchForm', $fields, $actions)
$form->setFormMethod('GET'); ->addExtraClass('cms-search-form')
$form->disableSecurityToken(); ->setFormMethod('GET')
$form->unsetValidator(); ->setFormAction($this->Link())
->disableSecurityToken()
->unsetValidator();
$form->loadDataFrom($this->request->getVars());
return $form; return $form;
} }
@ -527,7 +610,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
// TODO Can't merge $FormAttributes in template at the moment // TODO Can't merge $FormAttributes in template at the moment
$form->addExtraClass('center ss-tabset ' . $this->BaseCSSClasses()); $form->addExtraClass('center ss-tabset ' . $this->BaseCSSClasses());
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet'); // if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
if(!$record->canEdit() || $deletedFromStage) { if(!$record->canEdit() || $deletedFromStage) {
$readonlyFields = $form->Fields()->makeReadonly(); $readonlyFields = $form->Fields()->makeReadonly();
@ -543,43 +626,50 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
} }
} }
/**
* @return String HTML
*/
public function treeview($request) {
return $this->renderWith($this->getTemplatesWithSuffix('_TreeView'));
}
public function listview($request) {
return $this->renderWith($this->getTemplatesWithSuffix('_ListView'));
}
/** /**
* Returns the pages meet a certain criteria as {@see CMSSiteTreeFilter} or the subpages of a parent page * Returns the pages meet a certain criteria as {@see CMSSiteTreeFilter} or the subpages of a parent page
* defaulting to no filter and show all pages in first level. * defaulting to no filter and show all pages in first level.
* Doubles as search results, if any search parameters are set through {@link SearchForm()}. * Doubles as search results, if any search parameters are set through {@link SearchForm()}.
* *
* @param Array Search filter criteria
* @param Int Optional parent node to filter on (can't be combined with other search criteria)
* @return SS_List * @return SS_List
*/ */
public function getList(&$filterOn) { public function getList($params, $parentID = 0) {
$list = new DataList($this->stat('tree_class')); $list = new DataList($this->stat('tree_class'));
$request = $this->request;
$filter = null; $filter = null;
$ids = array(); $ids = array();
if($filterClass = $request->requestVar('FilterClass')){ if(isset($params['FilterClass']) && $filterClass = $params['FilterClass']){
if(!is_subclass_of($filterClass, 'CMSSiteTreeFilter')) { if(!is_subclass_of($filterClass, 'CMSSiteTreeFilter')) {
throw new Exception(sprintf('Invalid filter class passed: %s', $filterClass)); throw new Exception(sprintf('Invalid filter class passed: %s', $filterClass));
} }
$filter = new $filterClass($request->requestVars()); $filter = new $filterClass($params);
$filterOn = true; $filterOn = true;
foreach($pages=$filter->pagesIncluded() as $pageMap){ foreach($pages=$filter->pagesIncluded() as $pageMap){
$ids[] = $pageMap['ID']; $ids[] = $pageMap['ID'];
} }
if(count($ids)) $list->where('"'.$this->stat('tree_class').'"."ID" IN ('.implode(",", $ids).')'); if(count($ids)) $list->where('"'.$this->stat('tree_class').'"."ID" IN ('.implode(",", $ids).')');
}else{ } else {
$parentID = 0; $list->filter("ParentID", is_numeric($parentID) ? $parentID : 0);
if($this->urlParams['Action'] == 'listchildren' && $this->urlParams['ID']){
$parentID = $this->urlParams['ID'];
}
$list->filter("ParentID", $parentID);
} }
return $list; return $list;
} }
public function getListView(){ public function ListViewForm(){
$filterOn = false; $params = $this->request->requestVar('q');
$list = $this->getList($filterOn); $list = $this->getList($params, $this->request->requestVar('ParentID'));
$gridFieldConfig = GridFieldConfig::create()->addComponents( $gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldSortableHeader(), new GridFieldSortableHeader(),
new GridFieldDataColumns(), new GridFieldDataColumns(),
@ -587,7 +677,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
); );
$gridField = new GridField('Page','Pages', $list, $gridFieldConfig); $gridField = new GridField('Page','Pages', $list, $gridFieldConfig);
if($filterOn){ // Don't allow navigating into children nodes on filtered lists
if($params){
$gridField->setDisplayFields(array( $gridField->setDisplayFields(array(
'getTreeTitle' => _t('SiteTree.PAGETITLE', 'Page Title'), 'getTreeTitle' => _t('SiteTree.PAGETITLE', 'Page Title'),
'Created' => _t('SiteTree.CREATED', 'Date Created'), 'Created' => _t('SiteTree.CREATED', 'Date Created'),
@ -607,13 +698,26 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'LastEdited' => 'Date->Ago', 'LastEdited' => 'Date->Ago',
)); ));
$controller = $this;
$gridField->setFieldFormatting(array( $gridField->setFieldFormatting(array(
'getTreeTitle' => '<a class=\"cms-panel-link\" href=\"admin/page/edit/show/$ID\">$value</a>' 'listChildrenLink' => function(&$item) use($controller) {
$num = $item->numChildren();
if($num) {
return sprintf(
'<a class="cms-panel-link list-children-link" data-pjax="ListViewForm" data-target-panel="#Form_ListViewForm" href="%s?ParentID=%d&view=list">%s</a>',
$controller->Link(),
$item->ID,
$num
);
}
},
'getTreeTitle' => '<a class=\"cms-panel-link\" href=\"' .
singleton('CMSPageEditController')->Link('show') . '/$ID\">$value</a>'
)); ));
$listview = new Form( $listview = new Form(
$this, $this,
'ListView', 'ListViewForm',
new FieldList($gridField), new FieldList($gridField),
new FieldList() new FieldList()
); );
@ -624,14 +728,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return $listview; return $listview;
} }
public function getListViewHTML(){
return $this->getListView()->forTemplate();
}
public function ListView() {
return $this->getListView();
}
public function currentPageID() { public function currentPageID() {
$id = parent::currentPageID(); $id = parent::currentPageID();
@ -645,14 +741,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return $id; return $id;
} }
public function listchildren(){
if(Director::is_ajax()){
return $this->getListViewHTML();
}else{
return $this;
}
}
//------------------------------------------------------------------------------------------// //------------------------------------------------------------------------------------------//
// Data saving handlers // Data saving handlers

View File

@ -1,7 +1,7 @@
<?php <?php
class CMSPageAddController extends CMSPageEditController { class CMSPageAddController extends CMSPageEditController {
static $url_segment = 'page/add'; static $url_segment = 'pages/add';
static $url_rule = '/$Action/$ID/$OtherID'; static $url_rule = '/$Action/$ID/$OtherID';
static $url_priority = 42; static $url_priority = 42;
static $menu_title = 'Add page'; static $menu_title = 'Add page';

View File

@ -5,15 +5,8 @@
*/ */
class CMSPageEditController extends CMSMain { class CMSPageEditController extends CMSMain {
static $url_segment = 'page/edit'; static $url_segment = 'pages/edit';
static $url_rule = '/$Action/$ID/$OtherID'; static $url_rule = '/$Action/$ID/$OtherID';
static $url_priority = 41; static $url_priority = 41;
static $required_permission_codes = 'CMS_ACCESS_CMSMain'; static $required_permission_codes = 'CMS_ACCESS_CMSMain';
public function Breadcrumbs($unlinked = false) {
$crumbs = parent::Breadcrumbs($unlinked);
// Remove "root" element, as its already shown in the tree panel
$crumbs->shift();
return $crumbs;
}
} }

View File

@ -6,7 +6,7 @@
*/ */
class CMSPageHistoryController extends CMSMain { class CMSPageHistoryController extends CMSMain {
static $url_segment = 'page/history'; static $url_segment = 'pages/history';
static $url_rule = '/$Action/$ID/$VersionID/$OtherVersionID'; static $url_rule = '/$Action/$ID/$VersionID/$OtherVersionID';
static $url_priority = 42; static $url_priority = 42;
static $menu_title = 'History'; static $menu_title = 'History';
@ -370,10 +370,4 @@ class CMSPageHistoryController extends CMSMain {
} }
} }
public function Breadcrumbs($unlinked = false) {
$crumbs = parent::Breadcrumbs($unlinked);
// Remove "root" element, as its already shown in the tree panel
$crumbs->shift();
return $crumbs;
}
} }

View File

@ -5,7 +5,7 @@
*/ */
class CMSPageSettingsController extends CMSMain { class CMSPageSettingsController extends CMSMain {
static $url_segment = 'page/settings'; static $url_segment = 'pages/settings';
static $url_rule = '/$Action/$ID/$OtherID'; static $url_rule = '/$Action/$ID/$OtherID';
static $url_priority = 42; static $url_priority = 42;
static $required_permission_codes = 'CMS_ACCESS_CMSMain'; static $required_permission_codes = 'CMS_ACCESS_CMSMain';
@ -16,10 +16,4 @@ class CMSPageSettingsController extends CMSMain {
return parent::getEditForm($record, ($record) ? $record->getSettingsFields() : null); return parent::getEditForm($record, ($record) ? $record->getSettingsFields() : null);
} }
public function Breadcrumbs($unlinked = false) {
$crumbs = parent::Breadcrumbs($unlinked);
// Remove "root" element, as its already shown in the tree panel
$crumbs->shift();
return $crumbs;
}
} }

View File

@ -7,42 +7,14 @@ class CMSPagesController extends CMSMain {
static $url_segment = 'pages'; static $url_segment = 'pages';
static $url_rule = '/$Action/$ID/$OtherID'; static $url_rule = '/$Action/$ID/$OtherID';
static $url_priority = 41; static $url_priority = 40;
static $menu_title = 'Pages'; static $menu_title = 'Pages';
static $required_permission_codes = 'CMS_ACCESS_CMSMain'; static $required_permission_codes = 'CMS_ACCESS_CMSMain';
function init() {
parent::init();
Requirements::javascript(CMS_DIR . '/javascript/CMSPagesController.Tree.js');
}
function show($request) {
if($request->param('ID')) {
$c = new CMSPageEditController();
return $this->redirect(Controller::join_links($c->Link('show'), $request->param('ID')));
}
return parent::show($request);
}
function Link($action = null) {
// Special case: All show links should redirect to the page edit interface instead (mostly from tree nodes)
if(preg_match('/^show/', $action)) {
return singleton('CMSPageEditController')->Link($action);
}
return parent::Link($action);
}
function PreviewLink() { function PreviewLink() {
return false; return false;
} }
function AddLink() {
return singleton("CMSPageAddController")->Link();
}
public function currentPageID() { public function currentPageID() {
return false; return false;
} }

View File

@ -2490,13 +2490,6 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
return $this->getTreeTitle(); return $this->getTreeTitle();
} }
function listChildrenLink(){
if($num = $this->numChildren()){
$link = singleton('CMSPagesController')->Link('listchildren')."/".$this->ID;
return '<a href="'.$link.'" class="list-children-link">'.$num.'</a>';
}
}
/** /**
* getTreeTitle will return three <span> html DOM elements, an empty <span> with * getTreeTitle will return three <span> html DOM elements, an empty <span> with
* the class 'jstree-pageicon' in front, following by a <span> wrapping around its * the class 'jstree-pageicon' in front, following by a <span> wrapping around its

View File

@ -1,7 +1,7 @@
/** This file is the central collection of included modules, links to custom SCSS files, and any global SCSS variable definitions. DO NOT ADD stylesheet rules to this file directly! Note: By prefixing files with an underscore, they won't create individual CSS files. */ /** This file is the central collection of included modules, links to custom SCSS files, and any global SCSS variable definitions. DO NOT ADD stylesheet rules to this file directly! Note: By prefixing files with an underscore, they won't create individual CSS files. */
/** ----------------------------- Core Compass Libraries ------------------------------ */ /** ----------------------------- Core Compass Libraries ------------------------------ */
/** ----------------------------- CMS Components ------------------------------ */ /** ----------------------------- CMS Components ------------------------------ */
/** Style custom to the CMSMain admin interface. CMSMain extends the built in SilverStripe admin section styles. As much as possible we want to use those built in styles. If anything in this file can be implemented in a generic way then it should be include in the admin scss files. @package cms */ /** Style custom to the CMSMain admin interface. CMSMain extends the built in SilverStripe admin section styles. As much as possible we want to use those built in styles. If anything in this file can be implemented in a generic way then it should be include in the admin scss files. @package cms */
/** ------------------------------------------------------------------ Page History Section. ----------------------------------------------------------------- */ /** ------------------------------------------------------------------ Page History Section. ----------------------------------------------------------------- */
#cms-page-history-versions tr.loading { color: #999; } #cms-page-history-versions tr.loading { color: #999; }
#cms-page-history-versions tr.loading td:hover { cursor: none; } #cms-page-history-versions tr.loading td:hover { cursor: none; }
@ -10,6 +10,13 @@
.CMSPageHistoryController ins { background-color: #DFD; padding: 2px; text-decoration: none; } .CMSPageHistoryController ins { background-color: #DFD; padding: 2px; text-decoration: none; }
.CMSPageHistoryController del { background-color: #FDD; padding: 2px; color: #ff4444; } .CMSPageHistoryController del { background-color: #FDD; padding: 2px; color: #ff4444; }
/** -------------------------------------------- Tree View (collapsed for sidebar) -------------------------------------------- */
#cms-content-treeview .cms-tree-expand-trigger { display: none; }
.cms-content-tools #cms-content-treeview .cms-tree-view-modes, .cms-content-tools #cms-content-treeview .cms-content-batchactions { display: none; }
.cms-content-tools #cms-content-treeview .cms-tree-expand-trigger { display: inline-block; }
.cms-content-tools #cms-content-treeview .cms-tree .badge, .cms-content-tools #cms-content-treeview .cms-tree a > .jstree-icon { display: none; }
.cms .AssetAdmin .cms-content-fields { overflow: hidden; } .cms .AssetAdmin .cms-content-fields { overflow: hidden; }
.cms .AssetAdmin .cms-content-fields .cms-edit-form.AssetAdmin { overflow-y: auto; } .cms .AssetAdmin .cms-content-fields .cms-edit-form.AssetAdmin { overflow-y: auto; }
.cms .AssetAdmin .cms-content-fields .cms-content-tools .cms-panel-content { overflow: hidden; } .cms .AssetAdmin .cms-content-fields .cms-content-tools .cms-panel-content { overflow: hidden; }

View File

@ -1,153 +0,0 @@
/**
* File: CMSMain.js
*/
(function($) {
$.entwine('ss', function($){
$('#pages-controller-cms-content').entwine({
/**
* we need to check if the current url contains a sub url 'listchildren' and
* select its list view if it does, otherwise use the default tabs() call which is
* using cookie options
*/
redrawTabs: function() {
if(window.location.href.match(/listchildren/)){
this.rewriteHashlinks();
this.tabs({ selected: 1 });
}else{
this._super();
}
}
});
/**
* Class: #Form_SearchForm
*
* Control the site tree filter.
* Toggles search form fields based on a dropdown selection,
* similar to "Smart Search" criteria in iTunes.
*/
$('#Form_SearchForm').entwine({
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;
// Reset binding through entwine doesn't work in IE
this.bind('reset', function(e) {
self._onreset(e);
});
this._super();
},
/**
* Function: onsubmit
*
* Filter tree based on selected criteria.
*/
onsubmit: function(e) {
var self = this;
var data = [];
// convert from jQuery object literals to hash map
$(this.serializeArray()).each(function(i, el) {
data[el.name] = el.value;
});
// TODO Disable checkbox tree controls that currently don't work with search.
this.find('.checkboxAboveTree :checkbox').attr('disabled', 'disabled');
// TODO disable buttons to avoid multiple submission
//this.find(':submit').attr('disabled', true);
this.find(':submit[name=action_doSearchTree]').addClass('loading');
var params = this.serializeArray();
this._reloadSitetree(params);
this._reloadListview(params);
return false;
},
/**
* Function: onreset
*
* Parameters:
* (Event) e
*/
_onreset: function(e) {
// TODO Enable checkbox tree controls
this.find('.checkboxAboveTree :checkbox').attr('disabled', 'false');
this.resetForm();
//the dropdown field wont be reset due to it is applied to chosen.js so need to treated specially
this.find('.field.dropdown select').val('').trigger("liszt:updated");
this._reloadSitetree();
this._reloadListview();
return false;
},
/**
* Function: _reloadSitetree
*/
_reloadSitetree: function(params) {
var self = this;
$('.cms-tree').search(
params,
function() {
self.find(':submit').attr('disabled', false).removeClass('loading');
self.find('.checkboxAboveTree :checkbox').attr('disabled', 'true');
},
function() {
self.find(':submit').attr('disabled', false).removeClass('loading');
self.find('.checkboxAboveTree :checkbox').attr('disabled', 'true');
errorMessage('Could not filter site tree<br />' + response.responseText);
}
);
},
_reloadListview: function(params){
$('.cms-list').refresh(params);
}
});
$('#cms-content-listview .cms-list').entwine({
refresh: function(params){
var self = this;
$.ajax({
url: this.data('url-list'),
data: params,
success: function(data, status, xhr) {
self.html(data);
},
error: function(xhr, status, e) {
errorMessage(e);
}
});
},
replace: function(url){
if(window.History.enabled) {
var container = $('.cms-container')
container.loadPanel(url, '', {selector: '.cms-list form'});
} else {
window.location = $.path.makeUrlAbsolute(url, $('base').attr('href'));
}
}
});
$('.cms-list .list-children-link').entwine({
onclick: function(e) {
this.closest('.cms-list').replace(this.attr('href'));
e.preventDefault();
return false;
}
});
});
})(jQuery);

View File

@ -43,3 +43,31 @@
color: darken(#FDD, 30%); color: darken(#FDD, 30%);
} }
} }
/** --------------------------------------------
* Tree View (collapsed for sidebar)
* -------------------------------------------- */
#cms-content-treeview {
.cms-tree-expand-trigger {
display: none; // Don't show trigger in expanded mode
}
}
.cms-content-tools { // Hide certain elements when shown in "sidebar mode"
#cms-content-treeview {
.cms-tree-view-modes,
.cms-content-batchactions {
display: none;
}
.cms-tree-expand-trigger {
display: inline-block;
}
.cms-tree {
.badge,
a > .jstree-icon {
display: none;
}
}
}
}

View File

@ -1,17 +0,0 @@
<div class="cms-content-tools west cms-panel cms-panel-layout" data-expandOnClick="true" data-layout-type="border" id="cms-content-tools-CMSPageEditController">
<div class="cms-content-header cms-panel-header north">
<h2><% _t('CMSPageEditController.Title','Pages') %></h2>
</div>
<div class="cms-panel-content center">
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-hints="$SiteTreeHints">
$SiteTreeAsUL
</div>
</div>
<div class="cms-panel-content-collapsed">
<h3 class="cms-panel-header">$SiteConfig.Title</h3>
</div>
</div>

View File

@ -0,0 +1,35 @@
<div id="pages-controller-cms-content" class="cms-content center ss-tabset $BaseCSSClasses" data-layout-type="border">
<div class="cms-content-header north">
<div>
<h2>
<% include CMSBreadcrumbs %>
</h2>
<div class="cms-content-header-tabs">
<ul>
<li <% if class == 'CMSPageEditController' %>class="ui-state-selected"<% end_if %>>
<a href="$LinkPageEdit" class="content-treeview cms-panel-link" title="Form_EditForm">
<% _t('CMSMain.TabContent', 'Content') %>
</a>
</li>
<li <% if class == 'CMSPageSettingsController' %>class="ui-state-selected"<% end_if %>>
<a href="$LinkPageSettings" class="content-listview cms-panel-link" title="Form_EditForm">
<% _t('CMSMain.TabSettings', 'Settings') %>
</a>
</li>
<li <% if class == 'CMSPageHistoryController' %>class="ui-state-selected"<% end_if %>>
<a href="$LinkPageHistory" class="content-listview cms-panel-link" title="Form_EditForm">
<% _t('CMSMain.TabHistory', 'History') %>
</a>
</li>
</ul>
</div>
</div>
</div>
$Tools
$EditForm
</div>

View File

@ -0,0 +1,33 @@
<form $FormAttributes data-layout-type="border">
<div class="cms-content-fields center">
<% if Message %>
<p id="{$FormName}_error" class="message $MessageType">$Message</p>
<% else %>
<p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
<% end_if %>
<fieldset>
<% if Legend %><legend>$Legend</legend><% end_if %>
<% control Fields %>
$FieldHolder
<% end_control %>
<div class="clear"><!-- --></div>
</fieldset>
</div>
<div class="cms-content-actions south">
<% if Actions %>
<div class="Actions">
<% control Actions %>
$Field
<% end_control %>
<% if Controller.PreviewLink %>
<a href="$Controller.PreviewLink" class="cms-preview-toggle-link ss-ui-button" data-icon="preview">
<% _t('LeftAndMain.PreviewButton', 'Preview') %> &raquo;
</a>
<% end_if %>
</div>
<% end_if %>
</div>
</form>

View File

@ -0,0 +1,22 @@
<div class="cms-content-toolbar">
<% include CMSPagesController_ContentToolActions %>
</div>
<div class="ss-dialog cms-page-add-form-dialog cms-dialog-content" id="cms-page-add-form" title="<% _t('CMSMain.AddNew', 'Add new page') %>">
$AddForm
</div>
<div class="cms-panel-content center">
<% if TreeIsFiltered %>
<div class="cms-tree-filtered">
<strong><% _t('CMSMain.ListFiltered', 'Filtered list.') %></strong>
<a href="$LinkPages" class="cms-panel-link">
<% _t('CMSMain.TreeFilteredClear', 'Clear filter') %>
</a>
</div>
<% end_if %>
<div class="cms-list" data-url-list="$Link(getListViewHTML)">
$ListViewForm
</div>
</div>

View File

@ -0,0 +1,10 @@
<div class="cms-content-tools west cms-panel cms-panel-layout collapsed" id="cms-content-tools" data-expandOnClick="true" data-layout-type="border" id="cms-content-tools-CMSMain">
<div class="cms-panel-content center">
<div class="cms-content-view cms-tree-view-sidebar cms-panel-deferred" id="cms-content-treeview" data-url="$LinkTreeView">
<%-- Lazy-loaded via ajax --%>
</div>
</div>
<div class="cms-panel-content-collapsed">
<h3 class="cms-panel-header">$SiteConfig.Title</h3>
</div>
</div>

View File

@ -0,0 +1,26 @@
<div class="cms-content-toolbar">
<% include CMSPagesController_ContentToolbar %>
</div>
<div class="ss-dialog cms-page-add-form-dialog cms-dialog-content" id="cms-page-add-form" title="<% _t('CMSMain.AddNew', 'Add new page') %>">
$AddForm
</div>
<button href="$LinkPages" class="cms-tree-expand-trigger cms-panel-link ss-button" data-icon="pencil">
<% _t('CMSMain.EditTree', 'Edit Tree') %>
</button>
<div class="center">
<% if TreeIsFiltered %>
<div class="cms-tree-filtered">
<strong><% _t('CMSMain.TreeFiltered', 'Filtered tree.') %></strong>
<a href="$LinkPages" class="cms-panel-link">
<% _t('CMSMain.TreeFilteredClear', 'Clear filter') %>
</a>
</div>
<% end_if %>
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-hints="$SiteTreeHints">
$SiteTreeAsUL
</div>
</div>

View File

@ -1,9 +1,4 @@
<div class="cms-content-tools west cms-panel cms-panel-layout" data-expandOnClick="true" data-layout-type="border" id="cms-content-tools-CMSPageHistoryController"> <div class="cms-content-tools west cms-panel cms-panel-layout" data-expandOnClick="true" data-layout-type="border" id="cms-content-tools-CMSPageHistoryController">
<div class="cms-content-header north">
<div>
<h2><% _t('CMSPageHistoryController.History','History') %></h2>
</div>
</div>
<div class="cms-panel-content cms-helper-hide-actions center"> <div class="cms-panel-content cms-helper-hide-actions center">
$VersionsForm $VersionsForm

View File

@ -1 +0,0 @@
<% include CMSPageEditController_Tools %>

View File

@ -9,10 +9,10 @@
<div class="cms-content-header-tabs"> <div class="cms-content-header-tabs">
<ul> <ul>
<li> <li>
<a href="#cms-content-treeview" class="content-treeview"><% _t('CMSPagesController.TreeView', 'Tree View') %></a> <a href="#cms-content-treeview" class="content-treeview cms-panel-link" data-href="$LinkTreeView"><% _t('CMSPagesController.TreeView', 'Tree View') %></a>
</li> </li>
<li> <li>
<a href="#cms-content-listview" class="content-listview"><% _t('CMSPagesController.ListView', 'List View') %></a> <a href="#cms-content-listview" class="content-listview cms-panel-link" data-href="$LinkListView"><% _t('CMSPagesController.ListView', 'List View') %></a>
</li> </li>
<!-- <!--
<li> <li>
@ -28,30 +28,12 @@
<div class="cms-content-fields center ui-widget-content cms-panel-padded"> <div class="cms-content-fields center ui-widget-content cms-panel-padded">
<div id="cms-content-treeview"> <div class="cms-content-view cms-panel-deferred" id="cms-content-treeview" data-url="$LinkTreeView">
<%-- Lazy-loaded via ajax --%>
<div class="cms-content-toolbar">
<% include CMSPagesController_ContentToolbar %>
</div>
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-hints="$SiteTreeHints">
$SiteTreeAsUL
</div>
<div class="ss-dialog cms-page-add-form-dialog cms-dialog-content" id="cms-page-add-form" title="<% _t('CMSMain.AddNew', 'Add new page') %>">
$AddForm
</div>
</div> </div>
<div id="cms-content-listview"> <div class="cms-content-view cms-panel-deferred" id="cms-content-listview" data-url="$LinkListView">
<div class="cms-content-toolbar"> <%-- Lazy-loaded via ajax --%>
<% include CMSPagesController_ContentToolActions %>
</div>
<div class="cms-list" data-url-list="$Link(getListViewHTML)">
$ListView
</div>
</div> </div>
<!-- <!--
<div id="cms-content-galleryview"> <div id="cms-content-galleryview">

View File

@ -1,5 +1,5 @@
<div class="cms-actions-row"> <div class="cms-actions-row">
<a class="cms-page-add-button ss-ui-button ss-ui-action-constructive cms-panel-link" data-icon="add" href="$AddLink"><% _t('CMSMain.AddNewButton', 'Add new') %></a> <a class="cms-page-add-button ss-ui-button ss-ui-action-constructive cms-panel-link" data-icon="add" href="$LinkPageAdd"><% _t('CMSMain.AddNewButton', 'Add new') %></a>
</div> </div>
<div class="cms-content-batchactions"> <div class="cms-content-batchactions">