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


PHP PerchUtil::excerpt方法代码示例

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


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

示例1: replace_content_tags

 public function replace_content_tags($namespace, $content_vars, $contents)
 {
     if (is_array($content_vars)) {
         // Find all matching tags
         $s = '#<perch:' . $namespace . '[^>]*/>#';
         $count = preg_match_all($s, $contents, $matches, PREG_SET_ORDER);
         if ($count) {
             foreach ($matches as $match) {
                 $match = $match[0];
                 $tag = new PerchXMLTag($match);
                 if ($tag->suppress) {
                     $contents = str_replace($match, '', $contents);
                 } else {
                     if (isset($content_vars[$tag->id])) {
                         $value = $content_vars[$tag->id];
                     } else {
                         $replacement = '';
                         if ($tag->else()) {
                             $replacement = $tag->else();
                         }
                         $contents = str_replace($match, $replacement, $contents);
                         continue;
                     }
                     $field_is_markup = false;
                     if ($tag->type) {
                         $FieldType = PerchFieldTypes::get($tag->type, false, $tag);
                         $modified_value = $FieldType->get_processed($value);
                         $field_is_markup = $FieldType->processed_output_is_markup;
                     } else {
                         $modified_value = $value;
                     }
                     // check for 'rewrite' attribute
                     if ($tag->rewrite) {
                         $modified_value = $this->_rewrite($tag, $modified_value);
                     }
                     // check for 'format' attribute
                     if ($tag->format) {
                         $modified_value = $this->_format($tag, $modified_value);
                     }
                     // check for 'replace' strings
                     if ($tag->replace) {
                         $pairs = explode(',', $tag->replace);
                         if (PerchUtil::count($pairs)) {
                             foreach ($pairs as $pair) {
                                 $pairparts = explode('|', $pair);
                                 if (isset($pairparts[0]) && isset($pairparts[1])) {
                                     $modified_value = str_replace(trim($pairparts[0]), trim($pairparts[1]), $modified_value);
                                 }
                             }
                         }
                     }
                     // Urlify
                     if ($tag->urlify) {
                         $modified_value = PerchUtil::urlify($modified_value);
                     }
                     // Trim by chars
                     if ($tag->chars) {
                         if (strlen($modified_value) > (int) $tag->chars) {
                             $modified_value = PerchUtil::excerpt_char($modified_value, (int) $tag->chars, false, true, $tag->append);
                         }
                     }
                     // Trim by words
                     if ($tag->words) {
                         $modified_value = PerchUtil::excerpt($modified_value, (int) $tag->words, false, true, $tag->append);
                     }
                     // Hash
                     if ($tag->hash == 'md5') {
                         $modified_value = md5($modified_value);
                     }
                     // check that what we've got isn't an array. If it is, try your best to get a good string.
                     if (is_array($modified_value)) {
                         if (isset($modified_value['_default'])) {
                             $modified_value = (string) $modified_value['_default'];
                         } else {
                             if (isset($modified_value['processed'])) {
                                 $modified_value = (string) $modified_value['processed'];
                             } else {
                                 $modified_value = (string) array_shift($modified_value);
                             }
                         }
                     }
                     // Strip tags
                     if ($tag->striptags) {
                         $modified_value = strip_tags($modified_value);
                     }
                     // Append
                     if (!$tag->words && !$tag->chars && $tag->append) {
                         $modified_value .= $tag->append;
                     }
                     // URL Encode
                     if ($tag->urlencode) {
                         $modified_value = rawurlencode($modified_value);
                     }
                     // Escape quotes
                     if ($tag->escape) {
                         $modified_value = PerchUtil::html($modified_value, true, false);
                         $field_is_markup = true;
                     }
                     // check encoding
                     if ($this->autoencode && !$field_is_markup) {
//.........这里部分代码省略.........
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:101,代码来源:PerchTemplate.class.php

示例2: strtotime

        ?>
/responses/detail/?id=<?php 
        echo $HTML->encode(urlencode($Response->id()));
        ?>
"><?php 
        echo $HTML->encode(strftime('%d %b %Y %H:%M', strtotime($Response->responseCreated())));
        ?>
</a></td>
                <td>
                    <?php 
        $details = PerchUtil::json_safe_decode($Response->responseJSON(), true);
        $out = array();
        if (PerchUtil::count($details)) {
            foreach ($details['fields'] as $item) {
                if (isset($item['attributes']['label'])) {
                    $out[] = '<strong>' . $HTML->encode($item['attributes']['label']) . ':</strong> ' . $HTML->encode(PerchUtil::excerpt($item['value'], 10));
                }
            }
            echo implode('<br />', $out);
        }
        ?>
                </td>
                <td><a href="<?php 
        echo $API->app_path();
        ?>
/responses/delete/?id=<?php 
        echo $HTML->encode(urlencode($Response->id()));
        ?>
" class="delete inline-delete"><?php 
        echo $Lang->get('Delete');
        ?>
开发者ID:jimcurran,项目名称:bdmusichub,代码行数:31,代码来源:responses.list.post.php

示例3:

                <a class="sub" href="<?php 
    echo PERCH_LOGINPATH . '/core/apps/content/edit/?id=' . PerchUtil::html($Region->id());
    ?>
"><?php 
    echo PerchUtil::html($Region->regionKey());
    ?>
</a>
                <span class="sep icon"></span> 
                <a href="<?php 
    echo PERCH_LOGINPATH . '/core/apps/content/edit/?id=' . PerchUtil::html($Region->id()) . '&amp;itm=' . $details[0]['itemID'];
    ?>
"><?php 
    $item = $details[0];
    $id = $item['itemID'];
    if (isset($item['perch_' . $id . '__title'])) {
        echo PerchUtil::html(PerchUtil::excerpt($item['perch_' . $id . '__title'], 10));
    } else {
        if (isset($item['itemOrder'])) {
            echo PerchLang::get('Item') . ' ' . PerchUtil::html($item['itemOrder'] - 999);
        } else {
            echo PerchLang::get('New Item');
        }
    }
    ?>
</a>
                <?php 
} else {
    ?>
                    <a href="<?php 
    echo PERCH_LOGINPATH . '/core/apps/content/edit/?id=' . PerchUtil::html($Region->id());
    ?>
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:31,代码来源:edit.form.post.php


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