Merge lp:~quam-plures-core/quam-plures/qp5_colls-blogs_chaps-cats into lp:quam-plures
- qp5_colls-blogs_chaps-cats
- Merge into trunk
Proposed by
EdB
Status: | Merged |
---|---|
Merged at revision: | 7660 |
Proposed branch: | lp:~quam-plures-core/quam-plures/qp5_colls-blogs_chaps-cats |
Merge into: | lp:quam-plures |
Diff against target: |
63688 lines (+20565/-20951) 166 files modified
index.php (+58/-57) multiblogs.php (+3/-3) qp_inc/_application.php (+2/-2) qp_inc/_blog_main.inc.php (+276/-310) qp_inc/_core/__core.init.php (+101/-87) qp_inc/_core/_class.funcs.php (+151/-0) qp_inc/_core/_class4.funcs.php (+0/-40) qp_inc/_core/_class5.funcs.php (+0/-175) qp_inc/_core/_misc.funcs.php (+389/-311) qp_inc/_core/_param.funcs.php (+178/-104) qp_inc/_core/_url.funcs.php (+114/-90) qp_inc/_core/model/__core.install.php (+59/-58) qp_inc/_core/ui/_uiwidget.class.php (+35/-16) qp_inc/_main.inc.php (+166/-332) qp_inc/antispam/distribute.ctrl.php (+0/-2) qp_inc/antispam/list.ctrl.php (+1/-2) qp_inc/antispam/settings.ctrl.php (+1/-4) qp_inc/antispam/views/_list.view.php (+3/-3) qp_inc/blogs/blog_settings.ctrl.php (+240/-0) qp_inc/blogs/blogs.ctrl.php (+261/-0) qp_inc/blogs/model/_blog.class.php (+2139/-0) qp_inc/blogs/model/_blog.funcs.php (+423/-0) qp_inc/blogs/model/_blog_cache.class.php (+315/-0) qp_inc/blogs/model/_blog_settings.class.php (+156/-0) qp_inc/blogs/views/_blog_features.form.php (+228/-0) qp_inc/blogs/views/_blog_general.form.php (+136/-0) qp_inc/blogs/views/_blog_group_perm.form.php (+471/-0) qp_inc/blogs/views/_blog_list.view.php (+158/-0) qp_inc/blogs/views/_blog_plugin_settings.form.php (+80/-0) qp_inc/blogs/views/_blog_sel_type.view.php (+31/-0) qp_inc/blogs/views/_blog_urls.form.php (+354/-0) qp_inc/blogs/views/_blog_user_perm.form.php (+489/-0) qp_inc/categories/categories.ctrl.php (+341/-0) qp_inc/categories/model/_category.class.php (+303/-0) qp_inc/categories/model/_category.funcs.php (+367/-0) qp_inc/categories/model/_categorycache.class.php (+281/-0) qp_inc/categories/views/_category.form.php (+69/-0) qp_inc/categories/views/_category_list.view.php (+194/-0) qp_inc/categories/views/_category_move.form.php (+41/-0) qp_inc/chapters/chapters.ctrl.php (+0/-426) qp_inc/chapters/index.html (+0/-1) qp_inc/chapters/model/_chapter.class.php (+0/-310) qp_inc/chapters/model/_chaptercache.class.php (+0/-316) qp_inc/chapters/model/index.html (+0/-1) qp_inc/chapters/views/_chapter.form.php (+0/-91) qp_inc/chapters/views/_chapter_list.view.php (+0/-241) qp_inc/chapters/views/_chapter_move.form.php (+0/-67) qp_inc/chapters/views/index.html (+0/-1) qp_inc/collections/coll_settings.ctrl.php (+0/-285) qp_inc/collections/collections.ctrl.php (+0/-349) qp_inc/collections/index.html (+0/-1) qp_inc/collections/model/_blog.class.php (+0/-1932) qp_inc/collections/model/_blog.funcs.php (+0/-445) qp_inc/collections/model/_blogcache.class.php (+0/-357) qp_inc/collections/model/_category.funcs.php (+0/-374) qp_inc/collections/model/_collsettings.class.php (+0/-176) qp_inc/collections/model/index.html (+0/-1) qp_inc/collections/views/_coll_features.form.php (+0/-217) qp_inc/collections/views/_coll_general.form.php (+0/-146) qp_inc/collections/views/_coll_group_perm.form.php (+0/-511) qp_inc/collections/views/_coll_list.view.php (+0/-172) qp_inc/collections/views/_coll_plugin_settings.form.php (+0/-102) qp_inc/collections/views/_coll_sel_type.view.php (+0/-44) qp_inc/collections/views/_coll_urls.form.php (+0/-375) qp_inc/collections/views/_coll_user_perm.form.php (+0/-519) qp_inc/collections/views/index.html (+0/-1) qp_inc/comments/_comments.ctrl.php (+139/-217) qp_inc/comments/model/_comment.class.php (+592/-430) qp_inc/comments/model/_commentlist.class.php (+37/-59) qp_inc/cron/jobs/_post_notifications.job.php (+11/-7) qp_inc/dashboard/dashboard.ctrl.php (+19/-20) qp_inc/files/files.ctrl.php (+27/-29) qp_inc/files/model/_file.class.php (+569/-537) qp_inc/files/upload.ctrl.php (+196/-202) qp_inc/files/views/_file_browse_set.form.php (+50/-70) qp_inc/items/item_statuses.ctrl.php (+23/-41) qp_inc/items/item_types.ctrl.php (+24/-38) qp_inc/items/items.ctrl.php (+725/-834) qp_inc/items/model/_item.class.php (+1064/-889) qp_inc/items/model/_item.funcs.php (+198/-164) qp_inc/items/model/_itemcache.class.php (+40/-69) qp_inc/items/model/_itemlight.class.php (+413/-351) qp_inc/items/model/_itemlist.class.php (+267/-264) qp_inc/items/model/_itemlistlight.class.php (+514/-583) qp_inc/items/model/_itemquery.class.php (+253/-179) qp_inc/items/model/_itemtype.class.php (+25/-43) qp_inc/items/model/_itemtypecache.class.php (+38/-63) qp_inc/items/views/_item_list_table.view.php (+109/-117) qp_inc/locales/_charset.funcs.php (+2/-1) qp_inc/locales/locales.ctrl.php (+11/-16) qp_inc/plugins/_plugin.class.php (+389/-224) qp_inc/plugins/_plugin.funcs.php (+125/-120) qp_inc/plugins/model/_plugins.class.php (+100/-54) qp_inc/plugins/model/_plugins_admin.class.php (+494/-534) qp_inc/sessions/model/_hit.class.php (+230/-195) qp_inc/sessions/model/_hitlist.class.php (+58/-97) qp_inc/sessions/model/_hitlog.funcs.php (+41/-16) qp_inc/sessions/model/_session.class.php (+63/-52) qp_inc/sessions/stats.ctrl.php (+132/-161) qp_inc/settings/model/_generalsettings.class.php (+57/-72) qp_inc/settings/settings.ctrl.php (+99/-170) qp_inc/settings/views/_general.form.php (+147/-214) qp_inc/templates/_template.funcs.php (+63/-47) qp_inc/templates/model/_template.class.php (+29/-15) qp_inc/templates/model/_templatecache.class.php (+5/-1) qp_inc/templates/templates.ctrl.php (+3/-10) qp_inc/templates/views/_template_select_create.view.php (+1/-1) qp_inc/tools/tools.ctrl.php (+48/-64) qp_inc/users/model/_user.class.php (+63/-17) qp_inc/users/users.ctrl.php (+13/-12) qp_inc/users/views/_user.form.php (+27/-32) qp_inc/widgets/_bloglist.widget.php (+1/-1) qp_inc/widgets/_category_list.widget.php (+2/-2) qp_inc/widgets/_comment_list.widget.php (+1/-1) qp_inc/widgets/_common_links.widget.php (+4/-4) qp_inc/widgets/_free_html.widget.php (+1/-1) qp_inc/widgets/_item_list.widget.php (+3/-3) qp_inc/widgets/_link_list.widget.php (+1/-1) qp_inc/widgets/_linkblog.widget.php (+1/-1) qp_inc/widgets/_logo.widget.php (+1/-1) qp_inc/widgets/_longdesc.widget.php (+1/-1) qp_inc/widgets/_media_index.widget.php (+5/-5) qp_inc/widgets/_menu_link.widget.php (+1/-1) qp_inc/widgets/_page_list.widget.php (+1/-1) qp_inc/widgets/_post_list.widget.php (+1/-1) qp_inc/widgets/_related_post_list.widget.php (+1/-1) qp_inc/widgets/_search_form.widget.php (+1/-1) qp_inc/widgets/_single_item.widget.php (+1/-1) qp_inc/widgets/_tag_cloud.widget.php (+4/-4) qp_inc/widgets/_tagline.widget.php (+2/-2) qp_inc/widgets/_title.widget.php (+1/-1) qp_inc/widgets/_user_tools.widget.php (+1/-1) qp_inc/widgets/_xml_feeds.widget.php (+1/-1) qp_inc/widgets/model/_widget.class.php (+103/-93) qp_inc/widgets/model/_widgetcache.class.php (+25/-20) qp_inc/widgets/views/_widget.form.php (+3/-4) qp_inc/widgets/views/_widget_list.view.php (+3/-4) qp_inc/widgets/views/_widget_list_available.view.php (+5/-7) qp_inc/widgets/widgets.ctrl.php (+25/-29) qp_inc/xhtml_validator/_xhtml_validator.class.php (+65/-57) qp_inc/xmlrpc/apis/_b2.api.php (+66/-70) qp_inc/xmlrpc/apis/_metaweblog.api.php (+224/-302) qp_inc/xmlrpc/model/_xmlrpcs.funcs.php (+149/-160) qp_install/_functions_create.php (+14/-21) qp_install/_functions_dbupgrade.php (+177/-8) qp_install/_functions_install.php (+46/-47) qp_install/index.php (+9/-36) qp_plugins/archives_plugin/_archives.plugin.php (+281/-328) qp_plugins/calendar_plugin/_calendar.plugin.php (+516/-545) qp_plugins/captcha_img_plugin/_captcha_img.plugin.php (+329/-347) qp_plugins/comment_gravatars_plugin/_comment_gravatars.plugin.php (+91/-90) qp_plugins/commenttags_plugin/_commenttags.plugin.php (+1/-1) qp_plugins/smilies_plugin/_smilies.plugin.php (+0/-1) qp_plugins/tinymce_plugin/_tinymce.plugin.php (+6/-6) qp_plugins/twitter_plugin/_twitter.plugin.php (+11/-9) qp_srvc/subs_update.php (+41/-58) qp_templates/_atom/index.main.php (+4/-4) qp_templates/_msgform.disp.php (+2/-2) qp_templates/_subs.disp.php (+2/-2) qp_view_admin/_adminUI_general.class.php (+621/-608) qp_view_admin/admin.global.css (+197/-268) qp_view_admin/earth/style.css (+336/-343) qp_view_admin/fire/style.css (+359/-367) qp_view_admin/login/_login_form.main.php (+2/-2) qp_view_admin/water/style.css (+332/-339) qp_view_admin/wind/style.css (+337/-349) |
To merge this branch: | bzr merge lp:~quam-plures-core/quam-plures/qp5_colls-blogs_chaps-cats |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Quam Plures Core Team | Pending | ||
Review via email: mp+153436@code.launchpad.net |
Commit message
Description of the change
http://
Tested as much as I can think of and haven't found any more problems, so yay progress :)
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'index.php' |
2 | --- index.php 2010-12-31 12:12:03 +0000 |
3 | +++ index.php 2013-03-14 18:35:26 +0000 |
4 | @@ -1,79 +1,76 @@ |
5 | <?php |
6 | /** |
7 | - * This is the main public interface file. |
8 | - * |
9 | - * IF YOU ARE READING THIS IN YOUR WEB BROWSER, IT MEANS THAT PHP IS NOT PROPERLY INSTALLED |
10 | - * ON YOUR WEB SERVER. IF YOU DON'T KNOW WHAT THIS MEANS, CONTACT YOUR SERVER ADMINISTRATOR |
11 | - * OR YOUR HOSTING COMPANY. |
12 | - * |
13 | - * This file is NOT mandatory. You can delete it if you want. |
14 | - * You can also replace the contents of this file with contents similar to the contents |
15 | - * of a_stub.php, a_notemplate.php, multiblogs.php, etc. |
16 | - * |
17 | - * Quam Plures - {@link http://quamplures.net/} |
18 | - * Released under GNU GPL License - {@link http://quamplures.net/license.html} |
19 | - * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/} |
20 | - * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/} |
21 | - * |
22 | - * {@internal Note: we need at least one file in the main package}} |
23 | - * |
24 | - * @package pond |
25 | + * This is the main public interface file |
26 | + * |
27 | + * IF YOU ARE READING THIS IN YOUR WEB BROWSER, IT MEANS THAT PHP IS |
28 | + * NOT PROPERLY INSTALLED ON YOUR WEB SERVER. IF YOU DON'T KNOW WHAT |
29 | + * THIS MEANS, CONTACT YOUR SERVER ADMINISTRATOR OR HOSTING COMPANY. |
30 | + * |
31 | + * This file is NOT mandatory. You can delete it if you want. You can also |
32 | + * replace the contents of this file with a stub file or something like |
33 | + * multiblogs.php or summary.php. |
34 | + * @author {@link http://wonderwinds.com/ Ed Bennett} |
35 | + * @author {@link http://fplanque.net/ Francois PLANQUE} |
36 | + * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project} |
37 | + * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 |
38 | + * @package core |
39 | */ |
40 | |
41 | /** |
42 | - * First thing: Do the minimal initializations required for QP: |
43 | + * Load the configuration minimum |
44 | */ |
45 | require_once dirname(__FILE__).'/qp_config/_config.php'; |
46 | |
47 | /** |
48 | - * Check this: we are requiring _main.inc.php INSTEAD of _blog_main.inc.php |
49 | - * because we are not trying to initialize any particular blog |
50 | + * Main initialization, without a specific blog identified |
51 | */ |
52 | require_once $inc_path.'_main.inc.php'; |
53 | |
54 | -// Check if a specific blog has been requested in the URL: |
55 | +// Check if a specific blog has been requested in the URL |
56 | param( 'blog', 'integer', '', true ); |
57 | |
58 | if( empty($blog) ) |
59 | -{ // No blog requested by URL param, let's try to match something in the URL |
60 | - $Debuglog->add( 'No blog param received, checking extra path...', 'detectblog' ); |
61 | - |
62 | +{ |
63 | + // No blog requested by URL param, let's try to match something in the URL |
64 | $BlogCache = & get_Cache( 'BlogCache' ); |
65 | |
66 | if( preg_match( '#^(.+?)index.php/([^/]+)#', $ReqHost.$ReqPath, $matches ) ) |
67 | - { // We have an URL blog name: |
68 | - $Debuglog->add( 'Found a potential URL blog name: '.$matches[2], 'detectblog' ); |
69 | - if( (($Blog = & $BlogCache->get_by_urlname( $matches[2], false )) !== false) ) |
70 | - { // We found a matching blog: |
71 | + { |
72 | + // We have an URL blog name |
73 | + if( ( ( $Blog = & $BlogCache->get_by_urlname( $matches[2], false ) ) !== false ) ) |
74 | + { |
75 | + // We found a matching blog |
76 | $blog = $Blog->ID; |
77 | } |
78 | } |
79 | |
80 | if( empty($blog) ) |
81 | - { // No blog identified by URL name, let's try to match the absolute URL |
82 | + { |
83 | + // No blog identified by URL name, let's try to match the absolute URL |
84 | if( preg_match( '#^(.+?)index.php#', $ReqHost.$ReqPath, $matches ) ) |
85 | - { // Remove what's not part of the absolute URL |
86 | + { |
87 | + // Remove what's not part of the absolute URL |
88 | $ReqAbsUrl = $matches[1]; |
89 | } |
90 | else |
91 | { |
92 | $ReqAbsUrl = $ReqHost.$ReqPath; |
93 | } |
94 | - $Debuglog->add( 'Looking up absolute url : '.$ReqAbsUrl, 'detectblog' ); |
95 | - |
96 | - if( (($Blog = & $BlogCache->get_by_url( $ReqAbsUrl, false )) !== false) ) |
97 | - { // We found a matching blog: |
98 | + if( ( ( $Blog = & $BlogCache->get_by_url( $ReqAbsUrl, false ) ) !== false ) ) |
99 | + { |
100 | + // We found a matching blog |
101 | $blog = $Blog->ID; |
102 | - $Debuglog->add( 'Found matching blog: '.$blog, 'detectblog' ); |
103 | } |
104 | } |
105 | |
106 | if( empty($blog) ) |
107 | - { // Still no blog requested, use default |
108 | - $blog = $Settings->get('default_blog_ID'); |
109 | - if( (($Blog = & $BlogCache->get_by_ID( $blog, false, false )) !== false) ) |
110 | - { // We found a matching blog: |
111 | - $Debuglog->add( 'Using default blog '.$blog, 'detectblog' ); |
112 | + { |
113 | + // Still no blog requested, use default |
114 | + $blog = $Settings->get( 'default_blog_ID' ); |
115 | + if( ( ($Blog = & $BlogCache->get_by_ID( $blog, false, false ) ) !== false ) ) |
116 | + { |
117 | + // We found a matching blog |
118 | + // debuglog-add removed |
119 | } |
120 | else |
121 | { |
122 | @@ -81,8 +78,9 @@ |
123 | } |
124 | } |
125 | |
126 | - if( empty($blog) ) |
127 | - { // No specific blog to be displayed, so make something nice then exit |
128 | + if( empty( $blog ) ) |
129 | + { |
130 | + // No specific blog to be displayed, so make something nice then exit |
131 | header_content_type( 'text/html' ); // sets charset |
132 | ?> |
133 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
134 | @@ -114,14 +112,15 @@ |
135 | <?php |
136 | // messages generated from actions |
137 | messages( array() ); |
138 | - $BlogCache = & get_Cache('BlogCache'); |
139 | + $BlogCache = & get_Cache( 'BlogCache' ); |
140 | $BlogCache->load_all(); |
141 | if( count( $BlogCache->cache ) == 0 ) |
142 | - { // There is no blog on this system! |
143 | + { |
144 | + // There is no blog on this system! |
145 | echo '<p><strong>'; |
146 | printf( T_('%s is installed and ready but you haven\'t created any blog on this system yet.'), $app_name ); |
147 | echo '</strong></p>'; |
148 | - echo '<p><a href="'.$admin_url.'?ctrl=collections&action=new">'.T_( 'Create a first blog' ).' »</a></p>'; |
149 | + echo '<p><a href="'.$admin_url.'?ctrl=blogs&action=new">'.T_( 'Create a first blog' ).' »</a></p>'; |
150 | } |
151 | else |
152 | { |
153 | @@ -143,31 +142,33 @@ |
154 | ?> |
155 | </div></div></div></div></body></html> |
156 | <?php |
157 | - exit(); |
158 | + exit(0); |
159 | } |
160 | } |
161 | |
162 | -// A blog has been requested... Let's set a few default params: |
163 | +// A blog has been requested ... Let's set a few default params..... |
164 | |
165 | -# You could *force* a specific template here with this setting: |
166 | +// You could *force* a specific template here with this setting: |
167 | # $template = 'basic'; |
168 | |
169 | -# This setting retricts posts to those published, thus hiding drafts. |
170 | -# You should not have to change this. |
171 | +// This setting retricts posts to those published, thus hiding drafts. You should |
172 | +// not have to change this. |
173 | $show_statuses = array(); |
174 | |
175 | -# Here you can set a limit before which posts will be ignored |
176 | -# You can use a unix timestamp value or 'now' which will hide all posts in the past |
177 | +// Here you can set a limit before which posts will be ignored. You can use a |
178 | +// unix timestamp value or 'now' which will hide all posts in the past |
179 | $timestamp_min = ''; |
180 | |
181 | -# Here you can set a limit after which posts will be ignored |
182 | -# You can use a unix timestamp value or 'now' which will hide all posts in the future |
183 | +// Here you can set a limit after which posts will be ignored. You can use a |
184 | +// unix timestamp value or 'now' which will hide all posts in the future |
185 | $timestamp_max = 'now'; |
186 | |
187 | -# Additionnaly, you can set other values (see URL params in the manual)... |
188 | +// Additionnaly, you can set other values (see URL params in the manual)... |
189 | # $order = 'ASC'; // This for example would display the blog in chronological order... |
190 | |
191 | -// That's it, now let Quam Plures do the rest! :) |
192 | +/** |
193 | + * Main initialization, with the identified $blog |
194 | + */ |
195 | require $inc_path.'_blog_main.inc.php'; |
196 | |
197 | ?> |
198 | |
199 | === modified file 'multiblogs.php' |
200 | --- multiblogs.php 2013-03-08 20:58:52 +0000 |
201 | +++ multiblogs.php 2013-03-14 18:35:26 +0000 |
202 | @@ -212,7 +212,7 @@ |
203 | 'unit' => $unit, |
204 | ) ); |
205 | |
206 | - // Run the query: |
207 | + // Run the query |
208 | $BlogBList->query(); |
209 | while( $Item = & $BlogBList->get_item() ) |
210 | { |
211 | @@ -249,7 +249,7 @@ |
212 | 'unit' => $unit, |
213 | ) ); |
214 | |
215 | - // Run the query: |
216 | + // Run the query |
217 | $LinkblogList->query(); |
218 | while( $Item = & $LinkblogList->get_item() ) |
219 | { |
220 | @@ -285,7 +285,7 @@ |
221 | <h3><?php echo T_('Misc') ?></h3> |
222 | <ul> |
223 | <?php |
224 | - // Administrative links: |
225 | + // Administrative links |
226 | user_login_link( '<li>', '</li>' ); |
227 | user_register_link( '<li>', '</li>' ); |
228 | user_admin_link( '<li>', '</li>' ); |
229 | |
230 | === modified file 'qp_inc/_application.php' |
231 | --- qp_inc/_application.php 2013-03-08 20:58:52 +0000 |
232 | +++ qp_inc/_application.php 2013-03-14 18:35:26 +0000 |
233 | @@ -19,10 +19,10 @@ |
234 | $app_homepage = 'http://quamplures.net/'; |
235 | |
236 | // The fileset version: incremented in tenths, at whatever rate feels good :) |
237 | -$files_version = '1.10'; |
238 | +$files_version = '1.20'; |
239 | |
240 | // The database version, incrememented by 1 with each change in upgrade_dbase_tables() |
241 | -$app_db_version = 20; |
242 | +$app_db_version = 34; |
243 | |
244 | $app_version = $files_version.'.'.$app_db_version; |
245 | |
246 | |
247 | === modified file 'qp_inc/_blog_main.inc.php' |
248 | --- qp_inc/_blog_main.inc.php 2011-06-28 05:46:28 +0000 |
249 | +++ qp_inc/_blog_main.inc.php 2013-03-14 18:35:26 +0000 |
250 | @@ -1,174 +1,126 @@ |
251 | <?php |
252 | /** |
253 | - * This file loads and initializes the blog to be displayed. |
254 | - * |
255 | - * This file is part of the Quam Plures project - {@link http://quamplures.net/}. |
256 | - * See also {@link https://launchpad.net/quam-plures}. |
257 | - * |
258 | - * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/} |
259 | - * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}. |
260 | - * Parts of this file are copyright (c)2004-2005 by Daniel HAHLER - {@link http://thequod.de/contact}. |
261 | - * |
262 | - * @license http://quamplures.net/license.html GNU General Public License (GPL) |
263 | - * |
264 | - * {@internal Open Source relicensing agreement: |
265 | - * Daniel HAHLER grants Francois PLANQUE the right to license |
266 | - * Daniel HAHLER's contributions to this file and the b2evolution project |
267 | - * under any OSI approved OSS license (http://www.opensource.org/licenses/). |
268 | - * }} |
269 | - * |
270 | - * {@internal Below is a list of authors who have contributed to design/coding of this file: }} |
271 | - * @author blueyed: Daniel HAHLER |
272 | - * @author fplanque: Francois PLANQUE |
273 | - * |
274 | - * @package pond |
275 | + * This file loads and initializes the blog to be displayed |
276 | + * |
277 | + * @author {@link http://wonderwinds.com/ Ed Bennett} |
278 | + * @author {@link http://daniel.hahler.de/ Daniel HAHLER} |
279 | + * @author {@link http://fplanque.net/ Francois PLANQUE} |
280 | + * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project} |
281 | + * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 |
282 | + * @package core |
283 | */ |
284 | - |
285 | -if( !defined('QP_CONFIG_LOADED') ) die( 'Please, do not access this page directly.' ); |
286 | +if(!defined('QP_CONFIG_LOADED')) die('fail'); |
287 | |
288 | /** |
289 | - * Initialize everything: |
290 | + * Initialize everything |
291 | */ |
292 | require_once dirname(__FILE__).'/_main.inc.php'; |
293 | |
294 | -load_funcs('templates/_template.funcs.php'); |
295 | -load_class('items/model/_itemlist.class.php'); |
296 | +load_funcs( 'templates/_template.funcs.php' ); |
297 | |
298 | $Timer->start( '_blog_main.inc' ); |
299 | |
300 | - |
301 | -/* |
302 | - * blog ID. This is a little bit special. |
303 | - * |
304 | - * In most cases $blog should be set by a stub file and the param() call below will just check that it's an integer. |
305 | - * |
306 | - * Note we do NOT memorize the param as we don't want it in regenerate_url() calls. |
307 | - * Whenever we do, index.php will already have called param() with memorize=true |
308 | - * |
309 | - * In some cases $blog will not have been set before and it will be set with the param() call below. |
310 | - * Currently, this only happens with the old /qp_srvc/ RSS stubs. |
311 | - */ |
312 | +// blog ID. This is a little bit special. In most cases $blog should be set by a |
313 | +// stub file and the param() call below will just check that it's an integer. Note |
314 | +// we do NOT memorize the param as we don't want it in regenerate_url() calls. Whenever |
315 | +// we do, index.php will already have called param() with memorize=true In some cases |
316 | +// $blog will not have been set before and it will be set with the param() call below. |
317 | +// Currently, this only happens with the old /qp_srvc/ RSS stubs. |
318 | param( 'blog', 'integer', '', false ); |
319 | |
320 | -// Getting current blog info: |
321 | +// Getting current blog info |
322 | $BlogCache = & get_Cache( 'BlogCache' ); |
323 | -/** |
324 | - * @var Blog |
325 | - */ |
326 | $Blog = & $BlogCache->get_by_ID( $blog, false, false ); |
327 | if( empty( $Blog ) ) |
328 | { |
329 | - require $templates_path.'_404_blog_not_found.main.php'; // error & exit |
330 | - // EXIT. |
331 | + // error & exit |
332 | + require $templates_path.'_404_blog_not_found.main.php'; |
333 | } |
334 | |
335 | - |
336 | // Init $disp |
337 | param( 'disp', 'string', 'posts', true ); |
338 | $disp_detail = ''; |
339 | |
340 | - |
341 | -/* |
342 | - * _______________________________ Locale / Charset for the Blog _________________________________ |
343 | - * |
344 | - TODO: blueyed>> This should get moved as default to the locale detection in _main.inc.php, |
345 | - as we only want to activate the I/O charset, which is probably the user's.. |
346 | - It prevents using a locale/charset in the front office, apart from the one given as default for the blog!! |
347 | -fp>there is no blog defined in _main and there should not be any |
348 | -blueyed> Sure, but that means we should either split it, or use the locale here only, if there's no-one given with higher priority. |
349 | -*/ |
350 | -// Activate matching locale: |
351 | -$Debuglog->add( 'Activating blog locale: '.$Blog->get('locale'), 'locale' ); |
352 | +// Locale / Charset for the Blog - activate matching locale |
353 | locale_activate( $Blog->get('locale') ); |
354 | |
355 | - |
356 | -// Re-Init charset handling, in case current_charset has changed: |
357 | +// Re-Init charset handling, in case current_charset has changed |
358 | if( init_charsets( $current_charset ) ) |
359 | { |
360 | - // Reload Blog(s) (for encoding of name, tagline etc): |
361 | - $BlogCache->clear(); |
362 | - |
363 | - $Blog = & $BlogCache->get_by_ID( $blog ); |
364 | -} |
365 | - |
366 | - |
367 | -/* |
368 | - * _____________________________ Extra path info decoding ________________________________ |
369 | - * |
370 | - * This will translate extra path into 'regular' params. |
371 | - * |
372 | - * Decoding should try to work like this: |
373 | - * |
374 | - * baseurl/blog-urlname/junk/.../junk/post-title -> points to a single post (no ending slash) |
375 | - * baseurl/blog-urlname/junk/.../junk/p142 -> points to a single post |
376 | - * baseurl/blog-urlname/2006/ -> points to a yearly archive because of ending slash + 4 digits |
377 | - * baseurl/blog-urlname/2006/12/ -> points to a monthly archive |
378 | - * baseurl/blog-urlname/2006/12/31/ -> points to a daily archive |
379 | - * baseurl/blog-urlname/2006/w53/ -> points to a weekly archive |
380 | - * baseurl/blog-urlname/junk/.../junk/chap-urlname/ -> points to a single chapter/category (because of ending slash) |
381 | - * Note: category names cannot be named like this [a-z][0-9]+ |
382 | - */ |
383 | -if( ! isset( $resolve_extra_path ) ) { $resolve_extra_path = true; } |
384 | + // Reload Blog(s) (for encoding of name, tagline etc) |
385 | + $BlogCache->clear(); |
386 | + $Blog = & $BlogCache->get_by_ID( $blog ); |
387 | +} |
388 | + |
389 | +// Extra path info decoding. This will translate extra path into 'regular' params. |
390 | +// Decoding should try to work like this: |
391 | +// - baseurl/blog-urlname/junk/.../junk/post-title -> points to a single post (no ending slash) |
392 | +// - baseurl/blog-urlname/junk/.../junk/p142 -> points to a single post |
393 | +// - baseurl/blog-urlname/2006/ -> points to a yearly archive because of ending slash + 4 digits |
394 | +// - baseurl/blog-urlname/2006/12/ -> points to a monthly archive |
395 | +// - baseurl/blog-urlname/2006/12/31/ -> points to a daily archive |
396 | +// - baseurl/blog-urlname/2006/w53/ -> points to a weekly archive |
397 | +// - baseurl/blog-urlname/junk/.../junk/cat-urlname/ -> points to a single category (because of ending slash) |
398 | +// Note: category names cannot be named like this [a-z][0-9]+ |
399 | +if( ! isset( $resolve_extra_path ) ) |
400 | +{ |
401 | + $resolve_extra_path = true; |
402 | +} |
403 | + |
404 | if( $resolve_extra_path ) |
405 | { |
406 | - // Check and Remove blog base URI from ReqPath: |
407 | + // Check and Remove blog base URI from ReqPath |
408 | $blog_baseuri = substr( $Blog->gen_baseurl(), strlen( $Blog->get('baseurlroot') ) ); |
409 | - $Debuglog->add( 'blog_baseuri: "'.$blog_baseuri.'"', 'params' ); |
410 | |
411 | - // Remove trailer: |
412 | + // Remove trailer |
413 | $blog_baseuri_regexp = preg_replace( '¤(\.php[0-9]?)?/?$¤', '', $blog_baseuri ); |
414 | - // Readd possibilities in order to get a broad match: |
415 | + // Read possibilities in order to get a broad match |
416 | $blog_baseuri_regexp = '¤^'.preg_quote( $blog_baseuri_regexp ).'(\.php[0-9]?)?/(.+)$¤'; |
417 | |
418 | if( preg_match( $blog_baseuri_regexp, $ReqPath, $matches ) ) |
419 | - { // We have extra path info |
420 | + { |
421 | + // We have extra path info |
422 | $path_string = $matches[2]; |
423 | - |
424 | - $Debuglog->add( 'Extra path info found! path_string=' . $path_string , 'params' ); |
425 | - |
426 | // Replace encoded ";" and ":" with regular chars (used for tags) |
427 | - // TODO: dh> why not urldecode it altogether? fp> would prolly make sense but requires testing -- note: check with tags (move urldecode from tags up here) |
428 | - // TODO: PHP5: use str_ireplace |
429 | $path_string = str_replace( |
430 | - array('%3b', '%3B', '%3a', '%3A'), |
431 | - array(';', ';', ':', ':'), |
432 | + array( '%3b', '%3B', '%3a', '%3A' ), |
433 | + array( ';', ';', ':', ':' ), |
434 | $path_string ); |
435 | |
436 | - // Slice the path: |
437 | + // Slice the path |
438 | $path_elements = preg_split( '~/~', $path_string, 20, PREG_SPLIT_NO_EMPTY ); |
439 | |
440 | if( isset( $path_elements[0] ) |
441 | && ( $path_elements[0] == $Blog->stub |
442 | || $path_elements[0] == $Blog->urlname |
443 | || $path_elements[0] == 'index.php' ) ) |
444 | - { // Ignore stub files, blog url names, and index.php |
445 | + { |
446 | + // Ignore stub files, blog url names, and index.php |
447 | array_shift( $path_elements ); |
448 | - $Debuglog->add( 'Ignoring stub filename, blog urlname, or index.php in extra path info' , 'params' ); |
449 | } |
450 | |
451 | if( isset( $path_elements[0] ) |
452 | && ( substr_count( $path_elements[0], '.' ) != 0 ) |
453 | && is_file( $basepath.$path_elements[0] ) ) |
454 | - { // Ignore filenames that exist in root |
455 | + { |
456 | + // Ignore filenames that exist in root |
457 | array_shift( $path_elements ); |
458 | - $Debuglog->add( 'Ignoring filenames that exist as installation root files in extra path info' , 'params' ); |
459 | } |
460 | |
461 | // Do we still have extra path info to decode? |
462 | if( count($path_elements) ) |
463 | { |
464 | - // TODO: dh> add plugin hook here, which would allow to handle path elements (name spaces in clean URLs), and to override internal functionality (e.g. handle tags in a different way). |
465 | // Is this a tag ("prefix-only" mode)? |
466 | - if( $Blog->get_setting('tag_links') == 'prefix-only' |
467 | + if( $Blog->get_setting( 'tag_links' ) == 'prefix-only' |
468 | && count($path_elements) == 2 |
469 | - && $path_elements[0] == $Blog->get_setting('tag_prefix') |
470 | + && $path_elements[0] == $Blog->get_setting( 'tag_prefix' ) |
471 | && isset($path_elements[1]) ) |
472 | { |
473 | $tag = strip_tags(urldecode($path_elements[1])); |
474 | - |
475 | - // # of posts per page for tag page: |
476 | + // # of posts per page for tag page |
477 | if( ! $posts = $Blog->get_setting( 'tag_posts_per_page' ) ) |
478 | - { // use blog default |
479 | + { |
480 | + // use blog default |
481 | $posts = $Blog->get_setting( 'posts_per_page' ); |
482 | } |
483 | } |
484 | @@ -177,189 +129,201 @@ |
485 | // Does the pathinfo end with a / or a ; ? |
486 | $last_char = substr( $path_string, -1 ); |
487 | $last_part = $path_elements[count( $path_elements )-1]; |
488 | - $last_len = strlen( $last_part ); |
489 | + $last_len = strlen( $last_part ); |
490 | if( ( $last_char == '-' && ( ! $tags_dash_fix || $last_len != 40 ) ) || $last_char == ':'|| $last_char == ';' ) |
491 | - { // - : or ; -> We'll consider this to be a tag page |
492 | + { |
493 | + // - : or ; -> We'll consider this to be a tag page |
494 | $tag = substr( $last_part, 0, -1 ); |
495 | $tag = urldecode($tag); |
496 | - $tag = strip_tags($tag); // security |
497 | + $tag = strip_tags($tag); // security |
498 | |
499 | // # of posts per page: |
500 | if( ! $posts = $Blog->get_setting( 'tag_posts_per_page' ) ) |
501 | - { // use blog default |
502 | + { |
503 | + // use blog default |
504 | $posts = $Blog->get_setting( 'posts_per_page' ); |
505 | } |
506 | } |
507 | elseif( ( $tags_dash_fix && $last_char == '-' && $last_len == 40 ) || $last_char != '/' ) |
508 | - { // NO ENDING SLASH or ends with a dash, is 40 chars long and $tags_dash_fix is true |
509 | - // -> We'll consider this to be a ref to a post. |
510 | - $Debuglog->add( 'We consider this o be a ref to a post - last char: '.$last_char, 'params' ); |
511 | + { |
512 | + // NO ENDING SLASH or ends with a dash, is 40 chars long and $tags_dash_fix is true |
513 | + // -> We'll consider this to be a reference to a post. |
514 | |
515 | - // Set a lot of defaults as if we had received a complex URL: |
516 | + // Set a lot of defaults as if we had received a complex URL |
517 | $m = ''; |
518 | $more = 1; // Display the extended entries' text |
519 | - $c = 1; // Display comments |
520 | - $tb = 1; // Display trackbacks |
521 | + $c = 1; // Display comments |
522 | + $tb = 1; // Display trackbacks |
523 | |
524 | if( preg_match( '#^p([0-9]+)$#', $last_part, $req_post ) ) |
525 | - { // The last param is of the form p000 |
526 | - $p = $req_post[1]; // Post to display |
527 | + { |
528 | + // The last param is of the form p000 |
529 | + $p = $req_post[1]; // Post to display |
530 | } |
531 | else |
532 | - { // Last param is a string, we'll consider this to be a post urltitle |
533 | + { |
534 | + // Last param is a string, we'll consider this to be a post urltitle |
535 | $title = $last_part; |
536 | } |
537 | } |
538 | else |
539 | - { // ENDING SLASH -> we are looking for a daterange OR a chapter: |
540 | - $Debuglog->add( 'Last part: '.$last_part , 'params' ); |
541 | + { |
542 | + // ENDING SLASH -> we are looking for a daterange OR a category |
543 | if( preg_match( '|^w?[0-9]+$|', $last_part ) ) |
544 | - { // Last part is a number or a "week" number: |
545 | + { |
546 | + // Last part is a number or a "week" number |
547 | $i=0; |
548 | - $Debuglog->add( 'Last part is a number or a "week" number: '.$path_elements[$i] , 'params' ); |
549 | if( isset( $path_elements[$i] ) ) |
550 | { |
551 | if( is_numeric( $path_elements[$i] ) ) |
552 | - { // We'll consider this to be the year |
553 | + { |
554 | + // We'll consider this to be the year |
555 | $m = $path_elements[$i++]; |
556 | - $Debuglog->add( 'Setting year from extra path info. $m=' . $m , 'params' ); |
557 | |
558 | - // Also use the prefered posts per page for archives (may be NULL, in which case the blog default will be used later on) |
559 | + // Also use the prefered posts per page for archives (may be NULL, |
560 | + // in which case the blog default will be used later on) |
561 | if( ! $posts = $Blog->get_setting( 'archive_posts_per_page' ) ) |
562 | - { // use blog default |
563 | + { |
564 | + // use blog default |
565 | $posts = $Blog->get_setting( 'posts_per_page' ); |
566 | } |
567 | |
568 | if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) ) |
569 | - { // We'll consider this to be the month |
570 | + { |
571 | + // We'll consider this to be the month |
572 | $m .= $path_elements[$i++]; |
573 | - $Debuglog->add( 'Setting month from extra path info. $m=' . $m , 'params' ); |
574 | |
575 | if( isset( $path_elements[$i] ) && is_numeric( $path_elements[$i] ) ) |
576 | - { // We'll consider this to be the day |
577 | + { |
578 | + // We'll consider this to be the day |
579 | $m .= $path_elements[$i++]; |
580 | - $Debuglog->add( 'Setting day from extra path info. $m=' . $m , 'params' ); |
581 | } |
582 | } |
583 | elseif( isset( $path_elements[$i] ) && substr( $path_elements[$i], 0, 1 ) == 'w' ) |
584 | - { // We consider this a week number |
585 | + { |
586 | + // We consider this a week number |
587 | $w = substr( $path_elements[$i], 1, 2 ); |
588 | } |
589 | } |
590 | else |
591 | - { // We did not get a number/year... |
592 | + { |
593 | + // We did not get a number/year... |
594 | $disp = '404'; |
595 | $disp_detail = '404-malformed_url-missing_year'; |
596 | } |
597 | } |
598 | } |
599 | - elseif( preg_match( '|^[A-Za-z0-9\-_]+$|', $last_part ) ) // UNDERSCORES for catching OLD URLS!!! |
600 | - { // We are pointing to a chapter/category: |
601 | - $ChapterCache = & get_Cache( 'ChapterCache' ); |
602 | - /** |
603 | - * @var Chapter |
604 | - */ |
605 | - $Chapter = & $ChapterCache->get_by_urlname( $last_part, false ); |
606 | - if( empty( $Chapter ) ) |
607 | - { // We could not match a chapter... |
608 | - // We are going to consider this to be a post title with a misplaced trailing slash. |
609 | - // That happens when upgrading from WP for example. |
610 | + elseif( preg_match( '|^[A-Za-z0-9\-_]+$|', $last_part ) ) // UNDERSCORES for catching OLD URLS!!! |
611 | + { |
612 | + // We are pointing to a category |
613 | + $CategoryCache = & get_Cache( 'CategoryCache' ); |
614 | + $Category = & $CategoryCache->get_by_urlname( $last_part, false ); |
615 | + if( empty( $Category ) ) |
616 | + { |
617 | + // We could not match a category; consider this to be a post title with a |
618 | + // misplaced trailing slash. That happens when upgrading from WP for example. |
619 | $title = $last_part; // Will be sought later |
620 | - $already_looked_into_chapters = true; |
621 | + $already_looked_into_cats = true; |
622 | } |
623 | else |
624 | - { // We could match a chapter from the extra path: |
625 | - $cat = $Chapter->ID; |
626 | + { |
627 | + // We could match a category from the extra path |
628 | + $cat = $Category->ID; |
629 | // Also use the prefered posts per page for a cat |
630 | - if( ! $posts = $Blog->get_setting( 'chapter_posts_per_page' ) ) |
631 | - { // use blog default |
632 | + if( ! $posts = $Blog->get_setting( 'category_posts_per_page' ) ) |
633 | + { |
634 | + // use blog default |
635 | $posts = $Blog->get_setting( 'posts_per_page' ); |
636 | } |
637 | } |
638 | } |
639 | else |
640 | - { // We did not get anything we can decode... |
641 | + { |
642 | + // We did not get anything we can decode... |
643 | $disp = '404'; |
644 | $disp_detail = '404-malformed_url-bad_char'; |
645 | } |
646 | } |
647 | } |
648 | } |
649 | - |
650 | } |
651 | } |
652 | |
653 | - |
654 | -/* |
655 | - * ____________________________ Query params ____________________________ |
656 | - * |
657 | - * Note: if the params have been set by the extra-path-info above, param() will not touch them. |
658 | - */ |
659 | -param( 'p', 'integer', '', true ); // Specific post number to display |
660 | -param( 'title', 'string', '', true ); // urtitle of post to display |
661 | -param( 'redir', 'string', 'yes', false ); // Do we allow redirection to canonical URL? (allows to force a 'single post' URL for commenting) |
662 | -param( 'preview', 'integer', 0, true ); // Is this preview ? |
663 | -param( 'stats', 'integer', 0 ); // Deprecated but might still be used by spambots |
664 | -param( 'cat', 'integer', '', true ); // Chapter ID |
665 | - |
666 | -// In case these were not set by the stub: |
667 | -if( !isset($timestamp_min) ) $timestamp_min = ''; |
668 | -if( !isset($timestamp_max) ) $timestamp_max = ''; |
669 | - |
670 | - |
671 | -/* |
672 | - * ____________________________ Get specific Item if requested ____________________________ |
673 | - */ |
674 | -if( !empty($p) || !empty($title) ) |
675 | -{ // We are going to display a single post |
676 | - // Make sure the single post we're requesting (still) exists: |
677 | +// Query params ... Note: if the params have been set by the extra-path-info |
678 | +// above, param() will not touch them. |
679 | + |
680 | +// Specific post number to display |
681 | +param( 'p', 'integer', '', true ); |
682 | +// urtitle of post to display |
683 | +param( 'title', 'string', '', true ); |
684 | +// Do we allow redirection to canonical URL? (allows to force a 'single post' URL for commenting) |
685 | +param( 'redir', 'string', 'yes', false ); |
686 | +// Is this preview ? |
687 | +param( 'preview', 'integer', 0, true ); |
688 | +// Deprecated but might still be used by spambots |
689 | +param( 'stats', 'integer', 0 ); |
690 | +// category ID |
691 | +param( 'cat', 'integer', '', true ); |
692 | + |
693 | +// In case these were not set by the stub |
694 | +if( ! isset( $timestamp_min ) ) $timestamp_min = ''; |
695 | +if( ! isset( $timestamp_max ) ) $timestamp_max = ''; |
696 | + |
697 | +// Get specific Item if requested |
698 | +if( ! empty( $p ) || ! empty( $title ) ) |
699 | +{ |
700 | + // We are going to display a single post |
701 | + // Make sure the single post we're requesting (still) exists |
702 | $ItemCache = & get_Cache( 'ItemCache' ); |
703 | - if( !empty($p) ) |
704 | - { // Get from post ID: |
705 | + if( ! empty( $p ) ) |
706 | + { |
707 | + // Get from post ID |
708 | $Item = & $ItemCache->get_by_ID( $p, false ); |
709 | } |
710 | else |
711 | - { // Get from post title: |
712 | + { |
713 | + // Get from post title |
714 | $orig_title = $title; |
715 | $title = preg_replace( '/[^A-Za-z0-9_]/', '-', $title ); |
716 | $Item = & $ItemCache->get_by_urltitle( $title, false ); |
717 | } |
718 | if( empty( $Item ) ) |
719 | - { // Post doesn't exist! |
720 | - |
721 | + { |
722 | + // Post doesn't exist! |
723 | // fp> TODO: ->viewing_allowed() for draft, private, protected and deprecated... |
724 | - |
725 | $title_fallback = false; |
726 | $tag_fallback = ( $tags_dash_fix && substr( $orig_title, -1 ) == '-' && strlen( $orig_title ) == 40 ); |
727 | |
728 | - if( ! $tag_fallback && !empty($title) && empty($already_looked_into_chapters) ) |
729 | - { // Let's try to fall back to a category/chapter... |
730 | - $ChapterCache = & get_Cache( 'ChapterCache' ); |
731 | - /** |
732 | - * @var Chapter |
733 | - */ |
734 | - $Chapter = & $ChapterCache->get_by_urlname( $title, false ); |
735 | - if( !empty( $Chapter ) ) |
736 | - { // We could match a chapter from the extra path: |
737 | - $cat = $Chapter->ID; |
738 | + if( ! $tag_fallback && ! empty( $title ) && empty( $already_looked_into_cats ) ) |
739 | + { |
740 | + // Let's try to fall back to a category... |
741 | + $CategoryCache = & get_Cache( 'CategoryCache' ); |
742 | + $Category = & $CategoryCache->get_by_urlname( $title, false ); |
743 | + if( ! empty( $Category ) ) |
744 | + { |
745 | + // We could match a category from the extra path |
746 | + $cat = $Category->ID; |
747 | $title_fallback = true; |
748 | $title = NULL; |
749 | // Also use the prefered posts per page for a cat |
750 | - if( ! $posts = $Blog->get_setting( 'chapter_posts_per_page' ) ) |
751 | - { // use blog default |
752 | + if( ! $posts = $Blog->get_setting( 'category_posts_per_page' ) ) |
753 | + { |
754 | + // use blog default |
755 | $posts = $Blog->get_setting( 'posts_per_page' ); |
756 | } |
757 | } |
758 | } |
759 | |
760 | - if( !empty($title) ) |
761 | - { // Let's try to fall back to a tag... |
762 | + if( ! empty( $title ) ) |
763 | + { |
764 | + // Let's try to fall back to a tag... |
765 | if( $tag_fallback ) |
766 | { |
767 | $title = substr( $orig_title, 0, -1 ); |
768 | } |
769 | if( $Blog->get_tag_post_count( $title ) ) |
770 | - { // We could match a tag from the extra path: |
771 | + { |
772 | + // We could match a tag from the extra path |
773 | $tag = $title; |
774 | $title_fallback = true; |
775 | $title = NULL; |
776 | @@ -367,88 +331,79 @@ |
777 | } |
778 | |
779 | if( ! $title_fallback ) |
780 | - { // We were not able to fallback to anythign meaningful: |
781 | + { |
782 | + // We were not able to fallback to anything meaningful |
783 | $disp = '404'; |
784 | $disp_detail = '404-post_not_found'; |
785 | } |
786 | } |
787 | } |
788 | -else if( ! empty( $cat ) ) |
789 | -{ // We are pointing to a chapter/category (by ID): |
790 | - $ChapterCache = & get_Cache( 'ChapterCache' ); |
791 | - /** |
792 | - * @var Chapter |
793 | - */ |
794 | - $Chapter = & $ChapterCache->get_by_ID( $cat, false ); |
795 | +elseif( ! empty( $cat ) ) |
796 | +{ |
797 | + // We are pointing to a category (by ID) |
798 | + $CategoryCache = & get_Cache( 'CategoryCache' ); |
799 | + $Category = & $CategoryCache->get_by_ID( $cat, false ); |
800 | |
801 | - if( ! $Chapter ) |
802 | - { // Category not found, bail out: |
803 | + if( ! $Category ) |
804 | + { |
805 | + // Category not found, bail out |
806 | $disp = '404'; |
807 | $disp_detail = '404-category-not-found'; |
808 | } |
809 | } |
810 | |
811 | - |
812 | -/* |
813 | - * ____________________________ "Clean up" the request ____________________________ |
814 | - * |
815 | - * Make sure that: |
816 | - * 1) disp is set to "single" if single post requested |
817 | - * 2) URL is canonical if: |
818 | - * - some content was requested in a weird/deprecated way |
819 | - * - or if content identifiers have changed |
820 | - */ |
821 | +// "Clean up" the request |
822 | +// Make sure that: |
823 | +// 1) disp is set to "single" if single post requested |
824 | +// 2) URL is canonical if: |
825 | +// - some content was requested in a weird/deprecated way |
826 | +// - or if content identifiers have changed |
827 | if( $stats || $disp == 'stats' ) |
828 | -{ // This used to be a spamfest... |
829 | - require $templates_path.'_410_stats_gone.main.php'; // error & exit |
830 | - // EXIT. |
831 | +{ |
832 | + // This used to be a spamfest, error & exit |
833 | + require $templates_path.'_410_stats_gone.main.php'; |
834 | } |
835 | -elseif( !empty($preview) ) |
836 | -{ // Preview |
837 | +elseif( ! empty( $preview ) ) |
838 | +{ |
839 | + // Preview |
840 | $disp = 'single'; |
841 | // Consider this as an admin hit! |
842 | $Hit->referer_type = 'admin'; |
843 | } |
844 | -elseif( $disp == 'posts' && !empty($Item) ) |
845 | -{ // We are going to display a single post |
846 | - // if( in_array( $Item->ptyp_ID, array( 1000, 1500, 1520, 1530, 1570 ) ) ) // pages and intros |
847 | +elseif( $disp == 'posts' && ! empty( $Item ) ) |
848 | +{ |
849 | + // We are going to display a single post |
850 | if( $Item->ptyp_ID == 1000 ) |
851 | { |
852 | + // this is a page-type |
853 | $disp = 'page'; |
854 | } |
855 | + elseif( in_array( $Item->ptyp_ID, array( 1500, 1520, 1530, 1570 ) ) ) |
856 | + { |
857 | + // these are intro-types |
858 | + $disp = 'intro'; |
859 | + } |
860 | else |
861 | { |
862 | + // must be good old permalink single post |
863 | $disp = 'single'; |
864 | } |
865 | - |
866 | - // fp> note: the redirecting code that was here moved to template_init() with the other redirecting code. |
867 | - // That feels more consistent and may also allow some templates to handle redirects differently (framing?) |
868 | - // I hope I didn't screw that up... but it felt like the historical reasons for this to be here no longer applied. |
869 | } |
870 | |
871 | - |
872 | -/* |
873 | - * ______________________ DETERMINE WHICH TEMPLATE TO USE FOR DISPLAY _______________________ |
874 | - */ |
875 | - |
876 | -/** |
877 | - * Check if a temporary template has been requested (used for RSS syndication |
878 | - * for example). |
879 | - * |
880 | - * This will be handled like any other template. |
881 | - * tempskin is also checked for b2evolution backward compatibility. |
882 | - * |
883 | - * @todo maybe restrict that to authorized users? |
884 | - */ |
885 | +// DETERMINE WHICH TEMPLATE TO USE FOR DISPLAY |
886 | +// Check if a temporary template has been requested (used for RSS syndication for example). |
887 | +// This will be handled like any other template. tempskin is also checked for b2evolution |
888 | +// backward compatibility. |
889 | + |
890 | if( param( 'viewmode', 'string', param( 'tempskin', 'string' ), true ) !== '' ) |
891 | { |
892 | $template = $viewmode; |
893 | } |
894 | |
895 | if( isset( $template ) ) |
896 | -{ // A template has been requested by folder_name (url or stub): |
897 | - |
898 | - // Check validity of requested template name: |
899 | +{ |
900 | + // A template has been requested by folder_name (url or stub) |
901 | + // Check validity of requested template name |
902 | if( preg_match( '~([^-A-Za-z0-9._]|\.\.)~', $template ) ) |
903 | { |
904 | debug_die( 'The requested template name is invalid.' ); |
905 | @@ -458,10 +413,13 @@ |
906 | $Template = & $TemplateCache->new_obj( NULL, $template ); |
907 | |
908 | if( $Template->type == 'feed' ) |
909 | - { // Check if we actually allow the display of the feed; last chance to revert to 404 displayed in default template. |
910 | - // Note: Templates with the type "feed" can always be accessed, even when they're not installed. |
911 | - if( $Blog->get_setting('feed_content') == 'none' ) |
912 | - { // We don't want to provide feeds; revert to 404! |
913 | + { |
914 | + // Check if we actually allow the display of the feed; last chance to revert |
915 | + // to 404 displayed in default template. Note: Templates with the type "feed" |
916 | + // can always be accessed, even when they're not installed. |
917 | + if( $Blog->get_setting( 'feed_content' ) == 'none' ) |
918 | + { |
919 | + // We don't want to provide feeds; revert to 404! |
920 | unset( $template ); |
921 | unset( $Template ); |
922 | $disp = '404'; |
923 | @@ -469,108 +427,115 @@ |
924 | } |
925 | } |
926 | elseif( template_exists( $template ) && ! template_installed( $template ) ) |
927 | - { // The requested template is not a feed template and exists in the file system, but isn't installed: |
928 | + { |
929 | + // The requested template is not a feed and exists, but isn't installed |
930 | debug_die( sprintf( T_( 'The template [%s] is not installed on this system.' ), htmlspecialchars( $template ) ) ); |
931 | } |
932 | else if( ! empty( $viewmode ) ) |
933 | - { // By definition, we want to see the temporary template (if we don't use feedburner... ) |
934 | + { |
935 | + // By definition, we want to see the temporary template (if we don't use feedburner...) |
936 | $redir = 'no'; |
937 | } |
938 | } |
939 | |
940 | -if( !isset( $template ) && !empty($Blog->template_ID) ) // Note: if $template is set to '', then we want to do a "no template" display |
941 | -{ // Use default template from the database |
942 | +// Note: if $template is set to '', then we want to do a "no template" display |
943 | +if( ! isset( $template ) && ! empty( $Blog->template_ID ) ) |
944 | +{ |
945 | + // Use default template from the database |
946 | $TemplateCache = & get_cache( 'TemplateCache' ); |
947 | $Template = & $TemplateCache->get_by_ID( $Blog->template_ID ); |
948 | $template = $Template->folder; |
949 | } |
950 | |
951 | -// Because a lot of bloggers will delete templates, we have to make this fool proof with extra checking: |
952 | -if( !empty( $template ) && !template_exists( $template ) ) |
953 | -{ // We want to use a template, but it doesn't exist! |
954 | +// we have to make this fool proof with extra checking ... if someone deletes a template |
955 | +if( ! empty( $template ) && ! template_exists( $template ) ) |
956 | +{ |
957 | + // We want to use a template, but it doesn't exist! |
958 | $err_msg = sprintf( T_('The template [%s] set for blog [%s] does not exist. It must be properly set in the <a %s>blog properties</a> or properly overriden in a stub file.'), |
959 | - htmlspecialchars($template), |
960 | - $Blog->dget('shortname'), |
961 | - 'href="'.$admin_url.'?ctrl=coll_settings&tab=template&blog='.$Blog->ID.'"' ); |
962 | + htmlspecialchars( $template ), |
963 | + $Blog->dget( 'shortname' ), |
964 | + 'href="'.$admin_url.'?ctrl=blog_settings&tab=template&blog='.$Blog->ID.'"' ); |
965 | debug_die( $err_msg ); |
966 | } |
967 | |
968 | - |
969 | $Timer->pause( '_blog_main.inc'); |
970 | |
971 | - |
972 | -/* |
973 | - * _______________________________ READY TO DISPLAY _______________________________ |
974 | - * |
975 | - * At this point $template holds the name of the template we want to use, or '' for no template! |
976 | - */ |
977 | - |
978 | - |
979 | -// Trigger plugin event: |
980 | +// READY TO DISPLAY :) |
981 | +// At this point $template holds the name of the template we want to use, or '' |
982 | +// for no template ... which probably doesn't work at all so test it and fix it. |
983 | + |
984 | +// Trigger plugin event |
985 | // fp> TODO: please doc with example of what this can be used for |
986 | -$Plugins->trigger_event( 'BeforeBlogDisplay', array('template'=>$template) ); |
987 | - |
988 | - |
989 | -if( !empty( $template ) ) |
990 | -{ // We want to display with a template now: |
991 | - |
992 | - // Instanciate PageCache: |
993 | - load_class( '_core/model/_pagecache.class.php' ); |
994 | +$Plugins->trigger_event( 'BeforeBlogDisplay', array( |
995 | + 'template' => $template |
996 | +) ); |
997 | + |
998 | +if( ! empty( $template ) ) |
999 | +{ |
1000 | + // We want to display with a template now |
1001 | + |
1002 | + // Instanciate PageCache |
1003 | $PageCache = new PageCache( $Blog ); |
1004 | - // Check for cached content & Start caching if needed |
1005 | - // Note: there are some redirects inside the templates themselves for canonical URLs, |
1006 | - // If we have a cache hit, the redirect won't take place until the cache expires -- probably ok. |
1007 | - // If we start collecting and a redirect happens, the collecting will just be lost and that's what we want. |
1008 | + // Check for cached content & Start caching if needed Note: there are some redirects |
1009 | + // inside the templates themselves for canonical URLs, If we have a cache hit, the |
1010 | + // redirect won't take place until the cache expires -- probably ok. If we start |
1011 | + // collecting and a redirect happens, the collecting will just be lost and that's what we want. |
1012 | if( ! $PageCache->check() ) |
1013 | - { // Cache miss, we have to generate: |
1014 | - |
1015 | - if( $template_provided_by_plugin = template_provided_by_plugin($template) ) |
1016 | + { |
1017 | + // Cache miss, we have to generate |
1018 | + if( $template_provided_by_plugin = template_provided_by_plugin( $template ) ) |
1019 | { |
1020 | - $Plugins->call_method( $template_provided_by_plugin, 'DisplayTemplate', $tmp_params = array('template'=>$template) ); |
1021 | + $Plugins->call_method( $template_provided_by_plugin, 'DisplayTemplate', $tmp_params = array( 'template' => $template ) ); |
1022 | } |
1023 | else |
1024 | { |
1025 | - // Path for the current template: |
1026 | + // Path for the current template |
1027 | $ads_current_template_path = $templates_path.$template.'/'; |
1028 | |
1029 | $disp_handlers = array( |
1030 | - '404' => '404_not_found.main.php', |
1031 | - 'arcdir' => 'arcdir.main.php', |
1032 | - 'catdir' => 'catdir.main.php', |
1033 | - 'comments' => 'comments.main.php', |
1034 | - 'credits' => 'credits.main.php', |
1035 | + '404' => '404_not_found.main.php', |
1036 | + 'arcdir' => 'arcdir.main.php', |
1037 | + 'catdir' => 'catdir.main.php', |
1038 | + 'comments' => 'comments.main.php', |
1039 | + 'credits' => 'credits.main.php', |
1040 | 'feedback-popup' => 'feedback_popup.main.php', |
1041 | - 'mediaidx' => 'mediaidx.main.php', |
1042 | - 'msgform' => 'msgform.main.php', |
1043 | - 'page' => 'page.main.php', |
1044 | - 'posts' => 'posts.main.php', |
1045 | - 'profile' => 'profile.main.php', |
1046 | - 'single' => 'single.main.php', |
1047 | - 'subs' => 'subs.main.php', |
1048 | + 'mediaidx' => 'mediaidx.main.php', |
1049 | + 'msgform' => 'msgform.main.php', |
1050 | + 'page' => 'page.main.php', |
1051 | + 'posts' => 'posts.main.php', |
1052 | + 'profile' => 'profile.main.php', |
1053 | + 'single' => 'single.main.php', |
1054 | + 'subs' => 'subs.main.php', |
1055 | // All others will default to index.main.php |
1056 | ); |
1057 | |
1058 | - if( !empty($disp_handlers[$disp]) ) |
1059 | + if( ! empty( $disp_handlers[$disp] ) ) |
1060 | { |
1061 | if( file_exists( $disp_handler = $ads_current_template_path.$disp_handlers[$disp] ) ) |
1062 | - { // The template has a customized page handler for this display: |
1063 | - $Debuglog->add('blog_main: include '.rel_path_to_base($disp_handler).' (custom to this template)', 'template'); |
1064 | + { |
1065 | + /** |
1066 | + * The template has a customized page handler for this display |
1067 | + */ |
1068 | require $disp_handler; |
1069 | } |
1070 | else |
1071 | - { // Use the default handler from the templates dir: |
1072 | - $Debuglog->add('blog_main: include '.rel_path_to_base($ads_current_template_path.'index.main.php').' (default handler)', 'template'); |
1073 | + { |
1074 | + /** |
1075 | + * Use the default handler from the templates dir |
1076 | + */ |
1077 | require $ads_current_template_path.'index.main.php'; |
1078 | } |
1079 | } |
1080 | else |
1081 | - { // Use the default handler from the templates dir: |
1082 | - $Debuglog->add('blog_main: include '.rel_path_to_base($ads_current_template_path.'index.main.php').' (default index handler)', 'template'); |
1083 | + { |
1084 | + /** |
1085 | + * Use the default handler from the templates dir |
1086 | + */ |
1087 | require $ads_current_template_path.'index.main.php'; |
1088 | } |
1089 | } |
1090 | |
1091 | - // Save collected cached data if needed: |
1092 | + // Save collected cached data if needed |
1093 | $PageCache->end_collect(); |
1094 | } |
1095 | |
1096 | @@ -579,12 +544,13 @@ |
1097 | exit(0); |
1098 | } |
1099 | else |
1100 | -{ // We don't use a template. Hopefully the caller will do some displaying. |
1101 | +{ |
1102 | + // We don't use a template. Hopefully the caller will do some displaying. |
1103 | // Set a few vars with default values, just in case... |
1104 | $ads_current_template_path = $srvc_path; |
1105 | |
1106 | - // We'll just return to the caller now... (if we have not used a template, the caller should do the display after this) |
1107 | + // We'll just return to the caller now... (if we have not used a template, the |
1108 | + // caller should do the display after this) |
1109 | } |
1110 | |
1111 | - |
1112 | ?> |
1113 | |
1114 | === modified file 'qp_inc/_core/__core.init.php' |
1115 | --- qp_inc/_core/__core.init.php 2013-03-08 20:58:52 +0000 |
1116 | +++ qp_inc/_core/__core.init.php 2013-03-14 18:35:26 +0000 |
1117 | @@ -27,73 +27,79 @@ |
1118 | |
1119 | // Aliases for table names |
1120 | $app_db_config['aliases'] = array( |
1121 | - 'T_antispam' => $app_db_tableprefix.'antispam', |
1122 | - 'T_blogs' => $app_db_tableprefix.'blogs', |
1123 | - 'T_categories' => $app_db_tableprefix.'categories', |
1124 | - 'T_coll_group_perms' => $app_db_tableprefix.'bloggroups', |
1125 | - 'T_coll_user_perms' => $app_db_tableprefix.'blogusers', |
1126 | - 'T_coll_settings' => $app_db_tableprefix.'coll_settings', |
1127 | - 'T_comments' => $app_db_tableprefix.'comments', |
1128 | - 'T_cron__log' => $app_db_tableprefix.'cron__log', |
1129 | - 'T_cron__task' => $app_db_tableprefix.'cron__task', |
1130 | - 'T_files' => $app_db_tableprefix.'files', |
1131 | - 'T_filetypes' => $app_db_tableprefix.'filetypes', |
1132 | - 'T_groups' => $app_db_tableprefix.'groups', |
1133 | - 'T_global__cache' => $app_db_tableprefix.'global__cache', |
1134 | - 'T_items__item' => $app_db_tableprefix.'items__item', |
1135 | - 'T_items__itemtag' => $app_db_tableprefix.'items__itemtag', |
1136 | - 'T_items__prerendering' => $app_db_tableprefix.'items__prerendering', |
1137 | - 'T_items__status' => $app_db_tableprefix.'items__status', |
1138 | - 'T_items__tag' => $app_db_tableprefix.'items__tag', |
1139 | - 'T_items__type' => $app_db_tableprefix.'items__type', |
1140 | - 'T_items__version' => $app_db_tableprefix.'items__version', |
1141 | - 'T_links' => $app_db_tableprefix.'links', |
1142 | - 'T_locales' => $app_db_tableprefix.'locales', |
1143 | - 'T_plugins' => $app_db_tableprefix.'plugins', |
1144 | - 'T_pluginevents' => $app_db_tableprefix.'pluginevents', |
1145 | - 'T_pluginsettings' => $app_db_tableprefix.'pluginsettings', |
1146 | - 'T_pluginusersettings' => $app_db_tableprefix.'pluginusersettings', |
1147 | - 'T_postcats' => $app_db_tableprefix.'postcats', |
1148 | - 'T_settings' => $app_db_tableprefix.'settings', |
1149 | + 'T_antispam' => $app_db_tableprefix.'antispam', |
1150 | + 'T_blogs' => $app_db_tableprefix.'blogs', |
1151 | + 'T_categories' => $app_db_tableprefix.'categories', |
1152 | + 'T_coll_group_perms' => $app_db_tableprefix.'bloggroups', |
1153 | + 'T_coll_user_perms' => $app_db_tableprefix.'blogusers', |
1154 | + 'T_comments' => $app_db_tableprefix.'comments', |
1155 | + 'T_cron__log' => $app_db_tableprefix.'cron__log', |
1156 | + 'T_cron__task' => $app_db_tableprefix.'cron__task', |
1157 | + 'T_files' => $app_db_tableprefix.'files', |
1158 | + 'T_filetypes' => $app_db_tableprefix.'filetypes', |
1159 | + 'T_groups' => $app_db_tableprefix.'groups', |
1160 | + 'T_global__cache' => $app_db_tableprefix.'global__cache', |
1161 | + 'T_items__prerendering' => $app_db_tableprefix.'items__prerendering', |
1162 | + 'T_items__status' => $app_db_tableprefix.'items__status', |
1163 | + 'T_items__version' => $app_db_tableprefix.'items__version', |
1164 | + 'T_links' => $app_db_tableprefix.'links', |
1165 | + 'T_locales' => $app_db_tableprefix.'locales', |
1166 | + 'T_plugins' => $app_db_tableprefix.'plugins', |
1167 | + 'T_pluginevents' => $app_db_tableprefix.'pluginevents', |
1168 | + 'T_pluginsettings' => $app_db_tableprefix.'pluginsettings', |
1169 | + 'T_pluginusersettings' => $app_db_tableprefix.'pluginusersettings', |
1170 | + 'T_settings' => $app_db_tableprefix.'settings', |
1171 | 'T_templates__container' => $app_db_tableprefix.'templates__container', |
1172 | - 'T_templates__template' => $app_db_tableprefix.'templates__template', |
1173 | - 'T_subscriptions' => $app_db_tableprefix.'subscriptions', |
1174 | - 'T_users' => $app_db_tableprefix.'users', |
1175 | - 'T_plugin_sharedfields' => $app_db_tableprefix.'plugin_sharedfields', |
1176 | - 'T_plugin_sharedvalues' => $app_db_tableprefix.'plugin_sharedvalues', |
1177 | - 'T_usersettings' => $app_db_tableprefix.'usersettings', |
1178 | - 'T_widget' => $app_db_tableprefix.'widget', |
1179 | + 'T_templates__template' => $app_db_tableprefix.'templates__template', |
1180 | + 'T_subscriptions' => $app_db_tableprefix.'subscriptions', |
1181 | + 'T_users' => $app_db_tableprefix.'users', |
1182 | + 'T_plugin_sharedfields' => $app_db_tableprefix.'plugin_sharedfields', |
1183 | + 'T_plugin_sharedvalues' => $app_db_tableprefix.'plugin_sharedvalues', |
1184 | + 'T_usersettings' => $app_db_tableprefix.'usersettings', |
1185 | + 'T_widget' => $app_db_tableprefix.'widget', |
1186 | + // old ones that leave after monster branch is done |
1187 | + 'T_blog_settings' => $app_db_tableprefix.'coll_settings', |
1188 | + 'T_coll_settings' => $app_db_tableprefix.'coll_settings', // old |
1189 | + 'T_items' => $app_db_tableprefix.'items__item', |
1190 | + 'T_items__item' => $app_db_tableprefix.'items__item', // old |
1191 | + 'T_item_cats' => $app_db_tableprefix.'postcats', |
1192 | + 'T_postcats' => $app_db_tableprefix.'postcats', // old |
1193 | + 'T_item_types' => $app_db_tableprefix.'items__type', |
1194 | + 'T_items__type' => $app_db_tableprefix.'items__type', // old |
1195 | + 'T_item_tags' => $app_db_tableprefix.'items__itemtag', |
1196 | + 'T_items__itemtag' => $app_db_tableprefix.'items__itemtag', // old |
1197 | + 'T_tags' => $app_db_tableprefix.'items__tag', |
1198 | + 'T_items__tag' => $app_db_tableprefix.'items__tag', // old |
1199 | ); |
1200 | |
1201 | // Controller mappings |
1202 | $ctrl_mappings = array( |
1203 | - 'antispam' => 'antispam/list.ctrl.php', |
1204 | - 'aspm_distro' => 'antispam/distribute.ctrl.php', |
1205 | + 'antispam' => 'antispam/list.ctrl.php', |
1206 | + 'aspm_distro' => 'antispam/distribute.ctrl.php', |
1207 | 'aspm_settings' => 'antispam/settings.ctrl.php', |
1208 | - 'chapters' => 'chapters/chapters.ctrl.php', |
1209 | - 'collections' => 'collections/collections.ctrl.php', |
1210 | - 'coll_settings' => 'collections/coll_settings.ctrl.php', // old |
1211 | - 'blog_settings' => 'collections/coll_settings.ctrl.php', // new after monster |
1212 | - 'comments' => 'comments/_comments.ctrl.php', |
1213 | - 'crontab' => 'cron/cronjobs.ctrl.php', |
1214 | - 'dashboard' => 'dashboard/dashboard.ctrl.php', |
1215 | - 'features' => 'settings/features.ctrl.php', |
1216 | - 'files' => 'files/files.ctrl.php', |
1217 | - 'fileset' => 'files/file_settings.ctrl.php', |
1218 | - 'filetypes' => 'files/file_types.ctrl.php', |
1219 | - 'items' => 'items/items.ctrl.php', |
1220 | - 'itemstatuses' => 'items/item_statuses.ctrl.php', |
1221 | - 'itemtypes' => 'items/item_types.ctrl.php', |
1222 | - 'locales' => 'locales/locales.ctrl.php', |
1223 | - 'plugins' => 'plugins/plugins.ctrl.php', |
1224 | - 'settings' => 'settings/settings.ctrl.php', |
1225 | - 'templates' => 'templates/templates.ctrl.php', |
1226 | - 'stats' => 'sessions/stats.ctrl.php', |
1227 | - 'system' => 'tools/system.ctrl.php', |
1228 | - 'tools' => 'tools/tools.ctrl.php', |
1229 | - 'users' => 'users/users.ctrl.php', |
1230 | - 'upload' => 'files/upload.ctrl.php', |
1231 | - 'widgets' => 'widgets/widgets.ctrl.php', |
1232 | + 'blogs' => 'blogs/blogs.ctrl.php', |
1233 | + 'blog_settings' => 'blogs/blog_settings.ctrl.php', |
1234 | + 'cats' => 'categories/categories.ctrl.php', |
1235 | + 'comments' => 'comments/_comments.ctrl.php', |
1236 | + 'crontab' => 'cron/cronjobs.ctrl.php', |
1237 | + 'dashboard' => 'dashboard/dashboard.ctrl.php', |
1238 | + 'features' => 'settings/features.ctrl.php', |
1239 | + 'files' => 'files/files.ctrl.php', |
1240 | + 'fileset' => 'files/file_settings.ctrl.php', |
1241 | + 'filetypes' => 'files/file_types.ctrl.php', |
1242 | + 'items' => 'items/items.ctrl.php', |
1243 | + 'itemstatuses' => 'items/item_statuses.ctrl.php', |
1244 | + 'itemtypes' => 'items/item_types.ctrl.php', |
1245 | + 'locales' => 'locales/locales.ctrl.php', |
1246 | + 'plugins' => 'plugins/plugins.ctrl.php', |
1247 | + 'settings' => 'settings/settings.ctrl.php', |
1248 | + 'templates' => 'templates/templates.ctrl.php', |
1249 | + 'stats' => 'sessions/stats.ctrl.php', |
1250 | + 'system' => 'tools/system.ctrl.php', |
1251 | + 'tools' => 'tools/tools.ctrl.php', |
1252 | + 'users' => 'users/users.ctrl.php', |
1253 | + 'upload' => 'files/upload.ctrl.php', |
1254 | + 'widgets' => 'widgets/widgets.ctrl.php', |
1255 | ); |
1256 | |
1257 | /** |
1258 | @@ -253,15 +259,15 @@ |
1259 | if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) ) |
1260 | { |
1261 | // current user has blog settings permissions |
1262 | - $coll_chapters_perm = $current_User->check_perm( 'blog_cats', '', false, $blog ); |
1263 | - $blogsets_url = $admin_url.'?ctrl=coll_settings&blog='.$blog_id.'&'; |
1264 | + $blog_cats_perm = $current_User->check_perm( 'blog_cats', '', false, $blog ); |
1265 | + $blogsets_url = $admin_url.'?ctrl=blog_settings&blog='.$blog_id.'&'; |
1266 | |
1267 | if( $blog_props_perm ) |
1268 | { |
1269 | // current user has some perms in a blog |
1270 | $entries['blog_settings']['text'] = T_('Blog settings').' ◊'; |
1271 | $entries['blog_settings']['title'] = T_('Blog settings, lists blogs'); |
1272 | - $entries['blog_settings']['href'] = $admin_url.'?ctrl=collections'; |
1273 | + $entries['blog_settings']['href'] = $admin_url.'?ctrl=blogs'; |
1274 | $entries['blog_settings']['disabled'] = false; |
1275 | $entries['blog_settings']['entries'] = array( |
1276 | 'bloglabel' => array( |
1277 | @@ -290,13 +296,13 @@ |
1278 | ), |
1279 | ); |
1280 | } |
1281 | - if( $coll_chapters_perm ) |
1282 | + if( $blog_cats_perm ) |
1283 | { |
1284 | // current user has categories permissions in this blog |
1285 | $entries['blog_settings']['entries'] += array( |
1286 | 'chapters' => array( |
1287 | 'text' => T_('Categories').'…', |
1288 | - 'href' => $admin_url.'?ctrl=chapters&blog='.$blog_id, |
1289 | + 'href' => $admin_url.'?ctrl=cats&blog='.$blog_id, |
1290 | ), |
1291 | ); |
1292 | } |
1293 | @@ -348,7 +354,7 @@ |
1294 | // current user can edit/create blogs |
1295 | $entries['dashboard']['entries']['newblog'] = array( |
1296 | 'text' => T_('Create new blog').'…', |
1297 | - 'href' => $admin_url.'?ctrl=collections&action=new', |
1298 | + 'href' => $admin_url.'?ctrl=blogs&action=new', |
1299 | ); |
1300 | } |
1301 | $entries['dashboard']['entries']['templates'] = array( |
1302 | @@ -639,7 +645,7 @@ |
1303 | $entries['tools']['entries']['newblog_sep'] = array( 'separator' => true ); |
1304 | $entries['tools']['entries']['newblog'] = array( |
1305 | 'text' => T_('Create new blog').'…', |
1306 | - 'href' => $admin_url.'?ctrl=collections&action=new', |
1307 | + 'href' => $admin_url.'?ctrl=blogs&action=new', |
1308 | ); |
1309 | } |
1310 | } |
1311 | @@ -871,7 +877,7 @@ |
1312 | global $loc_transinfo; |
1313 | |
1314 | // BLOG SETTINGS: |
1315 | - if( $ctrl == 'collections' ) |
1316 | + if( $ctrl == 'blogs' ) |
1317 | { |
1318 | // We are viewing the blog list, nothing fancy involved: |
1319 | $AdminUI->add_menu_entries( |
1320 | @@ -879,7 +885,7 @@ |
1321 | array( |
1322 | 'blogs' => array( |
1323 | 'text' => T_('Blog settings'), |
1324 | - 'href' => $dispatcher.'?ctrl=collections', |
1325 | + 'href' => $dispatcher.'?ctrl=blogs', |
1326 | ), |
1327 | ) |
1328 | ); |
1329 | @@ -891,23 +897,23 @@ |
1330 | |
1331 | // What perms do we have? |
1332 | $blog_props_perm = $current_User->check_perm( 'blog_properties', 'any', false, $blog ); |
1333 | - $coll_chapters_perm = $current_User->check_perm( 'blog_cats', '', false, $blog ); |
1334 | + $blog_cats_perm = $current_User->check_perm( 'blog_cats', '', false, $blog ); |
1335 | |
1336 | // Determine default page based on permissions: |
1337 | if( $blog_props_perm ) |
1338 | { |
1339 | // Default: show General Blog Settings |
1340 | - $default_page = $dispatcher.'?ctrl=coll_settings&tab=general&blog='.$blog; |
1341 | + $default_page = $dispatcher.'?ctrl=blog_settings&tab=general&blog='.$blog; |
1342 | } |
1343 | - elseif( $coll_chapters_perm ) |
1344 | + elseif( $blog_cats_perm ) |
1345 | { |
1346 | // Default: show categories |
1347 | - $default_page = $dispatcher.'?ctrl=chapters&blog='.$blog; |
1348 | + $default_page = $dispatcher.'?ctrl=cats&blog='.$blog; |
1349 | } |
1350 | else |
1351 | { |
1352 | // Default: Show list of blogs |
1353 | - $default_page = $dispatcher.'?ctrl=collections'; |
1354 | + $default_page = $dispatcher.'?ctrl=blogs'; |
1355 | } |
1356 | |
1357 | $AdminUI->add_menu_entries( |
1358 | @@ -926,30 +932,35 @@ |
1359 | array( |
1360 | 'general' => array( |
1361 | 'text' => T_('General'), |
1362 | - 'href' => $dispatcher.'?ctrl=coll_settings&tab=general&blog='.$blog, ), |
1363 | + 'href' => $dispatcher.'?ctrl=blog_settings&tab=general&blog='.$blog |
1364 | + ), |
1365 | 'features' => array( |
1366 | 'text' => T_('Features'), |
1367 | - 'href' => $dispatcher.'?ctrl=coll_settings&tab=features&blog='.$blog, ), |
1368 | + 'href' => $dispatcher.'?ctrl=blog_settings&tab=features&blog='.$blog |
1369 | + ), |
1370 | 'template' => array( |
1371 | 'text' => T_('Template'), |
1372 | - 'href' => $dispatcher.'?ctrl=coll_settings&tab=template&blog='.$blog, ), |
1373 | + 'href' => $dispatcher.'?ctrl=blog_settings&tab=template&blog='.$blog |
1374 | + ), |
1375 | 'plugin_settings' => array( |
1376 | 'text' => T_('Plugin settings'), |
1377 | - 'href' => $dispatcher.'?ctrl=coll_settings&tab=plugin_settings&blog='.$blog, ), |
1378 | + 'href' => $dispatcher.'?ctrl=blog_settings&tab=plugin_settings&blog='.$blog |
1379 | + ), |
1380 | 'widgets' => array( |
1381 | 'text' => T_('Widgets'), |
1382 | - 'href' => $dispatcher.'?ctrl=widgets&blog='.$blog, ), |
1383 | + 'href' => $dispatcher.'?ctrl=widgets&blog='.$blog |
1384 | + ), |
1385 | ) |
1386 | ); |
1387 | } |
1388 | |
1389 | - if( $coll_chapters_perm ) |
1390 | + if( $blog_cats_perm ) |
1391 | { |
1392 | $AdminUI->add_menu_entries( 'blogs', |
1393 | array( |
1394 | 'chapters' => array( |
1395 | 'text' => T_('Categories'), |
1396 | - 'href' => $dispatcher.'?ctrl=chapters&blog='.$blog |
1397 | + 'href' => $dispatcher.'?ctrl=cats&blog='.$blog |
1398 | ), |
1399 | ) |
1400 | ); |
1401 | @@ -961,7 +972,8 @@ |
1402 | array( |
1403 | 'urls' => array( |
1404 | 'text' => T_('URLs'), |
1405 | - 'href' => $dispatcher.'?ctrl=coll_settings&tab=urls&blog='.$blog, ), |
1406 | + 'href' => $dispatcher.'?ctrl=blog_settings&tab=urls&blog='.$blog |
1407 | + ), |
1408 | ) |
1409 | ); |
1410 | |
1411 | @@ -970,11 +982,13 @@ |
1412 | $AdminUI->add_menu_entries( 'blogs', |
1413 | array( |
1414 | 'perm' => array( |
1415 | - 'text' => T_('User perms'), // keep label short |
1416 | - 'href' => $dispatcher.'?ctrl=coll_settings&tab=perm&blog='.$blog, ), |
1417 | + 'text' => T_('User perms'), |
1418 | + 'href' => $dispatcher.'?ctrl=blog_settings&tab=perm&blog='.$blog |
1419 | + ), |
1420 | 'permgroup' => array( |
1421 | - 'text' => T_('Group perms'), // keep label short |
1422 | - 'href' => $dispatcher.'?ctrl=coll_settings&tab=permgroup&blog='.$blog, ), |
1423 | + 'text' => T_('Group perms'), |
1424 | + 'href' => $dispatcher.'?ctrl=blog_settings&tab=permgroup&blog='.$blog |
1425 | + ), |
1426 | ) |
1427 | ); |
1428 | } |
1429 | |
1430 | === added file 'qp_inc/_core/_class.funcs.php' |
1431 | --- qp_inc/_core/_class.funcs.php 1970-01-01 00:00:00 +0000 |
1432 | +++ qp_inc/_core/_class.funcs.php 2013-03-14 18:35:26 +0000 |
1433 | @@ -0,0 +1,151 @@ |
1434 | +<?php |
1435 | +/** |
1436 | + * Function for handling Classes in PHP5 |
1437 | + * |
1438 | + * @author {@link http://wonderwinds.com/ Ed Bennett} |
1439 | + * @author {@link http://daniel.hahler.de/ Daniel HAHLER} |
1440 | + * @author {@link http://fplanque.net/ Francois PLANQUE} |
1441 | + * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project} |
1442 | + * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 |
1443 | + * @package core |
1444 | + */ |
1445 | +if(!defined('QP_MAIN_INIT')) die('fail'); |
1446 | + |
1447 | +/** |
1448 | + * Autoload the required .class.php file |
1449 | + * |
1450 | + * Autoload the required .class.php file when a class is accessed but not defined yet. |
1451 | + * This gets hooked into spl_autoload_register (preferred) or called through __autoload. |
1452 | + */ |
1453 | +function autoload_class( $classname ) |
1454 | +{ |
1455 | + static $map_class_path; |
1456 | + |
1457 | + if( ! isset( $map_class_path ) ) |
1458 | + { |
1459 | + global $admintemplates_path; |
1460 | + global $inc_path; |
1461 | + |
1462 | + $_map_class_path = array( |
1463 | + 'abstractsettings' => $inc_path.'settings/model/_abstractsettings.class.php', |
1464 | + 'adminui' => $admintemplates_path.'/wind/_adminUI.class.php', |
1465 | + 'adminui_general' => $admintemplates_path.'/_adminUI_general.class.php', |
1466 | + 'blog' => $inc_path.'blogs/model/_blog.class.php', |
1467 | + 'blogcache' => $inc_path.'blogs/model/_blog_cache.class.php', |
1468 | + 'blogsettings' => $inc_path.'blogs/model/_blog_settings.class.php', |
1469 | + 'chapter' => $inc_path.'categories/model/_category.class.php', |
1470 | + 'categorycache' => $inc_path.'categories/model/_categorycache.class.php', |
1471 | + 'comment' => $inc_path.'comments/model/_comment.class.php', |
1472 | + 'commentlist' => $inc_path.'comments/model/_commentlist.class.php', |
1473 | + 'componentwidget' => $inc_path.'widgets/model/_widget.class.php', |
1474 | + 'cronjob' => $inc_path.'cron/model/_cronjob.class.php', |
1475 | + 'dataobject' => $inc_path.'_core/model/dataobjects/_dataobject.class.php', |
1476 | + 'dataobjectcache' => $inc_path.'_core/model/dataobjects/_dataobjectcache.class.php', |
1477 | + 'dataobjectlist' => $inc_path.'_core/model/dataobjects/_dataobjectlist.class.php', |
1478 | + 'dataobjectlist2' => $inc_path.'_core/model/dataobjects/_dataobjectlist2.class.php', |
1479 | + 'db' => $inc_path.'_core/model/db/_db.class.php', |
1480 | + 'file' => $inc_path.'files/model/_file.class.php', |
1481 | + 'filecache' => $inc_path.'files/model/_filecache.class.php', |
1482 | + 'filelist' => $inc_path.'files/model/_filelist.class.php', |
1483 | + 'fileroot' => $inc_path.'files/model/_fileroot.class.php', |
1484 | + 'filerootcache' => $inc_path.'files/model/_filerootcache.class.php', |
1485 | + 'filetype' => $inc_path.'files/model/_filetype.class.php', |
1486 | + 'filetypecache' => $inc_path.'files/model/_filetypecache.class.php', |
1487 | + 'form' => $inc_path.'_core/ui/forms/_form.class.php', |
1488 | + 'generalsettings' => $inc_path.'settings/model/_generalsettings.class.php', |
1489 | + 'genericcache' => $inc_path.'generic/model/_genericcache.class.php', |
1490 | + 'genericcategory' => $inc_path.'generic/model/_genericcategory.class.php', |
1491 | + 'genericcategorycache' => $inc_path.'generic/model/_genericcategorycache.class.php', |
1492 | + 'genericelement' => $inc_path.'generic/model/_genericelement.class.php', |
1493 | + 'genericordered' => $inc_path.'generic/model/_genericordered.class.php', |
1494 | + 'genericorderedcache' => $inc_path.'generic/model/_genericorderedcache.class.php', |
1495 | + 'goal' => $inc_path.'sessions/model/_goal.class.php', |
1496 | + 'group' => $inc_path.'users/model/_group.class.php', |
1497 | + 'hit' => $inc_path.'sessions/model/_hit.class.php', |
1498 | + 'hitlist' => $inc_path.'sessions/model/_hitlist.class.php', |
1499 | + 'iconlegend' => $inc_path.'_core/ui/_iconlegend.class.php', |
1500 | + 'idna_convert' => $inc_path.'_ext/idna/_idna_convert.class.php', |
1501 | + 'item' => $inc_path.'items/model/_item.class.php', |
1502 | + 'itemcache' => $inc_path.'items/model/_itemcache.class.php', |
1503 | + 'itemlight' => $inc_path.'items/model/_itemlight.class.php', |
1504 | + 'itemlist2' => $inc_path.'items/model/_itemlist.class.php', |
1505 | + 'itemlistlight' => $inc_path.'items/model/_itemlistlight.class.php', |
1506 | + 'itemquery' => $inc_path.'items/model/_itemquery.class.php', |
1507 | + 'itemtype' => $inc_path.'items/model/_itemtype.class.php', |
1508 | + 'itemtypecache' => $inc_path.'items/model/_itemtypecache.class.php', |
1509 | + 'link' => $inc_path.'items/model/_link.class.php', |
1510 | + 'linkcache' => $inc_path.'items/model/_linkcache.class.php', |
1511 | + 'log' => $inc_path.'_core/model/_log.class.php', |
1512 | + 'log_noop' => $inc_path.'_core/model/_log.class.php', |
1513 | + 'menu' => $inc_path.'_core/ui/_menu.class.php', |
1514 | + 'mime_parser_class' => $inc_path.'_ext/mime_parser/mime_parser.php', |
1515 | + 'pagecache' => $inc_path.'_core/model/_pagecache.class.php', |
1516 | + 'plugin' => $inc_path.'plugins/_plugin.class.php', |
1517 | + 'plugins' => $inc_path.'plugins/model/_plugins.class.php', |
1518 | + 'plugins_admin' => $inc_path.'plugins/model/_plugins_admin.class.php', |
1519 | + 'plugins_admin_no_db' => $inc_path.'plugins/model/_plugins_admin_no_db.class.php', |
1520 | + 'pluginsettings' => $inc_path.'plugins/model/_pluginsettings.class.php', |
1521 | + 'pluginusersettings' => $inc_path.'plugins/model/_pluginusersettings.class.php', |
1522 | + 'pofile' => $inc_path.'locales/_pofile.class.php', |
1523 | + 'potfile' => $inc_path.'locales/_pofile.class.php', |
1524 | + 'results' => $inc_path.'_core/ui/results/_results.class.php', |
1525 | + 'resultsel' => $inc_path.'_core/ui/results/_resultsel.class.php', |
1526 | + 'rfc822_addresses_class' => $inc_path.'_ext/mime_parser/rfc822_addresses.php', |
1527 | + 'session' => $inc_path.'sessions/model/_session.class.php', |
1528 | + 'sql' => $inc_path.'_core/model/db/_sql.class.php', |
1529 | + 'table' => $inc_path.'_core/ui/_uiwidget.class.php', |
1530 | + 'template' => $inc_path.'templates/model/_template.class.php', |
1531 | + 'templatecache' => $inc_path.'templates/model/_templatecache.class.php', |
1532 | + 'timer' => $inc_path.'_core/model/_timer.class.php', |
1533 | + 'user' => $inc_path.'users/model/_user.class.php', |
1534 | + 'usercache' => $inc_path.'users/model/_usercache.class.php', |
1535 | + 'usersettings' => $inc_path.'users/model/_usersettings.class.php', |
1536 | + 'widget' => $inc_path.'_core/ui/_uiwidget.class.php', |
1537 | + 'widgetcache' => $inc_path.'widgets/model/_widgetcache.class.php', |
1538 | + 'xhtml_validator' => $inc_path.'xhtml_validator/_xhtml_validator.class.php', |
1539 | + 'zip_file' => $inc_path.'_ext/_zip_archives.php', |
1540 | + ); |
1541 | + $map_class_path = $_map_class_path; |
1542 | + } |
1543 | + |
1544 | + $classname = strtolower( $classname ); |
1545 | + if( isset( $map_class_path[$classname] ) ) |
1546 | + { |
1547 | + require_once $map_class_path[$classname]; |
1548 | + } |
1549 | +} |
1550 | + |
1551 | + |
1552 | +/** |
1553 | + * Use spl_autoload_register mechanism |
1554 | + * |
1555 | + * This way several autoload functions can be used (PHP>=5.1.2). |
1556 | + */ |
1557 | +if( function_exists( 'spl_autoload_register' ) ) |
1558 | +{ |
1559 | + spl_autoload_register( 'autoload_class' ); |
1560 | +} |
1561 | +else |
1562 | +{ |
1563 | + /** |
1564 | + * PHP<5.1.2: Use the fallback method |
1565 | + * |
1566 | + * @deprecated - quam plures requires 5.2 or higher |
1567 | + */ |
1568 | + function __autoload( $classname ) |
1569 | + { |
1570 | + return autoload_class( $classname ); |
1571 | + } |
1572 | +} |
1573 | + |
1574 | +/** |
1575 | + * Load class file. No-op for PHP5, uses __autoload(). |
1576 | + * |
1577 | + * @deprecated - after "monster" all the load_class() calls will be removed |
1578 | + */ |
1579 | +function load_class( $class_path ) |
1580 | +{ |
1581 | + return true; |
1582 | +} |
1583 | + |
1584 | +?> |
1585 | |
1586 | === removed file 'qp_inc/_core/_class4.funcs.php' |
1587 | --- qp_inc/_core/_class4.funcs.php 2010-12-31 12:12:03 +0000 |
1588 | +++ qp_inc/_core/_class4.funcs.php 1970-01-01 00:00:00 +0000 |
1589 | @@ -1,40 +0,0 @@ |
1590 | -<?php |
1591 | -/** |
1592 | - * Function for handling Classes in PHP 4. |
1593 | - * |
1594 | - * In PHP5, _class5.funcs.php should be used instead. |
1595 | - * |
1596 | - * This file is part of Quam Plures - {@link http://quamplures.net/} |
1597 | - * See also {@link https://launchpad.net/quam-plures}. |
1598 | - * |
1599 | - * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/} |
1600 | - * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/} |
1601 | - * |
1602 | - * {@internal License choice |
1603 | - * - If you have received this file as part of a package, please find the license.txt file in |
1604 | - * the same folder or the closest folder above for complete license terms. |
1605 | - * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) |
1606 | - * then you must choose one of the following licenses before using the file: |
1607 | - * - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php |
1608 | - * - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php |
1609 | - * }} |
1610 | - * |
1611 | - * @author fplanque: Francois PLANQUE |
1612 | - * |
1613 | - * @package pond |
1614 | - */ |
1615 | -if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); |
1616 | - |
1617 | - |
1618 | -/** |
1619 | - * Load class file |
1620 | - */ |
1621 | -function load_class( $class_path ) |
1622 | -{ |
1623 | - global $inc_path; |
1624 | - require_once $inc_path.$class_path; |
1625 | - return true; |
1626 | -} |
1627 | - |
1628 | - |
1629 | -?> |
1630 | \ No newline at end of file |
1631 | |
1632 | === removed file 'qp_inc/_core/_class5.funcs.php' |
1633 | --- qp_inc/_core/_class5.funcs.php 2011-01-09 02:10:50 +0000 |
1634 | +++ qp_inc/_core/_class5.funcs.php 1970-01-01 00:00:00 +0000 |
1635 | @@ -1,175 +0,0 @@ |
1636 | -<?php |
1637 | -/** |
1638 | - * Function for handling Classes in PHP 5. |
1639 | - * |
1640 | - * In PHP4, _class4.funcs.php should be used instead. |
1641 | - * |
1642 | - * This file is part of Quam Plures - {@link http://quamplures.net/} |
1643 | - * See also {@link https://launchpad.net/quam-plures}. |
1644 | - * |
1645 | - * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/} |
1646 | - * @copyright (c)2009 by Francois PLANQUE - {@link http://fplanque.net/} |
1647 | - * Parts of this file are copyright (c)2009 by Daniel HAHLER - {@link http://daniel.hahler.de/}. |
1648 | - * |
1649 | - * {@internal License choice |
1650 | - * - If you have received this file as part of a package, please find the license.txt file in |
1651 | - * the same folder or the closest folder above for complete license terms. |
1652 | - * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) |
1653 | - * then you must choose one of the following licenses before using the file: |
1654 | - * - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php |
1655 | - * - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php |
1656 | - * }} |
1657 | - * |
1658 | - * {@internal Open Source relicensing agreement: |
1659 | - * Daniel HAHLER grants Francois PLANQUE the right to license |
1660 | - * Daniel HAHLER's contributions to this file and the b2evolution project |
1661 | - * under any OSI approved OSS license (http://www.opensource.org/licenses/). |
1662 | - * }} |
1663 | - * |
1664 | - * @author blueyed: Daniel HAHLER. |
1665 | - * |
1666 | - * @package pond |
1667 | - */ |
1668 | -if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); |
1669 | - |
1670 | - |
1671 | -/** |
1672 | - * Autoload the required .class.php file when a class is accessed but not defined yet. |
1673 | - * This gets hooked into spl_autoload_register (preferred) or called through __autoload. |
1674 | - * Requires PHP5. |
1675 | - */ |
1676 | -function evocms_autoload_class( $classname ) |
1677 | -{ |
1678 | - static $map_class_path; |
1679 | - |
1680 | - /* |
1681 | - List generated with (executed in ./blogs): |
1682 | - for i in $(find . -name \*.class.php -o -name \*.widget.php); do echo "'$(basename $i .php | tr '[:upper:'] '[:lower:'] | sed 's/.widget$/_widget/; s/.class$//; s/^_//; s/^collsettings$/collectionsettings/; s/^itemlist$/itemlist2/; s/^widget$/componentwidget/; s/^uiwidget$/widget/')' => $(echo $i|sed "s~^./qp_inc/~\$inc_path.'~;s~^./qp_view_admin/~\$admintemplates_path.'/~")',"; done |
1683 | - */ |
1684 | - if( ! isset($map_class_path) ) |
1685 | - { |
1686 | - global $inc_path, $admintemplates_path; |
1687 | - $_map_class_path = array( |
1688 | - /* SPECIAL: several classes in one file. */ |
1689 | - 'table' => $inc_path.'_core/ui/_uiwidget.class.php', |
1690 | - 'log_noop' => $inc_path.'_core/model/_log.class.php', |
1691 | - 'zip_file' => $inc_path.'_ext/_zip_archives.php', |
1692 | - 'potfile' => $inc_path.'locales/_pofile.class.php', |
1693 | - /* SPECIAL END */ |
1694 | - |
1695 | - /* AUTOGENERATED LIST: */ |
1696 | - 'commentlist' => $inc_path.'comments/model/_commentlist.class.php', |
1697 | - 'comment' => $inc_path.'comments/model/_comment.class.php', |
1698 | - 'template' => $inc_path.'templates/model/_template.class.php', |
1699 | - 'templatecache' => $inc_path.'templates/model/_templatecache.class.php', |
1700 | - 'iconlegend' => $inc_path.'_core/ui/_iconlegend.class.php', |
1701 | - 'form' => $inc_path.'_core/ui/forms/_form.class.php', |
1702 | - 'resultsel' => $inc_path.'_core/ui/results/_resultsel.class.php', |
1703 | - 'results' => $inc_path.'_core/ui/results/_results.class.php', |
1704 | - 'widget' => $inc_path.'_core/ui/_uiwidget.class.php', |
1705 | - 'pagecache' => $inc_path.'_core/model/_pagecache.class.php', |
1706 | - 'dataobjectcache' => $inc_path.'_core/model/dataobjects/_dataobjectcache.class.php', |
1707 | - 'dataobjectlist' => $inc_path.'_core/model/dataobjects/_dataobjectlist.class.php', |
1708 | - 'dataobjectlist2' => $inc_path.'_core/model/dataobjects/_dataobjectlist2.class.php', |
1709 | - 'dataobject' => $inc_path.'_core/model/dataobjects/_dataobject.class.php', |
1710 | - 'timer' => $inc_path.'_core/model/_timer.class.php', |
1711 | - 'log' => $inc_path.'_core/model/_log.class.php', |
1712 | - 'sql' => $inc_path.'_core/model/db/_sql.class.php', |
1713 | - 'db' => $inc_path.'_core/model/db/_db.class.php', |
1714 | - 'filetype' => $inc_path.'files/model/_filetype.class.php', |
1715 | - 'filetypecache' => $inc_path.'files/model/_filetypecache.class.php', |
1716 | - 'filerootcache' => $inc_path.'files/model/_filerootcache.class.php', |
1717 | - 'file' => $inc_path.'files/model/_file.class.php', |
1718 | - 'filecache' => $inc_path.'files/model/_filecache.class.php', |
1719 | - 'filelist' => $inc_path.'files/model/_filelist.class.php', |
1720 | - 'fileroot' => $inc_path.'files/model/_fileroot.class.php', |
1721 | - 'widgetcache' => $inc_path.'widgets/model/_widgetcache.class.php', |
1722 | - 'componentwidget' => $inc_path.'widgets/model/_widget.class.php', |
1723 | - 'session' => $inc_path.'sessions/model/_session.class.php', |
1724 | - 'hitlist' => $inc_path.'sessions/model/_hitlist.class.php', |
1725 | - 'hit' => $inc_path.'sessions/model/_hit.class.php', |
1726 | - 'goal' => $inc_path.'sessions/model/_goal.class.php', |
1727 | - 'idna_convert' => $inc_path.'_ext/idna/_idna_convert.class.php', |
1728 | - 'item' => $inc_path.'items/model/_item.class.php', |
1729 | - 'itemlistlight' => $inc_path.'items/model/_itemlistlight.class.php', |
1730 | - 'itemlight' => $inc_path.'items/model/_itemlight.class.php', |
1731 | - 'link' => $inc_path.'items/model/_link.class.php', |
1732 | - 'itemlist2' => $inc_path.'items/model/_itemlist.class.php', |
1733 | - 'itemtype' => $inc_path.'items/model/_itemtype.class.php', |
1734 | - 'itemquery' => $inc_path.'items/model/_itemquery.class.php', |
1735 | - 'linkcache' => $inc_path.'items/model/_linkcache.class.php', |
1736 | - 'itemtypecache' => $inc_path.'items/model/_itemtypecache.class.php', |
1737 | - 'itemcache' => $inc_path.'items/model/_itemcache.class.php', |
1738 | - 'group' => $inc_path.'users/model/_group.class.php', |
1739 | - 'usercache' => $inc_path.'users/model/_usercache.class.php', |
1740 | - 'user' => $inc_path.'users/model/_user.class.php', |
1741 | - 'usersettings' => $inc_path.'users/model/_usersettings.class.php', |
1742 | - 'genericorderedcache' => $inc_path.'generic/model/_genericorderedcache.class.php', |
1743 | - 'genericordered' => $inc_path.'generic/model/_genericordered.class.php', |
1744 | - 'genericcategory' => $inc_path.'generic/model/_genericcategory.class.php', |
1745 | - 'genericcategorycache' => $inc_path.'generic/model/_genericcategorycache.class.php', |
1746 | - 'genericelement' => $inc_path.'generic/model/_genericelement.class.php', |
1747 | - 'genericcache' => $inc_path.'generic/model/_genericcache.class.php', |
1748 | - 'xhtml_validator' => $inc_path.'xhtml_validator/_xhtml_validator.class.php', |
1749 | - 'pofile' => $inc_path.'locales/_pofile.class.php', |
1750 | - 'plugins' => $inc_path.'plugins/model/_plugins.class.php', |
1751 | - 'plugins_admin' => $inc_path.'plugins/model/_plugins_admin.class.php', |
1752 | - 'pluginsettings' => $inc_path.'plugins/model/_pluginsettings.class.php', |
1753 | - 'pluginusersettings' => $inc_path.'plugins/model/_pluginusersettings.class.php', |
1754 | - 'plugins_admin_no_db' => $inc_path.'plugins/model/_plugins_admin_no_db.class.php', |
1755 | - 'plugin' => $inc_path.'plugins/_plugin.class.php', |
1756 | - 'cronjob' => $inc_path.'cron/model/_cronjob.class.php', |
1757 | - 'generalsettings' => $inc_path.'settings/model/_generalsettings.class.php', |
1758 | - 'abstractsettings' => $inc_path.'settings/model/_abstractsettings.class.php', |
1759 | - 'blogcache' => $inc_path.'collections/model/_blogcache.class.php', |
1760 | - 'collectionsettings' => $inc_path.'collections/model/_collsettings.class.php', |
1761 | - 'blog' => $inc_path.'collections/model/_blog.class.php', |
1762 | - 'chaptercache' => $inc_path.'chapters/model/_chaptercache.class.php', |
1763 | - 'chapter' => $inc_path.'chapters/model/_chapter.class.php', |
1764 | - 'adminui_general' => $admintemplates_path.'/_adminUI_general.class.php', |
1765 | - 'adminui' => $admintemplates_path.'/wind/_adminUI.class.php', |
1766 | - 'menu' => $inc_path.'_core/ui/_menu.class.php', |
1767 | - 'rfc822_addresses_class' => $inc_path.'_ext/mime_parser/rfc822_addresses.php', |
1768 | - 'mime_parser_class' => $inc_path.'_ext/mime_parser/mime_parser.php', |
1769 | - /* AUTOGENERATED LIST END */ |
1770 | - ); |
1771 | - $map_class_path = $_map_class_path; |
1772 | - } |
1773 | - |
1774 | - $classname = strtolower($classname); |
1775 | - if( isset($map_class_path[$classname]) ) |
1776 | - { |
1777 | - require_once $map_class_path[$classname]; |
1778 | - } |
1779 | -} |
1780 | - |
1781 | - |
1782 | -/* |
1783 | - * Use spl_autoload_register mechanism, if available (PHP>=5.1.2). |
1784 | - * This way, several autoload functions can be used. |
1785 | - */ |
1786 | -if( function_exists('spl_autoload_register') ) |
1787 | -{ |
1788 | - // spl_autoload_register( 'var_dump' ); |
1789 | - spl_autoload_register( 'evocms_autoload_class' ); |
1790 | -} |
1791 | -else |
1792 | -{ |
1793 | - // PHP<5.1.2: Use the fallback method. |
1794 | - function __autoload( $classname ) |
1795 | - { |
1796 | - return evocms_autoload_class($classname); |
1797 | - } |
1798 | -} |
1799 | - |
1800 | - |
1801 | -/** |
1802 | - * Load class file. No-op for PHP5, uses __autoload(). |
1803 | - */ |
1804 | -function load_class( $class_path ) |
1805 | -{ |
1806 | - return true; |
1807 | -} |
1808 | - |
1809 | - |
1810 | -?> |
1811 | |
1812 | === modified file 'qp_inc/_core/_misc.funcs.php' |
1813 | --- qp_inc/_core/_misc.funcs.php 2013-02-28 16:40:18 +0000 |
1814 | +++ qp_inc/_core/_misc.funcs.php 2013-03-14 18:35:26 +0000 |
1815 | @@ -2,7 +2,7 @@ |
1816 | /** |
1817 | * This file implements general purpose functions |
1818 | * |
1819 | - * @todo (0000): dh> Refactor into smaller chunks/files. We should avoid using a |
1820 | + * @todo (0000) dh> Refactor into smaller chunks/files. We should avoid using a |
1821 | * "huge" misc early! |
1822 | * - _debug.funcs.php |
1823 | * - _formatting.funcs.php |
1824 | @@ -10,6 +10,8 @@ |
1825 | * - ? |
1826 | * |
1827 | * @author {@link http://wonderwinds.com/ Ed Bennett} |
1828 | + * @author {@link http://astonishme.co.uk/ Yabba (Paul Jones, rest in peace)} |
1829 | + * @author {@link http://ax86.net/ Tilman BLUMENBACH} |
1830 | * @author {@link http://progidistri.com/ PROGIDISTRI} |
1831 | * @author {@link http://daniel.hahler.de/ Daniel HAHLER} |
1832 | * @author {@link http://funky-m.com/ Vegar BERG GULDAL} |
1833 | @@ -41,9 +43,9 @@ |
1834 | } |
1835 | |
1836 | /** |
1837 | - * Get a cache reference. |
1838 | + * Get a cache reference |
1839 | * |
1840 | - * @todo fp> split into 1 function per case. (typed @return values) |
1841 | + * @todo (0000) fp> split into 1 function per case. (typed @return values) |
1842 | * @param string The cache to get (see source code for possible names). |
1843 | * @return mixed The requested cache (debug_die()s on invalid cache name). |
1844 | */ |
1845 | @@ -64,9 +66,9 @@ |
1846 | $BlogCache = new BlogCache(); // COPY (FUNC) |
1847 | return $BlogCache; |
1848 | |
1849 | - case 'ChapterCache': |
1850 | - $ChapterCache = new ChapterCache(); // COPY (FUNC) |
1851 | - return $ChapterCache; |
1852 | + case 'CategoryCache': |
1853 | + $CategoryCache = new CategoryCache(); // COPY (FUNC) |
1854 | + return $CategoryCache; |
1855 | |
1856 | case 'FileCache': |
1857 | $FileCache = new FileCache(); // COPY (FUNC) |
1858 | @@ -89,7 +91,7 @@ |
1859 | return $GroupCache; |
1860 | |
1861 | case 'ItemCacheLight'; |
1862 | - $ItemCacheLight = new DataObjectCache( 'ItemLight', false, 'T_items__item', 'post_', 'post_ID' ); // COPY (FUNC) |
1863 | + $ItemCacheLight = new DataObjectCache( 'ItemLight', false, 'T_items', 'post_', 'post_ID' ); // COPY (FUNC) |
1864 | return $ItemCacheLight; |
1865 | |
1866 | case 'ItemCache'; |
1867 | @@ -137,11 +139,10 @@ |
1868 | return $WidgetCache; |
1869 | |
1870 | case 'EnabledWidgetCache': |
1871 | - // This simply instantiates a WidgetCache object, setting the |
1872 | - // $enabled_only parameter to true. Using a member variable |
1873 | - // instead of per-method parameters to load only the enabled |
1874 | - // widgets should be cleaner when there will be more methods |
1875 | - // in the WidgetCache class in the future. |
1876 | + // This simply instantiates a WidgetCache object, setting the $enabled_only |
1877 | + // parameter to true. Using a member variable instead of per-method parameters |
1878 | + // to load only the enabled widgets should be cleaner when there will be more |
1879 | + // methods in the WidgetCache class in the future. |
1880 | $EnabledWidgetCache = new WidgetCache( true ); |
1881 | return $EnabledWidgetCache; |
1882 | |
1883 | @@ -163,7 +164,7 @@ |
1884 | |
1885 | |
1886 | /** |
1887 | - * Shutdown function: update session! |
1888 | + * Shutdown function: update session |
1889 | * |
1890 | * This is registered in _main.inc.php with register_shutdown_function() |
1891 | * This is called by PHP at the end of the script. |
1892 | @@ -173,7 +174,7 @@ |
1893 | global $Session; |
1894 | global $Settings; |
1895 | |
1896 | - // fp> do we need special processing if we are in CLI mode? probably earlier actually |
1897 | + // fp> do we need special processing if we are in CLI mode? probably earlier actually |
1898 | // if( ! $is_cli ) |
1899 | // Note: it might be useful at some point to do special processing if the script has been aborted or has timed out |
1900 | // connection_aborted() |
1901 | @@ -182,7 +183,7 @@ |
1902 | // Update the SESSION: |
1903 | $Session->dbsave(); |
1904 | |
1905 | - // Auto pruning of old HITS, old SESSIONS and potentially MORE analytics data: |
1906 | + // Auto pruning of old HITS, old SESSIONS and potentially MORE analytics data |
1907 | if( $Settings->get( 'auto_prune_stats_mode' ) == 'page' ) |
1908 | { |
1909 | // Autopruning is requested |
1910 | @@ -193,18 +194,16 @@ |
1911 | // Then again, it's for debug only, so it shouldn't matter that much. |
1912 | debug_info(); |
1913 | |
1914 | - // Update the SESSION again, at the very end: |
1915 | + // Update the SESSION again, at the very end |
1916 | // (e.g. "Debugslogs" may have been removed in debug_info()) |
1917 | $Session->dbsave(); |
1918 | } |
1919 | |
1920 | |
1921 | -/***** Formatting functions *****/ |
1922 | - |
1923 | /** |
1924 | * Format a string/content for being output |
1925 | * |
1926 | - * @todo (0000): htmlspecialchars() takes a charset argument, which we could provide ( $app_charset? ) |
1927 | + * @todo (0000) htmlspecialchars() takes a charset argument, which we could provide ( $app_charset? ) |
1928 | * @param string raw text |
1929 | * @param string format, can be one of the following |
1930 | * - raw: do nothing |
1931 | @@ -260,7 +259,7 @@ |
1932 | |
1933 | // use as a form value: escapes &, quotes and < > but leaves code alone |
1934 | case 'formvalue': |
1935 | - $content = htmlspecialchars( $content, ENT_QUOTES ); // Handles &, ", ', < and > |
1936 | + $content = htmlspecialchars( $content, ENT_QUOTES ); // Handles &, ", ', < and > |
1937 | break; |
1938 | |
1939 | // use in an XML file: strip HTML tags |
1940 | @@ -298,11 +297,13 @@ |
1941 | /* |
1942 | * autobrize(-) |
1943 | */ |
1944 | -function autobrize( $content ) { |
1945 | +function autobrize( $content ) |
1946 | +{ |
1947 | $content = callback_on_non_matching_blocks( $content, '~<code>.+?</code>~is', 'autobrize_callback' ); |
1948 | return $content; |
1949 | } |
1950 | |
1951 | + |
1952 | /** |
1953 | * Adds <br>'s to non code blocks |
1954 | * @param string $content |
1955 | @@ -316,7 +317,8 @@ |
1956 | return( $content ); |
1957 | } |
1958 | |
1959 | -/* |
1960 | + |
1961 | +/** |
1962 | * unautobrize(-) |
1963 | */ |
1964 | function unautobrize( $content ) |
1965 | @@ -325,20 +327,24 @@ |
1966 | return $content; |
1967 | } |
1968 | |
1969 | + |
1970 | /** |
1971 | * Removes <br>'s from non code blocks |
1972 | + * |
1973 | * @param string $content |
1974 | * @return string content with <br>'s removed |
1975 | */ |
1976 | function unautobrize_callback( $content ) |
1977 | { |
1978 | - $content = preg_replace("/<br>\n/", "\n", $content); //for PHP versions before 4.0.5 |
1979 | - $content = preg_replace("/<br \/>\n/", "\n", $content); |
1980 | + $content = preg_replace( "/<br>\n/", "\n", $content) ; //for PHP versions before 4.0.5 |
1981 | + $content = preg_replace( "/<br \/>\n/", "\n", $content ); |
1982 | return( $content ); |
1983 | } |
1984 | |
1985 | + |
1986 | /** |
1987 | - * Add leading zeroes to a number when necessary. |
1988 | + * Add leading zeroes to a number when necessary |
1989 | + * |
1990 | * @param string The original number. |
1991 | * @param integer How many digits shall the number have? |
1992 | * @return string The padded number. |
1993 | @@ -348,8 +354,10 @@ |
1994 | return str_pad( $number, $threshold, '0', STR_PAD_LEFT ); |
1995 | } |
1996 | |
1997 | + |
1998 | /** |
1999 | - * Crop string to maxlen with … at the end if needed. |
2000 | + * Crop string to maxlen with … at the end if needed |
2001 | + * |
2002 | * @param string |
2003 | * @param int Maximum length |
2004 | * @return string |
2005 | @@ -366,7 +374,8 @@ |
2006 | |
2007 | |
2008 | /** |
2009 | - * Crop string to maxwords preserving tags. |
2010 | + * Crop string to maxwords preserving tags |
2011 | + * |
2012 | * @param string |
2013 | * @param int Maximum number words |
2014 | * @param mixed array Optional parameters |
2015 | @@ -375,9 +384,9 @@ |
2016 | function strmaxwords( $str, $maxwords = 50, $params = array() ) |
2017 | { |
2018 | $params = array_merge( array( |
2019 | - 'continued_link' => '', |
2020 | - 'continued_text' => '…', |
2021 | - 'always_continue' => false, |
2022 | + 'continued_link' => '', |
2023 | + 'continued_text' => '…', |
2024 | + 'always_continue' => false, |
2025 | ), $params ); |
2026 | $open = false; |
2027 | $have_seen_non_whitespace = false; |
2028 | @@ -530,6 +539,7 @@ |
2029 | |
2030 | /** |
2031 | * mbstring wrapper for strlen function |
2032 | + * |
2033 | * @param string |
2034 | * @return string |
2035 | */ |
2036 | @@ -548,6 +558,7 @@ |
2037 | |
2038 | /** |
2039 | * mbstring wrapper for substr function |
2040 | + * |
2041 | * @param string |
2042 | * @param int start position |
2043 | * @param int string length |
2044 | @@ -578,6 +589,7 @@ |
2045 | * gets passed. This gets used to make links clickable or replace smilies. E.g., to replace |
2046 | * only in non-HTML tags, call it like: |
2047 | * <code>callback_on_non_matching_blocks( $text, '~<[^>]*>~s', 'your_callback' );</code> |
2048 | + * |
2049 | * @param string Text to handle |
2050 | * @param string Regular expression pattern that defines blocks to exclude. |
2051 | * @param callback Function name or object/method array to use as callback. |
2052 | @@ -624,11 +636,11 @@ |
2053 | |
2054 | |
2055 | /** |
2056 | - * Make links clickable in a given text. |
2057 | + * Make links clickable in a given text |
2058 | * |
2059 | * It replaces only text which is not between <a> tags already. |
2060 | * |
2061 | - * @todo (0000): dh> this should not replace links in tags! currently fails for |
2062 | + * @todo (0000) dh> this should not replace links in tags! currently fails for |
2063 | * something like '<img src=" http://example.com/" />' (not usual though!). fp> I |
2064 | * am trying to address this by not replacing anything inside tags. This should |
2065 | * be replaced by a clean state machine (one single variable for current state) |
2066 | @@ -766,12 +778,11 @@ |
2067 | /** |
2068 | * Callback function for {@link make_clickable()}. |
2069 | * |
2070 | - * original function: phpBB, extended here for AIM & ICQ |
2071 | - * fplanque restricted :// to http:// and mailto:// |
2072 | - * Fixed to not include trailing dot and comma. |
2073 | + * original function: phpBB, extended here for AIM & ICQ. fplanque restricted :// |
2074 | + * to http:// and mailto://. Fixed to not include trailing dot and comma. |
2075 | * |
2076 | - * fp> I'm thinking of moving this into the autolinks plugin (only place where it's used) |
2077 | - * and break it up into something more systematic. |
2078 | + * fp> I'm thinking of moving this into the autolinks plugin (only place where it's |
2079 | + * used) and break it up into something more systematic. |
2080 | * |
2081 | * @return string The clickable text. |
2082 | */ |
2083 | @@ -779,9 +790,8 @@ |
2084 | { |
2085 | $pattern_domain = '([a-z0-9\-]+\.[a-z0-9\-.\~]+)'; // a domain name (not very strict) |
2086 | $text = preg_replace( |
2087 | - /* Tblue> I removed the double quotes from the first RegExp because |
2088 | - it made URLs in tag attributes clickable. |
2089 | - See http://forums.b2evolution.net/viewtopic.php?p=92073 */ |
2090 | + // Tblue> I removed the double quotes from the first RegExp because |
2091 | + // it made URLs in tag attributes clickable. |
2092 | array( '#(^|[\s>])(https?|mailto)://([^<>{}\s]+[^.,<>{}\s])#i', |
2093 | '#(^|[\s>])aim:([^,<\s]+)#i', |
2094 | '#(^|[\s>])icq:(\d+)#i', |
2095 | @@ -798,9 +808,9 @@ |
2096 | } |
2097 | |
2098 | |
2099 | -/***** // Formatting functions *****/ |
2100 | - |
2101 | - |
2102 | +/** |
2103 | + * dummy docblock |
2104 | + */ |
2105 | function date2mysql( $ts ) |
2106 | { |
2107 | return date( 'Y-m-d H:i:s', $ts ); |
2108 | @@ -823,7 +833,8 @@ |
2109 | } |
2110 | |
2111 | /** |
2112 | - * Format a MYSQL date to current locale date format. |
2113 | + * Format a MYSQL date to current locale date format |
2114 | + * |
2115 | * @param string MYSQL date YYYY-MM-DD HH:MM:SS |
2116 | */ |
2117 | function mysql2localedate( $mysqlstring ) |
2118 | @@ -831,16 +842,28 @@ |
2119 | return mysql2date( locale_datefmt(), $mysqlstring ); |
2120 | } |
2121 | |
2122 | + |
2123 | +/** |
2124 | + * dummy docblock |
2125 | + */ |
2126 | function mysql2localetime( $mysqlstring ) |
2127 | { |
2128 | return mysql2date( locale_timefmt(), $mysqlstring ); |
2129 | } |
2130 | |
2131 | + |
2132 | +/** |
2133 | + * dummy docblock |
2134 | + */ |
2135 | function mysql2localedatetime( $mysqlstring ) |
2136 | { |
2137 | return mysql2date( locale_datefmt().' '.locale_timefmt(), $mysqlstring ); |
2138 | } |
2139 | |
2140 | + |
2141 | +/** |
2142 | + * dummy docblock |
2143 | + */ |
2144 | function mysql2localedatetime_spans( $mysqlstring, $datefmt = NULL, $timefmt = NULL ) |
2145 | { |
2146 | if( is_null( $datefmt ) ) |
2147 | @@ -852,16 +875,14 @@ |
2148 | $timefmt = locale_timefmt(); |
2149 | } |
2150 | |
2151 | - return '<span class="date">' |
2152 | - .mysql2date( $datefmt, $mysqlstring ) |
2153 | - .'</span> <span class="time">' |
2154 | - .mysql2date( $timefmt, $mysqlstring ) |
2155 | - .'</span>'; |
2156 | + return '<span class="date">'.mysql2date( $datefmt, $mysqlstring ) |
2157 | + .'</span> <span class="time">'.mysql2date( $timefmt, $mysqlstring ).'</span>'; |
2158 | } |
2159 | |
2160 | |
2161 | /** |
2162 | * Format a MYSQL date |
2163 | + * |
2164 | * @param string enhanced format string |
2165 | * @param string MYSQL date YYYY-MM-DD HH:MM:SS |
2166 | * @param boolean true to use GM time |
2167 | @@ -881,14 +902,20 @@ |
2168 | |
2169 | /** |
2170 | * Date internationalization: same as date() formatting but with i18n support |
2171 | + * |
2172 | * @param string enhanced format string |
2173 | * @param integer UNIX timestamp |
2174 | * @param boolean true to use GM time |
2175 | */ |
2176 | function date_i18n( $dateformatstring, $unixtimestamp, $useGM = false ) |
2177 | { |
2178 | - global $month, $month_abbrev, $weekday, $weekday_abbrev, $weekday_letter; |
2179 | - global $localtimenow, $time_difference; |
2180 | + global $localtimenow; |
2181 | + global $month; |
2182 | + global $month_abbrev; |
2183 | + global $time_difference; |
2184 | + global $weekday; |
2185 | + global $weekday_abbrev; |
2186 | + global $weekday_letter; |
2187 | |
2188 | if( $dateformatstring == 'isoZ' ) |
2189 | { |
2190 | @@ -907,21 +934,16 @@ |
2191 | |
2192 | /* |
2193 | Special symbols: |
2194 | - 'b': wether it's today (1) or not (0) |
2195 | + 'b': whether it's today (1) or not (0) |
2196 | 'l': weekday |
2197 | 'D': weekday abbrev |
2198 | 'e': weekday letter |
2199 | 'F': month |
2200 | 'M': month abbrev |
2201 | */ |
2202 | - |
2203 | - #echo $dateformatstring, '<br />'; |
2204 | - |
2205 | // protect special symbols, that date() would need proper locale set for |
2206 | $protected_dateformatstring = preg_replace( '/(?<!\\\)([blDeFM])/', '@@@\\\$1@@@', $dateformatstring ); |
2207 | |
2208 | - #echo $protected_dateformatstring, '<br />'; |
2209 | - |
2210 | $r = date( $protected_dateformatstring, $unixtimestamp ); |
2211 | |
2212 | if( $protected_dateformatstring != $dateformatstring ) |
2213 | @@ -933,20 +955,21 @@ |
2214 | |
2215 | // replace special symbols |
2216 | $r = str_replace( array( |
2217 | - '@@@b@@@', |
2218 | - '@@@l@@@', |
2219 | - '@@@D@@@', |
2220 | - '@@@e@@@', |
2221 | - '@@@F@@@', |
2222 | - '@@@M@@@', |
2223 | - ), |
2224 | - array( $istoday, |
2225 | - trim( T_( $weekday[$dateweekday] ) ), |
2226 | - trim( T_( $weekday_abbrev[$dateweekday] ) ), |
2227 | - trim( T_( $weekday_letter[$dateweekday] ) ), |
2228 | - trim( T_( $month[$datemonth] ) ), |
2229 | - trim( T_( $month_abbrev[$datemonth] ) ) ), |
2230 | - $r ); |
2231 | + '@@@b@@@', |
2232 | + '@@@l@@@', |
2233 | + '@@@D@@@', |
2234 | + '@@@e@@@', |
2235 | + '@@@F@@@', |
2236 | + '@@@M@@@', |
2237 | + ), |
2238 | + array( |
2239 | + $istoday, |
2240 | + trim( T_( $weekday[$dateweekday] ) ), |
2241 | + trim( T_( $weekday_abbrev[$dateweekday] ) ), |
2242 | + trim( T_( $weekday_letter[$dateweekday] ) ), |
2243 | + trim( T_( $month[$datemonth] ) ), |
2244 | + trim( T_( $month_abbrev[$datemonth] ) ) ), |
2245 | + $r ); |
2246 | } |
2247 | } |
2248 | |
2249 | @@ -956,6 +979,7 @@ |
2250 | |
2251 | /** |
2252 | * Add given # of days to a timestamp |
2253 | + * |
2254 | * @param integer timestamp |
2255 | * @param integer days |
2256 | * @return integer timestamp |
2257 | @@ -966,17 +990,22 @@ |
2258 | date( 'm', $timestamp ), date( 'd', $timestamp )+$days, date( 'Y', $timestamp ) ); |
2259 | } |
2260 | |
2261 | + |
2262 | /** |
2263 | * Format dates into a string in a way similar to sprintf() |
2264 | */ |
2265 | function date_sprintf( $string, $timestamp ) |
2266 | { |
2267 | global $date_sprintf_timestamp; |
2268 | + |
2269 | $date_sprintf_timestamp = $timestamp; |
2270 | - |
2271 | return preg_replace_callback( '/%\{(.*?)\}/', 'date_sprintf_callback', $string ); |
2272 | } |
2273 | |
2274 | + |
2275 | +/** |
2276 | + * callback |
2277 | + */ |
2278 | function date_sprintf_callback( $matches ) |
2279 | { |
2280 | global $date_sprintf_timestamp; |
2281 | @@ -987,6 +1016,7 @@ |
2282 | |
2283 | |
2284 | /** |
2285 | + * Get start date for week |
2286 | * |
2287 | * @param integer year |
2288 | * @param integer month (0-53) |
2289 | @@ -997,8 +1027,8 @@ |
2290 | $new_years_date = mktime( 0, 0, 0, 1, 1, $year ); |
2291 | $weekday = date( 'w', $new_years_date ); |
2292 | |
2293 | - // How many days until start of week: |
2294 | - $days_to_new_week = (7 - $weekday + $startofweek) % 7; |
2295 | + // How many days until start of week |
2296 | + $days_to_new_week = ( 7 - $weekday + $startofweek ) % 7; |
2297 | |
2298 | // We now add the required number of days to find the 1st sunday/monday in the year: |
2299 | //$first_week_start_date = $new_years_date + $days_to_new_week * 86400; |
2300 | @@ -1027,7 +1057,7 @@ |
2301 | $date = mktime( 0, 0, 0, date( 'm', $date ), date( 'd', $date )-1, date( 'Y', $date ) ); |
2302 | } |
2303 | $week['start'] = $date; |
2304 | - $week['end'] = $date + 604800; // 7 days |
2305 | + $week['end'] = $date + 604800; // 7 days |
2306 | |
2307 | return( $week ); |
2308 | } |
2309 | @@ -1035,6 +1065,7 @@ |
2310 | |
2311 | /** |
2312 | * Get difference between two MySQL timestamps |
2313 | + * |
2314 | * @link http://www.php.net/manual/en/function.time.php#85481 |
2315 | * @param string MYSQL date (YYYY-MM-DD HH:MM:SS) |
2316 | * @param string MYSQL date (YYYY-MM-DD HH:MM:SS), defaults to 0 for right now |
2317 | @@ -1057,7 +1088,7 @@ |
2318 | |
2319 | if( $delta_minutes <= 1 ) |
2320 | { |
2321 | - return ($delta_minutes == 0) ? T_('less than a minute') : T_('1 minute'); |
2322 | + return ( $delta_minutes == 0 ) ? T_('less than a minute') : T_('1 minute'); |
2323 | } |
2324 | |
2325 | if( $delta_minutes < 45 ) |
2326 | @@ -1097,17 +1128,13 @@ |
2327 | |
2328 | |
2329 | /** |
2330 | - * Check that email address looks valid. |
2331 | + * Check that email address looks valid |
2332 | * |
2333 | * @param string email address to check |
2334 | * @param string Format to use ('simple', 'rfc') |
2335 | - * 'simple': |
2336 | - * Single email address. |
2337 | - * 'rfc': |
2338 | - * Full email address, may include name (RFC2822) |
2339 | - * - example@example.org |
2340 | - * - Me <example@example.org> |
2341 | - * - "Me" <example@example.org> |
2342 | + * - 'simple': Single email address. |
2343 | + * - 'rfc': Full email address, may include name (RFC2822) like example@example.org |
2344 | + * or Me <example@example.org> or "Me" <example@example.org> |
2345 | * |
2346 | * @see Plugin::IsValidRawEmail() |
2347 | * @see Plugin::IsValidFilteredEmail() |
2348 | @@ -1136,12 +1163,12 @@ |
2349 | // The plugin thinks the email address is invalid. No further processing. |
2350 | return false; |
2351 | } |
2352 | - else if( $plug_choice == Plugin::EmailValid ) |
2353 | + elseif( $plug_choice == Plugin::EmailValid ) |
2354 | { |
2355 | // The plugin assures us that everything is perfectly fine. |
2356 | return true; |
2357 | } |
2358 | - else if( $plug_choice == Plugin::EmailNotSure ) |
2359 | + elseif( $plug_choice == Plugin::EmailNotSure ) |
2360 | { |
2361 | // No plugin could decide on the validity of the address. |
2362 | // Apply our own checks. |
2363 | @@ -1195,10 +1222,7 @@ |
2364 | // Now we have a syntactically valid email. Let's see if there are any other |
2365 | // plugins that might decide that there's something else wrong with the address. |
2366 | $plug_ret = $Plugins->trigger_event_first_false( 'IsValidFilteredEmail', |
2367 | - array( |
2368 | - 'email' => $email, |
2369 | - 'format' => $format, |
2370 | - ) ); |
2371 | + array( 'email' => $email, 'format' => $format, ) ); |
2372 | |
2373 | if( ! empty( $plug_ret ) ) |
2374 | { |
2375 | @@ -1214,13 +1238,17 @@ |
2376 | */ |
2377 | function is_windows() |
2378 | { |
2379 | - return ( strtoupper(substr(PHP_OS,0,3)) == 'WIN' ); |
2380 | + return ( strtoupper( substr( PHP_OS, 0, 3 ) ) == 'WIN' ); |
2381 | } |
2382 | |
2383 | |
2384 | -function xmlrpc_getposttitle($content) |
2385 | +/** |
2386 | + * dummy docblock |
2387 | + */ |
2388 | +function xmlrpc_getposttitle( $content ) |
2389 | { |
2390 | global $post_default_title; |
2391 | + |
2392 | if( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) |
2393 | { |
2394 | $post_title = $matchtitle[1]; |
2395 | @@ -1229,17 +1257,16 @@ |
2396 | { |
2397 | $post_title = $post_default_title; |
2398 | } |
2399 | - return($post_title); |
2400 | + return( $post_title ); |
2401 | } |
2402 | |
2403 | |
2404 | /** |
2405 | * Also used by post by mail |
2406 | * |
2407 | - * @deprecated by xmlrpc_getpostcategories() |
2408 | - * @todo (1111): this is used only by qp_srvc/getmail.php in v0.0.0 (EdB) |
2409 | + * @deprecated by xmlrpc_getpostcategories() ... uh no: this is used only by qp_srvc/getmail.php in v0.0.0 (EdB) |
2410 | */ |
2411 | -function xmlrpc_getpostcategory($content) |
2412 | +function xmlrpc_getpostcategory( $content ) |
2413 | { |
2414 | if( preg_match( '/<category>([0-9]+?)<\/category>/is', $content, $matchcat ) ) |
2415 | { |
2416 | @@ -1251,14 +1278,14 @@ |
2417 | |
2418 | |
2419 | /** |
2420 | - * Extract categories out of "<category>" tag from $content. |
2421 | + * Extract categories out of "<category>" tag from $content |
2422 | * |
2423 | - * NOTE: w.bloggar sends something like "<category>00000013,00000001,00000004,</category>" to |
2424 | - * blogger.newPost. |
2425 | + * NOTE: w.bloggar sends something like "<category>00000013,00000001,00000004,</category>" |
2426 | + * to blogger.newPost. |
2427 | * |
2428 | * @return false|array |
2429 | */ |
2430 | -function xmlrpc_getpostcategories($content) |
2431 | +function xmlrpc_getpostcategories( $content ) |
2432 | { |
2433 | $cats = array(); |
2434 | |
2435 | @@ -1275,20 +1302,21 @@ |
2436 | } |
2437 | |
2438 | |
2439 | -/* |
2440 | +/** |
2441 | * xmlrpc_removepostdata(-) |
2442 | */ |
2443 | -function xmlrpc_removepostdata($content) |
2444 | +function xmlrpc_removepostdata( $content ) |
2445 | { |
2446 | $content = preg_replace('/<title>(.*?)<\/title>/si', '', $content); |
2447 | $content = preg_replace('/<category>(.*?)<\/category>/si', '', $content); |
2448 | - $content = trim($content); |
2449 | - return($content); |
2450 | + $content = trim( $content ); |
2451 | + return( $content ); |
2452 | } |
2453 | |
2454 | |
2455 | /** |
2456 | * Echo the XML-RPC call Result and optionally log into file |
2457 | + * |
2458 | * @param object XMLRPC response object |
2459 | * @param boolean true to echo |
2460 | * @param mixed File resource or == '' for no file logging. |
2461 | @@ -1306,18 +1334,18 @@ |
2462 | { |
2463 | // We got a remote error |
2464 | if( $display ) echo T_('Remote error'), ': ', $result->faultString(), ' (', $result->faultCode(), ")<br />\n"; |
2465 | - debug_fwrite($log, $result->faultCode().' -- '.$result->faultString()); |
2466 | + debug_fwrite( $log, $result->faultCode().' -- '.$result->faultString() ); |
2467 | return false; |
2468 | } |
2469 | |
2470 | // We'll display the response |
2471 | $val = $result->value(); |
2472 | - $value = xmlrpc_decode_recurse($result->value()); |
2473 | + $value = xmlrpc_decode_recurse( $result->value() ); |
2474 | |
2475 | - if( is_array($value) ) |
2476 | + if( is_array( $value ) ) |
2477 | { |
2478 | $out = ''; |
2479 | - foreach($value as $l_value) |
2480 | + foreach( $value as $l_value ) |
2481 | { |
2482 | $out .= ' ['.$l_value.'] '; |
2483 | } |
2484 | @@ -1327,7 +1355,7 @@ |
2485 | $out = $value; |
2486 | } |
2487 | |
2488 | - debug_fwrite($log, $out); |
2489 | + debug_fwrite( $log, $out ); |
2490 | |
2491 | if( $display ) echo T_('Response').': '.$out."<br />\n"; |
2492 | |
2493 | @@ -1337,6 +1365,7 @@ |
2494 | |
2495 | /** |
2496 | * Log the XML-RPC call Result into LOG object |
2497 | + * |
2498 | * @param object XMLRPC response object |
2499 | * @param Log object to add messages to |
2500 | * @return boolean true = success, false = error |
2501 | @@ -1359,12 +1388,12 @@ |
2502 | |
2503 | // We got a response |
2504 | $val = $result->value(); |
2505 | - $value = xmlrpc_decode_recurse($result->value()); |
2506 | + $value = xmlrpc_decode_recurse( $result->value() ); |
2507 | |
2508 | - if( is_array($value) ) |
2509 | + if( is_array( $value ) ) |
2510 | { |
2511 | $out = ''; |
2512 | - foreach($value as $l_value) |
2513 | + foreach( $value as $l_value ) |
2514 | { |
2515 | $out .= ' ['.$l_value.'] '; |
2516 | } |
2517 | @@ -1383,33 +1412,49 @@ |
2518 | } |
2519 | |
2520 | |
2521 | - |
2522 | -function debug_fopen($filename, $mode) { |
2523 | +/** |
2524 | + * dummy docblock |
2525 | + */ |
2526 | +function debug_fopen( $filename, $mode ) |
2527 | +{ |
2528 | global $debug; |
2529 | + |
2530 | if( $debug == 1 && ( ! empty( $filename ) ) ) |
2531 | { |
2532 | - $fp = fopen($filename, $mode); |
2533 | + $fp = fopen( $filename, $mode ); |
2534 | return $fp; |
2535 | - } else { |
2536 | + } |
2537 | + else |
2538 | + { |
2539 | return false; |
2540 | } |
2541 | } |
2542 | |
2543 | -function debug_fwrite($fp, $string) |
2544 | + |
2545 | +/** |
2546 | + * dummy docblock |
2547 | + */ |
2548 | +function debug_fwrite( $fp, $string ) |
2549 | { |
2550 | global $debug; |
2551 | + |
2552 | if( $debug && $fp ) |
2553 | { |
2554 | - fwrite($fp, $string); |
2555 | + fwrite( $fp, $string ); |
2556 | } |
2557 | } |
2558 | |
2559 | -function debug_fclose($fp) |
2560 | + |
2561 | +/** |
2562 | + * dummy docblock |
2563 | + */ |
2564 | +function debug_fclose( $fp ) |
2565 | { |
2566 | global $debug; |
2567 | + |
2568 | if( $debug && $fp ) |
2569 | { |
2570 | - fclose($fp); |
2571 | + fclose( $fp ); |
2572 | } |
2573 | } |
2574 | |
2575 | @@ -1417,6 +1462,7 @@ |
2576 | |
2577 | /** |
2578 | * Wrap pre tag around {@link var_dump()} for better debugging |
2579 | + * |
2580 | * @param $var__var__var__var__,... mixed variable(s) to dump |
2581 | */ |
2582 | function pre_dump( $var__var__var__var__ ) |
2583 | @@ -1428,13 +1474,13 @@ |
2584 | $func_num_args = func_num_args(); |
2585 | $count = 0; |
2586 | |
2587 | - if( ! empty($is_cli) ) |
2588 | + if( ! empty( $is_cli ) ) |
2589 | { |
2590 | // CLI, no encoding of special chars |
2591 | $count = 0; |
2592 | foreach( func_get_args() as $lvar ) |
2593 | { |
2594 | - var_dump($lvar); |
2595 | + var_dump( $lvar ); |
2596 | |
2597 | $count++; |
2598 | if( $count < $func_num_args ) |
2599 | @@ -1456,7 +1502,7 @@ |
2600 | echo "\n<div style=\"padding:1ex;border:1px solid #00f;\">\n"; |
2601 | foreach( func_get_args() as $lvar ) |
2602 | { |
2603 | - xdebug_var_dump($lvar); |
2604 | + xdebug_var_dump( $lvar ); |
2605 | |
2606 | $count++; |
2607 | if( $count < $func_num_args ) |
2608 | @@ -1502,11 +1548,14 @@ |
2609 | * Get a function trace from {@link debug_backtrace()} as html table. |
2610 | * |
2611 | * Adopted from {@link http://us2.php.net/manual/de/function.debug-backtrace.php#47644}. |
2612 | - * @param integer|NULL Get the last x entries from the stack (after $ignore_from is applied). Anything non-numeric means "all". |
2613 | - * @param array After a key/value pair matches a stack entry, this and the rest is ignored. |
2614 | - * For example, array( 'class' => 'DB' ) would exclude everything after the stack |
2615 | - * "enters" class DB and everything that got called afterwards. |
2616 | - * You can also give an array of arrays which means that every condition in one of the given array must match. |
2617 | + * |
2618 | + * @param integer|NULL Get the last x entries from the stack (after $ignore_from is applied). |
2619 | + * Anything non-numeric means "all". |
2620 | + * @param array After a key/value pair matches a stack entry, this and the rest |
2621 | + * is ignored. For example, array( 'class' => 'DB' ) would exclude everything after |
2622 | + * the stack "enters" class DB and everything that got called afterwards. |
2623 | + * You can also give an array of arrays which means that every condition in one |
2624 | + * of the given array must match. |
2625 | * @param integer Number of stack entries to include, after $ignore_from matches. |
2626 | * @return string HTML table |
2627 | */ |
2628 | @@ -1521,7 +1570,7 @@ |
2629 | |
2630 | $backtrace = debug_backtrace(); |
2631 | $count_ignored = 0; // remember how many have been ignored |
2632 | - $limited = false; // remember if we have limited to $limit_to_last |
2633 | + $limited = false; // remember if we have limited to $limit_to_last |
2634 | |
2635 | if( $ignore_from ) |
2636 | { |
2637 | @@ -1529,7 +1578,7 @@ |
2638 | $trace_length = 0; |
2639 | $break_because_of_offset = false; |
2640 | |
2641 | - for( $i = count($backtrace); $i > 0; $i-- ) |
2642 | + for( $i = count( $backtrace ); $i > 0; $i-- ) |
2643 | { |
2644 | // Search the backtrace from behind (first call) |
2645 | $l_stack = & $backtrace[$i-1]; |
2646 | @@ -1543,13 +1592,13 @@ |
2647 | foreach( $ignore_from as $l_ignore_key => $l_ignore_value ) |
2648 | { |
2649 | // Check if we want to ignore from here |
2650 | - if( is_array($l_ignore_value) ) |
2651 | + if( is_array( $l_ignore_value ) ) |
2652 | { |
2653 | // It's an array - all must match |
2654 | foreach( $l_ignore_value as $l_ignore_mult_key => $l_ignore_mult_val ) |
2655 | { |
2656 | if( ! isset( $l_stack[$l_ignore_mult_key] ) /* not set with this stack entry */ |
2657 | - || strcasecmp($l_stack[$l_ignore_mult_key], $l_ignore_mult_val) /* not this value (case-insensitive) */ ) |
2658 | + || strcasecmp( $l_stack[$l_ignore_mult_key], $l_ignore_mult_val ) /* not this value (case-insensitive) */ ) |
2659 | { |
2660 | continue 2; // next ignore setting, because not all match. |
2661 | } |
2662 | @@ -1561,8 +1610,8 @@ |
2663 | } |
2664 | break 2; // ignore from here |
2665 | } |
2666 | - elseif( isset($l_stack[$l_ignore_key]) |
2667 | - && !strcasecmp($l_stack[$l_ignore_key], $l_ignore_value) /* is equal case-insensitive */ ) |
2668 | + elseif( isset( $l_stack[$l_ignore_key] ) |
2669 | + && !strcasecmp( $l_stack[$l_ignore_key], $l_ignore_value ) /* is equal case-insensitive */ ) |
2670 | { |
2671 | if( $offset_ignore_from-- > 0 ) |
2672 | { |
2673 | @@ -1575,13 +1624,13 @@ |
2674 | $trace_length++; |
2675 | } |
2676 | |
2677 | - $count_ignored = count($backtrace) - $trace_length; |
2678 | + $count_ignored = count( $backtrace ) - $trace_length; |
2679 | |
2680 | $backtrace = array_slice( $backtrace, 0-$trace_length ); // cut off ignored ones |
2681 | } |
2682 | |
2683 | - $count_backtrace = count($backtrace); |
2684 | - if( is_numeric($limit_to_last) && $limit_to_last < $count_backtrace ) |
2685 | + $count_backtrace = count( $backtrace ); |
2686 | + if( is_numeric( $limit_to_last ) && $limit_to_last < $count_backtrace ) |
2687 | { |
2688 | // we want to limit to a maximum number |
2689 | $limited = true; |
2690 | @@ -1607,45 +1656,51 @@ |
2691 | $r .= '<li style="padding:0.5ex 0; border-bottom:1px solid #77d;">'; |
2692 | } |
2693 | $args = array(); |
2694 | - if( isset($l_trace['args']) && is_array( $l_trace['args'] ) ) |
2695 | + if( isset( $l_trace['args'] ) && is_array( $l_trace['args'] ) ) |
2696 | { |
2697 | // Prepare args |
2698 | foreach( $l_trace['args'] as $l_arg ) |
2699 | { |
2700 | - $l_arg_type = gettype($l_arg); |
2701 | + $l_arg_type = gettype( $l_arg ); |
2702 | switch( $l_arg_type ) |
2703 | { |
2704 | case 'integer': |
2705 | case 'double': |
2706 | - $args[] = $l_arg; |
2707 | - break; |
2708 | + $args[] = $l_arg; |
2709 | + break; |
2710 | + |
2711 | case 'string': |
2712 | - $args[] = '"'.htmlspecialchars(str_replace("\n", '', substr($l_arg, 0, 64))).((strlen($l_arg) > 64) ? '...' : '').'"'; |
2713 | - break; |
2714 | + $args[] = '"'.htmlspecialchars( str_replace( "\n", '', substr( $l_arg, 0, 64 ) ) ).( ( strlen( $l_arg ) > 64 ) ? '...' : '' ).'"'; |
2715 | + break; |
2716 | + |
2717 | case 'array': |
2718 | - $args[] = 'Array('.count( $l_arg ).')'; |
2719 | - break; |
2720 | + $args[] = 'Array('.count( $l_arg ).')'; |
2721 | + break; |
2722 | + |
2723 | case 'object': |
2724 | - $args[] = 'Object('.get_class($l_arg).')'; |
2725 | - break; |
2726 | + $args[] = 'Object('.get_class( $l_arg ).')'; |
2727 | + break; |
2728 | + |
2729 | case 'resource': |
2730 | - $args[] = 'Resource('.strstr($l_arg, '#').')'; |
2731 | - break; |
2732 | + $args[] = 'Resource('.strstr( $l_arg, '#' ).')'; |
2733 | + break; |
2734 | + |
2735 | case 'boolean': |
2736 | - $args[] = $l_arg ? 'true' : 'false'; |
2737 | - break; |
2738 | + $args[] = $l_arg ? 'true' : 'false'; |
2739 | + break; |
2740 | + |
2741 | default: |
2742 | - $args[] = $l_arg_type; |
2743 | + $args[] = $l_arg_type; |
2744 | } |
2745 | } |
2746 | } |
2747 | |
2748 | $call = "<strong>\n"; |
2749 | - if( isset($l_trace['class']) ) |
2750 | + if( isset( $l_trace['class'] ) ) |
2751 | { |
2752 | $call .= $l_trace['class']; |
2753 | } |
2754 | - if( isset($l_trace['type']) ) |
2755 | + if( isset( $l_trace['type'] ) ) |
2756 | { |
2757 | $call .= $l_trace['type']; |
2758 | } |
2759 | @@ -1659,7 +1714,7 @@ |
2760 | $r .= $call."<br />\n"; |
2761 | |
2762 | $r .= '<strong>'; |
2763 | - if( isset($l_trace['file']) ) |
2764 | + if( isset( $l_trace['file'] ) ) |
2765 | { |
2766 | $r .= "File: </strong> ".$l_trace['file']; |
2767 | } |
2768 | @@ -1667,7 +1722,7 @@ |
2769 | { |
2770 | $r .= '[runtime created function]</strong>'; |
2771 | } |
2772 | - if( isset($l_trace['line']) ) |
2773 | + if( isset( $l_trace['line'] ) ) |
2774 | { |
2775 | $r .= ' on line '.$l_trace['line']; |
2776 | } |
2777 | @@ -1681,7 +1736,8 @@ |
2778 | $r .= '<p>No backtrace available.</p>'; |
2779 | } |
2780 | |
2781 | - // Extra notes, might be to much, but explains why we stopped at some point. Feel free to comment it out or remove it. |
2782 | + // Extra notes, might be to much, but explains why we stopped at some point. |
2783 | + // Feel free to comment it out or remove it. |
2784 | $notes = array(); |
2785 | if( $count_ignored ) |
2786 | { |
2787 | @@ -1705,19 +1761,22 @@ |
2788 | /** |
2789 | * Outputs Unexpected Error message. When in debug mode it also prints a backtrace. |
2790 | * |
2791 | - * This should be used instead of die() everywhere. |
2792 | - * This should NOT be used instead of exit() anywhere. |
2793 | - * Dying means the application has encontered and unexpected situation, |
2794 | - * i-e: something that should never occur during normal operation. |
2795 | - * Examples: database broken, user changed URL by hand... |
2796 | + * This should be used instead of die() everywhere. This should NOT be used instead |
2797 | + * of exit() anywhere. Dying means the application has encountered and unexpected |
2798 | + * situation, i-e: something that should never occur during normal operation. Examples: |
2799 | + * database broken, user changed URL by hand... |
2800 | + * |
2801 | * @param string Message to output |
2802 | * @param array Additional params |
2803 | * - "status" (Default: '500 Internal Server Error') |
2804 | */ |
2805 | function debug_die( $additional_info = '', $params = array() ) |
2806 | { |
2807 | - global $debug, $app_baseurl; |
2808 | - global $log_app_errors, $app_name, $is_cli; |
2809 | + global $app_baseurl; |
2810 | + global $app_name; |
2811 | + global $debug; |
2812 | + global $is_cli; |
2813 | + global $log_app_errors; |
2814 | |
2815 | $params = array_merge( array( 'status' => '500 Internal Server Error', ), $params ); |
2816 | |
2817 | @@ -1731,14 +1790,14 @@ |
2818 | } |
2819 | else |
2820 | { |
2821 | - // Attempt to output an error header (will not work if the output buffer has already flushed once): |
2822 | + // Attempt to output an error header (will not work if the output buffer has already flushed once) |
2823 | // This should help preventing indexing robots from indexing the error :P |
2824 | if( ! headers_sent() ) |
2825 | { |
2826 | load_funcs( '_core/_template.funcs.php' ); |
2827 | header_content_type( 'text/html' ); // it's ok, if a previous header would be replaced; |
2828 | $status_header = $_SERVER['SERVER_PROTOCOL'].' '.$params['status']; |
2829 | - header($status_header); |
2830 | + header( $status_header ); |
2831 | } |
2832 | |
2833 | echo '<div style="background-color: #fdd; padding: 1ex; margin-bottom: 1ex;">'; |
2834 | @@ -1770,9 +1829,9 @@ |
2835 | |
2836 | // Log error through PHP's logging facilities |
2837 | $log_message = $app_name.' error: '; |
2838 | - if( ! empty($additional_info) ) |
2839 | + if( ! empty( $additional_info ) ) |
2840 | { |
2841 | - $log_message .= trim( strip_tags($additional_info) ); |
2842 | + $log_message .= trim( strip_tags( $additional_info ) ); |
2843 | } |
2844 | else |
2845 | { |
2846 | @@ -1798,16 +1857,16 @@ |
2847 | { |
2848 | // Append backtrace |
2849 | // indent after newlines |
2850 | - $backtrace_cli = preg_replace( '~(\S)(\n)(\S)~', '$1 $2$3', $backtrace_cli ); |
2851 | + $backtrace_cli = preg_replace( '~(\S)(\n)(\S)~', '$1 $2$3', $backtrace_cli ); |
2852 | $log_message .= "\nBacktrace:\n".$backtrace_cli; |
2853 | } |
2854 | |
2855 | - $log_message .= "\nREQUEST_URI: ".( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '-' ); |
2856 | + $log_message .= "\nREQUEST_URI: ".( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '-' ); |
2857 | $log_message .= "\nHTTP_REFERER: ".( isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '-' ); |
2858 | |
2859 | error_log( str_replace("\n", ' / ', $log_message), 0 /* PHP's system logger */ ); |
2860 | |
2861 | - // DEBUG OUTPUT: |
2862 | + // DEBUG OUTPUT |
2863 | if( $debug ) |
2864 | { |
2865 | if( $is_cli ) |
2866 | @@ -1816,7 +1875,7 @@ |
2867 | echo $backtrace; |
2868 | } |
2869 | |
2870 | - // EXIT: |
2871 | + // EXIT |
2872 | if( ! $is_cli ) |
2873 | { |
2874 | // Attempt to keep the html valid (but it doesn't really matter anyway) |
2875 | @@ -1831,13 +1890,15 @@ |
2876 | * Outputs Bad request Error message. When in debug mode it also prints a backtrace |
2877 | * |
2878 | * This should be used when a bad user input is detected? |
2879 | + * |
2880 | * @param string Message to output (HTML) |
2881 | */ |
2882 | function bad_request_die( $additional_info = '' ) |
2883 | { |
2884 | - global $debug, $app_baseurl; |
2885 | + global $app_baseurl; |
2886 | + global $debug; |
2887 | |
2888 | - // Attempt to output an error header (will not work if the output buffer has already flushed once): |
2889 | + // Attempt to output an error header (will not work if the output buffer has already flushed once) |
2890 | // This should help preventing indexing robots from indexing the error :P |
2891 | if( ! headers_sent() ) |
2892 | { |
2893 | @@ -1875,6 +1936,7 @@ |
2894 | |
2895 | /** |
2896 | * Outputs debug info according to {@link $debug} or $force param |
2897 | + * |
2898 | * @param boolean true to force output regardless of {@link $debug} |
2899 | * @param boolean true to force clean output (without HTML) regardless of {@link $is_cli} |
2900 | */ |
2901 | @@ -1920,7 +1982,7 @@ |
2902 | if( $debug < 2 && ( empty( $Hit ) || $Hit->get_agent_type() != 'browser' ) ) |
2903 | { |
2904 | // Don't display if it's not a browser (very needed for proper RSS display btw) |
2905 | - // ($Hit is empty e.g. during install) |
2906 | + // $Hit is empty e.g. during install |
2907 | return; |
2908 | } |
2909 | } |
2910 | @@ -1950,7 +2012,7 @@ |
2911 | { |
2912 | // don't display changing items when we want to test obhandler |
2913 | |
2914 | - // Timer table: |
2915 | + // Timer table |
2916 | $time_page = $Timer->get_duration( 'total' ); |
2917 | $timer_rows = array(); |
2918 | foreach( $Timer->get_categories() as $l_cat ) |
2919 | @@ -1967,7 +2029,7 @@ |
2920 | |
2921 | // Remove "total", it will get outputted as the last one |
2922 | $total_time = $timer_rows['total']; |
2923 | - unset($timer_rows['total']); |
2924 | + unset( $timer_rows['total'] ); |
2925 | |
2926 | if( $clean ) |
2927 | { |
2928 | @@ -2010,9 +2072,9 @@ |
2929 | echo $row."\n"; |
2930 | } |
2931 | } |
2932 | - $count_collapse = count($table_rows_collapse); |
2933 | + $count_collapse = count( $table_rows_collapse ); |
2934 | |
2935 | - // Collapse ignored rows, allowing to expand them with Javascript: |
2936 | + // Collapse ignored rows, allowing to expand them with Javascript |
2937 | if( $count_collapse > 5 ) |
2938 | { |
2939 | echo '<tr><td colspan="4" class="center"> <a href="" onclick="var e = document.getElementById(\'evo-debuglog-timer-long\'); e.style.display = (e.style.display == \'none\' ? \'\' : \'none\'); return false;">+ '.$count_collapse.' < 0.005s</a> </td></tr>'; |
2940 | @@ -2050,7 +2112,7 @@ |
2941 | echo '</table>'; |
2942 | } |
2943 | |
2944 | - if( isset($DB) ) |
2945 | + if( isset( $DB ) ) |
2946 | { |
2947 | if( $clean ) |
2948 | { |
2949 | @@ -2089,7 +2151,7 @@ |
2950 | // DEBUGLOG(s) FROM PREVIOUS SESSIONS, after REDIRECT(s) (with list of categories at top): |
2951 | if( isset( $Session ) && ( $sess_Debuglogs = $Session->get( 'Debuglogs' ) ) && ! empty( $sess_Debuglogs ) ) |
2952 | { |
2953 | - $count_sess_Debuglogs = count($sess_Debuglogs); |
2954 | + $count_sess_Debuglogs = count( $sess_Debuglogs ); |
2955 | if( $count_sess_Debuglogs > 1 ) |
2956 | { |
2957 | // Links to those Debuglogs |
2958 | @@ -2126,22 +2188,22 @@ |
2959 | } |
2960 | else |
2961 | { |
2962 | - $log_container_head = '<h3 id="debug_sess_debuglog_'.($k+1).'" style="color:#f00;">Debug messages from redirected page (#'.($k+1).')</h3>' |
2963 | + $log_container_head = '<h3 id="debug_sess_debuglog_'.( $k + 1 ).'" style="color:#f00;">Debug messages from redirected page (#'.( $k + 1 ).')</h3>' |
2964 | // link to real Debuglog: |
2965 | .'<p><a href="'.$ReqHostPathQuery.'#debug_debuglog">See below for the Debuglog from the current request.</a></p>'; |
2966 | - $log_cats = array_keys($sess_Debuglog->get_messages( $log_categories )); // the real list (with all replaced and only existing ones) |
2967 | + $log_cats = array_keys( $sess_Debuglog->get_messages( $log_categories ) ); // the real list (with all replaced and only existing ones) |
2968 | $log_head_links = array(); |
2969 | |
2970 | foreach( $log_cats as $l_cat ) |
2971 | { |
2972 | - $log_head_links[] .= '<a href="'.$ReqHostPathQuery.'#debug_redir_'.($k+1).'_info_cat_'.str_replace( ' ', '_', $l_cat ).'">'.$l_cat.'</a>'; |
2973 | + $log_head_links[] .= '<a href="'.$ReqHostPathQuery.'#debug_redir_'.( $k + 1 ).'_info_cat_'.str_replace( ' ', '_', $l_cat ).'">'.$l_cat.'</a>'; |
2974 | } |
2975 | $log_container_head .= implode( ' | ', $log_head_links ); |
2976 | |
2977 | echo format_to_output( |
2978 | $sess_Debuglog->display( array( |
2979 | 'container' => array( 'string' => $log_container_head, 'template' => false ), |
2980 | - 'all' => array( 'string' => '<h4 id="debug_redir_'.($k+1).'_info_cat_%s">%s:</h4>', 'template' => false ) ), |
2981 | + 'all' => array( 'string' => '<h4 id="debug_redir_'.( $k + 1 ).'_info_cat_%s">%s:</h4>', 'template' => false ) ), |
2982 | '', false, $log_categories ), |
2983 | 'htmlbody' ); |
2984 | } |
2985 | @@ -2149,10 +2211,10 @@ |
2986 | $Session->delete( 'Debuglogs' ); |
2987 | } |
2988 | |
2989 | - // CURRENT DEBUGLOG (with list of categories at top): |
2990 | + // CURRENT DEBUGLOG (with list of categories at top) |
2991 | $log_categories = array( 'error', 'note', 'all' ); // Categories to output (in that order) |
2992 | $log_container_head = $clean ? ( "\n".'== Debug messages =='."\n" ) : '<h3 id="debug_debuglog">Debug messages</h3>'; |
2993 | - if( ! empty($sess_Debuglogs) ) |
2994 | + if( ! empty( $sess_Debuglogs ) ) |
2995 | { |
2996 | // link to first sess_Debuglog |
2997 | if( $clean ) |
2998 | @@ -2167,7 +2229,7 @@ |
2999 | |
3000 | if( ! $clean ) |
3001 | { |
3002 | - $log_cats = array_keys($Debuglog->get_messages( $log_categories )); // the real list (with all replaced and only existing ones) |
3003 | + $log_cats = array_keys( $Debuglog->get_messages( $log_categories ) ); // the real list (with all replaced and only existing ones) |
3004 | $log_head_links = array(); |
3005 | foreach( $log_cats as $l_cat ) |
3006 | { |
3007 | @@ -2177,10 +2239,10 @@ |
3008 | |
3009 | echo format_to_output( |
3010 | $Debuglog->display( array( |
3011 | - 'container' => array( 'string' => $log_container_head, 'template' => false ), |
3012 | - 'all' => array( 'string' => '<h4 id="debug_info_cat_%s">%s:</h4>', 'template' => false ) ), |
3013 | + 'container' => array( 'string' => $log_container_head, 'template' => false ), |
3014 | + 'all' => array( 'string' => '<h4 id="debug_info_cat_%s">%s:</h4>', 'template' => false ) ), |
3015 | '', false, $log_categories ), |
3016 | - 'htmlbody' ); |
3017 | + 'htmlbody' ); |
3018 | |
3019 | echo '<h3 id="app_debug_queries">DB</h3>'; |
3020 | } |
3021 | @@ -2188,15 +2250,15 @@ |
3022 | { |
3023 | echo format_to_output( |
3024 | $Debuglog->display( array( |
3025 | - 'container' => array( 'string' => $log_container_head, 'template' => false ), |
3026 | - 'all' => array( 'string' => '= %s ='."\n\n", 'template' => false ) ), |
3027 | + 'container' => array( 'string' => $log_container_head, 'template' => false ), |
3028 | + 'all' => array( 'string' => '= %s ='."\n\n", 'template' => false ) ), |
3029 | '', false, $log_categories, '', 'raw', false ), |
3030 | - 'raw' ); |
3031 | + 'raw' ); |
3032 | |
3033 | echo "\n".'== DB =='."\n\n"; |
3034 | } |
3035 | |
3036 | - if($app_db_config) |
3037 | + if( $app_db_config ) |
3038 | { |
3039 | if( ! $clean ) |
3040 | { |
3041 | @@ -2204,15 +2266,15 @@ |
3042 | } |
3043 | |
3044 | echo T_('DB Username').': '.$app_db_config['user']."\n". |
3045 | - T_('DB Database').': '.$app_db_config['name']."\n". |
3046 | - T_('DB Host').': '.$app_db_config['host']."\n". |
3047 | - T_('DB tables prefix').': '.$app_db_tableprefix."\n". |
3048 | - T_('DB connection charset').': '.$app_db_config['connection_charset']."\n"; |
3049 | + T_('DB Database').': '.$app_db_config['name']."\n". |
3050 | + T_('DB Host').': '.$app_db_config['host']."\n". |
3051 | + T_('DB tables prefix').': '.$app_db_tableprefix."\n". |
3052 | + T_('DB connection charset').': '.$app_db_config['connection_charset']."\n"; |
3053 | |
3054 | echo $clean ? "\n" : '</pre>'; |
3055 | } |
3056 | |
3057 | - if( ! isset($DB) ) |
3058 | + if( ! isset( $DB ) ) |
3059 | { |
3060 | echo 'No DB object.'.( $clean ? "\n" : '' ); |
3061 | } |
3062 | @@ -2229,12 +2291,12 @@ |
3063 | |
3064 | |
3065 | /** |
3066 | - * Prevent email header injection. |
3067 | + * Prevent email header injection |
3068 | */ |
3069 | function mail_sanitize_header_string( $header_str, $close_brace = false ) |
3070 | { |
3071 | // Prevent injection! (remove everything after (and including) \n or \r) |
3072 | - $header_str = preg_replace( '~(\r|\n).*$~s', '', trim($header_str) ); |
3073 | + $header_str = preg_replace( '~(\r|\n).*$~s', '', trim( $header_str ) ); |
3074 | |
3075 | if( $close_brace && strpos( $header_str, '<' ) !== false && strpos( $header_str, '>' ) === false ) |
3076 | { |
3077 | @@ -2247,6 +2309,7 @@ |
3078 | |
3079 | /** |
3080 | * Encode to RFC 1342 "Representation of Non-ASCII Text in Internet Message Headers" |
3081 | + * |
3082 | * @param string |
3083 | * @param string 'Q' for Quoted printable, 'B' for base64 |
3084 | */ |
3085 | @@ -2254,14 +2317,14 @@ |
3086 | { |
3087 | global $app_charset; |
3088 | |
3089 | - /* mbstring way (did not work for Alex RU) |
3090 | + /* mbstring way (did not work for Alex RU) |
3091 | if( function_exists('mb_encode_mimeheader') ) |
3092 | { |
3093 | // encode subject |
3094 | $orig = mb_internal_encoding(); |
3095 | mb_internal_encoding('utf-8'); |
3096 | $r = mb_encode_mimeheader( $header_str, 'utf-8', $mode ); |
3097 | - mb_internal_encoding($orig); |
3098 | + mb_internal_encoding( $orig ); |
3099 | return $r; |
3100 | } |
3101 | */ |
3102 | @@ -2289,7 +2352,7 @@ |
3103 | |
3104 | |
3105 | /** |
3106 | - * Sends a mail, wrapping PHP's mail() function. |
3107 | + * Sends a mail, wrapping PHP's mail() function |
3108 | * |
3109 | * {@link $current_locale} will be used to set the charset. |
3110 | * |
3111 | @@ -2297,9 +2360,8 @@ |
3112 | * {@link http://www.faqs.org/rfcs/rfc2822 RFC2822}, but seems to be safer, |
3113 | * because some mail transfer agents replace \n by \r\n automatically. |
3114 | * |
3115 | - * @todo Unit testing with "nice addresses" This gets broken over and over again. |
3116 | - * |
3117 | - * @param string Recipient email address. (Caould be multiple comma-separated addresses.) |
3118 | + * @todo (0000) Unit testing with "nice addresses" This gets broken over and over again. |
3119 | + * @param string Recipient email address. (Could be multiple comma-separated addresses.) |
3120 | * @param string Recipient name. (Only use if sending to a single address) |
3121 | * @param string Subject of the mail |
3122 | * @param string The message text |
3123 | @@ -2308,7 +2370,8 @@ |
3124 | * Defaults to {@link $notify_from} if NULL. |
3125 | * @param string From name. |
3126 | * @param array Additional headers ( headername => value ). Take care of injection! |
3127 | - * @return boolean True if mail could be sent (not necessarily delivered!), false if not - (return value of {@link mail()}) |
3128 | + * @return boolean True if mail could be sent (not necessarily delivered!), false |
3129 | + * if not - (return value of {@link mail()}) |
3130 | */ |
3131 | function send_mail( $to, $to_name, $subject, $message, $from = NULL, $from_name = NULL, $headers = array() ) |
3132 | { |
3133 | @@ -2340,11 +2403,11 @@ |
3134 | // fplanque: Windows XP, Apache 1.3, PHP 4.4, MS SMTP : will not accept "nice" addresses. |
3135 | if( ! empty( $to_name ) ) |
3136 | { |
3137 | - $to = '"'.mail_encode_header_string($to_name).'" <'.$to.'>'; |
3138 | + $to = '"'.mail_encode_header_string( $to_name ).'" <'.$to.'>'; |
3139 | } |
3140 | if( ! empty( $from_name ) ) |
3141 | { |
3142 | - $from = '"'.mail_encode_header_string($from_name).'" <'.$from.'>'; |
3143 | + $from = '"'.mail_encode_header_string( $from_name ).'" <'.$from.'>'; |
3144 | } |
3145 | } |
3146 | |
3147 | @@ -2352,7 +2415,7 @@ |
3148 | // From has to go into headers |
3149 | $headers['From'] = $from; |
3150 | |
3151 | - $subject = mail_encode_header_string($subject); |
3152 | + $subject = mail_encode_header_string( $subject ); |
3153 | |
3154 | $message = str_replace( array( "\r\n", "\r" ), $NL, $message ); |
3155 | |
3156 | @@ -2414,7 +2477,7 @@ |
3157 | */ |
3158 | function disp_cond( $var, $disp_one, $disp_more = NULL, $disp_none = NULL ) |
3159 | { |
3160 | - if( is_numeric($var) && $var > 1 ) |
3161 | + if( is_numeric( $var ) && $var > 1 ) |
3162 | { |
3163 | printf( ( $disp_more === NULL ? $disp_one : $disp_more ), $var ); |
3164 | return true; |
3165 | @@ -2436,23 +2499,24 @@ |
3166 | |
3167 | |
3168 | /** |
3169 | - * Create IMG tag for an action icon. |
3170 | - * |
3171 | - * @todo (EdB) $icon_weight and $word_weight need serious overhaul. |
3172 | - * |
3173 | + * Create IMG tag for an action icon |
3174 | + * |
3175 | + * @todo (EdB) $icon_weight and $word_weight need serious overhaul |
3176 | * @param string TITLE text (IMG and A link) |
3177 | * @param string icon code for {@link get_icon()} |
3178 | * @param string URL where the icon gets linked to (empty to not wrap the icon in a link) |
3179 | - * @param string word to be displayed after icon (if no icon gets displayed, $title will be used instead!) |
3180 | - * @param integer 1-5: weight of the icon. The icon will be displayed only if its weight is >= than the user setting threshold. |
3181 | - * Use 5, if it's a required icon - all others could get disabled by the user. (Default: 4) |
3182 | - * @param integer 1-5: weight of the word. The word will be displayed only if its weight is >= than the user setting threshold. |
3183 | - * (Default: 1) |
3184 | - * @param array Additional attributes to the A tag. The values must be properly encoded for html output (e.g. quotes). |
3185 | - * It may also contain these params: |
3186 | - * - 'use_js_popup': if true, the link gets opened as JS popup. You must also pass an "id" attribute for this! |
3187 | - * - 'use_js_size': use this to override the default popup size ("500, 400") |
3188 | - * - 'class': defaults to 'action_icon', if not set; use "" to not use it |
3189 | + * @param string word to be displayed after icon (if no icon gets displayed, |
3190 | + * $title will be used instead!) |
3191 | + * @param integer 1-5: weight of the icon. The icon will be displayed only if its |
3192 | + * weight is >= than the user setting threshold. Use 5 if it's a required icon; |
3193 | + * all others could get disabled by the user. (Default: 4) |
3194 | + * @param integer 1-5: weight of the word. The word will be displayed only if its |
3195 | + * weight is >= than the user setting threshold. (Default: 1) |
3196 | + * @param array Additional attributes to the A tag. The values must be properly |
3197 | + * encoded for html output (e.g. quotes). It may also contain these params: |
3198 | + * - 'use_js_popup': if true, the link gets opened as JS popup. You must also pass an "id" attribute for this! |
3199 | + * - 'use_js_size': use this to override the default popup size ("500, 400") |
3200 | + * - 'class': defaults to 'action_icon', if not set; use "" to not use it |
3201 | * @return string The generated action icon link. |
3202 | */ |
3203 | function action_icon( $title, $icon, $url, $word = NULL, $icon_weight = NULL, $word_weight = NULL, $link_attribs = array() ) |
3204 | @@ -2462,23 +2526,23 @@ |
3205 | $link_attribs['href'] = $url; |
3206 | $link_attribs['title'] = $title; |
3207 | |
3208 | - if( is_null($icon_weight) ) |
3209 | + if( is_null( $icon_weight ) ) |
3210 | { |
3211 | $icon_weight = 4; |
3212 | } |
3213 | - if( is_null($word_weight) ) |
3214 | + if( is_null( $word_weight ) ) |
3215 | { |
3216 | $word_weight = 1; |
3217 | } |
3218 | |
3219 | - if( ! isset($link_attribs['class']) ) |
3220 | + if( ! isset( $link_attribs['class'] ) ) |
3221 | { |
3222 | $link_attribs['class'] = 'action_icon'; |
3223 | } |
3224 | |
3225 | if( get_icon( $icon, 'rollover' ) ) |
3226 | { |
3227 | - if( empty($link_attribs['class']) ) |
3228 | + if( empty( $link_attribs['class'] ) ) |
3229 | { |
3230 | $link_attribs['class'] = 'rollover'; |
3231 | } |
3232 | @@ -2489,14 +2553,14 @@ |
3233 | } |
3234 | |
3235 | // "use_js_popup": open link in a JS popup |
3236 | - // @todo (0000): this needs to be rewritten with jQuery instead |
3237 | - if( false && ! empty($link_attribs['use_js_popup']) ) |
3238 | + // @todo (0000) this needs to be rewritten with jQuery instead |
3239 | + if( false && ! empty( $link_attribs['use_js_popup'] ) ) |
3240 | { |
3241 | - $popup_js = 'var win = new PopupWindow(); win.setUrl( \''.$link_attribs['href'].'\' ); win.setSize( ); '; |
3242 | + $popup_js = 'var win = new PopupWindow(); win.setUrl( \''.$link_attribs['href'].'\' ); win.setSize(); '; |
3243 | |
3244 | - if( isset($link_attribs['use_js_size']) ) |
3245 | + if( isset( $link_attribs['use_js_size'] ) ) |
3246 | { |
3247 | - if( ! empty($link_attribs['use_js_size']) ) |
3248 | + if( ! empty( $link_attribs['use_js_size'] ) ) |
3249 | { |
3250 | $popup_size = $link_attribs['use_js_size']; |
3251 | } |
3252 | @@ -2505,7 +2569,7 @@ |
3253 | { |
3254 | $popup_size = '500, 400'; |
3255 | } |
3256 | - if( isset($popup_size) ) |
3257 | + if( isset( $popup_size ) ) |
3258 | { |
3259 | $popup_js .= 'win.setSize( '.$popup_size.' ); '; |
3260 | } |
3261 | @@ -2520,10 +2584,11 @@ |
3262 | $link_attribs['onclick'] .= $popup_js; |
3263 | } |
3264 | } |
3265 | - unset($link_attribs['use_js_popup']); |
3266 | - unset($link_attribs['use_js_size']); |
3267 | + unset( $link_attribs['use_js_popup'] ); |
3268 | + unset( $link_attribs['use_js_size'] ); |
3269 | |
3270 | - // NOTE: We do not use format_to_output with get_field_attribs_as_string() here, because it interferes with the Results class (eval() fails on entitied quotes..) (blueyed) |
3271 | + // NOTE: We do not use format_to_output with get_field_attribs_as_string() here |
3272 | + // because it interferes with the Results class (eval() fails on entitied quotes..) (blueyed) |
3273 | $r = '<a '.get_field_attribs_as_string( $link_attribs, false ).'>'; |
3274 | |
3275 | $display_icon = ( $icon_weight >= 3 ); |
3276 | @@ -2568,18 +2633,20 @@ |
3277 | |
3278 | |
3279 | /** |
3280 | - * Get properties of an icon. |
3281 | + * Get properties of an icon |
3282 | * |
3283 | * Note: to get a file type icon, use {@link File::get_icon()} instead. |
3284 | * |
3285 | * @uses get_icon_info() |
3286 | * @param string icon for what? (key) |
3287 | - * @param string what to return for that icon ('imgtag', 'alt', 'legend', 'file', 'url', 'size' {@link imgsize()}) |
3288 | + * @param string what to return for that icon ('imgtag', 'alt', 'legend', 'file', |
3289 | + * 'url', 'size' {@link imgsize()}) |
3290 | * @param array additional params ( |
3291 | - * 'class' => class name when getting 'imgtag', |
3292 | - * 'size' => param for 'size', |
3293 | - * 'title' => title attribute for 'imgtag') |
3294 | - * @param boolean true to include this icon into the legend at the bottom of the page (works for 'imgtag' only) |
3295 | + * - 'class' => class name when getting 'imgtag', |
3296 | + * - 'size' => param for 'size', |
3297 | + * - 'title' => title attribute for 'imgtag') |
3298 | + * @param boolean true to include this icon into the legend at the bottom of the |
3299 | + * page (works for 'imgtag' only) |
3300 | */ |
3301 | function get_icon( $iconKey, $what = 'imgtag', $params = NULL, $include_in_legend = false ) |
3302 | { |
3303 | @@ -2593,7 +2660,7 @@ |
3304 | require_once $conf_path.'_icons.php'; |
3305 | } |
3306 | |
3307 | - $icon = get_icon_info($iconKey); |
3308 | + $icon = get_icon_info( $iconKey ); |
3309 | if( ! $icon || ! isset( $icon['file'] ) ) |
3310 | { |
3311 | return '[no image defined for '.var_export( $iconKey, true ).'!]'; |
3312 | @@ -2648,7 +2715,7 @@ |
3313 | |
3314 | |
3315 | case 'class': |
3316 | - if( isset($icon['class']) ) |
3317 | + if( isset( $icon['class'] ) ) |
3318 | { |
3319 | return $icon['class']; |
3320 | } |
3321 | @@ -2798,8 +2865,10 @@ |
3322 | |
3323 | |
3324 | /** |
3325 | - * Get list of client IP addresses from REMOTE_ADDR and HTTP_X_FORWARDED_FOR, |
3326 | - * in this order. '' is used when no IP could be found. |
3327 | + * Get list of client IP addresses |
3328 | + * |
3329 | + * From REMOTE_ADDR and HTTP_X_FORWARDED_FOR, in that order. |
3330 | + * '' is used when no IP could be found. |
3331 | * |
3332 | * @param boolean True, to get only the first IP (probably REMOTE_ADDR) |
3333 | * @return array|string Depends on first param. |
3334 | @@ -2812,8 +2881,8 @@ |
3335 | { |
3336 | foreach( explode( ',', $_SERVER['REMOTE_ADDR'] ) as $l_ip ) |
3337 | { |
3338 | - $l_ip = trim($l_ip); |
3339 | - if( ! empty($l_ip) ) |
3340 | + $l_ip = trim( $l_ip ); |
3341 | + if( ! empty( $l_ip ) ) |
3342 | { |
3343 | $r[] = $l_ip; |
3344 | } |
3345 | @@ -2847,6 +2916,7 @@ |
3346 | * Get the base domain (without protocol and any subdomain) of an URL |
3347 | * |
3348 | * Gets a max of 3 domain parts (x.y.tld) |
3349 | + * |
3350 | * @param string URL |
3351 | * @return string the base domain (may become empty, if found invalid) |
3352 | */ |
3353 | @@ -2857,7 +2927,7 @@ |
3354 | // Chop away the http part and the path: |
3355 | $domain = preg_replace( '~^([a-z]+://)?([^:/#]+)(.*)$~i', '\\2', $url ); |
3356 | |
3357 | - if( empty($domain) || preg_match( '~^(\d+\.)+\d+$~', $domain ) ) |
3358 | + if( empty( $domain ) || preg_match( '~^(\d+\.)+\d+$~', $domain ) ) |
3359 | { |
3360 | // Empty or All numeric = IP address, don't try to cut it any further |
3361 | return $domain; |
3362 | @@ -2868,14 +2938,14 @@ |
3363 | // NOTE: \w includes "_" |
3364 | |
3365 | // convert URL to IDN: |
3366 | - $domain = idna_encode($domain); |
3367 | + $domain = idna_encode( $domain ); |
3368 | |
3369 | - $domain_pattern = '~ ( \w (\w|-|_)* \. ){0,2} \w (\w|-|_)* $~ix'; |
3370 | + $domain_pattern = '~ ( \w (\w|-|_)* \. ){0,2} \w (\w|-|_)* $~ix'; |
3371 | if( ! preg_match( $domain_pattern, $domain, $match ) ) |
3372 | { |
3373 | return ''; |
3374 | } |
3375 | - $base_domain = convert_charset(idna_decode($match[0]), $app_charset, 'UTF-8'); |
3376 | + $base_domain = convert_charset(idna_decode( $match[0] ), $app_charset, 'UTF-8'); |
3377 | |
3378 | // Remove any www*. prefix: |
3379 | $base_domain = preg_replace( '~^www.*?\.~i', '', $base_domain ); |
3380 | @@ -2886,6 +2956,7 @@ |
3381 | |
3382 | /** |
3383 | * Generate a valid key of size $length |
3384 | + * |
3385 | * @param integer length of key |
3386 | * @param string chars to use in generated key |
3387 | * @return string key |
3388 | @@ -2893,11 +2964,11 @@ |
3389 | function generate_random_key( $length = 32, $keychars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ) |
3390 | { |
3391 | $key = ''; |
3392 | - $rnd_max = strlen($keychars) - 1; |
3393 | + $rnd_max = strlen( $keychars ) - 1; |
3394 | |
3395 | for( $i = 0; $i < $length; $i++ ) |
3396 | { |
3397 | - $key .= $keychars{mt_rand(0, $rnd_max)}; // get a random character out of $keychars |
3398 | + $key .= $keychars{ mt_rand( 0, $rnd_max ) }; // get a random character out of $keychars |
3399 | } |
3400 | |
3401 | return $key; |
3402 | @@ -2906,6 +2977,7 @@ |
3403 | |
3404 | /** |
3405 | * Generate a random password with no ambiguous chars |
3406 | + * |
3407 | * @param integer length of password |
3408 | * @return string password |
3409 | */ |
3410 | @@ -2943,7 +3015,7 @@ |
3411 | return false; |
3412 | |
3413 | default: |
3414 | - debug_die( 'Unhandled action in form: '.strip_tags($action_parts[0]) ); |
3415 | + debug_die( 'Unhandled action in form: '.strip_tags( $action_parts[0] ) ); |
3416 | } |
3417 | } |
3418 | |
3419 | @@ -2952,7 +3024,6 @@ |
3420 | * Generate a link that toggles display of an element on clicking |
3421 | * |
3422 | * @todo Provide functionality to make those links accessible without JS (using GET parameter) |
3423 | - * |
3424 | * @uses toggle_display_by_id() (JS) |
3425 | * @param string ID (html) of the link |
3426 | * @param string ID (html) of the target to toggle displaying |
3427 | @@ -2971,13 +3042,14 @@ |
3428 | |
3429 | /** |
3430 | * Escape a string to be used in Javascript |
3431 | + * |
3432 | * @param string |
3433 | * @return string |
3434 | */ |
3435 | function jsspecialchars( $s ) |
3436 | { |
3437 | $r = str_replace( |
3438 | - array( '\\', '"', "'" ), |
3439 | + array( '\\', '"', "'" ), |
3440 | array( '\\\\', '\"', "\'" ), |
3441 | $s ); |
3442 | return htmlspecialchars( $r, ENT_QUOTES ); |
3443 | @@ -2986,6 +3058,7 @@ |
3444 | |
3445 | /** |
3446 | * Compact a date in a number keeping only integer value of the string |
3447 | + * |
3448 | * @param string date |
3449 | */ |
3450 | function compact_date( $date ) |
3451 | @@ -2996,16 +3069,18 @@ |
3452 | |
3453 | /** |
3454 | * Decompact a date in a date format ( Y-m-d h:m:s ) |
3455 | + * |
3456 | * @param string date |
3457 | */ |
3458 | function decompact_date( $date ) |
3459 | { |
3460 | $date0 = $date; |
3461 | - return substr($date0,0,4).'-'.substr($date0,4,2).'-'.substr($date0,6,2).' '.substr($date0,8,2).':'.substr($date0,10,2).':'.substr($date0,12,2); |
3462 | + return substr( $date0, 0, 4 ).'-'.substr( $date0, 4, 2 ).'-'.substr( $date0, 6, 2 ).' '.substr( $date0, 8, 2 ).':'.substr( $date0, 10, 2 ).':'.substr( $date0, 12, 2 ); |
3463 | } |
3464 | |
3465 | /** |
3466 | * Check the format of the phone number param and format it in a french number if it is |
3467 | + * |
3468 | * @param string phone number |
3469 | */ |
3470 | function format_phone( $phone, $hide_country_dialing_code_if_same_as_locale = true ) |
3471 | @@ -3046,7 +3121,7 @@ |
3472 | } |
3473 | else |
3474 | { |
3475 | - // ( +dialing xxxxxxxxxxx ) |
3476 | + // ( +dialing xxxxxxxxxxx ) |
3477 | $phone_formated = '+'.$dialing_code.' '.substr( $phone, strlen( $dialing_code )+1 ); |
3478 | } |
3479 | } |
3480 | @@ -3054,7 +3129,7 @@ |
3481 | { |
3482 | if( strlen( $phone ) == 10 ) |
3483 | { |
3484 | - // We can format it like a french phone number ( xx.xx.xx.xx.xx ) |
3485 | + // We can format it like a french phone number ( xx.xx.xx.xx.xx ) |
3486 | $phone_formated = format_french_phone( $phone ); |
3487 | } |
3488 | else |
3489 | @@ -3070,6 +3145,7 @@ |
3490 | |
3491 | /** |
3492 | * Format a string in a french phone number |
3493 | + * |
3494 | * @param string phone number |
3495 | */ |
3496 | function format_french_phone( $phone ) |
3497 | @@ -3079,13 +3155,11 @@ |
3498 | |
3499 | |
3500 | /** |
3501 | - * Generate a link to a online help resource. |
3502 | - * testing the concept of online help (aka webhelp). |
3503 | - * this function should be relocated somewhere better if it is taken onboard by the project |
3504 | - * |
3505 | - * @todo (legacy): replace [?] with icon, |
3506 | - * @todo (legacy): write url suffix dynamically based on topic and language |
3507 | - * |
3508 | + * Generate a link to a online help resource |
3509 | + * |
3510 | + * The idea is we can link a section in the admin to a help page. |
3511 | + * |
3512 | + * @deprecated by "monster" branch, though one day it might come back |
3513 | * @param string Topic |
3514 | * @return string |
3515 | */ |
3516 | @@ -3110,7 +3184,8 @@ |
3517 | |
3518 | |
3519 | /** |
3520 | - * Build a string out of $field_attribs, with each attribute prefixed by a space character. |
3521 | + * Build a string out of $field_attribs, with each attribute prefixed by a space character |
3522 | + * |
3523 | * @param array Array of field attributes. |
3524 | * @param boolean Use format_to_output() for the attributes? |
3525 | * @return string |
3526 | @@ -3135,7 +3210,7 @@ |
3527 | } |
3528 | else |
3529 | { |
3530 | - // @todo (0000): this uses strip_tags et al! Shouldn't we just use "formvalue" always? |
3531 | + // @todo (0000) this uses strip_tags et al! Shouldn't we just use "formvalue" always? |
3532 | // (E.g. it kills "for( var i=0; i<a; i++ )..." (in an onclick attr) from "<a" on. |
3533 | // The workaround is to use spaces ("i < a"), but I was confused first) |
3534 | $r .= ' '.$l_attr.'="'.format_to_output( $l_value, 'htmlattr' ).'"'; |
3535 | @@ -3172,9 +3247,9 @@ |
3536 | * If there are at least two elements, the last one is concatenated using |
3537 | * $implode_last, while the ones before are imploded using $implode_by. |
3538 | * |
3539 | - * @todo (0000): I don't think using entities/HTML as default for $implode_last is sane! |
3540 | + * @todo (0000) I don't think using entities/HTML as default for $implode_last is sane! |
3541 | * Use "&" instead and make sure that the output for HTML is HTML compliant.. |
3542 | - * @todo (0000): Support for locales that have a different kind of enumeration?! |
3543 | + * @todo (0000) Support for locales that have a different kind of enumeration?! |
3544 | * @return string |
3545 | */ |
3546 | function implode_with_and( $arr, $implode_by = ', ', $implode_last = ' & ' ) |
3547 | @@ -3182,16 +3257,15 @@ |
3548 | switch( count( $arr ) ) |
3549 | { |
3550 | case 0: |
3551 | - return ''; |
3552 | + return ''; |
3553 | |
3554 | case 1: |
3555 | - $r = array_shift( $arr ); |
3556 | - return $r; |
3557 | + $r = array_shift( $arr ); |
3558 | + return $r; |
3559 | |
3560 | default: |
3561 | - $r = implode( $implode_by, array_slice( $arr, 0, -1 ) ) |
3562 | - .$implode_last.array_pop( $arr ); |
3563 | - return $r; |
3564 | + $r = implode( $implode_by, array_slice( $arr, 0, -1 ) ).$implode_last.array_pop( $arr ); |
3565 | + return $r; |
3566 | } |
3567 | } |
3568 | |
3569 | @@ -3210,8 +3284,9 @@ |
3570 | */ |
3571 | function send_javascript_message( $methods = array(), $send_as_html = false, $target = '' ) |
3572 | { |
3573 | + global $Messages; |
3574 | + |
3575 | // lets spit out any messages |
3576 | - global $Messages; |
3577 | ob_start(); |
3578 | $Messages->display(); |
3579 | $output = ob_get_clean(); |
3580 | @@ -3286,29 +3361,30 @@ |
3581 | |
3582 | /** |
3583 | * Basic tidy up of strings |
3584 | - * @author {@link http://astonishme.co.uk/ Yabba (Paul Jones, rest in peace)} |
3585 | - * @author Tblue |
3586 | + * |
3587 | * @param string $unformatted raw data |
3588 | * @return string formatted data |
3589 | */ |
3590 | function format_to_js( $unformatted ) |
3591 | { |
3592 | - return str_replace( array( |
3593 | - '\'', |
3594 | - '\n', |
3595 | - '\r', |
3596 | - '\t', |
3597 | - "\n", |
3598 | - "\r", |
3599 | - ), |
3600 | - array( |
3601 | - '\\\'', |
3602 | - '\\\\n', |
3603 | - '\\\\r', |
3604 | - '\\\\t', |
3605 | - '\n', |
3606 | - '\r', |
3607 | - ), $unformatted ); |
3608 | + return str_replace( |
3609 | + array( |
3610 | + '\'', |
3611 | + '\n', |
3612 | + '\r', |
3613 | + '\t', |
3614 | + "\n", |
3615 | + "\r", |
3616 | + ), |
3617 | + array( |
3618 | + '\\\'', |
3619 | + '\\\\n', |
3620 | + '\\\\r', |
3621 | + '\\\\t', |
3622 | + '\n', |
3623 | + '\r', |
3624 | + ), |
3625 | + $unformatted ); |
3626 | } |
3627 | |
3628 | |
3629 | @@ -3334,6 +3410,7 @@ |
3630 | |
3631 | /** |
3632 | * Generate order by clause |
3633 | + * |
3634 | * @return string |
3635 | */ |
3636 | function gen_order_clause( $order_by, $order_dir, $dbprefix, $dbIDname_disambiguation ) |
3637 | @@ -3341,15 +3418,15 @@ |
3638 | $orderby = str_replace( ' ', ',', $order_by ); |
3639 | $orderby_array = explode( ',', $orderby ); |
3640 | |
3641 | - // Format each order param with default column names: |
3642 | + // Format each order param with default column names |
3643 | $orderby_array = preg_replace( '#^(.+)$#', $dbprefix.'$1 '.$order_dir, $orderby_array ); |
3644 | |
3645 | $order_by = implode( ', ', $orderby_array ); |
3646 | |
3647 | - // Special case for RAND: |
3648 | + // Special case for RAND |
3649 | $order_by = str_replace( $dbprefix.'RAND ', 'RAND() ', $order_by ); |
3650 | |
3651 | - // Add an ID parameter to make sure there is no ambiguity in ordering on similar items: |
3652 | + // Add an ID parameter to make sure there is no ambiguity in ordering on similar items |
3653 | $order_by = $order_by.', '.$dbIDname_disambiguation.' '.$order_dir; |
3654 | |
3655 | return $order_by; |
3656 | @@ -3358,6 +3435,7 @@ |
3657 | |
3658 | /** |
3659 | * Get the IconLegend instance |
3660 | + * |
3661 | * @return IconLegend or false, if the user has not set "display_icon_legend" |
3662 | */ |
3663 | function & get_IconLegend() |
3664 | @@ -3367,6 +3445,7 @@ |
3665 | if( ! isset( $IconLegend ) ) |
3666 | { |
3667 | global $UserSettings; |
3668 | + |
3669 | if( $UserSettings->get( 'display_icon_legend' ) ) |
3670 | { |
3671 | // Icon Legend |
3672 | @@ -3383,6 +3462,7 @@ |
3673 | |
3674 | /** |
3675 | * Check if two arrays contain the same elements |
3676 | + * |
3677 | * @param array The first array. |
3678 | * @param array The second array. |
3679 | * @return boolean True if both arrays contain the same elements, false otherwise. |
3680 | @@ -3391,9 +3471,8 @@ |
3681 | { |
3682 | $one_count = count( $one ); |
3683 | |
3684 | - /* We consider the arrays to be equal if they have the same number of |
3685 | - * elements and all elements of $one are present in $two. |
3686 | - */ |
3687 | + // We consider the arrays to be equal if they have the same number of |
3688 | + // elements and all elements of $one are present in $two. |
3689 | return $one_count == count( $two ) && count( array_intersect( $one, $two ) ) == $one_count; |
3690 | } |
3691 | |
3692 | @@ -3401,11 +3480,10 @@ |
3693 | /** |
3694 | * Get the Bazaar revision of this QP installation |
3695 | * |
3696 | - * Useful for snapshot users etc. -- they can include it in bug reports. |
3697 | - * This function tries to find out the current revision from the .bzr control |
3698 | - * directory or from the file .bzrrevision in the installation root (this is used |
3699 | - * for snapshots). |
3700 | - * |
3701 | + * Useful for snapshot users etc. -- they can include it in bug reports. This function |
3702 | + * tries to find out the current revision from the .bzr control directory or from |
3703 | + * the file .bzrrevision in the installation root (this is used for snapshots). |
3704 | + * |
3705 | * @return boolean|int false on failure, the bzr revision otherwise. |
3706 | */ |
3707 | function get_bzr_revision() |
3708 | |
3709 | === modified file 'qp_inc/_core/_param.funcs.php' |
3710 | --- qp_inc/_core/_param.funcs.php 2013-03-08 20:58:52 +0000 |
3711 | +++ qp_inc/_core/_param.funcs.php 2013-03-14 18:35:26 +0000 |
3712 | @@ -59,8 +59,8 @@ |
3713 | $use_default = true, |
3714 | $strict_typing = 'allow_empty' ) |
3715 | { |
3716 | + global $app_charset; |
3717 | global $debug; |
3718 | - global $app_charset; |
3719 | global $io_charset; |
3720 | |
3721 | // STEP 1 : Set the variable |
3722 | @@ -281,12 +281,13 @@ |
3723 | /** |
3724 | * Get the action from params |
3725 | * |
3726 | - * If we got no "action" param, we'll check for an "actionArray" param |
3727 | - * ( <input type="submit" name="actionArray[real_action]" ...> ). |
3728 | - * And the real $action will be found in the first key... |
3729 | - * When there are multiple submit buttons, this is smarter than checking the value |
3730 | - * which is a translated string. When there is an image button, this allows to work |
3731 | - * around IE not sending the value (it only sends X & Y coords of the click). |
3732 | + * If we got no "action" param, we'll check for an "actionArray" param (<input |
3733 | + * type="submit" name="actionArray[real_action]" ...>). And the real $action will |
3734 | + * be found in the first key... When there are multiple submit buttons, this is |
3735 | + * smarter than checking the value which is a translated string. When there is an |
3736 | + * image button, this allows to work around IE not sending the value (it only sends |
3737 | + * X & Y coords of the click). |
3738 | + * |
3739 | * @param mixed Default to use. |
3740 | * @return string |
3741 | */ |
3742 | @@ -312,6 +313,7 @@ |
3743 | * This is just a wrapper around {@link param()} which unsets and restores GET and |
3744 | * POST. IMHO this is less hackish, at least performance wise then using a $sources |
3745 | * param for param() |
3746 | + * |
3747 | * @uses param() |
3748 | * @see param() |
3749 | */ |
3750 | @@ -339,9 +341,12 @@ |
3751 | |
3752 | |
3753 | /** |
3754 | + * Check a param string to see if it is empty |
3755 | + * |
3756 | + * @uses param_check_not_empty() |
3757 | * @param string param name |
3758 | * @param string error message |
3759 | - * @param string|NULL error message for form field ($err_msg gets used if === NULL). |
3760 | + * @param string|NULL error message for form field; $err_msg gets used if === NULL. |
3761 | * @return boolean true if OK |
3762 | */ |
3763 | function param_string_not_empty( $var, $err_msg, $field_err_msg = NULL ) |
3764 | @@ -352,9 +357,12 @@ |
3765 | |
3766 | |
3767 | /** |
3768 | + * Check a param to see if it is empty |
3769 | + * |
3770 | + * @uses param_error() |
3771 | * @param string param name |
3772 | * @param string error message |
3773 | - * @param string|NULL error message for form field ($err_msg gets used if === NULL). |
3774 | + * @param string|NULL error message for form field; $err_msg gets used if === NULL. |
3775 | * @return boolean true if OK |
3776 | */ |
3777 | function param_check_not_empty( $var, $err_msg, $field_err_msg = NULL ) |
3778 | @@ -369,8 +377,9 @@ |
3779 | |
3780 | |
3781 | /** |
3782 | - * Checks if the param is an integer (no float, e.g. 3.14). |
3783 | + * Checks if the param is an integer (no float, e.g. 3.14) |
3784 | * |
3785 | + * @uses param_error() |
3786 | * @param string param name |
3787 | * @param string error message |
3788 | * @return boolean true if OK |
3789 | @@ -395,6 +404,7 @@ |
3790 | /** |
3791 | * Checks if the param is a decimal number |
3792 | * |
3793 | + * @uses param_error() |
3794 | * @param string param name |
3795 | * @param string error message |
3796 | * @return boolean true if OK |
3797 | @@ -417,7 +427,9 @@ |
3798 | |
3799 | |
3800 | /** |
3801 | - * Gets a param and makes sure it's a decimal number (no float, e.g. 3.14) in a given range. |
3802 | + * Gets a param and makes sure it's a decimal number (no float, e.g. 3.14) in a given range |
3803 | + * |
3804 | + * @uses param_check_range() |
3805 | * @param string param name |
3806 | * @param integer min value |
3807 | * @param integer max value |
3808 | @@ -433,6 +445,8 @@ |
3809 | |
3810 | /** |
3811 | * Checks if the param is a decimal number (no float, e.g. 3.14) in a given range |
3812 | + * |
3813 | + * @uses param_error() |
3814 | * @param string param name |
3815 | * @param integer min value |
3816 | * @param integer max value |
3817 | @@ -458,6 +472,9 @@ |
3818 | |
3819 | |
3820 | /** |
3821 | + * Check if an email address is valid or not |
3822 | + * |
3823 | + * @uses param_error() |
3824 | * @param string param name |
3825 | * @return boolean true if OK |
3826 | */ |
3827 | @@ -469,7 +486,7 @@ |
3828 | return true; |
3829 | } |
3830 | |
3831 | - if( !is_email( $GLOBALS[$var] ) ) |
3832 | + if( ! is_email( $GLOBALS[$var] ) ) |
3833 | { |
3834 | param_error( $var, T_('The email address is invalid.') ); |
3835 | return false; |
3836 | @@ -479,6 +496,10 @@ |
3837 | |
3838 | |
3839 | /** |
3840 | + * Checks to see if a URL is a valid format |
3841 | + * |
3842 | + * @uses param_error() |
3843 | + * @uses validate_url() |
3844 | * @param string param name |
3845 | * @param string |
3846 | * @return boolean true if OK |
3847 | @@ -500,6 +521,8 @@ |
3848 | |
3849 | /** |
3850 | * Check if the value is a file name |
3851 | + * |
3852 | + * @uses param_error() |
3853 | * @param string param name |
3854 | * @param string error message |
3855 | * @return boolean true if OK |
3856 | @@ -516,10 +539,12 @@ |
3857 | |
3858 | |
3859 | /** |
3860 | - * Check if the value of a param is a regular expression (syntax). |
3861 | + * Check if the value of a param is a regular expression (syntax) |
3862 | + * |
3863 | + * @uses param_error() |
3864 | * @param string param name |
3865 | * @param string error message |
3866 | - * @param string|NULL error message for form field ($err_msg gets used if === NULL). |
3867 | + * @param string|NULL error message for form field; $err_msg gets used if === NULL. |
3868 | * @return boolean true if OK |
3869 | */ |
3870 | function param_check_isregexp( $var, $err_msg, $field_err_msg = NULL ) |
3871 | @@ -535,7 +560,11 @@ |
3872 | |
3873 | /** |
3874 | * Sets a date parameter by converting locale date (if valid) to ISO date |
3875 | + * |
3876 | * If the date is not valid, it is set to the param unchanged (unconverted). |
3877 | + * |
3878 | + * @uses param_check_date() |
3879 | + * @uses set_param() |
3880 | * @param string param name |
3881 | * @param string error message |
3882 | * @param boolean Is a non-empty date required? |
3883 | @@ -567,6 +596,8 @@ |
3884 | * |
3885 | * NOTE: for tokens like e.g. "D" (abbr. weekday), T_() gets used and it uses |
3886 | * the current locale! |
3887 | + * |
3888 | + * @uses param_error() |
3889 | * @param string param name |
3890 | * @param string error message |
3891 | * @param boolean Is a non-empty date required? |
3892 | @@ -604,13 +635,13 @@ |
3893 | return "([1-3]?\\d)"; // day, 1-31 |
3894 | |
3895 | case "l": |
3896 | - return "(".str_replace("~", "\~", implode("|", array_map("trim", array_map("T_", $GLOBALS["weekday"])))).")"; |
3897 | + return "(".str_replace( "~", "\~", implode( "|", array_map( "trim", array_map( "T_", $GLOBALS["weekday"] ) ) ) ).")"; |
3898 | |
3899 | case "D": |
3900 | - return "(".str_replace("~", "\~", implode("|", array_map("trim", array_map("T_", $GLOBALS["weekday_abbrev"])))).")"; |
3901 | + return "(".str_replace( "~", "\~", implode( "|", array_map( "trim", array_map( "T_", $GLOBALS["weekday_abbrev"] ) ) ) ).")"; |
3902 | |
3903 | case "e": // QP extension! |
3904 | - return "(".str_replace("~", "\~", implode("|", array_map("trim", array_map("T_", $GLOBALS["weekday_letter"])))).")"; |
3905 | + return "(".str_replace( "~", "\~", implode( "|", array_map( "trim", array_map( "T_", $GLOBALS["weekday_letter"] ) ) ) ).")"; |
3906 | |
3907 | case "S": |
3908 | return "(st|nd|rd|th)"; // english suffix for day |
3909 | @@ -622,10 +653,10 @@ |
3910 | return "(1?\\d)"; // month, 1-12 |
3911 | |
3912 | case "F": |
3913 | - return "(".str_replace("~", "\~", implode("|", array_map("trim", array_map("T_", $GLOBALS["month"])))).")"; // A full textual representation of a month, such as January or March |
3914 | + return "(".str_replace("~", "\~", implode( "|", array_map( "trim", array_map( "T_", $GLOBALS["month"] ) ) ) ).")"; // A full textual representation of a month, such as January or March |
3915 | |
3916 | case "M": |
3917 | - return "(".str_replace("~", "\~", implode("|", array_map("trim", array_map("T_", $GLOBALS["month_abbrev"])))).")"; |
3918 | + return "(".str_replace("~", "\~", implode( "|", array_map( "trim", array_map( "T_", $GLOBALS["month_abbrev"] ) ) ) ).")"; |
3919 | |
3920 | case "y": |
3921 | return "(\\d\\d)"; // year, 00-99 |
3922 | @@ -657,30 +688,30 @@ |
3923 | { |
3924 | case 'd': |
3925 | case 'j': |
3926 | - $day = $numbers[$position+1]; |
3927 | + $day = $numbers[$position + 1]; |
3928 | break; |
3929 | |
3930 | case 'm': |
3931 | case 'n': |
3932 | - $month = $numbers[$position+1]; |
3933 | + $month = $numbers[$position + 1]; |
3934 | break; |
3935 | |
3936 | // full month name |
3937 | case 'F': |
3938 | $month = array_search( |
3939 | - strtolower( $numbers[$position+1] ), array_map( 'strtolower', array_map( |
3940 | + strtolower( $numbers[$position + 1] ), array_map( 'strtolower', array_map( |
3941 | 'trim', array_map( 'T_', $GLOBALS['month'] ) ) ) ); |
3942 | break; |
3943 | |
3944 | case 'M': |
3945 | $month = array_search( |
3946 | - strtolower( $numbers[$position+1] ), array_map( 'strtolower', array_map( |
3947 | + strtolower( $numbers[$position + 1] ), array_map( 'strtolower', array_map( |
3948 | 'trim', array_map( 'T_', $GLOBALS['month_abbrev'] ) ) ) ); |
3949 | break; |
3950 | |
3951 | case 'y': |
3952 | case 'Y': |
3953 | - $year = $numbers[$position+1]; |
3954 | + $year = $numbers[$position + 1]; |
3955 | if( $year < 50 ) |
3956 | { |
3957 | $year = 2000 + $year; |
3958 | @@ -695,7 +726,7 @@ |
3959 | |
3960 | if( checkdate( $month, $day, $year ) ) |
3961 | { |
3962 | - // all clean! :) We convert the value to ISO |
3963 | + // all clean! :) We convert the value to ISO |
3964 | $iso_date = substr( '0'.$year, -4 ).'-'.substr( '0'.$month, -2 ).'-'.substr( '0'.$day, -2 ); |
3965 | |
3966 | return $iso_date; |
3967 | @@ -710,8 +741,12 @@ |
3968 | |
3969 | |
3970 | /** |
3971 | - * Sets a date parameter with values from the request or to provided default, |
3972 | - * And check we have a compact date (numbers only) ( used for URL filtering ) |
3973 | + * Sets a date parameter with values from the request or to provided default |
3974 | + * |
3975 | + * Also check we have a compact date (numbers only) used for URL filtering. |
3976 | + * |
3977 | + * @uses param_check_date() |
3978 | + * @uses set_param() |
3979 | * @param string Variable to set |
3980 | * @param mixed Default value or TRUE if user input required |
3981 | * @param boolean memorize ( see {@link param()} ) |
3982 | @@ -749,8 +784,11 @@ |
3983 | * Set a time parameter with the value from the request of the var argument |
3984 | * |
3985 | * Sets a time parameter with the value from the request of the var argument |
3986 | - * or of the concat of the var argument_h: var argument_mn: var argument_s , |
3987 | + * or of the concat of the var argument_h: var argument_mn: var argument_s, |
3988 | * except if param is already set! |
3989 | + * |
3990 | + * @uses param() |
3991 | + * @uses param_error() |
3992 | * @param string Variable to set |
3993 | * @param mixed Default value or TRUE if user input required |
3994 | * @param boolean Do we need to memorize this to regenerate the URL for this page? |
3995 | @@ -803,14 +841,16 @@ |
3996 | |
3997 | |
3998 | /** |
3999 | - * Extend a LIST parameter with an ARRAY param. |
4000 | + * Extend a LIST parameter with an ARRAY param |
4001 | * |
4002 | * Will be used for author/authorsel[], etc. Note: cannot be used for catsel[] |
4003 | * because catsel is NON-recursive. |
4004 | + * |
4005 | + * @uses param() |
4006 | * @see param_compile_cat_array() |
4007 | * @param string Variable to extend |
4008 | * @param string Name of array Variable to use as an extension |
4009 | - * @param boolean Save non numeric prefix? ( 1 char -- can be used as a modifier, e-g: - + * ) |
4010 | + * @param boolean Save non numeric prefix? ( 1 char -- can be used as a modifier, e-g: - + * ) |
4011 | */ |
4012 | function param_extend_list( $var, $var_ext_array, $save_prefix = true ) |
4013 | { |
4014 | @@ -866,16 +906,22 @@ |
4015 | |
4016 | |
4017 | /** |
4018 | + * Compiles the cat array from $cat |
4019 | + * |
4020 | * Compiles the cat array from $cat (recursive + optional modifiers) and |
4021 | * $catsel[] (non recursive) and keeps those values available for future |
4022 | * reference (category widget) |
4023 | + * |
4024 | + * @uses param() |
4025 | + * @uses compile_cat_array() |
4026 | */ |
4027 | function param_compile_cat_array( $restrict_to_blog = 0, $cat_default = NULL, $catsel_default = array() ) |
4028 | { |
4029 | // For now, we'll need those as globals! |
4030 | // fp> this is used for the categories widget |
4031 | // fp> we want might to use a $set_globals params to compile_cat_array() |
4032 | - global $cat_array, $cat_modifier; |
4033 | + global $cat_array; |
4034 | + global $cat_modifier; |
4035 | |
4036 | $cat = param( 'cat', '/^[*\-]?([0-9]+(,[0-9]+)*)?$/', $cat_default, true ); // List of cats to restrict to |
4037 | $catsel = param( 'catsel', 'array', $catsel_default, true ); // Array of cats to restrict to |
4038 | @@ -888,9 +934,12 @@ |
4039 | |
4040 | |
4041 | /** |
4042 | + * params check at least once |
4043 | + * |
4044 | + * @uses param_error_multiple() |
4045 | * @param array of param names |
4046 | * @param string error message |
4047 | - * @param string|NULL error message for form field ($err_msg gets used if === NULL). |
4048 | + * @param string|NULL error message for form field; $err_msg gets used if === NULL. |
4049 | * @return boolean true if OK |
4050 | */ |
4051 | function params_check_at_least_one( $vars, $err_msg, $field_err_msg = NULL ) |
4052 | @@ -911,10 +960,13 @@ |
4053 | |
4054 | |
4055 | /** |
4056 | - * Sets a combo parameter with values from the request, |
4057 | - * => the value of the select option and the input text value if new is selected |
4058 | - * Display an error if the new value is selected that the input text has a value |
4059 | - * |
4060 | + * Sets a combo parameter with values from the request |
4061 | + * |
4062 | + * The value of the select option and the input text value if new is selected, |
4063 | + * Display an error if the new value is selected that the input text has a value. |
4064 | + * |
4065 | + * @uses param() |
4066 | + * @uses param_error() |
4067 | * @param string Variable to set |
4068 | * @param mixed Default value or TRUE if user input required |
4069 | * @param boolean true: allows to select new without entring a value in the input combo text |
4070 | @@ -948,7 +1000,8 @@ |
4071 | |
4072 | |
4073 | /** |
4074 | - * set a parameter with the second part(X2) of the value from request ( X1-X2 ) |
4075 | + * set a parameter with the second part(X2) of the value from request (X1-X2) |
4076 | + * |
4077 | * @param string Variable to set |
4078 | */ |
4079 | function param_child_select_value( $var ) |
4080 | @@ -973,6 +1026,8 @@ |
4081 | |
4082 | /** |
4083 | * @param string param name |
4084 | + * |
4085 | + * @uses param_error() |
4086 | * @return boolean true if OK |
4087 | */ |
4088 | function param_check_phone( $var, $required = false ) |
4089 | @@ -1000,6 +1055,10 @@ |
4090 | |
4091 | |
4092 | /** |
4093 | + * Check passwords (2 entered, they match) |
4094 | + * |
4095 | + * @uses param_error() |
4096 | + * @uses param_error_multiple() |
4097 | * @param string param name |
4098 | * @param string param name |
4099 | * @param boolean Is a password required? (non-empty) |
4100 | @@ -1012,18 +1071,18 @@ |
4101 | $pass1 = $GLOBALS[$var1]; |
4102 | $pass2 = $GLOBALS[$var2]; |
4103 | |
4104 | - if( empty($pass1) && empty($pass2) && ! $required ) |
4105 | + if( empty( $pass1 ) && empty( $pass2 ) && ! $required ) |
4106 | { |
4107 | // empty is OK |
4108 | return true; |
4109 | } |
4110 | |
4111 | - if( empty($pass1) ) |
4112 | + if( empty( $pass1 ) ) |
4113 | { |
4114 | param_error( $var1, T_('Please enter your password twice.') ); |
4115 | return false; |
4116 | } |
4117 | - if( empty($pass2) ) |
4118 | + if( empty( $pass2 ) ) |
4119 | { |
4120 | param_error( $var2, T_('Please enter your password twice.') ); |
4121 | return false; |
4122 | @@ -1032,13 +1091,13 @@ |
4123 | // checking the password has been typed twice the same |
4124 | if( $pass1 != $pass2 ) |
4125 | { |
4126 | - param_error_multiple( array( $var1, $var2), T_('You typed two different passwords.') ); |
4127 | + param_error_multiple( array( $var1, $var2 ), T_('You typed two different passwords.') ); |
4128 | return false; |
4129 | } |
4130 | |
4131 | if( strlen( $pass1 ) < $Settings->get( 'user_minpwdlen' ) ) |
4132 | { |
4133 | - param_error_multiple( array( $var1, $var2), sprintf( T_('The minimum password length is %d characters.'), $Settings->get( 'user_minpwdlen' ) ) ); |
4134 | + param_error_multiple( array( $var1, $var2 ), sprintf( T_('The minimum password length is %d characters.'), $Settings->get( 'user_minpwdlen' ) ) ); |
4135 | return false; |
4136 | } |
4137 | |
4138 | @@ -1056,7 +1115,7 @@ |
4139 | { |
4140 | global $Messages; |
4141 | |
4142 | - return $Messages->count('error'); |
4143 | + return $Messages->count( 'error' ); |
4144 | } |
4145 | |
4146 | |
4147 | @@ -1073,6 +1132,7 @@ |
4148 | |
4149 | /** |
4150 | * Get error message for a param |
4151 | + * |
4152 | * @return string |
4153 | */ |
4154 | function param_get_error_msg( $var ) |
4155 | @@ -1089,10 +1149,14 @@ |
4156 | |
4157 | |
4158 | /** |
4159 | - * Add an error for a variable, either to the Form's field and/or the global {@link $Messages} object |
4160 | + * Add an error for a variable |
4161 | + * |
4162 | + * Either to the Form's field and/or the global {@link $Messages} object |
4163 | + * |
4164 | + * @uses param_add_message_to_Log() |
4165 | * @param string param name |
4166 | * @param string|NULL error message (by using NULL you can only add an error to the field, but not the $Message object) |
4167 | - * @param string|NULL error message for form field ($err_msg gets used if === NULL). |
4168 | + * @param string|NULL error message for form field - $err_msg gets used if === NULL. |
4169 | */ |
4170 | function param_error( $var, $err_msg, $field_err_msg = NULL ) |
4171 | { |
4172 | @@ -1107,7 +1171,7 @@ |
4173 | } |
4174 | $param_input_err_messages[$var] = $field_err_msg; |
4175 | |
4176 | - if( isset($err_msg) ) |
4177 | + if( isset( $err_msg ) ) |
4178 | { |
4179 | param_add_message_to_Log( $var, $err_msg, 'error' ); |
4180 | } |
4181 | @@ -1116,11 +1180,14 @@ |
4182 | |
4183 | |
4184 | /** |
4185 | - * Add an error for multiple variables, either to the Form's field and/or the global {@link $Messages} object. |
4186 | - * |
4187 | + * Add an error for multiple variables |
4188 | + * |
4189 | + * Either to the Form's field and/or the global {@link $Messages} object. |
4190 | + * |
4191 | + * @uses param_add_message_to_Log() |
4192 | * @param array of param names |
4193 | * @param string|NULL error message (by using NULL you can only add an error to the field, but not the $Message object) |
4194 | - * @param string|NULL error message for form fields ($err_msg gets used if === NULL). |
4195 | + * @param string|NULL error message for form fields - $err_msg gets used if === NULL. |
4196 | */ |
4197 | function param_error_multiple( $vars, $err_msg, $field_err_msg = NULL ) |
4198 | { |
4199 | @@ -1140,7 +1207,7 @@ |
4200 | } |
4201 | } |
4202 | |
4203 | - if( isset($err_msg) ) |
4204 | + if( isset( $err_msg ) ) |
4205 | { |
4206 | param_add_message_to_Log( $var, $err_msg, 'error' ); |
4207 | } |
4208 | @@ -1162,8 +1229,8 @@ |
4209 | |
4210 | if( ! empty( $link_param_err_messages_to_field_IDs ) ) |
4211 | { |
4212 | - $var_id = Form::get_valid_id($var); |
4213 | - $start_link = '<a href="#'.$var_id.'" onclick="var form_elem = document.getElementById(\''.$var_id.'\'); if( form_elem ) { if(form_elem.select) { form_elem.select(); } else if(form_elem.focus) { form_elem.focus(); } }">'; // "SELECT" does not have .select() |
4214 | + $var_id = Form::get_valid_id( $var ); |
4215 | + $start_link = '<a href="#'.$var_id.'" onclick="var form_elem = document.getElementById(\''.$var_id.'\'); if( form_elem ) { if(form_elem.select) { form_elem.select(); } else if(form_elem.focus) { form_elem.focus(); } }">'; |
4216 | |
4217 | if( strpos( $err_msg, '<a' ) !== false ) |
4218 | { |
4219 | @@ -1171,7 +1238,7 @@ |
4220 | $err_msg = preg_replace( '~(\s*)(<a\s+[^>]+>[^<]*</a>\s*)~i', '</a>$1»$2'.$start_link, $err_msg ); |
4221 | } |
4222 | |
4223 | - if( substr($err_msg, 0, 4) == '</a>' ) |
4224 | + if( substr( $err_msg, 0, 4 ) == '</a>' ) |
4225 | { |
4226 | // There was a link at the beginning of $err_msg: we do not prepend an emtpy link before it |
4227 | $Messages->add( substr( $err_msg, 4 ).'</a>', $log_category ); |
4228 | @@ -1208,9 +1275,9 @@ |
4229 | $global_param_list = array(); |
4230 | } |
4231 | |
4232 | - $global_param_list[$var] = array( 'type' => $type, 'default' => (($default===true) ? NULL : $default) ); |
4233 | + $global_param_list[$var] = array( 'type' => $type, 'default' => ( ( $default === true ) ? NULL : $default ) ); |
4234 | |
4235 | - if( !is_null( $value ) ) |
4236 | + if( ! is_null( $value ) ) |
4237 | { |
4238 | // We want to set the variable too |
4239 | set_param( $var, $value ); |
4240 | @@ -1219,7 +1286,8 @@ |
4241 | |
4242 | |
4243 | /** |
4244 | - * Forget a param so that is will not get included in subsequent {@link regenerate_url()} calls. |
4245 | + * Forget a param so that is will not get included in subsequent {@link regenerate_url()} calls |
4246 | + * |
4247 | * @param string Param name |
4248 | */ |
4249 | function forget_param( $var ) |
4250 | @@ -1237,7 +1305,7 @@ |
4251 | { |
4252 | global $global_param_list; |
4253 | |
4254 | - return isset($global_param_list[$var]); |
4255 | + return isset( $global_param_list[$var] ); |
4256 | } |
4257 | |
4258 | |
4259 | @@ -1258,7 +1326,7 @@ |
4260 | |
4261 | |
4262 | /** |
4263 | - * Get the value of a param. |
4264 | + * Get the value of a param |
4265 | * |
4266 | * @return NULL|mixed The value of the param, if set. NULL otherwise. |
4267 | */ |
4268 | @@ -1302,6 +1370,7 @@ |
4269 | if( ! in_array( $var, $ignore ) ) |
4270 | { |
4271 | global $$var; |
4272 | + |
4273 | $value = $$var; |
4274 | $memo[$var] = $$var; |
4275 | } |
4276 | @@ -1313,8 +1382,9 @@ |
4277 | |
4278 | /** |
4279 | * Regenerate current URL from parameters |
4280 | - * This may clean it up |
4281 | - * But it is also useful when generating static pages: you cannot rely on $_REQUEST[] |
4282 | + * |
4283 | + * This may clean it up, but it is also useful when generating static pages: you |
4284 | + * cannot rely on $_REQUEST[] |
4285 | * |
4286 | * @param mixed|string (delimited by commas) or array of params to ignore (can be regexps in /.../) |
4287 | * @param array|string Param(s) to set |
4288 | @@ -1323,29 +1393,31 @@ |
4289 | */ |
4290 | function regenerate_url( $ignore = '', $set = '', $pagefileurl = '', $glue = '&' ) |
4291 | { |
4292 | - global $global_param_list, $ReqHost, $ReqPath; |
4293 | global $base_tag_set; |
4294 | + global $global_param_list; |
4295 | + global $ReqHost; |
4296 | + global $ReqPath; |
4297 | |
4298 | // Transform ignore param into an array: |
4299 | - if( empty($ignore) ) |
4300 | + if( empty( $ignore ) ) |
4301 | { |
4302 | $ignore = array(); |
4303 | } |
4304 | - elseif( !is_array($ignore) ) |
4305 | + elseif( ! is_array( $ignore ) ) |
4306 | { |
4307 | $ignore = explode( ',', $ignore ); |
4308 | } |
4309 | |
4310 | - // Construct array of all params that have been memorized: |
4311 | + // Construct array of all params that have been memorized |
4312 | // (Note: we only include values if they differ from the default and they are not in the ignore list) |
4313 | $params = array(); |
4314 | - if( isset($global_param_list) ) foreach( $global_param_list as $var => $thisparam ) |
4315 | + if( isset( $global_param_list ) ) foreach( $global_param_list as $var => $thisparam ) |
4316 | { |
4317 | // For each saved param... |
4318 | $type = $thisparam['type']; |
4319 | $defval = $thisparam['default']; |
4320 | |
4321 | - // Check if the param should to be ignored: |
4322 | + // Check if the param should to be ignored |
4323 | $skip = false; |
4324 | foreach( $ignore as $ignore_pattern ) |
4325 | { |
4326 | @@ -1386,13 +1458,13 @@ |
4327 | $url_array = array(); |
4328 | foreach( $value as $value ) |
4329 | { |
4330 | - $params[] = $var.'%5B%5D='.rawurlencode($value); |
4331 | + $params[] = $var.'%5B%5D='.rawurlencode( $value ); |
4332 | } |
4333 | } |
4334 | else |
4335 | { |
4336 | // not an array : normal formatting |
4337 | - $params[] = $var.'='.rawurlencode($value); |
4338 | + $params[] = $var.'='.rawurlencode( $value ); |
4339 | } |
4340 | } |
4341 | } |
4342 | @@ -1402,7 +1474,7 @@ |
4343 | { |
4344 | // We got some forced params |
4345 | // Transform set param into an array: |
4346 | - if( !is_array($set) ) |
4347 | + if( ! is_array( $set ) ) |
4348 | { |
4349 | $set = array( $set ); |
4350 | } |
4351 | @@ -1437,7 +1509,7 @@ |
4352 | |
4353 | |
4354 | /** |
4355 | - * Checks if a given regular expression is valid. |
4356 | + * Checks if a given regular expression is valid |
4357 | * |
4358 | * It changes the error_handler and restores it. |
4359 | * |
4360 | @@ -1461,7 +1533,7 @@ |
4361 | |
4362 | |
4363 | /** |
4364 | - * Meant to replace error handler temporarily. |
4365 | + * Meant to replace error handler temporarily |
4366 | * |
4367 | * @return integer number of errors |
4368 | */ |
4369 | @@ -1494,12 +1566,12 @@ |
4370 | { |
4371 | if( is_array( $mixed ) ) |
4372 | { |
4373 | - foreach($mixed as $k => $v) |
4374 | + foreach( $mixed as $k => $v ) |
4375 | { |
4376 | $mixed[$k] = remove_magic_quotes( $v ); |
4377 | } |
4378 | } |
4379 | - elseif( is_string($mixed) ) |
4380 | + elseif( is_string( $mixed ) ) |
4381 | { |
4382 | $mixed = str_replace( '\'\'', '\'', $mixed ); |
4383 | } |
4384 | @@ -1509,7 +1581,8 @@ |
4385 | else |
4386 | { |
4387 | /** |
4388 | - * Remove quotes from input. |
4389 | + * Remove quotes from input |
4390 | + * |
4391 | * This handles magic_quotes_gpc and magic_quotes_sybase PHP settings/variants. |
4392 | * |
4393 | * NOTE: you should not use it directly, but one of the param-functions! |
4394 | @@ -1521,12 +1594,12 @@ |
4395 | { |
4396 | if( is_array( $mixed ) ) |
4397 | { |
4398 | - foreach($mixed as $k => $v) |
4399 | + foreach( $mixed as $k => $v ) |
4400 | { |
4401 | $mixed[$k] = remove_magic_quotes( $v ); |
4402 | } |
4403 | } |
4404 | - elseif( is_string($mixed) ) |
4405 | + elseif( is_string( $mixed ) ) |
4406 | { |
4407 | $mixed = stripslashes( $mixed ); |
4408 | } |
4409 | @@ -1547,11 +1620,10 @@ |
4410 | |
4411 | |
4412 | /** |
4413 | - * Checks for sanitized code. |
4414 | + * Checks for sanitized code |
4415 | * |
4416 | - * WARNING: this does *NOT* (necessarilly) make the HTML code safe. |
4417 | - * It only checks on it and produces error messages. |
4418 | - * It is NOT (necessarily) safe to use the output. |
4419 | + * WARNING: this does *NOT* (necessarilly) make the HTML code safe. It only checks |
4420 | + * on it and produces error messages. It is NOT (necessarily) safe to use the output. |
4421 | * |
4422 | * @param string param name |
4423 | * @param string error message |
4424 | @@ -1587,7 +1659,7 @@ |
4425 | |
4426 | |
4427 | /** |
4428 | - * DEPRECATED Stub for plugin compatibility: |
4429 | + * DEPRECATED Stub for plugin compatibility |
4430 | */ |
4431 | function format_to_post( $content, $autobr = 0, $is_comment = 0, $encoding = NULL ) |
4432 | { |
4433 | @@ -1694,13 +1766,13 @@ |
4434 | { |
4435 | if( $context == 'xmlrpc_posting' ) |
4436 | { |
4437 | - $errmsg = ($context == 'commenting') |
4438 | + $errmsg = ( $context == 'commenting' ) |
4439 | ? T_('Illegal content found (spam?)') |
4440 | : sprintf( T_('Illegal content found: blacklisted word "%s"'), $block ); |
4441 | } |
4442 | else |
4443 | { |
4444 | - $errmsg = ($context == 'commenting') |
4445 | + $errmsg = ( $context == 'commenting' ) |
4446 | ? T_('Illegal content found (spam?)') |
4447 | : sprintf( T_('Illegal content found: blacklisted word «%s»'), htmlspecialchars( $block ) ); |
4448 | } |
4449 | @@ -1753,7 +1825,7 @@ |
4450 | { |
4451 | // We want to validate XHTML |
4452 | |
4453 | - // figure out what we want to validate against ($flavor) |
4454 | + // figure out what we want to validate against |
4455 | $skip = false; |
4456 | $flavor = 'xhtml'; |
4457 | $source = array_merge( array( |
4458 | @@ -1831,7 +1903,7 @@ |
4459 | // DEPRECATED but still... |
4460 | $content = strip_tags( $content, $comment_allowed_tags ); |
4461 | } |
4462 | - else if( ! $escape_comments |
4463 | + elseif( ! $escape_comments |
4464 | && preg_match_all( '#(?:<!--|<!\[CDATA\[|<\?)#i', $content, $matches, PREG_OFFSET_CAPTURE ) ) |
4465 | { |
4466 | // We are posting an item, try an el-cheapo check for unclosed comments, |
4467 | @@ -1926,7 +1998,8 @@ |
4468 | |
4469 | |
4470 | /** |
4471 | - * Balances Tags of string using a modified stack. |
4472 | + * Balances Tags of string using a modified stack |
4473 | + * |
4474 | * @param string HTML to be balanced |
4475 | * @return string Balanced HTML |
4476 | */ |
4477 | @@ -1941,39 +2014,41 @@ |
4478 | { |
4479 | $newtext = $newtext.$tagqueue; |
4480 | |
4481 | - $i = strpos($text,$regex[0]); |
4482 | - $l = strlen($tagqueue) + strlen($regex[0]); |
4483 | + $i = strpos( $text,$regex[0] ); |
4484 | + $l = strlen( $tagqueue ) + strlen( $regex[0] ); |
4485 | |
4486 | // clear the shifter |
4487 | $tagqueue = ''; |
4488 | |
4489 | // Pop or Push |
4490 | - if( substr($regex[1],0,1) == '/' ) |
4491 | + if( substr( $regex[1], 0, 1 ) == '/' ) |
4492 | { |
4493 | // End Tag |
4494 | - $tag = strtolower(substr($regex[1],1)); |
4495 | + $tag = strtolower( substr( $regex[1], 1 ) ); |
4496 | |
4497 | // if too many closing tags |
4498 | - if($stacksize <= 0) |
4499 | + if( $stacksize <= 0 ) |
4500 | { |
4501 | $tag = ''; |
4502 | // or close to be safe $tag = '/'.$tag; |
4503 | } |
4504 | // if stacktop value = tag close value then pop |
4505 | - else if( $tagstack[$stacksize - 1] == $tag ) |
4506 | + elseif( $tagstack[$stacksize - 1] == $tag ) |
4507 | { |
4508 | // found closing tag |
4509 | $tag = '</'.$tag.'>'; // Close Tag |
4510 | // Pop |
4511 | - array_pop ($tagstack); |
4512 | + array_pop ( $tagstack ); |
4513 | $stacksize--; |
4514 | } else { |
4515 | // closing tag not at top, search for it |
4516 | - for ($j=$stacksize-1;$j>=0;$j--) { |
4517 | + for( $j = $stacksize - 1; $j >= 0; $j-- ) |
4518 | + { |
4519 | if( $tagstack[$j] == $tag ) |
4520 | { |
4521 | // add tag to tagqueue |
4522 | - for ($k=$stacksize-1;$k>=$j;$k--){ |
4523 | + for( $k = $stacksize - 1; $k >= $j; $k-- ) |
4524 | + { |
4525 | $tagqueue .= '</'.array_pop( $tagstack ).'>'; |
4526 | $stacksize--; |
4527 | } |
4528 | @@ -1986,14 +2061,14 @@ |
4529 | else |
4530 | { |
4531 | // Begin Tag |
4532 | - $tag = strtolower($regex[1]); |
4533 | + $tag = strtolower( $regex[1] ); |
4534 | |
4535 | // Tag Cleaning |
4536 | |
4537 | // Push if not img, br, hr, param or input |
4538 | - if($tag != 'br' && $tag != 'img' && $tag != 'hr' && $tag != 'param' && $tag != 'input') |
4539 | + if( $tag != 'br' && $tag != 'img' && $tag != 'hr' && $tag != 'param' && $tag != 'input' ) |
4540 | { |
4541 | - $stacksize = array_push ($tagstack, $tag); |
4542 | + $stacksize = array_push ( $tagstack, $tag ); |
4543 | $closing = '>'; |
4544 | } |
4545 | else |
4546 | @@ -2003,16 +2078,16 @@ |
4547 | // Attributes |
4548 | // $attributes = $regex[2]; |
4549 | $attributes = $regex[2]; |
4550 | - if($attributes) |
4551 | + if( $attributes ) |
4552 | { |
4553 | - $attributes = ' '.trim($attributes); |
4554 | + $attributes = ' '.trim( $attributes ); |
4555 | } |
4556 | |
4557 | $tag = '<'.$tag.$attributes.$closing; |
4558 | } |
4559 | |
4560 | $newtext .= substr( $text, 0, $i ).$tag; |
4561 | - $text = substr($text,$i+$l); |
4562 | + $text = substr( $text, $i + $l ); |
4563 | } |
4564 | |
4565 | // Clear Tag Queue |
4566 | @@ -2022,12 +2097,11 @@ |
4567 | $newtext .= $text; |
4568 | |
4569 | // Empty Stack |
4570 | - while($x = array_pop($tagstack)) { |
4571 | + while( $x = array_pop( $tagstack ) ) |
4572 | + { |
4573 | $newtext = $newtext.'</'.$x.'>'; // Add remaining tags to close |
4574 | } |
4575 | - |
4576 | return $newtext; |
4577 | } |
4578 | |
4579 | - |
4580 | ?> |
4581 | |
4582 | === modified file 'qp_inc/_core/_url.funcs.php' |
4583 | --- qp_inc/_core/_url.funcs.php 2013-02-28 16:40:18 +0000 |
4584 | +++ qp_inc/_core/_url.funcs.php 2013-03-14 18:35:26 +0000 |
4585 | @@ -62,7 +62,7 @@ |
4586 | // Scheme not allowed |
4587 | $scheme = 'mailto:'; |
4588 | return $verbose |
4589 | - ? sprintf( T_('URI scheme "%s" not allowed.'), htmlspecialchars($scheme) ) |
4590 | + ? sprintf( T_('URI scheme "%s" not allowed.'), htmlspecialchars( $scheme ) ) |
4591 | : T_('URI scheme not allowed.'); |
4592 | } |
4593 | |
4594 | @@ -73,14 +73,14 @@ |
4595 | ? sprintf( T_('Invalid email link: %s.'), htmlspecialchars( $url ) ) |
4596 | : T_('Invalid email link.'); |
4597 | } |
4598 | - elseif( ! is_email( $match[2] ) ) |
4599 | + elseif( ! is_email( $match[2] ) ) |
4600 | { |
4601 | return $verbose |
4602 | - ? sprintf( T_('Supplied email address (%s) is invalid.'), htmlspecialchars($match[2]) ) |
4603 | + ? sprintf( T_('Supplied email address (%s) is invalid.'), htmlspecialchars( $match[2] ) ) |
4604 | : T_('Invalid email address.'); |
4605 | } |
4606 | } |
4607 | - elseif( substr($url, 0, 6) == 'clsid:' ) |
4608 | + elseif( substr( $url, 0, 6 ) == 'clsid:' ) |
4609 | { |
4610 | // clsid:link |
4611 | if( ! in_array( 'clsid', $allowed_uri_schemes ) ) |
4612 | @@ -105,7 +105,7 @@ |
4613 | // Scheme not allowed |
4614 | $scheme = 'javascript:'; |
4615 | return $verbose |
4616 | - ? sprintf( T_('URI scheme "%s" not allowed.'), htmlspecialchars($scheme) ) |
4617 | + ? sprintf( T_('URI scheme "%s" not allowed.'), htmlspecialchars( $scheme ) ) |
4618 | : T_('URI scheme not allowed.'); |
4619 | } |
4620 | |
4621 | @@ -116,18 +116,18 @@ |
4622 | // convert URL to IDN |
4623 | $url = idna_encode( $url ); |
4624 | |
4625 | - if( ! preg_match('~^ # start |
4626 | - ([a-z][a-z0-9+.\-]*) # scheme |
4627 | - :// # authorize absolute URLs only ( // not present in clsid: -- problem? ; mailto: handled above) |
4628 | - (\w+(:\w+)?@)? # username or username and password (optional) |
4629 | + if( ! preg_match('~^ # start |
4630 | + ([a-z][a-z0-9+.\-]*) # scheme |
4631 | + :// # authorize absolute URLs only ( // not present in clsid: -- problem? ; mailto: handled above) |
4632 | + (\w+(:\w+)?@)? # username or username and password (optional) |
4633 | ( localhost | |
4634 | - [a-z0-9]([a-z0-9\-])* # Don t allow anything too funky like entities |
4635 | - \. # require at least 1 dot |
4636 | - [a-z0-9]([a-z0-9.\-])+ # Don t allow anything too funky like entities |
4637 | + [a-z0-9]([a-z0-9\-])* # Don t allow anything too funky like entities |
4638 | + \. # require at least 1 dot |
4639 | + [a-z0-9]([a-z0-9.\-])+ # Don t allow anything too funky like entities |
4640 | ) |
4641 | - (:[0-9]+)? # optional port specification |
4642 | - .* # allow anything in the path (including spaces - used in FileManager - but no newlines). |
4643 | - $~ix', $url, $match) ) |
4644 | + (:[0-9]+)? # optional port specification |
4645 | + .* # allow anything in the path (including spaces - used in FileManager - but no newlines). |
4646 | + $~ix', $url, $match ) ) |
4647 | { |
4648 | // Cannot validate URL structure |
4649 | return $verbose |
4650 | @@ -151,10 +151,12 @@ |
4651 | if( $context == 'commenting' ) |
4652 | { |
4653 | // We do not allow relative URLs in comments |
4654 | - return $verbose ? sprintf( T_('URL "%s" must be absolute.'), htmlspecialchars( $url ) ) : T_('URL must be absolute.'); |
4655 | + return $verbose |
4656 | + ? sprintf( T_('URL "%s" must be absolute.'), htmlspecialchars( $url ) ) |
4657 | + : T_('URL must be absolute.'); |
4658 | } |
4659 | |
4660 | - $char = substr($url, 0, 1); |
4661 | + $char = substr( $url, 0, 1 ); |
4662 | if( $char != '/' && $char != '#' ) |
4663 | { |
4664 | // must start with a slash or hash (for HTML anchors to the same page) |
4665 | @@ -180,29 +182,27 @@ |
4666 | |
4667 | |
4668 | /** |
4669 | - * Get allowed URI schemes for a given context. |
4670 | + * Get allowed URI schemes for a given context |
4671 | + * |
4672 | * @param string Context ("posting", "commenting") |
4673 | * @return array |
4674 | */ |
4675 | function get_allowed_uri_schemes( $context = 'posting' ) |
4676 | { |
4677 | - /** |
4678 | - * @var User |
4679 | - */ |
4680 | global $current_User; |
4681 | |
4682 | $schemes = array( |
4683 | - 'http', |
4684 | - 'https', |
4685 | - 'ftp', |
4686 | - 'gopher', |
4687 | - 'nntp', |
4688 | - 'news', |
4689 | - 'mailto', |
4690 | - 'irc', |
4691 | - 'aim', |
4692 | - 'icq' |
4693 | - ); |
4694 | + 'http', |
4695 | + 'https', |
4696 | + 'ftp', |
4697 | + 'gopher', |
4698 | + 'nntp', |
4699 | + 'news', |
4700 | + 'mailto', |
4701 | + 'irc', |
4702 | + 'aim', |
4703 | + 'icq' |
4704 | + ); |
4705 | |
4706 | if( $context == 'commenting' ) |
4707 | { |
4708 | @@ -223,9 +223,7 @@ |
4709 | { |
4710 | $schemes[] = 'clsid'; |
4711 | } |
4712 | - |
4713 | } |
4714 | - |
4715 | return $schemes; |
4716 | } |
4717 | |
4718 | @@ -234,7 +232,8 @@ |
4719 | * Get the last HTTP status code received by the HTTP/HTTPS wrapper of PHP |
4720 | * |
4721 | * @param array The $http_response_header array (by reference). |
4722 | - * @return integer|boolean False if no HTTP status header could be found, the HTTP status code otherwise. |
4723 | + * @return integer|boolean False if no HTTP status header could be found, the |
4724 | + * HTTP status code otherwise. |
4725 | */ |
4726 | function _http_wrapper_last_status( & $headers ) |
4727 | { |
4728 | @@ -245,7 +244,6 @@ |
4729 | return $matches[1]; |
4730 | } |
4731 | } |
4732 | - |
4733 | return false; |
4734 | } |
4735 | |
4736 | @@ -253,14 +251,16 @@ |
4737 | /** |
4738 | * Fetch remote page |
4739 | * |
4740 | - * Attempt to retrieve a remote page using a HTTP GET request, first with cURL, then fsockopen, then fopen. |
4741 | + * Attempt to retrieve a remote page using a HTTP GET request, first with cURL, |
4742 | + * then fsockopen, then fopen. |
4743 | + * |
4744 | * @param string URL |
4745 | * @param array Info (by reference) |
4746 | * - 'error': holds error message, if any |
4747 | * - 'status': HTTP status (e.g. 200 or 404) |
4748 | * - 'used_method': Used method ("curl", "fopen", "fsockopen" or null if no methodis available) |
4749 | - * @todo (0000): Should we try remaining methods, if the previous one(s) failed? |
4750 | - * @todo (0000): Also allow HTTP POST. |
4751 | + * @todo (0000) Should we try remaining methods, if the previous one(s) failed? |
4752 | + * @todo (0000) Also allow HTTP POST. |
4753 | * @param integer Timeout |
4754 | * @return string|false The remote page as a string; false in case of error |
4755 | */ |
4756 | @@ -300,7 +300,7 @@ |
4757 | $info['used_method'] = 'fsockopen'; |
4758 | |
4759 | if( ( $url_parsed = @parse_url( $url ) ) === false |
4760 | - || ! isset( $url_parsed['host'] ) ) |
4761 | + || ! isset( $url_parsed['host'] ) ) |
4762 | { |
4763 | $info['error'] = 'Could not parse URL'; |
4764 | return false; |
4765 | @@ -318,7 +318,7 @@ |
4766 | $out .= 'Host: '.$host; |
4767 | if( ! empty( $url_parsed['port'] ) ) |
4768 | { |
4769 | - // we don't want to add :80 if not specified. remote end may not resolve it. (e-g b2evo multiblog does not) |
4770 | + // we don't want to add :80 if not specified. remote end may not resolve it |
4771 | $out .= ':'.$port; |
4772 | } |
4773 | $out .= "\r\n".'Connection: Close'."\r\n\r\n"; |
4774 | @@ -330,10 +330,10 @@ |
4775 | return false; |
4776 | } |
4777 | |
4778 | - // Send request: |
4779 | + // Send request |
4780 | fwrite( $fp, $out ); |
4781 | |
4782 | - // Set timeout for data: |
4783 | + // Set timeout for data |
4784 | if( function_exists( 'stream_set_timeout' ) ) |
4785 | { |
4786 | stream_set_timeout( $fp, $timeout ); // PHP 4.3.0 |
4787 | @@ -343,9 +343,9 @@ |
4788 | socket_set_timeout( $fp, $timeout ); // PHP 4 |
4789 | } |
4790 | |
4791 | - // Read response: |
4792 | + // Read response |
4793 | $r = ''; |
4794 | - // First line: |
4795 | + // First line |
4796 | $s = fgets( $fp ); |
4797 | if( ! preg_match( '~^HTTP/\d+\.\d+ (\d+)~', $s, $match ) ) |
4798 | { |
4799 | @@ -359,7 +359,7 @@ |
4800 | { |
4801 | $r .= fgets( $fp ); |
4802 | } |
4803 | - fclose($fp); |
4804 | + fclose( $fp ); |
4805 | |
4806 | if( ( $pos = strpos( $r, "\r\n\r\n" ) ) === false ) |
4807 | { |
4808 | @@ -378,7 +378,7 @@ |
4809 | if( ! $fp ) |
4810 | { |
4811 | if( isset( $http_response_header ) |
4812 | - && ( $code = _http_wrapper_last_status( $http_response_header ) ) !== false ) |
4813 | + && ( $code = _http_wrapper_last_status( $http_response_header ) ) !== false ) |
4814 | { |
4815 | // fopen() returned false because it got a bad HTTP code |
4816 | $info['error'] = 'Invalid response'; |
4817 | @@ -389,9 +389,9 @@ |
4818 | $info['error'] = 'fopen() failed'; |
4819 | return false; |
4820 | } |
4821 | - // Check just to be sure: |
4822 | - else if( ! isset( $http_response_header ) |
4823 | - || ( $code = _http_wrapper_last_status( $http_response_header ) ) === false ) |
4824 | + // Check just to be sure |
4825 | + elseif( ! isset( $http_response_header ) |
4826 | + || ( $code = _http_wrapper_last_status( $http_response_header ) ) === false ) |
4827 | { |
4828 | $info['error'] = 'Invalid response'; |
4829 | $r = false; |
4830 | @@ -410,7 +410,7 @@ |
4831 | return $r; |
4832 | } |
4833 | |
4834 | - // All failed: |
4835 | + // All failed |
4836 | $info['error'] = 'No method available to access URL!'; |
4837 | return false; |
4838 | } |
4839 | @@ -418,16 +418,17 @@ |
4840 | |
4841 | /** |
4842 | * Get $url with the same protocol (http/https) as $other_url |
4843 | + * |
4844 | * @param string URL |
4845 | * @param string other URL (defaults to {@link $ReqHost}) |
4846 | * @return string |
4847 | */ |
4848 | function url_same_protocol( $url, $other_url = NULL ) |
4849 | { |
4850 | - if( is_null($other_url) ) |
4851 | + global $ReqHost; |
4852 | + |
4853 | + if( is_null( $other_url ) ) |
4854 | { |
4855 | - global $ReqHost; |
4856 | - |
4857 | $other_url = $ReqHost; |
4858 | } |
4859 | |
4860 | @@ -452,23 +453,26 @@ |
4861 | |
4862 | |
4863 | /** |
4864 | - * Add param(s) at the end of an URL, using either "?" or "&" depending on existing url |
4865 | + * Add param(s) at the end of an URL |
4866 | + * |
4867 | + * Using either "?" or "&" depending on existing url |
4868 | + * |
4869 | * @param string existing url |
4870 | * @param string params to add |
4871 | * @param string delimiter to use for more params |
4872 | */ |
4873 | function url_add_param( $url, $param, $glue = '&' ) |
4874 | { |
4875 | - if( empty($param) ) |
4876 | + if( empty( $param ) ) |
4877 | { |
4878 | return $url; |
4879 | } |
4880 | |
4881 | - if( ($anchor_pos = strpos($url, '#')) !== false ) |
4882 | + if( ( $anchor_pos = strpos( $url, '#' ) ) !== false ) |
4883 | { |
4884 | // There's an "#anchor" in the URL |
4885 | - $anchor = substr($url, $anchor_pos); |
4886 | - $url = substr($url, 0, $anchor_pos); |
4887 | + $anchor = substr( $url, $anchor_pos ); |
4888 | + $url = substr( $url, 0, $anchor_pos ); |
4889 | } |
4890 | else |
4891 | { |
4892 | @@ -476,11 +480,11 @@ |
4893 | $anchor = ''; |
4894 | } |
4895 | |
4896 | - if( strpos($url, '?') !== false ) |
4897 | + if( strpos( $url, '?' ) !== false ) |
4898 | { |
4899 | // There are already params in the URL |
4900 | $r = $url; |
4901 | - if( substr($url, -1) != '?' ) |
4902 | + if( substr( $url, -1 ) != '?' ) |
4903 | { |
4904 | // the "?" is not the last char |
4905 | $r .= $glue; |
4906 | @@ -494,18 +498,19 @@ |
4907 | |
4908 | |
4909 | /** |
4910 | - * Add a tail (starting with "/") at the end of an URL before any params (starting with "?") |
4911 | + * Add a tail (starting with "/") at the end of an URL before any params |
4912 | + * |
4913 | * @param string existing url |
4914 | * @param string tail to add |
4915 | */ |
4916 | function url_add_tail( $url, $tail ) |
4917 | { |
4918 | $parts = explode( '?', $url ); |
4919 | - if( substr($parts[0], -1) == '/' ) |
4920 | + if( substr( $parts[0], -1 ) == '/' ) |
4921 | { |
4922 | - $parts[0] = substr($parts[0], 0, -1); |
4923 | + $parts[0] = substr( $parts[0], 0, -1 ); |
4924 | } |
4925 | - if( isset($parts[1]) ) |
4926 | + if( isset( $parts[1] ) ) |
4927 | { |
4928 | return $parts[0].$tail.'?'.$parts[1]; |
4929 | } |
4930 | @@ -515,7 +520,7 @@ |
4931 | |
4932 | |
4933 | /** |
4934 | - * Try to make $url relative to $target_url, if scheme, host, user and pass matches. |
4935 | + * Try to make $url relative to $target_url, if scheme, host, user and pass matches |
4936 | * |
4937 | * This is useful for redirect_to params, to keep them short and avoid mod_security |
4938 | * rejecting the request as "Not Acceptable" (whole URL as param). |
4939 | @@ -534,7 +539,7 @@ |
4940 | // invalid url |
4941 | return $url; |
4942 | } |
4943 | - if( empty($parsed_url['scheme']) || empty($parsed_url['host']) ) |
4944 | + if( empty( $parsed_url['scheme'] ) || empty( $parsed_url['host'] ) ) |
4945 | { |
4946 | // no protocol or host information |
4947 | return $url; |
4948 | @@ -546,58 +551,72 @@ |
4949 | // invalid url |
4950 | return $url; |
4951 | } |
4952 | - if( ! empty($target_url['scheme']) && $target_url['scheme'] != $parsed_url['scheme'] ) |
4953 | + if( ! empty( $target_url['scheme'] ) && $target_url['scheme'] != $parsed_url['scheme'] ) |
4954 | { |
4955 | // scheme/protocol is different |
4956 | return $url; |
4957 | } |
4958 | - if( ! empty($target_url['host']) ) |
4959 | + if( ! empty( $target_url['host']) ) |
4960 | { |
4961 | - if( empty($target_url['scheme']) || $target_url['host'] != $parsed_url['host'] ) |
4962 | + if( empty( $target_url['scheme'] ) || $target_url['host'] != $parsed_url['host'] ) |
4963 | { |
4964 | // target has no scheme (but a host) or hosts differ |
4965 | return $url; |
4966 | } |
4967 | |
4968 | if( @$target_url['port'] != @$parsed_url['port'] ) |
4969 | + { |
4970 | return $url; |
4971 | + } |
4972 | if( @$target_url['user'] != @$parsed_url['user'] ) |
4973 | + { |
4974 | return $url; |
4975 | + } |
4976 | if( @$target_url['pass'] != @$parsed_url['pass'] ) |
4977 | + { |
4978 | return $url; |
4979 | + } |
4980 | } |
4981 | |
4982 | - // We can make the URL relative: |
4983 | + // We can make the URL relative |
4984 | $r = ''; |
4985 | if( ! empty( $parsed_url['path'] ) ) |
4986 | + { |
4987 | $r .= $parsed_url['path']; |
4988 | + } |
4989 | if( ! empty( $parsed_url['query'] ) ) |
4990 | + { |
4991 | $r .= '?'.$parsed_url['query']; |
4992 | + } |
4993 | if( ! empty( $parsed_url['fragment'] ) ) |
4994 | + { |
4995 | $r .= '?'.$parsed_url['fragment']; |
4996 | + } |
4997 | |
4998 | return $r; |
4999 | } |
5000 |
The diff has been truncated for viewing.