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


PHP fORM::getColumnName方法代码示例

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


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

示例1: validateMoneyColumns

 /**
  * Validates all money columns
  * 
  * @internal
  * 
  * @param  fActiveRecord $object                The fActiveRecord instance
  * @param  array         &$values               The current values
  * @param  array         &$old_values           The old values
  * @param  array         &$related_records      Any records related to this record
  * @param  array         &$cache                The cache array for the record
  * @param  array         &$validation_messages  An array of ordered validation messages
  * @return void
  */
 public static function validateMoneyColumns($object, &$values, &$old_values, &$related_records, &$cache, &$validation_messages)
 {
     $class = get_class($object);
     if (empty(self::$money_columns[$class])) {
         return;
     }
     foreach (self::$money_columns[$class] as $column => $currency_column) {
         if ($values[$column] instanceof fMoney || $values[$column] === NULL) {
             continue;
         }
         // Remove any previous validation warnings
         unset($validation_messages[$column]);
         $column_name = fValidationException::formatField(fORM::getColumnName($class, $currency_column));
         if ($currency_column && !in_array($values[$currency_column], fMoney::getCurrencies())) {
             $validation_messages[$column] = self::compose('%sThe currency specified is invalid', $column_name);
         } else {
             $validation_messages[$column] = self::compose('%sPlease enter a monetary value', $column_name);
         }
     }
 }
开发者ID:hibble,项目名称:printmaster,代码行数:33,代码来源:fORMMoney.php

示例2: validate

 /**
  * Validates uploaded files to ensure they match all of the criteria defined
  * 
  * @internal
  * 
  * @param  fActiveRecord $object                The fActiveRecord instance
  * @param  array         &$values               The current values
  * @param  array         &$old_values           The old values
  * @param  array         &$related_records      Any records related to this record
  * @param  array         &$cache                The cache array for the record
  * @param  array         &$validation_messages  The existing validation messages
  * @return void
  */
 public static function validate($object, &$values, &$old_values, &$related_records, &$cache, &$validation_messages)
 {
     $class = get_class($object);
     foreach (self::$file_upload_columns[$class] as $column => $directory) {
         $column_name = fORM::getColumnName($class, $column);
         if (isset($validation_messages[$column])) {
             $search_message = self::compose('%sPlease enter a value', fValidationException::formatField($column_name));
             $replace_message = self::compose('%sPlease upload a file', fValidationException::formatField($column_name));
             $validation_messages[$column] = str_replace($search_message, $replace_message, $validation_messages[$column]);
         }
         // Grab the error that occured
         try {
             if (fUpload::check($column)) {
                 $uploader = self::setUpFUpload($class, $column);
                 $uploader->validate($column);
             }
         } catch (fValidationException $e) {
             if ($e->getMessage() != self::compose('Please upload a file')) {
                 $validation_messages[$column] = fValidationException::formatField($column_name) . $e->getMessage();
             }
         }
     }
 }
开发者ID:hibble,项目名称:printmaster,代码行数:36,代码来源:fORMFile.php

示例3: checkValidValuesRule

 /**
  * Validates against a valid values rule
  *
  * @param  string $class         The class this rule applies to
  * @param  array  &$values       An associative array of all values for the record
  * @param  string $column        The column the rule applies to
  * @param  array  $valid_values  An array of valid values to check the column against
  * @return string  The error message for the rule specified
  */
 private static function checkValidValuesRule($class, &$values, $column, $valid_values)
 {
     if ($values[$column] === NULL) {
         return;
     }
     if (!in_array($values[$column], $valid_values)) {
         return self::compose('%1$sPlease choose from one of the following: %2$s', fValidationException::formatField(fORM::getColumnName($class, $column)), join(', ', $valid_values));
     }
 }
开发者ID:alandsidel,项目名称:flourish-classes,代码行数:18,代码来源:fORMValidation.php

示例4: validateTimezoneColumns

 /**
  * Validates all timestamp/timezone columns
  *
  * @internal
  *
  * @param  fActiveRecord $object                The fActiveRecord instance
  * @param  array         &$values               The current values
  * @param  array         &$old_values           The old values
  * @param  array         &$related_records      Any records related to this record
  * @param  array         &$cache                The cache array for the record
  * @param  array         &$validation_messages  An array of ordered validation messages
  * @return void
  */
 public static function validateTimezoneColumns($object, &$values, &$old_values, &$related_records, &$cache, &$validation_messages)
 {
     $class = get_class($object);
     if (empty(self::$timezone_columns[$class])) {
         return;
     }
     foreach (self::$timezone_columns[$class] as $timezone_column => $timestamp_column) {
         if ($values[$timestamp_column] instanceof fTimestamp || $values[$timestamp_column] === NULL) {
             continue;
         }
         if (!fTimestamp::isValidTimezone($values[$timezone_column])) {
             $validation_messages[$timezone_column] = self::compose('%sThe timezone specified is invalid', fValidationException::formatField(fORM::getColumnName($class, $timezone_column)));
         } else {
             $validation_messages[$timestamp_column] = self::compose('%sPlease enter a date/time', fValidationException::formatField(fORM::getColumnName($class, $timestamp_column)));
         }
     }
 }
开发者ID:alandsidel,项目名称:flourish-classes,代码行数:30,代码来源:fORMDate.php

示例5: validate

 /**
  * Makes sure the ordering value is sane, removes error messages about missing values
  *
  * @internal
  *
  * @param  fActiveRecord $object                The fActiveRecord instance
  * @param  array         &$values               The current values
  * @param  array         &$old_values           The old values
  * @param  array         &$related_records      Any records related to this record
  * @param  array         &$cache                The cache array for the record
  * @param  array         &$validation_messages  An array of ordered validation messages
  * @return void
  */
 public static function validate($object, &$values, &$old_values, &$related_records, &$cache, &$validation_messages)
 {
     $class = get_class($object);
     $table = fORM::tablize($class);
     $db = fORMDatabase::retrieve($class, 'read');
     $schema = fORMSchema::retrieve($class);
     foreach (self::$ordering_columns[$class] as $column => $other_columns) {
         $current_value = $values[$column];
         $old_value = fActiveRecord::retrieveOld($old_values, $column);
         $params = array("SELECT MAX(%r) FROM %r", $column, $table);
         if ($other_columns) {
             $params[0] .= " WHERE ";
             $params = self::addOtherFieldsWhereParams($schema, $params, $table, $other_columns, $values);
         }
         $current_max_value = (int) call_user_func_array($db->translatedQuery, $params)->fetchScalar();
         $new_max_value = $current_max_value;
         if ($new_set = self::isInNewSet($column, $other_columns, $values, $old_values)) {
             $new_max_value = $current_max_value + 1;
             $new_set_new_value = fActiveRecord::changed($values, $old_values, $column);
         }
         $column_name = fORM::getColumnName($class, $column);
         // Remove any previous validation warnings
         $filtered_messages = array();
         foreach ($validation_messages as $validation_column => $validation_message) {
             if (!preg_match('#(^|,)' . preg_quote($column, '#') . '(,|$)#D', $validation_column)) {
                 $filtered_messages[$validation_column] = $validation_message;
             }
         }
         $validation_messages = $filtered_messages;
         // If we have a completely empty value, we don't need to validate since a valid value will be generated
         if ($current_value === '' || $current_value === NULL) {
             continue;
         }
         if (!is_numeric($current_value) || strlen((int) $current_value) != strlen($current_value)) {
             $validation_messages[$column] = self::compose('%sPlease enter an integer', fValidationException::formatField($column_name));
         } elseif ($current_value < 1) {
             $validation_messages[$column] = self::compose('%sThe value can not be less than 1', fValidationException::formatField($column_name));
         }
     }
 }
开发者ID:gopalgrover23,项目名称:flourish-classes,代码行数:53,代码来源:fORMOrdering.php

示例6: validate

 /**
  * Makes sure the ordering value is sane, removes error messages about missing values
  * 
  * @internal
  * 
  * @param  fActiveRecord $object                The fActiveRecord instance
  * @param  array         &$values               The current values
  * @param  array         &$old_values           The old values
  * @param  array         &$related_records      Any records related to this record
  * @param  array         &$cache                The cache array for the record
  * @param  array         &$validation_messages  An array of ordered validation messages
  * @return void
  */
 public static function validate($object, &$values, &$old_values, &$related_records, &$cache, &$validation_messages)
 {
     $class = get_class($object);
     $table = fORM::tablize($class);
     $column = self::$ordering_columns[$class]['column'];
     $other_columns = self::$ordering_columns[$class]['other_columns'];
     $current_value = $values[$column];
     $old_value = fActiveRecord::retrieveOld($old_values, $column);
     $sql = "SELECT max(" . $column . ") FROM " . $table;
     if ($other_columns) {
         $sql .= " WHERE " . self::createOtherFieldsWhereClause($table, $other_columns, $values);
     }
     $current_max_value = (int) fORMDatabase::retrieve()->translatedQuery($sql)->fetchScalar();
     $new_max_value = $current_max_value;
     if ($new_set = self::isInNewSet($column, $other_columns, $values, $old_values)) {
         $new_max_value = $current_max_value + 1;
         $new_set_new_value = fActiveRecord::changed($values, $old_values, $column);
     }
     $column_name = fORM::getColumnName($class, $column);
     // Remove any previous validation warnings
     $filtered_messages = array();
     foreach ($validation_messages as $validation_message) {
         if (!preg_match('#^' . str_replace('___', '(.*?)', preg_quote(fValidationException::formatField('___' . $column_name . '___'), '#')) . '#', $validation_message)) {
             $filtered_messages[] = $validation_message;
         }
     }
     $validation_messages = $filtered_messages;
     // If we have a completely empty value, we don't need to validate since a valid value will be generated
     if ($current_value === '' || $current_value === NULL) {
         return;
     }
     if (!is_numeric($current_value) || strlen((int) $current_value) != strlen($current_value)) {
         $validation_messages[] = self::compose('%sPlease enter an integer', fValidationException::formatField($column_name));
     } elseif ($current_value < 1) {
         $validation_messages[] = self::compose('%sThe value can not be less than 1', fValidationException::formatField($column_name));
     }
 }
开发者ID:jsuarez,项目名称:MyDesign,代码行数:50,代码来源:fORMOrdering.php

示例7: validateLinkColumns

 /**
  * Validates all link columns
  *
  * @internal
  *
  * @param  fActiveRecord $object                The fActiveRecord instance
  * @param  array         &$values               The current values
  * @param  array         &$old_values           The old values
  * @param  array         &$related_records      Any records related to this record
  * @param  array         &$cache                The cache array for the record
  * @param  array         &$validation_messages  An array of ordered validation messages
  * @return void
  */
 public static function validateLinkColumns($object, &$values, &$old_values, &$related_records, &$cache, &$validation_messages)
 {
     $class = get_class($object);
     if (empty(self::$link_columns[$class])) {
         return;
     }
     foreach (self::$link_columns[$class] as $column => $enabled) {
         if (!is_string($values[$column])) {
             continue;
         }
         $ip_regex = '(?:(?:[01]?\\d?\\d|2[0-4]\\d|25[0-5])\\.){3}(?:[01]?\\d?\\d|2[0-4]\\d|25[0-5])';
         $hostname_regex = '[a-z]+(?:[a-z0-9\\-]*[a-z0-9]\\.?|\\.)*';
         $domain_regex = '([a-z]+([a-z0-9\\-]*[a-z0-9])?\\.)+[a-z]{2,}';
         if (!preg_match('#^(https?://(' . $ip_regex . '|' . $hostname_regex . ')(?=/|$)|' . $domain_regex . '(?=/|$)|/)#i', $values[$column])) {
             $validation_messages[$column] = self::compose('%sPlease enter a link in the form http://www.example.com', fValidationException::formatField(fORM::getColumnName($class, $column)));
         }
     }
 }
开发者ID:gopalgrover23,项目名称:flourish-classes,代码行数:31,代码来源:fORMColumn.php

示例8: validateOneToStar

 /**
  * Validates one-to-* related records
  *
  * @param  string $class             The class to validate the related records for
  * @param  array  &$values           The values for the object
  * @param  array  &$related_records  The related records for the object
  * @param  string $related_class     The name of the class for this record set
  * @param  string $route             The route between the table and related table
  * @return array  An array of validation messages
  */
 private static function validateOneToStar($class, &$values, &$related_records, $related_class, $route)
 {
     $table = fORM::tablize($class);
     $related_table = fORM::tablize($related_class);
     $first_pk_column = self::determineFirstPKColumn($class, $related_class, $route);
     $filter = self::determineRequestFilter($class, $related_class, $route);
     $pk_field = $filter . $first_pk_column;
     $input_keys = array_keys(fRequest::get($pk_field, 'array', array()));
     $related_record_name = self::getRelatedRecordName($class, $related_class, $route);
     $messages = array();
     $one_to_one = fORMSchema::isOneToOne($table, $related_table, $route);
     if ($one_to_one) {
         $records = array(self::createRecord($class, $values, $related_records, $related_class, $route));
     } else {
         $records = self::buildRecords($class, $values, $related_records, $related_class, $route);
     }
     // Ignore validation messages about the primary key since it will be added
     $primary_key_name = fValidationException::formatField(fORM::getColumnName($related_class, $route));
     $primary_key_regex = '#^' . preg_quote($primary_key_name, '#') . '.*$#D';
     fORMValidation::addRegexReplacement($related_class, $primary_key_regex, '');
     foreach ($records as $i => $record) {
         fRequest::filter($filter, isset($input_keys[$i]) ? $input_keys[$i] : $i);
         $record_messages = $record->validate(TRUE);
         foreach ($record_messages as $record_message) {
             $token_field = fValidationException::formatField('__TOKEN__');
             $extract_message_regex = '#' . str_replace('__TOKEN__', '(.*?)', preg_quote($token_field, '#')) . '(.*)$#D';
             preg_match($extract_message_regex, $record_message, $matches);
             if ($one_to_one) {
                 $column_name = self::compose('%1$s %2$s', $related_record_name, $matches[1]);
             } else {
                 $column_name = self::compose('%1$s #%2$s %3$s', $related_record_name, $i + 1, $matches[1]);
             }
             $messages[] = self::compose('%1$s%2$s', fValidationException::formatField($column_name), $matches[2]);
         }
         fRequest::unfilter();
     }
     fORMValidation::removeRegexReplacement($related_class, $primary_key_regex, '');
     return $messages;
 }
开发者ID:jsuarez,项目名称:MyDesign,代码行数:49,代码来源:fORMRelated.php

示例9: validateLinkColumns

 /**
  * Validates all link columns
  * 
  * @internal
  * 
  * @param  fActiveRecord $object                The fActiveRecord instance
  * @param  array         &$values               The current values
  * @param  array         &$old_values           The old values
  * @param  array         &$related_records      Any records related to this record
  * @param  array         &$cache                The cache array for the record
  * @param  array         &$validation_messages  An array of ordered validation messages
  * @return void
  */
 public static function validateLinkColumns($object, &$values, &$old_values, &$related_records, &$cache, &$validation_messages)
 {
     $class = get_class($object);
     if (empty(self::$link_columns[$class])) {
         return;
     }
     foreach (self::$link_columns[$class] as $column => $enabled) {
         if (!strlen($values[$column])) {
             continue;
         }
         if (!preg_match('#^(http(s)?://|/|([a-z0-9\\-]+\\.)+[a-z]{2,})#i', $values[$column])) {
             $validation_messages[] = self::compose('%sPlease enter a link in the form http://www.example.com', fValidationException::formatField(fORM::getColumnName($class, $column)));
         }
     }
 }
开发者ID:jsuarez,项目名称:MyDesign,代码行数:28,代码来源:fORMColumn.php


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