[geeklog-cvs] Geeklog-1.x/system/classes config.class.php,1.2,1.3

Dirk Haun dhaun at qs1489.pair.com
Sun Sep 23 12:51:35 EDT 2007


Update of /cvsroot/geeklog/Geeklog-1.x/system/classes
In directory qs1489.pair.com:/tmp/cvs-serv38161/system/classes

Modified Files:
	config.class.php 
Log Message:
Link to local copy of the documentation for help; some source code cosmetics


Index: config.class.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/system/classes/config.class.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** config.class.php	3 Sep 2007 02:25:19 -0000	1.2
--- config.class.php	23 Sep 2007 16:51:33 -0000	1.3
***************
*** 3,7 ****
  /* Reminder: always indent with 4 spaces (no tabs). */
  // +---------------------------------------------------------------------------+
! // | Geeklog 1.4                                                               |
  // +---------------------------------------------------------------------------+
  // | config.class.php                                                          |
--- 3,7 ----
  /* Reminder: always indent with 4 spaces (no tabs). */
  // +---------------------------------------------------------------------------+
! // | Geeklog 1.5                                                               |
  // +---------------------------------------------------------------------------+
  // | config.class.php                                                          |
***************
*** 11,15 ****
  // | Copyright (C) 2007 by the following authors:                              |
  // |                                                                           |
! // | Authors: Aaron Blankstein          kantai at gmail.com                       |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
--- 11,15 ----
  // | Copyright (C) 2007 by the following authors:                              |
  // |                                                                           |
! // | Authors: Aaron Blankstein  - kantai AT gmail DOT com                      |
  // +---------------------------------------------------------------------------+
  // |                                                                           |
***************
*** 30,40 ****
  // +---------------------------------------------------------------------------+
  //
  
! class config{
      var $ref;
      var $dbconfig_file;
      var $config_array;
  	
!     /* This function will return an instance of the config class. If an 
       * instance with the given group/reference name does not exist, then it 
       * will create a new one. This function insures	that there is only one 
--- 30,42 ----
  // +---------------------------------------------------------------------------+
  //
+ // $Id$
  
! class config {
      var $ref;
      var $dbconfig_file;
      var $config_array;
  	
!     /**
!      * This function will return an instance of the config class. If an 
       * instance with the given group/reference name does not exist, then it 
       * will create a new one. This function insures	that there is only one 
***************
*** 47,51 ****
       *	@return config 			   The newly created or referenced config object
       */
!     function &get_instance(){
          static $instance;
          return $instance;
--- 49,54 ----
       *	@return config 			   The newly created or referenced config object
       */
!     function &get_instance()
!     {
          static $instance;
          return $instance;
***************
*** 55,60 ****
      {
          $instance =& config::get_instance();
!         if ($instance[$ref] === null)
! 	  $instance[$ref] = ($obj === null ? new config($ref) : $obj);
          return $instance[$ref];
      }
--- 58,64 ----
      {
          $instance =& config::get_instance();
!         if ($instance[$ref] === null) {
!             $instance[$ref] = ($obj === null ? new config($ref) : $obj);
!         }
          return $instance[$ref];
      }
***************
*** 65,69 ****
      }
      
!     /* This function sets the secure configuration file (database related 
       * settings) for the configuration class to read. This should only need to
       * be called for the 'Core' group. It also must be called before 
--- 69,74 ----
      }
      
!     /**
!      * This function sets the secure configuration file (database related 
       * settings) for the configuration class to read. This should only need to
       * be called for the 'Core' group. It also must be called before 
***************
*** 78,82 ****
      }
      
!     /* This function reads the secure configuration file and loads 
       * lib-database.php. This needs to be called in the 'Core' group before 
       * &init_config() can be used. It only needs to be called once
--- 83,88 ----
      }
      
!     /**
!      * This function reads the secure configuration file and loads 
       * lib-database.php. This needs to be called in the 'Core' group before 
       * &init_config() can be used. It only needs to be called once
***************
*** 92,96 ****
          }
      }
!     /* This function initializes the configuration array (i.e. $_CONF) and 
       * will return a reference to the newly created array. The class keeps
       * track of this reference, and the set function will mutate it.
--- 98,104 ----
          }
      }
! 
!     /**
!      * This function initializes the configuration array (i.e. $_CONF) and 
       * will return a reference to the newly created array. The class keeps
       * track of this reference, and the set function will mutate it.
***************
*** 113,117 ****
          return $this->config_array;
      }
!     /* This function sets a configuration variable to a value in the database 
       * and in the current array. If the variable does not already exist, 
       * nothing will happen.
--- 121,127 ----
          return $this->config_array;
      }
! 
!     /**
!      * This function sets a configuration variable to a value in the database 
       * and in the current array. If the variable does not already exist, 
       * nothing will happen.
***************
*** 128,136 ****
              "SET value = '{$escaped_val}' WHERE " .
              "name = '{$escaped_name}' AND group_name = '{$this->ref}'";
!         if($_DB_dbms == 'mssql'){
              $sql_query = str_replace("\\'","''",$sql_query);
              $sql_query = str_replace('\\"','"',$sql_query);
              $_DB->dbQuery($sql_query, 0, 1);
!         }else{
              DB_query($sql_query);
          }
--- 138,146 ----
              "SET value = '{$escaped_val}' WHERE " .
              "name = '{$escaped_name}' AND group_name = '{$this->ref}'";
!         if ($_DB_dbms == 'mssql') {
              $sql_query = str_replace("\\'","''",$sql_query);
              $sql_query = str_replace('\\"','"',$sql_query);
              $_DB->dbQuery($sql_query, 0, 1);
!         } else {
              DB_query($sql_query);
          }
***************
*** 139,143 ****
              $this->_post_configuration();
      }
!     function restore_param($name){
          global $_TABLES;
          $escaped_name = addslashes($name);
--- 149,155 ----
              $this->_post_configuration();
      }
! 
!     function restore_param($name)
!     {
          global $_TABLES;
          $escaped_name = addslashes($name);
***************
*** 146,150 ****
          DB_query($sql);
      }
!     function unset_param($name){
          global $_TABLES;
          $escaped_name = addslashes($name);
--- 158,164 ----
          DB_query($sql);
      }
! 
!     function unset_param($name)
!     {
          global $_TABLES;
          $escaped_name = addslashes($name);
***************
*** 208,216 ****
          $sql_query = vsprintf($format, $Qargs);
  
!         if($_DB_dbms == 'mssql'){
              $sql_query = str_replace("\\'","''",$sql_query);
              $sql_query = str_replace('\\"','"',$sql_query);
              $_DB->dbQuery($sql_query, 0, 1);
!         }else{
              DB_query($sql_query);
          }
--- 222,230 ----
          $sql_query = vsprintf($format, $Qargs);
  
!         if ($_DB_dbms == 'mssql') {
              $sql_query = str_replace("\\'","''",$sql_query);
              $sql_query = str_replace('\\"','"',$sql_query);
              $_DB->dbQuery($sql_query, 0, 1);
!         } else {
              DB_query($sql_query);
          }
***************
*** 218,222 ****
          $this->config_array[$param_name] = $default_value;
      }
!     /* Permanently deletes a parameter
       * @param string  $param_name   This is the name of the parameter to delete
       */
--- 232,238 ----
          $this->config_array[$param_name] = $default_value;
      }
! 
!     /**
!      * Permanently deletes a parameter
       * @param string  $param_name   This is the name of the parameter to delete
       */
***************
*** 228,232 ****
          unset($this->config_array[$param_name]);
      }
! 	/* Gets extended (GUI related) information from the database
  	 * @param string subgroup			filters by subgroup
  	 * @return array(string => string => array(string => mixed))
--- 244,250 ----
          unset($this->config_array[$param_name]);
      }
! 
! 	/**
!      * Gets extended (GUI related) information from the database
  	 * @param string subgroup			filters by subgroup
  	 * @return array(string => string => array(string => mixed))
***************
*** 261,266 ****
          return $res;
      }
      /* Changes any config settings that depend on other configuration settings. */
!     function _post_configuration(){
          $this->config_array['path_layout'] = $this->config_array['path_themes'] 
              . $this->config_array['theme'] . '/';
--- 279,286 ----
          return $res;
      }
+ 
      /* Changes any config settings that depend on other configuration settings. */
!     function _post_configuration()
!     {
          $this->config_array['path_layout'] = $this->config_array['path_themes'] 
              . $this->config_array['theme'] . '/';
***************
*** 273,276 ****
--- 293,297 ----
          return array_keys(config::get_instance());
      }
+ 
      function get_sgroups()
      {
***************
*** 286,290 ****
      }
  
! 	/* This function is responsible for creating the configuration GUI
  	 *
  	 * @param string sg		This is the subgroup name to load the gui for. 
--- 307,312 ----
      }
  
! 	/**
!      * This function is responsible for creating the configuration GUI
  	 *
  	 * @param string sg		This is the subgroup name to load the gui for. 
***************
*** 297,301 ****
  	 *						the "Changes" message box.						
  	 */
- 	
      function get_ui($sg=0, $change_result=null)
      {
--- 319,322 ----
***************
*** 350,353 ****
--- 371,375 ----
          return $display;
      }
+ 
      function _UI_get_change_block($changes)
      {
***************
*** 404,426 ****
          if ($deletable)
              $t->set_var('delete', $t->parse('output', 'delete-button'));
!         else if ($this->ref == 'Core' ){
              $t->set_var('unset_link', 
                          "<a href='#' onClick='unset(\"{$name}\");'>(X)</a>");
!             if(($a = strrchr($name, '[')) !== FALSE)
                  $o = substr($a, 1, -1);
!             else
                  $o = $name;
!             if (! is_numeric($o) )
                  $t->set_var('doc_link', 
!                             "(<a target='help' href='http://www.geeklog.net" .
!                             "/docs/config.html#desc_{$o}'>?</a>)");
          }
          if ($type == "unset") {
              return $t->finish($t->parse('output', 'unset-param'));
!         } else if ($type == "text") {
              return $t->finish($t->parse('output', 'text-element'));
!         } else if ($type == "placeholder") {
              return $t->finish($t->parse('output', 'placeholder-element'));
!         } else if ($type == "select") {
              if (! is_array($selectionArray))
                  return $t->finish($t->parse('output', 'text-element'));
--- 426,455 ----
          if ($deletable)
              $t->set_var('delete', $t->parse('output', 'delete-button'));
!         elseif ($this->ref == 'Core' ) {
              $t->set_var('unset_link', 
                          "<a href='#' onClick='unset(\"{$name}\");'>(X)</a>");
!             if (($a = strrchr($name, '[')) !== FALSE) {
                  $o = substr($a, 1, -1);
!             } else {
                  $o = $name;
!             }
!             if (! is_numeric($o)) {
!                 if (!empty($GLOBALS['_CONF']['site_url'])) {
!                     $baseUrl = $GLOBALS['_CONF']['site_url'];
!                 } else {
!                     $baseUrl = 'http://www.geeklog.net';
!                 }
                  $t->set_var('doc_link', 
!                             '(<a href="' . $baseUrl . '/docs/config.html#desc_'
!                             . $o . '" target="help">?</a>)');
!             }
          }
          if ($type == "unset") {
              return $t->finish($t->parse('output', 'unset-param'));
!         } elseif ($type == "text") {
              return $t->finish($t->parse('output', 'text-element'));
!         } elseif ($type == "placeholder") {
              return $t->finish($t->parse('output', 'placeholder-element'));
!         } elseif ($type == "select") {
              if (! is_array($selectionArray))
                  return $t->finish($t->parse('output', 'text-element'));
***************
*** 437,441 ****
              }
              return $t->parse('output', 'select-element');
!         }else if (strpos($type, "@") === 0){
              $result = "";
              foreach ($val as $valkey => $valval) {
--- 466,470 ----
              }
              return $t->parse('output', 'select-element');
!         } elseif (strpos($type, "@") === 0) {
              $result = "";
              foreach ($val as $valkey => $valval) {
***************
*** 445,449 ****
              }
              return $result;
!         }else if (strpos($type, "*") === 0 || strpos($type, "%") === 0){
              $t->set_var('arr_name', $name);
              $t->set_var('array_type', $type);
--- 474,478 ----
              }
              return $result;
!         } elseif (strpos($type, "*") === 0 || strpos($type, "%") === 0) {
              $t->set_var('arr_name', $name);
              $t->set_var('array_type', $type);
***************
*** 461,465 ****
          }
      }
! 	/* This function takes $_POST input and evaluates it
  	 *
  	 * param array(string=>mixed) $change_array		this is the $_POST array
--- 490,496 ----
          }
      }
! 
! 	/**
!      * This function takes $_POST input and evaluates it
  	 *
  	 * param array(string=>mixed) $change_array		this is the $_POST array
***************
*** 486,495 ****
      function _validate_input(&$input_val)
      {
!         if (is_array($input_val)){
              $r = array();
              foreach ($input_val as $key => $val)
                  if ($key !== 'placeholder')
                      $r[$key] = $this->_validate_input($val);
!         }else{
              $r = COM_stripSlashes( $input_val );
              if ($r == 'b:0' OR $r == 'b:1')
--- 517,526 ----
      function _validate_input(&$input_val)
      {
!         if (is_array($input_val)) {
              $r = array();
              foreach ($input_val as $key => $val)
                  if ($key !== 'placeholder')
                      $r[$key] = $this->_validate_input($val);
!         } else {
              $r = COM_stripSlashes( $input_val );
              if ($r == 'b:0' OR $r == 'b:1')




More information about the geeklog-cvs mailing list