916 * Prints out the categorization box found on most regular pages. Doesn't take or return anything, but assumes that the page information is already set in $paths. |
926 * Prints out the categorization box found on most regular pages. Doesn't take or return anything, but assumes that the page information is already set in $paths. |
917 */ |
927 */ |
918 |
928 |
919 function show_category_info() |
929 function show_category_info() |
920 { |
930 { |
921 global $db, $session, $paths, $template, $plugins; // Common objects |
931 throw new Exception('show_category_info() is deprecated. Use Namespace_*::display_categories().'); |
922 global $lang; |
|
923 |
|
924 if ( $paths->namespace == 'Category' ) |
|
925 { |
|
926 // Show member pages and subcategories |
|
927 $q = $db->sql_query('SELECT p.urlname, p.namespace, p.name, p.namespace=\'Category\' AS is_category FROM '.table_prefix.'categories AS c |
|
928 LEFT JOIN '.table_prefix.'pages AS p |
|
929 ON ( p.urlname = c.page_id AND p.namespace = c.namespace ) |
|
930 WHERE c.category_id=\'' . $db->escape($paths->page_id) . '\' |
|
931 ORDER BY is_category DESC, p.name ASC;'); |
|
932 if ( !$q ) |
|
933 { |
|
934 $db->_die(); |
|
935 } |
|
936 echo '<h3>' . $lang->get('onpage_cat_heading_subcategories') . '</h3>'; |
|
937 echo '<div class="tblholder">'; |
|
938 echo '<table border="0" cellspacing="1" cellpadding="4">'; |
|
939 echo '<tr>'; |
|
940 $ticker = 0; |
|
941 $counter = 0; |
|
942 $switched = false; |
|
943 $class = 'row1'; |
|
944 while ( $row = $db->fetchrow() ) |
|
945 { |
|
946 if ( $row['is_category'] == 0 && !$switched ) |
|
947 { |
|
948 if ( $counter > 0 ) |
|
949 { |
|
950 // Fill-in |
|
951 while ( $ticker < 3 ) |
|
952 { |
|
953 $ticker++; |
|
954 echo '<td class="' . $class . '" style="width: 33.3%;"></td>'; |
|
955 } |
|
956 } |
|
957 else |
|
958 { |
|
959 echo '<td class="' . $class . '">' . $lang->get('onpage_cat_msg_no_subcategories') . '</td>'; |
|
960 } |
|
961 echo '</tr></table></div>' . "\n\n"; |
|
962 echo '<h3>' . $lang->get('onpage_cat_heading_pages') . '</h3>'; |
|
963 echo '<div class="tblholder">'; |
|
964 echo '<table border="0" cellspacing="1" cellpadding="4">'; |
|
965 echo '<tr>'; |
|
966 $counter = 0; |
|
967 $ticker = -1; |
|
968 $switched = true; |
|
969 } |
|
970 $counter++; |
|
971 $ticker++; |
|
972 if ( $ticker == 3 ) |
|
973 { |
|
974 echo '</tr><tr>'; |
|
975 $ticker = 0; |
|
976 $class = ( $class == 'row3' ) ? 'row1' : 'row3'; |
|
977 } |
|
978 echo "<td class=\"{$class}\" style=\"width: 33.3%;\">"; // " to workaround stupid jEdit bug |
|
979 |
|
980 $link = makeUrlNS($row['namespace'], sanitize_page_id($row['urlname'])); |
|
981 echo '<a href="' . $link . '"'; |
|
982 $key = $paths->nslist[$row['namespace']] . sanitize_page_id($row['urlname']); |
|
983 if ( !isPage( $key ) ) |
|
984 { |
|
985 echo ' class="wikilink-nonexistent"'; |
|
986 } |
|
987 echo '>'; |
|
988 $title = get_page_title_ns($row['urlname'], $row['namespace']); |
|
989 echo htmlspecialchars($title); |
|
990 echo '</a>'; |
|
991 |
|
992 echo "</td>"; |
|
993 } |
|
994 if ( !$switched ) |
|
995 { |
|
996 if ( $counter > 0 ) |
|
997 { |
|
998 // Fill-in |
|
999 while ( $ticker < 2 ) |
|
1000 { |
|
1001 $ticker++; |
|
1002 echo '<td class="' . $class . '" style="width: 33.3%;"></td>'; |
|
1003 } |
|
1004 } |
|
1005 else |
|
1006 { |
|
1007 echo '<td class="' . $class . '">' . $lang->get('onpage_cat_msg_no_subcategories') . '</td>'; |
|
1008 } |
|
1009 echo '</tr></table></div>' . "\n\n"; |
|
1010 echo '<h3>' . $lang->get('onpage_cat_heading_pages') . '</h3>'; |
|
1011 echo '<div class="tblholder">'; |
|
1012 echo '<table border="0" cellspacing="1" cellpadding="4">'; |
|
1013 echo '<tr>'; |
|
1014 $counter = 0; |
|
1015 $ticker = 0; |
|
1016 $switched = true; |
|
1017 } |
|
1018 if ( $counter > 0 ) |
|
1019 { |
|
1020 // Fill-in |
|
1021 while ( $ticker < 2 ) |
|
1022 { |
|
1023 $ticker++; |
|
1024 echo '<td class="' . $class . '" style="width: 33.3%;"></td>'; |
|
1025 } |
|
1026 } |
|
1027 else |
|
1028 { |
|
1029 echo '<td class="' . $class . '">' . $lang->get('onpage_cat_msg_no_pages') . '</td>'; |
|
1030 } |
|
1031 echo '</tr></table></div>' . "\n\n"; |
|
1032 } |
|
1033 |
|
1034 if ( $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
|
1035 { |
|
1036 echo '<div class="mdg-comment" style="margin: 10px 0 0 0;" id="category_box_wrapper">'; |
|
1037 echo '<div style="float: right;">'; |
|
1038 echo '(<a href="#" onclick="ajaxCatToTag(); return false;">' . $lang->get('tags_catbox_link') . '</a>)'; |
|
1039 echo '</div>'; |
|
1040 echo '<div id="mdgCatBox">' . $lang->get('catedit_catbox_lbl_categories') . ' '; |
|
1041 |
|
1042 $where = '( c.page_id=\'' . $db->escape($paths->page_id) . '\' AND c.namespace=\'' . $db->escape($paths->namespace) . '\' )'; |
|
1043 $prefix = table_prefix; |
|
1044 $sql = <<<EOF |
|
1045 SELECT c.category_id FROM {$prefix}categories AS c |
|
1046 LEFT JOIN {$prefix}pages AS p |
|
1047 ON ( ( p.urlname = c.page_id AND p.namespace = c.namespace ) OR ( p.urlname IS NULL AND p.namespace IS NULL ) ) |
|
1048 WHERE $where |
|
1049 ORDER BY p.name ASC, c.page_id ASC; |
|
1050 EOF; |
|
1051 $q = $db->sql_query($sql); |
|
1052 if ( !$q ) |
|
1053 $db->_die(); |
|
1054 |
|
1055 if ( $row = $db->fetchrow() ) |
|
1056 { |
|
1057 $list = array(); |
|
1058 do |
|
1059 { |
|
1060 $cid = sanitize_page_id($row['category_id']); |
|
1061 $title = get_page_title_ns($cid, 'Category'); |
|
1062 $link = makeUrlNS('Category', $cid); |
|
1063 $list[] = '<a href="' . $link . '">' . htmlspecialchars($title) . '</a>'; |
|
1064 } |
|
1065 while ( $row = $db->fetchrow() ); |
|
1066 echo implode(', ', $list); |
|
1067 } |
|
1068 else |
|
1069 { |
|
1070 echo $lang->get('catedit_catbox_lbl_uncategorized'); |
|
1071 } |
|
1072 |
|
1073 $can_edit = ( $session->get_permissions('edit_cat') && ( !$paths->page_protected || $session->get_permissions('even_when_protected') ) ); |
|
1074 if ( $can_edit ) |
|
1075 { |
|
1076 $edit_link = '<a href="' . makeUrl($paths->page, 'do=catedit', true) . '" onclick="ajaxCatEdit(); return false;">' . $lang->get('catedit_catbox_link_edit') . '</a>'; |
|
1077 echo ' [ ' . $edit_link . ' ]'; |
|
1078 } |
|
1079 |
|
1080 echo '</div></div>'; |
|
1081 |
|
1082 } |
|
1083 |
|
1084 } |
932 } |
1085 |
933 |
1086 /** |
934 /** |
1087 * Prints out the file information box seen on File: pages. Doesn't take or return anything, but assumes that the page information is already set in $paths, and expects $paths->namespace to be File. |
935 * Prints out the file information box seen on File: pages. Doesn't take or return anything, but assumes that the page information is already set in $paths, and expects $paths->namespace to be File. |
1088 */ |
936 */ |
1089 |
937 |
1090 function show_file_info($page = false) |
938 function show_file_info($page = false) |
1091 { |
939 { |
1092 global $db, $session, $paths, $template, $plugins; // Common objects |
940 throw new Exception('show_file_info() is deprecated. Use Namespace_File::show_info().'); |
1093 global $lang; |
|
1094 |
|
1095 $local_page_id = $paths->page_id; |
|
1096 $local_namespace = $paths->namespace; |
|
1097 |
|
1098 if ( is_object($page) ) |
|
1099 { |
|
1100 $local_page = $page->page_id; |
|
1101 $local_namespace = $page->namespace; |
|
1102 } |
|
1103 |
|
1104 // Prevent unnecessary work |
|
1105 if ( $local_namespace != 'File' ) |
|
1106 return null; |
|
1107 |
|
1108 $selfn = $local_page_id; |
|
1109 if ( substr($paths->cpage['name'], 0, strlen($paths->nslist['File'])) == $paths->nslist['File']) |
|
1110 { |
|
1111 $selfn = substr($local_page_id, strlen($paths->nslist['File']), strlen($local_page_id)); |
|
1112 } |
|
1113 $selfn = $db->escape($selfn); |
|
1114 $q = $db->sql_query('SELECT f.mimetype,f.time_id,f.size,l.log_id FROM ' . table_prefix . "files AS f\n" |
|
1115 . " LEFT JOIN " . table_prefix . "logs AS l\n" |
|
1116 . " ON ( l.time_id = f.time_id AND ( l.action = 'reupload' OR l.action IS NULL ) )\n" |
|
1117 . " WHERE f.page_id = '$selfn'\n" |
|
1118 . " ORDER BY f.time_id DESC;"); |
|
1119 if ( !$q ) |
|
1120 { |
|
1121 $db->_die('The file type could not be fetched.'); |
|
1122 } |
|
1123 |
|
1124 if ( $db->numrows() < 1 ) |
|
1125 { |
|
1126 echo '<div class="mdg-comment" style="margin-left: 0;"> |
|
1127 <h3>' . $lang->get('onpage_filebox_heading') . '</h3> |
|
1128 <p>' . $lang->get('onpage_filebox_msg_not_found', array('upload_link' => makeUrlNS('Special', 'UploadFile/'.$local_page_id))) . '</p> |
|
1129 </div> |
|
1130 <br />'; |
|
1131 return; |
|
1132 } |
|
1133 $r = $db->fetchrow(); |
|
1134 $mimetype = $r['mimetype']; |
|
1135 $datestring = enano_date('F d, Y h:i a', (int)$r['time_id']); |
|
1136 echo '<div class="mdg-comment" style="margin-left: 0;"> |
|
1137 <h3>' . $lang->get('onpage_filebox_heading') . '</h3> |
|
1138 <p>' . $lang->get('onpage_filebox_lbl_type') . ' '.$r['mimetype'].'<br />'; |
|
1139 |
|
1140 $size = $r['size'] . ' ' . $lang->get('etc_unit_bytes'); |
|
1141 if ( $r['size'] >= 1048576 ) |
|
1142 { |
|
1143 $size .= ' (' . ( round($r['size'] / 1048576, 1) ) . ' ' . $lang->get('etc_unit_megabytes_short') . ')'; |
|
1144 } |
|
1145 else if ( $r['size'] >= 1024 ) |
|
1146 { |
|
1147 $size .= ' (' . ( round($r['size'] / 1024, 1) ) . ' ' . $lang->get('etc_unit_kilobytes_short') . ')'; |
|
1148 } |
|
1149 |
|
1150 echo $lang->get('onpage_filebox_lbl_size', array('size' => $size)); |
|
1151 |
|
1152 echo '<br />' . $lang->get('onpage_filebox_lbl_uploaded') . ' ' . $datestring . '</p>'; |
|
1153 if ( substr($mimetype, 0, 6) != 'image/' && ( substr($mimetype, 0, 5) != 'text/' || $mimetype == 'text/html' || $mimetype == 'text/javascript' ) ) |
|
1154 { |
|
1155 echo '<div class="warning-box"> |
|
1156 ' . $lang->get('onpage_filebox_msg_virus_warning') . ' |
|
1157 </div>'; |
|
1158 } |
|
1159 if ( substr($mimetype, 0, 6) == 'image/' ) |
|
1160 { |
|
1161 echo '<p> |
|
1162 <a href="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn).'"> |
|
1163 <img style="border: 0;" alt="'.$paths->page.'" src="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn.htmlspecialchars(urlSeparator).'preview').'" /> |
|
1164 </a> |
|
1165 </p>'; |
|
1166 } |
|
1167 echo '<p> |
|
1168 <a href="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn.'/'.$r['time_id'].htmlspecialchars(urlSeparator).'download').'"> |
|
1169 ' . $lang->get('onpage_filebox_btn_download') . ' |
|
1170 </a>'; |
|
1171 if(!$paths->page_protected && ( $paths->wiki_mode || $session->get_permissions('upload_new_version') )) |
|
1172 { |
|
1173 echo ' | <a href="'.makeUrlNS('Special', 'UploadFile'.'/'.$selfn).'"> |
|
1174 ' . $lang->get('onpage_filebox_btn_upload_new') . ' |
|
1175 </a>'; |
|
1176 } |
|
1177 echo '</p>'; |
|
1178 if ( $db->numrows() > 1 ) |
|
1179 { |
|
1180 // requery, sql_result_seek() doesn't work on postgres |
|
1181 $db->free_result(); |
|
1182 $q = $db->sql_query('SELECT f.mimetype,f.time_id,f.size,l.log_id FROM ' . table_prefix . "files AS f\n" |
|
1183 . " LEFT JOIN " . table_prefix . "logs AS l\n" |
|
1184 . " ON ( l.time_id = f.time_id AND ( l.action = 'reupload' OR l.action IS NULL ) )\n" |
|
1185 . " WHERE f.page_id = '$selfn'\n" |
|
1186 . " ORDER BY f.time_id DESC;"); |
|
1187 if ( !$q ) |
|
1188 $db->_die(); |
|
1189 |
|
1190 echo '<h3>' . $lang->get('onpage_filebox_heading_history') . '</h3><p>'; |
|
1191 $last_rollback_id = false; |
|
1192 while ( $r = $db->fetchrow() ) |
|
1193 { |
|
1194 echo '(<a href="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn.'/'.$r['time_id'].htmlspecialchars(urlSeparator).'download').'">' . $lang->get('onpage_filebox_btn_this_version') . '</a>) '; |
|
1195 if ( $session->get_permissions('history_rollback') && $last_rollback_id ) |
|
1196 echo ' (<a href="#rollback:' . $last_rollback_id . '" onclick="ajaxRollback(\''.$last_rollback_id.'\'); return false;">' . $lang->get('onpage_filebox_btn_revert') . '</a>) '; |
|
1197 else if ( $session->get_permissions('history_rollback') && !$last_rollback_id ) |
|
1198 echo ' (' . $lang->get('onpage_filebox_btn_current') . ') '; |
|
1199 $last_rollback_id = $r['log_id']; |
|
1200 $mimetype = $r['mimetype']; |
|
1201 $datestring = enano_date('F d, Y h:i a', (int)$r['time_id']); |
|
1202 |
|
1203 echo $datestring.': '.$r['mimetype'].', '; |
|
1204 |
|
1205 $fs = $r['size']; |
|
1206 $fs = (int)$fs; |
|
1207 |
|
1208 if($fs >= 1048576) |
|
1209 { |
|
1210 $fs = round($fs / 1048576, 1); |
|
1211 $size = $fs . ' ' . $lang->get('etc_unit_megabytes_short'); |
|
1212 } |
|
1213 else |
|
1214 if ( $fs >= 1024 ) |
|
1215 { |
|
1216 $fs = round($fs / 1024, 1); |
|
1217 $size = $fs . ' ' . $lang->get('etc_unit_kilobytes_short'); |
|
1218 } |
|
1219 else |
|
1220 { |
|
1221 $size = $fs . ' ' . $lang->get('etc_unit_bytes'); |
|
1222 } |
|
1223 |
|
1224 echo $size; |
|
1225 |
|
1226 echo '<br />'; |
|
1227 } |
|
1228 echo '</p>'; |
|
1229 } |
|
1230 $db->free_result(); |
|
1231 echo '</div><br />'; |
|
1232 } |
941 } |
1233 |
942 |
1234 /** |
943 /** |
1235 * Shows header information on the current page. Currently this is only the delete-vote feature. Doesn't take or return anything, but assumes that the page information is already set in $paths. |
944 * Shows header information on the current page. Currently this is only the delete-vote feature. Doesn't take or return anything, but assumes that the page information is already set in $paths. |
1236 */ |
945 */ |