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


PHP PSU::html_all_entities方法代码示例

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


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

示例1: parse_data

 /**
  * Method to parse the source's data into a standard format
  */
 protected function parse_data()
 {
     // Create a normalized feed array (to be served later)
     $parsed_data = array();
     // Reference just the feed
     $feed = $this->data->feed;
     // If the feed doesn't have a title, give it a generic name
     $feed_title = $feed->title();
     if (strlen($feed_title) <= 0) {
         $feed_title = 'Plymouth State News';
     }
     // Let's loop through each article
     $item_count = 0;
     foreach ($feed as $item) {
         // If we've gone over the post limit setting, then break out of this loop
         if ($item_count > $this->post_limit) {
             // Stop adding posts from this feed
             break;
         }
         // Cut posts if they're too old
         $post_timestamp = strtotime($item->pubDate());
         if (time() - $post_timestamp > $this->old_post_days * 86400) {
             // Skip adding this one... its too old
             continue;
         }
         // Quick function to clean the posts text
         $clean_the_post = function ($post) {
             // Run some cleaners on the string
             $post = htmlspecialchars_decode($post);
             $post = html_entity_decode($post);
             $post = strip_tags($post);
             $post = \PSU::html_all_entities($post);
             $post = str_replace('&#12287;', '\'', $post);
             return $post;
         };
         $post_text = $clean_the_post($item->title());
         // Add the posts data to the normalized array
         $parsed_data[] = array('source' => 'RSS', 'title' => $feed_title, 'userid' => '', 'rawtime' => $item->pubDate(), 'timestamp' => $post_timestamp, 'datetime' => \PSU::html5_datetime($post_timestamp), 'time_ago' => \PSU::date_diff($post_timestamp, time(), 'simple'), 'url' => $item->link(), 'text' => $post_text, 'description' => $item->description(), 'content' => $item->content());
         $item_count++;
     }
     return $parsed_data;
 }
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:45,代码来源:Rss.php


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