Example #1
0
function smartsection_items_spot_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $opt_display_last = $options[0];
    $opt_items_count = $options[1];
    $opt_categoryid = $options[2];
    $sel_items = isset($options[3]) ? explode(',', $options[3]) : '';
    $opt_display_poster = $options[4];
    $opt_display_comment = $options[5];
    $opt_display_type = $options[6];
    if ($opt_categoryid == 0) {
        $opt_categoryid = -1;
    }
    $block = array();
    $smartsection_item_handler =& smartsection_gethandler('item');
    if ($opt_display_last == 1) {
        $itemsObj = $smartsection_item_handler->getAllPublished($opt_items_count, 0, $opt_categoryid, $sort = 'datesub', $order = 'DESC', 'summary');
        $i = 1;
        $itemsCount = count($itemsObj);
        if ($itemsObj) {
            foreach ($itemsObj as $key => $thisitem) {
                $item = array();
                $item = $thisitem->toArray();
                $item['who_when'] = sprintf(_MB_SSECTION_WHO_WHEN, $thisitem->posterName(), $thisitem->datesub());
                if ($i < $itemsCount) {
                    $item['showline'] = true;
                } else {
                    $item['showline'] = false;
                }
                $i++;
                $block['items'][] = $item;
            }
        }
    } else {
        $i = 1;
        $itemsCount = count($sel_items);
        foreach ($sel_items as $item_id) {
            $itemObj = new SmartsectionItem($item_id);
            if (!$itemObj->notLoaded() && $itemObj->checkPermission()) {
                $categoryObj = $itemObj->category();
                $item = array();
                $item = $itemObj->toArray();
                $item['who_when'] = sprintf(_MB_SSECTION_WHO_WHEN, $itemObj->posterName(), $itemObj->datesub());
                if ($i < $itemsCount) {
                    $item['showline'] = true;
                } else {
                    $item['showline'] = false;
                }
                $i++;
                $block['items'][] = $item;
            }
        }
    }
    if (isset($block['items']) && count($block['items']) == 0) {
        return false;
    }
    $block['lang_reads'] = _MB_SSECTION_READS;
    $block['lang_comments'] = _MB_SSECTION_COMMENTS;
    $block['lang_readmore'] = _MB_SSECTION_READMORE;
    $block['display_whowhen_link'] = $opt_display_poster;
    $block['display_comment_link'] = $opt_display_comment;
    $block['display_type'] = $opt_display_type;
    return $block;
}