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


PHP PodsForm::field_method方法代码示例

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


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

示例1: pods_register_related_object

/**
 * Register a related object
 *
 * @param string $name Object name
 * @param string $label Object label
 * @param array $options Object options
 *
 * @return array|boolean Object array or false if unsuccessful
 * @since 2.3
 */
function pods_register_related_object($name, $label, $options = null)
{
    return PodsForm::field_method('pick', 'register_related_object', $name, $label, $options);
}
开发者ID:Ingenex,项目名称:redesign,代码行数:14,代码来源:general.php

示例2: get_field_definition

 /**
  * Gets the schema definition of a field.
  *
  * @param string $type Field type to look for
  * @param array $options (optional) Options of the field to pass to the schema function.
  *
  * @return array|bool|mixed|null
  *
  * @since 2.0
  */
 private function get_field_definition($type, $options = null)
 {
     $definition = PodsForm::field_method($type, 'schema', $options);
     return $this->do_hook('field_definition', $definition, $type, $options);
 }
开发者ID:satokora,项目名称:IT354Project,代码行数:15,代码来源:PodsAPI.php

示例3: array

        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'));
    global $wpdb;
    $tables = $wpdb->get_results("SHOW TABLES", ARRAY_N);
开发者ID:jeremybradbury,项目名称:wp-ninja-kit,代码行数:31,代码来源:setup-edit.php

示例4: cpac_meta_values

 public function cpac_meta_values($meta, $fieldtype, $field, $type, $object_id)
 {
     $tableless_field_types = PodsForm::tableless_field_types();
     $object = $type;
     if ('wp-media' == $type) {
         $object = 'media';
     } elseif ('wp-users' == $type) {
         $object = 'user';
     } elseif ('wp-comments' == $type) {
         $object = 'comment';
     }
     $pod = pods_api()->load_pod(array('name' => $object), false);
     // Add Pods fields
     if (!empty($pod) && isset($pod['fields'][$field])) {
         if (in_array($pod['type'], array('post_type', 'user', 'comment', 'media')) && (!empty($fieldtype) || in_array($pod['fields'][$field]['type'], $tableless_field_types))) {
             $meta = get_metadata('post_type' == $pod['type'] ? 'post' : $pod['type'], $object_id, $field, true);
         }
         $meta = PodsForm::field_method($pod['fields'][$field]['type'], 'ui', $object_id, $meta, $field, array_merge($pod['fields'][$field], $pod['fields'][$field]['options']), $pod['fields'], $pod);
     }
     return $meta;
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:21,代码来源:PodsMeta.php

示例5: table


//.........这里部分代码省略.........
                ?>
" class="iedit<?php 
                echo esc_attr($toggle_class);
                ?>
">
                            <?php 
                if (!empty($this->actions_bulk)) {
                    ?>
                                <th scope="row" class="check-column"><input type="checkbox" name="action_bulk_ids<?php 
                    echo esc_attr($this->num);
                    ?>
[]" value="<?php 
                    echo esc_attr($row[$this->sql['field_id']]);
                    ?>
"></th>
            <?php 
                }
                foreach ($fields as $field => $attributes) {
                    if (false === $attributes['display']) {
                        continue;
                    }
                    if (!isset($row[$field])) {
                        $row[$field] = $this->get_field($field);
                    }
                    $row_value = $row[$field];
                    if (!empty($attributes['custom_display'])) {
                        if (is_callable($attributes['custom_display'])) {
                            $row_value = call_user_func_array($attributes['custom_display'], array($row, &$this, $row_value, $field, $attributes));
                        } elseif (is_object($this->pod) && class_exists('Pods_Helpers')) {
                            $row_value = $this->pod->helper($attributes['custom_display'], $row_value, $field);
                        }
                    } else {
                        ob_start();
                        $field_value = PodsForm::field_method($attributes['type'], 'ui', $this->id, $row_value, $field, array_merge($attributes, pods_var_raw('options', $attributes, array(), null, true)), $fields, $this->pod);
                        $field_output = trim((string) ob_get_clean());
                        if (false === $field_value) {
                            $row_value = '';
                        } elseif (0 < strlen(trim((string) $field_value))) {
                            $row_value = trim((string) $field_value);
                        } elseif (0 < strlen($field_output)) {
                            $row_value = $field_output;
                        }
                    }
                    if (false !== $attributes['custom_relate']) {
                        global $wpdb;
                        $table = $attributes['custom_relate'];
                        $on = $this->sql['field_id'];
                        $is = $row[$this->sql['field_id']];
                        $what = array('name');
                        if (is_array($table)) {
                            if (isset($table['on'])) {
                                $on = pods_sanitize($table['on']);
                            }
                            if (isset($table['is']) && isset($row[$table['is']])) {
                                $is = pods_sanitize($row[$table['is']]);
                            }
                            if (isset($table['what'])) {
                                $what = array();
                                if (is_array($table['what'])) {
                                    foreach ($table['what'] as $wha) {
                                        $what[] = pods_sanitize($wha);
                                    }
                                } else {
                                    $what[] = pods_sanitize($table['what']);
                                }
                            }
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:67,代码来源:PodsUI.php

示例6: 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

示例7: 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

示例8: 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

示例9: apply_filters

$date_format = apply_filters('pods_form_ui_field_date_js_formats', $date_format);
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-ui');
$attributes = array();
$type = 'text';
if (1 == pods_var($form_field_type . '_html5', $options)) {
    $type = $form_field_type;
}
$attributes['type'] = $type;
$attributes['tabindex'] = 2;
$format = PodsForm::field_method('date', 'format', $options);
$method = 'datepicker';
$args = array('dateFormat' => $date_format[pods_var($form_field_type . '_format', $options, 'mdy', null, true)], 'changeMonth' => true, 'changeYear' => true);
$html5_format = 'Y-m-d';
$date = PodsForm::field_method('date', 'createFromFormat', $format, (string) $value);
$date_default = PodsForm::field_method('date', 'createFromFormat', 'Y-m-d', (string) $value);
$formatted_date = $value;
if (1 == pods_var($form_field_type . '_allow_empty', $options, 1) && in_array($value, array('0000-00-00', '0000-00-00 00:00:00', '00:00:00'))) {
    $formatted_date = $value = '';
} elseif ('text' != $type) {
    $formatted_date = $value;
    if (false !== $date) {
        $value = $date->format($html5_format);
    } elseif (false !== $date_default) {
        $value = $date_default->format($html5_format);
    } elseif (!empty($value)) {
        $value = date_i18n($html5_format, strtotime((string) $value));
    } else {
        $value = date_i18n($html5_format);
    }
}
开发者ID:Ingenex,项目名称:redesign,代码行数:31,代码来源:date.php

示例10: array

}
$attributes['type'] = $type;
$attributes['tabindex'] = 2;
$format = PodsForm::field_method('time', 'format', $options);
$method = 'timepicker';
$args = array('timeFormat' => $time_format[pods_var($form_field_type . '_format', $options, 'h_mma', null, true)]);
if (false !== stripos($args['timeFormat'], 'tt')) {
    $args['ampm'] = true;
}
$html5_format = '\\TH:i:s';
if (24 == pods_var($form_field_type . '_type', $options, 12)) {
    $args['ampm'] = false;
    $args['timeFormat'] = $time_format_24[pods_var($form_field_type . '_format_24', $options, 'hh_mm', null, true)];
}
$date = PodsForm::field_method('time', 'createFromFormat', $format, (string) $value);
$date_default = PodsForm::field_method('time', 'createFromFormat', 'H:i:s', (string) $value);
$formatted_date = $value;
if (1 == pods_var($form_field_type . '_allow_empty', $options, 1) && in_array($value, array('', '0000-00-00', '0000-00-00 00:00:00', '00:00:00'))) {
    $formatted_date = $value = '';
} elseif ('text' != $type) {
    $formatted_date = $value;
    if (false !== $date) {
        $value = $date->format($html5_format);
    } elseif (false !== $date_default) {
        $value = $date_default->format($html5_format);
    } elseif (!empty($value)) {
        $value = date_i18n($html5_format, strtotime((string) $value));
    } else {
        $value = date_i18n($html5_format);
    }
}
开发者ID:satokora,项目名称:IT354Project,代码行数:31,代码来源:time.php

示例11: field


//.........这里部分代码省略.........
         $field_data = $this->fields[$first_field];
         $field_type = 'field';
     } elseif (!empty($this->pod_data['object_fields'])) {
         if (isset($this->pod_data['object_fields'][$first_field])) {
             $field_data = $this->pod_data['object_fields'][$first_field];
             $field_type = 'object_field';
         } else {
             foreach ($this->pod_data['object_fields'] as $object_field => $object_field_opt) {
                 if (in_array($first_field, $object_field_opt['alias'])) {
                     if ($first_field == $params->name) {
                         $params->name = $object_field;
                     }
                     $first_field = $object_field;
                     $field_data = $object_field_opt;
                     $field_type = 'object_field';
                     break;
                 }
             }
         }
     }
     // Simple fields have no other output options
     if ('pick' == $field_data['type'] && in_array($field_data['pick_object'], $simple_tableless_objects)) {
         $params->output = 'arrays';
     }
     if (empty($value) && in_array($field_data['type'], $tableless_field_types)) {
         $params->raw = true;
         $value = false;
         if ('arrays' != $params->output && isset($this->row['_' . $params->output . '_' . $params->name])) {
             $value = $this->row['_' . $params->output . '_' . $params->name];
         } elseif ('arrays' == $params->output && isset($this->row[$params->name])) {
             $value = $this->row[$params->name];
         }
         if (false !== $value && !is_array($value) && 'pick' == $field_data['type'] && in_array($field_data['pick_object'], $simple_tableless_objects)) {
             $value = PodsForm::field_method('pick', 'simple_value', $params->name, $value, $field_data, $this->pod_data, $this->id(), true);
         }
     }
     if (empty($value) && isset($this->row[$params->name]) && (!in_array($field_data['type'], $tableless_field_types) || 'arrays' == $params->output)) {
         if (empty($field_data) || in_array($field_data['type'], array('boolean', 'number', 'currency'))) {
             $params->raw = true;
         }
         if (null === $params->single) {
             if (isset($this->fields[$params->name]) && !in_array($this->fields[$params->name]['type'], $tableless_field_types)) {
                 $params->single = true;
             } else {
                 $params->single = false;
             }
         }
         $value = $this->row[$params->name];
     } elseif (empty($value)) {
         $object_field_found = false;
         if ('object_field' == $field_type) {
             $object_field_found = true;
             if (isset($this->row[$first_field])) {
                 $value = $this->row[$first_field];
             } elseif (in_array($field_data['type'], $tableless_field_types)) {
                 $this->fields[$first_field] = $field_data;
                 $object_field_found = false;
             } else {
                 return null;
             }
         }
         if ('post_type' == $this->pod_data['type'] && !isset($this->fields[$params->name])) {
             if (!isset($this->fields['post_thumbnail']) && ('post_thumbnail' == $params->name || 0 === strpos($params->name, 'post_thumbnail.'))) {
                 $size = 'thumbnail';
                 if (0 === strpos($params->name, 'post_thumbnail.')) {
                     $field_names = explode('.', $params->name);
开发者ID:satokora,项目名称:IT354Project,代码行数:67,代码来源:Pods.php

示例12: print_r

    echo 'pods-form-ui-row-type-' . $field['type'] . ' pods-form-ui-row-name-' . PodsForm::clean($field['name'], true);
    ?>
">
									<th scope="row" valign="top">
										<strong><?php 
    echo $field['label'];
    ?>
</strong>
									</th>
									<td>
										<?php 
    if (is_array($value) || is_object($value)) {
        print_r($value, true);
    } else {
        ob_start();
        $field_value = PodsForm::field_method($field['type'], 'ui', $obj->id, $value, $field['name'], array_merge($field, pods_var_raw('options', $field, array(), null, true)), $obj->fields['view']);
        $field_output = trim((string) ob_get_clean());
        if (false === $field_value) {
            $value = '';
        } elseif (0 < strlen(trim((string) $field_value))) {
            $value = trim((string) $field_value);
        } elseif (0 < strlen($field_output)) {
            $value = $field_output;
        }
        echo $value;
    }
    ?>
									</td>
								</tr>
							<?php 
}
开发者ID:KevinFairbanks,项目名称:pods-jobs-queue,代码行数:31,代码来源:view-job.php

示例13: _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

示例14: cpac_meta_values

 public function cpac_meta_values($meta, $field_type, $field, $type, $id)
 {
     $tableless_field_types = PodsForm::tableless_field_types();
     $object = $type;
     if ('wp-media' == $type) {
         $object = 'media';
     } elseif ('wp-users' == $type) {
         $object = 'user';
     } elseif ('wp-comments' == $type) {
         $object = 'comment';
     }
     if (empty(self::$current_pod_data) || !is_object(self::$current_pod_data) || self::$current_pod_data['name'] != $object) {
         self::$current_pod_data = pods_api()->load_pod(array('name' => $object), false);
     }
     $pod = self::$current_pod_data;
     // Add Pods fields
     if (!empty($pod) && isset($pod['fields'][$field])) {
         if (in_array($pod['type'], array('post_type', 'user', 'taxonomy', 'comment', 'media')) && (!empty($field_type) || in_array($pod['fields'][$field]['type'], $tableless_field_types))) {
             $metadata_type = $pod['type'];
             if (in_array($metadata_type, array('post_type', 'media'))) {
                 $metadata_type = 'post';
             } elseif ('taxonomy' == $metadata_type) {
                 $metadata_type = 'term';
             }
             $meta = get_metadata($metadata_type, $id, $field, true);
         }
         $meta = PodsForm::field_method($pod['fields'][$field]['type'], 'ui', $id, $meta, $field, array_merge($pod['fields'][$field], $pod['fields'][$field]['options']), $pod['fields'], $pod);
     }
     return $meta;
 }
开发者ID:pods-framework,项目名称:pods,代码行数:30,代码来源:PodsMeta.php

示例15: import

 /**
  * Import data from an array or a CSV file.
  *
  * @param mixed $import_data PHP associative array or CSV input
  * @param bool $numeric_mode Use IDs instead of the name field when matching
  * @param string $format Format of import data, options are php or csv
  *
  * @return array IDs of imported items
  *
  * @since 1.7.1
  * @todo This needs some love and use of table_info etc for relationships
  */
 public function import($import_data, $numeric_mode = false, $format = null)
 {
     /**
      * @var $wpdb wpdb
      */
     global $wpdb;
     if (null === $format && null !== $this->format) {
         $format = $this->format;
     }
     if ('csv' == $format && !is_array($import_data)) {
         $data = pods_migrate('sv', ',')->parse($import_data);
         $import_data = $data['items'];
     }
     pods_query("SET NAMES utf8");
     pods_query("SET CHARACTER SET utf8");
     // Loop through the array of items
     $ids = array();
     // Test to see if it's an array of arrays
     if (!is_array(@current($import_data))) {
         $import_data = array($import_data);
     }
     $pod = $this->load_pod(array('name' => $this->pod));
     if (false === $pod) {
         return pods_error(__('Pod not found', 'pods'), $this);
     }
     $fields = array_merge($pod['fields'], $pod['object_fields']);
     $simple_tableless_objects = PodsForm::field_method('pick', 'simple_objects');
     foreach ($import_data as $key => $data_row) {
         $data = array();
         // Loop through each field (use $fields so only valid fields get parsed)
         foreach ($fields as $field_name => $field_data) {
             if (!isset($data_row[$field_name]) && !isset($data_row[$field_data['label']])) {
                 continue;
             }
             $field_id = $field_data['id'];
             $type = $field_data['type'];
             $pick_object = isset($field_data['pick_object']) ? $field_data['pick_object'] : '';
             $pick_val = isset($field_data['pick_val']) ? $field_data['pick_val'] : '';
             if (isset($data_row[$field_name])) {
                 $field_value = $data_row[$field_name];
             } else {
                 $field_value = $data_row[$field_data['label']];
             }
             if (null !== $field_value && false !== $field_value && '' !== $field_value) {
                 if ('pick' == $type || in_array($type, PodsForm::file_field_types())) {
                     $field_values = is_array($field_value) ? $field_value : array($field_value);
                     $pick_values = array();
                     foreach ($field_values as $pick_value) {
                         if (in_array($type, PodsForm::file_field_types()) || 'media' == $pick_object) {
                             $where = "`guid` = '" . pods_sanitize($pick_value) . "'";
                             if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                 $where = "`ID` = " . pods_absint($pick_value);
                             }
                             $result = pods_query("SELECT `ID` AS `id` FROM `{$wpdb->posts}` WHERE `post_type` = 'attachment' AND {$where} ORDER BY `ID`", $this);
                             if (!empty($result)) {
                                 $pick_values[] = $result[0]->id;
                             }
                         } elseif ('pick' == $type) {
                             $related_pod = false;
                             if ('pod' == $pick_object) {
                                 $related_pod = $this->load_pod(array('name' => $pick_val, 'table_info' => true), false);
                             }
                             if (empty($related_pod)) {
                                 $related_pod = array('id' => 0, 'type' => $pick_object);
                             }
                             if (in_array('taxonomy', array($pick_object, $related_pod['type']))) {
                                 $where = "`t`.`name` = '" . pods_sanitize($pick_value) . "'";
                                 if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                     $where = "`tt`.`term_id` = " . pods_absint($pick_value);
                                 }
                                 $result = pods_query("SELECT `t`.`term_id` AS `id` FROM `{$wpdb->term_taxonomy}` AS `tt` LEFT JOIN `{$wpdb->terms}` AS `t` ON `t`.`term_id` = `tt`.`term_id` WHERE `taxonomy` = '{$pick_val}' AND {$where} ORDER BY `t`.`term_id`", $this);
                                 if (!empty($result)) {
                                     $pick_values[] = $result[0]->id;
                                 }
                             } elseif (in_array('post_type', array($pick_object, $related_pod['type'])) || in_array('media', array($pick_object, $related_pod['type']))) {
                                 $where = "`post_title` = '" . pods_sanitize($pick_value) . "'";
                                 if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                     $where = "`ID` = " . pods_absint($pick_value);
                                 }
                                 $result = pods_query("SELECT `ID` AS `id` FROM `{$wpdb->posts}` WHERE `post_type` = '{$pick_val}' AND {$where} ORDER BY `ID`", $this);
                                 if (!empty($result)) {
                                     $pick_values[] = $result[0]->id;
                                 }
                             } elseif (in_array('user', array($pick_object, $related_pod['type']))) {
                                 $where = "`user_login` = '" . pods_sanitize($pick_value) . "'";
                                 if (0 < pods_absint($pick_value) && false !== $numeric_mode) {
                                     $where = "`ID` = " . pods_absint($pick_value);
                                 }
//.........这里部分代码省略.........
开发者ID:Ingenex,项目名称:redesign,代码行数:101,代码来源:PodsAPI.php


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