OSB enhancements to date
This commit is contained in:
36
modules/static_page/classes/controller/staticpage.php
Normal file
36
modules/static_page/classes/controller/staticpage.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides static pages
|
||||
*
|
||||
* @package OSB
|
||||
* @subpackage Page
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_StaticPage extends Controller_TemplateDefault {
|
||||
/**
|
||||
* By default show a menu of available categories
|
||||
* @todo Only show categories according to their validity dates
|
||||
*/
|
||||
public function action_view($id) {
|
||||
$sp = ORM::factory('staticpage',$id);
|
||||
|
||||
if (! $sp->loaded())
|
||||
Request::instance()->redirect('staticpage_category/index');
|
||||
|
||||
array_push($this->_control,
|
||||
array($sp->staticpage_category->name=>sprintf('staticpage_category/view/'.$sp->static_page_category_id)));
|
||||
array_push($this->_control,array($sp->staticpage_translate->title=>$this->request->uri()));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>$sp->staticpage_translate->title,
|
||||
'body'=>View::factory('staticpage/view')
|
||||
->set('record',$sp),
|
||||
));
|
||||
|
||||
$this->template->content = Block::factory();
|
||||
}
|
||||
}
|
@@ -0,0 +1,72 @@
|
||||
<?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 {
|
||||
protected $_control = array(
|
||||
array('Site Index'=>'staticpage_category'),
|
||||
);
|
||||
|
||||
/**
|
||||
* By default show a menu of available categories
|
||||
*/
|
||||
public function action_index() {
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Site Index Categories'),
|
||||
'body'=>View::factory('staticpage/category/list')
|
||||
->set('results',$this->_get_categories()),
|
||||
));
|
||||
|
||||
$this->template->content = Block::factory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the available topics in a category
|
||||
* @todo Only show categories according to their validity dates
|
||||
* @todo Obey sort order
|
||||
*/
|
||||
public function action_view($id) {
|
||||
$spc = ORM::factory('staticpage_category',$id);
|
||||
|
||||
if (! $spc->loaded())
|
||||
Request::instance()->redirect('welcome/index');
|
||||
|
||||
array_push($this->_control,array($spc->name=>$this->request->uri()));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s',_('Category'),$spc->name),
|
||||
'body'=>View::factory('staticpage/category/view')
|
||||
->set('results',$this->_get_category($spc->id)),
|
||||
));
|
||||
|
||||
$this->template->content = Block::factory();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
27
modules/static_page/classes/model/staticpage.php
Normal file
27
modules/static_page/classes/model/staticpage.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides static pages.
|
||||
*
|
||||
* @package OSB
|
||||
* @subpackage Static Page
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_StaticPage extends ORMOSB {
|
||||
protected $_table_name = 'static_page';
|
||||
|
||||
protected $_sorting = array(
|
||||
'name'=>'asc',
|
||||
);
|
||||
|
||||
protected $_has_many = array(
|
||||
'staticpage_translate'=>array('foreign_key'=>'static_page_id'),
|
||||
);
|
||||
|
||||
protected $_belongs_to = array(
|
||||
'staticpage_category'=>array('foreign_key'=>'static_page_category_id'),
|
||||
);
|
||||
}
|
19
modules/static_page/classes/model/staticpage/category.php
Normal file
19
modules/static_page/classes/model/staticpage/category.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides static page categories
|
||||
*
|
||||
* @package OSB
|
||||
* @subpackage Static Page
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_StaticPage_Category extends ORMOSB {
|
||||
protected $_table_name = 'static_page_category';
|
||||
|
||||
protected $_sorting = array(
|
||||
'name'=>'asc',
|
||||
);
|
||||
}
|
19
modules/static_page/classes/model/staticpage/translate.php
Normal file
19
modules/static_page/classes/model/staticpage/translate.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Static Page Translation
|
||||
*
|
||||
* @package OSB
|
||||
* @subpackage Static Page
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Model_StaticPage_Translate extends ORMOSB {
|
||||
protected $_table_name = 'static_page_translate';
|
||||
|
||||
protected $_belongs_to = array(
|
||||
'staticpage'=>array('foreign_key'=>'id'),
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user