2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides static menu categories
|
|
|
|
*
|
|
|
|
* @package OSB
|
|
|
|
* @subpackage Page
|
|
|
|
* @category Controllers
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2010 Deon George
|
|
|
|
* @license http://dev.leenooks.net/license.html
|
|
|
|
*/
|
|
|
|
class Controller_StaticPage_Category extends Controller_TemplateDefault {
|
|
|
|
/**
|
|
|
|
* By default show a menu of available categories
|
|
|
|
*/
|
|
|
|
public function action_index() {
|
2012-11-09 23:13:57 +00:00
|
|
|
HTTP::redirect('staticpage_category/list');
|
2011-12-21 01:39:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function action_list() {
|
2010-11-29 22:41:08 +00:00
|
|
|
Block::add(array(
|
|
|
|
'title'=>_('Site Index Categories'),
|
|
|
|
'body'=>View::factory('staticpage/category/list')
|
|
|
|
->set('results',$this->_get_categories()),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the available topics in a category
|
|
|
|
* @todo Only show categories according to their validity dates
|
|
|
|
* @todo Obey sort order
|
|
|
|
*/
|
2012-11-09 23:13:57 +00:00
|
|
|
public function action_view() {
|
|
|
|
$id = $this->request->param('id');
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
$spc = ORM::factory('staticpage_category',$id);
|
|
|
|
|
|
|
|
if (! $spc->loaded())
|
2012-11-09 23:13:57 +00:00
|
|
|
HTTP::redirect('welcome/index');
|
2010-11-29 22:41:08 +00:00
|
|
|
|
2011-05-14 07:35:33 +00:00
|
|
|
Breadcrumb::name($this->request->uri(),$spc->name);
|
2010-11-29 22:41:08 +00:00
|
|
|
|
|
|
|
Block::add(array(
|
|
|
|
'title'=>sprintf('%s: %s',_('Category'),$spc->name),
|
|
|
|
'body'=>View::factory('staticpage/category/view')
|
|
|
|
->set('results',$this->_get_category($spc->id)),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain a list of pages in a category
|
|
|
|
*/
|
|
|
|
private function _get_category($id) {
|
|
|
|
return ORM::factory('staticpage')
|
|
|
|
->where('static_page_category_id','=',$id)
|
|
|
|
->find_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain a list of our categories
|
|
|
|
* @todo Only show categories according to the users group memeberhsip
|
|
|
|
* @todo Obey sort order
|
|
|
|
*/
|
|
|
|
private function _get_categories() {
|
|
|
|
return ORM::factory('staticpage_category')
|
|
|
|
->find_all();
|
|
|
|
}
|
|
|
|
}
|
2011-08-16 02:27:19 +00:00
|
|
|
?>
|