Пример #1
0
/**
* @desc Genera la información para mostrar la Sindicación
* @param int Limite de resultados
* @return Array
*/
function &exmbb_rssshow($limit)
{
    global $util, $mc;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    include_once XOOPS_ROOT_PATH . '/modules/exmbb/class/bbforum.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/exmbb/class/bbpost.class.php';
    foreach ($_GET as $k => $v) {
        ${$k} = $v;
    }
    $feed = array();
    // Información General
    $ret = array();
    $mc =& $util->moduleConfig('exmbb');
    if ($show == 'all') {
        $feed['title'] = htmlspecialchars(_MI_BB_RSSALL);
        $feed['link'] = XOOPS_URL . '/modules/exmbb';
        $feed['description'] = htmlspecialchars($util->filterTags($mc['rssdesc']));
        $sql = "SELECT a.*, b.title FROM " . $db->prefix("exmbb_posts") . " a," . $db->prefix("exmbb_topics") . " b WHERE \n\t\t\t\ta.approved='1' AND b.id_topic=a.id_topic ORDER BY a.post_time DESC LIMIT 0,{$limit}";
    } else {
        if ($id <= 0) {
            return;
        }
        $forum = new BBForum($id);
        if ($forum->isNew()) {
            return;
        }
        $feed['title'] = htmlspecialchars(sprintf(_MI_BB_RSSNAMEFORUM, $forum->name()));
        $feed['link'] = XOOPS_URL . '/modules/exmbb/forum.php?id=' . $forum->id();
        $feed['description'] = htmlspecialchars($forum->description());
        $sql = "SELECT a.*, b.title FROM " . $db->prefix("exmbb_posts") . " a," . $db->prefix("exmbb_topics") . " b WHERE a.id_forum='{$id}' AND a.approved='1' AND b.id_topic=a.id_topic ORDER BY a.post_time DESC LIMIT 0,{$limit}";
    }
    // Generamos los elementos
    $result = $db->query($sql);
    $posts = array();
    while ($row = $db->fetchArray($result)) {
        $post = new BBPost();
        $post->assignVars($row);
        $rtn = array();
        $rtn['title'] = htmlspecialchars($row['title']);
        $rtn['link'] = htmlspecialchars(XOOPS_URL . '/modules/exmbb/topic.php?pid=' . $post->id() . "#p" . $post->id(), ENT_QUOTES);
        $rtn['description'] = utf8_encode($post->text());
        $rtn['date'] = formatTimestamp($post->date());
        $posts[] = $rtn;
    }
    $ret = array('feed' => $feed, 'items' => $posts);
    return $ret;
}