Index: branches/liquidthreads/skins/monobook/main.css |
— | — | @@ -108,8 +108,9 @@ |
109 | 109 | }*/ |
110 | 110 | |
111 | 111 | #lqt_subject_field { |
112 | | - margin-top: 0.7em; |
113 | | - margin-bottom: 0.5em; |
| 112 | + margin-top: 0.7em; |
| 113 | + margin-bottom: 0.5em; |
| 114 | + width: 80%; |
114 | 115 | } |
115 | 116 | |
116 | 117 | .lqt_post .lqt_footer a { |
Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -13,11 +13,6 @@ |
14 | 14 | } |
15 | 15 | else { |
16 | 16 | |
17 | | -/** database ID of post to edit. */ |
18 | | -define('LQT_COMMAND_EDIT_POST', 'lqt_edit_post'); |
19 | | -/** database ID of post to reply to */ |
20 | | -define('LQT_COMMAND_REPLY_TO_POST', 'lqt_reply_to'); |
21 | | - |
22 | 17 | require_once('LqtModel.php'); |
23 | 18 | |
24 | 19 | class LqtDispatch { |
— | — | @@ -106,6 +101,19 @@ |
107 | 102 | * Output methods with logic * |
108 | 103 | *******************************/ |
109 | 104 | |
| 105 | + /** |
| 106 | + * Return an HTML form element whose value is gotten from the request. |
| 107 | + * TODO: figure out a clean way to expand this to other forms. |
| 108 | + */ |
| 109 | + function perpetuate( $name, $as ) { |
| 110 | + $value = $this->request->getVal($name, ''); |
| 111 | + if ( $as == 'hidden' ) { |
| 112 | + return <<<HTML |
| 113 | + <input type="hidden" name="$name" id="$name" value="$value"> |
| 114 | +HTML; |
| 115 | + } |
| 116 | + } |
| 117 | + |
110 | 118 | function showNewThreadForm() { |
111 | 119 | $this->showEditingFormInGeneral( null, 'new', null ); |
112 | 120 | } |
— | — | @@ -133,22 +141,17 @@ |
134 | 142 | $e = new EditPage($article); |
135 | 143 | $e->suppressIntro = true; |
136 | 144 | |
137 | | - $e->editFormTextBottom .= "<input type=\"hidden\" name=\"lqt_edit_post\" value=\"{$article->getTitle()->getPrefixedURL()}\">"; |
| 145 | + $e->editFormTextBeforeContent .= |
| 146 | + $this->perpetuate('lqt_edit_post', 'hidden') . |
| 147 | + $this->perpetuate('lqt_reply_to', 'hidden') . |
| 148 | + $this->perpetuate('lqt_new_thread_form', 'hidden'); |
138 | 149 | |
139 | | - if ( $edit_type == 'reply' ) { |
140 | | - $e->editFormTextBottom .= "<input type=\"hidden\" name=\"lqt_reply_to\" value=\"{$edit_applies_to->id()}\">"; |
141 | | - } |
142 | | - |
143 | | - if ( $edit_type == 'new' ) { |
144 | | - $e->editFormTextBottom .= "<input type=\"hidden\" name=\"lqt_new_thread_form\" value=\"1\">"; |
145 | | - } |
146 | | - |
147 | 150 | if ( $thread == null || $thread->superthread() == null ) { |
148 | 151 | // This is a top-level post; show the subject line. |
149 | 152 | $subject = $this->request->getVal('lqt_subject_field', $thread ? $thread->subject() : ''); |
150 | 153 | $e->editFormTextBeforeContent .= <<<HTML |
151 | 154 | <label for="lqt_subject_field">Subject: </label> |
152 | | - <input type="text" size="50" name="lqt_subject_field" id="lqt_subject_field" value="$subject"><br> |
| 155 | + <input type="text" size="60" name="lqt_subject_field" id="lqt_subject_field" value="$subject"><br> |
153 | 156 | HTML; |
154 | 157 | } |
155 | 158 | |
— | — | @@ -210,6 +213,19 @@ |
211 | 214 | } |
212 | 215 | } |
213 | 216 | |
| 217 | + function lqtTalkpageUrl( $title, $operator = null, $operand = null ) { |
| 218 | + if ( $operator == 'lqt_reply_to' ) { |
| 219 | + $query = array( 'lqt_reply_to' => $operand ? $operand->id() : null ); |
| 220 | + } else if ($operator == 'lqt_edit_post') { |
| 221 | + $query = array( 'lqt_edit_post' => $operand ? $operand->rootPost()->getTitle()->getPrefixedURL() : null ); |
| 222 | + } else if ($operator == 'lqt_new_thread_form' ) { |
| 223 | + $query = array( 'lqt_new_thread_form' => '1' ); |
| 224 | + } else { |
| 225 | + $query = array(); |
| 226 | + } |
| 227 | + return $title->getFullURL( $this->queryStringFromArray($query) ); |
| 228 | + } |
| 229 | + |
214 | 230 | function showThreadFooter( $thread ) { |
215 | 231 | |
216 | 232 | $this->output->addHTML(wfOpenElement('ul', array('class'=>'lqt_footer'))); |
— | — | @@ -218,16 +234,16 @@ |
219 | 235 | $p = new Parser(); $sig = $p->getUserSig( $thread->rootPost()->originalAuthor() ); |
220 | 236 | $this->output->addWikitext( $sig, false ); |
221 | 237 | $this->output->addHTML( wfCloseElement( 'li' ) ); |
222 | | - |
223 | | - $commands = array( 'Edit' => $this->selflink( array( LQT_COMMAND_EDIT_POST => $thread->rootPost()->getTitle()->getPrefixedURL() ) ), |
224 | | - 'Reply' => $this->selflink( array( LQT_COMMAND_REPLY_TO_POST => $thread->id() ) )); |
225 | | - |
| 238 | + |
| 239 | + $commands = array( 'Edit' => $this->lqtTalkpageUrl( $this->title, 'lqt_edit_post', $thread ), |
| 240 | + 'Reply' => $this->lqtTalkpageUrl( $this->title, 'lqt_reply_to', $thread ) ); |
| 241 | + |
226 | 242 | foreach( $commands as $label => $href ) { |
227 | 243 | $this->output->addHTML( wfOpenElement( 'li' ) ); |
228 | 244 | $this->output->addHTML( wfElement('a', array('href'=>$href), $label) ); |
229 | 245 | $this->output->addHTML( wfCloseElement( 'li' ) ); |
230 | 246 | } |
231 | | - |
| 247 | + |
232 | 248 | $this->output->addHTML(wfCloseELement('ul')); |
233 | 249 | } |
234 | 250 | |
— | — | @@ -236,7 +252,7 @@ |
237 | 253 | |
238 | 254 | $this->openDiv( 'lqt_post' ); |
239 | 255 | |
240 | | - if( $this->commandApplies( LQT_COMMAND_EDIT_POST, $post ) ) { |
| 256 | + if( $this->commandApplies( 'lqt_edit_post', $post ) ) { |
241 | 257 | $this->showPostEditingForm( $thread ); |
242 | 258 | } else{ |
243 | 259 | $this->showPostBody( $post ); |
— | — | @@ -245,7 +261,7 @@ |
246 | 262 | |
247 | 263 | $this->closeDiv(); |
248 | 264 | |
249 | | - if( $this->commandAppliesToThread( LQT_COMMAND_REPLY_TO_POST, $thread ) ) { |
| 265 | + if( $this->commandAppliesToThread( 'lqt_reply_to', $thread ) ) { |
250 | 266 | $this->indent(); |
251 | 267 | $this->showReplyForm( $thread ); |
252 | 268 | $this->unindent(); |
— | — | @@ -296,7 +312,8 @@ |
297 | 313 | if( $this->request->getBool('lqt_new_thread_form') ) { |
298 | 314 | $this->showNewThreadForm(); |
299 | 315 | } else { |
300 | | - $this->output->addHTML("<strong><a href=\"{$this->title->getFullURL('lqt_new_thread_form=1')}\">Start a Discussion</a></strong>"); |
| 316 | + $url = $this->lqtTalkpageUrl( $this->title, 'lqt_new_thread_form' ); |
| 317 | + $this->output->addHTML("<strong><a href=\"$url\">Start a Discussion</a></strong>"); |
301 | 318 | } |
302 | 319 | $threads = Thread::allThreadsOfArticle($this->article); |
303 | 320 | foreach($threads as $t) { |