Location: PHPKode > projects > OpenSEF for Joomla > includes/sef.config.php
<?php
/**
 * OpenSEF for Joomla!
 * @copyright (c) 2005-2006 The OpenSEF Project (http://projects.j-prosolution.com)
 * @copyright (c) 2004-2005 Xaneon Development (www.xaneon.com)
 * @license GPL http://www.gnu.org/copyleft/gpl.html
 *
 * TODO
 */

/** Ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct access to this location is not allowed.' );

/*
 * TODO
 */
class xclPackageInfo {
  var $loaded = false;
  var $xmlFile = null;
  var $xmlDoc = null;

  /*
   * TODO
   */
  function xclPackageInfo( $xmlFile ) {
    if (empty( $xmlFile ) || !file_exists( $xmlFile ))
      return null;

    require_once( $GLOBALS['mosConfig_absolute_path'] .
      '/includes/domit/xml_domit_lite_include.php' );
    $xmlDoc =& new DOMIT_Lite_Document();
    $xmlDoc->resolveErrors( true );
    if (!$xmlDoc->loadXML( $xmlFile, false, true ))
      return false;

    $this->loaded = true;
    $this->xmlFile = $xmlFile;
    $this->xmlDoc =& $xmlDoc;
  }

  /*
   * TODO
   */
  function isAvailable() {
    return $this->loaded;
  }

  /*
   * TODO
   */
  function getElement( $path ) {
    return $this->xmlDoc->getElementsByPath( $path, 1 );
  }

  /*
   * TODO
   */
  function getElementText( $path, $defaultValue = null ) {
    $element =& $this->xmlDoc->getElementsByPath( $path, 1 );
    return (is_object( $element ) ? $element->getText() : $defaultValue);
  }

  /*
   * TODO
   */
  function getElementAttribute( $path, $attribute, $defaultValue = null ) {
    if (($element = $this->xmlDoc->getElementsByPath( $path, 1 )) !== null) {
      $attrs =& $element->attributes;
      if (!is_null( $attribute ) && is_array( $attrs )
          && isset( $attrs[$attribute] )) {
        return $attrs[$attribute];
      }
    }
    return $defaultValue;
  }
}

/*
 * TODO
 */
class xclConfig {
  var $_db                    = null;
  var $_scope                 = null;

  /*
   * TODO
   */
  function xclConfig( &$db, $scope, $reload = true ) {
    $this->_db =& $db;
    $this->_scope = $scope;
    $this->load( $reload );
  }

  /*
   * TODO
   */
  function load( $reload = false ) {
   
      $query = 'SELECT name, value FROM #__opensef_config' .
        "\nWHERE scope = '{$this->_scope}' ORDER BY name ASC";
      $this->_db->setQuery( $query );
      $rows = $this->_db->loadObjectList();
      if ($this->_db->getErrorNum()) {
        trigger_error( $this->_db->stderr(), E_USER_WARNING );
        return false;
      }
      foreach ($rows as $row) {
        $rowData = get_object_vars( $row );
        $rowName = $rowData['name'];
        $rowValue = (isset( $rowData['value'] ) ? $rowData['value'] : null);
        $this->$rowName = htmlspecialchars(stripslashes( $rowValue ));
      }
      if ($this->enabled)
        $this->store( false );
    
    return true;
  }

  /*
   * TODO
   */
  function store( $updateDb = false ) {
  	set_magic_quotes_runtime(0);
    if ($updateDb) {
      $vars = get_object_vars( $this );
      foreach ($vars as $key => $value) {
        if ($key[0] != '_') {
          $value = addslashes( $value );
          $query = 'REPLACE INTO #__opensef_config' .
            "\nSET scope = '{$this->_scope}'," .
            "\nname = '$key', value = '$value'";
          $this->_db->setQuery( $query );
          if (!$this->_db->query()) {
            trigger_error( $this->_db->stderr(), E_USER_WARNING );
            return false;
          }
        }
      }
    }
    return true;
  } // function store

}

?>
Return current item: OpenSEF for Joomla