Initial version

This commit is contained in:
Deon George 2014-06-30 14:22:57 +10:00
commit d4b3b0f9bc
18 changed files with 1262 additions and 0 deletions

6
.gitmodules vendored Normal file
View File

@ -0,0 +1,6 @@
[submodule "includes/kohana"]
path = includes/kohana
url = ssh://deon@l.dlcm.co:222/afs/local/git/lnkohana
[submodule "modules/lnApp"]
path = modules/lnApp
url = ssh://deon@l.dlcm.co:222/afs/local/git/lnapp

28
.htaccess Normal file
View File

@ -0,0 +1,28 @@
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /aer
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
AuthType Basic
AuthName "Restricted !"
# (Following line optional)
AuthBasicProvider file
AuthUserFile /local/WEB/sites/net.leenooks.dev/aer/.htuser
Require valid-user

170
application/bootstrap.php Normal file
View File

@ -0,0 +1,170 @@
<?php defined('SYSPATH') or die('No direct script access.');
// -- Environment setup --------------------------------------------------------
// Load the core Kohana class
require SYSPATH.'classes/Kohana/Core'.EXT;
if (is_file(APPPATH.'classes/Kohana'.EXT))
{
// Application extends the core
require APPPATH.'classes/Kohana'.EXT;
}
else
{
// Load empty core extension
require SYSPATH.'classes/Kohana'.EXT;
}
/**
* Set the default time zone.
*
* @link http://kohanaframework.org/guide/using.configuration
* @link http://www.php.net/manual/timezones
*/
date_default_timezone_set('Australia/Melbourne');
/**
* Set the default locale.
*
* @link http://kohanaframework.org/guide/using.configuration
* @link http://www.php.net/manual/function.setlocale
*/
setlocale(LC_ALL, 'en_US.utf-8');
/**
* Enable the Kohana auto-loader.
*
* @link http://kohanaframework.org/guide/using.autoloading
* @link http://www.php.net/manual/function.spl-autoload-register
*/
spl_autoload_register(array('Kohana', 'auto_load'));
/**
* Optionally, you can enable a compatibility auto-loader for use with
* older modules that have not been updated for PSR-0.
*
* It is recommended to not enable this unless absolutely necessary.
*/
//spl_autoload_register(array('Kohana', 'auto_load_lowercase'));
/**
* Enable the Kohana auto-loader for unserialization.
*
* @link http://www.php.net/manual/function.spl-autoload-call
* @link http://www.php.net/manual/var.configuration#unserialize-callback-func
*/
ini_set('unserialize_callback_func', 'spl_autoload_call');
// -- Configuration and initialization -----------------------------------------
/**
* Set the default language
*/
I18n::lang('en-us');
/**
* Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
*
* Note: If you supply an invalid environment name, a PHP warning will be thrown
* saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
*/
if (isset($_SERVER['KOHANA_ENV']))
{
Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV']));
}
/**
* Initialize Kohana, setting the default options.
*
* The following options are available:
*
* - string base_url path, and optionally domain, of your application NULL
* - string index_file name of your index file, usually "index.php" index.php
* - string charset internal character set used for input and output utf-8
* - string cache_dir set the internal cache directory APPPATH/cache
* - integer cache_life lifetime, in seconds, of items cached 60
* - boolean errors enable or disable error handling TRUE
* - boolean profile enable or disable internal profiling TRUE
* - boolean caching enable or disable internal caching FALSE
* - boolean expose set the X-Powered-By header FALSE
*/
Kohana::init(array(
'base_url' => '/aer',
'caching' => TRUE,
'index_file' => '',
));
/**
* Attach the file write to logging. Multiple writers are supported.
*/
Kohana::$log->attach(new Log_File(APPPATH.'logs'));
/**
* Attach a file reader to config. Multiple readers are supported.
*/
Kohana::$config->attach(new Config_File);
/**
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
'lnapp' => MODPATH.'lnApp', // lnApp Base Application Tools
// 'oauth' => MODPATH.'oauth', // OAuth Module for External Authentication
'auth' => SMDPATH.'auth', // Basic authentication
'cache' => SMDPATH.'cache', // Caching with multiple backends
// 'cron' => SMDPATH.'cron', // Kohana Cron Module
// 'codebench' => SMDPATH.'codebench', // Benchmarking tool
'database' => SMDPATH.'database', // Database access
// 'gchart' => MODPATH.'gchart', // Google Chart Module
// 'highchart' => MODPATH.'highchart', // Highcharts Chart Module
// 'image' => SMDPATH.'image', // Image manipulation
// 'khemail' => SMDPATH.'khemail', // Email module for Kohana 3 PHP Framework
// 'minion' => SMDPATH.'minion', // CLI Tasks
'orm' => SMDPATH.'orm', // Object Relationship Mapping
'pagination' => SMDPATH.'pagination', // Kohana Pagination module for Kohana 3 PHP Framework
// 'unittest' => SMDPATH.'unittest', // Unit testing
// 'userguide' => SMDPATH.'userguide', // User guide and API documentation
'xml' => SMDPATH.'xml', // XML module for Kohana 3 PHP Framework
));
/**
* Enable specalised interfaces
*/
Route::set('sections', '<directory>/<controller>(/<action>(/<id>(/<sid>)))',
array(
'directory' => '('.implode('|',array_values(URL::$method_directory)).')'
))
->defaults(array(
'action' => 'index',
));
// Static file serving (CSS, JS, images)
Route::set('default/media', 'media(/<file>)', array('file' => '.+'))
->defaults(array(
'controller' => 'media',
'action' => 'get',
));
/**
* Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI.
*/
Route::set('default', '(<controller>(/<action>(/<id>)))', array('id'=>'[a-zA-Z0-9_.-]+'))
->defaults(array(
'controller' => 'welcome',
'action' => 'index',
));
/**
* If APC is enabled, and we need to clear the cache
*/
if (file_exists(APPPATH.'cache/CLEAR_APC_CACHE') AND function_exists('apc_clear_cache') AND (PHP_SAPI !== 'cli')) {
if (! apc_clear_cache() OR ! unlink(APPPATH.'cache/CLEAR_APC_CACHE'))
throw new Kohana_Exception('Unable to clear the APC cache.');
}
// If we are a CLI, set our session dir
if (PHP_SAPI === 'cli')
session_save_path('tmp/');
?>

View File

@ -0,0 +1,113 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends the core Kohana class by adding some core application
* specific functions, and configuration.
*
* @package WWZ
* @category Helpers
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Config extends Kohana_Config {
// Our default logo, if there is no site logo
public static $logo = 'img/logo-small.png';
/**
* Some early initialisation
*
* At this point, KH hasnt been fully initialised either, so we cant rely on
* too many KH functions yet.
*
* NOTE: Kohana doesnt provide a parent construct for the Kohana_Config class.
*/
public function __construct() {
}
/**
* Get the singleton instance of Config.
*
* $config = Config::instance();
*
* @return Config
* @compat Restore KH 3.1 functionality
*/
public static function instance() {
if (Config::$_instance === NULL)
// Create a new instance
Config::$_instance = new Config;
return Config::$_instance;
}
/**
* Return our caching mechanism
*/
public static function cachetype() {
return is_null(Kohana::$config->load('config')->cache_type) ? 'file' : Kohana::$config->load('config')->cache_type;
}
public static function copywrite() {
return '(c) 2014 Deon George';
}
public static function country() {
return NULL;
}
/**
* Show a date using a site configured format
*/
public static function date($date) {
return (is_null($date) OR ! $date) ? '' : date('d-M-Y',$date);
}
public static function language() {
// @todo To implement
return 'auto';
}
/**
* The URI to show for the login prompt.
* Normally if the user is logged in, we can replace it with something else
*/
public static function login_uri() {
return ($ao = Auth::instance()->get_user() AND is_object($ao)) ? $ao->name() : HTML::anchor('login',_('Login'));
}
public static function logo() {
return HTML::image(static::logo_uri(),array('class'=>'headlogo','alt'=>_('Logo')));
}
public static function logo_uri($protocol=NULL) {
list ($path,$suffix) = explode('.',static::$logo);
return URL::site(Route::get('default/media')->uri(array('file'=>$path.'.'.$suffix),array('alt'=>static::sitename())),$protocol);
}
public static function siteid($format=FALSE) {
return '';
}
/**
* Work out our site mode (dev,test,prod)
*/
public static function sitemode() {
return Kohana::$config->load('config.site')->mode;
}
public static function sitename() {
return 'AER Translate';
}
public static function theme() {
return 'theme/'.Kohana::$config->load('config')->theme;
}
public static function version() {
// @todo Work out our versioning
return 'TBA';
}
}
?>

View File

@ -0,0 +1,218 @@
<?php defined('SYSPATH') or die('No direct script access.');
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php';
class Controller_Translate extends Controller_TemplateDefault {
private $_tags = array(
'span.aer_title',
'span.source_panel_heading',
'td.section_heading',
'td.standard_point ul li',
'span.source_panel_heading',
'td.document_name',
'td.collection',
'td.author',
'td.business_case_heading',
'span.source_panel_heading',
'span.target_panel_heading',
'td.grid_header',
'td.tco_label',
'td.summary_header',
'td.summary_tag',
'td.summary_data',
'span.target_mig_panel_heading',
);
private function aer() {
$file = '/local/WEB/sites/net.leenooks.dev/aer/application/media/aer/Honda Foundry_aer.htm';
// Fix errors in the HTML file
$data = file_get_contents($file);
$data = preg_replace('/<td class="grid_total"<td class="grid_header">/','<td class="grid_header">',$data);
return $data;
}
public function action_index() {
HTTP::redirect(URL::link('','translate/render'));
$output = '';
Block::factory()
->title('Hello')
->title_icon('icon-cog')
->body($output);
}
public function action_import() {
$html = new simple_html_dom();
$html->load($this->aer());
$this->store($html->find('head',0)->find('title',0));
foreach ($this->_tags as $z)
foreach ($html->find($z) as $x)
$this->store($x);
HTTP::redirect(URL::link('','translate/index'));
}
public function action_render() {
$output = '';
if ($this->request->post('language_id')) {
$html = new simple_html_dom();
$html->load($this->aer());
$x = $html->find('head',0);
$x->innertext .= '<meta http-equiv="content-type" content="text/html;charset=utf-8">';
$lo = ORM::factory('Language',$this->request->post('language_id'));
foreach ($this->_tags as $z)
foreach ($html->find($z) as $x)
$x->innertext = $this->translate($x,$lo);
// Convert order the img tags
foreach ($html->find('img') as $z) {
$z->src = sprintf('%s/%s',URL::site('media/aer'),$z->src);
}
$this->response->body($html);
$this->auto_render = FALSE;
// We dont know what sort of payment type yet
} else {
$x = $this->lang();
$output .= Form::open();
$output .= Form::select('language_id',ORM::factory('Language')->list_select(),$x->id);
$output .= Form::button('submit','Submit',array('class'=>'btn btn-primary'));
$output .= Form::close();
}
Block::factory()
->title('Render in...')
->title_icon('icon-share')
->body($output);
}
public function action_save() {
foreach ($this->request->post('x') as $id => $value) {
if (! $value)
continue;
$to = ORM::factory('Translate',array('language_id'=>$this->request->post('language_id'),'original_id'=>$id));
$to->translation = $value;
$to->language_id = $this->request->post('language_id');
$to->original_id = $id;
$to->save();
}
HTTP::redirect(sprintf('%s?language_id=%s&page=%s',URL::link('','translate/text'),$this->request->post('language_id'),$this->request->post('page')));
}
private function lang() {
foreach ($this->request->accept_lang() as $k=>$v) {
if (strlen($k) == 2)
$k = sprintf('%s_%s',strtolower($k),strtoupper($k));
else {
list($k,$v) = preg_split('/[-_]/',$k,2);
$k = sprintf('%s_%s',strtolower($k),strtoupper($v));
}
if ($x=ORM::factory('Language',array('iso'=>$k)))
return $x;
}
}
private function store(simple_html_dom_node $x,$l=0) {
if ($x->children()) {
foreach ($x->children() as $y) {
$this->store($y,$l+1);
$y->innertext = '%s';
}
}
// If we have a numeric value, convert it to %d
$x->innertext = preg_replace('/[0-9.]+/','%d',$x->innertext);
$oo = ORM::factory('Original',array('sentence'=>$x->innertext));
if (! trim($x->innertext) or (in_array(trim($x->innertext),array('$','&nbsp;')) or preg_match('/%d%?$/',$x->innertext))) {
return $x->innertext;
} elseif (! $oo->loaded()) {
$oo->sentence = $x->innertext;
$oo->save();
}
return $x->innertext;
}
private function translate(simple_html_dom_node $x,Model_Language $lo,$l=0) {
$nums = NULL;
$matches = array();
$dom_tmp = str_get_html($x->outertext);
$dom_tmp_node = $dom_tmp->firstChild();
$string = $this->store($dom_tmp_node,$l);
$oo = ORM::factory('Original',array('sentence'=>$string));
// If we have numbers, we'll need to save them.
if (preg_match('/%d/',$string))
$nums = preg_match('/[0-9.]+/',$x->innertext,$matches);
if ($oo->loaded()) {
$to = ORM::factory('Translate',array('original_id'=>$oo->id,'language_id'=>$lo->id));
$string = $to->loaded() ? $to->translation : $x->innertext;
}
if ($nums && $nums == 1)
$string = str_replace('%d',$matches[0],$string);
elseif ($nums > 1)
throw HTTP_Exception::factory('501','Argh, didnt allow for more than 1 match');
if ($x->children()) {
foreach ($x->children() as $y) {
$string = preg_replace('/%s/',$this->translate($y,$lo,$l+1),$string);
}
}
return $string;
}
public function action_text() {
$output = '';
if ($this->request->query('language_id')) {
$output .= Form::open(URL::link('','translate/save'));
$output .= Form::hidden('language_id',$this->request->query('language_id'));
$oo = ORM::factory('Original')
->select('translate.translation')
->join('translate','LEFT OUTER')
->on('original.id','=','translate.original_id')
->on('translate.language_id','=',$this->request->query('language_id'));
$output .= View::factory('translate')
->set('o',$oo->find_all());
// We dont know what sort of payment type yet
} else {
$x = $this->lang();
$output .= Form::open(NULL,array('method'=>'GET'));
$output .= Form::select('language_id',ORM::factory('Language')->list_select(),$x->id);
}
$output .= Form::button('submit','Submit',array('class'=>'btn btn-primary'));
$output .= Form::close();
Block::factory()
->title('Translate Text')
->title_icon('icon-share')
->body($output);
}
} // End Welcome

View File

@ -0,0 +1,10 @@
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Welcome extends Controller {
public function action_index()
{
HTTP::redirect(URL::link('','translate'));
}
} // End Welcome

View File

@ -0,0 +1,15 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class overrides Kohana's Cookie
*
* @package AER
* @category Modifications
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Cookie extends Kohana_Cookie {
public static $salt = 'AER';
}
?>

View File

@ -0,0 +1,30 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports AER Languages Memos.
*
* @package AER
* @category Models
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Language extends ORM_OSB {
// Relationships
protected $_belongs_to = array(
);
protected $_has_one = array(
);
protected $_form = array('id'=>'id','value'=>'name');
/**
* Filters used to format the display of values into friendlier values
*/
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),
),
);
}
?>

View File

@ -0,0 +1,28 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports AER Original Text Memos.
*
* @package AER
* @category Models
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Original extends ORM_OSB {
// Relationships
protected $_belongs_to = array(
);
protected $_has_one = array(
);
/**
* Filters used to format the display of values into friendlier values
*/
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),
),
);
}
?>

View File

@ -0,0 +1,30 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports AER Translated Text.
*
* @package AER
* @category Models
* @author Deon George
* @copyright (c) 2014 Deon George
* @license http://dev.leenooks.net/license.html
*/
class Model_Translate extends ORM_OSB {
// Relationships
protected $_belongs_to = array(
);
protected $_has_one = array(
);
protected $_form = array('id'=>'id','value'=>'translation');
/**
* Filters used to format the display of values into friendlier values
*/
protected $_display_filters = array(
'date_orig'=>array(
array('Config::datetime',array(':value')),
),
);
}
?>

View File

@ -0,0 +1,287 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends Kohana's [ORM] class to create defaults for OSB.
*
* @package OSB
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
abstract class ORM_OSB extends ORM {
/**
* @var string Database to connect to
*/
protected $_db = 'default';
protected $_created_column = array('column'=>'date_orig','format'=>TRUE);
protected $_updated_column = array('column'=>'date_last','format'=>TRUE);
// Our attributes used in forms.
protected $_form = array();
// Our attributes that should be converted to NULL when empty
protected $_nullifempty = array();
// Our attribute values that need to be stored as serialized
protected $_serialize_column = array();
// If we need to load any sub items on loading this model
protected $_sub_items = array();
protected $_sub_items_load = array();
protected $_sub_items_sorted = FALSE;
// Rules to assist with site ID and getting next record ID for inserts.
public function xrules() {
return array(
'id'=>array(
array('ORM_OSB::get_next_id',array(':model',':field')),
),
'site_id'=>array(
array('ORM_OSB::set_site_id',array(':model',':field')),
),
);
}
/**
* Retrieve and Store DB BLOB data.
*/
private function _blob($data,$set=FALSE) {
try {
return $set ? gzcompress($this->_serialize($data,$set)) : $this->_serialize(gzuncompress($data));
// Maybe the data isnt compressed?
} catch (Exception $e) {
return $this->_serialize($data,$set);
}
}
/**
* Auto process some data as it comes from the database
* @see parent::__get()
*/
public function __get($column) {
if (array_key_exists($column,$this->_table_columns)) {
// If the column is a blob, we'll decode it automatically
if (
$this->_table_columns[$column]['data_type'] == 'blob'
AND ! is_null($this->_object[$column])
AND ! isset($this->_changed[$column])
AND (! isset($this->_table_columns[$column]['auto_convert']) OR ! $this->_table_columns[$column]['auto_convert'])
) {
// In case our blob hasnt been saved as one.
try {
$this->_object[$column] = $this->_blob($this->_object[$column]);
}
catch(Exception $e) {
HTTP_Exception::factory(501,Kohana_Exception::text($e));
}
$this->_table_columns[$column]['auto_convert'] = TRUE;
}
// If the column is a serialized object, we'll unserialize it.
if (
in_array($column,$this->_serialize_column)
AND is_string($this->_object[$column])
AND ! is_null($this->_object[$column])
AND ! isset($this->_changed[$column])
AND (! isset($this->_table_columns[$column]['unserialized']) OR ! $this->_table_columns[$column]['unserialized'])
) {
// In case our object hasnt been saved as serialized.
try {
$this->_object[$column] = unserialize($this->_object[$column]);
}
catch(Exception $e) {
HTTP_Exception::factory(501,Kohana_Exception::text($e));
}
$this->_table_columns[$column]['unserialized'] = TRUE;
}
}
return parent::__get($column);
}
/**
* Intercept our object load, so that we can load our subitems
*/
protected function _load_values(array $values) {
parent::_load_values($values);
$sort = FALSE;
if ($this->_loaded AND $this->_sub_items_load AND count($this->_sub_items_load) == 1)
foreach ($this->_sub_items_load as $item => $sort)
$this->_sub_items = $this->$item->find_all()->as_array();
if ($sort) {
Sort::MAsort($this->_sub_items,$sort);
$this->_sub_items_sorted = TRUE;
}
return $this;
}
/**
* If a column is marked to be nullified if it is empty, this is where it is done.
*/
private function _nullifempty(array $array) {
foreach ($array as $k=>$v) {
if (is_array($v)) {
if (is_null($x=$this->_nullifempty($v)))
unset($array[$k]);
else
$array[$k] = $x;
} elseif (! $v AND $v !== 0 AND $v !== '0')
unset($array[$k]);
}
return count($array) ? $array : NULL;
}
/**
* Try and (un)serialize our data, and if it fails, just return it.
*/
private function _serialize($data,$set=FALSE) {
try {
return $set ? serialize($data) : unserialize($data);
// Maybe the data serialized?
} catch (Exception $e) {
return $data;
}
}
public function config($key) {
$mc = Config::instance()->module_config($this->_object_name);
return empty($mc[$key]) ? '' : $mc[$key];
}
public function dump() {
$result = array();
$result['this'] = $this->object();
foreach ($this->_sub_items as $o)
$result['sub'][] = $o->dump();
return $result;
}
/**
* Get Next record id
*
* @param array Validate object
* @param string Primary Key
*/
final public static function get_next_id($model,$field) {
if (! is_null($model->$field))
return TRUE;
$model->_changed[$field] = $field;
$ido = ORM::factory('Module')
->where('name','=',$model->_table_name)
->find();
if (! $ido->loaded())
throw new Kohana_Exception('Problem getting record_id for :table',array(':table'=>$model->_table_name));
$model->$field = $ido->record_id->next_id($ido->id);
return TRUE;
}
public function keyget($column,$key=NULL) {
if (is_null($key) OR ! is_array($this->$column))
return $this->$column;
else
return array_key_exists($key,$this->$column) ? $this->{$column}[$key] : NULL;
}
final public function mid() {
return ORM::factory('Module',array('name'=>$this->_table_name));
}
public function xsave(Validation $validation=NULL) {
// Find any fields that have changed, and process them.
if ($this->_changed)
foreach ($this->_changed as $c) {
// Any fields that are blobs, and encode them.
if (! is_null($this->_object[$c]) AND $this->_table_columns[$c]['data_type'] == 'blob') {
$this->_object[$c] = $this->_blob($this->_object[$c],TRUE);
// We need to reset our auto_convert flag
if (isset($this->_table_columns[$c]['auto_convert']))
$this->_table_columns[$c]['auto_convert'] = FALSE;
// Any fields that should be seriailzed, we'll do that.
} elseif (is_array($this->_object[$c]) AND in_array($c,$this->_serialize_column)) {
$this->_object[$c] = serialize($this->_object[$c]);
}
// Test if the value has still changed
if ($this->_original_values AND $this->_object[$c] == $this->_original_values[$c])
unset($this->_changed[$c]);
}
return parent::save($validation);
}
/**
* Set the site ID attribute for each row update
*/
final public static function set_site_id($model,$field) {
if (! is_null($model->$field))
return TRUE;
$model->_changed[$field] = $field;
$model->$field = Company::instance()->site();
return TRUE;
}
public function subitems() {
return $this->_sub_items;
}
/**
* Override the Kohana processing so we can null values if required.
*/
public function values(array $values,array $expected=NULL) {
foreach ($values as $k=>$v) {
// Convert to NULL
if (in_array($k,$this->_nullifempty)) {
if (is_array($v))
$values[$k] = $this->_nullifempty($v);
elseif (! $v AND $v !== 0 AND $v !== '0')
$values[$k] = NULL;
}
}
return parent::values($values,$expected);
}
/**
* Function help to find records that are active
*/
public function list_active($active=TRUE) {
$x=($active ? $this->_where_active() : $this);
return $x->find_all();
}
public function list_count($active=TRUE) {
$x=($active ? $this->_where_active() : $this);
return $x->find_all()->count();
}
}
?>

View File

@ -0,0 +1,31 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
return array
(
'default' => array
(
'type' => 'MySQL',
'connection' => array(
/**
* The following options are available for MySQL:
*
* string hostname server hostname, or socket
* string database database name
* string username database username
* string password database password
* boolean persistent use persistent connections?
* array variables system variables as "key => value" pairs
*
* Ports and sockets may be appended to the hostname.
*/
'hostname' => 'localhost',
'database' => 'weblnaer',
'username' => 'aer',
'password' => 'AeR',
'persistent' => TRUE,
),
'table_prefix' => '',
'charset' => 'utf8',
'caching' => FALSE,
),
);

View File

View File

@ -0,0 +1,130 @@
<!DOCTYPE html>
<html>
<head>
<title><?php echo $meta->title; ?></title>
<link rel="shortcut icon" href="<?php echo $meta->shortcut_icon ? $meta->shortcut_icon : '/favicon.ico' ?>" type="image/vnd.microsoft.icon" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="<?php echo $meta->language; ?>" />
<meta name="keywords" content="<?php echo $meta->keywords; ?>" />
<meta name="description" content="<?php echo $meta->description; ?>" />
<meta name="copyright" content="<?php echo Config::copywrite(); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<?php
if (Kohana::$environment >= Kohana::TESTING OR Request::current()->secure()) {
echo HTML::style('media/theme/bootstrap/css/bootstrap.min.css');
echo HTML::style('media/theme/bootstrap/css/bootstrap-responsive.min.css');
echo HTML::style('media/vendor/font-awesome/css/font-awesome.min.css');
} else {
echo HTML::style($meta->secure().'netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap.min.css');
echo HTML::style($meta->secure().'netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css');
echo HTML::style($meta->secure().'netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css');
}
echo HTML::style($meta->secure().'fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,800italic,400,600,800');
echo HTML::style('media/css/ui-lightness/jquery-ui-1.10.0.custom.min.css');
echo HTML::style('media/theme/baseadmin/css/base-admin-2.css');
echo HTML::style('media/theme/baseadmin/css/base-admin-2-responsive.css');
echo HTML::style('media/theme/baseadmin/css/custom.css');
echo Style::factory()->render_all();
?>
</head>
<body>
<?php if (! empty($shownavbar)) : ?>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"><i class="icon-cog"></i> </a>
<a class="brand" href="<?php echo URL::site(); ?>"><?php echo Config::sitename(); ?><sup></sup></a>
<div class="nav-collapse collapse">
<ul class="nav pull-right">
<?php echo $navbar; ?>
</ul>
<div class="navbar-search pull-right">
<div class="navbar-search-addon">
<i class="icon-search"></i>
<?php echo HTML::image('media/img/spinner.gif',array('class'=>'right','name'=>'searching')); ?>
<input type="text" name="search-query" class="search-query" placeholder="Search" data-provide="typeahead" disabled="disabled">
</div>
</div>
</div><!--/.nav-collapse -->
</div> <!-- /container -->
</div> <!-- /navbar-inner -->
</div> <!-- /nvarbar -->
<div class="subnavbar">
<div class="subnavbar-inner">
<div class="container">
<a class="btn-subnavbar collapsed" data-toggle="collapse" data-target=".subnav-collapse">
<i class="icon-reorder"></i>
</a>
<div class="subnav-collapse collapse">
<ul class="mainnav">
<li class="">
<a href="<?php echo URL::link('','index',TRUE); ?>"><i class="icon-home"></i> <span>Home</span></a>
</li>
<li class="">
<a href="<?php echo URL::link('','import',TRUE); ?>"><i class="icon-tasks"></i> <span>Import</span></a>
</li>
<li class="">
<a href="<?php echo URL::link('','text',TRUE); ?>"><i class="icon-tasks"></i> <span>Strings</span></a>
</li>
<li class="">
<a href="<?php echo URL::link('','render',TRUE); ?>"><i class="icon-tasks"></i> <span>Render</span></a>
</li>
<?php if (($ao = Auth::instance()->get_user()) AND $ao->isAdmin()) : ?>
<li class="">
<a href="<?php echo URL::link('admin','welcome',TRUE); ?>"><i class="icon-tasks"></i> <span>Admin</span></a>
</li>
<?php endif ?>
</ul>
</div> <!-- /.subnav-collapse -->
</div> <!-- /container -->
</div> <!-- /subnavbar-inner -->
</div> <!-- /subnavbar -->
<?php endif ?>
<div class="error_container">
<div class="error_details">
<div class="row">
<div class="span10 offset2">
<?php echo SystemMessage::factory()->render_all(); ?>
</div>
</div> <!-- /row -->
</div> <!-- /error_details -->
</div> <!-- /error_container -->
<div class="main">
<div class="container">
<div class="row">
<?php echo $content; ?>
</div> <!-- /row -->
</div> <!-- /container -->
</div> <!-- /main -->
<?php
if (Kohana::$environment >= Kohana::TESTING OR Request::current()->secure()) {
echo HTML::script('media/js/jquery/jquery-1.9.1.min.js');
echo HTML::script('media/theme/bootstrap/js/bootstrap.min.js');
echo HTML::script('media/js/lodash/lodash-1.2.1.min.js');
} else {
echo HTML::script($meta->secure().'code.jquery.com/jquery-1.9.1.min.js');
echo HTML::script($meta->secure().'netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js');
echo HTML::script($meta->secure().'cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.min.js');
}
echo HTML::script('media/theme/baseadmin/js/backtotop.js');
echo HTML::script('media/js/search.js');
echo HTML::script('media/js/custom.js');
echo Script::factory()->render_all();
?>
</body>
</html>

View File

@ -0,0 +1,33 @@
<?php $pag = new Pagination(array('total_items'=>$o->count(),'items_per_page'=>10)); ?>
<?php echo (string)$pag; ?>
<?php echo Form::hidden('page',$pag->current_page()); ?>
<table class="table table-striped table-condensed table-hover" id="list-table">
<thead><tr>
<th>Text</th>
<th>Translation</th>
<th>Ignore</th>
</tr></thead>
<tbody>
<?php $i=0;foreach ($o as $oo) : ?>
<?php
if (++$i < $pag->current_first_item())
continue;
elseif ($i > $pag->current_last_item())
break;
?>
<?php while (preg_match('/</',$oo->sentence) OR preg_match('/>/',$oo->sentence)) :
$oo->sentence = preg_replace('/</','&lt',$oo->sentence);
$oo->sentence = preg_replace('/>/','&gt',$oo->sentence);
endwhile
?>
<tr>
<td width="49%"><?php echo $oo->sentence; ?></td>
<td width="49%"><?php echo Form::input(sprintf('x[%s]',$oo->id),$oo->translation,array('style'=>'width: 100%;')); ?></td>
<!-- <td><?php echo Form::checkbox('ignore',FALSE); ?></td> -->
</tr>
<?php endforeach ?>
</tbody>
</table>

1
includes/kohana Submodule

@ -0,0 +1 @@
Subproject commit e2475dba9e6eaeafc6ecc4c71542937638354cd4

131
index.php Normal file
View File

@ -0,0 +1,131 @@
<?php
/**
* The directory in which your application specific resources are located.
* The application directory must contain the bootstrap.php file.
*
* @link http://kohanaframework.org/guide/about.install#application
*/
$application = 'application';
/**
* The directory in which your modules are located.
*
* @link http://kohanaframework.org/guide/about.install#modules
*/
$modules = 'modules';
/**
* The directory in which upstream Kohana resources (modules) are located.
*/
$sysmodules = 'includes/kohana/modules';
/**
* The directory in which the Kohana resources are located. The system
* directory must contain the classes/kohana.php file.
*
* @link http://kohanaframework.org/guide/about.install#system
*/
$system = 'includes/kohana/system';
/**
* The default extension of resource files. If you change this, all resources
* must be renamed to use the new extension.
*
* @link http://kohanaframework.org/guide/about.install#ext
*/
define('EXT', '.php');
/**
* Set the PHP error reporting level. If you set this in php.ini, you remove this.
* @link http://www.php.net/manual/errorfunc.configuration#ini.error-reporting
*
* When developing your application, it is highly recommended to enable notices
* and strict warnings. Enable them by using: E_ALL | E_STRICT
*
* In a production environment, it is safe to ignore notices and strict warnings.
* Disable them by using: E_ALL ^ E_NOTICE
*
* When using a legacy application with PHP >= 5.3, it is recommended to disable
* deprecated notices. Disable with: E_ALL & ~E_DEPRECATED
*/
error_reporting(E_ALL | E_STRICT);
/**
* End of standard configuration! Changing any of the code below should only be
* attempted by those with a working knowledge of Kohana internals.
*
* @link http://kohanaframework.org/guide/using.configuration
*/
// Set the full path to the docroot
define('DOCROOT', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR);
// Make the application relative to the docroot, for symlink'd index.php
if ( ! is_dir($application) AND is_dir(DOCROOT.$application))
$application = DOCROOT.$application;
// Make the modules relative to the docroot, for symlink'd index.php
if ( ! is_dir($modules) AND is_dir(DOCROOT.$modules))
$modules = DOCROOT.$modules;
// Make the system relative to the docroot, for symlink'd index.php
if ( ! is_dir($sysmodules) AND is_dir(DOCROOT.$sysmodules))
$sysmodules = DOCROOT.$sysmodules;
// Make the system relative to the docroot, for symlink'd index.php
if ( ! is_dir($system) AND is_dir(DOCROOT.$system))
$system = DOCROOT.$system;
// Define the absolute paths for configured directories
define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR);
define('SMDPATH', realpath($sysmodules).DIRECTORY_SEPARATOR);
define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
// Clean up the configuration vars
unset($application, $modules, $sysmodules, $system);
if (file_exists('install'.EXT))
{
// Load the installation check
return include 'install'.EXT;
}
/**
* Define the start time of the application, used for profiling.
*/
if ( ! defined('KOHANA_START_TIME'))
{
define('KOHANA_START_TIME', microtime(TRUE));
}
/**
* Define the memory usage at the start of the application, used for profiling.
*/
if ( ! defined('KOHANA_START_MEMORY'))
{
define('KOHANA_START_MEMORY', memory_get_usage());
}
// Bootstrap the application
require APPPATH.'bootstrap'.EXT;
if (PHP_SAPI == 'cli') // Try and load minion
{
class_exists('Minion_Task') OR die('Please enable the Minion module for CLI support.');
set_exception_handler(array('Minion_Exception', 'handler'));
Minion_Task::factory(Minion_CLI::options())->execute();
}
else
{
/**
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
* If no source is specified, the URI will be automatically detected.
*/
echo Request::factory(TRUE, array(), FALSE)
->execute()
->send_headers(TRUE)
->body();
}

1
modules/lnApp Submodule

@ -0,0 +1 @@
Subproject commit a889d25eda0d6c1b8766b15f2d71f3dd4f0357d9