Index: trunk/extensions/SemanticMediaWiki/includes/SMW_InlineQueries.php |
— | — | @@ -39,57 +39,8 @@ |
40 | 40 | require_once( "$IP/includes/Linker.php" ); |
41 | 41 | require_once('SMW_QueryPrinters.php'); |
42 | 42 | |
43 | | -/* The variables below define the default settings. Changes can be made by |
44 | | - setting new values in SMW_LocalSettings.php */ |
45 | | - |
46 | | -/* Configure default behaviour of inline queries */ |
47 | | - // Default linking behaviour. Can be one of "none", "subject", "all" |
48 | | - $smwgIQDefaultLinking = 'subject'; |
49 | | - // Which namespaces should be searched by default? Setting this to NULL will |
50 | | - // switch off such default restrictions on searching (possibly increasing performance) |
51 | | - $smwgIQSearchNamespaces = array(NS_MAIN, NS_IMAGE); |
52 | | -/* Configure power/performance trade-off for inline queries */ |
53 | | - // Switches on or off all queries. |
54 | | - $smwgIQEnabled = true; |
55 | | - // Maximum number of conditions *overall*. Each value restriction is counted as |
56 | | - // one, i.e. a disjunction || counts for each of its disjuncts. Note that subcategories |
57 | | - // and resolved redirects currently extend the number of conditions as well! |
58 | | - $smwgIQMaxConditions = 50; |
59 | | - // Maximum number of tables to be joined *overall*. Note that the combination of DISTINCT |
60 | | - // and restricted SELECT statements ensures that further joins do not multiply the number |
61 | | - // of results. Still it is desirable to restrict this number below $smwgIQMaxConditions. |
62 | | - $smwgIQMaxTables = 10; |
63 | | - // Maximum number of additional fields that can be displayed using statements with '*'. |
64 | | - // This implicitly also limits the number of rows in output tables. |
65 | | - $smwgIQMaxPrintout = 10; |
66 | | - // Switches on or off all subqueries. |
67 | | - $smwgIQSubQueriesEnabled = true; |
68 | | - // Maximum number of rows returned in any query. |
69 | | - $smwgIQMaxLimit = 10000; //practically no limit |
70 | | - // Maximum number of rows printed in an inline query. |
71 | | - $smwgIQMaxInlineLimit = 500; |
72 | | - // Default number of rows returned in a query. |
73 | | - $smwgIQDefaultLimit = 50; |
74 | | - // If true, disjunctive queries are enabled. May cost performance. |
75 | | - $smwgIQDisjunctiveQueriesEnabled = true; |
76 | | - // Sets the level of inclusions by subCategory-relations. For example, if Student |
77 | | - // is a Subcategory of Person, Students will only be returned if querying for Persons |
78 | | - // if this is set at least to 1 (as it is a direct Subcategory). |
79 | | - // Disjunctive queries must be enabled for this feature to work. May cost performance. |
80 | | - $smwgIQSubcategoryInclusions = 10; |
81 | | - // Normalizes the redirects, basically implements the sameAs semantics |
82 | | - // as defined by the mapping of redirects to sameAs. |
83 | | - // Disjunctive queries must be enabled for this feature to work. May cost performance. |
84 | | - $smwgIQRedirectNormalization = true; |
85 | | - // If true, sorting is enabled. May cost performance. |
86 | | - $smwgIQSortingEnabled = true; |
87 | | - |
88 | | -// first, we register a hook that will register a hook in the parser |
89 | | -// global $wgHooks; |
90 | | -// $wgHooks['ParserBeforeStrip'][] = 'smwfRegisterInlineQueries'; |
91 | | - |
92 | 43 | // This hook registers a hook in the parser |
93 | | -function smwfRegisterInlineQueries( $semantic, $mediawiki, $rules ) { |
| 44 | +function smwfOldRegisterInlineQueries( $semantic, $mediawiki, $rules ) { |
94 | 45 | global $wgParser; |
95 | 46 | $wgParser->setHook( 'ask', 'smwfProcessInlineQueries' ); |
96 | 47 | return true; // always return true, in order not to stop MW's hook processing! |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php |
— | — | @@ -864,7 +864,7 @@ |
865 | 865 | // nothin to check |
866 | 866 | } elseif ($description instanceof SMWClassDescription) { |
867 | 867 | if ($this->addInnerJoin('CATS', $from, $db, $curtables)) { |
868 | | - $where .= $curtables['CATS'] . '.cl_to=' . $db->addQuotes($description->getCategory()->getText()); |
| 868 | + $where .= $curtables['CATS'] . '.cl_to=' . $db->addQuotes($description->getCategory()->getDBKey()); |
869 | 869 | } |
870 | 870 | } elseif ($description instanceof SMWNominalDescription) { |
871 | 871 | if (array_key_exists('PREVREL', $curtables)) { |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -89,6 +89,8 @@ |
90 | 90 | require_once($smwgIP . '/specials/AskSpecial/SMW_SpecialAsk.php'); |
91 | 91 | require_once($smwgIP . '/specials/ExtendedStatistics/SMW_SpecialExtendedStatistics.php'); |
92 | 92 | |
| 93 | + include_once($smwgIP . '/includes/SMW_QueryProcessor.php'); |
| 94 | + |
93 | 95 | require_once($smwgIP . '/specials/Relations/SMW_SpecialRelations.php'); |
94 | 96 | require_once($smwgIP . '/specials/Relations/SMW_SpecialUnusedRelations.php'); |
95 | 97 | require_once($smwgIP . '/specials/Relations/SMW_SpecialWantedRelations.php'); |
— | — | @@ -115,6 +117,7 @@ |
116 | 118 | $wgHooks['TitleMoveComplete'][]='smwfMoveHook'; |
117 | 119 | $wgHooks['BeforePageDisplay'][]='smwfAddHTMLHeader'; |
118 | 120 | $wgHooks['ParserBeforeStrip'][] = 'smwfRegisterInlineQueries'; // a hook for registering the <ask> parser hook |
| 121 | + |
119 | 122 | $wgHooks['ArticleFromTitle'][] = 'smwfShowListPage'; |
120 | 123 | |
121 | 124 | /**********************************************/ |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php |
— | — | @@ -687,7 +687,7 @@ |
688 | 688 | /////////////////////////////////////////////////////////////////////////////// |
689 | 689 | /////////////////////////////////////////////////////////////////////////////// |
690 | 690 | /////////////////////////////////////////////////////////////////////////////// |
691 | | -///////////// Old (still active) implementations of query printers //////////// |
| 691 | +///////////// Old implementations of query printers //////////// |
692 | 692 | /////////////////////////////////////////////////////////////////////////////// |
693 | 693 | /////////////////////////////////////////////////////////////////////////////// |
694 | 694 | /////////////////////////////////////////////////////////////////////////////// |
— | — | @@ -696,548 +696,548 @@ |
697 | 697 | * Interface (abstract class) that must be implemented by all printers for inline |
698 | 698 | * query results. |
699 | 699 | */ |
700 | | -interface SMWQueryPrinter { |
701 | | - /** |
702 | | - * Print all results and return an output string. This method needs to call back to |
703 | | - * the query object for fetching data. |
704 | | - */ |
705 | | - public function printResult(); |
706 | | -} |
707 | | - |
708 | | -/** |
709 | | - * Printer for tabular data. |
710 | | - */ |
711 | | -class SMWTablePrinter implements SMWQueryPrinter { |
712 | | - private $mIQ; // the querying object that called the printer |
713 | | - private $mQuery; // the query that was executed and whose results are to be printed |
714 | | - |
715 | | - public function SMWTablePrinter($iq, $query) { |
716 | | - $this->mIQ = $iq; |
717 | | - $this->mQuery = $query; |
718 | | - } |
719 | | - |
720 | | - public function printResult() { |
721 | | - global $smwgIQRunningNumber; |
722 | | - |
723 | | - // print header |
724 | | - if ('broadtable' == $this->mIQ->getFormat()) |
725 | | - $widthpara = ' width="100%"'; |
726 | | - else $widthpara = ''; |
727 | | - $result = $this->mIQ->getIntro() . "<table class=\"smwtable\"$widthpara id=\"querytable" . $smwgIQRunningNumber . "\">\n"; |
728 | | - if ($this->mIQ->showHeaders()) { |
729 | | - $result .= "\n\t\t<tr>"; |
730 | | - foreach ($this->mQuery->mPrint as $print_data) { |
731 | | - $result .= "\t\t\t<th>" . $print_data[0] . "</th>\n"; |
732 | | - } |
733 | | - $result .= "\n\t\t</tr>"; |
734 | | - } |
735 | | - |
736 | | - // print all result rows |
737 | | - while ( $row = $this->mIQ->getNextRow() ) { |
738 | | - $result .= "\t\t<tr>\n"; |
739 | | - $firstcol = true; |
740 | | - foreach ($this->mQuery->mPrint as $print_data) { |
741 | | - $iterator = $this->mIQ->getIterator($print_data,$row,$firstcol); |
742 | | - $result .= "<td>"; |
743 | | - $first = true; |
744 | | - while ($cur = $iterator->getNext()) { |
745 | | - if ($first) $first = false; else $result .= '<br />'; |
746 | | - $result .= $cur[0]; |
747 | | - } |
748 | | - $result .= "</td>"; |
749 | | - $firstcol = false; |
750 | | - } |
751 | | - $result .= "\n\t\t</tr>\n"; |
752 | | - } |
753 | | - |
754 | | - if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
755 | | - $label = $this->mIQ->getSearchLabel(); |
756 | | - if ($label === NULL) { //apply default |
757 | | - $label = wfMsgForContent('smw_iq_moreresults'); |
758 | | - } |
759 | | - if ($label != '') { |
760 | | - $result .= "\n\t\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . count($this->mQuery->mPrint) . '"> <a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a></td></tr>'; |
761 | | - } |
762 | | - } |
763 | | - |
764 | | - // print footer |
765 | | - $result .= "\t</table>"; |
766 | | - |
767 | | - return $result; |
768 | | - } |
769 | | -} |
770 | | - |
771 | | -/** |
772 | | - * Printer for list data. Somewhat confusing code, since one has to iterate through lists, |
773 | | - * inserting texts in between their elements depending on whether the element is the first |
774 | | - * that is printed, the first that is printed in parentheses, or the last that will be printed. |
775 | | - * Maybe one could further simplify this. |
776 | | - */ |
777 | | -class SMWListPrinter implements SMWQueryPrinter { |
778 | | - private $mIQ; // the querying object that called the printer |
779 | | - private $mQuery; // the query that was executed and whose results are to be printed |
780 | | - |
781 | | - public function SMWListPrinter($iq, $query) { |
782 | | - $this->mIQ = $iq; |
783 | | - $this->mQuery = $query; |
784 | | - } |
785 | | - |
786 | | - public function printResult() { |
787 | | - global $wgTitle,$smwgStoreActive; |
788 | | - // print header |
789 | | - $result = $this->mIQ->getIntro(); |
790 | | - $params = $this->mIQ->getParameters(); |
791 | | - if ( ('ul' == $this->mIQ->getFormat()) || ('ol' == $this->mIQ->getFormat()) ) { |
792 | | - $result .= '<' . $this->mIQ->getFormat() . '>'; |
793 | | - $footer = '</' . $this->mIQ->getFormat() . '>'; |
794 | | - $rowstart = "\n\t<li>"; |
795 | | - $rowend = '</li>'; |
796 | | - $plainlist = false; |
797 | | - } else { |
798 | | - if (array_key_exists('sep', $params)) { |
799 | | - $listsep = htmlspecialchars(str_replace('_', ' ', $params['sep'])); |
800 | | - $finallistsep = $listsep; |
801 | | - } else { // default list ", , , and, " |
802 | | - $listsep = ', '; |
803 | | - $finallistsep = wfMsgForContent('smw_finallistconjunct') . ' '; |
804 | | - } |
805 | | - $footer = ''; |
806 | | - $rowstart = ''; |
807 | | - $rowend = ''; |
808 | | - $plainlist = true; |
809 | | - } |
810 | | - |
811 | | - if (array_key_exists('template', $params)) { |
812 | | - $templatename = $params['template']; |
813 | | - $parser_options = new ParserOptions(); |
814 | | - $parser_options->setEditSection(false); // embedded sections should not have edit links |
815 | | - $parser = new Parser(); |
816 | | - $usetemplate = true; |
817 | | - } else { |
818 | | - $usetemplate = false; |
819 | | - } |
820 | | - |
821 | | - // print all result rows |
822 | | - $first_row = true; |
823 | | - $row = $this->mIQ->getNextRow(); |
824 | | - while ( $row ) { |
825 | | - $nextrow = $this->mIQ->getNextRow(); // look ahead |
826 | | - if ( !$first_row && $plainlist ) { |
827 | | - if ($nextrow) $result .= $listsep; // the comma between "rows" other than the last one |
828 | | - else $result .= $finallistsep; |
829 | | - } else $result .= $rowstart; |
830 | | - |
831 | | - $first_col = true; |
832 | | - if ($usetemplate) { // build template code |
833 | | - $wikitext = ''; |
834 | | - foreach ($this->mQuery->mPrint as $print_data) { |
835 | | - $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
836 | | - $wikitext .= "|"; |
837 | | - $first_value = true; |
838 | | - while ($cur = $iterator->getNext()) { |
839 | | - if ($first_value) $first_value = false; else $wikitext .= ', '; |
840 | | - $wikitext .= $cur[0]; |
841 | | - } |
842 | | - $first_col = false; |
843 | | - } |
844 | | - $result .= '{{' . $templatename . str_replace('=','|', $wikitext) . '}}'; // encode '=' for use in templates (templates fail otherwise) |
845 | | - } else { // build simple list |
846 | | - $first_col = true; |
847 | | - $found_values = false; // has anything but the first column been printed? |
848 | | - foreach ($this->mQuery->mPrint as $print_data) { |
849 | | - $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
850 | | - $first_value = true; |
851 | | - while ($cur = $iterator->getNext()) { |
852 | | - if (!$first_col && !$found_values) { // first values after first column |
853 | | - $result .= ' ('; |
854 | | - $found_values = true; |
855 | | - } elseif ($found_values || !$first_value) { |
856 | | - // any value after '(' or non-first values on first column |
857 | | - $result .= ', '; |
858 | | - } |
859 | | - if ($first_value) { // first value in any column, print header |
860 | | - $first_value = false; |
861 | | - if ( $this->mIQ->showHeaders() && ('' != $print_data[0]) ) { |
862 | | - $result .= $print_data[0] . ' '; |
863 | | - } |
864 | | - } |
865 | | - $result .= $cur[0]; // actual output value |
866 | | - } |
867 | | - $first_col = false; |
868 | | - } |
869 | | - if ($found_values) $result .= ')'; |
870 | | - } |
871 | | - $result .= $rowend; |
872 | | - $first_row = false; |
873 | | - $row = $nextrow; |
874 | | - } |
875 | | - |
876 | | - if ($usetemplate) { |
877 | | - $old_smwgStoreActive = $smwgStoreActive; |
878 | | - $smwgStoreActive = false; // no annotations stored, no factbox printed |
879 | | - $parserOutput = $parser->parse($result, $wgTitle, $parser_options); |
880 | | - $result = $parserOutput->getText(); |
881 | | - $smwgStoreActive = $old_smwgStoreActive; |
882 | | - } |
883 | | - |
884 | | - if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
885 | | - $label = $this->mIQ->getSearchLabel(); |
886 | | - if ($label === NULL) { //apply defaults |
887 | | - if ('ol' == $this->mIQ->getFormat()) $label = ''; |
888 | | - else $label = wfMsgForContent('smw_iq_moreresults'); |
889 | | - } |
890 | | - if (!$first_row) $result .= ' '; // relevant for list, unproblematic for ul/ol |
891 | | - if ($label != '') { |
892 | | - $result .= $rowstart . '<a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a>' . $rowend; |
893 | | - } |
894 | | - } |
895 | | - |
896 | | - // print footer |
897 | | - $result .= $footer; |
898 | | - |
899 | | - return $result; |
900 | | - } |
901 | | -} |
902 | | - |
903 | | -/** |
904 | | - * Printer for timeline data. |
905 | | - */ |
906 | | -class SMWTimelinePrinter implements SMWQueryPrinter { |
907 | | - private $mIQ; // the querying object that called the printer |
908 | | - private $mQuery; // the query that was executed and whose results are to be printed |
909 | | - |
910 | | - public function SMWTimelinePrinter($iq, $query) { |
911 | | - $this->mIQ = $iq; |
912 | | - $this->mQuery = $query; |
913 | | - } |
914 | | - |
915 | | - public function printResult() { |
916 | | - global $smwgIQRunningNumber; |
917 | | - |
918 | | - $eventline = ('eventline' == $this->mIQ->getFormat()); |
919 | | - $params = $this->mIQ->getParameters(); |
920 | | - |
921 | | - $startdate = ''; |
922 | | - |
923 | | - if (array_key_exists('timelinestart', $params)) { |
924 | | - $startdate = smwfNormalTitleDBKey($params['timelinestart']); |
925 | | - } |
926 | | - if (array_key_exists('timelineend', $params)) { |
927 | | - $enddate = smwfNormalTitleDBKey($params['timelineend']); |
928 | | - } else $enddate = ''; |
929 | | - |
930 | | - if ( !$eventline && ($startdate == '') ) { // seek defaults |
931 | | - foreach ($this->mQuery->mPrint as $print_data) { |
932 | | - if ( ($print_data[1] == SMW_IQ_PRINT_ATTS) && ($print_data[3]->getTypeID() == 'datetime' ) ) { |
933 | | - if ( ($enddate == '') && ($startdate != '') && ($startdate != $print_data[2]) ) |
934 | | - $enddate = $print_data[2]; |
935 | | - if ( ($startdate == '') && ($enddate != $print_data[2]) ) |
936 | | - $startdate = $print_data[2]; |
937 | | - } |
938 | | - } |
939 | | - } |
940 | | - |
941 | | - if (array_key_exists('timelinesize', $params)) { |
942 | | - $size = htmlspecialchars(str_replace(';', ' ', $params['timelinesize'])); // str_replace makes sure this is only one value, not mutliple CSS fields (prevent CSS attacks) |
943 | | - } else $size = "300px"; |
944 | | - |
945 | | - // print header |
946 | | - $result = "<div class=\"smwtimeline\" id=\"smwtimeline$smwgIQRunningNumber\" style=\"height: $size\">"; |
947 | | - $result .= '<span class="smwtlcomment">' . wfMsgForContent('smw_iq_nojs',$this->mIQ->getQueryURL()) . '</span>'; // note for people without JavaScript |
948 | | - |
949 | | - if (array_key_exists('timelinebands', $params)) { //check for band parameter, should look like "DAY,MONTH,YEAR" |
950 | | - $bands = preg_split('/[,][\s]?/',$params['timelinebands']); |
951 | | - foreach ($bands as $band) { |
952 | | - $result .= '<span class="smwtlband">' . htmlspecialchars($band) . '</span>'; |
953 | | - //just print any "band" given, the JavaScript will figure out what to make of it |
954 | | - } |
955 | | - } |
956 | | - |
957 | | - // print all result rows |
958 | | - $positions = array(); // possible positions, collected to select one for centering |
959 | | - $curcolor = 0; // color cycling is used for eventline |
960 | | - if ( ($startdate != '') || $eventline ) { |
961 | | - $output = false; // true if output for the popup was given on current line |
962 | | - if ($eventline) $events = array(); // array of events that are to be printed |
963 | | - while ( $row = $this->mIQ->getNextRow() ) { |
964 | | - $hastime = false; // true as soon as some startdate value was found |
965 | | - $hastitle = false; // true as soon as some label for the event was found |
966 | | - $curdata = ''; // current *inner* print data (within some event span) |
967 | | - $curmeta = ''; // current event meta data |
968 | | - $curarticle = ''; // label of current article, if it was found |
969 | | - $first_col = true; |
970 | | - foreach ($this->mQuery->mPrint as $print_data) { |
971 | | - $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
972 | | - $first_value = true; |
973 | | - while ($cur = $iterator->getNext()) { |
974 | | - $header = ''; |
975 | | - if ($first_value) { |
976 | | - // find header for current value: |
977 | | - if ( $this->mIQ->showHeaders() && ('' != $print_data[0]) ) { |
978 | | - $header = $print_data[0] . ' '; |
979 | | - } |
980 | | - // is this a start date? |
981 | | - if ( ($print_data[1] == SMW_IQ_PRINT_ATTS) && ($print_data[2] == $startdate) ) { |
982 | | - //FIXME: Timeline scripts should support XSD format explicitly. They |
983 | | - //currently seem to implement iso8601 which deviates from XSD in cases. |
984 | | - $curmeta .= '<span class="smwtlstart">' . $cur[1]->getXSDValue() . '</span>'; |
985 | | - $positions[$cur[1]->getNumericValue()] = $cur[1]->getXSDValue(); |
986 | | - $hastime = true; |
987 | | - } |
988 | | - // is this the end date? |
989 | | - if ( ($print_data[1] == SMW_IQ_PRINT_ATTS) && ($print_data[2] == $enddate) ) { |
990 | | - $curmeta .= '<span class="smwtlend">' . $cur[1]->getXSDValue() . '</span>'; |
991 | | - } |
992 | | - // find title for displaying event |
993 | | - if ( !$hastitle ) { |
994 | | - if ( mb_substr($cur[0],0,3) == '<a ') // treat hyperlinks differently |
995 | | - $curmeta .= '<span class="smwtlurl">' . $cur[0] . '</span>'; |
996 | | - else $curmeta .= '<span class="smwtltitle">' . $cur[0] . '</span>'; |
997 | | - if ( ($print_data[1] == SMW_IQ_PRINT_RSEL) ) { // $cur describes an article title |
998 | | - $curarticle = $cur[2]; |
999 | | - } |
1000 | | - $hastitle = true; |
1001 | | - } |
1002 | | - } 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 |
1003 | | - if (!$first_col || !$first_value || $eventline) { |
1004 | | - $curdata .= $header . $cur[0]; |
1005 | | - $output = true; |
1006 | | - } |
1007 | | - 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) ) { |
1008 | | - $events[] = array($cur[1]->getXSDValue(), $print_data[0], $cur[1]->getNumericValue()); |
1009 | | - } |
1010 | | - $first_value = false; |
1011 | | - } |
1012 | | - if ($output) $curdata .= "<br />"; |
1013 | | - $output = false; |
1014 | | - $first_col = false; |
1015 | | - } |
1016 | | - |
1017 | | - if ( $hastime ) { |
1018 | | - $result .= '<span class="smwtlevent">' . $curmeta . '<span class="smwtlcoloricon">' . $curcolor . '</span>' . $curdata . '</span>'; |
1019 | | - } |
1020 | | - if ( $eventline ) { |
1021 | | - foreach ($events as $event) { |
1022 | | - $result .= '<span class="smwtlevent"><span class="smwtlstart">' . $event[0] . '</span><span class="smwtlurl">' . $event[1] . '</span><span class="smwtlcoloricon">' . $curcolor . '</span>'; |
1023 | | - if ( $curarticle != '' ) $result .= '<span class="smwtlprefix">' . $curarticle . ' </span>'; |
1024 | | - $result .= $curdata . '</span>'; |
1025 | | - $positions[$event[2]] = $event[0]; |
1026 | | - } |
1027 | | - $events = array(); |
1028 | | - $curcolor = ($curcolor + 1) % 10; |
1029 | | - } |
1030 | | - } |
1031 | | - // find display position: |
1032 | | - if (array_key_exists('timelineposition', $params)) { |
1033 | | - $pos = $params['timelineposition']; |
1034 | | - } else $pos = 'middle'; |
1035 | | - ksort($positions); |
1036 | | - $positions = array_values($positions); |
1037 | | - switch ($pos) { |
1038 | | - case 'start': |
1039 | | - $result .= '<span class="smwtlposition">' . $positions[0] . '</span>'; |
1040 | | - break; |
1041 | | - case 'end': |
1042 | | - $result .= '<span class="smwtlposition">' . $positions[count($positions)-1] . '</span>'; |
1043 | | - break; |
1044 | | - case 'today': break; // default |
1045 | | - case 'middle': default: |
1046 | | - $result .= '<span class="smwtlposition">' . $positions[ceil(count($positions)/2)-1] . '</span>'; |
1047 | | - break; |
1048 | | - } |
1049 | | - } |
1050 | | - |
| 700 | +// interface SMWQueryPrinter { |
| 701 | +// /** |
| 702 | +// * Print all results and return an output string. This method needs to call back to |
| 703 | +// * the query object for fetching data. |
| 704 | +// */ |
| 705 | +// public function printResult(); |
| 706 | +// } |
| 707 | +// |
| 708 | +// /** |
| 709 | +// * Printer for tabular data. |
| 710 | +// */ |
| 711 | +// class SMWTablePrinter implements SMWQueryPrinter { |
| 712 | +// private $mIQ; // the querying object that called the printer |
| 713 | +// private $mQuery; // the query that was executed and whose results are to be printed |
| 714 | +// |
| 715 | +// public function SMWTablePrinter($iq, $query) { |
| 716 | +// $this->mIQ = $iq; |
| 717 | +// $this->mQuery = $query; |
| 718 | +// } |
| 719 | +// |
| 720 | +// public function printResult() { |
| 721 | +// global $smwgIQRunningNumber; |
| 722 | +// |
| 723 | +// // print header |
| 724 | +// if ('broadtable' == $this->mIQ->getFormat()) |
| 725 | +// $widthpara = ' width="100%"'; |
| 726 | +// else $widthpara = ''; |
| 727 | +// $result = $this->mIQ->getIntro() . "<table class=\"smwtable\"$widthpara id=\"querytable" . $smwgIQRunningNumber . "\">\n"; |
| 728 | +// if ($this->mIQ->showHeaders()) { |
| 729 | +// $result .= "\n\t\t<tr>"; |
| 730 | +// foreach ($this->mQuery->mPrint as $print_data) { |
| 731 | +// $result .= "\t\t\t<th>" . $print_data[0] . "</th>\n"; |
| 732 | +// } |
| 733 | +// $result .= "\n\t\t</tr>"; |
| 734 | +// } |
| 735 | +// |
| 736 | +// // print all result rows |
| 737 | +// while ( $row = $this->mIQ->getNextRow() ) { |
| 738 | +// $result .= "\t\t<tr>\n"; |
| 739 | +// $firstcol = true; |
| 740 | +// foreach ($this->mQuery->mPrint as $print_data) { |
| 741 | +// $iterator = $this->mIQ->getIterator($print_data,$row,$firstcol); |
| 742 | +// $result .= "<td>"; |
| 743 | +// $first = true; |
| 744 | +// while ($cur = $iterator->getNext()) { |
| 745 | +// if ($first) $first = false; else $result .= '<br />'; |
| 746 | +// $result .= $cur[0]; |
| 747 | +// } |
| 748 | +// $result .= "</td>"; |
| 749 | +// $firstcol = false; |
| 750 | +// } |
| 751 | +// $result .= "\n\t\t</tr>\n"; |
| 752 | +// } |
| 753 | +// |
1051 | 754 | // if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
1052 | 755 | // $label = $this->mIQ->getSearchLabel(); |
1053 | 756 | // if ($label === NULL) { //apply default |
1054 | 757 | // $label = wfMsgForContent('smw_iq_moreresults'); |
1055 | 758 | // } |
1056 | 759 | // if ($label != '') { |
1057 | | -// $result .= "\n\t\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . count($this->mQuery->mPrint) . '\"> <a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a></td></tr>'; |
| 760 | +// $result .= "\n\t\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . count($this->mQuery->mPrint) . '"> <a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a></td></tr>'; |
1058 | 761 | // } |
1059 | 762 | // } |
| 763 | +// |
| 764 | +// // print footer |
| 765 | +// $result .= "\t</table>"; |
| 766 | +// |
| 767 | +// return $result; |
| 768 | +// } |
| 769 | +// } |
| 770 | +// |
| 771 | +// /** |
| 772 | +// * Printer for list data. Somewhat confusing code, since one has to iterate through lists, |
| 773 | +// * inserting texts in between their elements depending on whether the element is the first |
| 774 | +// * that is printed, the first that is printed in parentheses, or the last that will be printed. |
| 775 | +// * Maybe one could further simplify this. |
| 776 | +// */ |
| 777 | +// class SMWListPrinter implements SMWQueryPrinter { |
| 778 | +// private $mIQ; // the querying object that called the printer |
| 779 | +// private $mQuery; // the query that was executed and whose results are to be printed |
| 780 | +// |
| 781 | +// public function SMWListPrinter($iq, $query) { |
| 782 | +// $this->mIQ = $iq; |
| 783 | +// $this->mQuery = $query; |
| 784 | +// } |
| 785 | +// |
| 786 | +// public function printResult() { |
| 787 | +// global $wgTitle,$smwgStoreActive; |
| 788 | +// // print header |
| 789 | +// $result = $this->mIQ->getIntro(); |
| 790 | +// $params = $this->mIQ->getParameters(); |
| 791 | +// if ( ('ul' == $this->mIQ->getFormat()) || ('ol' == $this->mIQ->getFormat()) ) { |
| 792 | +// $result .= '<' . $this->mIQ->getFormat() . '>'; |
| 793 | +// $footer = '</' . $this->mIQ->getFormat() . '>'; |
| 794 | +// $rowstart = "\n\t<li>"; |
| 795 | +// $rowend = '</li>'; |
| 796 | +// $plainlist = false; |
| 797 | +// } else { |
| 798 | +// if (array_key_exists('sep', $params)) { |
| 799 | +// $listsep = htmlspecialchars(str_replace('_', ' ', $params['sep'])); |
| 800 | +// $finallistsep = $listsep; |
| 801 | +// } else { // default list ", , , and, " |
| 802 | +// $listsep = ', '; |
| 803 | +// $finallistsep = wfMsgForContent('smw_finallistconjunct') . ' '; |
| 804 | +// } |
| 805 | +// $footer = ''; |
| 806 | +// $rowstart = ''; |
| 807 | +// $rowend = ''; |
| 808 | +// $plainlist = true; |
| 809 | +// } |
| 810 | +// |
| 811 | +// if (array_key_exists('template', $params)) { |
| 812 | +// $templatename = $params['template']; |
| 813 | +// $parser_options = new ParserOptions(); |
| 814 | +// $parser_options->setEditSection(false); // embedded sections should not have edit links |
| 815 | +// $parser = new Parser(); |
| 816 | +// $usetemplate = true; |
| 817 | +// } else { |
| 818 | +// $usetemplate = false; |
| 819 | +// } |
| 820 | +// |
| 821 | +// // print all result rows |
| 822 | +// $first_row = true; |
| 823 | +// $row = $this->mIQ->getNextRow(); |
| 824 | +// while ( $row ) { |
| 825 | +// $nextrow = $this->mIQ->getNextRow(); // look ahead |
| 826 | +// if ( !$first_row && $plainlist ) { |
| 827 | +// if ($nextrow) $result .= $listsep; // the comma between "rows" other than the last one |
| 828 | +// else $result .= $finallistsep; |
| 829 | +// } else $result .= $rowstart; |
| 830 | +// |
| 831 | +// $first_col = true; |
| 832 | +// if ($usetemplate) { // build template code |
| 833 | +// $wikitext = ''; |
| 834 | +// foreach ($this->mQuery->mPrint as $print_data) { |
| 835 | +// $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
| 836 | +// $wikitext .= "|"; |
| 837 | +// $first_value = true; |
| 838 | +// while ($cur = $iterator->getNext()) { |
| 839 | +// if ($first_value) $first_value = false; else $wikitext .= ', '; |
| 840 | +// $wikitext .= $cur[0]; |
| 841 | +// } |
| 842 | +// $first_col = false; |
| 843 | +// } |
| 844 | +// $result .= '{{' . $templatename . str_replace('=','|', $wikitext) . '}}'; // encode '=' for use in templates (templates fail otherwise) |
| 845 | +// } else { // build simple list |
| 846 | +// $first_col = true; |
| 847 | +// $found_values = false; // has anything but the first column been printed? |
| 848 | +// foreach ($this->mQuery->mPrint as $print_data) { |
| 849 | +// $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
| 850 | +// $first_value = true; |
| 851 | +// while ($cur = $iterator->getNext()) { |
| 852 | +// if (!$first_col && !$found_values) { // first values after first column |
| 853 | +// $result .= ' ('; |
| 854 | +// $found_values = true; |
| 855 | +// } elseif ($found_values || !$first_value) { |
| 856 | +// // any value after '(' or non-first values on first column |
| 857 | +// $result .= ', '; |
| 858 | +// } |
| 859 | +// if ($first_value) { // first value in any column, print header |
| 860 | +// $first_value = false; |
| 861 | +// if ( $this->mIQ->showHeaders() && ('' != $print_data[0]) ) { |
| 862 | +// $result .= $print_data[0] . ' '; |
| 863 | +// } |
| 864 | +// } |
| 865 | +// $result .= $cur[0]; // actual output value |
| 866 | +// } |
| 867 | +// $first_col = false; |
| 868 | +// } |
| 869 | +// if ($found_values) $result .= ')'; |
| 870 | +// } |
| 871 | +// $result .= $rowend; |
| 872 | +// $first_row = false; |
| 873 | +// $row = $nextrow; |
| 874 | +// } |
| 875 | +// |
| 876 | +// if ($usetemplate) { |
| 877 | +// $old_smwgStoreActive = $smwgStoreActive; |
| 878 | +// $smwgStoreActive = false; // no annotations stored, no factbox printed |
| 879 | +// $parserOutput = $parser->parse($result, $wgTitle, $parser_options); |
| 880 | +// $result = $parserOutput->getText(); |
| 881 | +// $smwgStoreActive = $old_smwgStoreActive; |
| 882 | +// } |
| 883 | +// |
| 884 | +// if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
| 885 | +// $label = $this->mIQ->getSearchLabel(); |
| 886 | +// if ($label === NULL) { //apply defaults |
| 887 | +// if ('ol' == $this->mIQ->getFormat()) $label = ''; |
| 888 | +// else $label = wfMsgForContent('smw_iq_moreresults'); |
| 889 | +// } |
| 890 | +// if (!$first_row) $result .= ' '; // relevant for list, unproblematic for ul/ol |
| 891 | +// if ($label != '') { |
| 892 | +// $result .= $rowstart . '<a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a>' . $rowend; |
| 893 | +// } |
| 894 | +// } |
| 895 | +// |
| 896 | +// // print footer |
| 897 | +// $result .= $footer; |
| 898 | +// |
| 899 | +// return $result; |
| 900 | +// } |
| 901 | +// } |
| 902 | +// |
| 903 | +// /** |
| 904 | +// * Printer for timeline data. |
| 905 | +// */ |
| 906 | +// class SMWTimelinePrinter implements SMWQueryPrinter { |
| 907 | +// private $mIQ; // the querying object that called the printer |
| 908 | +// private $mQuery; // the query that was executed and whose results are to be printed |
| 909 | +// |
| 910 | +// public function SMWTimelinePrinter($iq, $query) { |
| 911 | +// $this->mIQ = $iq; |
| 912 | +// $this->mQuery = $query; |
| 913 | +// } |
| 914 | +// |
| 915 | +// public function printResult() { |
| 916 | +// global $smwgIQRunningNumber; |
| 917 | +// |
| 918 | +// $eventline = ('eventline' == $this->mIQ->getFormat()); |
| 919 | +// $params = $this->mIQ->getParameters(); |
| 920 | +// |
| 921 | +// $startdate = ''; |
| 922 | +// |
| 923 | +// if (array_key_exists('timelinestart', $params)) { |
| 924 | +// $startdate = smwfNormalTitleDBKey($params['timelinestart']); |
| 925 | +// } |
| 926 | +// if (array_key_exists('timelineend', $params)) { |
| 927 | +// $enddate = smwfNormalTitleDBKey($params['timelineend']); |
| 928 | +// } else $enddate = ''; |
| 929 | +// |
| 930 | +// if ( !$eventline && ($startdate == '') ) { // seek defaults |
| 931 | +// foreach ($this->mQuery->mPrint as $print_data) { |
| 932 | +// if ( ($print_data[1] == SMW_IQ_PRINT_ATTS) && ($print_data[3]->getTypeID() == 'datetime' ) ) { |
| 933 | +// if ( ($enddate == '') && ($startdate != '') && ($startdate != $print_data[2]) ) |
| 934 | +// $enddate = $print_data[2]; |
| 935 | +// if ( ($startdate == '') && ($enddate != $print_data[2]) ) |
| 936 | +// $startdate = $print_data[2]; |
| 937 | +// } |
| 938 | +// } |
| 939 | +// } |
| 940 | +// |
| 941 | +// if (array_key_exists('timelinesize', $params)) { |
| 942 | +// $size = htmlspecialchars(str_replace(';', ' ', $params['timelinesize'])); // str_replace makes sure this is only one value, not mutliple CSS fields (prevent CSS attacks) |
| 943 | +// } else $size = "300px"; |
| 944 | +// |
| 945 | +// // print header |
| 946 | +// $result = "<div class=\"smwtimeline\" id=\"smwtimeline$smwgIQRunningNumber\" style=\"height: $size\">"; |
| 947 | +// $result .= '<span class="smwtlcomment">' . wfMsgForContent('smw_iq_nojs',$this->mIQ->getQueryURL()) . '</span>'; // note for people without JavaScript |
| 948 | +// |
| 949 | +// if (array_key_exists('timelinebands', $params)) { //check for band parameter, should look like "DAY,MONTH,YEAR" |
| 950 | +// $bands = preg_split('/[,][\s]?/',$params['timelinebands']); |
| 951 | +// foreach ($bands as $band) { |
| 952 | +// $result .= '<span class="smwtlband">' . htmlspecialchars($band) . '</span>'; |
| 953 | +// //just print any "band" given, the JavaScript will figure out what to make of it |
| 954 | +// } |
| 955 | +// } |
| 956 | +// |
| 957 | +// // print all result rows |
| 958 | +// $positions = array(); // possible positions, collected to select one for centering |
| 959 | +// $curcolor = 0; // color cycling is used for eventline |
| 960 | +// if ( ($startdate != '') || $eventline ) { |
| 961 | +// $output = false; // true if output for the popup was given on current line |
| 962 | +// if ($eventline) $events = array(); // array of events that are to be printed |
| 963 | +// while ( $row = $this->mIQ->getNextRow() ) { |
| 964 | +// $hastime = false; // true as soon as some startdate value was found |
| 965 | +// $hastitle = false; // true as soon as some label for the event was found |
| 966 | +// $curdata = ''; // current *inner* print data (within some event span) |
| 967 | +// $curmeta = ''; // current event meta data |
| 968 | +// $curarticle = ''; // label of current article, if it was found |
| 969 | +// $first_col = true; |
| 970 | +// foreach ($this->mQuery->mPrint as $print_data) { |
| 971 | +// $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
| 972 | +// $first_value = true; |
| 973 | +// while ($cur = $iterator->getNext()) { |
| 974 | +// $header = ''; |
| 975 | +// if ($first_value) { |
| 976 | +// // find header for current value: |
| 977 | +// if ( $this->mIQ->showHeaders() && ('' != $print_data[0]) ) { |
| 978 | +// $header = $print_data[0] . ' '; |
| 979 | +// } |
| 980 | +// // is this a start date? |
| 981 | +// if ( ($print_data[1] == SMW_IQ_PRINT_ATTS) && ($print_data[2] == $startdate) ) { |
| 982 | +// //FIXME: Timeline scripts should support XSD format explicitly. They |
| 983 | +// //currently seem to implement iso8601 which deviates from XSD in cases. |
| 984 | +// $curmeta .= '<span class="smwtlstart">' . $cur[1]->getXSDValue() . '</span>'; |
| 985 | +// $positions[$cur[1]->getNumericValue()] = $cur[1]->getXSDValue(); |
| 986 | +// $hastime = true; |
| 987 | +// } |
| 988 | +// // is this the end date? |
| 989 | +// if ( ($print_data[1] == SMW_IQ_PRINT_ATTS) && ($print_data[2] == $enddate) ) { |
| 990 | +// $curmeta .= '<span class="smwtlend">' . $cur[1]->getXSDValue() . '</span>'; |
| 991 | +// } |
| 992 | +// // find title for displaying event |
| 993 | +// if ( !$hastitle ) { |
| 994 | +// if ( mb_substr($cur[0],0,3) == '<a ') // treat hyperlinks differently |
| 995 | +// $curmeta .= '<span class="smwtlurl">' . $cur[0] . '</span>'; |
| 996 | +// else $curmeta .= '<span class="smwtltitle">' . $cur[0] . '</span>'; |
| 997 | +// if ( ($print_data[1] == SMW_IQ_PRINT_RSEL) ) { // $cur describes an article title |
| 998 | +// $curarticle = $cur[2]; |
| 999 | +// } |
| 1000 | +// $hastitle = true; |
| 1001 | +// } |
| 1002 | +// } 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 |
| 1003 | +// if (!$first_col || !$first_value || $eventline) { |
| 1004 | +// $curdata .= $header . $cur[0]; |
| 1005 | +// $output = true; |
| 1006 | +// } |
| 1007 | +// 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) ) { |
| 1008 | +// $events[] = array($cur[1]->getXSDValue(), $print_data[0], $cur[1]->getNumericValue()); |
| 1009 | +// } |
| 1010 | +// $first_value = false; |
| 1011 | +// } |
| 1012 | +// if ($output) $curdata .= "<br />"; |
| 1013 | +// $output = false; |
| 1014 | +// $first_col = false; |
| 1015 | +// } |
| 1016 | +// |
| 1017 | +// if ( $hastime ) { |
| 1018 | +// $result .= '<span class="smwtlevent">' . $curmeta . '<span class="smwtlcoloricon">' . $curcolor . '</span>' . $curdata . '</span>'; |
| 1019 | +// } |
| 1020 | +// if ( $eventline ) { |
| 1021 | +// foreach ($events as $event) { |
| 1022 | +// $result .= '<span class="smwtlevent"><span class="smwtlstart">' . $event[0] . '</span><span class="smwtlurl">' . $event[1] . '</span><span class="smwtlcoloricon">' . $curcolor . '</span>'; |
| 1023 | +// if ( $curarticle != '' ) $result .= '<span class="smwtlprefix">' . $curarticle . ' </span>'; |
| 1024 | +// $result .= $curdata . '</span>'; |
| 1025 | +// $positions[$event[2]] = $event[0]; |
| 1026 | +// } |
| 1027 | +// $events = array(); |
| 1028 | +// $curcolor = ($curcolor + 1) % 10; |
| 1029 | +// } |
| 1030 | +// } |
| 1031 | +// // find display position: |
| 1032 | +// if (array_key_exists('timelineposition', $params)) { |
| 1033 | +// $pos = $params['timelineposition']; |
| 1034 | +// } else $pos = 'middle'; |
| 1035 | +// ksort($positions); |
| 1036 | +// $positions = array_values($positions); |
| 1037 | +// switch ($pos) { |
| 1038 | +// case 'start': |
| 1039 | +// $result .= '<span class="smwtlposition">' . $positions[0] . '</span>'; |
| 1040 | +// break; |
| 1041 | +// case 'end': |
| 1042 | +// $result .= '<span class="smwtlposition">' . $positions[count($positions)-1] . '</span>'; |
| 1043 | +// break; |
| 1044 | +// case 'today': break; // default |
| 1045 | +// case 'middle': default: |
| 1046 | +// $result .= '<span class="smwtlposition">' . $positions[ceil(count($positions)/2)-1] . '</span>'; |
| 1047 | +// break; |
| 1048 | +// } |
| 1049 | +// } |
| 1050 | +// |
| 1051 | +// // if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
| 1052 | +// // $label = $this->mIQ->getSearchLabel(); |
| 1053 | +// // if ($label === NULL) { //apply default |
| 1054 | +// // $label = wfMsgForContent('smw_iq_moreresults'); |
| 1055 | +// // } |
| 1056 | +// // if ($label != '') { |
| 1057 | +// // $result .= "\n\t\t<tr class=\"smwfooter\"><td class=\"sortbottom\" colspan=\"" . count($this->mQuery->mPrint) . '\"> <a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a></td></tr>'; |
| 1058 | +// // } |
| 1059 | +// // } |
| 1060 | +// |
| 1061 | +// // print footer |
| 1062 | +// $result .= "</div>"; |
| 1063 | +// |
| 1064 | +// return $result; |
| 1065 | +// } |
| 1066 | +// } |
| 1067 | +// |
| 1068 | +// /** |
| 1069 | +// * Printer for embedded data. |
| 1070 | +// * Embeds in the page output the contents of the pages in the query result set. |
| 1071 | +// * Only the first column of the query is considered. If it is a page reference then that page's contents is embedded. |
| 1072 | +// * The optional "titlestyle" formatting parameter can be used to apply a format to the headings for the page titles. |
| 1073 | +// * If "titlestyle" is not specified, a <h1> tag is used. |
| 1074 | +// * @author Fernando Correia |
| 1075 | +// * @author Markus Kr�tzsch |
| 1076 | +// */ |
| 1077 | +// class SMWEmbeddedPrinter implements SMWQueryPrinter { |
| 1078 | +// private $mIQ; // the querying object that called the printer |
| 1079 | +// private $mQuery; // the query that was executed and whose results are to be printed |
| 1080 | +// |
| 1081 | +// public function SMWEmbeddedPrinter($iq, $query) { |
| 1082 | +// $this->mIQ = $iq; |
| 1083 | +// $this->mQuery = $query; |
| 1084 | +// } |
| 1085 | +// |
| 1086 | +// public function printResult() { |
| 1087 | +// // handle factbox |
| 1088 | +// global $smwgStoreActive; |
| 1089 | +// $old_smwgStoreActive = $smwgStoreActive; |
| 1090 | +// $smwgStoreActive = false; // no annotations stored, no factbox printed |
| 1091 | +// |
| 1092 | +// // print header |
| 1093 | +// $result = $this->mIQ->getIntro(); |
| 1094 | +// |
| 1095 | +// // use titleformat parameter if specified |
| 1096 | +// $params = $this->mIQ->getParameters(); |
| 1097 | +// if (array_key_exists('embedonly', $params)) { |
| 1098 | +// $showhead = false; |
| 1099 | +// } else { |
| 1100 | +// $showhead = true; |
| 1101 | +// } |
| 1102 | +// |
| 1103 | +// if (array_key_exists('embedformat', $params)) { |
| 1104 | +// switch ($params['embedformat']) { |
| 1105 | +// case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': |
| 1106 | +// $footer = ''; |
| 1107 | +// $embstart = ''; |
| 1108 | +// $headstart = '<' . $params['embedformat'] . '>'; |
| 1109 | +// $headend = '</' . $params['embedformat'] . ">\n"; |
| 1110 | +// $embend = ''; |
| 1111 | +// break; |
| 1112 | +// case 'ul': case 'ol': |
| 1113 | +// $result .= '<' . $params['embedformat'] . '>'; |
| 1114 | +// $footer = '</' . $params['embedformat'] . '>'; |
| 1115 | +// $embstart = '<li>'; |
| 1116 | +// $headstart = ''; |
| 1117 | +// $headend = "<br />\n"; |
| 1118 | +// $embend = "</li>\n"; |
| 1119 | +// break; |
| 1120 | +// } |
| 1121 | +// } else { |
| 1122 | +// $footer = ''; |
| 1123 | +// $embstart = ''; |
| 1124 | +// $headstart = '<h1>'; |
| 1125 | +// $headend = "</h1>\n"; |
| 1126 | +// $embend = ''; |
| 1127 | +// } |
| 1128 | +// |
| 1129 | +// // print all result rows |
| 1130 | +// $parser_options = new ParserOptions(); |
| 1131 | +// $parser_options->setEditSection(false); // embedded sections should not have edit links |
| 1132 | +// $parser = new Parser(); |
| 1133 | +// |
| 1134 | +// while ( $row = $this->mIQ->getNextRow() ) { |
| 1135 | +// $first_col = true; |
| 1136 | +// foreach ($this->mQuery->mPrint as $print_data) { |
| 1137 | +// $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
| 1138 | +// if ( ($print_data[1] == SMW_IQ_PRINT_RELS) || ($print_data[1] == SMW_IQ_PRINT_RSEL) ) { |
| 1139 | +// while ($cur = $iterator->getNext()) { |
| 1140 | +// $result .= $embstart; |
| 1141 | +// if ($showhead) { |
| 1142 | +// $result .= $headstart . $cur[0] . $headend; |
| 1143 | +// } |
| 1144 | +// $article_namespace = $cur[1]; |
| 1145 | +// $article_title = $cur[2]; // TODO: ouch .. we need to check whether this exists |
| 1146 | +// if ( (NULL != $article_title) and ('' != $article_title) ) { |
| 1147 | +// $title_text = $article_namespace; |
| 1148 | +// if ($title_text != '') $title_text .= ':'; |
| 1149 | +// $title_text .= $article_title; |
| 1150 | +// $title = Title::newFromText($title_text); // TODO: is this actually the right title to use for parsing? |
| 1151 | +// if (NULL != $title) { |
| 1152 | +// $parserOutput = $parser->parse('{{' . $article_namespace . ':' . $article_title . '}}', $title, $parser_options); |
| 1153 | +// $result .= $parserOutput->getText(); |
| 1154 | +// } |
| 1155 | +// } |
| 1156 | +// $result .= $embend; |
| 1157 | +// } |
| 1158 | +// } |
| 1159 | +// break; // only use first column for now |
| 1160 | +// } |
| 1161 | +// } |
| 1162 | +// |
| 1163 | +// // show link to more results |
| 1164 | +// if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
| 1165 | +// $label = $this->mIQ->getSearchLabel(); |
| 1166 | +// if ($label === NULL) { //apply defaults |
| 1167 | +// $label = wfMsgForContent('smw_iq_moreresults'); |
| 1168 | +// } |
| 1169 | +// if ($label != '') { |
| 1170 | +// $result .= $embstart . '<a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a>' . $embend ; |
| 1171 | +// } |
| 1172 | +// } |
| 1173 | +// $result .= $footer; |
| 1174 | +// |
| 1175 | +// $smwgStoreActive = $old_smwgStoreActive; |
| 1176 | +// return $result; |
| 1177 | +// } |
| 1178 | +// } |
| 1179 | +// |
| 1180 | +// /** |
| 1181 | +// * Printer for template data. Passes a result a result row as anonymous parameters to |
| 1182 | +// * a given template (which might ignore them or not) and prints the result. Values |
| 1183 | +// */ |
| 1184 | +// class SMWTemplatePrinter implements SMWQueryPrinter { |
| 1185 | +// private $mIQ; // the querying object that called the printer |
| 1186 | +// private $mQuery; // the query that was executed and whose results are to be printed |
| 1187 | +// |
| 1188 | +// public function SMWTemplatePrinter($iq, $query) { |
| 1189 | +// $this->mIQ = $iq; |
| 1190 | +// $this->mQuery = $query; |
| 1191 | +// } |
| 1192 | +// |
| 1193 | +// public function printResult() { |
| 1194 | +// // handle factbox |
| 1195 | +// global $smwgStoreActive, $wgTitle; |
| 1196 | +// $old_smwgStoreActive = $smwgStoreActive; |
| 1197 | +// $smwgStoreActive = false; // no annotations stored, no factbox printed |
| 1198 | +// |
| 1199 | +// // print all result rows |
| 1200 | +// $parserinput = $this->mIQ->getIntro(); |
| 1201 | +// $params = $this->mIQ->getParameters(); |
| 1202 | +// if (array_key_exists('template', $params)) { |
| 1203 | +// $templatename = $params['template']; |
| 1204 | +// } else { |
| 1205 | +// return 'Please set parameter "template" for <ask> to work.'; // TODO: internationalise |
| 1206 | +// } |
| 1207 | +// |
| 1208 | +// $parser_options = new ParserOptions(); |
| 1209 | +// $parser_options->setEditSection(false); // embedded sections should not have edit links |
| 1210 | +// $parser = new Parser(); |
| 1211 | +// while ( $row = $this->mIQ->getNextRow() ) { |
| 1212 | +// $wikitext = ''; |
| 1213 | +// $firstcol = true; |
| 1214 | +// foreach ($this->mQuery->mPrint as $print_data) { |
| 1215 | +// $iterator = $this->mIQ->getIterator($print_data,$row,$firstcol); |
| 1216 | +// $wikitext .= "|"; |
| 1217 | +// $first = true; |
| 1218 | +// while ($cur = $iterator->getNext()) { |
| 1219 | +// if ($first) $first = false; else $wikitext .= ', '; |
| 1220 | +// $wikitext .= $cur[0]; |
| 1221 | +// } |
| 1222 | +// $firstcol = false; |
| 1223 | +// } |
| 1224 | +// $parserinput .= '{{' . $templatename . str_replace('=','|', $wikitext) . '}}'; // encode '=' for use in templates (templates fail otherwise) |
| 1225 | +// } |
| 1226 | +// $parserOutput = $parser->parse($parserinput, $wgTitle, $parser_options); |
| 1227 | +// $result = $parserOutput->getText(); |
| 1228 | +// // show link to more results |
| 1229 | +// if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
| 1230 | +// $label = $this->mIQ->getSearchLabel(); |
| 1231 | +// if ($label === NULL) { //apply defaults |
| 1232 | +// $label = wfMsgForContent('smw_iq_moreresults'); |
| 1233 | +// } |
| 1234 | +// if ($label != '') { |
| 1235 | +// $result .= '<a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a>'; |
| 1236 | +// } |
| 1237 | +// } |
| 1238 | +// |
| 1239 | +// $smwgStoreActive = $old_smwgStoreActive; |
| 1240 | +// return $result; |
| 1241 | +// } |
| 1242 | +// } |
1060 | 1243 | |
1061 | | - // print footer |
1062 | | - $result .= "</div>"; |
1063 | | - |
1064 | | - return $result; |
1065 | | - } |
1066 | | -} |
1067 | | - |
1068 | | -/** |
1069 | | - * Printer for embedded data. |
1070 | | - * Embeds in the page output the contents of the pages in the query result set. |
1071 | | - * Only the first column of the query is considered. If it is a page reference then that page's contents is embedded. |
1072 | | - * The optional "titlestyle" formatting parameter can be used to apply a format to the headings for the page titles. |
1073 | | - * If "titlestyle" is not specified, a <h1> tag is used. |
1074 | | - * @author Fernando Correia |
1075 | | - * @author Markus Kr�tzsch |
1076 | | - */ |
1077 | | -class SMWEmbeddedPrinter implements SMWQueryPrinter { |
1078 | | - private $mIQ; // the querying object that called the printer |
1079 | | - private $mQuery; // the query that was executed and whose results are to be printed |
1080 | | - |
1081 | | - public function SMWEmbeddedPrinter($iq, $query) { |
1082 | | - $this->mIQ = $iq; |
1083 | | - $this->mQuery = $query; |
1084 | | - } |
1085 | | - |
1086 | | - public function printResult() { |
1087 | | - // handle factbox |
1088 | | - global $smwgStoreActive; |
1089 | | - $old_smwgStoreActive = $smwgStoreActive; |
1090 | | - $smwgStoreActive = false; // no annotations stored, no factbox printed |
1091 | | - |
1092 | | - // print header |
1093 | | - $result = $this->mIQ->getIntro(); |
1094 | | - |
1095 | | - // use titleformat parameter if specified |
1096 | | - $params = $this->mIQ->getParameters(); |
1097 | | - if (array_key_exists('embedonly', $params)) { |
1098 | | - $showhead = false; |
1099 | | - } else { |
1100 | | - $showhead = true; |
1101 | | - } |
1102 | | - |
1103 | | - if (array_key_exists('embedformat', $params)) { |
1104 | | - switch ($params['embedformat']) { |
1105 | | - case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': |
1106 | | - $footer = ''; |
1107 | | - $embstart = ''; |
1108 | | - $headstart = '<' . $params['embedformat'] . '>'; |
1109 | | - $headend = '</' . $params['embedformat'] . ">\n"; |
1110 | | - $embend = ''; |
1111 | | - break; |
1112 | | - case 'ul': case 'ol': |
1113 | | - $result .= '<' . $params['embedformat'] . '>'; |
1114 | | - $footer = '</' . $params['embedformat'] . '>'; |
1115 | | - $embstart = '<li>'; |
1116 | | - $headstart = ''; |
1117 | | - $headend = "<br />\n"; |
1118 | | - $embend = "</li>\n"; |
1119 | | - break; |
1120 | | - } |
1121 | | - } else { |
1122 | | - $footer = ''; |
1123 | | - $embstart = ''; |
1124 | | - $headstart = '<h1>'; |
1125 | | - $headend = "</h1>\n"; |
1126 | | - $embend = ''; |
1127 | | - } |
1128 | | - |
1129 | | - // print all result rows |
1130 | | - $parser_options = new ParserOptions(); |
1131 | | - $parser_options->setEditSection(false); // embedded sections should not have edit links |
1132 | | - $parser = new Parser(); |
1133 | | - |
1134 | | - while ( $row = $this->mIQ->getNextRow() ) { |
1135 | | - $first_col = true; |
1136 | | - foreach ($this->mQuery->mPrint as $print_data) { |
1137 | | - $iterator = $this->mIQ->getIterator($print_data,$row,$first_col); |
1138 | | - if ( ($print_data[1] == SMW_IQ_PRINT_RELS) || ($print_data[1] == SMW_IQ_PRINT_RSEL) ) { |
1139 | | - while ($cur = $iterator->getNext()) { |
1140 | | - $result .= $embstart; |
1141 | | - if ($showhead) { |
1142 | | - $result .= $headstart . $cur[0] . $headend; |
1143 | | - } |
1144 | | - $article_namespace = $cur[1]; |
1145 | | - $article_title = $cur[2]; // TODO: ouch .. we need to check whether this exists |
1146 | | - if ( (NULL != $article_title) and ('' != $article_title) ) { |
1147 | | - $title_text = $article_namespace; |
1148 | | - if ($title_text != '') $title_text .= ':'; |
1149 | | - $title_text .= $article_title; |
1150 | | - $title = Title::newFromText($title_text); // TODO: is this actually the right title to use for parsing? |
1151 | | - if (NULL != $title) { |
1152 | | - $parserOutput = $parser->parse('{{' . $article_namespace . ':' . $article_title . '}}', $title, $parser_options); |
1153 | | - $result .= $parserOutput->getText(); |
1154 | | - } |
1155 | | - } |
1156 | | - $result .= $embend; |
1157 | | - } |
1158 | | - } |
1159 | | - break; // only use first column for now |
1160 | | - } |
1161 | | - } |
1162 | | - |
1163 | | - // show link to more results |
1164 | | - if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
1165 | | - $label = $this->mIQ->getSearchLabel(); |
1166 | | - if ($label === NULL) { //apply defaults |
1167 | | - $label = wfMsgForContent('smw_iq_moreresults'); |
1168 | | - } |
1169 | | - if ($label != '') { |
1170 | | - $result .= $embstart . '<a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a>' . $embend ; |
1171 | | - } |
1172 | | - } |
1173 | | - $result .= $footer; |
1174 | | - |
1175 | | - $smwgStoreActive = $old_smwgStoreActive; |
1176 | | - return $result; |
1177 | | - } |
1178 | | -} |
1179 | | - |
1180 | | -/** |
1181 | | - * Printer for template data. Passes a result a result row as anonymous parameters to |
1182 | | - * a given template (which might ignore them or not) and prints the result. Values |
1183 | | - */ |
1184 | | -class SMWTemplatePrinter implements SMWQueryPrinter { |
1185 | | - private $mIQ; // the querying object that called the printer |
1186 | | - private $mQuery; // the query that was executed and whose results are to be printed |
1187 | | - |
1188 | | - public function SMWTemplatePrinter($iq, $query) { |
1189 | | - $this->mIQ = $iq; |
1190 | | - $this->mQuery = $query; |
1191 | | - } |
1192 | | - |
1193 | | - public function printResult() { |
1194 | | - // handle factbox |
1195 | | - global $smwgStoreActive, $wgTitle; |
1196 | | - $old_smwgStoreActive = $smwgStoreActive; |
1197 | | - $smwgStoreActive = false; // no annotations stored, no factbox printed |
1198 | | - |
1199 | | - // print all result rows |
1200 | | - $parserinput = $this->mIQ->getIntro(); |
1201 | | - $params = $this->mIQ->getParameters(); |
1202 | | - if (array_key_exists('template', $params)) { |
1203 | | - $templatename = $params['template']; |
1204 | | - } else { |
1205 | | - return 'Please set parameter "template" for <ask> to work.'; // TODO: internationalise |
1206 | | - } |
1207 | | - |
1208 | | - $parser_options = new ParserOptions(); |
1209 | | - $parser_options->setEditSection(false); // embedded sections should not have edit links |
1210 | | - $parser = new Parser(); |
1211 | | - while ( $row = $this->mIQ->getNextRow() ) { |
1212 | | - $wikitext = ''; |
1213 | | - $firstcol = true; |
1214 | | - foreach ($this->mQuery->mPrint as $print_data) { |
1215 | | - $iterator = $this->mIQ->getIterator($print_data,$row,$firstcol); |
1216 | | - $wikitext .= "|"; |
1217 | | - $first = true; |
1218 | | - while ($cur = $iterator->getNext()) { |
1219 | | - if ($first) $first = false; else $wikitext .= ', '; |
1220 | | - $wikitext .= $cur[0]; |
1221 | | - } |
1222 | | - $firstcol = false; |
1223 | | - } |
1224 | | - $parserinput .= '{{' . $templatename . str_replace('=','|', $wikitext) . '}}'; // encode '=' for use in templates (templates fail otherwise) |
1225 | | - } |
1226 | | - $parserOutput = $parser->parse($parserinput, $wgTitle, $parser_options); |
1227 | | - $result = $parserOutput->getText(); |
1228 | | - // show link to more results |
1229 | | - if ($this->mIQ->isInline() && $this->mIQ->hasFurtherResults()) { |
1230 | | - $label = $this->mIQ->getSearchLabel(); |
1231 | | - if ($label === NULL) { //apply defaults |
1232 | | - $label = wfMsgForContent('smw_iq_moreresults'); |
1233 | | - } |
1234 | | - if ($label != '') { |
1235 | | - $result .= '<a href="' . $this->mIQ->getQueryURL() . '">' . $label . '</a>'; |
1236 | | - } |
1237 | | - } |
1238 | | - |
1239 | | - $smwgStoreActive = $old_smwgStoreActive; |
1240 | | - return $result; |
1241 | | - } |
1242 | | -} |
1243 | | - |
1244 | 1244 | ?> |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php |
— | — | @@ -52,6 +52,28 @@ |
53 | 53 | ## |
54 | 54 | |
55 | 55 | ### |
| 56 | +# Settings for inline queries (<ask>) and for semantic queries in general. |
| 57 | +# Especially meant to prevent overly high server-load by complex queries. |
| 58 | +## |
| 59 | +$smwgIQEnabled = true; // (De)activates all query related features |
| 60 | +$smwgIQDefaultLinking = 'subject'; // Default linking behaviour. Can be one of "none", "subject", "all" |
| 61 | +$smwgIQSearchNamespaces = array(NS_MAIN, NS_IMAGE); // Which namespaces should be searched by default? |
| 62 | + // Value NULL switches off default restrictions on searching (faster) |
| 63 | +$smwgIQMaxConditions = 50; // Max number of "conditions" (e.g. value or category conditions in a query) |
| 64 | +$smwgIQMaxTables = 10; // Max number of "joins" in a query. Restricts nesting depth of queries. |
| 65 | +$smwgIQMaxPrintout = 10; // Max number of supported printouts (added columns in result table, * statements) |
| 66 | +$smwgIQSubQueriesEnabled = true; //(De)activates subqueries (<q>-Syntax), use $smwgIQMaxTables for limiting them |
| 67 | +$smwgIQMaxLimit = 10000; // Max number of results ever retrieved, even when using special query pages. |
| 68 | +$smwgIQMaxInlineLimit = 500; // Max number of rows printed in an inline query on a single page. |
| 69 | +$smwgIQDefaultLimit = 50; // Default number of rows returned in a query. Can be increased with <ask limit="num">... |
| 70 | +$smwgIQDisjunctiveQueriesEnabled = true; // Support disjunctions in queries (||)? |
| 71 | +$smwgIQSubcategoryInclusions = 10; // Restrict level of sub-category inclusion (steps within category hierarchy) |
| 72 | + // Use 0 to disable hierarchy-inferencing in queries |
| 73 | +$smwgIQRedirectNormalization = true; // Should redirects be interpreted as equivalence between page names? |
| 74 | +$smwgIQSortingEnabled = true; // (De)activate sorting of results. |
| 75 | +## |
| 76 | + |
| 77 | +### |
56 | 78 | # Settings for RDF export |
57 | 79 | ## |
58 | 80 | $smwgAllowRecursiveExport = false; // can normal users request recursive export? |
— | — | @@ -127,6 +149,7 @@ |
128 | 150 | $smwgTranslate = false; |
129 | 151 | |
130 | 152 | ### |
| 153 | +# -- FEATURE IS DISABLED -- |
131 | 154 | # If you want to import ontologies, you need to install RAP, |
132 | 155 | # a free RDF API for PHP, see |
133 | 156 | # http://www.wiwiss.fu-berlin.de/suhl/bizer/rdfapi/ |
— | — | @@ -136,14 +159,8 @@ |
137 | 160 | # highly experimental at the moment, and may not do what you |
138 | 161 | # extect. |
139 | 162 | ## |
140 | | -$smwgRAPPath = $smwgIP . '/libs/rdfapi-php'; |
| 163 | +//$smwgRAPPath = $smwgIP . '/libs/rdfapi-php'; |
141 | 164 | //$smwgRAPPath = '/another/example/path/rdfapi-php'; |
142 | 165 | ## |
143 | 166 | |
144 | | -// load (default) settings for inline queries |
145 | | -require_once('SMW_InlineQueries.php'); |
146 | | - |
147 | | -// get local configuration ... |
148 | | -//require("SMW_LocalSettings.php"); |
149 | | - |
150 | 167 | ?> |