API CHANGE ajshort: Deprecated the Director site mode and callback functionality.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@80055 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-06-25 08:15:52 +00:00
parent 0d1db9834d
commit 6fd387c99c
5 changed files with 24 additions and 33 deletions

View File

@ -98,8 +98,6 @@ class ContentController extends Controller {
else singleton('SiteTree')->extend('contentcontrollerInit', $this); else singleton('SiteTree')->extend('contentcontrollerInit', $this);
if(Director::redirected_to()) return; if(Director::redirected_to()) return;
Director::set_site_mode('site');
// Check page permissions // Check page permissions
if($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->can('View')) { if($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->can('View')) {

View File

@ -19,6 +19,9 @@ class Director {
static private $rules = array(); static private $rules = array();
/**
* @deprecated 2.4
*/
static $siteMode; static $siteMode;
static $alternateBaseFolder; static $alternateBaseFolder;
@ -35,8 +38,7 @@ class Director {
static protected $environment_type; static protected $environment_type;
/** /**
* Sets the site mode (if it is the public site or the cms), * @deprecated 2.4
* and runs registered modules.
*/ */
static protected $callbacks; static protected $callbacks;
@ -638,11 +640,13 @@ class Director {
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
/** /**
* Sets the site mode (if it is the public site or the cms), and runs registered modules. * @deprecated 2.4
*
* @param string $mode 'site' or 'cms'
*/ */
static function set_site_mode($mode) { static function set_site_mode($mode) {
user_error (
'Director::set_site_mode() is deprecated as the functionality is no longer neccesary.', E_USER_NOTICE
);
Director::$siteMode = $mode; Director::$siteMode = $mode;
if(isset(self::$callbacks[$mode])) { if(isset(self::$callbacks[$mode])) {
@ -653,23 +657,24 @@ class Director {
} }
/** /**
* @return string 'site' or 'cms' * @deprecated 2.4
*/ */
static function get_site_mode() { static function get_site_mode() {
user_error (
'Director::set_site_mode() is deprecated as the functionality is no longer neccesary.', E_USER_NOTICE
);
return Director::$siteMode; return Director::$siteMode;
} }
/** /**
* Allows a module to register with the director to be run once * @deprecated 2.4 Use a custom extension on your controller.
* the controller is instantiated. The optional 'mode' parameter
* can be either 'site' or 'cms', as those are the two values currently
* set by controllers. The callback function will be run at the
* initialization of the relevant controller.
*
* @param $function string PHP-function array based on http://php.net/call_user_func
* @param $mode string
*/ */
static function add_callback($function, $mode = 'site') { static function add_callback($function, $mode = 'site') {
user_error (
'Director::add_callback() is deprecated, please use a custom extension on your controller', E_USER_NOTICE
);
self::$callbacks[$mode][] = $function; self::$callbacks[$mode][] = $function;
} }

View File

@ -35,8 +35,6 @@ class ModelAsController extends Controller implements NestedController {
public function init() { public function init() {
singleton('SiteTree')->extend('modelascontrollerInit', $this); singleton('SiteTree')->extend('modelascontrollerInit', $this);
Director::set_site_mode('site');
} }
public function getNestedController() { public function getNestedController() {

View File

@ -19,11 +19,6 @@ class RootURLController extends Controller {
*/ */
protected static $default_homepage_urlsegment = 'home'; protected static $default_homepage_urlsegment = 'home';
public function init() {
Director::set_site_mode('site');
parent::init();
}
public function handleRequest($request) { public function handleRequest($request) {
self::$is_at_root = true; self::$is_at_root = true;
$this->pushCurrent(); $this->pushCurrent();
@ -116,4 +111,4 @@ class RootURLController extends Controller {
} }
} }
?> ?>

View File

@ -154,9 +154,7 @@ class Translatable extends DataObjectDecorator {
/** /**
* The language in which we are reading dataobjects. * The language in which we are reading dataobjects.
* Usually stored in session, specific to the "site mode": *
* either 'site' or 'cms'.
* @see Director::get_site_mode()
* @var string * @var string
*/ */
protected static $current_locale = null; protected static $current_locale = null;
@ -198,19 +196,16 @@ class Translatable extends DataObjectDecorator {
/** /**
* Choose the language the site is currently on. * Choose the language the site is currently on.
* If $_GET['locale'] is set, then it will use that language, and store it in the session. *
* Otherwise it checks the session for a possible stored language, either from namespace to the site_mode * If $_GET['locale'] is currently set, then that locale will be used. Otherwise the member preference (if logged
* ('site' or 'cms'), or for a 'global' language setting. * in) or default locale will be used.
* The final option is the member preference.
* *
* @todo Re-implement cookie and member option * @todo Re-implement cookie and member option
* *
* @uses Director::get_site_mode()
* @param $langsAvailable array A numerical array of languages which are valid choices (optional) * @param $langsAvailable array A numerical array of languages which are valid choices (optional)
* @return string Selected language (also saved in $current_locale). * @return string Selected language (also saved in $current_locale).
*/ */
static function choose_site_locale($langsAvailable = array()) { static function choose_site_locale($langsAvailable = array()) {
$siteMode = Director::get_site_mode(); // either 'cms' or 'site'
if(self::$current_locale) { if(self::$current_locale) {
return self::$current_locale; return self::$current_locale;
} }