12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
13 */ |
13 */ |
14 |
14 |
15 class Namespace_User extends Namespace_Default |
15 class Namespace_User extends Namespace_Default |
16 { |
16 { |
|
17 public function __construct($page_id, $namespace, $revision_id = 0) |
|
18 { |
|
19 global $db, $session, $paths, $template, $plugins; // Common objects |
|
20 global $lang; |
|
21 |
|
22 parent::__construct($page_id, $namespace, $revision_id); |
|
23 |
|
24 if ( ( $this->title == str_replace('_', ' ', $this->page_id) || $this->title == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->exists ) |
|
25 { |
|
26 $this->title = $lang->get('userpage_page_title', array('username' => $this->page_id)); |
|
27 $this->cdata['name'] = $this->title; |
|
28 } |
|
29 |
|
30 } |
|
31 |
17 public function send() |
32 public function send() |
18 { |
33 { |
19 global $db, $session, $paths, $template, $plugins; // Common objects |
34 global $db, $session, $paths, $template, $plugins; // Common objects |
20 global $email; |
35 global $email; |
21 global $lang, $output; |
36 global $lang, $output; |
53 * echo out table cells as normal. The table on the left (the wide one) has |
68 * echo out table cells as normal. The table on the left (the wide one) has |
54 * four columns, and the one on the right has one column. |
69 * four columns, and the one on the right has one column. |
55 * |
70 * |
56 * See plugins.php for a guide on creating and attaching to hooks. |
71 * See plugins.php for a guide on creating and attaching to hooks. |
57 */ |
72 */ |
58 |
73 |
59 $page_urlname = dirtify_page_id($this->page_id); |
74 $page_urlname = dirtify_page_id($this->page_id); |
60 if ( $this->page_id == $paths->page_id && $this->namespace == $paths->namespace ) |
|
61 $page_name = $this->cdata['name']; |
|
62 |
75 |
63 $target_username = strtr($page_urlname, |
76 $target_username = strtr($page_urlname, |
64 Array( |
77 Array( |
65 '_' => ' ', |
78 '_' => ' ', |
66 '<' => '<', |
79 '<' => '<', |
68 )); |
81 )); |
69 |
82 |
70 $target_username = preg_replace('/^' . str_replace('/', '\\/', preg_quote($paths->nslist['User'])) . '/', '', $target_username); |
83 $target_username = preg_replace('/^' . str_replace('/', '\\/', preg_quote($paths->nslist['User'])) . '/', '', $target_username); |
71 list($target_username) = explode('/', $target_username); |
84 list($target_username) = explode('/', $target_username); |
72 |
85 |
73 if ( ( $page_name == str_replace('_', ' ', $this->page_id) || $page_name == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->exists ) |
86 $output->set_title($this->title); |
74 { |
|
75 $page_name = $lang->get('userpage_page_title', array('username' => $target_username)); |
|
76 } |
|
77 |
|
78 $output->set_title($page_name); |
|
79 |
|
80 $q = $db->sql_query('SELECT u.username, u.user_id AS authoritative_uid, u.real_name, u.email, u.reg_time, u.user_has_avatar, u.avatar_type, x.*, COUNT(c.comment_id) AS n_comments |
87 $q = $db->sql_query('SELECT u.username, u.user_id AS authoritative_uid, u.real_name, u.email, u.reg_time, u.user_has_avatar, u.avatar_type, x.*, COUNT(c.comment_id) AS n_comments |
81 FROM '.table_prefix.'users u |
88 FROM '.table_prefix.'users u |
82 LEFT JOIN '.table_prefix.'users_extra AS x |
89 LEFT JOIN '.table_prefix.'users_extra AS x |
83 ON ( u.user_id = x.user_id OR x.user_id IS NULL ) |
90 ON ( u.user_id = x.user_id OR x.user_id IS NULL ) |
84 LEFT JOIN '.table_prefix.'comments AS c |
91 LEFT JOIN '.table_prefix.'comments AS c |