From b8adcd8aad039800665749ca942288a7f82a61c8 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 11 Aug 2008 00:21:44 +0000 Subject: [PATCH] (merged from branches/roa. use "svn log -c -g " for detailed commit message) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60289 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- css/Form.css | 9 +++++ forms/ResetFormAction.php | 8 +++-- forms/TableListField.php | 60 +++++++++++++++++++------------- lang/en_US.php | 3 +- security/LoginAttempt.php | 5 +++ security/MemberAuthenticator.php | 1 + 6 files changed, 59 insertions(+), 27 deletions(-) diff --git a/css/Form.css b/css/Form.css index 2fdeb6b17..5b3a9e315 100644 --- a/css/Form.css +++ b/css/Form.css @@ -61,6 +61,15 @@ form .indicator.block { display: inline; } +/* Emulating link styling for actions requiring lesser attention, e.g. "cancel" FormActions */ +form button.minorAction { + background: none; + padding: 0; + border: 0; + color: #0074C6; /* same for "a" tag in cms/css/typography.css */ + text-decoration: underline; +} + /** * Composite Fields - raw concatenation of fields for programmatic purposes. diff --git a/forms/ResetFormAction.php b/forms/ResetFormAction.php index 3ef108bb2..4709ae01e 100755 --- a/forms/ResetFormAction.php +++ b/forms/ResetFormAction.php @@ -8,8 +8,12 @@ class ResetFormAction extends FormAction { function Field() { - if($this->description) $titleAttr = "title=\"" . Convert::raw2att($this->description) . "\""; - return "id() . "\" type=\"reset\" name=\"{$this->name}\" value=\"" . $this->attrTitle() . "\" $titleAttr />"; + $titleAttr = $this->description ? "title=\"" . Convert::raw2att($this->description) . "\"" : ''; + if($this->useButtonTag) { + return "\n"; + } else { + return "extraClass() . "\" id=\"" . $this->id() . "\" type=\"reset\" name=\"$this->action\" value=\"" . $this->attrTitle() . "\" $titleAttr />\n"; + } } } diff --git a/forms/TableListField.php b/forms/TableListField.php index 4c5f140bc..3c45730f6 100755 --- a/forms/TableListField.php +++ b/forms/TableListField.php @@ -1,4 +1,10 @@ + * array("\""=>"\"\"","\r"=>"", "\r\n"=>"", "\n"=>"") + * + */ + public $csvFieldEscape = array( + "\""=>"\"\"", + "\r\n"=>"", + "\r"=>"", + "\n"=>"", + ); + /** * @var int Shows total count regardless or pagination @@ -165,14 +185,6 @@ class TableListField extends FormField { */ public $fieldFormatting = array(); - /** - * @var array Specify custom escape for the fields, e.g. to escape all accurance of "\r", "\r\n" and "\n" of the field - * value, we need to set this field as array("\r"=>"", "\r\n"=>"", "\n"=>"") ; - * Example: setFieldEscape(array("\""=>"\"\"","\r"=>"", "\r\n"=>"", "\n"=>"") is needed for exporting the table to a .csv - * file - */ - public $fieldEscape = array(); - /** * @var string */ @@ -829,29 +841,33 @@ JS $sourceClass = $this->sourceClass; $dataobject = new $sourceClass(); + + // @todo Will create a large unpaginated dataobjectset based on how many records are in table (performance issue) $items = $dataobject->buildDataObjectSet($records, 'DataObjectSet'); $fieldItems = new DataObjectSet(); - - if($items&&$items->count()) foreach($items as $item) { - $fieldItem = new TableListField_Item($item, $this); + if($items && $items->count()) foreach($items as $item) { + // create a TableListField_Item to support resolving of + // relation-fields in dot notation via TableListField_Item->Fields() if($item) $fieldItems->push(new TableListField_Item($item, $this)); } + // temporary override to adjust TableListField_Item behaviour $this->setFieldFormatting(array()); - $this->setFieldEscape(array( - "\""=>"\"\"", - "\r\n"=>"", - "\r"=>"", - "\n"=>"", - )); + $this->fieldList = $csvColumns; if($fieldItems) { - foreach($fieldItems as $fieldItem) { - $fileData .= $fieldItem->renderwith("TableListField_Item_export"); + $fields = $fieldItem->Fields(); + foreach($fields as $field) { + $fileData .= "\"" . $field->Value . "\""; + if($field->Last()) { + $fileData .= "\n"; + } else { + $fileData .= $this->csvSeparator; + } + } } - HTTP::sendFileToBrowser($fileData, $fileName); } else { user_error("No records found", E_USER_ERROR); @@ -931,10 +947,6 @@ JS $this->fieldFormatting = $formatting; } - function setFieldEscape($escape){ - $this->fieldEscape = $escape; - } - /** * @return String */ diff --git a/lang/en_US.php b/lang/en_US.php index f8cc71501..fc3c6bd07 100644 --- a/lang/en_US.php +++ b/lang/en_US.php @@ -358,6 +358,7 @@ $lang['en_US']['SimpleImageField']['NOUPLOAD'] = 'No Image Uploaded'; $lang['en_US']['TableField']['ISREQUIRED'] = 'In %s \'%s\' is required.'; $lang['en_US']['TableListField']['CSVEXPORT'] = 'Export to CSV'; $lang['en_US']['TableListField']['PRINT'] = 'Print'; +$lang['en_US']['TableListField']['VREXPORT'] = 'Export to Vertical Response'; $lang['en_US']['ToggleField']['MORE'] = 'more'; $lang['en_US']['ToggleField']['LESS'] = 'less'; $lang['en_US']['DropdownField']['CHOOSE'] = array( @@ -636,13 +637,13 @@ $lang['en_US']['FieldEditor.ss']['CHECKBOXGROUP'] = 'Checkboxes'; $lang['en_US']['FieldEditor.ss']['MEMBERTITLE'] = 'Add member list field'; $lang['en_US']['FieldEditor.ss']['MEMBER'] = 'Member List'; $lang['en_US']['Image_iframe.ss']['TITLE'] = 'Image Uploading Iframe'; -$lang['en_US']['TableListField_PageControls.ss']['VIEWLAST'] = 'View last'; $lang['en_US']['TableListField_PageControls.ss']['VIEWFIRST'] = 'View first'; $lang['en_US']['TableListField_PageControls.ss']['VIEWPREVIOUS'] = 'View previous'; $lang['en_US']['TableListField_PageControls.ss']['DISPLAYING'] = 'Displaying'; $lang['en_US']['TableListField_PageControls.ss']['TO'] = 'to'; $lang['en_US']['TableListField_PageControls.ss']['OF'] = 'of'; $lang['en_US']['TableListField_PageControls.ss']['VIEWNEXT'] = 'View next'; +$lang['en_US']['TableListField_PageControls.ss']['VIEWLAST'] = 'View last'; $lang['en_US']['RelationComplexTableField.ss']['ADD'] = 'Add'; $lang['en_US']['RelationComplexTableField.ss']['SHOW'] = 'show'; $lang['en_US']['RelationComplexTableField.ss']['EDIT'] = 'edit'; diff --git a/security/LoginAttempt.php b/security/LoginAttempt.php index 450ebceec..adffd4bc3 100644 --- a/security/LoginAttempt.php +++ b/security/LoginAttempt.php @@ -8,6 +8,10 @@ * Security::set_login_recording(true); * * + * Caution: Please make sure that enabling logging + * complies with your privacy standards. We're logging + * username and IP. + * * @package sapphire * @subpackage security */ @@ -16,6 +20,7 @@ class LoginAttempt extends DataObject { static $db = array( 'Email' => 'Varchar(255)', 'Status' => "Enum('Success,Failure')", + 'IP' => 'Varchar(255)', ); static $has_one = array( diff --git a/security/MemberAuthenticator.php b/security/MemberAuthenticator.php index d405b9a26..ddfa6d686 100644 --- a/security/MemberAuthenticator.php +++ b/security/MemberAuthenticator.php @@ -49,6 +49,7 @@ class MemberAuthenticator extends Authenticator { $attempt->Status = 'Failure'; } $attempt->Email = $RAW_data['Email']; + $attempt->IP = Controller::curr()->getRequest()->getIP(); $attempt->write(); }