Changeset 468 for trunk/docs


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:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/docs/codebase_v1-to-v2_upgrade_checklist.txt

    r334 r468  
    1 <?php
    2 
    31=====================================================================
    42In General
     
    86
    97    include SITE_BASE . '/_templates/header.ihtml';
    10    
     8
    119do this:
    1210
    1311    include 'header.ihtml';
    14    
     12
    1513
    16142. CODE_BASE is a defunct constant. The location of the codebase is no longer important as long as it can be found in the currently configured include_path. This will usually include the local site directory (where the codebase normally would be found) as well as the server-wide /usr/lib/php directory where the codebase might be included for the whole server. So now, instead of this:
    1715
    1816    require_once CODE_BASE . '/lib/Utilities.inc.php';
    19    
     17
    2018do this:
    2119
    2220    require_once 'codebase/lib/Utilities.inc.php';
    23    
    24    
     21
     22
    25233. $CFG-> variables are gone. Most of these should be converted into their $app and $auth equivalents. If a $CFG variable is NOT something used by the codebase but is still needed by the website application, I suggest converting these values to a $cfg array. For example, this:
    2624
    2725    $CFG->gallery_images_url = '/gallery_images';
    28    
     26
    2927should become:
    3028
    3129    $cfg['gallery_images_url'] = '/gallery_images';
    32    
     30
    3331And of course change the code where they are used to support the array instead of object-properties. If the array is inside of double-quotes it should be written like:
    3432
    35     "{$cfg['gallery_images_url']}/my/path". 
    36    
    37 If the value used is now to be retrieved from a $object->getParam(...) method call, you'll need to do this: 
     33    "{$cfg['gallery_images_url']}/my/path".
     34
     35If the value used is now to be retrieved from a $object->getParam(...) method call, you'll need to do this:
    3836
    3937    $object->getParam('gallery_images_url') . '/my/path'
     
    4341
    4442    <a href="<?php echo ohref("$CFG->site_url/my/file.php"); ?>">
    45    
     43
    4644to this:
    4745
    4846    <a href="<?php echo $app->ohref("/my/file.php"); ?>">
    49    
     47
    5048(In other words, the URL should be a not-fully-qualified URL starting with a slash.)
    5149
     
    6260        '\1' => '\2'
    6361    ));
    64    
    65    
     62
     63
    66646. Many classes now require object-method calls, and the object must be globally scoped. For example, to call the $cache->exists() method inside a function, be sure to add:
    6765
    6866    global $cache;
    69    
     67
    7068at the top of the function.
    7169
    72    
     70
    7371
    7472=====================================================================
     
    8078---------------------------------------------------------------------
    8179$CFG global variables are converted to object properties specific to their usage.
    82    
     80
    8381For example:
    8482
     
    9896Convert functions to methods.
    9997
    100 raiseMsg(...)                           $app->raiseMsg(...) 
    101 logMsg(...)                             $app->logMsg(...) 
     98raiseMsg(...)                           $app->raiseMsg(...)
     99logMsg(...)                             $app->logMsg(...)
    102100include 'message_header.ihtml';         $app->printRaisedMessages();
    103101$carry_queries = array(... , ...);      $app->carryQuery(...);  //call for each value in array
    104 ohref(...)                              $app->ohref(...) 
    105 printHiddenSession(...);                $app->printHiddenSession(...); 
    106 dieURL(...);                            $app->dieURL(...); 
    107 dieBoomerangURL(...);                   $app->dieBoomerangURL(...); 
    108 setBoomerangURL(...);                   $app->setBoomerangURL(...); 
    109 getBoomerangURL(...);                   $app->getBoomerangURL(...); 
    110 validBoomerangURL(...);                 $app->validBoomerangURL(...); 
    111 deleteBoomerangURL(...);                $app->deleteBoomerangURL(...); 
     102ohref(...)                              $app->ohref(...)
     103printHiddenSession(...);                $app->printHiddenSession(...);
     104dieURL(...);                            $app->dieURL(...);
     105dieBoomerangURL(...);                   $app->dieBoomerangURL(...);
     106setBoomerangURL(...);                   $app->setBoomerangURL(...);
     107getBoomerangURL(...);                   $app->getBoomerangURL(...);
     108validBoomerangURL(...);                 $app->validBoomerangURL(...);
     109deleteBoomerangURL(...);                $app->deleteBoomerangURL(...);
    112110sslOn();                                $app->sslOn();
    113111sslOff();                               $app->sslOff();
     
    121119=====================================================================
    122120DB
    123 ===================================================================== 
     121=====================================================================
    124122
    125123dbQuery(...)                            $db->query(...)
     
    209207
    210208    $lock = new RecordLock($GLOBALS['_admin']);
    211    
     209
    212210to:
    213211
     
    215213    global $auth;
    216214    $lock =& Lock::getInstance($auth);
    217      
     215
    218216And instantiate the original global $lock object in _config.inc.php as follows:
    219217
     
    236234
    237235    $version = new RecordVersion();
    238    
     236
    239237to:
    240238
     
    250248Changed all method calls to now require object calls rather than static calls. In other words, change this:
    251249
    252     if (SessionCache::isCached('mydata')) { 
     250    if (SessionCache::isCached('mydata')) {
    253251        $list = SessionCache::getCache('mydata');
    254252    }
     
    304302
    305303include_once 'form_error_header.ihtml';      $fv->printErrorMessages();
    306 
    307 
    308 ?>
  • trunk/docs/examples/_config.inc.php

    r432 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/>.
    2121 */
    2222
    23 /** 
     23/**
    2424 * _config.inc.php lives in the document root of the site/application. It is the beginning of everything.
    2525 *
     
    2828 * @since   03 Dec 2005 19:09:32
    2929 */
    30  
     30
    3131// The constant __FILE__ must be an absolute directory path, starting with / on unix or C: on windows.
    3232// To work around a PHP bug always include this config file with: require_once dirname(__FILE__) . '/_config.inc.php';
     
    3939define('COMMON_BASE', realpath(dirname(__FILE__) . '/../'));
    4040
    41 // The DocRoot for this application. SITE_BASE is different from $_SERVER['DOCUMENT_ROOT'] because the 
     41// The DocRoot for this application. SITE_BASE is different from $_SERVER['DOCUMENT_ROOT'] because the
    4242// latter does not change when using the apache Alias directive or URL Rewriting to define a site.
    4343define('SITE_BASE', dirname(__FILE__));
     
    148148require_once 'codebase/lib/Cache.inc.php';
    149149$cache = new Cache('global');
    150 $cache->setParam(array('enabled' => true));
     150$cache->setParam(array('enabled' => true)); // TODO: Enable caching after site launch.
    151151
    152152// Setup CSS files to include. These will always be available.
    153153require_once 'codebase/lib/CSS.inc.php';
    154154$css = new CSS();
    155 $css->setParam(array('cache_css' => false)); /// Enable caching after site launch.
     155$css->setParam(array('cache_css' => false)); // TODO: Enable caching after site launch.
    156156$css->setFile('codebase/css/codebase.inc.css');
    157157$css->setFile('codebase/css/utilities.inc.css');
     
    170170// require_once 'global/config.inc.php';
    171171
    172 ?>
  • trunk/docs/examples/contact_form/contact.php

    r413 r468  
    119119}
    120120
    121 ?>
  • trunk/docs/examples/db_auth.inc.php

    r404 r468  
    3535    'db_pass' => '',
    3636));
    37 ?>
  • trunk/docs/examples/example.cli.php

    r396 r468  
    146146
    147147
    148 ?>
  • trunk/docs/examples/script_template.php

    r396 r468  
    6060
    6161
    62 ?>
Note: See TracChangeset for help on using the changeset viewer.