Index: trunk/extensions/CategoryBrowser/CategoryBrowser.php |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | /* default minimal count of DB rows to start paging */ |
42 | 42 | define( 'CB_PAGING_ROWS', 20 ); |
43 | 43 | /* minimal count of rows in image gallery (not DB rows!) pager */ |
44 | | -define( 'CB_FILES_ROWS', 3 ); |
| 44 | +define( 'CB_FILES_MAX_ROWS', 3 ); |
45 | 45 | /* maximal number of logical operations in SQL filter (condition) */ |
46 | 46 | define( 'CB_MAX_LOGICAL_OP', 5 ); |
47 | 47 | |
— | — | @@ -67,7 +67,8 @@ |
68 | 68 | // default limits of different pagers |
69 | 69 | static $categoriesLimit = CB_PAGING_ROWS; |
70 | 70 | static $pagesLimit = CB_PAGING_ROWS; |
71 | | - static $filesLimit = CB_FILES_ROWS; |
| 71 | + static $filesLimit = null; |
| 72 | + static $filesMaxRows = CB_FILES_MAX_ROWS; |
72 | 73 | |
73 | 74 | /** |
74 | 75 | * Add this extension to the mediawiki's extensions list. |
— | — | @@ -113,6 +114,14 @@ |
114 | 115 | $wgAjaxExportList[] = 'CategoryBrowser::getSubOffsetHtml'; |
115 | 116 | $wgAjaxExportList[] = 'CategoryBrowser::applyEncodedQueue'; |
116 | 117 | $wgAjaxExportList[] = 'CategoryBrowser::generateSelectedOption'; |
| 118 | + |
| 119 | + # calculate proper limit for files pager |
| 120 | + # by default, limit for ImageGallery is maxrows * perrow : |
| 121 | + self::$filesLimit = CB_Setup::$filesMaxRows * CB_Setup::$imageGalleryPerRow; |
| 122 | + if ( self::$filesLimit <= 0 ) { |
| 123 | + # ImageGallery is disabled, use pages limit instead |
| 124 | + self::$filesLimit = CB_Setup::$pagesLimit; |
| 125 | + } |
117 | 126 | } |
118 | 127 | |
119 | 128 | /* |
— | — | @@ -127,8 +136,8 @@ |
128 | 137 | self::$skin = is_object( $wgUser ) ? self::$user->getSkin() : $wgSkin; |
129 | 138 | self::$response = $wgRequest->response(); |
130 | 139 | self::$cookie_prefix = 'CategoryBrowser_' . self::$user->getId() . '_'; |
131 | | - // find out current collation of category table 'cat_title' field |
132 | | - // this is required to switch between CI and CS search |
| 140 | + # find out current collation of category table 'cat_title' field |
| 141 | + # this is required to switch between CI and CS search |
133 | 142 | $db = & wfGetDB( DB_SLAVE ); |
134 | 143 | $category_table = $db->tableName( 'category' ); |
135 | 144 | $db_result = $db->query( "SHOW FULL COLUMNS FROM ${category_table}" ); |
Index: trunk/extensions/CategoryBrowser/CategoryBrowserModel.php |
— | — | @@ -107,6 +107,7 @@ |
108 | 108 | * otherwise throws an error |
109 | 109 | * warning: will fail, when called before calling $this->getCurrentRows() ! |
110 | 110 | * warning: $this->limit is not set properly before calling $this->getCurrentRows() ! |
| 111 | + * todo: unused anymore; keep because might be useful in some cases |
111 | 112 | */ |
112 | 113 | function getListType() { |
113 | 114 | // it is not enough to check $this->entries[0], |
Index: trunk/extensions/CategoryBrowser/CategoryBrowserCtrl.php |
— | — | @@ -265,7 +265,7 @@ |
266 | 266 | 'js_nav_func' => "filesNav", |
267 | 267 | 'select_fields' => "page_title, page_namespace, page_len, page_is_redirect", |
268 | 268 | 'ns_cond' => "page_namespace = " . NS_FILE, |
269 | | - 'default_limit' => CB_Setup::$filesLimit * CB_Setup::$imageGalleryPerRow |
| 269 | + 'default_limit' => CB_Setup::$filesLimit |
270 | 270 | ) |
271 | 271 | ); |
272 | 272 | wfLoadExtensionMessages( 'CategoryBrowser' ); |
— | — | @@ -273,27 +273,28 @@ |
274 | 274 | if ( count( $args ) < 2 ) { |
275 | 275 | return 'Too few parameters in ' . __METHOD__; |
276 | 276 | } |
277 | | - if ( !isset( $pager_types[ $args[0] ] ) ) { |
278 | | - return 'Unknown pager type in ' . __METHOD__; |
| 277 | + $pager_type = $args[0]; |
| 278 | + if ( !isset( $pager_types[ $pager_type ] ) ) { |
| 279 | + return 'Unknown pager type=' . CB_Setup::specialchars( $pager_type ) . ' in ' . __METHOD__; |
279 | 280 | } |
280 | | - $pager_type = & $pager_types[ $args[0] ]; |
281 | | - $limit = ( count( $args ) > 3 ) ? abs( intval( $args[3] ) ) : $pager_type[ 'default_limit' ]; |
| 281 | + $pager_setup = & $pager_types[ $args[0] ]; |
| 282 | + $limit = ( count( $args ) > 3 ) ? abs( intval( $args[3] ) ) : $pager_setup[ 'default_limit' ]; |
282 | 283 | $offset = ( count( $args ) > 2 ) ? abs( intval( $args[2] ) ) : 0; |
283 | 284 | $parentCatId = abs( intval( $args[1] ) ); |
284 | 285 | $cb = new CategoryBrowser(); |
285 | 286 | $pager = new CB_SubPager( $parentCatId, $offset, $limit, |
286 | | - $pager_type[ 'js_nav_func' ], |
287 | | - $pager_type[ 'select_fields' ], |
288 | | - $pager_type[ 'ns_cond' ] ); |
| 287 | + $pager_setup[ 'js_nav_func' ], |
| 288 | + $pager_setup[ 'select_fields' ], |
| 289 | + $pager_setup[ 'ns_cond' ] ); |
289 | 290 | $pager->getCurrentRows(); |
290 | | - switch ( $pager->getListType() ) { |
291 | | - case 'generateCatList' : |
| 291 | + switch ( $pager_type ) { |
| 292 | + case 'subcats' : |
292 | 293 | $view = new CB_CategoriesView( $pager ); |
293 | 294 | break; |
294 | | - case 'generatePagesList' : |
| 295 | + case 'pages' : |
295 | 296 | $view = new CB_PagesView( $pager ); |
296 | 297 | break; |
297 | | - case 'generateFilesList' : |
| 298 | + case 'files' : |
298 | 299 | # respect extension & core settings |
299 | 300 | global $wgOut, $wgCategoryMagicGallery; |
300 | 301 | // unstub $wgOut, otherwise $wgOut->mNoGallery may be unavailable |