author | Dan |
Mon, 06 Aug 2007 10:37:42 -0400 | |
changeset 84 | f99fb84bd959 |
parent 83 | 80facec76d9f |
child 85 | 7c68a18a27be |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/* |
|
3 |
Plugin Name: Special page-related pages |
|
4 |
Plugin URI: http://enanocms.org/ |
|
5 |
Description: Provides the page Special:CreatePage, which can be used to create new pages. Also adds the About Enano and GNU General Public License pages. |
|
6 |
Author: Dan Fuhry |
|
7 |
Version: 1.0 |
|
8 |
Author URI: http://enanocms.org/ |
|
9 |
*/ |
|
10 |
||
11 |
/* |
|
12 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
|
13 |
* Version 1.0 release candidate 2 |
|
14 |
* Copyright (C) 2006-2007 Dan Fuhry |
|
15 |
* |
|
16 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
20 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
21 |
*/ |
|
22 |
||
23 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
24 |
||
25 |
$plugins->attachHook('base_classes_initted', ' |
|
26 |
global $paths; |
|
27 |
$paths->add_page(Array( |
|
28 |
\'name\'=>\'Create page\', |
|
29 |
\'urlname\'=>\'CreatePage\', |
|
30 |
\'namespace\'=>\'Special\', |
|
31 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
32 |
)); |
|
33 |
||
34 |
$paths->add_page(Array( |
|
35 |
\'name\'=>\'All pages\', |
|
36 |
\'urlname\'=>\'AllPages\', |
|
37 |
\'namespace\'=>\'Special\', |
|
38 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
39 |
)); |
|
40 |
||
41 |
$paths->add_page(Array( |
|
42 |
\'name\'=>\'List of special pages\', |
|
43 |
\'urlname\'=>\'SpecialPages\', |
|
44 |
\'namespace\'=>\'Special\', |
|
45 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
46 |
)); |
|
47 |
||
48 |
$paths->add_page(Array( |
|
49 |
\'name\'=>\'About Enano\', |
|
50 |
\'urlname\'=>\'About_Enano\', |
|
51 |
\'namespace\'=>\'Special\', |
|
52 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
53 |
)); |
|
54 |
||
55 |
$paths->add_page(Array( |
|
56 |
\'name\'=>\'GNU General Public License\', |
|
57 |
\'urlname\'=>\'GNU_General_Public_License\', |
|
58 |
\'namespace\'=>\'Special\', |
|
59 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
60 |
)); |
|
83 | 61 |
|
62 |
$paths->add_page(Array( |
|
63 |
\'name\'=>\'Tag cloud\', |
|
64 |
\'urlname\'=>\'TagCloud\', |
|
65 |
\'namespace\'=>\'Special\', |
|
66 |
\'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\', |
|
67 |
)); |
|
0 | 68 |
'); |
69 |
||
70 |
// function names are IMPORTANT!!! The name pattern is: page_<namespace ID>_<page URLname, without namespace> |
|
71 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
72 |
function page_Special_CreatePage() |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
73 |
{ |
0 | 74 |
global $db, $session, $paths, $template, $plugins; // Common objects |
75 |
if ( isset($_POST['do']) ) |
|
76 |
{ |
|
77 |
$p = $_POST['pagename']; |
|
78 |
$k = array_keys($paths->nslist); |
|
79 |
for ( $i = 0; $i < sizeof( $paths->nslist ); $i++ ) |
|
80 |
{ |
|
81 |
$ln = strlen( $paths->nslist[$k[$i]] ); |
|
82 |
if ( substr($p, 0, $ln) == $paths->nslist[$k[$i]] ) |
|
83 |
{ |
|
84 |
$namespace = $k[$i]; |
|
85 |
} |
|
86 |
} |
|
87 |
if ( $namespace == 'Special' || ( $namespace == 'System' && $session->user_level < USER_LEVEL_ADMIN ) || $namespace == 'Admin') |
|
88 |
{ |
|
89 |
$template->header(); |
|
90 |
||
91 |
echo '<h3>The page could not be created.</h3><p>The name "'.$p.'" is invalid.</p>'; |
|
92 |
||
93 |
$template->footer(); |
|
94 |
$db->close(); |
|
95 |
||
96 |
exit; |
|
97 |
} |
|
98 |
$name = $db->escape(str_replace('_', ' ', $p)); |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
99 |
$urlname = str_replace(' ', '_', $p); |
0 | 100 |
$namespace = $_POST['namespace']; |
101 |
if ( $namespace == 'Special' || ( $namespace == 'System' && $session->user_level < USER_LEVEL_ADMIN ) || $namespace == 'Admin') |
|
102 |
{ |
|
103 |
$template->header(); |
|
104 |
||
105 |
echo '<h3>The page could not be created.</h3><p>The name "'.$paths->nslist[$namespace].$p.'" is invalid.</p>'; |
|
106 |
||
107 |
$template->footer(); |
|
108 |
$db->close(); |
|
109 |
||
110 |
exit; |
|
111 |
} |
|
112 |
||
113 |
$tn = $paths->nslist[$_POST['namespace']] . $urlname; |
|
114 |
if ( isset($paths->pages[$tn]) ) |
|
115 |
{ |
|
116 |
die_friendly('Error creating page', '<p>The page already exists.</p>'); |
|
117 |
} |
|
118 |
||
119 |
if ( $paths->nslist[$namespace] == substr($urlname, 0, strlen($paths->nslist[$namespace]) ) ) |
|
120 |
{ |
|
121 |
$urlname = substr($urlname, strlen($paths->nslist[$namespace]), strlen($urlname)); |
|
122 |
} |
|
123 |
||
124 |
$k = array_keys( $paths->nslist ); |
|
125 |
if(!in_array($_POST['namespace'], $k)) |
|
126 |
{ |
|
127 |
$db->_die('An SQL injection attempt was caught at '.dirname(__FILE__).':'.__LINE__.'.'); |
|
128 |
} |
|
129 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
130 |
$urlname = sanitize_page_id($urlname); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
131 |
$urlname = $db->escape($urlname); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
132 |
|
0 | 133 |
$perms = $session->fetch_page_acl($urlname, $namespace); |
134 |
if ( !$perms->get_permissions('create_page') ) |
|
135 |
die_friendly('Error creating page', '<p>An access control rule is preventing you from creating pages.</p>'); |
|
136 |
||
137 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'logs(time_id,date_string,log_type,action,author,page_id,namespace) VALUES('.time().', \''.date('d M Y h:i a').'\', \'page\', \'create\', \''.$session->username.'\', \''.$urlname.'\', \''.$_POST['namespace'].'\');'); |
|
138 |
if ( !$q ) |
|
139 |
{ |
|
140 |
$db->_die('The page log could not be updated.'); |
|
141 |
} |
|
142 |
||
143 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'pages(name,urlname,namespace) VALUES(\''.$name.'\', \''.$urlname.'\', \''.$_POST['namespace'].'\');'); |
|
144 |
if ( !$q ) |
|
145 |
{ |
|
146 |
$db->_die('The page entry could not be inserted.'); |
|
147 |
} |
|
148 |
$q = $db->sql_query('INSERT INTO '.table_prefix.'page_text(page_id,namespace,page_text) VALUES(\''.$urlname.'\', \''.$_POST['namespace'].'\', \''.$db->escape('Please edit this page! <nowiki><script type="text/javascript">ajaxEditor();</script></nowiki>').'\');'); |
|
149 |
if ( !$q ) |
|
150 |
{ |
|
151 |
$db->_die('The page text entry could not be inserted.'); |
|
152 |
} |
|
153 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
0
diff
changeset
|
154 |
header('Location: '.makeUrlNS($_POST['namespace'], sanitize_page_id($p))); |
0 | 155 |
exit; |
156 |
} |
|
157 |
$template->header(); |
|
158 |
if ( !$session->get_permissions('create_page') ) |
|
159 |
{ |
|
160 |
echo 'Wiki mode is disabled, only admins can create pages.'; |
|
161 |
||
162 |
$template->footer(); |
|
163 |
$db->close(); |
|
164 |
||
165 |
exit; |
|
166 |
} |
|
167 |
echo RenderMan::render('Using the form below you can create a page.'); |
|
168 |
?> |
|
169 |
<form action="" method="post"> |
|
170 |
<p> |
|
171 |
<select name="namespace"> |
|
172 |
<?php |
|
173 |
$k = array_keys($paths->nslist); |
|
174 |
for ( $i = 0; $i < sizeof($k); $i++ ) |
|
175 |
{ |
|
176 |
if ( $paths->nslist[$k[$i]] == '' ) |
|
177 |
{ |
|
178 |
$s = '[No prefix]'; |
|
179 |
} |
|
180 |
else |
|
181 |
{ |
|
182 |
$s = $paths->nslist[$k[$i]]; |
|
183 |
} |
|
184 |
if ( ( $k[$i] != 'System' || $session->user_level >= USER_LEVEL_ADMIN ) && $k[$i] != 'Admin' && $k[$i] != 'Special') |
|
185 |
{ |
|
186 |
echo '<option value="'.$k[$i].'">'.$s.'</option>'; |
|
187 |
} |
|
188 |
} |
|
189 |
?> |
|
190 |
</select> <input type="text" name="pagename" /></p> |
|
191 |
<p><input type="submit" name="do" value="Create Page" /></p> |
|
192 |
</form> |
|
193 |
<?php |
|
194 |
$template->footer(); |
|
195 |
} |
|
196 |
||
197 |
function page_Special_AllPages() |
|
198 |
{ |
|
199 |
// This should be an easy one |
|
200 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
201 |
$template->header(); |
|
202 |
$sz = sizeof( $paths->pages ) / 2; |
|
203 |
echo '<p>Below is a list of all of the pages on this website.</p><div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4">'; |
|
204 |
$cclass = 'row1'; |
|
205 |
for ( $i = 0; $i < $sz; $i = $i ) |
|
206 |
{ |
|
207 |
if ( $cclass == 'row1') |
|
208 |
{ |
|
209 |
$cclass='row3'; |
|
210 |
} |
|
211 |
else if ( $cclass == 'row3') |
|
212 |
{ |
|
213 |
$cclass='row1'; |
|
214 |
} |
|
215 |
echo '<tr>'; |
|
216 |
for ( $j = 0; $j < 2; $j = $j ) |
|
217 |
{ |
|
218 |
if ( $i < $sz && $paths->pages[$i]['namespace'] != 'Special' && $paths->pages[$i]['namespace'] != 'Admin' && $paths->pages[$i]['visible'] == 1) |
|
219 |
{ |
|
220 |
echo '<td style="width: 50%" class="'.$cclass.'"><a href="'.makeUrl($paths->pages[$i]['urlname']).'">'; |
|
221 |
if ( $paths->pages[$i]['namespace'] != 'Article' ) |
|
222 |
{ |
|
223 |
echo '('.$paths->pages[$i]['namespace'].') '; |
|
224 |
} |
|
225 |
echo $paths->pages[$i]['name'].'</a></td>'; |
|
226 |
$j++; |
|
227 |
} |
|
228 |
else if ( $i >= $sz ) |
|
229 |
{ |
|
230 |
echo '<td style="width: 50%" class="row2"></td>'; |
|
231 |
$j++; |
|
232 |
} |
|
233 |
$i++; |
|
234 |
} |
|
235 |
echo '</tr>'; |
|
236 |
} |
|
237 |
echo '</table></div>'; |
|
238 |
$template->footer(); |
|
239 |
} |
|
240 |
||
241 |
function page_Special_SpecialPages() |
|
242 |
{ |
|
243 |
// This should be an easy one |
|
244 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
245 |
$template->header(); |
|
246 |
$sz = sizeof($paths->pages) / 2; |
|
247 |
echo '<p>Below is a list of all of the special pages on this website.</p><div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4">'; |
|
248 |
$cclass='row1'; |
|
249 |
for ( $i = 0; $i < $sz; $i = $i) |
|
250 |
{ |
|
251 |
if ( $cclass == 'row1' ) |
|
252 |
{ |
|
253 |
$cclass = 'row3'; |
|
254 |
} |
|
255 |
else if ( $cclass == 'row3') |
|
256 |
{ |
|
257 |
$cclass='row1'; |
|
258 |
} |
|
259 |
echo '<tr>'; |
|
260 |
for ( $j = 0; $j < 2; $j = $j ) |
|
261 |
{ |
|
262 |
if ( $i < $sz && $paths->pages[$i]['namespace'] == 'Special' && $paths->pages[$i]['visible'] == 1) |
|
263 |
{ |
|
264 |
echo '<td style="width: 50%" class="'.$cclass.'"><a href="'.makeUrl($paths->pages[$i]['urlname']).'">'; |
|
265 |
echo $paths->pages[$i]['name'].'</a></td>'; |
|
266 |
$j++; |
|
267 |
} |
|
268 |
else if ( $i >= $sz ) |
|
269 |
{ |
|
270 |
echo '<td style="width: 50%" class="row2"></td>'; |
|
271 |
$j++; |
|
272 |
} |
|
273 |
$i++; |
|
274 |
} |
|
275 |
echo '</tr>'; |
|
276 |
} |
|
277 |
echo '</table></div>'; |
|
278 |
$template->footer(); |
|
279 |
} |
|
280 |
||
281 |
function page_Special_About_Enano() |
|
282 |
{ |
|
283 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
284 |
$platform = 'Unknown'; |
|
285 |
$uname = @file_get_contents('/proc/sys/kernel/ostype'); |
|
286 |
if($uname == "Linux\n") |
|
287 |
$platform = 'Linux'; |
|
288 |
else if(file_exists('/hurd/pfinet')) // I have a little experience with GNU/Hurd :-) http://hurdvm.enanocms.org/ |
|
289 |
$platform = 'GNU/Hurd'; |
|
290 |
else if(file_exists('C:\Windows\system32\ntoskrnl.exe')) |
|
291 |
$platform = 'Windows NT'; |
|
292 |
else if(file_exists('C:\Windows\system\krnl386.exe')) |
|
293 |
$platform = 'Windows 9x/DOS'; |
|
294 |
else if(file_exists('/bin/bash')) |
|
295 |
$platform = 'Other GNU/Mac OS X'; |
|
296 |
else if(is_dir('/bin')) |
|
297 |
$platform = 'Other POSIX'; |
|
298 |
$template->header(); |
|
299 |
?> |
|
300 |
<br /> |
|
301 |
<div class="tblholder"> |
|
302 |
<table border="0" cellspacing="1" cellpadding="4"> |
|
303 |
<tr><th colspan="2" style="text-align: left;">About the Enano Content Management System</th></tr> |
|
23
320acf077276
At last, I fixed all those phased-out enano.homelinux.org links!
Dan
parents:
22
diff
changeset
|
304 |
<tr><td colspan="2" class="row3"><p>This website is powered by <a href="http://enanocms.org/">Enano</a>, the lightweight and open source |
38 | 305 |
CMS that everyone can use. Enano is copyright © 2006-2007 Dan Fuhry. For legal information, along with a list of libraries that Enano |
23
320acf077276
At last, I fixed all those phased-out enano.homelinux.org links!
Dan
parents:
22
diff
changeset
|
306 |
uses, please see <a href="http://enanocms.org/Legal_information">Legal Information</a>.</p> |
0 | 307 |
<p>The developers and maintainers of Enano strongly believe that software should not only be free to use, but free to be modified, |
308 |
distributed, and used to create derivative works. For more information about Free Software, check out the |
|
309 |
<a href="http://en.wikipedia.org/wiki/Free_Software" onclick="window.open(this.href); return false;">Wikipedia page</a> or |
|
310 |
the <a href="http://www.fsf.org/" onclick="window.open(this.href); return false;">Free Software Foundation's</a> homepage.</p> |
|
311 |
<p>This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU General Public License |
|
312 |
as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p> |
|
313 |
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
314 |
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.</p> |
|
315 |
<p>You should have received <a href="<?php echo makeUrlNS('Special', 'GNU_General_Public_License'); ?>">a copy of |
|
316 |
the GNU General Public License</a> along with this program; if not, write to:</p> |
|
317 |
<p style="margin-left 2em;">Free Software Foundation, Inc.,<br /> |
|
318 |
51 Franklin Street, Fifth Floor<br /> |
|
319 |
Boston, MA 02110-1301, USA</p> |
|
320 |
<p>Alternatively, you can <a href="http://www.gnu.org/copyleft/gpl.html">read it online</a>.</p> |
|
321 |
</td></tr> |
|
322 |
<tr> |
|
323 |
<td class="row2" colspan="2"> |
|
53 | 324 |
<table border="0" style="margin: 0 auto; background: none; width: 100%;" cellpadding="5"> |
0 | 325 |
<tr> |
53 | 326 |
<td style="text-align: center;"> |
36
425261984266
Added "page hint" on search page; deprecated "www." on EnanoCMS.org links
Dan
parents:
23
diff
changeset
|
327 |
<a href="http://enanocms.org/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;"> |
53 | 328 |
<img alt="Powered by Enano" |
329 |
src="<?php echo scriptPath; ?>/images/about-powered-enano.png" |
|
330 |
onmouseover="this.src='<?php echo scriptPath; ?>/images/about-powered-enano-hover.png';" |
|
331 |
onmouseout="this.src='<?php echo scriptPath; ?>/images/about-powered-enano.png';" |
|
332 |
style="border-width: 0px;" width="88" height="31" /> |
|
333 |
</a> |
|
0 | 334 |
</td> |
335 |
<td style="text-align: center;"> |
|
336 |
<a href="http://www.php.net/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;"> |
|
337 |
<img alt="Written in PHP" src="<?php echo scriptPath; ?>/images/about-powered-php.png" style="border-width: 0px;" width="88" height="31" /> |
|
338 |
</a> |
|
339 |
</td> |
|
340 |
<td style="text-align: center;"> |
|
341 |
<a href="http://www.mysql.com/" onclick="window.open(this.href); return false;" style="background: none; padding: 0;"> |
|
342 |
<img alt="Database engine powered by MySQL" src="<?php echo scriptPath; ?>/images/about-powered-mysql.png" style="border-width: 0px;" width="88" height="31" /> |
|
343 |
</a> |
|
344 |
</td> |
|
345 |
</tr> |
|
346 |
</table> |
|
347 |
</td> |
|
348 |
</tr> |
|
36
425261984266
Added "page hint" on search page; deprecated "www." on EnanoCMS.org links
Dan
parents:
23
diff
changeset
|
349 |
<tr><td style="width: 100px;" class="row1"><a href="http://enanocms.org">Enano</a> version:</td><td class="row1"><?php echo enano_version(true); ?></td></tr> |
0 | 350 |
<tr><td style="width: 100px;" class="row2">Web server:</td><td class="row2"><?php if(isset($_SERVER['SERVER_SOFTWARE'])) echo $_SERVER['SERVER_SOFTWARE']; else echo 'Unable to determine web server software.'; ?></td></tr> |
351 |
<tr><td style="width: 100px;" class="row1">Server platform:</td><td class="row1"><?php echo $platform; ?></td></tr> |
|
352 |
<tr><td style="width: 100px;" class="row2"><a href="http://www.php.net/">PHP</a> version:</td><td class="row2"><?php echo PHP_VERSION; ?></td></tr> |
|
353 |
<tr><td style="width: 100px;" class="row1"><a href="http://www.mysql.com/">MySQL</a> version:</td><td class="row1"><?php echo mysql_get_server_info($db->_conn); ?></td></tr> |
|
354 |
</table> |
|
355 |
</div> |
|
356 |
<?php |
|
357 |
$template->footer(); |
|
358 |
} |
|
359 |
||
360 |
function page_Special_GNU_General_Public_License() |
|
361 |
{ |
|
362 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
363 |
$template->header(); |
|
364 |
if(file_exists(ENANO_ROOT.'/GPL')) |
|
365 |
{ |
|
366 |
echo '<p>The following text represents the license that the <a href="'.makeUrlNS('Special', 'About_Enano').'">Enano</a> content management system is under. To make it easier to read, the text has been wiki-formatted; in no other way has it been changed.</p>'; |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
69
diff
changeset
|
367 |
echo RenderMan::render( file_get_contents ( ENANO_ROOT . '/GPL' ) ); |
0 | 368 |
} |
369 |
else |
|
370 |
{ |
|
36
425261984266
Added "page hint" on search page; deprecated "www." on EnanoCMS.org links
Dan
parents:
23
diff
changeset
|
371 |
echo '<p>It appears that the file "GPL" is missing from your Enano installation. You may find a wiki-formatted copy of the GPL at: <a href="http://enanocms.org/GPL">http://enanocms.org/GPL</a>.</p>'; |
0 | 372 |
} |
373 |
$template->footer(); |
|
374 |
} |
|
375 |
||
83 | 376 |
function page_Special_TagCloud() |
377 |
{ |
|
378 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
379 |
||
380 |
$template->header(); |
|
381 |
||
382 |
if ( $tag = $paths->getParam(0) ) |
|
383 |
{ |
|
384 |
$tag = sanitize_tag($tag); |
|
385 |
$q = $db->sql_query('SELECT page_id, namespace FROM '.table_prefix.'tags WHERE tag_name=\'' . $db->escape($tag) . '\';'); |
|
386 |
if ( !$q ) |
|
387 |
$db->_die(); |
|
388 |
if ( $row = $db->fetchrow() ) |
|
389 |
{ |
|
390 |
echo '<div class="tblholder"> |
|
391 |
<table border="0" cellspacing="1" cellpadding="4">'; |
|
392 |
echo '<tr><th colspan="2">Pages tagged "' . htmlspecialchars($tag) . '"</th></tr>'; |
|
393 |
echo '<tr>'; |
|
394 |
$i = 0; |
|
395 |
$td_class = 'row1'; |
|
396 |
do |
|
397 |
{ |
|
398 |
if ( $i % 2 == 0 && $i > 1 ) |
|
399 |
{ |
|
400 |
$td_class = ( $td_class == 'row2' ) ? 'row1' : 'row2'; |
|
401 |
echo '</tr><tr>'; |
|
402 |
} |
|
403 |
$i++; |
|
404 |
$title = get_page_title_ns($row['page_id'], $row['namespace']); |
|
405 |
if ( $row['namespace'] != 'Article' && isset($paths->nslist[$row['namespace']]) ) |
|
406 |
$title = $paths->nslist[$row['namespace']] . $title; |
|
407 |
$url = makeUrlNS($row['namespace'], $row['page_id']); |
|
408 |
$class = ( isPage( $paths->nslist[$row['namespace']] . $row['page_id'] ) ) ? '' : ' class="wikilink-nonexistent"'; |
|
409 |
$link = '<a href="' . htmlspecialchars($url) . '"' . $class . '>' . htmlspecialchars($title) . '</a>'; |
|
410 |
echo "<td class=\"$td_class\" style=\"width: 50%;\">$link</td>"; |
|
411 |
// " workaround for jEdit highlighting bug |
|
412 |
} |
|
413 |
while ( $row = $db->fetchrow() ); |
|
414 |
while ( $i % 2 > 0 ) |
|
415 |
{ |
|
416 |
$i++; |
|
417 |
echo "<td class=\"$td_class\" style=\"width: 50%;\"></td>"; |
|
418 |
} |
|
419 |
// " workaround for jEdit highlighting bug |
|
420 |
echo '<tr> |
|
421 |
<th colspan="2" class="subhead"><a href="' . makeUrlNS('Special', 'TagCloud') . '" style="color: white;">« Return to tag cloud</a></th> |
|
422 |
</tr>'; |
|
423 |
echo '</table>'; |
|
424 |
echo '</div>'; |
|
425 |
} |
|
426 |
} |
|
427 |
else |
|
428 |
{ |
|
429 |
$cloud = new TagCloud(); |
|
430 |
||
431 |
$q = $db->sql_query('SELECT tag_name FROM '.table_prefix.'tags;'); |
|
432 |
if ( !$q ) |
|
433 |
$db->_die(); |
|
434 |
if ( $db->numrows() < 1 ) |
|
435 |
{ |
|
436 |
echo '<p>No pages are tagged yet.</p>'; |
|
437 |
} |
|
438 |
else |
|
439 |
{ |
|
440 |
echo '<h3>Summary of page tagging</h3>'; |
|
441 |
while ( $row = $db->fetchrow() ) |
|
442 |
{ |
|
443 |
$cloud->add_word($row['tag_name']); |
|
444 |
} |
|
445 |
echo $cloud->make_html('normal'); |
|
446 |
echo '<p>Hover your mouse over a tag to see how many pages have the tag. Click on a tag to see a list of the pages that have it.</p>'; |
|
447 |
} |
|
448 |
} |
|
449 |
||
450 |
$template->footer(); |
|
451 |
} |
|
452 |
||
453 |
// tag cloud sidebar block |
|
454 |
function sidebar_add_tag_cloud() |
|
455 |
{ |
|
456 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
457 |
$cloud = new TagCloud(); |
|
458 |
||
459 |
$q = $db->sql_query('SELECT tag_name FROM '.table_prefix.'tags;'); |
|
460 |
if ( !$q ) |
|
461 |
$db->_die(); |
|
462 |
if ( $db->numrows() < 1 ) |
|
463 |
{ |
|
464 |
$sb_html = 'No pages are tagged yet.'; |
|
465 |
} |
|
466 |
else |
|
467 |
{ |
|
468 |
while ( $row = $db->fetchrow() ) |
|
469 |
{ |
|
470 |
$cloud->add_word($row['tag_name']); |
|
471 |
} |
|
472 |
$sb_html = $cloud->make_html('small', 'justify') . '<br /><a style="text-align: center;" href="' . makeUrlNS('Special', 'TagCloud') . '">Larger version</a>'; |
|
473 |
} |
|
474 |
$template->sidebar_widget('Tag cloud', "<div style='padding: 5px;'>$sb_html</div>"); |
|
475 |
} |
|
476 |
||
477 |
$plugins->attachHook('compile_template', 'sidebar_add_tag_cloud();'); |
|
478 |
||
0 | 479 |
?> |