includes/template.php
changeset 228 b0a4d179be85
parent 195 eec079676fe7
parent 227 0eca1498a77b
child 231 b11a2f1353c0
equal deleted inserted replaced
197:90b7a52bea45 228:b0a4d179be85
    40     $this->toolbar_menu = '';
    40     $this->toolbar_menu = '';
    41     $this->additional_headers = '';
    41     $this->additional_headers = '';
    42     $this->plugin_blocks = Array();
    42     $this->plugin_blocks = Array();
    43     $this->theme_loaded = false;
    43     $this->theme_loaded = false;
    44     
    44     
    45     $this->fading_button = '<div style="background-image: url('.scriptPath.'/images/about-powered-enano-hover.png); background-repeat: no-repeat; width: 88px; height: 31px; margin: 0 auto;">
    45     $this->fading_button = '<div style="background-image: url('.scriptPath.'/images/about-powered-enano-hover.png); background-repeat: no-repeat; width: 88px; height: 31px; margin: 0 auto 5px auto;">
    46                               <a href="http://enanocms.org/" onclick="window.open(this.href); return false;"><img style="border-width: 0;" alt=" " src="'.scriptPath.'/images/about-powered-enano.png" onmouseover="domOpacity(this, 100, 0, 500);" onmouseout="domOpacity(this, 0, 100, 500);" /></a>
    46                               <a href="http://enanocms.org/" onclick="window.open(this.href); return false;"><img style="border-width: 0;" alt=" " src="'.scriptPath.'/images/about-powered-enano.png" onmouseover="domOpacity(this, 100, 0, 500);" onmouseout="domOpacity(this, 0, 100, 500);" /></a>
    47                             </div>';
    47                             </div>';
    48     
    48     
    49     $this->theme_list = Array();
    49     $this->theme_list = Array();
    50     $this->named_theme_list = Array();
    50     $this->named_theme_list = Array();
   133   
   133   
   134   function init_vars()
   134   function init_vars()
   135   {
   135   {
   136     global $db, $session, $paths, $template, $plugins; // Common objects
   136     global $db, $session, $paths, $template, $plugins; // Common objects
   137     global $email;
   137     global $email;
       
   138     global $lang;
   138     
   139     
   139     dc_here("template: initializing all variables");
   140     dc_here("template: initializing all variables");
   140     
   141     
   141     if(!$this->theme || !$this->style)
   142     if(!$this->theme || !$this->style)
   142     {
   143     {
   195     
   196     
   196     // Get the "article" button text (depends on namespace)
   197     // Get the "article" button text (depends on namespace)
   197     switch($paths->namespace) {
   198     switch($paths->namespace) {
   198       case "Article":
   199       case "Article":
   199       default:
   200       default:
   200         $ns = 'article';
   201         $ns = $lang->get('onpage_lbl_page_article');
   201         break;
   202         break;
   202       case "Admin":
   203       case "Admin":
   203         $ns = 'administration page';
   204         $ns = $lang->get('onpage_lbl_page_admin');
   204         break;
   205         break;
   205       case "System":
   206       case "System":
   206         $ns = 'system message';
   207         $ns = $lang->get('onpage_lbl_page_system');
   207         break;
   208         break;
   208       case "File":
   209       case "File":
   209         $ns = 'uploaded file';
   210         $ns = $lang->get('onpage_lbl_page_file');
   210         break;
   211         break;
   211       case "Help":
   212       case "Help":
   212         $ns = 'documentation page';
   213         $ns = $lang->get('onpage_lbl_page_help');
   213         break;
   214         break;
   214       case "User":
   215       case "User":
   215         $ns = 'user page';
   216         $ns = $lang->get('onpage_lbl_page_user');
   216         break;
   217         break;
   217       case "Special":
   218       case "Special":
   218         $ns = 'special page';
   219         $ns = $lang->get('onpage_lbl_page_special');
   219         break;
   220         break;
   220       case "Template":
   221       case "Template":
   221         $ns = 'template';
   222         $ns = $lang->get('onpage_lbl_page_template');
   222         break;
   223         break;
   223       case "Project":
   224       case "Project":
   224         $ns = 'project page';
   225         $ns = $lang->get('onpage_lbl_page_project');
   225         break;
   226         break;
   226       case "Category":
   227       case "Category":
   227         $ns = 'category';
   228         $ns = $lang->get('onpage_lbl_page_category');
   228         break;
   229         break;
   229     }
   230     }
   230     $this->namespace_string = $ns;
   231     $this->namespace_string = $ns;
       
   232     unset($ns);
   231     $code = $plugins->setHook('page_type_string_set');
   233     $code = $plugins->setHook('page_type_string_set');
   232     foreach ( $code as $cmd )
   234     foreach ( $code as $cmd )
   233     {
   235     {
   234       eval($cmd);
   236       eval($cmd);
   235     }
   237     }
   282       
   284       
   283       $db->free_result();
   285       $db->free_result();
   284       $n = ( $session->get_permissions('mod_comments') ) ? (string)$nc : (string)$na;
   286       $n = ( $session->get_permissions('mod_comments') ) ? (string)$nc : (string)$na;
   285       if ( $session->get_permissions('mod_comments') && $nu > 0 )
   287       if ( $session->get_permissions('mod_comments') && $nu > 0 )
   286       {
   288       {
   287         $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);
   288       }
   301       }
   289       
   302       
   290       $button->assign_vars(array(
   303       $button->assign_vars(array(
   291           '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"',
   292           'PARENTFLAGS' => 'id="mdgToolbar_discussion"',
   305           'PARENTFLAGS' => 'id="mdgToolbar_discussion"',
   293           'HREF' => makeUrl($paths->page, 'do=comments', true),
   306           'HREF' => makeUrl($paths->page, 'do=comments', true),
   294           'TEXT' => 'discussion ('.$n.')',
   307           'TEXT' => $btn_text,
   295         ));
   308         ));
   296       
   309       
   297       $tb .= $button->run();
   310       $tb .= $button->run();
   298     }
   311     }
   299     // Edit button
   312     // Edit button
   301     {
   314     {
   302       $button->assign_vars(array(
   315       $button->assign_vars(array(
   303         '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"',
   304         'PARENTFLAGS' => 'id="mdgToolbar_edit"',
   317         'PARENTFLAGS' => 'id="mdgToolbar_edit"',
   305         'HREF' => makeUrl($paths->page, 'do=edit', true),
   318         'HREF' => makeUrl($paths->page, 'do=edit', true),
   306         'TEXT' => 'edit this page'
   319         'TEXT' => $lang->get('onpage_btn_edit')
   307         ));
   320         ));
   308       $tb .= $button->run();
   321       $tb .= $button->run();
   309     // View source button
   322     // View source button
   310     }
   323     }
   311     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') 
   312     {
   325     {
   313       $button->assign_vars(array(
   326       $button->assign_vars(array(
   314         '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"',
   315         'PARENTFLAGS' => 'id="mdgToolbar_edit"',
   328         'PARENTFLAGS' => 'id="mdgToolbar_edit"',
   316         'HREF' => makeUrl($paths->page, 'do=viewsource', true),
   329         'HREF' => makeUrl($paths->page, 'do=viewsource', true),
   317         'TEXT' => 'view source'
   330         'TEXT' => $lang->get('onpage_btn_viewsource')
   318         ));
   331         ));
   319       $tb .= $button->run();
   332       $tb .= $button->run();
   320     }
   333     }
   321     // History button
   334     // History button
   322     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') )
   323     {
   336     {
   324       $button->assign_vars(array(
   337       $button->assign_vars(array(
   325         '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"',
   326         'PARENTFLAGS' => 'id="mdgToolbar_history"',
   339         'PARENTFLAGS' => 'id="mdgToolbar_history"',
   327         'HREF'        => makeUrl($paths->page, 'do=history', true),
   340         'HREF'        => makeUrl($paths->page, 'do=history', true),
   328         'TEXT'        => 'history'
   341         'TEXT'        => $lang->get('onpage_btn_history')
   329         ));
   342         ));
   330       $tb .= $button->run();
   343       $tb .= $button->run();
   331     }
   344     }
   332     
   345     
   333     $menubtn = $this->makeParserText($tplvars['toolbar_menu_button']);
   346     $menubtn = $this->makeParserText($tplvars['toolbar_menu_button']);
   337     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' )
   338     {
   351     {
   339       $menubtn->assign_vars(array(
   352       $menubtn->assign_vars(array(
   340           '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"',
   341           'HREF'  => makeUrl($paths->page, 'do=rename', true),
   354           'HREF'  => makeUrl($paths->page, 'do=rename', true),
   342           'TEXT'  => 'rename',
   355           'TEXT'  => $lang->get('onpage_btn_rename'),
   343         ));
   356         ));
   344       $this->toolbar_menu .= $menubtn->run();
   357       $this->toolbar_menu .= $menubtn->run();
   345     }
   358     }
   346     
   359     
   347     // Vote-to-delete button
   360     // Vote-to-delete button
   348     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')
   349     {
   362     {
   350       $menubtn->assign_vars(array(
   363       $menubtn->assign_vars(array(
   351           '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"',
   352           'HREF'  => makeUrl($paths->page, 'do=delvote', true),
   365           'HREF'  => makeUrl($paths->page, 'do=delvote', true),
   353           'TEXT'  => 'vote to delete this page',
   366           'TEXT'  => $lang->get('onpage_btn_votedelete'),
   354         ));
   367         ));
   355       $this->toolbar_menu .= $menubtn->run();
   368       $this->toolbar_menu .= $menubtn->run();
   356     }
   369     }
   357     
   370     
   358     // Clear-votes button
   371     // Clear-votes button
   359     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)
   360     {
   373     {
   361       $menubtn->assign_vars(array(
   374       $menubtn->assign_vars(array(
   362           '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"',
   363           'HREF'  => makeUrl($paths->page, 'do=resetvotes', true),
   376           'HREF'  => makeUrl($paths->page, 'do=resetvotes', true),
   364           'TEXT'  => 'reset deletion votes',
   377           'TEXT'  => $lang->get('onpage_btn_votedelete_reset'),
   365         ));
   378         ));
   366       $this->toolbar_menu .= $menubtn->run();
   379       $this->toolbar_menu .= $menubtn->run();
   367     }
   380     }
   368     
   381     
   369     // Printable page button
   382     // Printable page button
   370     if ( $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
   383     if ( $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
   371     {
   384     {
   372       $menubtn->assign_vars(array(
   385       $menubtn->assign_vars(array(
   373           '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"',
   374           'HREF'  => makeUrl($paths->page, 'printable=yes', true),
   387           'HREF'  => makeUrl($paths->page, 'printable=yes', true),
   375           'TEXT'  => 'view printable version',
   388           'TEXT'  => $lang->get('onpage_btn_printable'),
   376         ));
   389         ));
   377       $this->toolbar_menu .= $menubtn->run();
   390       $this->toolbar_menu .= $menubtn->run();
   378     }
   391     }
   379     
   392     
   380     // Protect button
   393     // Protect button
   381     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'))
   382     {
   395     {
   383       
   396       
   384       $label = $this->makeParserText($tplvars['toolbar_label']);
   397       $label = $this->makeParserText($tplvars['toolbar_label']);
   385       $label->assign_vars(array('TEXT' => 'protection:'));
   398       $label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_protect')));
   386       $t0 = $label->run();
   399       $t0 = $label->run();
   387       
   400       
   388       $ctmp = ''; 
   401       $ctmp = ''; 
   389       if ( $paths->cpage['protected'] == 1 )
   402       if ( $paths->cpage['protected'] == 1 )
   390       {
   403       {
   391         $ctmp=' style="text-decoration: underline;"';
   404         $ctmp=' style="text-decoration: underline;"';
   392       }
   405       }
   393       $menubtn->assign_vars(array(
   406       $menubtn->assign_vars(array(
   394           '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,
   395           'HREF'  => makeUrl($paths->page, 'do=protect&level=1', true),
   408           'HREF'  => makeUrl($paths->page, 'do=protect&level=1', true),
   396           'TEXT'  => 'on'
   409           'TEXT'  => $lang->get('onpage_btn_protect_on')
   397         ));
   410         ));
   398       $t1 = $menubtn->run();
   411       $t1 = $menubtn->run();
   399       
   412       
   400       $ctmp = '';
   413       $ctmp = '';
   401       if ( $paths->cpage['protected'] == 0 )
   414       if ( $paths->cpage['protected'] == 0 )
   403         $ctmp=' style="text-decoration: underline;"';
   416         $ctmp=' style="text-decoration: underline;"';
   404       }
   417       }
   405       $menubtn->assign_vars(array(
   418       $menubtn->assign_vars(array(
   406           'FLAGS' => 'accesskey="o" onclick="if ( !KILL_SWITCH ) { ajaxProtect(0); return false; }" id="protbtn_0" title="Allows everyone to edit this page. [alt-o]"'.$ctmp,
   419           'FLAGS' => 'accesskey="o" onclick="if ( !KILL_SWITCH ) { ajaxProtect(0); return false; }" id="protbtn_0" title="Allows everyone to edit this page. [alt-o]"'.$ctmp,
   407           'HREF'  => makeUrl($paths->page, 'do=protect&level=0', true),
   420           'HREF'  => makeUrl($paths->page, 'do=protect&level=0', true),
   408           'TEXT'  => 'off'
   421           'TEXT'  => $lang->get('onpage_btn_protect_off')
   409         ));
   422         ));
   410       $t2 = $menubtn->run();
   423       $t2 = $menubtn->run();
   411       
   424       
   412       $ctmp = '';
   425       $ctmp = '';
   413       if ( $paths->cpage['protected'] == 2 )
   426       if ( $paths->cpage['protected'] == 2 )
   415         $ctmp = ' style="text-decoration: underline;"';
   428         $ctmp = ' style="text-decoration: underline;"';
   416       }
   429       }
   417       $menubtn->assign_vars(array(
   430       $menubtn->assign_vars(array(
   418           '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,
   431           '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,
   419           'HREF'  => makeUrl($paths->page, 'do=protect&level=2', true),
   432           'HREF'  => makeUrl($paths->page, 'do=protect&level=2', true),
   420           'TEXT'  => 'semi'
   433           'TEXT'  => $lang->get('onpage_btn_protect_semi')
   421         ));
   434         ));
   422       $t3 = $menubtn->run();
   435       $t3 = $menubtn->run();
   423       
   436       
   424       $this->toolbar_menu .= '        <table border="0" cellspacing="0" cellpadding="0">
   437       $this->toolbar_menu .= '        <table border="0" cellspacing="0" cellpadding="0">
   425           <tr>
   438           <tr>
   434     // Wiki mode button
   447     // Wiki mode button
   435     if($session->get_permissions('read') && $paths->page_exists && $session->get_permissions('set_wiki_mode') && $paths->namespace != 'Special' && $paths->namespace != 'Admin')
   448     if($session->get_permissions('read') && $paths->page_exists && $session->get_permissions('set_wiki_mode') && $paths->namespace != 'Special' && $paths->namespace != 'Admin')
   436     {
   449     {
   437       // label at start
   450       // label at start
   438       $label = $this->makeParserText($tplvars['toolbar_label']);
   451       $label = $this->makeParserText($tplvars['toolbar_label']);
   439       $label->assign_vars(array('TEXT' => 'page wiki mode:'));
   452       $label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_wikimode')));
   440       $t0 = $label->run();
   453       $t0 = $label->run();
   441       
   454       
   442       // on button
   455       // on button
   443       $ctmp = '';
   456       $ctmp = '';
   444       if ( $paths->cpage['wiki_mode'] == 1 )
   457       if ( $paths->cpage['wiki_mode'] == 1 )
   446         $ctmp = ' style="text-decoration: underline;"';
   459         $ctmp = ' style="text-decoration: underline;"';
   447       }
   460       }
   448       $menubtn->assign_vars(array(
   461       $menubtn->assign_vars(array(
   449           'FLAGS' => /* 'onclick="if ( !KILL_SWITCH ) { ajaxSetWikiMode(1); return false; }" id="wikibtn_1" title="Forces wiki functions to be allowed on this page."'. */ $ctmp,
   462           'FLAGS' => /* 'onclick="if ( !KILL_SWITCH ) { ajaxSetWikiMode(1); return false; }" id="wikibtn_1" title="Forces wiki functions to be allowed on this page."'. */ $ctmp,
   450           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=1', true),
   463           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=1', true),
   451           'TEXT' => 'on'
   464           'TEXT' => $lang->get('onpage_btn_wikimode_on')
   452         ));
   465         ));
   453       $t1 = $menubtn->run();
   466       $t1 = $menubtn->run();
   454       
   467       
   455       // off button
   468       // off button
   456       $ctmp = '';
   469       $ctmp = '';
   459         $ctmp=' style="text-decoration: underline;"';
   472         $ctmp=' style="text-decoration: underline;"';
   460       }
   473       }
   461       $menubtn->assign_vars(array(
   474       $menubtn->assign_vars(array(
   462           'FLAGS' => /* 'onclick="if ( !KILL_SWITCH ) { ajaxSetWikiMode(0); return false; }" id="wikibtn_0" title="Forces wiki functions to be disabled on this page."'. */ $ctmp,
   475           'FLAGS' => /* 'onclick="if ( !KILL_SWITCH ) { ajaxSetWikiMode(0); return false; }" id="wikibtn_0" title="Forces wiki functions to be disabled on this page."'. */ $ctmp,
   463           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=0', true),
   476           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=0', true),
   464           'TEXT' => 'off'
   477           'TEXT' => $lang->get('onpage_btn_wikimode_off')
   465         ));
   478         ));
   466       $t2 = $menubtn->run();
   479       $t2 = $menubtn->run();
   467       
   480       
   468       // global button
   481       // global button
   469       $ctmp = ''; 
   482       $ctmp = ''; 
   472         $ctmp=' style="text-decoration: underline;"';
   485         $ctmp=' style="text-decoration: underline;"';
   473       }
   486       }
   474       $menubtn->assign_vars(array(
   487       $menubtn->assign_vars(array(
   475           '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,
   488           '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,
   476           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=2', true),
   489           'HREF' => makeUrl($paths->page, 'do=setwikimode&level=2', true),
   477           'TEXT' => 'global'
   490           'TEXT' => $lang->get('onpage_btn_wikimode_global')
   478         ));
   491         ));
   479       $t3 = $menubtn->run();
   492       $t3 = $menubtn->run();
   480       
   493       
   481       // Tack it onto the list of buttons that are already there...
   494       // Tack it onto the list of buttons that are already there...
   482       $this->toolbar_menu .= '        <table border="0" cellspacing="0" cellpadding="0">
   495       $this->toolbar_menu .= '        <table border="0" cellspacing="0" cellpadding="0">
   493     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' )
   494     {
   507     {
   495       $menubtn->assign_vars(array(
   508       $menubtn->assign_vars(array(
   496           '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"',
   497           'HREF'  => makeUrl($paths->page, 'do=flushlogs', true),
   510           'HREF'  => makeUrl($paths->page, 'do=flushlogs', true),
   498           'TEXT'  => 'clear page logs',
   511           'TEXT'  => $lang->get('onpage_btn_clearlogs'),
   499         ));
   512         ));
   500       $this->toolbar_menu .= $menubtn->run();
   513       $this->toolbar_menu .= $menubtn->run();
   501     }
   514     }
   502     
   515     
   503     // Delete page button
   516     // Delete page button
   504     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' )
   505     {
   518     {
   506       $s = 'delete this page';
   519       $s = $lang->get('onpage_btn_deletepage');
   507       if ( $paths->cpage['delvotes'] == 1 )
   520       if ( $paths->cpage['delvotes'] == 1 )
   508       {
   521       {
   509         $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);
   510       }
   527       }
   511       else if ( $paths->cpage['delvotes'] > 1 )
   528       else if ( $paths->cpage['delvotes'] > 1 )
   512       {
   529       {
   513         $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);
   514       }
   535       }
   515       
   536       
   516       $menubtn->assign_vars(array(
   537       $menubtn->assign_vars(array(
   517           '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"',
   518           'HREF'  => makeUrl($paths->page, 'do=deletepage', true),
   539           'HREF'  => makeUrl($paths->page, 'do=deletepage', true),
   540     }
   561     }
   541     if ( $a && $session->get_permissions('read') && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
   562     if ( $a && $session->get_permissions('read') && $paths->page_exists && $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
   542     {
   563     {
   543       // label at start
   564       // label at start
   544       $label = $this->makeParserText($tplvars['toolbar_label']);
   565       $label = $this->makeParserText($tplvars['toolbar_label']);
   545       $label->assign_vars(array('TEXT' => 'page password:'));
   566       $label->assign_vars(array('TEXT' => $lang->get('onpage_lbl_password')));
   546       $t0 = $label->run();
   567       $t0 = $label->run();
   547       
   568       
   548       $menubtn->assign_vars(array(
   569       $menubtn->assign_vars(array(
   549           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxSetPassword()); return false; }" title="Require a password in order for this page to be viewed"',
   570           'FLAGS' => 'onclick="if ( !KILL_SWITCH ) { void(ajaxSetPassword()); return false; }" title="Require a password in order for this page to be viewed"',
   550           'HREF'  => '#',
   571           'HREF'  => '#',
   551           'TEXT'  => 'set',
   572           'TEXT'  => $lang->get('onpage_btn_password_set'),
   552         ));
   573         ));
   553       $t = $menubtn->run();
   574       $t = $menubtn->run();
   554       
   575       
   555       $this->toolbar_menu .= '<table border="0" cellspacing="0" cellpadding="0"><tr><td>'.$t0.'</td><td><input type="password" id="mdgPassSetField" size="10" /></td><td>'.$t.'</td></tr></table>';
   576       $this->toolbar_menu .= '<table border="0" cellspacing="0" cellpadding="0"><tr><td>'.$t0.'</td><td><input type="password" id="mdgPassSetField" size="10" /></td><td>'.$t.'</td></tr></table>';
   556     }
   577     }
   559     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)
   560     {
   581     {
   561       $menubtn->assign_vars(array(
   582       $menubtn->assign_vars(array(
   562           '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"',
   563           'HREF'  => makeUrl($paths->page, 'do=aclmanager', true),
   584           'HREF'  => makeUrl($paths->page, 'do=aclmanager', true),
   564           'TEXT'  => 'manage page access',
   585           'TEXT'  => $lang->get('onpage_btn_acl'),
   565         ));
   586         ));
   566       $this->toolbar_menu .= $menubtn->run();
   587       $this->toolbar_menu .= $menubtn->run();
   567     }
   588     }
   568     
   589     
   569     // Administer page button
   590     // Administer page button
   570     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' )
   571     {
   592     {
   572       $menubtn->assign_vars(array(
   593       $menubtn->assign_vars(array(
   573           '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"',
   574           'HREF'  => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true),
   595           'HREF'  => makeUrlNS('Special', 'Administration', 'module='.$paths->nslist['Admin'].'PageManager', true),
   575           'TEXT'  => 'administrative options',
   596           'TEXT'  => $lang->get('onpage_btn_admin'),
   576         ));
   597         ));
   577       $this->toolbar_menu .= $menubtn->run();
   598       $this->toolbar_menu .= $menubtn->run();
   578     }
   599     }
   579     
   600     
   580     if ( strlen($this->toolbar_menu) > 0 )
   601     if ( strlen($this->toolbar_menu) > 0 )
   581     {
   602     {
   582       $button->assign_vars(array(
   603       $button->assign_vars(array(
   583         '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"',
   584         'PARENTFLAGS' => '',
   605         'PARENTFLAGS' => '',
   585         'HREF'        => makeUrl($paths->page, 'do=moreoptions', true),
   606         'HREF'        => makeUrl($paths->page, 'do=moreoptions', true),
   586         'TEXT'        => 'more options'
   607         'TEXT'        => $lang->get('onpage_btn_moreoptions')
   587         ));
   608         ));
   588       $tb .= $button->run();
   609       $tb .= $button->run();
   589     }
   610     }
   590     
   611     
   591     $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;
   630     $p = ( isset($_GET['printable']) ) ? '/printable' : '';
   651     $p = ( isset($_GET['printable']) ) ? '/printable' : '';
   631     
   652     
   632     // Add the e-mail address client code to the header
   653     // Add the e-mail address client code to the header
   633     $this->add_header($email->jscode());
   654     $this->add_header($email->jscode());
   634     
   655     
       
   656     // Add language file
       
   657     $lang_uri = makeUrlNS('Special', 'LangExportJSON/' . $lang->lang_id, false, true);
       
   658     $this->add_header("<script type=\"text/javascript\" src=\"$lang_uri\"></script>");
       
   659     
   635     // Generate the code for the Log out and Change theme sidebar buttons
   660     // Generate the code for the Log out and Change theme sidebar buttons
   636     // Once again, the new template parsing system can be used here
   661     // Once again, the new template parsing system can be used here
   637     
   662     
   638     $parser = $this->makeParserText($tplvars['sidebar_button']);
   663     $parser = $this->makeParserText($tplvars['sidebar_button']);
   639     
   664     
   640     $parser->assign_vars(Array(
   665     $parser->assign_vars(Array(
   641         'HREF'=>makeUrlNS('Special', 'Logout'),
   666         'HREF'=>makeUrlNS('Special', 'Logout'),
   642         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { mb_logout(); return false; }"',
   667         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { mb_logout(); return false; }"',
   643         'TEXT'=>'Log out',
   668         'TEXT'=>$lang->get('sidebar_btn_logout'),
   644       ));
   669       ));
   645     
   670     
   646     $logout_link = $parser->run();
   671     $logout_link = $parser->run();
   647     
   672     
   648     $parser->assign_vars(Array(
   673     $parser->assign_vars(Array(
   649         'HREF'=>makeUrlNS('Special', 'Login/' . $paths->page),
   674         'HREF'=>makeUrlNS('Special', 'Login/' . $paths->page),
   650         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxStartLogin(); return false; }"',
   675         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxStartLogin(); return false; }"',
   651         'TEXT'=>'Log in',
   676         'TEXT'=>$lang->get('sidebar_btn_login'),
   652       ));
   677       ));
   653     
   678     
   654     $login_link = $parser->run();
   679     $login_link = $parser->run();
   655     
   680     
   656     $parser->assign_vars(Array(
   681     $parser->assign_vars(Array(
   657         'HREF'=>makeUrlNS('Special', 'ChangeStyle/'.$paths->page),
   682         'HREF'=>makeUrlNS('Special', 'ChangeStyle/'.$paths->page),
   658         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxChangeStyle(); return false; }"',
   683         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxChangeStyle(); return false; }"',
   659         'TEXT'=>'Change theme',
   684         'TEXT'=>$lang->get('sidebar_btn_changestyle'),
   660       ));
   685       ));
   661     
   686     
   662     $theme_link = $parser->run();
   687     $theme_link = $parser->run();
   663     
   688     
   664     $parser->assign_vars(Array(
   689     $parser->assign_vars(Array(
   665         'HREF'=>makeUrlNS('Special', 'Administration'),
   690         'HREF'=>makeUrlNS('Special', 'Administration'),
   666         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { void(ajaxStartAdminLogin()); return false; }"',
   691         'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { void(ajaxStartAdminLogin()); return false; }"',
   667         'TEXT'=>'Administration',
   692         'TEXT'=>$lang->get('sidebar_btn_administration'),
   668       ));
   693       ));
   669     
   694     
   670     $admin_link = $parser->run();
   695     $admin_link = $parser->run();
   671     
   696     
   672     $SID = ($session->sid_super) ? $session->sid_super : '';
   697     $SID = ($session->sid_super) ? $session->sid_super : '';
   708               // if($t['theme_id'] == $session->theme) $js_dynamic .= ' selected="selected"';
   733               // if($t['theme_id'] == $session->theme) $js_dynamic .= ' selected="selected"';
   709               $js_dynamic .= '>'.$t['theme_name'].'</option>';
   734               $js_dynamic .= '>'.$t['theme_name'].'</option>';
   710             }
   735             }
   711           }
   736           }
   712       $js_dynamic .= '\';
   737       $js_dynamic .= '\';
   713       var ENANO_CURRENT_THEME = \''. $session->theme .'\';';
   738       var ENANO_CURRENT_THEME = \''. $session->theme .'\';
       
   739       var ENANO_LANG_ID = ' . $lang->lang_id . ';
       
   740       var ENANO_PAGE_TYPE = "' . addslashes($this->namespace_string) . '";';
   714       foreach($paths->nslist as $k => $c)
   741       foreach($paths->nslist as $k => $c)
   715       {
   742       {
   716         $js_dynamic .= "namespace_list['{$k}'] = '$c';";
   743         $js_dynamic .= "namespace_list['{$k}'] = '$c';";
   717       }
   744       }
   718       $js_dynamic .= "\n    //]]>\n    </script>";
   745       $js_dynamic .= "\n    //]]>\n    </script>";
   770   }
   797   }
   771   
   798   
   772   function header($simple = false) 
   799   function header($simple = false) 
   773   {
   800   {
   774     global $db, $session, $paths, $template, $plugins; // Common objects
   801     global $db, $session, $paths, $template, $plugins; // Common objects
       
   802     global $lang;
       
   803     
   775     ob_start();
   804     ob_start();
   776     
   805     
   777     if(!$this->theme_loaded)
   806     if(!$this->theme_loaded)
   778     {
   807     {
   779       $this->load_theme($session->theme, $session->style);
   808       $this->load_theme($session->theme, $session->style);
   796     }
   825     }
   797     if ( !$simple && $session->sw_timed_out )
   826     if ( !$simple && $session->sw_timed_out )
   798     {
   827     {
   799       $login_link = makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . $session->user_level, true);
   828       $login_link = makeUrlNS('Special', 'Login/' . $paths->fullpage, 'level=' . $session->user_level, true);
   800       echo '<div class="usermessage">';
   829       echo '<div class="usermessage">';
   801       echo '<b>Your administrative session has timed out.</b> <a href="' . $login_link . '">Log in again</a>';
   830       echo $lang->get('user_msg_elev_timed_out', array( 'login_link' => $login_link ));
   802       echo '</div>';
   831       echo '</div>';
   803     }
   832     }
   804     if ( $this->site_disabled && $session->user_level >= USER_LEVEL_ADMIN && ( $paths->page != $paths->nslist['Special'] . 'Administration' ) )
   833     if ( $this->site_disabled && $session->user_level >= USER_LEVEL_ADMIN && ( $paths->page != $paths->nslist['Special'] . 'Administration' ) )
   805     {
   834     {
   806       $admin_link = makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'GeneralConfig', true);
   835       $admin_link = makeUrlNS('Special', 'Administration', 'module=' . $paths->nslist['Admin'] . 'GeneralConfig', true);
  1137       // $md5 will be set by the cached file
  1166       // $md5 will be set by the cached file
  1138       // This makes sure that a cached copy of the template is used only if its MD5
  1167       // This makes sure that a cached copy of the template is used only if its MD5
  1139       // matches the MD5 of the file that the compiled file was compiled from.
  1168       // matches the MD5 of the file that the compiled file was compiled from.
  1140       if ( isset($md5) && $md5 == md5($text) )
  1169       if ( isset($md5) && $md5 == md5($text) )
  1141       {
  1170       {
  1142         return str_replace('\\"', '"', $tpl_text);
  1171         return $this->compile_template_text_post(str_replace('\\"', '"', $tpl_text));
  1143       }
  1172       }
  1144     }
  1173     }
  1145     
  1174     
  1146     // We won't use the cached copy here
  1175     // We won't use the cached copy here
  1147     $text = file_get_contents($tpl_file_fullpath);
  1176     $text = file_get_contents($tpl_file_fullpath);
  1176       // $tpl_text actually will contain the compiled code
  1205       // $tpl_text actually will contain the compiled code
  1177       fwrite($h, '<?php ' . $notice . ' $md5 = \'' . $md5 . '\'; $tpl_text = \'' . $text_escaped . '\'; ?>');
  1206       fwrite($h, '<?php ' . $notice . ' $md5 = \'' . $md5 . '\'; $tpl_text = \'' . $text_escaped . '\'; ?>');
  1178       fclose($h);
  1207       fclose($h);
  1179     }
  1208     }
  1180     
  1209     
  1181     return $text; //('<pre>'.htmlspecialchars($text).'</pre>');
  1210     return $this->compile_template_text_post($text); //('<pre>'.htmlspecialchars($text).'</pre>');
  1182   }
  1211   }
  1183   
  1212   
  1184   
  1213   
  1185   /**
  1214   /**
  1186    * Compiles (parses) some template code with the current master set of variables and booleans.
  1215    * Compiles (parses) some template code with the current master set of variables and booleans.
  1189    */
  1218    */
  1190   
  1219   
  1191   function compile_template_text($text)
  1220   function compile_template_text($text)
  1192   {
  1221   {
  1193     // this might do something else in the future, possibly cache large templates
  1222     // this might do something else in the future, possibly cache large templates
  1194     return $this->compile_tpl_code($text);
  1223     return $this->compile_template_text_post($this->compile_tpl_code($text));
  1195   }
  1224   }
  1196   
  1225   
  1197   /**
  1226   /**
  1198    * For convenience - compiles AND parses some template code.
  1227    * For convenience - compiles AND parses some template code.
  1199    * @param string Text to process
  1228    * @param string Text to process
  1201    */
  1230    */
  1202   
  1231   
  1203   function parse($text)
  1232   function parse($text)
  1204   {
  1233   {
  1205     $text = $this->compile_template_text($text);
  1234     $text = $this->compile_template_text($text);
       
  1235     $text = $this->compile_template_text_post($text);
  1206     return eval($text);
  1236     return eval($text);
       
  1237   }
       
  1238   
       
  1239   /**
       
  1240    * Post-processor for template code. Basically what this does is it localizes {lang:foo} blocks.
       
  1241    * @param string Mostly-processed TPL code
       
  1242    * @return string
       
  1243    */
       
  1244   
       
  1245   function compile_template_text_post($text)
       
  1246   {
       
  1247     global $lang;
       
  1248     preg_match_all('/\{lang:([a-z0-9]+_[a-z0-9_]+)\}/', $text, $matches);
       
  1249     foreach ( $matches[1] as $i => $string_id )
       
  1250     {
       
  1251       $string = $lang->get($string_id);
       
  1252       $string = str_replace('\\', '\\\\', $string);
       
  1253       $string = str_replace('\'', '\\\'', $string);
       
  1254       $text = str_replace_once($matches[0][$i], $string, $text);
       
  1255     }
       
  1256     return $text;
  1207   }
  1257   }
  1208   
  1258   
  1209   // Steps to turn this:
  1259   // Steps to turn this:
  1210   //   [[Project:Community Portal]]
  1260   //   [[Project:Community Portal]]
  1211   // into this:
  1261   // into this:
  1233    */
  1283    */
  1234   
  1284   
  1235   function tplWikiFormat($message, $filter_links = false, $filename = 'elements.tpl')
  1285   function tplWikiFormat($message, $filter_links = false, $filename = 'elements.tpl')
  1236   {
  1286   {
  1237     global $db, $session, $paths, $template, $plugins; // Common objects
  1287     global $db, $session, $paths, $template, $plugins; // Common objects
       
  1288     global $lang;
       
  1289     
  1238     $filter_links = false;
  1290     $filter_links = false;
  1239     $tplvars = $this->extract_vars($filename);
  1291     $tplvars = $this->extract_vars($filename);
  1240     if($session->sid_super) $as = htmlspecialchars(urlSeparator).'auth='.$session->sid_super;
  1292     if($session->sid_super) $as = htmlspecialchars(urlSeparator).'auth='.$session->sid_super;
  1241     else $as = '';
  1293     else $as = '';
  1242     error_reporting(E_ALL);
  1294     error_reporting(E_ALL);
  1361         else $c = $links[2][$i];
  1413         else $c = $links[2][$i];
  1362         $message = str_replace('{CONDITIONAL:'.$i.':'.$random_id.'}', $c, $message);
  1414         $message = str_replace('{CONDITIONAL:'.$i.':'.$random_id.'}', $c, $message);
  1363       }
  1415       }
  1364     }
  1416     }
  1365     
  1417     
       
  1418     preg_match_all('/\{lang:([a-z0-9]+_[a-z0-9_]+)\}/', $message, $matches);
       
  1419     foreach ( $matches[1] as $i => $string_id )
       
  1420     {
       
  1421       $string = $lang->get($string_id);
       
  1422       $string = str_replace('\\', '\\\\', $string);
       
  1423       $string = str_replace('\'', '\\\'', $string);
       
  1424       $message = str_replace_once($matches[0][$i], $string, $message);
       
  1425     }
       
  1426     
  1366     /*
  1427     /*
  1367      * HTML RENDERER
  1428      * HTML RENDERER
  1368      */
  1429      */
  1369      
  1430      
  1370     // Images
  1431     // Images
  1411     
  1472     
  1412     // External links
  1473     // External links
  1413     // $message = preg_replace('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?) ([^\]]+)\\]#', '<a href="\\1://\\2">\\3</a><br style="display: none;" />', $message);
  1474     // $message = preg_replace('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?) ([^\]]+)\\]#', '<a href="\\1://\\2">\\3</a><br style="display: none;" />', $message);
  1414     // $message = preg_replace('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?)\\]#', '<a href="\\1://\\2">\\1://\\2</a><br style="display: none;" />', $message);
  1475     // $message = preg_replace('#\[(http|ftp|irc):\/\/([a-z0-9\/:_\.\?&%\#@_\\\\-]+?)\\]#', '<a href="\\1://\\2">\\1://\\2</a><br style="display: none;" />', $message);
  1415     
  1476     
  1416     preg_match_all('/\[((https?|ftp|irc):\/\/([^@\]"\':]+)?((([a-z0-9-]+\.)*)[a-z0-9-]+)(\/[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]*(\?(([a-z0-9_-]+)(=[A-z0-9_%\|~`\!@#\$\^&\*\(\):;\.,\/-\[\]]+)?((&([a-z0-9_-]+)(=[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]+)?)*))?)?)?) ([^\]]+)\]/is', $message, $ext_link);
  1477     preg_match_all('/\[((https?|ftp|irc):\/\/([^@\s\]"\':]+)?((([a-z0-9-]+\.)*)[a-z0-9-]+)(\/[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]*(\?(([a-z0-9_-]+)(=[A-z0-9_%\|~`\!@#\$\^&\*\(\):;\.,\/-\[\]]+)?((&([a-z0-9_-]+)(=[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]+)?)*))?)?)?) ([^\]]+)\]/is', $message, $ext_link);
       
  1478     
       
  1479     // die('<pre>' . htmlspecialchars( print_r($ext_link, true) ) . '</pre>');
  1417     
  1480     
  1418     for ( $i = 0; $i < count($ext_link[0]); $i++ )
  1481     for ( $i = 0; $i < count($ext_link[0]); $i++ )
  1419     {
  1482     {
  1420       $text_parser->assign_vars(Array(  
  1483       $text_parser->assign_vars(Array(  
  1421           'HREF'  => $ext_link[1][$i],
  1484           'HREF'  => $ext_link[1][$i],
  1423           'TEXT'  => $ext_link[16][$i]
  1486           'TEXT'  => $ext_link[16][$i]
  1424         ));
  1487         ));
  1425       $message = str_replace($ext_link[0][$i], $text_parser->run(), $message);
  1488       $message = str_replace($ext_link[0][$i], $text_parser->run(), $message);
  1426     }
  1489     }
  1427     
  1490     
  1428     preg_match_all('/\[((https?|ftp|irc):\/\/([^@\]"\':]+)?((([a-z0-9-]+\.)*)[a-z0-9-]+)(\/[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]*(\?(([a-z0-9_-]+)(=[A-z0-9_%\|~`\!@#\$\^&\*\(\):;\.,\/-\[\]]+)?((&([a-z0-9_-]+)(=[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]+)?)*))?)?)?)\]/is', $message, $ext_link);
  1491     preg_match_all('/\[((https?|ftp|irc):\/\/([^@\s\]"\':]+)?((([a-z0-9-]+\.)*)[a-z0-9-]+)(\/[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]*(\?(([a-z0-9_-]+)(=[A-z0-9_%\|~`\!@#\$\^&\*\(\):;\.,\/-\[\]]+)?((&([a-z0-9_-]+)(=[A-z0-9_%\|~`!\!@#\$\^&\*\(\):;\.,\/-]+)?)*))?)?)?)\]/is', $message, $ext_link);
  1429     
  1492     
  1430     for ( $i = 0; $i < count($ext_link[0]); $i++ )
  1493     for ( $i = 0; $i < count($ext_link[0]); $i++ )
  1431     {
  1494     {
  1432       $text_parser->assign_vars(Array(  
  1495       $text_parser->assign_vars(Array(  
  1433           'HREF'  => $ext_link[1][$i],
  1496           'HREF'  => $ext_link[1][$i],
  1671     // SourceForge/W3C buttons
  1734     // SourceForge/W3C buttons
  1672     $ob = Array();
  1735     $ob = Array();
  1673     $admintitle = ( $session->user_level >= USER_LEVEL_ADMIN ) ? 'title="You may disable this button in the admin panel under General Configuration."' : '';
  1736     $admintitle = ( $session->user_level >= USER_LEVEL_ADMIN ) ? 'title="You may disable this button in the admin panel under General Configuration."' : '';
  1674     if(getConfig('sflogo_enabled')=='1')
  1737     if(getConfig('sflogo_enabled')=='1')
  1675     {
  1738     {
  1676       $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>';
  1739       $sflogo_secure = ( isset($_SERVER['HTTPS']) ) ? 'https' : 'http';
       
  1740       $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="' . $sflogo_secure . '://sflogo.sourceforge.net/sflogo.php?group_id='.getConfig('sflogo_groupid').'&amp;type='.getConfig('sflogo_type').'" /></a>';
  1677     }
  1741     }
  1678     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>';
  1742     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>';
  1679     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>';
  1743     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>';
  1680     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>';
  1744     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>';
  1681     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>';
  1745     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>';