common::getSetting PHP Method

getSetting() public method

Returns the value for the specified setting name.
public getSetting ( $name )
    function getSetting($name)
    {
        require_once $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "classes" . DIRECTORY_SEPARATOR . "settings.class.php";
        $settings = new settings();
        if ($name == "dataStorage") {
            return $settings::db_driver;
        }
        if ($settings::db_driver == 'xml') {
            // XML
            $theseSettings = simplexml_load_file($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "settings.xml");
            foreach ($theseSettings as $setting) {
                if ($setting->name == $name) {
                    return $setting->value;
                }
            }
        } else {
            // PDO
            $dbh = $this->pdoOpen();
            $sql = "SELECT * FROM " . $settings::db_prefix . "settings WHERE name = :name";
            $sth = $dbh->prepare($sql);
            $sth->bindParam(':name', $name, PDO::PARAM_STR, 50);
            $sth->execute();
            $row = $sth->fetch();
            $sth = NULL;
            $dbh = NULL;
            return $row['value'];
        }
        return "";
    }

Usage Example

Exemplo 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;
 }
All Usage Examples Of common::getSetting