Skip to content
Snippets Groups Projects
Commit 44d2a76d authored by tbrehm's avatar tbrehm
Browse files

Added missing error messages to the dns wizard.

Improved language file loading.
parent 93f3e1a9
No related branches found
No related tags found
No related merge requests found
<?php <?php
/* /*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, Redistribution and use in source and binary forms, with or without modification,
...@@ -147,19 +147,21 @@ class app { ...@@ -147,19 +147,21 @@ class app {
} }
} }
/** Loads language */ /** Translates strings in current language */
public function lng($text) public function lng($text)
{ {
if($this->_language_inc != 1) { if($this->_language_inc != 1) {
//* loading global and module Wordbook //* loading global and module Wordbook
// TODO: this need to be made clearer somehow - pedro // TODO: this need to be made clearer somehow - pedro
@include_once(ISPC_ROOT_PATH.'/lib/lang/'.$_SESSION['s']['language'].'.lng'); //@include_once(ISPC_ROOT_PATH.'/lib/lang/'.$_SESSION['s']['language'].'.lng');
$this->load_language_file('/lib/lang/'.$_SESSION['s']['language'].'.lng');
if(isset($_SESSION['s']['module']['name']) && isset($_SESSION['s']['language'])) { if(isset($_SESSION['s']['module']['name']) && isset($_SESSION['s']['language'])) {
$lng_file = ISPC_ROOT_PATH.'/web/'.$_SESSION['s']['module']['name'].'/lib/lang/'.$_SESSION['s']['language'].'.lng'; $lng_file = '/web/'.$_SESSION['s']['module']['name'].'/lib/lang/'.$_SESSION['s']['language'].'.lng';
if(!file_exists($lng_file)) $lng_file = ISPC_ROOT_PATH.'/web/'.$_SESSION['s']['module']['name'].'/lib/lang/en.lng'; if(!file_exists($lng_file)) $lng_file = '/web/'.$_SESSION['s']['module']['name'].'/lib/lang/en.lng';
@include_once($lng_file); //@include_once($lng_file);
$this->load_language_file($lng_file);
} }
if(isset($wb)) $this->_wb = $wb; //if(isset($wb)) $this->_wb = $wb;
$this->_language_inc = 1; $this->_language_inc = 1;
} }
if(!empty($this->_wb[$text])) { if(!empty($this->_wb[$text])) {
...@@ -167,6 +169,22 @@ class app { ...@@ -167,6 +169,22 @@ class app {
} }
return $text; return $text;
} }
//** Helper function to load the language files.
public function load_language_file($filename) {
$filename = ISPC_ROOT_PATH.'/'.$filename;
if(substr($filename,-4) != '.lng') $this->error('Language file has wrong extension.');
if(file_exists($filename)) {
@include_once($filename);
if(is_array($wb)) {
if(is_array($this->_wb)) {
$this->_wb = array_merge($wb,$this->_wb);
} else {
$this->_wb = $wb;
}
}
}
}
public function tpl_defaults() public function tpl_defaults()
{ {
......
...@@ -39,6 +39,7 @@ $app->auth->check_module_permissions('dns'); ...@@ -39,6 +39,7 @@ $app->auth->check_module_permissions('dns');
$app->uses('tpl,validate_dns'); $app->uses('tpl,validate_dns');
$app->tpl->newTemplate("form.tpl.htm"); $app->tpl->newTemplate("form.tpl.htm");
$app->tpl->setInclude('content_tpl','templates/dns_wizard.htm'); $app->tpl->setInclude('content_tpl','templates/dns_wizard.htm');
$app->load_language_file('/web/dns/lib/lang/'.$_SESSION['s']['language'].'_dns_wizard.lng');
// import variables // import variables
$template_id = (isset($_POST['template_id']))?intval($_POST['template_id']):0; $template_id = (isset($_POST['template_id']))?intval($_POST['template_id']):0;
...@@ -109,11 +110,11 @@ if($_POST['create'] == 1) { ...@@ -109,11 +110,11 @@ if($_POST['create'] == 1) {
$error = ''; $error = '';
if(isset($_POST['domain']) && $_POST['domain'] == '') $error .= $app->lng('error_domain_empty'); if(isset($_POST['domain']) && $_POST['domain'] == '') $error .= $app->lng('error_domain_empty').'<br />';
if(isset($_POST['ip']) && $_POST['ip'] == '') $error .= $app->lng('error_ip_empty'); if(isset($_POST['ip']) && $_POST['ip'] == '') $error .= $app->lng('error_ip_empty').'<br />';
if(isset($_POST['ns1']) && $_POST['ns1'] == '') $error .= $app->lng('error_ns1_empty'); if(isset($_POST['ns1']) && $_POST['ns1'] == '') $error .= $app->lng('error_ns1_empty').'<br />';
if(isset($_POST['ns2']) && $_POST['ns2'] == '') $error .= $app->lng('error_ns2_empty'); if(isset($_POST['ns2']) && $_POST['ns2'] == '') $error .= $app->lng('error_ns2_empty').'<br />';
if(isset($_POST['email']) && $_POST['email'] == '') $error .= $app->lng('error_email_empty'); if(isset($_POST['email']) && $_POST['email'] == '') $error .= $app->lng('error_email_empty').'<br />';
// replace template placeholders // replace template placeholders
...@@ -164,14 +165,14 @@ if($_POST['create'] == 1) { ...@@ -164,14 +165,14 @@ if($_POST['create'] == 1) {
} // end foreach } // end foreach
if($vars['origin'] == '') $error .= $app->lng('error_origin_empty'); if($vars['origin'] == '') $error .= $app->lng('error_origin_empty').'<br />';
if($vars['ns'] == '') $error .= $app->lng('error_ns_empty'); if($vars['ns'] == '') $error .= $app->lng('error_ns_empty').'<br />';
if($vars['mbox'] == '') $error .= $app->lng('error_mbox_empty'); if($vars['mbox'] == '') $error .= $app->lng('error_mbox_empty').'<br />';
if($vars['refresh'] == '') $error .= $app->lng('error_refresh_empty'); if($vars['refresh'] == '') $error .= $app->lng('error_refresh_empty').'<br />';
if($vars['retry'] == '') $error .= $app->lng('error_retry_empty'); if($vars['retry'] == '') $error .= $app->lng('error_retry_empty').'<br />';
if($vars['expire'] == '') $error .= $app->lng('error_expire_empty'); if($vars['expire'] == '') $error .= $app->lng('error_expire_empty').'<br />';
if($vars['minimum'] == '') $error .= $app->lng('error_minimum_empty'); if($vars['minimum'] == '') $error .= $app->lng('error_minimum_empty').'<br />';
if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty'); if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty').'<br />';
if($error == '') { if($error == '') {
// Insert the soa record // Insert the soa record
......
...@@ -10,7 +10,18 @@ $wb['email_txt'] = 'Email'; ...@@ -10,7 +10,18 @@ $wb['email_txt'] = 'Email';
$wb['ns1_txt'] = 'NS 1'; $wb['ns1_txt'] = 'NS 1';
$wb['ns2_txt'] = 'NS 2'; $wb['ns2_txt'] = 'NS 2';
$wb['ip_txt'] = 'IP Address'; $wb['ip_txt'] = 'IP Address';
$wb['error_origin_empty'] = 'Origin empty.'; $wb['error_origin_empty'] = 'Origin empty.';
$wb['error_ns_empty'] = 'NS empty.';
$wb['error_mbox_empty'] = 'Mbox empty.';
$wb['error_refresh_empty'] = 'Refresh empty.';
$wb['error_retry_empty'] = 'Retry empty.';
$wb['error_expire_empty'] = 'Expire empty.';
$wb['error_minimum_empty'] = 'Minimum empty.';
$wb['error_ttl_empty'] = 'TTL empty.';
$wb['error_domain_empty'] = 'Domain empty';
$wb['error_ip_empty'] = 'IP empty.';
$wb['error_ns1_empty'] = 'NS1 empty.';
$wb['error_ns2_empty'] = 'NS2 empty.';
$wb['error_email_empty'] = 'EMail empty.';
?> ?>
\ No newline at end of file
<h2><tmpl_var name="list_head_txt"></h2> <h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p> <p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_dns_wizard"> <tmpl_if name="error">
<div id="errorMsg"><h3>ERROR</h3><ol><tmpl_var name="error"></ol></div>
<div class="pnl_formsarea"> </tmpl_if>
<fieldset class="inlineLabels"><legend>DNS Zone</legend>
<div class="ctrlHolder"> <div class="panel panel_dns_wizard">
<label for="template_id">{tmpl_var name='template_id_txt'}</label>
<select name="template_id" id="template_id" class="selectInput" onChange="submitForm('pageForm','dns/dns_wizard.php')"> <div class="pnl_formsarea">
{tmpl_var name='template_id_option'} <fieldset class="inlineLabels"><legend>DNS Zone</legend>
</select> <div class="ctrlHolder">
</div> <label for="template_id">{tmpl_var name='template_id_txt'}</label>
<tmpl_if name="is_admin"> <select name="template_id" id="template_id" class="selectInput" onChange="submitForm('pageForm','dns/dns_wizard.php')">
<div class="ctrlHolder"> {tmpl_var name='template_id_option'}
<label for="server_id">{tmpl_var name='server_id_txt'}</label> </select>
<select name="server_id" id="server_id" class="selectInput"> </div>
{tmpl_var name='server_id'} <tmpl_if name="is_admin">
</select> <div class="ctrlHolder">
</div> <label for="server_id">{tmpl_var name='server_id_txt'}</label>
<div class="ctrlHolder"> <select name="server_id" id="server_id" class="selectInput">
<label for="client_group_id">{tmpl_var name='client_txt'}</label> {tmpl_var name='server_id'}
<select name="client_group_id" id="client_group_id" class="selectInput"> </select>
{tmpl_var name='client_group_id'} </div>
</select> <div class="ctrlHolder">
</div> <label for="client_group_id">{tmpl_var name='client_txt'}</label>
</tmpl_if> <select name="client_group_id" id="client_group_id" class="selectInput">
<tmpl_if name="DOMAIN_VISIBLE"> {tmpl_var name='client_group_id'}
<div class="ctrlHolder"> </select>
<label for="domain">{tmpl_var name='domain_txt'}</label> </div>
<input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" /> </tmpl_if>
</div> <tmpl_if name="DOMAIN_VISIBLE">
</tmpl_if> <div class="ctrlHolder">
<tmpl_if name="IP_VISIBLE"> <label for="domain">{tmpl_var name='domain_txt'}</label>
<div class="ctrlHolder"> <input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
<label for="ip">{tmpl_var name='ip_txt'}</label> </div>
<input name="ip" id="ip" value="{tmpl_var name='ip'}" size="30" maxlength="255" type="text" class="textInput" /> </tmpl_if>
</div> <tmpl_if name="IP_VISIBLE">
</tmpl_if> <div class="ctrlHolder">
<tmpl_if name="NS1_VISIBLE"> <label for="ip">{tmpl_var name='ip_txt'}</label>
<div class="ctrlHolder"> <input name="ip" id="ip" value="{tmpl_var name='ip'}" size="30" maxlength="255" type="text" class="textInput" />
<label for="ns1">{tmpl_var name='ns1_txt'}</label> </div>
<input name="ns1" id="ns1" value="{tmpl_var name='ns1'}" size="30" maxlength="255" type="text" class="textInput" /> </tmpl_if>
</div> <tmpl_if name="NS1_VISIBLE">
</tmpl_if> <div class="ctrlHolder">
<tmpl_if name="NS2_VISIBLE"> <label for="ns1">{tmpl_var name='ns1_txt'}</label>
<div class="ctrlHolder"> <input name="ns1" id="ns1" value="{tmpl_var name='ns1'}" size="30" maxlength="255" type="text" class="textInput" />
<label for="ns2">{tmpl_var name='ns2_txt'}</label> </div>
<input name="ns2" id="ns2" value="{tmpl_var name='ns2'}" size="30" maxlength="255" type="text" class="textInput" /> </tmpl_if>
</div> <tmpl_if name="NS2_VISIBLE">
</tmpl_if> <div class="ctrlHolder">
<tmpl_if name="EMAIL_VISIBLE"> <label for="ns2">{tmpl_var name='ns2_txt'}</label>
<div class="ctrlHolder"> <input name="ns2" id="ns2" value="{tmpl_var name='ns2'}" size="30" maxlength="255" type="text" class="textInput" />
<label for="email">{tmpl_var name='email_txt'}</label> </div>
<input name="email" id="email" value="{tmpl_var name='email'}" size="30" maxlength="255" type="text" class="textInput" /> </tmpl_if>
</div> <tmpl_if name="EMAIL_VISIBLE">
</tmpl_if> <div class="ctrlHolder">
</fieldset> <label for="email">{tmpl_var name='email_txt'}</label>
<input name="email" id="email" value="{tmpl_var name='email'}" size="30" maxlength="255" type="text" class="textInput" />
<input type="hidden" name="create" value="0" /> </div>
</tmpl_if>
<div class="buttonHolder buttons"> </fieldset>
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" name="btn_create" onClick="document.pageForm.create.value=1; submitForm('pageForm','dns/dns_wizard.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
<button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('dns/dns_wizard.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button> <input type="hidden" name="create" value="0" />
</div>
</div> <div class="buttonHolder buttons">
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" name="btn_create" onClick="document.pageForm.create.value=1; submitForm('pageForm','dns/dns_wizard.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
</div> <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('dns/dns_wizard.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
</div>
</div>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment