includes/pageprocess.php
changeset 91 8079b0288e8e
parent 83 80facec76d9f
child 92 aa8ffe41d1c4
equal deleted inserted replaced
90:9d29f7e101d6 91:8079b0288e8e
   210                 <p>$message</p>";
   210                 <p>$message</p>";
   211         }
   211         }
   212         return false;
   212         return false;
   213       }
   213       }
   214     }
   214     }
   215     else if ( $this->namespace == 'User' )
   215     else if ( $this->namespace == 'User' && strpos($this->page_id, '/') === false )
   216     {
   216     {
   217       $this->_handle_userpage();
   217       $this->_handle_userpage();
   218     }
   218     }
   219     else if ( ( $this->namespace == 'Template' || $this->namespace == 'System' ) && $this->page_exists )
   219     else if ( ( $this->namespace == 'Template' || $this->namespace == 'System' ) && $this->page_exists )
   220     {
   220     {
   369   function render($incl_inner_headers = true, $_errormsg = false)
   369   function render($incl_inner_headers = true, $_errormsg = false)
   370   {
   370   {
   371     global $db, $session, $paths, $template, $plugins; // Common objects
   371     global $db, $session, $paths, $template, $plugins; // Common objects
   372     
   372     
   373     $text = $this->fetch_text();
   373     $text = $this->fetch_text();
       
   374     $text = preg_replace('/([\s]*)__NOBREADCRUMBS__([\s]*)/', '', $text);
       
   375     $text = preg_replace('/([\s]*)__NOTOC__([\s]*)/', '', $text);
   374     
   376     
   375     $redir_enabled = false;
   377     $redir_enabled = false;
   376     if ( preg_match('/^#redirect \[\[([^\]]+?)\]\]/i', $text, $match ) )
   378     if ( preg_match('/^#redirect \[\[([^\]]+?)\]\]/i', $text, $match ) )
   377     {
   379     {
   378       $redir_enabled = true;
   380       $redir_enabled = true;
   416     }
   418     }
   417     
   419     
   418     $template->tpl_strings['PAGE_NAME'] = htmlspecialchars( $this->title );
   420     $template->tpl_strings['PAGE_NAME'] = htmlspecialchars( $this->title );
   419     
   421     
   420     $this->header();
   422     $this->header();
       
   423     $this->do_breadcrumbs();
   421     
   424     
   422     if ( $_errormsg )
   425     if ( $_errormsg )
   423     {
   426     {
   424       echo $_errormsg;
   427       echo $_errormsg;
   425     }
   428     }
   629         '<' => '&lt;',
   632         '<' => '&lt;',
   630         '>' => '&gt;'
   633         '>' => '&gt;'
   631         ));
   634         ));
   632     
   635     
   633     $target_username = preg_replace('/^' . preg_quote($paths->nslist['User']) . '/', '', $target_username);
   636     $target_username = preg_replace('/^' . preg_quote($paths->nslist['User']) . '/', '', $target_username);
       
   637     $target_username = explode('/', $target_username);
       
   638     $target_username = $target_username[0];
   634     
   639     
   635     if ( ( $page_name == str_replace('_', ' ', $this->page_id) || $page_name == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->page_exists )
   640     if ( ( $page_name == str_replace('_', ' ', $this->page_id) || $page_name == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->page_exists )
   636     {
   641     {
   637       $page_name = "$target_username's user page";
   642       $page_name = "$target_username's user page";
   638     }
   643     }
  1042    
  1047    
  1043   function err_page_not_existent($userpage = false)
  1048   function err_page_not_existent($userpage = false)
  1044   {
  1049   {
  1045     global $db, $session, $paths, $template, $plugins; // Common objects
  1050     global $db, $session, $paths, $template, $plugins; // Common objects
  1046     
  1051     
       
  1052     header('HTTP/1.1 404 Not Found');
       
  1053     
  1047     $this->header();
  1054     $this->header();
  1048     header('HTTP/1.1 404 Not Found');
  1055     $this->do_breadcrumbs();
       
  1056     
  1049     if ( $userpage )
  1057     if ( $userpage )
  1050     {
  1058     {
  1051       echo '<h3>There is no page with this title yet.</h3>
  1059       echo '<h3>There is no page with this title yet.</h3>
  1052              <p>This user has not created his or her user page yet.';
  1060              <p>This user has not created his or her user page yet.';
  1053     }
  1061     }
  1075       {
  1083       {
  1076         $r = $db->fetchrow();
  1084         $r = $db->fetchrow();
  1077         echo '<p><b>This page was deleted on ' . $r['date_string'] . '.</b> The stated reason was:</p><blockquote>' . $r['edit_summary'] . '</blockquote><p>You can probably <a href="'.makeUrl($paths->page, 'do=rollback&amp;id='.$r['time_id']).'" onclick="ajaxRollback(\''.$r['time_id'].'\'); return false;">roll back</a> the deletion.</p>';
  1085         echo '<p><b>This page was deleted on ' . $r['date_string'] . '.</b> The stated reason was:</p><blockquote>' . $r['edit_summary'] . '</blockquote><p>You can probably <a href="'.makeUrl($paths->page, 'do=rollback&amp;id='.$r['time_id']).'" onclick="ajaxRollback(\''.$r['time_id'].'\'); return false;">roll back</a> the deletion.</p>';
  1078       }
  1086       }
  1079       $db->free_result();
  1087       $db->free_result();
       
  1088     }
       
  1089     if ( $session->user_level >= USER_LEVEL_ADMIN )
       
  1090     {
       
  1091       echo '<p>Additional admin options: <a href="' . makeUrl($paths->page, 'do=detag', true) . '" title="Remove any tags on this page">detag page</a></p>';
  1080     }
  1092     }
  1081     echo '<p>
  1093     echo '<p>
  1082             HTTP Error: 404 Not Found
  1094             HTTP Error: 404 Not Found
  1083           </p>';
  1095           </p>';
  1084     $this->footer();
  1096     $this->footer();
  1085   }
  1097   }
  1086   
  1098   
  1087   /**
  1099   /**
       
  1100    * Echoes out breadcrumb data, if appropriate.
       
  1101    * @access private
       
  1102    */
       
  1103   
       
  1104   function do_breadcrumbs()
       
  1105   {
       
  1106     global $db, $session, $paths, $template, $plugins; // Common objects
       
  1107     if ( strpos($this->text_cache, '__NOBREADCRUMBS__') !== false )
       
  1108       return false;
       
  1109     $breadcrumb_data = explode('/', $this->page_id);
       
  1110     if ( count($breadcrumb_data) > 1 )
       
  1111     {
       
  1112       echo '<!-- Start breadcrumbs -->
       
  1113             <div class="breadcrumbs">
       
  1114               ';
       
  1115       foreach ( $breadcrumb_data as $i => $higherpage )
       
  1116       {
       
  1117         $higherpage = $paths->nslist[$this->namespace] . sanitize_page_id(implode('/', array_slice($breadcrumb_data, 0, ($i+1))));
       
  1118         if ( ($i + 1) == count($breadcrumb_data) )
       
  1119         {
       
  1120           $title = get_page_title($higherpage, false);
       
  1121           if ( !$this->page_exists )
       
  1122           {
       
  1123             $title = explode('/', $title);
       
  1124             $title = array_reverse($title);
       
  1125             $title = $title[0];
       
  1126           }
       
  1127           echo htmlspecialchars($title);
       
  1128           break;
       
  1129         }
       
  1130         else if ( isPage($higherpage) )
       
  1131         {
       
  1132           $title = get_page_title($higherpage, false);
       
  1133           echo '<a href="' . makeUrl($higherpage, false, true) . '">' . htmlspecialchars($title) . '</a>';
       
  1134         }
       
  1135         else
       
  1136         {
       
  1137           $title = get_page_title($higherpage, false);
       
  1138           $title = explode('/', $title);
       
  1139           $title = array_reverse($title);
       
  1140           $title = $title[0];
       
  1141           echo '<a href="' . makeUrl($higherpage, false, true) . '" class="wikilink-nonexistent">' . htmlspecialchars($title) . '</a>';
       
  1142         }
       
  1143         echo ' &raquo; ';
       
  1144       }
       
  1145       echo '</div>
       
  1146             <!-- End breadcrumbs -->
       
  1147             ';
       
  1148     }
       
  1149   }
       
  1150   
       
  1151   /**
  1088    * PHP 4 constructor.
  1152    * PHP 4 constructor.
  1089    * @see PageProcessor::__construct()
  1153    * @see PageProcessor::__construct()
  1090    */
  1154    */
  1091   
  1155   
  1092   function PageProcessor( $page_id, $namespace, $revision_id = 0 )
  1156   function PageProcessor( $page_id, $namespace, $revision_id = 0 )