Trim some unnecessary API

This commit is contained in:
Damian Mooyman 2017-12-13 14:35:21 +13:00
parent 8a04e9c46b
commit 073cb77500
2 changed files with 14 additions and 18 deletions

View File

@ -143,7 +143,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
); );
private static $url_handlers = [ private static $url_handlers = [
'EditForm/$ID' => 'EditForm' 'EditForm/$ID' => 'EditForm',
]; ];
private static $casting = array( private static $casting = array(
@ -902,16 +902,12 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
); );
$dateGroup->setTitle(_t('SilverStripe\\CMS\\Search\\SearchForm.PAGEFILTERDATEHEADING', 'Last edited')); $dateGroup->setTitle(_t('SilverStripe\\CMS\\Search\\SearchForm.PAGEFILTERDATEHEADING', 'Last edited'));
// view mode
$viewMode = HiddenField::create('view', false, $this->ViewState('listview'));
// Create the Field list // Create the Field list
$fields = new FieldList( $fields = new FieldList(
$content, $content,
$pageFilter, $pageFilter,
$pageClasses, $pageClasses,
$dateGroup, $dateGroup
$viewMode
); );
// Create the Search and Reset action // Create the Search and Reset action
@ -1390,26 +1386,32 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
* This method exclusively handles deferred ajax requests to render the * This method exclusively handles deferred ajax requests to render the
* pages tree deferred handler (no pjax-fragment) * pages tree deferred handler (no pjax-fragment)
* *
* @return string HTML * @return DBHTMLText HTML response with the rendered treeview
*/ */
public function treeview() public function treeview()
{ {
return $this->renderWith($this->getTemplatesWithSuffix('_TreeView')); return $this->renderWith($this->getTemplatesWithSuffix('_TreeView'));
} }
public function listview($request) /**
* Returns deferred listview for the current level
*
* @return DBHTMLText HTML response with the rendered listview
*/
public function listview()
{ {
return $this->renderWith($this->getTemplatesWithSuffix('_ListView')); return $this->renderWith($this->getTemplatesWithSuffix('_ListView'));
} }
/** /**
* Get view state based on the current action
*
* @param string $default * @param string $default
* @return string * @return string
*/ */
public function ViewState($default = 'treeview') public function ViewState($default = 'treeview')
{ {
$mode = $this->getRequest()->requestVar('view') $mode = $this->getRequest()->param('Action');
?: $this->getRequest()->param('Action');
switch ($mode) { switch ($mode) {
case 'listview': case 'listview':
case 'treeview': case 'treeview':
@ -1419,11 +1421,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
} }
} }
public function RequestViewState()
{
return $this->getRequest()->requestVar('view');
}
/** /**
* Callback to request the list of page types allowed under a given page instance. * Callback to request the list of page types allowed under a given page instance.
* Provides a slower but more precise response over SiteTreeHints * Provides a slower but more precise response over SiteTreeHints
@ -1508,7 +1505,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
public function ListViewForm() public function ListViewForm()
{ {
$params = $this->getRequest()->requestVar('q'); $params = $this->getRequest()->requestVar('q');
// $parentID = $this->getRequest()->param('ParentID');
$parentID = $this->getRequest()->requestVar('ParentID'); $parentID = $this->getRequest()->requestVar('ParentID');
$list = $this->getList($params, $parentID); $list = $this->getList($params, $parentID);
$gridFieldConfig = GridFieldConfig::create()->addComponents( $gridFieldConfig = GridFieldConfig::create()->addComponents(

View File

@ -4,9 +4,9 @@
data-url-treeview="$LinkTreeViewDeferred" data-url-treeview="$LinkTreeViewDeferred"
data-url-listview="$LinkListViewDeferred" data-url-listview="$LinkListViewDeferred"
data-url-listviewroot="$LinkListViewRoot" data-url-listviewroot="$LinkListViewRoot"
data-no-ajax="<% if $TreeIsFiltered || $RequestViewState = 'listview'%>true<% else %>false<% end_if %>" data-no-ajax="<% if $TreeIsFiltered %>true<% else %>false<% end_if %>"
> >
<% if $TreeIsFiltered || $RequestViewState = 'listview' %> <% if $TreeIsFiltered %>
<% include SilverStripe\\CMS\\Controllers\\CMSMain_ListView %> <% include SilverStripe\\CMS\\Controllers\\CMSMain_ListView %>
<% else %> <% else %>
<%-- Lazy-loaded via ajax --%> <%-- Lazy-loaded via ajax --%>