UPDATE: change all instances of $this->request to use appropriate getter/setter

This commit is contained in:
Stevie Mayhew 2015-04-30 11:04:02 +12:00
parent c8262f6202
commit 7ddf5fa697
9 changed files with 55 additions and 55 deletions

View File

@ -50,8 +50,8 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{
* Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
*/
public function currentPageID() {
if(is_numeric($this->request->requestVar('ID'))) {
return $this->request->requestVar('ID');
if(is_numeric($this->getRequest()->requestVar('ID'))) {
return $this->getRequest()->requestVar('ID');
} elseif (is_numeric($this->urlParams['ID'])) {
return $this->urlParams['ID'];
} elseif(Session::get("{$this->class}.currentPage")) {
@ -100,15 +100,15 @@ JS
$context = $this->getSearchContext();
// Overwrite name filter to search both Name and Title attributes
$context->removeFilterByName('Name');
$params = $this->request->requestVar('q');
$params = $this->getRequest()->requestVar('q');
$list = $context->getResults($params);
// Don't filter list when a detail view is requested,
// to avoid edge cases where the filtered list wouldn't contain the requested
// record due to faulty session state (current folder not always encoded in URL, see #7408).
if(!$folder->ID
&& $this->request->requestVar('ID') === null
&& ($this->request->param('ID') == 'field')
&& $this->getRequest()->requestVar('ID') === null
&& ($this->getRequest()->param('ID') == 'field')
) {
return $list;
}
@ -423,7 +423,7 @@ JS
$form->setFormMethod('GET');
$form->setFormAction(Controller::join_links($this->Link('show'), $folder->ID));
$form->addExtraClass('cms-search-form');
$form->loadDataFrom($this->request->getVars());
$form->loadDataFrom($this->getRequest()->getVars());
$form->disableSecurityToken();
// This have to match data-name attribute on the gridfield so that the javascript selectors work
$form->setAttribute('data-gridfield', 'File');
@ -437,7 +437,7 @@ JS
'AddForm',
new FieldList(
new TextField("Name", _t('File.Name')),
new HiddenField('ParentID', false, $this->request->getVar('ParentID'))
new HiddenField('ParentID', false, $this->getRequest()->getVar('ParentID'))
),
new FieldList(
FormAction::create('doAdd', _t('AssetAdmin_left_ss.GO','Go'))
@ -669,16 +669,16 @@ JS
$items[0]->Link = Controller::join_links(singleton('AssetAdmin')->Link('show'), 0);
// If a search is in progress, don't show the path
if($this->request->requestVar('q')) {
if($this->getRequest()->requestVar('q')) {
$items = $items->limit(1);
$items->push(new ArrayData(array(
'Title' => _t('LeftAndMain.SearchResults', 'Search Results'),
'Link' => Controller::join_links($this->Link(), '?' . http_build_query(array('q' => $this->request->requestVar('q'))))
'Link' => Controller::join_links($this->Link(), '?' . http_build_query(array('q' => $this->getRequest()->requestVar('q'))))
)));
}
// If we're adding a folder, note that in breadcrumbs as well
if($this->request->param('Action') == 'addfolder') {
if($this->getRequest()->param('Action') == 'addfolder') {
$items->push(new ArrayData(array(
'Title' => _t('Folder.AddFolderButton', 'Add folder'),
'Link' => false

View File

@ -36,8 +36,8 @@ class CMSFileAddController extends LeftAndMain {
* Return fake-ID "root" if no ID is found (needed to upload files into the root-folder)
*/
public function currentPageID() {
if(is_numeric($this->request->requestVar('ID'))) {
return $this->request->requestVar('ID');
if(is_numeric($this->getRequest()->requestVar('ID'))) {
return $this->getRequest()->requestVar('ID');
} elseif (is_numeric($this->urlParams['ID'])) {
return $this->urlParams['ID'];
} elseif(Session::get("{$this->class}.currentPage")) {

View File

@ -59,7 +59,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
public function init() {
// set reading lang
if(SiteTree::has_extension('Translatable') && !$this->request->isAjax()) {
if(SiteTree::has_extension('Translatable') && !$this->getRequest()->isAjax()) {
Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree')));
}
@ -203,8 +203,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
public function LinkWithSearch($link) {
// Whitelist to avoid side effects
$params = array(
'q' => (array)$this->request->getVar('q'),
'ParentID' => $this->request->getVar('ParentID')
'q' => (array)$this->getRequest()->getVar('q'),
'ParentID' => $this->getRequest()->getVar('ParentID')
);
$link = Controller::join_links(
$link,
@ -265,7 +265,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
* @return boolean
*/
public function TreeIsFiltered() {
return $this->request->getVar('q');
return $this->getRequest()->getVar('q');
}
public function ExtraTreeTools() {
@ -344,7 +344,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
->unsetValidator();
// Load the form with previously sent search data
$form->loadDataFrom($this->request->getVars());
$form->loadDataFrom($this->getRequest()->getVars());
// Allow decorators to modify the form
$this->extend('updateSearchForm', $form);
@ -367,7 +367,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
}
public function doSearch($data, $form) {
return $this->getsubtree($this->request);
return $this->getsubtree($this->getRequest());
}
/**
@ -402,7 +402,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// Generate basic cache key. Too complex to encompass all variations
$cache = SS_Cache::factory('CMSMain_SiteTreeHints');
$cacheKey = md5(implode('_', array(Member::currentUserID(), implode(',', $cacheCanCreate), implode(',', $classes))));
if($this->request->getVar('flush')) $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
if($this->getRequest()->getVar('flush')) $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
$json = $cache->load($cacheKey);
if(!$json) {
$def['Root'] = array();
@ -515,8 +515,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
return $id;
}
else if($id && is_numeric($id)) {
if($this->request->getVar('Version')) {
$versionID = (int) $this->request->getVar('Version');
if($this->getRequest()->getVar('Version')) {
$versionID = (int) $this->getRequest()->getVar('Version');
}
if($versionID) {
@ -753,8 +753,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
}
public function ListViewForm() {
$params = $this->request->requestVar('q');
$list = $this->getList($params, $parentID = $this->request->requestVar('ParentID'));
$params = $this->getRequest()->requestVar('q');
$list = $this->getList($params, $parentID = $this->getRequest()->requestVar('ParentID'));
$gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldSortableHeader(),
new GridFieldDataColumns(),
@ -895,7 +895,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
$record->doPublish();
}
return $this->getResponseNegotiator()->respond($this->request);
return $this->getResponseNegotiator()->respond($this->getRequest());
}
/**
@ -1004,7 +1004,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
);
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
return $this->getResponseNegotiator()->respond($this->request);
return $this->getResponseNegotiator()->respond($this->getRequest());
}
/**
@ -1051,7 +1051,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
))
);
return $this->getResponseNegotiator()->respond($this->request);
return $this->getResponseNegotiator()->respond($this->getRequest());
}
/**
@ -1074,7 +1074,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
);
// Even if the record has been deleted from stage and live, it can be viewed in "archive mode"
return $this->getResponseNegotiator()->respond($this->request);
return $this->getResponseNegotiator()->respond($this->getRequest());
}
public function publish($data, $form) {
@ -1097,7 +1097,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
rawurlencode(_t('CMSMain.REMOVEDPAGE',"Removed '{title}' from the published site", array('title' => $record->Title)))
);
return $this->getResponseNegotiator()->respond($this->request);
return $this->getResponseNegotiator()->respond($this->getRequest());
}
/**
@ -1106,7 +1106,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
public function rollback() {
return $this->doRollback(array(
'ID' => $this->currentPageID(),
'Version' => $this->request->param('VersionID')
'Version' => $this->getRequest()->param('VersionID')
), null);
}
@ -1148,10 +1148,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// The X-Pjax header forces a "full" content refresh on redirect.
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $record->ID);
$this->response->addHeader('X-ControllerURL', $url);
$this->request->addHeader('X-Pjax', 'Content');
$this->getRequest()->addHeader('X-Pjax', 'Content');
$this->response->addHeader('X-Pjax', 'Content');
return $this->getResponseNegotiator()->respond($this->request);
return $this->getResponseNegotiator()->respond($this->getRequest());
}
/**
@ -1301,7 +1301,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
))
);
return $this->getResponseNegotiator()->respond($this->request);
return $this->getResponseNegotiator()->respond($this->getRequest());
}
public function duplicate($request) {
@ -1331,10 +1331,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
);
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $newPage->ID);
$this->response->addHeader('X-ControllerURL', $url);
$this->request->addHeader('X-Pjax', 'Content');
$this->getRequest()->addHeader('X-Pjax', 'Content');
$this->response->addHeader('X-Pjax', 'Content');
return $this->getResponseNegotiator()->respond($this->request);
return $this->getResponseNegotiator()->respond($this->getRequest());
} else {
return new SS_HTTPResponse("CMSMain::duplicate() Bad ID: '$id'", 400);
}
@ -1361,10 +1361,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
);
$url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $newPage->ID);
$this->response->addHeader('X-ControllerURL', $url);
$this->request->addHeader('X-Pjax', 'Content');
$this->getRequest()->addHeader('X-Pjax', 'Content');
$this->response->addHeader('X-Pjax', 'Content');
return $this->getResponseNegotiator()->respond($this->request);
return $this->getResponseNegotiator()->respond($this->getRequest());
} else {
return new SS_HTTPResponse("CMSMain::duplicatewithchildren() Bad ID: '$id'", 400);
}

View File

@ -96,7 +96,7 @@ class CMSPageAddController extends CMSPageEditController {
// CMSMain->currentPageID() automatically sets the homepage,
// which we need to counteract in the default selection (which should default to root, ID=0)
if($parentID = $this->request->getVar('ParentID')) {
if($parentID = $this->getRequest()->getVar('ParentID')) {
$parentModeField->setValue('child');
$parentField->setValue((int)$parentID);
} else {
@ -156,7 +156,7 @@ class CMSPageAddController extends CMSPageEditController {
$record->write();
} catch(ValidationException $ex) {
$form->sessionMessage($ex->getResult()->message(), 'bad');
return $this->getResponseNegotiator()->respond($this->request);
return $this->getResponseNegotiator()->respond($this->getRequest());
}
$editController = singleton('CMSPageEditController');

View File

@ -80,7 +80,7 @@ class CMSPageHistoryController extends CMSMain {
}
public function getSilverStripeNavigator() {
$record = $this->getRecord($this->currentPageID(), $this->request->param('VersionID'));
$record = $this->getRecord($this->currentPageID(), $this->getRequest()->param('VersionID'));
if($record) {
$navigator = new SilverStripeNavigator($record);
return $navigator->renderWith($this->getTemplatesWithSuffix('_SilverStripeNavigator'));
@ -194,9 +194,9 @@ class CMSPageHistoryController extends CMSMain {
$page = $this->getRecord($id);
$versionsHtml = '';
$action = $this->request->param('Action');
$versionID = $this->request->param('VersionID');
$otherVersionID = $this->request->param('OtherVersionID');
$action = $this->getRequest()->param('Action');
$versionID = $this->getRequest()->param('VersionID');
$otherVersionID = $this->getRequest()->param('OtherVersionID');
$showUnpublishedChecked = 0;
$compareModeChecked = ($action == "compare");
@ -260,7 +260,7 @@ class CMSPageHistoryController extends CMSMain {
$actions
)->setHTMLID('Form_VersionsForm');
$form->setResponseNegotiator($this->getResponseNegotiator());
$form->loadDataFrom($this->request->requestVars());
$form->loadDataFrom($this->getRequest()->requestVars());
$hiddenID->setValue($id);
$form->unsetValidator();
@ -291,7 +291,7 @@ class CMSPageHistoryController extends CMSMain {
$form = $this->CompareVersionsForm($version1, $version2);
// javascript solution, render into template
if($this->request->isAjax()) {
if($this->getRequest()->isAjax()) {
return $this->customise(array(
"EditForm" => $form
))->renderWith(array(

View File

@ -20,7 +20,7 @@ class CMSPagesController extends CMSMain {
* @return String
*/
public function ViewState() {
return $this->request->getVar('view');
return $this->getRequest()->getVar('view');
}
public function isCurrentPage(DataObject $record) {
@ -31,7 +31,7 @@ class CMSPagesController extends CMSMain {
$items = parent::Breadcrumbs($unlinked);
//special case for building the breadcrumbs when calling the listchildren Pages ListView action
if($parentID = $this->request->getVar('ParentID')) {
if($parentID = $this->getRequest()->getVar('ParentID')) {
$page = DataObject::get_by_id('SiteTree', $parentID);
//build a reversed list of the parent tree
@ -43,8 +43,8 @@ class CMSPagesController extends CMSMain {
//turns the title and link of the breadcrumbs into template-friendly variables
$params = array_filter(array(
'view' => $this->request->getVar('view'),
'q' => $this->request->getVar('q')
'view' => $this->getRequest()->getVar('view'),
'q' => $this->getRequest()->getVar('q')
));
foreach($pages as $page) {
$params['ParentID'] = $page->ID;

View File

@ -215,7 +215,7 @@ class ContentController extends Controller {
*/
public function httpError($code, $message = null) {
// Don't use the HTML response for media requests
$response = $this->request->isMedia() ? null : ErrorPage::response_for($code);
$response = $this->getRequest()->isMedia() ? null : ErrorPage::response_for($code);
// Failover to $message if the HTML response is unavailable / inappropriate
parent::httpError($code, $response ? $response : $message);
}

View File

@ -47,7 +47,7 @@ class ModelAsController extends Controller implements NestedController {
* @return SS_HTTPResponse
*/
public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
$this->request = $request;
$this->setRequest($request);
$this->setDataModel($model);
$this->pushCurrent();
@ -75,7 +75,7 @@ class ModelAsController extends Controller implements NestedController {
$result = $this->getNestedController();
if($result instanceof RequestHandler) {
$result = $result->handleRequest($this->request, $model);
$result = $result->handleRequest($this->getRequest(), $model);
} else if(!($result instanceof SS_HTTPResponse)) {
user_error("ModelAsController::getNestedController() returned bad object type '" .
get_class($result)."'", E_USER_WARNING);
@ -93,7 +93,7 @@ class ModelAsController extends Controller implements NestedController {
* @throws Exception If URLSegment not passed in as a request parameter.
*/
public function getNestedController() {
$request = $this->request;
$request = $this->getRequest();
if(!$URLSegment = $request->param('URLSegment')) {
throw new Exception('ModelAsController->getNestedController(): was not passed a URLSegment value.');
@ -125,7 +125,7 @@ class ModelAsController extends Controller implements NestedController {
Debug::message("Using record #$sitetree->ID of type $sitetree->class with link {$sitetree->Link()}");
}
return self::controller_for($sitetree, $this->request->param('Action'));
return self::controller_for($sitetree, $this->getRequest()->param('Action'));
}
/**

View File

@ -17,8 +17,8 @@ class ContentControllerSearchExtension extends Extension {
public function SearchForm() {
$searchText = _t('SearchForm.SEARCH', 'Search');
if($this->owner->request && $this->owner->request->getVar('Search')) {
$searchText = $this->owner->request->getVar('Search');
if($this->owner->getRequest() && $this->owner->getRequest()->getVar('Search')) {
$searchText = $this->owner->getRequest()->getVar('Search');
}
$fields = new FieldList(