Index: trunk/extensions/DublinCoreRdf/DublinCoreRdf.php |
— | — | @@ -3,8 +3,9 @@ |
4 | 4 | $wgExtensionCredits['other'][] = array( |
5 | 5 | 'path' => __FILE__, |
6 | 6 | 'name' => 'DublinCoreRdf', |
7 | | - 'url' => '', |
| 7 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:DublinCoreRdf', |
8 | 8 | 'author' => 'Evan Prodromou', |
| 9 | + 'descriptionmsg' => "Dublin Core RDF-metadata" |
9 | 10 | ); |
10 | 11 | |
11 | 12 | $wgHooks['MediaWikiPerformAction'][] = 'efDublinCorePerformAction'; |
Index: trunk/extensions/CreativeCommonsRdf/CreativeCommonsRdf.php |
— | — | @@ -3,15 +3,16 @@ |
4 | 4 | $wgExtensionCredits['other'][] = array( |
5 | 5 | 'path' => __FILE__, |
6 | 6 | 'name' => 'CreativeCoreRdf', |
7 | | - 'url' => '', |
| 7 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:CreativeCoreRdf', |
8 | 8 | 'author' => 'Evan Prodromou', |
| 9 | + 'descriptionmsg' => "CreativeCommons RDF-metadata" |
9 | 10 | ); |
10 | 11 | |
11 | | -$wgHooks['MediaWikiPerformAction'][] = 'efCreativeCoreRdfPreformAction'; |
| 12 | +$wgHooks['MediaWikiPerformAction'][] = 'efCreativeCommonsRdfPreformAction'; |
12 | 13 | |
13 | | -$wgAutoloadClasses['CreativeCoreRdf'] = $dir . 'CreativeCoreRdf_body.php'; |
| 14 | +$wgAutoloadClasses['CreativeCommonsRdf'] = $dir . 'CreativeCommonsRdf_body.php'; |
14 | 15 | |
15 | | -function efCreativeCoreRdfPreformAction( $output, $article, $title, $user, $request, $mediaWiki ) { |
| 16 | +function efCreativeCommonsRdfPreformAction( $output, $article, $title, $user, $request, $mediaWiki ) { |
16 | 17 | if ( $mediaWiki->getAction() !== 'creativecommons' ) { |
17 | 18 | return true; |
18 | 19 | } |
Index: trunk/extensions/CreativeCommonsRdf/CreativeCommonsRdf_body.php |
— | — | @@ -22,182 +22,6 @@ |
23 | 23 | * @file |
24 | 24 | */ |
25 | 25 | |
26 | | -abstract class RdfMetaData { |
27 | | - const RDF_TYPE_PREFS = 'application/rdf+xml,text/xml;q=0.7,application/xml;q=0.5,text/rdf;q=0.1'; |
28 | | - |
29 | | - /** |
30 | | - * Constructor |
31 | | - * @param $article Article object |
32 | | - */ |
33 | | - public function __construct( Article $article ) { |
34 | | - $this->mArticle = $article; |
35 | | - } |
36 | | - |
37 | | - public abstract function show(); |
38 | | - |
39 | | - /** |
40 | | - * |
41 | | - */ |
42 | | - protected function setup() { |
43 | | - global $wgOut, $wgRequest; |
44 | | - |
45 | | - $httpaccept = isset( $_SERVER['HTTP_ACCEPT'] ) ? $_SERVER['HTTP_ACCEPT'] : null; |
46 | | - $rdftype = wfNegotiateType( wfAcceptToPrefs( $httpaccept ), wfAcceptToPrefs( self::RDF_TYPE_PREFS ) ); |
47 | | - |
48 | | - if( !$rdftype ){ |
49 | | - wfHttpError( 406, 'Not Acceptable', wfMsg( 'notacceptable' ) ); |
50 | | - return false; |
51 | | - } else { |
52 | | - $wgOut->disable(); |
53 | | - $wgRequest->response()->header( "Content-type: {$rdftype}; charset=utf-8" ); |
54 | | - $wgOut->sendCacheControl(); |
55 | | - return true; |
56 | | - } |
57 | | - } |
58 | | - |
59 | | - /** |
60 | | - * |
61 | | - */ |
62 | | - protected function reallyFullUrl() { |
63 | | - return $this->mArticle->getTitle()->getFullURL(); |
64 | | - } |
65 | | - |
66 | | - protected function basics() { |
67 | | - global $wgLanguageCode, $wgSitename; |
68 | | - |
69 | | - $this->element( 'title', $this->mArticle->mTitle->getText() ); |
70 | | - $this->pageOrString( 'publisher', wfMsg( 'aboutpage' ), $wgSitename ); |
71 | | - $this->element( 'language', $wgLanguageCode ); |
72 | | - $this->element( 'type', 'Text' ); |
73 | | - $this->element( 'format', 'text/html' ); |
74 | | - $this->element( 'identifier', $this->reallyFullUrl() ); |
75 | | - $this->element( 'date', $this->date( $this->mArticle->getTimestamp() ) ); |
76 | | - |
77 | | - $lastEditor = User::newFromId( $this->mArticle->getUser() ); |
78 | | - $this->person( 'creator', $lastEditor ); |
79 | | - |
80 | | - foreach( $this->mArticle->getContributors() as $user ){ |
81 | | - $this->person( 'contributor', $user ); |
82 | | - } |
83 | | - |
84 | | - $this->rights(); |
85 | | - } |
86 | | - |
87 | | - protected function element( $name, $value ) { |
88 | | - $value = htmlspecialchars( $value ); |
89 | | - print "\t\t<dc:{$name}>{$value}</dc:{$name}>\n"; |
90 | | - } |
91 | | - |
92 | | - protected function date($timestamp) { |
93 | | - return substr($timestamp, 0, 4) . '-' |
94 | | - . substr($timestamp, 4, 2) . '-' |
95 | | - . substr($timestamp, 6, 2); |
96 | | - } |
97 | | - |
98 | | - protected function pageOrString( $name, $page, $str ) { |
99 | | - if( $page instanceof Title ) |
100 | | - $nt = $page; |
101 | | - else |
102 | | - $nt = Title::newFromText( $page ); |
103 | | - |
104 | | - if( !$nt || $nt->getArticleID() == 0 ){ |
105 | | - $this->element( $name, $str ); |
106 | | - } else { |
107 | | - $this->page( $name, $nt ); |
108 | | - } |
109 | | - } |
110 | | - |
111 | | - protected function page( $name, $title ) { |
112 | | - $this->url( $name, $title->getFullUrl() ); |
113 | | - } |
114 | | - |
115 | | - protected function url($name, $url) { |
116 | | - $url = htmlspecialchars( $url ); |
117 | | - print "\t\t<dc:{$name} rdf:resource=\"{$url}\" />\n"; |
118 | | - } |
119 | | - |
120 | | - protected function person( $name, User $user ) { |
121 | | - if( $user->isAnon() ){ |
122 | | - $this->element( $name, wfMsgExt( 'anonymous', array( 'parsemag' ), 1 ) ); |
123 | | - } else { |
124 | | - $real = $user->getRealName(); |
125 | | - if( $real ) { |
126 | | - $this->element( $name, $real ); |
127 | | - } else { |
128 | | - $userName = $user->getName(); |
129 | | - $this->pageOrString( $name, $user->getUserPage(), wfMsgExt( 'siteuser', 'parsemag', $userName, $userName ) ); |
130 | | - } |
131 | | - } |
132 | | - } |
133 | | - |
134 | | - /** |
135 | | - * Takes an arg, for future enhancement with different rights for |
136 | | - * different pages. |
137 | | - */ |
138 | | - protected function rights() { |
139 | | - global $wgRightsPage, $wgRightsUrl, $wgRightsText; |
140 | | - |
141 | | - if( $wgRightsPage && ( $nt = Title::newFromText( $wgRightsPage ) ) |
142 | | - && ($nt->getArticleID() != 0)) { |
143 | | - $this->page('rights', $nt); |
144 | | - } else if( $wgRightsUrl ){ |
145 | | - $this->url('rights', $wgRightsUrl); |
146 | | - } else if( $wgRightsText ){ |
147 | | - $this->element( 'rights', $wgRightsText ); |
148 | | - } |
149 | | - } |
150 | | - |
151 | | - protected function getTerms( $url ){ |
152 | | - global $wgLicenseTerms; |
153 | | - |
154 | | - if( $wgLicenseTerms ){ |
155 | | - return $wgLicenseTerms; |
156 | | - } else { |
157 | | - $known = $this->getKnownLicenses(); |
158 | | - if( isset( $known[$url] ) ) { |
159 | | - return $known[$url]; |
160 | | - } else { |
161 | | - return array(); |
162 | | - } |
163 | | - } |
164 | | - } |
165 | | - |
166 | | - protected function getKnownLicenses() { |
167 | | - $ccLicenses = array('by', 'by-nd', 'by-nd-nc', 'by-nc', |
168 | | - 'by-nc-sa', 'by-sa'); |
169 | | - $ccVersions = array('1.0', '2.0'); |
170 | | - $knownLicenses = array(); |
171 | | - |
172 | | - foreach ($ccVersions as $version) { |
173 | | - foreach ($ccLicenses as $license) { |
174 | | - if( $version == '2.0' && substr( $license, 0, 2) != 'by' ) { |
175 | | - # 2.0 dropped the non-attribs licenses |
176 | | - continue; |
177 | | - } |
178 | | - $lurl = "http://creativecommons.org/licenses/{$license}/{$version}/"; |
179 | | - $knownLicenses[$lurl] = explode('-', $license); |
180 | | - $knownLicenses[$lurl][] = 're'; |
181 | | - $knownLicenses[$lurl][] = 'di'; |
182 | | - $knownLicenses[$lurl][] = 'no'; |
183 | | - if (!in_array('nd', $knownLicenses[$lurl])) { |
184 | | - $knownLicenses[$lurl][] = 'de'; |
185 | | - } |
186 | | - } |
187 | | - } |
188 | | - |
189 | | - /* Handle the GPL and LGPL, too. */ |
190 | | - |
191 | | - $knownLicenses['http://creativecommons.org/licenses/GPL/2.0/'] = |
192 | | - array('de', 're', 'di', 'no', 'sa', 'sc'); |
193 | | - $knownLicenses['http://creativecommons.org/licenses/LGPL/2.1/'] = |
194 | | - array('de', 're', 'di', 'no', 'sa', 'sc'); |
195 | | - $knownLicenses['http://www.gnu.org/copyleft/fdl.html'] = |
196 | | - array('de', 're', 'di', 'no', 'sa', 'sc'); |
197 | | - |
198 | | - return $knownLicenses; |
199 | | - } |
200 | | -} |
201 | | - |
202 | 26 | class CreativeCommonsRdf extends RdfMetaData { |
203 | 27 | |
204 | 28 | public function show(){ |