Exemple #1
0
 public static function icon($data, Fhem $F, Button $B)
 {
     switch ($F->A("FhemHMModel")) {
         case "HM-Sec-RHS":
             if ($data->attributes()->state == "open") {
                 $B->image("warning");
             }
             if ($data->attributes()->state == "closed") {
                 $B->image("bestaetigung");
             }
             if ($data->attributes()->state == "tilted") {
                 $B->image("notice");
             }
             break;
     }
 }
Exemple #2
0
 public function process(Fhem $F, $xml)
 {
     $state = $xml->attributes()->state;
     $stateText = "";
     $event = "\$j('#FhemControlID_" . $F->getID() . "').removeClass('highlight');";
     $FS = new Button("", "./images/i2/empty.png", "icon");
     $FS->style("float:left;margin-right:5px;width:32px;height:32px;");
     if ($state != "off" && $state != "aus") {
         $FS->image("./fheME/SieHabenPost/SieHabenPost.png");
         $stateText = "Sie haben Post!";
         $event = "\$j('#FhemControlID_" . $F->getID() . "').addClass('highlight');";
     }
     return "{$FS}<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b><br /><small style=\"color:grey;\">{$stateText}</small><div style=\"clear:both;\"></div>" . OnEvent::script($event);
 }
 public function updateGUI($ID = null)
 {
     $result = array();
     $S = new mFhemServerGUI();
     $S->addAssocV3("FhemServerType", "=", "0");
     while ($s = $S->getNextEntry()) {
         try {
             $x = simplexml_load_string($s->getListXML());
         } catch (NoServerConnectionException $e) {
             continue;
         }
         if (isset($x->dummy_LIST->dummy) and count($x->dummy_LIST->dummy) > 0) {
             foreach ($x->dummy_LIST->dummy as $k => $v) {
                 $F = new mFhemGUI();
                 $F->addAssocV3("FhemServerID", "=", $s->getID());
                 $F->addAssocV3("FhemName", "=", $v->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 $state = $v->attributes()->state;
                 #if($F->A("FhemModel") == "fs20irf") $state = "off";
                 #$state = strtolower(str_replace("dim", "", $state));
                 $FS = new Button("", "./fheME/Fhem/off.png", "icon");
                 $FS->style("float:left;margin-right:5px;");
                 if ($state != "off" && $state != "aus") {
                     $FS->image("./fheME/Fhem/on.png");
                 }
                 if (!is_numeric(str_replace("%", "", $state))) {
                     $state = "";
                 }
                 $return = "{$FS}<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b> <small style=\"color:grey;\">{$state}</small><div style=\"clear:both;\"></div>";
                 if ($F->A("FhemExtension") != "none" and $F->A("FhemExtension") != "") {
                     $c = $F->A("FhemExtension");
                     $c = new $c(-1);
                     $return = $c->process($F, $v);
                 }
                 $result[$F->getID()] = array("model" => $F->A("FhemModel"), "state" => $return);
             }
         }
         if (isset($x->FS20_LIST->FS20) and count($x->FS20_LIST->FS20) > 0) {
             foreach ($x->FS20_LIST->FS20 as $k => $v) {
                 $F = new mFhemGUI();
                 $F->addAssocV3("FhemServerID", "=", $s->getID());
                 $F->addAssocV3("FhemName", "=", $v->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 $state = $v->attributes()->state;
                 if ($F->A("FhemModel") == "fs20irf") {
                     $state = "off";
                 }
                 $state = strtolower(str_replace("dim", "", $state));
                 $FS = new Button("", "./fheME/Fhem/off.png", "icon");
                 $FS->style("float:left;margin-right:5px;");
                 if ($state != "off" && $state != "aus") {
                     $FS->image("./fheME/Fhem/on.png");
                 }
                 if (!is_numeric(str_replace("%", "", $state))) {
                     $state = "";
                 }
                 $result[$F->getID()] = array("model" => $F->A("FhemModel"), "state" => "{$FS}<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b> <small style=\"color:grey;\">{$state}</small><div style=\"clear:both;\"></div>");
             }
         }
         if (isset($x->IT_LIST->IT) and count($x->IT_LIST->IT) > 0) {
             foreach ($x->IT_LIST->IT as $k => $v) {
                 $F = new mFhemGUI();
                 $F->addAssocV3("FhemServerID", "=", $s->getID());
                 $F->addAssocV3("FhemName", "=", $v->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 $state = $v->attributes()->state;
                 $state = strtolower(str_replace("dim", "", $state));
                 $IT = new Button("", "./fheME/Fhem/off.png", "icon");
                 $IT->style("float:right;margin-right:-10px;margin-top:-13px;margin-left:3px;");
                 if ($state != "off" && $state != "aus") {
                     $IT->image("./fheME/Fhem/on.png");
                 }
                 $result[$F->getID()] = array("model" => $F->A("FhemITModel"), "state" => "{$IT}<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b> ");
             }
         }
         if (isset($x->CUL_HM_LIST->CUL_HM) and count($x->CUL_HM_LIST->CUL_HM) > 0) {
             foreach ($x->CUL_HM_LIST->CUL_HM as $k => $v) {
                 $F = new mFhemGUI();
                 $F->addAssocV3("FhemServerID", "=", $s->getID());
                 $F->addAssocV3("FhemName", "=", $v->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 $result[$F->getID()] = $F->getStatus($v);
             }
         }
         if (isset($x->CUL_EM_LIST->CUL_EM) and count($x->CUL_EM_LIST->CUL_EM) > 0) {
             foreach ($x->CUL_EM_LIST->CUL_EM as $em) {
                 $F = anyC::get("Fhem", "FhemServerID", $s->getID());
                 $F->addAssocV3("FhemName", "=", $em->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 foreach ($em->STATE as $state) {
                     if ($state->attributes()->key == "current") {
                         $current = $state->attributes()->value;
                     }
                 }
                 $result[$F->getID()] = array("model" => $F->A("FhemEMModel"), "state" => "<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b><small style=\"color:grey;\">" . $current . "</small>");
             }
         }
         if (isset($x->FHT_LIST->FHT) and count($x->FHT_LIST->FHT) > 0) {
             foreach ($x->FHT_LIST->FHT as $fht) {
                 $F = anyC::get("Fhem", "FhemServerID", $s->getID());
                 $F->addAssocV3("FhemName", "=", $fht->attributes()->name);
                 $F = $F->getNextEntry();
                 if ($F == null) {
                     continue;
                 }
                 if ($ID and $F->getID() != $ID) {
                     continue;
                 }
                 $measuredTemp = 0;
                 $warnings = "";
                 $actuator = "";
                 $desiredTemp = "";
                 $mode = "";
                 foreach ($fht->STATE as $state) {
                     if ($state->attributes()->key == "measured-temp") {
                         $measuredTemp = str_replace(" (Celsius)", "", $state->attributes()->value);
                     }
                     if ($state->attributes()->key == "warnings") {
                         $warnings = $state->attributes()->value;
                     }
                     if ($state->attributes()->key == "actuator") {
                         $actuator = $state->attributes()->value;
                     }
                     if ($state->attributes()->key == "desired-temp") {
                         $desiredTemp = $state->attributes()->value;
                     }
                     if ($state->attributes()->key == "mode") {
                         $mode = $state->attributes()->value;
                     }
                 }
                 $M = "";
                 if ($mode == "holiday_short") {
                     $M = new Button("", "./fheME/Fhem/modeHoliday.png", "icon");
                     $M->style("float:right;margin-top:-12px;margin-right:-9px;");
                 }
                 $B = "";
                 if ($warnings == "Temperature too low") {
                     $B = new Button("", "./fheME/Fhem/tooCold.png", "icon");
                     $B->style("float:left;margin-right:5px;");
                 }
                 if ($warnings == "Window open") {
                     $B = new Button("", "./fheME/Fhem/windowOpen.png", "icon");
                     $B->style("float:left;margin-right:5px;");
                 }
                 if ($warnings == "Battery low") {
                     $B = new Button("", "./fheME/Fhem/batteryLow.png", "icon");
                     $B->style("float:left;margin-right:5px;");
                 }
                 $Icon = new Button("", "./fheME/Fhem/fhemFHT.png", "icon");
                 $Icon->style("float:left;margin-right:5px;");
                 $result[$F->getID()] = array("model" => $F->A("FhemFHTModel"), "state" => "{$Icon}{$M}<b>" . ($F->A("FhemAlias") == "" ? $F->A("FhemName") : $F->A("FhemAlias")) . "</b><small style=\"color:grey;\"> " . Util::CLFormatNumber(str_replace(".", ".", $measuredTemp), 1) . "/" . Util::CLFormatNumber(str_replace(".", ".", $desiredTemp), 1) . "<span id=\"FhemID_" . $F->getID() . "TargetTemp\" data-value=\"desired-temp {$desiredTemp}\"></span> <small>({$actuator})</small>" . ($warnings != "none" ? "<br />{$B}{$warnings}" : "") . "<div style=\"clear:both;\"></div>");
             }
         }
     }
     echo json_encode($result, defined("JSON_UNESCAPED_UNICODE") ? JSON_UNESCAPED_UNICODE : 0);
 }
Exemple #4
0
 public function showFeed()
 {
     $list = new HTMLList();
     $list->addListStyle("list-style-type:none;padding:5px;max-height:400px;overflow:auto;");
     $E = $this->parseFeed();
     $i = 0;
     foreach ($E as $item) {
         if ($this->A("RSSParserCount") > 0 and $this->A("RSSParserCount") <= $i) {
             break;
         }
         $B = new Button("", "empty", "icon");
         $B->style("float:left;margin-right:10px;margin-top:-5px;");
         if ($item->icon != null) {
             $B->image($item->icon);
         } else {
             $B = "";
         }
         $list->addItem($B . "<div id=\"RSSParserItemSF{$i}\" style=\"margin-top:33px;position:absolute;width:400px;display:none;border-width:1px;border-style:solid;padding:5px;border-radius:5px;\" onclick=\"\$j(this).toggle();\" class=\"backgroundColor0 borderColor1 RSSParserItemSF\"><small>" . $item->description . "</small></div>\n\t\t\t\t" . ($item->description != "" ? "<a href=\"#\" onclick=\"\$j('.RSSParserItemSF').hide(); \$j('#RSSParserItemSF{$i}').toggle();\" >" : "") . $item->title . ($item->description != "" ? "</a>" : "") . "<br /><small style=\"color:grey;\">" . Util::CLDateTimeParser($item->pubDate) . "</small>");
         $list->addItemStyle("clear:both;display:block;margin-left:0px;");
         $i++;
     }
     echo $list;
 }
 public function getWindow($redo = false)
 {
     register_shutdown_function('BackupManagerGUIFatalErrorShutdownHandler');
     $F = new File(Util::getRootPath() . "system/Backup");
     if (!$F->A("FileIsWritable")) {
         $B = new Button("Achtung", "restrictions");
         $B->type("icon");
         $B->style("float:left;margin-right:10px;");
         $T = new HTMLTable(1);
         $T->addRow($B . "Es können keine Backups von Ihrer Datenbank angelegt werden, da das Verzeichnis /system/Backup nicht durch den Webserver beschreibbar ist.");
         $T->addRow("Machen Sie das Verzeichnis mit einem FTP-Programm beschreibbar. Klicken Sie dazu mit der rechten Maustaste auf das Verzeichnis auf dem Server, wählen Sie \"Eigenschaften\", und geben Sie den Modus 777 an, damit es durch den Besitzer, die Gruppe und alle Anderen les- und schreibbar ist.");
         $BRefresh = new Button("Aktualisieren", "refresh");
         $BRefresh->rmePCR("BackupManager", "", "getWindow", "", "Popup.displayNamed('BackupManagerGUI','Backup-Manager',transport);");
         $BRefresh->style("float:right;");
         $T->addRow($BRefresh);
         $T->addRow("");
         $T->addRowClass("backgroundColor0");
         $T->addRow($this->noBackupButton());
         die($T);
     }
     $html = "";
     if (!BackupManagerGUI::checkForTodaysBackup() or $redo) {
         $T = new HTMLTable(1);
         if ($redo) {
             unlink(BackupManagerGUI::getNewBackupName());
         }
         $BOK = $this->makeBackupOfToday();
         $F = new File(BackupManagerGUI::getNewBackupName());
         $F->loadMe();
         if ($BOK === basename(BackupManagerGUI::getNewBackupName()) and $F->A("FileSize") > 100) {
             $B = new Button("Backup abgeschlossen", "okCatch");
             $B->type("icon");
             $B->style("float:left;margin-right:10px;");
             $T->addRow($B . "Das Backup wurde erfolgreich abgeschlossen!<br />Die Größe der Sicherungsdatei beträgt <strong>" . Util::formatByte($F->A("FileSize"), 2) . "</strong>");
             $T->addRowClass("backgroundColor0");
             try {
                 $ftpUpload = $this->FTPUpload(Util::getRootPath() . "system/Backup/{$BOK}");
                 if ($ftpUpload === true) {
                     $B = new Button("FTP-Upload erfolgreich", "okCatch");
                     $B->type("icon");
                     $B->style("float:left;margin-right:10px;");
                     $T->addRow(array($B . "Das Backup wurde erfolgreich auf den FTP-Server hochgeladen"));
                 }
                 $sftpUpload = $this->SFTPUpload(Util::getRootPath() . "system/Backup/{$BOK}");
                 if ($sftpUpload === true) {
                     $B = new Button("SFTP-Upload erfolgreich", "okCatch");
                     $B->type("icon");
                     $B->style("float:left;margin-right:10px;");
                     $T->addRow(array($B . "Das Backup wurde erfolgreich auf den SFTP-Server hochgeladen"));
                 }
             } catch (Exception $e) {
                 $B->image("warning");
                 $T->addRow(array($B . $e->getMessage()));
             }
             $html .= $T;
         } else {
             $B = new Button("Es ist ein Fehler aufgetreten", "stop");
             $B->type("icon");
             $B->style("float:left;margin-right:10px;");
             $T->addRow($B . "Beim Erstellen des Backups ist ein Fehler aufgetreten: {$BOK}");
             $html .= $T;
         }
         $html .= OnEvent::script(OnEvent::frame("desktopLeft", "Desktop", "2"));
         #"<script type=\"text/javascript\">contentManager.reloadFrame('contentLeft');</script>";
     }
     $gesamt = 0;
     $data = $this->getBackupsList();
     $i = 0;
     $maxD = 5;
     if (count($data) < $maxD) {
         $maxD = count($data);
     }
     $TF = new HTMLTable(2, "Backups ({$maxD}/" . count($data) . ")");
     $TF->addColStyle(2, "text-align:right;");
     $TF->setColWidth(2, "80px");
     foreach ($data as $name => $size) {
         if ($i < 5) {
             if ($name == basename(BackupManagerGUI::getNewBackupName())) {
                 $name = "<span style=\"color:green;\">{$name}</span>";
             }
             $TF->addRow(array($name, Util::formatByte($size, 2)));
         }
         $i++;
         $gesamt += $size;
     }
     $TF->addRow("");
     $TF->addRowClass("backgroundColor0");
     $TF->addRow(array("<b>Gesamt:</b>", "<b>" . Util::formatByte($gesamt, 2) . "</b>"));
     $TF->addCellStyle(1, "text-align:right");
     $TF->addRow(array("Diese Backups können als Admin-Benutzer im Installation-Plugin heruntergeladen und wiederhergestellt werden."));
     $TF->addRowColspan(1, 2);
     $TF->addRow("");
     $TF->addRowClass("backgroundColor0");
     $TF->addRow(array($this->noBackupButton()));
     $TF->addRowColspan(1, 2);
     $BC = new Button("Fenster\nschließen", "bestaetigung");
     $BC->onclick(OnEvent::closePopup("", "BackupManagerGUI"));
     $BC->style("float:right;margin:10px;");
     $BD = new Button("Details\nanzeigen", "down");
     $BD->onclick("\$j('#BMMoreDetails').slideToggle();");
     $BD->style("margin:10px;");
     $BD->className("backgroundColor0");
     echo $html . $BC . $BD . "<div style=\"clear:both;\"></div><div id=\"BMMoreDetails\" style=\"display:none;\">" . $TF . "</div>";
 }