includes/namespaces/default.php
changeset 970 d894086f38cc
parent 963 b572ce1114f1
child 979 aafb9f6806c9
equal deleted inserted replaced
969:0506adb8eb6c 970:d894086f38cc
   140       return null;
   140       return null;
   141     }
   141     }
   142     
   142     
   143     $this->exists = false;
   143     $this->exists = false;
   144     $ns_char = substr($paths->nslist['Special'], -1);
   144     $ns_char = substr($paths->nslist['Special'], -1);
   145       
       
   146     $page_name = $this->namespace == 'Article' ? dirtify_page_id($this->page_id) : "{$this->namespace}{$ns_char}" . dirtify_page_id($this->page_id);
   145     $page_name = $this->namespace == 'Article' ? dirtify_page_id($this->page_id) : "{$this->namespace}{$ns_char}" . dirtify_page_id($this->page_id);
       
   146     $this->title = $page_name;
       
   147     
   147     $this->cdata = array(
   148     $this->cdata = array(
   148       'name' => $page_name,
   149       'name' => $page_name,
   149       'urlname' => $this->page_id,
   150       'urlname' => $this->page_id,
   150       'namespace' => $this->namespace,
   151       'namespace' => $this->namespace,
   151       'special' => 0,
   152       'special' => 0,
   733       $html .= '<div style="float: right;">';
   734       $html .= '<div style="float: right;">';
   734       $html .= '(<a href="#" onclick="ajaxCatToTag(); return false;">' . $lang->get('tags_catbox_link') . '</a>)';
   735       $html .= '(<a href="#" onclick="ajaxCatToTag(); return false;">' . $lang->get('tags_catbox_link') . '</a>)';
   735       $html .= '</div>';
   736       $html .= '</div>';
   736       $html .= '<div id="mdgCatBox">' . $lang->get('catedit_catbox_lbl_categories') . ' ';
   737       $html .= '<div id="mdgCatBox">' . $lang->get('catedit_catbox_lbl_categories') . ' ';
   737       
   738       
   738       $where = '( c.page_id=\'' . $db->escape($this->page_id) . '\' AND c.namespace=\'' . $db->escape($this->namespace) . '\' )';
   739       $q = $db->sql_query('SELECT category_id FROM ' . table_prefix . "categories WHERE page_id = '$this->page_id' AND namespace = '$this->namespace';");
   739       $prefix = table_prefix;
       
   740       $sql = <<<EOF
       
   741 SELECT c.category_id FROM {$prefix}categories AS c
       
   742   LEFT JOIN {$prefix}pages AS p
       
   743     ON ( ( p.urlname = c.page_id AND p.namespace = c.namespace ) OR ( p.urlname IS NULL AND p.namespace IS NULL ) )
       
   744   WHERE $where
       
   745   ORDER BY p.name ASC, c.page_id ASC;
       
   746 EOF;
       
   747       $q = $db->sql_query($sql);
       
   748       if ( !$q )
   740       if ( !$q )
   749         $db->_die();
   741         $db->_die();
   750       
   742       
   751       if ( $row = $db->fetchrow() )
   743       if ( $row = $db->fetchrow() )
   752       {
   744       {
   943       return $cache[$pathskey];
   935       return $cache[$pathskey];
   944     
   936     
   945     $page_id_db = $db->escape($page_id);
   937     $page_id_db = $db->escape($page_id);
   946     $namespace_db = $db->escape($namespace);
   938     $namespace_db = $db->escape($namespace);
   947     
   939     
   948     $q = $db->sql_query('SELECT * FROM ' . table_prefix . "pages WHERE urlname = '$page_id_db' AND namespace = '$namespace_db';");
   940     $q = $db->sql_query('SELECT p.*, COUNT(ca.comment_id) AS comments_approved, COUNT(cu.comment_id) AS comments_unapproved, COUNT(cs.comment_id) AS comments_spam'
       
   941                          . ' FROM ' . table_prefix . "pages AS p\n"
       
   942                       . "  LEFT JOIN " . table_prefix . "comments AS ca\n"
       
   943                       . "    ON ( (ca.approved = " . COMMENT_APPROVED . " AND ca.page_id = p.urlname ) OR ca.comment_id IS NULL)\n"
       
   944                       . "  LEFT JOIN " . table_prefix . "comments AS cu\n"
       
   945                       . "    ON ( (cu.approved = " . COMMENT_UNAPPROVED . " AND cu.page_id = p.urlname ) OR cu.comment_id IS NULL)\n"
       
   946                       . "  LEFT JOIN " . table_prefix . "comments AS cs\n"
       
   947                       . "    ON ( (cs.approved = " . COMMENT_SPAM . " AND cs.page_id = p.urlname ) OR cs.comment_id IS NULL)\n"
       
   948                       . "  WHERE p.urlname = '$page_id_db' AND p.namespace = '$namespace_db'\n"
       
   949                       . "  GROUP BY p.urlname, p.name, p.namespace, p.page_order, p.special, p.visible, p.protected, p.wiki_mode, p.comments_on, p.delvotes, p.delvote_ips, p.page_format, p.password;");
       
   950     
   949     if ( !$q )
   951     if ( !$q )
   950       $db->_die();
   952       $db->_die();
   951     
   953     
   952     if ( $db->numrows() < 1 )
   954     if ( $db->numrows() < 1 )
   953     {
   955     {