function b_ams_top_show($options) { $myts =& MyTextSanitizer::getInstance(); include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newsstory.php"; $block = array(); if (!isset($options[4]) || $options[4] == 0 || $options[4] == array(0)) { $stories = AmsStory::getAllPublished($options[1], 0, false, 0, 1, true, $options[0]); } else { // If using Xoops 2.0.9.1 way of saving array values if (is_array($options[4])) { $topics = $options[4]; } else { $topics = array_slice($options, 4); } $stories = AmsStory::getAllPublished($options[1], 0, false, $topics, 1, true, $options[0]); } foreach ($stories as $key => $story) { switch ($options[0]) { case "rating": $stat = $story->rating; break; case "counter": $stat = $story->counter(); break; case "published": $stat = formatTimestamp($story->published(), "s"); break; } $news = array(); $title = $story->title(); if (strlen($title) >= $options[2]) { $title = xoops_substr($title, 0, $options[2] - 1); } $html = $story->nohtml ? 0 : 1; $news['title'] = $title; $news['id'] = $story->storyid(); $news['date'] = formatTimestamp($story->published(), "s"); $news['hits'] = $stat; $news['friendlyurl'] = $story->friendlyurl; $news['friendlyurl_enable'] = $story->friendlyurl_enable; if ($options[3] > 0) { $news['teaser'] = xoops_substr($myts->displayTarea($story->hometext, $html), 0, $options[3] - 1); } else { $news['teaser'] = ""; } $block['stories'][] = $news; } return $block; }
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; }
function getSpotlightBlock($display_only = true) { $myts =& MyTextSanitizer::getInstance(); include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newsstory.php"; $block = array(); if ($display_only) { $criteria = new Criteria('display', 1); } else { $criteria = new Criteria('spotlightid', 0, ">"); } $criteria->setSort('weight'); $spots =& $this->getObjects($criteria); if (count($spots) == 0) { return $block; } $ids = array(); foreach (array_keys($spots) as $i) { switch ($spots[$i]->getVar('mode')) { // Latest Article case 1: $article_arr = AmsStory::getAllPublished(1, 0, false, 0, 1, true, 'published', $ids); $article =& $article_arr[0]; if (!is_object($article)) { continue; } $ids[$article->storyid()] = $article->storyid(); $uids[] = $article->uid(); break; // Latest Article in Topic // Latest Article in Topic case 2: $article_arr = AmsStory::getAllPublished(1, 0, false, $spots[$i]->getVar('topicid'), 1, true, 'published', $ids); $article =& $article_arr[0]; if (!is_object($article)) { continue; } $ids[$article->storyid()] = $article->storyid(); $uids[] = $article->uid(); break; // Specific Article // Specific Article case 3: $article = new AmsStory($spots[$i]->getVar('storyid')); if (!is_object($article)) { continue; } $ids[$article->storyid()] = $article->storyid(); $uids[] = $article->uid(); break; case 4: $article = ""; } $spotarticles[] = $article; } $member_handler =& xoops_gethandler('member'); $users = $member_handler->getUsers(new Criteria('uid', "(" . implode(',', array_unique($uids)) . ")", 'IN'), true); foreach (array_keys($spotarticles) as $i) { $article =& $spotarticles[$i]; $image = $spots[$i]->getImage($article); if (is_object($article)) { $article->uname($users); $teaser = $spots[$i]->getVar('autoteaser') != 1 ? $myts->displayTarea($spots[$i]->getVar('teaser', 'n'), 1) : ($spots[$i]->getVar('maxlength') > 0 ? xoops_substr($article->hometext(), 0, $spots[$i]->getVar('maxlength'), "") : $article->hometext()); $id = $article->storyid(); $title = $article->title(); $hits = $article->counter(); $poster = $article->uname; $posterid = $article->uid(); $posttime = formatTimestamp($article->published()); $custom = 0; $friendlyurl_enable = $article->friendlyurl_enable; $friendlyurl = $article->friendlyurl; } else { $id = 0; $title = ""; $hits = 0; $custom = 1; $posterid = 0; $posttime = ""; $poster = ""; $teaser = $myts->displayTarea($spots[$i]->getVar('teaser', 'n'), 1); } $block['spotlights'][] = array('spotid' => $spots[$i]->getVar('spotlightid'), 'id' => $id, 'title' => $title, 'hits' => $hits, 'image' => $image, 'text' => $teaser, 'weight' => $spots[$i]->getVar('weight'), 'display' => $spots[$i]->getVar('display'), 'posttime' => $posttime, 'poster' => $poster, 'posterid' => $posterid, 'autoteaser' => $spots[$i]->getVar('autoteaser'), 'custom' => $custom, 'friendlyurl_enable' => $friendlyurl_enable, 'friendlyurl' => $friendlyurl); } $block['ids'] = $ids; return $block; }
$xt->getTopic($xoopsOption['storytopic']); $pagetitle .= ' - ' . $xt->topic_title(); $xoopsTpl->assign('breadcrumb', $xt->getTopicPath(true)); } else { $xoopsTpl->assign('breadcrumb', ''); } } else { include_once XOOPS_ROOT_PATH . "/class/tree.php"; $xt = new AmsTopic($xoopsDB->prefix("ams_topics")); $allTopics = $xt->getAllTopics($xoopsModuleConfig['restrictindex']); $topic_obj_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); $alltopics = $topic_obj_tree->getFirstChild(0); $article_counts = AmsStory::countPublishedOrderedByTopic(); $smarty_topics = array(); foreach (array_keys($alltopics) as $i) { $allstories[$i] = AmsStory::getAllPublished($xoopsOption['storynum'], 0, false, $i, 0); if (count($allstories[$i]) > 0) { foreach ($allstories[$i] as $thisstory) { $uids[$thisstory->uid()] = $thisstory->uid(); } } if (!isset($article_counts[$i])) { $article_counts[$i] = 0; } } if (count($uids) > 0) { $member_handler =& xoops_gethandler('member'); $user_arr = $member_handler->getUsers(new Criteria('uid', "(" . implode(',', array_keys($uids)) . ")", 'IN'), true); foreach ($alltopics as $topicid => $topic) { $topicstories = array(); foreach ($allstories[$topicid] as $thisstory) {