More udpates from other projects
This commit is contained in:
parent
39406e1f76
commit
123ae34beb
4
classes/Kohana.php
Normal file
4
classes/Kohana.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
class Kohana extends lnApp_Core {}
|
||||||
|
?>
|
4
classes/StaticList.php
Normal file
4
classes/StaticList.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
abstract class StaticList extends lnApp_StaticList {}
|
||||||
|
?>
|
4
classes/StaticList/YesNo.php
Normal file
4
classes/StaticList/YesNo.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
class StaticList_YesNo extends lnApp_StaticList_YesNo {}
|
||||||
|
?>
|
52
classes/lnApp/Core.php
Normal file
52
classes/lnApp/Core.php
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class overrides Kohana's Core
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Modifications
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2014 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_Core extends Kohana_Core {
|
||||||
|
/**
|
||||||
|
* Work out our Class Name as per Kohana's standards
|
||||||
|
*/
|
||||||
|
public static function classname($name) {
|
||||||
|
return str_replace(' ','_',ucwords(strtolower(str_replace('_',' ',$name))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find files using a multi-site enabled application
|
||||||
|
*
|
||||||
|
* In order of precedence, we'll return:
|
||||||
|
* 1) site-theme file, ie: site/X/THEME/${file}
|
||||||
|
* 2) site file, ie: site/X/${file}
|
||||||
|
* 3) theme file, ie: THEME/${file}
|
||||||
|
* 4) normal search, ie: ${file}
|
||||||
|
*/
|
||||||
|
public static function find_file($dir,$file,$ext=NULL,$array=FALSE) {
|
||||||
|
// Limit our scope to the following dirs
|
||||||
|
// @note, we cannot have classes checked, since Config() doesnt exist yet
|
||||||
|
$dirs = array('views','media');
|
||||||
|
|
||||||
|
if (! in_array($dir,$dirs) OR PHP_SAPI === 'cli')
|
||||||
|
return parent::find_file($dir,$file,$ext,$array);
|
||||||
|
|
||||||
|
$prefixes = array('');
|
||||||
|
|
||||||
|
// Our search order.
|
||||||
|
array_unshift($prefixes,Site::Theme().'/');
|
||||||
|
array_unshift($prefixes,sprintf('site/%s/',Site::ID()));
|
||||||
|
array_unshift($prefixes,sprintf('site/%s/%s/',Site::ID(),Site::Theme()));
|
||||||
|
|
||||||
|
foreach ($prefixes as $p)
|
||||||
|
if ($x = parent::find_file($dir,$p.$file,$ext,$array))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// We found a path.
|
||||||
|
return $x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -32,6 +32,13 @@ abstract class lnApp_Site {
|
|||||||
return sprintf('%s %s',self::Date($date),self::Time($date));
|
return sprintf('%s %s',self::Date($date),self::Time($date));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the site configured language
|
||||||
|
*/
|
||||||
|
public static function ID() {
|
||||||
|
return Kohana::$config->load('config')->id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the site configured language
|
* Return the site configured language
|
||||||
*/
|
*/
|
||||||
|
66
classes/lnApp/StaticList.php
Normal file
66
classes/lnApp/StaticList.php
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is class renders standard lists and their values
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010-2014 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_StaticList {
|
||||||
|
// Our Static Items List
|
||||||
|
abstract protected function _table();
|
||||||
|
|
||||||
|
// Due to static scope, sometimes we need to call this function from the child class.
|
||||||
|
protected function _get($id) {
|
||||||
|
$table = $this->_table();
|
||||||
|
|
||||||
|
if (! $table)
|
||||||
|
return 'No Table';
|
||||||
|
elseif (! $id AND empty($table[$id]))
|
||||||
|
return '';
|
||||||
|
elseif (empty($table[$id]))
|
||||||
|
return sprintf('No Value (%s)',$id);
|
||||||
|
else
|
||||||
|
return $table[$id];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup our class instantiation
|
||||||
|
* @note This must be declared in the child class due to static scope
|
||||||
|
*/
|
||||||
|
public static function factory() {
|
||||||
|
$x = get_called_class();
|
||||||
|
|
||||||
|
return new $x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders form input
|
||||||
|
*
|
||||||
|
* @param string Form name to render
|
||||||
|
* @param string Default value to populate in the Form input.
|
||||||
|
*/
|
||||||
|
public static function form($name,$default='',$addblank=FALSE,array $attributes=NULL) {
|
||||||
|
$table = self::factory()->_table();
|
||||||
|
|
||||||
|
if ($addblank)
|
||||||
|
$table = array_merge(array(''=>' '),$table);
|
||||||
|
|
||||||
|
return Form::Select($name,$table,$default,$attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists our available keys
|
||||||
|
*/
|
||||||
|
public static function keys() {
|
||||||
|
return array_keys(self::factory()->_table());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table() {
|
||||||
|
return self::factory()->_table();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
29
classes/lnApp/StaticList/YesNo.php
Normal file
29
classes/lnApp/StaticList/YesNo.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is class renders Yes/No responses and forms.
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @category Helpers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2009-2013 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
abstract class lnApp_StaticList_YesNo extends StaticList {
|
||||||
|
protected function _table() {
|
||||||
|
return array(
|
||||||
|
0=>_('No'),
|
||||||
|
1=>_('Yes'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function get($value,$format=FALSE) {
|
||||||
|
if (! $value)
|
||||||
|
$value = 0;
|
||||||
|
|
||||||
|
return $format ? View::factory(Site::Theme().'/label/bool')
|
||||||
|
->set('label',$value ? 'label-success' : '')
|
||||||
|
->set('column',self::factory()->_get($value)) : $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
@ -11,10 +11,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'date_format' => 'd-M-Y',
|
'id' => '', // Site ID, for mullti site usage
|
||||||
'language' => 'auto',
|
'date_format' => 'd-M-Y', // Site Date Format
|
||||||
'method_security' => FALSE,
|
'language' => 'auto', // Site Language
|
||||||
'theme' => 'bootstrap',
|
'method_security' => FALSE, // Enable User Based method security
|
||||||
'time_format' => 'H:i:s',
|
'theme' => 'bootstrap', // Site Theme
|
||||||
|
'time_format' => 'H:i:s', // Site Time Format
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
|
1
views/theme/bootstrap/label/bool.php
Normal file
1
views/theme/bootstrap/label/bool.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<span class="label <?php echo $label; ?>" style="font-weight: normal;"><?php echo $column; ?></span>
|
Reference in New Issue
Block a user