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


PHP RSS::add_posts方法代码示例

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


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

示例1: action_handler_dev_feed

 public function action_handler_dev_feed($handler_vars)
 {
     $rss = Plugins::get_by_interface('RSS');
     if (count($rss) !== 1) {
         exit;
     }
     $xml = reset($rss)->create_rss_wrapper();
     $connection_string = Options::get('tracfeed__connection_string');
     $username = Options::get('tracfeed__username');
     $password = Options::get('tracfeed__password');
     $db = DatabaseConnection::ConnectionFactory($connection_string);
     $db->connect($connection_string, $username, $password);
     $times = $db->get_column('SELECT time from ticket_change group by time order by time desc limit 15;');
     $mintime = array_reduce($times, 'min', reset($times));
     $comments = $db->get_results("\n\t\t\tSELECT *, ticket_change.time as changetime from ticket_change \n\t\t\tINNER JOIN ticket on ticket.id = ticket_change.ticket\n\t\t\twhere \n\t\t\tchangetime >= ? and\n\t\t\tnot (field ='comment' and newvalue = '') \n\t\t\torder by ticket_change.time DESC;\n\t\t", array($mintime));
     $posts = array();
     foreach ($comments as $comment) {
         $post_id = md5($comment->ticket . ':' . $comment->changetime . ':' . $comment->author);
         if (!array_key_exists($post_id, $posts)) {
             $post = new Post();
             $post->title = "Ticket #{$comment->ticket}: {$comment->summary}";
             $post->content = "Changes by {$comment->author} on ticket <a href=\"http://trac.habariproject.org/habari/ticket/{$comment->ticket}\">#{$comment->ticket}</a>.\n<br>\n<br>";
             $post->guid = 'tag:' . Site::get_url('hostname') . ',trac_comment,' . $post_id;
             $post->content_type = 'dev_feed';
             $post->slug = "http://trac.habariproject.org/habari/ticket/{$comment->ticket}";
             $post->pubdate = date('r', $comment->changetime);
             $posts[$post_id] = $post;
         } else {
             $post = $posts[$post_id];
         }
         switch ($comment->field) {
             case 'comment':
                 $content = $comment->newvalue;
                 $content = preg_replace('/\\b(https?|ftp|file):\\/\\/[-A-Z0-9+&@#\\/%?=~_|!:,.;]*[-A-Z0-9+&@#\\/%=~_|]/i', '<a href="$0">[link]</a>', $content);
                 $content = preg_replace('%\\br([0-9]+)\\b%', '<a href="http://trac.habariproject.org/habari/changeset/$1">r$1</a>', $content);
                 $content = preg_replace('%\\b#([0-9]+)\\b%', '<a href="http://trac.habariproject.org/habari/ticket/$1">$1</a>', $content);
                 $post->content .= "Comment #{$comment->oldvalue} by {$comment->author}:\n<blockquote><pre>{$content}</pre></blockquote>\n<br>";
                 break;
             default:
                 if (trim($comment->oldvalue) == '') {
                     $post->content .= "Set <b>{$comment->field}</b> to: {$comment->newvalue}\n<br>";
                 } else {
                     $post->content .= "Changed <b>{$comment->field}</b> from: {$comment->oldvalue}\n<br> To: {$comment->newvalue}\n<br>";
                 }
                 break;
         }
     }
     $xml = RSS::add_posts($xml, $posts);
     ob_clean();
     header('Content-Type: application/xml');
     echo $xml->asXML();
     exit;
 }
开发者ID:habari-extras,项目名称:tracfeed,代码行数:53,代码来源:tracfeed.plugin.php


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