Index: trunk/extensions/SemanticMediaWiki/specials/Export/SMW_SpecialOWLExport.php |
— | — | @@ -1,10 +1,10 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * File holding the SMWSpecialOWLExport class for the Special:ExportRDF page. |
| 5 | + * File holding the SMWSpecialOWLExport class for the Special:ExportRDF page. |
6 | 6 | * |
7 | 7 | * @file SMW_SpecialOWLExport.php |
8 | | - * |
| 8 | + * |
9 | 9 | * @ingroup SMWSpecialPage |
10 | 10 | * @ingroup SpecialPage |
11 | 11 | * |
— | — | @@ -19,35 +19,35 @@ |
20 | 20 | * This special page for MediaWiki implements an OWL-export of semantic data, |
21 | 21 | * gathered both from the annotations in articles, and from metadata already |
22 | 22 | * present in the database. |
23 | | - * |
| 23 | + * |
24 | 24 | * @ingroup SMWSpecialPage |
25 | 25 | * @ingroup SpecialPage |
26 | | - * |
| 26 | + * |
27 | 27 | * @author Markus Krötzsch |
28 | 28 | */ |
29 | 29 | class SMWSpecialOWLExport extends SpecialPage { |
30 | | - |
| 30 | + |
31 | 31 | public function __construct() { |
32 | 32 | parent::__construct( 'ExportRDF' ); |
33 | 33 | } |
34 | 34 | |
35 | 35 | public function execute( $page = '' ) { |
36 | 36 | global $wgOut, $wgRequest, $wgUser, $smwgAllowRecursiveExport, $smwgExportBacklinks, $smwgExportAll; |
37 | | - |
| 37 | + |
38 | 38 | $wgOut->setPageTitle( wfMsg( 'exportrdf' ) ); |
39 | | - |
| 39 | + |
40 | 40 | $recursive = 0; // default, no recursion |
41 | 41 | $backlinks = $smwgExportBacklinks; // default |
42 | | - |
| 42 | + |
43 | 43 | // check whether we already know what to export // |
44 | | - |
| 44 | + |
45 | 45 | if ( $page == '' ) { // try to get GET parameter; simple way of calling the export |
46 | 46 | $page = $wgRequest->getVal( 'page' ); |
47 | 47 | } else { |
48 | 48 | // this is needed since MediaWiki 1.8, but it is wrong for 1.7 |
49 | 49 | $page = rawurldecode( $page ); |
50 | 50 | } |
51 | | - |
| 51 | + |
52 | 52 | if ( $page == '' ) { // try to get POST list; some settings are only available via POST |
53 | 53 | $pageblob = $wgRequest->getText( 'pages' ); |
54 | 54 | if ( '' != $pageblob ) { |
— | — | @@ -56,11 +56,11 @@ |
57 | 57 | } else { |
58 | 58 | $pages = array( $page ); |
59 | 59 | } |
60 | | - |
| 60 | + |
61 | 61 | if ( isset( $pages ) ) { // export to RDF |
62 | 62 | $wgOut->disable(); |
63 | 63 | ob_start(); |
64 | | - |
| 64 | + |
65 | 65 | // Only use rdf+xml mimetype if explicitly requested |
66 | 66 | // TODO: should the see also links in the exported RDF then have this parameter as well? |
67 | 67 | if ( $wgRequest->getVal( 'xmlmime' ) == 'rdf' ) { |
— | — | @@ -68,11 +68,11 @@ |
69 | 69 | } else { |
70 | 70 | header( "Content-type: application/xml; charset=UTF-8" ); |
71 | 71 | } |
72 | | - |
| 72 | + |
73 | 73 | if ( $wgRequest->getText( 'postform' ) == 1 ) { |
74 | 74 | $postform = true; // effect: assume "no" from missing parameters generated by checkboxes |
75 | 75 | } else $postform = false; |
76 | | - |
| 76 | + |
77 | 77 | $rec = $wgRequest->getText( 'recursive' ); |
78 | 78 | if ( $rec == '' ) $rec = $wgRequest->getVal( 'recursive' ); |
79 | 79 | if ( ( $rec == '1' ) && ( $smwgAllowRecursiveExport || $wgUser->isAllowed( 'delete' ) ) ) { |
— | — | @@ -87,7 +87,7 @@ |
88 | 88 | } |
89 | 89 | $date = $wgRequest->getText( 'date' ); |
90 | 90 | if ( $date == '' ) $date = $wgRequest->getVal( 'date' ); |
91 | | - |
| 91 | + |
92 | 92 | $exp = new OWLExport(); |
93 | 93 | if ( $date != '' ) $exp->setDate( $date ); |
94 | 94 | $exp->printPages( $pages, $recursive, $backlinks ); |
— | — | @@ -112,9 +112,9 @@ |
113 | 113 | } |
114 | 114 | } |
115 | 115 | } |
116 | | - |
| 116 | + |
117 | 117 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
118 | | - |
| 118 | + |
119 | 119 | // nothing exported yet; show user interface: |
120 | 120 | $html = '<form name="tripleSearch" action="" method="POST">' . "\n" . |
121 | 121 | '<p>' . wfMsg( 'smw_exportrdf_docu' ) . "</p>\n" . |
— | — | @@ -131,9 +131,9 @@ |
132 | 132 | $html .= '<input type="text" name="date" value="' . date( DATE_W3C, mktime( 0, 0, 0, 1, 1, 2000 ) ) . '" id="date"> <label for="ea">' . wfMsg( 'smw_exportrdf_lastdate' ) . '</label></input><br />' . "\n"; |
133 | 133 | } |
134 | 134 | $html .= "<br /><input type=\"submit\" value=\"" . wfMsg( 'smw_exportrdf_submit' ) . "\"/>\n</form>"; |
135 | | - $wgOut->addHTML( $html ); |
136 | | - } |
137 | | - |
| 135 | + $wgOut->addHTML( $html ); |
| 136 | + } |
| 137 | + |
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
— | — | @@ -203,12 +203,6 @@ |
204 | 204 | private $global_namespaces; |
205 | 205 | |
206 | 206 | /** |
207 | | - * Array of references to the SWIVT schema. Will be added at the end of the |
208 | | - * export. |
209 | | - */ |
210 | | - private $schema_refs; |
211 | | - |
212 | | - /** |
213 | 207 | * Unprinted XML is composed from the strings $pre_ns_buffer and $post_ns_buffer. |
214 | 208 | * The split between the two is such that one can append additional namespace |
215 | 209 | * declarations to $pre_ns_buffer so that they affect all current elements. The |
— | — | @@ -242,7 +236,6 @@ |
243 | 237 | public function __construct() { |
244 | 238 | $this->element_queue = array(); |
245 | 239 | $this->element_done = array(); |
246 | | - $this->schema_refs = array(); |
247 | 240 | $this->date = ''; |
248 | 241 | } |
249 | 242 | |
— | — | @@ -594,24 +587,13 @@ |
595 | 588 | "\t\t<owl:imports rdf:resource=\"http://semantic-mediawiki.org/swivt/1.0\" />\n" . |
596 | 589 | "\t</owl:Ontology>\n" . |
597 | 590 | "\t<!-- exported page data -->\n"; |
598 | | - $this->addSchemaRef( "page", "owl:AnnotationProperty" ); |
599 | | - $this->addSchemaRef( "creationDate", "owl:AnnotationProperty" ); |
600 | | - $this->addSchemaRef( "Subject", "owl:Class" ); |
601 | 591 | } |
602 | 592 | |
603 | 593 | /** |
604 | | - * Prints the footer. Prints also all open schema-references. |
605 | | - * No schema-references can be added after printing the footer. |
| 594 | + * Prints the footer. |
606 | 595 | */ |
607 | 596 | protected function printFooter() { |
608 | | - $this->post_ns_buffer .= "\t<!-- References to the SWiVT Ontology, see http://semantic-mediawiki.org/swivt/ -->\n"; |
609 | | - foreach ( $this->schema_refs as $name => $type ) { |
610 | | - $this->post_ns_buffer .= |
611 | | - "\t<$type rdf:about=\"&swivt;$name\">\n" . |
612 | | - "\t\t<rdfs:isDefinedBy rdf:resource=\"http://semantic-mediawiki.org/swivt/1.0\"/>\n" . |
613 | | - "\t</$type>\n"; |
614 | | - } |
615 | | - $this->post_ns_buffer .= "\t<!-- Created by Semantic MediaWiki, http://semantic-mediawiki.org -->\n"; |
| 597 | + $this->post_ns_buffer .= "\t<!-- Created by Semantic MediaWiki, http://semantic-mediawiki.org/ -->\n"; |
616 | 598 | $this->post_ns_buffer .= '</rdf:RDF>'; |
617 | 599 | } |
618 | 600 | |
— | — | @@ -769,16 +751,16 @@ |
770 | 752 | |
771 | 753 | print $this->pre_ns_buffer; |
772 | 754 | $this->pre_ns_buffer = ''; |
773 | | - |
| 755 | + |
774 | 756 | foreach ( $this->extra_namespaces as $nsshort => $nsuri ) { |
775 | 757 | if ( $this->first_flush ) { |
776 | 758 | $this->global_namespaces[$nsshort] = true; |
777 | 759 | print "\n\t"; |
778 | 760 | } else print ' '; |
779 | | - |
| 761 | + |
780 | 762 | print "xmlns:$nsshort=\"$nsuri\""; |
781 | 763 | } |
782 | | - |
| 764 | + |
783 | 765 | $this->extra_namespaces = array(); |
784 | 766 | print $this->post_ns_buffer; |
785 | 767 | $this->post_ns_buffer = ''; |
— | — | @@ -802,21 +784,6 @@ |
803 | 785 | } |
804 | 786 | |
805 | 787 | /** |
806 | | - * Adds a reference to the SWIVT schema. This will make sure that at the end of the page, |
807 | | - * all required schema references will be defined and point to the appropriate ontology. |
808 | | - * |
809 | | - * @param $name The fragmend identifier of the entity to be referenced. The SWIVT namespace |
810 | | - * is added. |
811 | | - * @param $type The type of the referenced identifier, i.e. is it an annotation property, an |
812 | | - * object property, a class, etc. Should be given as a QName (i.e. in the form "owl:Class", |
813 | | - * etc.) |
814 | | - */ |
815 | | - public function addSchemaRef( $name, $type ) { |
816 | | - if ( !array_key_exists( $name, $this->schema_refs ) ) |
817 | | - $this->schema_refs[$name] = $type; |
818 | | - } |
819 | | - |
820 | | - /** |
821 | 788 | * Add a given SMWExpResource to the export queue if needed. |
822 | 789 | */ |
823 | 790 | public function queueElement( $element ) { |