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


PHP FeedCreator::addItem方法代码示例

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


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

示例1: rss_buildItems


//.........这里部分代码省略.........
                            $content = "<pre>\n" . hsc($udf->format($df)) . "\n</pre>";
                        }
                    }
                    break;
                case 'html':
                    if ($ditem['media']) {
                        if ($size = media_image_preview_size($id, false, new JpegMeta(mediaFN($id)))) {
                            $more = 'w=' . $size[0] . '&h=' . $size[1] . 't=' . @filemtime(mediaFN($id));
                            $src = ml($id, $more);
                            $content = '<img src="' . $src . '" alt="' . $id . '" />';
                        } else {
                            $content = '';
                        }
                    } else {
                        if (@filemtime(wikiFN($id)) === $date) {
                            $content = p_wiki_xhtml($id, '', false);
                        } else {
                            $content = p_wiki_xhtml($id, $date, false);
                        }
                        // no TOC in feeds
                        $content = preg_replace('/(<!-- TOC START -->).*(<!-- TOC END -->)/s', '', $content);
                        // add alignment for images
                        $content = preg_replace('/(<img .*?class="medialeft")/s', '\\1 align="left"', $content);
                        $content = preg_replace('/(<img .*?class="mediaright")/s', '\\1 align="right"', $content);
                        // make URLs work when canonical is not set, regexp instead of rerendering!
                        if (!$conf['canonical']) {
                            $base = preg_quote(DOKU_REL, '/');
                            $content = preg_replace('/(<a href|<img src)="(' . $base . ')/s', '$1="' . DOKU_URL, $content);
                        }
                    }
                    break;
                case 'abstract':
                default:
                    if ($ditem['media']) {
                        if ($size = media_image_preview_size($id, false, new JpegMeta(mediaFN($id)))) {
                            $more = 'w=' . $size[0] . '&h=' . $size[1] . 't=' . @filemtime(mediaFN($id));
                            $src = ml($id, $more);
                            $content = '<img src="' . $src . '" alt="' . $id . '" />';
                        } else {
                            $content = '';
                        }
                    } else {
                        $content = $meta['description']['abstract'];
                    }
            }
            $item->description = $content;
            //FIXME a plugin hook here could be senseful
            // add user
            # FIXME should the user be pulled from metadata as well?
            $user = @$ditem['user'];
            // the @ spares time repeating lookup
            $item->author = '';
            if ($user && $conf['useacl'] && $auth) {
                $userInfo = $auth->getUserData($user);
                if ($userInfo) {
                    switch ($conf['showuseras']) {
                        case 'username':
                            $item->author = $userInfo['name'];
                            break;
                        default:
                            $item->author = $user;
                            break;
                    }
                } else {
                    $item->author = $user;
                }
                if ($userInfo && !$opt['guardmail']) {
                    $item->authorEmail = $userInfo['mail'];
                } else {
                    //cannot obfuscate because some RSS readers may check validity
                    $item->authorEmail = $user . '@' . $ditem['ip'];
                }
            } elseif ($user) {
                // this happens when no ACL but some Apache auth is used
                $item->author = $user;
                $item->authorEmail = $user . '@' . $ditem['ip'];
            } else {
                $item->authorEmail = 'anonymous@' . $ditem['ip'];
            }
            // add category
            if (isset($meta['subject'])) {
                $item->category = $meta['subject'];
            } else {
                $cat = getNS($id);
                if ($cat) {
                    $item->category = $cat;
                }
            }
            // finally add the item to the feed object, after handing it to registered plugins
            $evdata = array('item' => &$item, 'opt' => &$opt, 'ditem' => &$ditem, 'rss' => &$rss);
            $evt = new Doku_Event('FEED_ITEM_ADD', $evdata);
            if ($evt->advise_before()) {
                $rss->addItem($item);
            }
            $evt->advise_after();
            // for completeness
        }
    }
    $event->advise_after();
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:101,代码来源:feed.php


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