links::getAllLinks PHP Method

    function getAllLinks()
    {
        require_once $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . "settings.class.php";
        $settings = new settings();
        if ($settings::db_driver == "xml") {
            // XML
            $links = array();
            $xmlLinks = simplexml_load_file($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "links.xml");
            foreach ($xmlLinks as $xmlLink) {
                $links[] = array("name" => $xmlLink->name, "address" => $xmlLink->address);
            }
        } else {
            // PDO
            require_once $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . "common.class.php";
            $common = new common();
            $dbh = $common->pdoOpen();
            $sql = "SELECT name, address FROM " . $settings::db_prefix . "links ORDER BY name";
            $sth = $dbh->prepare($sql);
            $sth->execute();
            $links = $sth->fetchAll(PDO::FETCH_ASSOC);
            $sth = NULL;
            $dbh = NULL;
        }
        return $links;
    }

Usage Example

Ejemplo n.º 1
0
 function display(&$pageData)
 {
     $common = new common($this);
     // Check if the portal is installed or needs upgraded.
     $thisVersion = "2.5.0";
     if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/classes/settings.class.php")) {
         header("Location: /install/install.php");
     } elseif ($common->getSetting("version") != $thisVersion) {
         header("Location: /install/upgrade.php");
     }
     // The Base URL of this page (needed for Plane Finder client link)
     $pageData['baseurl'] = $common->getBaseUrl();
     // Load the master template along with required data for the master template..
     $master = $this->readTemplate('master.tpl');
     require_once $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . "links.class.php";
     $links = new links();
     $pageData['links'] = $links->getAllLinks();
     // Load the template for the requested page.
     $page = $this->readTemplate($common->removeExtension($_SERVER["SCRIPT_NAME"]) . '.tpl');
     $output = $this->mergeAreas($master, $page);
     $output = $this->mergeSettings($output);
     $output = $this->mergePageData($output, $pageData);
     $output = $this->processIfs($output, $pageData);
     $output = $this->processForeach($output, $pageData);
     $output = $this->processFors($output, $pageData);
     $output = $this->processWhiles($output, $pageData);
     $output = $this->removeComments($output);
     // Insert page ID mainly used to mark an active navigation link when using Bootstrap.
     $output = str_replace("{template:pageId}", $common->removeExtension($_SERVER["SCRIPT_NAME"]) . "-link", $output);
     echo $output;
 }