getDB(); // TODO: Implement } /** * Fetches the entries of a specified page * * @return array of Entry */ public static function getPageEntries($site, $instance, $page, $pagesize) { $db = System::getInstance()->getDB(); $usrv = System::getInstance()->getUserSvc(); $start = $page * $pagesize; $sql = 'SELECT * FROM ' . $db->escapeTableName(self::$ENTRYTABLE); $sql .= ' WHERE site_id=' . $site . ' AND instance=' . $db->escapeValue($instance); $sql .= ' ORDER BY created_at DESC'; $list = $db->getObjectList($sql, '\\MCMS\\_\\Modx\\MCMS\\News\\_\\Model\\Entry', NULL, $pagesize, $start); foreach($list as $idx=>&$entry) { $entry->created_by = NULL; if($entry->created_by_id > 0) { $usr = $usrv->getUser((int) $entry->created_by_id); $entry->created_by = $usr; } } return $list; } /** * Counts the number of pages of news entries. * * @param int $site * the id of the website * @param string $instance * the instance name * @param int $pagesize * the number of entries per page * @return int the number of pages */ public static function getPageCount($site, $instance, $pagesize) { $db = System::getInstance()->getDB(); $where = 'WHERE site_id=' . $site . ' AND instance=' . $db->escapeValue($instance); $count = $db->getObject("SELECT COUNT(id) AS c FROM " . $db->escapeTableName(self::$ENTRYTABLE) . ' ' . $where)->c; $pages = ceil($count / $pagesize); return $pages; } public static function getHistory($siteId, $instance, $page, $pagesize, $reverse) { $db = System::getInstance()->getDB(); // TODO: Implement } public static function getComments(MMModNewsEntry $newsEntry, $page, $pagesize, $reverse) { $db = System::getInstance()->getDB(); // TODO: Implement } }