Extension:CCAgreement
Jump to navigation
Jump to search
![]() | 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 . |
![]() | This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
CCAgreement Release status: unmaintained |
|
---|---|
Implementation | User interface |
Description | Agreement with Creative Commons licencing |
Author(s) | Josef Martiňák (Jossmarttalk) |
Latest version | 0.1.1 (2012-06-21) |
MediaWiki | 1.22+ |
Database changes | No |
License | GNU General Public License 2.0 or later |
Download | see here |
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.
Installation[edit]
- Download and place the file(s) in a directory called
CCAgreement
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/CCAgreement/CCAgreement.php";
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Code[edit]
- CCAgreement.php
<?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.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);
// Append the licence iframe and text message
$tmp = "\n<br/>";
if($context->getLanguage()->getCode() == "cs") {
$tmp .= "<iframe src= \"http://creativecommons.org/licenses/by/3.0/cz/\" ";
$tmp .= "width=\"800\" height=\"1150\"></iframe>\n";
}
else {
$tmp .= "<iframe src= \"http://creativecommons.org/licenses/by/3.0/cz/deed.en\" ";
$tmp .= "width=\"800\" height=\"1150\" ></iframe>\n";
}
$tmp .= "<br/><br/>".$context->msg('cca-agreement')->parse()."<br/><br/>\n";
$out->mBodytext = preg_replace("/(<div class=\"mw-submit\">)/","$tmp$1",$out->mBodytext);
}
}
return true;
}
- CCAgreement.i18n.php
<?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.',
);