Extension:CCAgreement
From MediaWiki.org
| This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net. |
|
CCAgreement Release status: beta |
|||
|---|---|---|---|
| Implementation | User interface | ||
| Description | Agreement with Creative Commons licencing | ||
| Author(s) | Josef Martiňák (Jossmarttalk) | ||
| Last version | 0.1 (2012-06-21) | ||
| MediaWiki | 1.19+ | ||
| Database changes | No | ||
| License | GPL | ||
| Download | see here | ||
| Example | test signup | ||
|
|||
| Check usage and version matrix | |||
The CCAgreement extension changes the look of the SignUp page. New user confirms then by clicking the submit button an agreement with Creative Commons licencing.
It is developed for www.wikiskripta.eu and www.wikilectures.eu and there are currently three language versions: Czech, English and German.
Contents |
Installation [edit]
- Create folder extensions/CCAgreement and put in the CCAgreement.php and CCAgreement.i18n.php.
- In LocalSettings.php add this line
require_once( "$IP/extensions/CCAgreement/CCAgreement.php" );
Code [edit]
CCAgreement.php [edit]
<?php #################################################################################################### # Extension changes the look of the SignUp page. New user confirms by clicking # the submit button an agreement with Creative Commons licencing. #################################################################################################### if (!defined('MEDIAWIKI')) { echo <<<EOT To install my extension, put the following line in LocalSettings.php: require_once( "\$IP/extensions/CCAgreement/CCAgreement.php" ); EOT; exit( 1 ); } $wgExtensionCredits['specialpage'][] = array( 'name' => 'CCAgreement', 'author' => 'Josef Martiňák', 'url' => "https://www.mediawiki.org/wiki/Extension:CCAgreement", 'descriptionmsg' => 'cca-desc', 'version' => '0.1', ); $dir = dirname(__FILE__) . '/'; $wgExtensionMessagesFiles['CCAgreement'] = $dir . 'CCAgreement.i18n.php'; $wgHooks['BeforePageDisplay'][] = 'AddLicencing'; function AddLicencing(&$out,&$skin) { $context = $out; $title = $context->getTitle(); if($title->isSpecialPage() && SpecialPage::resolveAlias($title->getBaseText()) == "Userlogin"){ $query = $context->getRequest()->getQueryValues(); if(!empty($query["type"]) && $query["type"] == "signup"){ // Change submit button text and position $out->mBodytext = preg_replace("/(id=\"wpCreateaccount\"[^>]*)value=\"[^\"]*\"/", "$1value=\"".$context->msg('cca-submit-button')->text()."\"",$out->mBodytext); $out->mBodytext = preg_replace("/(?=[^\"]*\"mw-submit)<td><\/td>/","",$out->mBodytext); $out->mBodytext = preg_replace("/<td class=\"mw-submit\">/", "<td class=\"mw-submit\" colspan=\"2\">",$out->mBodytext); // Append the licence iframe and text message $tmp = "<tr><td colspan=\"2\">\n<br/>"; if($context->getLanguage()->getCode() == "cs") { $tmp .= "<iframe src= \"http://creativecommons.org/licenses/by/3.0/cz/\" "; $tmp .= "width=\"800\" height=\"1050\"></iframe>\n"; } else { $tmp .= "<iframe src= \"http://creativecommons.org/licenses/by/3.0/\" "; $tmp .= "width=\"800\" height=\"1020\" ></iframe>\n"; } $tmp .= "<br/><br/>".$context->msg('cca-agreement')->parse()."<br/><br/>\n"; $tmp .= "</td>\n</tr>\n"; $out->mBodytext = preg_replace("/(?=[^\"]*\"mw-submit)<tr>/",$tmp."<tr>",$out->mBodytext); } } return true; }
CCAgreement.i18n.php [edit]
<?php $messages = array(); /* *** English *** */ $messages['en'] = array( 'cca-desc' => 'Assures an agreement to Creative Commons licencing', 'cca-submit-button' => 'I AGREE - create account', 'cca-agreement' => 'I will release all my texts under the licence above. Details can be found at [[{{SITENAME}}:Author Law]].', ); /* *** Czech *** */ $messages['cs'] = array( 'cca-desc' => 'Potvrzení souhlasu s licencí Creative Commons', 'cca-submit-button' => 'SOUHLASÍM - vytvořit účet', 'cca-agreement' => 'Všechny své texty uvolním za podmínek výše uvedené licence. Další podrobnosti jsou na stránce [[{{SITENAME}}:Autorské právo]].', ); /* *** German *** */ $messages['de'] = array( 'cca-desc' => 'Stellt die Zustimmung zur Lizenzierung gemäß Creative Commons sicher', 'cca-submit-button' => 'Ich stimme zu − Benutzerkonto erstellen', 'cca-agreement' => 'Ich werde alle meine Beiträge gemäß obig benannter Lizenz veröffentlichen. Weitere Einzelheiten sind auf der Seite [[{{SITENAME}}:Autorenrichtlinie]] verfügbar.', );

