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


PHP PerchUtil::json_safe_encode方法代码示例

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


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

示例1: perch_forms_form_handler

function perch_forms_form_handler($SubmittedForm)
{
    if ($SubmittedForm->validate()) {
        $API = new PerchAPI(1.0, 'perch_forms');
        $Forms = new PerchForms_Forms($API);
        $formKey = $SubmittedForm->id;
        $Form = $Forms->find_by_key($formKey);
        if (!is_object($Form)) {
            $data = array();
            $data['formKey'] = $formKey;
            $data['formTemplate'] = $SubmittedForm->templatePath;
            $data['formOptions'] = PerchUtil::json_safe_encode(array('store' => true));
            $attrs = $SubmittedForm->get_form_attributes();
            if ($attrs->label()) {
                $data['formTitle'] = $attrs->label();
            } else {
                $data['formTitle'] = PerchUtil::filename($formKey, false);
            }
            $Form = $Forms->create($data);
        }
        if (is_object($Form)) {
            $Form->process_response($SubmittedForm);
        }
    }
    $Perch = Perch::fetch();
    PerchUtil::debug($Perch->get_form_errors($SubmittedForm->formID));
}
开发者ID:scottbrabazon,项目名称:scottbrabazon.com,代码行数:27,代码来源:runtime.php

示例2: get_search_sql

 public static function get_search_sql($key)
 {
     $db = PerchDB::fetch();
     $encoded_key = str_replace('"', '', PerchUtil::json_safe_encode($key));
     $opts = func_get_arg(1);
     $sql = '   \'' . __CLASS__ . '\' AS source, MATCH(ci.itemSearch) AGAINST(' . $db->pdb($key) . ') AS score, 
             r.regionPage AS col1, ci.itemSearch AS col2, ci.itemJSON AS col3, r.regionOptions AS col4, p.pageNavText AS col5, p.pageTitle AS col6, regionTemplate AS col7, r.regionKey AS col8
             FROM ' . PERCH_DB_PREFIX . 'content_regions r, ' . PERCH_DB_PREFIX . 'content_items ci, ' . PERCH_DB_PREFIX . 'pages p
             WHERE r.regionID=ci.regionID AND r.regionRev=ci.itemRev AND r.pageID=p.pageID AND r.regionPage!=\'*\' AND r.regionSearchable=1 
                 AND (MATCH(ci.itemSearch) AGAINST(' . $db->pdb($key) . ') OR MATCH(ci.itemSearch) AGAINST(' . $db->pdb($encoded_key) . ') )
                 AND r.regionPage LIKE ' . $db->pdb($opts['from-path'] . '%') . ' 
                 ';
     return $sql;
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:14,代码来源:PerchContent_SearchHandler.class.php

示例3: create

 /**
  * Insert a new log into the database, filtering sensitive information
  * and encoding data for storage.
  *
  * @param array $data
  * @return JwActivityLog_Action
  */
 public function create($data)
 {
     // Meta data
     $data['actionDateTime'] = date("Y-m-d H:i:s");
     $data['resourceUrl'] = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
     // Remove sensitive information
     if (isset($data['userAccountData']['userPassword'])) {
         unset($data['userAccountData']['userPassword']);
     }
     if (isset($data['userAccountData']['userHash'])) {
         unset($data['userAccountData']['userHash']);
     }
     // Encode for storage
     $data['userAccountData'] = PerchUtil::json_safe_encode($data['userAccountData']);
     return parent::create($data);
 }
开发者ID:drewm,项目名称:Perch-Activity-Log,代码行数:23,代码来源:JwActivityLog_Actions.class.php

示例4: update_profile

 public function update_profile($SubmittedForm)
 {
     $data = $SubmittedForm->data;
     $out = array();
     $properties = PerchUtil::json_safe_decode($this->memberProperties(), true);
     foreach ($data as $key => $val) {
         if (array_key_exists($key, $this->field_aliases)) {
             $out[$this->field_aliases[$key]] = $val;
             $key = $this->field_aliases[$key];
         }
         if (!in_array($key, $this->static_fields)) {
             $properties[$key] = $val;
         }
     }
     if (isset($out['memberEmail'])) {
         if (!$this->check_email_unique($out['memberEmail'])) {
             unset($out['memberEmail']);
         }
     }
     $out['memberProperties'] = PerchUtil::json_safe_encode($properties);
     $this->update($out);
 }
开发者ID:jaredmedley,项目名称:Perch-Core-Files,代码行数:22,代码来源:PerchMembers_Member.class.php

示例5: register_with_form

 public function register_with_form($SubmittedForm)
 {
     $key = $SubmittedForm->id . (isset($SubmittedForm->form_attributes['type']) ? '.' . $SubmittedForm->form_attributes['type'] : '');
     $Forms = new PerchMembers_Forms($this->api);
     $Form = $Forms->find_or_create($key);
     $do_login = false;
     if (is_object($Form)) {
         $form_settings = PerchUtil::json_safe_decode($Form->formSettings(), true);
         $member = array('memberAuthType' => 'native', 'memberEmail' => '', 'memberPassword' => '', 'memberStatus' => 'pending', 'memberCreated' => date('Y-m-d H:i:s'));
         $data = $SubmittedForm->data;
         $properties = array();
         foreach ($data as $key => $val) {
             if (array_key_exists($key, $this->field_aliases)) {
                 $member[$this->field_aliases[$key]] = $val;
                 $key = $this->field_aliases[$key];
             }
             if (!in_array($key, $this->static_fields)) {
                 $properties[$key] = $val;
             }
         }
         $member['memberProperties'] = PerchUtil::json_safe_encode($properties);
         // Password
         $clear_pwd = $member['memberPassword'];
         if (defined('PERCH_NONPORTABLE_HASHES') && PERCH_NONPORTABLE_HASHES) {
             $portable_hashes = false;
         } else {
             $portable_hashes = true;
         }
         $Hasher = new PasswordHash(8, $portable_hashes);
         $member['memberPassword'] = $Hasher->HashPassword($clear_pwd);
         $Member = $this->create($member);
         $member = array('memberAuthID' => $Member->memberID());
         if (isset($form_settings['moderate']) && $form_settings['moderate'] == '1') {
             if (isset($form_settings['moderator_email'])) {
                 $this->_email_moderator($form_settings['moderator_email'], $Member);
             }
         } else {
             $member['memberStatus'] = 'active';
             $do_login = true;
         }
         $Member->update($member);
         if (isset($form_settings['default_tags']) && $form_settings['default_tags'] != '') {
             $tags = explode(',', $form_settings['default_tags']);
             if (PerchUtil::count($tags)) {
                 foreach ($tags as $tagDisplay) {
                     $expiry = false;
                     if (strpos($tagDisplay, '|') > 0) {
                         $parts = explode('|', $tagDisplay);
                         $tagDisplay = $parts[0];
                         $expiry = $parts[1];
                     }
                     $tagDisplay = trim($tagDisplay);
                     $tag = PerchUtil::urlify($tagDisplay);
                     $Member->add_tag($tag, $tagDisplay, $expiry);
                 }
             }
         }
         if (is_object($Member) && $do_login) {
             $key = base64_encode('login:perch_members:login/login_form.html');
             $data = array('email' => $Member->memberEmail(), 'password' => $clear_pwd, 'pos');
             $files = array();
             $Perch = Perch::fetch();
             $Perch->dispatch_form($key, $data, $files);
         }
         if (is_object($Member) && $clear_pwd === '__auto__') {
             $Member->update(array('memberPassword' => null));
         }
     }
 }
开发者ID:jaredmedley,项目名称:Perch-Core-Files,代码行数:69,代码来源:PerchMembers_Members.class.php

示例6: array

    $assetID = $ids[0];
    $Asset = $Assets->find($assetID);
    $Asset->reindex();
    if (PerchUtil::count($ids)) {
        if (!PerchSession::is_set('resourceIDs')) {
            $logged_ids = array();
            PerchSession::set('resourceIDs', $logged_ids);
        } else {
            $logged_ids = PerchSession::get('resourceIDs');
        }
        foreach ($ids as $assetID) {
            if (!in_array($assetID, $logged_ids)) {
                $logged_ids[] = $assetID;
            }
        }
        PerchSession::set('resourceIDs', $logged_ids);
    }
    if ($is_image) {
        $result = $Assets->get_resize_profile($Asset->id(), $width, $height, $crop ? '1' : '0', false, $density);
        if ($result) {
            echo stripslashes(PerchUtil::json_safe_encode(array('filelink' => $result['web_path'])));
        } else {
            echo stripslashes(PerchUtil::json_safe_encode(array('filelink' => $Asset->web_path())));
        }
        exit;
    } else {
        echo stripslashes(PerchUtil::json_safe_encode(array('filelink' => $Asset->web_path())));
        exit;
    }
}
echo 'FAIL';
开发者ID:jimcurran,项目名称:bdmusichub,代码行数:31,代码来源:upload.php

示例7: get_posted_content

 public function get_posted_content($Template, $Factory, $Item = false, $include_repeaters = true, $json_encode = true)
 {
     $data = array();
     $prev = false;
     if ($Item) {
         $prev = $Item->to_array();
     }
     $dynamic_fields = $this->receive_from_template_fields($Template, $prev, $Factory, $Item, true, false);
     $static_fields = array();
     // fetch out static fields
     foreach ($Factory->static_fields as $field) {
         if (array_key_exists($field, $dynamic_fields)) {
             //($dynamic_fields[$field])) {
             if (is_array($dynamic_fields[$field])) {
                 if (isset($dynamic_fields[$field]['_default'])) {
                     $data[$field] = trim($dynamic_fields[$field]['_default']);
                 }
                 if (isset($dynamic_fields[$field]['processed'])) {
                     $data[$field] = trim($dynamic_fields[$field]['processed']);
                 }
             }
             if (!isset($data[$field])) {
                 $data[$field] = $dynamic_fields[$field];
             }
             unset($dynamic_fields[$field]);
         } else {
             if (isset($_POST[$field])) {
                 if (!is_array($_POST[$field])) {
                     $data[$field] = trim(PerchUtil::safe_stripslashes($_POST[$field]));
                 } else {
                     $data[$field] = $_POST[$field];
                 }
             }
         }
     }
     if (!$json_encode) {
         return $dynamic_fields;
     }
     $data[$Factory->dynamic_fields_column] = PerchUtil::json_safe_encode($dynamic_fields);
     return $data;
 }
开发者ID:jaredmedley,项目名称:Perch-Core-Files,代码行数:41,代码来源:PerchAPI_Form.class.php

示例8: set_options

 /**
  * Set region options
  *
  * @param string $options 
  * @return void
  * @author Drew McLellan
  */
 public function set_options($options)
 {
     $existing = $this->get_options();
     if (!is_array($existing)) {
         $existing = array();
     }
     $opts = array_merge($existing, $options);
     $data = array();
     $data['regionOptions'] = PerchUtil::json_safe_encode($opts);
     $this->update($data);
     // clear cache
     $this->options = false;
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:20,代码来源:PerchContent_Region.class.php

示例9: array

$Template = $API->get('Template');
$Template->set('blog/section.html', 'blog');
$Form->handle_empty_block_generation($Template);
$tags = $Template->find_all_tags_and_repeaters();
$Form->require_field('sectionTitle', 'Required');
$Form->set_required_fields_from_template($Template, $details);
if ($Form->submitted()) {
    $postvars = array('sectionTitle');
    $data = $Form->receive($postvars);
    $data['blogID'] = $Blog->id();
    $prev = false;
    if (isset($details['sectionDynamicFields'])) {
        $prev = PerchUtil::json_safe_decode($details['sectionDynamicFields'], true);
    }
    $dynamic_fields = $Form->receive_from_template_fields($Template, $prev, $Sections, $Section);
    $data['sectionDynamicFields'] = PerchUtil::json_safe_encode($dynamic_fields);
    if (!is_object($Section)) {
        $data['sectionSlug'] = PerchUtil::urlify($data['sectionTitle']);
        $Section = $Sections->create($data);
        PerchUtil::redirect($API->app_path() . '/sections/edit/?id=' . $Section->id() . '&created=1');
    }
    $Section->update($data);
    if (is_object($Section)) {
        $message = $HTML->success_message('Your section has been successfully edited. Return to %ssection listing%s', '<a href="' . $API->app_path() . '/sections">', '</a>');
    } else {
        $message = $HTML->failure_message('Sorry, that section could not be edited.');
    }
    // clear the caches
    PerchBlog_Cache::expire_all();
    $details = $Section->to_array();
}
开发者ID:jimcurran,项目名称:bdmusichub,代码行数:31,代码来源:section.edit.pre.php

示例10: PerchAPI

if (!$CurrentUser->has_priv('content.pages.attributes')) {
    PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/');
}
// Page attributes
$API = new PerchAPI(1.0, 'perch_pages');
$Page->api($API);
$Template = $API->get('Template');
$status = $Template->set('pages/attributes/' . $Page->pageAttributeTemplate(), 'pages');
if ($status == 404) {
    $Alert->set('notice', PerchLang::get('The page attribute template (%s) could not be found.', '<code>templates/pages/attributes/' . $Page->pageAttributeTemplate() . '</code>'));
}
$details = $Page->to_array();
$Form = $API->get('Form');
$Form->handle_empty_block_generation($Template);
$req = array();
$req['pageTitle'] = "Required";
$req['pageNavText'] = "Required";
$Form->set_required($req);
$Form->set_required_fields_from_template($Template, $details, array('pageTitle', 'pageNavText'));
if ($Form->posted() && $Form->validate()) {
    $postvars = array('pageTitle', 'pageNavText');
    $data = $Form->receive($postvars);
    $existing = PerchUtil::json_safe_decode($Page->pageAttributes(), true);
    $dynamic_fields = $Form->receive_from_template_fields($Template, $existing, $Pages, $Page);
    $data['pageAttributes'] = PerchUtil::json_safe_encode($dynamic_fields);
    $Page->update($data);
    // log resources
    $Page->log_resources();
    $Alert->set('success', PerchLang::get('Successfully updated'));
    $details = $Page->to_array();
}
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:31,代码来源:page.details.pre.php

示例11: array

$view = 'grid';
$filters = array();
if (isset($_GET['filter']) && $_GET['filter'] == 'new') {
    $filters['new'] = true;
}
if (isset($_GET['app']) && $_GET['app'] != '') {
    $filters['app'] = $_GET['app'];
}
if (isset($_GET['type']) && $_GET['type'] != '') {
    $filters['type'] = $_GET['type'];
}
if (isset($_GET['bucket']) && $_GET['bucket'] != '') {
    $filters['bucket'] = $_GET['bucket'];
}
if (isset($_GET['date']) && $_GET['date'] != '') {
    $filters['date'] = $_GET['date'];
}
if (isset($_GET['q']) && $_GET['q'] != '') {
    $term = $_GET['q'];
    $assets = $Assets->search($term, $filters);
} else {
    $assets = $Assets->get_filtered_for_admin($Paging, $filters);
}
$out = array();
if (PerchUtil::count($assets)) {
    foreach ($assets as $Asset) {
        $out[] = $Asset->to_api_array();
    }
}
echo PerchUtil::json_safe_encode(array('assets' => $out));
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:30,代码来源:get-assets.php

示例12: write_to_lang_file

 private function write_to_lang_file($items)
 {
     if (!is_array($this->translations)) {
         $this->translations = array('lang' => $this->lang);
     }
     $out = array_merge($this->translations, $items);
     $tidy_json = true;
     $json = PerchUtil::json_safe_encode($out, $tidy_json);
     if (is_writable($this->lang_file)) {
         file_put_contents($this->lang_file, $json);
     }
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:12,代码来源:PerchLang.class.php

示例13: header

<?php

include __DIR__ . '/../inc/pre_config.php';
include __DIR__ . '/../../config/config.php';
include PERCH_CORE . '/inc/loader.php';
$Perch = PerchAdmin::fetch();
include PERCH_CORE . '/inc/auth_light.php';
header('Content-Type: application/javascript');
echo "Perch.Privs.init(\n\t";
echo PerchUtil::json_safe_encode($CurrentUser->get_privs());
echo ');';
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:11,代码来源:js_privs.php

示例14: array

}
$Template = $API->get('Template');
$Template->set('events/category.html', 'events');
$Form->handle_empty_block_generation($Template);
$tags = $Template->find_all_tags_and_repeaters();
$Form->require_field('categoryTitle', 'Required');
$Form->set_required_fields_from_template($Template, $details);
if ($Form->submitted()) {
    $postvars = array('categoryTitle');
    $data = $Form->receive($postvars);
    $prev = false;
    if (isset($details['categoryDynamicFields'])) {
        $prev = PerchUtil::json_safe_decode($details['categoryDynamicFields'], true);
    }
    $dynamic_fields = $Form->receive_from_template_fields($Template, $prev, $Categories, $Category);
    $data['categoryDynamicFields'] = PerchUtil::json_safe_encode($dynamic_fields);
    if (!is_object($Category)) {
        $data['categorySlug'] = PerchUtil::urlify($data['categoryTitle']);
        $Category = $Categories->create($data);
        PerchUtil::redirect($API->app_path() . '/categories/edit/?id=' . $Category->id() . '&created=1');
    }
    $Category->update($data);
    if (is_object($Category)) {
        $message = $HTML->success_message('Your category has been successfully edited. Return to %scategory listing%s', '<a href="' . $API->app_path() . '/categories">', '</a>');
    } else {
        $message = $HTML->failure_message('Sorry, that category could not be edited.');
    }
    // clear the caches
    PerchEvents_Cache::expire_all();
    $details = $Category->to_array();
}
开发者ID:jimcurran,项目名称:bdmusichub,代码行数:31,代码来源:category.edit.pre.php

示例15: import_from_wp


//.........这里部分代码省略.........
             }
         }
         foreach ($item->children('content', true) as $tag) {
             $tagName = $tag->getName();
             switch ($tagName) {
                 case 'encoded':
                     $raw = (string) $tag;
                     if ($format == 'textile') {
                         $html = PerchUtil::text_to_html($raw);
                         $post['postDescRaw'] = $raw;
                         $post['postDescHTML'] = $html;
                     } else {
                         $post['postDescRaw'] = $raw;
                         $post['postDescHTML'] = $raw;
                     }
                     break;
             }
         }
         foreach ($item->children('excerpt', true) as $tag) {
             $tagName = $tag->getName();
             switch ($tagName) {
                 case 'encoded':
                     $raw = (string) $tag;
                     $html = PerchUtil::text_to_html($raw);
                     $fields = array();
                     $fields['excerpt'] = array();
                     if ($format == 'textile') {
                         $fields['excerpt']['raw'] = $raw;
                         $fields['excerpt']['processed'] = $html;
                     } else {
                         $fields['excerpt']['raw'] = $html;
                         $fields['excerpt']['processed'] = $html;
                     }
                     $post['postDynamicFields'] = PerchUtil::json_safe_encode($fields);
                     break;
             }
         }
         // Callbacks
         if ($callback) {
             $post = call_user_func($callback, $post, $Template);
         }
         // Section
         $post['sectionID'] = $sectionID;
         // Create the post
         $Post = $Posts->create($post, $Template);
         if (is_object($Post)) {
             $out[] = array('type' => 'success', 'messages' => array('Post ' . $Post->postTitle(), 'Successfully imported'));
             // CATEGORIES AND TAGS
             $Categories = new PerchCategories_Categories();
             $Tags = new PerchBlog_Tags($this->api);
             $postTags = array();
             $cat_ids = array();
             foreach ($item->category as $category) {
                 $attributes = $category->attributes();
                 $slug = (string) $attributes['nicename'];
                 $label = (string) $category;
                 switch ((string) $attributes['domain']) {
                     case 'post_tag':
                         $Tag = $Tags->find_or_create($slug, $label);
                         if (is_object($Tag)) {
                             $postTags[] = $Tag->tagSlug();
                             $out[] = array('type' => 'success', 'messages' => array('Tag ' . $Tag->tagSlug(), 'Successfully imported'));
                         }
                         break;
                     case 'category':
                         PerchUtil::debug("Find or create {$slug}", 'notice');
开发者ID:jimcurran,项目名称:bdmusichub,代码行数:67,代码来源:PerchBlog_Util.class.php


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