function allHeadlines() { $s = new NewsStory(); $s->orderBy('date desc, rank desc, id desc'); $res = $s->find(array()); $out = array(); foreach ($res as $story) { if (strlen($story->title) > 33) { $story->title = substr($story->title, 0, 30) . '...'; } $out[$story->id] = Date::format($story->date, 'm/d') . ' - ' . $story->title; } return $out; }
<?php loader_import('news.Story'); loader_import('news.Functions'); $story = new NewsStory(); $story->limit($parameters['limit']); $story->orderBy('date desc, rank desc, id desc'); if (!isset($parameters['sec'])) { $params = array(); } else { $params = array('category' => $parameters['sec']); } $res = $story->find($params); if (!$res) { $res = array(); } echo template_simple('sidebar.spt', array('list' => $res, 'dates' => $parameters['dates'], 'thumbs' => $parameters['thumbs']));
if (!$parameters['query']) { echo template_simple('search.spt', $parameters); return; } loader_import('news.Functions'); loader_import('news.Story'); $story = new NewsStory(); if (!$parameters['limit']) { $parameters['limit'] = 10; } if (!$parameters['offset']) { $parameters['offset'] = 0; } $story->limit($parameters['limit']); $story->offset($parameters['offset']); loader_import('help.Help'); $params = array(); foreach (help_split_query($parameters['query']) as $item) { $q = db_quote('%' . $item . '%'); $params[] = 'title like ' . $q . ' or summary like ' . $q . ' or body like ' . $q; } $parameters['results'] = $story->find($params); $parameters['total'] = $story->total; loader_import('saf.GUI.Pager'); $pg = new Pager($parameters['offset'], $parameters['limit'], $parameters['total']); $pg->getInfo(); $pg->setUrl(site_prefix() . '/index/news-search-action?query=' . urlencode($parameters['query'])); template_simple_register('pager', $pg); echo template_simple('search.spt', $parameters);
//page_keywords ($obj->keywords); } $obj->context = $box['context']; echo template_simple('story.spt', $obj); } elseif (!empty($parameters['section'])) { // view section list if (!$parameters['limit']) { $parameters['limit'] = appconf('limit'); } if (!$parameters['offset']) { $parameters['offset'] = 0; } $story->limit($parameters['limit']); $story->offset($parameters['offset']); $story->orderBy('date desc, rank desc, id desc'); $list = $story->find(array('category' => $parameters['section'])); if (!$list) { echo template_simple('invalid_section.spt', array('error' => $story->error)); return; } $total = $story->total; loader_import('saf.GUI.Pager'); $pg = new Pager($parameters['offset'], $parameters['limit'], $total); $pg->setUrl(site_prefix() . '/index/news-app?section=' . $parameters['section']); $pg->getInfo(); $date = false; $newlist = array(); foreach ($list as $item) { if ($date != $item->date) { $date = $item->date; $i = new StdClass();