From 550931c02aa22ec1559ad99379a829bc4a7d7fce Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Tue, 10 Mar 2009 21:59:19 +0000 Subject: [PATCH] Merged from branches/2.3 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@72801 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/AssetAdmin.php | 4 +- code/LeftAndMain.php | 6 +-- code/MemberTableField.php | 7 ++- code/SecurityAdmin.php | 1 + code/sitefeatures/PageCommentInterface.php | 57 ++++++++++++++++++---- css/layout.css | 3 +- 6 files changed, 62 insertions(+), 16 deletions(-) diff --git a/code/AssetAdmin.php b/code/AssetAdmin.php index 83f2445d..4e87d253 100755 --- a/code/AssetAdmin.php +++ b/code/AssetAdmin.php @@ -424,7 +424,7 @@ JS; */ public function SiteTreeAsUL() { $obj = singleton('Folder'); - $obj->setMarkingFilter('ClassName', 'Folder'); + $obj->setMarkingFilter('ClassName', ClassInfo::subclassesFor('Folder')); $obj->markPartialTree(); if($p = $this->currentPage()) $obj->markToExpose($p); @@ -454,7 +454,7 @@ JS; */ public function getsubtree() { $obj = DataObject::get_by_id('Folder', $_REQUEST['ID']); - $obj->setMarkingFilter('ClassName', 'Folder'); + $obj->setMarkingFilter('ClassName', ClassInfo::subclassesFor('Folder')); $obj->markPartialTree(); $results = $obj->getChildrenAsUL( diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 7e87dba4..33fd85e9 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -181,7 +181,7 @@ class LeftAndMain extends Controller { Requirements::javascript(THIRDPARTY_DIR . '/loader.js'); Requirements::javascript(THIRDPARTY_DIR . '/hover.js'); Requirements::javascript(THIRDPARTY_DIR . '/layout_helpers.js'); - Requirements::javascript(SAPPHIRE_DIR . "/javascript/i18n.js"); + Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang'); Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js'); Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/dragdrop.js'); @@ -983,7 +983,7 @@ JS; * @param String $name The application name * @param String $logoText The logo text */ - static $application_link = "http://www.silverstripe.com/"; + static $application_link = "http://www.silverstripe.org/"; static function setApplicationName($name, $logoText = null, $link = null) { self::$application_name = $name; self::$application_logo_text = $logoText ? $logoText : $name; @@ -1116,4 +1116,4 @@ JS; } -?> \ No newline at end of file +?> diff --git a/code/MemberTableField.php b/code/MemberTableField.php index b9f259af..ce7b49de 100755 --- a/code/MemberTableField.php +++ b/code/MemberTableField.php @@ -283,7 +283,12 @@ class MemberTableField extends ComplexTableField { function AddRecordForm() { $fields = new FieldSet(); foreach($this->FieldList() as $fieldName => $fieldTitle) { - $fields->push(new TextField($fieldName)); + // If we're adding the set password field, we want to hide the text from any peeping eyes + if($fieldName == 'SetPassword') { + $fields->push(new PasswordField($fieldName)); + } else { + $fields->push(new TextField($fieldName)); + } } $fields->push(new HiddenField('ctf[ID]', null, $this->group->ID)); diff --git a/code/SecurityAdmin.php b/code/SecurityAdmin.php index ff868a4a..a4fd1815 100644 --- a/code/SecurityAdmin.php +++ b/code/SecurityAdmin.php @@ -34,6 +34,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider { Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js"); // needed for MemberTableField (Requirements not determined before Ajax-Call) + Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang'); Requirements::javascript(SAPPHIRE_DIR . "/javascript/TableListField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/TableField.js"); Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js"); diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index feae3dd2..f60c5d26 100755 --- a/code/sitefeatures/PageCommentInterface.php +++ b/code/sitefeatures/PageCommentInterface.php @@ -17,19 +17,32 @@ class PageCommentInterface extends RequestHandler { protected $controller, $methodName, $page; /** - * @var boolean If this is true, you must be logged in to post a comment + * If this is true, you must be logged in to post a comment * (and therefore, you don't need to specify a 'Your name' field unless * your name is blank) + * + * @var bool */ static $comments_require_login = false; /** - * @var string If this is a valid permission code, you must be logged in + * If this is a valid permission code, you must be logged in * and have the appropriate permission code on your account before you can * post a comment. + * + * @var string */ static $comments_require_permission = ""; + /** + * If this is true it will include the javascript for AJAX + * commenting. If it is set to false then it will not load + * the files required and it will fall back + * + * @var bool + */ + static $use_ajax_commenting = true; + /** * Create a new page comment interface * @param controller The controller that the interface is used on @@ -62,6 +75,14 @@ class PageCommentInterface extends RequestHandler { self::$comments_require_permission = $permission; } + /** + * See {@link PageCommentInterface::$use_ajax_commenting} + * @param bool + */ + static function set_use_ajax_commenting($state) { + self::$use_ajax_commenting = $state; + } + function forTemplate() { return $this->renderWith('PageCommentInterface'); } @@ -87,9 +108,11 @@ class PageCommentInterface extends RequestHandler { } /** - * @return boolean true if this page comment form requires users to have a + * if this page comment form requires users to have a * valid permission code in order to post (used to customize the error * message). + * + * @return bool */ function PostingRequiresPermission() { return self::$comments_require_permission; @@ -100,12 +123,6 @@ class PageCommentInterface extends RequestHandler { } function PostCommentForm() { - Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js'); - Requirements::javascript(THIRDPARTY_DIR . '/prototype.js'); - Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js'); - Requirements::javascript(CMS_DIR . '/javascript/PageCommentInterface.js'); - - $fields = new FieldSet( new HiddenField("ParentID", "ParentID", $this->page->ID) ); @@ -135,6 +152,28 @@ class PageCommentInterface extends RequestHandler { new FormAction("postcomment", _t('PageCommentInterface.POST', 'Post')) )); + // Optional Spam Protection. + if(class_exists('SpamProtecterManager')) { + // Update the form to add the protecter field to it + $protecter = SpamProtecterManager::update_form($form); + if($protecter) { + $protecter->setFieldMapping('Name', 'Comment'); + + // Because most of the Spam Protection will need to query another service + // disable ajax commenting + self::set_use_ajax_commenting(false); + } + } + + // Shall We use AJAX? + if(self::$use_ajax_commenting) { + Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js'); + Requirements::javascript(THIRDPARTY_DIR . '/prototype.js'); + Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js'); + Requirements::javascript(CMS_DIR . '/javascript/PageCommentInterface.js'); + } + + // Load the data from Session $form->loadDataFrom(array( "Name" => Cookie::get("PageCommentInterface_Name"), "Comment" => Cookie::get("PageCommentInterface_Comment"), diff --git a/css/layout.css b/css/layout.css index 1815012b..e56e48af 100644 --- a/css/layout.css +++ b/css/layout.css @@ -534,9 +534,10 @@ iframe { } #contentPanel .thumbnailstrip { border: none; - width: 180px; + width: 190px; height: 120px; overflow-y: auto; + margin-right: 0 !important; } #Caption {