Example #1
0
 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggregated array of ValidationFailed objects will be returned.
  *
  * @param array $columns Array of column names to validate.
  * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objects otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aPage !== null) {
             if (!$this->aPage->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aPage->getValidationFailures());
             }
         }
         if ($this->aUserRelatedByCreatedBy !== null) {
             if (!$this->aUserRelatedByCreatedBy->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUserRelatedByCreatedBy->getValidationFailures());
             }
         }
         if ($this->aUserRelatedByUpdatedBy !== null) {
             if (!$this->aUserRelatedByUpdatedBy->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUserRelatedByUpdatedBy->getValidationFailures());
             }
         }
         if (($retval = PagePropertyPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
 public function validate()
 {
     $result = parent::validate();
     /* @var $result ValidationResult */
     if ($this->EntriesPerPage <= 0) {
         $message = _t("GuestbookPage.ENTRIESPERPAGEERROR", 'EntriesPerPage must be greater than zero. Was {count}.', "", array('count' => $this->EntriesPerPage));
         $result->error($message);
     }
     return $result;
 }
 public function validate()
 {
     $valid = parent::validate();
     if ($this->EmailSubmitButtonText == '') {
         $this->EmailSubmitButtonText = 'Submit Enquiry';
     }
     if ($this->CaptchaText == '') {
         $this->CaptchaText = 'Verification Image';
     }
     return $valid;
 }
Example #4
0
 public function actionCreate()
 {
     $model = new Page(Page::SCENARIO_CREATE);
     $model->type = Page::TYPE_QA;
     $form = new Form('content.PageCForm', $model);
     if ($form->submitted() && $model->validate()) {
         $model->save();
         $this->redirect(['index']);
     }
     $this->render('create', ['form' => $form]);
 }
 /**
  * Ensure that the IFrameURL is a valid url and prevents XSS
  * 
  * @throws ValidationException
  * @return ValidationResult
  */
 public function validate()
 {
     $result = parent::validate();
     //whitelist allowed URL schemes
     $allowed_schemes = array('http', 'https');
     if ($matches = parse_url($this->IFrameURL)) {
         if (isset($matches['scheme']) && !in_array($matches['scheme'], $allowed_schemes)) {
             $result->error(_t('IFramePage.VALIDATION.BANNEDURLSCHEME', "This URL scheme is not allowed."));
         }
     }
     return $result;
 }
Example #6
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'show' page.
  */
 public function actionCreate()
 {
     $model = new Page();
     if (isset($_POST['Page'])) {
         $model->attributes = $_POST['Page'];
         if (isset($_POST['previewPage'])) {
             $model->validate();
         } else {
             if (isset($_POST['submitPage']) && $model->save()) {
                 $this->redirect(array('show', 'slug' => $model->slug));
             }
         }
     }
     $this->pageTitle = Yii::t('lan', 'New Page');
     $this->render('create', array('model' => $model));
 }
 /**
  *	Confirm that the current page is valid.
  */
 public function validate()
 {
     $parent = $this->getParent();
     // The URL segment will conflict with a year/month/day/media format when numeric.
     if (is_numeric($this->URLSegment) || !$parent instanceof MediaHolder || $this->MediaTypeID && $parent->MediaTypeID != $this->MediaTypeID) {
         // Customise a validation error message.
         $message = is_numeric($this->URLSegment) ? '"URL Segment" must not be numeric!' : 'Invalid media holder!';
         $error = new SS_HTTPResponse_Exception($message, 403);
         $error->getResponse()->addHeader('X-Status', rawurlencode($message));
         // Allow extension customisation.
         $this->extend('validateMediaPage', $error);
         throw $error;
     }
     return parent::validate();
 }
Example #8
0
 public function validate()
 {
     $result = parent::validate();
     // "Can be root" validation
     $orig = $this->CopyContentFrom();
     if (!$orig->stat('can_be_root') && !$this->ParentID) {
         $result->error(_t('VirtualPage.PageTypNotAllowedOnRoot', 'Original page type "{type}" is not allowed on the root level for this virtual page', array('type' => $orig->i18n_singular_name())), 'CAN_BE_ROOT_VIRTUAL');
     }
     return $result;
 }
Example #9
0
 public function handleGet()
 {
     global $_GET;
     $this->_page = Page::getDefault();
     if (isset($_GET['p'])) {
         $this->_page = Page::validate($_GET['p']);
     }
     $this->_lang = Language::getDefault();
     if (isset($_GET['l'])) {
         $this->_lang = Language::validate($_GET['l']);
         $this->saveCookie('language', $this->_lang, 60 * 60 * 24 * 365);
     }
     foreach ($_GET as $id => $val) {
         $this->_gets[$id] = Validator::cleanInput($val);
     }
 }
Example #10
0
 public function validate()
 {
     $result = parent::validate();
     /*if($this->ID>0){
           if($this->Price <= 0) {
               $result->error('Must set a positive price value');
           }
           if($this->Weight <= 0){
               $result->error('Must set a positive weight value');
           }
           if($this->Code == ''){
               $result->error('Must set a product code');
           }
       }*/
     return $result;
 }
 protected function validate()
 {
     return parent::validate();
 }
Example #12
0
	function validate() {
		$result = parent::validate();

		// "Can be root" validation
		$orig = $this->CopyContentFrom();
		if(!$orig->stat('can_be_root') && !$this->ParentID) {
			$result->error(
				sprintf(
					_t(
						'VirtualPage.PageTypNotAllowedOnRoot', 
						'Original page type "%s" is not allowed on the root level for this virtual page', 
						
						'First argument is a class name'
					),
					$orig->i18n_singular_name()
				),
				'CAN_BE_ROOT_VIRTUAL'
			);
		}

		return $result;
	}