Index: trunk/extensions/DynamicPageList/DynamicPageList2.i18n.php |
— | — | @@ -65,77 +65,77 @@ |
66 | 66 | * $1: wrong parameter given by user |
67 | 67 | * $3: list of possible titles of namespaces (except pseudo-namespaces: Media, Special) |
68 | 68 | */ |
69 | | - 'dpl2_log_' . self::FATAL_WRONGNS => "Error: Wrong '$0' parameter: '$1'! Help: <code>$0= <i>empty string</i> (Main)$3</code>.", |
| 69 | + 'dpl2_log_' . self::FATAL_WRONGNS => "ERROR: Wrong '$0' parameter: '$1'! Help: <code>$0= <i>empty string</i> (Main)$3</code>.", |
70 | 70 | /** |
71 | 71 | * $0: 'linksto' (left as $0 just in case the parameter is renamed in the future) |
72 | 72 | * $1: wrong parameter given by user |
73 | 73 | */ |
74 | | - 'dpl2_log_' . self::FATAL_WRONGLINKSTO => "Error: Wrong '$0' parameter: '$1'! Help: <code>$0= <i>full pagename</i></code>.", |
| 74 | + 'dpl2_log_' . self::FATAL_WRONGLINKSTO => "ERROR: Wrong '$0' parameter: '$1'! Help: <code>$0= <i>full pagename</i></code>.", |
75 | 75 | /** |
76 | 76 | * $0: max number of categories that can be included |
77 | 77 | */ |
78 | | - 'dpl2_log_' . self::FATAL_TOOMANYCATS => 'Error: Too many categories! Maximum: $0. Help: increase <code>ExtDynamicPageList2::$maxCategoryCount</code> to specify more categories or set <code>ExtDynamicPageList2::$allowUnlimitedCategories=true</code> for no limitation. (Set the variable in <code>LocalSettings.php</code>, after including <code>DynamicPageList2.php</code>.)', |
| 78 | + 'dpl2_log_' . self::FATAL_TOOMANYCATS => 'ERROR: Too many categories! Maximum: $0. Help: increase <code>ExtDynamicPageList2::$maxCategoryCount</code> to specify more categories or set <code>ExtDynamicPageList2::$allowUnlimitedCategories=true</code> for no limitation. (Set the variable in <code>LocalSettings.php</code>, after including <code>DynamicPageList2.php</code>.)', |
79 | 79 | /** |
80 | 80 | * $0: min number of categories that have to be included |
81 | 81 | */ |
82 | | - 'dpl2_log_' . self::FATAL_TOOFEWCATS => 'Error: Too few categories! Minimum: $0. Help: decrease <code>ExtDynamicPageList2::$minCategoryCount</code> to specify fewer categories. (Set the variable preferably in <code>LocalSettings.php</code>, after including <code>DynamicPageList2.php</code>.)', |
83 | | - 'dpl2_log_' . self::FATAL_NOSELECTION => "Error: No selection criteria found! You must use at least one of the following parameters: category, namespace, titlematch, linksto, uses, createdby, modifiedby, lastmodifiedby or their 'not' variants", |
84 | | - 'dpl2_log_' . self::FATAL_CATDATEBUTNOINCLUDEDCATS => "Error: You need to include at least one category if you want to use 'addfirstcategorydate=true' or 'ordermethod=categoryadd'!", |
85 | | - 'dpl2_log_' . self::FATAL_CATDATEBUTMORETHAN1CAT => "Error: If you include more than one category, you cannot use 'addfirstcategorydate=true' or 'ordermethod=categoryadd'!", |
86 | | - 'dpl2_log_' . self::FATAL_MORETHAN1TYPEOFDATE => 'Error: You cannot add more than one type of date at a time!', |
| 82 | + 'dpl2_log_' . self::FATAL_TOOFEWCATS => 'ERROR: Too few categories! Minimum: $0. Help: decrease <code>ExtDynamicPageList2::$minCategoryCount</code> to specify fewer categories. (Set the variable preferably in <code>LocalSettings.php</code>, after including <code>DynamicPageList2.php</code>.)', |
| 83 | + 'dpl2_log_' . self::FATAL_NOSELECTION => "ERROR: No selection criteria found! You must use at least one of the following parameters: category, namespace, titlematch, linksto, uses, createdby, modifiedby, lastmodifiedby or their 'not' variants", |
| 84 | + 'dpl2_log_' . self::FATAL_CATDATEBUTNOINCLUDEDCATS => "ERROR: You need to include at least one category if you want to use 'addfirstcategorydate=true' or 'ordermethod=categoryadd'!", |
| 85 | + 'dpl2_log_' . self::FATAL_CATDATEBUTMORETHAN1CAT => "ERROR: If you include more than one category, you cannot use 'addfirstcategorydate=true' or 'ordermethod=categoryadd'!", |
| 86 | + 'dpl2_log_' . self::FATAL_MORETHAN1TYPEOFDATE => 'ERROR: You cannot add more than one type of date at a time!', |
87 | 87 | /** |
88 | 88 | * $0: param=val that is possible only with $1 as last 'ordermethod' parameter |
89 | 89 | * $1: last 'ordermethod' parameter required for $0 |
90 | 90 | */ |
91 | | - 'dpl2_log_' . self::FATAL_WRONGORDERMETHOD => "Error: You can use '$0' with 'ordermethod=[...,]$1' only!", |
| 91 | + 'dpl2_log_' . self::FATAL_WRONGORDERMETHOD => "ERROR: You can use '$0' with 'ordermethod=[...,]$1' only!", |
92 | 92 | /** |
93 | 93 | * $0: the number of arguments in includepage |
94 | 94 | */ |
95 | | - 'dpl2_log_' . self::FATAL_DOMINANTSECTIONRANGE => "Error: the index for the dominant section must be between 1 and the number of arguments of includepage ($0 in this case)", |
| 95 | + 'dpl2_log_' . self::FATAL_DOMINANTSECTIONRANGE => "ERROR: the index for the dominant section must be between 1 and the number of arguments of includepage ($0 in this case)", |
96 | 96 | /** |
97 | 97 | * $0: prefix_dpl_clview where 'prefix' is the prefix of your mediawiki table names |
98 | 98 | * $1: SQL query to create the prefix_dpl_clview on your mediawiki DB |
99 | 99 | */ |
100 | | - 'dpl2_log_' . self::FATAL_NOCLVIEW => "Error: Cannot perform logical operations on the Uncategorized pages (e.g. with the 'category' parameter) because the $0 view does not exist on the database! Help: have the DB admin execute this query: <code>$1</code>.", |
101 | | - 'dpl2_log_' . self::FATAL_OPENREFERENCES => 'Error: specifying "openreferences" is incompatible with some other option you specified. See the manual for details.', |
| 100 | + 'dpl2_log_' . self::FATAL_NOCLVIEW => "ERROR: Cannot perform logical operations on the Uncategorized pages (e.g. with the 'category' parameter) because the $0 view does not exist on the database! Help: have the DB admin execute this query: <code>$1</code>.", |
| 101 | + 'dpl2_log_' . self::FATAL_OPENREFERENCES => 'ERROR: specifying "openreferences" is incompatible with some other option you specified. See the manual for details.', |
102 | 102 | |
103 | 103 | // WARN |
104 | 104 | /** |
105 | 105 | * $0: unknown parameter given by user |
106 | 106 | * $1: list of DPL2 available parameters separated by ', ' |
107 | 107 | */ |
108 | | - 'dpl2_log_' . self::WARN_UNKNOWNPARAM => "Warning: Unknown parameter '$0' is ignored. Help: available parameters: <code>$1</code>.", |
| 108 | + 'dpl2_log_' . self::WARN_UNKNOWNPARAM => "WARNING: Unknown parameter '$0' is ignored. Help: available parameters: <code>$1</code>.", |
109 | 109 | /** |
110 | 110 | * $3: list of valid param values separated by ' | ' |
111 | 111 | */ |
112 | | - 'dpl2_log_' . self::WARN_WRONGPARAM => "Warning: Wrong '$0' parameter: '$1'! Using default: '$2'. Help: <code>$0= $3</code>.", |
| 112 | + 'dpl2_log_' . self::WARN_WRONGPARAM => "WARNING: Wrong '$0' parameter: '$1'! Using default: '$2'. Help: <code>$0= $3</code>.", |
113 | 113 | /** |
114 | 114 | * $0: param name |
115 | 115 | * $1: wrong param value given by user |
116 | 116 | * $2: default param value used instead by program |
117 | 117 | */ |
118 | | - 'dpl2_log_' . self::WARN_WRONGPARAM_INT => "Warning: Wrong '$0' parameter: '$1'! Using default: '$2' (no limit). Help: <code>$0= <i>empty string</i> (no limit) | n</code>, with <code>n</code> a positive integer.", |
119 | | - 'dpl2_log_' . self::WARN_NORESULTS => 'Warning: No results!', |
120 | | - 'dpl2_log_' . self::WARN_CATOUTPUTBUTWRONGPARAMS => "Warning: Add* parameters ('adduser', 'addeditdate', etc.)' and 'includepage' have no effect with 'mode=category'. Only the page namespace/title can be viewed in this mode.", |
| 118 | + 'dpl2_log_' . self::WARN_WRONGPARAM_INT => "WARNING: Wrong '$0' parameter: '$1'! Using default: '$2' (no limit). Help: <code>$0= <i>empty string</i> (no limit) | n</code>, with <code>n</code> a positive integer.", |
| 119 | + 'dpl2_log_' . self::WARN_NORESULTS => 'WARNING: No results!', |
| 120 | + 'dpl2_log_' . self::WARN_CATOUTPUTBUTWRONGPARAMS => "WARNING: Add* parameters ('adduser', 'addeditdate', etc.)' and 'includepage' have no effect with 'mode=category'. Only the page namespace/title can be viewed in this mode.", |
121 | 121 | /** |
122 | 122 | * $0: 'headingmode' value given by user |
123 | 123 | * $1: value used instead by program (which means no heading) |
124 | 124 | */ |
125 | | - 'dpl2_log_' . self::WARN_HEADINGBUTSIMPLEORDERMETHOD => "Warning: 'headingmode=$0' has no effect with 'ordermethod' on a single component. Using: '$1'. Help: you can use not-$1 'headingmode' values with 'ordermethod' on multiple components. The first component is used for headings. E.g. 'ordermethod=category,<i>comp</i>' (<i>comp</i> is another component) for category headings.", |
| 125 | + 'dpl2_log_' . self::WARN_HEADINGBUTSIMPLEORDERMETHOD => "WARNING: 'headingmode=$0' has no effect with 'ordermethod' on a single component. Using: '$1'. Help: you can use not-$1 'headingmode' values with 'ordermethod' on multiple components. The first component is used for headings. E.g. 'ordermethod=category,<i>comp</i>' (<i>comp</i> is another component) for category headings.", |
126 | 126 | /** |
127 | 127 | * $0: 'log' value |
128 | 128 | */ |
129 | | - 'dpl2_log_' . self::WARN_DEBUGPARAMNOTFIRST => "Warning: 'debug=$0' is not in first position in the DPL element. The new debug settings are not applied before all previous parameters have been parsed and checked.", |
| 129 | + 'dpl2_log_' . self::WARN_DEBUGPARAMNOTFIRST => "WARNING: 'debug=$0' is not in first position in the DPL element. The new debug settings are not applied before all previous parameters have been parsed and checked.", |
130 | 130 | /** |
131 | 131 | * $0: title of page that creates an infinite transclusion loop |
132 | 132 | */ |
133 | | - 'dpl2_log_' . self::WARN_TRANSCLUSIONLOOP => "Warning: An infinite transclusion loop is created by page '$0'.", |
| 133 | + 'dpl2_log_' . self::WARN_TRANSCLUSIONLOOP => "WARNING: An infinite transclusion loop is created by page '$0'.", |
134 | 134 | |
135 | 135 | // DEBUG |
136 | 136 | /** |
137 | 137 | * $0: SQL query executed to generate the dynamic page list |
138 | 138 | */ |
139 | | - 'dpl2_log_' . self::DEBUG_QUERY => 'Query: <code>$0</code>', |
| 139 | + 'dpl2_log_' . self::DEBUG_QUERY => 'QUERY: <code>$0</code>', |
140 | 140 | |
141 | 141 | /* |
142 | 142 | Output formatting |
— | — | @@ -233,7 +233,7 @@ |
234 | 234 | /** |
235 | 235 | * $1: number of articles |
236 | 236 | */ |
237 | | - 'dpl2_articlecount' => '{{PLURAL:$1|???? $1 ????|???? ?? ???}} ??? ????? ??.' |
| 237 | + 'dpl2_articlecount' => '{{plural:$1|???? $1 ????|???? ?? ???}} ??? ????? ??.' |
238 | 238 | ); |
239 | 239 | self::$messages['it'] = array( |
240 | 240 | /* |
Index: trunk/extensions/DynamicPageList/DynamicPageList2.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | * Note: DynamicPageList2 is based on DynamicPageList. |
11 | 11 | * |
12 | 12 | * Usage: |
13 | | - * require_once("extensions/DynamicPageList2.php"); in LocalSettings.php |
| 13 | + * require_once("extensions/DynamicPageList/DynamicPageList2.php"); in LocalSettings.php |
14 | 14 | * |
15 | 15 | * @package MediaWiki |
16 | 16 | * @subpackage Extensions |
— | — | @@ -259,6 +259,20 @@ |
260 | 260 | * @version 1.6.9 |
261 | 261 | * added check against non-includable namespaces |
262 | 262 | * added includetrim' command |
| 263 | + * @version 1.7.0 |
| 264 | + * bug fix at articlecategory (underscore) |
| 265 | + * bug fix in installation checking (#2128) |
| 266 | + * new command 'imageused' |
| 267 | + * @version 1.7.1 |
| 268 | + * allow % within included template parameters |
| 269 | + * @version 1.7.2 |
| 270 | + * experimental sorting of result tables (tablesortcol) |
| 271 | + * @version 1.7.3 |
| 272 | + * %SECTION% can now be used within multiseseparators |
| 273 | + * preliminary patch for MW 1.12 (recursive template expansion) |
| 274 | + * @version 1.7.4 |
| 275 | + * new command: imagecontainer |
| 276 | + * @version 1.7.5 |
263 | 277 | |
264 | 278 | * ! when making changes here you must update the VERSION constant at the beginning of class ExtSynamicPageList2 ! |
265 | 279 | */ |
— | — | @@ -298,7 +312,7 @@ |
299 | 313 | |
300 | 314 | class ExtDynamicPageList2 |
301 | 315 | { |
302 | | - const VERSION = '1.6.9'; // current version |
| 316 | + const VERSION = '1.7.4'; // current version |
303 | 317 | |
304 | 318 | /** |
305 | 319 | * Extension options |
— | — | @@ -518,6 +532,16 @@ |
519 | 533 | */ |
520 | 534 | 'notlinksto' => array('default' => ''), |
521 | 535 | /** |
| 536 | + * this parameter restricts the output to articles which use one of the specified images. |
| 537 | + * Examples: imageused=Image:my image|Image:your image |
| 538 | + */ |
| 539 | + 'imageused' => array('default' => ''), |
| 540 | + /** |
| 541 | + * this parameter restricts the output to images which are used (contained) by one of the specified pages. |
| 542 | + * Examples: imagecontainer=my article|your article |
| 543 | + */ |
| 544 | + 'imagecontainer' => array('default' => ''), |
| 545 | + /** |
522 | 546 | * this parameter restricts the output to articles which use the specified template. |
523 | 547 | * Examples: uses=Template:my template |
524 | 548 | */ |
— | — | @@ -742,6 +766,10 @@ |
743 | 767 | */ |
744 | 768 | 'tablerow' => array('default' => ''), |
745 | 769 | /** |
| 770 | + * The number (starting with 1) of the column to be used for sorting |
| 771 | + */ |
| 772 | + 'tablesortcol' => array('default' => '0', 'pattern' => '/^-?\d*$/'), |
| 773 | + /** |
746 | 774 | * Max # characters of page title to display. |
747 | 775 | * Empty value (default) means no limit. |
748 | 776 | * Not applicable to mode=category. |
— | — | @@ -878,7 +906,15 @@ |
879 | 907 | // $dump2 = self::dumpParsedRefs($parser,"after DPL func"); |
880 | 908 | // return $dump1.$text.$dump2; |
881 | 909 | |
882 | | - return self::dynamicPageList($input, $params, $parser, $reset, 'func'); |
| 910 | + $dplresult = self::dynamicPageList($input, $params, $parser, $reset, 'func'); |
| 911 | + global $wgVersion; |
| 912 | + if (version_compare($wgVersion, '1.12.0')<0 || $parser instanceof Parser_OldPP) return $dplresult; |
| 913 | + // old parser does further recursive processing by default |
| 914 | + return array( // normal parser needs to be coaxed to do further recursive processing |
| 915 | + $parser->getPreprocessor()->preprocessToObj($dplresult, Parser::PTD_FOR_INCLUSION ), |
| 916 | + "isChildObj" => true |
| 917 | + ); |
| 918 | + |
883 | 919 | } |
884 | 920 | |
885 | 921 | public static function dplChapterParserFunction(&$parser, $text='', $heading=' ', $maxLength = -1, $page = '?page?', $link = 'default', $trim=false ) { |
— | — | @@ -1131,6 +1167,7 @@ |
1132 | 1168 | $aListSeparators = array(); |
1133 | 1169 | $sTable = self::$options['table']['default']; |
1134 | 1170 | $aTableRow = array(); |
| 1171 | + $iTableSortCol = self::$options['tablesortcol']['default']; |
1135 | 1172 | |
1136 | 1173 | $sInlTxt = self::$options['inlinetext']['default']; |
1137 | 1174 | |
— | — | @@ -1225,6 +1262,9 @@ |
1226 | 1263 | $aLinksFrom = array(); |
1227 | 1264 | $aNotLinksFrom = array(); |
1228 | 1265 | |
| 1266 | + $aImageUsed = array(); |
| 1267 | + $aImageContainer= array(); |
| 1268 | + |
1229 | 1269 | $aUses = array(); |
1230 | 1270 | $aNotUses = array(); |
1231 | 1271 | |
— | — | @@ -1476,6 +1516,31 @@ |
1477 | 1517 | if(!$bSelectionCriteriaFound) return $logger->msgWrongParam('notlinksfrom', $sArg); |
1478 | 1518 | break; |
1479 | 1519 | |
| 1520 | + case 'imageused': |
| 1521 | + $pages = explode('|', trim($sArg)); |
| 1522 | + $n=0; |
| 1523 | + foreach($pages as $page) { |
| 1524 | + if (trim($page)=='') continue; |
| 1525 | + if (!($theTitle = Title::newFromText(trim($page)))) return $logger->msgWrongParam('imageused', $sArg); |
| 1526 | + $aImageUsed[$n++] = $theTitle; |
| 1527 | + $bSelectionCriteriaFound=true; |
| 1528 | + } |
| 1529 | + if(!$bSelectionCriteriaFound) return $logger->msgWrongParam('imageused', $sArg); |
| 1530 | + $bConflictsWithOpenReferences=true; |
| 1531 | + break; |
| 1532 | + |
| 1533 | + case 'imagecontainer': |
| 1534 | + $pages = explode('|', trim($sArg)); |
| 1535 | + $n=0; |
| 1536 | + foreach($pages as $page) { |
| 1537 | + if (trim($page)=='') continue; |
| 1538 | + if (!($theTitle = Title::newFromText(trim($page)))) return $logger->msgWrongParam('imagecontainer', $sArg); |
| 1539 | + $aImageContainer[$n++] = $theTitle; |
| 1540 | + $bSelectionCriteriaFound=true; |
| 1541 | + } |
| 1542 | + if(!$bSelectionCriteriaFound) return $logger->msgWrongParam('imagecontainer', $sArg); |
| 1543 | + break; |
| 1544 | + |
1480 | 1545 | case 'uses': |
1481 | 1546 | $pages = explode('|', $sArg); |
1482 | 1547 | $n=0; |
— | — | @@ -1693,7 +1758,7 @@ |
1694 | 1759 | break; |
1695 | 1760 | |
1696 | 1761 | case 'articlecategory': |
1697 | | - $sArticleCategory = $sArg; |
| 1762 | + $sArticleCategory = str_replace(' ','_',$sArg); |
1698 | 1763 | break; |
1699 | 1764 | |
1700 | 1765 | /** |
— | — | @@ -1966,6 +2031,13 @@ |
1967 | 2032 | else $aTableRow = explode (',',$sArg); |
1968 | 2033 | break; |
1969 | 2034 | |
| 2035 | + case 'tablesortcol': |
| 2036 | + if( preg_match(self::$options['tablesortcol']['pattern'], $sArg) ) |
| 2037 | + $iTableSortCol = ($sArg == '') ? 0 : intval($sArg); |
| 2038 | + else // wrong value |
| 2039 | + $output .= $logger->msgWrongParam('tablesortcol', $sArg); |
| 2040 | + break; |
| 2041 | + |
1970 | 2042 | case 'dominantsection': |
1971 | 2043 | if( preg_match(self::$options['dominantsection']['pattern'], $sArg) ) |
1972 | 2044 | $iDominantSection = ($sArg == '') ? NULL: intval($sArg); |
— | — | @@ -2133,14 +2205,13 @@ |
2134 | 2206 | global $wgHooks; |
2135 | 2207 | if (!isset($wgHooks['ParserAfterTidy']) || |
2136 | 2208 | !( in_array( __CLASS__ . '::endReset',$wgHooks['ParserAfterTidy']) || |
2137 | | - in_array( array(__CLASS__, 'endReset' ),$wgHooks['ParserAfterTidy']) ) ) { |
| 2209 | + in_array( array(__CLASS__, 'endReset' ),$wgHooks['ParserAfterTidy'],true) ) ) { |
2138 | 2210 | // changed back to globals, gs |
2139 | 2211 | //$wgHooks['ParserAfterTidy'][] = __CLASS__ . '::endReset'; |
2140 | 2212 | $wgHooks['ParserAfterTidy'][] = __CLASS__ . '__endReset'; |
2141 | 2213 | } |
2142 | 2214 | } |
2143 | | - |
2144 | | - |
| 2215 | + |
2145 | 2216 | // ###### CHECKS ON PARAMETERS ###### |
2146 | 2217 | // too many categories!! |
2147 | 2218 | if ( ($iTotalCatCount > self::$maxCategoryCount) && (!self::$allowUnlimitedCategories) ) |
— | — | @@ -2293,7 +2364,7 @@ |
2294 | 2365 | else $sSqlDistinct = 'DISTINCT'; |
2295 | 2366 | $sSqlGroupBy = ''; |
2296 | 2367 | if ($sDistinctResultSet == 'strict' |
2297 | | - && (count($aLinksTo)+count($aNotLinksTo)+count($aLinksFrom)+count($aNotLinksFrom))>0 ) $sSqlGroupBy = 'page_title'; |
| 2368 | + && (count($aLinksTo)+count($aNotLinksTo)+count($aLinksFrom)+count($aNotLinksFrom)+count($aImageUsed))>0 ) $sSqlGroupBy = 'page_title'; |
2298 | 2369 | $sSqlSortkey = ''; |
2299 | 2370 | $sSqlCl_to = ''; |
2300 | 2371 | $sSqlCats = ''; |
— | — | @@ -2311,6 +2382,7 @@ |
2312 | 2383 | $sSqlRev_user = ''; |
2313 | 2384 | $sSqlCond_page_rev = ''; |
2314 | 2385 | $sPageLinksTable = $dbr->tableName( 'pagelinks' ); |
| 2386 | + $sImageLinksTable = $dbr->tableName( 'imagelinks' ); |
2315 | 2387 | $sTemplateLinksTable = $dbr->tableName( 'templatelinks' ); |
2316 | 2388 | $sSqlPageLinksTable = ''; |
2317 | 2389 | $sSqlCond_page_pl = ''; |
— | — | @@ -2478,6 +2550,40 @@ |
2479 | 2551 | } |
2480 | 2552 | } |
2481 | 2553 | |
| 2554 | + // imageused |
| 2555 | + if ( count($aImageUsed)>0 ) { |
| 2556 | + $sSqlPageLinksTable .= $sImageLinksTable . ' as il, '; |
| 2557 | + $sSqlCond_page_pl .= ' AND '.$sPageTable.'.page_id=il.il_from AND ('; |
| 2558 | + $sSqlSelPage = ', il.il_to as image_sel_title'; |
| 2559 | + $n=0; |
| 2560 | + foreach ($aImageUsed as $link) { |
| 2561 | + if ($n>0) $sSqlCond_page_pl .= ' OR '; |
| 2562 | + if ($bIgnoreCase) $sSqlCond_page_pl .= "UPPER(il.il_to)=UPPER(" . $dbr->addQuotes( $link->getDbKey() ).')'; |
| 2563 | + else $sSqlCond_page_pl .= "il.il_to=" . $dbr->addQuotes( $link->getDbKey() ); |
| 2564 | + $n++; |
| 2565 | + } |
| 2566 | + $sSqlCond_page_pl .= ')'; |
| 2567 | + } |
| 2568 | + |
| 2569 | + // imagecontainer |
| 2570 | + if ( count($aImageContainer)>0 ) { |
| 2571 | + $sSqlPageLinksTable .= $sImageLinksTable . ' as ic, '; |
| 2572 | + if ($acceptOpenReferences) { |
| 2573 | + $sSqlCond_page_pl .= ' AND ('; |
| 2574 | + } |
| 2575 | + else { |
| 2576 | + $sSqlCond_page_pl .= ' AND '.$sPageTable.'.page_namespace=\'6\' AND '.$sPageTable.'.page_title=ic.il_to AND ('; |
| 2577 | + } |
| 2578 | + $n=0; |
| 2579 | + foreach ($aImageContainer as $link) { |
| 2580 | + if ($n>0) $sSqlCond_page_pl .= ' OR '; |
| 2581 | + if ($bIgnoreCase) $sSqlCond_page_pl .= "UPPER(ic.il_from)=UPPER(" . $dbr->addQuotes( $link->getArticleID() ).')'; |
| 2582 | + else $sSqlCond_page_pl .= "ic.il_from=" . $dbr->addQuotes( $link->getArticleID() ); |
| 2583 | + $n++; |
| 2584 | + } |
| 2585 | + $sSqlCond_page_pl .= ')'; |
| 2586 | + } |
| 2587 | + |
2482 | 2588 | // uses |
2483 | 2589 | if ( count($aUses)>0 ) { |
2484 | 2590 | $sSqlPageLinksTable .= ' '.$sTemplateLinksTable . ' as tl, '; |
— | — | @@ -2610,8 +2716,13 @@ |
2611 | 2717 | // SELECT ... FROM |
2612 | 2718 | if ($acceptOpenReferences) |
2613 | 2719 | // SELECT ... FROM |
2614 | | - $sSqlSelectFrom = "SELECT $sSqlCalcFoundRows $sSqlDistinct " . $sSqlCl_to . 'pl_namespace, pl_title' . $sSqlSelPage . $sSqlSortkey . ' FROM ' . $sPageLinksTable; |
2615 | | - else |
| 2720 | + if (count($aImageContainer)>0) { |
| 2721 | + $sSqlSelectFrom = "SELECT $sSqlCalcFoundRows $sSqlDistinct " . $sSqlCl_to . 'ic.il_to, ' . $sSqlSelPage . "ic.il_to as sortkey" . ' FROM ' . $sImageLinksTable . ' AS ic'; |
| 2722 | + } |
| 2723 | + else { |
| 2724 | + $sSqlSelectFrom = "SELECT $sSqlCalcFoundRows $sSqlDistinct " . $sSqlCl_to . 'pl_namespace, pl_title' . $sSqlSelPage . $sSqlSortkey . ' FROM ' . $sPageLinksTable; |
| 2725 | + } |
| 2726 | + else |
2616 | 2727 | $sSqlSelectFrom = "SELECT $sSqlCalcFoundRows $sSqlDistinct " . $sSqlCl_to . $sPageTable.'.page_namespace as page_namespace,'. |
2617 | 2728 | $sPageTable.'.page_title as page_title' . $sSqlSelPage . $sSqlSortkey . $sSqlPage_counter . |
2618 | 2729 | $sSqlPage_size . $sSqlPage_touched . $sSqlRev_user . |
— | — | @@ -2875,12 +2986,18 @@ |
2876 | 2987 | $pageNamespace = 14; // CATEGORY |
2877 | 2988 | $pageTitle = $row->cl_to; |
2878 | 2989 | } else if ($acceptOpenReferences) { |
2879 | | - // existing PAGE TITLE |
2880 | | - $pageNamespace = $row->pl_namespace; |
2881 | | - $pageTitle = $row->pl_title; |
| 2990 | + if (count($aImageContainer)>0) { |
| 2991 | + $pageNamespace = 6; |
| 2992 | + $pageTitle = $row->il_to; |
| 2993 | + } |
| 2994 | + else { |
| 2995 | + // maybe non-existing title |
| 2996 | + $pageNamespace = $row->pl_namespace; |
| 2997 | + $pageTitle = $row->pl_title; |
| 2998 | + } |
2882 | 2999 | } |
2883 | 3000 | else { |
2884 | | - // maybe non-existing title |
| 3001 | + // existing PAGE TITLE |
2885 | 3002 | $pageNamespace = $row->page_namespace; |
2886 | 3003 | $pageTitle = $row->page_title; |
2887 | 3004 | } |
— | — | @@ -2939,6 +3056,15 @@ |
2940 | 3057 | } |
2941 | 3058 | } |
2942 | 3059 | |
| 3060 | + //STORE selected image |
| 3061 | + if ( count($aImageUsed)>0 ) { |
| 3062 | + if (!isset($row->image_sel_title)) { |
| 3063 | + $dplArticle->mImageSelTitle = 'unknown image'; |
| 3064 | + } else { |
| 3065 | + $dplArticle->mImageSelTitle = $row->image_sel_title; |
| 3066 | + } |
| 3067 | + } |
| 3068 | + |
2943 | 3069 | if ($bGoalIsPages) { |
2944 | 3070 | //REVISION SPECIFIED |
2945 | 3071 | if( $sLastRevisionBefore.$sAllRevisionsBefore.$sFirstRevisionSince.$sAllRevisionsSince !='') { |
— | — | @@ -3029,7 +3155,7 @@ |
3030 | 3156 | $dpl = new DPL2($aHeadings, $bHeadingCount, $iColumns, $iRows, $iRowSize, $sRowColFormat, $aArticles, |
3031 | 3157 | $aOrderMethods[0], $hListMode, $listMode, $bEscapeLinks, $bIncPage, $iIncludeMaxLen, |
3032 | 3158 | $aSecLabels, $aSecLabelsMatch, $aSecLabelsNotMatch, $bIncParsed, $parser, $logger, $aReplaceInTitle, |
3033 | | - $iTitleMaxLen, $defaultTemplateSuffix, $aTableRow, $bIncludeTrim); |
| 3159 | + $iTitleMaxLen, $defaultTemplateSuffix, $aTableRow, $bIncludeTrim, $iTableSortCol); |
3034 | 3160 | |
3035 | 3161 | if ($rowcount == -1) $rowcount = $dpl->getRowCount(); |
3036 | 3162 | $dpl2result = $dpl->getText(); |
— | — | @@ -3067,7 +3193,7 @@ |
3068 | 3194 | global $wgHooks; |
3069 | 3195 | if (!isset($wgHooks['ParserAfterTidy']) || |
3070 | 3196 | !(in_array(__CLASS__ . '::endEliminate',$wgHooks['ParserAfterTidy']) || |
3071 | | - in_array( array( __CLASS__, 'endEliminate'),$wgHooks['ParserAfterTidy']))) { |
| 3197 | + in_array( array( __CLASS__, 'endEliminate'),$wgHooks['ParserAfterTidy'],true))) { |
3072 | 3198 | // changed back to globals, gs |
3073 | 3199 | // $wgHooks['ParserAfterTidy'][] = __CLASS__ . '::endEliminate'; |
3074 | 3200 | $wgHooks['ParserAfterTidy'][] = __CLASS__ . '__endEliminate'; |
— | — | @@ -3108,7 +3234,7 @@ |
3109 | 3235 | |
3110 | 3236 | } |
3111 | 3237 | |
3112 | | - // create keys for TableRow which representg the structure of the "include=" arguments |
| 3238 | + // create keys for TableRow which represent the structure of the "include=" arguments |
3113 | 3239 | private static function updateTableRowKeys(&$aTableRow,$aSecLabels) { |
3114 | 3240 | $tableRow = $aTableRow; |
3115 | 3241 | $aTableRow=array(); |
— | — | @@ -3219,6 +3345,7 @@ |
3220 | 3346 | var $mNamespace = -1; // namespace (number) |
3221 | 3347 | var $mSelTitle = ''; // selected title of initial page |
3222 | 3348 | var $mSelNamespace = -1;// selected namespace (number) of initial page |
| 3349 | + var $mImageSelTitle = ''; // selected title of image |
3223 | 3350 | var $mLink = ''; // html link to page |
3224 | 3351 | var $mStartChar = ''; // page title first char |
3225 | 3352 | var $mParentHLink = ''; // heading (link to the associated page) that page belongs to in the list (default '' means no heading) |
— | — | @@ -3350,7 +3477,7 @@ |
3351 | 3478 | function DPL2($headings, $bHeadingCount, $iColumns, $iRows, $iRowSize, $sRowColFormat, $articles, $headingtype, $hlistmode, |
3352 | 3479 | $listmode, $bescapelinks, $includepage, $includemaxlen, $includeseclabels, $includeseclabelsmatch, |
3353 | 3480 | $includeseclabelsnotmatch, $includematchparsed, &$parser, $logger, $replaceInTitle, $iTitleMaxLen, |
3354 | | - $defaultTemplateSuffix, $aTableRow, $bIncludeTrim ) { |
| 3481 | + $defaultTemplateSuffix, $aTableRow, $bIncludeTrim, $iTableSortCol ) { |
3355 | 3482 | global $wgContLang; |
3356 | 3483 | $this->nameSpaces = $wgContLang->getNamespaces(); |
3357 | 3484 | $this->mArticles = $articles; |
— | — | @@ -3406,13 +3533,13 @@ |
3407 | 3534 | $greml -= $portion; |
3408 | 3535 | // $this->mOutput .= "nsize=$nsize, portion=$portion, greml=$greml"; |
3409 | 3536 | if ($greml>0) { |
3410 | | - $this->mOutput .= $this->formatList($nstart-$offset, $portion, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim); |
| 3537 | + $this->mOutput .= $this->formatList($nstart-$offset, $portion, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim, $iTableSortCol); |
3411 | 3538 | $nstart += $portion; |
3412 | 3539 | $portion=0; |
3413 | 3540 | break; |
3414 | 3541 | } |
3415 | 3542 | else { |
3416 | | - $this->mOutput .= $this->formatList($nstart-$offset, $portion+$greml, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim); |
| 3543 | + $this->mOutput .= $this->formatList($nstart-$offset, $portion+$greml, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim, $iTableSortCol); |
3417 | 3544 | $nstart += ($portion+$greml); |
3418 | 3545 | $portion = (-$greml); |
3419 | 3546 | if ($iColumns!=1) $this->mOutput .= "\n|valign=top|\n"; |
— | — | @@ -3439,7 +3566,7 @@ |
3440 | 3567 | $this->mOutput .= $hlistmode->sItemStart; |
3441 | 3568 | $this->mOutput .= $hlistmode->sHeadingStart . $headingLink . $hlistmode->sHeadingEnd; |
3442 | 3569 | if ($bHeadingCount) $this->mOutput .= $this->formatCount($headingCount); |
3443 | | - $this->mOutput .= $this->formatList($headingStart, $headingCount, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim); |
| 3570 | + $this->mOutput .= $this->formatList($headingStart, $headingCount, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim, $iTableSortCol); |
3444 | 3571 | $this->mOutput .= $hlistmode->sItemEnd; |
3445 | 3572 | $headingStart += $headingCount; |
3446 | 3573 | } |
— | — | @@ -3456,7 +3583,7 @@ |
3457 | 3584 | if ($rest>0) $nsize += 1; |
3458 | 3585 | $this->mOutput .= "{|".$sRowColFormat."\n|\n"; |
3459 | 3586 | for ($g=0;$g<$iGroup;$g++) { |
3460 | | - $this->mOutput .= $this->formatList($nstart, $nsize, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim); |
| 3587 | + $this->mOutput .= $this->formatList($nstart, $nsize, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim, $iTableSortCol); |
3461 | 3588 | if ($iColumns!=1) $this->mOutput .= "\n|valign=top|\n"; |
3462 | 3589 | else $this->mOutput .= "\n|-\n|\n"; |
3463 | 3590 | $nstart = $nstart + $nsize; |
— | — | @@ -3472,14 +3599,14 @@ |
3473 | 3600 | $this->mOutput .= '{|'.$sRowColFormat."\n|\n"; |
3474 | 3601 | do { |
3475 | 3602 | if ($nstart+$nsize > $count) $nsize = $count - $nstart; |
3476 | | - $this->mOutput .= $this->formatList($nstart, $nsize, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim); |
| 3603 | + $this->mOutput .= $this->formatList($nstart, $nsize, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim, $iTableSortCol); |
3477 | 3604 | $this->mOutput .= "\n|-\n|\n"; |
3478 | 3605 | $nstart = $nstart + $nsize; |
3479 | 3606 | if ($nstart >= $count) break; |
3480 | 3607 | } while (true); |
3481 | 3608 | $this->mOutput .= "\n|}\n"; |
3482 | 3609 | } else { |
3483 | | - $this->mOutput .= $this->formatList(0, count($articles), $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim); |
| 3610 | + $this->mOutput .= $this->formatList(0, count($articles), $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim, $iTableSortCol); |
3484 | 3611 | } |
3485 | 3612 | |
3486 | 3613 | } |
— | — | @@ -3532,6 +3659,7 @@ |
3533 | 3660 | $sTag = str_replace('%PAGESEL%',$this->nameSpaces[$article->mSelNamespace].':'.str_replace('_',' ',$article->mSelTitle),$sTag); |
3534 | 3661 | } |
3535 | 3662 | } |
| 3663 | + if ($article->mImageSelTitle!= '') $sTag = str_replace('%IMAGESEL%',str_replace('_',' ',$article->mImageSelTitle),$sTag); |
3536 | 3664 | if (!empty($article->mCategoryLinks) ) { |
3537 | 3665 | $sTag = str_replace('%'.'CATLIST%',implode(', ', $article->mCategoryLinks),$sTag); |
3538 | 3666 | $sTag = str_replace('%'.'CATNAMES%',implode(', ', $article->mCategoryTexts),$sTag); |
— | — | @@ -3543,20 +3671,19 @@ |
3544 | 3672 | return $sTag; |
3545 | 3673 | } |
3546 | 3674 | |
3547 | | - function formatList($iStart, $iCount, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim) { |
| 3675 | + function formatList($iStart, $iCount, $iTitleMaxLen, $defaultTemplateSuffix, $bIncludeTrim, $iTableSortCol) { |
3548 | 3676 | global $wgUser, $wgLang, $wgContLang; |
3549 | 3677 | |
3550 | 3678 | $mode = $this->mListMode; |
3551 | 3679 | //categorypage-style list output mode |
3552 | | - if($mode->name == 'category') |
3553 | | - return $this->formatCategoryList($iStart, $iCount); |
| 3680 | + if($mode->name == 'category') return $this->formatCategoryList($iStart, $iCount); |
3554 | 3681 | |
3555 | 3682 | //other list modes |
3556 | 3683 | $sk = & $wgUser->getSkin(); |
3557 | 3684 | |
3558 | 3685 | //process results of query, outputing equivalent of <li>[[Article]]</li> for each result, |
3559 | 3686 | //or something similar if the list uses other startlist/endlist; |
3560 | | - $r = $mode->sListStart; |
| 3687 | + $rBody=''; |
3561 | 3688 | // the following statement caused a problem with multiple columns: $this->filteredCount = 0; |
3562 | 3689 | for ($i = $iStart; $i < $iStart+$iCount; $i++) { |
3563 | 3690 | $article = $this->mArticles[$i]; |
— | — | @@ -3618,9 +3745,9 @@ |
3619 | 3746 | else $mustNotMatch = ''; |
3620 | 3747 | |
3621 | 3748 | // if chapters are selected by number we get the heading from DPL2Include::includeHeading |
3622 | | - $sectionHeading=''; |
| 3749 | + $sectionHeading[0]=''; |
3623 | 3750 | if($sSecLabel[0] == '#') { |
3624 | | - $sectionHeading=substr($sSecLabel,1); |
| 3751 | + $sectionHeading[0]=substr($sSecLabel,1); |
3625 | 3752 | // Uses DPL2Include::includeHeading() from LabeledSectionTransclusion extension to include headings from the page |
3626 | 3753 | $secPieces = DPL2Include::includeHeading($this->mParser, $article->mTitle->getPrefixedText(), substr($sSecLabel, 1),'', |
3627 | 3754 | $sectionHeading,false,$maxlen,$cutLink,$bIncludeTrim); |
— | — | @@ -3636,9 +3763,15 @@ |
3637 | 3764 | } |
3638 | 3765 | } |
3639 | 3766 | $this->formatSingleItems($secPieces,$s); |
3640 | | - $secPiece[$s] = implode(isset($mode->aMultiSecSeparators[$s])? |
3641 | | - $this->substTagParm($mode->aMultiSecSeparators[$s], $pagename, $article, |
3642 | | - $this->filteredCount, $iTitleMaxLen):'',$secPieces); |
| 3767 | + $secPiece[$s] = $secPieces[0]; |
| 3768 | + for ($sp=1;$sp<count($secPieces);$sp++) { |
| 3769 | + if (isset($mode->aMultiSecSeparators[$s])) { |
| 3770 | + $secPiece[$s] .= str_replace('%SECTION%',$sectionHeading[$sp], |
| 3771 | + $this->substTagParm($mode->aMultiSecSeparators[$s], $pagename, $article, |
| 3772 | + $this->filteredCount, $iTitleMaxLen)); |
| 3773 | + } |
| 3774 | + $secPiece[$s] .= $secPieces[$sp]; |
| 3775 | + } |
3643 | 3776 | if ($mode->iDominantSection>=0 && $s==$mode->iDominantSection && count($secPieces)>1) $dominantPieces=$secPieces; |
3644 | 3777 | if (($mustMatch!='' || $mustNotMatch!='') && count($secPieces)<=0) { |
3645 | 3778 | $matchFailed=true; // NOTHING MATCHED |
— | — | @@ -3650,7 +3783,8 @@ |
3651 | 3784 | $template1 = substr($sSecLabel,1,strpos($sSecLabel,'}')-1); |
3652 | 3785 | $template2 = str_replace('}','',substr($sSecLabel,1)); |
3653 | 3786 | $secPieces = DPL2Include::includeTemplate($this->mParser, $this, $s, $article, $template1, |
3654 | | - $template2, $template2.$defaultTemplateSuffix,$mustMatch,$mustNotMatch,$this->mIncParsed); |
| 3787 | + $template2, $template2.$defaultTemplateSuffix,$mustMatch, |
| 3788 | + $mustNotMatch,$this->mIncParsed,$iTitleMaxLen); |
3655 | 3789 | $secPiece[$s] = implode(isset($mode->aMultiSecSeparators[$s])? |
3656 | 3790 | $this->substTagParm($mode->aMultiSecSeparators[$s], $pagename, $article, $this->filteredCount, $iTitleMaxLen):'',$secPieces); |
3657 | 3791 | if ($mode->iDominantSection>=0 && $s==$mode->iDominantSection && count($secPieces)>1) $dominantPieces=$secPieces; |
— | — | @@ -3674,14 +3808,14 @@ |
3675 | 3809 | // separator tags |
3676 | 3810 | if (count($mode->sSectionTags)==1) { |
3677 | 3811 | // If there is only one separator tag use it always |
3678 | | - $septag[$s*2] = str_replace('%SECTION%',$sectionHeading,$this->substTagParm($mode->sSectionTags[0], $pagename, $article, $this->filteredCount, $iTitleMaxLen)); |
| 3812 | + $septag[$s*2] = str_replace('%SECTION%',$sectionHeading[0],$this->substTagParm($mode->sSectionTags[0], $pagename, $article, $this->filteredCount, $iTitleMaxLen)); |
3679 | 3813 | } |
3680 | 3814 | else if (isset($mode->sSectionTags[$s*2])) { |
3681 | | - $septag[$s*2] = str_replace('%SECTION%',$sectionHeading,$this->substTagParm($mode->sSectionTags[$s*2], $pagename, $article, $this->filteredCount, $iTitleMaxLen)); |
| 3815 | + $septag[$s*2] = str_replace('%SECTION%',$sectionHeading[0],$this->substTagParm($mode->sSectionTags[$s*2], $pagename, $article, $this->filteredCount, $iTitleMaxLen)); |
3682 | 3816 | } |
3683 | 3817 | else $septag[$s*2] = ''; |
3684 | 3818 | if (isset($mode->sSectionTags[$s*2+1])) { |
3685 | | - $septag[$s*2+1] = str_replace('%SECTION%',$sectionHeading,$this->substTagParm($mode->sSectionTags[$s*2+1], $pagename, $article, $this->filteredCount, $iTitleMaxLen)); |
| 3819 | + $septag[$s*2+1] = str_replace('%SECTION%',$sectionHeading[0],$this->substTagParm($mode->sSectionTags[$s*2+1], $pagename, $article, $this->filteredCount, $iTitleMaxLen)); |
3686 | 3820 | } |
3687 | 3821 | else $septag[$s*2+1]=''; |
3688 | 3822 | |
— | — | @@ -3712,61 +3846,87 @@ |
3713 | 3847 | $this->filteredCount = $this->filteredCount + 1; |
3714 | 3848 | } |
3715 | 3849 | |
3716 | | - if($i > $iStart) $r .= $mode->sInline; //If mode is not 'inline', sInline attribute is empty, so does nothing |
| 3850 | + if($i > $iStart) $rBody .= $mode->sInline; //If mode is not 'inline', sInline attribute is empty, so does nothing |
3717 | 3851 | |
3718 | 3852 | // symbolic substitution of %PAGE% by the current article's name |
3719 | 3853 | if ($mode->name == 'userformat') { |
3720 | | - $r .= $this->substTagParm($mode->sItemStart, $pagename, $article,$this->filteredCount, $iTitleMaxLen); |
| 3854 | + $rBody .= $this->substTagParm($mode->sItemStart, $pagename, $article,$this->filteredCount, $iTitleMaxLen); |
3721 | 3855 | } |
3722 | 3856 | else { |
3723 | | - $r .= $mode->sItemStart; |
| 3857 | + $rBody .= $mode->sItemStart; |
3724 | 3858 | if($article->mDate != '') { |
3725 | 3859 | if ($article->myDate != '') { |
3726 | | - if($article->mRevision != '') $r .= ' <html><a href="'.$pagename.'?oldid='.$article->mRevision.'">' |
3727 | | - . $article->myDate.'</a></html>'; |
3728 | | - else $r .= $article->myDate; |
| 3860 | + if($article->mRevision != '') $rBody .= ' <html><a href="'.$pagename.'?oldid='.$article->mRevision.'">' |
| 3861 | + . $article->myDate.'</a></html>'; |
| 3862 | + else $rBody .= $article->myDate; |
3729 | 3863 | } else { |
3730 | | - if($article->mRevision != '') $r .= ' <html><a href="'.$pagename.'?oldid='.$article->mRevision.'">' |
3731 | | - . $wgLang->timeanddate($article->mDate, true).'</a></html> : '; |
3732 | | - else $r .= $wgLang->timeanddate($article->mDate, true) . ': '; |
| 3864 | + if($article->mRevision != '') $rBody .= ' <html><a href="'.$pagename.'?oldid='.$article->mRevision.'">' |
| 3865 | + . $wgLang->timeanddate($article->mDate, true).'</a></html> : '; |
| 3866 | + else $rBody .= $wgLang->timeanddate($article->mDate, true) . ': '; |
3733 | 3867 | } |
3734 | 3868 | } |
3735 | 3869 | // output the link to the article |
3736 | | - $r .= $article->mLink; |
| 3870 | + $rBody .= $article->mLink; |
3737 | 3871 | if($article->mSize != '' && $mode->name != 'userformat') { |
3738 | | - if (strlen($article->mSize) > 3) $r .= ' [' . substr($article->mSize,0,strlen($article->mSize)-3) . ' kB]'; |
3739 | | - else $r .= ' [' . $article->mSize . ' B]'; |
| 3872 | + if (strlen($article->mSize) > 3) $rBody .= ' [' . substr($article->mSize,0,strlen($article->mSize)-3) . ' kB]'; |
| 3873 | + else $rBody .= ' [' . $article->mSize . ' B]'; |
3740 | 3874 | } |
3741 | 3875 | if($article->mCounter != '' && $mode->name != 'userformat') { |
3742 | 3876 | // Adapted from SpecialPopularPages::formatResult() |
3743 | 3877 | $nv = $this->msgExt( 'nviews', array( 'parsemag', 'escape'), $wgLang->formatNum( $article->mCounter ) ); |
3744 | | - $r .= ' ' . $wgContLang->getDirMark() . '(' . $nv . ')'; |
| 3878 | + $rBody .= ' ' . $wgContLang->getDirMark() . '(' . $nv . ')'; |
3745 | 3879 | } |
3746 | | - if($article->mUserLink != '') $r .= ' . . [[User:' . $article->mUser .'|'.$article->mUser.']]'; |
3747 | | - if($article->mContributor != '')$r .= ' . . [[User:' . $article->mContributor .'|'.$article->mContributor." $article->mContrib]]"; |
| 3880 | + if($article->mUserLink != '') $rBody .= ' . . [[User:' . $article->mUser .'|'.$article->mUser.']]'; |
| 3881 | + if($article->mContributor != '')$rBody .= ' . . [[User:' . $article->mContributor .'|'.$article->mContributor." $article->mContrib]]"; |
3748 | 3882 | |
3749 | | - if( !empty($article->mCategoryLinks) ) $r .= ' . . <SMALL>' . wfMsg('categories') . ': ' . implode(' | ', $article->mCategoryLinks) . '</SMALL>'; |
| 3883 | + if( !empty($article->mCategoryLinks) ) $rBody .= ' . . <SMALL>' . wfMsg('categories') . ': ' . implode(' | ', $article->mCategoryLinks) . '</SMALL>'; |
3750 | 3884 | } |
3751 | 3885 | |
3752 | 3886 | // add included contents |
3753 | 3887 | |
3754 | 3888 | if ($this->mIncPage) { |
3755 | 3889 | DPL2Include::open($this->mParser, $this->mParserTitle->getPrefixedText()); |
3756 | | - $r .= $incwiki; |
| 3890 | + $rBody .= $incwiki; |
3757 | 3891 | DPL2Include::close($this->mParser, $this->mParserTitle->getPrefixedText()); |
3758 | 3892 | } |
3759 | 3893 | |
3760 | 3894 | if ($mode->name == 'userformat') { |
3761 | | - $r .= $this->substTagParm($mode->sItemEnd, $pagename, $article, $this->filteredCount, $iTitleMaxLen); |
| 3895 | + $rBody .= $this->substTagParm($mode->sItemEnd, $pagename, $article, $this->filteredCount, $iTitleMaxLen); |
3762 | 3896 | } |
3763 | | - else |
3764 | | - $r .= $mode->sItemEnd; |
| 3897 | + else { |
| 3898 | + $rBody .= $mode->sItemEnd; |
| 3899 | + } |
3765 | 3900 | } |
3766 | | - $r .= $mode->sListEnd; |
3767 | | - |
3768 | | - return $r; |
| 3901 | + // if requested we sort the table by the contents of a given column |
| 3902 | + if ($iTableSortCol!=0) { |
| 3903 | + $sortcol = abs($iTableSortCol) + 1; |
| 3904 | + $rows=explode("\n|-",$rBody); |
| 3905 | + foreach($rows as $row) { |
| 3906 | + if (($word = explode("\n|",$row,$sortcol))!==false && count($word)>=$sortcol) { |
| 3907 | + $rowsKey[] = $word[$sortcol - 1]; |
| 3908 | + } else { |
| 3909 | + $rowsKey[] = $row; |
| 3910 | + } |
| 3911 | + } |
| 3912 | + if ($iTableSortCol<0) krsort($rowsKey); |
| 3913 | + else ksort ($rowsKey); |
| 3914 | + $rows=array_combine(array_values($rowsKey),$rows); |
| 3915 | + ksort($rows); |
| 3916 | + $rBody="\n|-".join("\n|-",$rows)."\n|-"; |
| 3917 | + } |
| 3918 | + return $mode->sListStart . $rBody . $mode->sListEnd; |
3769 | 3919 | } |
3770 | 3920 | |
| 3921 | + // generate a hyperlink to the article |
| 3922 | + function articleLink($tag,$article,$iTitleMaxLen) { |
| 3923 | + $pagename = $article->mTitle->getPrefixedText(); |
| 3924 | + if ($this->mEscapeLinks && ($article->mNamespace==14 || $article->mNamespace==6) ) { |
| 3925 | + // links to categories or images need an additional ":" |
| 3926 | + $pagename = ':'.$pagename; |
| 3927 | + } |
| 3928 | + return $this->substTagParm($tag, $pagename, $article, $this->filteredCount, $iTitleMaxLen); |
| 3929 | + } |
| 3930 | + |
3771 | 3931 | //format one item of an entry in the output list (i.e. the collection of occurences of one item from the include parameter) |
3772 | 3932 | function formatItem($piece, $tagStart, $tagEnd) { |
3773 | 3933 | return $tagStart.$piece.$tagEnd; |
Index: trunk/extensions/DynamicPageList/DynamicPageList2Include.php |
— | — | @@ -78,6 +78,11 @@ |
79 | 79 | * changed call time by reference in extract Heading |
80 | 80 | * @version 1.6.9 |
81 | 81 | * added include trimming |
| 82 | + * @version 1.7.1 |
| 83 | + * allow % within included template parameters |
| 84 | + * @version 1.7.3 |
| 85 | + * %SECTION% can now be used within multiseseparators (see includeHeading) |
| 86 | + |
82 | 87 | */ |
83 | 88 | |
84 | 89 | class DPL2Include |
— | — | @@ -380,10 +385,10 @@ |
381 | 386 | } |
382 | 387 | |
383 | 388 | if (isset($m[0][0])) { |
384 | | - $sectionHeading=preg_replace("/^=+\s*/","",$m[0][0]); |
385 | | - $sectionHeading=preg_replace("/\s*=+\s*$/","",$sectionHeading); |
| 389 | + $sectionHeading[$n]=preg_replace("/^=+\s*/","",$m[0][0]); |
| 390 | + $sectionHeading[$n]=preg_replace("/\s*=+\s*$/","",$sectionHeading[$n]); |
386 | 391 | } |
387 | | - else $sectionHeading = ''; |
| 392 | + else $sectionHeading[$n] = ''; |
388 | 393 | if ($nr==1) { |
389 | 394 | // output n-th section and done |
390 | 395 | $output[0] = self::parse($parser,$title,$piece, "#lsth:${page}|${sec}", $nhead, $recursionCheck, $maxLength, $link, $trim); |
— | — | @@ -411,7 +416,7 @@ |
412 | 417 | // and do NOT match the condition "$mustNotMatch" (if specified) |
413 | 418 | // we use a callback function to format retrieved parameters, accessible via $dpl->formatTemplateArg() |
414 | 419 | public static function includeTemplate($parser, $dpl, $dplNr, $article, $template1='', $template2='', $defaultTemplate, |
415 | | - $mustMatch, $mustNotMatch, $matchParsed) |
| 420 | + $mustMatch, $mustNotMatch, $matchParsed, $iTitleMaxLen) |
416 | 421 | { |
417 | 422 | $page = $article->mTitle->getPrefixedText(); |
418 | 423 | $date = $article->myDate; |
— | — | @@ -526,14 +531,22 @@ |
527 | 532 | $output[$n] .= "|"; // \n"; |
528 | 533 | } |
529 | 534 | $found=false; |
530 | | - // named parameter |
531 | | - $exParmQuote = str_replace('/','\/',$exParm); |
532 | | - foreach ($parms as $parm) { |
533 | | - if (!preg_match("/^\s*$exParmQuote\s*=/",$parm)) continue; |
534 | | - $found=true; |
535 | | - $output[$n] .= $dpl->formatTemplateArg(preg_replace("/^$exParmQuote\s*=\s*/","",$parm),$dplNr,$exParmKey,$firstCall,$maxlen); |
536 | | - break; |
| 535 | + // % in parameter name |
| 536 | + if (strpos($exParm,'%')!==FALSE) { |
| 537 | + // %% is a short form for inclusion of %PAGE% and %TITLE% |
| 538 | + $found=true; |
| 539 | + $output[$n] .= $dpl->formatTemplateArg($dpl->articleLink($exParm,$article,$iTitleMaxLen),$dplNr,$exParmKey,$firstCall,$maxlen); |
537 | 540 | } |
| 541 | + if (!$found) { |
| 542 | + // named parameter |
| 543 | + $exParmQuote = str_replace('/','\/',$exParm); |
| 544 | + foreach ($parms as $parm) { |
| 545 | + if (!preg_match("/^\s*$exParmQuote\s*=/",$parm)) continue; |
| 546 | + $found=true; |
| 547 | + $output[$n] .= $dpl->formatTemplateArg(preg_replace("/^$exParmQuote\s*=\s*/","",$parm),$dplNr,$exParmKey,$firstCall,$maxlen); |
| 548 | + break; |
| 549 | + } |
| 550 | + } |
538 | 551 | if (!$found && is_numeric($exParm) && intval($exParm) == $exParm) { |
539 | 552 | // numeric parameter |
540 | 553 | $np=0; |