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


PHP PodsForm::file_field_types方法代码示例

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


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

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

示例2: 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::simple_tableless_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:satokora,项目名称:IT354Project,代码行数:101,代码来源:PodsAPI.php

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

示例4: delete_attachment

 /**
  * Delete Attachments from relationships
  *
  * @param int $_ID
  */
 public function delete_attachment($_ID)
 {
     global $wpdb;
     $_ID = (int) $_ID;
     do_action('pods_delete_attachment', $_ID);
     $file_types = "'" . implode("', '", PodsForm::file_field_types()) . "'";
     if (!pods_tableless()) {
         $sql = "\n                DELETE `rel`\n                FROM `@wp_podsrel` AS `rel`\n                LEFT JOIN `{$wpdb->posts}` AS `p`\n                    ON\n                        `p`.`post_type` = '_pods_field'\n                        AND ( `p`.`ID` = `rel`.`field_id` OR `p`.`ID` = `rel`.`related_field_id` )\n                LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n                    ON\n                        `pm`.`post_id` = `p`.`ID`\n                        AND `pm`.`meta_key` = 'type'\n                        AND `pm`.`meta_value` IN ( {$file_types} )\n                WHERE\n                    `p`.`ID` IS NOT NULL\n                    AND `pm`.`meta_id` IS NOT NULL\n                    AND `rel`.`item_id` = {$_ID}";
         pods_query($sql, false);
     }
     // Post Meta
     if (!empty(PodsMeta::$post_types)) {
         $sql = "\n                DELETE `rel`\n                FROM `@wp_postmeta` AS `rel`\n                LEFT JOIN `{$wpdb->posts}` AS `p`\n                    ON\n                        `p`.`post_type` = '_pods_field'\n                LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n                    ON\n                        `pm`.`post_id` = `p`.`ID`\n                        AND `pm`.`meta_key` = 'type'\n                        AND `pm`.`meta_value` IN ( {$file_types} )\n                WHERE\n                    `p`.`ID` IS NOT NULL\n                    AND `pm`.`meta_id` IS NOT NULL\n                    AND `rel`.`meta_key` = `p`.`post_name`\n                    AND `rel`.`meta_value` = '{$_ID}'";
         pods_query($sql, false);
     }
     // User Meta
     if (!empty(PodsMeta::$user)) {
         $sql = "\n                DELETE `rel`\n                FROM `@wp_usermeta` AS `rel`\n                LEFT JOIN `{$wpdb->posts}` AS `p`\n                    ON\n                        `p`.`post_type` = '_pods_field'\n                LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n                    ON\n                        `pm`.`post_id` = `p`.`ID`\n                        AND `pm`.`meta_key` = 'type'\n                        AND `pm`.`meta_value` IN ( {$file_types} )\n                WHERE\n                    `p`.`ID` IS NOT NULL\n                    AND `pm`.`meta_id` IS NOT NULL\n                    AND `rel`.`meta_key` = `p`.`post_name`\n                    AND `rel`.`meta_value` = '{$_ID}'";
         pods_query($sql, false);
     }
     // Comment Meta
     if (!empty(PodsMeta::$comment)) {
         $sql = "\n                DELETE `rel`\n                FROM `@wp_commentmeta` AS `rel`\n                LEFT JOIN `{$wpdb->posts}` AS `p`\n                    ON\n                        `p`.`post_type` = '_pods_field'\n                LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n                    ON\n                        `pm`.`post_id` = `p`.`ID`\n                        AND `pm`.`meta_key` = 'type'\n                        AND `pm`.`meta_value` IN ( {$file_types} )\n                WHERE\n                    `p`.`ID` IS NOT NULL\n                    AND `pm`.`meta_id` IS NOT NULL\n                    AND `rel`.`meta_key` = `p`.`post_name`\n                    AND `rel`.`meta_value` = '{$_ID}'";
         pods_query($sql, false);
     }
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:31,代码来源:PodsInit.php

示例5: pods_var_raw

">
<?php 
        }
    }
    if (!is_array($field_option['group'])) {
        $row_name = $field_name;
        if (!isset($pods_tab_form)) {
            $row_name = 'field_data[' . $pods_i . '][' . $field_name . ']';
        }
        $value = $field_option['default'];
        if (isset($field_option['value']) && 0 < strlen($field_option['value'])) {
            $value = $field_option['value'];
        } else {
            $value = pods_var_raw($field_name, $field, $value);
        }
        if (in_array($field_option['type'], PodsForm::file_field_types())) {
            if (is_array($value) && !isset($value['id'])) {
                foreach ($value as $k => $v) {
                    if (isset($v['id'])) {
                        $value[$k] = $v['id'];
                    }
                }
            }
        }
        ?>
        <div class="pods-field-option">
            <?php 
        echo PodsForm::row($row_name, $value, $field_option['type'], $field_option);
        ?>
        </div>
        <?php 
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:31,代码来源:field-option.php

示例6: admin_ajax_upload

 /**
  * Handle plupload AJAX
  *
  * @since 2.3
  */
 public function admin_ajax_upload()
 {
     if (false === headers_sent()) {
         if ('' == session_id()) {
             @session_start();
         }
     }
     // Sanitize input
     $params = stripslashes_deep((array) $_POST);
     foreach ($params as $key => $value) {
         if ('action' == $key) {
             continue;
         }
         unset($params[$key]);
         $params[str_replace('_podsfix_', '', $key)] = $value;
     }
     $params = (object) $params;
     $methods = array('upload');
     if (!isset($params->method) || !in_array($params->method, $methods) || !isset($params->pod) || !isset($params->field) || !isset($params->uri) || empty($params->uri)) {
         pods_error('Invalid AJAX request', PodsInit::$admin);
     } elseif (!empty($params->pod) && empty($params->field)) {
         pods_error('Invalid AJAX request', PodsInit::$admin);
     } elseif (empty($params->pod) && !current_user_can('upload_files')) {
         pods_error('Invalid AJAX request', PodsInit::$admin);
     }
     // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
     if (is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
         $_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
     } elseif (empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
         $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
     }
     if (empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie'])) {
         $_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
     }
     global $current_user;
     unset($current_user);
     /**
      * Access Checking
      */
     $upload_disabled = false;
     if (defined('PODS_DISABLE_FILE_UPLOAD') && true === PODS_DISABLE_FILE_UPLOAD) {
         $upload_disabled = true;
     } elseif (defined('PODS_UPLOAD_REQUIRE_LOGIN') && is_bool(PODS_UPLOAD_REQUIRE_LOGIN) && true === PODS_UPLOAD_REQUIRE_LOGIN && !is_user_logged_in()) {
         $upload_disabled = true;
     } elseif (defined('PODS_UPLOAD_REQUIRE_LOGIN') && !is_bool(PODS_UPLOAD_REQUIRE_LOGIN) && (!is_user_logged_in() || !current_user_can(PODS_UPLOAD_REQUIRE_LOGIN))) {
         $upload_disabled = true;
     }
     $uid = @session_id();
     if (is_user_logged_in()) {
         $uid = 'user_' . get_current_user_id();
     }
     $nonce_check = 'pods_upload_' . (int) $params->pod . '_' . $uid . '_' . $params->uri . '_' . (int) $params->field;
     if (true === $upload_disabled || !isset($params->_wpnonce) || false === wp_verify_nonce($params->_wpnonce, $nonce_check)) {
         pods_error(__('Unauthorized request', 'pods'), PodsInit::$admin);
     }
     $pod = array();
     $field = array('type' => 'file', 'options' => array());
     $api = pods_api();
     if (!empty($params->pod)) {
         $pod = $api->load_pod(array('id' => (int) $params->pod));
         $field = $api->load_field(array('id' => (int) $params->field));
         if (empty($pod) || empty($field) || $pod['id'] != $field['pod_id'] || !isset($pod['fields'][$field['name']])) {
             pods_error(__('Invalid field request', 'pods'), PodsInit::$admin);
         }
         if (!in_array($field['type'], PodsForm::file_field_types())) {
             pods_error(__('Invalid field', 'pods'), PodsInit::$admin);
         }
     }
     $method = $params->method;
     // Cleaning up $params
     unset($params->action);
     unset($params->method);
     unset($params->_wpnonce);
     $params->post_id = pods_var('post_id', $params, 0, null, true);
     /**
      * Upload a new file (advanced - returns URL and ID)
      */
     if ('upload' == $method) {
         $file = $_FILES['Filedata'];
         $limit_size = pods_var($field['type'] . '_restrict_filesize', $field['options']);
         if (!empty($limit_size)) {
             if (false !== stripos($limit_size, 'MB')) {
                 $limit_size = (double) trim(str_ireplace('MB', '', $limit_size));
                 $limit_size = $limit_size * 1025 * 1025;
                 // convert to KB to B
             } elseif (false !== stripos($limit_size, 'KB')) {
                 $limit_size = (double) trim(str_ireplace('KB', '', $limit_size));
                 $limit_size = $limit_size * 1025 * 1025;
                 // convert to B
             } elseif (false !== stripos($limit_size, 'GB')) {
                 $limit_size = (double) trim(str_ireplace('GB', '', $limit_size));
                 $limit_size = $limit_size * 1025 * 1025 * 1025;
                 // convert to MB to KB to B
             } elseif (false !== stripos($limit_size, 'B')) {
                 $limit_size = (double) trim(str_ireplace('B', '', $limit_size));
//.........这里部分代码省略.........
开发者ID:centaurustech,项目名称:chipin,代码行数:101,代码来源:file.php

示例7: field


//.........这里部分代码省略.........
                         if (!isset($all_fields[$pod][$field]['pod_id'])) {
                             $all_fields[$pod][$field]['pod_id'] = 0;
                         }
                         if (isset($all_fields[$pod][$field]['id'])) {
                             $ids = $this->api->lookup_related_items($all_fields[$pod][$field]['id'], $all_fields[$pod][$field]['pod_id'], $ids, $all_fields[$pod][$field]);
                         }
                         // No items found
                         if (empty($ids)) {
                             return false;
                         } elseif (0 < $last_limit) {
                             $ids = array_slice($ids, 0, $last_limit);
                         }
                         // Get $pod if related to a Pod
                         if (!empty($pick_object) && !empty($pick_val)) {
                             if ('pod' == $pick_object) {
                                 $pod = $pick_val;
                             } else {
                                 $check = $this->api->get_table_info($pick_object, $pick_val);
                                 if (!empty($check) && !empty($check['pod'])) {
                                     $pod = $check['pod']['name'];
                                 }
                             }
                         }
                     } else {
                         // Invalid field
                         if (0 == $key) {
                             return false;
                         }
                         $last_loop = true;
                     }
                     if ($last_loop) {
                         $object_type = $last_object;
                         $object = $last_pick_val;
                         if (in_array($last_type, PodsForm::file_field_types())) {
                             $object_type = 'media';
                             $object = 'attachment';
                         }
                         $data = array();
                         $table = $this->api->get_table_info($object_type, $object, null, null, $last_options);
                         $join = $where = array();
                         if (!empty($table['join'])) {
                             $join = (array) $table['join'];
                         }
                         if (!empty($table['where']) || !empty($ids)) {
                             foreach ($ids as $id) {
                                 $where[$id] = '`t`.`' . $table['field_id'] . '` = ' . (int) $id;
                             }
                             if (!empty($where)) {
                                 $where = array(implode(' OR ', $where));
                             }
                             if (!empty($table['where'])) {
                                 $where = array_merge($where, array_values((array) $table['where']));
                             }
                         }
                         /**
                          * @var $related_obj Pods
                          */
                         $related_obj = false;
                         if ('pod' == $object_type) {
                             $related_obj = pods($object, null, false);
                         } elseif (isset($table['pod']) && !empty($table['pod'])) {
                             $related_obj = pods($table['pod']['name'], null, false);
                         }
                         if (!empty($table['table']) || !empty($related_obj)) {
                             $sql = array('select' => '*, `t`.`' . $table['field_id'] . '` AS `pod_item_id`', 'table' => $table['table'], 'join' => $join, 'where' => $where, 'orderby' => $params->orderby, 'pagination' => false, 'search' => false, 'limit' => -1);
                             // Output types
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:67,代码来源:Pods.php


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