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);
if(Director::redirected_to()) return;
Director::set_site_mode('site');
// Check page permissions
if($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->can('View')) {

View File

@ -19,6 +19,9 @@ class Director {
static private $rules = array();
/**
* @deprecated 2.4
*/
static $siteMode;
static $alternateBaseFolder;
@ -35,8 +38,7 @@ class Director {
static protected $environment_type;
/**
* Sets the site mode (if it is the public site or the cms),
* and runs registered modules.
* @deprecated 2.4
*/
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.
*
* @param string $mode 'site' or 'cms'
* @deprecated 2.4
*/
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;
if(isset(self::$callbacks[$mode])) {
@ -653,23 +657,24 @@ class Director {
}
/**
* @return string 'site' or 'cms'
* @deprecated 2.4
*/
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;
}
/**
* Allows a module to register with the director to be run once
* 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
* @deprecated 2.4 Use a custom extension on your controller.
*/
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;
}

View File

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

View File

@ -19,11 +19,6 @@ class RootURLController extends Controller {
*/
protected static $default_homepage_urlsegment = 'home';
public function init() {
Director::set_site_mode('site');
parent::init();
}
public function handleRequest($request) {
self::$is_at_root = true;
$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.
* Usually stored in session, specific to the "site mode":
* either 'site' or 'cms'.
* @see Director::get_site_mode()
*
* @var string
*/
protected static $current_locale = null;
@ -198,19 +196,16 @@ class Translatable extends DataObjectDecorator {
/**
* 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
* ('site' or 'cms'), or for a 'global' language setting.
* The final option is the member preference.
*
* If $_GET['locale'] is currently set, then that locale will be used. Otherwise the member preference (if logged
* in) or default locale will be used.
*
* @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)
* @return string Selected language (also saved in $current_locale).
*/
static function choose_site_locale($langsAvailable = array()) {
$siteMode = Director::get_site_mode(); // either 'cms' or 'site'
if(self::$current_locale) {
return self::$current_locale;
}