Index: trunk/extensions/SemanticDrilldown/specials/SD_BrowseData.php |
— | — | @@ -5,6 +5,7 @@ |
6 | 6 | * previously been created. |
7 | 7 | * |
8 | 8 | * @author Yaron Koren |
| 9 | + * @author Sanyam Goyal |
9 | 10 | */ |
10 | 11 | |
11 | 12 | if ( !defined( 'MEDIAWIKI' ) ) die(); |
— | — | @@ -28,25 +29,13 @@ |
29 | 30 | $wgParser->disableCache(); |
30 | 31 | } |
31 | 32 | $this->setHeaders(); |
32 | | - $mainCssDir = $sdgScriptPath . '/skins/'; |
33 | 33 | $wgOut->addLink( array( |
34 | 34 | 'rel' => 'stylesheet', |
35 | 35 | 'type' => 'text/css', |
36 | 36 | 'media' => "screen", |
37 | | - 'href' => $mainCssDir . 'SD_main.css' |
| 37 | + 'href' => $sdgScriptPath . '/skins/SD_main.css' |
38 | 38 | ) ); |
39 | | - $wgOut->addLink( array( |
40 | | - 'rel' => 'stylesheet', |
41 | | - 'type' => 'text/css', |
42 | | - 'media' => "screen", |
43 | | - 'href' => $mainCssDir . 'xtheme-gray.css' |
44 | | - ) ); |
45 | | - $wgOut->addLink( array( |
46 | | - 'rel' => 'stylesheet', |
47 | | - 'type' => 'text/css', |
48 | | - 'media' => "screen", |
49 | | - 'href' => $mainCssDir . 'combos.css' |
50 | | - ) ); |
| 39 | + |
51 | 40 | $javascript_text = <<<END |
52 | 41 | function toggleFilterDiv(element_id, label_element) { |
53 | 42 | element = document.getElementById(element_id); |
— | — | @@ -67,7 +56,7 @@ |
68 | 57 | } |
69 | 58 | |
70 | 59 | END; |
71 | | - $wgOut->addScript( ' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n" ); |
| 60 | + $wgOut->addScript( '<script type="text/javascript">' . "\n" . $javascript_text . '</script>' ); |
72 | 61 | |
73 | 62 | // set default |
74 | 63 | if ( $sdgNumResultsPerPage == null ) |
— | — | @@ -594,49 +583,90 @@ |
595 | 584 | } |
596 | 585 | |
597 | 586 | function printComboBoxInput( $filter_name, $filter_values, $cur_value = null ) { |
598 | | - global $wgRequest; |
| 587 | + global $wgRequest, $smwgJQueryIncluded, $smwgJQueryUIIncluded, |
| 588 | + $sdgJQueryIncluded, $sdgScriptPath, $wgOut; |
599 | 589 | |
600 | 590 | $filter_name = str_replace( ' ', '_', $filter_name ); |
601 | 591 | $input_id = "_search_$filter_name"; |
602 | | - $text = <<<END |
| 592 | + $combobox_id = "c_search_$filter_name"; |
| 593 | + if ( !$sdgJQueryIncluded ) { |
| 594 | + $wgOut->addLink( |
| 595 | + array( |
| 596 | + 'rel' => 'stylesheet', |
| 597 | + 'type' => 'text/css', |
| 598 | + 'media' => "screen", |
| 599 | + 'href' => $sdgScriptPath . "/skins/jquery-ui/base/jquery.ui.all.css" |
| 600 | + ) |
| 601 | + ); |
| 602 | + } |
603 | 603 | |
604 | | -<script> |
605 | | -Ext.onReady(function(){ |
606 | | - var {$filter_name}_values = [ |
| 604 | + $scripts = array(); |
| 605 | + if ( !$smwgJQueryIncluded ) { |
| 606 | + $scripts[] = "$sdgScriptPath/libs/jquery-1.4.2.min.js"; |
| 607 | + $smwgJQueryIncluded = true; |
| 608 | + }; |
607 | 609 | |
| 610 | + if ( !$smwgJQueryUIIncluded ) { |
| 611 | + $scripts[] = "$sdgScriptPath/libs/jquery-ui/jquery.ui.core.min.js"; |
| 612 | + $scripts[] = "$sdgScriptPath/libs/jquery-ui/jquery.ui.widget.min.js"; |
| 613 | + } |
| 614 | + if ( !$sdgJQueryIncluded ) { |
| 615 | + $scripts[] = "$sdgScriptPath/libs/jquery-ui/jquery.ui.button.min.js"; |
| 616 | + } |
| 617 | + if ( !$smwgJQueryUIIncluded ) { |
| 618 | + $scripts[] = "$sdgScriptPath/libs/jquery-ui/jquery.ui.position.min.js"; |
| 619 | + $scripts[] = "$sdgScriptPath/libs/jquery-ui/jquery.ui.autocomplete.min.js"; |
| 620 | + $smwgJQueryUIIncluded = true; |
| 621 | + } |
| 622 | + if ( !$sdgJQueryIncluded ) { |
| 623 | + $scripts[] = "$sdgScriptPath/libs/SemanticDrilldown.js"; |
| 624 | + $sdgJQueryIncluded = true; |
| 625 | + } |
| 626 | + |
| 627 | + foreach ( $scripts as $script ) { |
| 628 | + $wgOut->addScript( '<script type="text/javascript" src="' . $script . '"></script> '); |
| 629 | + } |
| 630 | + |
| 631 | + $combobox_js =<<<END |
| 632 | +<script type="text/javascript"> |
| 633 | + jQuery(document).ready(function(){ |
| 634 | + jQuery("#$combobox_id").combobox(); |
| 635 | + }); |
| 636 | +</script> |
608 | 637 | END; |
| 638 | + $wgOut->addScript( $combobox_js ); |
| 639 | + |
| 640 | + $text =<<< END |
| 641 | +<form method="get"> |
| 642 | + <div class="ui-widget"> |
| 643 | + <select id="$combobox_id" name="$cur_value"> |
| 644 | + <option value="$input_id"></option>; |
| 645 | + |
| 646 | +END; |
609 | 647 | foreach ( $filter_values as $value => $num_instances ) { |
610 | 648 | if ( $value != '_other' && $value != '_none' ) { |
611 | 649 | $display_value = str_replace( '_', ' ', $value ); |
612 | 650 | $display_value = str_replace( '\'', '\\\'', $display_value ); |
613 | | - $text .= " ['$display_value', '$display_value'],\n"; |
| 651 | + $text .= ' <option value="'.$display_value.'">'.$display_value.'</option>'; |
614 | 652 | } |
615 | 653 | } |
616 | | - $text .= <<<END |
617 | | - ] |
618 | 654 | |
619 | | - var comboFromArray = new Ext.form.ComboBox({ |
620 | | - store: {$filter_name}_values, |
621 | | - emptyText: '$cur_value', |
622 | | - applyTo: '$input_id' |
623 | | - }); |
624 | | -}); |
625 | | -</script> |
626 | | -<form method="get"> |
627 | | -<input type="text" name="$input_id" id="$input_id" value=""> |
| 655 | + $text .=<<<END |
| 656 | + </select> |
| 657 | + </div> |
628 | 658 | |
629 | 659 | END; |
630 | 660 | |
631 | 661 | foreach ( $wgRequest->getValues() as $key => $val ) { |
632 | 662 | if ( $key != $input_id ) |
633 | 663 | $text .= <<<END |
634 | | -<input type="hidden" name="$key" value="$val" /> |
| 664 | + <input type="hidden" name="$key" value="$val" /> |
635 | 665 | |
636 | 666 | END; |
637 | 667 | } |
638 | 668 | $search_label = wfMsg( 'searchresultshead' ); |
639 | 669 | $text .= <<<END |
640 | | -<input type="submit" value="$search_label" /> |
| 670 | + <input type="submit" value="$search_label" /> |
641 | 671 | </form> |
642 | 672 | |
643 | 673 | END; |
— | — | @@ -831,7 +861,7 @@ |
832 | 862 | $header .= "$subcategory_text: "; |
833 | 863 | $subcat_string = str_replace( '_', ' ', $this->subcategory ); |
834 | 864 | $remove_filter_url = $this->makeBrowseURL( $this->category, $this->applied_filters ); |
835 | | - $header .= "\n" . ' <span class="drilldown-header-value">' . $subcat_string . '</span> <a href="' . $remove_filter_url . '" title="' . wfMsg( 'sd_browsedata_removesubcategoryfilter' ) . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a>'; |
| 865 | + $header .= "\n" . ' <span class="drilldown-header-value">' . $subcat_string . '</span> <a href="' . $remove_filter_url . '" title="' . wfMsg( 'sd_browsedata_removesubcategoryfilter' ) . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a> '; |
836 | 866 | } |
837 | 867 | foreach ( $this->applied_filters as $i => $af ) { |
838 | 868 | $header .= ( ! $this->subcategory && $i == 0 ) ? " > " : "\n <span class=\"drilldown-header-value\">&</span> "; |
— | — | @@ -862,7 +892,7 @@ |
863 | 893 | $temp_filters_array[$i]->search_term = null; |
864 | 894 | $remove_filter_url = $this->makeBrowseURL( $this->category, $temp_filters_array, $this->subcategory ); |
865 | 895 | $temp_filters_array[$i]->search_term = $removed_search_term; |
866 | | - $header .= "\n " . ' <span class="drilldown-header-value">~ \'' . $af->search_term . '\'</span> <a href="' . $remove_filter_url . '" title="' . wfMsg( 'sd_browsedata_removefilter' ) . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /></a>'; |
| 896 | + $header .= "\n " . ' <span class="drilldown-header-value">~ \'' . $af->search_term . '\'</span> <a href="' . $remove_filter_url . '" title="' . wfMsg( 'sd_browsedata_removefilter' ) . '"><img src="' . $sdgScriptPath . '/skins/filter-x.png" /> </a>'; |
867 | 897 | } elseif ( $af->lower_date != null || $af->upper_date != null ) { |
868 | 898 | $header .= "\n <span class=\"drilldown-header-value\">" . $af->lower_date_string . " - " . $af->upper_date_string . "</span>"; |
869 | 899 | } |
— | — | @@ -1058,19 +1088,6 @@ |
1059 | 1089 | : implode( '', $html ); |
1060 | 1090 | |
1061 | 1091 | $out->addHTML( $html ); |
1062 | | - |
1063 | | - global $sdgScriptPath; |
1064 | | - $out->addLink( array( |
1065 | | - 'rel' => 'stylesheet', |
1066 | | - 'type' => 'text/css', |
1067 | | - 'media' => "screen", |
1068 | | - 'href' => $sdgScriptPath . '/skins/ext-all.css' |
1069 | | - ) ); |
1070 | | - // overwrite style from ext-all.css, to set the correct |
1071 | | - // image for the combobox arrow |
1072 | | - $out->addScript( "<style>.x-form-field-wrap .x-form-trigger{background:transparent url($sdgScriptPath/skins/trigger.gif) no-repeat 0 0;}</style>" ); |
1073 | | - $out->addScript( '<script type="text/javascript" src="' . $sdgScriptPath . '/libs/ext-base.js"></script>' ); |
1074 | | - $out->addScript( '<script type="text/javascript" src="' . $sdgScriptPath . '/libs/ext-all.js"></script>' ); |
1075 | 1092 | } |
1076 | 1093 | |
1077 | 1094 | // Take non-semantic result set returned by Database->query() method, and |