function render() { $oView = new \BaikalAdmin\View\Settings\System(); $oView->setData("message", \Formal\Core\Message::notice("Do not change anything on this page unless you really know what you are doing.<br />You might break Baïkal if you misconfigure something here.", "Warning !", false)); $oView->setData("form", $this->oForm->render()); return $oView->render(); }
public function render() { $sActionUrl = \Flake\Util\Tools::getCurrentUrl(); $sSubmittedFlagName = "auth"; $sMessage = ""; if (self::isSubmitted() && !\BaikalAdmin\Core\Auth::isAuthenticated()) { $sMessage = \Formal\Core\Message::error("The login/password you provided is invalid. Please retry.", "Authentication error"); } elseif (self::justLoggedOut()) { $sMessage = \Formal\Core\Message::notice("You have been disconnected from your session.", "Session ended", FALSE); } $sLogin = htmlspecialchars(\Flake\Util\Tools::POST("login")); $sPassword = htmlspecialchars(\Flake\Util\Tools::POST("password")); if (trim($sLogin) === "") { $sLogin = "******"; } $oView = new \BaikalAdmin\View\Login(); $oView->setData("message", $sMessage); $oView->setData("actionurl", $sActionUrl); $oView->setData("submittedflagname", $sSubmittedFlagName); $oView->setData("login", $sLogin); $oView->setData("password", $sPassword); return $oView->render(); }
protected function actionDelete() { $aParams = $this->getParams(); $iModel = intval($aParams["delete"]); if ($this->actionDeleteConfirmed() !== false) { # catching Exception thrown when model already destroyed # happens when user refreshes page on delete-URL, for instance try { $oModel = new \Baikal\Model\AddressBook($iModel); $oModel->destroy(); } catch (\Exception $e) { # already deleted; silently discarding } # Redirecting to admin home \Flake\Util\Tools::redirectUsingMeta($this->linkHome()); } else { $oModel = new \Baikal\Model\AddressBook($iModel); $this->aMessages[] = \Formal\Core\Message::warningConfirmMessage("Check twice, you're about to delete " . $oModel->label() . "</strong> from the database !", "<p>You are about to delete a contact book and all it's visiting cards. This operation cannot be undone.</p><p>So, now that you know all that, what shall we do ?</p>", $this->linkDeleteConfirm($oModel), "Delete <strong><i class='" . $oModel->icon() . " icon-white'></i> " . $oModel->label() . "</strong>", $this->linkHome()); } }
public function render() { $aHtml = array(); $oMorpho = $this->getMorpho(); $oMorpho->elements()->reset(); foreach ($oMorpho->elements() as $oElement) { # Setting current prop value for element # Set on empty (just created) FormMorphology # And obtained from Model instance $oElement->setValue($this->modelInstance()->get($oElement->option("prop"))); $aHtml[] = $oElement->render(); } $elements = implode("\n", $aHtml); $sModelClass = $this->sModelClass; ###################################################### # Displaying messages ###################################################### if ($this->submitted()) { # There were errors detected during execute() # Error messages are displayed if (!empty($this->aErrors)) { $this->sDisplayMessage = ""; $aMessages = array(); reset($this->aErrors); foreach ($this->aErrors as $aError) { if (trim($aError["message"]) === "") { continue; } $aMessages[] = $aError["message"]; } $this->sDisplayMessage = \Formal\Core\Message::error(implode("<br />", $aMessages), "Validation error"); } } $sSubmittedFlagName = $this->submitSignatureName(); if ($this->option("close") === TRUE) { $sCloseUrl = $this->option("closeurl"); $sCloseButton = '<a class="btn" href="' . $sCloseUrl . '">Close</a>'; } else { $sCloseButton = ""; } $sActionUrl = $this->option("action"); $sHtml = <<<HTML <form class="form-horizontal" action="{$sActionUrl}" method="post" enctype="multipart/formdata"> \t<input type="hidden" name="{$sSubmittedFlagName}" value="1" /> \t<input type="hidden" name="refreshed" value="0" /> \t<fieldset> \t\t<legend style="line-height: 40px;">{$this->sDisplayTitle}</legend> \t\t{$this->sDisplayMessage} \t\t{$elements} \t\t<div class="form-actions"> \t\t\t<button type="submit" class="btn btn-primary">Save changes</button> \t\t\t{$sCloseButton} \t\t</div> \t</fieldset> </form> HTML; return $sHtml; }
function render() { $aHtml = []; $oMorpho = $this->getMorpho(); $oMorpho->elements()->reset(); foreach ($oMorpho->elements() as $oElement) { # Setting current prop value for element # Set on empty (just created) FormMorphology # And obtained from Model instance $oElement->setValue($this->modelInstance()->get($oElement->option("prop"))); $aHtml[] = $oElement->render(); } $elements = implode("\n", $aHtml); $sModelClass = $this->sModelClass; ###################################################### # Displaying messages ###################################################### if ($this->submitted()) { # There were errors detected during execute() # Error messages are displayed if (!empty($this->aErrors)) { $this->sDisplayMessage = ""; $aMessages = []; reset($this->aErrors); foreach ($this->aErrors as $aError) { if (trim($aError["message"]) === "") { continue; } $aMessages[] = $aError["message"]; } $this->sDisplayMessage = \Formal\Core\Message::error(implode("<br />", $aMessages), "Validation error"); } } $sSubmittedFlagName = $this->submitSignatureName(); if ($this->option("close") === true) { $sCloseUrl = $this->option("closeurl"); $sCloseButton = '<a class="btn" href="' . $sCloseUrl . '">Close</a>'; } else { $sCloseButton = ""; } if (!isset($_SESSION['CSRF_TOKEN'])) { throw new \LogicException('A CSRF token must be set in the session. Try clearing your cookies and logging in again'); } $csrfToken = htmlspecialchars($_SESSION['CSRF_TOKEN']); $sActionUrl = $this->option("action"); $sHtml = <<<HTML <form class="form-horizontal" action="{$sActionUrl}" method="post" enctype="multipart/formdata"> <input type="hidden" name="{$sSubmittedFlagName}" value="1" /> <input type="hidden" name="refreshed" value="0" /> <input type="hidden" name="CSRF_TOKEN" value="{$csrfToken}" /> <fieldset> <legend style="line-height: 40px;">{$this->sDisplayTitle}</legend> {$this->sDisplayMessage} {$elements} <div class="form-actions"> <button type="submit" class="btn btn-primary">Save changes</button> {$sCloseButton} </div> </fieldset> </form> HTML; return $sHtml; }