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


PHP FrmAppHelper::maybe_json_decode方法代码示例

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


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

示例1: import_xml_entries

 public static function import_xml_entries($entries, $imported)
 {
     global $frm_duplicate_ids, $wpdb;
     $saved_entries = array();
     $track_child_ids = array();
     // Import all child entries first
     self::put_child_entries_first($entries);
     foreach ($entries as $item) {
         $entry = array('id' => (int) $item->id, 'item_key' => (string) $item->item_key, 'name' => (string) $item->name, 'description' => FrmAppHelper::maybe_json_decode((string) $item->description), 'ip' => (string) $item->ip, 'form_id' => isset($imported['forms'][(int) $item->form_id]) ? $imported['forms'][(int) $item->form_id] : (int) $item->form_id, 'post_id' => isset($imported['posts'][(int) $item->post_id]) ? $imported['posts'][(int) $item->post_id] : (int) $item->post_id, 'user_id' => FrmAppHelper::get_user_id_param((string) $item->user_id), 'parent_item_id' => (int) $item->parent_item_id, 'is_draft' => (int) $item->is_draft, 'updated_by' => FrmAppHelper::get_user_id_param((string) $item->updated_by), 'created_at' => (string) $item->created_at, 'updated_at' => (string) $item->updated_at);
         $metas = array();
         foreach ($item->item_meta as $meta) {
             $field_id = (int) $meta->field_id;
             if (is_array($frm_duplicate_ids) && isset($frm_duplicate_ids[$field_id])) {
                 $field_id = $frm_duplicate_ids[$field_id];
             }
             $field = FrmField::getOne($field_id);
             if (!$field) {
                 continue;
             }
             $metas[$field_id] = FrmAppHelper::maybe_json_decode((string) $meta->meta_value);
             $metas[$field_id] = apply_filters('frm_import_val', $metas[$field_id], $field);
             self::convert_field_values($field, $field_id, $metas, $saved_entries);
             if ($field->type == 'user_id' && $metas[$field_id] && is_numeric($metas[$field_id])) {
                 $entry['frm_user_id'] = $metas[$field_id];
             }
             unset($field, $meta);
         }
         unset($item);
         $entry['item_meta'] = $metas;
         unset($metas);
         // edit entry if the key and created time match
         $editing = FrmDb::get_var('frm_items', array('item_key' => $entry['item_key'], 'created_at' => date('Y-m-d H:i:s', strtotime($entry['created_at']))));
         if ($editing) {
             FrmEntry::update_entry_from_xml($entry['id'], $entry);
             $imported['updated']['items']++;
             $saved_entries[$entry['id']] = $entry['id'];
         } else {
             if ($e = FrmEntry::create_entry_from_xml($entry)) {
                 $saved_entries[$entry['id']] = $e;
                 $imported['imported']['items']++;
             }
         }
         self::track_imported_child_entries($saved_entries[$entry['id']], $entry['parent_item_id'], $track_child_ids);
         unset($entry);
     }
     self::update_parent_item_ids($track_child_ids, $saved_entries);
     unset($entries);
     return $imported;
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:49,代码来源:FrmProXMLHelper.php

示例2: populate_postmeta

 private static function populate_postmeta(&$post, $meta, $imported)
 {
     global $frm_duplicate_ids;
     $m = array('key' => (string) $meta->meta_key, 'value' => (string) $meta->meta_value);
     //switch old form and field ids to new ones
     if ($m['key'] == 'frm_form_id' && isset($imported['forms'][(int) $m['value']])) {
         $m['value'] = $imported['forms'][(int) $m['value']];
     } else {
         $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
         if (!empty($frm_duplicate_ids)) {
             if ($m['key'] == 'frm_dyncontent') {
                 $m['value'] = FrmFieldsHelper::switch_field_ids($m['value']);
             } else {
                 if ($m['key'] == 'frm_options') {
                     foreach (array('date_field_id', 'edate_field_id') as $setting_name) {
                         if (isset($m['value'][$setting_name]) && is_numeric($m['value'][$setting_name]) && isset($frm_duplicate_ids[$m['value'][$setting_name]])) {
                             $m['value'][$setting_name] = $frm_duplicate_ids[$m['value'][$setting_name]];
                         }
                     }
                     $check_dup_array = array();
                     if (isset($m['value']['order_by']) && !empty($m['value']['order_by'])) {
                         if (is_numeric($m['value']['order_by']) && isset($frm_duplicate_ids[$m['value']['order_by']])) {
                             $m['value']['order_by'] = $frm_duplicate_ids[$m['value']['order_by']];
                         } else {
                             if (is_array($m['value']['order_by'])) {
                                 $check_dup_array[] = 'order_by';
                             }
                         }
                     }
                     if (isset($m['value']['where']) && !empty($m['value']['where'])) {
                         $check_dup_array[] = 'where';
                     }
                     foreach ($check_dup_array as $check_k) {
                         foreach ((array) $m['value'][$check_k] as $mk => $mv) {
                             if (isset($frm_duplicate_ids[$mv])) {
                                 $m['value'][$check_k][$mk] = $frm_duplicate_ids[$mv];
                             }
                             unset($mk, $mv);
                         }
                     }
                 }
             }
         }
     }
     if (!is_array($m['value'])) {
         $m['value'] = FrmAppHelper::maybe_json_decode($m['value']);
     }
     $post['postmeta'][(string) $meta->meta_key] = $m['value'];
 }
开发者ID:EyesX,项目名称:formidable-forms,代码行数:49,代码来源:FrmXMLHelper.php

示例3: prepare_action

 public function prepare_action($action)
 {
     $action->post_content = (array) FrmAppHelper::maybe_json_decode($action->post_content);
     $action->post_excerpt = sanitize_title($action->post_excerpt);
     $default_values = $this->get_global_defaults();
     // fill default values
     $action->post_content += $default_values;
     foreach ($default_values as $k => $vals) {
         if (is_array($vals) && !empty($vals)) {
             if ('event' == $k && !$this->action_options['force_event'] && !empty($action->post_content[$k])) {
                 continue;
             }
             $action->post_content[$k] = wp_parse_args($action->post_content[$k], $vals);
         }
     }
     if (!is_array($action->post_content['event'])) {
         $action->post_content['event'] = explode(',', $action->post_content['event']);
     }
     return $action;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:20,代码来源:FrmFormAction.php

示例4: get_all

 public function get_all($orderby = 'title', $order = 'ASC', $limit = 99)
 {
     $post_atts = array('post_type' => FrmStylesController::$post_type, 'post_status' => 'publish', 'numberposts' => $limit, 'orderby' => $orderby, 'order' => $order);
     $temp_styles = FrmAppHelper::check_cache(serialize($post_atts), 'frm_styles', $post_atts, 'get_posts');
     if (empty($temp_styles)) {
         global $wpdb;
         // make sure there wasn't a conflict with the query
         $query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type=%s AND post_status=%s ORDER BY post_title ASC LIMIT 99', FrmStylesController::$post_type, 'publish');
         $temp_styles = FrmAppHelper::check_cache('frm_backup_style_check', 'frm_styles', $query, 'get_results');
         if (empty($temp_styles)) {
             // create a new style if there are none
             $new = $this->get_new();
             $new->post_title = $new->post_name = __('Formidable Style', 'formidable');
             $new->menu_order = 1;
             $new = $this->save((array) $new);
             $this->update('default');
             $post_atts['include'] = $new;
             $temp_styles = get_posts($post_atts);
         }
     }
     $default_values = $this->get_defaults();
     $default_style = false;
     $styles = array();
     foreach ($temp_styles as $style) {
         $this->id = $style->ID;
         if ($style->menu_order) {
             if ($default_style) {
                 // only return one default
                 $style->menu_order = 0;
             } else {
                 // check for a default style
                 $default_style = $style->ID;
             }
         }
         $style->post_content = FrmAppHelper::maybe_json_decode($style->post_content);
         // fill default values
         $style->post_content = $this->override_defaults($style->post_content);
         $style->post_content = wp_parse_args($style->post_content, $default_values);
         $styles[$style->ID] = $style;
     }
     if (!$default_style) {
         $default_style = reset($styles);
         $styles[$default_style->ID]->menu_order = 1;
     }
     return $styles;
 }
开发者ID:tshdvs,项目名称:GooseMobile,代码行数:46,代码来源:FrmStyle.php

示例5: import_xml_forms

 public static function import_xml_forms($forms, $imported)
 {
     $frm_form = new FrmForm();
     $frm_field = new FrmField();
     foreach ($forms as $item) {
         $form = array('id' => (int) $item->id, 'form_key' => (string) $item->form_key, 'name' => (string) $item->name, 'description' => (string) $item->description, 'options' => (string) $item->options, 'logged_in' => (int) $item->logged_in, 'is_template' => (int) $item->is_template, 'default_template' => (int) $item->default_template, 'editable' => (int) $item->editable, 'status' => (string) $item->status, 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)));
         $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
         // if template, allow to edit if form keys match, otherwise, creation date must also match
         $edit_query = array('form_key' => $form['form_key'], 'is_template' => $form['is_template']);
         if (!$form['is_template']) {
             $edit_query['created_at'] = $form['created_at'];
         }
         $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
         $this_form = $frm_form->getAll($edit_query, '', 1);
         unset($edit_query);
         if (!empty($this_form)) {
             $form_id = $this_form->id;
             $frm_form->update($form_id, $form);
             $imported['updated']['forms']++;
             $form_fields = $frm_field->getAll(array('fi.form_id' => $form_id), 'field_order');
             $old_fields = array();
             foreach ($form_fields as $f) {
                 $old_fields[$f->id] = $f;
                 $old_fields[$f->field_key] = $f->id;
                 unset($f);
             }
             $form_fields = $old_fields;
             unset($old_fields);
         } else {
             //form does not exist, so create it
             if ($form_id = $frm_form->create($form)) {
                 $imported['imported']['forms']++;
             }
         }
         foreach ($item->field as $field) {
             $f = array('id' => (int) $field->id, 'field_key' => (string) $field->field_key, 'name' => (string) $field->name, 'description' => (string) $field->description, 'type' => (string) $field->type, 'default_value' => FrmAppHelper::maybe_json_decode((string) $field->default_value), 'field_order' => (int) $field->field_order, 'form_id' => (int) $form_id, 'required' => (int) $field->required, 'options' => FrmAppHelper::maybe_json_decode((string) $field->options), 'field_options' => FrmAppHelper::maybe_json_decode((string) $field->field_options));
             if (is_array($f['default_value']) && in_array($f['type'], array('text', 'email', 'url', 'textarea', 'number', 'phone', 'date', 'time', 'image', 'hidden', 'password', 'tag'))) {
                 if (count($f['default_value']) === 1) {
                     $f['default_value'] = '[' . reset($f['default_value']) . ']';
                 } else {
                     $f['default_value'] = reset($f['default_value']);
                 }
             }
             $f = apply_filters('frm_duplicated_field', $f);
             if ($this_form) {
                 // check for field to edit by field id
                 if (isset($form_fields[$f['id']])) {
                     $frm_field->update($f['id'], $f);
                     $imported['updated']['fields']++;
                     unset($form_fields[$f['id']]);
                     //unset old field key
                     if (isset($form_fields[$f['field_key']])) {
                         unset($form_fields[$f['field_key']]);
                     }
                 } else {
                     if (isset($form_fields[$f['field_key']])) {
                         // check for field to edit by field key
                         unset($f['id']);
                         $frm_field->update($form_fields[$f['field_key']], $f);
                         $imported['updated']['fields']++;
                         unset($form_fields[$form_fields[$f['field_key']]]);
                         //unset old field id
                         unset($form_fields[$f['field_key']]);
                         //unset old field key
                     } else {
                         if ($frm_field->create($f)) {
                             // if no matching field id or key in this form, create the field
                             $imported['imported']['fields']++;
                         }
                     }
                 }
             } else {
                 if ($frm_field->create($f)) {
                     $imported['imported']['fields']++;
                 }
             }
             unset($field);
         }
         // Delete any fields attached to this form that were not included in the template
         if (isset($form_fields) && !empty($form_fields)) {
             foreach ($form_fields as $field) {
                 if (is_object($field)) {
                     $frm_field->destroy($field->id);
                 }
                 unset($field);
             }
             unset($form_fields);
         }
         // Update field ids/keys to new ones
         do_action('frm_after_duplicate_form', $form_id, $form);
         $imported['forms'][(int) $item->id] = $form_id;
         unset($form);
         unset($item);
     }
     unset($frm_form);
     unset($frm_field);
     return $imported;
 }
开发者ID:amit0773,项目名称:manaslake,代码行数:98,代码来源:FrmXMLHelper.php

示例6: import_xml_entries

 public static function import_xml_entries($entries, $imported)
 {
     global $frm_duplicate_ids, $wpdb, $frm_field;
     $frm_entry = new FrmEntry();
     $saved_entries = array();
     foreach ($entries as $item) {
         $entry = array('id' => (int) $item->id, 'item_key' => (string) $item->item_key, 'name' => (string) $item->name, 'description' => FrmAppHelper::maybe_json_decode((string) $item->description), 'ip' => (string) $item->ip, 'form_id' => isset($imported['forms'][(int) $item->form_id]) ? $imported['forms'][(int) $item->form_id] : (int) $item->form_id, 'post_id' => isset($imported['posts'][(int) $item->post_id]) ? $imported['posts'][(int) $item->post_id] : (int) $item->post_id, 'user_id' => FrmProAppHelper::get_user_id_param((string) $item->user_id), 'parent_item_id' => (int) $item->parent_item_id, 'is_draft' => (int) $item->is_draft, 'updated_by' => FrmProAppHelper::get_user_id_param((string) $item->updated_by), 'created_at' => (string) $item->created_at, 'updated_at' => (string) $item->updated_at);
         $metas = array();
         foreach ($item->item_meta as $meta) {
             $field_id = (int) $meta->field_id;
             if (is_array($frm_duplicate_ids) && isset($frm_duplicate_ids[$field_id])) {
                 $field_id = $frm_duplicate_ids[$field_id];
             }
             $field = $frm_field->getOne($field_id);
             if (!$field) {
                 continue;
             }
             $metas[$field_id] = FrmAppHelper::maybe_json_decode((string) $meta->meta_value);
             $metas[$field_id] = apply_filters('frm_import_val', $metas[$field_id], $field);
             switch ($field->type) {
                 case 'user_id':
                     $metas[$field_id] = FrmProAppHelper::get_user_id_param($metas[$field_id]);
                     if ($metas[$field_id] && is_numeric($metas[$field_id])) {
                         $entry['frm_user_id'] = $metas[$field_id];
                     }
                     break;
                 case 'file':
                     $metas[$field_id] = self::get_file_id($metas[$field_id]);
                     break;
                 case 'date':
                     $metas[$field_id] = self::get_date($metas[$field_id]);
                     break;
                 case 'data':
                     $metas[$field_id] = self::get_dfe_id($metas[$field_id], $field, $saved_entries, $metas);
                     break;
                 case 'select':
                 case 'checkbox':
                     $metas[$field_id] = self::get_multi_opts($metas[$field_id], $field);
                     break;
             }
             unset($field);
             unset($meta);
         }
         unset($item);
         $entry['item_meta'] = $metas;
         unset($metas);
         // edit entry if the key and created time match
         $editing = $wpdb->get_var($wpdb->prepare("SELECT id FROM {$wpdb->prefix}frm_items WHERE item_key=%s AND created_at=%s", $entry['item_key'], date('Y-m-d H:i:s', strtotime($entry['created_at']))));
         if ($editing) {
             $frm_entry->update($entry['id'], $entry);
             $imported['updated']['items']++;
             $saved_entries[$entry['id']] = $entry['id'];
         } else {
             if ($e = $frm_entry->create($entry)) {
                 $saved_entries[$entry['id']] = $e;
                 $imported['imported']['items']++;
             }
         }
         unset($entry);
     }
     unset($entries);
     return $imported;
 }
开发者ID:amit0773,项目名称:manaslake,代码行数:63,代码来源:FrmProXMLHelper.php


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