Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php |
— | — | @@ -703,571 +703,3 @@ |
704 | 704 | return $result; |
705 | 705 | } |
706 | 706 | } |
707 | | - |
708 | | - |
709 | | - |
710 | | - |
711 | | - |
712 | | - |
713 | | - |
714 | | - |
715 | | - |
716 | | - |
717 | | - |
718 | | -/////////////////////////////////////////////////////////////////////////////// |
719 | | -/////////////////////////////////////////////////////////////////////////////// |
720 | | -/////////////////////////////////////////////////////////////////////////////// |
721 | | -///////////// Old implementations of query printers //////////// |
722 | | -/////////////////////////////////////////////////////////////////////////////// |
723 | | -/////////////////////////////////////////////////////////////////////////////// |
724 | | -/////////////////////////////////////////////////////////////////////////////// |
725 | | - |
726 | | -/** |
727 | | - * Interface (abstract class) that must be implemented by all printers for inline |
728 | | - * query results. |
729 | | - */ |
730 | | -// interface SMWQueryPrinter { |
731 | | -// /** |
732 | | -// * Print all results and return an output string. This method needs to call back to |
733 | | -// * the query object for fetching data. |
734 | | -// */ |
735 | | -// public function printResult(); |
736 | | -// } |
737 | | -// |
738 | | -// /** |
739 | | -// * Printer for tabular data. |
740 | | -// */ |
741 | | -// class SMWTablePrinter implements SMWQueryPrinter { |
742 | | -// private $mIQ; // the querying object that called the printer |
743 | | -// private $mQuery; // the query that was executed and whose results are to be printed |
744 | | -// |
745 | | -// public function SMWTablePrinter($iq, $query) { |
746 | | -// $this->mIQ = $iq; |
747 | | -// $this->mQuery = $query; |
748 | | -// } |
749 | | -// |
750 | | -// public function printResult() { |
751 | | -// global $smwgIQRunningNumber; |
752 | | -// |
753 | | -// // print header |
754 | | -// if ('broadtable' == $this->mIQ->getFormat()) |
755 | | -// $widthpara = ' width="100%"'; |
756 | | -// else $widthpara = ''; |
757 | | -// $result = $this->mIQ->getIntro() . "<table class=\"smwtable\"$widthpara id=\"querytable" . $smwgIQRunningNumber . "\">\n"; |
758 | | -// if ($this->mIQ->showHeaders()) { |
759 | | -// $result .= "\n\t\t<tr>"; |
760 | | -// foreach ($this->mQuery->mPrint as $print_data) { |
761 | | -// $result .= "\t\t\t<th>" . $print_data[0] . "</th>\n"; |
762 | | -// } |
763 | | -// $result .= "\n\t\t</tr>"; |
764 | | -// } |
765 | | -// |
766 | | -// // print all result rows |
767 | | -// while ( $row = $this->mIQ->getNextRow() ) { |
768 | | -// $result .= "\t\t<tr>\n"; |
769 | | -// $firstcol = true; |
770 | | -// foreach ($this->mQuery->mPrint as $print_data) { |
771 | | -// $iterator = $this->mIQ->getIterator($print_data,$row,$firstcol); |
772 | | -// $result .= "<td>"; |
773 | | -// $first = true; |
774 | | -// while ($cur = $iterator->getNext()) { |
775 | | -// if ($first) $first = false; else $result .= '<br />'; |
776 | | -// $result .= $cur[0]; |
777 | | -// } |
778 | | -// $result .= "</td>"; |
779 | | -// $firstcol = false; |
780 | | -// } |
781 | | -// $result .= "\n\t\t</tr>\n"; |
782 | | -// } |
783 | | -// |
784 | | -// if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
785 | | -// $label = $this->mIQ->getSearchLabel(); |
786 | | -// if ($label === NULL) { //apply default |
787 | | -// $label = wfMsgForContent('smw_iq_moreresults'); |
788 | | -// } |
789 | | -// if ($label != '') { |
790 | | -// $result .= "\n\t\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . count($this->mQuery->mPrint) . '"> <a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a></td></tr>'; |
791 | | -// } |
792 | | -// } |
793 | | -// |
794 | | -// // print footer |
795 | | -// $result .= "\t</table>"; |
796 | | -// |
797 | | -// return $result; |
798 | | -// } |
799 | | -// } |
800 | | -// |
801 | | -// /** |
802 | | -// * Printer for list data. Somewhat confusing code, since one has to iterate through lists, |
803 | | -// * inserting texts in between their elements depending on whether the element is the first |
804 | | -// * that is printed, the first that is printed in parentheses, or the last that will be printed. |
805 | | -// * Maybe one could further simplify this. |
806 | | -// */ |
807 | | -// class SMWListPrinter implements SMWQueryPrinter { |
808 | | -// private $mIQ; // the querying object that called the printer |
809 | | -// private $mQuery; // the query that was executed and whose results are to be printed |
810 | | -// |
811 | | -// public function SMWListPrinter($iq, $query) { |
812 | | -// $this->mIQ = $iq; |
813 | | -// $this->mQuery = $query; |
814 | | -// } |
815 | | -// |
816 | | -// public function printResult() { |
817 | | -// global $wgTitle,$smwgStoreActive; |
818 | | -// // print header |
819 | | -// $result = $this->mIQ->getIntro(); |
820 | | -// $params = $this->mIQ->getParameters(); |
821 | | -// if ( ('ul' == $this->mIQ->getFormat()) || ('ol' == $this->mIQ->getFormat()) ) { |
822 | | -// $result .= '<' . $this->mIQ->getFormat() . '>'; |
823 | | -// $footer = '</' . $this->mIQ->getFormat() . '>'; |
824 | | -// $rowstart = "\n\t<li>"; |
825 | | -// $rowend = '</li>'; |
826 | | -// $plainlist = false; |
827 | | -// } else { |
828 | | -// if (array_key_exists('sep', $params)) { |
829 | | -// $listsep = htmlspecialchars(str_replace('_', ' ', $params['sep'])); |
830 | | -// $finallistsep = $listsep; |
831 | | -// } else { // default list ", , , and, " |
832 | | -// $listsep = ', '; |
833 | | -// $finallistsep = wfMsgForContent('smw_finallistconjunct') . ' '; |
834 | | -// } |
835 | | -// $footer = ''; |
836 | | -// $rowstart = ''; |
837 | | -// $rowend = ''; |
838 | | -// $plainlist = true; |
839 | | -// } |
840 | | -// |
841 | | -// if (array_key_exists('template', $params)) { |
842 | | -// $templatename = $params['template']; |
843 | | -// $parser_options = new ParserOptions(); |
844 | | -// $parser_options->setEditSection(false); // embedded sections should not have edit links |
845 | | -// $parser = new Parser(); |
846 | | -// $usetemplate = true; |
847 | | -// } else { |
848 | | -// $usetemplate = false; |
849 | | -// } |
850 | | -// |
851 | | -// // print all result rows |
852 | | -// $first_row = true; |
853 | | -// $row = $this->mIQ->getNextRow(); |
854 | | -// while ( $row ) { |
855 | | -// $nextrow = $this->mIQ->getNextRow(); // look ahead |
856 | | -// if ( !$first_row && $plainlist ) { |
857 | | -// if ($nextrow) $result .= $listsep; // the comma between "rows" other than the last one |
858 | | -// else $result .= $finallistsep; |
859 | | -// } else $result .= $rowstart; |
860 | | -// |
861 | | -// $first_col = true; |
862 | | -// if ($usetemplate) { // build template code |
863 | | -// $wikitext = ''; |
864 | | -// foreach ($this->mQuery->mPrint as $print_data) { |
865 | | -// $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
866 | | -// $wikitext .= "|"; |
867 | | -// $first_value = true; |
868 | | -// while ($cur = $iterator->getNext()) { |
869 | | -// if ($first_value) $first_value = false; else $wikitext .= ', '; |
870 | | -// $wikitext .= $cur[0]; |
871 | | -// } |
872 | | -// $first_col = false; |
873 | | -// } |
874 | | -// $result .= '{{' . $templatename . str_replace('=','|', $wikitext) . '}}'; // encode '=' for use in templates (templates fail otherwise) |
875 | | -// } else { // build simple list |
876 | | -// $first_col = true; |
877 | | -// $found_values = false; // has anything but the first column been printed? |
878 | | -// foreach ($this->mQuery->mPrint as $print_data) { |
879 | | -// $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
880 | | -// $first_value = true; |
881 | | -// while ($cur = $iterator->getNext()) { |
882 | | -// if (!$first_col && !$found_values) { // first values after first column |
883 | | -// $result .= ' ('; |
884 | | -// $found_values = true; |
885 | | -// } elseif ($found_values || !$first_value) { |
886 | | -// // any value after '(' or non-first values on first column |
887 | | -// $result .= ', '; |
888 | | -// } |
889 | | -// if ($first_value) { // first value in any column, print header |
890 | | -// $first_value = false; |
891 | | -// if ( $this->mIQ->showHeaders() && ('' != $print_data[0]) ) { |
892 | | -// $result .= $print_data[0] . ' '; |
893 | | -// } |
894 | | -// } |
895 | | -// $result .= $cur[0]; // actual output value |
896 | | -// } |
897 | | -// $first_col = false; |
898 | | -// } |
899 | | -// if ($found_values) $result .= ')'; |
900 | | -// } |
901 | | -// $result .= $rowend; |
902 | | -// $first_row = false; |
903 | | -// $row = $nextrow; |
904 | | -// } |
905 | | -// |
906 | | -// if ($usetemplate) { |
907 | | -// $old_smwgStoreActive = $smwgStoreActive; |
908 | | -// $smwgStoreActive = false; // no annotations stored, no factbox printed |
909 | | -// $parserOutput = $parser->parse($result, $wgTitle, $parser_options); |
910 | | -// $result = $parserOutput->getText(); |
911 | | -// $smwgStoreActive = $old_smwgStoreActive; |
912 | | -// } |
913 | | -// |
914 | | -// if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
915 | | -// $label = $this->mIQ->getSearchLabel(); |
916 | | -// if ($label === NULL) { //apply defaults |
917 | | -// if ('ol' == $this->mIQ->getFormat()) $label = ''; |
918 | | -// else $label = wfMsgForContent('smw_iq_moreresults'); |
919 | | -// } |
920 | | -// if (!$first_row) $result .= ' '; // relevant for list, unproblematic for ul/ol |
921 | | -// if ($label != '') { |
922 | | -// $result .= $rowstart . '<a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a>' . $rowend; |
923 | | -// } |
924 | | -// } |
925 | | -// |
926 | | -// // print footer |
927 | | -// $result .= $footer; |
928 | | -// |
929 | | -// return $result; |
930 | | -// } |
931 | | -// } |
932 | | -// |
933 | | -// /** |
934 | | -// * Printer for timeline data. |
935 | | -// */ |
936 | | -// class SMWTimelinePrinter implements SMWQueryPrinter { |
937 | | -// private $mIQ; // the querying object that called the printer |
938 | | -// private $mQuery; // the query that was executed and whose results are to be printed |
939 | | -// |
940 | | -// public function SMWTimelinePrinter($iq, $query) { |
941 | | -// $this->mIQ = $iq; |
942 | | -// $this->mQuery = $query; |
943 | | -// } |
944 | | -// |
945 | | -// public function printResult() { |
946 | | -// global $smwgIQRunningNumber; |
947 | | -// |
948 | | -// $eventline = ('eventline' == $this->mIQ->getFormat()); |
949 | | -// $params = $this->mIQ->getParameters(); |
950 | | -// |
951 | | -// $startdate = ''; |
952 | | -// |
953 | | -// if (array_key_exists('timelinestart', $params)) { |
954 | | -// $startdate = smwfNormalTitleDBKey($params['timelinestart']); |
955 | | -// } |
956 | | -// if (array_key_exists('timelineend', $params)) { |
957 | | -// $enddate = smwfNormalTitleDBKey($params['timelineend']); |
958 | | -// } else $enddate = ''; |
959 | | -// |
960 | | -// if ( !$eventline && ($startdate == '') ) { // seek defaults |
961 | | -// foreach ($this->mQuery->mPrint as $print_data) { |
962 | | -// if ( ($print_data[1] == SMW_IQ_PRINT_ATTS) && ($print_data[3]->getTypeID() == 'datetime' ) ) { |
963 | | -// if ( ($enddate == '') && ($startdate != '') && ($startdate != $print_data[2]) ) |
964 | | -// $enddate = $print_data[2]; |
965 | | -// if ( ($startdate == '') && ($enddate != $print_data[2]) ) |
966 | | -// $startdate = $print_data[2]; |
967 | | -// } |
968 | | -// } |
969 | | -// } |
970 | | -// |
971 | | -// if (array_key_exists('timelinesize', $params)) { |
972 | | -// $size = htmlspecialchars(str_replace(';', ' ', $params['timelinesize'])); // str_replace makes sure this is only one value, not mutliple CSS fields (prevent CSS attacks) |
973 | | -// } else $size = "300px"; |
974 | | -// |
975 | | -// // print header |
976 | | -// $result = "<div class=\"smwtimeline\" id=\"smwtimeline$smwgIQRunningNumber\" style=\"height: $size\">"; |
977 | | -// $result .= '<span class="smwtlcomment">' . wfMsgForContent('smw_iq_nojs',$this->mIQ->getQueryURL()) . '</span>'; // note for people without JavaScript |
978 | | -// |
979 | | -// if (array_key_exists('timelinebands', $params)) { //check for band parameter, should look like "DAY,MONTH,YEAR" |
980 | | -// $bands = preg_split('/[,][\s]?/',$params['timelinebands']); |
981 | | -// foreach ($bands as $band) { |
982 | | -// $result .= '<span class="smwtlband">' . htmlspecialchars($band) . '</span>'; |
983 | | -// //just print any "band" given, the JavaScript will figure out what to make of it |
984 | | -// } |
985 | | -// } |
986 | | -// |
987 | | -// // print all result rows |
988 | | -// $positions = array(); // possible positions, collected to select one for centering |
989 | | -// $curcolor = 0; // color cycling is used for eventline |
990 | | -// if ( ($startdate != '') || $eventline ) { |
991 | | -// $output = false; // true if output for the popup was given on current line |
992 | | -// if ($eventline) $events = array(); // array of events that are to be printed |
993 | | -// while ( $row = $this->mIQ->getNextRow() ) { |
994 | | -// $hastime = false; // true as soon as some startdate value was found |
995 | | -// $hastitle = false; // true as soon as some label for the event was found |
996 | | -// $curdata = ''; // current *inner* print data (within some event span) |
997 | | -// $curmeta = ''; // current event meta data |
998 | | -// $curarticle = ''; // label of current article, if it was found |
999 | | -// $first_col = true; |
1000 | | -// foreach ($this->mQuery->mPrint as $print_data) { |
1001 | | -// $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
1002 | | -// $first_value = true; |
1003 | | -// while ($cur = $iterator->getNext()) { |
1004 | | -// $header = ''; |
1005 | | -// if ($first_value) { |
1006 | | -// // find header for current value: |
1007 | | -// if ( $this->mIQ->showHeaders() && ('' != $print_data[0]) ) { |
1008 | | -// $header = $print_data[0] . ' '; |
1009 | | -// } |
1010 | | -// // is this a start date? |
1011 | | -// if ( ($print_data[1] == SMW_IQ_PRINT_ATTS) && ($print_data[2] == $startdate) ) { |
1012 | | -// //FIXME: Timeline scripts should support XSD format explicitly. They |
1013 | | -// //currently seem to implement iso8601 which deviates from XSD in cases. |
1014 | | -// $curmeta .= '<span class="smwtlstart">' . $cur[1]->getXSDValue() . '</span>'; |
1015 | | -// $positions[$cur[1]->getNumericValue()] = $cur[1]->getXSDValue(); |
1016 | | -// $hastime = true; |
1017 | | -// } |
1018 | | -// // is this the end date? |
1019 | | -// if ( ($print_data[1] == SMW_IQ_PRINT_ATTS) && ($print_data[2] == $enddate) ) { |
1020 | | -// $curmeta .= '<span class="smwtlend">' . $cur[1]->getXSDValue() . '</span>'; |
1021 | | -// } |
1022 | | -// // find title for displaying event |
1023 | | -// if ( !$hastitle ) { |
1024 | | -// if ( mb_substr($cur[0],0,3) == '<a ') // treat hyperlinks differently |
1025 | | -// $curmeta .= '<span class="smwtlurl">' . $cur[0] . '</span>'; |
1026 | | -// else $curmeta .= '<span class="smwtltitle">' . $cur[0] . '</span>'; |
1027 | | -// if ( ($print_data[1] == SMW_IQ_PRINT_RSEL) ) { // $cur describes an article title |
1028 | | -// $curarticle = $cur[2]; |
1029 | | -// } |
1030 | | -// $hastitle = true; |
1031 | | -// } |
1032 | | -// } elseif ($output) $curdata .= ', '; //it *can* happen that output is false here, if the subject was not printed (fixed subbjct query) and mutliple items appear in the first row |
1033 | | -// if (!$first_col || !$first_value || $eventline) { |
1034 | | -// $curdata .= $header . $cur[0]; |
1035 | | -// $output = true; |
1036 | | -// } |
1037 | | -// if ($eventline && ($print_data[1] == SMW_IQ_PRINT_ATTS) && ($print_data[3]->getTypeID() == 'datetime') && ('' != $print_data[0]) && ($print_data[2] != $startdate) && ($print_data[2] != $enddate) ) { |
1038 | | -// $events[] = array($cur[1]->getXSDValue(), $print_data[0], $cur[1]->getNumericValue()); |
1039 | | -// } |
1040 | | -// $first_value = false; |
1041 | | -// } |
1042 | | -// if ($output) $curdata .= "<br />"; |
1043 | | -// $output = false; |
1044 | | -// $first_col = false; |
1045 | | -// } |
1046 | | -// |
1047 | | -// if ( $hastime ) { |
1048 | | -// $result .= '<span class="smwtlevent">' . $curmeta . '<span class="smwtlcoloricon">' . $curcolor . '</span>' . $curdata . '</span>'; |
1049 | | -// } |
1050 | | -// if ( $eventline ) { |
1051 | | -// foreach ($events as $event) { |
1052 | | -// $result .= '<span class="smwtlevent"><span class="smwtlstart">' . $event[0] . '</span><span class="smwtlurl">' . $event[1] . '</span><span class="smwtlcoloricon">' . $curcolor . '</span>'; |
1053 | | -// if ( $curarticle != '' ) $result .= '<span class="smwtlprefix">' . $curarticle . ' </span>'; |
1054 | | -// $result .= $curdata . '</span>'; |
1055 | | -// $positions[$event[2]] = $event[0]; |
1056 | | -// } |
1057 | | -// $events = array(); |
1058 | | -// $curcolor = ($curcolor + 1) % 10; |
1059 | | -// } |
1060 | | -// } |
1061 | | -// // find display position: |
1062 | | -// if (array_key_exists('timelineposition', $params)) { |
1063 | | -// $pos = $params['timelineposition']; |
1064 | | -// } else $pos = 'middle'; |
1065 | | -// ksort($positions); |
1066 | | -// $positions = array_values($positions); |
1067 | | -// switch ($pos) { |
1068 | | -// case 'start': |
1069 | | -// $result .= '<span class="smwtlposition">' . $positions[0] . '</span>'; |
1070 | | -// break; |
1071 | | -// case 'end': |
1072 | | -// $result .= '<span class="smwtlposition">' . $positions[count($positions)-1] . '</span>'; |
1073 | | -// break; |
1074 | | -// case 'today': break; // default |
1075 | | -// case 'middle': default: |
1076 | | -// $result .= '<span class="smwtlposition">' . $positions[ceil(count($positions)/2)-1] . '</span>'; |
1077 | | -// break; |
1078 | | -// } |
1079 | | -// } |
1080 | | -// |
1081 | | -// // if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
1082 | | -// // $label = $this->mIQ->getSearchLabel(); |
1083 | | -// // if ($label === NULL) { //apply default |
1084 | | -// // $label = wfMsgForContent('smw_iq_moreresults'); |
1085 | | -// // } |
1086 | | -// // if ($label != '') { |
1087 | | -// // $result .= "\n\t\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . count($this->mQuery->mPrint) . '\"> <a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a></td></tr>'; |
1088 | | -// // } |
1089 | | -// // } |
1090 | | -// |
1091 | | -// // print footer |
1092 | | -// $result .= "</div>"; |
1093 | | -// |
1094 | | -// return $result; |
1095 | | -// } |
1096 | | -// } |
1097 | | -// |
1098 | | -// /** |
1099 | | -// * Printer for embedded data. |
1100 | | -// * Embeds in the page output the contents of the pages in the query result set. |
1101 | | -// * Only the first column of the query is considered. If it is a page reference then that page's contents is embedded. |
1102 | | -// * The optional "titlestyle" formatting parameter can be used to apply a format to the headings for the page titles. |
1103 | | -// * If "titlestyle" is not specified, a <h1> tag is used. |
1104 | | -// * @author Fernando Correia |
1105 | | -// * @author Markus Kr�tzsch |
1106 | | -// */ |
1107 | | -// class SMWEmbeddedPrinter implements SMWQueryPrinter { |
1108 | | -// private $mIQ; // the querying object that called the printer |
1109 | | -// private $mQuery; // the query that was executed and whose results are to be printed |
1110 | | -// |
1111 | | -// public function SMWEmbeddedPrinter($iq, $query) { |
1112 | | -// $this->mIQ = $iq; |
1113 | | -// $this->mQuery = $query; |
1114 | | -// } |
1115 | | -// |
1116 | | -// public function printResult() { |
1117 | | -// // handle factbox |
1118 | | -// global $smwgStoreActive; |
1119 | | -// $old_smwgStoreActive = $smwgStoreActive; |
1120 | | -// $smwgStoreActive = false; // no annotations stored, no factbox printed |
1121 | | -// |
1122 | | -// // print header |
1123 | | -// $result = $this->mIQ->getIntro(); |
1124 | | -// |
1125 | | -// // use titleformat parameter if specified |
1126 | | -// $params = $this->mIQ->getParameters(); |
1127 | | -// if (array_key_exists('embedonly', $params)) { |
1128 | | -// $showhead = false; |
1129 | | -// } else { |
1130 | | -// $showhead = true; |
1131 | | -// } |
1132 | | -// |
1133 | | -// if (array_key_exists('embedformat', $params)) { |
1134 | | -// switch ($params['embedformat']) { |
1135 | | -// case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': |
1136 | | -// $footer = ''; |
1137 | | -// $embstart = ''; |
1138 | | -// $headstart = '<' . $params['embedformat'] . '>'; |
1139 | | -// $headend = '</' . $params['embedformat'] . ">\n"; |
1140 | | -// $embend = ''; |
1141 | | -// break; |
1142 | | -// case 'ul': case 'ol': |
1143 | | -// $result .= '<' . $params['embedformat'] . '>'; |
1144 | | -// $footer = '</' . $params['embedformat'] . '>'; |
1145 | | -// $embstart = '<li>'; |
1146 | | -// $headstart = ''; |
1147 | | -// $headend = "<br />\n"; |
1148 | | -// $embend = "</li>\n"; |
1149 | | -// break; |
1150 | | -// } |
1151 | | -// } else { |
1152 | | -// $footer = ''; |
1153 | | -// $embstart = ''; |
1154 | | -// $headstart = '<h1>'; |
1155 | | -// $headend = "</h1>\n"; |
1156 | | -// $embend = ''; |
1157 | | -// } |
1158 | | -// |
1159 | | -// // print all result rows |
1160 | | -// $parser_options = new ParserOptions(); |
1161 | | -// $parser_options->setEditSection(false); // embedded sections should not have edit links |
1162 | | -// $parser = new Parser(); |
1163 | | -// |
1164 | | -// while ( $row = $this->mIQ->getNextRow() ) { |
1165 | | -// $first_col = true; |
1166 | | -// foreach ($this->mQuery->mPrint as $print_data) { |
1167 | | -// $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
1168 | | -// if ( ($print_data[1] == SMW_IQ_PRINT_RELS) || ($print_data[1] == SMW_IQ_PRINT_RSEL) ) { |
1169 | | -// while ($cur = $iterator->getNext()) { |
1170 | | -// $result .= $embstart; |
1171 | | -// if ($showhead) { |
1172 | | -// $result .= $headstart . $cur[0] . $headend; |
1173 | | -// } |
1174 | | -// $article_namespace = $cur[1]; |
1175 | | -// $article_title = $cur[2]; // TODO: ouch .. we need to check whether this exists |
1176 | | -// if ( (NULL != $article_title) and ('' != $article_title) ) { |
1177 | | -// $title_text = $article_namespace; |
1178 | | -// if ($title_text != '') $title_text .= ':'; |
1179 | | -// $title_text .= $article_title; |
1180 | | -// $title = Title::newFromText($title_text); // TODO: is this actually the right title to use for parsing? |
1181 | | -// if (NULL != $title) { |
1182 | | -// $parserOutput = $parser->parse('{{' . $article_namespace . ':' . $article_title . '}}', $title, $parser_options); |
1183 | | -// $result .= $parserOutput->getText(); |
1184 | | -// } |
1185 | | -// } |
1186 | | -// $result .= $embend; |
1187 | | -// } |
1188 | | -// } |
1189 | | -// break; // only use first column for now |
1190 | | -// } |
1191 | | -// } |
1192 | | -// |
1193 | | -// // show link to more results |
1194 | | -// if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
1195 | | -// $label = $this->mIQ->getSearchLabel(); |
1196 | | -// if ($label === NULL) { //apply defaults |
1197 | | -// $label = wfMsgForContent('smw_iq_moreresults'); |
1198 | | -// } |
1199 | | -// if ($label != '') { |
1200 | | -// $result .= $embstart . '<a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a>' . $embend ; |
1201 | | -// } |
1202 | | -// } |
1203 | | -// $result .= $footer; |
1204 | | -// |
1205 | | -// $smwgStoreActive = $old_smwgStoreActive; |
1206 | | -// return $result; |
1207 | | -// } |
1208 | | -// } |
1209 | | -// |
1210 | | -// /** |
1211 | | -// * Printer for template data. Passes a result a result row as anonymous parameters to |
1212 | | -// * a given template (which might ignore them or not) and prints the result. Values |
1213 | | -// */ |
1214 | | -// class SMWTemplatePrinter implements SMWQueryPrinter { |
1215 | | -// private $mIQ; // the querying object that called the printer |
1216 | | -// private $mQuery; // the query that was executed and whose results are to be printed |
1217 | | -// |
1218 | | -// public function SMWTemplatePrinter($iq, $query) { |
1219 | | -// $this->mIQ = $iq; |
1220 | | -// $this->mQuery = $query; |
1221 | | -// } |
1222 | | -// |
1223 | | -// public function printResult() { |
1224 | | -// // handle factbox |
1225 | | -// global $smwgStoreActive, $wgTitle; |
1226 | | -// $old_smwgStoreActive = $smwgStoreActive; |
1227 | | -// $smwgStoreActive = false; // no annotations stored, no factbox printed |
1228 | | -// |
1229 | | -// // print all result rows |
1230 | | -// $parserinput = $this->mIQ->getIntro(); |
1231 | | -// $params = $this->mIQ->getParameters(); |
1232 | | -// if (array_key_exists('template', $params)) { |
1233 | | -// $templatename = $params['template']; |
1234 | | -// } else { |
1235 | | -// return 'Please set parameter "template" for <ask> to work.'; // TODO: internationalise |
1236 | | -// } |
1237 | | -// |
1238 | | -// $parser_options = new ParserOptions(); |
1239 | | -// $parser_options->setEditSection(false); // embedded sections should not have edit links |
1240 | | -// $parser = new Parser(); |
1241 | | -// while ( $row = $this->mIQ->getNextRow() ) { |
1242 | | -// $wikitext = ''; |
1243 | | -// $firstcol = true; |
1244 | | -// foreach ($this->mQuery->mPrint as $print_data) { |
1245 | | -// $iterator = $this->mIQ->getIterator($print_data,$row,$firstcol); |
1246 | | -// $wikitext .= "|"; |
1247 | | -// $first = true; |
1248 | | -// while ($cur = $iterator->getNext()) { |
1249 | | -// if ($first) $first = false; else $wikitext .= ', '; |
1250 | | -// $wikitext .= $cur[0]; |
1251 | | -// } |
1252 | | -// $firstcol = false; |
1253 | | -// } |
1254 | | -// $parserinput .= '{{' . $templatename . str_replace('=','|', $wikitext) . '}}'; // encode '=' for use in templates (templates fail otherwise) |
1255 | | -// } |
1256 | | -// $parserOutput = $parser->parse($parserinput, $wgTitle, $parser_options); |
1257 | | -// $result = $parserOutput->getText(); |
1258 | | -// // show link to more results |
1259 | | -// if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
1260 | | -// $label = $this->mIQ->getSearchLabel(); |
1261 | | -// if ($label === NULL) { //apply defaults |
1262 | | -// $label = wfMsgForContent('smw_iq_moreresults'); |
1263 | | -// } |
1264 | | -// if ($label != '') { |
1265 | | -// $result .= '<a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a>'; |
1266 | | -// } |
1267 | | -// } |
1268 | | -// |
1269 | | -// $smwgStoreActive = $old_smwgStoreActive; |
1270 | | -// return $result; |
1271 | | -// } |
1272 | | -// } |
1273 | | - |
1274 | | - |