75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php
|
|
|
|
$page = "browse_pages";
|
|
include "header.php";
|
|
|
|
|
|
$p = rc_toolkit::get_request('p', 1);
|
|
$s = rc_toolkit::get_request('s');
|
|
|
|
|
|
$keyword = rc_toolkit::get_request('keyword');
|
|
$cat_id = rc_toolkit::get_request('cat_id');
|
|
|
|
|
|
$sort_map = array(
|
|
'title' => 'page_name ASC',
|
|
'created' => 'page_id DESC',
|
|
'updated' => 'page_updated_at DESC',
|
|
);
|
|
|
|
$session_object =& SESession::getInstance();
|
|
if (array_key_exists($s, $sort_map)) {
|
|
$session_object->set('page_browse_sort_by', $s);
|
|
}
|
|
$s = $session_object->get('page_browse_sort_by','title');
|
|
|
|
$rc_page = new rc_page();
|
|
|
|
$catlang_ids = $rc_page->page_cat_languages();
|
|
$pagecat_languagevar_id = null;
|
|
if (array_key_exists($cat_id, $catlang_ids)) {
|
|
$pagecat_languagevar_id = $catlang_ids[$cat_id];
|
|
}
|
|
else {
|
|
$cat_id = 0;
|
|
}
|
|
|
|
|
|
|
|
$cs = array("page_status='1'");
|
|
|
|
if ($cat_id) {
|
|
$cs['cat'] = "page_pagecat_id = '$cat_id' OR pagecat_dependency = '$cat_id'";
|
|
}
|
|
if ($keyword) {
|
|
$cs['key'] = "page_name LIKE '%$keyword%'";
|
|
}
|
|
$where = rc_toolkit::criteria_builder($cs,'AND',true);
|
|
|
|
|
|
|
|
$total_pages = $rc_page->CountByCriteria($where);
|
|
|
|
$pages_per_page = 10;
|
|
$page_vars = make_page($total_pages, $pages_per_page, $p);
|
|
|
|
|
|
$pages = $rc_page->get_records("$where ORDER BY $sort_map[$s] LIMIT {$page_vars[0]}, $pages_per_page");
|
|
|
|
//rc_toolkit::debug($page_vars, $total_pages);
|
|
|
|
$smarty->assign('s', $s);
|
|
$smarty->assign('pages', $pages);
|
|
$smarty->assign('total_pages', $total_pages);
|
|
$smarty->assign('p', $page_vars[1]);
|
|
$smarty->assign('maxpage', $page_vars[2]);
|
|
$smarty->assign('p_start', $page_vars[0]+1);
|
|
$smarty->assign('p_end', $page_vars[0]+count($pages));
|
|
|
|
$smarty->assign_by_ref('cats', $rc_page->page_categories());
|
|
$smarty->assign('pagecat_languagevar_id', $pagecat_languagevar_id);
|
|
$smarty->assign('cat_id', $cat_id);
|
|
$smarty->assign('keyword', $keyword);
|
|
include "footer.php";
|