Skip to content

Commit

Permalink
Added internationalization bits to the color codes and media types. T…
Browse files Browse the repository at this point in the history
…hat appears to be complete. close opendcim#190. Converted over the db calls in the configuration file to the PDO methods opendcim#164
  • Loading branch information
wilpig committed Jun 6, 2013
1 parent c4273d3 commit f6d6663
Show file tree
Hide file tree
Showing 20 changed files with 6,467 additions and 3,563 deletions.
2 changes: 1 addition & 1 deletion config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Config ($db=null){
return;
}

function UpdateConfig($db){
function UpdateConfig($db=null){
global $dbh;

foreach($this->ParameterArray as $key=>$value){
Expand Down
63 changes: 34 additions & 29 deletions configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,27 @@ function BuildFileList(){
$config->ParameterArray[$key]=$_REQUEST[$key];
}
}
$config->UpdateConfig($facDB);
$config->UpdateConfig();

//Disable all tooltip items and clear the SortOrder
mysql_query("UPDATE fac_CabinetToolTip SET SortOrder = NULL, Enabled=0;");
$dbh->exec("UPDATE fac_CabinetToolTip SET SortOrder = NULL, Enabled=0;");
if(isset($_POST["tooltip"]) && !empty($_POST["tooltip"])){
$p=$dbh->prepare("UPDATE fac_CabinetToolTip SET SortOrder=:sortorder, Enabled=1 WHERE Field=:field LIMIT 1;");
foreach($_POST["tooltip"] as $order => $field){
mysql_query("UPDATE fac_CabinetToolTip SET SortOrder=".intval($order).", Enabled=1 WHERE Field='".addslashes($field)."' LIMIT 1;");
$p->bindParam(":sortorder",$order);
$p->bindParam(":field",$field);
$p->execute();
}
}

//Disable all cdu tooltip items and clear the SortOrder
mysql_query("UPDATE fac_CDUToolTip SET SortOrder = NULL, Enabled=0;");
$dbh->exec("UPDATE fac_CDUToolTip SET SortOrder = NULL, Enabled=0;");
if(isset($_POST["cdutooltip"]) && !empty($_POST["cdutooltip"])){
$p=$dbh->prepare("UPDATE fac_CDUToolTip SET SortOrder=:sortorder, Enabled=1 WHERE Field=:field LIMIT 1;");
foreach($_POST["cdutooltip"] as $order => $field){
mysql_query("UPDATE fac_CDUToolTip SET SortOrder=".intval($order).", Enabled=1 WHERE Field='".addslashes($field)."' LIMIT 1;");
$p->bindParam(":sortorder",$order);
$p->bindParam(":field",$field);
$p->execute();
}
}
}
Expand Down Expand Up @@ -291,23 +297,23 @@ function formatOffset($offset) {

// Figure out what the URL to this page
$href="";
$href.=($_SERVER['HTTPS'])?'https://':'http://';
$href.=(isset($_SERVER['HTTPS']))?'https://':'http://';
$href.=$_SERVER['SERVER_NAME'];
$href.=substr($_SERVER['REQUEST_URI'], 0, -strlen(basename($_SERVER['REQUEST_URI'])));

// Build up the list of items available for the tooltips
$tooltip="<select id=\"tooltip\" name=\"tooltip[]\" multiple=\"multiple\">\n";
$ttconfig=mysql_query("SELECT * FROM fac_CabinetToolTip ORDER BY SortOrder ASC, Enabled DESC, Label ASC;");
while($row=mysql_fetch_assoc($ttconfig)){
$sql="SELECT * FROM fac_CabinetToolTip ORDER BY SortOrder ASC, Enabled DESC, Label ASC;";
foreach($dbh->query($sql) as $row){
$selected=($row["Enabled"])?" selected":"";
$tooltip.="<option value=\"".$row['Field']."\"$selected>".__($row["Label"])."</option>\n";
}
$tooltip.="</select>";

// Build up the list of items available for the tooltips
$cdutooltip="<select id=\"cdutooltip\" name=\"cdutooltip[]\" multiple=\"multiple\">\n";
$ttconfig=mysql_query("SELECT * FROM fac_CDUToolTip ORDER BY SortOrder ASC, Enabled DESC, Label ASC;");
while($row=mysql_fetch_assoc($ttconfig)){
$sql="SELECT * FROM fac_CDUToolTip ORDER BY SortOrder ASC, Enabled DESC, Label ASC;";
foreach($dbh->query($sql) as $row){
$selected=($row["Enabled"])?" selected":"";
$cdutooltip.="<option value=\"".$row['Field']."\"$selected>".__($row["Label"])."</option>\n";
}
Expand Down Expand Up @@ -484,22 +490,22 @@ function removemedia(row){
});
}else{
var defaultbutton={
"Clear all": function(){
"<?php echo __("Clear all"); ?>": function(){
$.post('',{mtid: row.find('div:nth-child(2) input').attr('data'),mt: '', mtcc: '', clear: ''}).done(function(data){
if(data.trim()=='u'){ // success
$('#modal').dialog("destroy");
row.effect('explode', {}, 500, function(){
$(this).remove();
});
}else{ // failed to delete
$('#modaltext').html('AAAAAAAAAAHHHHHHHHHH!!! *crash* *fire* *chaos*<br><br>Something just went horribly wrong.');
$('#modaltext').html('AAAAAAAAAAHHHHHHHHHH!!! *crash* *fire* *chaos*<br><br><?php echo __("Something just went horribly wrong."); ?>');
$('#modal').dialog('option','buttons',cancelbutton);
}
});
}
}
var replacebutton={
"Replace": function(){
"<?php echo __("Replace"); ?>": function(){
// send command to replace all connections with x
$.post('',{mtid: row.find('div:nth-child(2) input').attr('data'),mt: '', mtcc: '', change: $('#modal select').val()}).done(function(data){
if(data.trim()=='u'){ // success
Expand All @@ -508,18 +514,18 @@ function removemedia(row){
$(this).remove();
});
}else{ // failed to delete
$('#modaltext').html('AAAAAAAAAAHHHHHHHHHH!!! *crash* *fire* *chaos*<br><br>Something just went horribly wrong.');
$('#modaltext').html('AAAAAAAAAAHHHHHHHHHH!!! *crash* *fire* *chaos*<br><br><?php echo __("Something just went horribly wrong."); ?>');
$('#modal').dialog('option','buttons',cancelbutton);
}
});
}
}
var cancelbutton={
Cancel: function(){
"<?php echo __("Cancel"); ?>": function(){
$(this).dialog("destroy");
}
}
var modal=$('<div />', {id: 'modal', title: 'Media Type Delete Override'}).html('<div id="modaltext">this code is in use somewhere. add a modal requesting permission to remove this record and all associated entries<select id="replaceme"></select></div>').dialog({
<?php echo " var modal=$('<div />', {id: 'modal', title: '".__("Media Type Delete Override")."'}).html('<div id=\"modaltext\">".__("This media type is in use somewhere. Select an alternate type to assign to all the records to or choose clear all.")."<select id=\"replaceme\"></select></div>').dialog({"; ?>
dialogClass: 'no-close',
appendTo: 'body',
modal: true,
Expand Down Expand Up @@ -658,7 +664,7 @@ function removecolor(rowobject,lookup){
});
}else{
var defaultbutton={
"Clear all": function(){
"<?php echo __("Clear all"); ?>": function(){
$.post('',{cid: rowobject.find('div:nth-child(2) input').attr('data'),cc: '', ccdn: '', clear: ''}).done(function(data){
if(data.trim()=='u'){ // success
$('#modal').dialog("destroy");
Expand All @@ -667,14 +673,14 @@ function removecolor(rowobject,lookup){
$(this).remove();
});
}else{ // failed to delete
$('#modaltext').html('AAAAAAAAAAHHHHHHHHHH!!! *crash* *fire* *chaos*<br><br>Something just went horribly wrong.');
$('#modaltext').html('AAAAAAAAAAHHHHHHHHHH!!! *crash* *fire* *chaos*<br><br><?php echo __("Something just went horribly wrong."); ?>');
$('#modal').dialog('option','buttons',cancelbutton);
}
});
}
}
var replacebutton={
"Replace": function(){
"<?php echo __("Replace"); ?>": function(){
// send command to replace all connections with x
$.post('',{cid: rowobject.find('div:nth-child(2) input').attr('data'),cc: '', ccdn: '', change: $('#modal select').val()}).done(function(data){
if(data.trim()=='u'){ // success
Expand All @@ -687,18 +693,18 @@ function removecolor(rowobject,lookup){
// color so they will display the new color
$('#mediatypes > div ~ div:not(:last-child) input').val('').change();
}else{ // failed to delete
$('#modaltext').html('AAAAAAAAAAHHHHHHHHHH!!! *crash* *fire* *chaos*<br><br>Something just went horribly wrong.');
$('#modaltext').html('AAAAAAAAAAHHHHHHHHHH!!! *crash* *fire* *chaos*<br><br><?php echo __("Something just went horribly wrong."); ?>');
$('#modal').dialog('option','buttons',cancelbutton);
}
});
}
}
var cancelbutton={
Cancel: function(){
"<?php echo __("Cancel"); ?>": function(){
$(this).dialog("destroy");
}
}
var modal=$('<div />', {id: 'modal', title: 'Code Delete Override'}).html('<div id="modaltext">This code is in use somewhere. You can either choose to clear all instances of this color being used or choose to have them replaced with another color. <select id="replaceme"></select></div>').dialog({
<?php echo " var modal=$('<div />', {id: 'modal', title: '".__("Code Delete Override")."'}).html('<div id=\"modaltext\">".__("This code is in use somewhere. You can either choose to clear all instances of this color being used or choose to have them replaced with another color.")." <select id=\"replaceme\"></select></div>').dialog({"; ?>
dialogClass: 'no-close',
appendTo: 'body',
modal: true,
Expand Down Expand Up @@ -802,7 +808,6 @@ function bindrow(row){
bindrow($(this).parent('div'));
});


// Reporting - Utilities

$('input[id^="snmp"],input[id="cut"]').each(function(){
Expand Down Expand Up @@ -1157,12 +1162,12 @@ function bindrow(row){
<div class="table" id="mediatypes">
<div>
<div></div>
<div>Media Type</div>
<div>Default Color</div>
<div>',__("Media Type"),'</div>
<div>',__("Default Color"),'</div>
</div>
',$mediatypes,'
<div>
<div id="newline"><img alt="add new row" src="images/add.gif"></div>
<div id="newline"><img title="',__("Add new row"),'" src="images/add.gif"></div>
<div><input type="text" name="mediatype[]"></div>
<div>',$colorselector,'</div>
</div>
Expand All @@ -1171,12 +1176,12 @@ function bindrow(row){
<div class="table" id="cablecolor">
<div>
<div></div>
<div>Color</div>
<div>Default Note</div>
<div>',__("Color"),'</div>
<div>',__("Default Note"),'</div>
</div>
',$cablecolors,'
<div>
<div id="newline"><img alt="add new row" src="images/add.gif"></div>
<div id="newline"><img title="',__("Add new row"),'" src="images/add.gif"></div>
<div><input type="text" name="colorcode[]"></div>
<div><input type="text" name="ccdefaulttext[]"></div>
</div>
Expand Down
Binary file modified locale/ca_AD/LC_MESSAGES/openDCIM.mo
Binary file not shown.
Loading

0 comments on commit f6d6663

Please sign in to comment.