Esempio n. 1
0
function myWordsBlockTags($options)
{
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $sql = "SELECT * FROM " . $db->prefix("mod_mywords_tags") . " ORDER BY RAND() LIMIT 0,{$options['0']}";
    $result = $db->query($sql);
    $block = array();
    $max = 0;
    $min = 0;
    while ($row = $db->fetchArray($result)) {
        $tag = new MWTag();
        $tag->assignVars($row);
        $block['tags'][] = array('id' => $tag->id(), 'posts' => $tag->getVar('posts'), 'link' => $tag->permalink(), 'name' => $tag->getVar('tag'), 'size' => $options[1] * $tag->getVar('posts') + 0.9);
    }
    RMTemplate::get()->add_style('mwblocks.css', 'mywords');
    return $block;
}
Esempio n. 2
0
     break;
 case 'tag':
     include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwtag.class.php';
     $id = rmc_server_var($_GET, 'tag', 0);
     if ($id <= 0) {
         redirect_header('backend.php', 1, __('Sorry, specified tag was not foud!', 'mywords'));
         die;
     }
     $tag = new MWTag($id);
     if ($tag->isNew()) {
         redirect_header('backend.php', 1, __('Sorry, specified tag was not foud!', 'mywords'));
         die;
     }
     $rss_channel['title'] = sprintf(__('Posts tagged %s in %s', 'mywords'), $tag->tag, $xoopsConfig['sitename']);
     $rss_channel['link'] = $tag->permalink();
     $rss_channel['description'] = sprintf(__('Posts tagged as %s', 'mywords'), $tag->getVar('tag'));
     $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss');
     $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true);
     $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true);
     $rss_channel['category'] = "Blog";
     $rss_channel['generator'] = 'Common Utilities';
     $rss_channel['language'] = RMCLANG;
     $posts = MWFunctions::get_posts_by_tag($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()) {
Esempio n. 3
0
 * Paginamos los resultados
 */
$limit = $mc['posts_limit'];
$table_tags = $db->prefix("mw_tagspost");
$table_posts = $db->prefix("mw_posts");
$sql = "SELECT COUNT(*) FROM {$table_posts} as a, {$table_tags} as b WHERE b.tag='" . $tag->id() . "' AND \n        a.id_post=b.post AND status='publish' AND \n\t\t((visibility='public' OR visibility='password') OR (visibility='private' AND\n\t\tauthor=" . ($xoopsUser ? $xoopsUser->uid() : -1) . "))";
list($num) = $db->fetchRow($db->query($sql));
if ($page > 0) {
    $page -= 1;
}
$start = $page * $mc['posts_limit'];
$tpages = (int) ($num / $mc['posts_limit']);
if ($num % $mc['posts_limit'] > 0) {
    $tpages++;
}
$pactual = $page + 1;
if ($pactual > $tpages) {
    $rest = $pactual - $tpages;
    $pactual = $pactual - $rest + 1;
    $start = ($pactual - 1) * $limit;
}
$nav = new RMPageNav($num, $limit, $pactual, 6);
$nav->target_url($tag->permalink() . ($mc['permalinks'] > 1 ? 'page/{PAGE_NUM}/' : '&page={PAGE_NUM}'));
$xoopsTpl->assign("nav_pages", $nav->render(false, 0));
$xoopsTpl->assign('pactual', $pactual);
$xoopsTpl->assign('lang_taggedtitle', sprintf(__('Posts tagged as "%s"', 'mywords'), $tag->getVar('tag')));
$sql = "SELECT a.* FROM {$table_posts} as a, {$table_tags} as b WHERE b.tag='" . $tag->id() . "' AND\n        a.id_post=b.post AND status='publish' AND \n\t\t((visibility='public' OR visibility='password') OR (visibility='private' AND\n\t\tauthor=" . ($xoopsUser ? $xoopsUser->uid() : -1) . ")) ORDER BY pubdate DESC LIMIT {$start},{$limit}";
$result = $db->query($sql);
require 'post_data.php';
$xoopsTpl->assign('xoops_pagetitle', sprintf(__('Posts tagged as "%s"', 'mywords'), $tag->getVar('tag')));
include 'footer.php';