Beispiel #1
0
function mywordsBlockRecent($options)
{
    global $xoopsModuleConfig, $xoopsModule, $xoopsUser;
    $mc = RMSettings::module_settings('mywords');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $by = '';
    switch ($options[1]) {
        case 'recent':
            $by = 'pubdate';
            break;
        case 'popular':
            $by = "`reads`";
            break;
        case 'comm':
            $by = "`comments`";
            break;
    }
    $posts = MWFunctions::get_posts_by_cat($options[5], 0, $options[0], $by, 'DESC');
    $block = array();
    foreach ($posts as $post) {
        $ret = array();
        $ret['id'] = $post->id();
        $ret['title'] = $post->getVar('title');
        $ret['link'] = $post->permalink();
        // Content
        if ($options[2]) {
            $ret['content'] = TextCleaner::getInstance()->truncate($post->content(true), $options[3]);
        }
        // Pubdate
        if ($options[4]) {
            $ret['date'] = formatTimestamp($post->getVar('pubdate'), 'c');
        }
        // Show reads
        if ($options[1] == 'popular') {
            $ret['hits'] = sprintf(__('%u Reads', 'mywords'), $post->getVar('reads'));
        } elseif ($options[1] == 'comm') {
            $ret['comments'] = sprintf(__('%u Comments', 'mywords'), $post->getVar('comments'));
        }
        $ret['time'] = $post->getVar('pubdate');
        $ret['image'] = RMIMage::get()->load_from_params($post->image);
        $block['posts'][] = $ret;
    }
    RMTemplate::get()->add_style('mwblocks.css', 'mywords');
    return $block;
}
Beispiel #2
0
 }
 $cat = new MWCategory($id);
 if ($cat->isNew()) {
     redirect_header('backend.php', 1, __('Sorry, specified category was not foud!', 'mywords'));
     die;
 }
 $rss_channel['title'] = sprintf(__('Posts in %s - %s', 'mywords'), $cat->name, $xoopsConfig['sitename']);
 $rss_channel['link'] = $cat->permalink();
 $rss_channel['description'] = htmlspecialchars($cat->getVar('description'), ENT_QUOTES);
 $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss');
 $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true);
 $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true);
 $rss_channel['category'] = $cat->getVar('name');
 $rss_channel['generator'] = 'Common Utilities';
 $rss_channel['language'] = RMCLANG;
 $posts = MWFunctions::get_posts_by_cat($id, 0, 10);
 $rss_items = array();
 foreach ($posts as $post) {
     $item = array();
     $item['title'] = $post->getVar('title');
     $item['link'] = $post->permalink();
     $img = new RMImage();
     $img->load_from_params($post->getVar('image', 'e'));
     if (!$img->isNew()) {
         $image = '<img src="' . $img->url() . '" alt="' . $post->getVar('title') . '" /><br />';
     } else {
         $image = '';
     }
     $item['description'] = XoopsLocal::convert_encoding(htmlspecialchars($image . $post->content(true), ENT_QUOTES));
     $item['pubdate'] = formatTimestamp($post->getVar('pubdate'), 'rss');
     $item['guid'] = $post->permalink();