From f71804e46506ee0d30f8e8c13f7748c583e556f3 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 26 Oct 2009 03:06:42 +0000 Subject: [PATCH] API CHANGE: Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog. MINOR: Replaced usage of renamed classes with the new namespaced name. From: Sam Minnee git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@90076 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/CMSMain.php | 4 ++-- code/ModelAdmin.php | 20 ++++++++++---------- code/{SSReport.php => Report.php} | 14 +++++++------- code/ReportAdmin.php | 14 +++++++------- code/SideReport.php | 2 +- code/StaticExporter.php | 2 +- tests/LeftAndMainTest.php | 2 +- tests/SideReportTest.php | 4 ++-- 8 files changed, 31 insertions(+), 31 deletions(-) rename code/{SSReport.php => Report.php} (89%) mode change 100644 => 100755 tests/SideReportTest.php diff --git a/code/CMSMain.php b/code/CMSMain.php index 2d72159c..5c1ac4f3 100755 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -1208,10 +1208,10 @@ JS; return FormResponse::respond(); } else { - return new HTTPResponse("SiteTree #$id not found", 400); + return new SS_HTTPResponse("SiteTree #$id not found", 400); } } else { - return new HTTPResponse("Please pass an ID in the form content", 400); + return new SS_HTTPResponse("Please pass an ID in the form content", 400); } } diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index c97845a0..027dce0d 100755 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -332,7 +332,7 @@ class ModelAdmin_CollectionController extends Controller { * Delegate to the RecordController if a valid numeric ID appears in the URL * segment. * - * @param HTTPRequest $request + * @param SS_HTTPRequest $request * @return RecordController */ public function handleID($request) { @@ -480,7 +480,7 @@ class ModelAdmin_CollectionController extends Controller { * * @param array $data * @param Form $form - * @param HTTPRequest $request + * @param SS_HTTPRequest $request */ function import($data, $form, $request) { $modelName = $data['ClassName']; @@ -610,7 +610,7 @@ class ModelAdmin_CollectionController extends Controller { $numResults = $tableField->TotalCount(); if($numResults) { - return new HTTPResponse( + return new SS_HTTPResponse( $resultsForm->forTemplate(), 200, sprintf( @@ -619,7 +619,7 @@ class ModelAdmin_CollectionController extends Controller { ) ); } else { - return new HTTPResponse( + return new SS_HTTPResponse( $resultsForm->forTemplate(), 200, _t('ModelAdmin.NORESULTS',"Your search didn't return any matching items") @@ -710,7 +710,7 @@ class ModelAdmin_CollectionController extends Controller { */ function ResultsForm($searchCriteria) { - if($searchCriteria instanceof HTTPRequest) $searchCriteria = $searchCriteria->getVars(); + if($searchCriteria instanceof SS_HTTPRequest) $searchCriteria = $searchCriteria->getVars(); $tf = $this->getResultsTable($searchCriteria); @@ -749,7 +749,7 @@ class ModelAdmin_CollectionController extends Controller { * @return unknown */ function add($request) { - return new HTTPResponse( + return new SS_HTTPResponse( $this->AddForm()->forAjaxTemplate(), 200, sprintf( @@ -816,7 +816,7 @@ class ModelAdmin_CollectionController extends Controller { if(Director::is_ajax()) { $recordController = new ModelAdmin_RecordController($this, $request, $model->ID); - return new HTTPResponse( + return new SS_HTTPResponse( $recordController->EditForm()->forAjaxTemplate(), 200, sprintf( @@ -867,7 +867,7 @@ class ModelAdmin_RecordController extends Controller { function edit($request) { if ($this->currentRecord) { if(Director::is_ajax()) { - return new HTTPResponse( + return new SS_HTTPResponse( $this->EditForm()->forAjaxTemplate(), 200, sprintf( @@ -924,7 +924,7 @@ class ModelAdmin_RecordController extends Controller { * * @param array $data * @param Form $form - * @param HTTPRequest $request + * @param SS_HTTPRequest $request * @return mixed */ function doSave($data, $form, $request) { @@ -962,7 +962,7 @@ class ModelAdmin_RecordController extends Controller { /** * Renders the record view template. * - * @param HTTPRequest $request + * @param SS_HTTPRequest $request * @return mixed */ function view($request) { diff --git a/code/SSReport.php b/code/Report.php similarity index 89% rename from code/SSReport.php rename to code/Report.php index 518567ee..71ff6ade 100644 --- a/code/SSReport.php +++ b/code/Report.php @@ -4,12 +4,12 @@ * viewable in the Reports top menu section of CMS. * * To include your own report into the ReportAdmin - * of the CMS, your subclass of SSReport should + * of the CMS, your subclass of SS_Report should * overload these: * - * @link SSReport::$title - * @link SSReport::$description - * @link SSReport->getReportField() + * @link SS_Report::$title + * @link SS_Report::$description + * @link SS_Report->getReportField() * * getReportField() should return a FormField instance, * such as a ComplexTableField, or TableListField. This @@ -20,13 +20,13 @@ * a TableListField listing orders that have the property * "Unprinted = 1". * - * @see ReportAdmin for where SSReport instances are + * @see ReportAdmin for where SS_Report instances are * used in the CMS. * * @package cms * @subpackage reports */ -class SSReport extends ViewableData { +class SS_Report extends ViewableData { /** * This is the title of the report, @@ -51,7 +51,7 @@ class SSReport extends ViewableData { * data objects. * * @uses getReportField() to render a table, or similar field for the report. This - * method should be defined on the SSReport subclasses. + * method should be defined on the SS_Report subclasses. * * @return FieldSet */ diff --git a/code/ReportAdmin.php b/code/ReportAdmin.php index 82cf1cf9..a1db6556 100755 --- a/code/ReportAdmin.php +++ b/code/ReportAdmin.php @@ -3,10 +3,10 @@ * Reports section of the CMS. * * All reports that should show in the ReportAdmin section - * of the CMS need to subclass {@link SSReport}, and implement + * of the CMS need to subclass {@link SS_Report}, and implement * the appropriate methods and variables that are required. * - * @see SSReport + * @see SS_Report * * @package cms * @subpackage reports @@ -47,7 +47,7 @@ class ReportAdmin extends LeftAndMain { */ public function getReportClassNames() { - $baseClass = 'SSReport'; + $baseClass = 'SS_Report'; $response = array(); // get all sub-classnames (incl. base classname). @@ -98,7 +98,7 @@ class ReportAdmin extends LeftAndMain { } /** - * Return a DataObjectSet of SSReport subclasses + * Return a DataObjectSet of SS_Report subclasses * that are available for use. * * @return DataObjectSet @@ -121,7 +121,7 @@ class ReportAdmin extends LeftAndMain { /** * Show a report based on the URL query string. * - * @param HTTPRequest $request The HTTP request object + * @param SS_HTTPRequest $request The HTTP request object */ public function show($request) { $params = $request->allParams(); @@ -193,7 +193,7 @@ class ReportAdmin extends LeftAndMain { $actions = new FieldSet(); if(is_numeric($id)) $page = DataObject::get_by_id('SiteTree', $id); - $reportClass = is_object($page) ? 'SSReport_' . $page->ClassName : $id; + $reportClass = is_object($page) ? 'SS_Report_' . $page->ClassName : $id; $obj = new $reportClass(); if($obj) $fields = $obj->getCMSFields(); @@ -214,7 +214,7 @@ class ReportAdmin extends LeftAndMain { * * The test for an existance of a report * is done by checking for a subclass of - * "SSReport" that exists. + * "SS_Report" that exists. * * @return boolean */ diff --git a/code/SideReport.php b/code/SideReport.php index c7cbffe4..65fe66a2 100755 --- a/code/SideReport.php +++ b/code/SideReport.php @@ -107,7 +107,7 @@ class SideReport_RecentlyEdited extends SideReport { return _t('SideReport.LAST2WEEKS',"Pages edited in the last 2 weeks"); } function records($params = null) { - $threshold = strtotime('-14 days', SSDatetime::now()->Format('U')); + $threshold = strtotime('-14 days', SS_Datetime::now()->Format('U')); return DataObject::get("SiteTree", "\"SiteTree\".\"LastEdited\" > '".date("Y-m-d H:i:s", $threshold)."'", "\"SiteTree\".\"LastEdited\" DESC"); } function fieldsToShow() { diff --git a/code/StaticExporter.php b/code/StaticExporter.php index 206079fc..0316a5b9 100755 --- a/code/StaticExporter.php +++ b/code/StaticExporter.php @@ -92,7 +92,7 @@ class StaticExporter extends Controller { Filesystem::removeFolder($tmpBaseFolder); // return as download to the client - $response = HTTPRequest::send_file($archiveContent, "$baseFolderName.tar.gz", 'application/x-tar-gz'); + $response = SS_HTTPRequest::send_file($archiveContent, "$baseFolderName.tar.gz", 'application/x-tar-gz'); echo $response->output(); } diff --git a/tests/LeftAndMainTest.php b/tests/LeftAndMainTest.php index d5b3a527..8f9cad55 100644 --- a/tests/LeftAndMainTest.php +++ b/tests/LeftAndMainTest.php @@ -30,7 +30,7 @@ class LeftAndMainTest extends FunctionalTest { $response = $this->get($link); - $this->assertType('HTTPResponse', $response, "$link should return a response object"); + $this->assertType('SS_HTTPResponse', $response, "$link should return a response object"); $this->assertEquals(200, $response->getStatusCode(), "$link should return 200 status code"); // Check that a HTML page has been returned $this->assertRegExp('/]*>/i', $response->getBody(), "$link should contain tag"); diff --git a/tests/SideReportTest.php b/tests/SideReportTest.php old mode 100644 new mode 100755 index 2165ca4b..5964c10e --- a/tests/SideReportTest.php +++ b/tests/SideReportTest.php @@ -23,7 +23,7 @@ class SideReportTest extends SapphireTest { } function testRecentlyEdited() { - SSDateTime::set_mock_now('31-06-2009 00:00:00'); + SS_Datetime::set_mock_now('31-06-2009 00:00:00'); $after = $this->objFromFixture('SiteTree', 'after'); $before = $this->objFromFixture('SiteTree', 'before'); @@ -35,6 +35,6 @@ class SideReportTest extends SapphireTest { $this->assertContains($after->ID, $r->records()->column('ID')); $this->assertNotContains($before->ID, $r->records()->column('ID')); - SSDateTime::clear_mock_now(); + SS_DateTime::clear_mock_now(); } } \ No newline at end of file