[236] | 1 | <?php |
---|
| 2 | |
---|
| 3 | ===================================================================== |
---|
| 4 | In General |
---|
| 5 | ===================================================================== |
---|
| 6 | |
---|
| 7 | 1. Include methods have changed. Instead of accessing file paths absolutely, all files are searched in the include_path. So, instead of: |
---|
| 8 | |
---|
| 9 | include SITE_BASE . '/_templates/header.ihtml'; |
---|
| 10 | |
---|
| 11 | do this: |
---|
| 12 | |
---|
| 13 | include 'header.ihtml'; |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | 2. 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: |
---|
| 17 | |
---|
| 18 | require_once CODE_BASE . '/lib/Utilities.inc.php'; |
---|
| 19 | |
---|
| 20 | do this: |
---|
| 21 | |
---|
| 22 | require_once 'codebase/lib/Utilities.inc.php'; |
---|
| 23 | |
---|
[237] | 24 | |
---|
[236] | 25 | 3. $CFG-> variables are gone. Most of these should be converted into their $app and $auth equivelents. 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: |
---|
| 26 | |
---|
| 27 | $CFG->gallery_images_url = '/gallery_images'; |
---|
| 28 | |
---|
| 29 | should become: |
---|
| 30 | |
---|
| 31 | $cfg['gallery_images_url'] = '/gallery_images'; |
---|
| 32 | |
---|
[239] | 33 | And 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: |
---|
[236] | 34 | |
---|
[239] | 35 | "{$cfg['gallery_images_url']}/my/path". |
---|
| 36 | |
---|
| 37 | If the value used is now to be retreived from a $object->getParam(...) method call, you'll need to do this: |
---|
[237] | 38 | |
---|
[239] | 39 | $object->getParam('gallery_images_url') . '/my/path' |
---|
| 40 | |
---|
| 41 | |
---|
[236] | 42 | 4. $CFG->site_url is not needed when referencing URLs. Change this: |
---|
| 43 | |
---|
| 44 | <a href="<?php echo ohref("$CFG->site_url/my/file.php"); ?>"> |
---|
| 45 | |
---|
| 46 | to this: |
---|
| 47 | |
---|
| 48 | <a href="<?php echo $app->ohref("/my/file.php"); ?>"> |
---|
| 49 | |
---|
| 50 | (In otherwords, the URL should be a not-fully-qualified URL starting with a slash.) |
---|
[237] | 51 | |
---|
| 52 | |
---|
[239] | 53 | // 5. Expect formatting incosistencies! When doing global search-replace expect whitespace to be erratic, variable names to change, and lines to be otherwise inconsistent. Here's a good example of a safe way to match a line: |
---|
[237] | 54 | |
---|
| 55 | Searching for "$CFG->ssl_domain = 'www.example.com';": |
---|
| 56 | |
---|
[239] | 57 | // $CFG->(\w+)\s*=\s*['"](\w+)['"]; |
---|
[237] | 58 | |
---|
| 59 | Replace: |
---|
| 60 | |
---|
| 61 | $app->setParam(array( |
---|
| 62 | '\1' => '\2' |
---|
| 63 | )); |
---|
[236] | 64 | |
---|
[237] | 65 | |
---|
| 66 | 6. 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: |
---|
[236] | 67 | |
---|
[237] | 68 | global $cache; |
---|
[236] | 69 | |
---|
[237] | 70 | at the top of the function. |
---|
[236] | 71 | |
---|
[237] | 72 | |
---|
| 73 | |
---|
[236] | 74 | ===================================================================== |
---|
| 75 | App |
---|
| 76 | ===================================================================== |
---|
| 77 | |
---|
| 78 | The _config.inc.php file is 99% different. Start over from scratch using codebase/docs/example_config.inc.php. |
---|
| 79 | |
---|
| 80 | --------------------------------------------------------------------- |
---|
| 81 | $CFG global variables are converted to object properties specific to their usage. |
---|
| 82 | |
---|
| 83 | For example: |
---|
| 84 | |
---|
| 85 | $CFG->ssl_domain = 'www.example.com'; |
---|
| 86 | $CFG->login_timeout = 21600; |
---|
| 87 | |
---|
| 88 | are converted to: |
---|
| 89 | |
---|
| 90 | $app->setParam(array( |
---|
| 91 | 'ssl_domain' => 'www.example.com' |
---|
| 92 | )); |
---|
| 93 | $auth->setParam(array( |
---|
| 94 | 'login_timeout' => 21600, |
---|
| 95 | )); |
---|
| 96 | |
---|
| 97 | --------------------------------------------------------------------- |
---|
| 98 | Convert functions to methods. |
---|
| 99 | |
---|
[239] | 100 | raiseMsg(...) $app->raiseMsg(...) |
---|
| 101 | logMsg(...) $app->logMsg(...) |
---|
[236] | 102 | include 'message_header.ihtml'; $app->printRaisedMessages(); |
---|
[239] | 103 | $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(...); |
---|
[236] | 112 | sslOn(); $app->sslOn(); |
---|
| 113 | sslOff(); $app->sslOff(); |
---|
| 114 | |
---|
[239] | 115 | $CFG->site_name $app->getParam('site_name') |
---|
[236] | 116 | |
---|
| 117 | ===================================================================== |
---|
| 118 | DB |
---|
| 119 | ===================================================================== |
---|
| 120 | |
---|
| 121 | dbQuery(...) $db->query(...) |
---|
| 122 | dbTableExists(...) $db->tableExists(...) |
---|
| 123 | addslashes(...) $db->escapeString(...) |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | ===================================================================== |
---|
| 127 | Auth_SQL |
---|
| 128 | ===================================================================== |
---|
| 129 | |
---|
| 130 | $auth->clearAuth() $auth->clear() |
---|
| 131 | $auth->setVal(...) $auth->set(...) |
---|
| 132 | $auth->getVal(...) $auth->get(...) |
---|
| 133 | $auth->setFeature(...) $auth->setParam(...) |
---|
| 134 | $auth->getFeature(...) $auth->getParam(...) |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | ===================================================================== |
---|
| 138 | ImageThumb |
---|
| 139 | ===================================================================== |
---|
| 140 | |
---|
| 141 | $thumb->setSourceDirectory(...) $thumb->setParam(array('source_dir' => ...)) |
---|
| 142 | $thumb->createDestDirs(...) $this->_createDestDirs(...) NOW PRIVATE! |
---|
| 143 | $thumb->validFileExtension(...) $this->_validFileExtension(...) NOW PRIVATE! |
---|
| 144 | |
---|
| 145 | ===================================================================== |
---|
| 146 | MySQLSessionHandler |
---|
| 147 | ===================================================================== |
---|
| 148 | |
---|
| 149 | Renamed to DBSessionHandler.inc.php |
---|
| 150 | Interface totally changed. See example in App.inc.php. |
---|
| 151 | |
---|
| 152 | ===================================================================== |
---|
| 153 | Navigation |
---|
| 154 | ===================================================================== |
---|
| 155 | |
---|
| 156 | Renamed to Navigation.inc.php |
---|
| 157 | |
---|
| 158 | $nav->addPage(...) $nav->add(...) |
---|
[239] | 159 | $nav->setFeature(array(...)) $nav->set(...) |
---|
[236] | 160 | $nav->getFeature(...) $nav->get(...) |
---|
| 161 | $nav->getTitle() $nav->get('title') |
---|
| 162 | $nav->printTitle() echo $nav->get('title') |
---|
| 163 | $nav->getPath() $nav->get('path') |
---|
| 164 | $nav->printPath() echo $nav->get('path') |
---|
| 165 | $nav->printBreadcrumbs() echo $nav->getBreadcrumbs() |
---|
| 166 | |
---|
[239] | 167 | $nav->path_delimiter $nav->getParam('path_delimiter') |
---|
| 168 | NOTE: this applies to any object property that has been converted to a param. |
---|
| 169 | |
---|
| 170 | |
---|
[236] | 171 | ===================================================================== |
---|
| 172 | PEdit |
---|
| 173 | ===================================================================== |
---|
| 174 | |
---|
| 175 | Massive changes. See quinn. |
---|
| 176 | |
---|
| 177 | ===================================================================== |
---|
| 178 | Prefs |
---|
| 179 | ===================================================================== |
---|
| 180 | |
---|
| 181 | $prefs = new Prefs($dbh, $params) $prefs = new Prefs('namespace') |
---|
| 182 | NOTE: new instantiation interface |
---|
| 183 | |
---|
[239] | 184 | $prefs->setDefault(..., scope) $prefs->setDefaults(array(...)) |
---|
[236] | 185 | NOTE: plurality - function need not be called once-per-default. |
---|
| 186 | |
---|
| 187 | $prefs->setValue(..., $scope) $prefs->set(...) |
---|
| 188 | $prefs->getValue(..., $scope) $prefs->get(...) |
---|
| 189 | $prefs->clearValue(..., $scope) $prefs->delete(...) |
---|
| 190 | NOTE: $scope no longer used in the above methods. |
---|
| 191 | |
---|
| 192 | $prefs->retrieve() $prefs->load() |
---|
| 193 | |
---|
| 194 | ===================================================================== |
---|
| 195 | Lock |
---|
| 196 | ===================================================================== |
---|
| 197 | |
---|
| 198 | Renamed from RecordLock.inc.php to Lock.inc.php |
---|
| 199 | |
---|
| 200 | Only one major interface change: instead of calling $lock->dieErrorPage() you will wrap the header/footer includes around the method call $lock->printErrorHTML(). |
---|
| 201 | |
---|
| 202 | Also, change instantiation call from: |
---|
| 203 | |
---|
| 204 | $lock = new RecordLock($GLOBALS['_admin']); |
---|
| 205 | |
---|
| 206 | to: |
---|
| 207 | |
---|
| 208 | global $lock; |
---|
[239] | 209 | global $auth; |
---|
[236] | 210 | $lock =& Lock::getInstance($auth); |
---|
| 211 | |
---|
| 212 | And instantiate the original global $lock object in _config.inc.php as follows: |
---|
| 213 | |
---|
| 214 | // Global record-locking object. |
---|
| 215 | $lock =& Lock::getInstance($auth); |
---|
| 216 | $lock->setParam(array( |
---|
| 217 | 'timeout' => 0, |
---|
| 218 | 'auto_timeout' => 1800, |
---|
| 219 | 'error_url' => '/lock.php', |
---|
| 220 | )); |
---|
| 221 | |
---|
| 222 | |
---|
| 223 | ===================================================================== |
---|
| 224 | Version |
---|
| 225 | ===================================================================== |
---|
| 226 | |
---|
| 227 | Renamed from RecordVersion.inc.php to Version.inc.php |
---|
| 228 | |
---|
| 229 | Change usage from: |
---|
| 230 | |
---|
| 231 | $version = new RecordVersion(); |
---|
| 232 | |
---|
| 233 | to: |
---|
| 234 | |
---|
[239] | 235 | $version =& Version::getInstance($auth); |
---|
[236] | 236 | |
---|
| 237 | |
---|
| 238 | ===================================================================== |
---|
| 239 | Cache |
---|
| 240 | ===================================================================== |
---|
| 241 | |
---|
| 242 | Renamed from SessionCache.inc.php to Cache.inc.php |
---|
| 243 | |
---|
| 244 | Changed all method calls to now require object calls rather than static calls. In other words, change this: |
---|
| 245 | |
---|
| 246 | if (SessionCache::isCached('mydata')) { |
---|
| 247 | $list = SessionCache::getCache('mydata'); |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | to: |
---|
| 251 | |
---|
| 252 | if ($cache->exists('mydata')) { |
---|
| 253 | $node_list = $cache->get('mydata'); |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | And have $cache instantiated in _config.inc.php like this: |
---|
| 257 | |
---|
| 258 | // Global cache object. |
---|
| 259 | $cache = new Cache('global'); |
---|
| 260 | $cache->setParam(array('enabled' => true)); |
---|
| 261 | |
---|
| 262 | |
---|
| 263 | SessionCache::putCache($val, $key) $cache->set($key, $val) |
---|
| 264 | NOTE: notice method arguments have been reversed. |
---|
| 265 | |
---|
[239] | 266 | SessionCache::getCache(...) $cache->get(...) |
---|
[236] | 267 | SessionCache::isCached(...) $cache->exists(...) |
---|
| 268 | SessionCache::breakCache(...) $cache->delete(...) |
---|
| 269 | |
---|
| 270 | |
---|
| 271 | ===================================================================== |
---|
| 272 | Upload |
---|
| 273 | ===================================================================== |
---|
| 274 | |
---|
| 275 | Change all object properties from direct access to method-access: |
---|
| 276 | |
---|
| 277 | $file->allow_overwriting = true; $file->setParam('allow_overwriting', true); |
---|
| 278 | $file->valid_file_extensions = true; $file->setParam('valid_file_extensions', true); |
---|
[239] | 279 | $file->dest_file_perms = 0666; $file->setParam('dest_file_perms', 0666); |
---|
[236] | 280 | ...etc. |
---|
| 281 | |
---|
| 282 | $file->setUploadPath(...) $file->setParam(array('upload_path' => ...)) |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | ===================================================================== |
---|
| 286 | Utilities |
---|
| 287 | ===================================================================== |
---|
| 288 | |
---|
| 289 | humanFileSize($size, $unit, $format) humanFileSize($size, $format, $max_unit) |
---|
| 290 | NOTE: changed interface |
---|
| 291 | |
---|
| 292 | dbArrayToList(...) escapedList(...) |
---|
| 293 | NOTE: The functionality of this has changed, better check output is valid. |
---|
| 294 | |
---|
[239] | 295 | ===================================================================== |
---|
| 296 | FormValidator |
---|
| 297 | ===================================================================== |
---|
[236] | 298 | |
---|
[239] | 299 | include 'form_error_header.ihtml'; $fv->printErrorMessages(); |
---|
[236] | 300 | |
---|
[239] | 301 | |
---|
[236] | 302 | ?> |
---|