Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialAsk.php |
— | — | @@ -1,20 +1,16 @@ |
2 | 2 | <?php |
3 | | -/** |
4 | | - * @file |
5 | | - * @ingroup SMWSpecialPage |
6 | | - * @ingroup SpecialPage |
7 | | - */ |
8 | 3 | |
9 | 4 | /** |
10 | | - * @author Markus Krötzsch |
11 | | - * @author Yaron Koren |
12 | | - * @author Sanyam Goyal |
13 | | - * |
14 | 5 | * This special page for MediaWiki implements a customisable form for |
15 | 6 | * executing queries outside of articles. |
16 | 7 | * |
| 8 | + * @file SMW_SpecialAsk.php |
17 | 9 | * @ingroup SMWSpecialPage |
18 | 10 | * @ingroup SpecialPage |
| 11 | + * |
| 12 | + * @author Markus Krötzsch |
| 13 | + * @author Yaron Koren |
| 14 | + * @author Sanyam Goyal |
19 | 15 | */ |
20 | 16 | class SMWAskPage extends SpecialPage { |
21 | 17 | |
— | — | @@ -24,7 +20,7 @@ |
25 | 21 | protected $m_editquery = false; |
26 | 22 | |
27 | 23 | // MW 1.13 compatibilty |
28 | | - private static $pipeseparator = '|'; |
| 24 | + protected static $pipeseparator = '|'; |
29 | 25 | |
30 | 26 | /** |
31 | 27 | * Constructor |
— | — | @@ -34,13 +30,16 @@ |
35 | 31 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
36 | 32 | } |
37 | 33 | |
38 | | - function execute( $p ) { |
| 34 | + public function execute( $p ) { |
39 | 35 | global $wgOut, $wgRequest, $smwgQEnabled, $smwgRSSEnabled, $smwgMW_1_14; |
| 36 | + |
40 | 37 | $this->setHeaders(); |
41 | 38 | wfProfileIn( 'doSpecialAsk (SMW)' ); |
| 39 | + |
42 | 40 | if ( $smwgMW_1_14 ) { // since MW 1.14.0 this is governed by a message |
43 | 41 | SMWAskPage::$pipeseparator = wfMsgExt( 'pipe-separator' , 'escapenoentities' ); |
44 | 42 | } |
| 43 | + |
45 | 44 | if ( !$smwgQEnabled ) { |
46 | 45 | $wgOut->addHTML( '<br />' . wfMsg( 'smw_iq_disabled' ) ); |
47 | 46 | } else { |
— | — | @@ -55,6 +54,7 @@ |
56 | 55 | $this->makeHTMLResult(); |
57 | 56 | } |
58 | 57 | } |
| 58 | + |
59 | 59 | SMWOutputs::commitToOutputPage( $wgOut ); // make sure locally collected output data is pushed to the output! |
60 | 60 | wfProfileOut( 'doSpecialAsk (SMW)' ); |
61 | 61 | } |
— | — | @@ -70,6 +70,7 @@ |
71 | 71 | if ( $wgRequest->getCheck( 'q' ) ) { // called by own Special, ignore full param string in that case |
72 | 72 | $query_values = $wgRequest->getArray( 'p' ); |
73 | 73 | $query_val = $wgRequest->getVal( 'p' ); |
| 74 | + |
74 | 75 | if ( ! empty( $query_val ) ) |
75 | 76 | $rawparams = SMWInfolink::decodeParameters( $query_val, false ); // p is used for any additional parameters in certain links |
76 | 77 | else { |
— | — | @@ -82,15 +83,19 @@ |
83 | 84 | } else { // called from wiki, get all parameters |
84 | 85 | $rawparams = SMWInfolink::decodeParameters( $p, true ); |
85 | 86 | } |
| 87 | + |
86 | 88 | // Check for q= query string, used whenever this special page calls itself (via submit or plain link): |
87 | 89 | $this->m_querystring = $wgRequest->getText( 'q' ); |
88 | 90 | if ( $this->m_querystring != '' ) { |
89 | 91 | $rawparams[] = $this->m_querystring; |
90 | 92 | } |
| 93 | + |
91 | 94 | // Check for param strings in po (printouts), appears in some links and in submits: |
92 | 95 | $paramstring = $wgRequest->getText( 'po' ); |
| 96 | + |
93 | 97 | if ( $paramstring != '' ) { // parameters from HTML input fields |
94 | 98 | $ps = explode( "\n", $paramstring ); // params separated by newlines here (compatible with text-input for printouts) |
| 99 | + |
95 | 100 | foreach ( $ps as $param ) { // add initial ? if omitted (all params considered as printouts) |
96 | 101 | $param = trim( $param ); |
97 | 102 | if ( ( $param != '' ) && ( $param { 0 } != '?' ) ) { |
— | — | @@ -110,6 +115,7 @@ |
111 | 116 | $this->m_params['format'] = 'broadtable'; |
112 | 117 | } |
113 | 118 | } |
| 119 | + |
114 | 120 | if ( !array_key_exists( 'order', $this->m_params ) ) { |
115 | 121 | $order_values = $wgRequest->getArray( 'order' ); |
116 | 122 | if ( is_array( $order_values ) ) { |
— | — | @@ -120,7 +126,9 @@ |
121 | 127 | } |
122 | 128 | } |
123 | 129 | } |
| 130 | + |
124 | 131 | $this->m_num_sort_values = 0; |
| 132 | + |
125 | 133 | if ( !array_key_exists( 'sort', $this->m_params ) ) { |
126 | 134 | $sort_values = $wgRequest->getArray( 'sort' ); |
127 | 135 | if ( is_array( $sort_values ) ) { |
— | — | @@ -128,6 +136,7 @@ |
129 | 137 | $this->m_num_sort_values = count( $sort_values ); |
130 | 138 | } |
131 | 139 | } |
| 140 | + |
132 | 141 | // Find implicit ordering for RSS -- needed for downwards compatibility with SMW <=1.1 |
133 | 142 | /* |
134 | 143 | if ( ($this->m_params['format'] == 'rss') && ($this->m_params['sort'] == '') && ($sortcount==0)) { |
— | — | @@ -139,16 +148,20 @@ |
140 | 149 | } |
141 | 150 | } |
142 | 151 | */ |
| 152 | + |
143 | 153 | if ( !array_key_exists( 'offset', $this->m_params ) ) { |
144 | 154 | $this->m_params['offset'] = $wgRequest->getVal( 'offset' ); |
145 | 155 | if ( $this->m_params['offset'] == '' ) $this->m_params['offset'] = 0; |
146 | 156 | } |
| 157 | + |
147 | 158 | if ( !array_key_exists( 'limit', $this->m_params ) ) { |
148 | 159 | $this->m_params['limit'] = $wgRequest->getVal( 'limit' ); |
| 160 | + |
149 | 161 | if ( $this->m_params['limit'] == '' ) { |
150 | | - $this->m_params['limit'] = ( $this->m_params['format'] == 'rss' ) ? 10:20; // standard limit for RSS |
| 162 | + $this->m_params['limit'] = ( $this->m_params['format'] == 'rss' ) ? 10 : 20; // Standard limit for RSS. |
151 | 163 | } |
152 | 164 | } |
| 165 | + |
153 | 166 | $this->m_params['limit'] = min( $this->m_params['limit'], $smwgQMaxInlineLimit ); |
154 | 167 | |
155 | 168 | $this->m_editquery = ( $wgRequest->getVal( 'eq' ) == 'yes' ) || ( $this->m_querystring == '' ); |
— | — | @@ -157,7 +170,7 @@ |
158 | 171 | static protected function addAutocompletionJavascriptAndCSS() { |
159 | 172 | global $wgOut, $smwgScriptPath, $smwgJQueryIncluded, $smwgJQueryUIIncluded; |
160 | 173 | |
161 | | - // Add CSS and JavaScript for jQuery and jQuery UI |
| 174 | + // Add CSS and JavaScript for jQuery and jQuery UI. |
162 | 175 | $wgOut->addExtensionStyle( "$smwgScriptPath/skins/jquery-ui/base/jquery.ui.all.css" ); |
163 | 176 | |
164 | 177 | $scripts = array(); |
— | — | @@ -186,13 +199,17 @@ |
187 | 200 | /* collect property names for autocomplete */ |
188 | 201 | $propertyNames[] = array(); |
189 | 202 | $results = smwfGetStore()->getPropertiesSpecial(); |
| 203 | + |
190 | 204 | foreach ( $results as $result ) { |
191 | 205 | $propertyNames[] = $result[0]->getWikiValue(); |
192 | 206 | } |
| 207 | + |
193 | 208 | $results = smwfGetStore()->getUnusedPropertiesSpecial(); |
| 209 | + |
194 | 210 | foreach ( $results as $result ) { |
195 | 211 | $propertyNames[] = $result->getWikiValue(); |
196 | 212 | } |
| 213 | + |
197 | 214 | sort( $propertyNames ); |
198 | 215 | |
199 | 216 | $properties_po = "["; |
— | — | @@ -355,11 +372,14 @@ |
356 | 373 | $tmp_parray[$key] = $value; |
357 | 374 | } |
358 | 375 | } |
| 376 | + |
359 | 377 | $urltail .= '&p=' . urlencode( SMWInfolink::encodeParameters( $tmp_parray ) ); |
360 | 378 | $printoutstring = ''; |
| 379 | + |
361 | 380 | foreach ( $this->m_printouts as $printout ) { |
362 | 381 | $printoutstring .= $printout->getSerialisation() . "\n"; |
363 | 382 | } |
| 383 | + |
364 | 384 | if ( $printoutstring != '' ) $urltail .= '&po=' . urlencode( $printoutstring ); |
365 | 385 | if ( array_key_exists( 'sort', $this->m_params ) ) $urltail .= '&sort=' . $this->m_params['sort']; |
366 | 386 | if ( array_key_exists( 'order', $this->m_params ) ) $urltail .= '&order=' . $this->m_params['order']; |
— | — | @@ -367,7 +387,8 @@ |
368 | 388 | if ( $this->m_querystring != '' ) { |
369 | 389 | $queryobj = SMWQueryProcessor::createQuery( $this->m_querystring, $this->m_params, SMWQueryProcessor::SPECIAL_PAGE , $this->m_params['format'], $this->m_printouts ); |
370 | 390 | $res = smwfGetStore()->getQueryResult( $queryobj ); |
371 | | - // try to be smart for rss/ical if no description/title is given and we have a concept query: |
| 391 | + |
| 392 | + // Try to be smart for rss/ical if no description/title is given and we have a concept query: |
372 | 393 | if ( $this->m_params['format'] == 'rss' ) { |
373 | 394 | $desckey = 'rssdescription'; |
374 | 395 | $titlekey = 'rsstitle'; |
— | — | @@ -375,12 +396,15 @@ |
376 | 397 | $desckey = 'icalendardescription'; |
377 | 398 | $titlekey = 'icalendartitle'; |
378 | 399 | } else { $desckey = false; } |
| 400 | + |
379 | 401 | if ( ( $desckey ) && ( $queryobj->getDescription() instanceof SMWConceptDescription ) && |
380 | 402 | ( !isset( $this->m_params[$desckey] ) || !isset( $this->m_params[$titlekey] ) ) ) { |
381 | 403 | $concept = $queryobj->getDescription()->getConcept(); |
| 404 | + |
382 | 405 | if ( !isset( $this->m_params[$titlekey] ) ) { |
383 | 406 | $this->m_params[$titlekey] = $concept->getText(); |
384 | 407 | } |
| 408 | + |
385 | 409 | if ( !isset( $this->m_params[$desckey] ) ) { |
386 | 410 | $dv = end( smwfGetStore()->getPropertyValues( SMWWikiPageValue::makePageFromTitle( $concept ), SMWPropertyValue::makeProperty( '_CONC' ) ) ); |
387 | 411 | if ( $dv instanceof SMWConceptValue ) { |
— | — | @@ -388,9 +412,12 @@ |
389 | 413 | } |
390 | 414 | } |
391 | 415 | } |
| 416 | + |
392 | 417 | $printer = SMWQueryProcessor::getResultPrinter( $this->m_params['format'], SMWQueryProcessor::SPECIAL_PAGE ); |
393 | 418 | $result_mime = $printer->getMimeType( $res ); |
| 419 | + |
394 | 420 | global $wgRequest; |
| 421 | + |
395 | 422 | $hidequery = $wgRequest->getVal( 'eq' ) == 'no'; |
396 | 423 | // if it's an export format (like CSV, JSON, etc.), |
397 | 424 | // don't actually export the data if 'eq' is set to |
— | — | @@ -400,18 +427,19 @@ |
401 | 428 | $result_mime = false; |
402 | 429 | if ( $result_mime == false ) { |
403 | 430 | if ( $res->getCount() > 0 ) { |
404 | | - if ( $this->m_editquery ) |
405 | | - $urltail .= '&eq=yes'; |
406 | | - if ( $hidequery ) |
407 | | - $urltail .= '&eq=no'; |
| 431 | + if ( $this->m_editquery ) $urltail .= '&eq=yes'; |
| 432 | + if ( $hidequery ) $urltail .= '&eq=no'; |
| 433 | + |
408 | 434 | $navigation = $this->getNavigationBar( $res, $urltail ); |
409 | 435 | $result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n"; |
410 | 436 | $query_result = $printer->getResult( $res, $this->m_params, SMW_OUTPUT_HTML ); |
| 437 | + |
411 | 438 | if ( is_array( $query_result ) ) { |
412 | 439 | $result .= $query_result[0]; |
413 | 440 | } else { |
414 | 441 | $result .= $query_result; |
415 | 442 | } |
| 443 | + |
416 | 444 | $result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n"; |
417 | 445 | } else { |
418 | 446 | $result = '<div style="text-align: center;">' . wfMsg( 'smw_result_noresults' ) . '</div>'; |
— | — | @@ -428,14 +456,18 @@ |
429 | 457 | } else { |
430 | 458 | $wgOut->setHTMLtitle( wfMsg( 'ask' ) ); |
431 | 459 | } |
| 460 | + |
432 | 461 | $result = $this->getInputForm( $printoutstring, 'offset=' . $this->m_params['offset'] . '&limit=' . $this->m_params['limit'] . $urltail ) . $result; |
433 | 462 | $wgOut->addHTML( $result ); |
434 | 463 | } else { |
435 | 464 | $wgOut->disable(); |
| 465 | + |
436 | 466 | header( "Content-type: $result_mime; charset=UTF-8" ); |
| 467 | + |
437 | 468 | if ( $result_name !== false ) { |
438 | 469 | header( "content-disposition: attachment; filename=$result_name" ); |
439 | 470 | } |
| 471 | + |
440 | 472 | print $result; |
441 | 473 | } |
442 | 474 | } |
— | — | @@ -443,6 +475,7 @@ |
444 | 476 | |
445 | 477 | protected function getInputForm( $printoutstring, $urltail ) { |
446 | 478 | global $wgUser, $smwgQSortingSupport, $wgLang, $smwgResultFormats; |
| 479 | + |
447 | 480 | $skin = $wgUser->getSkin(); |
448 | 481 | $result = ''; |
449 | 482 | |
— | — | @@ -466,16 +499,20 @@ |
467 | 500 | $orders = explode( ',', $this->m_params['order'] ); |
468 | 501 | reset( $sorts ); |
469 | 502 | } |
| 503 | + |
470 | 504 | foreach ( $orders as $i => $order ) { |
471 | 505 | $result .= "<div id=\"sort_div_$i\">" . wfMsg( 'smw_ask_sortby' ) . ' <input type="text" name="sort[' . $i . ']" value="' . |
472 | 506 | htmlspecialchars( $sorts[$i] ) . "\" size=\"35\"/>\n" . '<select name="order[' . $i . ']"><option '; |
| 507 | + |
473 | 508 | if ( $order == 'ASC' ) $result .= 'selected="selected" '; |
474 | 509 | $result .= 'value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . '</option><option '; |
475 | 510 | if ( $order == 'DESC' ) $result .= 'selected="selected" '; |
| 511 | + |
476 | 512 | $result .= 'value="DESC">' . wfMsg( 'smw_ask_descorder' ) . "</option></select>\n"; |
477 | 513 | $result .= '[<a href="javascript:removeInstance(\'sort_div_' . $i . '\')">' . wfMsg( 'delete' ) . '</a>]' . "\n"; |
478 | 514 | $result .= "</div>\n"; |
479 | 515 | } |
| 516 | + |
480 | 517 | $result .= '<div id="sorting_starter" style="display: none">' . wfMsg( 'smw_ask_sortby' ) . ' <input type="text" name="sort_num" size="35" />' . "\n"; |
481 | 518 | $result .= ' <select name="order_num">' . "\n"; |
482 | 519 | $result .= ' <option value="ASC">' . wfMsg( 'smw_ask_ascorder' ) . "</option>\n"; |
— | — | @@ -487,23 +524,27 @@ |
488 | 525 | |
489 | 526 | $printer = SMWQueryProcessor::getResultPrinter( 'broadtable', SMWQueryProcessor::SPECIAL_PAGE ); |
490 | 527 | $url = htmlspecialchars( $skin->makeSpecialUrl( 'Ask', "showformatoptions=\" + this.value + \"" ) ); |
| 528 | + |
491 | 529 | foreach ( $this->m_params as $param => $value ) { |
492 | | - if ( $param !== 'format' ) |
493 | | - $url .= "¶ms[$param]=$value"; |
| 530 | + if ( $param !== 'format' ) $url .= "¶ms[$param]=$value"; |
494 | 531 | } |
| 532 | + |
495 | 533 | $result .= "<br /><br />\n<p>" . wfMsg( 'smw_ask_format_as' ) . ' <input type="hidden" name="eq" value="yes"/>' . "\n" . |
496 | 534 | '<select id="formatSelector" name="p[format]" onChange=\'JavaScript:xmlhttpPost("' . $url . "\")'>\n" . |
497 | 535 | ' <option value="broadtable"' . ( $this->m_params['format'] == 'broadtable' ? ' selected' : '' ) . '>' . |
498 | 536 | $printer->getName() . ' (' . wfMsg( 'smw_ask_defaultformat' ) . ')</option>' . "\n"; |
499 | 537 | |
500 | 538 | $formats = array(); |
| 539 | + |
501 | 540 | foreach ( array_keys( $smwgResultFormats ) as $format ) { |
502 | 541 | if ( ( $format != 'broadtable' ) && ( $format != 'count' ) && ( $format != 'debug' ) ) { // special formats "count" and "debug" currently not supported |
503 | 542 | $printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::SPECIAL_PAGE ); |
504 | 543 | $formats[$format] = $printer->getName(); |
505 | 544 | } |
506 | 545 | } |
| 546 | + |
507 | 547 | natcasesort( $formats ); |
| 548 | + |
508 | 549 | foreach ( $formats as $format => $name ) { |
509 | 550 | $result .= ' <option value="' . $format . '"' . ( $this->m_params['format'] == $format ? ' selected' : '' ) . '>' . $name . "</option>\n"; |
510 | 551 | } |
— | — | @@ -549,8 +590,7 @@ |
550 | 591 | return $result; |
551 | 592 | } |
552 | 593 | |
553 | | - private static function getEmbedToggle() |
554 | | - { |
| 594 | + protected static function getEmbedToggle() { |
555 | 595 | return '<span id="embed_show"><a href="#" rel="nofollow" onclick="' . |
556 | 596 | "document.getElementById('inlinequeryembed').style.display='block';" . |
557 | 597 | "document.getElementById('embed_hide').style.display='inline';" . |
— | — | @@ -565,14 +605,16 @@ |
566 | 606 | } |
567 | 607 | |
568 | 608 | /** |
569 | | - * Build the navigation for some given query result, reuse url-tail parameters |
| 609 | + * Build the navigation for some given query result, reuse url-tail parameters. |
570 | 610 | */ |
571 | 611 | protected function getNavigationBar( $res, $urltail ) { |
572 | 612 | global $wgUser, $smwgQMaxInlineLimit; |
| 613 | + |
573 | 614 | $skin = $wgUser->getSkin(); |
574 | 615 | $offset = $this->m_params['offset']; |
575 | 616 | $limit = $this->m_params['limit']; |
576 | | - // prepare navigation bar |
| 617 | + |
| 618 | + // Prepare navigation bar. |
577 | 619 | if ( $offset > 0 ) { |
578 | 620 | $navigation = '<a href="' . htmlspecialchars( $skin->makeSpecialUrl( 'Ask', 'offset=' . max( 0, $offset - $limit ) . '&limit=' . $limit . $urltail ) ) . '" rel="nofollow">' . wfMsg( 'smw_result_prev' ) . '</a>'; |
579 | 621 | } else { |
— | — | @@ -588,21 +630,26 @@ |
589 | 631 | } |
590 | 632 | |
591 | 633 | $first = true; |
| 634 | + |
592 | 635 | foreach ( array( 20, 50, 100, 250, 500 ) as $l ) { |
593 | 636 | if ( $l > $smwgQMaxInlineLimit ) break; |
| 637 | + |
594 | 638 | if ( $first ) { |
595 | 639 | $navigation .= '        ('; |
596 | 640 | $first = false; |
597 | 641 | } else { |
598 | 642 | $navigation .= ' ' . SMWAskPage::$pipeseparator . ' '; |
599 | 643 | } |
| 644 | + |
600 | 645 | if ( $limit != $l ) { |
601 | 646 | $navigation .= '<a href="' . htmlspecialchars( $skin->makeSpecialUrl( 'Ask', 'offset=' . $offset . '&limit=' . $l . $urltail ) ) . '" rel="nofollow">' . $l . '</a>'; |
602 | 647 | } else { |
603 | 648 | $navigation .= '<b>' . $l . '</b>'; |
604 | 649 | } |
605 | 650 | } |
| 651 | + |
606 | 652 | $navigation .= ')'; |
| 653 | + |
607 | 654 | return $navigation; |
608 | 655 | } |
609 | 656 | |
— | — | @@ -611,63 +658,69 @@ |
612 | 659 | * based on the getParameters() value for that format's query printer |
613 | 660 | */ |
614 | 661 | function showFormatOptions( $format, $param_values ) { |
615 | | - $text = ""; |
| 662 | + $text = ''; |
| 663 | + |
616 | 664 | $printer = SMWQueryProcessor::getResultPrinter( $format, SMWQueryProcessor::SPECIAL_PAGE ); |
617 | | - if ( method_exists( $printer, 'getParameters' ) ) |
618 | | - $params = $printer->getParameters(); |
619 | | - else |
620 | | - $params = array(); |
| 665 | + |
| 666 | + |
| 667 | + $params = method_exists( $printer, 'getParameters' ) ? $printer->getParameters() : array(); |
| 668 | + |
621 | 669 | foreach ( $params as $i => $param ) { |
622 | 670 | $param_name = $param['name']; |
623 | 671 | $type = $param['type']; |
624 | 672 | $desc = $param['description']; |
625 | | - $cur_value = ( array_key_exists( $param_name, $param_values ) ) ? $param_values[$param_name] : ""; |
| 673 | + $cur_value = ( array_key_exists( $param_name, $param_values ) ) ? $param_values[$param_name] : ''; |
| 674 | + |
626 | 675 | // 3 values per row, with alternating colors for rows |
627 | 676 | if ( $i % 3 == 0 ) { |
628 | 677 | $bgcolor = ( $i % 6 ) == 0 ? '#dddddd' : 'white'; |
629 | 678 | $text .= "<div style=\"background: $bgcolor;\">"; |
630 | 679 | } |
| 680 | + |
631 | 681 | $text .= "<div style=\"width: 30%; padding: 5px; float: left;\">$param_name:\n"; |
| 682 | + |
632 | 683 | switch ( $type ) { |
633 | | - case 'int': |
634 | | - $text .= "<input type=\"text\" name=\"p[$param_name]\" size=\"6\" value=\"$cur_value\" />"; |
635 | | - break; |
636 | | - case 'string': |
637 | | - $text .= "<input type=\"text\" name=\"p[$param_name]\" size=\"32\" value=\"$cur_value\" />"; |
638 | | - break; |
639 | | - case 'enumeration': |
640 | | - $values = $param['values']; |
641 | | - $text .= "<select name=\"p[$param_name]\">\n"; |
642 | | - $text .= " <option value=''></option>\n"; |
643 | | - foreach ( $values as $val ) { |
644 | | - if ( $cur_value == $val ) |
645 | | - $selected_str = 'selected'; |
646 | | - else |
647 | | - $selected_str = ''; |
648 | | - $text .= " <option value='$val' $selected_str>$val</option>\n"; |
649 | | - } |
650 | | - $text .= "</select>"; |
651 | | - break; |
652 | | - case 'enum-list': |
653 | | - $all_values = $param['values']; |
654 | | - $cur_values = explode( ',', $cur_value ); |
655 | | - foreach ( $all_values as $val ) { |
656 | | - $checked_str = ( in_array( $val, $cur_values ) ) ? "checked" : ""; |
657 | | - $text .= "<span style=\"white-space: nowrap; padding-right: 5px;\"><input type=\"checkbox\" name=\"p[$param_name][$val]\" value=\"true\" $checked_str /> <tt>$val</tt></span>\n"; |
658 | | - } |
659 | | - break; |
660 | | - case 'boolean': |
661 | | - $checked_str = ( array_key_exists( $param_name, $param_values ) ) ? 'checked' : ''; |
662 | | - $text .= "<input type=\"checkbox\" name=\"p[$param_name]\" value=\"true\" $checked_str />"; |
663 | | - break; |
| 684 | + case 'int': |
| 685 | + $text .= "<input type=\"text\" name=\"p[$param_name]\" size=\"6\" value=\"$cur_value\" />"; |
| 686 | + break; |
| 687 | + case 'string': |
| 688 | + $text .= "<input type=\"text\" name=\"p[$param_name]\" size=\"32\" value=\"$cur_value\" />"; |
| 689 | + break; |
| 690 | + case 'enumeration': |
| 691 | + $values = $param['values']; |
| 692 | + $text .= "<select name=\"p[$param_name]\">\n"; |
| 693 | + $text .= " <option value=''></option>\n"; |
| 694 | + foreach ( $values as $val ) { |
| 695 | + if ( $cur_value == $val ) |
| 696 | + $selected_str = 'selected'; |
| 697 | + else |
| 698 | + $selected_str = ''; |
| 699 | + $text .= " <option value='$val' $selected_str>$val</option>\n"; |
| 700 | + } |
| 701 | + $text .= "</select>"; |
| 702 | + break; |
| 703 | + case 'enum-list': |
| 704 | + $all_values = $param['values']; |
| 705 | + $cur_values = explode( ',', $cur_value ); |
| 706 | + foreach ( $all_values as $val ) { |
| 707 | + $checked_str = ( in_array( $val, $cur_values ) ) ? "checked" : ""; |
| 708 | + $text .= "<span style=\"white-space: nowrap; padding-right: 5px;\"><input type=\"checkbox\" name=\"p[$param_name][$val]\" value=\"true\" $checked_str /> <tt>$val</tt></span>\n"; |
| 709 | + } |
| 710 | + break; |
| 711 | + case 'boolean': |
| 712 | + $checked_str = ( array_key_exists( $param_name, $param_values ) ) ? 'checked' : ''; |
| 713 | + $text .= "<input type=\"checkbox\" name=\"p[$param_name]\" value=\"true\" $checked_str />"; |
| 714 | + break; |
664 | 715 | } |
| 716 | + |
665 | 717 | $text .= "\n <br /><em>$desc</em>\n</div>\n"; |
| 718 | + |
666 | 719 | if ( $i % 3 == 2 || $i == count( $params ) - 1 ) { |
667 | 720 | $text .= "<div style=\"clear: both\";></div></div>\n"; |
668 | 721 | } |
669 | 722 | } |
| 723 | + |
670 | 724 | return $text; |
671 | 725 | } |
672 | 726 | |
673 | 727 | } |
674 | | - |