コード例 #1
0
ファイル: ams_spotlight.php プロジェクト: severnaya99/Sg-2010
function b_ams_spotlight_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newsstory.php";
    global $xoopsModule;
    if (!isset($xoopsModule) || $xoopsModule->getVar('dirname') != "AMS") {
        $mod_handler =& xoops_gethandler('module');
        $amsModule =& $mod_handler->getByDirname('AMS');
    } else {
        $amsModule =& $xoopsModule;
    }
    $spotlight_handler =& xoops_getmodulehandler('spotlight', 'AMS');
    $block =& $spotlight_handler->getSpotlightBlock();
    //load special block instruction if exist
    if (file_exists(XOOPS_ROOT_PATH . '/modules/AMS/templates/' . $options[2] . '.php')) {
        include XOOPS_ROOT_PATH . '/modules/AMS/templates/' . $options[2] . '.php';
    }
    $GLOBALS['xoopsTpl']->assign('spotlights', $block['spotlights']);
    $block['spotlightcontent'] = $GLOBALS['xoopsTpl']->fetch('db:' . $options[2]);
    $GLOBALS['xoopsTpl']->clear_assign('spotlights');
    if (count($options) > 0) {
        if (intval($options[0]) > 0) {
            $stories = AmsStory::getAllPublished(intval($options[0]), 0, false, 0, 1, true, 'published', $block['ids']);
            $count = 0;
            foreach (array_keys($stories) as $i) {
                $block['stories'][] = array('id' => $stories[$i]->storyid(), 'title' => $stories[$i]->title(), 'hits' => $stories[$i]->counter(), 'friendlyurl_enable' => $stories[$i]->friendlyurl_enable, 'friendlyurl' => $stories[$i]->friendlyurl);
                $count++;
            }
        }
        if ($options[1] == 1) {
            $block['total_art'] = AmsStory::countPublishedByTopic();
            $block['total_read'] = AmsStory::countReads();
            $comment_handler =& xoops_gethandler('comment');
            $block['total_comments'] = $comment_handler->getCount(new Criteria('com_modid', $amsModule->getVar('mid')));
        }
        $block['showministats'] = $options[1];
        $block['showother'] = intval($options[0]) > 0;
    }
    return $block;
}