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


PHP Field::checkPostFieldData方法代码示例

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


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

示例1: checkPostFieldData

 public function checkPostFieldData($data, &$error = null, $entry_id = null)
 {
     if (isset($data['entry']) and is_array($data['entry'])) {
         $entryManager = new EntryManager(Symphony::Engine());
         $fieldManager = new FieldManager(Symphony::Engine());
         $field = $fieldManager->fetch($this->get('linked_field_id'));
         $field_id = $this->get('id');
         $status = self::__OK__;
         $handled_entries = array();
         self::$errors[$field_id] = array();
         self::$entries[$field_id] = array();
         // Create:
         foreach ($data['entry'] as $index => $entry_data) {
             $existing_id = null;
             // Find existing entry:
             if ((int) $data['entry_id'][$index] > 0) {
                 $entries = $entryManager->fetch((int) $data['entry_id'][$index], $this->get('linked_section_id'));
                 if (isset($entries[0])) {
                     $entry = $entries[0];
                     $existing_id = $entry->get('id');
                 }
             }
             // Skip duplicate entries:
             if ($existing_id != null && in_array($existing_id, $handled_entries)) {
                 continue;
             }
             // Create a new entry:
             if ($existing_id == null) {
                 $entry = $entryManager->create();
                 $entry->set('section_id', $this->get('linked_section_id'));
                 $entry->set('author_id', isset(Symphony::Engine()->Author) ? Symphony::Engine()->Author->get('id') : 1);
                 $entry->set('creation_date', DateTimeObj::get('Y-m-d H:i:s'));
                 $entry->set('creation_date_gmt', DateTimeObj::getGMT('Y-m-d H:i:s'));
                 $entry->assignEntryId();
             }
             // Append correct linked data:
             $existing_data = $entry->getData($this->get('linked_field_id'));
             $existing_entries = array();
             if (isset($existing_data['linked_entry_id'])) {
                 if (!is_array($existing_data['linked_entry_id'])) {
                     $existing_entries[] = $existing_data['linked_entry_id'];
                 } else {
                     foreach ($existing_data['linked_entry_id'] as $linked_entry_id) {
                         $existing_entries[] = $linked_entry_id;
                     }
                 }
             }
             if (!in_array($entry_id, $existing_entries)) {
                 $existing_entries[] = $entry_id;
             }
             $entry_data[$field->get('element_name')] = $existing_entries;
             // Validate:
             if (__ENTRY_FIELD_ERROR__ == $entry->checkPostData($entry_data, $errors)) {
                 self::$errors[$field_id][$index] = $errors;
                 $status = self::__INVALID_FIELDS__;
             }
             if (__ENTRY_OK__ != $entry->setDataFromPost($entry_data, $error)) {
                 $status = self::__INVALID_FIELDS__;
             }
             // Cleanup dud entry:
             if ($existing_id == null and $status != self::__OK__) {
                 $existing_id = $entry->get('id');
                 $entry->set('id', 0);
                 Symphony::Database()->delete('tbl_entries', " `id` = '{$existing_id}' ");
             }
             self::$entries[$field_id][$index] = $entry;
             $handled_entries[] = $entry->get('id');
         }
         return $status;
     }
     return parent::checkPostFieldData($data, $error, $entry_id);
 }
开发者ID:symphonists,项目名称:bilinkfield,代码行数:72,代码来源:field.bilink.php

示例2: checkPostFieldData

 public function checkPostFieldData($data, &$message, $entry_id = null)
 {
     $message = null;
     if (!is_array($data)) {
         $data = array($data);
     }
     $available_codes = $this->get('available_codes');
     $not_allowed = array();
     foreach ($data as $code) {
         if (!in_array($code, $available_codes)) {
             $not_allowed[] = $code;
         }
     }
     if (!empty($not_allowed)) {
         $msg = array();
         $options = Extension_Languages::findOptions();
         foreach ($not_allowed as $code) {
             foreach ($options as $details) {
                 if ($details[0] == $code) {
                     $msg[] = $details[2];
                     break;
                 }
             }
         }
         $message = __('Languages `%s` are not allowed.', array(implode(', ', $msg)));
         return self::__INVALID_FIELDS__;
     }
     return parent::checkPostFieldData($data, $message, $entry_id);
 }
开发者ID:siimsoni,项目名称:languages,代码行数:29,代码来源:field.languages.php

示例3: checkPostFieldData

 /**
  * @see http://symphony-cms.com/learn/api/2.3/toolkit/field/#checkPostFieldData
  */
 public function checkPostFieldData($data, &$message, $entry_id = null)
 {
     if (!is_array($data)) {
         $data = array($data);
     }
     $data = array_filter($data);
     $status = parent::checkPostFieldData($data, $message, $entry_id);
     if ($status != self::__OK__) {
         return $status;
     }
     if (empty($data) || !is_array($data)) {
         return self::__OK__;
     }
     if ($this->get('allow_multiple') == 0 && count($data) > 1) {
         $message = __("'%s' allows single item only.", array($this->get('label')));
         return self::__INVALID_FIELDS__;
     }
     return self::__OK__;
 }
开发者ID:symphonists,项目名称:subsectionmanager,代码行数:22,代码来源:field.subsectionmanager.php

示例4: checkPostFieldData

 public function checkPostFieldData($data, &$message, $entry_id = null)
 {
     $field_id = $this->get('id');
     $entry_id = (int) $entry_id;
     if (!in_array($data, array_keys($this->_states)) and !empty($data)) {
         $message = "Invalid status given.";
         return self::__INVALID_FIELDS__;
     }
     return parent::checkPostFieldData($data, $message, $entry_id);
 }
开发者ID:bauhouse,项目名称:sym-extensions,代码行数:10,代码来源:field.memberstatus.php

示例5: checkPostFieldData

 public function checkPostFieldData($data, &$message, $entry_id = null)
 {
     return Field::checkPostFieldData($data, $message, $entry_id);
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:4,代码来源:field.select.php


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