Ignore:
Timestamp:
Feb 20, 2014 3:03:59 AM (10 years ago)
Author:
anonymous
Message:

Completed integrating /branches/eli_branch into /trunk. Changes include:

  • Removed closing ?> from end of files
  • Upgrade old-style contructor methods to use construct() instead.
  • Class properties and methods defined as public, private, static or protected
  • Ensure code runs under E_ALL with only mysql_* deprecated warnings
  • Search for the '@' symbol anywhere it might be used to supress runtime errors, then replace with proper error recovery.
  • Run the php cli -l option to check files for syntax errors.
  • Bring tests up-to-date with latest version and methods of PHPUnit
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/lib/Version.inc.php

    r396 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3939class Version {
    4040
     41    // A place to keep an object instance for the singleton pattern.
     42    private static $instance = null;
     43
    4144    // Configuration of this object.
    42     var $_params = array(
     45    private $_params = array(
    4346        'max_qty' => 100, // Never have more than this many versions of each record.
    4447        'min_qty' => 25, // Keep at least this many versions of each record.
    4548        'min_days' => 7, // Keep ALL versions within this many days, even if MORE than min_qty.
    4649        'db_table' => 'version_tbl',
    47        
     50
    4851        // Automatically create table and verify columns. Better set to false after site launch.
    4952        // This value is overwritten by the $app->getParam('db_create_tables') setting if it is available.
     
    5457
    5558    // Auth_SQL object from which to access a current user_id.
    56     var $_auth;
     59    private $_auth;
    5760
    5861    /**
     
    6366     * @static
    6467     */
    65     static function &getInstance($auth_object)
    66     {
    67         static $instance = null;
    68 
    69         if ($instance === null) {
    70             $instance = new Version($auth_object);
    71         }
    72 
    73         return $instance;
     68    public static function &getInstance($auth_object)
     69    {
     70        if (self::$instance === null) {
     71            self::$instance = new self($auth_object);
     72        }
     73
     74        return self::$instance;
    7475    }
    7576
     
    7980     * @param mixed  $auth_object  An Auth_SQL object.
    8081     */
    81     function Version($auth_object)
     82    public function __construct($auth_object)
    8283    {
    8384        $app =& App::getInstance();
     
    102103     * @since   26 Aug 2005 17:09:36
    103104     */
    104     function initDB($recreate_db=false)
     105    public function initDB($recreate_db=false)
    105106    {
    106107        $app =& App::getInstance();
     
    155156     * @param  array $params   Array of param keys and values to set.
    156157     */
    157     function setParam($params=null)
     158    public function setParam($params=null)
    158159    {
    159160        if (isset($params) && is_array($params)) {
     
    170171     * @return mixed               Configured parameter value.
    171172     */
    172     function getParam($param)
     173    public function getParam($param)
    173174    {
    174175        $app =& App::getInstance();
    175    
     176
    176177        if (isset($this->_params[$param])) {
    177178            return $this->_params[$param];
     
    192193     * @return int                  The id for the version (mysql last insert id).
    193194     */
    194     function create($record_table, $record_key, $record_val, $title='', $notes='')
     195    public function create($record_table, $record_key, $record_val, $title='', $notes='')
    195196    {
    196197        $app =& App::getInstance();
     
    204205            return false;
    205206        }
    206        
     207
    207208        // Get previous version_number.
    208209        $qid = $db->query("
     
    253254     * @return int                  The id for the version (mysql last insert id).
    254255     */
    255     function restore($version_id)
     256    public function restore($version_id)
    256257    {
    257258        $app =& App::getInstance();
     
    314315     * @return mixed                Array of versions, or false if none.
    315316     */
    316     function deleteOld($record_table, $record_key, $record_val)
    317     {
    318         $db =& DB::getInstance();
    319    
     317    public function deleteOld($record_table, $record_key, $record_val)
     318    {
     319        $db =& DB::getInstance();
     320
    320321        $this->initDB();
    321322
     
    381382     * @return mixed                Array of versions, or false if none.
    382383     */
    383     function getList($record_table, $record_key, $record_val)
    384     {
    385         $db =& DB::getInstance();
    386    
     384    public function getList($record_table, $record_key, $record_val)
     385    {
     386        $db =& DB::getInstance();
     387
    387388        $this->initDB();
    388389
    389390        // Get versions of this record.
    390391        $qid = $db->query("
    391             SELECT 
     392            SELECT
    392393                version_id,
    393394                saved_by_user_id,
     
    418419     * @return mixed                Array of data saved in version, or false if none.
    419420     */
    420     function getVerson($version_id)
    421     {
    422         $db =& DB::getInstance();
    423    
     421    public function getVerson($version_id)
     422    {
     423        $db =& DB::getInstance();
     424
    424425        $this->initDB();
    425426
     
    439440     * @return mixed                Array of data saved in version, or false if none.
    440441     */
    441     function getData($version_id)
    442     {
    443         $db =& DB::getInstance();
    444    
     442    public function getData($version_id)
     443    {
     444        $db =& DB::getInstance();
     445
    445446        $this->initDB();
    446447
     
    465466     * @return mixed                Array of data saved in version, or false if none.
    466467     */
    467     function getCurrent($record_table, $record_key, $record_val)
    468     {
    469         $db =& DB::getInstance();
    470    
     468    public function getCurrent($record_table, $record_key, $record_val)
     469    {
     470        $db =& DB::getInstance();
     471
    471472        $this->initDB();
    472473
     
    484485
    485486} // End of class.
    486 ?>
Note: See TracChangeset for help on using the changeset viewer.