Commit 44d2a76d authored by tbrehm's avatar tbrehm
Browse files

Added missing error messages to the dns wizard.

Improved language file loading.
parent 93f3e1a9
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
......@@ -147,19 +147,21 @@ class app {
}
}
/** Loads language */
/** Translates strings in current language */
public function lng($text)
{
if($this->_language_inc != 1) {
//* loading global and module Wordbook
// 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'])) {
$lng_file = ISPC_ROOT_PATH.'/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';
@include_once($lng_file);
$lng_file = '/web/'.$_SESSION['s']['module']['name'].'/lib/lang/'.$_SESSION['s']['language'].'.lng';
if(!file_exists($lng_file)) $lng_file = '/web/'.$_SESSION['s']['module']['name'].'/lib/lang/en.lng';
//@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;
}
if(!empty($this->_wb[$text])) {
......@@ -167,6 +169,22 @@ class app {
}
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()
{
......
......@@ -39,6 +39,7 @@ $app->auth->check_module_permissions('dns');
$app->uses('tpl,validate_dns');
$app->tpl->newTemplate("form.tpl.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
$template_id = (isset($_POST['template_id']))?intval($_POST['template_id']):0;
......@@ -109,11 +110,11 @@ if($_POST['create'] == 1) {
$error = '';
if(isset($_POST['domain']) && $_POST['domain'] == '') $error .= $app->lng('error_domain_empty');
if(isset($_POST['ip']) && $_POST['ip'] == '') $error .= $app->lng('error_ip_empty');
if(isset($_POST['ns1']) && $_POST['ns1'] == '') $error .= $app->lng('error_ns1_empty');
if(isset($_POST['ns2']) && $_POST['ns2'] == '') $error .= $app->lng('error_ns2_empty');
if(isset($_POST['email']) && $_POST['email'] == '') $error .= $app->lng('error_email_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').'<br />';
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').'<br />';
if(isset($_POST['email']) && $_POST['email'] == '') $error .= $app->lng('error_email_empty').'<br />';
// replace template placeholders
......@@ -164,14 +165,14 @@ if($_POST['create'] == 1) {
} // end foreach
if($vars['origin'] == '') $error .= $app->lng('error_origin_empty');
if($vars['ns'] == '') $error .= $app->lng('error_ns_empty');
if($vars['mbox'] == '') $error .= $app->lng('error_mbox_empty');
if($vars['refresh'] == '') $error .= $app->lng('error_refresh_empty');
if($vars['retry'] == '') $error .= $app->lng('error_retry_empty');
if($vars['expire'] == '') $error .= $app->lng('error_expire_empty');
if($vars['minimum'] == '') $error .= $app->lng('error_minimum_empty');
if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty');
if($vars['origin'] == '') $error .= $app->lng('error_origin_empty').'<br />';
if($vars['ns'] == '') $error .= $app->lng('error_ns_empty').'<br />';
if($vars['mbox'] == '') $error .= $app->lng('error_mbox_empty').'<br />';
if($vars['refresh'] == '') $error .= $app->lng('error_refresh_empty').'<br />';
if($vars['retry'] == '') $error .= $app->lng('error_retry_empty').'<br />';
if($vars['expire'] == '') $error .= $app->lng('error_expire_empty').'<br />';
if($vars['minimum'] == '') $error .= $app->lng('error_minimum_empty').'<br />';
if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty').'<br />';
if($error == '') {
// Insert the soa record
......
......@@ -10,7 +10,18 @@ $wb['email_txt'] = 'Email';
$wb['ns1_txt'] = 'NS 1';
$wb['ns2_txt'] = 'NS 2';
$wb['ip_txt'] = 'IP Address';
$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>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_dns_wizard">
<div class="pnl_formsarea">
<fieldset class="inlineLabels"><legend>DNS Zone</legend>
<div class="ctrlHolder">
<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')">
{tmpl_var name='template_id_option'}
</select>
</div>
<tmpl_if name="is_admin">
<div class="ctrlHolder">
<label for="server_id">{tmpl_var name='server_id_txt'}</label>
<select name="server_id" id="server_id" class="selectInput">
{tmpl_var name='server_id'}
</select>
</div>
<div class="ctrlHolder">
<label for="client_group_id">{tmpl_var name='client_txt'}</label>
<select name="client_group_id" id="client_group_id" class="selectInput">
{tmpl_var name='client_group_id'}
</select>
</div>
</tmpl_if>
<tmpl_if name="DOMAIN_VISIBLE">
<div class="ctrlHolder">
<label for="domain">{tmpl_var name='domain_txt'}</label>
<input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
</tmpl_if>
<tmpl_if name="IP_VISIBLE">
<div class="ctrlHolder">
<label for="ip">{tmpl_var name='ip_txt'}</label>
<input name="ip" id="ip" value="{tmpl_var name='ip'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
</tmpl_if>
<tmpl_if name="NS1_VISIBLE">
<div class="ctrlHolder">
<label for="ns1">{tmpl_var name='ns1_txt'}</label>
<input name="ns1" id="ns1" value="{tmpl_var name='ns1'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
</tmpl_if>
<tmpl_if name="NS2_VISIBLE">
<div class="ctrlHolder">
<label for="ns2">{tmpl_var name='ns2_txt'}</label>
<input name="ns2" id="ns2" value="{tmpl_var name='ns2'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
</tmpl_if>
<tmpl_if name="EMAIL_VISIBLE">
<div class="ctrlHolder">
<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" />
</div>
</tmpl_if>
</fieldset>
<input type="hidden" name="create" value="0" />
<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>
<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>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<tmpl_if name="error">
<div id="errorMsg"><h3>ERROR</h3><ol><tmpl_var name="error"></ol></div>
</tmpl_if>
<div class="panel panel_dns_wizard">
<div class="pnl_formsarea">
<fieldset class="inlineLabels"><legend>DNS Zone</legend>
<div class="ctrlHolder">
<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')">
{tmpl_var name='template_id_option'}
</select>
</div>
<tmpl_if name="is_admin">
<div class="ctrlHolder">
<label for="server_id">{tmpl_var name='server_id_txt'}</label>
<select name="server_id" id="server_id" class="selectInput">
{tmpl_var name='server_id'}
</select>
</div>
<div class="ctrlHolder">
<label for="client_group_id">{tmpl_var name='client_txt'}</label>
<select name="client_group_id" id="client_group_id" class="selectInput">
{tmpl_var name='client_group_id'}
</select>
</div>
</tmpl_if>
<tmpl_if name="DOMAIN_VISIBLE">
<div class="ctrlHolder">
<label for="domain">{tmpl_var name='domain_txt'}</label>
<input name="domain" id="domain" value="{tmpl_var name='domain'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
</tmpl_if>
<tmpl_if name="IP_VISIBLE">
<div class="ctrlHolder">
<label for="ip">{tmpl_var name='ip_txt'}</label>
<input name="ip" id="ip" value="{tmpl_var name='ip'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
</tmpl_if>
<tmpl_if name="NS1_VISIBLE">
<div class="ctrlHolder">
<label for="ns1">{tmpl_var name='ns1_txt'}</label>
<input name="ns1" id="ns1" value="{tmpl_var name='ns1'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
</tmpl_if>
<tmpl_if name="NS2_VISIBLE">
<div class="ctrlHolder">
<label for="ns2">{tmpl_var name='ns2_txt'}</label>
<input name="ns2" id="ns2" value="{tmpl_var name='ns2'}" size="30" maxlength="255" type="text" class="textInput" />
</div>
</tmpl_if>
<tmpl_if name="EMAIL_VISIBLE">
<div class="ctrlHolder">
<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" />
</div>
</tmpl_if>
</fieldset>
<input type="hidden" name="create" value="0" />
<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>
<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>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment