includes/namespaces/special.php
changeset 1227 bdac73ed481e
parent 1209 944d2fe1fb1e
child 1278 9a4b0c3056ac
equal deleted inserted replaced
1226:de56132c008d 1227:bdac73ed481e
    11  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    11  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
    12  */
    12  */
    13 
    13 
    14 class Namespace_Special extends Namespace_Default
    14 class Namespace_Special extends Namespace_Default
    15 {
    15 {
    16   public function __construct($page_id, $namespace, $revision_id = 0)
    16 	public function __construct($page_id, $namespace, $revision_id = 0)
    17   {
    17 	{
    18     global $db, $session, $paths, $template, $plugins; // Common objects
    18 		global $db, $session, $paths, $template, $plugins; // Common objects
    19     
    19 		
    20     $this->page_id = sanitize_page_id($page_id);
    20 		$this->page_id = sanitize_page_id($page_id);
    21     $this->namespace = $namespace;
    21 		$this->namespace = $namespace;
    22     $this->build_cdata();
    22 		$this->build_cdata();
    23     $this->revision_id = intval($revision_id);
    23 		$this->revision_id = intval($revision_id);
    24     
    24 		
    25     $this->page_protected = true;
    25 		$this->page_protected = true;
    26     $this->wiki_mode = 0;
    26 		$this->wiki_mode = 0;
    27   }
    27 	}
    28   
    28 	
    29   public function build_cdata()
    29 	public function build_cdata()
    30   {
    30 	{
    31     global $db, $session, $paths, $template, $plugins; // Common objects
    31 		global $db, $session, $paths, $template, $plugins; // Common objects
    32     global $lang;
    32 		global $lang;
    33     
    33 		
    34     $this->exists = function_exists("page_{$this->namespace}_{$this->page_id}");
    34 		$this->exists = function_exists("page_{$this->namespace}_{$this->page_id}");
    35     
    35 		
    36     if ( isset($paths->pages[ $paths->get_pathskey($this->page_id, $this->namespace) ]) )
    36 		if ( isset($paths->pages[ $paths->get_pathskey($this->page_id, $this->namespace) ]) )
    37     {
    37 		{
    38       $page_name = $paths->pages[ $paths->get_pathskey($this->page_id, $this->namespace) ]['name'];
    38 			$page_name = $paths->pages[ $paths->get_pathskey($this->page_id, $this->namespace) ]['name'];
    39     }
    39 		}
    40     else
    40 		else
    41     {
    41 		{
    42       $page_name = "{$paths->nslist[ $this->namespace ]}{$this->page_id}";
    42 			$page_name = "{$paths->nslist[ $this->namespace ]}{$this->page_id}";
    43       if ( ($_ = $lang->get('specialpage_' . strtolower($this->page_id))) !== 'specialpage_' . strtolower($this->page_id) )
    43 			if ( ($_ = $lang->get('specialpage_' . strtolower($this->page_id))) !== 'specialpage_' . strtolower($this->page_id) )
    44       {
    44 			{
    45         $page_name = $_;
    45 				$page_name = $_;
    46       }
    46 			}
    47     }
    47 		}
    48     
    48 		
    49     $this->cdata = array(
    49 		$this->cdata = array(
    50         'name' => $lang->get($page_name),
    50 				'name' => $lang->get($page_name),
    51         'urlname' => $this->page_id,
    51 				'urlname' => $this->page_id,
    52         'namespace' => $this->namespace,
    52 				'namespace' => $this->namespace,
    53         'special' => 0,
    53 				'special' => 0,
    54         'visible' => 0,
    54 				'visible' => 0,
    55         'comments_on' => 0,
    55 				'comments_on' => 0,
    56         'protected' => 0,
    56 				'protected' => 0,
    57         'delvotes' => 0,
    57 				'delvotes' => 0,
    58         'delvote_ips' => '',
    58 				'delvote_ips' => '',
    59         'wiki_mode' => 2,
    59 				'wiki_mode' => 2,
    60         'page_exists' => false,
    60 				'page_exists' => false,
    61         'page_format' => getConfig('default_page_format', 'wikitext')
    61 				'page_format' => getConfig('default_page_format', 'wikitext')
    62       );
    62 			);
    63     $this->cdata = Namespace_Default::bake_cdata($this->cdata);
    63 		$this->cdata = Namespace_Default::bake_cdata($this->cdata);
    64     
    64 		
    65     $this->title =& $this->cdata['name'];
    65 		$this->title =& $this->cdata['name'];
    66   }
    66 	}
    67   
    67 	
    68   function send()
    68 	function send()
    69   {
    69 	{
    70     global $output;
    70 		global $output;
    71     
    71 		
    72     if ( $this->exists )
    72 		if ( $this->exists )
    73     {
    73 		{
    74       call_user_func("page_{$this->namespace}_{$this->page_id}");
    74 			call_user_func("page_{$this->namespace}_{$this->page_id}");
    75     }
    75 		}
    76     else
    76 		else
    77     {
    77 		{
    78       $output->header();
    78 			$output->header();
    79       $this->error_404();
    79 			$this->error_404();
    80       $output->footer();
    80 			$output->footer();
    81     }
    81 		}
    82   }
    82 	}
    83   
    83 	
    84   // We add the unused variable $userpage here to silence "declaration should be compatible" errors
    84 	// We add the unused variable $userpage here to silence "declaration should be compatible" errors
    85   function error_404()
    85 	function error_404()
    86   {
    86 	{
    87     global $lang, $output;
    87 		global $lang, $output;
    88     $func_name = "page_{$this->namespace}_{$this->page_id}";
    88 		$func_name = "page_{$this->namespace}_{$this->page_id}";
    89     
    89 		
    90     if ( $this->namespace == 'Admin' )
    90 		if ( $this->namespace == 'Admin' )
    91       die_semicritical($lang->get('page_msg_admin_404_title'), $lang->get('page_msg_admin_404_body', array('func_name' => $func_name)), true);
    91 			die_semicritical($lang->get('page_msg_admin_404_title'), $lang->get('page_msg_admin_404_body', array('func_name' => $func_name)), true);
    92     
    92 		
    93     $title = $lang->get('page_err_custompage_function_missing_title');
    93 		$title = $lang->get('page_err_custompage_function_missing_title');
    94     $message = $lang->get('page_err_custompage_function_missing_body', array( 'function_name' => $func_name ));
    94 		$message = $lang->get('page_err_custompage_function_missing_body', array( 'function_name' => $func_name ));
    95     
    95 		
    96     $output->set_title($title);
    96 		$output->set_title($title);
    97     $output->header();
    97 		$output->header();
    98     echo "<p>$message</p>";
    98 		echo "<p>$message</p>";
    99     $output->footer();
    99 		$output->footer();
   100   }
   100 	}
   101   
   101 	
   102   function set_conds()
   102 	function set_conds()
   103   {
   103 	{
   104     parent::set_conds();
   104 		parent::set_conds();
   105     
   105 		
   106     $this->conds['printable'] = false;
   106 		$this->conds['printable'] = false;
   107     $this->conds['adminpage'] = false;
   107 		$this->conds['adminpage'] = false;
   108   }
   108 	}
   109 }
   109 }