Revize 207
Přidáno uživatelem Michal Kliment před více než 15 roky(ů)
freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'original term' => 'Původní výraz',
|
||
'ospf area id' => 'OSPF area ID',
|
||
'outbound' => 'odchozí',
|
||
'page title' => 'Titulek stránky',
|
||
'password successfully changed' => 'Heslo úspěšně změněno',
|
||
'password' => 'Heslo',
|
||
'pay from account' => 'Platit z účtu',
|
||
... | ... | |
'subnets' => 'Podsítě',
|
||
'suppliers account' => '',
|
||
'surname' => 'Příjmení',
|
||
'system settings' => 'Nastavení systému',
|
||
'system variables' => 'Systémové proměnné',
|
||
'system variables were successfully updated' => 'Systémové proměnné byly úspěšně aktualizovány',
|
||
'system variables werent successfully updated' => 'Systémové proměnné nebyly úspěšně aktualizovány',
|
||
'tag_802_1q' => 'tag 802.1Q',
|
||
'technology' => 'Technologie',
|
||
'the transfer successfully done' => 'Transakce úspěšně dokončena',
|
freenetis/trunk/kohana/application/models/config.php | ||
---|---|---|
parent::__construct();
|
||
}
|
||
|
||
public function get_db_schema_version()
|
||
public function get_value_from_name($name = '')
|
||
{
|
||
$this->db->where('name','db_schema_version');
|
||
$result = $this->db->query('select value from config where name = "db_schema_version"');
|
||
return (count($result)) ? $result[0]->value : 0;
|
||
$result = $this->db->query('select value from config where name = "'.$name.'"');
|
||
return (count($result)) ? $result[0]->value : '';
|
||
}
|
||
|
||
public function get_all_values()
|
||
{
|
||
return $this->db->query('select name, value from config order by name');
|
||
}
|
||
|
||
public function check_exist_variable($name = '')
|
||
{
|
||
return count ($result = $this->db->query('select value from config where name = "'.$name.'"'));
|
||
}
|
||
|
||
public function update_variable($name,$value)
|
||
{
|
||
return $this->db->query('update config set value = "'.$value.'" where name = "'.$name.'"');
|
||
}
|
||
|
||
public function insert_variable($name,$value)
|
||
{
|
||
return $this->db->query('insert into config (name,value) values("'.$name.'","'.$value.'")');
|
||
}
|
||
|
||
public function set_db_schema_version($revision = NULL)
|
||
{
|
||
if ($revision)
|
freenetis/trunk/kohana/application/controllers/settings.php | ||
---|---|---|
<?php
|
||
class Settings_Controller extends Controller {
|
||
|
||
function index()
|
||
{
|
||
url::redirect(url_lang::base().'settings/system');
|
||
}
|
||
|
||
function system()
|
||
{
|
||
|
||
// access control
|
||
if (!$this->acl_check_edit(get_class($this),'system'))
|
||
Controller::error(1);
|
||
|
||
// creating of new forge
|
||
$this->form = new Forge(url_lang::base()."settings/system", '', 'POST', array('id' => 'article_form'));
|
||
$this->form->set_attr('class', 'form_class')->set_attr('method', 'post');
|
||
|
||
$this->form->group('')->label(url_lang::lang('texts.System variables'));
|
||
|
||
// just only variable page title
|
||
$this->form->input('title')->label(url_lang::lang('texts.Page title').':')->rules('length[3,40]')->value($this->setting->title);
|
||
|
||
$this->form->submit('submit')->value(url_lang::lang('texts.Save'));
|
||
special::required_forge_style($this->form, ' *', 'required');
|
||
|
||
// form validate
|
||
if ($this->form->validate())
|
||
{
|
||
$form_data = $this->form->as_array();
|
||
|
||
$config_model = new Config_Model();
|
||
|
||
$issaved = true;
|
||
|
||
foreach ($form_data as $name => $value)
|
||
{
|
||
// check if variable exists
|
||
if ($config_model->check_exist_variable($name))
|
||
// update of variable
|
||
$issaved = $issaved && $config_model->update_variable($name,$value);
|
||
else
|
||
// insert new variable
|
||
$issaved = $issaved && $config_model->insert_variable($name,$value);
|
||
}
|
||
if ($issaved)
|
||
// if all action were succesfull
|
||
$this->session->set_flash('message', url_lang::lang('texts.System variables were successfully updated').'.');
|
||
else
|
||
// if not
|
||
$this->session->set_flash('message', url_lang::lang('texts.System variables werent successfully updated').'.');
|
||
|
||
url::redirect(url_lang::base().'settings/system');
|
||
}
|
||
|
||
// create view for this template
|
||
$view = new View('template');
|
||
$view->header = new View('base/header');
|
||
$view->footer = new View('base/footer');
|
||
$view->content = new View('settings/system');
|
||
$view->content->form = $this->form->html();
|
||
$view->content->headline = url_lang::lang('texts.System settings');
|
||
$view->header->menu = Controller::render_menu();
|
||
$view->header->title = url_lang::lang('texts.System settings');
|
||
$view->render(TRUE);
|
||
}
|
||
|
||
}
|
||
?>
|
freenetis/trunk/kohana/application/libraries/Setting.php | ||
---|---|---|
<?php defined('SYSPATH') or die('No direct script access.');
|
||
|
||
class Setting
|
||
{
|
||
private $config = NULL;
|
||
|
||
private $title = 'FreeNetIS';
|
||
private $db_schema_version = 0;
|
||
|
||
public function __construct()
|
||
{
|
||
// creating of config model
+ $this->config = new Config_Model();
|
||
}
|
||
|
||
function __get($property)
|
||
{
|
||
try // try if query return exception, for example config table doesn't exist
|
||
{
|
||
return $this->config->get_value_from_name($property);
|
||
}
|
||
catch (Kohana_Database_Exception $e)
|
||
{
|
||
// then return default value for some defined private atribute
|
||
return (isset($this->$property)) ? $this->$property : NULL;
|
||
}
|
||
}
|
||
|
||
}
|
freenetis/trunk/kohana/application/libraries/MY_Controller.php | ||
---|---|---|
public $gacl_class;
|
||
private $myMenu;
|
||
public $arr;
|
||
public $setting = NULL;
|
||
|
||
private $ICON_ERROR = 1;
|
||
private $ICON_GOOD = 2;
|
||
... | ... | |
|
||
parent::__construct();
|
||
//authentication goes here for example
|
||
|
||
|
||
if(!$this->test_db())
|
||
{
|
||
$this->error(3);
|
||
die();
|
||
}
|
||
|
||
try
|
||
{
|
||
$config = new Config_Model();
|
||
if(!$config->get_db_schema_version()) url::redirect(url_lang::base().'installation');
|
||
else if (url_lang::current()=='installation') url::redirect(url_lang::base().'login');
|
||
}
|
||
catch (Kohana_Database_Exception $e)
|
||
{
|
||
if (url_lang::current()!='installation') url::redirect(url_lang::base().'installation');
|
||
}
|
||
$this->setting = new Setting();
|
||
|
||
|
||
if (!$this->setting->db_schema_version && url_lang::current()!='installation') url::redirect(url_lang::base().'installation');
|
||
|
||
|
||
if (!$this->session->get('user_id', 0) && url_lang::current()!='login' && url_lang::current()!='registration' && url_lang::current()!='scheduler/run' && substr(url_lang::current(),0,9)!='redirect/' && url_lang::current()!='installation')
|
||
{
|
||
// Not logged in - redirect to login page
|
||
... | ... | |
$this->showbox($message, $this->ICON_ERROR, $content);
|
||
break;
|
||
}
|
||
// must be die() - else it will be render twice !
|
||
die();
|
||
}
|
||
|
||
public function warning($message, $content = NULL)
|
||
... | ... | |
if ($this->acl_check_2D('menu', 'administration'))
|
||
$myMenu .= '<li class="administration"><h2>'.url_lang::lang('texts.Administration').'</h2>
|
||
<ul>
|
||
<li>'.html::anchor(url_lang::base().'database', url_lang::lang('texts.Database')).'</li>
|
||
<li>'.html::anchor(url_lang::base().'settings/system', url_lang::lang('texts.System settings')).'</li>
|
||
<li>'.html::anchor(url_lang::base().'access_rights', url_lang::lang('texts.Access rights')).'</li>
|
||
<li>'.html::anchor(url_lang::base().'translations', url_lang::lang('texts.Translations')).'</li>
|
||
<li>'.html::anchor(url_lang::base().'enum_types', url_lang::lang('texts.Enumerations')).'</li>
|
freenetis/trunk/kohana/application/views/login.php | ||
---|---|---|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
<title><?php echo $title ?> | slfree.net</title>
|
||
<title><?php echo $title ?> | <?php echo $this->setting->title ?></title>
|
||
<?php echo html::stylesheet('media/css/forms.css') ?>
|
||
<?php echo html::stylesheet('media/css/login.css') ?>
|
||
</head>
|
freenetis/trunk/kohana/application/views/settings/system.php | ||
---|---|---|
<h2><?php echo $headline ?></h2>
|
||
<?php echo ($message = $this->session->get('message')) ? '<div class="message">'.$message.'</div>' : '' ?>
|
||
<?php echo (isset($create)) ? $create : '' ?>
|
||
<br /><br />
|
||
<?php echo $form ?>
|
freenetis/trunk/kohana/application/views/registration.php | ||
---|---|---|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
<title><?php echo $title ?> | slfree.net</title>
|
||
<title><?php echo $title ?> | <?php echo $this->setting->title ?></title>
|
||
<?php echo html::stylesheet('media/css/login.css') ?>
|
||
<?php echo html::stylesheet('media/css/forms.css') ?>
|
||
</head>
|
freenetis/trunk/kohana/application/views/base/header-no_menu.php | ||
---|---|---|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
<title><?php echo $title ?> | slfree.net</title>
|
||
<title><?php echo $title ?> | <?php echo $this->setting->title ?></title>
|
||
<?php echo html::link('media/images/favicon.ico', 'shorrcut icon', 'image/x-icon', FALSE); ?>
|
||
<?php echo html::stylesheet('media/css/style.css') ?>
|
||
<?php echo html::stylesheet('media/css/tables.css') ?>
|
freenetis/trunk/kohana/application/views/base/header.php | ||
---|---|---|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
<title><?php echo $title ?> | slfree.net</title>
|
||
<title><?php echo $title ?> | <?php echo $this->setting->title ?></title>
|
||
<?php echo html::link('media/images/favicon.ico', 'shorrcut icon', 'image/x-icon', FALSE); ?>
|
||
<?php echo html::stylesheet('media/css/style.css') ?>
|
||
<?php echo html::stylesheet('media/css/tables.css') ?>
|
Také k dispozici: Unified diff
Pridana knihovna Setting, ktera zapouzdruje veskere nastavovani skrz db.
Pridan kontroler settings, ktera tyto nastavovani umoznuje menit - zatim
pouze implementovano jedine nastaveni systemu - nastaveni titulku stranku
(doposud bylo natvrdo slfree.net).
Dale pridano par prekladu.