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 | |
---|
24 | |
---|
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 | |
---|
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: |
---|
34 | |
---|
35 | "{$cfg['gallery_images_url']}/my/path". |
---|
36 | |
---|
37 | If the value used is now to be retreived from a $object->getParam(...) method call, youll need to do this: |
---|
38 | |
---|
39 | $object->getParam('gallery_images_url') . '/my/path' |
---|
40 | |
---|
41 | |
---|
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.) |
---|
51 | |
---|
52 | |
---|
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: |
---|
54 | |
---|
55 | Searching for "$CFG->ssl_domain = 'www.example.com';": |
---|
56 | |
---|
57 | // $CFG->(\w+)\s*=\s*['"](\w+)['"]; |
---|
58 | |
---|
59 | Replace: |
---|
60 | |
---|
61 | $app->setParam(array( |
---|
62 | '\1' => '\2' |
---|
63 | )); |
---|
64 | |
---|
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: |
---|
67 | |
---|
68 | global $cache; |
---|
69 | |
---|
70 | at the top of the function. |
---|
71 | |
---|
72 | |
---|
73 | |
---|
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 | |
---|
100 | raiseMsg(...) $app->raiseMsg(...) |
---|
101 | logMsg(...) $app->logMsg(...) |
---|
102 | include 'message_header.ihtml'; $app->printRaisedMessages(); |
---|
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(...); |
---|
112 | sslOn(); $app->sslOn(); |
---|
113 | sslOff(); $app->sslOff(); |
---|
114 | |
---|
115 | The following regex will find any of the above: |
---|
116 | (?<!raiseMsg|logMsg|include|ohref|printHiddenSession|dieURL|dieBoomerangURL|setBoomerangURL|getBoomerangURL|validBoomerangURL|deleteBoomerangURL|sslOn|sslOff) |
---|
117 | |
---|
118 | Also convert all site config variables, as earlier: |
---|
119 | $CFG->site_name $app->getParam('site_name') |
---|
120 | |
---|
121 | ===================================================================== |
---|
122 | DB |
---|
123 | ===================================================================== |
---|
124 | |
---|
125 | dbQuery(...) $db->query(...) |
---|
126 | dbTableExists(...) $db->tableExists(...) |
---|
127 | addslashes(...) $db->escapeString(...) |
---|
128 | |
---|
129 | $dbh |
---|
130 | $GLOBALS['dbh'] $db->getDBH() |
---|
131 | |
---|
132 | ===================================================================== |
---|
133 | Auth_SQL |
---|
134 | ===================================================================== |
---|
135 | |
---|
136 | $auth->clearAuth() $auth->clear() |
---|
137 | $auth->setVal(...) $auth->set(...) |
---|
138 | $auth->getVal(...) $auth->get(...) |
---|
139 | $auth->setFeature(...) $auth->setParam(...) |
---|
140 | $auth->getFeature(...) $auth->getParam(...) |
---|
141 | |
---|
142 | |
---|
143 | ===================================================================== |
---|
144 | ImageThumb |
---|
145 | ===================================================================== |
---|
146 | |
---|
147 | $thumb->setSourceDirectory(...) $thumb->setParam(array('source_dir' => ...)) |
---|
148 | $thumb->createDestDirs(...) $this->_createDestDirs(...) NOW PRIVATE! |
---|
149 | $thumb->validFileExtension(...) $this->_validFileExtension(...) NOW PRIVATE! |
---|
150 | |
---|
151 | ===================================================================== |
---|
152 | MySQLSessionHandler |
---|
153 | ===================================================================== |
---|
154 | |
---|
155 | Renamed to DBSessionHandler.inc.php |
---|
156 | Interface totally changed. See example in App.inc.php. |
---|
157 | |
---|
158 | ===================================================================== |
---|
159 | Navigation |
---|
160 | ===================================================================== |
---|
161 | |
---|
162 | Renamed to Navigation.inc.php |
---|
163 | |
---|
164 | $nav->addPage(...) $nav->add(...) |
---|
165 | $nav->setFeature(array(...)) $nav->setParam(...) |
---|
166 | $nav->getFeature(...) $nav->getParam(...) |
---|
167 | $nav->getTitle() $nav->get('title') |
---|
168 | $nav->printTitle() echo $nav->get('title') |
---|
169 | $nav->getPath() $nav->get('path') |
---|
170 | $nav->printPath() echo $nav->get('path') |
---|
171 | $nav->printBreadcrumbs() echo $nav->getBreadcrumbs() |
---|
172 | |
---|
173 | $nav->path_delimiter $nav->getParam('path_delimiter') |
---|
174 | NOTE: this applies to any object property that has been converted to a param. |
---|
175 | |
---|
176 | |
---|
177 | ===================================================================== |
---|
178 | PEdit |
---|
179 | ===================================================================== |
---|
180 | |
---|
181 | Massive changes. See Quinn. |
---|
182 | |
---|
183 | ===================================================================== |
---|
184 | Prefs |
---|
185 | ===================================================================== |
---|
186 | |
---|
187 | $prefs = new Prefs($dbh, $params) $prefs = new Prefs('namespace') |
---|
188 | NOTE: new instantiation interface |
---|
189 | |
---|
190 | $prefs->setDefault(..., scope) $prefs->setDefaults(array(...)) |
---|
191 | NOTE: plurality - function need not be called once-per-default. |
---|
192 | |
---|
193 | $prefs->setValue(..., $scope) $prefs->set(...) |
---|
194 | $prefs->getValue(..., $scope) $prefs->get(...) |
---|
195 | $prefs->clearValue(..., $scope) $prefs->delete(...) |
---|
196 | NOTE: $scope no longer used in the above methods. |
---|
197 | |
---|
198 | $prefs->retrieve() $prefs->load() |
---|
199 | |
---|
200 | ===================================================================== |
---|
201 | Lock |
---|
202 | ===================================================================== |
---|
203 | |
---|
204 | Renamed from RecordLock.inc.php to Lock.inc.php |
---|
205 | |
---|
206 | Only one major interface change: instead of calling $lock->dieErrorPage() you will wrap the header/footer includes around the method call $lock->printErrorHTML(). |
---|
207 | |
---|
208 | Also, change instantiation call from: |
---|
209 | |
---|
210 | $lock = new RecordLock($GLOBALS['_admin']); |
---|
211 | |
---|
212 | to: |
---|
213 | |
---|
214 | global $lock; |
---|
215 | global $auth; |
---|
216 | $lock =& Lock::getInstance($auth); |
---|
217 | |
---|
218 | And instantiate the original global $lock object in _config.inc.php as follows: |
---|
219 | |
---|
220 | // Global record-locking object. |
---|
221 | $lock =& Lock::getInstance($auth); |
---|
222 | $lock->setParam(array( |
---|
223 | 'timeout' => 0, |
---|
224 | 'auto_timeout' => 1800, |
---|
225 | 'error_url' => '/lock.php', |
---|
226 | )); |
---|
227 | |
---|
228 | |
---|
229 | ===================================================================== |
---|
230 | Version |
---|
231 | ===================================================================== |
---|
232 | |
---|
233 | Renamed from RecordVersion.inc.php to Version.inc.php |
---|
234 | |
---|
235 | Change usage from: |
---|
236 | |
---|
237 | $version = new RecordVersion(); |
---|
238 | |
---|
239 | to: |
---|
240 | |
---|
241 | $version =& Version::getInstance($auth); |
---|
242 | |
---|
243 | |
---|
244 | ===================================================================== |
---|
245 | Cache |
---|
246 | ===================================================================== |
---|
247 | |
---|
248 | Renamed from SessionCache.inc.php to Cache.inc.php |
---|
249 | |
---|
250 | Changed all method calls to now require object calls rather than static calls. In other words, change this: |
---|
251 | |
---|
252 | if (SessionCache::isCached('mydata')) { |
---|
253 | $list = SessionCache::getCache('mydata'); |
---|
254 | } |
---|
255 | |
---|
256 | to: |
---|
257 | |
---|
258 | if ($cache->exists('mydata')) { |
---|
259 | $list = $cache->get('mydata'); |
---|
260 | } |
---|
261 | |
---|
262 | And have $cache instantiated in _config.inc.php like this: |
---|
263 | |
---|
264 | // Global cache object. |
---|
265 | $cache = new Cache('global'); |
---|
266 | $cache->setParam(array('enabled' => true)); |
---|
267 | |
---|
268 | |
---|
269 | SessionCache::putCache($val, $key) $cache->set($key, $val) |
---|
270 | NOTE: notice method arguments have been reversed. |
---|
271 | |
---|
272 | SessionCache::getCache(...) $cache->get(...) |
---|
273 | SessionCache::isCached(...) $cache->exists(...) |
---|
274 | SessionCache::breakCache(...) $cache->delete(...) |
---|
275 | |
---|
276 | |
---|
277 | ===================================================================== |
---|
278 | Upload |
---|
279 | ===================================================================== |
---|
280 | |
---|
281 | Change all object properties from direct access to method-access: |
---|
282 | |
---|
283 | $file->allow_overwriting = true; $file->setParam('allow_overwriting', true); |
---|
284 | $file->valid_file_extensions = true; $file->setParam('valid_file_extensions', true); |
---|
285 | $file->dest_file_perms = 0666; $file->setParam('dest_file_perms', 0666); |
---|
286 | ...etc. |
---|
287 | |
---|
288 | $file->setUploadPath(...) $file->setParam(array('upload_path' => ...)) |
---|
289 | |
---|
290 | |
---|
291 | ===================================================================== |
---|
292 | Utilities |
---|
293 | ===================================================================== |
---|
294 | |
---|
295 | humanFileSize($size, $unit, $format) humanFileSize($size, $format, $max_unit) |
---|
296 | NOTE: changed interface |
---|
297 | |
---|
298 | dbArrayToList(...) escapedList(...) |
---|
299 | NOTE: The functionality of this has changed, better check output is valid. |
---|
300 | |
---|
301 | ===================================================================== |
---|
302 | FormValidator |
---|
303 | ===================================================================== |
---|
304 | |
---|
305 | include_once 'form_error_header.ihtml'; $fv->printErrorMessages(); |
---|
306 | |
---|
307 | |
---|
308 | ?> |
---|