SyncCode I3 class.Config.inc.php

From MWWiki

Jump to: navigation, search

Back to WordPress Synchronizer

<?php
 
defined('WS') or die('Restricted access');
 
/**
 * This file's purpose is simply to store any information pertinent to the 
 * global configuration settings of the application.  No object instantiations 
 * are made here; only setting up the parameters for those instantiations.
 * 
 * @package WordPress.Synchronizer
 * @author Shannon Quinn
 * @version 0.1
 */
 
// ---------------------------------------------
// Revisions
// 0.1  - 9/25/08
//      - Altered file from previous project
 
class Config {
 
  /***********************\
  |   Private Attributes  |
  \***********************/
 
  // For the sake of clarity...I am forgoing official PHPDoc style guidelines
  // and providing a single-line description of each field.  This will
  // make the file at large more readable and, most importantly, more editable.
 
  // GLOBAL WEBSITE CONFIGURATION
  private $sitename = "WordPress Synchronizer";
  private $debug = true;
 
  // FIRST BLOG CONFIGURATION
  private $url1      = "your url here"
  private $username1 = "your username here"
  private $password1 = "your password here"
 
  // SECOND BLOG CONFIGURATION
  private $url2      = "your url here";
  private $username2 = "your username here";
  private $password2 = "your password here";
 
  // FILESYSTEM PATHS
  private $abs_path = "your absolute path here";
  private $rel_path = "your relative path here";
  //private $abs_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $rel_path;
 
  /***********************\
  |       Functions       |
  \***********************/
 
  /**
   * Constructor.
   * 
   * @access private
   */
  private function __construct() {
    if ($this->password2 == '' && $this->username2 == '') {
      $this->password2 = $this->password1;
      $this->username2 = $this->username1;
    }
  }
 
  /**
   * Accessor method by which the Factory class generates instances.
   * 
   * @static
   * @access public
   * @return object An instance of a Config object.
   */
  public static function getInstance() {
    static $instance;
    if (!is_object($instance)) {
      $instance = new Config();
    }
    return $instance;
  }
 
  /**
   * General accessor for configuration settings.
   * 
   * @access public
   * @param string $var The name of the configuration variable.
   * @param mixed $default The default return value.
   * @return mixed The value of $var, or $default if not set.
   */
  public function getValue($var, $default = null) {
    if (isset($this->$var)) {
      // if this variable exists, return its value
      return $this->$var;
    }
 
    // return the default if the specified variable does not exist
    return $default;
  }
 
  /**
   * This is a wrapper for the FirePHP debugger function, fb().
   * 
   * It prints everything to the console, performing all checks necessary
   * to ensure that the FirePHP extension is installed, that the function
   * is callable, and that debug mode is on.
   *
   * @access public
   * @param string $title A description of the variable to be printed in the console.
   * @param mixed $variable The value of the variable to be printed.
   */
  public function debugoutput($title, $variable) {
    // make sure debug mode is on, and make sure the FirePHP extension
    // is installed and ready
    if ($this->getValue('debug') && is_callable('fb')) {
      ob_start(); // buffer output
      if (is_array($variable) && isset($variable[0]) && is_array($variable[0])) {
        fb(array($title, $variable), FirePHP::TABLE);
      } else {
        fb($variable, $title, FirePHP::LOG);
      }
    } else if ($this->getValue('debug')) { // firebug isn't installed
 
    }
  }
 
}
 
?>
Personal tools