Skip to content
This repository
Browse code

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
  • Loading branch information...
commit 6aeac37906bc2d244bccedd467f0402e5942166e 1 parent dcdb0b4
Ingo Schommer authored April 16, 2012
1  _config.php
@@ -37,6 +37,7 @@
37 37
 Object::add_extension('File', 'SiteTreeFileExtension');
38 38
 
39 39
 // TODO Remove once we can configure CMSMenu through static, nested configuration files
  40
+CMSMenu::remove_menu_item('CMSMain');
40 41
 CMSMenu::remove_menu_item('CMSPageEditController');
41 42
 CMSMenu::remove_menu_item('CMSPageSettingsController');
42 43
 CMSMenu::remove_menu_item('CMSPageHistoryController');
190  code/controllers/CMSMain.php
@@ -11,13 +11,13 @@
11 11
  */
12 12
 class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider {
13 13
 	
14  
-	static $url_segment = 'page';
  14
+	static $url_segment = 'pages';
15 15
 	
16 16
 	static $url_rule = '/$Action/$ID/$OtherID';
17 17
 	
18 18
 	// Maintain a lower priority than other administration sections
19 19
 	// so that Director does not think they are actions of CMSMain
20  
-	static $url_priority = 40;
  20
+	static $url_priority = 39;
21 21
 	
22 22
 	static $menu_title = 'Edit Page';
23 23
 	
@@ -43,9 +43,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
43 43
 		'SiteTreeAsUL',
44 44
 		'getshowdeletedsubtree',
45 45
 		'batchactions',
46  
-		'ListView',
47  
-		'getListView',
48  
-		'listchildren',
  46
+		'treeview',
  47
+		'listview',
  48
+		'ListViewForm',
49 49
 	);
50 50
 	
51 51
 	public function init() {
@@ -78,7 +78,24 @@ public function init() {
78 78
 		CMSBatchActionHandler::register('delete', 'CMSBatchAction_Delete');
79 79
 		CMSBatchActionHandler::register('deletefromlive', 'CMSBatchAction_DeleteFromLive');
80 80
 	}
81  
-	
  81
+
  82
+	function index($request) {
  83
+		// In case we're not showing a specific record, explicitly remove any session state,
  84
+		// to avoid it being highlighted in the tree, and causing an edit form to show.
  85
+		if(!$request->param('Action')) $this->setCurrentPageId(null);
  86
+
  87
+		return parent::index($request);
  88
+	}
  89
+
  90
+	protected function getResponseNegotiator() {
  91
+		$negotiator = parent::getResponseNegotiator();
  92
+		$controller = $this;
  93
+		$negotiator->setCallback('ListViewForm', function() use(&$controller) {
  94
+			return $controller->ListViewForm()->forTemplate();
  95
+		});
  96
+		return $negotiator;
  97
+	}
  98
+
82 99
 	/**
83 100
 	 * If this is set to true, the "switchView" context in the
84 101
 	 * template is shown, with links to the staging and publish site.
@@ -123,6 +140,62 @@ public function Link($action = null) {
123 140
 			"$action"
124 141
 		);
125 142
 	}
  143
+
  144
+	public function LinkPages() {
  145
+		return singleton('CMSPagesController')->Link();
  146
+	}
  147
+
  148
+	public function LinkTreeView() {
  149
+		return $this->LinkWithSearch(singleton('CMSMain')->Link('treeview'));
  150
+	}
  151
+
  152
+	public function LinkListView() {
  153
+		return $this->LinkWithSearch(singleton('CMSMain')->Link('listview'));
  154
+	}
  155
+
  156
+	public function LinkGalleryView() {
  157
+		return $this->LinkWithSearch(singleton('CMSMain')->Link('galleryview'));
  158
+	}
  159
+
  160
+	public function LinkPageEdit() {
  161
+		if($id = $this->currentPageID()) {
  162
+			return $this->LinkWithSearch(
  163
+				Controller::join_links(singleton('CMSPageEditController')->Link('show'), $id)
  164
+			);
  165
+		}
  166
+	}
  167
+
  168
+	public function LinkPageSettings() {
  169
+		if($id = $this->currentPageID()) {
  170
+			return $this->LinkWithSearch(
  171
+				Controller::join_links(singleton('CMSPageSettingsController')->Link('show'), $id)
  172
+			);
  173
+		}
  174
+	}
  175
+
  176
+	public function LinkPageHistory() {
  177
+		if($id = $this->currentPageID()) {
  178
+			return $this->LinkWithSearch(
  179
+				Controller::join_links(singleton('CMSPageHistoryController')->Link('show'), $id)
  180
+			);
  181
+		}
  182
+	}
  183
+
  184
+	protected function LinkWithSearch($link) {
  185
+		// Whitelist to avoid side effects
  186
+		$params = array(
  187
+			'q' => (array)$this->request->getVar('q'),
  188
+			'ParentID' => $this->request->getVar('ParentID')
  189
+		);
  190
+		return Controller::join_links(
  191
+			$link,
  192
+			array_filter(array_values($params)) ? '?' . http_build_query($params) : null
  193
+		);
  194
+	}
  195
+
  196
+	function LinkPageAdd() {
  197
+		return singleton("CMSPageAddController")->Link();
  198
+	}
126 199
 	
127 200
 	/**
128 201
 	 * @return string
@@ -155,6 +228,13 @@ public function SiteTreeAsUL() {
155 228
 
156 229
 		return $html;
157 230
 	}
  231
+
  232
+	/**
  233
+	 * @return boolean
  234
+	 */
  235
+	public function TreeIsFiltered() {
  236
+		return $this->request->getVar('q');
  237
+	}
158 238
 	
159 239
 	function SearchForm() {
160 240
 		// get all page types in a dropdown-compatible format
@@ -177,19 +257,19 @@ function SearchForm() {
177 257
 		);
178 258
 		
179 259
 		$fields = new FieldList(
180  
-			new TextField('Term', _t('CMSSearch.FILTERLABELTEXT', 'Content')),
  260
+			new TextField('q[Term]', _t('CMSSearch.FILTERLABELTEXT', 'Content')),
181 261
 			$dateGroup = new FieldGroup(
182  
-				new HeaderField('Date', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4),
183  
-				$dateFrom = new DateField('LastEditedFrom', _t('CMSSearch.FILTERDATEFROM', 'From')),
184  
-				$dateTo = new DateField('LastEditedTo', _t('CMSSearch.FILTERDATETO', 'To'))
  262
+				new HeaderField('q[Date]', _t('CMSSearch.FILTERDATEHEADING', 'Date'), 4),
  263
+				$dateFrom = new DateField('q[LastEditedFrom]', _t('CMSSearch.FILTERDATEFROM', 'From')),
  264
+				$dateTo = new DateField('q[LastEditedTo]', _t('CMSSearch.FILTERDATETO', 'To'))
185 265
 			),
186 266
 			new DropdownField(
187  
-				'FilterClass', 
  267
+				'q[FilterClass]', 
188 268
 				_t('CMSMain.PAGES', 'Pages'), 
189 269
 				$filterMap
190 270
 			),
191 271
 			new DropdownField(
192  
-				'ClassName', 
  272
+				'q[ClassName]', 
193 273
 				_t('CMSMain.PAGETYPEOPT','Page Type', 'Dropdown for limiting search to a page type'), 
194 274
 				$pageTypes, 
195 275
 				null, 
@@ -211,11 +291,14 @@ function SearchForm() {
211 291
 		// Use <button> to allow full jQuery UI styling
212 292
 		foreach($actions->dataFields() as $action) $action->setUseButtonTag(true);
213 293
 		
214  
-		$form = new Form($this, 'SearchForm', $fields, $actions);
215  
-		$form->setFormMethod('GET');
216  
-		$form->disableSecurityToken();
217  
-		$form->unsetValidator();
218  
-		
  294
+		$form = Form::create($this, 'SearchForm', $fields, $actions)
  295
+			->addExtraClass('cms-search-form')
  296
+			->setFormMethod('GET')
  297
+			->setFormAction($this->Link())
  298
+			->disableSecurityToken()
  299
+			->unsetValidator();
  300
+		$form->loadDataFrom($this->request->getVars());
  301
+
219 302
 		return $form;
220 303
 	}
221 304
 	
@@ -527,7 +610,7 @@ public function getEditForm($id = null, $fields = null) {
527 610
 			$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
528 611
 			// TODO Can't merge $FormAttributes in template at the moment
529 612
 			$form->addExtraClass('center ss-tabset ' . $this->BaseCSSClasses());
530  
-			if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
  613
+			// if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
531 614
 
532 615
 			if(!$record->canEdit() || $deletedFromStage) {
533 616
 				$readonlyFields = $form->Fields()->makeReadonly();
@@ -542,44 +625,51 @@ public function getEditForm($id = null, $fields = null) {
542 625
 			);
543 626
 		}
544 627
 	}
  628
+
  629
+	/**
  630
+	 * @return String HTML
  631
+	 */
  632
+	public function treeview($request) {
  633
+		return $this->renderWith($this->getTemplatesWithSuffix('_TreeView'));
  634
+	}
  635
+
  636
+	public function listview($request) {
  637
+		return $this->renderWith($this->getTemplatesWithSuffix('_ListView'));
  638
+	}
545 639
 	
546 640
 	/**
547 641
 	 * Returns the pages meet a certain criteria as {@see CMSSiteTreeFilter} or the subpages of a parent page
548 642
 	 * defaulting to no filter and show all pages in first level.
549 643
 	 * Doubles as search results, if any search parameters are set through {@link SearchForm()}.
550 644
 	 * 
  645
+	 * @param Array Search filter criteria
  646
+	 * @param Int Optional parent node to filter on (can't be combined with other search criteria)
551 647
 	 * @return SS_List
552 648
 	 */
553  
-	public function getList(&$filterOn) {
  649
+	public function getList($params, $parentID = 0) {
554 650
 		$list = new DataList($this->stat('tree_class'));
555  
-		
556  
-		$request = $this->request;
557 651
 		$filter = null;
558 652
 		$ids = array();
559  
-		if($filterClass = $request->requestVar('FilterClass')){
  653
+		if(isset($params['FilterClass']) && $filterClass = $params['FilterClass']){
560 654
 			if(!is_subclass_of($filterClass, 'CMSSiteTreeFilter')) {
561 655
 				throw new Exception(sprintf('Invalid filter class passed: %s', $filterClass));
562 656
 			}
563  
-			$filter = new $filterClass($request->requestVars());
  657
+			$filter = new $filterClass($params);
564 658
 			$filterOn = true;
565 659
 			foreach($pages=$filter->pagesIncluded() as $pageMap){
566 660
 				$ids[] = $pageMap['ID'];
567 661
 			}
568 662
 			if(count($ids)) $list->where('"'.$this->stat('tree_class').'"."ID" IN ('.implode(",", $ids).')');
569  
-		}else{
570  
-			$parentID = 0;
571  
-			if($this->urlParams['Action'] == 'listchildren' && $this->urlParams['ID']){
572  
-				$parentID = $this->urlParams['ID'];
573  
-			}
574  
-			$list->filter("ParentID", $parentID);
  663
+		} else {
  664
+			$list->filter("ParentID", is_numeric($parentID) ? $parentID : 0);
575 665
 		}
576 666
 
577 667
 		return $list;
578 668
 	}
579 669
 	
580  
-	public function getListView(){
581  
-		$filterOn = false;
582  
-		$list = $this->getList($filterOn);
  670
+	public function ListViewForm(){
  671
+		$params = $this->request->requestVar('q');
  672
+		$list = $this->getList($params, $this->request->requestVar('ParentID'));
583 673
 		$gridFieldConfig = GridFieldConfig::create()->addComponents(
584 674
 			new GridFieldSortableHeader(),
585 675
 			new GridFieldDataColumns(),
@@ -587,7 +677,8 @@ public function getListView(){
587 677
 		);
588 678
 		$gridField = new GridField('Page','Pages', $list, $gridFieldConfig);
589 679
 		
590  
-		if($filterOn){
  680
+		// Don't allow navigating into children nodes on filtered lists
  681
+		if($params){
591 682
 			$gridField->setDisplayFields(array(
592 683
 				'getTreeTitle' => _t('SiteTree.PAGETITLE', 'Page Title'),
593 684
 				'Created' => _t('SiteTree.CREATED', 'Date Created'),
@@ -607,13 +698,26 @@ public function getListView(){
607 698
 			'LastEdited' => 'Date->Ago',
608 699
 		));
609 700
 
  701
+		$controller = $this;
610 702
 		$gridField->setFieldFormatting(array(
611  
-			'getTreeTitle' => '<a class=\"cms-panel-link\" href=\"admin/page/edit/show/$ID\">$value</a>'
  703
+			'listChildrenLink' => function(&$item) use($controller) {
  704
+				$num = $item->numChildren();
  705
+				if($num) {
  706
+					return sprintf(
  707
+						'<a class="cms-panel-link list-children-link" data-pjax="ListViewForm" data-target-panel="#Form_ListViewForm" href="%s?ParentID=%d&view=list">%s</a>',
  708
+						$controller->Link(),
  709
+						$item->ID,
  710
+						$num
  711
+					);	
  712
+				}
  713
+			},
  714
+			'getTreeTitle' => '<a class=\"cms-panel-link\" href=\"' . 
  715
+				singleton('CMSPageEditController')->Link('show') . '/$ID\">$value</a>'
612 716
 		));
613 717
 		
614 718
 		$listview = new Form(
615 719
 			$this,
616  
-			'ListView',
  720
+			'ListViewForm',
617 721
 			new FieldList($gridField),
618 722
 			new FieldList()
619 723
 		);
@@ -624,14 +728,6 @@ public function getListView(){
624 728
 		return $listview;
625 729
 	}
626 730
 	
627  
-	public function getListViewHTML(){
628  
-		return $this->getListView()->forTemplate();
629  
-	}
630  
-	
631  
-	public function ListView() {
632  
-		return $this->getListView();
633  
-	}
634  
-	
635 731
 	public function currentPageID() {
636 732
 		$id = parent::currentPageID();
637 733
 		
@@ -645,14 +741,6 @@ public function currentPageID() {
645 741
 		return $id;
646 742
 	}
647 743
 	
648  
-	public function listchildren(){
649  
-		if(Director::is_ajax()){
650  
-			return $this->getListViewHTML();
651  
-		}else{
652  
-			return $this;
653  
-		}
654  
-	}
655  
-
656 744
 	//------------------------------------------------------------------------------------------//
657 745
 	// Data saving handlers
658 746
 
2  code/controllers/CMSPageAddController.php
... ...
@@ -1,7 +1,7 @@
1 1
 <?php
2 2
 class CMSPageAddController extends CMSPageEditController {
3 3
 
4  
-	static $url_segment = 'page/add';
  4
+	static $url_segment = 'pages/add';
5 5
 	static $url_rule = '/$Action/$ID/$OtherID';
6 6
 	static $url_priority = 42;
7 7
 	static $menu_title = 'Add page';
9  code/controllers/CMSPageEditController.php
@@ -5,15 +5,8 @@
5 5
  */
6 6
 class CMSPageEditController extends CMSMain {
7 7
 
8  
-	static $url_segment = 'page/edit';
  8
+	static $url_segment = 'pages/edit';
9 9
 	static $url_rule = '/$Action/$ID/$OtherID';
10 10
 	static $url_priority = 41;
11 11
 	static $required_permission_codes = 'CMS_ACCESS_CMSMain';
12  
-
13  
-	public function Breadcrumbs($unlinked = false) {
14  
-		$crumbs = parent::Breadcrumbs($unlinked);
15  
-		// Remove "root" element, as its already shown in the tree panel
16  
-		$crumbs->shift();
17  
-		return $crumbs;
18  
-	}
19 12
 }
8  code/controllers/CMSPageHistoryController.php
@@ -6,7 +6,7 @@
6 6
  */
7 7
 class CMSPageHistoryController extends CMSMain {
8 8
 
9  
-	static $url_segment = 'page/history';
  9
+	static $url_segment = 'pages/history';
10 10
 	static $url_rule = '/$Action/$ID/$VersionID/$OtherVersionID';
11 11
 	static $url_priority = 42;
12 12
 	static $menu_title = 'History';
@@ -370,10 +370,4 @@ function CompareVersionsForm($versionID, $otherVersionID) {
370 370
 		}
371 371
 	}
372 372
 
373  
-	public function Breadcrumbs($unlinked = false) {
374  
-		$crumbs = parent::Breadcrumbs($unlinked);
375  
-		// Remove "root" element, as its already shown in the tree panel
376  
-		$crumbs->shift();
377  
-		return $crumbs;
378  
-	}
379 373
 }
8  code/controllers/CMSPageSettingsController.php
@@ -5,7 +5,7 @@
5 5
  */
6 6
 class CMSPageSettingsController extends CMSMain {
7 7
 
8  
-	static $url_segment = 'page/settings';
  8
+	static $url_segment = 'pages/settings';
9 9
 	static $url_rule = '/$Action/$ID/$OtherID';
10 10
 	static $url_priority = 42;
11 11
 	static $required_permission_codes = 'CMS_ACCESS_CMSMain';
@@ -16,10 +16,4 @@ function getEditForm($id = null, $fields = null) {
16 16
 		return parent::getEditForm($record, ($record) ? $record->getSettingsFields() : null);
17 17
 	}
18 18
 
19  
-	public function Breadcrumbs($unlinked = false) {
20  
-		$crumbs = parent::Breadcrumbs($unlinked);
21  
-		// Remove "root" element, as its already shown in the tree panel
22  
-		$crumbs->shift();
23  
-		return $crumbs;
24  
-	}
25 19
 }
30  code/controllers/CMSPagesController.php
@@ -7,42 +7,14 @@ class CMSPagesController extends CMSMain {
7 7
 	
8 8
 	static $url_segment = 'pages';
9 9
 	static $url_rule = '/$Action/$ID/$OtherID';
10  
-	static $url_priority = 41;
  10
+	static $url_priority = 40;
11 11
 	static $menu_title = 'Pages';	
12 12
 	static $required_permission_codes = 'CMS_ACCESS_CMSMain';
13 13
 	
14  
-	function init() {
15  
-		parent::init();
16  
-		
17  
-		Requirements::javascript(CMS_DIR . '/javascript/CMSPagesController.Tree.js');
18  
-	}
19  
-	
20  
-	function show($request) {
21  
-		if($request->param('ID')) {
22  
-			$c = new CMSPageEditController();
23  
-			return $this->redirect(Controller::join_links($c->Link('show'), $request->param('ID')));
24  
-		}
25  
-		
26  
-		return parent::show($request);
27  
-	}
28  
-	
29  
-	function Link($action = null) {
30  
-		// Special case: All show links should redirect to the page edit interface instead (mostly from tree nodes)
31  
-		if(preg_match('/^show/', $action)) {
32  
-			return singleton('CMSPageEditController')->Link($action);
33  
-		}
34  
-		
35  
-		return parent::Link($action);
36  
-	}
37  
-	
38 14
 	function PreviewLink() {
39 15
 		return false;
40 16
 	}
41 17
 
42  
-	function AddLink() {
43  
-		return singleton("CMSPageAddController")->Link();
44  
-	}
45  
-
46 18
 	public function currentPageID() {
47 19
 		return false;
48 20
 	}
7  code/model/SiteTree.php
@@ -2490,13 +2490,6 @@ function TreeTitle() {
2490 2490
 		return $this->getTreeTitle();
2491 2491
 	}
2492 2492
 	
2493  
-	function listChildrenLink(){
2494  
-		if($num = $this->numChildren()){
2495  
-			$link = singleton('CMSPagesController')->Link('listchildren')."/".$this->ID;
2496  
-			return '<a href="'.$link.'" class="list-children-link">'.$num.'</a>';
2497  
-		}
2498  
-	}
2499  
-
2500 2493
 	/**
2501 2494
 	 * getTreeTitle will return three <span> html DOM elements, an empty <span> with
2502 2495
 	 * the class 'jstree-pageicon' in front, following by a <span> wrapping around its
9  css/screen.css
... ...
@@ -1,7 +1,7 @@
1 1
 /** 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. */
2 2
 /** ----------------------------- Core Compass Libraries ------------------------------ */
3 3
 /** ----------------------------- CMS Components ------------------------------ */
4  
-/** 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 */
  4
+/** 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 */
5 5
 /** ------------------------------------------------------------------ Page History Section. ----------------------------------------------------------------- */
6 6
 #cms-page-history-versions tr.loading { color: #999; }
7 7
 #cms-page-history-versions tr.loading td:hover { cursor: none; }
@@ -10,6 +10,13 @@
10 10
 .CMSPageHistoryController ins { background-color: #DFD; padding: 2px; text-decoration: none; }
11 11
 .CMSPageHistoryController del { background-color: #FDD; padding: 2px; color: #ff4444; }
12 12
 
  13
+/** -------------------------------------------- Tree View (collapsed for sidebar) -------------------------------------------- */
  14
+#cms-content-treeview .cms-tree-expand-trigger { display: none; }
  15
+
  16
+.cms-content-tools #cms-content-treeview .cms-tree-view-modes, .cms-content-tools #cms-content-treeview .cms-content-batchactions { display: none; }
  17
+.cms-content-tools #cms-content-treeview .cms-tree-expand-trigger { display: inline-block; }
  18
+.cms-content-tools #cms-content-treeview .cms-tree .badge, .cms-content-tools #cms-content-treeview .cms-tree a > .jstree-icon { display: none; }
  19
+
13 20
 .cms .AssetAdmin .cms-content-fields { overflow: hidden; }
14 21
 .cms .AssetAdmin .cms-content-fields .cms-edit-form.AssetAdmin { overflow-y: auto; }
15 22
 .cms .AssetAdmin .cms-content-fields .cms-content-tools .cms-panel-content { overflow: hidden; }
153  javascript/CMSMain.js
... ...
@@ -1,153 +0,0 @@
1  
-/**
2  
- * File: CMSMain.js
3  
- */
4  
-(function($) {
5  
-	$.entwine('ss', function($){
6  
-		
7  
-		$('#pages-controller-cms-content').entwine({
8  
-			/**
9  
-			 * we need to check if the current url contains a sub url 'listchildren' and 
10  
-			 * select its list view if it does, otherwise use the default tabs() call which is
11  
-			 * using cookie options
12  
-			 */
13  
-			redrawTabs: function() {
14  
-				if(window.location.href.match(/listchildren/)){
15  
-					this.rewriteHashlinks();
16  
-					this.tabs({ selected: 1 }); 
17  
-				}else{
18  
-					this._super();
19  
-				}
20  
-			}
21  
-		});
22  
-	
23  
-		/**
24  
-		 * Class: #Form_SearchForm
25  
-		 * 
26  
-		 * Control the site tree filter.
27  
-		 * Toggles search form fields based on a dropdown selection,
28  
-		 * similar to "Smart Search" criteria in iTunes.
29  
-		 */
30  
-		$('#Form_SearchForm').entwine({
31  
-	
32  
-			/**
33  
-			 * Constructor: onmatch
34  
-			 */
35  
-			onmatch: function() {
36  
-				var self = this;
37  
-
38  
-				// Reset binding through entwine doesn't work in IE
39  
-				this.bind('reset', function(e) {
40  
-					self._onreset(e);
41  
-				});
42  
-		
43  
-				this._super();
44  
-			},
45  
-	
46  
-			/**
47  
-			 * Function: onsubmit
48  
-			 * 
49  
-			 * Filter tree based on selected criteria.
50  
-			 */
51  
-			onsubmit: function(e) {
52  
-				var self = this;
53  
-				var data = [];
54  
-		
55  
-				// convert from jQuery object literals to hash map
56  
-				$(this.serializeArray()).each(function(i, el) {
57  
-					data[el.name] = el.value;
58  
-				});
59  
-		
60  
-				// TODO Disable checkbox tree controls that currently don't work with search.
61  
-				this.find('.checkboxAboveTree :checkbox').attr('disabled', 'disabled');
62  
-				
63  
-				// TODO disable buttons to avoid multiple submission
64  
-				//this.find(':submit').attr('disabled', true);
65  
-		
66  
-				this.find(':submit[name=action_doSearchTree]').addClass('loading');
67  
-				
68  
-				var params = this.serializeArray();
69  
-				this._reloadSitetree(params);
70  
-				this._reloadListview(params);
71  
-
72  
-				return false;
73  
-			},
74  
-		
75  
-			/**
76  
-			 * Function: onreset
77  
-			 * 
78  
-			 * Parameters:
79  
-			 *  (Event) e
80  
-			 */
81  
-			_onreset: function(e) {
82  
-				// TODO Enable checkbox tree controls
83  
-				this.find('.checkboxAboveTree :checkbox').attr('disabled', 'false');
84  
-
85  
-				this.resetForm();
86  
-				//the dropdown field wont be reset due to it is applied to chosen.js so need to treated specially
87  
-				this.find('.field.dropdown select').val('').trigger("liszt:updated");
88  
-				this._reloadSitetree();
89  
-				this._reloadListview();
90  
-				return false;
91  
-			},
92  
-	
93  
-			/**
94  
-			 * Function: _reloadSitetree
95  
-			 */
96  
-			_reloadSitetree: function(params) {
97  
-				var self = this;
98  
-		
99  
-				$('.cms-tree').search(
100  
-					params,
101  
-					function() {
102  
-						self.find(':submit').attr('disabled', false).removeClass('loading');
103  
-						self.find('.checkboxAboveTree :checkbox').attr('disabled', 'true');
104  
-					},
105  
-					function() {
106  
-						self.find(':submit').attr('disabled', false).removeClass('loading');
107  
-						self.find('.checkboxAboveTree :checkbox').attr('disabled', 'true');
108  
-						errorMessage('Could not filter site tree<br />' + response.responseText);
109  
-					}
110  
-				);		
111  
-			},
112  
-			
113  
-			_reloadListview: function(params){
114  
-				$('.cms-list').refresh(params);
115  
-				
116  
-			}
117  
-		});
118  
-		
119  
-		$('#cms-content-listview .cms-list').entwine({
120  
-			refresh: function(params){
121  
-				var self = this;
122  
-				
123  
-				$.ajax({
124  
-					url: this.data('url-list'),
125  
-					data: params,
126  
-					success: function(data, status, xhr) {
127  
-						self.html(data);
128  
-					},
129  
-					error: function(xhr, status, e) {
130  
-						errorMessage(e);
131  
-					}
132  
-				});
133  
-			},
134  
-			replace: function(url){
135  
-				if(window.History.enabled) {
136  
-					var container = $('.cms-container')
137  
-					container.loadPanel(url, '', {selector: '.cms-list form'});
138  
-				} else {
139  
-					window.location = $.path.makeUrlAbsolute(url, $('base').attr('href'));
140  
-				}
141  
-			}
142  
-		});
143  
-		
144  
-		$('.cms-list .list-children-link').entwine({
145  
-			onclick: function(e) {
146  
-				this.closest('.cms-list').replace(this.attr('href'));
147  
-				e.preventDefault();
148  
-				return false;
149  
-
150  
-			}
151  
-		});
152  
-	});
153  
-})(jQuery);
0  javascript/CMSPagesController.Tree.js
No changes.
28  scss/_CMSMain.scss
@@ -43,3 +43,31 @@
43 43
 		color: darken(#FDD, 30%);
44 44
 	}
45 45
 }
  46
+
  47
+/** --------------------------------------------
  48
+ * Tree View (collapsed for sidebar)
  49
+ * -------------------------------------------- */
  50
+#cms-content-treeview {
  51
+	.cms-tree-expand-trigger {
  52
+		display: none; // Don't show trigger in expanded mode
  53
+	}
  54
+}
  55
+
  56
+.cms-content-tools { // Hide certain elements when shown in "sidebar mode"
  57
+	#cms-content-treeview {
  58
+		.cms-tree-view-modes,
  59
+		.cms-content-batchactions {
  60
+			display: none;
  61
+		}
  62
+		.cms-tree-expand-trigger {
  63
+			display: inline-block; 
  64
+		}
  65
+
  66
+		.cms-tree {
  67
+			.badge,
  68
+			a > .jstree-icon {
  69
+				display: none;
  70
+			}
  71
+		}
  72
+	}
  73
+}
17  templates/CMSPageEditController_Tools.ss
... ...
@@ -1,17 +0,0 @@
1  
-<div class="cms-content-tools west cms-panel cms-panel-layout" data-expandOnClick="true" data-layout-type="border" id="cms-content-tools-CMSPageEditController">
2  
-	<div class="cms-content-header cms-panel-header north">
3  
-		<h2><% _t('CMSPageEditController.Title','Pages') %></h2>
4  
-	</div>
5  
-	
6  
-	<div class="cms-panel-content center">
7  
-		<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-hints="$SiteTreeHints">
8  
-			$SiteTreeAsUL
9  
-		</div>
10  
-	</div>
11  
-
12  
-	<div class="cms-panel-content-collapsed">
13  
-		<h3 class="cms-panel-header">$SiteConfig.Title</h3>
14  
-	</div>
15  
-
16  
-</div>
17  
-
35  templates/Includes/CMSMain_Content.ss
... ...
@@ -0,0 +1,35 @@
  1
+<div id="pages-controller-cms-content" class="cms-content center ss-tabset $BaseCSSClasses" data-layout-type="border">
  2
+
  3
+	<div class="cms-content-header north">
  4
+		<div>
  5
+			<h2>
  6
+				<% include CMSBreadcrumbs %>
  7
+			</h2>
  8
+		
  9
+			<div class="cms-content-header-tabs">
  10
+				<ul>
  11
+					<li <% if class == 'CMSPageEditController' %>class="ui-state-selected"<% end_if %>>
  12
+						<a href="$LinkPageEdit" class="content-treeview cms-panel-link" title="Form_EditForm">
  13
+							<% _t('CMSMain.TabContent', 'Content') %>
  14
+						</a>
  15
+					</li>
  16
+					<li <% if class == 'CMSPageSettingsController' %>class="ui-state-selected"<% end_if %>>
  17
+						<a href="$LinkPageSettings" class="content-listview cms-panel-link" title="Form_EditForm">
  18
+							<% _t('CMSMain.TabSettings', 'Settings') %>
  19
+						</a>
  20
+					</li>
  21
+					<li <% if class == 'CMSPageHistoryController' %>class="ui-state-selected"<% end_if %>>
  22
+						<a href="$LinkPageHistory" class="content-listview cms-panel-link" title="Form_EditForm">
  23
+							<% _t('CMSMain.TabHistory', 'History') %>
  24
+						</a>
  25
+					</li>
  26
+				</ul>
  27
+			</div>
  28
+		</div>
  29
+	</div>
  30
+
  31
+	$Tools
  32
+
  33
+	$EditForm
  34
+	
  35
+</div>
33  templates/Includes/CMSMain_EditForm.ss
... ...
@@ -0,0 +1,33 @@
  1
+<form $FormAttributes data-layout-type="border">
  2
+
  3
+	<div class="cms-content-fields center">
  4
+		<% if Message %>
  5
+		<p id="{$FormName}_error" class="message $MessageType">$Message</p>
  6
+		<% else %>
  7
+		<p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
  8
+		<% end_if %>
  9
+
  10
+		<fieldset>
  11
+			<% if Legend %><legend>$Legend</legend><% end_if %> 
  12
+			<% control Fields %>
  13
+				$FieldHolder
  14
+			<% end_control %>
  15
+			<div class="clear"><!-- --></div>
  16
+		</fieldset>
  17
+	</div>
  18
+
  19
+	<div class="cms-content-actions south">
  20
+		<% if Actions %>
  21
+		<div class="Actions">
  22
+			<% control Actions %>
  23
+				$Field
  24
+			<% end_control %>
  25
+			<% if Controller.PreviewLink %>
  26
+			<a href="$Controller.PreviewLink" class="cms-preview-toggle-link ss-ui-button" data-icon="preview">
  27
+				<% _t('LeftAndMain.PreviewButton', 'Preview') %> &raquo;
  28
+			</a>
  29
+			<% end_if %>
  30
+		</div>
  31
+		<% end_if %>
  32
+	</div>
  33
+</form>
22  templates/Includes/CMSMain_ListView.ss
... ...
@@ -0,0 +1,22 @@
  1
+<div class="cms-content-toolbar">
  2
+	<% include CMSPagesController_ContentToolActions %>
  3
+</div>
  4
+
  5
+<div class="ss-dialog cms-page-add-form-dialog cms-dialog-content" id="cms-page-add-form" title="<% _t('CMSMain.AddNew', 'Add new page') %>">
  6
+	$AddForm
  7
+</div>
  8
+
  9
+<div class="cms-panel-content center">
  10
+	<% if TreeIsFiltered %>
  11
+	<div class="cms-tree-filtered">
  12
+		<strong><% _t('CMSMain.ListFiltered', 'Filtered list.') %></strong>
  13
+		<a href="$LinkPages" class="cms-panel-link">
  14
+			<% _t('CMSMain.TreeFilteredClear', 'Clear filter') %>
  15
+		</a>
  16
+	</div>
  17
+	<% end_if %>
  18
+
  19
+	<div class="cms-list" data-url-list="$Link(getListViewHTML)">
  20
+		$ListViewForm
  21
+	</div>
  22
+</div>
10  templates/Includes/CMSMain_Tools.ss
... ...
@@ -0,0 +1,10 @@
  1
+<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">
  2
+	<div class="cms-panel-content center">
  3
+		<div class="cms-content-view cms-tree-view-sidebar cms-panel-deferred" id="cms-content-treeview" data-url="$LinkTreeView">
  4
+			<%-- Lazy-loaded via ajax --%>
  5
+		</div>
  6
+	</div>
  7
+	<div class="cms-panel-content-collapsed">
  8
+		<h3 class="cms-panel-header">$SiteConfig.Title</h3>
  9
+	</div>
  10
+</div>
26  templates/Includes/CMSMain_TreeView.ss
... ...
@@ -0,0 +1,26 @@
  1
+<div class="cms-content-toolbar">
  2
+	<% include CMSPagesController_ContentToolbar %>
  3
+</div>
  4
+
  5
+<div class="ss-dialog cms-page-add-form-dialog cms-dialog-content" id="cms-page-add-form" title="<% _t('CMSMain.AddNew', 'Add new page') %>">
  6
+	$AddForm
  7
+</div>
  8
+
  9
+<button href="$LinkPages" class="cms-tree-expand-trigger cms-panel-link ss-button" data-icon="pencil">
  10
+	<% _t('CMSMain.EditTree', 'Edit Tree') %>
  11
+</button>
  12
+
  13
+<div class="center">
  14
+	<% if TreeIsFiltered %>
  15
+	<div class="cms-tree-filtered">
  16
+		<strong><% _t('CMSMain.TreeFiltered', 'Filtered tree.') %></strong>
  17
+		<a href="$LinkPages" class="cms-panel-link">
  18
+			<% _t('CMSMain.TreeFilteredClear', 'Clear filter') %>
  19
+		</a>
  20
+	</div>
  21
+	<% end_if %>
  22
+
  23
+	<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-hints="$SiteTreeHints">
  24
+		$SiteTreeAsUL
  25
+	</div>
  26
+</div>
5  templates/Includes/CMSPageHistoryController_Tools.ss
... ...
@@ -1,9 +1,4 @@
1 1
 <div class="cms-content-tools west cms-panel cms-panel-layout" data-expandOnClick="true" data-layout-type="border" id="cms-content-tools-CMSPageHistoryController">
2  
-	<div class="cms-content-header north">
3  
-		<div>
4  
-			<h2><% _t('CMSPageHistoryController.History','History') %></h2>
5  
-		</div>
6  
-	</div>
7 2
 	
8 3
 	<div class="cms-panel-content cms-helper-hide-actions center">
9 4
 		$VersionsForm
1  templates/Includes/CMSPageSettingsController_Tools.ss
... ...
@@ -1 +0,0 @@
1  
-<% include CMSPageEditController_Tools %>
30  templates/Includes/CMSPagesController_Content.ss
@@ -9,10 +9,10 @@
9 9
 			<div class="cms-content-header-tabs">
10 10
 				<ul>
11 11
 					<li>
12  
-						<a href="#cms-content-treeview" class="content-treeview"><% _t('CMSPagesController.TreeView', 'Tree View') %></a>
  12
+						<a href="#cms-content-treeview" class="content-treeview cms-panel-link" data-href="$LinkTreeView"><% _t('CMSPagesController.TreeView', 'Tree View') %></a>
13 13
 					</li>
14 14
 					<li>
15  
-						<a href="#cms-content-listview" class="content-listview"><% _t('CMSPagesController.ListView', 'List View') %></a>
  15
+						<a href="#cms-content-listview" class="content-listview cms-panel-link"  data-href="$LinkListView"><% _t('CMSPagesController.ListView', 'List View') %></a>
16 16
 					</li>
17 17
 					<!--
18 18
 					<li>
@@ -28,30 +28,12 @@
28 28
 
29 29
 	<div class="cms-content-fields center ui-widget-content cms-panel-padded">
30 30
 		
31  
-		<div id="cms-content-treeview">
32  
-			
33  
-			<div class="cms-content-toolbar">
34  
-				<% include CMSPagesController_ContentToolbar %>
35  
-			</div>
36  
-			
37  
-			<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-hints="$SiteTreeHints">
38  
-				$SiteTreeAsUL
39  
-			</div>
40  
-			
41  
-			<div class="ss-dialog cms-page-add-form-dialog cms-dialog-content" id="cms-page-add-form" title="<% _t('CMSMain.AddNew', 'Add new page') %>">
42  
-				$AddForm
43  
-			</div>
44  
-
  31
+		<div class="cms-content-view cms-panel-deferred" id="cms-content-treeview" data-url="$LinkTreeView">
  32
+			<%-- Lazy-loaded via ajax --%>
45 33
 		</div>
46 34
 	
47  
-		<div id="cms-content-listview">
48  
-			<div class="cms-content-toolbar">
49  
-				<% include CMSPagesController_ContentToolActions %>
50  
-			</div>
51  
-			
52  
-			<div class="cms-list" data-url-list="$Link(getListViewHTML)">
53  
-				$ListView
54  
-			</div>
  35
+		<div class="cms-content-view cms-panel-deferred" id="cms-content-listview" data-url="$LinkListView">
  36
+			<%-- Lazy-loaded via ajax --%>
55 37
 		</div>
56 38
 		<!--
57 39
 		<div id="cms-content-galleryview">
2  templates/Includes/CMSPagesController_ContentToolActions.ss
... ...
@@ -1,5 +1,5 @@
1 1
 <div class="cms-actions-row">
2  
-	<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>
  2
+	<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>
3 3
 </div>
4 4
 
5 5
 <div class="cms-content-batchactions">

0 notes on commit 6aeac37

Please sign in to comment.
Something went wrong with that request. Please try again.