Example #1
0
 public function getPath($sName)
 {
     if (self::isAFramework($sName)) {
         throw new \Flake\Core\Exception(htmlspecialchars(${$sName}) . " is not a framework.", $sName);
     }
     return \Flake\Util\Tools::appendSlash(PROJECT_PATH_FRAMEWORKS . $sName);
 }
 function push(&$mMixed)
 {
     if (!\Flake\Util\Tools::is_a($mMixed, $this->sTypeClassOrProtocol)) {
         throw new \Exception("\\Flake\\Core\\CollectionTyped<" . $this->sTypeClassOrProtocol . ">: Given object is not correctly typed.");
     }
     parent::push($mMixed);
 }
Example #3
0
 public function execute()
 {
     \BaikalAdmin\Core\Auth::unAuthenticate();
     $sControllerForDefaultRoute = $GLOBALS["ROUTER"]::getControllerForRoute("default");
     $sLink = $GLOBALS["ROUTER"]::buildRouteForController($sControllerForDefaultRoute, "loggedout");
     \Flake\Util\Tools::redirect($sLink);
 }
Example #4
0
 public function posted()
 {
     $aPost = \Flake\Util\Tools::POST("witness");
     if (is_array($aPost)) {
         $sProp = $this->option("prop");
         return array_key_exists($sProp, $aPost) && intval($aPost[$sProp]) === 1;
     }
     return FALSE;
 }
Example #5
0
 public static function authenticate()
 {
     if (intval(\Flake\Util\Tools::POST("auth")) !== 1) {
         return FALSE;
     }
     $sUser = \Flake\Util\Tools::POST("login");
     $sPass = \Flake\Util\Tools::POST("password");
     $sPassHash = self::hashAdminPassword($sPass);
     if ($sUser === "admin" && $sPassHash === BAIKAL_ADMIN_PASSWORDHASH) {
         $_SESSION["baikaladminauth"] = md5(BAIKAL_ADMIN_PASSWORDHASH);
         return TRUE;
     }
     return FALSE;
 }
Example #6
0
 function render()
 {
     $sBigIcon = "glyph2x-magic";
     $sBaikalVersion = BAIKAL_VERSION;
     $oView = new \BaikalAdmin\View\Install\Initialize();
     $oView->setData("baikalversion", BAIKAL_VERSION);
     if ($this->oForm->persisted()) {
         $sLink = PROJECT_URI . "admin/install/?/database";
         \Flake\Util\Tools::redirect($sLink);
         exit(0);
         #$sMessage = "<p>Baïkal is now configured. You may <a class='btn btn-success' href='" . PROJECT_URI . "admin/'>Access the Baïkal admin</a></p>";
         #$sForm = "";
     } else {
         $sMessage = "";
         $sForm = $this->oForm->render();
     }
     $oView->setData("message", $sMessage);
     $oView->setData("form", $sForm);
     return $oView->render();
 }
Example #7
0
 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());
     }
 }
Example #8
0
    public function render()
    {
        $disabled = "";
        $inputclass = "";
        $groupclass = "";
        $placeholder = "";
        $value = $this->value();
        $label = $this->option("label");
        $prop = $this->option("prop");
        $helpblock = "";
        $popover = "";
        if ($this->option("readonly") === TRUE) {
            $inputclass .= " disabled";
            $disabled = " disabled";
        }
        if ($this->option("error") === TRUE) {
            $groupclass .= " error";
        }
        $aOptions = $this->option("options");
        if (!is_array($aOptions)) {
            throw new \Exception("\\Formal\\Element\\Listbox->render(): 'options' has to be an array.");
        }
        if (($sHelp = trim($this->option("help"))) !== "") {
            $helpblock = "<p class=\"help-block\">" . $sHelp . "</p>";
        }
        if (($aPopover = $this->option("popover")) !== "") {
            $inputclass .= " popover-focus ";
            $popover = " title=\"" . htmlspecialchars($aPopover["title"]) . "\" ";
            $popover .= " data-content=\"" . htmlspecialchars($aPopover["content"]) . "\" ";
        }
        $clientvalue = htmlspecialchars($value);
        $aRenderedOptions = array();
        if (\Flake\Util\Tools::arrayIsSeq($aOptions)) {
            # Array is sequential
            reset($aOptions);
            foreach ($aOptions as $sOptionValue) {
                $selected = $sOptionValue === $value ? " selected=\"selected\"" : "";
                $aRenderedOptions[] = "<option" . $selected . ">" . htmlspecialchars($sOptionValue) . "</option>";
            }
        } else {
            # Array is associative
            reset($aOptions);
            foreach ($aOptions as $sOptionValue => $sOptionCaption) {
                $selected = $sOptionValue === $value ? " selected=\"selected\"" : "";
                $aRenderedOptions[] = "<option value=\"" . htmlspecialchars($sOptionValue) . "\"" . $selected . ">" . htmlspecialchars($sOptionCaption) . "</option>";
            }
        }
        reset($aRenderedOptions);
        $sRenderedOptions = implode("\n", $aRenderedOptions);
        unset($aRenderedOptions);
        $sHtml = <<<HTML
\t<div class="control-group{$groupclass}">
\t\t<label class="control-label" for="{$prop}">{$label}</label>
\t\t<div class="controls">
\t\t\t<select class="{$inputclass}" id="{$prop}" name="data[{$prop}]"{$disabled}{$popover}>
\t\t\t\t{$sRenderedOptions}
\t\t\t</select>
\t\t\t{$helpblock}
\t\t</div>
\t</div>
HTML;
        return $sHtml . $this->renderWitness();
    }
Example #9
0
 public static function getURLParams()
 {
     $aTokens = self::getRouteTokens();
     # stripping route
     if (!empty($aTokens)) {
         $sRouteUrl = implode("/", $aTokens);
         $sCurrentRoute = $GLOBALS["ROUTER"]::getCurrentRoute();
         if (strpos($sRouteUrl, $sCurrentRoute) === FALSE) {
             throw new \Exception("Flake\\Util\\Router\\QuestionMarkRewrite::getURLParams(): unrecognized route.");
         }
         $sParams = \Flake\Util\Tools::trimSlashes(substr($sRouteUrl, strlen($sCurrentRoute)));
         $aParams = array();
         if ($sParams !== "") {
             $aParams = explode("/", $sParams);
         }
         reset($aParams);
         foreach ($aParams as $sParam => $sValue) {
             $aParams[$sParam] = rawurldecode($sValue);
         }
         return $aParams;
     }
     return array();
 }
Example #10
0
 function parse($aMarkers = array())
 {
     return \Flake\Util\Tools::parseTemplateCode($this->sHtml, $aMarkers);
 }
Example #11
0
 public static function isDBInitialized()
 {
     return isset($GLOBALS["DB"]) && \Flake\Util\Tools::is_a($GLOBALS["DB"], "\\Flake\\Core\\Database");
 }
Example #12
0
 public function refreshed()
 {
     return intval(\Flake\Util\Tools::POST("refreshed")) === 1;
 }
Example #13
0
 protected static function isSubmitted()
 {
     return intval(\Flake\Util\Tools::POST("auth")) === 1;
 }
Example #14
0
 public function addCss($sCssAbsPath)
 {
     if (\Flake\Util\Frameworks::enabled("LessPHP")) {
         $sCompiledPath = PATH_buildcss;
         $sFileName = basename($sCssAbsPath);
         $sCompiledFilePath = $sCompiledPath . \Flake\Util\Tools::shortMD5($sFileName) . "_" . $sFileName;
         if (substr(strtolower($sCompiledFilePath), -4) !== ".css") {
             $sCompiledFilePath .= ".css";
         }
         if (!file_exists($sCompiledPath)) {
             @mkdir($sCompiledPath);
             if (!file_exists($sCompiledPath)) {
                 die("Page: Cannot create " . $sCompiledPath);
             }
         }
         \Frameworks\LessPHP\Delegate::compileCss($sCssAbsPath, $sCompiledFilePath);
         $sCssUrl = \Flake\Util\Tools::serverToRelativeWebPath($sCompiledFilePath);
     } else {
         $sCssUrl = \Flake\Util\Tools::serverToRelativeWebPath($sCssAbsPath);
     }
     $sHtml = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $sCssUrl . "\" media=\"all\"/>";
     $this->zone("head")->addBlock(new \Flake\Controller\HtmlBlock($sHtml));
 }
Example #15
0
 function isA($sClassOrProtocolName)
 {
     return \Flake\Util\Tools::is_a($this, $sClassOrProtocolName);
 }