Index: trunk/extensions/SelectCategory/jquery.treeview.css |
— | — | @@ -1,4 +1,4 @@ |
2 | | -.treeview, .treeview ul { |
| 2 | +.treeview, .treeview ul { |
3 | 3 | padding: 0; |
4 | 4 | margin: 0; |
5 | 5 | list-style: none; |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | float:none; |
25 | 25 | } |
26 | 26 | |
27 | | -.treeview li { |
| 27 | +.treeview li { |
28 | 28 | margin: 0; |
29 | 29 | padding: 3px 0pt 3px 16px; |
30 | 30 | } |
— | — | @@ -42,23 +42,23 @@ |
43 | 43 | .treeview .expandable-hitarea { background-position: -80px -3px; } |
44 | 44 | |
45 | 45 | .treeview li.last { background-position: 0 -1766px } |
46 | | -.treeview li.lastCollapsable, .treeview li.lastExpandable { background-image: url(images/treeview-default.gif); } |
| 46 | +.treeview li.lastCollapsable, .treeview li.lastExpandable { background-image: url(images/treeview-default.gif); } |
47 | 47 | .treeview li.lastCollapsable { background-position: 0 -111px } |
48 | 48 | .treeview li.lastExpandable { background-position: -32px -67px } |
49 | 49 | |
50 | 50 | .treeview div.lastCollapsable-hitarea, .treeview div.lastExpandable-hitarea { background-position: 0; } |
51 | 51 | |
52 | 52 | .treeview-red li { background-image: url(images/treeview-red-line.gif); } |
53 | | -.treeview-red .hitarea, .treeview-red li.lastCollapsable, .treeview-red li.lastExpandable { background-image: url(images/treeview-red.gif); } |
| 53 | +.treeview-red .hitarea, .treeview-red li.lastCollapsable, .treeview-red li.lastExpandable { background-image: url(images/treeview-red.gif); } |
54 | 54 | |
55 | 55 | .treeview-black li { background-image: url(images/treeview-black-line.gif); } |
56 | | -.treeview-black .hitarea, .treeview-black li.lastCollapsable, .treeview-black li.lastExpandable { background-image: url(images/treeview-black.gif); } |
| 56 | +.treeview-black .hitarea, .treeview-black li.lastCollapsable, .treeview-black li.lastExpandable { background-image: url(images/treeview-black.gif); } |
57 | 57 | |
58 | 58 | .treeview-gray li { background-image: url(images/treeview-gray-line.gif); } |
59 | | -.treeview-gray .hitarea, .treeview-gray li.lastCollapsable, .treeview-gray li.lastExpandable { background-image: url(images/treeview-gray.gif); } |
| 59 | +.treeview-gray .hitarea, .treeview-gray li.lastCollapsable, .treeview-gray li.lastExpandable { background-image: url(images/treeview-gray.gif); } |
60 | 60 | |
61 | 61 | .treeview-famfamfam li { background-image: url(images/treeview-famfamfam-line.gif); } |
62 | | -.treeview-famfamfam .hitarea, .treeview-famfamfam li.lastCollapsable, .treeview-famfamfam li.lastExpandable { background-image: url(images/treeview-famfamfam.gif); } |
| 62 | +.treeview-famfamfam .hitarea, .treeview-famfamfam li.lastCollapsable, .treeview-famfamfam li.lastExpandable { background-image: url(images/treeview-famfamfam.gif); } |
63 | 63 | |
64 | 64 | .treeview .placeholder { |
65 | 65 | background: url(images/ajax-loader.gif) 0 0 no-repeat; |
Index: trunk/extensions/SelectCategory/jquery.treeview.js |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | /* |
3 | 3 | * Treeview 1.4.1 - jQuery plugin to hide and show branches of a tree |
4 | | - * |
| 4 | + * |
5 | 5 | * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ |
6 | 6 | * http://docs.jquery.com/Plugins/Treeview |
7 | 7 | * |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | } else { |
52 | 52 | this.hide(); |
53 | 53 | if (callback) |
54 | | - this.each(callback); |
| 54 | + this.each(callback); |
55 | 55 | } |
56 | 56 | }, |
57 | 57 | prepareBranches: function(settings) { |
— | — | @@ -70,18 +70,18 @@ |
71 | 71 | if ( this == event.target ) |
72 | 72 | toggler.apply($j(this).next()); |
73 | 73 | }).add( $j("a", this) ).hoverClass(); |
74 | | - |
| 74 | + |
75 | 75 | if (!settings.prerendered) { |
76 | 76 | // handle closed ones first |
77 | 77 | this.filter(":has(>ul:hidden)") |
78 | 78 | .addClass(CLASSES.expandable) |
79 | 79 | .replaceClass(CLASSES.last, CLASSES.lastExpandable); |
80 | | - |
| 80 | + |
81 | 81 | // handle open ones |
82 | 82 | this.not(":has(>ul:hidden)") |
83 | 83 | .addClass(CLASSES.collapsable) |
84 | 84 | .replaceClass(CLASSES.last, CLASSES.lastCollapsable); |
85 | | - |
| 85 | + |
86 | 86 | // create hitarea if not present |
87 | 87 | var hitarea = this.find("div." + CLASSES.hitarea); |
88 | 88 | if (!hitarea.length) |
— | — | @@ -94,23 +94,23 @@ |
95 | 95 | $j(this).addClass( classes ); |
96 | 96 | }) |
97 | 97 | } |
98 | | - |
| 98 | + |
99 | 99 | // apply event to hitarea |
100 | 100 | this.find("div." + CLASSES.hitarea).click( toggler ); |
101 | 101 | }, |
102 | 102 | treeview: function(settings) { |
103 | | - |
| 103 | + |
104 | 104 | settings = $j.extend({ |
105 | 105 | cookieId: "treeview" |
106 | 106 | }, settings); |
107 | | - |
| 107 | + |
108 | 108 | if ( settings.toggle ) { |
109 | 109 | var callback = settings.toggle; |
110 | 110 | settings.toggle = function() { |
111 | 111 | return callback.apply($j(this).parent()[0], arguments); |
112 | 112 | }; |
113 | 113 | } |
114 | | - |
| 114 | + |
115 | 115 | // factory for treecontroller |
116 | 116 | function treeController(tree, control) { |
117 | 117 | // factory for click handlers |
— | — | @@ -130,9 +130,9 @@ |
131 | 131 | // click on second to expand tree |
132 | 132 | $j("a:eq(1)", control).click( handler(CLASSES.expandable) ); |
133 | 133 | // click on third to toggle tree |
134 | | - $j("a:eq(2)", control).click( handler() ); |
| 134 | + $j("a:eq(2)", control).click( handler() ); |
135 | 135 | } |
136 | | - |
| 136 | + |
137 | 137 | // handle toggle event |
138 | 138 | function toggler() { |
139 | 139 | $j(this) |
— | — | @@ -164,7 +164,7 @@ |
165 | 165 | } |
166 | 166 | } |
167 | 167 | this.data("toggler", toggler); |
168 | | - |
| 168 | + |
169 | 169 | function serialize() { |
170 | 170 | function binary(arg) { |
171 | 171 | return arg ? 1 : 0; |
— | — | @@ -175,7 +175,7 @@ |
176 | 176 | }); |
177 | 177 | $j.cookie(settings.cookieId, data.join(""), settings.cookieOptions ); |
178 | 178 | } |
179 | | - |
| 179 | + |
180 | 180 | function deserialize() { |
181 | 181 | var stored = $j.cookie(settings.cookieId); |
182 | 182 | if ( stored ) { |
— | — | @@ -185,13 +185,13 @@ |
186 | 186 | }); |
187 | 187 | } |
188 | 188 | } |
189 | | - |
| 189 | + |
190 | 190 | // add treeview class to activate styles |
191 | 191 | this.addClass("treeview"); |
192 | | - |
| 192 | + |
193 | 193 | // prepare branches and find all tree items with child lists |
194 | 194 | var branches = this.find("li").prepareBranches(settings); |
195 | | - |
| 195 | + |
196 | 196 | switch(settings.persist) { |
197 | 197 | case "cookie": |
198 | 198 | var toggleCallback = settings.toggle; |
— | — | @@ -222,19 +222,19 @@ |
223 | 223 | } |
224 | 224 | break; |
225 | 225 | } |
226 | | - |
| 226 | + |
227 | 227 | branches.applyClasses(settings, toggler); |
228 | | - |
| 228 | + |
229 | 229 | // if control option is set, create the treecontroller and show it |
230 | 230 | if ( settings.control ) { |
231 | 231 | treeController(this, settings.control); |
232 | 232 | $j(settings.control).show(); |
233 | 233 | } |
234 | | - |
| 234 | + |
235 | 235 | return this; |
236 | 236 | } |
237 | 237 | }); |
238 | | - |
| 238 | + |
239 | 239 | // classes used by the plugin |
240 | 240 | // need to be styled via external stylesheet, see first example |
241 | 241 | $j.treeview = {}; |
— | — | @@ -252,5 +252,5 @@ |
253 | 253 | last: "last", |
254 | 254 | hitarea: "hitarea" |
255 | 255 | }); |
256 | | - |
257 | | -})(jQuery); |
\ No newline at end of file |
| 256 | + |
| 257 | +})(jQuery); |
Index: trunk/extensions/SelectCategory/SelectCategoryFunctions.php |
— | — | @@ -22,100 +22,100 @@ |
23 | 23 | |
24 | 24 | # check if we should do anything or sleep |
25 | 25 | if ( fnSelectCategoryCheckConditions( $m_isUpload, $m_pageObj ) ) { |
26 | | - # Register CSS file for our select box: |
27 | | - global $wgOut, $wgScriptPath, $wgUser, $wgTitle; |
28 | | - global $wgSelectCategoryMaxLevel; |
29 | | - |
30 | | - $wgOut->addLink( |
31 | | - array( |
32 | | - 'rel' => 'stylesheet', |
33 | | - 'type' => 'text/css', |
34 | | - 'href' => $wgScriptPath.'/extensions/SelectCategory/SelectCategory.css' |
35 | | - ) |
36 | | - ); |
37 | | - $wgOut->addLink( |
38 | | - array( |
39 | | - 'rel' => 'stylesheet', |
40 | | - 'type' => 'text/css', |
41 | | - 'href' => $wgScriptPath.'/extensions/SelectCategory/jquery.treeview.css' |
42 | | - ) |
43 | | - ); |
44 | | - $wgOut->addScript( '<script src="'.$wgScriptPath.'/extensions/SelectCategory/jquery.treeview.js" type="text/javascript"></script>' ); |
45 | | - $wgOut->addScript( '<script src="'.$wgScriptPath.'/extensions/SelectCategory/SelectCategory.js" type="text/javascript"></script>' ); |
46 | | - |
47 | | - $m_skin =& $wgUser->getSkin(); |
48 | | - |
49 | | - # Get all categories from wiki: |
50 | | - $m_allCats = fnSelectCategoryGetAllCategories(); |
51 | | - # Load system messages: |
52 | | - wfLoadExtensionMessages( 'SelectCategory' ); |
53 | | - # Get the right member variables, depending on if we're on an upload form or not: |
54 | | - if( !$m_isUpload ) { |
55 | | - # Extract all categorylinks from page: |
56 | | - $m_pageCats = fnSelectCategoryGetPageCategories( $m_pageObj ); |
| 26 | + # Register CSS file for our select box: |
| 27 | + global $wgOut, $wgScriptPath, $wgUser, $wgTitle; |
| 28 | + global $wgSelectCategoryMaxLevel; |
57 | 29 | |
58 | | - # Never ever use editFormTextTop here as it resides outside the <form> so we will never get contents |
59 | | - $m_place = 'editFormTextAfterWarn'; |
60 | | - # Print the localised title for the select box: |
61 | | - $m_textBefore = '<b>'. wfMsg( 'selectcategory-title' ) . '</b>:'; |
62 | | - } else { |
63 | | - # No need to get categories: |
64 | | - $m_pageCats = array(); |
| 30 | + $wgOut->addLink( |
| 31 | + array( |
| 32 | + 'rel' => 'stylesheet', |
| 33 | + 'type' => 'text/css', |
| 34 | + 'href' => $wgScriptPath.'/extensions/SelectCategory/SelectCategory.css' |
| 35 | + ) |
| 36 | + ); |
| 37 | + $wgOut->addLink( |
| 38 | + array( |
| 39 | + 'rel' => 'stylesheet', |
| 40 | + 'type' => 'text/css', |
| 41 | + 'href' => $wgScriptPath.'/extensions/SelectCategory/jquery.treeview.css' |
| 42 | + ) |
| 43 | + ); |
| 44 | + $wgOut->addScript( '<script src="'.$wgScriptPath.'/extensions/SelectCategory/jquery.treeview.js" type="text/javascript"></script>' ); |
| 45 | + $wgOut->addScript( '<script src="'.$wgScriptPath.'/extensions/SelectCategory/SelectCategory.js" type="text/javascript"></script>' ); |
65 | 46 | |
66 | | - # Place output at the right place: |
67 | | - $m_place = 'uploadFormTextAfterSummary'; |
68 | | - # Print the part of the table including the localised title for the select box: |
69 | | - $m_textBefore = "\n</td></tr><tr><td align='right'><label for='wpSelectCategory'>" . wfMsg( 'selectcategory-title' ) .":</label></td><td align='left'>"; |
70 | | - } |
71 | | - # Introduce the output: |
72 | | - $m_pageObj->$m_place .= "<!-- SelectCategory begin -->\n"; |
73 | | - # Print the select box: |
74 | | - $m_pageObj->$m_place .= "\n$m_textBefore"; |
| 47 | + $m_skin =& $wgUser->getSkin(); |
75 | 48 | |
76 | | - # Begin list output, use <div> to enable custom formatting |
77 | | - $m_level = 0; |
78 | | - $m_pageObj->$m_place .= '<ul id="SelectCategoryList">'; |
79 | | - foreach( $m_allCats as $m_cat => $m_depth ) { |
80 | | - $checked = ''; |
81 | | - # See if the category was already added, so check it |
82 | | - if( isset( $m_pageCats[$m_cat] ) ) { |
83 | | - $checked = 'checked="checked"'; |
84 | | - } |
85 | | - # Clean HTML Output: |
86 | | - $category = htmlspecialchars( $m_cat ); |
| 49 | + # Get all categories from wiki: |
| 50 | + $m_allCats = fnSelectCategoryGetAllCategories(); |
| 51 | + # Load system messages: |
| 52 | + wfLoadExtensionMessages( 'SelectCategory' ); |
| 53 | + # Get the right member variables, depending on if we're on an upload form or not: |
| 54 | + if( !$m_isUpload ) { |
| 55 | + # Extract all categorylinks from page: |
| 56 | + $m_pageCats = fnSelectCategoryGetPageCategories( $m_pageObj ); |
87 | 57 | |
88 | | - # iterate through levels and adjust divs accordingly |
89 | | - while( $m_level < $m_depth ) { |
90 | | - # Collapse subcategories after reaching the configured MaxLevel |
91 | | - if( $m_level >= ( $wgSelectCategoryMaxLevel - 1 ) ) { |
92 | | - $m_class = 'display:none;'; |
93 | | - } else { |
94 | | - $m_class = 'display:block;'; |
95 | | - } |
96 | | - $m_pageObj->$m_place .= '<ul style="'.$m_class.'">'."\n"; |
97 | | - $m_level++; |
98 | | - } |
99 | | - if( $m_level == $m_depth ) $m_pageObj->$m_place .= '</li>'."\n"; |
100 | | - while( $m_level > $m_depth ) { |
101 | | - $m_pageObj->$m_place .= '</ul></li>'."\n"; |
102 | | - $m_level--; |
103 | | - } |
104 | | - # Clean names for text output |
105 | | - $title = str_replace( '_', ' ', $category ); |
106 | | - $m_title = $wgTitle->newFromText( $category, NS_CATEGORY ); |
107 | | - # Output the actual checkboxes, indented |
108 | | - $m_pageObj->$m_place .= '<li><input type="checkbox" name="SelectCategoryList[]" value="'.$category.'" class="checkbox" '.$checked.' />'.$m_skin->link( $m_title, $title )."\n"; |
109 | | - # set id for next level |
110 | | - $m_level_id = 'sc_'.$m_cat; |
111 | | - } # End walking through cats (foreach) |
112 | | - # End of list output - close all remaining divs |
113 | | - while( $m_level > -1 ) { |
114 | | - $m_pageObj->$m_place .= '</li></ul>'."\n"; |
115 | | - $m_level--; |
116 | | - } |
| 58 | + # Never ever use editFormTextTop here as it resides outside the <form> so we will never get contents |
| 59 | + $m_place = 'editFormTextAfterWarn'; |
| 60 | + # Print the localised title for the select box: |
| 61 | + $m_textBefore = '<b>'. wfMsg( 'selectcategory-title' ) . '</b>:'; |
| 62 | + } else { |
| 63 | + # No need to get categories: |
| 64 | + $m_pageCats = array(); |
117 | 65 | |
118 | | - # Print localised help string: |
119 | | - $m_pageObj->$m_place .= "<!-- SelectCategory end -->\n"; |
| 66 | + # Place output at the right place: |
| 67 | + $m_place = 'uploadFormTextAfterSummary'; |
| 68 | + # Print the part of the table including the localised title for the select box: |
| 69 | + $m_textBefore = "\n</td></tr><tr><td align='right'><label for='wpSelectCategory'>" . wfMsg( 'selectcategory-title' ) .":</label></td><td align='left'>"; |
| 70 | + } |
| 71 | + # Introduce the output: |
| 72 | + $m_pageObj->$m_place .= "<!-- SelectCategory begin -->\n"; |
| 73 | + # Print the select box: |
| 74 | + $m_pageObj->$m_place .= "\n$m_textBefore"; |
| 75 | + |
| 76 | + # Begin list output, use <div> to enable custom formatting |
| 77 | + $m_level = 0; |
| 78 | + $m_pageObj->$m_place .= '<ul id="SelectCategoryList">'; |
| 79 | + foreach( $m_allCats as $m_cat => $m_depth ) { |
| 80 | + $checked = ''; |
| 81 | + # See if the category was already added, so check it |
| 82 | + if( isset( $m_pageCats[$m_cat] ) ) { |
| 83 | + $checked = 'checked="checked"'; |
| 84 | + } |
| 85 | + # Clean HTML Output: |
| 86 | + $category = htmlspecialchars( $m_cat ); |
| 87 | + |
| 88 | + # iterate through levels and adjust divs accordingly |
| 89 | + while( $m_level < $m_depth ) { |
| 90 | + # Collapse subcategories after reaching the configured MaxLevel |
| 91 | + if( $m_level >= ( $wgSelectCategoryMaxLevel - 1 ) ) { |
| 92 | + $m_class = 'display:none;'; |
| 93 | + } else { |
| 94 | + $m_class = 'display:block;'; |
| 95 | + } |
| 96 | + $m_pageObj->$m_place .= '<ul style="'.$m_class.'">'."\n"; |
| 97 | + $m_level++; |
| 98 | + } |
| 99 | + if( $m_level == $m_depth ) $m_pageObj->$m_place .= '</li>'."\n"; |
| 100 | + while( $m_level > $m_depth ) { |
| 101 | + $m_pageObj->$m_place .= '</ul></li>'."\n"; |
| 102 | + $m_level--; |
| 103 | + } |
| 104 | + # Clean names for text output |
| 105 | + $title = str_replace( '_', ' ', $category ); |
| 106 | + $m_title = $wgTitle->newFromText( $category, NS_CATEGORY ); |
| 107 | + # Output the actual checkboxes, indented |
| 108 | + $m_pageObj->$m_place .= '<li><input type="checkbox" name="SelectCategoryList[]" value="'.$category.'" class="checkbox" '.$checked.' />'.$m_skin->link( $m_title, $title )."\n"; |
| 109 | + # set id for next level |
| 110 | + $m_level_id = 'sc_'.$m_cat; |
| 111 | + } # End walking through cats (foreach) |
| 112 | + # End of list output - close all remaining divs |
| 113 | + while( $m_level > -1 ) { |
| 114 | + $m_pageObj->$m_place .= '</li></ul>'."\n"; |
| 115 | + $m_level--; |
| 116 | + } |
| 117 | + |
| 118 | + # Print localised help string: |
| 119 | + $m_pageObj->$m_place .= "<!-- SelectCategory end -->\n"; |
120 | 120 | } |
121 | 121 | |
122 | 122 | # Return true to let the rest work: |
— | — | @@ -130,32 +130,32 @@ |
131 | 131 | # check if we should do anything or sleep |
132 | 132 | if ( fnSelectCategoryCheckConditions( $m_isUpload, $m_pageObj ) ) { |
133 | 133 | |
134 | | - # Get localised namespace string: |
135 | | - $m_catString = $wgContLang->getNsText( NS_CATEGORY ); |
| 134 | + # Get localised namespace string: |
| 135 | + $m_catString = $wgContLang->getNsText( NS_CATEGORY ); |
136 | 136 | |
137 | | - # default sort key is page name with stripped namespace name, |
138 | | - # otherwise sorting is ugly. |
139 | | - if( $wgTitle->getNamespace() == NS_MAIN ) { |
140 | | - $default_sortkey = ""; |
141 | | - } else { |
142 | | - $default_sortkey = "|{{PAGENAME}}"; |
143 | | - } |
| 137 | + # default sort key is page name with stripped namespace name, |
| 138 | + # otherwise sorting is ugly. |
| 139 | + if( $wgTitle->getNamespace() == NS_MAIN ) { |
| 140 | + $default_sortkey = ""; |
| 141 | + } else { |
| 142 | + $default_sortkey = "|{{PAGENAME}}"; |
| 143 | + } |
144 | 144 | |
145 | | - # Get some distance from the rest of the content: |
146 | | - $m_text = "\n"; |
| 145 | + # Get some distance from the rest of the content: |
| 146 | + $m_text = "\n"; |
147 | 147 | |
148 | | - # Iterate through all selected category entries: |
149 | | - if (array_key_exists('SelectCategoryList', $_POST)) { |
150 | | - foreach( $_POST['SelectCategoryList'] as $m_cat ) { |
151 | | - $m_text .= "\n[[$m_catString:$m_cat$default_sortkey]]"; |
152 | | - } |
153 | | - } |
154 | | - # If it is an upload we have to call a different method: |
155 | | - if ( $m_isUpload ) { |
156 | | - $m_pageObj->mUploadDescription .= $m_text; |
157 | | - } else{ |
158 | | - $m_pageObj->textbox1 .= $m_text; |
159 | | - } |
| 148 | + # Iterate through all selected category entries: |
| 149 | + if (array_key_exists('SelectCategoryList', $_POST)) { |
| 150 | + foreach( $_POST['SelectCategoryList'] as $m_cat ) { |
| 151 | + $m_text .= "\n[[$m_catString:$m_cat$default_sortkey]]"; |
| 152 | + } |
| 153 | + } |
| 154 | + # If it is an upload we have to call a different method: |
| 155 | + if ( $m_isUpload ) { |
| 156 | + $m_pageObj->mUploadDescription .= $m_text; |
| 157 | + } else{ |
| 158 | + $m_pageObj->textbox1 .= $m_text; |
| 159 | + } |
160 | 160 | } |
161 | 161 | |
162 | 162 | # Return to the let MediaWiki do the rest of the work: |
— | — | @@ -175,33 +175,33 @@ |
176 | 176 | # Get current namespace (save duplicate call of method): |
177 | 177 | $m_namespace = $wgTitle->getNamespace(); |
178 | 178 | if( $m_namespace >= 0 && $wgSelectCategoryRoot[$m_namespace] ) { |
179 | | - # Include root and step into the recursion: |
180 | | - $m_allCats = array_merge( array( $wgSelectCategoryRoot[$m_namespace] => 0 ), fnSelectCategoryGetChildren( $wgSelectCategoryRoot[$m_namespace] ) ); |
| 179 | + # Include root and step into the recursion: |
| 180 | + $m_allCats = array_merge( array( $wgSelectCategoryRoot[$m_namespace] => 0 ), fnSelectCategoryGetChildren( $wgSelectCategoryRoot[$m_namespace] ) ); |
181 | 181 | } else { |
182 | | - # Initialize return value: |
183 | | - $m_allCats = array(); |
| 182 | + # Initialize return value: |
| 183 | + $m_allCats = array(); |
184 | 184 | |
185 | | - # Get a database object: |
186 | | - $m_dbObj = wfGetDB( DB_SLAVE ); |
187 | | - # Get table names to access them in SQL query: |
188 | | - $m_tblCatLink = $m_dbObj->tableName( 'categorylinks' ); |
189 | | - $m_tblPage = $m_dbObj->tableName( 'page' ); |
| 185 | + # Get a database object: |
| 186 | + $m_dbObj = wfGetDB( DB_SLAVE ); |
| 187 | + # Get table names to access them in SQL query: |
| 188 | + $m_tblCatLink = $m_dbObj->tableName( 'categorylinks' ); |
| 189 | + $m_tblPage = $m_dbObj->tableName( 'page' ); |
190 | 190 | |
191 | | - # Automagically detect root categories: |
192 | | - $m_sql = " SELECT tmpSelectCat1.cl_to AS title |
193 | | - FROM $m_tblCatLink AS tmpSelectCat1 |
194 | | - LEFT JOIN $m_tblPage AS tmpSelectCatPage ON (tmpSelectCat1.cl_to = tmpSelectCatPage.page_title AND tmpSelectCatPage.page_namespace = 14) |
195 | | - LEFT JOIN $m_tblCatLink AS tmpSelectCat2 ON tmpSelectCatPage.page_id = tmpSelectCat2.cl_from |
196 | | - WHERE tmpSelectCat2.cl_from IS NULL GROUP BY tmpSelectCat1.cl_to"; |
197 | | - # Run the query: |
198 | | - $m_res = $m_dbObj->query( $m_sql, __METHOD__ ); |
199 | | - # Process the resulting rows: |
200 | | - while ( $m_row = $m_dbObj->fetchRow( $m_res ) ) { |
201 | | - $m_allCats += array( $m_row['title'] => 0 ); |
202 | | - $m_allCats += fnSelectCategoryGetChildren( $m_row['title'] ); |
203 | | - } |
204 | | - # Free result: |
205 | | - $m_dbObj->freeResult( $m_res ); |
| 191 | + # Automagically detect root categories: |
| 192 | + $m_sql = " SELECT tmpSelectCat1.cl_to AS title |
| 193 | + FROM $m_tblCatLink AS tmpSelectCat1 |
| 194 | + LEFT JOIN $m_tblPage AS tmpSelectCatPage ON (tmpSelectCat1.cl_to = tmpSelectCatPage.page_title AND tmpSelectCatPage.page_namespace = 14) |
| 195 | + LEFT JOIN $m_tblCatLink AS tmpSelectCat2 ON tmpSelectCatPage.page_id = tmpSelectCat2.cl_from |
| 196 | + WHERE tmpSelectCat2.cl_from IS NULL GROUP BY tmpSelectCat1.cl_to"; |
| 197 | + # Run the query: |
| 198 | + $m_res = $m_dbObj->query( $m_sql, __METHOD__ ); |
| 199 | + # Process the resulting rows: |
| 200 | + while ( $m_row = $m_dbObj->fetchRow( $m_res ) ) { |
| 201 | + $m_allCats += array( $m_row['title'] => 0 ); |
| 202 | + $m_allCats += fnSelectCategoryGetChildren( $m_row['title'] ); |
| 203 | + } |
| 204 | + # Free result: |
| 205 | + $m_dbObj->freeResult( $m_res ); |
206 | 206 | } |
207 | 207 | |
208 | 208 | # Afterwards return the array to the caller: |
— | — | @@ -220,24 +220,24 @@ |
221 | 221 | |
222 | 222 | # The normal query to get all children of a given root category: |
223 | 223 | $m_sql = ' |
224 | | - SELECT tmpSelectCatPage.page_title AS title |
225 | | - FROM '.$m_tblCatLink.' AS tmpSelectCat |
226 | | - LEFT JOIN '.$m_tblPage.' AS tmpSelectCatPage |
227 | | - ON tmpSelectCat.cl_from = tmpSelectCatPage.page_id |
228 | | - WHERE tmpSelectCat.cl_to LIKE '.$m_dbObj->addQuotes( $m_root ).' |
229 | | - AND tmpSelectCatPage.page_namespace = 14 |
230 | | - ORDER BY tmpSelectCatPage.page_title ASC;'; |
| 224 | + SELECT tmpSelectCatPage.page_title AS title |
| 225 | + FROM '.$m_tblCatLink.' AS tmpSelectCat |
| 226 | + LEFT JOIN '.$m_tblPage.' AS tmpSelectCatPage |
| 227 | + ON tmpSelectCat.cl_from = tmpSelectCatPage.page_id |
| 228 | + WHERE tmpSelectCat.cl_to LIKE '.$m_dbObj->addQuotes( $m_root ).' |
| 229 | + AND tmpSelectCatPage.page_namespace = 14 |
| 230 | + ORDER BY tmpSelectCatPage.page_title ASC;'; |
231 | 231 | # Run the query: |
232 | 232 | $m_res = $m_dbObj->query( $m_sql, __METHOD__ ); |
233 | 233 | # Process the resulting rows: |
234 | 234 | while ( $m_row = $m_dbObj->fetchRow( $m_res ) ) { |
235 | | - # Survive category link loops: |
236 | | - if( $m_root == $m_row['title'] ) { |
237 | | - continue; |
238 | | - } |
239 | | - # Add current entry to array: |
240 | | - $m_allCats += array( $m_row['title'] => $m_depth ); |
241 | | - $m_allCats += fnSelectCategoryGetChildren( $m_row['title'], $m_depth + 1 ); |
| 235 | + # Survive category link loops: |
| 236 | + if( $m_root == $m_row['title'] ) { |
| 237 | + continue; |
| 238 | + } |
| 239 | + # Add current entry to array: |
| 240 | + $m_allCats += array( $m_row['title'] => $m_depth ); |
| 241 | + $m_allCats += fnSelectCategoryGetChildren( $m_row['title'], $m_depth + 1 ); |
242 | 242 | } |
243 | 243 | # Free result: |
244 | 244 | $m_dbObj->freeResult( $m_res ); |
— | — | @@ -251,13 +251,13 @@ |
252 | 252 | function fnSelectCategoryGetPageCategories( $m_pageObj ) { |
253 | 253 | |
254 | 254 | if (array_key_exists('SelectCategoryList', $_POST)) { |
255 | | - # We have already extracted the categories, return them instead |
256 | | - # of extracting zero categories from the page text. |
257 | | - $m_catLinks = array(); |
258 | | - foreach( $_POST['SelectCategoryList'] as $m_cat ) { |
259 | | - $m_catLinks[ $m_cat ] = true; |
260 | | - } |
261 | | - return $m_catLinks; |
| 255 | + # We have already extracted the categories, return them instead |
| 256 | + # of extracting zero categories from the page text. |
| 257 | + $m_catLinks = array(); |
| 258 | + foreach( $_POST['SelectCategoryList'] as $m_cat ) { |
| 259 | + $m_catLinks[ $m_cat ] = true; |
| 260 | + } |
| 261 | + return $m_catLinks; |
262 | 262 | } |
263 | 263 | |
264 | 264 | global $wgContLang; |
— | — | @@ -276,12 +276,12 @@ |
277 | 277 | |
278 | 278 | # Check linewise for category links: |
279 | 279 | foreach( explode( "\n", $m_pageText ) as $m_textLine ) { |
280 | | - # Filter line through pattern and store the result: |
281 | | - $m_cleanText .= preg_replace( "/{$m_pattern}/i", "", $m_textLine ) . "\n"; |
282 | | - # Check if we have found a category, else proceed with next line: |
283 | | - if( !preg_match( "/{$m_pattern}/i", $m_textLine) ) continue; |
284 | | - # Get the category link from the original text and store it in our list: |
285 | | - $m_catLinks[ str_replace( ' ', '_', preg_replace( "/.*{$m_pattern}/i", $m_replace, $m_textLine ) ) ] = true; |
| 280 | + # Filter line through pattern and store the result: |
| 281 | + $m_cleanText .= preg_replace( "/{$m_pattern}/i", "", $m_textLine ) . "\n"; |
| 282 | + # Check if we have found a category, else proceed with next line: |
| 283 | + if( !preg_match( "/{$m_pattern}/i", $m_textLine) ) continue; |
| 284 | + # Get the category link from the original text and store it in our list: |
| 285 | + $m_catLinks[ str_replace( ' ', '_', preg_replace( "/.*{$m_pattern}/i", $m_replace, $m_textLine ) ) ] = true; |
286 | 286 | } |
287 | 287 | # Place the cleaned text into the text box: |
288 | 288 | $m_pageObj->textbox1 = trim( $m_cleanText ); |
— | — | @@ -302,23 +302,23 @@ |
303 | 303 | # implication in PHP) but not if we do a sectionedit: |
304 | 304 | |
305 | 305 | if ($m_isUpload == true) { |
306 | | - return true; |
| 306 | + return true; |
307 | 307 | } |
308 | 308 | |
309 | 309 | $ns = $wgTitle->getNamespace(); |
310 | 310 | if( array_key_exists( $ns, $wgSelectCategoryNamespaces ) ) { |
311 | | - $enabledForNamespace = $wgSelectCategoryNamespaces[$ns]; |
| 311 | + $enabledForNamespace = $wgSelectCategoryNamespaces[$ns]; |
312 | 312 | } else { |
313 | | - $enabledForNamespace = false; |
| 313 | + $enabledForNamespace = false; |
314 | 314 | } |
315 | 315 | |
316 | 316 | # Check if page is subpage once to save method calls below: |
317 | 317 | $m_isSubpage = $wgTitle->isSubpage(); |
318 | 318 | |
319 | 319 | if ($enabledForNamespace |
320 | | - && (!$m_isSubpage |
321 | | - || $m_isSubpage && $wgSelectCategoryEnableSubpage) |
322 | | - && $m_pageObj->section == false) { |
323 | | - return true; |
| 320 | + && (!$m_isSubpage |
| 321 | + || $m_isSubpage && $wgSelectCategoryEnableSubpage) |
| 322 | + && $m_pageObj->section == false) { |
| 323 | + return true; |
324 | 324 | } |
325 | 325 | } |