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