本文整理汇总了PHP中Articles::list_for_author_by方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::list_for_author_by方法的具体用法?PHP Articles::list_for_author_by怎么用?PHP Articles::list_for_author_by使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::list_for_author_by方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
if (!($text = Cache::get($cache_id))) {
// loads feeding parameters
Safe::load('parameters/feeds.include.php');
// structured data
$values = array();
$values['channel'] = array();
// set channel information
$values['channel']['title'] = $item['full_name'] ? $item['full_name'] : $item['nick_name'];
$values['channel']['link'] = Users::get_permalink($item);
$values['channel']['description'] = $item['introduction'];
// the image for this channel
if (isset($context['powered_by_image']) && $context['powered_by_image']) {
$values['channel']['image'] = $context['url_to_home'] . $context['url_to_root'] . $context['powered_by_image'];
}
// the list of newest pages
$values['items'] = (array) Articles::list_for_author_by('publication', $item['id'], 0, 50, 'feed');
// make a text
include_once '../services/codec.php';
include_once '../services/rss_codec.php';
$result = rss_Codec::encode($values);
$status = @$result[0];
$text = @$result[1];
// save in cache for the next request
Cache::put($cache_id, $text, 'articles');
}
//
// transfer to the user agent
//
// handle the output correctly
render_raw('text/xml; charset=' . $context['charset']);
// suggest a name on download
示例2: render_random
/**
* select a random page
*
* The provided anchor can reference:
* - a section 'section:123'
* - a category 'category:456'
* - a user 'user:789'
* - 'self'
* - nothing
*
* @param string the anchor (e.g. 'section:123')
* @param string layout to use
* @return string the rendered text
**/
public static function render_random($anchor = '', $layout = '')
{
global $context;
// we return some text;
$text = '';
// label is explicit
$label = '';
if ($position = strrpos($anchor, ',')) {
$label = trim(substr($anchor, $position + 1));
$anchor = trim(substr($anchor, 0, $position));
}
// scope is limited to current surfer
if ($anchor == 'self' && Surfer::get_id()) {
$anchor = 'user:' . Surfer::get_id();
// refresh on every page load
Cache::poison();
}
// scope is limited to one section
if (!strncmp($anchor, 'section:', 8)) {
// look at this branch of the content tree
$anchors = Sections::get_branch_at_anchor($anchor);
// query the database and layout that stuff
$items =& Articles::list_for_anchor_by('random', $anchors, 0, 1, 'raw');
// scope is limited to one author
} elseif (!strncmp($anchor, 'user:', 5)) {
$items =& Articles::list_for_author_by('random', str_replace('user:', '', $anchor), 0, 1, 'raw');
} else {
$items =& Articles::list_by('random', 0, 1, 'raw');
}
// we have an array to format
if ($items) {
foreach ($items as $id => $item) {
// make a link to the target page
$link = Articles::get_permalink($item);
if (!$label) {
$label = Skin::strip($item['title']);
}
$text =& Skin::build_link($link, $label, 'article');
if ($layout == 'description') {
// the introduction text, if any
$text .= BR . Codes::beautify($item['introduction']);
// load overlay, if any
if (isset($item['overlay']) && $item['overlay']) {
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get text related to the overlay, if any
if (is_object($overlay)) {
$text .= $overlay->get_text('view', $item);
}
}
// the description, which is the actual page body
$text .= '<div>' . Codes::beautify($item['description']) . '</div>';
}
// we take only one item
break;
}
}
// job done
return $text;
}