예제 #1
0
 function PostCommentForm()
 {
     Requirements::javascript('jsparty/behaviour.js');
     Requirements::javascript('jsparty/prototype.js');
     Requirements::javascript('jsparty/scriptaculous/effects.js');
     Requirements::javascript('cms/javascript/PageCommentInterface.js');
     $fields = new FieldSet(new HiddenField("ParentID", "ParentID", $this->page->ID), new TextField("Name", _t('PageCommentInterface.YOURNAME', 'Your name')));
     if (MathSpamProtection::isEnabled()) {
         $fields->push(new TextField("Math", sprintf(_t('PageCommentInterface.SPAMQUESTION', "Spam protection question: %s"), MathSpamProtection::getMathQuestion())));
     }
     $fields->push(new TextareaField("Comment", _t('PageCommentInterface.YOURCOMMENT', "Comments")));
     $form = new PageCommentInterface_Form($this->controller, $this->methodName . ".PostCommentForm", $fields, new FieldSet(new FormAction("postcomment", _t('PageCommentInterface.POST', 'Post'))));
     $form->loadDataFrom(array("Name" => Cookie::get("PageCommentInterface_Name")));
     return $form;
 }
예제 #2
0
 function PostCommentForm()
 {
     $fields = new FieldSet(new HiddenField("ParentID", "ParentID", $this->page->ID));
     $member = Member::currentUser();
     if ((self::$comments_require_login || self::$comments_require_permission) && $member && $member->FirstName) {
         // note this was a ReadonlyField - which displayed the name in a span as well as the hidden field but
         // it was not saving correctly. Have changed it to a hidden field. It passes the data correctly but I
         // believe the id of the form field is wrong.
         $fields->push(new ReadonlyField("NameView", _t('PageCommentInterface.YOURNAME', 'Your name'), $member->getName()));
         $fields->push(new HiddenField("Name", "", $member->getName()));
     } else {
         $fields->push(new TextField("Name", _t('PageCommentInterface.YOURNAME', 'Your name')));
     }
     // optional commenter URL
     $fields->push(new TextField("CommenterURL", _t('PageCommentInterface.COMMENTERURL', "Your website URL")));
     if (MathSpamProtection::isEnabled()) {
         $fields->push(new TextField("Math", sprintf(_t('PageCommentInterface.SPAMQUESTION', "Spam protection question: %s"), MathSpamProtection::getMathQuestion())));
     }
     $fields->push(new TextareaField("Comment", _t('PageCommentInterface.YOURCOMMENT', "Comments")));
     $form = new PageCommentInterface_Form($this, "PostCommentForm", $fields, new FieldSet(new FormAction("postcomment", _t('PageCommentInterface.POST', 'Post'))));
     // Set it so the user gets redirected back down to the form upon form fail
     $form->setRedirectToFormOnValidationError(true);
     // Optional Spam Protection.
     if (class_exists('SpamProtectorManager')) {
         SpamProtectorManager::update_form($form, null, array('Name', 'CommenterURL', 'Comment'));
         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"), "CommenterURL" => Cookie::get("PageCommentInterface_CommenterURL")));
     return $form;
 }
 function PostCommentForm()
 {
     if (!$this->page->ProvideComments) {
         return false;
     }
     $fields = new FieldSet(new HiddenField("ParentID", "ParentID", $this->page->ID));
     $member = Member::currentUser();
     if ((self::$comments_require_login || self::$comments_require_permission) && $member && $member->FirstName) {
         // note this was a ReadonlyField - which displayed the name in a span as well as the hidden field but
         // it was not saving correctly. Have changed it to a hidden field. It passes the data correctly but I
         // believe the id of the form field is wrong.
         $fields->push(new ReadonlyField("NameView", _t('PageCommentInterface.YOURNAME', 'Your name'), $member->getName()));
         $fields->push(new HiddenField("Name", "", $member->getName()));
     } else {
         $fields->push(new TextField("Name", _t('PageCommentInterface.YOURNAME', 'Your name')));
     }
     // optional commenter URL
     $fields->push(new TextField("CommenterURL", _t('PageCommentInterface.COMMENTERURL', "Your website URL")));
     if (MathSpamProtection::isEnabled()) {
         $fields->push(new TextField("Math", sprintf(_t('PageCommentInterface.SPAMQUESTION', "Spam protection question: %s"), MathSpamProtection::getMathQuestion())));
     }
     $fields->push(new TextareaField("Comment", _t('PageCommentInterface.YOURCOMMENT', "Comments")));
     $form = new PageCommentInterface_Form($this, "PostCommentForm", $fields, new FieldSet(new FormAction("postcomment", _t('PageCommentInterface.POST', 'Post'))), new RequiredFields('Name', 'Comment'));
     // Set it so the user gets redirected back down to the form upon form fail
     $form->setRedirectToFormOnValidationError(true);
     // Optional Spam Protection.
     if (class_exists('SpamProtectorManager')) {
         SpamProtectorManager::update_form($form, null, array('Name' => 'author_name', 'CommenterURL' => 'author_url', 'Comment' => 'post_body'));
         self::set_use_ajax_commenting(false);
     }
     // Add note about moderated comments
     if (PageComment::moderationEnabled()) {
         $fields->push(new LiteralField('ModerationNote', sprintf('<p class="moderationMessage"><small>%s</small></p>', _t('PageCommentInterface.ModerationEnabledNote', 'Note: Comments are moderated and won\'t show until they are approved'))));
     }
     // Shall We use AJAX?
     if (self::$use_ajax_commenting) {
         Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
         Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
         Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
         Requirements::javascript(CMS_DIR . '/javascript/PageCommentInterface.js');
     }
     $this->extend('updatePageCommentForm', $form);
     // Load the users data from a cookie
     $cookie = Cookie::get('PageCommentInterface_Data');
     if ($cookie) {
         $visibleFields = array();
         foreach ($fields as $field) {
             if (!$field instanceof HiddenField) {
                 $visibleFields[] = $field->Name();
             }
         }
         $form->loadDataFrom(Convert::json2array($cookie), false, $visibleFields);
     }
     return $form;
 }
	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)
		);
		
		$member = Member::currentUser();
		
		if((self::$comments_require_login || self::$comments_require_permission) && $member && $member->FirstName) {
			// note this was a ReadonlyField - which displayed the name in a span as well as the hidden field but
			// it was not saving correctly. Have changed it to a hidden field. It passes the data correctly but I 
			// believe the id of the form field is wrong.
			$fields->push(new ReadonlyField("NameView", _t('PageCommentInterface.YOURNAME', 'Your name'), $member->getName()));
			$fields->push(new HiddenField("Name", "", $member->getName()));
		} else {
			$fields->push(new TextField("Name", _t('PageCommentInterface.YOURNAME', 'Your name')));
		}
				
		// optional commenter URL
		$fields->push(new TextField("CommenterURL", _t('PageCommentInterface.COMMENTERURL', "Your website URL")));
		
		if(MathSpamProtection::isEnabled()){
			$fields->push(new TextField("Math", sprintf(_t('PageCommentInterface.SPAMQUESTION', "Spam protection question: %s"), MathSpamProtection::getMathQuestion())));
		}				
		
		$fields->push(new TextareaField("Comment", _t('PageCommentInterface.YOURCOMMENT', "Comments")));
		
		$form = new PageCommentInterface_Form($this, "PostCommentForm", $fields, new FieldSet(
			new FormAction("postcomment", _t('PageCommentInterface.POST', 'Post'))
		));
		
		$form->loadDataFrom(array(
			"Name" => Cookie::get("PageCommentInterface_Name"),
			"Comment" => Cookie::get("PageCommentInterface_Comment"),
			"URL" => Cookie::get("PageCommentInterface_CommenterURL")	
		));
		
		return $form;
	}