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


PHP PerchUtil::bool_val方法代码示例

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


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

示例1: subscribe_from_form

 public function subscribe_from_form($Form)
 {
     $Settings = $this->api->get('Settings');
     $api_key = $Settings->get('perch_mailchimp_api_key')->settingValue();
     $list_id = $Settings->get('perch_mailchimp_list_id')->settingValue();
     $merge_vars = array();
     $groupings = array();
     $confirmed = false;
     $double_optin = true;
     $send_welcome = true;
     $update_existing = true;
     $replace_interests = false;
     $FormTag = $Form->get_form_attributes();
     if ($FormTag->is_set('double_optin')) {
         $double_optin = $FormTag->double_optin();
     }
     if ($FormTag->is_set('send_welcome')) {
         $send_welcome = $FormTag->send_welcome();
     }
     $attr_map = $Form->get_attribute_map('mailer');
     if (PerchUtil::count($attr_map)) {
         foreach ($attr_map as $fieldID => $merge_var) {
             switch ($merge_var) {
                 case 'email':
                     $email = $Form->data[$fieldID];
                     break;
                 case 'confirm_subscribe':
                     $confirmed = PerchUtil::bool_val($Form->data[$fieldID]);
                     break;
                 default:
                     $merge_vars[$merge_var] = $Form->data[$fieldID];
                     break;
             }
         }
     }
     if ($confirmed) {
         $MailChimp = new MailChimp($api_key);
         $result = $MailChimp->call('lists/subscribe', array('id' => $list_id, 'email' => array('email' => $email), 'merge_vars' => $merge_vars, 'double_optin' => $double_optin, 'update_existing' => $update_existing, 'replace_interests' => $replace_interests, 'send_welcome' => $send_welcome));
         return $result;
     }
     return false;
 }
开发者ID:connor-baer,项目名称:waterford-website,代码行数:42,代码来源:PerchMailchimp_Subscribers.class.php

示例2: PerchContent_Pages

<?php

$Pages = new PerchContent_Pages();
$Regions = new PerchContent_Regions();
$expand_list = array(0);
// Find new pages and initialise
$Pages->order_new_pages();
// Collapse list?
$do_list_collapse = $Settings->get('content_collapseList')->val();
$Perch->add_javascript_block("Perch.Apps.Content.settings = { 'collapseList':" . (PerchUtil::bool_val($do_list_collapse) ? 'true' : 'false') . " };");
// default state
$filter = 'all';
$do_regions = false;
$show_shared = true;
if (isset($_GET['filter']) && $_GET['filter'] == 'new') {
    $filter = 'new';
    $do_regions = true;
    $do_list_collapse = false;
    $show_shared = false;
}
if (isset($_GET['template']) && $_GET['template'] != '') {
    $filter = 'template';
    $do_regions = true;
    $do_list_collapse = false;
    $show_shared = true;
    $template_to_filter = urldecode($_GET['template']);
}
// Get pages
if ($do_list_collapse) {
    $expand_list = array(0);
    // get the existing expand list
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:31,代码来源:list.pre.php

示例3: old_fields_from_template

 public function old_fields_from_template($Template, $details = array(), $seen_tags = array(), $include_repeaters = true)
 {
     if ($include_repeaters) {
         $tags = $Template->find_all_tags_and_repeaters();
     } else {
         $tags = $Template->find_all_tags();
     }
     $Form = $this;
     $out = '';
     if (PerchUtil::count($tags)) {
         foreach ($tags as $tag) {
             $item_id = 'perch_' . $tag->id();
             $raw_id = 'perch_' . $tag->id() . '_raw';
             $tag->set('input_id', $item_id);
             $tag->set('post_prefix', 'perch_');
             if (!in_array($tag->id(), $seen_tags) && $tag->type() != 'hidden') {
                 if ($tag->type() == 'slug' && !$tag->editable()) {
                     continue;
                 }
                 if ($tag->divider_before()) {
                     $out .= '<h2 class="divider">' . PerchUtil::html($tag->divider_before()) . '</h2>';
                 }
                 $out .= '<div class="field ' . $Form->error($item_id, false) . '">';
                 $label_text = PerchUtil::html($tag->label());
                 if ($tag->type() == 'textarea') {
                     if (PerchUtil::bool_val($tag->textile()) == true) {
                         $label_text .= ' <span><a href="' . PERCH_LOGINPATH . '/core/help/textile" class="assist">Textile</a></span>';
                     }
                     if (PerchUtil::bool_val($tag->markdown()) == true) {
                         $label_text .= ' <span><a href="' . PERCH_LOGINPATH . '/core/help/markdown" class="assist">Markdown</a></span>';
                     }
                 }
                 $Form->disable_html_encoding();
                 $out .= $Form->label($item_id, $label_text, '', false, false);
                 $Form->enable_html_encoding();
                 $FieldType = PerchFieldTypes::get($tag->type(), $Form, $tag, $tags, $this->app_id);
                 $out .= $FieldType->render_inputs($details);
                 if ($tag->help()) {
                     $out .= $Form->field_help($tag->help());
                 }
                 $out .= '</div>';
                 if ($tag->divider_after()) {
                     $out .= '<h2 class="divider">' . PerchUtil::html($tag->divider_after()) . '</h2>';
                 }
                 $seen_tags[] = $tag->id();
             }
         }
     }
     return $out;
 }
开发者ID:jaredmedley,项目名称:Perch-Core-Files,代码行数:50,代码来源:PerchAPI_Form.class.php

示例4: render_related

 protected function render_related($type, $opening_tag, $condition_contents, $exact_match, $template_contents, $content_vars, $index_in_group)
 {
     $Tag = new PerchXMLTag($opening_tag);
     $out = '';
     if ($Tag->suppress()) {
         return str_replace($exact_match, '', $template_contents);
     }
     if (is_array($content_vars) && isset($content_vars[$Tag->id()]) && PerchUtil::count($content_vars[$Tag->id()])) {
         if (!class_exists('PerchContent_Collections', false)) {
             include_once PERCH_CORE . '/runway/apps/content/PerchContent_Collections.class.php';
             include_once PERCH_CORE . '/runway/apps/content/PerchContent_Collection.class.php';
             include_once PERCH_CORE . '/runway/apps/content/PerchContent_CollectionItems.class.php';
             include_once PERCH_CORE . '/runway/apps/content/PerchContent_CollectionItem.class.php';
         }
         $Collections = $this->_get_cached_object('PerchContent_Collections');
         $value = $Collections->get_data_from_ids_runtime($Tag->collection(), $content_vars[$Tag->id()], $Tag->sort());
         $RelatedTemplate = new PerchTemplate(false, $this->namespace);
         $RelatedTemplate->load($condition_contents);
         if (PerchUtil::bool_val($Tag->scope_parent())) {
             $vars_for_cat = array();
             if (PerchUtil::count($content_vars)) {
                 foreach ($content_vars as $key => $val) {
                     if ($key != $Tag->id() && $key != 'itemJSON') {
                         $vars_for_cat['parent.' . $key] = $val;
                     }
                 }
             }
             $vars_for_cat = array_merge($vars_for_cat, $content_vars[$Tag->id()]);
             foreach ($value as &$item) {
                 $item = array_merge($item, $vars_for_cat);
             }
         }
         $out = $RelatedTemplate->render_group($value, true);
     } else {
         if (strpos($condition_contents, 'perch:noresults')) {
             $s = '/<perch:noresults[^>]*>(.*?)<\\/perch:noresults>/s';
             $count = preg_match_all($s, $condition_contents, $matches, PREG_SET_ORDER);
             if ($count > 0) {
                 foreach ($matches as $match) {
                     $out .= $match[1];
                 }
             }
         }
     }
     return str_replace($exact_match, $out, $template_contents);
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:46,代码来源:PerchTemplate.class.php

示例5: get_raw

 public function get_raw($post = false, $Item = false)
 {
     if ($post === false) {
         $post = $_POST;
     }
     $id = $this->Tag->id();
     if (isset($post[$id])) {
         $raw = trim($post[$id]);
         $flang = 'plain';
         if ($this->Tag->html()) {
             $flang = 'html';
         }
         $value = PerchUtil::safe_stripslashes($raw);
         // Strip HTML by default
         if (!is_array($value) && PerchUtil::bool_val($this->Tag->html()) == false) {
             $value = PerchUtil::html($value);
             $value = strip_tags($value);
         }
         $Markdown = new PerchParsedown();
         $value = $Markdown->smartypants($value);
         $flang = 'smartypants';
         $store = array('_flang' => $flang, 'raw' => $raw, 'processed' => $value);
         $this->raw_item = $store;
         return $this->raw_item;
     }
     return null;
 }
开发者ID:jaredmedley,项目名称:Perch-Core-Files,代码行数:27,代码来源:PerchFieldTypes.class.php

示例6: _replace_form_tags

 private function _replace_form_tags($template, $opening_tag, $closing_tag)
 {
     $Perch = Perch::fetch();
     $OpeningTag = new PerchXMLTag($opening_tag);
     if ($OpeningTag->prefix()) {
         if ($OpeningTag->prefix() == 'none') {
             $this->field_prefix = '';
         } else {
             $this->field_prefix = $OpeningTag->prefix() . '_';
         }
     } else {
         $Perch->form_count++;
         $this->field_prefix = 'form' . $Perch->form_count . '_';
     }
     $attrs = array();
     $attrs['id'] = $this->field_prefix . $OpeningTag->id();
     $attrs['class'] = $OpeningTag->class();
     $attrs['action'] = $OpeningTag->action();
     $attrs['method'] = $OpeningTag->method();
     $attrs['role'] = $OpeningTag->role();
     $attrs['name'] = $OpeningTag->name();
     $attrs['autocomplete'] = $OpeningTag->autocomplete();
     $aria = $OpeningTag->search_attributes_for('aria-');
     if (PerchUtil::count($aria)) {
         $attrs = array_merge($attrs, $aria);
     }
     $html5data = $OpeningTag->search_attributes_for('data-');
     if (PerchUtil::count($html5data)) {
         $attrs = array_merge($attrs, $html5data);
     }
     $this->form_id = $OpeningTag->id();
     $this->handling_app = $OpeningTag->app();
     $this->template_path = $OpeningTag->template();
     $this->action = $OpeningTag->action();
     $this->app = $OpeningTag->app();
     $this->method = $OpeningTag->method();
     if (PERCH_HTML5 && $OpeningTag->novalidate()) {
         $attrs['novalidate'] = 'novalidate';
     }
     if (PERCH_RUNWAY) {
         if (!$attrs['action']) {
             $Runway = PerchRunway::fetch();
             $attrs['action'] = $Runway->get_page();
         }
     } else {
         if (!$attrs['action']) {
             $attrs['action'] = $Perch->get_page_as_set(true);
         }
     }
     // submit via ssl?
     if (PERCH_SSL && $OpeningTag->ssl() && PerchUtil::bool_val($OpeningTag->ssl())) {
         $attrs['action'] = PerchUtil::url_to_ssl($attrs['action']);
     }
     if (!$attrs['method']) {
         $attrs['method'] = 'post';
     }
     $this->form_key = base64_encode($this->form_id . ':' . $this->handling_app . ':' . $this->template_path . ':' . time());
     // Does it have file fields?
     $s = '/(<perch:input[^>]*type="(file|image)"[^>]*>)/s';
     if (preg_match($s, $template)) {
         $attrs['enctype'] = 'multipart/form-data';
     }
     $new_opening_tag = PerchXMLTag::create('form', 'opening', $attrs);
     $template = str_replace($opening_tag, $new_opening_tag, $template);
     $new_closing_tag = PerchXMLTag::create('form', 'closing');
     $template = str_replace($closing_tag, $new_closing_tag, $template);
     return $template;
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:68,代码来源:PerchTemplatedForm.class.php

示例7: display_item_fields


//.........这里部分代码省略.........
                         }
                     }
                     foreach ($subitems as $subitem) {
                         $edit_prefix = 'perch_' . $repeater_id . '_' . $repeater_i . '_';
                         foreach ($subitem as $key => $val) {
                             $subitem[$edit_prefix . $key] = $val;
                         }
                         echo '<div class="repeated-item">';
                         echo '<div class="index"><span>' . ($repeater_i + 1) . '</span><span class="icon"></span></div>';
                         echo '<div class="repeated-fields">';
                         PerchContent_Util::display_item_fields($tag->tags, $repeater_id . '_' . $repeater_i, $subitem, $Page, $Form, $Template);
                         echo '<input type="hidden" name="perch_' . ($repeater_id . '_' . $repeater_i) . '_present" class="present" value="1" />';
                         echo '<input type="hidden" name="perch_' . ($repeater_id . '_' . $repeater_i) . '_prevpos" value="' . $repeater_i . '" />';
                         echo '</div>';
                         echo '<div class="rm"></div>';
                         echo '</div>';
                         $repeater_i++;
                     }
                 }
                 $spare = true;
                 if ($tag->max() && $repeater_i - 1 >= (int) $tag->max()) {
                     $spare = false;
                 }
                 if ($spare) {
                     // And one spare
                     echo '<div class="repeated-item spare">';
                     echo '<div class="index icon"><span>' . ($repeater_i + 1) . '</span><span class="icon"></span></div>';
                     echo '<div class="repeated-fields">';
                     PerchContent_Util::display_item_fields($tag->tags, $repeater_id . '_' . $repeater_i, array(), $Page, $Form, $Template);
                     echo '<input type="hidden" name="perch_' . ($repeater_id . '_' . $repeater_i) . '_present" class="present" value="1" />';
                     echo '</div>';
                     echo '<div class="rm"></div>';
                     echo '</div>';
                     echo '</div>';
                     // .repeated
                     // footer
                     echo '<div class="repeater-footer">';
                     echo '<input type="hidden" name="perch_' . $repeater_id . '_count" value="0" class="count" />';
                     echo '</div>';
                 }
                 echo '</div>';
                 if ($tag->divider_after()) {
                     echo '<h2 class="divider">' . PerchUtil::html($tag->divider_after()) . '</h2>';
                 }
             } elseif ($tag->type() == 'PerchBlocks') {
                 if ($tag->divider_before()) {
                     echo '<h2 class="divider">' . PerchUtil::html($tag->divider_before()) . '</h2>';
                 }
                 if ($tag->notes_before()) {
                     echo '<p class="formnotes">' . PerchUtil::html($tag->notes_before()) . '</p>';
                 }
                 echo PerchContent_Util::display_blocks($tags, $id, $item, $Page, $Form, $Template, $blocks_link_builder);
                 if ($tag->divider_after()) {
                     echo '<h2 class="divider">' . PerchUtil::html($tag->divider_after()) . '</h2>';
                 }
             } else {
                 if ($tag->divider_before()) {
                     echo '<h2 class="divider">' . PerchUtil::html($tag->divider_before()) . '</h2>';
                 }
                 if ($tag->notes_before()) {
                     echo '<p class="formnotes">' . PerchUtil::html($tag->notes_before()) . '</p>';
                 }
                 echo '<div class="field ' . $Form->error($item_id, false) . '">';
                 echo '<div class="fieldtbl">';
                 $label_text = PerchUtil::html($tag->label());
                 if ($tag->type() == 'textarea') {
                     if (PerchUtil::bool_val($tag->textile()) == true) {
                         $label_text .= ' <span><a href="' . PERCH_LOGINPATH . '/core/help/textile" class="assist">Textile</a></span>';
                     }
                     if (PerchUtil::bool_val($tag->markdown()) == true) {
                         $label_text .= ' <span><a href="' . PERCH_LOGINPATH . '/core/help/markdown" class="assist">Markdown</a></span>';
                     }
                 }
                 $Form->disable_html_encoding();
                 echo '<div class="fieldlbl">' . $Form->label($item_id, $label_text, '', false, false) . '</div>';
                 $Form->enable_html_encoding();
                 $FieldType = PerchFieldTypes::get($tag->type(), $Form, $tag, false, $Form->app_id);
                 echo '<div class="field-wrap">';
                 echo $FieldType->render_inputs($item);
                 if ($tag->help()) {
                     echo $Form->translated_hint($tag->help());
                 }
                 echo '</div>';
                 echo '</div>';
                 echo '</div>';
                 if ($tag->divider_after()) {
                     echo '<h2 class="divider">' . PerchUtil::html($tag->divider_after()) . '</h2>';
                 }
             }
             $seen_tags[] = $tag->id();
         } else {
             if (!in_array($tag->id(), $seen_tags) && $tag->edit_control()) {
                 // Hidden fields for editing purposes.
                 $FieldType = PerchFieldTypes::get('editcontrol', $Form, $tag, false, $Form->app_id);
                 echo $FieldType->render_inputs($item);
                 $seen_tags[] = $tag->id();
             }
         }
     }
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:101,代码来源:PerchContent_Util.class.php

示例8: subscribe_from_form

 public function subscribe_from_form(PerchAPI_SubmittedForm $SubmittedForm)
 {
     $listIDs = [];
     $merge_vars = [];
     $interests = [];
     $confirmed = false;
     $status = 'subscribed';
     $FormTag = $SubmittedForm->get_form_attributes();
     if ($FormTag->is_set('double_optin')) {
         if ($FormTag->double_optin()) {
             $status = 'pending';
         }
     }
     $attr_map = $SubmittedForm->get_attribute_map('mailer');
     if (PerchUtil::count($attr_map)) {
         foreach ($attr_map as $fieldID => $merge_var) {
             switch ($merge_var) {
                 case 'list':
                     if (isset($SubmittedForm->data[$fieldID])) {
                         $listIDs[] = $SubmittedForm->data[$fieldID];
                     }
                     break;
                 case 'email':
                     $email = $SubmittedForm->data[$fieldID];
                     break;
                 case 'confirm_subscribe':
                     $confirmed = PerchUtil::bool_val($SubmittedForm->data[$fieldID]);
                     break;
                 case 'interests':
                     $interests[$SubmittedForm->data[$fieldID]] = true;
                     break;
                 default:
                     $merge_vars[$merge_var] = $SubmittedForm->data[$fieldID];
                     break;
             }
         }
     }
     if (PerchUtil::count($listIDs)) {
         $data = [];
         $data['email_address'] = $email;
         $data['status'] = $status;
         if (PerchUtil::count($merge_vars)) {
             $data['merge_fields'] = $merge_vars;
         }
         if (PerchUtil::count($interests)) {
             $data['interests'] = $interests;
         }
         if ($confirmed) {
             $Lists = new PerchMailChimp_Lists($this->api);
             $MailChimpAPI = $this->get_api_instance();
             foreach ($listIDs as $listMailChimpID) {
                 $List = $Lists->get_one_by('listMailChimpID', $listMailChimpID);
                 if (is_object($List)) {
                     PerchUtil::debug('Subscribing to: ' . $List->listTitle());
                     $listID = $listMailChimpID;
                     $result = $MailChimpAPI->post("lists/{$listID}/members", $data);
                     if ($MailChimpAPI->success()) {
                     } else {
                         PerchUtil::debug($MailChimpAPI->getLastResponse());
                     }
                 }
             }
         }
     }
 }
开发者ID:jimcurran,项目名称:bdmusichub,代码行数:65,代码来源:PerchMailChimp_Subscribers.class.php


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