63 $data = array(); |
63 $data = array(); |
64 $q = $db->sql_query('SELECT COUNT(hit_id) AS num_hits, page_id, namespace FROM '.table_prefix.'hits GROUP BY page_id, namespace ORDER BY num_hits DESC LIMIT ' . $num . ';'); |
64 $q = $db->sql_query('SELECT COUNT(hit_id) AS num_hits, page_id, namespace FROM '.table_prefix.'hits GROUP BY page_id, namespace ORDER BY num_hits DESC LIMIT ' . $num . ';'); |
65 |
65 |
66 while ( $row = $db->fetchrow() ) |
66 while ( $row = $db->fetchrow() ) |
67 { |
67 { |
68 if ( isset($paths->pages[ $paths->nslist[ $row['namespace'] ] . $row['page_id'] ]) ) |
68 $title = get_page_title_ns($row['page_id'], $row['namespace']); |
69 { |
|
70 $page_data =& $paths->pages[ $paths->nslist[ $row['namespace'] ] . $row['page_id'] ]; |
|
71 $title = $page_data['name']; |
|
72 $page_id = $page_data['urlname']; |
|
73 } |
|
74 else if ( !isset($paths->nslist[$row['namespace']]) ) |
|
75 { |
|
76 $title = $row['namespace'] . ':' . $row['page_id']; |
|
77 $page_id = sanitize_page_id($title); |
|
78 } |
|
79 else |
|
80 { |
|
81 $title = dirtify_page_id( $paths->nslist[$row['namespace']] . $row['page_id'] ); |
|
82 $title = str_replace('_', ' ', $title); |
|
83 $page_id = sanitize_page_id($title); |
|
84 } |
|
85 $data[] = array( |
69 $data[] = array( |
86 'page_urlname' => $page_id, |
70 'page_urlname' => $paths->get_pathskey($row['page_id'], $row['namespace']), |
87 'page_title' => $title, |
71 'page_title' => $title, |
88 'num_hits' => $row['num_hits'] |
72 'num_hits' => $row['num_hits'] |
89 ); |
73 ); |
90 } |
74 } |
91 |
75 |