当前位置: 首页>>代码示例>>PHP>>正文


PHP General::validateString方法代码示例

本文整理汇总了PHP中General::validateString方法的典型用法代码示例。如果您正苦于以下问题:PHP General::validateString方法的具体用法?PHP General::validateString怎么用?PHP General::validateString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在General的用法示例。


在下文中一共展示了General::validateString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getSlice

 /**
  * Fetch recipient data.
  *
  * @todo bugtesting and error handling
  * @return array
  */
 public function getSlice()
 {
     $authors = $this->grab();
     $return['total-entries'] = $this->getCount();
     $pages = (int) $return['total-entries'] / (int) $this->dsParamLIMIT;
     $return['total-pages'] = round($pages);
     $return['remaining-pages'] = max(0, (int) $return['total-pages'] - (int) $this->dsParamSTARTPAGE);
     $return['remaining-entries'] = max(0, (int) $return['total-entries'] - (int) $this->dsParamSTARTPAGE * (int) $this->dsParamLIMIT);
     $return['entries-per-page'] = $this->dsParamLIMIT;
     $return['start'] = ((int) $this->dsParamSTARTPAGE - 1) * (int) $this->dsParamLIMIT + 1;
     $return['current-page'] = (int) $this->dsParamSTARTPAGE;
     require TOOLKIT . '/util.validators.php';
     foreach ($authors as $author) {
         $return['records'][] = array('id' => $author->get('id'), 'name' => $author->get('first_name') . ' ' . $author->get('last_name'), 'email' => $author->get('email'), 'valid' => General::validateString($author->get('email'), $validators['email']) ? true : false);
     }
     if ($this->newsletter_id !== NULL) {
         $newsletter = EmailNewsletterManager::create($this->newsletter_id);
         if (is_a($newsletter, 'EmailNewsletter')) {
             foreach ($return['records'] as $recipient) {
                 $newsletter->_markRecipient($recipient['email'], 'idle');
             }
         }
     }
     return $return;
 }
开发者ID:MST-SymphonyCMS,项目名称:email_newsletter_manager,代码行数:31,代码来源:class.recipientsourceauthor.php

示例2: getSlice

 /**
  * Fetch generated recipient data.
  *
  * Returns parsed recipient data. This means the xslt provided by the user
  * will be ran on the raw data, returning a name and email direcly useable
  * by the email API.
  *
  * This is the preferred way of getting recipient data.
  *
  * @todo bugtesting and error handling
  * @return array
  */
 public function getSlice()
 {
     $entries = $this->grab();
     $return['total-entries'] = (string) $entries['total-entries'];
     $return['total-pages'] = (string) $entries['total-pages'];
     $return['remaining-pages'] = (string) $entries['remaining-pages'];
     $return['remaining-entries'] = (string) $entries['remaining-entries'];
     $return['entries-per-page'] = (string) $entries['limit'];
     $return['start'] = (string) $entries['start'];
     $return['current-page'] = (string) $this->dsParamSTARTPAGE;
     $field_ids = array();
     $xsltproc = new XsltProcess();
     foreach ($this->nameFields as $nameField) {
         $field_ids[] = FieldManager::fetchFieldIDFromElementName($nameField, $this->getSource());
     }
     $email_field_id = FieldManager::fetchFieldIDFromElementName($this->emailField, $this->getSource());
     require TOOLKIT . '/util.validators.php';
     foreach ((array) $entries['records'] as $entry) {
         $entry_data = $entry->getData();
         $element = new XMLElement('entry');
         $name = '';
         $email = '';
         foreach ($entry_data as $field_id => $data) {
             if (in_array($field_id, $field_ids)) {
                 $field = FieldManager::fetch($field_id);
                 $field->appendFormattedElement($element, $data);
             }
             if ($field_id == $email_field_id) {
                 $email = $data['value'];
             }
         }
         $name = trim($xsltproc->process($element->generate(), $this->nameXslt));
         if (!empty($email)) {
             $return['records'][] = array('id' => $entry->get('id'), 'email' => $email, 'name' => $name, 'valid' => General::validateString($email, $validators['email']) ? true : false);
         }
     }
     if ($this->newsletter_id !== NULL) {
         $newsletter = EmailNewsletterManager::create($this->newsletter_id);
         if (is_a($newsletter, 'EmailNewsletter')) {
             foreach ($return['records'] as $recipient) {
                 $newsletter->_markRecipient($recipient['email'], 'idle');
             }
         }
     }
     return $return;
 }
开发者ID:MST-SymphonyCMS,项目名称:email_newsletter_manager,代码行数:58,代码来源:class.recipientsourcesection.php

示例3: commitFiles

 /**
  * Creates a new entry for each valid file in the `$target_section`
  */
 public function commitFiles()
 {
     $entryManager = new EntryManager(Administration::instance());
     $section = $this->target_section;
     // This is the default field instances that will populated with data.
     $entries = array();
     $fields = array('upload' => $this->target_field, 'name' => null, 'section' => null);
     foreach ($section->fetchFields() as $field) {
         if (General::validateString($field->get('type'), Extension_BulkImporter::$supported_fields['name']) && is_null($fields['name'])) {
             $fields['name'] = $field;
         }
         if (General::validateString($field->get('type'), Extension_BulkImporter::$supported_fields['section']) && is_null($fields['section'])) {
             $fields['section'] = $field;
         }
     }
     foreach ($this->files as $file) {
         $path = '/';
         if ($this->preserve_subdirectories) {
             $path = dirname(substr($file->location, strlen($this->extracted_directory)));
             if ($path != '/') {
                 $path .= '/';
             }
         } else {
             if ($this->archive_is_parent) {
                 $path = '/' . $this->extracted_archive . '/';
             }
         }
         $final_destination = preg_replace("/^\\/workspace/", '', $this->target_field->get('destination')) . $path . $file->rawname;
         if (!$file->isValid($this->target_field, $final_destination)) {
             continue;
         }
         $_post = array();
         $entry = $entryManager->create();
         $entry->set('section_id', $section->get('id'));
         $entry->set('author_id', Administration::instance()->Author->get('id'));
         // Set the Name
         if (!is_null($fields['name'])) {
             $_post[$fields['name']->get('element_name')] = $file->name;
         }
         // Set the Upload Field
         if (is_null($fields['upload'])) {
             throw new Exception(__('No valid upload field found in the <code>%s</code>', array($section->get('name'))));
         }
         $_post[$this->target_field->get('element_name')] = $final_destination;
         // Cache some info, before we move file
         // https://github.com/brendo/bulkimporter/pull/7#issuecomment-1105691
         $meta = array('size' => $file->size, 'mimetype' => $file->mimetype, 'meta' => serialize($this->target_field->getMetaInfo($file->location, $file->mimetype)));
         // Move the image from it's bulk-imported location
         $path = WORKSPACE . dirname($final_destination);
         if (!file_exists($path)) {
             General::realiseDirectory($path);
             chmod($path, intval(0755, 8));
         }
         if (rename($file->location, WORKSPACE . $final_destination)) {
             chmod(WORKSPACE . $final_destination, intval(0755, 8));
         }
         $errors = array();
         //	Check all the fields that they are correct
         if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($_post, $errors)) {
             if (!empty($errors)) {
                 $file->setErrors($errors);
             }
             continue;
         }
         if (__ENTRY_OK__ == $entry->setDataFromPost($_post, $errors, false, false)) {
             //	Because we can't upload the file using the inbuilt function
             //	we have to fake the expected output
             $upload = $entry->getData($this->target_field->get('id'));
             foreach ($meta as $key => $value) {
                 if (empty($upload[$key])) {
                     $upload[$key] = $value;
                 }
             }
             $entry->setData($this->target_field->get('id'), $upload);
             /**
              * Just prior to creation of an Entry
              *
              * @delegate EntryPreCreate
              * @param string $context
              * '/publish/new/'
              * @param Section $section
              * @param Entry $entry
              * @param array $fields
              */
             Symphony::ExtensionManager()->notifyMembers('EntryPreCreate', '/publish/new/', array('section' => $section, 'entry' => &$entry, 'fields' => &$_post));
             if ($entry->commit()) {
                 $file->setUploaded();
                 $entries[$final_destination] = $entry->get('id');
                 /**
                  * Creation of an Entry. New Entry object is provided.
                  *
                  * @delegate EntryPostCreate
                  * @param string $context
                  * '/publish/new/'
                  * @param Section $section
                  * @param Entry $entry
                  * @param array $fields
//.........这里部分代码省略.........
开发者ID:brendo,项目名称:bulkimporter,代码行数:101,代码来源:extension.driver.php

示例4: _parseNameAndEmail

 protected function _parseNameAndEmail(&$string)
 {
     $string = trim($string);
     if (strstr($string, '<')) {
         $name = trim(strstr($string, '<', true), "\" \t\n\r\v");
         $email = trim(strstr($string, '<'), "<> \t\n\r\v");
     } else {
         $email = trim($string, " \t\n\r\v");
         $name = NULL;
     }
     if (strlen($email) == 0) {
         unset($string);
     } else {
         require TOOLKIT . '/util.validators.php';
         return array('name' => $name, 'email' => $email, 'valid' => General::validateString($email, $validators['email']) ? true : false);
     }
 }
开发者ID:MST-SymphonyCMS,项目名称:email_newsletter_manager,代码行数:17,代码来源:class.recipientsourcestatic.php

示例5: __applyValidationRule

 private static function __applyValidationRule($data)
 {
     include TOOLKIT . '/util.validators.php';
     $rule = isset($validators['email']) ? $validators['email'] : fieldMemberEmail::$validator;
     return General::validateString($data, $rule);
 }
开发者ID:brendo,项目名称:members,代码行数:6,代码来源:field.memberemail.php

示例6: __applyValidationRules

 private function __applyValidationRules($data)
 {
     $rule = $this->get('validator');
     return $rule ? General::validateString($data, $rule) : true;
 }
开发者ID:bauhouse,项目名称:sym-calendar,代码行数:5,代码来源:field.input.php

示例7: applyValidationRules

 public function applyValidationRules($data)
 {
     $rule = $this->get('text_validator');
     return $rule ? General::validateString($data, $rule) : true;
 }
开发者ID:hotdoy,项目名称:EDclock,代码行数:5,代码来源:field.textbox.php

示例8: validate

 /**
  * Prior to saving an Author object, the validate function ensures that
  * the values in `$this->_fields` array are correct. As of Symphony 2.3
  * Authors must have unique username AND email address. This function returns
  * boolean, with an `$errors` array provided by reference to the callee
  * function.
  *
  * @param array $errors
  * @return boolean
  */
 public function validate(&$errors)
 {
     $errors = array();
     $current_author = null;
     if (is_null($this->get('first_name'))) {
         $errors['first_name'] = __('First name is required');
     }
     if (is_null($this->get('last_name'))) {
         $errors['last_name'] = __('Last name is required');
     }
     if ($this->get('id')) {
         $current_author = Symphony::Database()->fetchRow(0, sprintf("SELECT `email`, `username`\n                FROM `tbl_authors`\n                WHERE `id` = %d", $this->get('id')));
     }
     // Check that Email is provided
     if (is_null($this->get('email'))) {
         $errors['email'] = __('E-mail address is required');
         // Check Email is valid
     } elseif (!General::validateString($this->get('email'), $validators['email'])) {
         $errors['email'] = __('E-mail address entered is invalid');
         // Check that if an existing Author changes their email address that
         // it is not already used by another Author
     } elseif ($this->get('id')) {
         if ($current_author['email'] !== $this->get('email') && Symphony::Database()->fetchVar('count', 0, sprintf("SELECT COUNT(`id`) as `count`\n                    FROM `tbl_authors`\n                    WHERE `email` = '%s'", General::sanitize($this->get('email')))) != 0) {
             $errors['email'] = __('E-mail address is already taken');
         }
         // Check that Email is not in use by another Author
     } elseif (Symphony::Database()->fetchVar('id', 0, sprintf("SELECT `id`\n            FROM `tbl_authors`\n            WHERE `email` = '%s'\n            LIMIT 1", General::sanitize($this->get('email'))))) {
         $errors['email'] = __('E-mail address is already taken');
     }
     // Check the username exists
     if (is_null($this->get('username'))) {
         $errors['username'] = __('Username is required');
         // Check that if it's an existing Author that the username is not already
         // in use by another Author if they are trying to change it.
     } elseif ($this->get('id')) {
         if ($current_author['username'] !== $this->get('username') && Symphony::Database()->fetchVar('count', 0, sprintf("SELECT COUNT(`id`) as `count`\n                    FROM `tbl_authors`\n                    WHERE `username` = '%s'", General::sanitize($this->get('username')))) != 0) {
             $errors['username'] = __('Username is already taken');
         }
         // Check that the username is unique
     } elseif (Symphony::Database()->fetchVar('id', 0, sprintf("SELECT `id`\n            FROM `tbl_authors`\n            WHERE `username` = '%s'\n            LIMIT 1", General::sanitize($this->get('username'))))) {
         $errors['username'] = __('Username is already taken');
     }
     if (is_null($this->get('password'))) {
         $errors['password'] = __('Password is required');
     }
     return empty($errors) ? true : false;
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:57,代码来源:class.author.php

示例9: checkPostFieldData

 function checkPostFieldData($data, &$message, $entry_id = NULL)
 {
     /*
     UPLOAD_ERR_OK
     Value: 0; There is no error, the file uploaded with success.
     
     UPLOAD_ERR_INI_SIZE
     Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
     
     UPLOAD_ERR_FORM_SIZE
     Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
     
     UPLOAD_ERR_PARTIAL
     Value: 3; The uploaded file was only partially uploaded.
     
     UPLOAD_ERR_NO_FILE
     Value: 4; No file was uploaded.
     
     UPLOAD_ERR_NO_TMP_DIR
     Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
     
     UPLOAD_ERR_CANT_WRITE
     Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.
     
     UPLOAD_ERR_EXTENSION
     Value: 8; File upload stopped by extension. Introduced in PHP 5.2.0.
     */
     //	Array
     //	(
     //	    [name] => filename.pdf
     //	    [type] => application/pdf
     //	    [tmp_name] => /tmp/php/phpYtdlCl
     //	    [error] => 0
     //	    [size] => 16214
     //	)
     $message = NULL;
     try {
         $this->S3->getBucket($this->get('bucket'));
     } catch (Exception $e) {
         $message = __('The bucket %s doesn\'t exist! Please update this section.', array($this->get('bucket')));
         return self::__INVALID_FIELDS__;
     }
     if (empty($data) || isset($data['error']) && $data['error'] == UPLOAD_ERR_NO_FILE) {
         if ($this->get('required') == 'yes') {
             $message = __("'%s' is a required field.", array($this->get('label')));
             return self::__MISSING_FIELDS__;
         }
         return self::__OK__;
     }
     ## Its not an array, so just retain the current data and return
     if (!is_array($data)) {
         return self::__OK__;
     }
     if ($data['error'] != UPLOAD_ERR_NO_FILE && $data['error'] != UPLOAD_ERR_OK) {
         switch ($data['error']) {
             case UPLOAD_ERR_INI_SIZE:
                 $message = __('File chosen in "%1$s" exceeds the maximum allowed upload size of %2$s specified by your host.', array($this->get('label'), is_numeric(ini_get('upload_max_filesize')) ? General::formatFilesize(ini_get('upload_max_filesize')) : ini_get('upload_max_filesize')));
                 break;
             case UPLOAD_ERR_FORM_SIZE:
                 $message = __('File chosen in "%1$s" exceeds the maximum allowed upload size of %2$s, specified by Symphony.', array($this->get('label'), General::formatFilesize(Symphony::Configuration()->get('max_upload_size', 'admin'))));
                 break;
             case UPLOAD_ERR_PARTIAL:
                 $message = __("File chosen in '%s' was only partially uploaded due to an error.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_NO_TMP_DIR:
                 $message = __("File chosen in '%s' was only partially uploaded due to an error.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_CANT_WRITE:
                 $message = __("Uploading '%s' failed. Could not write temporary file to disk.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_EXTENSION:
                 $message = __("Uploading '%s' failed. File upload stopped by extension.", array($this->get('label')));
                 break;
         }
         return self::__ERROR_CUSTOM__;
     }
     ## Sanitize the filename
     $data['name'] = Lang::createFilename($data['name']);
     ## uniq the filename
     if ($this->get('unique_filename') == true && isset($data['name'])) {
         $this->getUniqueFilename($data['name']);
     }
     if ($this->get('validator') != NULL) {
         $rule = $this->get('validator');
         if (!General::validateString($data['name'], $rule)) {
             $message = __("File chosen in '%s' does not match allowable file types for that field.", array($this->get('label')));
             return self::__INVALID_FIELDS__;
         }
     }
     ## check if the file exists since we can't check directly through the s3 library, the file field is unique
     $row = Symphony::Database()->fetchRow(0, "SELECT * FROM `tbl_entries_data_" . $this->get('id') . "` WHERE `file`='" . $data['name'] . "'");
     if (isset($row['file'])) {
         $message = __('A file with the name %1$s already exists at that bucket. Please rename the file first, or choose another.', array($data['name']));
         return self::__INVALID_FIELDS__;
     }
     return self::__OK__;
 }
开发者ID:jdsimcoe,项目名称:s3upload_field,代码行数:97,代码来源:field.s3upload.php

示例10: checkPostFieldData

 public function checkPostFieldData($data, &$message, $entry_id = null)
 {
     /**
      * For information about PHPs upload error constants see:
      * @link http://php.net/manual/en/features.file-upload.errors.php
      */
     $message = null;
     if (empty($data) || is_array($data) && isset($data['error']) && $data['error'] == UPLOAD_ERR_NO_FILE) {
         if ($this->get('required') == 'yes') {
             $message = __('‘%s’ is a required field.', array($this->get('label')));
             return self::__MISSING_FIELDS__;
         }
         return self::__OK__;
     }
     // Its not an array, so just retain the current data and return
     if (is_array($data) === false) {
         $file = $this->getFilePath(basename($data));
         if (file_exists($file) === false || !is_readable($file)) {
             $message = __('The file uploaded is no longer available. Please check that it exists, and is readable.');
             return self::__INVALID_FIELDS__;
         }
         // Ensure that the file still matches the validator and hasn't
         // changed since it was uploaded.
         if ($this->get('validator') != null) {
             $rule = $this->get('validator');
             if (General::validateString($file, $rule) === false) {
                 $message = __('File chosen in ‘%s’ does not match allowable file types for that field.', array($this->get('label')));
                 return self::__INVALID_FIELDS__;
             }
         }
         return self::__OK__;
     }
     if (is_dir(DOCROOT . $this->get('destination') . '/') === false) {
         $message = __('The destination directory, %s, does not exist.', array('<code>' . $this->get('destination') . '</code>'));
         return self::__ERROR__;
     } elseif (is_writable(DOCROOT . $this->get('destination') . '/') === false) {
         $message = __('Destination folder is not writable.') . ' ' . __('Please check permissions on %s.', array('<code>' . $this->get('destination') . '</code>'));
         return self::__ERROR__;
     }
     if ($data['error'] != UPLOAD_ERR_NO_FILE && $data['error'] != UPLOAD_ERR_OK) {
         switch ($data['error']) {
             case UPLOAD_ERR_INI_SIZE:
                 $message = __('File chosen in ‘%1$s’ exceeds the maximum allowed upload size of %2$s specified by your host.', array($this->get('label'), is_numeric(ini_get('upload_max_filesize')) ? General::formatFilesize(ini_get('upload_max_filesize')) : ini_get('upload_max_filesize')));
                 break;
             case UPLOAD_ERR_FORM_SIZE:
                 $message = __('File chosen in ‘%1$s’ exceeds the maximum allowed upload size of %2$s, specified by Symphony.', array($this->get('label'), General::formatFilesize($_POST['MAX_FILE_SIZE'])));
                 break;
             case UPLOAD_ERR_PARTIAL:
             case UPLOAD_ERR_NO_TMP_DIR:
                 $message = __('File chosen in ‘%s’ was only partially uploaded due to an error.', array($this->get('label')));
                 break;
             case UPLOAD_ERR_CANT_WRITE:
                 $message = __('Uploading ‘%s’ failed. Could not write temporary file to disk.', array($this->get('label')));
                 break;
             case UPLOAD_ERR_EXTENSION:
                 $message = __('Uploading ‘%s’ failed. File upload stopped by extension.', array($this->get('label')));
                 break;
         }
         return self::__ERROR_CUSTOM__;
     }
     // Sanitize the filename
     $data['name'] = Lang::createFilename($data['name']);
     if ($this->get('validator') != null) {
         $rule = $this->get('validator');
         if (!General::validateString($data['name'], $rule)) {
             $message = __('File chosen in ‘%s’ does not match allowable file types for that field.', array($this->get('label')));
             return self::__INVALID_FIELDS__;
         }
     }
     return self::__OK__;
 }
开发者ID:valery,项目名称:symphony-2,代码行数:71,代码来源:field.upload.php

示例11: checkPostFieldData

 function checkPostFieldData($data, &$message, $entry_id = NULL)
 {
     /*
     	UPLOAD_ERR_OK
     	Value: 0; There is no error, the file uploaded with success.
     
     	UPLOAD_ERR_INI_SIZE
     	Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
     
     	UPLOAD_ERR_FORM_SIZE
     	Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
     
     	UPLOAD_ERR_PARTIAL
     	Value: 3; The uploaded file was only partially uploaded.
     
     	UPLOAD_ERR_NO_FILE
     	Value: 4; No file was uploaded.
     
     	UPLOAD_ERR_NO_TMP_DIR
     	Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
     
     	UPLOAD_ERR_CANT_WRITE
     	Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.
     
     	UPLOAD_ERR_EXTENSION
     	Value: 8; File upload stopped by extension. Introduced in PHP 5.2.0.
     */
     //	Array
     //	(
     //	    [name] => filename.pdf
     //	    [type] => application/pdf
     //	    [tmp_name] => /tmp/php/phpYtdlCl
     //	    [error] => 0
     //	    [size] => 16214
     //	)
     $message = NULL;
     if (empty($data) || $data['error'] == UPLOAD_ERR_NO_FILE) {
         if ($this->get('required') == 'yes') {
             $message = __("'%s' is a required field.", $this->get('label'));
             return self::__MISSING_FIELDS__;
         }
         return self::__OK__;
     }
     ## Its not an array, so just retain the current data and return
     if (!is_array($data)) {
         return self::__OK__;
     }
     if (!is_writable(DOCROOT . $this->get('destination') . '/')) {
         $message = __('Destination folder, <code>%s</code>, is not writable. Please check permissions.', array($this->get('destination')));
         return self::__ERROR__;
     }
     if ($data['error'] != UPLOAD_ERR_NO_FILE && $data['error'] != UPLOAD_ERR_OK) {
         switch ($data['error']) {
             case UPLOAD_ERR_INI_SIZE:
                 $message = __('File chosen in "%1$s" exceeds the maximum allowed upload size of %2$s specified by your host.', array($this->get('label'), is_numeric(ini_get('upload_max_filesize')) ? General::formatFilesize(ini_get('upload_max_filesize')) : ini_get('upload_max_filesize')));
                 break;
             case UPLOAD_ERR_FORM_SIZE:
                 $message = __('File chosen in "%1$s" exceeds the maximum allowed upload size of %2$s, specified by Symphony.', array($this->get('label'), General::formatFilesize($this->_engine->Configuration->get('max_upload_size', 'admin'))));
                 break;
             case UPLOAD_ERR_PARTIAL:
                 $message = __("File chosen in '%s' was only partially uploaded due to an error.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_NO_TMP_DIR:
                 $message = __("File chosen in '%s' was only partially uploaded due to an error.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_CANT_WRITE:
                 $message = __("Uploading '%s' failed. Could not write temporary file to disk.", array($this->get('label')));
                 break;
             case UPLOAD_ERR_EXTENSION:
                 $message = __("Uploading '%s' failed. File upload stopped by extension.", array($this->get('label')));
                 break;
         }
         return self::__ERROR_CUSTOM__;
     }
     ## Sanitize the filename
     $data['name'] = Lang::createFilename($data['name']);
     if ($this->get('validator') != NULL) {
         $rule = $this->get('validator');
         if (!General::validateString($data['name'], $rule)) {
             $message = __("File chosen in '%s' does not match allowable file types for that field.", array($this->get('label')));
             return self::__INVALID_FIELDS__;
         }
     }
     $abs_path = DOCROOT . '/' . trim($this->get('destination'), '/');
     $new_file = $abs_path . '/' . $data['name'];
     $existing_file = NULL;
     if ($entry_id) {
         $row = $this->Database->fetchRow(0, "SELECT * FROM `tbl_entries_data_" . $this->get('id') . "` WHERE `entry_id` = '{$entry_id}' LIMIT 1");
         $existing_file = $abs_path . '/' . trim($row['file'], '/');
     }
     if ($existing_file != $new_file && file_exists($new_file)) {
         $message = __('A file with the name %1$s already exists in %2$s. Please rename the file first, or choose another.', array($data['name'], $this->get('destination')));
         return self::__INVALID_FIELDS__;
     }
     return self::__OK__;
 }
开发者ID:bauhouse,项目名称:sym-fluid960gs,代码行数:96,代码来源:field.upload.php

示例12: __applyValidationRule

 private function __applyValidationRule($data)
 {
     return General::validateString($data, '/^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}$/');
 }
开发者ID:andrrr,项目名称:field_ip,代码行数:4,代码来源:field.ip.php

示例13: validate

 public function validate(MessageStack $errors)
 {
     if (is_null($this->first_name)) {
         $errors->append('first_name', __('First name is required'));
     }
     if (is_null($this->last_name)) {
         $errors->append('last_name', __('Last name is required'));
     }
     if (is_null($this->email)) {
         $errors->append('email', __('E-mail address is required'));
     } elseif (!General::validateString($this->email, '/^[^@]+@[^\\.@]+\\.[^@]+$/i')) {
         $errors->append('email', __('E-mail address entered is invalid'));
     }
     if (is_null($this->username)) {
         $errors->append('username', __('Username is required'));
     } elseif ($this->id) {
         $result = Symphony::Database()->query("SELECT `username` FROM `tbl_users` WHERE `id` = %d", array($this->id));
         $current_username = $result->current()->username;
         if ($current_username != $this->username && Symphony::Database()->query("SELECT `id` FROM `tbl_users` WHERE `username` = '%s'", array($this->username))->valid()) {
             $errors->append('username', __('Username is already taken'));
         }
     } elseif (Symphony::Database()->query("SELECT `id` FROM `tbl_users` WHERE `username` = '%s'", array($this->username))->valid()) {
         $errors->append('username', __('Username is already taken'));
     }
     if (is_null($this->password)) {
         $errors->append('password', __('Password is required'));
     }
     return $errors->length() == 0;
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:29,代码来源:class.user.php

示例14: _parseNameAndEmail

 protected function _parseNameAndEmail(&$string)
 {
     $string = trim($string);
     if (strstr($string, '<')) {
         $name = trim(strstr($string, '<', true), "\" \t\n\r\v");
         $email = trim(strstr($string, '<'), "<> \t\n\r\v");
     } else {
         $email = trim($string, " \t\n\r\v");
         $name = NULL;
     }
     if (strlen($email) == 0) {
         unset($string);
     } else {
         return array('name' => $name, 'email' => $email, 'valid' => General::validateString($this->_emailValidator, $recipient['email']) ? true : false);
     }
 }
开发者ID:jonmifsud,项目名称:email_newsletter_manager,代码行数:16,代码来源:class.recipientsourcestatic.php

示例15: validateRule

 public function validateRule($data)
 {
     $rule = $this->get('validator');
     return $rule ? General::validateString($data, $rule) : true;
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:5,代码来源:field.membername.php


注:本文中的General::validateString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。