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


PHP PodsForm::tableless_field_types方法代码示例

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


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

示例1: array

    }
    if (!empty(PodsForm::$field_group)) {
        if (!isset($field_types_select[PodsForm::$field_group])) {
            $field_types_select[PodsForm::$field_group] = array();
        }
        $field_types_select[PodsForm::$field_group][$type] = $field_type_data['label'];
    } else {
        if (!isset($field_types_select[__('Other', 'pods')])) {
            $field_types_select[__('Other', 'pods')] = array();
        }
        $field_types_select[__('Other', 'pods')][$type] = $field_type_data['label'];
    }
}
$field_defaults = array('name' => 'new_field', 'label' => 'New Field', 'description' => '', 'type' => 'text', 'pick_object' => '', 'sister_id' => '', 'required' => 0, 'unique' => 0);
$pick_object = PodsForm::field_method('pick', 'related_objects', true);
$tableless_field_types = PodsForm::tableless_field_types();
$simple_tableless_objects = PodsForm::field_method('pick', 'simple_objects');
$bidirectional_objects = PodsForm::field_method('pick', 'bidirectional_objects');
foreach ($pod['options'] as $_option => $_value) {
    $pod[$_option] = $_value;
}
foreach ($pod['fields'] as $_field => $_data) {
    $_data['options'] = (array) $_data['options'];
    foreach ($_data['options'] as $_option => $_value) {
        $pod['fields'][$_field][$_option] = $_value;
    }
}
$field_defaults = apply_filters('pods_field_defaults', apply_filters('pods_field_defaults_' . $pod['name'], $field_defaults, $pod));
$pick_table = pods_transient_get('pods_tables');
if (empty($pick_table)) {
    $pick_table = array('' => __('-- Select Table --', 'pods'));
开发者ID:jeremybradbury,项目名称:wp-ninja-kit,代码行数:31,代码来源:setup-edit.php

示例2: delete_meta

 /**
  * @param $object_type
  * @param null $_null
  * @param int $object_id
  * @param string $meta_key
  * @param string $meta_value
  * @param bool $delete_all
  *
  * @return null
  */
 public function delete_meta($object_type, $_null = null, $object_id = 0, $meta_key = '', $meta_value = '', $delete_all = false)
 {
     if (pods_tableless()) {
         return $_null;
     }
     $object = $this->get_object($object_type, $object_id);
     if (empty($object_id) || empty($object) || !isset($object['fields'][$meta_key])) {
         return $_null;
     }
     $pod = pods($object['name']);
     // @todo handle $delete_all (delete the field values from all pod items)
     if (!empty($meta_value) && in_array($object['fields'][$meta_key]['type'], PodsForm::tableless_field_types())) {
         $pod->fetch($object_id);
         $pod->remove_from($meta_key, $meta_value);
     } else {
         $pod->save(array($meta_key => null), null, $object_id);
     }
     return $_null;
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:29,代码来源:PodsMeta.php

示例3: lookup_related_items_from

 /**
  * Find related items related to an item
  *
  * @param int $field_id The Field ID
  * @param int $pod_id The Pod ID
  * @param int $id Item ID to get related IDs from
  * @param array $field Field data array
  * @param array $pod Pod data array
  *
  * @return array|bool
  *
  * @since 2.3
  *
  * @uses pods_query()
  */
 public function lookup_related_items_from($field_id, $pod_id, $id, $field = null, $pod = null)
 {
     $related_ids = false;
     $id = (int) $id;
     $tableless_field_types = PodsForm::tableless_field_types();
     if (empty($id) || !in_array(pods_v('type', $field), $tableless_field_types)) {
         return false;
     }
     $related_pick_limit = 0;
     if (!empty($field)) {
         $options = (array) pods_var_raw('options', $field, $field, null, true);
         $related_pick_limit = (int) pods_v('pick_limit', $options, 0);
         if ('single' == pods_var_raw('pick_format_type', $options)) {
             $related_pick_limit = 1;
         }
     }
     if (!pods_tableless()) {
         $field_id = (int) $field_id;
         $sister_id = (int) pods_var_raw('sister_id', $field, 0);
         $related_where = "\n                `field_id` = {$field_id}\n                AND `related_item_id` = {$id}\n            ";
         $sql = "\n                SELECT *\n                FROM `@wp_podsrel`\n                WHERE\n                    {$related_where}\n                ORDER BY `weight`\n            ";
         $relationships = pods_query($sql);
         if (!empty($relationships)) {
             $related_ids = array();
             foreach ($relationships as $relation) {
                 if ($field_id == $relation->field_id && !in_array($relation->item_id, $related_ids)) {
                     $related_ids[] = (int) $relation->item_id;
                 } elseif (0 < $sister_id && $field_id == $relation->related_field_id && !in_array($relation->related_item_id, $related_ids)) {
                     $related_ids[] = (int) $relation->related_item_id;
                 }
             }
         }
     } else {
         // @todo handle meta-based lookups
         return false;
         if (!is_array($pod)) {
             $pod = $this->load_pod(array('id' => $pod_id, 'table_info' => false), false);
         }
         if (!empty($pod) && in_array($pod['type'], array('post_type', 'media', 'user', 'comment', 'settings'))) {
             $related_ids = array();
             $meta_type = $pod['type'];
             if (in_array($pod['type'], array('post_type', 'media'))) {
                 $meta_type = 'post';
             }
             $no_conflict = pods_no_conflict_check($meta_type);
             if (!$no_conflict) {
                 pods_no_conflict_on($meta_type);
             }
             if ('settings' == $meta_type) {
                 $related_id = get_option('_pods_' . $pod['name'] . '_' . $field['name']);
                 if (empty($related_id)) {
                     $related_id = get_option($pod['name'] . '_' . $field['name']);
                 }
                 if (is_array($related_id) && !empty($related_id)) {
                     foreach ($related_id as $related) {
                         if (is_array($related) && !empty($related)) {
                             if (isset($related['id'])) {
                                 $related_ids[] = (int) $related['id'];
                             } else {
                                 foreach ($related as $r) {
                                     $related_ids[] = (int) $r;
                                 }
                             }
                         } else {
                             $related_ids[] = (int) $related;
                         }
                     }
                 }
             } else {
                 $related_id = get_metadata($meta_type, $id, '_pods_' . $field['name'], true);
                 if (empty($related_id)) {
                     $related_id = get_metadata($meta_type, $id, $field['name']);
                 }
                 if (is_array($related_id) && !empty($related_id)) {
                     foreach ($related_id as $related) {
                         if (is_array($related) && !empty($related)) {
                             if (isset($related['id'])) {
                                 $related_ids[] = (int) $related['id'];
                             } else {
                                 foreach ($related as $r) {
                                     if (isset($related['id'])) {
                                         $related_ids[] = (int) $r['id'];
                                     } else {
                                         $related_ids[] = (int) $r;
                                     }
//.........这里部分代码省略.........
开发者ID:satokora,项目名称:IT354Project,代码行数:101,代码来源:PodsAPI.php

示例4: pods_serial_comma

/**
 * Split an array into human readable text (Item, Item, and Item)
 *
 * @param array $value
 * @param string $field
 * @param array $fields
 * @param string $and
 * @param string $field_index
 *
 * @return string
 *
 * @since 2.0
 */
function pods_serial_comma($value, $field = null, $fields = null, $and = null, $field_index = null)
{
    if (is_object($value)) {
        $value = get_object_vars($value);
    }
    $defaults = array('field' => $field, 'fields' => $fields, 'and' => $and, 'field_index' => $field_index, 'separator' => ',', 'serial' => true);
    if (is_array($field)) {
        $defaults['field'] = null;
        $params = array_merge($defaults, $field);
    } else {
        $params = $defaults;
    }
    $params = (object) $params;
    $simple = false;
    if (!empty($params->fields) && is_array($params->fields) && isset($params->fields[$params->field])) {
        $params->field = $params->fields[$params->field];
        $simple_tableless_objects = PodsForm::simple_tableless_objects();
        if (!empty($params->field) && is_array($params->field) && in_array($params->field['type'], PodsForm::tableless_field_types())) {
            if (in_array($params->field['type'], PodsForm::file_field_types())) {
                if (null === $params->field_index) {
                    $params->field_index = 'guid';
                }
            } elseif (in_array($params->field['pick_object'], $simple_tableless_objects)) {
                $simple = true;
            } else {
                $table = pods_api()->get_table_info($params->field['pick_object'], $params->field['pick_val'], null, null, $params->field);
                if (!empty($table)) {
                    if (null === $params->field_index) {
                        $params->field_index = $table['field_index'];
                    }
                }
            }
        }
    } else {
        $params->field = null;
    }
    if ($simple && is_array($params->field) && !is_array($value) && '' !== $value && null !== $value) {
        $value = PodsForm::field_method('pick', 'simple_value', $params->field['name'], $value, $params->field);
    }
    if (!is_array($value)) {
        return $value;
    }
    if (null === $params->and) {
        $params->and = ' ' . __('and', 'pods') . ' ';
    }
    $last = '';
    $original_value = $value;
    if (!empty($value)) {
        $last = array_pop($value);
    }
    if ($simple && is_array($params->field) && !is_array($last) && '' !== $last && null !== $last) {
        $last = PodsForm::field_method('pick', 'simple_value', $params->field['name'], $last, $params->field);
    }
    if (is_array($last)) {
        if (null !== $params->field_index && isset($last[$params->field_index])) {
            $last = $last[$params->field_index];
        } elseif (isset($last[0])) {
            $last = $last[0];
        } elseif ($simple) {
            $last = current($last);
        } else {
            $last = '';
        }
    }
    if (!empty($value)) {
        if (null !== $params->field_index && isset($original_value[$params->field_index])) {
            return $original_value[$params->field_index];
        } elseif (null !== $params->field_index && isset($value[$params->field_index])) {
            return $value[$params->field_index];
        } elseif (!isset($value[0])) {
            $value = array($value);
        }
        foreach ($value as $k => $v) {
            if ($simple && is_array($params->field) && !is_array($v) && '' !== $v && null !== $v) {
                $v = PodsForm::field_method('pick', 'simple_value', $params->field['name'], $v, $params->field);
            }
            if (is_array($v)) {
                if (null !== $params->field_index && isset($v[$params->field_index])) {
                    $v = $v[$params->field_index];
                } elseif ($simple) {
                    $v = trim(implode($params->separator . ' ', $v), $params->separator . ' ');
                } else {
                    unset($value[$k]);
                    continue;
                }
            }
            $value[$k] = $v;
//.........这里部分代码省略.........
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:101,代码来源:data.php

示例5: traverse_recurse

 /**
  * Recursively join tables based on fields
  *
  * @param array $traverse_recurse Array of traversal options
  *
  * @return array Array of table joins
  *
  * @since 2.0
  */
 function traverse_recurse($traverse_recurse)
 {
     global $wpdb;
     $defaults = array('pod' => null, 'fields' => array(), 'joined' => 't', 'depth' => 0, 'joined_id' => 'id', 'joined_index' => 'id', 'params' => new stdClass(), 'last_table_info' => array());
     $traverse_recurse = array_merge($defaults, $traverse_recurse);
     $joins = array();
     if (0 == $traverse_recurse['depth'] && !empty($traverse_recurse['pod']) && !empty($traverse_recurse['last_table_info']) && isset($traverse_recurse['last_table_info']['id'])) {
         $pod_data = $traverse_recurse['last_table_info'];
     } elseif (empty($traverse_recurse['pod'])) {
         if (!empty($traverse_recurse['params']) && !empty($traverse_recurse['params']->table) && 0 === strpos($traverse_recurse['params']->table, $wpdb->prefix)) {
             if ($wpdb->posts == $traverse_recurse['params']->table) {
                 $traverse_recurse['pod'] = 'post_type';
             } elseif ($wpdb->terms == $traverse_recurse['params']->table) {
                 $traverse_recurse['pod'] = 'taxonomy';
             } elseif ($wpdb->users == $traverse_recurse['params']->table) {
                 $traverse_recurse['pod'] = 'user';
             } elseif ($wpdb->comments == $traverse_recurse['params']->table) {
                 $traverse_recurse['pod'] = 'comment';
             } else {
                 return $joins;
             }
             $pod_data = array();
             if (in_array($traverse_recurse['pod'], array('user', 'comment'))) {
                 $pod = $this->api->load_pod(array('name' => $traverse_recurse['pod'], 'table_info' => true));
                 if (!empty($pod) && $pod['type'] == $pod) {
                     $pod_data = $pod;
                 }
             }
             if (empty($pod_data)) {
                 $pod_data = array('id' => 0, 'name' => '_table_' . $traverse_recurse['pod'], 'type' => $traverse_recurse['pod'], 'storage' => 'taxonomy' == $traverse_recurse['pod'] ? 'none' : 'meta', 'fields' => array(), 'object_fields' => $this->api->get_wp_object_fields($traverse_recurse['pod']));
                 $pod_data = array_merge($this->api->get_table_info($traverse_recurse['pod'], ''), $pod_data);
             }
             $traverse_recurse['pod'] = $pod_data['name'];
         } else {
             return $joins;
         }
     } else {
         $pod_data = $this->api->load_pod(array('name' => $traverse_recurse['pod'], 'table_info' => true), false);
         if (empty($pod_data)) {
             return $joins;
         }
     }
     if (isset($pod_data['object_fields'])) {
         $pod_data['fields'] = array_merge($pod_data['fields'], $pod_data['object_fields']);
     }
     $tableless_field_types = PodsForm::tableless_field_types();
     $simple_tableless_objects = PodsForm::field_method('pick', 'simple_objects');
     $file_field_types = PodsForm::file_field_types();
     if (!isset($this->traversal[$traverse_recurse['pod']])) {
         $this->traversal[$traverse_recurse['pod']] = array();
     }
     if ((empty($pod_data['meta_table']) || $pod_data['meta_table'] == $pod_data['table']) && (empty($traverse_recurse['fields']) || !isset($traverse_recurse['fields'][$traverse_recurse['depth']]) || empty($traverse_recurse['fields'][$traverse_recurse['depth']]))) {
         return $joins;
     }
     $field = $traverse_recurse['fields'][$traverse_recurse['depth']];
     $ignore_aliases = array('wpml_languages', 'polylang_languages');
     $ignore_aliases = $this->do_hook('traverse_recurse_ignore_aliases', $ignore_aliases, $field, $traverse_recurse);
     if (in_array($field, $ignore_aliases)) {
         return $joins;
     }
     $meta_data_table = false;
     if (!isset($pod_data['fields'][$field]) && 'd' == $field && isset($traverse_recurse['fields'][$traverse_recurse['depth'] - 1])) {
         $field = $traverse_recurse['fields'][$traverse_recurse['depth'] - 1];
         $field_type = 'pick';
         if (isset($traverse_recurse['last_table_info']['pod']['fields'][$field])) {
             $field_type = $traverse_recurse['last_table_info']['pod']['fields'][$field]['type'];
         } elseif (isset($traverse_recurse['last_table_info']['pod']['object_fields'][$field])) {
             $field_type = $traverse_recurse['last_table_info']['pod']['object_fields'][$field]['type'];
         }
         $pod_data['fields'][$field] = array('id' => 0, 'name' => $field, 'type' => $field_type, 'pick_object' => $traverse_recurse['last_table_info']['pod']['type'], 'pick_val' => $traverse_recurse['last_table_info']['pod']['name']);
         $meta_data_table = true;
     }
     // Fallback to meta table if the pod type supports it
     if (!isset($pod_data['fields'][$field])) {
         $last = end($traverse_recurse['fields']);
         if ('post_type' == $pod_data['type'] && !isset($pod_data['object_fields'])) {
             $pod_data['object_fields'] = $this->api->get_wp_object_fields('post_type', $pod_data);
         }
         if ('post_type' == $pod_data['type'] && isset($pod_data['object_fields'][$field]) && in_array($pod_data['object_fields'][$field]['type'], $tableless_field_types)) {
             $pod_data['fields'][$field] = $pod_data['object_fields'][$field];
         } elseif (in_array($pod_data['type'], array('post_type', 'media', 'user', 'comment')) && 'meta_value' == $last) {
             $pod_data['fields'][$field] = PodsForm::field_setup(array('name' => $field));
         } else {
             if ('post_type' == $pod_data['type']) {
                 $pod_data['object_fields'] = $this->api->get_wp_object_fields('post_type', $pod_data, true);
                 if ('post_type' == $pod_data['type'] && isset($pod_data['object_fields'][$field]) && in_array($pod_data['object_fields'][$field]['type'], $tableless_field_types)) {
                     $pod_data['fields'][$field] = $pod_data['object_fields'][$field];
                 } else {
                     return $joins;
                 }
             } else {
//.........这里部分代码省略.........
开发者ID:Ingenex,项目名称:redesign,代码行数:101,代码来源:PodsData.php

示例6: remove_from

 /**
  * Remove an item from the values of a relationship field, remove a value from a number field (field-1), remove time to a date field
  *
  * @see PodsAPI::save_pod_item
  *
  * @param string $field Field name
  * @param mixed $value ID(s) to add, int|float to add to number field, string for dates (-1 week), or string for text
  * @param int $id (optional) ID of the pod item to update
  *
  * @return int The item ID
  *
  * @since 2.3.3
  */
 public function remove_from($field, $value = null, $id = null)
 {
     $pod =& $this;
     $fetch = false;
     if (null === $id) {
         $fetch = true;
         $id = $this->id();
     } elseif ($id != $this->id()) {
         $pod = pods($this->pod, $id);
     }
     $this->do_hook('remove_from', $field, $value, $id);
     if (!isset($this->fields[$field])) {
         return $id;
     }
     // Tableless fields
     if (in_array($this->fields[$field]['type'], PodsForm::tableless_field_types())) {
         if (empty($value)) {
             $value = array();
         }
         if (!empty($value)) {
             if (!is_array($value)) {
                 $value = explode(',', $value);
             }
             if ('pick' == $this->fields[$field]['type'] && in_array($this->fields[$field]['pick_object'], PodsForm::field_method('pick', 'simple_objects'))) {
                 $current_value = $pod->raw($field);
                 if (!empty($current_value)) {
                     $current_value = (array) $current_value;
                 }
                 foreach ($current_value as $k => $v) {
                     if (in_array($v, $value)) {
                         unset($current_value[$k]);
                     }
                 }
                 $value = $current_value;
             } else {
                 $related_ids = $this->api->lookup_related_items($this->fields[$field]['id'], $this->pod_data['id'], $id, $this->fields[$field], $this->pod_data);
                 foreach ($value as $k => $v) {
                     if (!preg_match('/[^0-9]/', $v)) {
                         $value[$k] = (int) $v;
                     } else {
                     }
                 }
                 foreach ($related_ids as $k => $v) {
                     if (in_array($v, $value)) {
                         unset($related_ids[$k]);
                     }
                 }
                 $value = $related_ids;
             }
             if (!empty($value)) {
                 $value = array_filter(array_unique($value));
             } else {
                 $value = array();
             }
         }
     } elseif (in_array($this->fields[$field]['type'], PodsForm::number_field_types())) {
         // Date fields don't support empty for removing
         if (empty($value)) {
             return $id;
         }
         $current_value = (double) $pod->raw($field);
         $value = $current_value - (double) $value;
     } elseif (in_array($this->fields[$field]['type'], PodsForm::date_field_types())) {
         // Date fields don't support empty for removing
         if (empty($value)) {
             return $id;
         }
         $current_value = $pod->raw($field);
         if (0 < strlen($current_value)) {
             $value = strtotime($value, strtotime($current_value));
         } else {
             $value = strtotime($value);
         }
         $value = date_i18n('Y-m-d h:i:s', $value);
     }
     // @todo handle object fields and taxonomies
     $params = array('pod' => $this->pod, 'id' => $id, 'data' => array($field => $value));
     $id = $this->api->save_pod_item($params);
     if (0 < $id && $fetch) {
         $pod->fetch($id, false);
     }
     return $id;
 }
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:96,代码来源:Pods.php

示例7: _fields

 /**
  * Return field array from $fields, a field's data, or a field option
  *
  * @param string $fields Field key name
  * @param string|null $field Field name
  * @param string|null $option Field option
  * @param bool $alt Set to true to check alternate fields array
  *
  * @return bool|mixed
  *
  * @since 2.3.10
  */
 protected function _fields($fields, $field = null, $option = null, $alt = true)
 {
     if (!$this->is_valid()) {
         if (null === $field || null === $option) {
             return array();
         }
         return false;
     }
     $alt_fields = 'object_fields';
     if ('object_fields' == $fields) {
         $alt_fields = 'fields';
     }
     // No fields found
     if (!isset($this->_object['fields']) || empty($this->_object['fields'])) {
         $field_data = array();
         // No fields and field not found, get alt field data
         if (!empty($field) && $alt) {
             $field_data = $this->_fields($alt_fields, $field, $option, false);
         }
     } elseif (empty($field)) {
         $field_data =& $this->_object['fields'];
         if (!$this->_live) {
             foreach ($field_data as $field_name => $fields) {
                 foreach ($fields as $field_option => $field_value) {
                     // i18n plugin integration
                     if ('label' == $field_option || 0 === strpos($field_option, 'label_')) {
                         $field_data[$field_name][$field_option] = __($field_value);
                     }
                 }
             }
         }
     } elseif (!isset($this->_object['fields'][$field])) {
         $field_data = array();
         // Field not found, get alt field data
         if ($alt) {
             $field_data = $this->_fields($alt_fields, $field, $option, false);
         }
     } elseif (empty($option)) {
         $field_data =& $this->_object['fields'][$field];
         if (!$this->_live) {
             foreach ($field_data as $field_option => $field_value) {
                 // i18n plugin integration
                 if ('label' == $field_option || 0 === strpos($field_option, 'label_')) {
                     $field_data[$field_option] = __($field_value);
                 }
             }
         }
     } else {
         $field_data = null;
         // Get a list of available items from a relationship field
         if ('data' == $option && in_array(pods_var_raw('type', $this->_object[$fields][$field]), PodsForm::tableless_field_types())) {
             $field_data = PodsForm::field_method('pick', 'get_field_data', $this->_object[$fields][$field]);
         } elseif (isset($this->_object[$fields][$field][$option])) {
             $field_data = $this->_object[$fields][$field][$option];
             // i18n plugin integration
             if ('label' == $option || 0 === strpos($option, 'label_')) {
                 $field_data = __($field_data);
             }
         }
     }
     return $field_data;
 }
开发者ID:Ingenex,项目名称:redesign,代码行数:74,代码来源:PodsObject.php

示例8: table_info

 /**
  * Get table info for a Pod
  *
  * @return array Table info
  */
 public function table_info()
 {
     if (!$this->is_valid() || !in_array($this->_field['type'], PodsForm::tableless_field_types())) {
         return array();
     }
     if (empty($this->_table_info)) {
         $this->_table_info = pods_api()->get_table_info($this->_field['pick_object'], $this->_field['pick_val'], null, null, $this->_field);
     }
     return $this->_table_info;
 }
开发者ID:Ingenex,项目名称:redesign,代码行数:15,代码来源:PodsObject_Field.php


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