| 1 |
<?php |
|---|
| 2 |
/** Language Module for FreePBX 2.4 |
|---|
| 3 |
* Copyright 2006 Philippe Lindheimer - Astrogen LLC |
|---|
| 4 |
* This program is free software; you can redistribute it and/or |
|---|
| 5 |
* modify it under the terms of the GNU General Public License |
|---|
| 6 |
* as published by the Free Software Foundation; either version 2 |
|---|
| 7 |
* of the License, or (at your option) any later version. |
|---|
| 8 |
* |
|---|
| 9 |
* This program is distributed in the hope that it will be useful, |
|---|
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
* GNU General Public License for more details. |
|---|
| 13 |
*/ |
|---|
| 14 |
|
|---|
| 15 |
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'setup'; |
|---|
| 16 |
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
|---|
| 17 |
if (isset($_REQUEST['delete'])) $action = 'delete'; |
|---|
| 18 |
|
|---|
| 19 |
$language_id = isset($_REQUEST['language_id']) ? $_REQUEST['language_id'] : false; |
|---|
| 20 |
$description = isset($_REQUEST['description']) ? $_REQUEST['description'] : ''; |
|---|
| 21 |
$lang_code = isset($_REQUEST['lang_code']) ? $_REQUEST['lang_code'] : ''; |
|---|
| 22 |
$dest = isset($_REQUEST['dest']) ? $_REQUEST['dest'] : ''; |
|---|
| 23 |
|
|---|
| 24 |
if (isset($_REQUEST['goto0']) && $_REQUEST['goto0']) { |
|---|
| 25 |
$dest = $_REQUEST[ $_REQUEST['goto0'].'0' ]; |
|---|
| 26 |
} |
|---|
| 27 |
|
|---|
| 28 |
switch ($action) { |
|---|
| 29 |
case 'add': |
|---|
| 30 |
languages_add($description, $lang_code, $dest); |
|---|
| 31 |
needreload(); |
|---|
| 32 |
redirect_standard(); |
|---|
| 33 |
break; |
|---|
| 34 |
case 'edit': |
|---|
| 35 |
languages_edit($language_id, $description, $lang_code, $dest); |
|---|
| 36 |
needreload(); |
|---|
| 37 |
redirect_standard('extdisplay'); |
|---|
| 38 |
break; |
|---|
| 39 |
case 'delete': |
|---|
| 40 |
languages_delete($language_id); |
|---|
| 41 |
needreload(); |
|---|
| 42 |
redirect_standard(); |
|---|
| 43 |
break; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
?> |
|---|
| 47 |
</div> |
|---|
| 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 |
<div class="content"> |
|---|
| 62 |
|
|---|
| 63 |
<?php |
|---|
| 64 |
|
|---|
| 65 |
if ($extdisplay) { |
|---|
| 66 |
// load |
|---|
| 67 |
$row = languages_get($extdisplay); |
|---|
| 68 |
|
|---|
| 69 |
$description = $row['description']; |
|---|
| 70 |
$lang_code = $row['lang_code']; |
|---|
| 71 |
$dest = $row['dest']; |
|---|
| 72 |
|
|---|
| 73 |
echo "<h2>"._("Edit: ")."$description ($lang_code)"."</h2>"; |
|---|
| 74 |
} else { |
|---|
| 75 |
echo "<h2>"._("Add Language")."</h2>"; |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
$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."); |
|---|
| 79 |
echo $helptext; |
|---|
| 80 |
?> |
|---|
| 81 |
|
|---|
| 82 |
<form name="editLanguage" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkLanguage(editLanguage);"> |
|---|
| 83 |
<input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>"> |
|---|
| 84 |
<input type="hidden" name="language_id" value="<?php echo $extdisplay; ?>"> |
|---|
| 85 |
<input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add'); ?>"> |
|---|
| 86 |
<table> |
|---|
| 87 |
<tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit Language Instance") : _("Add Language Instance")) ?><hr></h5></td></tr> |
|---|
| 88 |
<tr> |
|---|
| 89 |
<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> |
|---|
| 90 |
<td><input size="30" type="text" name="description" value="<?php echo $description; ?>"></td> |
|---|
| 91 |
</tr> |
|---|
| 92 |
<tr> |
|---|
| 93 |
<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> |
|---|
| 94 |
<td><input size="14" type="text" name="lang_code" value="<?php echo $lang_code; ?>" /></td> </tr> |
|---|
| 95 |
<tr><td colspan="2"><br><h5><?php echo _("Destination")?>:<hr></h5></td></tr> |
|---|
| 96 |
|
|---|
| 97 |
<?php |
|---|
| 98 |
//draw goto selects |
|---|
| 99 |
echo drawselects($dest,0); |
|---|
| 100 |
?> |
|---|
| 101 |
|
|---|
| 102 |
<tr> |
|---|
| 103 |
<td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"> |
|---|
| 104 |
<?php if ($extdisplay) { echo ' <input name="delete" type="submit" value="'._("Delete").'">'; } ?> |
|---|
| 105 |
</td> |
|---|
| 106 |
|
|---|
| 107 |
<?php |
|---|
| 108 |
if ($extdisplay) { |
|---|
| 109 |
$usage_list = framework_display_destination_usage(languages_getdest($extdisplay)); |
|---|
| 110 |
if (!empty($usage_list)) { |
|---|
| 111 |
?> |
|---|
| 112 |
<tr><td colspan="2"> |
|---|
| 113 |
<a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a> |
|---|
| 114 |
</td></tr> |
|---|
| 115 |
<?php |
|---|
| 116 |
} |
|---|
| 117 |
} |
|---|
| 118 |
?> |
|---|
| 119 |
</tr> |
|---|
| 120 |
</table> |
|---|
| 121 |
</form> |
|---|
| 122 |
|
|---|
| 123 |
<script language="javascript"> |
|---|
| 124 |
<!-- |
|---|
| 125 |
|
|---|
| 126 |
function checkLanguage(theForm) { |
|---|
| 127 |
var msgInvalidDescription = "<?php echo _('Invalid description specified'); ?>"; |
|---|
| 128 |
|
|---|
| 129 |
// set up the Destination stuff |
|---|
| 130 |
setDestinations(theForm, '_post_dest'); |
|---|
| 131 |
|
|---|
| 132 |
// form validation |
|---|
| 133 |
defaultEmptyOK = false; |
|---|
| 134 |
if (isEmpty(theForm.description.value)) |
|---|
| 135 |
return warnInvalid(theForm.description, msgInvalidDescription); |
|---|
| 136 |
|
|---|
| 137 |
if (!validateDestinations(theForm, 1, true)) |
|---|
| 138 |
return false; |
|---|
| 139 |
|
|---|
| 140 |
return true; |
|---|
| 141 |
} |
|---|
| 142 |
//--> |
|---|
| 143 |
</script> |
|---|