Skip to content

Commit

Permalink
New feature
Browse files Browse the repository at this point in the history
Add method to display result of an action
  • Loading branch information
DjMomo committed Aug 30, 2013
1 parent 65aca3a commit 0a12d67
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
30 changes: 30 additions & 0 deletions freebox.class.php
Expand Up @@ -426,6 +426,13 @@ public function convert_truefalse_to_boolean($var)
return $var;
}

public function convert_truefalse_to_text($var)
{
if ($var === true) return "true";
if ($var === false) return "false";
return $var;
}

/* Retourne tous les paramètres de la freebox dans un fichier XML */
public function config_to_XML()
{
Expand Down Expand Up @@ -476,6 +483,29 @@ public function config_to_XML()
$doc->appendChild($racine);
return $doc->saveXML();
}

public function DisplayResult($json,$action = "")
{
if ($json["success"] == true)
{
echo "$action OK !";
echo "<br />Données supplémentaires retournées par la Freebox : ";
$keys = array_keys($json["result"]);
$i = 0;
foreach ($json["result"] as $value)
{
$value = $this->convert_truefalse_to_text(utf8_decode($value));
echo "<br />".$keys[$i]."= $value";
$i++;
}
}
else
{
echo "Erreur lors de l'exécution de la commande $action.";
echo "<br />Le message d'erreur est le suivant : ".utf8_decode($json["msg"])." (".utf8_decode($json["error_code"]).")";
}

}
}


Expand Down
8 changes: 4 additions & 4 deletions freebox.php
Expand Up @@ -54,7 +54,7 @@
else
$brightness = 100;
$array_config = array('brightness' => $brightness);
$configuration->UpdateLcdConfig($array_config);
$freebox->DisplayResult($configuration->UpdateLcdConfig($array_config),"lcd_brightness");
break;
}
case "lcd_orientation" :
Expand All @@ -70,7 +70,7 @@
else
$orientation = 0;
$array_config = array('orientation' => $orientation);
$configuration->UpdateLcdConfig($array_config);
$freebox->DisplayResult($configuration->UpdateLcdConfig($array_config),"lcd_orieentation");
break;
}
case "reboot" :
Expand All @@ -79,7 +79,7 @@

// Instantation de la classe PHP de la partie System
$system = new System($freebox);
$system->Reboot();
$freebox->DisplayResult($system->Reboot(),"reboot");
break;
}

Expand All @@ -96,7 +96,7 @@
else
$enabled = false;
$array_config = array("ap_params" => array( "enabled" => $enabled));
$configuration->UpdateWifiConfig($array_config);
$freebox->DisplayResult($configuration->UpdateWifiConfig($array_config),"wifi");
break;
}
}
Expand Down

0 comments on commit 0a12d67

Please sign in to comment.