| // +---------------------------------------------------------------------------+ /** * Site news block. * * @package block * @author Demian Turner */ class Publisher_Block_RecentHtmlArticles2 { var $webRoot = SGL_BASE_URL; function init() { return $this->getBlockContent(); } function getBlockContent() { $aResult = $this->retrieveAll(); $newList = $this->toHtml($aResult); $newsContent = $newList; return $newsContent; } /** * Retrieves all published articles. * * @access public * @return array $aArticles array of article objects */ function retrieveAll() { $dbh = & SGL_DB::singleton(); $c = &SGL_Config::singleton(); $conf = $c->getAll(); $query = " SELECT i.item_id, ia.addition AS title, ia2.addition AS description, i.start_date FROM {$conf['table']['item']} i, {$conf['table']['item_addition']} ia, {$conf['table']['item_addition']} ia2, {$conf['table']['item_type']} it, {$conf['table']['item_type_mapping']} itm, {$conf['table']['item_type_mapping']} itm2 WHERE ia.item_type_mapping_id = itm.item_type_mapping_id AND ia2.item_type_mapping_id = itm2.item_type_mapping_id AND it.item_type_id = itm.item_type_id AND i.item_id = ia.item_id AND i.item_id = ia2.item_id AND i.start_date < '" . SGL_Date::getTime() . "' AND (i.expiry_date > '" . SGL_Date::getTime() . "' OR i.expiry_date IS NULL) AND itm.field_name = 'title' AND it.item_type_id = 2 AND itm.field_type != itm2.field_type AND i.status = " . SGL_STATUS_PUBLISHED . " ORDER BY i.start_date DESC LIMIT 5 "; $aArticles = $dbh->getAll($query); if (!DB::isError($aArticles)) { return $aArticles; } else { SGL::raiseError('perhaps no item tables exist', SGL_ERROR_NODATA); } } function toHtml($aNewsItems) { SGL::logMessage(null, PEAR_LOG_DEBUG); $newItems = ''; if (is_array($aNewsItems) && count($aNewsItems)) { foreach ($aNewsItems as $key => $obj) { $newItems .= '' . 'item_id") . '">' . SGL_Date::formatPretty($obj->start_date) . "
" . ''.$obj->title.'' . '

'.SGL_String::summarise($obj->description, 20).'

'; } $newItems .= '

more ...

'; $syndicate = <<< HTML

Seagull RSS

HTML; $newItems .= $syndicate; return $newItems; } else { return 'no recent HTML Articles'; } } } ?>