consistent plugin usage - creativecommons (event)
this and followup commits touches: use load_languiage API class method parenthesis "\n{\n <code>\n}\n", case break switches, consistent boolean usage, append css to eventData and other cleanups
This commit is contained in:
parent
4c9d8817b7
commit
a8218e8de3
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
||||||
|
|
||||||
class serendipity_event_creativecommons extends serendipity_event {
|
class serendipity_event_creativecommons extends serendipity_event
|
||||||
|
{
|
||||||
var $title = PLUGIN_CREATIVECOMMONS_NAME;
|
var $title = PLUGIN_CREATIVECOMMONS_NAME;
|
||||||
|
|
||||||
function introspect(&$propbag)
|
function introspect(&$propbag)
|
||||||
@ -12,9 +13,9 @@ class serendipity_event_creativecommons extends serendipity_event {
|
|||||||
$propbag->add('description', PLUGIN_CREATIVECOMMONS_DESC);
|
$propbag->add('description', PLUGIN_CREATIVECOMMONS_DESC);
|
||||||
$propbag->add('stackable', false);
|
$propbag->add('stackable', false);
|
||||||
$propbag->add('author', 'Evan Nemerson');
|
$propbag->add('author', 'Evan Nemerson');
|
||||||
$propbag->add('version', '1.5');
|
$propbag->add('version', '1.6');
|
||||||
$propbag->add('requirements', array(
|
$propbag->add('requirements', array(
|
||||||
'serendipity' => '0.8',
|
'serendipity' => '1.6',
|
||||||
'smarty' => '2.6.7',
|
'smarty' => '2.6.7',
|
||||||
'php' => '4.1.0'
|
'php' => '4.1.0'
|
||||||
));
|
));
|
||||||
@ -71,8 +72,8 @@ class serendipity_event_creativecommons extends serendipity_event {
|
|||||||
));
|
));
|
||||||
$propbag->add('radio_per_row', '1');
|
$propbag->add('radio_per_row', '1');
|
||||||
$propbag->add('default', 'yes');
|
$propbag->add('default', 'yes');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'image_type':
|
case 'image_type':
|
||||||
$image_types = array(
|
$image_types = array(
|
||||||
'generic' => PLUGIN_CREATIVECOMMONS_IMAGETYPE_GENERIC,
|
'generic' => PLUGIN_CREATIVECOMMONS_IMAGETYPE_GENERIC,
|
||||||
@ -95,18 +96,21 @@ class serendipity_event_creativecommons extends serendipity_event {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_content(&$title) {
|
function generate_content(&$title)
|
||||||
|
{
|
||||||
$title = $this->title;
|
$title = $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
function event_hook($event, &$bag, &$eventData, $addData = null) {
|
function event_hook($event, &$bag, &$eventData, $addData = null)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
|
$hooks = &$bag->get('event_hooks');
|
||||||
|
|
||||||
$license_data = $this->get_license_data();
|
$license_data = $this->get_license_data();
|
||||||
$license_version = $this->get_config('cc_version', '3.0');
|
$license_version = $this->get_config('cc_version', '3.0');
|
||||||
$license_type = $license_data['type'];
|
$license_type = $license_data['type'];
|
||||||
@ -129,81 +133,83 @@ class serendipity_event_creativecommons extends serendipity_event {
|
|||||||
|
|
||||||
$cc_visibility = 'invisible';
|
$cc_visibility = 'invisible';
|
||||||
|
|
||||||
switch ($event) {
|
if (isset($hooks[$event])) {
|
||||||
case 'frontend_display:html_layout':
|
|
||||||
$cc_visibility = 'visible';
|
switch($event) {
|
||||||
case 'frontend_display:html:per_entry':
|
|
||||||
$eventData['display_dat'] .= '<div style="text-align: center;">';
|
case 'frontend_display:html_layout':
|
||||||
if ($license_string == '') {
|
$cc_visibility = 'visible';
|
||||||
if ($cc_visibility == 'visible') {
|
case 'frontend_display:html:per_entry':
|
||||||
$image_titel = 'No Rights Reserved';
|
$eventData['display_dat'] .= '<div style="text-align: center;">';
|
||||||
$eventData['display_dat'] .= '<a href="http://creativecommons.org/licenses/publicdomain">';
|
if ($license_string == '') {
|
||||||
$eventData['display_dat'] .= '<img style="border: 0px" alt="' . $image_titel. '" title="' . $image_titel. '" src="' . serendipity_getTemplateFile('img/norights.png') .'" />';
|
if ($cc_visibility == 'visible') {
|
||||||
|
$image_titel = 'No Rights Reserved';
|
||||||
|
$eventData['display_dat'] .= '<a href="http://creativecommons.org/licenses/publicdomain">';
|
||||||
|
$eventData['display_dat'] .= '<img style="border: 0px" alt="' . $image_titel. '" title="' . $image_titel. '" src="' . serendipity_getTemplateFile('img/norights.png') .'" />';
|
||||||
|
$eventData['display_dat'] .= '</a>';
|
||||||
|
if (serendipity_db_bool($this->get_config('txt', true))) {
|
||||||
|
$eventData['display_dat'] .= '<br />' . str_replace('#license_uri#', $license_uri, PLUGIN_CREATIVECOMMONS_CAP_PD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($cc_visibility == 'visible') {
|
||||||
|
$image_titel = 'Creative Commons License - Some Rights Reserved';
|
||||||
|
$eventData['display_dat'] .= '<a href="'.$license_uri.'">';
|
||||||
|
$eventData['display_dat'] .= '<img style="border: 0px" alt="' . $image_titel. '" title="' . $image_titel. '" src="' . serendipity_getTemplateFile('img/somerights20.gif') .'" />';
|
||||||
$eventData['display_dat'] .= '</a>';
|
$eventData['display_dat'] .= '</a>';
|
||||||
if (serendipity_db_bool($this->get_config('txt', true))) {
|
if (serendipity_db_bool($this->get_config('txt', true))) {
|
||||||
$eventData['display_dat'] .= '<br />' . str_replace('#license_uri#', $license_uri, PLUGIN_CREATIVECOMMONS_CAP_PD);
|
$eventData['display_dat'] .= '<br />' . str_replace('#license_uri#', $license_uri, PLUGIN_CREATIVECOMMONS_CAP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($cc_visibility == 'visible') {
|
|
||||||
$image_titel = 'Creative Commons License - Some Rights Reserved';
|
$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.'">';
|
||||||
$eventData['display_dat'] .= '<a href="'.$license_uri.'">';
|
if (is_array($rdf)) {
|
||||||
$eventData['display_dat'] .= '<img style="border: 0px" alt="' . $image_titel. '" title="' . $image_titel. '" src="' . serendipity_getTemplateFile('img/somerights20.gif') .'" />';
|
foreach ($rdf as $rdf_t => $rdf_v) {
|
||||||
$eventData['display_dat'] .= '</a>';
|
$eventData['display_dat'] .= ' <'.$rdf_v.' rdf:resource="http://web.resource.org/cc/'.$rdf_t.'" />';
|
||||||
if (serendipity_db_bool($this->get_config('txt', true))) {
|
}
|
||||||
$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.'">';
|
$eventData['display_dat'] .= '</License></rdf:RDF> -->';
|
||||||
if (is_array($rdf)) {
|
$eventData['display_dat'] .= '</div>';
|
||||||
foreach ($rdf as $rdf_t => $rdf_v) {
|
break;
|
||||||
$eventData['display_dat'] .= ' <'.$rdf_v.' rdf:resource="http://web.resource.org/cc/'.$rdf_t.'" />';
|
|
||||||
|
case 'frontend_display:rss-2.0:per_entry':
|
||||||
|
$eventData['display_dat'] .= '<creativeCommons:license>'.$license_uri.'</creativeCommons:license>';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'frontend_display:rss-1.0:per_entry':
|
||||||
|
$eventData['display_dat'] .= '<cc:license rdf:resource="'.$license_uri.'" />';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'frontend_display:rss-1.0:once':
|
||||||
|
$eventData['display_dat'] .= '<cc:License rdf:about="'.$license_uri.'">';
|
||||||
|
if (is_array($rdf)) {
|
||||||
|
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>';
|
||||||
|
break;
|
||||||
|
|
||||||
$eventData['display_dat'] .= '</License></rdf:RDF> -->';
|
case 'frontend_display:rss-2.0:namespace':
|
||||||
$eventData['display_dat'] .= '</div>';
|
$eventData['display_dat'] .= ' xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" ';
|
||||||
return true;
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'frontend_display:rss-2.0:per_entry':
|
case 'frontend_display:rss-1.0:namespace':
|
||||||
$eventData['display_dat'] .= '<creativeCommons:license>'.$license_uri.'</creativeCommons:license>';
|
$eventData['display_dat'] .= ' xmlns:cc="http://web.resource.org/cc/" ';
|
||||||
return true;
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'frontend_display:rss-1.0:per_entry':
|
default:
|
||||||
$eventData['display_dat'] .= '<cc:license rdf:resource="'.$license_uri.'" />';
|
return false;
|
||||||
return true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'frontend_display:rss-1.0:once':
|
}
|
||||||
$eventData['display_dat'] .= '<cc:License rdf:about="'.$license_uri.'">';
|
return true;
|
||||||
if (is_array($rdf)) {
|
} else {
|
||||||
foreach ($rdf as $rdf_t => $rdf_v) {
|
return false;
|
||||||
$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() {
|
function get_license_data()
|
||||||
|
{
|
||||||
$license_type = array();
|
$license_type = array();
|
||||||
$license_version = $this->get_config('cc_version', '3.0');
|
$license_version = $this->get_config('cc_version', '3.0');
|
||||||
|
|
||||||
@ -355,7 +361,8 @@ class serendipity_event_creativecommons extends serendipity_event {
|
|||||||
'rdf' => $rdf
|
'rdf' => $rdf
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set sts=4 ts=4 expandtab : */
|
/* vim: set sts=4 ts=4 expandtab : */
|
||||||
?>
|
?>
|
Loading…
x
Reference in New Issue
Block a user