Open Source Billing

This commit is contained in:
Deon George
2013-10-10 13:44:53 +11:00
commit b02d70adf0
2344 changed files with 392978 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?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 = $this->request->param('id');
$sp = ORM::factory('staticpage',$id);
if (! $sp->loaded())
Request::current()->redirect('staticpage_category/index');
Breadcrumb::name($this->request->uri(),$sp->staticpage_translate->find()->title);
Block::add(array(
'title'=>$sp->staticpage_translate->find()->title,
'body'=>View::factory($this->viewpath())
->set('record',$sp),
));
}
}
?>

View File

@@ -0,0 +1,70 @@
<?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() {
HTTP::redirect('staticpage_category/list');
}
public function action_list() {
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
*/
public function action_view() {
$id = $this->request->param('id');
$spc = ORM::factory('staticpage_category',$id);
if (! $spc->loaded())
HTTP::redirect('welcome/index');
Breadcrumb::name($this->request->uri(),$spc->name);
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();
}
}
?>

View File

@@ -0,0 +1,28 @@
<?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 ORM_OSB {
protected $_table_name = 'static_page';
protected $_sorting = array(
'name'=>'asc',
);
protected $_has_many = array(
'staticpage_translate'=>array('foreign_key'=>'static_page_id','far_key'=>'id'),
);
protected $_belongs_to = array(
'staticpage_category'=>array('foreign_key'=>'static_page_category_id'),
);
}
?>

View File

@@ -0,0 +1,20 @@
<?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 ORM_OSB {
protected $_table_name = 'static_page_category';
protected $_sorting = array(
'name'=>'asc',
);
}
?>

View File

@@ -0,0 +1,20 @@
<?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 ORM_OSB {
protected $_table_name = 'static_page_translate';
protected $_belongs_to = array(
'staticpage'=>array('foreign_key'=>'id'),
);
}
?>

View File

@@ -0,0 +1,8 @@
<!-- @todo Move this back into the controller, so that we only have HTML views -->
<table width="100%" border="0">
<?php foreach ($results as $value) { ?>
<tr>
<td class="menu"><a href="<?php echo URL::site(Request::current()->uri(array('action'=>'view','id'=>$value->id))); ?>"><?php echo $value->name; ?></a></td>
</tr>
<?php } ?>
</table>

View File

@@ -0,0 +1,40 @@
<?php
if (! count($results)) {
echo _('Sorry, no pages were found in this category, or your account is not authorized for this category.');
return;
}
foreach ($results as $record) {
// Load the language
$translate = $record->staticpage_translate->where('static_page_id','=',$record->id)->and_where('language_id','=','fr')->find();
// If there isnt a translated page, show the default language
// @todo - default language should come from configuration
if (! $translate->loaded())
$translate = $record->staticpage_translate->where('static_page_id','=',$record->id)->and_where('language_id','=','en')->find();
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_background">
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr valign="top">
<td class="heading"><a href="<?php echo URL::site('staticpage/view/'.$record->id);?>"><?php echo $translate->title; ?></a></td>
</tr>
<tr>
<td style="background-color: #FFFFFF;">
<table width="100%" border="0" cellpadding="4">
<tr>
<td class="body"><?php echo $translate->body_intro; ?></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br/>
<?php
}
?>

View File

@@ -0,0 +1,32 @@
<?php
if (! $record) {
echo _('Sorry, no pages were found in this category, or your account is not authorized for this category.');
return;
}
// Load the language
$translate = $record->staticpage_translate->where('static_page_id','=',$record->id)->and_where('language_id','=','fr')->find();
// If there isnt a translated page, show the default language
// @todo - default language should come from configuration
if (! $translate->loaded())
$translate = $record->staticpage_translate->where('static_page_id','=',$record->id)->and_where('language_id','=','en')->find();
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_background">
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td style="background-color: #FFFFFF;">
<table width="100%" border="0" cellpadding="4">
<tr>
<td class="body"><?php echo $translate->body_full; ?></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>