includes/template.php
changeset 58 8f532d8ab5f5
parent 57 b354deeaa4c4
child 59 7c4a851fb5c5
equal deleted inserted replaced
48:fc9762553a3c 58:8f532d8ab5f5
    21    * @access private
    21    * @access private
    22    */
    22    */
    23   
    23   
    24   var $site_disabled = false;
    24   var $site_disabled = false;
    25   
    25   
       
    26   /**
       
    27    * One of the absolute best parts of Enano :-P
       
    28    * @var string
       
    29    */
       
    30   
       
    31   var $fading_button = '';
       
    32   
    26   function __construct()
    33   function __construct()
    27   {
    34   {
    28     global $db, $session, $paths, $template, $plugins; // Common objects
    35     global $db, $session, $paths, $template, $plugins; // Common objects
    29     dc_here('template: initializing all class variables');
    36     dc_here('template: initializing all class variables');
    30     $this->tpl_bool    = Array();
    37     $this->tpl_bool    = Array();
    32     $this->sidebar_extra = '';
    39     $this->sidebar_extra = '';
    33     $this->toolbar_menu = '';
    40     $this->toolbar_menu = '';
    34     $this->additional_headers = '';
    41     $this->additional_headers = '';
    35     $this->plugin_blocks = Array();
    42     $this->plugin_blocks = Array();
    36     $this->theme_loaded = false;
    43     $this->theme_loaded = false;
       
    44     
       
    45     $fading_button = '<a href="http://enanocms.org" onclick="if ( !KILL_SWITCH ) { window.open(this.href); return false; }" style="text-align: center; margin: 0 auto; display: table; background-image: none;">
       
    46                             <img alt="Powered by Enano CMS" style="border-width: 0; position: absolute;" 
       
    47                                  src="' . scriptPath . '/images/about-powered-enano.png" id="enanoFader" onmouseover="domOpacity(this, 100, 0, 500);" 
       
    48                                  onmouseout="opacity(this.id, 0, 100, 500);" />
       
    49                             <img alt="Powered by Enano CMS" style="border-width: 0px;" src="' . scriptPath . '/images/about-powered-enano-hover.png" />
       
    50                           </a>';
    37     
    51     
    38     $this->theme_list = Array();
    52     $this->theme_list = Array();
    39     $this->named_theme_list = Array();
    53     $this->named_theme_list = Array();
    40     $e = $db->sql_query('SELECT theme_id,theme_name,enabled,default_style FROM '.table_prefix.'themes WHERE enabled=1 ORDER BY theme_order;');
    54     $e = $db->sql_query('SELECT theme_id,theme_name,enabled,default_style FROM '.table_prefix.'themes WHERE enabled=1 ORDER BY theme_order;');
    41     if(!$e) $db->_die('The list of themes could not be selected.');
    55     if(!$e) $db->_die('The list of themes could not be selected.');
   231     
   245     
   232     $btn_selected = ( isset($tplvars['toolbar_button_selected'])) ? $tplvars['toolbar_button_selected'] : $tplvars['toolbar_button'];
   246     $btn_selected = ( isset($tplvars['toolbar_button_selected'])) ? $tplvars['toolbar_button_selected'] : $tplvars['toolbar_button'];
   233     $parser = $this->makeParserText($btn_selected);
   247     $parser = $this->makeParserText($btn_selected);
   234     
   248     
   235     $parser->assign_vars(array(
   249     $parser->assign_vars(array(
   236         'FLAGS' => 'onclick="void(ajaxReset()); return false;" title="View the page contents, all of the page contents, and nothing but the page contents (alt-a)" accesskey="a"',
   250         'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxReset()); return false; }" title="View the page contents, all of the page contents, and nothing but the page contents (alt-a)" accesskey="a"',
   237         'PARENTFLAGS' => 'id="mdgToolbar_article"',
   251         'PARENTFLAGS' => 'id="mdgToolbar_article"',
   238         'HREF' => makeUrl($paths->page, null, true),
   252         'HREF' => makeUrl($paths->page, null, true),
   239         'TEXT' => $this->namespace_string
   253         'TEXT' => $this->namespace_string
   240       ));
   254       ));
   241     
   255     
   275       {
   289       {
   276         $n .= ' total/'.$nu.' unapp.';
   290         $n .= ' total/'.$nu.' unapp.';
   277       }
   291       }
   278       
   292       
   279       $button->assign_vars(array(
   293       $button->assign_vars(array(
   280           'FLAGS' => 'onclick="void(ajaxComments()); return false;" title="View the comments that other users have posted about this page (alt-c)" accesskey="c"',
   294           '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"',
   281           'PARENTFLAGS' => 'id="mdgToolbar_discussion"',
   295           'PARENTFLAGS' => 'id="mdgToolbar_discussion"',
   282           'HREF' => makeUrl($paths->page, 'do=comments', true),
   296           'HREF' => makeUrl($paths->page, 'do=comments', true),
   283           'TEXT' => 'discussion ('.$n.')',
   297           'TEXT' => 'discussion ('.$n.')',
   284         ));
   298         ));
   285       
   299       
   287     }
   301     }
   288     // Edit button
   302     // Edit button
   289     if($session->get_permissions('read') && ($paths->namespace != 'Special' && $paths->namespace != 'Admin') && ( $session->get_permissions('edit_page') && ( ( $paths->page_protected && $session->get_permissions('even_when_protected') ) || !$paths->page_protected ) ) )
   303     if($session->get_permissions('read') && ($paths->namespace != 'Special' && $paths->namespace != 'Admin') && ( $session->get_permissions('edit_page') && ( ( $paths->page_protected && $session->get_permissions('even_when_protected') ) || !$paths->page_protected ) ) )
   290     {
   304     {
   291       $button->assign_vars(array(
   305       $button->assign_vars(array(
   292         'FLAGS' => 'onclick="void(ajaxEditor()); return false;" title="Edit the contents of this page (alt-e)" accesskey="e"',
   306         'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxEditor()); return false; }" title="Edit the contents of this page (alt-e)" accesskey="e"',
   293         'PARENTFLAGS' => 'id="mdgToolbar_edit"',
   307         'PARENTFLAGS' => 'id="mdgToolbar_edit"',
   294         'HREF' => makeUrl($paths->page, 'do=edit', true),
   308         'HREF' => makeUrl($paths->page, 'do=edit', true),
   295         'TEXT' => 'edit this page'
   309         'TEXT' => 'edit this page'
   296         ));
   310         ));
   297       $tb .= $button->run();
   311       $tb .= $button->run();
   298     // View source button
   312     // View source button
   299     }
   313     }
   300     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') 
   314     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') 
   301     {
   315     {
   302       $button->assign_vars(array(
   316       $button->assign_vars(array(
   303         'FLAGS' => 'onclick="void(ajaxViewSource()); return false;" title="View the source code (wiki markup) that this page uses (alt-e)" accesskey="e"',
   317         'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxViewSource()); return false; }" title="View the source code (wiki markup) that this page uses (alt-e)" accesskey="e"',
   304         'PARENTFLAGS' => 'id="mdgToolbar_edit"',
   318         'PARENTFLAGS' => 'id="mdgToolbar_edit"',
   305         'HREF' => makeUrl($paths->page, 'do=viewsource', true),
   319         'HREF' => makeUrl($paths->page, 'do=viewsource', true),
   306         'TEXT' => 'view source'
   320         'TEXT' => 'view source'
   307         ));
   321         ));
   308       $tb .= $button->run();
   322       $tb .= $button->run();
   309     }
   323     }
   310     // History button
   324     // History button
   311     if ( $session->get_permissions('read') /* && $paths->wiki_mode */ && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('history_view') )
   325     if ( $session->get_permissions('read') /* && $paths->wiki_mode */ && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' && $session->get_permissions('history_view') )
   312     {
   326     {
   313       $button->assign_vars(array(
   327       $button->assign_vars(array(
   314         'FLAGS'       => 'onclick="void(ajaxHistory()); return false;" title="View a log of actions taken on this page (alt-h)" accesskey="h"',
   328         'FLAGS'       => 'onclick="if ( !KILL_SWITCH ) { void(ajaxHistory()); return false; }" title="View a log of actions taken on this page (alt-h)" accesskey="h"',
   315         'PARENTFLAGS' => 'id="mdgToolbar_history"',
   329         'PARENTFLAGS' => 'id="mdgToolbar_history"',
   316         'HREF'        => makeUrl($paths->page, 'do=history', true),
   330         'HREF'        => makeUrl($paths->page, 'do=history', true),
   317         'TEXT'        => 'history'
   331         'TEXT'        => 'history'
   318         ));
   332         ));
   319       $tb .= $button->run();
   333       $tb .= $button->run();
   324     // Additional actions menu
   338     // Additional actions menu
   325     // Rename button
   339     // Rename button
   326     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' )
   340     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' )
   327     {
   341     {
   328       $menubtn->assign_vars(array(
   342       $menubtn->assign_vars(array(
   329           'FLAGS' => 'onclick="void(ajaxRename()); return false;" title="Change the display name of this page (alt-r)" accesskey="r"',
   343           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxRename()); return false; }" title="Change the display name of this page (alt-r)" accesskey="r"',
   330           'HREF'  => makeUrl($paths->page, 'do=rename', true),
   344           'HREF'  => makeUrl($paths->page, 'do=rename', true),
   331           'TEXT'  => 'rename',
   345           'TEXT'  => 'rename',
   332         ));
   346         ));
   333       $this->toolbar_menu .= $menubtn->run();
   347       $this->toolbar_menu .= $menubtn->run();
   334     }
   348     }
   335     
   349     
   336     // Vote-to-delete button
   350     // Vote-to-delete button
   337     if ( $paths->wiki_mode && $session->get_permissions('vote_delete') && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin')
   351     if ( $paths->wiki_mode && $session->get_permissions('vote_delete') && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin')
   338     {
   352     {
   339       $menubtn->assign_vars(array(
   353       $menubtn->assign_vars(array(
   340           'FLAGS' => 'onclick="void(ajaxDelVote()); return false;" title="Vote to have this page deleted (alt-d)" accesskey="d"',
   354           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxDelVote()); return false; }" title="Vote to have this page deleted (alt-d)" accesskey="d"',
   341           'HREF'  => makeUrl($paths->page, 'do=delvote', true),
   355           'HREF'  => makeUrl($paths->page, 'do=delvote', true),
   342           'TEXT'  => 'vote to delete this page',
   356           'TEXT'  => 'vote to delete this page',
   343         ));
   357         ));
   344       $this->toolbar_menu .= $menubtn->run();
   358       $this->toolbar_menu .= $menubtn->run();
   345     }
   359     }
   346     
   360     
   347     // Clear-votes button
   361     // Clear-votes button
   348     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)
   362     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)
   349     {
   363     {
   350       $menubtn->assign_vars(array(
   364       $menubtn->assign_vars(array(
   351           'FLAGS' => 'onclick="void(ajaxResetDelVotes()); return false;" title="Vote to have this page deleted (alt-y)" accesskey="y"',
   365           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxResetDelVotes()); return false; }" title="Vote to have this page deleted (alt-y)" accesskey="y"',
   352           'HREF'  => makeUrl($paths->page, 'do=resetvotes', true),
   366           'HREF'  => makeUrl($paths->page, 'do=resetvotes', true),
   353           'TEXT'  => 'reset deletion votes',
   367           'TEXT'  => 'reset deletion votes',
   354         ));
   368         ));
   355       $this->toolbar_menu .= $menubtn->run();
   369       $this->toolbar_menu .= $menubtn->run();
   356     }
   370     }
   378       if ( $paths->cpage['protected'] == 1 )
   392       if ( $paths->cpage['protected'] == 1 )
   379       {
   393       {
   380         $ctmp=' style="text-decoration: underline;"';
   394         $ctmp=' style="text-decoration: underline;"';
   381       }
   395       }
   382       $menubtn->assign_vars(array(
   396       $menubtn->assign_vars(array(
   383           'FLAGS' => 'accesskey="i" onclick="ajaxProtect(1); return false;" id="protbtn_1" title="Prevents all non-administrators from editing this page. [alt-i]"'.$ctmp,
   397           '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,
   384           'HREF'  => makeUrl($paths->page, 'do=protect&level=1', true),
   398           'HREF'  => makeUrl($paths->page, 'do=protect&level=1', true),
   385           'TEXT'  => 'on'
   399           'TEXT'  => 'on'
   386         ));
   400         ));
   387       $t1 = $menubtn->run();
   401       $t1 = $menubtn->run();
   388       
   402       
   390       if ( $paths->cpage['protected'] == 0 )
   404       if ( $paths->cpage['protected'] == 0 )
   391       {
   405       {
   392         $ctmp=' style="text-decoration: underline;"';
   406         $ctmp=' style="text-decoration: underline;"';
   393       }
   407       }
   394       $menubtn->assign_vars(array(
   408       $menubtn->assign_vars(array(
   395           'FLAGS' => 'accesskey="o" onclick="ajaxProtect(0); return false;" id="protbtn_0" title="Allows everyone to edit this page. [alt-o]"'.$ctmp,
   409           'FLAGS' => 'accesskey="o" onclick="if ( !KILL_SWITCH ) { ajaxProtect(0); return false; }" id="protbtn_0" title="Allows everyone to edit this page. [alt-o]"'.$ctmp,
   396           'HREF'  => makeUrl($paths->page, 'do=protect&level=0', true),
   410           'HREF'  => makeUrl($paths->page, 'do=protect&level=0', true),
   397           'TEXT'  => 'off'
   411           'TEXT'  => 'off'
   398         ));
   412         ));
   399       $t2 = $menubtn->run();
   413       $t2 = $menubtn->run();
   400       
   414       
   402       if ( $paths->cpage['protected'] == 2 )
   416       if ( $paths->cpage['protected'] == 2 )
   403       {
   417       {
   404         $ctmp = ' style="text-decoration: underline;"';
   418         $ctmp = ' style="text-decoration: underline;"';
   405       }
   419       }
   406       $menubtn->assign_vars(array(
   420       $menubtn->assign_vars(array(
   407           'FLAGS' => 'accesskey="p" onclick="ajaxProtect(2); return false;" id="protbtn_2" title="Allows only users who have been registered for 4 days to edit this page. [alt-p]"'.$ctmp,
   421           'FLAGS' => 'accesskey="p" onclick="if ( !KILL_SWITCH ) { ajaxProtect(2); return false; }" id="protbtn_2" title="Allows only users who have been registered for 4 days to edit this page. [alt-p]"'.$ctmp,
   408           'HREF'  => makeUrl($paths->page, 'do=protect&level=2', true),
   422           'HREF'  => makeUrl($paths->page, 'do=protect&level=2', true),
   409           'TEXT'  => 'semi'
   423           'TEXT'  => 'semi'
   410         ));
   424         ));
   411       $t3 = $menubtn->run();
   425       $t3 = $menubtn->run();
   412       
   426       
   433       if ( $paths->cpage['wiki_mode'] == 1 )
   447       if ( $paths->cpage['wiki_mode'] == 1 )
   434       {
   448       {
   435         $ctmp = ' style="text-decoration: underline;"';
   449         $ctmp = ' style="text-decoration: underline;"';
   436       }
   450       }
   437       $menubtn->assign_vars(array(
   451       $menubtn->assign_vars(array(
   438           'FLAGS' => 'onclick="ajaxSetWikiMode(1); return false;" id="wikibtn_1" title="Forces wiki functions to be allowed on this page."'.$ctmp,
   452           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { ajaxSetWikiMode(1); return false; }" id="wikibtn_1" title="Forces wiki functions to be allowed on this page."'.$ctmp,
   439           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=1', true),
   453           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=1', true),
   440           'TEXT' => 'on'
   454           'TEXT' => 'on'
   441         ));
   455         ));
   442       $t1 = $menubtn->run();
   456       $t1 = $menubtn->run();
   443       
   457       
   446       if ( $paths->cpage['wiki_mode'] == 0 )
   460       if ( $paths->cpage['wiki_mode'] == 0 )
   447       {
   461       {
   448         $ctmp=' style="text-decoration: underline;"';
   462         $ctmp=' style="text-decoration: underline;"';
   449       }
   463       }
   450       $menubtn->assign_vars(array(
   464       $menubtn->assign_vars(array(
   451           'FLAGS' => 'onclick="ajaxSetWikiMode(0); return false;" id="wikibtn_0" title="Forces wiki functions to be disabled on this page."'.$ctmp,
   465           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { ajaxSetWikiMode(0); return false; }" id="wikibtn_0" title="Forces wiki functions to be disabled on this page."'.$ctmp,
   452           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=0', true),
   466           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=0', true),
   453           'TEXT' => 'off'
   467           'TEXT' => 'off'
   454         ));
   468         ));
   455       $t2 = $menubtn->run();
   469       $t2 = $menubtn->run();
   456       
   470       
   459       if ( $paths->cpage['wiki_mode'] == 2 )
   473       if ( $paths->cpage['wiki_mode'] == 2 )
   460       {
   474       {
   461         $ctmp=' style="text-decoration: underline;"';
   475         $ctmp=' style="text-decoration: underline;"';
   462       }
   476       }
   463       $menubtn->assign_vars(array(
   477       $menubtn->assign_vars(array(
   464           'FLAGS' => 'onclick="ajaxSetWikiMode(2); return false;" id="wikibtn_2" title="Causes this page to use the global wiki mode setting (default)"'.$ctmp,
   478           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { ajaxSetWikiMode(2); return false; }" id="wikibtn_2" title="Causes this page to use the global wiki mode setting (default)"'.$ctmp,
   465           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=2', true),
   479           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=2', true),
   466           'TEXT' => 'global'
   480           'TEXT' => 'global'
   467         ));
   481         ));
   468       $t3 = $menubtn->run();
   482       $t3 = $menubtn->run();
   469       
   483       
   480     
   494     
   481     // Clear logs button
   495     // Clear logs button
   482     if ( $session->get_permissions('read') && $session->get_permissions('clear_logs') && $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
   496     if ( $session->get_permissions('read') && $session->get_permissions('clear_logs') && $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
   483     {
   497     {
   484       $menubtn->assign_vars(array(
   498       $menubtn->assign_vars(array(
   485           'FLAGS' => 'onclick="void(ajaxClearLogs()); return false;" title="Remove all edit and action logs for this page from the database. IRREVERSIBLE! (alt-l)" accesskey="l"',
   499           '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"',
   486           'HREF'  => makeUrl($paths->page, 'do=flushlogs', true),
   500           'HREF'  => makeUrl($paths->page, 'do=flushlogs', true),
   487           'TEXT'  => 'clear page logs',
   501           'TEXT'  => 'clear page logs',
   488         ));
   502         ));
   489       $this->toolbar_menu .= $menubtn->run();
   503       $this->toolbar_menu .= $menubtn->run();
   490     }
   504     }
   501       {
   515       {
   502         $s .= ' (<b>'.$paths->cpage['delvotes'].'</b> votes)';
   516         $s .= ' (<b>'.$paths->cpage['delvotes'].'</b> votes)';
   503       }
   517       }
   504       
   518       
   505       $menubtn->assign_vars(array(
   519       $menubtn->assign_vars(array(
   506           'FLAGS' => 'onclick="void(ajaxDeletePage()); return false;" title="Delete this page. This is always reversible unless the logs are cleared. (alt-k)" accesskey="k"',
   520           '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"',
   507           'HREF'  => makeUrl($paths->page, 'do=deletepage', true),
   521           'HREF'  => makeUrl($paths->page, 'do=deletepage', true),
   508           'TEXT'  => $s,
   522           'TEXT'  => $s,
   509         ));
   523         ));
   510       $this->toolbar_menu .= $menubtn->run();
   524       $this->toolbar_menu .= $menubtn->run();
   511       
   525       
   533       $label = $this->makeParserText($tplvars['toolbar_label']);
   547       $label = $this->makeParserText($tplvars['toolbar_label']);
   534       $label->assign_vars(array('TEXT' => 'page password:'));
   548       $label->assign_vars(array('TEXT' => 'page password:'));
   535       $t0 = $label->run();
   549       $t0 = $label->run();
   536       
   550       
   537       $menubtn->assign_vars(array(
   551       $menubtn->assign_vars(array(
   538           'FLAGS' => 'onclick="void(ajaxSetPassword()); return false;" title="Require a password in order for this page to be viewed"',
   552           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxSetPassword()); return false; }" title="Require a password in order for this page to be viewed"',
   539           'HREF'  => '#',
   553           'HREF'  => '#',
   540           'TEXT'  => 'set',
   554           'TEXT'  => 'set',
   541         ));
   555         ));
   542       $t = $menubtn->run();
   556       $t = $menubtn->run();
   543       
   557       
   546     
   560     
   547     // Manage ACLs button
   561     // Manage ACLs button
   548     if($session->get_permissions('edit_acl') || $session->user_level >= USER_LEVEL_ADMIN)
   562     if($session->get_permissions('edit_acl') || $session->user_level >= USER_LEVEL_ADMIN)
   549     {
   563     {
   550       $menubtn->assign_vars(array(
   564       $menubtn->assign_vars(array(
   551           'FLAGS' => 'onclick="return ajaxOpenACLManager();" title="Manage who can do what with this page (alt-m)" accesskey="m"',
   565           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { return ajaxOpenACLManager(); }" title="Manage who can do what with this page (alt-m)" accesskey="m"',
   552           'HREF'  => makeUrl($paths->page, 'do=aclmanager', true),
   566           'HREF'  => makeUrl($paths->page, 'do=aclmanager', true),
   553           'TEXT'  => 'manage page access',
   567           'TEXT'  => 'manage page access',
   554         ));
   568         ));
   555       $this->toolbar_menu .= $menubtn->run();
   569       $this->toolbar_menu .= $menubtn->run();
   556     }
   570     }
   557     
   571     
   558     // Administer page button
   572     // Administer page button
   559     if ( $session->user_level >= USER_LEVEL_ADMIN && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
   573     if ( $session->user_level >= USER_LEVEL_ADMIN && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
   560     {
   574     {
   561       $menubtn->assign_vars(array(
   575       $menubtn->assign_vars(array(
   562           'FLAGS' => 'onclick="void(ajaxAdminPage()); return false;" title="Administrative options for this page" accesskey="g"',
   576           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxAdminPage()); return false; }" title="Administrative options for this page" accesskey="g"',
   563           'HREF'  => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true),
   577           'HREF'  => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true),
   564           'TEXT'  => 'administrative options',
   578           'TEXT'  => 'administrative options',
   565         ));
   579         ));
   566       $this->toolbar_menu .= $menubtn->run();
   580       $this->toolbar_menu .= $menubtn->run();
   567     }
   581     }
   568     
   582     
   569     if ( strlen($this->toolbar_menu) > 0 )
   583     if ( strlen($this->toolbar_menu) > 0 )
   570     {
   584     {
   571       $button->assign_vars(array(
   585       $button->assign_vars(array(
   572         'FLAGS'       => 'id="mdgToolbar_moreoptions" onclick="return false;" title="Additional options for working with this page"',
   586         'FLAGS'       => 'id="mdgToolbar_moreoptions" onclick="if ( !KILL_SWITCH ) { return false; }" title="Additional options for working with this page"',
   573         'PARENTFLAGS' => '',
   587         'PARENTFLAGS' => '',
   574         'HREF'        => makeUrl($paths->page, 'do=moreoptions', true),
   588         'HREF'        => makeUrl($paths->page, 'do=moreoptions', true),
   575         'TEXT'        => 'more options'
   589         'TEXT'        => 'more options'
   576         ));
   590         ));
   577       $tb .= $button->run();
   591       $tb .= $button->run();
   627     
   641     
   628     $parser = $this->makeParserText($tplvars['sidebar_button']);
   642     $parser = $this->makeParserText($tplvars['sidebar_button']);
   629     
   643     
   630     $parser->assign_vars(Array(
   644     $parser->assign_vars(Array(
   631         'HREF'=>makeUrlNS('Special', 'Logout'),
   645         'HREF'=>makeUrlNS('Special', 'Logout'),
   632         'FLAGS'=>'onclick="mb_logout(); return false;"',
   646         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { mb_logout(); return false; }"',
   633         'TEXT'=>'Log out',
   647         'TEXT'=>'Log out',
   634       ));
   648       ));
   635     
   649     
   636     $logout_link = $parser->run();
   650     $logout_link = $parser->run();
   637     
   651     
   638     $parser->assign_vars(Array(
   652     $parser->assign_vars(Array(
   639         'HREF'=>makeUrlNS('Special', 'Login/' . $paths->page),
   653         'HREF'=>makeUrlNS('Special', 'Login/' . $paths->page),
   640         'FLAGS'=>'onclick="ajaxStartLogin(); return false;"',
   654         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxStartLogin(); return false; }"',
   641         'TEXT'=>'Log in',
   655         'TEXT'=>'Log in',
   642       ));
   656       ));
   643     
   657     
   644     $login_link = $parser->run();
   658     $login_link = $parser->run();
   645     
   659     
   646     $parser->assign_vars(Array(
   660     $parser->assign_vars(Array(
   647         'HREF'=>makeUrlNS('Special', 'ChangeStyle/'.$paths->page),
   661         'HREF'=>makeUrlNS('Special', 'ChangeStyle/'.$paths->page),
   648         'FLAGS'=>'onclick="ajaxChangeStyle(); return false;"',
   662         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxChangeStyle(); return false; }"',
   649         'TEXT'=>'Change theme',
   663         'TEXT'=>'Change theme',
   650       ));
   664       ));
   651     
   665     
   652     $theme_link = $parser->run();
   666     $theme_link = $parser->run();
   653     
   667     
  1219   function tinymce_textarea($name, $content = '', $rows = 20, $cols = 60)
  1233   function tinymce_textarea($name, $content = '', $rows = 20, $cols = 60)
  1220   {
  1234   {
  1221     $randomid = md5(microtime() . mt_rand());
  1235     $randomid = md5(microtime() . mt_rand());
  1222     $html = '';
  1236     $html = '';
  1223     $html .= '<textarea name="' . $name . '" rows="'.$rows.'" cols="'.$cols.'" style="width: 100%;" id="toggleMCEroot_'.$randomid.'">' . $content . '</textarea>';
  1237     $html .= '<textarea name="' . $name . '" rows="'.$rows.'" cols="'.$cols.'" style="width: 100%;" id="toggleMCEroot_'.$randomid.'">' . $content . '</textarea>';
  1224     $html .= '<div style="float: right; display: table;" id="mceSwitchAgent_' . $randomid . '">text editor&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#" onclick="toggleMCE_'.$randomid.'(); return false;">graphical editor</a></div>';
  1238     $html .= '<div style="float: right; display: table;" id="mceSwitchAgent_' . $randomid . '">text editor&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#" onclick="if ( !KILL_SWITCH ) { toggleMCE_'.$randomid.'(); return false; }">graphical editor</a></div>';
  1225     $html .= '<script type="text/javascript">
  1239     $html .= '<script type="text/javascript">
  1226                 // <![CDATA[
  1240                 // <![CDATA[
  1227                 function toggleMCE_'.$randomid.'()
  1241                 function toggleMCE_'.$randomid.'()
  1228                 {
  1242                 {
  1229                   var the_obj = document.getElementById(\'toggleMCEroot_' . $randomid . '\');
  1243                   var the_obj = document.getElementById(\'toggleMCEroot_' . $randomid . '\');
  1230                   var panel = document.getElementById(\'mceSwitchAgent_' . $randomid . '\');
  1244                   var panel = document.getElementById(\'mceSwitchAgent_' . $randomid . '\');
  1231                   if ( the_obj.dnIsMCE == "yes" )
  1245                   if ( the_obj.dnIsMCE == "yes" )
  1232                   {
  1246                   {
  1233                     $dynano(the_obj).destroyMCE();
  1247                     $dynano(the_obj).destroyMCE();
  1234                     panel.innerHTML = \'text editor&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#" onclick="toggleMCE_'.$randomid.'(); return false;">graphical editor</a>\';
  1248                     panel.innerHTML = \'text editor&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#" onclick="if ( !KILL_SWITCH ) { toggleMCE_'.$randomid.'(); return false; }">graphical editor</a>\';
  1235                   }
  1249                   }
  1236                   else
  1250                   else
  1237                   {
  1251                   {
  1238                     $dynano(the_obj).switchToMCE();
  1252                     $dynano(the_obj).switchToMCE();
  1239                     panel.innerHTML = \'<a href="#" onclick="toggleMCE_'.$randomid.'(); return false;">text editor</a>&nbsp;&nbsp;|&nbsp;&nbsp;graphical editor\';
  1253                     panel.innerHTML = \'<a href="#" onclick="if ( !KILL_SWITCH ) { toggleMCE_'.$randomid.'(); return false; }">text editor</a>&nbsp;&nbsp;|&nbsp;&nbsp;graphical editor\';
  1240                   }
  1254                   }
  1241                 }
  1255                 }
  1242                 // ]]>
  1256                 // ]]>
  1243               </script>';
  1257               </script>';
  1244     return $html;
  1258     return $html;
  1367   {
  1381   {
  1368     global $db, $session, $paths, $template, $plugins; // Common objects
  1382     global $db, $session, $paths, $template, $plugins; // Common objects
  1369     // SourceForge/W3C buttons
  1383     // SourceForge/W3C buttons
  1370     $ob = Array();
  1384     $ob = Array();
  1371     $admintitle = ( $session->user_level >= USER_LEVEL_ADMIN ) ? 'title="You may disable this button in the admin panel under General Configuration."' : '';
  1385     $admintitle = ( $session->user_level >= USER_LEVEL_ADMIN ) ? 'title="You may disable this button in the admin panel under General Configuration."' : '';
  1372     if(getConfig('powered_btn') =='1') $ob[] = '<a style="text-align: center;" href="http://enanocms.org/" onclick="window.open(this.href);return false;"><img '.$admintitle.'  alt="Powered by Enano" src="'.scriptPath.'/images/about-powered-enano.png" onmouseover="this.src=\''.scriptPath.'/images/about-powered-enano-hover.png\';" onmouseout="this.src=\''.scriptPath.'/images/about-powered-enano.png\';" style="border-width: 0px;" width="88" height="31" /></a>';
       
  1373     if(getConfig('sflogo_enabled')=='1')
  1386     if(getConfig('sflogo_enabled')=='1')
  1374     {
  1387     {
  1375       $ob[] = '<a style="text-align: center;" href="http://sourceforge.net/" onclick="window.open(this.href);return false;"><img style="border-width: 0px;" alt="SourceForge.net Logo" src="http://sflogo.sourceforge.net/sflogo.php?group_id='.getConfig('sflogo_groupid').'&amp;type='.getConfig('sflogo_type').'" /></a>';
  1388       $ob[] = '<a style="text-align: center;" href="http://sourceforge.net/" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border-width: 0px;" alt="SourceForge.net Logo" src="http://sflogo.sourceforge.net/sflogo.php?group_id='.getConfig('sflogo_groupid').'&amp;type='.getConfig('sflogo_type').'" /></a>';
  1376     }
  1389     }
  1377     if(getConfig('w3c_v32')     =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="window.open(this.href);return false;"><img style="border: 0px solid #FFFFFF;" alt="Valid HTML 3.2"  src="http://www.w3.org/Icons/valid-html32" /></a>';
  1390     if(getConfig('w3c_v32')     =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid HTML 3.2"  src="http://www.w3.org/Icons/valid-html32" /></a>';
  1378     if(getConfig('w3c_v40')     =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="window.open(this.href);return false;"><img style="border: 0px solid #FFFFFF;" alt="Valid HTML 4.0"  src="http://www.w3.org/Icons/valid-html40" /></a>';
  1391     if(getConfig('w3c_v40')     =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid HTML 4.0"  src="http://www.w3.org/Icons/valid-html40" /></a>';
  1379     if(getConfig('w3c_v401')    =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="window.open(this.href);return false;"><img style="border: 0px solid #FFFFFF;" alt="Valid HTML 4.01" src="http://www.w3.org/Icons/valid-html401" /></a>';
  1392     if(getConfig('w3c_v401')    =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid HTML 4.01" src="http://www.w3.org/Icons/valid-html401" /></a>';
  1380     if(getConfig('w3c_vxhtml10')=='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="window.open(this.href);return false;"><img style="border: 0px solid #FFFFFF;" alt="Valid XHTML 1.0" src="http://www.w3.org/Icons/valid-xhtml10" /></a>';
  1393     if(getConfig('w3c_vxhtml10')=='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid XHTML 1.0" src="http://www.w3.org/Icons/valid-xhtml10" /></a>';
  1381     if(getConfig('w3c_vxhtml11')=='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="window.open(this.href);return false;"><img style="border: 0px solid #FFFFFF;" alt="Valid XHTML 1.1" src="http://www.w3.org/Icons/valid-xhtml11" /></a>';
  1394     if(getConfig('w3c_vxhtml11')=='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid XHTML 1.1" src="http://www.w3.org/Icons/valid-xhtml11" /></a>';
  1382     if(getConfig('w3c_vcss')    =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="window.open(this.href);return false;"><img style="border: 0px solid #FFFFFF;" alt="Valid CSS"       src="http://www.w3.org/Icons/valid-css" /></a>';
  1395     if(getConfig('w3c_vcss')    =='1') $ob[] = '<a style="text-align: center;" href="http://validator.w3.org/check?uri=referer" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="Valid CSS"       src="http://www.w3.org/Icons/valid-css" /></a>';
  1383     if(getConfig('dbd_button')  =='1') $ob[] = '<a style="text-align: center;" href="http://www.defectivebydesign.org/join/button" onclick="window.open(this.href);return false;"><img style="border: 0px solid #FFFFFF;" alt="DRM technology restricts what you can do with your computer" src="http://defectivebydesign.org/sites/nodrm.civicactions.net/files/images/dbd_sm_btn.gif" /><br /><small>Protect your freedom >></small></a>';
  1396     if(getConfig('dbd_button')  =='1') $ob[] = '<a style="text-align: center;" href="http://www.defectivebydesign.org/join/button" onclick="if ( !KILL_SWITCH ) { window.open(this.href);return false; }"><img style="border: 0px solid #FFFFFF;" alt="DRM technology restricts what you can do with your computer" src="http://defectivebydesign.org/sites/nodrm.civicactions.net/files/images/dbd_sm_btn.gif" /><br /><small>Protect your freedom >></small></a>';
  1384     
  1397     
  1385     $code = $plugins->setHook('links_widget');
  1398     $code = $plugins->setHook('links_widget');
  1386     foreach ( $code as $cmd )
  1399     foreach ( $code as $cmd )
  1387     {
  1400     {
  1388       eval($cmd);
  1401       eval($cmd);
  1389     }
  1402     }
  1390     
  1403     
  1391     if(count($ob) > 0) $sb_links = '<div style="text-align: center; padding: 5px 0;">'.implode('<br />', $ob).'</div>';
  1404     if(count($ob) > 0) $sb_links = '<div style="text-align: center; padding: 5px 0;">'. ( ( getConfig('powered_btn') == '1' ) ? $this->fading_button : '' ) . implode('<br />', $ob).'</div>';
  1392     else $sb_links = '';
  1405     else $sb_links = '';
  1393     
  1406     
  1394     $this->sidebar_widget('Links', $sb_links);
  1407     $this->sidebar_widget('Links', $sb_links);
  1395   }
  1408   }
  1396   
  1409   
  1533     $tplvars = $this->extract_vars('elements.tpl');
  1546     $tplvars = $this->extract_vars('elements.tpl');
  1534     $tb = '';
  1547     $tb = '';
  1535     // Get the "article" button text (depends on namespace)
  1548     // Get the "article" button text (depends on namespace)
  1536     if(defined('IN_ENANO_INSTALL')) $ns = 'installation page';
  1549     if(defined('IN_ENANO_INSTALL')) $ns = 'installation page';
  1537     else $ns = 'system error page';
  1550     else $ns = 'system error page';
  1538     $t = str_replace('{FLAGS}', 'onclick="return false;" title="Hey! A button that doesn\'t do anything. Clever..." accesskey="a"', $tplvars['toolbar_button']);
  1551     $t = str_replace('{FLAGS}', 'onclick="if ( !KILL_SWITCH ) { return false; }" title="Hey! A button that doesn\'t do anything. Clever..." accesskey="a"', $tplvars['toolbar_button']);
  1539     $t = str_replace('{HREF}', '#', $t);
  1552     $t = str_replace('{HREF}', '#', $t);
  1540     $t = str_replace('{TEXT}', $ns, $t);
  1553     $t = str_replace('{TEXT}', $ns, $t);
  1541     $tb .= $t;
  1554     $tb .= $t;
  1542     
  1555     
  1543     // Page toolbar
  1556     // Page toolbar
  1706     $text = str_replace('<script type="text/javascript" src="{SCRIPTPATH}/ajax.php?title={PAGE_URLNAME}&amp;_mode=jsres"></script>', '', $text); // Remove the AJAX code - we don't need it, and it requires a database connection
  1719     $text = str_replace('<script type="text/javascript" src="{SCRIPTPATH}/ajax.php?title={PAGE_URLNAME}&amp;_mode=jsres"></script>', '', $text); // Remove the AJAX code - we don't need it, and it requires a database connection
  1707     $text = '$tpl_code = \''.str_replace('\'', '\\\'', $text).'\'; return $tpl_code;';
  1720     $text = '$tpl_code = \''.str_replace('\'', '\\\'', $text).'\'; return $tpl_code;';
  1708     $text = preg_replace('#<!-- BEGIN (.*?) -->#is', '\'; if($this->tpl_bool[\'\\1\']) { $tpl_code .= \'', $text);
  1721     $text = preg_replace('#<!-- BEGIN (.*?) -->#is', '\'; if($this->tpl_bool[\'\\1\']) { $tpl_code .= \'', $text);
  1709     $text = preg_replace('#<!-- IFPLUGIN (.*?) -->#is', '\'; if(getConfig(\'plugin_\\1\')==\'1\') { $tpl_code .= \'', $text);
  1722     $text = preg_replace('#<!-- IFPLUGIN (.*?) -->#is', '\'; if(getConfig(\'plugin_\\1\')==\'1\') { $tpl_code .= \'', $text);
  1710     if(defined('IN_ENANO_INSTALL')) $text = str_replace('<!-- SYSMSG Sidebar -->', '<div class="slider"><div class="heading"><a class="head">Installation progress</a></div><div class="slideblock">'.$sideinfo.'</div></div>', $text);
  1723     if(defined('IN_ENANO_INSTALL')) $text = str_replace('<!-- SYSMSG Sidebar -->', '<div class="slider"><div class="heading"><a class="head">Installation progress</a></div><div class="slideblock">'.$sideinfo.'</div></div>', $text);
  1711     else $text = str_replace('<!-- SYSMSG Sidebar -->', '<div class="slider"><div class="heading"><a class="head">System error</a></div><div class="slideblock"><a href="#" onclick="return false;">Enano critical error page</a></div></div>', $text);
  1724     else $text = str_replace('<!-- SYSMSG Sidebar -->', '<div class="slider"><div class="heading"><a class="head">System error</a></div><div class="slideblock"><a href="#" onclick="return false;>Enano critical error page</a></div></div>', $text);
  1712     $text = preg_replace('#<!-- SYSMSG (.*?) -->#is', '', $text);
  1725     $text = preg_replace('#<!-- SYSMSG (.*?) -->#is', '', $text);
  1713     $text = preg_replace('#<!-- BEGINNOT (.*?) -->#is', '\'; if(!$this->tpl_bool[\'\\1\']) { $tpl_code .= \'', $text);
  1726     $text = preg_replace('#<!-- BEGINNOT (.*?) -->#is', '\'; if(!$this->tpl_bool[\'\\1\']) { $tpl_code .= \'', $text);
  1714     $text = preg_replace('#<!-- BEGINELSE (.*?) -->#is', '\'; } else { $tpl_code .= \'', $text);
  1727     $text = preg_replace('#<!-- BEGINELSE (.*?) -->#is', '\'; } else { $tpl_code .= \'', $text);
  1715     $text = preg_replace('#<!-- END (.*?) -->#is', '\'; } $tpl_code .= \'', $text);
  1728     $text = preg_replace('#<!-- END (.*?) -->#is', '\'; } $tpl_code .= \'', $text);
  1716     $text = preg_replace('#{([A-z0-9]*)}#is', '\'.$this->tpl_strings[\'\\1\'].\'', $text);
  1729     $text = preg_replace('#{([A-z0-9]*)}#is', '\'.$this->tpl_strings[\'\\1\'].\'', $text);