diff --git a/_config.php b/_config.php old mode 100644 new mode 100755 index 6b0f5553f..2df556ef3 --- a/_config.php +++ b/_config.php @@ -36,17 +36,19 @@ Director::addRules(1, array( '$URLSegment//$Action/$ID/$OtherID' => 'ModelAsController', )); -/** - * Register the default internal shortcodes. - */ +/** + * Register the default internal shortcodes. + */ ShortcodeParser::get('default')->register('sitetree_link', array('SiteTree', 'link_shortcode_handler')); /** - * PHP 5.2 has a namespace conflict with our datetime class, - * for legacy support, we use this overload method. - * // ENFORCE STRONG_CREATE + * PHP 5.2 introduced a conflict with the Datetime field type, which was renamed to SSDatetime. This was later renamed + * to SS_Datetime to be consistent with other namespaced classes. + * + * Overload both of these to support legacy code. */ -Object::useCustomClass('Datetime','SSDatetime',true); +Object::useCustomClass('SSDatetime', 'SS_Datetime', true); +Object::useCustomClass('Datetime', 'SS_Datetime', true); /** diff --git a/api/RestfulService.php b/api/RestfulService.php index 95aaa878c..84a066eda 100644 --- a/api/RestfulService.php +++ b/api/RestfulService.php @@ -315,7 +315,7 @@ class RestfulService extends ViewableData { } } -class RestfulService_Response extends HTTPResponse { +class RestfulService_Response extends SS_HTTPResponse { protected $simpleXML; function __construct($body, $statusCode = 200, $headers = null) { diff --git a/api/SOAPModelAccess.php b/api/SOAPModelAccess.php index a326aa530..a8ebdbfc4 100755 --- a/api/SOAPModelAccess.php +++ b/api/SOAPModelAccess.php @@ -239,7 +239,7 @@ class SOAPModelAccess extends SapphireSoapServer { } /** - * @param HTTPResponse $response + * @param SS_HTTPResponse $response * @return string XML string containing the HTTP error message */ protected function getErrorMessage($response) { diff --git a/core/ClassInfo.php b/core/ClassInfo.php index e897eb15f..41de16ec7 100755 --- a/core/ClassInfo.php +++ b/core/ClassInfo.php @@ -30,7 +30,7 @@ class ClassInfo { private static $_cache_all_tables = null; /** - * @todo Move this to Database or DB + * @todo Move this to SS_Database or DB */ static function hasTable($class) { if(DB::isActive()) { diff --git a/core/HTTP.php b/core/HTTP.php index 305f6d34b..116e4dc6a 100644 --- a/core/HTTP.php +++ b/core/HTTP.php @@ -271,13 +271,13 @@ class HTTP { /** * Add the appropriate caching headers to the response, including If-Modified-Since / 304 handling. * - * @param HTTPResponse The HTTPResponse object to augment. Omitted the argument or passing a string is deprecated; in these + * @param SS_HTTPResponse The SS_HTTPResponse object to augment. Omitted the argument or passing a string is deprecated; in these * cases, the headers are output directly. */ static function add_cache_headers($body = null) { // Validate argument - if($body && !($body instanceof HTTPResponse)) { - user_error("HTTP::add_cache_headers() must be passed an HTTPResponse object", E_USER_WARNING); + if($body && !($body instanceof SS_HTTPResponse)) { + user_error("HTTP::add_cache_headers() must be passed an SS_HTTPResponse object", E_USER_WARNING); $body = null; } @@ -285,7 +285,7 @@ class HTTP { // below. if(Director::isDev()) return; - // The headers have been sent and we don't have an HTTPResponse object to attach things to; no point in us trying. + // The headers have been sent and we don't have an SS_HTTPResponse object to attach things to; no point in us trying. if(headers_sent() && !$body) return; // Popuplate $responseHeaders with all the headers that we want to build @@ -329,7 +329,7 @@ class HTTP { $responseHeaders['ETag'] = self::$etag; } - // Now that we've generated them, either output them or attach them to the HTTPResponse as appropriate + // Now that we've generated them, either output them or attach them to the SS_HTTPResponse as appropriate foreach($responseHeaders as $k => $v) { if($body) $body->addHeader($k, $v); else if(!headers_sent()) header("$k: $v"); diff --git a/core/Requirements.php b/core/Requirements.php index 319d360e1..e6a24e373 100644 --- a/core/Requirements.php +++ b/core/Requirements.php @@ -217,7 +217,7 @@ class Requirements { return self::backend()->includeInHTML($templateFile, $content); } - static function include_in_response(HTTPResponse $response) { + static function include_in_response(SS_HTTPResponse $response) { return self::backend()->include_in_response($response); } @@ -643,7 +643,7 @@ class Requirements_Backend { /** * Attach requirements inclusion to X-Include-JS and X-Include-CSS headers on the HTTP response */ - function include_in_response(HTTPResponse $response) { + function include_in_response(SS_HTTPResponse $response) { $this->process_combined_files(); $jsRequirements = array(); $cssRequirements = array(); diff --git a/core/control/ContentController.php b/core/control/ContentController.php index 3797a108f..334ffa6fe 100755 --- a/core/control/ContentController.php +++ b/core/control/ContentController.php @@ -123,9 +123,9 @@ class ContentController extends Controller { * This acts the same as {@link Controller::handleRequest()}, but if an action cannot be found this will attempt to * fall over to a child controller in order to provide functionality for nested URLs. * - * @return HTTPResponse + * @return SS_HTTPResponse */ - public function handleRequest(HTTPRequest $request) { + public function handleRequest(SS_HTTPRequest $request) { $child = null; $action = $request->param('Action'); @@ -163,7 +163,7 @@ class ContentController extends Controller { if($this->request->isMedia() || !$response = ErrorPage::response_for($code)) { parent::httpError($code, $message); } else { - throw new HTTPResponse_Exception($response); + throw new SS_HTTPResponse_Exception($response); } } diff --git a/core/control/ContentNegotiator.php b/core/control/ContentNegotiator.php index 8d5b20352..affaf7b7c 100755 --- a/core/control/ContentNegotiator.php +++ b/core/control/ContentNegotiator.php @@ -51,7 +51,7 @@ class ContentNegotiator { return self::$encoding; } - static function process(HTTPResponse $response) { + static function process(SS_HTTPResponse $response) { if(!self::enabled_for($response)) return; $mimes = array( @@ -100,11 +100,11 @@ class ContentNegotiator { * Assumes that a correct doctype is set, and doesn't change or append to it. * Replaces a few common tags and entities with their XHTML representations (
, ,  ). * - * @param $response HTTPResponse + * @param $response SS_HTTPResponse * @return string * @todo More flexible tag and entity parsing through regular expressions or tag definition lists */ - function xhtml(HTTPResponse $response) { + function xhtml(SS_HTTPResponse $response) { $content = $response->getBody(); // Only serve "pure" XHTML if the XML header is present @@ -130,7 +130,7 @@ class ContentNegotiator { * Replaces all occurrences of "application/xhtml+xml" with "text/html" in the template. * Removes "xmlns" attributes and any Pragmas. */ - function html(HTTPResponse $response) { + function html(SS_HTTPResponse $response) { $response->addHeader("Content-Type", "text/html; charset=" . self::$encoding); $response->addHeader("Vary", "Accept"); diff --git a/core/control/Controller.php b/core/control/Controller.php index 62289d5ac..579140dfb 100755 --- a/core/control/Controller.php +++ b/core/control/Controller.php @@ -18,8 +18,8 @@ class Controller extends RequestHandler { /** * @var array $requestParams Contains all GET and POST parameters - * passed to the current {@link HTTPRequest}. - * @uses HTTPRequest->requestVars() + * passed to the current {@link SS_HTTPRequest}. + * @uses SS_HTTPRequest->requestVars() */ protected $requestParams; @@ -46,13 +46,13 @@ class Controller extends RequestHandler { protected $basicAuthEnabled = true; /** - * @var HTTPResponse $response The response object that the controller returns. + * @var SS_HTTPResponse $response The response object that the controller returns. * Set in {@link handleRequest()}. */ protected $response; /** - * @var HTTPRequest $request The request object that the controller was called with. + * @var SS_HTTPRequest $request The request object that the controller was called with. * Set in {@link handleRequest()}. Useful to generate the {} */ protected $request; @@ -94,7 +94,7 @@ class Controller extends RequestHandler { } /** - * Executes this controller, and return an {@link HTTPResponse} object with the result. + * Executes this controller, and return an {@link SS_HTTPResponse} object with the result. * * This method first does a few set-up activities: * - Push this controller ont to the controller stack - @@ -119,18 +119,18 @@ class Controller extends RequestHandler { * and end the method with $this->popCurrent(). * Failure to do this will create weird session errors. * - * @param $request The {@link HTTPRequest} object that is responsible + * @param $request The {@link SS_HTTPRequest} object that is responsible * for distributing request parsing. - * @return HTTPResponse The response that this controller produces, + * @return SS_HTTPResponse The response that this controller produces, * including HTTP headers such as redirection info */ - function handleRequest(HTTPRequest $request) { + function handleRequest(SS_HTTPRequest $request) { if(!$request) user_error("Controller::handleRequest() not passed a request!", E_USER_ERROR); $this->pushCurrent(); $this->urlParams = $request->allParams(); $this->request = $request; - $this->response = new HTTPResponse(); + $this->response = new SS_HTTPResponse(); $this->extend('onBeforeInit'); @@ -148,8 +148,8 @@ class Controller extends RequestHandler { } $body = parent::handleRequest($request); - if($body instanceof HTTPResponse) { - if(isset($_REQUEST['debug_request'])) Debug::message("Request handler returned HTTPResponse object to $this->class controller; returning it without modification."); + if($body instanceof SS_HTTPResponse) { + if(isset($_REQUEST['debug_request'])) Debug::message("Request handler returned SS_HTTPResponse object to $this->class controller; returning it without modification."); $this->response = $body; } else { @@ -218,7 +218,7 @@ class Controller extends RequestHandler { } /** - * Returns the HTTPResponse object that this controller is building up. + * Returns the SS_HTTPResponse object that this controller is building up. * Can be used to set the status code and headers */ function getResponse() { @@ -229,7 +229,7 @@ class Controller extends RequestHandler { * Get the request with which this controller was called (if any). * Usually set in {@link handleRequest()}. * - * @return HTTPRequest + * @return SS_HTTPRequest */ function getRequest() { return $this->request; diff --git a/core/control/Director.php b/core/control/Director.php index 5df71268e..37c4c4271 100755 --- a/core/control/Director.php +++ b/core/control/Director.php @@ -77,7 +77,7 @@ class Director { * Process the given URL, creating the appropriate controller and executing it. * * Request processing is handled as folows: - * - Director::direct() creates a new HTTPResponse object and passes this to Director::handleRequest(). + * - Director::direct() creates a new SS_HTTPResponse object and passes this to Director::handleRequest(). * - Director::handleRequest($request) checks each of the Director rules and identifies a controller to handle this * request. * - Controller::handleRequest($request) is then called. This will find a rule to handle the URL, and call the rule @@ -108,7 +108,7 @@ class Director { } } - $req = new HTTPRequest( + $req = new SS_HTTPRequest( (isset($_SERVER['X-HTTP-Method-Override'])) ? $_SERVER['X-HTTP-Method-Override'] : $_SERVER['REQUEST_METHOD'], $url, $_GET, @@ -129,17 +129,17 @@ class Director { // Return code for a redirection request if(is_string($result) && substr($result,0,9) == 'redirect:') { - $response = new HTTPResponse(); + $response = new SS_HTTPResponse(); $response->redirect(substr($result, 9)); $response->output(); // Handle a controller } else if($result) { - if($result instanceof HTTPResponse) { + if($result instanceof SS_HTTPResponse) { $response = $result; } else { - $response = new HTTPResponse(); + $response = new SS_HTTPResponse(); $response->setBody($result); } @@ -170,7 +170,7 @@ class Director { * Overwritten by $postVars['_method'] if present. * @param string $body The HTTP body * @param array $headers HTTP headers with key-value pairs - * @return HTTPResponse + * @return SS_HTTPResponse * * @uses getControllerForURL() The rule-lookup logic is handled by this. * @uses Controller::run() Controller::run() handles the page logic for a Director::direct() call. @@ -219,7 +219,7 @@ class Director { $_COOKIE = array(); $_SERVER['REQUEST_URI'] = Director::baseURL() . $urlWithQuerystring; - $req = new HTTPRequest($httpMethod, $url, $getVars, $postVars, $body); + $req = new SS_HTTPRequest($httpMethod, $url, $getVars, $postVars, $body); if($headers) foreach($headers as $k => $v) $req->addHeader($k, $v); $result = Director::handleRequest($req, $session); @@ -242,11 +242,11 @@ class Director { } /** - * Handle an HTTP request, defined with a HTTPRequest object. + * Handle an HTTP request, defined with a SS_HTTPRequest object. * - * @return HTTPResponse|string + * @return SS_HTTPResponse|string */ - protected static function handleRequest(HTTPRequest $request, Session $session) { + protected static function handleRequest(SS_HTTPRequest $request, Session $session) { krsort(Director::$rules); if(isset($_REQUEST['debug'])) Debug::show(Director::$rules); @@ -732,7 +732,7 @@ class Director { */ static function set_environment_type($et) { if($et != 'dev' && $et != 'test' && $et != 'live') { - SSBacktrace::backtrace(); + SS_Backtrace::backtrace(); user_error("Director::set_environment_type passed '$et'. It should be passed dev, test, or live", E_USER_WARNING); } else { self::$environment_type = $et; diff --git a/core/control/HTTPRequest.php b/core/control/HTTPRequest.php index 126c2e14e..b5591f22e 100755 --- a/core/control/HTTPRequest.php +++ b/core/control/HTTPRequest.php @@ -4,7 +4,7 @@ * Represents a HTTP-request, including a URL that is tokenised for parsing, and a request method (GET/POST/PUT/DELETE). * This is used by {@link RequestHandler} objects to decide what to do. * - * The intention is that a single HTTPRequest object can be passed from one object to another, each object calling + * The intention is that a single SS_HTTPRequest object can be passed from one object to another, each object calling * match() to get the information that they need out of the URL. This is generally handled by * {@link RequestHandler::handleRequest()}. * @@ -14,7 +14,7 @@ * @package sapphire * @subpackage control */ -class HTTPRequest implements ArrayAccess { +class SS_HTTPRequest implements ArrayAccess { /** * @var string $url @@ -85,7 +85,7 @@ class HTTPRequest implements ArrayAccess { protected $unshiftedButParsedParts = 0; /** - * Construct a HTTPRequest from a URL relative to the site root. + * Construct a SS_HTTPRequest from a URL relative to the site root. */ function __construct($httpMethod, $url, $getVars = array(), $postVars = array(), $body = null) { $this->httpMethod = strtoupper(self::detect_method($httpMethod, $postVars)); @@ -176,7 +176,7 @@ class HTTPRequest implements ArrayAccess { } /** - * Checks if the {@link HTTPRequest->getExtension()} on this request matches one of the more common media types + * Checks if the {@link SS_HTTPRequest->getExtension()} on this request matches one of the more common media types * embedded into a webpage - e.g. css, png. * * This is useful for things like determining wether to display a fully rendered error page or not. Note that the @@ -265,12 +265,12 @@ class HTTPRequest implements ArrayAccess { function offsetUnset($offset) {} /** - * Construct an HTTPResponse that will deliver a file to the client + * Construct an SS_HTTPResponse that will deliver a file to the client */ static function send_file($fileData, $fileName, $mimeType = null) { if(!$mimeType) $mimeType = HTTP::getMimeType($fileName); - $response = new HTTPResponse($fileData); + $response = new SS_HTTPResponse($fileData); $response->addHeader("Content-Type", "$mimeType; name=\"" . addslashes($fileName) . "\""); $response->addHeader("Content-disposition", "attachment; filename=" . addslashes($fileName)); $response->addHeader("Content-Length", strlen($fileData)); diff --git a/core/control/HTTPResponse.php b/core/control/HTTPResponse.php index a74184f2b..7aedd8444 100755 --- a/core/control/HTTPResponse.php +++ b/core/control/HTTPResponse.php @@ -1,11 +1,11 @@ 'Continue', 101 => 'Switching Protocols', @@ -214,7 +214,7 @@ class HTTPResponse { */ public function getLinks() { user_error ( - 'HTTPResponse->getLinks() is deprecated, please use HTTP::getLinksIn() or DOMDocument.', E_USER_NOTICE + 'SS_HTTPResponse->getLinks() is deprecated, please use HTTP::getLinksIn() or DOMDocument.', E_USER_NOTICE ); $attributes = array('id', 'href', 'class'); @@ -238,46 +238,46 @@ class HTTPResponse { } /** - * A {@link HTTPResponse} encapsulated in an exception, which can interrupt the processing flow and be caught by the + * A {@link SS_HTTPResponse} encapsulated in an exception, which can interrupt the processing flow and be caught by the * {@link RequestHandler} and returned to the user. * * Example Usage: * - * throw new HTTPResponse_Exception('This request was invalid.', 400); - * throw new HTTPResponse_Exception(new HTTPResponse('There was an internal server error.', 500)); + * throw new SS_HTTPResponse_Exception('This request was invalid.', 400); + * throw new SS_HTTPResponse_Exception(new SS_HTTPResponse('There was an internal server error.', 500)); * * * @package sapphire * @subpackage control */ -class HTTPResponse_Exception extends Exception { +class SS_HTTPResponse_Exception extends Exception { protected $response; /** - * @see HTTPResponse::__construct(); + * @see SS_HTTPResponse::__construct(); */ public function __construct($body = null, $statusCode = null, $statusDescription = null) { - if($body instanceof HTTPResponse) { + if($body instanceof SS_HTTPResponse) { $this->setResponse($body); } else { - $this->setResponse(new HTTPResponse($body, $statusCode, $statusDescription)); + $this->setResponse(new SS_HTTPResponse($body, $statusCode, $statusDescription)); } parent::__construct($this->getResponse()->getBody(), $this->getResponse()->getStatusCode()); } /** - * @return HTTPResponse + * @return SS_HTTPResponse */ public function getResponse() { return $this->response; } /** - * @param HTTPResponse $response + * @param SS_HTTPResponse $response */ - public function setResponse(HTTPResponse $response) { + public function setResponse(SS_HTTPResponse $response) { $this->response = $response; } diff --git a/core/control/ModelAsController.php b/core/control/ModelAsController.php index 02624a687..6779cd819 100755 --- a/core/control/ModelAsController.php +++ b/core/control/ModelAsController.php @@ -32,9 +32,9 @@ class ModelAsController extends Controller implements NestedController { /** * @uses ModelAsController::getNestedController() - * @return HTTPResponse + * @return SS_HTTPResponse */ - public function handleRequest(HTTPRequest $request) { + public function handleRequest(SS_HTTPRequest $request) { $this->request = $request; $this->pushCurrent(); @@ -42,7 +42,7 @@ class ModelAsController extends Controller implements NestedController { // If the database has not yet been created, redirect to the build page. if(!DB::isActive() || !ClassInfo::hasTable('SiteTree')) { - $this->response = new HTTPResponse(); + $this->response = new SS_HTTPResponse(); $this->response->redirect('dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null)); $this->popCurrent(); @@ -80,7 +80,7 @@ class ModelAsController extends Controller implements NestedController { if(!$sitetree) { // If a root page has been renamed, redirect to the new location. if($redirect = $this->findOldPage($URLSegment)) { - $this->response = new HTTPResponse(); + $this->response = new SS_HTTPResponse(); $this->response->redirect($redirect->Link ( Controller::join_links($request->param('Action'), $request->param('ID'), $request->param('OtherID')) )); diff --git a/core/control/RequestHandler.php b/core/control/RequestHandler.php index 2d5a95b18..cc7028721 100755 --- a/core/control/RequestHandler.php +++ b/core/control/RequestHandler.php @@ -6,7 +6,7 @@ * Any RequestHandler object can be made responsible for handling its own segment of the URL namespace. * The {@link Director} begins the URL parsing process; it will parse the beginning of the URL to identify which * controller is being used. It will then call {@link handleRequest()} on that Controller, passing it the parameters that it - * parsed from the URL, and the {@link HTTPRequest} that contains the remainder of the URL to be parsed. + * parsed from the URL, and the {@link SS_HTTPRequest} that contains the remainder of the URL to be parsed. * * You can use ?debug_request=1 to view information about the different components and rule matches for a specific URL. * @@ -44,7 +44,7 @@ class RequestHandler extends ViewableData { * The default URL handling rules. This specifies that the next component of the URL corresponds to a method to * be called on this RequestHandlingData object. * - * The keys of this array are parse rules. See {@link HTTPRequest::match()} for a description of the rules available. + * The keys of this array are parse rules. See {@link SS_HTTPRequest::match()} for a description of the rules available. * * The values of the array are the method to be called if the rule matches. If this value starts with a '$', then the * named parameter of the parsed URL wil be used to determine the method name. @@ -91,10 +91,10 @@ class RequestHandler extends ViewableData { * customise the controller. * * @param $params The parameters taken from the parsed URL of the parent url handler - * @param $request The {@link HTTPRequest} object that is reponsible for distributing URL parsing - * @uses HTTPRequest - * @uses HTTPRequest->match() - * @return HTTPResponse|RequestHandler|string|array + * @param $request The {@link SS_HTTPRequest} object that is reponsible for distributing URL parsing + * @uses SS_HTTPRequest + * @uses SS_HTTPRequest->match() + * @return SS_HTTPResponse|RequestHandler|string|array */ function handleRequest($request) { // $handlerClass is used to step up the class hierarchy to implement url_handlers inheritance @@ -133,14 +133,14 @@ class RequestHandler extends ViewableData { try { $result = $this->$action($request); - } catch(HTTPResponse_Exception $responseException) { + } catch(SS_HTTPResponse_Exception $responseException) { $result = $responseException->getResponse(); } } else { return $this->httpError(403, "Action '$action' isn't allowed on class $this->class"); } - if($result instanceof HTTPResponse && $result->isError()) { + if($result instanceof SS_HTTPResponse && $result->isError()) { if(isset($_REQUEST['debug_request'])) Debug::message("Rule resulted in HTTP error; breaking"); return $result; } @@ -276,21 +276,21 @@ class RequestHandler extends ViewableData { } /** - * Throws a HTTP error response encased in a {@link HTTPResponse_Exception}, which is later caught in + * Throws a HTTP error response encased in a {@link SS_HTTPResponse_Exception}, which is later caught in * {@link RequestHandler::handleAction()} and returned to the user. * * @param int $errorCode * @param string $errorMessage - * @uses HTTPResponse_Exception + * @uses SS_HTTPResponse_Exception */ public function httpError($errorCode, $errorMessage = null) { - throw new HTTPResponse_Exception($errorMessage, $errorCode); + throw new SS_HTTPResponse_Exception($errorMessage, $errorCode); } /** - * Returns the HTTPRequest object that this controller is using. + * Returns the SS_HTTPRequest object that this controller is using. * - * @return HTTPRequest + * @return SS_HTTPRequest */ function getRequest() { return $this->request; diff --git a/core/control/RootURLController.php b/core/control/RootURLController.php index 31f88fcc9..f6e5166af 100755 --- a/core/control/RootURLController.php +++ b/core/control/RootURLController.php @@ -98,23 +98,23 @@ class RootURLController extends Controller { } /** - * @param HTTPRequest $request - * @return HTTPResponse + * @param SS_HTTPRequest $request + * @return SS_HTTPResponse */ - public function handleRequest(HTTPRequest $request) { + public function handleRequest(SS_HTTPRequest $request) { self::$is_at_root = true; $this->pushCurrent(); $this->init(); if(!DB::isActive() || !ClassInfo::hasTable('SiteTree')) { - $this->response = new HTTPResponse(); + $this->response = new SS_HTTPResponse(); $this->response->redirect('dev/build/?returnURL='); return $this->response; } - $request = new HTTPRequest ( + $request = new SS_HTTPRequest ( $request->httpMethod(), self::get_homepage_link() . '/', $request->getVars(), $request->postVars() ); $request->match('$URLSegment//$Action', true); diff --git a/core/model/DB.php b/core/model/DB.php index 48ac3e83f..1ce1574ee 100755 --- a/core/model/DB.php +++ b/core/model/DB.php @@ -8,7 +8,7 @@ class DB { /** * The global database connection. - * @var Database + * @var SS_Database */ private static $connections = array(); @@ -25,7 +25,7 @@ class DB { /** * Set the global database connection. - * Pass an object that's a subclass of Database. This object will be used when {@link DB::query()} + * Pass an object that's a subclass of SS_Database. This object will be used when {@link DB::query()} * is called. * @param $connection The connecton object to set as the connection. * @param $name The name to give to this connection. If you omit this argument, the connection @@ -33,7 +33,7 @@ class DB { * be accessed through DB::getConn($name). This is useful when you have an application that * needs to connect to more than one database. */ - static function setConn(Database $connection, $name = 'default') { + static function setConn(SS_Database $connection, $name = 'default') { self::$connections[$name] = $connection; } @@ -41,7 +41,7 @@ class DB { * Get the global database connection. * @param $name An optional name given to a connection in the DB::setConn() call. If omitted, * the default connection is returned. - * @return Database + * @return SS_Database */ static function getConn($name = 'default') { if(isset(self::$connections[$name])) { @@ -67,9 +67,9 @@ class DB { /** * Connect to a database. - * Given the database configuration, this method will create the correct subclass of Database, + * Given the database configuration, this method will create the correct subclass of SS_Database, * and set it as the global connection. - * @param array $database A map of options. The 'type' is the name of the subclass of Database to use. For the rest of the options, see the specific class. + * @param array $database A map of options. The 'type' is the name of the subclass of SS_Database to use. For the rest of the options, see the specific class. */ static function connect($databaseConfig) { // This is used by TestRunner::startsession() to test up a test session using an alt @@ -109,7 +109,7 @@ class DB { * Execute the given SQL query. * @param string $sql The SQL query to execute * @param int $errorLevel The level of error reporting to enable for the query - * @return Query + * @return SS_Query */ static function query($sql, $errorLevel = E_USER_ERROR) { self::$lastQuery = $sql; @@ -161,9 +161,9 @@ class DB { * initial database connection is not successful because the database * does not exist. * @param string $connect Connection string - * @param string $username Database username - * @param string $password Database Password - * @param string $database Database to which to create + * @param string $username SS_Database username + * @param string $password SS_Database Password + * @param string $database SS_Database to which to create * @return boolean Returns true if successful */ static function createDatabase($connect, $username, $password, $database) { @@ -240,7 +240,7 @@ class DB { } /** - * See {@link Database->dontRequireField()}. + * See {@link SS_Database->dontRequireField()}. * * @param string $table The table name. * @param string $fieldName diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 35d5e9c1a..e40f8c4ef 100755 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -171,8 +171,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity return array_merge ( array ( 'ClassName' => "Enum('" . implode(', ', ClassInfo::subclassesFor($class)) . "')", - 'Created' => 'SSDatetime', - 'LastEdited' => 'SSDatetime' + 'Created' => 'SS_Datetime', + 'LastEdited' => 'SS_Datetime' ), self::custom_database_fields($class) ); @@ -317,12 +317,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity foreach($record as $k => $v) { if($v) { if($k == 'Created' || $k == 'LastEdited') { - $fieldtype = 'SSDatetime'; + $fieldtype = 'SS_Datetime'; } else { $fieldtype = $this->db($k); } - // MSSQLDatabase::date() uses datetime for the data type for "Date" and "SSDatetime" + // MSSQLDatabase::date() uses datetime for the data type for "Date" and "SS_Datetime" switch($fieldtype) { case "Date": $v = preg_replace('/:[0-9][0-9][0-9]([ap]m)$/i', ' \\1', $v); @@ -330,7 +330,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity break; case "Datetime": - case "SSDatetime": + case "SS_Datetime": $v = preg_replace('/:[0-9][0-9][0-9]([ap]m)$/i', ' \\1', $v); $record[$k] = date('Y-m-d H:i:s', strtotime($v)); break; @@ -2136,8 +2136,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity static $fixedFields = array( 'ID' => 'Int', 'ClassName' => 'Enum', - 'LastEdited' => 'SSDatetime', - 'Created' => 'SSDatetime', + 'LastEdited' => 'SS_Datetime', + 'Created' => 'SS_Datetime', ); if(isset($fixedFields[$field])) return true; @@ -2155,8 +2155,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity // Add base fields which are not defined in static $db if($field == "ID") return "Int"; if($field == "ClassName" && get_parent_class($this) == "DataObject") return "Enum"; - if($field == "LastEdited" && get_parent_class($this) == "DataObject") return "SSDatetime"; - if($field == "Created" && get_parent_class($this) == "DataObject") return "SSDatetime"; + if($field == "LastEdited" && get_parent_class($this) == "DataObject") return "SS_Datetime"; + if($field == "Created" && get_parent_class($this) == "DataObject") return "SS_Datetime"; // Add fields from Versioned decorator if($field == "Version") return $this->hasExtension('Versioned') ? "Int" : false; @@ -2633,9 +2633,9 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * Take a database {@link Query} and instanciate an object for each record. + * Take a database {@link SS_Query} and instanciate an object for each record. * - * @param Query|array $records The database records, a {@link Query} object or an array of maps. + * @param SS_Query|array $records The database records, a {@link SS_Query} object or an array of maps. * @param string $containerClass The class to place all of the objects into. * * @return mixed The new objects in an object of type $containerClass @@ -2909,7 +2909,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $obj = new $className($record); $obj->write(); } - Database::alteration_message("Added default records to $className table","created"); + SS_Database::alteration_message("Added default records to $className table","created"); } } @@ -3211,8 +3211,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @var array */ public static $casting = array( - "LastEdited" => "SSDatetime", - "Created" => "SSDatetime", + "LastEdited" => "SS_Datetime", + "Created" => "SS_Datetime", "Title" => 'Text', ); @@ -3220,7 +3220,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * Specify custom options for a CREATE TABLE call. * Can be used to specify a custom storage engine for specific database table. * All options have to be keyed for a specific database implementation, - * identified by their class name (extending from {@link Database}). + * identified by their class name (extending from {@link SS_Database}). * * * array( @@ -3240,7 +3240,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity /** * If a field is in this array, then create a database index * on that field. This is a map from fieldname to index type. - * See {@link Database->requireIndex()} and custom subclasses for details on the array notation. + * See {@link SS_Database->requireIndex()} and custom subclasses for details on the array notation. * * @var array */ diff --git a/core/model/Database.php b/core/model/Database.php index f43f5350e..02e775986 100755 --- a/core/model/Database.php +++ b/core/model/Database.php @@ -5,7 +5,7 @@ * @package sapphire * @subpackage model */ -abstract class Database { +abstract class SS_Database { /** * This constant was added in SilverStripe 2.4 to indicate that SQL-queries * should now use ANSI-compatible syntax. The most notable affect of this @@ -30,10 +30,10 @@ abstract class Database { /** * Execute the given SQL query. * This abstract function must be defined by subclasses as part of the actual implementation. - * It should return a subclass of Query as the result. + * It should return a subclass of SS_Query as the result. * @param string $sql The SQL query to execute * @param int $errorLevel The level of error reporting to enable for the query - * @return Query + * @return SS_Query */ abstract function query($sql, $errorLevel = E_USER_ERROR); @@ -264,7 +264,7 @@ abstract class Database { if(!isset($this->tableList[strtolower($table)])) { $this->transCreateTable($table, $options, $extensions); - Database::alteration_message("Table $table: created","created"); + SS_Database::alteration_message("Table $table: created","created"); } else { $this->checkAndRepairTable($table, $options); @@ -331,7 +331,7 @@ abstract class Database { $suffix = $suffix ? ($suffix+1) : 2; } $this->renameTable($table, "_obsolete_{$table}$suffix"); - Database::alteration_message("Table $table: renamed to _obsolete_{$table}$suffix","obsolete"); + SS_Database::alteration_message("Table $table: renamed to _obsolete_{$table}$suffix","obsolete"); } } @@ -384,11 +384,11 @@ abstract class Database { if($newTable || !isset($this->indexList[$table][$index_alt])) { $this->transCreateIndex($table, $index, $spec); - Database::alteration_message("Index $table.$index: created as $spec","created"); + SS_Database::alteration_message("Index $table.$index: created as $spec","created"); } else if($array_spec != DB::getConn()->convertIndexSpec($spec)) { $this->transAlterIndex($table, $index, $spec); $spec_msg=DB::getConn()->convertIndexSpec($spec); - Database::alteration_message("Index $table.$index: changed to $spec_msg (from {$array_spec})","changed"); + SS_Database::alteration_message("Index $table.$index: changed to $spec_msg (from {$array_spec})","changed"); } } @@ -464,7 +464,7 @@ abstract class Database { $this->transCreateField($table, $field, $spec_orig); Profiler::unmark('createField'); - Database::alteration_message("Field $table.$field: created as $spec_orig","created"); + SS_Database::alteration_message("Field $table.$field: created as $spec_orig","created"); } else if($fieldValue != $specValue) { // If enums are being modified, then we need to fix existing data in the table. // Update any records where the enum is set to a legacy value to be set to the default. @@ -494,13 +494,13 @@ abstract class Database { $query .= "'{$holder[$i]}')"; DB::query($query); $amount = DB::affectedRows(); - Database::alteration_message("Changed $amount rows to default value of field $field (Value: $default)"); + SS_Database::alteration_message("Changed $amount rows to default value of field $field (Value: $default)"); } } Profiler::mark('alterField'); $this->transAlterField($table, $field, $spec_orig); Profiler::unmark('alterField'); - Database::alteration_message("Field $table.$field: changed to $specValue (from {$fieldValue})","changed"); + SS_Database::alteration_message("Field $table.$field: changed to $specValue (from {$fieldValue})","changed"); } Profiler::unmark('requireField'); } @@ -519,7 +519,7 @@ abstract class Database { $suffix = $suffix ? ($suffix+1) : 2; } $this->renameField($table, $fieldName, "_obsolete_{$fieldName}$suffix"); - Database::alteration_message("Field $table.$fieldName: renamed to $table._obsolete_{$fieldName}$suffix","obsolete"); + SS_Database::alteration_message("Field $table.$fieldName: renamed to $table._obsolete_{$fieldName}$suffix","obsolete"); } } @@ -540,7 +540,7 @@ abstract class Database { $fieldList[] = "\"$fieldName\" = $fieldVal"; $columnList[] = "\"$fieldName\""; - // Empty strings inserted as null in INSERTs. Replacement of Database::replace_with_null(). + // Empty strings inserted as null in INSERTs. Replacement of SS_Database::replace_with_null(). if($fieldVal === "''") $valueList[] = "null"; else $valueList[] = $fieldVal; } @@ -575,7 +575,7 @@ abstract class Database { default: $sql = null; - user_error("Database::manipulate() Can't recognise command '$writeInfo[command]'", E_USER_ERROR); + user_error("SS_Database::manipulate() Can't recognise command '$writeInfo[command]'", E_USER_ERROR); } } } @@ -590,7 +590,7 @@ abstract class Database { if(is_array($array)) { foreach($array as $key => $value) { if(is_array($value)) { - array_walk($array, array(Database, 'replace_with_null')); + array_walk($array, array(SS_Database, 'replace_with_null')); } } } @@ -614,11 +614,11 @@ abstract class Database { * Enable supression of database messages. */ function quiet() { - Database::$supressOutput = true; + SS_Database::$supressOutput = true; } static function alteration_message($message,$type=""){ - if(!Database::$supressOutput) { + if(!SS_Database::$supressOutput) { $color = ""; switch ($type){ case "created": @@ -692,15 +692,15 @@ abstract class Database { /** * Abstract query-result class. * Once again, this should be subclassed by an actual database implementation. It will only - * ever be constructed by a subclass of Database. The result of a database query - an iteratable object that's returned by DB::Query + * ever be constructed by a subclass of SS_Database. The result of a database query - an iteratable object that's returned by DB::SS_Query * - * Primarily, the Query class takes care of the iterator plumbing, letting the subclasses focusing + * Primarily, the SS_Query class takes care of the iterator plumbing, letting the subclasses focusing * on providing the specific data-access methods that are required: {@link nextRecord()}, {@link numRecords()} * and {@link seek()} * @package sapphire * @subpackage model */ -abstract class Query implements Iterator { +abstract class SS_Query implements Iterator { /** * The current record in the interator. * @var array diff --git a/core/model/DatabaseAdmin.php b/core/model/DatabaseAdmin.php index 859884730..6d6e5d6c6 100644 --- a/core/model/DatabaseAdmin.php +++ b/core/model/DatabaseAdmin.php @@ -229,7 +229,7 @@ class DatabaseAdmin extends Controller { /** * Clear all data out of the database - * @todo Move this code into Database class, for DB abstraction + * @todo Move this code into SS_Database class, for DB abstraction */ function clearAllData() { $tables = DB::getConn()->tableList(); diff --git a/core/model/ErrorPage.php b/core/model/ErrorPage.php index 8a071a086..154aebb48 100755 --- a/core/model/ErrorPage.php +++ b/core/model/ErrorPage.php @@ -25,22 +25,22 @@ class ErrorPage extends Page { protected static $static_filepath = ASSETS_PATH; /** - * Get a {@link HTTPResponse} to response to a HTTP error code if an {@link ErrorPage} for that code is present. + * Get a {@link SS_HTTPResponse} to response to a HTTP error code if an {@link ErrorPage} for that code is present. * * @param int $statusCode - * @return HTTPResponse + * @return SS_HTTPResponse */ public static function response_for($statusCode) { // first attempt to dynamically generate the error page if($errorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = $statusCode")) { - return ModelAsController::controller_for($errorPage)->handleRequest(new HTTPRequest('GET', '')); + return ModelAsController::controller_for($errorPage)->handleRequest(new SS_HTTPRequest('GET', '')); } // then fall back on a cached version $cachedPath = self::get_filepath_for_errorcode($statusCode, Translatable::get_current_locale()); if(file_exists($cachedPath)) { - $response = new HTTPResponse(); + $response = new SS_HTTPResponse(); $response->setStatusCode($statusCode); $response->setBody(file_get_contents($cachedPath)); @@ -68,7 +68,7 @@ class ErrorPage extends Page { $errorpage->Status = 'New page'; $errorpage->write(); - Database::alteration_message('404 page created', 'created'); + SS_Database::alteration_message('404 page created', 'created'); } } diff --git a/core/model/MySQLDatabase.php b/core/model/MySQLDatabase.php old mode 100644 new mode 100755 index 96cdb13bd..268af64cc --- a/core/model/MySQLDatabase.php +++ b/core/model/MySQLDatabase.php @@ -7,7 +7,7 @@ * @package sapphire * @subpackage model */ -class MySQLDatabase extends Database { +class MySQLDatabase extends SS_Database { /** * Connection to the DBMS. * @var resource @@ -261,7 +261,7 @@ class MySQLDatabase extends Database { if($alteredOptions && isset($alteredOptions[get_class($this)])) { $this->query(sprintf("ALTER TABLE \"%s\" %s", $tableName, $alteredOptions[get_class($this)])); - Database::alteration_message( + SS_Database::alteration_message( sprintf("Table %s options changed: %s", $tableName, $alteredOptions[get_class($this)]), "changed" ); @@ -281,7 +281,7 @@ class MySQLDatabase extends Database { */ public function checkAndRepairTable($tableName) { if(!$this->runTableCheckCommand("CHECK TABLE \"$tableName\"")) { - Database::alteration_message("Table $tableName: repaired","repaired"); + SS_Database::alteration_message("Table $tableName: repaired","repaired"); return $this->runTableCheckCommand("REPAIR TABLE \"$tableName\" USE_FRM"); } else { return true; @@ -368,7 +368,7 @@ class MySQLDatabase extends Database { * * @param string $tableName The name of the table. * @param string $indexName The name of the index. - * @param string $indexSpec The specification of the index, see {@link Database::requireIndex()} for more details. + * @param string $indexSpec The specification of the index, see {@link SS_Database::requireIndex()} for more details. */ public function createIndex($tableName, $indexName, $indexSpec) { $this->query("ALTER TABLE \"$tableName\" ADD " . $this->getIndexSqlDefinition($indexName, $indexSpec)); @@ -442,7 +442,7 @@ class MySQLDatabase extends Database { * Alter an index on a table. * @param string $tableName The name of the table. * @param string $indexName The name of the index. - * @param string $indexSpec The specification of the index, see {@link Database::requireIndex()} for more details. + * @param string $indexSpec The specification of the index, see {@link SS_Database::requireIndex()} for more details. */ public function alterIndex($tableName, $indexName, $indexSpec) { @@ -630,7 +630,7 @@ class MySQLDatabase extends Database { * @param array $values Contains a tokenised list of info about this data type * @return string */ - public function ssdatetime($values){ + public function ss_datetime($values){ //For reference, this is what typically gets passed to this function: //$parts=Array('datatype'=>'datetime'); //DB::requireField($this->tableName, $this->name, $values); @@ -923,7 +923,7 @@ class MySQLDatabase extends Database { * @package sapphire * @subpackage model */ -class MySQLQuery extends Query { +class MySQLQuery extends SS_Query { /** * The MySQLDatabase object that created this result set. * @var MySQLDatabase diff --git a/core/model/RedirectorPage.php b/core/model/RedirectorPage.php index ae7319bbb..2aab7c1f1 100755 --- a/core/model/RedirectorPage.php +++ b/core/model/RedirectorPage.php @@ -159,7 +159,7 @@ class RedirectorPage_Controller extends Page_Controller { * If we ever get this far, it means that the redirection failed. */ function index() { - return new HTTPResponse( + return new SS_HTTPResponse( "

" . _t('RedirectorPage.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') . "

" diff --git a/core/model/SQLQuery.php b/core/model/SQLQuery.php index 4dc3c428d..06e8d59b7 100755 --- a/core/model/SQLQuery.php +++ b/core/model/SQLQuery.php @@ -380,7 +380,7 @@ class SQLQuery { /** * Execute this query. - * @return Query + * @return SS_Query */ function execute() { return DB::query($this->sql(), E_USER_ERROR); diff --git a/core/model/SiteTree.php b/core/model/SiteTree.php index d0fb54b11..d3e792b9d 100755 --- a/core/model/SiteTree.php +++ b/core/model/SiteTree.php @@ -108,15 +108,15 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid ); static $many_many_extraFields = array( - "UsersCurrentlyEditing" => array("LastPing" => "SSDatetime"), + "UsersCurrentlyEditing" => array("LastPing" => "SS_Datetime"), "LinkTracking" => array("FieldName" => "Varchar"), "ImageTracking" => array("FieldName" => "Varchar") ); static $casting = array( "Breadcrumbs" => "HTMLText", - "LastEdited" => "SSDatetime", - "Created" => "SSDatetime", + "LastEdited" => "SS_Datetime", + "Created" => "SS_Datetime", ); static $defaults = array( @@ -1236,7 +1236,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $homepage->write(); $homepage->publish("Stage", "Live"); $homepage->flushCache(); - Database::alteration_message("Home page created","created"); + SS_Database::alteration_message("Home page created","created"); } if(DB::query("SELECT COUNT(*) FROM \"SiteTree\"")->value() == 1) { @@ -1247,7 +1247,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $aboutus->Status = "Published"; $aboutus->write(); $aboutus->publish("Stage", "Live"); - Database::alteration_message("About Us created","created"); + SS_Database::alteration_message("About Us created","created"); $contactus = new Page(); $contactus->Title = _t('SiteTree.DEFAULTCONTACTTITLE', 'Contact Us'); @@ -1268,7 +1268,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // only execute command if fields haven't been renamed to _obsolete_ already by the task if(array_key_exists('Viewers', $conn->fieldList('SiteTree'))) { $task = new UpgradeSiteTreePermissionSchemaTask(); - $task->run(new HTTPRequest('GET','/')); + $task->run(new SS_HTTPRequest('GET','/')); } } } diff --git a/core/model/Translatable.php b/core/model/Translatable.php index 8696fed23..039019426 100755 --- a/core/model/Translatable.php +++ b/core/model/Translatable.php @@ -618,7 +618,7 @@ class Translatable extends DataObjectDecorator implements PermissionProvider { unset($obj); } } - Database::alteration_message(sprintf( + SS_Database::alteration_message(sprintf( "Added default locale '%s' to table %s","changed", Translatable::default_locale(), $this->owner->class diff --git a/core/model/fieldtypes/DBField.php b/core/model/fieldtypes/DBField.php index 8d34b86bc..316e30c13 100755 --- a/core/model/fieldtypes/DBField.php +++ b/core/model/fieldtypes/DBField.php @@ -159,7 +159,7 @@ abstract class DBField extends ViewableData { * gets you the default representations * of all columns. * - * @param Query $query + * @param SS_Query $query */ function addToQuery(&$query) { diff --git a/core/model/fieldtypes/SSDatetime.php b/core/model/fieldtypes/Datetime.php similarity index 80% rename from core/model/fieldtypes/SSDatetime.php rename to core/model/fieldtypes/Datetime.php index 1d9b6db1e..13e070879 100644 --- a/core/model/fieldtypes/SSDatetime.php +++ b/core/model/fieldtypes/Datetime.php @@ -7,16 +7,16 @@ * PHP's built-in date() and strtotime() function according to your system locale. * * For all computations involving the current date and time, - * please use {@link SSDatetime::now()} instead of PHP's built-in date() and time() + * please use {@link SS_Datetime::now()} instead of PHP's built-in date() and time() * methods. This ensures that all time-based computations are testable with mock dates - * through {@link SSDatetime::set_mock_now()}. + * through {@link SS_Datetime::set_mock_now()}. * * @todo Add localization support, see http://open.silverstripe.com/ticket/2931 * * @package sapphire * @subpackage model */ -class SSDatetime extends Date { +class SS_Datetime extends Date { function setValue($value) { // Default to NZ date format - strtotime expects a US date @@ -49,7 +49,7 @@ class SSDatetime extends Date { function requireField() { $parts=Array('datatype'=>'datetime', 'arrayValue'=>$this->arrayValue); - $values=Array('type'=>'SSDatetime', 'parts'=>$parts); + $values=Array('type'=>'SS_Datetime', 'parts'=>$parts); DB::requireField($this->tableName, $this->name, $values); } @@ -70,13 +70,13 @@ class SSDatetime extends Date { * Returns either the current system date as determined * by date(), or a mocked date through {@link set_mock_now()}. * - * @return SSDatetime + * @return SS_Datetime */ static function now() { if(self::$mock_now) { return self::$mock_now; } else { - return DBField::create('SSDatetime', date('Y-m-d H:i:s')); + return DBField::create('SS_Datetime', date('Y-m-d H:i:s')); } } @@ -85,15 +85,15 @@ class SSDatetime extends Date { * Use {@link clear_mock_now()} to revert to the current system date. * Caution: This sets a fixed date that doesn't increment with time. * - * @param SSDatetime|string $datetime Either in object format, or as a SSDatetime compatible string. + * @param SS_Datetime|string $datetime Either in object format, or as a SS_Datetime compatible string. */ static function set_mock_now($datetime) { - if($datetime instanceof SSDatetime) { + if($datetime instanceof SS_Datetime) { self::$mock_now = $datetime; } elseif(is_string($datetime)) { - self::$mock_now = DBField::create('SSDatetime', $datetime); + self::$mock_now = DBField::create('SS_Datetime', $datetime); } else { - throw new Exception('SSDatetime::set_mock_now(): Wrong format: ' . $datetime); + throw new Exception('SS_Datetime::set_mock_now(): Wrong format: ' . $datetime); } } diff --git a/dev/SSBacktrace.php b/dev/Backtrace.php similarity index 97% rename from dev/SSBacktrace.php rename to dev/Backtrace.php index 469658665..1426bf544 100644 --- a/dev/SSBacktrace.php +++ b/dev/Backtrace.php @@ -3,7 +3,7 @@ * @package sapphire * @subpackage dev */ -class SSBacktrace { +class SS_Backtrace { /** * Return debug_backtrace() results with functions filtered @@ -26,9 +26,9 @@ class SSBacktrace { */ static function filter_backtrace($bt, $ignoredFunctions = null) { $defaultIgnoredFunctions = array( - 'SSLog::log', - 'SSBacktrace::backtrace', - 'SSBacktrace::filtered_backtrace', + 'SS_Log::log', + 'SS_Backtrace::backtrace', + 'SS_Backtrace::filtered_backtrace', 'Zend_Log_Writer_Abstract->write', 'Zend_Log->log', 'Zend_Log->__call', diff --git a/dev/SSCli.php b/dev/Cli.php similarity index 98% rename from dev/SSCli.php rename to dev/Cli.php index 916fa005a..0932f233a 100644 --- a/dev/SSCli.php +++ b/dev/Cli.php @@ -6,7 +6,7 @@ * @package sapphire * @subpackage dev */ -class SSCli extends Object { +class SS_Cli extends Object { /** * Returns true if the current STDOUT supports the use of colour control codes. */ diff --git a/dev/CliDebugView.php b/dev/CliDebugView.php index fb2857c65..a2869e254 100644 --- a/dev/CliDebugView.php +++ b/dev/CliDebugView.php @@ -28,8 +28,8 @@ class CliDebugView extends DebugView { */ public function writeError($httpRequest, $errno, $errstr, $errfile, $errline, $errcontext) { $errorType = self::$error_types[$errno]; - echo SSCli::text("ERROR [" . $errorType['title'] . "]: $errstr\nIN $httpRequest\n", "red", null, true); - echo SSCli::text("Line $errline in $errfile\n\n", "red"); + echo SS_Cli::text("ERROR [" . $errorType['title'] . "]: $errstr\nIN $httpRequest\n", "red", null, true); + echo SS_Cli::text("Line $errline in $errfile\n\n", "red"); } /** @@ -50,7 +50,7 @@ class CliDebugView extends DebugView { * Write a backtrace */ function writeTrace() { - SSBacktrace::backtrace(); + SS_Backtrace::backtrace(); } /** diff --git a/dev/CliTestReporter.php b/dev/CliTestReporter.php index 30f8f7690..44ddbe2a1 100644 --- a/dev/CliTestReporter.php +++ b/dev/CliTestReporter.php @@ -25,11 +25,11 @@ class CliTestReporter extends SapphireTestReporter { echo "\n\n"; if ($failCount == 0) { - echo SSCli::text(" ALL TESTS PASS ", "white", "green"); + echo SS_Cli::text(" ALL TESTS PASS ", "white", "green"); } else { - echo SSCli::text(" AT LEAST ONE FAILURE ", "white", "red"); + echo SS_Cli::text(" AT LEAST ONE FAILURE ", "white", "red"); } - echo "\n\n$testCount tests run: " . SSCli::text("$passCount passes", null) . ", ". SSCli::text("$failCount fails", null) . ", and 0 exceptions\n"; + echo "\n\n$testCount tests run: " . SS_Cli::text("$passCount passes", null) . ", ". SS_Cli::text("$failCount fails", null) . ", and 0 exceptions\n"; if(function_exists('memory_get_peak_usage')) { echo "Maximum memory usage: " . number_format(memory_get_peak_usage()/(1024*1024), 1) . "M\n\n"; @@ -54,11 +54,11 @@ class CliTestReporter extends SapphireTestReporter { public function endTest( PHPUnit_Framework_Test $test, $time) { // Status indicator, a la PHPUnit switch($this->currentTest['status']) { - case TEST_FAILURE: echo SSCli::text("F","red", null, true); break; - case TEST_ERROR: echo SSCli::text("E","red", null, true); break; - case TEST_INCOMPLETE: echo SSCli::text("I","yellow"); break; - case TEST_SUCCESS: echo SSCli::text(".","green"); break; - default: echo SSCli::text("?", "yellow"); break; + case TEST_FAILURE: echo SS_Cli::text("F","red", null, true); break; + case TEST_ERROR: echo SS_Cli::text("E","red", null, true); break; + case TEST_INCOMPLETE: echo SS_Cli::text("I","yellow"); break; + case TEST_SUCCESS: echo SS_Cli::text(".","green"); break; + default: echo SS_Cli::text("?", "yellow"); break; } static $colCount = 0; @@ -89,9 +89,9 @@ class CliTestReporter extends SapphireTestReporter { } - echo "\n\n" . SSCli::text($this->testNameToPhrase($test['name']) . "\n". $test['message'] . "\n", 'red', null, true); - echo SSCli::text("In line {$test['exception']['line']} of {$test['exception']['file']}" . "\n\n", 'red'); - echo SSBacktrace::get_rendered_backtrace($filteredTrace, true); + echo "\n\n" . SS_Cli::text($this->testNameToPhrase($test['name']) . "\n". $test['message'] . "\n", 'red', null, true); + echo SS_Cli::text("In line {$test['exception']['line']} of {$test['exception']['file']}" . "\n\n", 'red'); + echo SS_Backtrace::get_rendered_backtrace($filteredTrace, true); echo "\n--------------------\n"; } } diff --git a/dev/CodeViewer.php b/dev/CodeViewer.php index e3768a837..03740b663 100644 --- a/dev/CodeViewer.php +++ b/dev/CodeViewer.php @@ -113,7 +113,7 @@ class CodeViewer extends Controller { ))->renderWith('CodeViewer'); } - public function viewClass(HTTPRequest $request) { + public function viewClass(SS_HTTPRequest $request) { $class = $request->param('Class'); if(!class_exists($class)) { diff --git a/dev/Debug.php b/dev/Debug.php index 9c881c4af..41e58a3b0 100644 --- a/dev/Debug.php +++ b/dev/Debug.php @@ -12,8 +12,8 @@ * Uncaught exceptions are currently passed to the debug * reporter as standard PHP errors. * - * Errors handled by this class are passed along to {@link SSLog}. - * For configuration information, see the {@link SSLog} + * Errors handled by this class are passed along to {@link SS_Log}. + * For configuration information, see the {@link SS_Log} * class documentation. * * @todo add support for user defined config: Debug::die_on_notice(true | false) @@ -207,7 +207,7 @@ class Debug { if(error_reporting() == 0) return; // Send out the error details to the logger for writing - SSLog::log( + SS_Log::log( array( 'errno' => $errno, 'errstr' => $errstr, @@ -215,7 +215,7 @@ class Debug { 'errline' => $errline, 'errcontext' => $errcontext ), - SSLog::NOTICE + SS_Log::NOTICE ); if(Director::isDev()) { @@ -239,7 +239,7 @@ class Debug { } // Send out the error details to the logger for writing - SSLog::log( + SS_Log::log( array( 'errno' => $errno, 'errstr' => $errstr, @@ -247,7 +247,7 @@ class Debug { 'errline' => $errline, 'errcontext' => $errcontext ), - SSLog::WARN + SS_Log::WARN ); if(self::$log_errors_to) { @@ -276,7 +276,7 @@ class Debug { } // Send out the error details to the logger for writing - SSLog::log( + SS_Log::log( array( 'errno' => $errno, 'errstr' => $errstr, @@ -284,7 +284,7 @@ class Debug { 'errline' => $errline, 'errcontext' => $errcontext ), - SSLog::ERR + SS_Log::ERR ); if(self::$log_errors_to) { @@ -301,7 +301,7 @@ class Debug { /** * Render a user-facing error page, using the default HTML error template - * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link HTTPResponse} class + * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse} class * the keep dependencies minimal. * * @uses ErrorPage @@ -429,8 +429,8 @@ class Debug { * @deprecated 2.5 * To create error logs by email, use this code instead: * - * $emailWriter = new SSLogEmailWriter('my@email.com'); - * SSLog::add_writer($emailWriter, SSLog::ERR); + * $emailWriter = new SS_LogEmailWriter('my@email.com'); + * SS_Log::add_writer($emailWriter, SS_Log::ERR); * * * @param string $emailAddress @@ -443,12 +443,12 @@ class Debug { * @return boolean */ static function emailError($emailAddress, $errno, $errstr, $errfile, $errline, $errcontext, $errorType = "Error") { - user_error('Debug::send_errors_to() and Debug::emailError() is deprecated. Please use SSLog instead. - See the class documentation in SSLog.php for more information.', E_USER_NOTICE); - $priority = ($errorType == 'Error') ? SSLog::ERR : SSLog::WARN; - $writer = new SSLogEmailWriter($emailAddress); - SSLog::add_writer($writer, $priority); - SSLog::log( + user_error('Debug::send_errors_to() and Debug::emailError() is deprecated. Please use SS_Log instead. + See the class documentation in SS_Log.php for more information.', E_USER_NOTICE); + $priority = ($errorType == 'Error') ? SS_Log::ERR : SS_Log::WARN; + $writer = new SS_LogEmailWriter($emailAddress); + SS_Log::add_writer($writer, $priority); + SS_Log::log( array( 'errno' => $errno, 'errstr' => $errstr, @@ -458,7 +458,7 @@ class Debug { ), $priority ); - SSLog::remove_writer($writer); + SS_Log::remove_writer($writer); } /** @@ -469,15 +469,15 @@ class Debug { * * @todo Detect script path for CLI errors * @todo Log detailed errors to full file - * @deprecated 2.5 See SSLog on setting up error file logging + * @deprecated 2.5 See SS_Log on setting up error file logging */ protected static function log_error_if_necessary($errno, $errstr, $errfile, $errline, $errcontext, $errtype) { - user_error('Debug::log_error_if_necessary() and Debug::log_errors_to() are deprecated. Please use SSLog instead. - See the class documentation in SSLog.php for more information.', E_USER_NOTICE); - $priority = ($errtype == 'Error') ? SSLog::ERR : SSLog::WARN; - $writer = new SSLogFileWriter('../' . self::$log_errors_to); - SSLog::add_writer($writer, $priority); - SSLog::log( + user_error('Debug::log_error_if_necessary() and Debug::log_errors_to() are deprecated. Please use SS_Log instead. + See the class documentation in SS_Log.php for more information.', E_USER_NOTICE); + $priority = ($errtype == 'Error') ? SS_Log::ERR : SS_Log::WARN; + $writer = new SS_LogFileWriter('../' . self::$log_errors_to); + SS_Log::add_writer($writer, $priority); + SS_Log::log( array( 'errno' => $errno, 'errstr' => $errstr, @@ -487,12 +487,12 @@ class Debug { ), $priority ); - SSLog::remove_writer($writer); + SS_Log::remove_writer($writer); } /** * @param string $server IP-Address or domain - * @deprecated 2.5 See SSLog on setting up error email notification + * @deprecated 2.5 See SS_Log on setting up error email notification */ static function set_custom_smtp_server($server) { self::$custom_smtp_server = $server; @@ -500,7 +500,7 @@ class Debug { /** * @return string - * @deprecated 2.5 See SSLog on setting up error email notification + * @deprecated 2.5 See SS_Log on setting up error email notification */ static function get_custom_smtp_server() { return self::$custom_smtp_server; @@ -511,7 +511,7 @@ class Debug { * Can be used like so: * if(Director::isLive()) Debug::send_errors_to("sam@silverstripe.com"); * - * @deprecated 2.5 See SSLog on setting up error email notification + * @deprecated 2.5 See SS_Log on setting up error email notification * * @param string $emailAddress The email address to send errors to * @param string $sendWarnings Set to true to send warnings as well as errors (Default: false) @@ -523,7 +523,7 @@ class Debug { /** * @return string - * @deprecated 2.5 See SSLog on setting up error email notification + * @deprecated 2.5 See SS_Log on setting up error email notification */ static function get_send_errors_to() { return self::$send_errors_to; @@ -531,7 +531,7 @@ class Debug { /** * @param string $emailAddress - * @deprecated 2.5 See SSLog on setting up error email notification + * @deprecated 2.5 See SS_Log on setting up error email notification */ static function send_warnings_to($emailAddress) { self::$send_warnings_to = $emailAddress; @@ -539,7 +539,7 @@ class Debug { /** * @return string - * @deprecated 2.5 See SSLog on setting up error email notification + * @deprecated 2.5 See SS_Log on setting up error email notification */ static function get_send_warnings_to() { return self::$send_warnings_to; @@ -547,7 +547,7 @@ class Debug { /** * Call this to enable logging of errors. - * @deprecated 2.5 See SSLog on setting up error file logging + * @deprecated 2.5 See SS_Log on setting up error file logging */ static function log_errors_to($logFile = ".sserrors") { self::$log_errors_to = $logFile; @@ -564,19 +564,19 @@ class Debug { } /** - * @deprecated 2.5 Please use {@link SSBacktrace::backtrace()} + * @deprecated 2.5 Please use {@link SS_Backtrace::backtrace()} */ static function backtrace($returnVal = false, $ignoreAjax = false) { - user_error('Debug::backtrace() is deprecated. Please use SSBacktrace::backtrace() instead', E_USER_NOTICE); - return SSBacktrace::backtrace($returnVal, $ignoreAjax); + user_error('Debug::backtrace() is deprecated. Please use SS_Backtrace::backtrace() instead', E_USER_NOTICE); + return SS_Backtrace::backtrace($returnVal, $ignoreAjax); } /** - * @deprecated 2.5 Please use {@link SSBacktrace::get_rendered_backtrace()} + * @deprecated 2.5 Please use {@link SS_Backtrace::get_rendered_backtrace()} */ static function get_rendered_backtrace($bt, $plainText = false) { - user_error('Debug::get_rendered_backtrace() is deprecated. Please use SSBacktrace::get_rendered_backtrace() instead', E_USER_NOTICE); - return SSBacktrace::get_rendered_backtrace($bt, $plainText); + user_error('Debug::get_rendered_backtrace() is deprecated. Please use SS_Backtrace::get_rendered_backtrace() instead', E_USER_NOTICE); + return SS_Backtrace::get_rendered_backtrace($bt, $plainText); } /** diff --git a/dev/DebugView.php b/dev/DebugView.php index dc3331b4e..10a9fe0ef 100644 --- a/dev/DebugView.php +++ b/dev/DebugView.php @@ -153,7 +153,7 @@ class DebugView { */ function writeTrace($trace) { echo '

Trace

'; - echo SSBacktrace::get_rendered_backtrace($trace); + echo SS_Backtrace::get_rendered_backtrace($trace); echo ''; } diff --git a/dev/SSLog.php b/dev/Log.php similarity index 80% rename from dev/SSLog.php rename to dev/Log.php index 532aeb019..9abfa3767 100644 --- a/dev/SSLog.php +++ b/dev/Log.php @@ -6,32 +6,32 @@ * subclasses for output. * * These priorities are currently supported: - * - SSLog::ERR - * - SSLog::WARN - * - SSLog::NOTICE + * - SS_Log::ERR + * - SS_Log::WARN + * - SS_Log::NOTICE * - * You can add an error writer by calling {@link SSLog::add_writer()} + * You can add an error writer by calling {@link SS_Log::add_writer()} * * Example usage of logging errors by email notification: * - * $logEmailWriter = new SSLogEmailWriter('my@email.com'); - * SSLog::add_writer($logEmailWriter, SSLog::ERR); + * $logEmailWriter = new SS_LogEmailWriter('my@email.com'); + * SS_Log::add_writer($logEmailWriter, SS_Log::ERR); * * * Example usage of logging errors by file: * - * $logFileWriter = new SSLogFileWriter('/var/log/silverstripe/errors.log'); - * SSLog::add_writer($logFileWriter, SSLog::ERR); + * $logFileWriter = new SS_LogFileWriter('/var/log/silverstripe/errors.log'); + * SS_Log::add_writer($logFileWriter, SS_Log::ERR); * * * Each writer object can be assigned a formatter. The formatter is * responsible for formatting the message before giving it to the writer. - * {@link SSLogErrorEmailFormatter} is such an example that formats errors + * {@link SS_LogErrorEmailFormatter} is such an example that formats errors * into HTML for human readability in an email client. * * Formatters are added to writers like this: * - * $logEmailWriter = new SSLogEmailWriter('my@email.com'); + * $logEmailWriter = new SS_LogEmailWriter('my@email.com'); * $myEmailFormatter = new MyLogEmailFormatter(); * $logEmailWriter->setFormatter($myEmailFormatter); * @@ -42,7 +42,7 @@ require_once 'Zend/Log.php'; -class SSLog { +class SS_Log { const ERR = Zend_Log::ERR; const WARN = Zend_Log::WARN; @@ -50,13 +50,13 @@ class SSLog { /** * Logger class to use. - * @see SSLog::get_logger() + * @see SS_Log::get_logger() * @var string */ - public static $logger_class = 'SSZendLog'; + public static $logger_class = 'SS_ZendLog'; /** - * @see SSLog::get_logger() + * @see SS_Log::get_logger() * @var object */ protected static $logger; @@ -100,7 +100,7 @@ class SSLog { /** * Add a writer instance to the logger. * @param object $writer Zend_Log_Writer_Abstract instance - * @param const $priority Priority. Possible values: SSLog::ERR or SSLog::WARN + * @param const $priority Priority. Possible values: SS_Log::ERR or SS_Log::WARN * @param $comparison Priority comparison operator. Acts on the integer values of the error * levels, where more serious errors are lower numbers. By default this is "=", which means only * the given priority will be logged. Set to "<=" if you want to track errors of *at least* @@ -120,7 +120,7 @@ class SSLog { * error code, error line, error context (backtrace). * * @param string|array $message String of error message, or array of variables - * @param const $priority Priority. Possible values: SSLog::ERR or SSLog::WARN + * @param const $priority Priority. Possible values: SS_Log::ERR or SS_Log::WARN */ public static function log($message, $priority) { try { diff --git a/dev/SSLogEmailWriter.php b/dev/LogEmailWriter.php similarity index 87% rename from dev/SSLogEmailWriter.php rename to dev/LogEmailWriter.php index c7408c602..a4ca40c88 100644 --- a/dev/SSLogEmailWriter.php +++ b/dev/LogEmailWriter.php @@ -3,7 +3,7 @@ * Sends an error message to an email whenever an error occurs * in sapphire. * - * @see SSLog for more information on using writers. + * @see SS_Log for more information on using writers. * * @package sapphire * @subpackage dev @@ -11,7 +11,7 @@ require_once 'Zend/Log/Writer/Abstract.php'; -class SSLogEmailWriter extends Zend_Log_Writer_Abstract { +class SS_LogEmailWriter extends Zend_Log_Writer_Abstract { protected $emailAddress; @@ -29,7 +29,7 @@ class SSLogEmailWriter extends Zend_Log_Writer_Abstract { public function _write($event) { // If no formatter set up, use the default if(!$this->_formatter) { - $formatter = new SSLogErrorEmailFormatter(); + $formatter = new SS_LogErrorEmailFormatter(); $this->setFormatter($formatter); } diff --git a/dev/SSLogErrorEmailFormatter.php b/dev/LogErrorEmailFormatter.php similarity index 86% rename from dev/SSLogErrorEmailFormatter.php rename to dev/LogErrorEmailFormatter.php index 098abdd76..f7e143dd0 100644 --- a/dev/SSLogErrorEmailFormatter.php +++ b/dev/LogErrorEmailFormatter.php @@ -7,7 +7,7 @@ require_once 'Zend/Log/Formatter/Interface.php'; -class SSLogErrorEmailFormatter implements Zend_Log_Formatter_Interface { +class SS_LogErrorEmailFormatter implements Zend_Log_Formatter_Interface { public function format($event) { switch($event['priorityName']) { @@ -39,9 +39,9 @@ class SSLogErrorEmailFormatter implements Zend_Log_Formatter_Interface { $data .= "

$errorType: $errstr
At line $errline in $errfile\n
\n
\n

\n"; // Get a backtrace, filtering out debug method calls - $data .= SSBacktrace::backtrace(true, false, array( - 'SSLogErrorEmailFormatter->format', - 'SSLogEmailWriter->_write' + $data .= SS_Backtrace::backtrace(true, false, array( + 'SS_LogErrorEmailFormatter->format', + 'SS_LogEmailWriter->_write' )); $data .= "\n"; diff --git a/dev/SSLogErrorFileFormatter.php b/dev/LogErrorFileFormatter.php similarity index 93% rename from dev/SSLogErrorFileFormatter.php rename to dev/LogErrorFileFormatter.php index e69d721b3..3725551e1 100644 --- a/dev/SSLogErrorFileFormatter.php +++ b/dev/LogErrorFileFormatter.php @@ -8,7 +8,7 @@ require_once 'Zend/Log/Formatter/Interface.php'; -class SSLogErrorFileFormatter implements Zend_Log_Formatter_Interface { +class SS_LogErrorFileFormatter implements Zend_Log_Formatter_Interface { public function format($event) { $errno = $event['message']['errno']; diff --git a/dev/SSLogFileWriter.php b/dev/LogFileWriter.php similarity index 89% rename from dev/SSLogFileWriter.php rename to dev/LogFileWriter.php index f92fa2647..e1171ee18 100644 --- a/dev/SSLogFileWriter.php +++ b/dev/LogFileWriter.php @@ -8,7 +8,7 @@ * logs to. * * @uses error_log() built-in PHP function. - * @see SSLog for more information on using writers. + * @see SS_Log for more information on using writers. * * @package sapphire * @subpackage dev @@ -16,7 +16,7 @@ require_once 'Zend/Log/Writer/Abstract.php'; -class SSLogFileWriter extends Zend_Log_Writer_Abstract { +class SS_LogFileWriter extends Zend_Log_Writer_Abstract { /** * The path to the file that errors will be stored in. @@ -52,7 +52,7 @@ class SSLogFileWriter extends Zend_Log_Writer_Abstract { */ public function _write($event) { if(!$this->_formatter) { - $formatter = new SSLogErrorFileFormatter(); + $formatter = new SS_LogErrorFileFormatter(); $this->setFormatter($formatter); } $message = $this->_formatter->format($event); diff --git a/dev/SapphireREPL.php b/dev/SapphireREPL.php index 6bc3c67da..d8ef2cd31 100644 --- a/dev/SapphireREPL.php +++ b/dev/SapphireREPL.php @@ -44,10 +44,10 @@ class SapphireREPL extends Controller { echo "Sapphire Interactive Command-line (REPL interface). Type help for hints.\n\n"; while(true) { - echo SSCli::text("?> ", "cyan"); - echo SSCli::start_colour("yellow"); + echo SS_Cli::text("?> ", "cyan"); + echo SS_Cli::start_colour("yellow"); $command = trim(fgets(STDIN, 4096)); - echo SSCli::end_colour(); + echo SS_Cli::end_colour(); if ( $command == 'help' || $command == '?' ) { print "help or ? to exit\n" ; @@ -71,7 +71,7 @@ class SapphireREPL extends Controller { echo "\n"; } catch( Exception $__repl_exception ) { - echo SSCli::start_colour("red"); + echo SS_Cli::start_colour("red"); printf( '%s (code: %d) got thrown'.PHP_EOL, get_class($__repl_exception), $__repl_exception->getCode() ); print $__repl_exception; echo "\n"; diff --git a/dev/SapphireTestReporter.php b/dev/SapphireTestReporter.php index b1b8fd633..91df9b2fb 100644 --- a/dev/SapphireTestReporter.php +++ b/dev/SapphireTestReporter.php @@ -284,7 +284,7 @@ class SapphireTestReporter implements PHPUnit_Framework_TestListener { if ($test['status'] != 1) { echo "
⊗ ". $this->testNameToPhrase($test['name']) ."
"; echo "
".htmlentities($test['message'])."

"; - echo SSBacktrace::get_rendered_backtrace($test['trace']); + echo SS_Backtrace::get_rendered_backtrace($test['trace']); echo "
"; } } diff --git a/dev/TestSession.php b/dev/TestSession.php index 1525fd6d6..78b5b27f2 100644 --- a/dev/TestSession.php +++ b/dev/TestSession.php @@ -107,7 +107,7 @@ class TestSession { } /** - * Get the most recent response, as an HTTPResponse object + * Get the most recent response, as an SS_HTTPResponse object */ function lastResponse() { return $this->lastResponse; @@ -153,12 +153,12 @@ class TestSession { } /** - * Wrapper around HTTPResponse to make it look like a SimpleHTTPResposne + * Wrapper around SS_HTTPResponse to make it look like a SimpleHTTPResposne */ class TestSession_STResponseWrapper { private $response; - function __construct(HTTPResponse $response) { + function __construct(SS_HTTPResponse $response) { $this->response = $response; } diff --git a/dev/SSZendLog.php b/dev/ZendLog.php similarity index 87% rename from dev/SSZendLog.php rename to dev/ZendLog.php index 398b0e87e..43d02bfa1 100644 --- a/dev/SSZendLog.php +++ b/dev/ZendLog.php @@ -1,9 +1,9 @@ 'Varchar', - 'BounceTime' => 'SSDatetime', + 'BounceTime' => 'SS_Datetime', 'BounceMessage' => 'Varchar' ); diff --git a/email/QueuedEmail.php b/email/QueuedEmail.php index 72702ebf3..928be4818 100644 --- a/email/QueuedEmail.php +++ b/email/QueuedEmail.php @@ -7,7 +7,7 @@ class QueuedEmail extends DataObject { static $db = array( - 'Send' => 'SSDatetime', + 'Send' => 'SS_Datetime', 'Subject' => 'Varchar', 'From' => 'Varchar', 'Content' => 'Text' diff --git a/forms/Form.php b/forms/Form.php index 3ff01891a..00f3be429 100755 --- a/forms/Form.php +++ b/forms/Form.php @@ -266,12 +266,12 @@ class Form extends RequestHandler { $acceptType = $request->getHeader('Accept'); if(strpos($acceptType, 'application/json') !== FALSE) { // Send validation errors back as JSON with a flag at the start - $response = new HTTPResponse(Convert::array2json($this->validator->getErrors())); + $response = new SS_HTTPResponse(Convert::array2json($this->validator->getErrors())); $response->addHeader('Content-Type', 'application/json'); } else { $this->setupFormErrors(); // Send the newly rendered form tag as HTML - $response = new HTTPResponse($this->forTemplate()); + $response = new SS_HTTPResponse($this->forTemplate()); $response->addHeader('Content-Type', 'text/html'); } @@ -307,7 +307,7 @@ class Form extends RequestHandler { * formfield with the same name, this method gives priority * to the formfield. * - * @param HTTPRequest $request + * @param SS_HTTPRequest $request * @return FormField */ function handleField($request) { @@ -1246,7 +1246,7 @@ class Form extends RequestHandler { /** * Test a submission of this form. - * @return HTTPResponse the response object that the handling controller produces. You can interrogate this in your unit test. + * @return SS_HTTPResponse the response object that the handling controller produces. You can interrogate this in your unit test. */ function testSubmission($action, $data) { $data['action_' . $action] = true; @@ -1259,7 +1259,7 @@ class Form extends RequestHandler { /** * Test an ajax submission of this form. - * @return HTTPResponse the response object that the handling controller produces. You can interrogate this in your unit test. + * @return SS_HTTPResponse the response object that the handling controller produces. You can interrogate this in your unit test. */ function testAjaxSubmission($action, $data) { $data['ajax'] = 1; diff --git a/forms/ScaffoldingComplexTableField.php b/forms/ScaffoldingComplexTableField.php index f9ad336f0..eaec132f9 100644 --- a/forms/ScaffoldingComplexTableField.php +++ b/forms/ScaffoldingComplexTableField.php @@ -32,7 +32,7 @@ class ScaffoldingComplexTableField_Popup extends ComplexTableField_Popup { /** * Handle a generic action passed in by the URL mapping. * - * @param HTTPRequest $request + * @param SS_HTTPRequest $request */ public function handleAction($request) { $action = str_replace("-","_",$request->param('Action')); @@ -63,7 +63,7 @@ class ScaffoldingComplexTableField_Popup extends ComplexTableField_Popup { /** * Action to render results for an autocomplete filter. * - * @param HTTPRequest $request + * @param SS_HTTPRequest $request * @return void */ function filter($request) { diff --git a/forms/TableListField.php b/forms/TableListField.php index 1e2720c30..2133ec299 100755 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -401,7 +401,7 @@ JS * Caution: Other parameters such as {@sourceFilter} will be ignored. * Please use this only as a fallback for really complex queries (e.g. involving HAVING and GROUPBY). * - * @param $query Query + * @param $query SS_Query */ function setCustomQuery($query) { $this->customQuery = $query; @@ -921,7 +921,7 @@ JS $fileName = "export-$now.csv"; if($fileData = $this->generateExportFileData($numColumns, $numRows)){ - return HTTPRequest::send_file($fileData, $fileName); + return SS_HTTPRequest::send_file($fileData, $fileName); }else{ user_error("No records found", E_USER_ERROR); } diff --git a/forms/TreeDropdownField.php b/forms/TreeDropdownField.php index 7baa0bd9e..f5211d828 100755 --- a/forms/TreeDropdownField.php +++ b/forms/TreeDropdownField.php @@ -117,10 +117,10 @@ class TreeDropdownField extends FormField { /** * Get the whole tree of a part of the tree via an AJAX request. * - * @param HTTPRequest $request + * @param SS_HTTPRequest $request * @return string */ - public function tree(HTTPRequest $request) { + public function tree(SS_HTTPRequest $request) { $isSubTree = false; if($ID = (int) $request->param('ID')) { diff --git a/security/Member.php b/security/Member.php index 093aa1b38..8affc26ec 100644 --- a/security/Member.php +++ b/security/Member.php @@ -13,14 +13,14 @@ class Member extends DataObject { 'Password' => 'Varchar(64)', // support for up to SHA256! 'RememberLoginToken' => 'Varchar(50)', 'NumVisit' => 'Int', - 'LastVisited' => 'SSDatetime', + 'LastVisited' => 'SS_Datetime', 'Bounced' => 'Boolean', // Note: This does not seem to be used anywhere. 'AutoLoginHash' => 'Varchar(30)', - 'AutoLoginExpired' => 'SSDatetime', + 'AutoLoginExpired' => 'SS_Datetime', 'PasswordEncryption' => "Enum('none', 'none')", 'Salt' => 'Varchar(50)', 'PasswordExpiry' => 'Date', - 'LockedOutUntil' => 'SSDatetime', + 'LockedOutUntil' => 'SS_Datetime', 'Locale' => 'Varchar(6)', // handled in registerFailedLogin(), only used if $lock_out_after_incorrect_logins is set 'FailedLoginCount' => 'Int', @@ -954,7 +954,7 @@ class Member extends DataObject { if(!DB::query("SELECT * FROM \"Member\"")->value() && isset($_REQUEST['username']) && isset($_REQUEST['password'])) { Security::findAnAdministrator($_REQUEST['username'], $_REQUEST['password']); - Database::alteration_message("Added admin account","created"); + SS_Database::alteration_message("Added admin account","created"); } } diff --git a/security/Security.php b/security/Security.php index 9e3f4cf27..64f1595e9 100644 --- a/security/Security.php +++ b/security/Security.php @@ -146,7 +146,7 @@ class Security extends Controller { if(!$controller) $controller = Controller::curr(); if(Director::is_ajax()) { - $response = ($controller) ? $controller->getResponse() : new HTTPResponse(); + $response = ($controller) ? $controller->getResponse() : new SS_HTTPResponse(); $response->setStatusCode(403); $response->setBody('NOTLOGGEDIN:'); return $response; @@ -184,7 +184,7 @@ class Security extends Controller { // Work out the right message to show if(Member::currentUser()) { - $response = ($controller) ? $controller->getResponse() : new HTTPResponse(); + $response = ($controller) ? $controller->getResponse() : new SS_HTTPResponse(); $response->setStatusCode(403); // Replace %s with the log in link @@ -294,10 +294,10 @@ class Security extends Controller { $eventResults = $this->extend('onBeforeSecurityLogin'); // If there was a redirection, return if(Director::redirected_to()) return; - // If there was an HTTPResponse object returned, then return that + // If there was an SS_HTTPResponse object returned, then return that else if($eventResults) { foreach($eventResults as $result) { - if($result instanceof HTTPResponse) return $result; + if($result instanceof SS_HTTPResponse) return $result; } } @@ -446,7 +446,7 @@ class Security extends Controller { * Show the "password sent" page, after a user has requested * to reset their password. * - * @param HTTPRequest $request The HTTPRequest for this action. + * @param SS_HTTPRequest $request The SS_HTTPRequest for this action. * @return string Returns the "password sent" page as HTML code. */ public function passwordsent($request) { diff --git a/tests/ErrorPageTest.php b/tests/ErrorPageTest.php index 81959be1b..3196a6bad 100644 --- a/tests/ErrorPageTest.php +++ b/tests/ErrorPageTest.php @@ -43,10 +43,10 @@ class ErrorPageTest extends FunctionalTest { /* We have body text from the error page */ $this->assertNotNull($response->getBody(), 'We have body text from the error page'); - /* Status code of the HTTPResponse for error page is "404" */ - $this->assertEquals($response->getStatusCode(), '404', 'Status code of the HTTPResponse for error page is "404"'); + /* Status code of the SS_HTTPResponse for error page is "404" */ + $this->assertEquals($response->getStatusCode(), '404', 'Status code of the SS_HTTPResponse for error page is "404"'); - /* Status message of the HTTPResponse for error page is "Not Found" */ + /* Status message of the SS_HTTPResponse for error page is "Not Found" */ $this->assertEquals($response->getStatusDescription(), 'Not Found', 'Status message of the HTTResponse for error page is "Not found"'); } diff --git a/tests/HTTPRequestTest.php b/tests/HTTPRequestTest.php index 22a85c5b1..c46a2dd9d 100644 --- a/tests/HTTPRequestTest.php +++ b/tests/HTTPRequestTest.php @@ -4,7 +4,7 @@ class HTTPRequestTest extends SapphireTest { static $fixture_file = null; function testMatch() { - $request = new HTTPRequest("GET", "admin/crm/add"); + $request = new SS_HTTPRequest("GET", "admin/crm/add"); /* When a rule matches, but has no variables, array("_matched" => true) is returned. */ $this->assertEquals(array("_matched" => true), $request->match('admin/crm', true)); @@ -16,7 +16,7 @@ class HTTPRequestTest extends SapphireTest { } public function testHttpMethodOverrides() { - $request = new HTTPRequest( + $request = new SS_HTTPRequest( 'GET', 'admin/crm' ); @@ -25,7 +25,7 @@ class HTTPRequestTest extends SapphireTest { 'GET with no method override' ); - $request = new HTTPRequest( + $request = new SS_HTTPRequest( 'POST', 'admin/crm' ); @@ -34,7 +34,7 @@ class HTTPRequestTest extends SapphireTest { 'POST with no method override' ); - $request = new HTTPRequest( + $request = new SS_HTTPRequest( 'GET', 'admin/crm', array('_method' => 'DELETE') @@ -44,7 +44,7 @@ class HTTPRequestTest extends SapphireTest { 'GET with invalid POST method override' ); - $request = new HTTPRequest( + $request = new SS_HTTPRequest( 'POST', 'admin/crm', array(), @@ -55,7 +55,7 @@ class HTTPRequestTest extends SapphireTest { 'POST with valid method override to DELETE' ); - $request = new HTTPRequest( + $request = new SS_HTTPRequest( 'POST', 'admin/crm', array(), @@ -66,7 +66,7 @@ class HTTPRequestTest extends SapphireTest { 'POST with valid method override to PUT' ); - $request = new HTTPRequest( + $request = new SS_HTTPRequest( 'POST', 'admin/crm', array(), @@ -77,7 +77,7 @@ class HTTPRequestTest extends SapphireTest { 'POST with valid method override to HEAD ' ); - $request = new HTTPRequest( + $request = new SS_HTTPRequest( 'POST', 'admin/crm', array(), @@ -88,7 +88,7 @@ class HTTPRequestTest extends SapphireTest { 'POST with valid method override to HEAD' ); - $request = new HTTPRequest( + $request = new SS_HTTPRequest( 'POST', 'admin/crm', array('_method' => 'head') diff --git a/tests/RequestHandlingTest.php b/tests/RequestHandlingTest.php index 9d471ca76..fe7a56f0b 100755 --- a/tests/RequestHandlingTest.php +++ b/tests/RequestHandlingTest.php @@ -1,7 +1,7 @@ "SSDatetime" + "CompletionDate" => "SS_Datetime" ); static $has_one = array( diff --git a/tests/control/ModelAsControllerTest.php b/tests/control/ModelAsControllerTest.php index 9a8932999..7c1a382aa 100644 --- a/tests/control/ModelAsControllerTest.php +++ b/tests/control/ModelAsControllerTest.php @@ -17,7 +17,7 @@ class ModelAsControllerTest extends SapphireTest { $page->publish('Stage', 'Live'); $router = new ModelAsController(); - $request = new HTTPRequest( + $request = new SS_HTTPRequest( 'GET', 'test-page/action/id/otherid' ); $request->match('$URLSegment/$Action/$ID/$OtherID'); diff --git a/tests/dev/LogTest.php b/tests/dev/LogTest.php new file mode 100644 index 000000000..262868240 --- /dev/null +++ b/tests/dev/LogTest.php @@ -0,0 +1,36 @@ +testEmailWriter = new SS_LogEmailWriter('sean@silverstripe.com'); + $this->testFileWriter = new SS_LogFileWriter('../test.log'); + SS_Log::add_writer($this->testEmailWriter, SS_Log::ERR); + SS_Log::add_writer($this->testFileWriter, SS_Log::WARN); + } + + function testExistingWriter() { + $writers = SS_Log::get_writers(); + $this->assertType('array', $writers); + $this->assertEquals(2, count($writers)); + } + + function testRemoveWriter() { + SS_Log::remove_writer($this->testEmailWriter); + $writers = SS_Log::get_writers(); + $this->assertType('array', $writers); + $this->assertEquals(1, count($writers)); + SS_Log::remove_writer($this->testFileWriter); + $writers = SS_Log::get_writers(); + $this->assertType('array', $writers); + $this->assertEquals(0, count($writers)); + } + +} \ No newline at end of file diff --git a/tests/dev/SSLogTest.php b/tests/dev/SSLogTest.php deleted file mode 100644 index 17b5b4bea..000000000 --- a/tests/dev/SSLogTest.php +++ /dev/null @@ -1,36 +0,0 @@ -testEmailWriter = new SSLogEmailWriter('sean@silverstripe.com'); - $this->testFileWriter = new SSLogFileWriter('../test.log'); - SSLog::add_writer($this->testEmailWriter, SSLog::ERR); - SSLog::add_writer($this->testFileWriter, SSLog::WARN); - } - - function testExistingWriter() { - $writers = SSLog::get_writers(); - $this->assertType('array', $writers); - $this->assertEquals(2, count($writers)); - } - - function testRemoveWriter() { - SSLog::remove_writer($this->testEmailWriter); - $writers = SSLog::get_writers(); - $this->assertType('array', $writers); - $this->assertEquals(1, count($writers)); - SSLog::remove_writer($this->testFileWriter); - $writers = SSLog::get_writers(); - $this->assertType('array', $writers); - $this->assertEquals(0, count($writers)); - } - -} \ No newline at end of file diff --git a/tests/model/SSDatetimeTest.php b/tests/model/DatetimeTest.php similarity index 60% rename from tests/model/SSDatetimeTest.php rename to tests/model/DatetimeTest.php index fe59bb681..b18c6fb01 100644 --- a/tests/model/SSDatetimeTest.php +++ b/tests/model/DatetimeTest.php @@ -1,6 +1,6 @@ assertEquals($systemDatetime->Date(), $nowDatetime->Date()); } @@ -21,16 +21,16 @@ class SSDatetimeTest extends SapphireTest { function testNowWithMockDate() { // Test setting $mockDate = '2001-12-31 22:10:59'; - SSDatetime::set_mock_now($mockDate); - $systemDatetime = DBField::create('SSDatetime', date('Y-m-d H:i:s')); - $nowDatetime = SSDatetime::now(); + SS_Datetime::set_mock_now($mockDate); + $systemDatetime = DBField::create('SS_Datetime', date('Y-m-d H:i:s')); + $nowDatetime = SS_Datetime::now(); $this->assertNotEquals($systemDatetime->Date(), $nowDatetime->Date()); $this->assertEquals($nowDatetime->getValue(), $mockDate); // Test clearing - SSDatetime::clear_mock_now(); - $systemDatetime = DBField::create('SSDatetime', date('Y-m-d H:i:s')); - $nowDatetime = SSDatetime::now(); + SS_Datetime::clear_mock_now(); + $systemDatetime = DBField::create('SS_Datetime', date('Y-m-d H:i:s')); + $nowDatetime = SS_Datetime::now(); $this->assertEquals($systemDatetime->Date(), $nowDatetime->Date()); } } \ No newline at end of file