Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_creativecommons
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23112/serendipity_event_creativecommons
Modified Files:
serendipity_event_creativecommons.php
Log Message:
Should fix some issues with wrong radio button configuration.
Clean up code. Beautify and use correct indentation.
German translation (Sebastian, can you check if I did that right?).
Index: serendipity_event_creativecommons.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_creativecommons/serendipity_event_creativecommons.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- serendipity_event_creativecommons.php 2 Apr 2004 09:09:29 -0000 1.1
+++ serendipity_event_creativecommons.php 2 Apr 2004 11:03:20 -0000 1.2
@@ -1,21 +1,37 @@
<?php # $Id$
switch ($serendipity['lang']) {
+ case 'de':
+ @define('PLUGIN_CREATIVECOMMONS_NAME', 'Creative Commons Lizens');
+ @define('PLUGIN_CREATIVECOMMONS_DESC', 'Wählen Sie eine Lizens für den Inhalt');
+ @define('PLUGIN_CREATIVECOMMONS_TXT', 'Text anzeigen?');
+ @define('PLUGIN_CREATIVECOMMONS_TXT_DESC', 'Zeigt eine kurze Erklärung zu Ihrer individuellen Lizensierung an');
+ @define('PLUGIN_CREATIVECOMMONS_CAP', 'Der Inhalt dieses Werkes ist lizensiert unter der <a href="#license_uri#">Creative Commons Lizens</a>');
+ @define('PLUGIN_CREATIVECOMMONS_CAP_PD', 'Der Inhalt dieses Werkes ist als <a href="#license_url#}">Public Domain</a> gewidmet');
+ @define('PLUGIN_CREATIVECOMMONS_BY', 'Attribution (Nennung als Author) erforderlich?');
+ @define('PLUGIN_CREATIVECOMMONS_BY_DESC', 'Der Lizensgeber erlaubt anderen dieses Werk zu kopieren, zu verteilen, anzuwenden und darzustellen. Als Gegenleistung müssen Lizensnehmer den ursprünglichen Authoren nennen.');
+ @define('PLUGIN_CREATIVECOMMONS_NC', 'Kommerzielle Nutzung des Werkes erlauben?');
+ @define('PLUGIN_CREATIVECOMMONS_NC_DESC', 'Der Lizensgeber erlaubt anderen dieses Werk zu kopieren, zu verteilen, anzuwenden und darzustellen. Als Gegenleistung dürfen die Lizensnehmer das Werk nicht in kommerziellem Kontext einsetzen - es sei denn, sie erhalten die ausdrückliche Genehmigung.');
+ @define('PLUGIN_CREATIVECOMMONS_ND', 'Veränderungen des Werkes erlauben?');
+ @define('PLUGIN_CREATIVECOMMONS_ND_DESC', 'Der Lizensgeber erlaubt anderen dieses Werk in unveränderter Form zu kopieren, zu verteilen, anzuwenden und darzustellen. Daran anlehnende oder ableitende Werke sind nicht erlaubt.');
+ @define('PLUGIN_CREATIVECOMMONS_SA_DESC', 'Ja, solange dieses Recht weitergegeben wird');
+ break;
+
case 'en':
default:
@define('PLUGIN_CREATIVECOMMONS_NAME', 'Creative Commons License');
@define('PLUGIN_CREATIVECOMMONS_DESC', 'Choose a creative commons license for your content');
@define('PLUGIN_CREATIVECOMMONS_TXT', 'Show text?');
@define('PLUGIN_CREATIVECOMMONS_TXT_DESC', 'For visible notifications of license status, show a brief explanation of your license choice.');
- @define('PLUGIN_CREATIVECOMMONS_CAP', 'Original content in this work is licensed under a <a href="#license_uri#">Creative Commons License</a>');
- @define('PLUGIN_CREATIVECOMMONS_CAP_PD', 'Original content in this work is dedicated to the <a href="#license_url#}">Public Domain</a>');
+ @define('PLUGIN_CREATIVECOMMONS_CAP', 'Original content in this work is licensed under a <a href="#license_uri#">Creative Commons License</a>');
+ @define('PLUGIN_CREATIVECOMMONS_CAP_PD', 'Original content in this work is dedicated to the <a href="#license_url#}">Public Domain</a>');
@define('PLUGIN_CREATIVECOMMONS_BY', 'Require attribution?');
@define('PLUGIN_CREATIVECOMMONS_BY_DESC', 'The licensor permits others to copy, distribute, display, and perform the work. In return, licensees must give the original author credit.');
@define('PLUGIN_CREATIVECOMMONS_NC', 'Allow commercial uses of your work?');
@define('PLUGIN_CREATIVECOMMONS_NC_DESC', 'The licensor permits others to copy, distribute, display, and perform the work. In return, licensees may not use the work for commercial purposes -- unless they get the licensor\'s permission.');
@define('PLUGIN_CREATIVECOMMONS_ND', 'Allow modifications of your work?');
@define('PLUGIN_CREATIVECOMMONS_ND_DESC', 'The licensor permits others to copy, distribute, display and perform only unaltered copies of the work -- not derivative works based on it.');
- @define('PLUGIN_CREATIVECOMMONS_SA_DESC', 'Yes, as long as others share alike');
+ @define('PLUGIN_CREATIVECOMMONS_SA_DESC', 'Yes, as long as others share alike');
break;
}
@@ -43,221 +59,279 @@
$propbag->add('name', PLUGIN_CREATIVECOMMONS_BY);
$propbag->add('description', PLUGIN_CREATIVECOMMONS_BY_DESC);
break;
+
case 'nc':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_CREATIVECOMMONS_NC);
$propbag->add('description', PLUGIN_CREATIVECOMMONS_NC_DESC);
break;
+
case 'nd':
$propbag->add('type', 'radio');
$propbag->add('name', PLUGIN_CREATIVECOMMONS_ND);
$propbag->add('description', PLUGIN_CREATIVECOMMONS_ND_DESC);
- $propbag->add('radio_values', array('yes' => YES, 'sa' => PLUGIN_CREATIVECOMMONS_SA_DESC, 'no' => NO));
+ $propbag->add('radio', array(
+ 'value' => array('yes', 'sa', 'no'),
+ 'desc' => array(YES, PLUGIN_CREATIVECOMMONS_SA_DESC, NO)
+ ));
+ $propbag->add('radio_per_row', '1');
break;
+
case 'txt':
$propbag->add('type', 'boolean');
$propbag->add('name', PLUGIN_CREATIVECOMMONS_TXT);
$propbag->add('description', PLUGIN_CREATIVECOMMONS_TXT_DESC);
break;
+
default:
return false;
- break;
+ break;
}
return true;
}
function generate_content(&$title) {
- $title = PLUGIN_CREATIVECOMMONS_NAME;
+ $title = PLUGIN_CREATIVECOMMONS_NAME;
}
function event_hook($event, &$bag, &$eventData) {
- global $serendipity;
+ global $serendipity;
- $license_data = $this->get_license_data();
- $license_type = $license_data['type'];
- $license_string = $license_data['string'];
- $rdf = $license_data['rdf'];
+ $license_data = $this->get_license_data();
+ $license_type = $license_data['type'];
+ $license_string = $license_data['string'];
+ $rdf = $license_data['rdf'];
- if ( $license_string == '' )
- $license_uri = 'http://web.resource.org/cc/PublicDomain';
- else
- $license_uri = 'http://creativecommons.org/licenses/'.$license_string.'/1.0/';
+ if ($license_string == '') {
+ $license_uri = 'http://web.resource.org/cc/PublicDomain';
+ } else {
+ $license_uri = 'http://creativecommons.org/licenses/'.$license_string.'/1.0/';
+ }
- $cc_visibility = 'invisible';
+ $cc_visibility = 'invisible';
- switch ( $event ) {
- case 'frontend_display:html_layout':
- $cc_visibility = 'visible';
- case 'frontend_display:html:per_entry':
- $eventData['display_dat'] = '<div style="text-align: center;">';
- if ( $license_string == '' ) {
- if ( $cc_visibility == 'visible' ) {
- $eventData['display_dat'] .= '<a href="http://creativecommons.org/licenses/publicdomain">';
- $eventData['display_dat'] .= '<img border="0" alt="No Rights Reserved" src="'.$serendipity['serendipityHTTPPath'].'/pixel/norights.png"/>';
- $eventData['display_dat'] .= '</a>';
- if ( $this->get_config('txt') != 'false' ) {
- $eventData['display_dat'] .= '<br />'.str_replace('#license_uri#', $license_uri, PLUGIN_CREATIVECOMMONS_CAP_PD);
- }
- }
- }
- else {
- if ( $cc_visibility == 'visible' ) {
- $eventData['display_dat'] .= '<a href="'.$license_uri.'">';
- $eventData['display_dat'] .= '<img border="0" alt="Creative Commons License - Some Rights Reserved" src="'.$serendipity['serendipityHTTPPath'].'/pixel/somerights.png"/>';
- $eventData['display_dat'] .= '</a>';
- if ( $this->get_config('txt') != 'false' ) {
- $eventData['display_dat'] .= '<br />'.str_replace('#license_uri#', $license_uri, PLUGIN_CREATIVECOMMONS_CAP);
- }
- }
- }
+ switch ($event) {
+ case 'frontend_display:html_layout':
+ $cc_visibility = 'visible';
+ case 'frontend_display:html:per_entry':
+ $eventData['display_dat'] = '<div style="text-align: center;">';
+ if ($license_string == '') {
+ if ($cc_visibility == 'visible') {
+ $eventData['display_dat'] .= '<a href="http://creativecommons.org/licenses/publicdomain">';
+ $eventData['display_dat'] .= '<img style="border: 0px" alt="No Rights Reserved" src="' . $serendipity['serendipityHTTPPath'] . 'pixel/norights.png" />';
+ $eventData['display_dat'] .= '</a>';
+ if ($this->get_config('txt') != 'false') {
+ $eventData['display_dat'] .= '<br />' . str_replace('#license_uri#', $license_uri, PLUGIN_CREATIVECOMMONS_CAP_PD);
+ }
+ }
+ } elseif ($cc_visibility == 'visible') {
+ $eventData['display_dat'] .= '<a href="'.$license_uri.'">';
+ $eventData['display_dat'] .= '<img style="border: 0px" alt="Creative Commons License - Some Rights Reserved" src="' . $serendipity['serendipityHTTPPath'] . 'pixel/somerights.png" />';
+ $eventData['display_dat'] .= '</a>';
+ if ($this->get_config('txt') != 'false') {
+ $eventData['display_dat'] .= '<br />' . str_replace('#license_uri#', $license_uri, PLUGIN_CREATIVECOMMONS_CAP);
+ }
+ }
- $eventData['display_dat'] .= '<!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><Work rdf:about=""><license rdf:resource="'.$license_uri.'"/></Work><License rdf:about="'.$license_uri.'">';
- foreach ( $rdf as $rdf_t => $rdf_v ) {
- $eventData['display_dat'] .= ' <'.$rdf_v.' rdf:resource="http://web.resource.org/cc/'.$rdf_t.'" />';
- }
- $eventData['display_dat'] .= '</License></rdf:RDF> -->';
- $eventData['display_dat'] .= '</div>';
- return true;
- break;
- case 'frontend_display:rss-2.0:per_entry':
- $eventData['display_dat'] = '<creativeCommons:license>'.$license_uri.'</creativeCommons:license>';
- return true;
- break;
- case 'frontend_display:rss-1.0:per_entry':
- $eventData['display_dat'] = '<cc:license rdf:resource="'.$license_uri.'" />';
- return true;
- break;
- case 'frontend_display:rss-1.0:once':
- $eventData['display_dat'] = '<cc:License rdf:about="'.$license_uri.'">';
- foreach ( $rdf as $rdf_t => $rdf_v ) {
- $eventData['display_dat'] .= '<cc:'.$rdf_v.' rdf:resource="http://web.resource.org/cc/'.$rdf_t.'" />';
- }
- $eventData['display_dat'] .= '</cc:License>';
- return true;
- break;
- case 'frontend_display:rss-2.0:namespace':
- $eventData['display_dat'] = 'xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"';
- return true;
- break;
- case 'frontend_display:rss-1.0:namespace':
- $eventData['display_dat'] = 'xmlns:cc="http://web.resource.org/cc/"';
- return true;
- break;
- default:
- return true;
- break;
- }
+ $eventData['display_dat'] .= '<!-- <rdf:RDF xmlns="http://web.resource.org/cc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><Work rdf:about=""><license rdf:resource="'.$license_uri.'"/></Work><License rdf:about="'.$license_uri.'">';
+ if (is_array($df)) {
+ foreach ($rdf as $rdf_t => $rdf_v) {
+ $eventData['display_dat'] .= ' <'.$rdf_v.' rdf:resource="http://web.resource.org/cc/'.$rdf_t.'" />';
+ }
+ }
+
+ $eventData['display_dat'] .= '</License></rdf:RDF> -->';
+ $eventData['display_dat'] .= '</div>';
+ return true;
+ break;
+
+ case 'frontend_display:rss-2.0:per_entry':
+ $eventData['display_dat'] = '<creativeCommons:license>'.$license_uri.'</creativeCommons:license>';
+ return true;
+ break;
+
+ case 'frontend_display:rss-1.0:per_entry':
+ $eventData['display_dat'] = '<cc:license rdf:resource="'.$license_uri.'" />';
+ return true;
+ break;
+
+ case 'frontend_display:rss-1.0:once':
+ $eventData['display_dat'] = '<cc:License rdf:about="'.$license_uri.'">';
+ foreach ($rdf as $rdf_t => $rdf_v) {
+ $eventData['display_dat'] .= '<cc:'.$rdf_v.' rdf:resource="http://web.resource.org/cc/'.$rdf_t.'" />';
+ }
+ $eventData['display_dat'] .= '</cc:License>';
+ return true;
+ break;
+
+ case 'frontend_display:rss-2.0:namespace':
+ $eventData['display_dat'] = 'xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"';
+ return true;
+ break;
+
+ case 'frontend_display:rss-1.0:namespace':
+ $eventData['display_dat'] = 'xmlns:cc="http://web.resource.org/cc/"';
+ return true;
+ break;
+
+ default:
+ return true;
+ break;
+ }
}
function get_license_data() {
- $license_type = array();
+ $license_type = array();
- if ( $this->get_config('by') != 'false' ) {
- $license_type[] = 'by';
- }
- if ( $this->get_config('nc') == 'false' ) {
- $license_type[] = 'nc';
- }
- switch ( $this->get_config('nd') ) {
- case 'sa':
- $license_type[] = 'sa';
- break;
- case 'no':
- default:
- $license_type[] = 'nd';
- break;
- }
+ if ($this->get_config('by') != 'false') {
+ $license_type[] = 'by';
+ }
- $license_string = implode('-', $license_type);
+ if ($this->get_config('nc') == 'false') {
+ $license_type[] = 'nc';
+ }
- switch ( $license_string ) {
- case 'by':
- $rdf = array('Attribution' => 'requires',
- 'Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'DerivativeWorks' => 'permits',
- 'Notice' => 'requires');
- break;
- case 'by-nd':
- $rdf = array('Attribution' => 'requires',
- 'Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'Notice' => 'requires');
- break;
- case 'by-nd-nc':
- $rdf = array('Attribution' => 'requires',
- 'Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'CommercialUse' => 'prohibits',
- 'Notice' => 'requires');
- break;
- case 'by-nc':
- $rdf = array('Attribution' => 'requires',
- 'Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'DerivativeWorks' => 'permits',
- 'CommercialUse' => 'prohibits',
- 'Notice' => 'requires');
- break;
- case 'by-nc-sa':
- $rdf = array('Attribution' => 'requires',
- 'Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'DerivativeWorks' => 'permits',
- 'ShareAlike' => 'requires',
- 'CommercialUse' => 'prohibits',
- 'Notice' => 'requires');
- break;
- case 'by-sa':
- $rdf = array('Attribution' => 'requires',
- 'Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'DerivativeWorks' => 'permits',
- 'ShareAlike' => 'requires',
- 'Notice' => 'requires');
- break;
- case 'nd':
- $rdf = array('Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'Notice' => 'requires');
- break;
- case 'nd-nc':
- $rdf = array('Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'CommercialUse' => 'prohibits',
- 'Notice' => 'requires');
- break;
- case 'nc':
- $rdf = array('Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'DerivativeWorks' => 'permits',
- 'CommercialUse' => 'prohibits',
- 'Notice' => 'requires');
- break;
- case 'nc-sa':
- $rdf = array('Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'DerivativeWorks' => 'permits',
- 'ShareAlike' => 'requires',
- 'CommercialUse' => 'prohibits',
- 'Notice' => 'requires');
- break;
- case 'sa':
- $rdf = array('Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'DerivativeWorks' => 'permits',
- 'ShareAlike' => 'requires',
- 'Notice' => 'requires');
- break;
- case '':
- $rdf = array('Reproduction' => 'permits',
- 'Distribution' => 'permits',
- 'DerivativeWorks' => 'permits');
- break;
- }
- return array('type' => $license_type, 'string' => $license_string, 'rdf' => $rdf);
+ switch ($this->get_config('nd')) {
+ case 'sa':
+ $license_type[] = 'sa';
+ break;
+
+ case 'no':
+ default:
+ $license_type[] = 'nd';
+ break;
+ }
+
+ $license_string = implode('-', $license_type);
+
+ switch ($license_string) {
+ case 'by':
+ $rdf = array(
+ 'Attribution' => 'requires',
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'DerivativeWorks' => 'permits',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case 'by-nd':
+ $rdf = array(
+ 'Attribution' => 'requires',
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case 'by-nd-nc':
+ $rdf = array(
+ 'Attribution' => 'requires',
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'CommercialUse' => 'prohibits',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case 'by-nc':
+ $rdf = array(
+ 'Attribution' => 'requires',
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'DerivativeWorks' => 'permits',
+ 'CommercialUse' => 'prohibits',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case 'by-nc-sa':
+ $rdf = array(
+ 'Attribution' => 'requires',
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'DerivativeWorks' => 'permits',
+ 'ShareAlike' => 'requires',
+ 'CommercialUse' => 'prohibits',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case 'by-sa':
+ $rdf = array(
+ 'Attribution' => 'requires',
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'DerivativeWorks' => 'permits',
+ 'ShareAlike' => 'requires',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case 'nd':
+ $rdf = array(
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case 'nd-nc':
+ $rdf = array(
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'CommercialUse' => 'prohibits',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case 'nc':
+ $rdf = array(
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'DerivativeWorks' => 'permits',
+ 'CommercialUse' => 'prohibits',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case 'nc-sa':
+ $rdf = array(
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'DerivativeWorks' => 'permits',
+ 'ShareAlike' => 'requires',
+ 'CommercialUse' => 'prohibits',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case 'sa':
+ $rdf = array(
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'DerivativeWorks' => 'permits',
+ 'ShareAlike' => 'requires',
+ 'Notice' => 'requires'
+ );
+ break;
+
+ case '':
+ $rdf = array(
+ 'Reproduction' => 'permits',
+ 'Distribution' => 'permits',
+ 'DerivativeWorks' => 'permits'
+ );
+ break;
+ }
+
+ return array(
+ 'type' => $license_type,
+ 'string' => $license_string,
+ 'rdf' => $rdf
+ );
}
}
/* vim: set sts=4 ts=4 expandtab : */
-?>
\ No newline at end of file
+?>
|