Index: trunk/extensions/EducationProgram/compat/SpecialCachedPage.php |
— | — | @@ -2,15 +2,11 @@ |
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Abstract special page class with scaffolding for caching the HTML output. |
| 6 | + * This copy is kept for compatibility with MW < 1.20. |
| 7 | + * As of 1.20, this class can be found at includes/specials/SpecialCachedPage.php |
6 | 8 | * |
7 | | - * To enable the caching functionality, the cacheExpiry field should be set |
8 | | - * in the constructor. |
| 9 | + * TODO: uncomment when done w/ dev (double declaration makes PhpStorm mad :) |
9 | 10 | * |
10 | | - * To add HTML that should be cached, use addCachedHTML like this: |
11 | | - * $this->addCachedHTML( array( $this, 'displayCachedContent' ) ); |
12 | | - * |
13 | | - * After adding the last HTML that should be cached, call $this->saveCache(); |
14 | | - * |
15 | 11 | * @since 0.1 |
16 | 12 | * |
17 | 13 | * @file SpecialCachedPage.php |
— | — | @@ -19,241 +15,241 @@ |
20 | 16 | * @licence GNU GPL v3 or later |
21 | 17 | * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
22 | 18 | */ |
23 | | -abstract class SpecialCachedPage extends SpecialPage { |
24 | | - |
25 | | - /** |
26 | | - * The time to live for the cache, in seconds or a unix timestamp indicating the point of expiry. |
27 | | - * |
28 | | - * @since 0.1 |
29 | | - * @var integer|null |
30 | | - */ |
31 | | - protected $cacheExpiry = null; |
32 | | - |
33 | | - /** |
34 | | - * List of HTML chunks to be cached (if !hasCached) or that where cashed (of hasCached). |
35 | | - * If no cached already, then the newly computed chunks are added here, |
36 | | - * if it as cached already, chunks are removed from this list as they are needed. |
37 | | - * |
38 | | - * @since 0.1 |
39 | | - * @var array |
40 | | - */ |
41 | | - protected $cachedChunks; |
42 | | - |
43 | | - /** |
44 | | - * Indicates if the to be cached content was already cached. |
45 | | - * Null if this information is not available yet. |
46 | | - * |
47 | | - * @since 0.1 |
48 | | - * @var boolean|null |
49 | | - */ |
50 | | - protected $hasCached = null; |
51 | | - |
52 | | - /** |
53 | | - * Main method. |
54 | | - * |
55 | | - * @since 0.1 |
56 | | - * |
57 | | - * @param string|null $subPage |
58 | | - */ |
59 | | - public function execute( $subPage ) { |
60 | | - if ( $this->getRequest()->getText( 'action' ) === 'purge' ) { |
61 | | - $this->hasCached = false; |
62 | | - } |
63 | | - |
64 | | - if ( !is_null( $this->cacheExpiry ) ) { |
65 | | - $this->initCaching(); |
66 | | - |
67 | | - if ( $this->hasCached === true ) { |
68 | | - $this->getOutput()->setSubtitle( $this->getCachedNotice( $subPage ) ); |
69 | | - } |
70 | | - } |
71 | | - } |
72 | | - |
73 | | - /** |
74 | | - * Returns a message that notifies the user he/she is looking at |
75 | | - * a cached version of the page, including a refresh link. |
76 | | - * |
77 | | - * @since 0.1 |
78 | | - * |
79 | | - * @param string|null $subPage |
80 | | - * |
81 | | - * @return string |
82 | | - */ |
83 | | - protected function getCachedNotice( $subPage ) { |
84 | | - $refreshArgs = $this->getRequest()->getQueryValues(); |
85 | | - unset( $refreshArgs['title'] ); |
86 | | - $refreshArgs['action'] = 'purge'; |
87 | | - |
88 | | - $refreshLink = Linker::link( |
89 | | - $this->getTitle( $subPage ), |
90 | | - $this->msg( 'cachedspecial-refresh-now' )->escaped(), |
91 | | - array(), |
92 | | - $refreshArgs |
93 | | - ); |
94 | | - |
95 | | - if ( $this->cacheExpiry < 86400 * 3650 ) { |
96 | | - $message = $this->msg( |
97 | | - 'cachedspecial-viewing-cached-ttl', |
98 | | - $this->getDurationText( $this->cacheExpiry ) |
99 | | - )->escaped(); |
100 | | - } |
101 | | - else { |
102 | | - $message = $this->msg( |
103 | | - 'cachedspecial-viewing-cached-ts' |
104 | | - )->escaped(); |
105 | | - } |
106 | | - |
107 | | - return $message . ' ' . $refreshLink; |
108 | | - } |
109 | | - |
110 | | - /** |
111 | | - * Returns a message with the time to live of the cache. |
112 | | - * Takes care of compatibility with MW < 1.20, in which Language::formatDuration was introduced. |
113 | | - * |
114 | | - * @since 0.1 |
115 | | - * |
116 | | - * @param integer $seconds |
117 | | - * @param array $chosenIntervals |
118 | | - * |
119 | | - * @return string |
120 | | - */ |
121 | | - protected function getDurationText( $seconds, array $chosenIntervals = array( 'years', 'days', 'hours', 'minutes', 'seconds' ) ) { |
122 | | - if ( method_exists( $this->getLanguage(), 'formatDuration' ) ) { |
123 | | - return $this->getLanguage()->formatDuration( $seconds, $chosenIntervals ); |
124 | | - } |
125 | | - else { |
126 | | - $intervals = array( |
127 | | - 'years' => 31557600, // 86400 * 365.25 |
128 | | - 'weeks' => 604800, |
129 | | - 'days' => 86400, |
130 | | - 'hours' => 3600, |
131 | | - 'minutes' => 60, |
132 | | - 'seconds' => 1, |
133 | | - ); |
134 | | - |
135 | | - if ( !empty( $chosenIntervals ) ) { |
136 | | - $intervals = array_intersect_key( $intervals, array_flip( $chosenIntervals ) ); |
137 | | - } |
138 | | - |
139 | | - $segments = array(); |
140 | | - |
141 | | - foreach ( $intervals as $name => $length ) { |
142 | | - $value = floor( $seconds / $length ); |
143 | | - |
144 | | - if ( $value > 0 || ( $name == 'seconds' && empty( $segments ) ) ) { |
145 | | - $seconds -= $value * $length; |
146 | | - $segments[] = $this->msg( 'duration-' . $name, array( $value ) )->escaped(); |
147 | | - } |
148 | | - } |
149 | | - |
150 | | - return $this->getLanguage()->listToText( $segments ); |
151 | | - } |
152 | | - } |
153 | | - |
154 | | - /** |
155 | | - * Initializes the caching if not already done so. |
156 | | - * Should be called before any of the caching functionality is used. |
157 | | - * |
158 | | - * @since 0.1 |
159 | | - */ |
160 | | - protected function initCaching() { |
161 | | - if ( is_null( $this->hasCached ) ) { |
162 | | - $cachedChunks = wfGetCache( CACHE_ANYTHING )->get( $this->getCacheKey() ); |
163 | | - |
164 | | - $this->hasCached = is_array( $cachedChunks ); |
165 | | - $this->cachedChunks = $this->hasCached ? $cachedChunks : array(); |
166 | | - } |
167 | | - } |
168 | | - |
169 | | - /** |
170 | | - * Add some HTML to be cached. |
171 | | - * This is done by providing a callback function that should |
172 | | - * return the HTML to be added. It will only be called if the |
173 | | - * item is not in the cache yet or when the cache has been invalidated. |
174 | | - * |
175 | | - * @since 0.1 |
176 | | - * |
177 | | - * @param {function} $callback |
178 | | - * @param array $args |
179 | | - * @param string|null $key |
180 | | - */ |
181 | | - public function addCachedHTML( $callback, $args = array(), $key = null ) { |
182 | | - $this->initCaching(); |
183 | | - |
184 | | - if ( $this->hasCached ) { |
185 | | - $html = ''; |
186 | | - |
187 | | - if ( is_null( $key ) ) { |
188 | | - $itemKey = array_keys( array_slice( $this->cachedChunks, 0, 1 ) ); |
189 | | - $itemKey = array_shift( $itemKey ); |
190 | | - |
191 | | - if ( !is_integer( $itemKey ) ) { |
192 | | - wfWarn( "Attempted to get item with non-numeric key while the next item in the queue has a key ($itemKey) in " . __METHOD__ ); |
193 | | - } |
194 | | - elseif ( is_null( $itemKey ) ) { |
195 | | - wfWarn( "Attempted to get an item while the queue is empty in " . __METHOD__ ); |
196 | | - } |
197 | | - else { |
198 | | - $html = array_shift( $this->cachedChunks ); |
199 | | - } |
200 | | - } |
201 | | - else { |
202 | | - if ( array_key_exists( $key, $this->cachedChunks ) ) { |
203 | | - $html = $this->cachedChunks[$key]; |
204 | | - unset( $this->cachedChunks[$key] ); |
205 | | - } |
206 | | - else { |
207 | | - wfWarn( "There is no item with key '$key' in this->cachedChunks in " . __METHOD__ ); |
208 | | - } |
209 | | - } |
210 | | - } |
211 | | - else { |
212 | | - $html = call_user_func_array( $callback, $args ); |
213 | | - |
214 | | - if ( is_null( $key ) ) { |
215 | | - $this->cachedChunks[] = $html; |
216 | | - } |
217 | | - else { |
218 | | - $this->cachedChunks[$key] = $html; |
219 | | - } |
220 | | - } |
221 | | - |
222 | | - $this->getOutput()->addHTML( $html ); |
223 | | - } |
224 | | - |
225 | | - /** |
226 | | - * Saves the HTML to the cache in case it got recomputed. |
227 | | - * Should be called after the last time anything is added via addCachedHTML. |
228 | | - * |
229 | | - * @since 0.1 |
230 | | - */ |
231 | | - public function saveCache() { |
232 | | - if ( $this->hasCached === false && !empty( $this->cachedChunks ) ) { |
233 | | - wfGetCache( CACHE_ANYTHING )->set( $this->getCacheKey(), $this->cachedChunks, $this->cacheExpiry ); |
234 | | - } |
235 | | - } |
236 | | - |
237 | | - /** |
238 | | - * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry.. |
239 | | - * |
240 | | - * @since 0.1 |
241 | | - * |
242 | | - * @param integer $cacheExpiry |
243 | | - */ |
244 | | - protected function setExpirey( $cacheExpiry ) { |
245 | | - $this->cacheExpiry = $cacheExpiry; |
246 | | - } |
247 | | - |
248 | | - /** |
249 | | - * Returns the cache key to use to cache this page's HTML output. |
250 | | - * Is constructed from the special page name and language code. |
251 | | - * |
252 | | - * @since 0.1 |
253 | | - * |
254 | | - * @return string |
255 | | - */ |
256 | | - protected function getCacheKey() { |
257 | | - return wfMemcKey( $this->mName, $this->getLanguage()->getCode() ); |
258 | | - } |
259 | | - |
260 | | -} |
| 19 | +//abstract class SpecialCachedPage extends SpecialPage { |
| 20 | +// |
| 21 | +// /** |
| 22 | +// * The time to live for the cache, in seconds or a unix timestamp indicating the point of expiry. |
| 23 | +// * |
| 24 | +// * @since 0.1 |
| 25 | +// * @var integer|null |
| 26 | +// */ |
| 27 | +// protected $cacheExpiry = null; |
| 28 | +// |
| 29 | +// /** |
| 30 | +// * List of HTML chunks to be cached (if !hasCached) or that where cashed (of hasCached). |
| 31 | +// * If no cached already, then the newly computed chunks are added here, |
| 32 | +// * if it as cached already, chunks are removed from this list as they are needed. |
| 33 | +// * |
| 34 | +// * @since 0.1 |
| 35 | +// * @var array |
| 36 | +// */ |
| 37 | +// protected $cachedChunks; |
| 38 | +// |
| 39 | +// /** |
| 40 | +// * Indicates if the to be cached content was already cached. |
| 41 | +// * Null if this information is not available yet. |
| 42 | +// * |
| 43 | +// * @since 0.1 |
| 44 | +// * @var boolean|null |
| 45 | +// */ |
| 46 | +// protected $hasCached = null; |
| 47 | +// |
| 48 | +// /** |
| 49 | +// * Main method. |
| 50 | +// * |
| 51 | +// * @since 0.1 |
| 52 | +// * |
| 53 | +// * @param string|null $subPage |
| 54 | +// */ |
| 55 | +// public function execute( $subPage ) { |
| 56 | +// if ( $this->getRequest()->getText( 'action' ) === 'purge' ) { |
| 57 | +// $this->hasCached = false; |
| 58 | +// } |
| 59 | +// |
| 60 | +// if ( !is_null( $this->cacheExpiry ) ) { |
| 61 | +// $this->initCaching(); |
| 62 | +// |
| 63 | +// if ( $this->hasCached === true ) { |
| 64 | +// $this->getOutput()->setSubtitle( $this->getCachedNotice( $subPage ) ); |
| 65 | +// } |
| 66 | +// } |
| 67 | +// } |
| 68 | +// |
| 69 | +// /** |
| 70 | +// * Returns a message that notifies the user he/she is looking at |
| 71 | +// * a cached version of the page, including a refresh link. |
| 72 | +// * |
| 73 | +// * @since 0.1 |
| 74 | +// * |
| 75 | +// * @param string|null $subPage |
| 76 | +// * |
| 77 | +// * @return string |
| 78 | +// */ |
| 79 | +// protected function getCachedNotice( $subPage ) { |
| 80 | +// $refreshArgs = $this->getRequest()->getQueryValues(); |
| 81 | +// unset( $refreshArgs['title'] ); |
| 82 | +// $refreshArgs['action'] = 'purge'; |
| 83 | +// |
| 84 | +// $refreshLink = Linker::link( |
| 85 | +// $this->getTitle( $subPage ), |
| 86 | +// $this->msg( 'cachedspecial-refresh-now' )->escaped(), |
| 87 | +// array(), |
| 88 | +// $refreshArgs |
| 89 | +// ); |
| 90 | +// |
| 91 | +// if ( $this->cacheExpiry < 86400 * 3650 ) { |
| 92 | +// $message = $this->msg( |
| 93 | +// 'cachedspecial-viewing-cached-ttl', |
| 94 | +// $this->getDurationText( $this->cacheExpiry ) |
| 95 | +// )->escaped(); |
| 96 | +// } |
| 97 | +// else { |
| 98 | +// $message = $this->msg( |
| 99 | +// 'cachedspecial-viewing-cached-ts' |
| 100 | +// )->escaped(); |
| 101 | +// } |
| 102 | +// |
| 103 | +// return $message . ' ' . $refreshLink; |
| 104 | +// } |
| 105 | +// |
| 106 | +// /** |
| 107 | +// * Returns a message with the time to live of the cache. |
| 108 | +// * Takes care of compatibility with MW < 1.20, in which Language::formatDuration was introduced. |
| 109 | +// * |
| 110 | +// * @since 0.1 |
| 111 | +// * |
| 112 | +// * @param integer $seconds |
| 113 | +// * @param array $chosenIntervals |
| 114 | +// * |
| 115 | +// * @return string |
| 116 | +// */ |
| 117 | +// protected function getDurationText( $seconds, array $chosenIntervals = array( 'years', 'days', 'hours', 'minutes', 'seconds' ) ) { |
| 118 | +// if ( method_exists( $this->getLanguage(), 'formatDuration' ) ) { |
| 119 | +// return $this->getLanguage()->formatDuration( $seconds, $chosenIntervals ); |
| 120 | +// } |
| 121 | +// else { |
| 122 | +// $intervals = array( |
| 123 | +// 'years' => 31557600, // 86400 * 365.25 |
| 124 | +// 'weeks' => 604800, |
| 125 | +// 'days' => 86400, |
| 126 | +// 'hours' => 3600, |
| 127 | +// 'minutes' => 60, |
| 128 | +// 'seconds' => 1, |
| 129 | +// ); |
| 130 | +// |
| 131 | +// if ( !empty( $chosenIntervals ) ) { |
| 132 | +// $intervals = array_intersect_key( $intervals, array_flip( $chosenIntervals ) ); |
| 133 | +// } |
| 134 | +// |
| 135 | +// $segments = array(); |
| 136 | +// |
| 137 | +// foreach ( $intervals as $name => $length ) { |
| 138 | +// $value = floor( $seconds / $length ); |
| 139 | +// |
| 140 | +// if ( $value > 0 || ( $name == 'seconds' && empty( $segments ) ) ) { |
| 141 | +// $seconds -= $value * $length; |
| 142 | +// $segments[] = $this->msg( 'duration-' . $name, array( $value ) )->escaped(); |
| 143 | +// } |
| 144 | +// } |
| 145 | +// |
| 146 | +// return $this->getLanguage()->listToText( $segments ); |
| 147 | +// } |
| 148 | +// } |
| 149 | +// |
| 150 | +// /** |
| 151 | +// * Initializes the caching if not already done so. |
| 152 | +// * Should be called before any of the caching functionality is used. |
| 153 | +// * |
| 154 | +// * @since 0.1 |
| 155 | +// */ |
| 156 | +// protected function initCaching() { |
| 157 | +// if ( is_null( $this->hasCached ) ) { |
| 158 | +// $cachedChunks = wfGetCache( CACHE_ANYTHING )->get( $this->getCacheKey() ); |
| 159 | +// |
| 160 | +// $this->hasCached = is_array( $cachedChunks ); |
| 161 | +// $this->cachedChunks = $this->hasCached ? $cachedChunks : array(); |
| 162 | +// } |
| 163 | +// } |
| 164 | +// |
| 165 | +// /** |
| 166 | +// * Add some HTML to be cached. |
| 167 | +// * This is done by providing a callback function that should |
| 168 | +// * return the HTML to be added. It will only be called if the |
| 169 | +// * item is not in the cache yet or when the cache has been invalidated. |
| 170 | +// * |
| 171 | +// * @since 0.1 |
| 172 | +// * |
| 173 | +// * @param {function} $callback |
| 174 | +// * @param array $args |
| 175 | +// * @param string|null $key |
| 176 | +// */ |
| 177 | +// public function addCachedHTML( $callback, $args = array(), $key = null ) { |
| 178 | +// $this->initCaching(); |
| 179 | +// |
| 180 | +// if ( $this->hasCached ) { |
| 181 | +// $html = ''; |
| 182 | +// |
| 183 | +// if ( is_null( $key ) ) { |
| 184 | +// $itemKey = array_keys( array_slice( $this->cachedChunks, 0, 1 ) ); |
| 185 | +// $itemKey = array_shift( $itemKey ); |
| 186 | +// |
| 187 | +// if ( !is_integer( $itemKey ) ) { |
| 188 | +// wfWarn( "Attempted to get item with non-numeric key while the next item in the queue has a key ($itemKey) in " . __METHOD__ ); |
| 189 | +// } |
| 190 | +// elseif ( is_null( $itemKey ) ) { |
| 191 | +// wfWarn( "Attempted to get an item while the queue is empty in " . __METHOD__ ); |
| 192 | +// } |
| 193 | +// else { |
| 194 | +// $html = array_shift( $this->cachedChunks ); |
| 195 | +// } |
| 196 | +// } |
| 197 | +// else { |
| 198 | +// if ( array_key_exists( $key, $this->cachedChunks ) ) { |
| 199 | +// $html = $this->cachedChunks[$key]; |
| 200 | +// unset( $this->cachedChunks[$key] ); |
| 201 | +// } |
| 202 | +// else { |
| 203 | +// wfWarn( "There is no item with key '$key' in this->cachedChunks in " . __METHOD__ ); |
| 204 | +// } |
| 205 | +// } |
| 206 | +// } |
| 207 | +// else { |
| 208 | +// $html = call_user_func_array( $callback, $args ); |
| 209 | +// |
| 210 | +// if ( is_null( $key ) ) { |
| 211 | +// $this->cachedChunks[] = $html; |
| 212 | +// } |
| 213 | +// else { |
| 214 | +// $this->cachedChunks[$key] = $html; |
| 215 | +// } |
| 216 | +// } |
| 217 | +// |
| 218 | +// $this->getOutput()->addHTML( $html ); |
| 219 | +// } |
| 220 | +// |
| 221 | +// /** |
| 222 | +// * Saves the HTML to the cache in case it got recomputed. |
| 223 | +// * Should be called after the last time anything is added via addCachedHTML. |
| 224 | +// * |
| 225 | +// * @since 0.1 |
| 226 | +// */ |
| 227 | +// public function saveCache() { |
| 228 | +// if ( $this->hasCached === false && !empty( $this->cachedChunks ) ) { |
| 229 | +// wfGetCache( CACHE_ANYTHING )->set( $this->getCacheKey(), $this->cachedChunks, $this->cacheExpiry ); |
| 230 | +// } |
| 231 | +// } |
| 232 | +// |
| 233 | +// /** |
| 234 | +// * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry.. |
| 235 | +// * |
| 236 | +// * @since 0.1 |
| 237 | +// * |
| 238 | +// * @param integer $cacheExpiry |
| 239 | +// */ |
| 240 | +// protected function setExpirey( $cacheExpiry ) { |
| 241 | +// $this->cacheExpiry = $cacheExpiry; |
| 242 | +// } |
| 243 | +// |
| 244 | +// /** |
| 245 | +// * Returns the cache key to use to cache this page's HTML output. |
| 246 | +// * Is constructed from the special page name and language code. |
| 247 | +// * |
| 248 | +// * @since 0.1 |
| 249 | +// * |
| 250 | +// * @return string |
| 251 | +// */ |
| 252 | +// protected function getCacheKey() { |
| 253 | +// return wfMemcKey( $this->mName, $this->getLanguage()->getCode() ); |
| 254 | +// } |
| 255 | +// |
| 256 | +//} |
Index: trunk/extensions/EducationProgram/specials/SpecialInstitutions.php |
— | — | @@ -31,16 +31,40 @@ |
32 | 32 | * @param string|null $subPage |
33 | 33 | */ |
34 | 34 | public function execute( $subPage ) { |
| 35 | + |
35 | 36 | parent::execute( $subPage ); |
36 | 37 | |
37 | 38 | if ( $this->subPage === '' ) { |
| 39 | + $this->startCache( 3600, $this->getUser()->isAnon() ); |
| 40 | + |
38 | 41 | $this->displayNavigation(); |
39 | | - EPOrg::displayAddNewControl( $this->getContext() ); |
40 | | - EPOrg::displayPager( $this->getContext() ); |
| 42 | + |
| 43 | + if ( $this->getUser()->isAllowed( 'ep-org' ) ) { |
| 44 | + $this->getOutput()->addModules( 'ep.addorg' ); |
| 45 | + $this->addCachedHTML( 'EPOrg::getAddNewControl', array( $this->getContext() ) ); |
| 46 | + } |
| 47 | + |
| 48 | + $this->addCachedHTML( 'EPOrg::getPager', array( $this->getContext() ) ); |
| 49 | + |
| 50 | + $this->saveCache(); |
41 | 51 | } |
42 | 52 | else { |
43 | 53 | $this->getOutput()->redirect( Title::newFromText( $this->subPage, EP_NS_INSTITUTION )->getLocalURL() ); |
44 | 54 | } |
45 | 55 | } |
46 | 56 | |
| 57 | + /** |
| 58 | + * @see SpecialCachedPage::getCacheKey |
| 59 | + * @return array |
| 60 | + */ |
| 61 | + protected function getCacheKey() { |
| 62 | + $values = $this->getRequest()->getValues(); |
| 63 | + |
| 64 | + if ( array_key_exists( 'action', $values ) && $values['action'] === 'purge' ) { |
| 65 | + unset( $values['action'] ); |
| 66 | + } |
| 67 | + |
| 68 | + return array_merge( $values, parent::getCacheKey() ); |
| 69 | + } |
| 70 | + |
47 | 71 | } |
Index: trunk/extensions/EducationProgram/specials/SpecialEPPage.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | * @return boolean |
56 | 56 | */ |
57 | 57 | public function execute( $subPage ) { |
58 | | - parent::execute( $subPage ); |
| 58 | + // parent::execute( $subPage ); |
59 | 59 | |
60 | 60 | $subPage = is_null( $subPage ) ? '' : $subPage; |
61 | 61 | $this->subPage = trim( str_replace( '_', ' ', $subPage ) ); |
Index: trunk/extensions/EducationProgram/specials/SpecialEducationProgram.php |
— | — | @@ -19,7 +19,6 @@ |
20 | 20 | * @since 0.1 |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | | - $this->cacheExpiry = 3600; |
24 | 23 | parent::__construct( 'EducationProgram' ); |
25 | 24 | } |
26 | 25 | |
— | — | @@ -33,6 +32,8 @@ |
34 | 33 | public function execute( $subPage ) { |
35 | 34 | parent::execute( $subPage ); |
36 | 35 | |
| 36 | + $this->startCache( 3600 ); |
| 37 | + |
37 | 38 | $this->displayNavigation(); |
38 | 39 | |
39 | 40 | $this->addCachedHTML( array( $this, 'displaySummaryTable' ) ); |
Index: trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php |
— | — | @@ -19,7 +19,6 @@ |
20 | 20 | * @since 0.1 |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | | - $this->cacheExpiry = 180; |
24 | 23 | parent::__construct( 'StudentActivity' ); |
25 | 24 | } |
26 | 25 | |
— | — | @@ -33,6 +32,8 @@ |
34 | 33 | public function execute( $subPage ) { |
35 | 34 | parent::execute( $subPage ); |
36 | 35 | |
| 36 | + $this->startCache( 180 ); |
| 37 | + |
37 | 38 | $this->getOutput()->addModules( 'ep.studentactivity' ); |
38 | 39 | |
39 | 40 | $this->displayNavigation(); |
Index: trunk/extensions/EducationProgram/includes/EPOrg.php |
— | — | @@ -135,7 +135,7 @@ |
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | | - * Adds a control to add a new org to the provided context. |
| 139 | + * Returns thr HTML for a control to add a new org to the provided context. |
140 | 140 | * Adittional arguments can be provided to set the default values for the control fields. |
141 | 141 | * |
142 | 142 | * @since 0.1 |
— | — | @@ -143,40 +143,34 @@ |
144 | 144 | * @param IContextSource $context |
145 | 145 | * @param array $args |
146 | 146 | * |
147 | | - * @return boolean |
| 147 | + * @return string |
148 | 148 | */ |
149 | | - public static function displayAddNewControl( IContextSource $context, array $args = array() ) { |
150 | | - if ( !$context->getUser()->isAllowed( 'ep-org' ) ) { |
151 | | - return false; |
152 | | - } |
153 | | - |
154 | | - $out = $context->getOutput(); |
| 149 | + public static function getAddNewControl( IContextSource $context, array $args = array() ) { |
| 150 | + $html = ''; |
155 | 151 | |
156 | | - $out->addModules( 'ep.addorg' ); |
157 | | - |
158 | | - $out->addHTML( Html::openElement( |
| 152 | + $html .= Html::openElement( |
159 | 153 | 'form', |
160 | 154 | array( |
161 | 155 | 'method' => 'post', |
162 | 156 | 'action' => EPOrgs::singleton()->getTitleFor( 'NAME_PLACEHOLDER' )->getLocalURL( array( 'action' => 'edit' ) ), |
163 | 157 | ) |
164 | | - ) ); |
| 158 | + ); |
165 | 159 | |
166 | | - $out->addHTML( '<fieldset>' ); |
| 160 | + $html .= '<fieldset>'; |
167 | 161 | |
168 | | - $out->addHTML( '<legend>' . wfMsgHtml( 'ep-institutions-addnew' ) . '</legend>' ); |
| 162 | + $html .= '<legend>' . wfMsgHtml( 'ep-institutions-addnew' ) . '</legend>'; |
169 | 163 | |
170 | | - $out->addElement( 'p', array(), wfMsg( 'ep-institutions-namedoc' ) ); |
| 164 | + $html .= Html::element( 'p', array(), wfMsg( 'ep-institutions-namedoc' ) ); |
171 | 165 | |
172 | | - $out->addHTML( Xml::inputLabel( |
| 166 | + $html .= Xml::inputLabel( |
173 | 167 | wfMsg( 'ep-institutions-newname' ), |
174 | 168 | 'newname', |
175 | 169 | 'newname', |
176 | 170 | false, |
177 | 171 | array_key_exists( 'name', $args ) ? $args['name'] : false |
178 | | - ) ); |
| 172 | + ); |
179 | 173 | |
180 | | - $out->addHTML( ' ' . Html::input( |
| 174 | + $html .= ' ' . Html::input( |
181 | 175 | 'addneworg', |
182 | 176 | wfMsg( 'ep-institutions-add' ), |
183 | 177 | 'submit', |
— | — | @@ -184,38 +178,39 @@ |
185 | 179 | 'disabled' => 'disabled', |
186 | 180 | 'class' => 'ep-org-add', |
187 | 181 | ) |
188 | | - ) ); |
| 182 | + ); |
189 | 183 | |
190 | | - $out->addHTML( Html::hidden( 'isnew', 1 ) ); |
| 184 | + $html .= Html::hidden( 'isnew', 1 ); |
191 | 185 | |
192 | | - $out->addHTML( '</fieldset></form>' ); |
| 186 | + $html .= '</fieldset></form>'; |
193 | 187 | |
194 | | - return true; |
| 188 | + return $html; |
195 | 189 | } |
196 | 190 | |
197 | 191 | /** |
198 | | - * Display a pager with courses. |
| 192 | + * Returns the HTML for a pager with institutions. |
199 | 193 | * |
200 | 194 | * @since 0.1 |
201 | 195 | * |
202 | 196 | * @param IContextSource $context |
203 | 197 | * @param array $conditions |
| 198 | + * |
| 199 | + * @return string |
204 | 200 | */ |
205 | | - public static function displayPager( IContextSource $context, array $conditions = array() ) { |
| 201 | + public static function getPager( IContextSource $context, array $conditions = array() ) { |
206 | 202 | $pager = new EPOrgPager( $context, $conditions ); |
207 | 203 | |
208 | 204 | if ( $pager->getNumRows() ) { |
209 | | - $context->getOutput()->addHTML( |
| 205 | + return |
210 | 206 | $pager->getFilterControl() . |
211 | 207 | $pager->getNavigationBar() . |
212 | 208 | $pager->getBody() . |
213 | 209 | $pager->getNavigationBar() . |
214 | | - $pager->getMultipleItemControl() |
215 | | - ); |
| 210 | + $pager->getMultipleItemControl(); |
216 | 211 | } |
217 | 212 | else { |
218 | | - $context->getOutput()->addHTML( $pager->getFilterControl( true ) ); |
219 | | - $context->getOutput()->addWikiMsg( 'ep-institutions-noresults' ); |
| 213 | + return $pager->getFilterControl( true ) . |
| 214 | + $context->msg( 'ep-institutions-noresults' ); |
220 | 215 | } |
221 | 216 | } |
222 | 217 | |