196 |
196 |
197 // Get the "article" button text (depends on namespace) |
197 // Get the "article" button text (depends on namespace) |
198 switch($paths->namespace) { |
198 switch($paths->namespace) { |
199 case "Article": |
199 case "Article": |
200 default: |
200 default: |
201 $ns = 'article'; |
201 $ns = $lang->get('onpage_lbl_page_article'); |
202 break; |
202 break; |
203 case "Admin": |
203 case "Admin": |
204 $ns = 'administration page'; |
204 $ns = $lang->get('onpage_lbl_page_admin'); |
205 break; |
205 break; |
206 case "System": |
206 case "System": |
207 $ns = 'system message'; |
207 $ns = $lang->get('onpage_lbl_page_system'); |
208 break; |
208 break; |
209 case "File": |
209 case "File": |
210 $ns = 'uploaded file'; |
210 $ns = $lang->get('onpage_lbl_page_file'); |
211 break; |
211 break; |
212 case "Help": |
212 case "Help": |
213 $ns = 'documentation page'; |
213 $ns = $lang->get('onpage_lbl_page_help'); |
214 break; |
214 break; |
215 case "User": |
215 case "User": |
216 $ns = 'user page'; |
216 $ns = $lang->get('onpage_lbl_page_user'); |
217 break; |
217 break; |
218 case "Special": |
218 case "Special": |
219 $ns = 'special page'; |
219 $ns = $lang->get('onpage_lbl_page_special'); |
220 break; |
220 break; |
221 case "Template": |
221 case "Template": |
222 $ns = 'template'; |
222 $ns = $lang->get('onpage_lbl_page_template'); |
223 break; |
223 break; |
224 case "Project": |
224 case "Project": |
225 $ns = 'project page'; |
225 $ns = $lang->get('onpage_lbl_page_project'); |
226 break; |
226 break; |
227 case "Category": |
227 case "Category": |
228 $ns = 'category'; |
228 $ns = $lang->get('onpage_lbl_page_category'); |
229 break; |
229 break; |
230 } |
230 } |
231 $this->namespace_string = $ns; |
231 $this->namespace_string = $ns; |
|
232 unset($ns); |
232 $code = $plugins->setHook('page_type_string_set'); |
233 $code = $plugins->setHook('page_type_string_set'); |
233 foreach ( $code as $cmd ) |
234 foreach ( $code as $cmd ) |
234 { |
235 { |
235 eval($cmd); |
236 eval($cmd); |
236 } |
237 } |
283 |
284 |
284 $db->free_result(); |
285 $db->free_result(); |
285 $n = ( $session->get_permissions('mod_comments') ) ? (string)$nc : (string)$na; |
286 $n = ( $session->get_permissions('mod_comments') ) ? (string)$nc : (string)$na; |
286 if ( $session->get_permissions('mod_comments') && $nu > 0 ) |
287 if ( $session->get_permissions('mod_comments') && $nu > 0 ) |
287 { |
288 { |
288 $n .= ' total/'.$nu.' unapp.'; |
289 $subst = array( |
|
290 'num_comments' => $nc, |
|
291 'num_unapp' => $nu |
|
292 ); |
|
293 $btn_text = $lang->get('onpage_btn_discussion_unapp', $subst); |
|
294 } |
|
295 else |
|
296 { |
|
297 $subst = array( |
|
298 'num_comments' => $nc |
|
299 ); |
|
300 $btn_text = $lang->get('onpage_btn_discussion', $subst); |
289 } |
301 } |
290 |
302 |
291 $button->assign_vars(array( |
303 $button->assign_vars(array( |
292 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxComments()); return false; }" title="View the comments that other users have posted about this page (alt-c)" accesskey="c"', |
304 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxComments()); return false; }" title="View the comments that other users have posted about this page (alt-c)" accesskey="c"', |
293 'PARENTFLAGS' => 'id="mdgToolbar_discussion"', |
305 'PARENTFLAGS' => 'id="mdgToolbar_discussion"', |
294 'HREF' => makeUrl($paths->page, 'do=comments', true), |
306 'HREF' => makeUrl($paths->page, 'do=comments', true), |
295 'TEXT' => 'discussion ('.$n.')', |
307 'TEXT' => $btn_text, |
296 )); |
308 )); |
297 |
309 |
298 $tb .= $button->run(); |
310 $tb .= $button->run(); |
299 } |
311 } |
300 // Edit button |
312 // Edit button |
302 { |
314 { |
303 $button->assign_vars(array( |
315 $button->assign_vars(array( |
304 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxEditor()); return false; }" title="Edit the contents of this page (alt-e)" accesskey="e"', |
316 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxEditor()); return false; }" title="Edit the contents of this page (alt-e)" accesskey="e"', |
305 'PARENTFLAGS' => 'id="mdgToolbar_edit"', |
317 'PARENTFLAGS' => 'id="mdgToolbar_edit"', |
306 'HREF' => makeUrl($paths->page, 'do=edit', true), |
318 'HREF' => makeUrl($paths->page, 'do=edit', true), |
307 'TEXT' => 'edit this page' |
319 'TEXT' => $lang->get('onpage_btn_edit') |
308 )); |
320 )); |
309 $tb .= $button->run(); |
321 $tb .= $button->run(); |
310 // View source button |
322 // View source button |
311 } |
323 } |
312 else if($session->get_permissions('view_source') && ( !$session->get_permissions('edit_page') || !$session->get_permissions('even_when_protected') && $paths->page_protected ) && $paths->namespace != 'Special' && $paths->namespace != 'Admin') |
324 else if($session->get_permissions('view_source') && ( !$session->get_permissions('edit_page') || !$session->get_permissions('even_when_protected') && $paths->page_protected ) && $paths->namespace != 'Special' && $paths->namespace != 'Admin') |
313 { |
325 { |
314 $button->assign_vars(array( |
326 $button->assign_vars(array( |
315 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxViewSource()); return false; }" title="View the source code (wiki markup) that this page uses (alt-e)" accesskey="e"', |
327 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxViewSource()); return false; }" title="View the source code (wiki markup) that this page uses (alt-e)" accesskey="e"', |
316 'PARENTFLAGS' => 'id="mdgToolbar_edit"', |
328 'PARENTFLAGS' => 'id="mdgToolbar_edit"', |
317 'HREF' => makeUrl($paths->page, 'do=viewsource', true), |
329 'HREF' => makeUrl($paths->page, 'do=viewsource', true), |
318 'TEXT' => 'view source' |
330 'TEXT' => $lang->get('onpage_btn_viewsource') |
319 )); |
331 )); |
320 $tb .= $button->run(); |
332 $tb .= $button->run(); |
321 } |
333 } |
322 // History button |
334 // History button |
323 if ( $session->get_permissions('read') /* && $paths->wiki_mode */ && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('history_view') ) |
335 if ( $session->get_permissions('read') /* && $paths->wiki_mode */ && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('history_view') ) |
324 { |
336 { |
325 $button->assign_vars(array( |
337 $button->assign_vars(array( |
326 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxHistory()); return false; }" title="View a log of actions taken on this page (alt-h)" accesskey="h"', |
338 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxHistory()); return false; }" title="View a log of actions taken on this page (alt-h)" accesskey="h"', |
327 'PARENTFLAGS' => 'id="mdgToolbar_history"', |
339 'PARENTFLAGS' => 'id="mdgToolbar_history"', |
328 'HREF' => makeUrl($paths->page, 'do=history', true), |
340 'HREF' => makeUrl($paths->page, 'do=history', true), |
329 'TEXT' => 'history' |
341 'TEXT' => $lang->get('onpage_btn_history') |
330 )); |
342 )); |
331 $tb .= $button->run(); |
343 $tb .= $button->run(); |
332 } |
344 } |
333 |
345 |
334 $menubtn = $this->makeParserText($tplvars['toolbar_menu_button']); |
346 $menubtn = $this->makeParserText($tplvars['toolbar_menu_button']); |
338 if ( $session->get_permissions('read') && $paths->page_exists && ( $session->get_permissions('rename') && ( $paths->page_protected && $session->get_permissions('even_when_protected') || !$paths->page_protected ) ) && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
350 if ( $session->get_permissions('read') && $paths->page_exists && ( $session->get_permissions('rename') && ( $paths->page_protected && $session->get_permissions('even_when_protected') || !$paths->page_protected ) ) && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
339 { |
351 { |
340 $menubtn->assign_vars(array( |
352 $menubtn->assign_vars(array( |
341 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxRename()); return false; }" title="Change the display name of this page (alt-r)" accesskey="r"', |
353 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxRename()); return false; }" title="Change the display name of this page (alt-r)" accesskey="r"', |
342 'HREF' => makeUrl($paths->page, 'do=rename', true), |
354 'HREF' => makeUrl($paths->page, 'do=rename', true), |
343 'TEXT' => 'rename', |
355 'TEXT' => $lang->get('onpage_btn_rename'), |
344 )); |
356 )); |
345 $this->toolbar_menu .= $menubtn->run(); |
357 $this->toolbar_menu .= $menubtn->run(); |
346 } |
358 } |
347 |
359 |
348 // Vote-to-delete button |
360 // Vote-to-delete button |
349 if ( $paths->wiki_mode && $session->get_permissions('vote_delete') && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin') |
361 if ( $paths->wiki_mode && $session->get_permissions('vote_delete') && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin') |
350 { |
362 { |
351 $menubtn->assign_vars(array( |
363 $menubtn->assign_vars(array( |
352 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDelVote()); return false; }" title="Vote to have this page deleted (alt-d)" accesskey="d"', |
364 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDelVote()); return false; }" title="Vote to have this page deleted (alt-d)" accesskey="d"', |
353 'HREF' => makeUrl($paths->page, 'do=delvote', true), |
365 'HREF' => makeUrl($paths->page, 'do=delvote', true), |
354 'TEXT' => 'vote to delete this page', |
366 'TEXT' => $lang->get('onpage_btn_votedelete'), |
355 )); |
367 )); |
356 $this->toolbar_menu .= $menubtn->run(); |
368 $this->toolbar_menu .= $menubtn->run(); |
357 } |
369 } |
358 |
370 |
359 // Clear-votes button |
371 // Clear-votes button |
360 if ( $session->get_permissions('read') && $paths->wiki_mode && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('vote_reset') && $paths->cpage['delvotes'] > 0) |
372 if ( $session->get_permissions('read') && $paths->wiki_mode && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('vote_reset') && $paths->cpage['delvotes'] > 0) |
361 { |
373 { |
362 $menubtn->assign_vars(array( |
374 $menubtn->assign_vars(array( |
363 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxResetDelVotes()); return false; }" title="Vote to have this page deleted (alt-y)" accesskey="y"', |
375 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxResetDelVotes()); return false; }" title="Vote to have this page deleted (alt-y)" accesskey="y"', |
364 'HREF' => makeUrl($paths->page, 'do=resetvotes', true), |
376 'HREF' => makeUrl($paths->page, 'do=resetvotes', true), |
365 'TEXT' => 'reset deletion votes', |
377 'TEXT' => $lang->get('onpage_btn_votedelete_reset'), |
366 )); |
378 )); |
367 $this->toolbar_menu .= $menubtn->run(); |
379 $this->toolbar_menu .= $menubtn->run(); |
368 } |
380 } |
369 |
381 |
370 // Printable page button |
382 // Printable page button |
371 if ( $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
383 if ( $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
372 { |
384 { |
373 $menubtn->assign_vars(array( |
385 $menubtn->assign_vars(array( |
374 'FLAGS' => 'title="View a version of this page that is suitable for printing"', |
386 'FLAGS' => 'title="View a version of this page that is suitable for printing"', |
375 'HREF' => makeUrl($paths->page, 'printable=yes', true), |
387 'HREF' => makeUrl($paths->page, 'printable=yes', true), |
376 'TEXT' => 'view printable version', |
388 'TEXT' => $lang->get('onpage_btn_printable'), |
377 )); |
389 )); |
378 $this->toolbar_menu .= $menubtn->run(); |
390 $this->toolbar_menu .= $menubtn->run(); |
379 } |
391 } |
380 |
392 |
381 // Protect button |
393 // Protect button |
382 if($session->get_permissions('read') && $paths->wiki_mode && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('protect')) |
394 if($session->get_permissions('read') && $paths->wiki_mode && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('protect')) |
383 { |
395 { |
384 |
396 |
385 $label = $this->makeParserText($tplvars['toolbar_label']); |
397 $label = $this->makeParserText($tplvars['toolbar_label']); |
386 $label->assign_vars(array('TEXT' => 'protection:')); |
398 $label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_protect'))); |
387 $t0 = $label->run(); |
399 $t0 = $label->run(); |
388 |
400 |
389 $ctmp = ''; |
401 $ctmp = ''; |
390 if ( $paths->cpage['protected'] == 1 ) |
402 if ( $paths->cpage['protected'] == 1 ) |
391 { |
403 { |
392 $ctmp=' style="text-decoration: underline;"'; |
404 $ctmp=' style="text-decoration: underline;"'; |
393 } |
405 } |
394 $menubtn->assign_vars(array( |
406 $menubtn->assign_vars(array( |
395 'FLAGS' => 'accesskey="i" onclick="if ( !KILL_SWITCH ) { ajaxProtect(1); return false; }" id="protbtn_1" title="Prevents all non-administrators from editing this page. [alt-i]"'.$ctmp, |
407 'FLAGS' => 'accesskey="i" onclick="if ( !KILL_SWITCH ) { ajaxProtect(1); return false; }" id="protbtn_1" title="Prevents all non-administrators from editing this page. [alt-i]"'.$ctmp, |
396 'HREF' => makeUrl($paths->page, 'do=protect&level=1', true), |
408 'HREF' => makeUrl($paths->page, 'do=protect&level=1', true), |
397 'TEXT' => 'on' |
409 'TEXT' => $lang->get('onpage_btn_protect_on') |
398 )); |
410 )); |
399 $t1 = $menubtn->run(); |
411 $t1 = $menubtn->run(); |
400 |
412 |
401 $ctmp = ''; |
413 $ctmp = ''; |
402 if ( $paths->cpage['protected'] == 0 ) |
414 if ( $paths->cpage['protected'] == 0 ) |
494 if ( $session->get_permissions('read') && $session->get_permissions('clear_logs') && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
506 if ( $session->get_permissions('read') && $session->get_permissions('clear_logs') && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
495 { |
507 { |
496 $menubtn->assign_vars(array( |
508 $menubtn->assign_vars(array( |
497 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxClearLogs()); return false; }" title="Remove all edit and action logs for this page from the database. IRREVERSIBLE! (alt-l)" accesskey="l"', |
509 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxClearLogs()); return false; }" title="Remove all edit and action logs for this page from the database. IRREVERSIBLE! (alt-l)" accesskey="l"', |
498 'HREF' => makeUrl($paths->page, 'do=flushlogs', true), |
510 'HREF' => makeUrl($paths->page, 'do=flushlogs', true), |
499 'TEXT' => 'clear page logs', |
511 'TEXT' => $lang->get('onpage_btn_clearlogs'), |
500 )); |
512 )); |
501 $this->toolbar_menu .= $menubtn->run(); |
513 $this->toolbar_menu .= $menubtn->run(); |
502 } |
514 } |
503 |
515 |
504 // Delete page button |
516 // Delete page button |
505 if ( $session->get_permissions('read') && $session->get_permissions('delete_page') && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
517 if ( $session->get_permissions('read') && $session->get_permissions('delete_page') && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
506 { |
518 { |
507 $s = 'delete this page'; |
519 $s = $lang->get('onpage_btn_deletepage'); |
508 if ( $paths->cpage['delvotes'] == 1 ) |
520 if ( $paths->cpage['delvotes'] == 1 ) |
509 { |
521 { |
510 $s .= ' (<b>'.$paths->cpage['delvotes'].'</b> vote)'; |
522 $subst = array( |
|
523 'num_votes' => $paths->cpage['delvotes'], |
|
524 'plural' => '' |
|
525 ); |
|
526 $s .= $lang->get('onpage_btn_deletepage_votes', $subst); |
511 } |
527 } |
512 else if ( $paths->cpage['delvotes'] > 1 ) |
528 else if ( $paths->cpage['delvotes'] > 1 ) |
513 { |
529 { |
514 $s .= ' (<b>'.$paths->cpage['delvotes'].'</b> votes)'; |
530 $subst = array( |
|
531 'num_votes' => $paths->cpage['delvotes'], |
|
532 'plural' => $lang->get('meta_plural') |
|
533 ); |
|
534 $s .= $lang->get('onpage_btn_deletepage_votes', $subst); |
515 } |
535 } |
516 |
536 |
517 $menubtn->assign_vars(array( |
537 $menubtn->assign_vars(array( |
518 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDeletePage()); return false; }" title="Delete this page. This is always reversible unless the logs are cleared. (alt-k)" accesskey="k"', |
538 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDeletePage()); return false; }" title="Delete this page. This is always reversible unless the logs are cleared. (alt-k)" accesskey="k"', |
519 'HREF' => makeUrl($paths->page, 'do=deletepage', true), |
539 'HREF' => makeUrl($paths->page, 'do=deletepage', true), |
560 if($session->get_permissions('edit_acl') || $session->user_level >= USER_LEVEL_ADMIN) |
580 if($session->get_permissions('edit_acl') || $session->user_level >= USER_LEVEL_ADMIN) |
561 { |
581 { |
562 $menubtn->assign_vars(array( |
582 $menubtn->assign_vars(array( |
563 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { return ajaxOpenACLManager(); }" title="Manage who can do what with this page (alt-m)" accesskey="m"', |
583 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { return ajaxOpenACLManager(); }" title="Manage who can do what with this page (alt-m)" accesskey="m"', |
564 'HREF' => makeUrl($paths->page, 'do=aclmanager', true), |
584 'HREF' => makeUrl($paths->page, 'do=aclmanager', true), |
565 'TEXT' => 'manage page access', |
585 'TEXT' => $lang->get('onpage_btn_acl'), |
566 )); |
586 )); |
567 $this->toolbar_menu .= $menubtn->run(); |
587 $this->toolbar_menu .= $menubtn->run(); |
568 } |
588 } |
569 |
589 |
570 // Administer page button |
590 // Administer page button |
571 if ( $session->user_level >= USER_LEVEL_ADMIN && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
591 if ( $session->user_level >= USER_LEVEL_ADMIN && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
572 { |
592 { |
573 $menubtn->assign_vars(array( |
593 $menubtn->assign_vars(array( |
574 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxAdminPage()); return false; }" title="Administrative options for this page" accesskey="g"', |
594 'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxAdminPage()); return false; }" title="Administrative options for this page" accesskey="g"', |
575 'HREF' => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true), |
595 'HREF' => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true), |
576 'TEXT' => 'administrative options', |
596 'TEXT' => $lang->get('onpage_btn_admin'), |
577 )); |
597 )); |
578 $this->toolbar_menu .= $menubtn->run(); |
598 $this->toolbar_menu .= $menubtn->run(); |
579 } |
599 } |
580 |
600 |
581 if ( strlen($this->toolbar_menu) > 0 ) |
601 if ( strlen($this->toolbar_menu) > 0 ) |
582 { |
602 { |
583 $button->assign_vars(array( |
603 $button->assign_vars(array( |
584 'FLAGS' => 'id="mdgToolbar_moreoptions" onclick="if ( !KILL_SWITCH ) { return false; }" title="Additional options for working with this page"', |
604 'FLAGS' => 'id="mdgToolbar_moreoptions" onclick="if ( !KILL_SWITCH ) { return false; }" title="Additional options for working with this page"', |
585 'PARENTFLAGS' => '', |
605 'PARENTFLAGS' => '', |
586 'HREF' => makeUrl($paths->page, 'do=moreoptions', true), |
606 'HREF' => makeUrl($paths->page, 'do=moreoptions', true), |
587 'TEXT' => 'more options' |
607 'TEXT' => $lang->get('onpage_btn_moreoptions') |
588 )); |
608 )); |
589 $tb .= $button->run(); |
609 $tb .= $button->run(); |
590 } |
610 } |
591 |
611 |
592 $is_opera = (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'Opera')) ? true : false; |
612 $is_opera = (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'Opera')) ? true : false; |