| 1 |
<?php |
|---|
| 2 |
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'setup'; |
|---|
| 17 |
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
|---|
| 18 |
if (isset($_REQUEST['delete'])) $action = 'delete'; |
|---|
| 19 |
|
|---|
| 20 |
$language_id = isset($_REQUEST['language_id']) ? $_REQUEST['language_id'] : false; |
|---|
| 21 |
$description = isset($_REQUEST['description']) ? $_REQUEST['description'] : ''; |
|---|
| 22 |
$lang_code = isset($_REQUEST['lang_code']) ? $_REQUEST['lang_code'] : ''; |
|---|
| 23 |
$dest = isset($_REQUEST['dest']) ? $_REQUEST['dest'] : ''; |
|---|
| 24 |
|
|---|
| 25 |
if (isset($_REQUEST['goto0']) && $_REQUEST['goto0']) { |
|---|
| 26 |
$dest = $_REQUEST[ $_REQUEST['goto0'].'0' ]; |
|---|
| 27 |
} |
|---|
| 28 |
|
|---|
| 29 |
switch ($action) { |
|---|
| 30 |
case 'add': |
|---|
| 31 |
languages_add($description, $lang_code, $dest); |
|---|
| 32 |
needreload(); |
|---|
| 33 |
redirect_standard(); |
|---|
| 34 |
break; |
|---|
| 35 |
case 'edit': |
|---|
| 36 |
languages_edit($language_id, $description, $lang_code, $dest); |
|---|
| 37 |
needreload(); |
|---|
| 38 |
redirect_standard('extdisplay'); |
|---|
| 39 |
break; |
|---|
| 40 |
case 'delete': |
|---|
| 41 |
languages_delete($language_id); |
|---|
| 42 |
needreload(); |
|---|
| 43 |
redirect_standard(); |
|---|
| 44 |
break; |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
?> |
|---|
| 48 |
|
|---|
| 49 |
<div class="rnav"><ul> |
|---|
| 50 |
<?php |
|---|
| 51 |
|
|---|
| 52 |
echo '<li><a href="config.php?display=languages&type='.$type.'">'._('Add Language').'</a></li>'; |
|---|
| 53 |
|
|---|
| 54 |
foreach (languages_list() as $row) { |
|---|
| 55 |
echo '<li><a href="config.php?display=languages&type='.$type.'&extdisplay='.$row['language_id'].'" class="">'.$row['description'].'</a></li>'; |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
?> |
|---|
| 59 |
</ul></div> |
|---|
| 60 |
|
|---|
| 61 |
<?php |
|---|
| 62 |
|
|---|
| 63 |
if ($extdisplay) { |
|---|
| 64 |
|
|---|
| 65 |
$row = languages_get($extdisplay); |
|---|
| 66 |
|
|---|
| 67 |
$description = $row['description']; |
|---|
| 68 |
$lang_code = $row['lang_code']; |
|---|
| 69 |
$dest = $row['dest']; |
|---|
| 70 |
|
|---|
| 71 |
echo "<h2>"._("Edit: ")."$description ($lang_code)"."</h2>"; |
|---|
| 72 |
} else { |
|---|
| 73 |
echo "<h2>"._("Add Language")."</h2>"; |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
$helptext = _("Languages allow you to change the language of the call flow and then continue on to the desired destination. For example, you may have an IVR option that says \"For French Press 5 now\". You would then create a French language instance and point it's destination at a French IVR. The language of the call's channel will now be in French. This will result in French sounds being chosen if installed."); |
|---|
| 77 |
echo $helptext; |
|---|
| 78 |
?> |
|---|
| 79 |
|
|---|
| 80 |
<form name="editLanguage" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkLanguage(editLanguage);"> |
|---|
| 81 |
<input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>"> |
|---|
| 82 |
<input type="hidden" name="language_id" value="<?php echo $extdisplay; ?>"> |
|---|
| 83 |
<input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add'); ?>"> |
|---|
| 84 |
<table> |
|---|
| 85 |
<tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit Language Instance") : _("Add Language Instance")) ?><hr></h5></td></tr> |
|---|
| 86 |
<tr> |
|---|
| 87 |
<td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("The descriptive name of this language instance. For example \"French Main IVR\"")?></span></a></td> |
|---|
| 88 |
<td><input size="30" type="text" name="description" value="<?php echo $description; ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 89 |
</tr> |
|---|
| 90 |
<tr> |
|---|
| 91 |
<td><a href="#" class="info"><?php echo _("Language Code")?>:<span><?php echo _("The Asterisk language code you want to change to. For example \"fr\" for French, \"de\" for German")?></span></a></td> |
|---|
| 92 |
<td><input size="14" type="text" name="lang_code" value="<?php echo $lang_code; ?>" tabindex="<?php echo ++$tabindex;?>"/></td> </tr> |
|---|
| 93 |
<tr><td colspan="2"><br><h5><?php echo _("Destination")?>:<hr></h5></td></tr> |
|---|
| 94 |
|
|---|
| 95 |
<?php |
|---|
| 96 |
|
|---|
| 97 |
echo drawselects($dest,0); |
|---|
| 98 |
?> |
|---|
| 99 |
|
|---|
| 100 |
<tr> |
|---|
| 101 |
<td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 102 |
<?php if ($extdisplay) { echo ' <input name="delete" type="submit" value="'._("Delete").'">'; } ?> |
|---|
| 103 |
</td> |
|---|
| 104 |
|
|---|
| 105 |
<?php |
|---|
| 106 |
if ($extdisplay) { |
|---|
| 107 |
$usage_list = framework_display_destination_usage(languages_getdest($extdisplay)); |
|---|
| 108 |
if (!empty($usage_list)) { |
|---|
| 109 |
?> |
|---|
| 110 |
<tr><td colspan="2"> |
|---|
| 111 |
<a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a> |
|---|
| 112 |
</td></tr> |
|---|
| 113 |
<?php |
|---|
| 114 |
} |
|---|
| 115 |
} |
|---|
| 116 |
?> |
|---|
| 117 |
</tr> |
|---|
| 118 |
</table> |
|---|
| 119 |
</form> |
|---|
| 120 |
|
|---|
| 121 |
<script language="javascript"> |
|---|
| 122 |
<!-- |
|---|
| 123 |
|
|---|
| 124 |
function checkLanguage(theForm) { |
|---|
| 125 |
var msgInvalidDescription = "<?php echo _('Invalid description specified'); ?>"; |
|---|
| 126 |
|
|---|
| 127 |
// set up the Destination stuff |
|---|
| 128 |
setDestinations(theForm, '_post_dest'); |
|---|
| 129 |
|
|---|
| 130 |
// form validation |
|---|
| 131 |
defaultEmptyOK = false; |
|---|
| 132 |
if (isEmpty(theForm.description.value)) |
|---|
| 133 |
return warnInvalid(theForm.description, msgInvalidDescription); |
|---|
| 134 |
|
|---|
| 135 |
if (!validateDestinations(theForm, 1, true)) |
|---|
| 136 |
return false; |
|---|
| 137 |
|
|---|
| 138 |
return true; |
|---|
| 139 |
} |
|---|
| 140 |
//--> |
|---|
| 141 |
</script> |
|---|
| 142 |
|
|---|