Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_OrderedListPage.php |
— | — | @@ -1,8 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * Abstract class to encapsulate properties of OrderedListPages. |
5 | | - * Inherited by SMWTypePage and SMWPropertyPage. |
6 | | - * |
7 | 5 | * Some code adapted from CategoryPage.php |
8 | 6 | * |
9 | 7 | * @author Nikolas Iwan |
— | — | @@ -26,7 +24,6 @@ |
27 | 25 | protected $from; // start string: print $limit results from here |
28 | 26 | protected $until; // end string: print $limit results strictly before this article |
29 | 27 | protected $articles; // array of articles for which information is printed (primary ordering method) |
30 | | - protected $articles_start_char; // array of first characters of printed articles, used for making subheaders |
31 | 28 | protected $skin; // cache for the current skin, obtained from $wgUser |
32 | 29 | |
33 | 30 | /** |
— | — | @@ -63,7 +60,7 @@ |
64 | 61 | /** |
65 | 62 | * Initialise some parameters that might be changed by subclasses |
66 | 63 | * (e.g. $limit). Method can be overwritten in this case. |
67 | | - * If the method returns false, nothing will be printed besides |
| 64 | + * If the method returns false, nothing will be printed besides |
68 | 65 | * the original article. |
69 | 66 | */ |
70 | 67 | protected function initParameters() { |
— | — | @@ -87,7 +84,6 @@ |
88 | 85 | */ |
89 | 86 | protected function clearPageState() { |
90 | 87 | $this->articles = array(); |
91 | | - $this->articles_start_char = array(); |
92 | 88 | } |
93 | 89 | |
94 | 90 | /** |
— | — | @@ -168,7 +164,8 @@ |
169 | 165 | * Format a list of SMWWikipageValues chunked by letter in a three-column |
170 | 166 | * list, ordered vertically. |
171 | 167 | */ |
172 | | - protected function columnList($start, $end, $elements, $elements_start_char) { |
| 168 | + protected function columnList($start, $end, $elements) { |
| 169 | + global $wgContLang; |
173 | 170 | // divide list into three equal chunks |
174 | 171 | $chunk = (int) ( ($end-$start+1) / 3); |
175 | 172 | |
— | — | @@ -189,18 +186,20 @@ |
190 | 187 | $index < $endChunk && $index < $end; |
191 | 188 | $index++ ) { |
192 | 189 | // check for change of starting letter or begining of chunk |
| 190 | + $start_char = $wgContLang->convert( $wgContLang->firstChar( $elements[$index]->getSortkey() ) ); |
193 | 191 | if ( ($index == $startChunk) || |
194 | | - ($elements_start_char[$index] != $elements_start_char[$index - 1]) ) { |
| 192 | + ($start_char != $prev_start_char) ) { |
195 | 193 | if( $atColumnTop ) { |
196 | 194 | $atColumnTop = false; |
197 | 195 | } else { |
198 | 196 | $r .= "</ul>\n"; |
199 | 197 | } |
200 | 198 | $cont_msg = ""; |
201 | | - if ( $elements_start_char[$index] == $prev_start_char ) |
| 199 | + if ( $start_char == $prev_start_char ) { |
202 | 200 | $cont_msg = wfMsgHtml('listingcontinuesabbrev'); |
203 | | - $r .= "<h3>" . htmlspecialchars( $elements_start_char[$index] ) . " $cont_msg</h3>\n<ul>"; |
204 | | - $prev_start_char = $elements_start_char[$index]; |
| 201 | + } |
| 202 | + $r .= "<h3>" . htmlspecialchars( $start_char ) . " $cont_msg</h3>\n<ul>"; |
| 203 | + $prev_start_char = $start_char; |
205 | 204 | } |
206 | 205 | $r .= "<li>" . $elements[$index]->getLongHTMLText($this->getSkin()) . "</li>\n"; |
207 | 206 | } |
— | — | @@ -216,12 +215,17 @@ |
217 | 216 | /** |
218 | 217 | * Format a list of articles chunked by letter in a bullet list. |
219 | 218 | */ |
220 | | - protected function shortList($start, $end, $elements, $elements_start_char) { |
221 | | - $r = '<h3>' . htmlspecialchars( $elements_start_char[$start] ) . "</h3>\n"; |
| 219 | + protected function shortList($start, $end, $elements) { |
| 220 | + global $wgContLang; |
| 221 | + $start_char = $wgContLang->convert( $wgContLang->firstChar( $elements[$start]->getSortkey() ) ); |
| 222 | + $prev_start_char = $start_char; |
| 223 | + $r = '<h3>' . htmlspecialchars( $start_char ) . "</h3>\n"; |
222 | 224 | $r .= '<ul><li>'. $elements[$start]->getLongHTMLText($this->getSkin()) . '</li>'; |
223 | 225 | for ($index = $start+1; $index < $end; $index++ ) { |
224 | | - if ($elements_start_char[$index] != $elements_start_char[$index - 1]) { |
225 | | - $r .= "</ul><h3>" . htmlspecialchars( $elements_start_char[$index] ) . "</h3>\n<ul>"; |
| 226 | + $start_char = $wgContLang->convert( $wgContLang->firstChar( $elements[$index]->getSortkey() ) ); |
| 227 | + if ($start_char != $prev_start_char) { |
| 228 | + $r .= "</ul><h3>" . htmlspecialchars( $start_char ) . "</h3>\n<ul>"; |
| 229 | + $prev_start_char = $start_char; |
226 | 230 | } |
227 | 231 | $r .= '<li>' . $elements[$index]->getLongHTMLText($this->getSkin()) . '</li>'; |
228 | 232 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_TypePage.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Special handling for relation/attribute description pages. |
| 4 | + * Special handling for type description pages. |
5 | 5 | * Some code based on CategoryPage.php |
6 | 6 | * |
7 | 7 | * @author: Markus Krötzsch |
— | — | @@ -51,9 +51,6 @@ |
52 | 52 | } else { |
53 | 53 | $this->articles = $store->getSpecialSubjects(SMW_SP_HAS_TYPE, $typevalue, $options); |
54 | 54 | } |
55 | | - foreach ($this->articles as $dv) { |
56 | | - $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $dv->getSortkey() ) ); |
57 | | - } |
58 | 55 | } |
59 | 56 | |
60 | 57 | /** |
— | — | @@ -107,10 +104,10 @@ |
108 | 105 | } |
109 | 106 | |
110 | 107 | if ( count ( $this->articles ) > $cutoff ) { |
111 | | - return $this->columnList( $start, $end, $this->articles, $this->articles_start_char ); |
| 108 | + return $this->columnList( $start, $end, $this->articles ); |
112 | 109 | } elseif ( count($this->articles) > 0) { |
113 | 110 | // for short lists of articles |
114 | | - return $this->shortList( $start, $end, $this->articles, $this->articles_start_char ); |
| 111 | + return $this->shortList( $start, $end, $this->articles ); |
115 | 112 | } |
116 | 113 | return ''; |
117 | 114 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php |
— | — | @@ -18,7 +18,6 @@ |
19 | 19 | |
20 | 20 | protected $special_prop; // code number of special property, false if not. |
21 | 21 | private $subproperties; // list of sub-properties of this property |
22 | | - private $subprop_start_char; // array of first characters of printed articles, used for making subheaders |
23 | 22 | |
24 | 23 | /** |
25 | 24 | * Use small $limit (property pages might become large) |
— | — | @@ -33,7 +32,6 @@ |
34 | 33 | protected function clearPageState() { |
35 | 34 | parent::clearPageState(); |
36 | 35 | $this->subproperties = array(); |
37 | | - $this->subprop_start_char = array(); |
38 | 36 | } |
39 | 37 | |
40 | 38 | /** |
— | — | @@ -70,18 +68,11 @@ |
71 | 69 | $this->articles = array_reverse($this->articles); |
72 | 70 | } |
73 | 71 | |
74 | | - foreach ($this->articles as $dv) { |
75 | | - $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $dv->getSortkey() ) ); |
76 | | - } |
77 | | - |
78 | 72 | // retrieve all subproperties of this property |
79 | 73 | $s_options = new SMWRequestOptions(); |
80 | 74 | $s_options->sort = true; |
81 | 75 | $s_options->ascending = true; |
82 | 76 | $this->subproperties = $store->getSpecialSubjects(SMW_SP_SUBPROPERTY_OF, $this->getDataValue(), $s_options); |
83 | | - foreach ($this->subproperties as $dv) { |
84 | | - $this->subprop_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $dv->getSortKey() ) ); |
85 | | - } |
86 | 77 | } |
87 | 78 | |
88 | 79 | /** |
— | — | @@ -101,9 +92,9 @@ |
102 | 93 | $r .= "<div id=\"mw-subcategories\">\n<h2>" . wfMsg('smw_subproperty_header',$ti) . "</h2>\n"; |
103 | 94 | $r .= '<p>' . wfMsg('smw_subpropertyarticlecount', min($this->limit, count($this->subproperties))) . "</p>\n"; |
104 | 95 | if (count($this->subproperties) < 6) { |
105 | | - $r .= $this->shortList(0,count($this->subproperties), $this->subproperties, $this->subprop_start_char); |
| 96 | + $r .= $this->shortList(0,count($this->subproperties), $this->subproperties); |
106 | 97 | } else { |
107 | | - $r .= $this->columnList(0,count($this->subproperties), $this->subproperties, $this->subprop_start_char); |
| 98 | + $r .= $this->columnList(0,count($this->subproperties), $this->subproperties); |
108 | 99 | } |
109 | 100 | $r .= "\n</div>"; |
110 | 101 | } |
— | — | @@ -137,20 +128,18 @@ |
138 | 129 | } |
139 | 130 | |
140 | 131 | $r = '<table style="width: 100%; ">'; |
141 | | - $prevchar = 'None'; |
| 132 | + $prev_start_char = 'None'; |
142 | 133 | for ($index = $start; $index < $ac; $index++ ) { |
| 134 | + $start_char = $wgContLang->convert( $wgContLang->firstChar( $this->articles[$index]->getSortkey() ) ); |
143 | 135 | // Header for index letters |
144 | | - if ($this->articles_start_char[$index] != $prevchar) { |
145 | | - $r .= '<tr><th class="smwpropname"><h3>' . htmlspecialchars( $this->articles_start_char[$index] ) . "</h3></th><th></th></tr>\n"; |
146 | | - $prevchar = $this->articles_start_char[$index]; |
| 136 | + if ($start_char != $prev_start_char) { |
| 137 | + $r .= '<tr><th class="smwpropname"><h3>' . htmlspecialchars( $start_char ) . "</h3></th><th></th></tr>\n"; |
| 138 | + $prev_start_char = $start_char; |
147 | 139 | } |
148 | 140 | // Property name |
149 | 141 | $searchlink = SMWInfolink::newBrowsingLink('+',$this->articles[$index]->getShortHTMLText()); |
150 | 142 | $r .= '<tr><td class="smwpropname">' . $this->articles[$index]->getLongHTMLText($this->getSkin()) . |
151 | | - /*$this->getSkin()->makeKnownLinkObj( $this->articles[$index]->getTitle, |
152 | | - $wgContLang->convert( $this->articles[$index]->getLongHTMLText() ) ) .*/ |
153 | | - ' ' . $searchlink->getHTML($this->getSkin()) . |
154 | | - '</td><td class="smwprops">'; |
| 143 | + ' ' . $searchlink->getHTML($this->getSkin()) . '</td><td class="smwprops">'; |
155 | 144 | // Property values |
156 | 145 | $ropts = new SMWRequestOptions(); |
157 | 146 | $ropts->limit = 4; |