Ejemplo n.º 1
0
function mosLoadCustomModule(&$module, &$params)
{
    global $mosConfig_absolute_path, $mosConfig_cachepath;
    $rssurl = $params->get('rssurl', '');
    $rssitems = $params->get('rssitems', '');
    $rssdesc = $params->get('rssdesc', '');
    $moduleclass_sfx = $params->get('moduleclass_sfx', '');
    $rsscache = $params->get('rsscache', 3600);
    $cachePath = $mosConfig_cachepath . '/';
    echo '<table cellpadding="0" cellspacing="0" class="moduletable' . $moduleclass_sfx . '">';
    if ($module->content) {
        echo '<tr>';
        echo '<td>' . $module->content . '</td>';
        echo '</tr>';
    }
    // feed output
    if ($rssurl) {
        if (!is_writable($cachePath)) {
            echo '<tr>';
            echo '<td>Please make cache directory writable.</td>';
            echo '</tr>';
        } else {
            $LitePath = $mosConfig_absolute_path . '/includes/Cache/Lite.php';
            require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_rss_lite.php';
            $rssDoc = new xml_domit_rss_document_lite();
            $rssDoc->setRSSTimeout(5);
            $rssDoc->useHTTPClient(true);
            $rssDoc->useCacheLite(true, $LitePath, $cachePath, $rsscache);
            $success = $rssDoc->loadRSS($rssurl);
            if ($success) {
                $totalChannels = $rssDoc->getChannelCount();
                for ($i = 0; $i < $totalChannels; $i++) {
                    $currChannel =& $rssDoc->getChannel($i);
                    $feed_title = $currChannel->getTitle();
                    $feed_title = mosCommonHTML::newsfeedEncoding($rssDoc, $feed_title);
                    echo '<tr>';
                    echo '<td><strong><a href="' . $currChannel->getLink() . '" target="_child">';
                    echo $feed_title . '</a></strong></td>';
                    echo '</tr>';
                    if ($rssdesc) {
                        $feed_descrip = $currChannel->getDescription();
                        $feed_descrip = mosCommonHTML::newsfeedEncoding($rssDoc, $feed_descrip);
                        echo '<tr>';
                        echo '<td>' . $feed_descrip . '</td>';
                        echo '</tr>';
                    }
                    $actualItems = $currChannel->getItemCount();
                    $setItems = $rssitems;
                    if ($setItems > $actualItems) {
                        $totalItems = $actualItems;
                    } else {
                        $totalItems = $setItems;
                    }
                    for ($j = 0; $j < $totalItems; $j++) {
                        $currItem =& $currChannel->getItem($j);
                        $item_title = $currItem->getTitle();
                        $item_title = mosCommonHTML::newsfeedEncoding($rssDoc, $item_title);
                        $text = $currItem->getDescription();
                        $text = mosCommonHTML::newsfeedEncoding($rssDoc, $text);
                        echo '<tr>';
                        echo '<td><strong><a href="' . $currItem->getLink() . '" target="_child">';
                        echo $item_title . '</a></strong> - ' . $text . '</td>';
                        echo '</tr>';
                    }
                }
            }
        }
    }
    echo '</table>';
}