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


PHP pods_absint函数代码示例

本文整理汇总了PHP中pods_absint函数的典型用法代码示例。如果您正苦于以下问题:PHP pods_absint函数的具体用法?PHP pods_absint怎么用?PHP pods_absint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: install

 /**
  *
  */
 public function install($_blog_id = null)
 {
     /**
      * @var $wpdb WPDB
      */
     global $wpdb;
     // Switch DB table prefixes
     if (null !== $_blog_id && $_blog_id != $wpdb->blogid) {
         switch_to_blog(pods_absint($_blog_id));
     } else {
         $_blog_id = null;
     }
     $pods_version = get_option('pods_version');
     do_action('pods_install', PODS_VERSION, $pods_version, $_blog_id);
     if (!pods_tableless() && false !== apply_filters('pods_install_run', null, PODS_VERSION, $pods_version, $_blog_id) && !isset($_GET['pods_bypass_install'])) {
         $sql = file_get_contents(PODS_DIR . 'sql/dump.sql');
         $sql = apply_filters('pods_install_sql', $sql, PODS_VERSION, $pods_version, $_blog_id);
         $charset_collate = 'DEFAULT CHARSET utf8';
         if (!empty($wpdb->charset)) {
             $charset_collate = "DEFAULT CHARSET {$wpdb->charset}";
         }
         if (!empty($wpdb->collate)) {
             $charset_collate .= " COLLATE {$wpdb->collate}";
         }
         if ('DEFAULT CHARSET utf8' != $charset_collate) {
             $sql = str_replace('DEFAULT CHARSET utf8', $charset_collate, $sql);
         }
         $sql = explode(";\n", str_replace(array("\r", 'wp_'), array("\n", $wpdb->prefix), $sql));
         for ($i = 0, $z = count($sql); $i < $z; $i++) {
             $query = trim($sql[$i]);
             if (empty($query)) {
                 continue;
             }
             pods_query($query, 'Cannot setup SQL tables');
         }
     }
     do_action('pods_install_post', PODS_VERSION, $pods_version, $_blog_id);
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:41,代码来源:PodsUpgrade.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: delete_bulk

 /**
  * @param null $id
  *
  * @return bool|mixed
  */
 public function delete_bulk()
 {
     $this->do_hook('pre_delete_bulk');
     if (1 != pods_var('deleted_bulk', 'get', 0)) {
         $ids = $this->bulk;
         $success = false;
         if (!empty($ids)) {
             $ids = (array) $ids;
             foreach ($ids as $id) {
                 $id = pods_absint($id);
                 if (empty($id)) {
                     continue;
                 }
                 if ($callback = $this->callback('delete', $id)) {
                     $check = $callback;
                 } elseif (is_object($this->pod)) {
                     $check = $this->pod->delete($id);
                 } else {
                     $check = $this->pods_data->delete($this->sql['table'], array($this->sql['field_id'] => $id));
                 }
                 if ($check) {
                     $success = true;
                 }
             }
         }
         if ($success) {
             pods_redirect(pods_query_arg(array('action_bulk' => 'delete', 'deleted_bulk' => 1), array('page', 'lang', 'action', 'id')));
         } else {
             $this->error(sprintf(__("<strong>Error:</strong> %s has not been deleted.", 'pods'), $this->item));
         }
     } else {
         $this->message(sprintf(__("<strong>Deleted:</strong> %s have been deleted.", 'pods'), $this->items));
         unset($_GET['deleted_bulk']);
     }
     $this->action_bulk = false;
     unset($_GET['action_bulk']);
     $this->do_hook('post_delete_bulk');
     $this->manage();
 }
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:44,代码来源:PodsUI.php

示例4: showform


//.........这里部分代码省略.........
                        $pick_join = "`@wp_term_taxonomy` AS tx ON tx.`term_id` = t.`term_id";
                        $pick_where = "tx.`taxonomy` = '{$pick_val}' AND tx.`taxonomy` IS NOT NULL";
                        break;
                    case 'user':
                        $pick_table = '@wp_users';
                        $pick_field_id = 'ID';
                        $pick_field_name = 'user_login';
                        break;
                    case 'comment':
                        $pick_table = '@wp_comments';
                        $pick_field_id = 'comment_ID';
                        $pick_field_name = 'comment_date';
                        $pick_where = "t.`comment_type` = '{$pick_val}'";
                        break;
                    case 'table':
                        $pick_table = "{$pick_val}";
                        $pick_field_id = 'id';
                        $pick_field_name = 'name';
                        break;
                }
                $sql = "SELECT `related_item_id` FROM `@wp_podsrel` WHERE `item_id` = %d AND `field_id` = %d";
                $sql = array($sql, array($id, $field['id']));
                $result = pods_query($sql, $this);
                foreach ($result as $row) {
                    $selected_ids[] = $row->related_item_id;
                }
                // Use default values for public forms
                if (empty($selected_ids) && !empty($field['default'])) {
                    $default_ids = $field['default'];
                    if (!is_array($field['default'])) {
                        $default_ids = explode(',', $default_ids);
                    }
                    foreach ($default_ids as $default_id) {
                        $default_id = pods_absint($default_id);
                        if (0 < $default_id) {
                            $selected_ids[] = $default_id;
                        }
                    }
                }
                // If the PICK field is unique, get values already chosen
                $exclude = false;
                if (1 == $field['unique']) {
                    $unique_where = empty($id) ? '' : " AND `item_id` != %d";
                    $sql = "SELECT `related_item_id` FROM `@wp_podsrel` WHERE `field_id` = %d {$unique_where}";
                    $sql = array($sql, array($field['id']));
                    if (!empty($id)) {
                        $sql[1][] = $id;
                    }
                    $result = pods_query($sql, $this);
                    if (!empty($result)) {
                        $exclude = array();
                        foreach ($result as $row) {
                            $exclude[] = (int) $row->related_item_id;
                        }
                        $exclude = implode(',', $exclude);
                    }
                }
                if (!empty($field['options']['pick_filter'])) {
                    $pick_where .= ' AND ' . $field['options']['pick_filter'];
                }
                $params = array('exclude' => $exclude, 'selected_ids' => $selected_ids, 'table' => $pick_table, 'field_id' => $pick_field_id, 'field_name' => $pick_field_name, 'join' => $pick_join, 'orderby' => $field['options']['pick_orderby'], 'where' => $pick_where);
                $this->obj->row[$key] = $this->get_dropdown_values($params);
            } else {
                // Set a default value if no value is entered
                if (!isset($this->obj->row[$key]) || (null === $this->obj->row[$key] || false === $this->obj->row[$key])) {
                    if (!empty($field['default'])) {
开发者ID:centaurustech,项目名称:chipin,代码行数:67,代码来源:Pods.php

示例5: reset

 /**
  * Reset the current data
  *
  * @param int $row Row number to reset to
  *
  * @return mixed
  *
  * @since 2.0
  */
 public function reset($row = null)
 {
     $row = pods_absint($row);
     $this->row = false;
     if (isset($this->data[$row])) {
         $this->row = get_object_vars($this->data[$row]);
     }
     if (empty($row)) {
         $this->row_number = -1;
     } else {
         $this->row_number = $row - 1;
     }
     return $this->row;
 }
开发者ID:Ingenex,项目名称:redesign,代码行数:23,代码来源:PodsData.php

示例6: reset

 /**
  * @param null $_blog_id
  */
 public function reset($_blog_id = null)
 {
     global $wpdb;
     // Switch DB table prefixes
     if (null !== $_blog_id && $_blog_id != $wpdb->blogid) {
         switch_to_blog(pods_absint($_blog_id));
     } else {
         $_blog_id = null;
     }
     $api = pods_api();
     $pods = $api->load_pods(array('names_ids' => true));
     foreach ($pods as $pod_id => $pod_label) {
         $api->delete_pod(array('id' => $pod_id));
     }
     $templates = $api->load_templates();
     foreach ($templates as $template) {
         $api->delete_template(array('id' => $template['id']));
     }
     $pages = $api->load_pages();
     foreach ($pages as $page) {
         $api->delete_page(array('id' => $page['id']));
     }
     $helpers = $api->load_helpers();
     foreach ($helpers as $helper) {
         $api->delete_helper(array('id' => $helper['id']));
     }
     $tables = $wpdb->get_results("SHOW TABLES LIKE '{$wpdb->prefix}pods%'", ARRAY_N);
     if (!empty($tables)) {
         foreach ($tables as $table) {
             $table = $table[0];
             pods_query("DROP TABLE `{$table}`", false);
         }
     }
     // Remove any orphans
     $wpdb->query("\n                DELETE `p`, `pm`\n                FROM `{$wpdb->posts}` AS `p`\n                LEFT JOIN `{$wpdb->postmeta}` AS `pm`\n                    ON `pm`.`post_id` = `p`.`ID`\n                WHERE\n                    `p`.`post_type` LIKE '_pods_%'\n            ");
     delete_option('pods_framework_version');
     delete_option('pods_framework_db_version');
     delete_option('pods_framework_upgrade_2_0');
     delete_option('pods_framework_upgraded_1_x');
     // @todo Make sure all entries are being cleaned and do something about the pods_framework_upgrade_{version} dynamic entries created by PodsUpgrade
     delete_option('pods_framework_upgrade_2_0_0');
     delete_option('pods_framework_upgrade_2_0_sister_ids');
     delete_option('pods_framework_version_last');
     delete_option('pods_component_settings');
     $api->cache_flush_pods();
     pods_transient_clear('pods_flush_rewrites');
     self::$version = '';
     // Restore DB table prefix (if switched)
     if (null !== $_blog_id) {
         restore_current_blog();
     }
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:55,代码来源:PodsInit.php

示例7: __construct

 /**
  * Constructor - Pods Framework core
  *
  * @param string $pod The pod name
  * @param mixed $id (optional) The ID or slug, to load a single record; Provide array of $params to run 'find'
  *
  * @return \Pods
  *
  * @license http://www.gnu.org/licenses/gpl-2.0.html
  * @since 1.0.0
  * @link http://pods.io/docs/pods/
  */
 public function __construct($pod = null, $id = null)
 {
     if (null === $pod) {
         $queried_object = get_queried_object();
         if ($queried_object) {
             $id_lookup = true;
             // Post Type Singular
             if (isset($queried_object->post_type)) {
                 $pod = $queried_object->post_type;
             } elseif (isset($queried_object->taxonomy)) {
                 $pod = $queried_object->taxonomy;
             } elseif (isset($queried_object->user_login)) {
                 $pod = 'user';
             } elseif (isset($queried_object->public) && isset($queried_object->name)) {
                 $pod = $queried_object->name;
                 $id_lookup = false;
             }
             if (null === $id && $id_lookup) {
                 $id = get_queried_object_id();
             }
         }
     }
     $this->api = pods_api($pod);
     $this->api->display_errors =& $this->display_errors;
     $this->data = pods_data($this->api, $id, false);
     PodsData::$display_errors =& $this->display_errors;
     // Set up page variable
     if (pods_strict(false)) {
         $this->page = 1;
         $this->pagination = false;
         $this->search = false;
     } else {
         // Get the page variable
         $this->page = pods_var($this->page_var, 'get');
         $this->page = empty($this->page) ? 1 : max(pods_absint($this->page), 1);
     }
     // Set default pagination handling to on/off
     if (defined('PODS_GLOBAL_POD_PAGINATION')) {
         if (!PODS_GLOBAL_POD_PAGINATION) {
             $this->page = 1;
             $this->pagination = false;
         } else {
             $this->pagination = true;
         }
     }
     // Set default search to on/off
     if (defined('PODS_GLOBAL_POD_SEARCH')) {
         if (PODS_GLOBAL_POD_SEARCH) {
             $this->search = true;
         } else {
             $this->search = false;
         }
     }
     // Set default search mode
     $allowed_search_modes = array('int', 'text', 'text_like');
     if (defined('PODS_GLOBAL_POD_SEARCH_MODE') && in_array(PODS_GLOBAL_POD_SEARCH_MODE, $allowed_search_modes)) {
         $this->search_mode = PODS_GLOBAL_POD_SEARCH_MODE;
     }
     // Sync Settings
     $this->data->page =& $this->page;
     $this->data->limit =& $this->limit;
     $this->data->pagination =& $this->pagination;
     $this->data->search =& $this->search;
     $this->data->search_mode =& $this->search_mode;
     // Sync Pod Data
     $this->api->pod_data =& $this->data->pod_data;
     $this->pod_data =& $this->api->pod_data;
     $this->api->pod_id =& $this->data->pod_id;
     $this->pod_id =& $this->api->pod_id;
     $this->datatype_id =& $this->pod_id;
     $this->api->pod =& $this->data->pod;
     $this->pod =& $this->api->pod;
     $this->datatype =& $this->pod;
     $this->api->fields =& $this->data->fields;
     $this->fields =& $this->api->fields;
     $this->detail_page =& $this->data->detail_page;
     $this->id =& $this->data->id;
     $this->row =& $this->data->row;
     $this->rows =& $this->data->data;
     $this->row_number =& $this->data->row_number;
     $this->sql =& $this->data->sql;
     if (is_array($id) || is_object($id)) {
         $this->find($id);
     }
 }
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:97,代码来源:Pods.php

示例8: delete_bulk

 /**
  * @param null $id
  *
  * @return bool|mixed
  */
 public function delete_bulk()
 {
     $this->do_hook('pre_delete_bulk');
     if (1 != pods_var('deleted_bulk', 'get', 0)) {
         $ids = $this->bulk;
         $success = false;
         if (!empty($ids)) {
             $ids = (array) $ids;
             foreach ($ids as $id) {
                 $id = pods_absint($id);
                 if (empty($id)) {
                     continue;
                 }
                 if (isset($this->actions_custom['delete']) && is_callable($this->actions_custom['delete'])) {
                     $check = call_user_func_array($this->actions_custom['delete'], array($id, &$this));
                     if (false !== $check) {
                         $check = true;
                     }
                 } elseif (is_object($this->pod)) {
                     $check = $this->pod->delete($id);
                 } else {
                     $check = $this->pods_data->delete($this->table, array($this->data->field_id => $id));
                 }
                 if ($check) {
                     $success = true;
                 }
             }
         }
         if ($success) {
             pods_redirect(pods_var_update(array('action_bulk' => 'delete', 'deleted_bulk' => 1), array('page', 'lang', 'action', 'id')));
         } else {
             $this->error(__("<strong>Error:</strong> {$this->item} has not been deleted.", 'pods'));
         }
     } else {
         $this->message(__("<strong>Deleted:</strong> {$this->items} have been deleted.", 'pods'));
         unset($_GET['deleted_bulk']);
     }
     $this->action_bulk = false;
     unset($_GET['action_bulk']);
     $this->do_hook('post_delete_bulk');
     $this->manage();
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:47,代码来源:PodsUI.php


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