includes/pageprocess.php
changeset 741 a216e412c439
parent 696 bd5069e1f19a
child 793 c0724bf6039b
equal deleted inserted replaced
740:098e744df928 741:a216e412c439
   357           require_once(ENANO_ROOT.'/includes/stats.php');
   357           require_once(ENANO_ROOT.'/includes/stats.php');
   358           doStats($this->page_id, $this->namespace);
   358           doStats($this->page_id, $this->namespace);
   359         }
   359         }
   360       }
   360       }
   361     }
   361     }
   362     else // (disabled for compatibility reasons) if ( in_array($this->namespace, array('Article', 'User', 'Project', 'Help', 'File', 'Category')) && $this->page_exists )
   362     else
   363     {
   363     {
   364       // Send as regular page
   364       $this->send_from_db($strict_no_headers);
   365       if ( $this->send_headers )
   365     }
   366       {
   366   }
   367         $template->init_vars($this);
   367   
   368       }
   368   /**
   369       
   369    * Sends the page through by fetching it from the database.
   370       $text = $this->fetch_text();
   370    */
   371       
   371    
   372       if ( $text == 'err_no_text_rows' )
   372   function send_from_db($strict_no_headers = false)
   373       {
   373   {
   374         $this->err_no_rows();
   374     global $db, $session, $paths, $template, $plugins; // Common objects
   375         return false;
   375     global $lang;
   376       }
   376     
   377       else
   377     // Send as regular page
   378       {
   378     if ( $this->send_headers )
   379         $redirect = ( isset($_GET['redirect']) ) ? $_GET['redirect'] : 'YES YOU IDIOT';
   379     {
   380         if ( preg_match('/^#redirect \[\[([^\]]+)\]\]/i', $text, $match) && $redirect != 'no' )
   380       $template->init_vars($this);
       
   381     }
       
   382     
       
   383     $text = $this->fetch_text();
       
   384     
       
   385     if ( $text == 'err_no_text_rows' )
       
   386     {
       
   387       $this->err_no_rows();
       
   388       return false;
       
   389     }
       
   390     else
       
   391     {
       
   392       $redirect = ( isset($_GET['redirect']) ) ? $_GET['redirect'] : 'YES YOU IDIOT';
       
   393       if ( preg_match('/^#redirect \[\[([^\]]+)\]\]/i', $text, $match) && $redirect != 'no' )
       
   394       {
       
   395         // Redirect page!
       
   396         $page_to = sanitize_page_id($match[1]);
       
   397         $page_id_data = RenderMan::strToPageID($page_to);
       
   398         if ( count($this->redirect_stack) >= 3 )
   381         {
   399         {
   382           // Redirect page!
   400           $this->render( (!$strict_no_headers), '<div class="usermessage"><b>' . $lang->get('page_err_redirects_exceeded') . '</b></div>' );
   383           $page_to = sanitize_page_id($match[1]);
       
   384           $page_id_data = RenderMan::strToPageID($page_to);
       
   385           if ( count($this->redirect_stack) >= 3 )
       
   386           {
       
   387             $this->render( (!$strict_no_headers), '<div class="usermessage"><b>' . $lang->get('page_err_redirects_exceeded') . '</b></div>' );
       
   388           }
       
   389           else
       
   390           {
       
   391             $result = $this->_handle_redirect($page_id_data[0], $page_id_data[1]);
       
   392             if ( $result !== true )
       
   393             {
       
   394               // There was some error during the redirect process - usually an infinite redirect
       
   395               $this->render( (!$strict_no_headers), '<div class="usermessage"><b>' . $result . '</b></div>' );
       
   396             }
       
   397           }
       
   398         }
   401         }
   399         else
   402         else
   400         {
   403         {
   401           $this->render( (!$strict_no_headers) );
   404           $result = $this->_handle_redirect($page_id_data[0], $page_id_data[1]);
       
   405           if ( $result !== true )
       
   406           {
       
   407             // There was some error during the redirect process - usually an infinite redirect
       
   408             $this->render( (!$strict_no_headers), '<div class="usermessage"><b>' . $result . '</b></div>' );
       
   409           }
   402         }
   410         }
       
   411       }
       
   412       else
       
   413       {
       
   414         $this->render( (!$strict_no_headers) );
   403       }
   415       }
   404     }
   416     }
   405   }
   417   }
   406   
   418   
   407   /**
   419   /**
  1950     }
  1962     }
  1951     if ( $session->get_permissions('create_page') )
  1963     if ( $session->get_permissions('create_page') )
  1952     {
  1964     {
  1953       $standard_404 .= ' ' . $lang->get('page_msg_404_create', array(
  1965       $standard_404 .= ' ' . $lang->get('page_msg_404_create', array(
  1954           'create_flags' => 'href="'.makeUrlNS($this->namespace, $this->page_id, 'do=edit', true).'" onclick="ajaxEditor(); return false;"',
  1966           'create_flags' => 'href="'.makeUrlNS($this->namespace, $this->page_id, 'do=edit', true).'" onclick="ajaxEditor(); return false;"',
  1955           'mainpage_link' => makeUrl(getConfig('main_page'), false, true)
  1967           'mainpage_link' => makeUrl(get_main_page(), false, true)
  1956         ));
  1968         ));
  1957     }
  1969     }
  1958     else
  1970     else
  1959     {
  1971     {
  1960       $standard_404 .= ' ' . $lang->get('page_msg_404_gohome', array(
  1972       $standard_404 .= ' ' . $lang->get('page_msg_404_gohome', array(
  1961           'mainpage_link' => makeUrl(getConfig('main_page'), false, true)
  1973           'mainpage_link' => makeUrl(get_main_page(), false, true)
  1962         ));
  1974         ));
  1963     }
  1975     }
  1964     $standard_404 .= '</p>';
  1976     $standard_404 .= '</p>';
  1965     if ( $session->get_permissions('history_rollback') )
  1977     if ( $session->get_permissions('history_rollback') )
  1966     {
  1978     {
  2039               ';
  2051               ';
  2040       if ( $show_home )
  2052       if ( $show_home )
  2041       {
  2053       {
  2042         // Display the "home" link first.
  2054         // Display the "home" link first.
  2043         $pathskey = $paths->nslist[ $this->namespace ] . $this->page_id;
  2055         $pathskey = $paths->nslist[ $this->namespace ] . $this->page_id;
  2044         if ( $pathskey !== getConfig('main_page') )
  2056         if ( $pathskey !== get_main_page() )
  2045           echo '<a href="' . makeUrl(getConfig('main_page'), false, true) . '">';
  2057           echo '<a href="' . makeUrl(get_main_page(), false, true) . '">';
  2046         echo $lang->get('onpage_btn_breadcrumbs_home');
  2058         echo $lang->get('onpage_btn_breadcrumbs_home');
  2047         if ( $pathskey !== getConfig('main_page') )
  2059         if ( $pathskey !== get_main_page() )
  2048           echo '</a>';
  2060           echo '</a>';
  2049       }
  2061       }
  2050       foreach ( $breadcrumb_data as $i => $crumb )
  2062       foreach ( $breadcrumb_data as $i => $crumb )
  2051       {
  2063       {
  2052         $cumulative = implode('/', array_slice($breadcrumb_data, 0, ( $i + 1 )));
  2064         $cumulative = implode('/', array_slice($breadcrumb_data, 0, ( $i + 1 )));
  2053         if ( $show_home && $cumulative === getConfig('main_page') )
  2065         if ( $show_home && $cumulative === get_main_page() )
  2054           continue;
  2066           continue;
  2055         if ( $show_home || $i > 0 )
  2067         if ( $show_home || $i > 0 )
  2056           echo ' &raquo; ';
  2068           echo ' &raquo; ';
  2057         $title = ( isPage($cumulative) ) ? get_page_title($cumulative) : get_page_title($crumb);
  2069         $title = ( isPage($cumulative) ) ? get_page_title($cumulative) : get_page_title($crumb);
  2058         if ( $i + 1 == count($breadcrumb_data) )
  2070         if ( $i + 1 == count($breadcrumb_data) )