Merged from branches/2.2

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65523 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-11-10 03:51:35 +00:00
parent 9c9a461d67
commit 58dbe416ee
11 changed files with 68 additions and 29 deletions

View File

@ -590,7 +590,7 @@ class i18n extends Object {
'lt' => array('Lithuanian', 'lietuviškai'),
'lmo' => array('Lombard', 'Lombardo'),
'mk' => array('Macedonian', 'македонски'),
'mi' => array('Maori', 'Maori'),
'mi' => array('Maori', 'Māori'),
'ms' => array('Malay', 'Bahasa melayu'),
'mt' => array('Maltese', 'Malti'),
'mr' => array('Marathi', 'मराठी'),

View File

@ -185,6 +185,11 @@ class SiteTree extends DataObject {
'Content',
);
/**
* This controls whether of not extendCMSFields() is called by getCMSFields.
*/
private static $runCMSFieldsExtensions = true;
/**
* Get the URL for this page.
*
@ -1288,7 +1293,9 @@ class SiteTree extends DataObject {
$tabAccess->setTitle(_t('SiteTree.TABACCESS', "Access"));
$tabBacklinks->setTitle(_t('SiteTree.TABBACKLINKS', "BackLinks"));
if(self::$runCMSFieldsExtensions) {
$this->extend('updateCMSFields', $fields);
}
return $fields;
}
@ -1700,5 +1707,23 @@ class SiteTree extends DataObject {
return $classes;
}
/**
* Stops extendCMSFields() being called on getCMSFields().
* This is useful when you need access to fields added by subclasses
* of SiteTree in a decorator. Call before calling parent::getCMSFields(),
* and reenable afterwards.
*/
public static function disableCMSFieldsExtensions() {
self::$runCMSFieldsExtensions = false;
}
/**
* Reenables extendCMSFields() being called on getCMSFields() after
* it has been disabled by disableCMSFieldsExtensions().
*/
public static function enableCMSFieldsExtensions() {
self::$runCMSFieldsExtensions = true;
}
}
?>

View File

@ -67,6 +67,7 @@ class Text extends DBField {
* @param int $sentCount The amount of sentences you want.
*/
function LimitSentences($sentCount = 2) {
$output = '';
$data = Convert::xml2raw($this->value);
$sentences = explode('.', $data);
if(count($sentences) == 1) {

View File

@ -25,6 +25,7 @@ class Folder extends File {
$item = new Folder();
$item->ParentID = $parentID;
$item->Name = $part;
$item->Title = $part;
$item->write();
if(!file_exists($item->getFullPath())) mkdir($item->getFullPath(),Filesystem::$folder_create_mask);
}
@ -32,6 +33,8 @@ class Folder extends File {
}
return $item;
}
// To Make SSP Gallery structure work
// $item->Title = $part;
/**
* Syncronise the file database with the actual content of the assets folder

View File

@ -7,8 +7,10 @@
class CompositeDateField extends DateField {
function __construct($name, $title, $value = null, $yearRange = null){
$year = $month = $date = null;
if($value) list($year,$month, $date) = explode('-', $value);
$exploded = explode('-', $value);
$year = isset($exploded[0]) ? $exploded[0] : null;
$month = isset($exploded[1]) ? $exploded[1] : null;
$date = isset($exploded[2]) ? $exploded[2] : null;
$this->dateDropdown = new DropdownField($name."[date]", "",
array('NotSet' => '('._t('CompositeDateField.DAY', 'Day').')',

View File

@ -9,9 +9,9 @@ class CountryDropdownField extends DropdownField {
protected $defaultToVisitorCountry = true;
function __construct($name, $title, $source = null, $value = "", $form=null) {
if(!is_array($source)) {
$source = Geoip::getCountryDropDown();
}
if(!is_array($source)) $source = Geoip::getCountryDropDown();
if(!$value) $value = Geoip::visitor_country();
parent::__construct($name, $title, $source, $value, $form);
}

View File

@ -274,14 +274,14 @@ class TableField extends TableListField {
// Sort into proper array
$this->value = ArrayLib::invert($this->value);
$dataObjects = $this->sortData($this->value, $record->ID);
if($dataObjects['new']) {
if(isset($dataObjects['new']) && $dataObjects['new']) {
$newFields = $this->sortData($dataObjects['new'], $record->ID);
}
$savedObj = $this->saveData($dataObjects, $this->editExisting);
if($savedObj && $newFields) {
$savedObj += $this->saveData($newFields,false);
} else if($newFields) {
if($savedObj && isset($newFields)) {
$savedObj = $this->saveData($newFields,false);
} else if(isset($newFields)) {
$savedObj = $this->saveData($newFields,false);
}
$items = $this->sourceItems();

View File

@ -43,7 +43,7 @@ class TreeDropdownField extends FormField {
if($this->value) {
$record = DataObject::get_by_id($this->sourceObject, $this->value);
$title = ($record) ? $record->Title : '';
$title = ($record) ? $record->Title : _t('DropdownField.CHOOSE', "(Choose)", PR_MEDIUM, 'Start-value of a dropdown');
} else {
$title = _t('DropdownField.CHOOSE', "(Choose)", PR_MEDIUM, 'Start-value of a dropdown');
}

View File

@ -141,7 +141,12 @@ Behaviour.register({
},
onblur : function() {
if(this.old_onblur()) {
// Don't perform instant validation for CalendarDateField fields; it creates usability wierdness.
if(this.parentNode.className.indexOf('calendardate') == -1 || this.value) {
return $('$formID').validate(this);
} else {
return true;
}
}
}
},

View File

@ -119,22 +119,29 @@ class MemberLoginForm extends LoginForm {
Session::clear("BackURL");
Director::redirect($backURL);
} else {
$firstname = Convert::raw2xml($member->FirstName);
Session::set("Security.Message.message",
sprintf(_t('Member.WELCOMEBACK', "Welcome Back, %s"), $firstname)
);
Session::set("Security.Message.type", "good");
Director::redirectBack();
}
} else {
Session::set('SessionForms.MemberLoginForm.Email', $data['Email']);
Session::set('SessionForms.MemberLoginForm.Remember', isset($data['Remember']));
if(isset($_REQUEST['BackURL']) && $backURL = $_REQUEST['BackURL']) {
Session::set('BackURL', $backURL);
}
if(isset($_REQUEST['BackURL'])) $backURL = $_REQUEST['BackURL'];
else $backURL = null;
if($backURL) Session::set('BackURL', $backURL);
if($badLoginURL = Session::get("BadLoginURL")) {
Director::redirect($badLoginURL);
} else {
// Show the right tab on failed login
Director::redirect(Director::absoluteURL(Security::Link("login")) .
'#' . $this->FormName() .'_tab');
$loginLink = Director::absoluteURL(Security::Link("login"));
if($backURL) $loginLink .= '?BackURL=' . urlencode($backURL);
Director::redirect($loginLink . '#' . $this->FormName() .'_tab');
}
}
}
@ -163,12 +170,6 @@ class MemberLoginForm extends LoginForm {
*/
public function performLogin($data) {
if($member = MemberAuthenticator::authenticate($data, $this)) {
$firstname = Convert::raw2xml($member->FirstName);
Session::set("Security.Message.message",
sprintf(_t('Member.WELCOMEBACK', "Welcome Back, %s"), $firstname)
);
Session::set("Security.Message.type", "good");
$member->LogIn(isset($data['Remember']));
return $member;

View File

@ -349,6 +349,8 @@ class Security extends Controller {
));
}
Session::clear('Security.Message');
// custom processing
if(SSViewer::hasTemplate("Security_login")) {
return $customisedController->renderWith(array("Security_login", $this->stat('template_main')));
@ -802,7 +804,7 @@ class Security extends Controller {
'salt' => null,
'algorithm' => 'none');
} elseif((self::$encryptPasswords == false) || ($algorithm == 'none')) {
} elseif((!$algorithm && self::$encryptPasswords == false) || ($algorithm == 'none')) {
// The password should not be encrypted
return array('password' => substr($password, 0, 64),
'salt' => null,