From: Aaron Schulz Date: Sat, 18 Jan 2014 00:20:53 +0000 (-0800) Subject: Removed RdfMetaData X-Git-Tag: 1.31.0-rc.0~17207^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=4ebd4debf407ab3f3701f689f54d50bdf8820e03;p=lhc%2Fweb%2Fwiklou.git Removed RdfMetaData * Unused by core or extensions Change-Id: I3454d605a741bc97a51a1ad471a17eb3053d662f --- diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index bab00f9562..aaadba8162 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -174,7 +174,6 @@ $wgAutoloadLocalClasses = array( 'QueryPage' => 'includes/QueryPage.php', 'QuickTemplate' => 'includes/SkinTemplate.php', 'RawMessage' => 'includes/Message.php', - 'RdfMetaData' => 'includes/Metadata.php', 'ReadOnlyError' => 'includes/Exception.php', 'RedirectSpecialArticle' => 'includes/specialpage/RedirectSpecialPage.php', 'RedirectSpecialPage' => 'includes/specialpage/RedirectSpecialPage.php', diff --git a/includes/Metadata.php b/includes/Metadata.php deleted file mode 100644 index ea89f524bb..0000000000 --- a/includes/Metadata.php +++ /dev/null @@ -1,207 +0,0 @@ -. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * http://www.gnu.org/copyleft/gpl.html - * - * @author Evan Prodromou - * @file - */ - -abstract class RdfMetaData { - const RDF_TYPE_PREFS = 'application/rdf+xml,text/xml;q=0.7,application/xml;q=0.5,text/rdf;q=0.1'; - - /** - * Constructor - * @param Page $page - */ - public function __construct( Page $page ) { - $this->mArticle = $page; - } - - abstract public function show(); - - protected function setup() { - global $wgOut, $wgRequest; - - $httpaccept = isset( $_SERVER['HTTP_ACCEPT'] ) ? $_SERVER['HTTP_ACCEPT'] : null; - $rdftype = wfNegotiateType( - wfAcceptToPrefs( $httpaccept ), - wfAcceptToPrefs( self::RDF_TYPE_PREFS ) - ); - - if ( !$rdftype ) { - throw new HttpError( 406, wfMessage( 'notacceptable' ) ); - } - - $wgOut->disable(); - $wgRequest->response()->header( "Content-type: {$rdftype}; charset=utf-8" ); - $wgOut->sendCacheControl(); - return true; - } - - protected function reallyFullUrl() { - return $this->mArticle->getTitle()->getFullURL(); - } - - protected function basics() { - global $wgLanguageCode, $wgSitename; - - $this->element( 'title', $this->mArticle->getTitle()->getText() ); - $this->pageOrString( 'publisher', wfMessage( 'aboutpage' )->text(), $wgSitename ); - $this->element( 'language', $wgLanguageCode ); - $this->element( 'type', 'Text' ); - $this->element( 'format', 'text/html' ); - $this->element( 'identifier', $this->reallyFullUrl() ); - $this->element( 'date', $this->date( $this->mArticle->getTimestamp() ) ); - - $lastEditor = User::newFromId( $this->mArticle->getUser() ); - $this->person( 'creator', $lastEditor ); - - foreach ( $this->mArticle->getContributors() as $user ) { - $this->person( 'contributor', $user ); - } - - $this->rights(); - } - - protected function element( $name, $value ) { - $value = htmlspecialchars( $value ); - print "\t\t{$value}\n"; - } - - protected function date( $timestamp ) { - return substr( $timestamp, 0, 4 ) . '-' - . substr( $timestamp, 4, 2 ) . '-' - . substr( $timestamp, 6, 2 ); - } - - protected function pageOrString( $name, $page, $str ) { - if ( $page instanceof Title ) { - $nt = $page; - } else { - $nt = Title::newFromText( $page ); - } - - if ( !$nt || $nt->getArticleID() == 0 ) { - $this->element( $name, $str ); - } else { - $this->page( $name, $nt ); - } - } - - /** - * @param string $name - * @param Title $title - */ - protected function page( $name, $title ) { - $this->url( $name, $title->getFullURL() ); - } - - protected function url( $name, $url ) { - $url = htmlspecialchars( $url ); - print "\t\t\n"; - } - - protected function person( $name, User $user ) { - global $wgHiddenPrefs; - - if ( $user->isAnon() ) { - $this->element( $name, wfMessage( 'anonymous' )->numParams( 1 )->text() ); - } else { - $real = $user->getRealName(); - if ( $real && !in_array( 'realname', $wgHiddenPrefs ) ) { - $this->element( $name, $real ); - } else { - $userName = $user->getName(); - $this->pageOrString( - $name, - $user->getUserPage(), - wfMessage( 'siteuser', $userName, $userName )->text() - ); - } - } - } - - /** - * Takes an arg, for future enhancement with different rights for - * different pages. - */ - protected function rights() { - global $wgRightsPage, $wgRightsUrl, $wgRightsText; - - if ( $wgRightsPage && ( $nt = Title::newFromText( $wgRightsPage ) ) - && ( $nt->getArticleID() != 0 ) ) { - $this->page( 'rights', $nt ); - } elseif ( $wgRightsUrl ) { - $this->url( 'rights', $wgRightsUrl ); - } elseif ( $wgRightsText ) { - $this->element( 'rights', $wgRightsText ); - } - } - - protected function getTerms( $url ) { - global $wgLicenseTerms; - - if ( $wgLicenseTerms ) { - return $wgLicenseTerms; - } else { - $known = $this->getKnownLicenses(); - if ( isset( $known[$url] ) ) { - return $known[$url]; - } else { - return array(); - } - } - } - - protected function getKnownLicenses() { - $ccLicenses = array( 'by', 'by-nd', 'by-nd-nc', 'by-nc', - 'by-nc-sa', 'by-sa' ); - $ccVersions = array( '1.0', '2.0' ); - $knownLicenses = array(); - - foreach ( $ccVersions as $version ) { - foreach ( $ccLicenses as $license ) { - if ( $version == '2.0' && substr( $license, 0, 2 ) != 'by' ) { - # 2.0 dropped the non-attribs licenses - continue; - } - $lurl = "http://creativecommons.org/licenses/{$license}/{$version}/"; - $knownLicenses[$lurl] = explode( '-', $license ); - $knownLicenses[$lurl][] = 're'; - $knownLicenses[$lurl][] = 'di'; - $knownLicenses[$lurl][] = 'no'; - if ( !in_array( 'nd', $knownLicenses[$lurl] ) ) { - $knownLicenses[$lurl][] = 'de'; - } - } - } - - /* Handle the GPL and LGPL, too. */ - - $knownLicenses['http://creativecommons.org/licenses/GPL/2.0/'] = - array( 'de', 're', 'di', 'no', 'sa', 'sc' ); - $knownLicenses['http://creativecommons.org/licenses/LGPL/2.1/'] = - array( 'de', 're', 'di', 'no', 'sa', 'sc' ); - $knownLicenses['http://www.gnu.org/copyleft/fdl.html'] = - array( 'de', 're', 'di', 'no', 'sa', 'sc' ); - - return $knownLicenses; - } -}