Exemple #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;
}
Exemple #2
0
    if (isset($path[$srh]) && $path[$srh] == 'page') {
        if (!isset($path[$srh])) {
            $page = 0;
        } else {
            $page = $path[$srh + 1];
        }
    }
}
$request = substr($request, 0, strpos($request, 'page') > 0 ? strpos($request, 'page') - 1 : strlen($request));
/**
 * 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;
}