//$pm->setVariable('categoryid', $settings['categoryid']); // get articles; limit to this category and valid publication date $articles = new Model_News_Article(); $categories = new Model_News_Category(); if (isset($settings['categoryid']) && is_array($settings['categoryid']) && count($settings['categoryid']) && !in_array(0, $settings['categoryid'])) { $articles->where('news.categoryid IN ?', $settings['categoryid']); $categories->where('categoryid IN ?', $settings['categoryid']); } $articles->where('pubdate <= ?', Typeframe::Now()); $articles->where('expdate > ? OR expdate = ? OR expdate IS NULL', Typeframe::Now(), '0000-00-00 00:00:00'); $articles->where('status = ?', 'published'); $total = $articles->count(); // set up pagination $perpage = !empty($settings['perpage']) ? $settings['perpage'] : 20; $pag = Pagination::Calculate($total, $perpage); $articles->paginate($pag['page'], $pag['perpage']); $pm->setVariable('pagination', $pag); $settings = Typeframe::CurrentPage()->settings(); // add articles, pagination to template $pm->setVariable('news', $articles); //$pm->setVariableArray(Pagination::Calculate($articles->getTotal(), // $perpage, $articles->getCurrentPage())); // get categories; limit to the given parent category //$categories = new News_Category_Factory(); $categories = new Model_News_Category(); //if ($categoryid) $categories->where('parentid IN ?', $categoryid); //$categories->setParentId($categoryid); // add parent category to template /*if ($category) { $pm->addLoop('crumbs', $category);
*/ // get sorting options list($sort_options, $sort, $order) = News::GetAdminSortingOptions(); // set sorting in template $pm->setVariable('sort_options', $sort_options); $pm->setVariable('sort', $sort); if (!empty($_REQUEST['pageid'])) { $page = Model_Page::Get($_REQUEST['pageid']); if (!$page->exists() || $page['application'] != 'News' && $page['application'] != 'News RSS') { Typeframe::Redirect('Invalid page specified.', Typeframe::CurrentPage()->applicationUri(), 1); return; } $pm->setVariable('currentpage', $page); } $newspages = new Model_Page(); $newspages->where('application = ?', 'News'); $pm->setVariable('newspages', $newspages); $articles = new Model_News_Article(); $total = $articles->count(); if (!empty($_REQUEST['status'])) { $articles->where('status = ?', $_REQUEST['status']); } $articles->order($order); // set up pagination $page = @$_REQUEST['page'] && ctype_digit($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $perpage = isset($settings['perpage']) ? $settings['perpage'] : 10; //$articles->setPagination($page, $perpage); $articles->paginate($page, $perpage); // add pagination, articles to template $pm->setVariable('pagination', Pagination::Calculate($total, $perpage, $page)); $pm->setVariable('news', $articles);