function lastStories() { global $xoopsModule, $xoopsModuleConfig; $start = isset($_GET['start']) ? $_GET['start'] : 0; $title = isset($_POST['title']) ? $_POST['title'] : (isset($_GET['title']) ? $_GET['title'] : ""); $topicid = isset($_POST['topicid']) ? $_POST['topicid'] : (isset($_GET['topicid']) ? $_GET['topicid'] : 0); $status = isset($_POST['status']) ? $_POST['status'] : (isset($_GET['status']) ? $_GET['status'] : "none"); $author = isset($_POST['author']) ? $_POST['author'] : (isset($_GET['author']) ? $_GET['author'] : array()); $criteria = new CriteriaCompo(); $querystring = "op=newarticle"; if (isset($title) && $title != "") { $criteria->add(new Criteria('n.title', "%" . $title . "%", 'LIKE')); $querystring .= "&title=" . $title; } if (isset($author) && is_array($author) && count($author) != 0) { $criteria->add(new Criteria('t.uid', "(" . implode($author) . ")", 'IN')); foreach ($author as $uid) { $querystring .= "&author[]=" . $uid; } } if (isset($status) && $status != 'none') { if ($status == "published") { $status_crit = new CriteriaCompo(new Criteria('n.published', 0, '>')); $status_crit->add(new Criteria('n.published', time(), '<=')); $status_exp = new CriteriaCompo(new Criteria('n.expired', 0)); $status_exp->add(new Criteria('n.expired', time(), '>='), 'OR'); $status_crit->add($status_exp); $criteria->add($status_crit); } elseif ($status == "expired") { $criteria->add(new Criteria('n.expired', 0, '!=')); $criteria->add(new Criteria('n.expired', time(), '<')); } } if (isset($topicid) && $topicid != 0) { $criteria->add(new Criteria('n.topicid', $topicid)); } $order = isset($_POST['order']) ? $_POST['order'] : (isset($_GET['order']) ? $_GET['order'] : 'DESC'); $revOrder = $order == 'DESC' ? 'ASC' : 'DESC'; $criteria->setOrder($order); $sort = isset($_POST['sort']) ? $_POST['sort'] : (isset($_GET['sort']) ? $_GET['sort'] : 'n.published'); $criteria->setSort($sort); $revString = $querystring . "&sort=" . $sort . "&order=" . $revOrder; $querystring .= "&order=" . $order; include 'filterform.php'; $fform->display(); echo "<table width='100%' border='0' cellspacing='1' class='outer'>"; echo "<tr><td class=\"odd\"><p align=\"right\">"; echo "<b><a href=\"" . XOOPS_URL . "/modules/" . $xoopsModule->getVar("dirname") . "/submit.php\">"; echo "<img src=\"" . XOOPS_URL . "/modules/" . $xoopsModule->getVar("dirname") . "/images/new.png\">" . _AMS_AM_POSTNEWARTICLE . "</a></b></td></tr>"; echo "<tr><td class=\"odd\">"; echo "<div style='text-align: center;'><b>" . _AMS_AM_PUBLISHEDARTICLES . "</b> <a href='?" . $revString . "'>" . _AMS_AM_SORT . " " . $revOrder . "</a><br />"; $storyarray = AmsStory::getAllNews($xoopsModuleConfig['storycountadmin'], $start, $criteria); $storyids = array_keys($storyarray); $versioncount_arr = AmsStory::getVersionCounts($storyids); echo "<table border='1' width='100%'><tr class='bg3'>\r\n <td align='center'><a href='?" . $querystring . "&sort=n.storyid'>" . _AMS_AM_STORYID . "</a></td>\r\n <td align='center'><a href='?" . $querystring . "&sort=n.title'>" . _AMS_AM_TITLE . "</a></td>\r\n <td align='center'>" . _AMS_AM_VERSION . "</td>\r\n <td align='center'>" . _AMS_AM_TOPIC . "</td>\r\n <td align='center'>" . _AMS_AM_POSTER . "</td>\r\n <td align='center'><a href='?" . $querystring . "&sort=n.published'>" . _AMS_AM_PUBLISHED . "</a></td>\r\n <td align='center'>" . _AMS_AM_VERSIONCOUNT . "</td>\r\n <td align='center'><a href='?" . $querystring . "&sort=n.counter'>" . _AMS_AM_HITS . "</a></td>\r\n <td align='center'><a href='?" . $querystring . "&sort=n.rating'>" . _AMS_AM_RATING . "</a></td>\r\n <td align='center'><a href='?" . $querystring . "&sort=n.comments'>" . _AMS_AM_COMMENTS . "</a></td>\r\n <td align='center'>" . _AMS_AM_ACTION . "</td></tr>"; foreach ($storyarray as $eachstory) { $uids[] = $eachstory->uid(); } if (!empty($uids)) { $member_handler =& xoops_gethandler('member'); $users = $member_handler->getUsers(new Criteria('uid', "(" . implode(',', array_keys($uids)) . ")", 'IN'), true); foreach ($storyarray as $storyid => $eachstory) { $eachstory->uname($users); $published = formatTimestamp($eachstory->published(), 's'); //$expired = ( $eachstory -> expired() > 0 ) ? formatTimestamp( $eachstory -> expired(), 's' ) : '---'; $topic = $eachstory->topic(); echo "\r\n \t<tr><td align='center'><b>" . $storyid . "</b>\r\n \t</td><td align='left'><a href='" . XOOPS_URL . "/modules/" . $xoopsModule->dirname() . "/article.php?storyid=" . $eachstory->storyid() . "'>" . $eachstory->title() . "</a>\r\n \t</td><td align='left'>" . $eachstory->version() . "\r\n </td><td align='center'>" . $topic->topic_title() . "\r\n \t</td><td align='center'><a href='" . XOOPS_URL . "/userinfo.php?uid=" . $eachstory->uid() . "'>" . $eachstory->uname . "</a></td>\r\n <td align='center' class='nw'>" . $published . "</td>\r\n <td align='center'>" . $versioncount_arr[$eachstory->storyid()] . "</td>\r\n <td align='center'>" . $eachstory->counter() . "</td>\r\n <td align='center'>" . $eachstory->rating . "</td>\r\n <td align='center'>" . $eachstory->comments() . "</td>\r\n <td align='center'><a href='../submit.php?op=edit&storyid=" . $eachstory->storyid() . "'>" . _AMS_AM_EDIT . "</a>-<a href='index.php?op=delete&storyid=" . $eachstory->storyid() . "'>" . _AMS_AM_DELETE . "</a>"; echo "</td></tr>\n"; } } echo "</table><br /></div>"; echo "</td></tr></table><br />"; $totalPublished = AmsStory::countPublishedByTopic(); if ($totalPublished > $xoopsModuleConfig['storycountadmin']) { include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; $pagenav = new XoopsPageNav($totalPublished, $xoopsModuleConfig['storycountadmin'], $start, 'start', $querystring); echo $pagenav->renderNav(); } }