| 1 |
<?php
|
| 2 |
// $Id: creativecommons_lite.module,v 1.3 2008/06/10 06:27:10 gloscon Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* This module will display Creative Common licences for selected content type
|
| 6 |
*
|
| 7 |
*/
|
| 8 |
|
| 9 |
define('CC_LITE_PATH', drupal_get_path('module', 'creativecommons_lite'));
|
| 10 |
define('CC_LITE_IMAGE_PATH', base_path() . CC_LITE_PATH . '/images/');
|
| 11 |
|
| 12 |
/** from creativecommons.module
|
| 13 |
*
|
| 14 |
* Enclose each arg in paragraph tags.
|
| 15 |
*/
|
| 16 |
function para() {
|
| 17 |
$args = func_get_args();
|
| 18 |
$p = '';
|
| 19 |
|
| 20 |
foreach($args as $c) {
|
| 21 |
$p .= "<p>$c</p>";
|
| 22 |
}
|
| 23 |
|
| 24 |
return $p;
|
| 25 |
}
|
| 26 |
|
| 27 |
/**
|
| 28 |
* Implementation of hook_perm().
|
| 29 |
*/
|
| 30 |
function creativecommons_lite_perm() {
|
| 31 |
return array('administer creative commons lite');
|
| 32 |
}
|
| 33 |
|
| 34 |
|
| 35 |
/**
|
| 36 |
* Implementation of hook_menu().
|
| 37 |
*/
|
| 38 |
function creativecommons_lite_menu() {
|
| 39 |
$items = array();
|
| 40 |
|
| 41 |
$items['admin/settings/creativecommons-lite'] = array(
|
| 42 |
'title' => t('Creative Commons Lite'),
|
| 43 |
'description' => t('Configure the Creative Commons licence settings.'),
|
| 44 |
'page callback' => 'drupal_get_form',
|
| 45 |
'page arguments' => array('creativecommons_lite_settings_form'),
|
| 46 |
'access arguments' => array('administer creative commons lite')
|
| 47 |
);
|
| 48 |
|
| 49 |
return $items;
|
| 50 |
}
|
| 51 |
|
| 52 |
|
| 53 |
/**
|
| 54 |
* Implementation of hook_help().
|
| 55 |
*/
|
| 56 |
function creativecommons_lite_help($path, $arg) {
|
| 57 |
|
| 58 |
$cc_lite_desc = t('A Creative Commons licence helps you publish your work online while letting others know exactly what they can and can\'t do with your work. Creative Commons offers a flexible range of protections and freedoms for authors and artists, built upon the "all rights reserved" concept of traditional copyright to create a voluntary "some rights reserved" copyright.');
|
| 59 |
$cc_lite_desc_short = t('Assign a Creative Commons licence to content that appears on the site.');
|
| 60 |
$cc_lite_node = t('Attaching a Creative Commons licence to a node within Drupal can designate the content of that node, as well as any attached files, as Creatively Commoned material.');
|
| 61 |
$cc_lite_url = sprintf(t('Visit %s for more information.'), '<a href="http://creativecommons.org/learnmore">' . t('the Creative Commons website') . '</a>');
|
| 62 |
|
| 63 |
switch ($path) {
|
| 64 |
case 'admin/modules#description':
|
| 65 |
return $cc_lite_desc_short;
|
| 66 |
case 'admin/settings/creativecommons-lite':
|
| 67 |
return para($cc_lite_desc, $cc_lite_node, $cc_lite_url);
|
| 68 |
case 'admin/help#creativecommons-lite':
|
| 69 |
return para($cc_lite_desc, $cc_lite_node, $cc_lite_url);
|
| 70 |
}
|
| 71 |
}
|
| 72 |
|
| 73 |
|
| 74 |
/**
|
| 75 |
* Admin settings page
|
| 76 |
*/
|
| 77 |
function creativecommons_lite_settings_form() {
|
| 78 |
// Get all CC licence types
|
| 79 |
$types = creativecommons_lite_get_licence_array();
|
| 80 |
|
| 81 |
$form['creativecommons_lite_mandatory'] = array(
|
| 82 |
'#type' => 'checkbox',
|
| 83 |
'#title' => t('Mandatory licence specification'),
|
| 84 |
'#description' => t('Specifies whether or not the user is required to specify a licence.'),
|
| 85 |
'#default_value' => variable_get('creativecommons_lite_mandatory', 0),
|
| 86 |
);
|
| 87 |
|
| 88 |
$form['creativecommons_lite_no_text'] = array(
|
| 89 |
'#type' => 'checkbox',
|
| 90 |
'#title' => t('Don\'t display licence text'),
|
| 91 |
'#description' => t('Specifies whether or not the licence text should be displayed underneath the licence icons.'),
|
| 92 |
'#default_value' => variable_get('creativecommons_lite_no_text', 0),
|
| 93 |
);
|
| 94 |
|
| 95 |
$licence_icons = array(
|
| 96 |
'buttons_large' => '<img alt="' . $types['by-nc-sa'] . '" src="' . CC_LITE_IMAGE_PATH . 'buttons_large/by-nc-sa.png" />',
|
| 97 |
'buttons_small' => '<img alt="' . $types['by-nc-sa'] . '" src="' . CC_LITE_IMAGE_PATH . 'buttons_small/by-nc-sa.png" />',
|
| 98 |
'deed_icons' => '<img alt="' . t('Attribution') . '" src="' . CC_LITE_IMAGE_PATH . 'deed_icons/by.png" /><img alt="' . t('Non-Commercial') . '" src="' . CC_LITE_IMAGE_PATH . 'deed_icons/nc.png" /><img alt="' . t('Share Alike') . '" src="' . CC_LITE_IMAGE_PATH . 'deed_icons/sa.png" />',
|
| 99 |
'button_srr' => '<img alt="' . t('Some Rights Reserved') . '" src="' . CC_LITE_IMAGE_PATH . 'somerights20.png" />',
|
| 100 |
'none' => t('No icon'),
|
| 101 |
);
|
| 102 |
|
| 103 |
$form['creativecommons_lite_icon_style'] = array(
|
| 104 |
'#type' => 'radios',
|
| 105 |
'#title' => t('Licence icon style'),
|
| 106 |
'#options' => $licence_icons,
|
| 107 |
'#default_value' => variable_get('creativecommons_lite_icon_style', 'buttons_large'),
|
| 108 |
);
|
| 109 |
|
| 110 |
$form['creativecommons_lite_default_licence'] = array(
|
| 111 |
'#type' => 'select',
|
| 112 |
'#title' => t('Default licence'),
|
| 113 |
'#description' => t('Licence selected by default when adding a new node.'),
|
| 114 |
'#options' => $types,
|
| 115 |
'#default_value' => variable_get('creativecommons_lite_default_licence', ''),
|
| 116 |
);
|
| 117 |
|
| 118 |
// Remove the first empty option from the licence types
|
| 119 |
array_shift($types);
|
| 120 |
|
| 121 |
$form['creativecommons_lite_licence_options'] = array(
|
| 122 |
'#type' => 'select',
|
| 123 |
'#title' => t('Allowed licences'),
|
| 124 |
'#description' => t('Selection of licence types the user can choose from.'),
|
| 125 |
'#options' => $types,
|
| 126 |
'#multiple' => TRUE,
|
| 127 |
'#default_value' => variable_get('creativecommons_lite_licence_options', array_keys($types)),
|
| 128 |
);
|
| 129 |
|
| 130 |
$form['creativecommons_lite_jurisdiction'] = array(
|
| 131 |
'#type' => 'select',
|
| 132 |
'#title' => t('Licence jurisdiction'),
|
| 133 |
'#description' => t('Jurisdiction of the applied licence.'),
|
| 134 |
'#options' => creativecommons_lite_get_jurisdiction_array('names'),
|
| 135 |
'#default_value' => variable_get('creativecommons_lite_jurisdiction', ''),
|
| 136 |
);
|
| 137 |
|
| 138 |
return system_settings_form($form);
|
| 139 |
}
|
| 140 |
|
| 141 |
|
| 142 |
/**
|
| 143 |
* Implementation of hook_form_alter().
|
| 144 |
*/
|
| 145 |
function creativecommons_lite_form_alter(&$form, $form_state, $form_id) {
|
| 146 |
// setting for which content type this will show up
|
| 147 |
if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
|
| 148 |
$node_type = $form['#node_type']->type;
|
| 149 |
|
| 150 |
$form['workflow']["creativecommons_lite"] = array(
|
| 151 |
'#type' => 'checkbox',
|
| 152 |
'#title' => t('Allow user to add a Creative Commons licence.'),
|
| 153 |
'#description'=>t('User will be able to select licence while adding content. Selected licence will be displayed in right block on node view page.'),
|
| 154 |
'#return_value' => 1,
|
| 155 |
'#default_value' => variable_get("creativecommons_lite_$node_type", 0),
|
| 156 |
);
|
| 157 |
}
|
| 158 |
elseif (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
|
| 159 |
// add licence selection field to node
|
| 160 |
$node = $form['#node']; // got form
|
| 161 |
|
| 162 |
if (variable_get("creativecommons_lite_$node->type", 0)) {
|
| 163 |
$form = array_merge($form, creativecommons_lite_form($node));
|
| 164 |
$form['creativecommons_lite']['#weight'] = 29; // 30 comment and menu and after that author and publishing
|
| 165 |
}
|
| 166 |
}
|
| 167 |
}
|
| 168 |
|
| 169 |
|
| 170 |
/**
|
| 171 |
* Implementation of hook_form().
|
| 172 |
*/
|
| 173 |
function creativecommons_lite_form($node) {
|
| 174 |
$description = para(
|
| 175 |
sprintf(t('%s help you share your work while keeping your copyright. Other people can copy and distribute your work provided they give you credit—and only on the conditions you specify here.'), '<a href="http://creativecommons.org/learn/licenses/">' . t('Creative Commons licences') . '</a>') .
|
| 176 |
' ' . sprintf(t('Visit the Creative Commons website for an %s'), '<a href="http://creativecommons.org/about/licenses/meet-the-licenses">' . t('explanation of the different licences') . '.</a>'),
|
| 177 |
sprintf(t('Choose the %s if you want to offer your work with no conditions.'), '<a href="http://creativecommons.org/licenses/publicdomain/">' . t('Public Domain licence') . '</a>')
|
| 178 |
);
|
| 179 |
|
| 180 |
$types = array();
|
| 181 |
|
| 182 |
// available licence types
|
| 183 |
$types = creativecommons_lite_get_licence_array(variable_get('creativecommons_lite_licence_options', NULL));
|
| 184 |
|
| 185 |
// default to the default licence or the first licence if no default licence is set except for existing nodes.
|
| 186 |
if (!array_key_exists('cc_lite_licence', $node)) {
|
| 187 |
$node->cc_lite_licence = variable_get('creativecommons_lite_default_licence', key($types));
|
| 188 |
}
|
| 189 |
|
| 190 |
$form['creativecommons_lite'] = array(
|
| 191 |
'#type' => 'fieldset',
|
| 192 |
'#title' => t('Creative Commons licence'),
|
| 193 |
'#attributes' => array('class'=>'attachments'),
|
| 194 |
'#collapsible' => TRUE,
|
| 195 |
'#collapsed' => FALSE,
|
| 196 |
'#tree' => TRUE,
|
| 197 |
);
|
| 198 |
|
| 199 |
$form['creativecommons_lite'][] = array('#value'=>$description);
|
| 200 |
|
| 201 |
$form['creativecommons_lite']['cclite_select_licence_form']['cc_lite_licence'] = array(
|
| 202 |
'#type' => 'select',
|
| 203 |
'#tree'=> FALSE,
|
| 204 |
'#title' => t('Select a licence'),
|
| 205 |
'#default_value' => $node->cc_lite_licence,
|
| 206 |
'#options' => $types,
|
| 207 |
'#required' => variable_get('creativecommons_lite_mandatory', false),
|
| 208 |
);
|
| 209 |
|
| 210 |
return $form;
|
| 211 |
}
|
| 212 |
|
| 213 |
|
| 214 |
/**
|
| 215 |
* return html of a licence
|
| 216 |
*
|
| 217 |
* @param unknown_type $licence
|
| 218 |
* @return unknown
|
| 219 |
*/
|
| 220 |
function get_licence_html($licence) {
|
| 221 |
$licence_info = get_licence_info($licence);
|
| 222 |
|
| 223 |
$html = "\n<!--Creative Commons Licence-->\n";
|
| 224 |
|
| 225 |
if (variable_get('creativecommons_lite_icon_style', 'buttons_large') != 'none') {
|
| 226 |
if ($img = $licence_info['images']) {
|
| 227 |
foreach ($img as $img_tag) {
|
| 228 |
$html .= l($img_tag, $licence_info['licence_uri'], array(
|
| 229 |
'attributes' => array('rel' => 'license', 'title' => $licence_info['licence_name']),
|
| 230 |
'html' => TRUE)
|
| 231 |
) . "\n";
|
| 232 |
}
|
| 233 |
|
| 234 |
$html .= '<br />';
|
| 235 |
}
|
| 236 |
}
|
| 237 |
|
| 238 |
if (!variable_get('creativecommons_lite_no_text', 0)) {
|
| 239 |
$html .= t('This work is licenced under a') .
|
| 240 |
' ' . l($licence_info['licence_name'] .
|
| 241 |
' ' . t('Creative Commons licence'), $licence_info['licence_uri'], array('attributes' => array('rel' => 'license'))) .
|
| 242 |
"<br />\n";
|
| 243 |
}
|
| 244 |
|
| 245 |
$html .= "<!--/Creative Commons Licence-->\n";
|
| 246 |
|
| 247 |
return $html;
|
| 248 |
}
|
| 249 |
|
| 250 |
|
| 251 |
/**
|
| 252 |
* Implementation of hook_block().
|
| 253 |
*/
|
| 254 |
function creativecommons_lite_block($op='list', $delta=0, $edit = array()) {
|
| 255 |
// listing of blocks, such as on the admin/block page
|
| 256 |
if ($op == "list") {
|
| 257 |
$blocks[0] = array(
|
| 258 |
'info' => t('Creative Commons licence'),
|
| 259 |
'weight' => 0,
|
| 260 |
'enabled' => 1, // default make it enabled
|
| 261 |
'region' => 'right', // garland has no right default
|
| 262 |
'theme'=>'garland',
|
| 263 |
);
|
| 264 |
|
| 265 |
return $blocks;
|
| 266 |
}
|
| 267 |
elseif ($op == 'view') {
|
| 268 |
switch ($delta) {
|
| 269 |
case 0:
|
| 270 |
if (!is_numeric(arg(1))) {
|
| 271 |
return;
|
| 272 |
}
|
| 273 |
|
| 274 |
$nid = (int)arg(1);
|
| 275 |
$node = node_load(array('nid'=>$nid));
|
| 276 |
|
| 277 |
if ( $node && arg(0) == 'node' && ( $node->cc_lite_licence ) && ( (arg(2)=='view') || (arg(2)=='') ) ) {
|
| 278 |
if ($node->cc_lite_licence) {
|
| 279 |
// append html
|
| 280 |
$output = get_licence_html($node->cc_lite_licence);
|
| 281 |
|
| 282 |
if ($output) {
|
| 283 |
$block['content'] = '<p class="creativecommons">'.$output.'</p>';
|
| 284 |
}
|
| 285 |
}
|
| 286 |
}
|
| 287 |
|
| 288 |
return $block;
|
| 289 |
}
|
| 290 |
}
|
| 291 |
}
|
| 292 |
|
| 293 |
|
| 294 |
/**
|
| 295 |
* Return array of available licences
|
| 296 |
*
|
| 297 |
* @return unknown
|
| 298 |
*/
|
| 299 |
function creativecommons_lite_get_licence_array($options = NULL) {
|
| 300 |
$types = array();
|
| 301 |
|
| 302 |
$types['by'] = t('Attribution');
|
| 303 |
$types['by-nd'] = t('Attribution No Derivatives');
|
| 304 |
$types['by-nc-nd'] = t('Attribution Non-commercial No Derivatives');
|
| 305 |
$types['by-nc'] = t('Attribution Non-commercial');
|
| 306 |
$types['by-nc-sa'] = t('Attribution Non-commercial Share Alike');
|
| 307 |
$types['by-sa'] = t('Attribution Share Alike');
|
| 308 |
$types['publicdomain'] = t('Public Domain');
|
| 309 |
|
| 310 |
// Only include the provided options
|
| 311 |
if (is_array($options)) {
|
| 312 |
$types = array_intersect_key($types, $options);
|
| 313 |
}
|
| 314 |
|
| 315 |
// Add an empty option to the beginning of the types
|
| 316 |
$types = array_merge(array('' => ''), $types);
|
| 317 |
|
| 318 |
return $types;
|
| 319 |
}
|
| 320 |
|
| 321 |
|
| 322 |
function creativecommons_lite_get_jurisdiction_array($filter = null) {
|
| 323 |
// Available jurisdictions as of 2008-02-18 retrieved from: http://api.creativecommons.org/rest/1.5/support/jurisdictions
|
| 324 |
// License version of each jurisdiction as of 2008-02-18 retrieved for each jurisdiction from http://creativecommons.org/licenses/by-nc-sa/<jurisdiction>/
|
| 325 |
$jurisdictions = array(
|
| 326 |
'' => array('name' => '', 'version' => '3.0'),
|
| 327 |
'ar' => array('name' => 'Argentina', 'version' => '2.5'),
|
| 328 |
'au' => array('name' => 'Australia', 'version' => '2.5'),
|
| 329 |
'at' => array('name' => 'Austria', 'version' => '2.0'),
|
| 330 |
'be' => array('name' => 'Belgium', 'version' => '2.0'),
|
| 331 |
'br' => array('name' => 'Brazil', 'version' => '2.5'),
|
| 332 |
'bg' => array('name' => 'Bulgaria', 'version' => '2.5'),
|
| 333 |
'ca' => array('name' => 'Canada', 'version' => '2.5'),
|
| 334 |
'cl' => array('name' => 'Chile', 'version' => '2.0'),
|
| 335 |
'cn' => array('name' => 'China Mainland', 'version' => '2.5'),
|
| 336 |
'co' => array('name' => 'Colombia', 'version' => '2.5'),
|
| 337 |
'hr' => array('name' => 'Croatia', 'version' => '2.5'),
|
| 338 |
'hu' => array('name' => 'Hungary', 'version' => '2.5'),
|
| 339 |
'dk' => array('name' => 'Denmark', 'version' => '2.5'),
|
| 340 |
'fi' => array('name' => 'Finland', 'version' => '1.0'),
|
| 341 |
'fr' => array('name' => 'France', 'version' => '2.0'),
|
| 342 |
'de' => array('name' => 'Germany', 'version' => '2.0'),
|
| 343 |
'il' => array('name' => 'Israel', 'version' => '2.5'),
|
| 344 |
'in' => array('name' => 'India', 'version' => '2.5'),
|
| 345 |
'it' => array('name' => 'Italy', 'version' => '2.5'),
|
| 346 |
'jp' => array('name' => 'Japan', 'version' => '2.1'),
|
| 347 |
'kr' => array('name' => 'Korea', 'version' => '2.0'),
|
| 348 |
'mk' => array('name' => 'Macedonia', 'version' => '2.5'),
|
| 349 |
'my' => array('name' => 'Malaysia', 'version' => '2.5'),
|
| 350 |
'mt' => array('name' => 'Malta', 'version' => '2.5'),
|
| 351 |
'mx' => array('name' => 'Mexico', 'version' => '2.5'),
|
| 352 |
'nl' => array('name' => 'Netherlands', 'version' => '3.0'),
|
| 353 |
'pe' => array('name' => 'Peru', 'version' => '2.5'),
|
| 354 |
'ph' => array('name' => 'Philippines', 'version' => '3.0'),
|
| 355 |
'pl' => array('name' => 'Poland', 'version' => '2.5'),
|
| 356 |
'pt' => array('name' => 'Portugal', 'version' => '2.5'),
|
| 357 |
'si' => array('name' => 'Slovenia', 'version' => '2.5'),
|
| 358 |
'za' => array('name' => 'South Africa', 'version' => '2.5'),
|
| 359 |
'es' => array('name' => 'Spain', 'version' => '2.5'),
|
| 360 |
'se' => array('name' => 'Sweden', 'version' => '2.5'),
|
| 361 |
'ch' => array('name' => 'Switzerland', 'version' => '2.5'),
|
| 362 |
'tw' => array('name' => 'Taiwan', 'version' => '2.5'),
|
| 363 |
'uk' => array('name' => 'UK: England & Wales', 'version' => '2.0'),
|
| 364 |
'scotland' => array('name' => 'UK: Scotland', 'version' => '2.5'),
|
| 365 |
'us' => array('name' => 'United States', 'version' => '3.0'),
|
| 366 |
'gr' => array('name' => 'Greece', 'version' => '3.0'),
|
| 367 |
'lu' => array('name' => 'Luxembourg', 'version' => '3.0'),
|
| 368 |
'nz' => array('name' => 'New Zealand', 'version' => '3.0'),
|
| 369 |
'rs' => array('name' => 'Serbia', 'version' => '3.0')
|
| 370 |
);
|
| 371 |
|
| 372 |
switch ($filter) {
|
| 373 |
case 'names':
|
| 374 |
$names = array();
|
| 375 |
|
| 376 |
foreach ($jurisdictions as $key => $value) {
|
| 377 |
$names[$key] = $value['name'];
|
| 378 |
}
|
| 379 |
|
| 380 |
return $names;
|
| 381 |
break;
|
| 382 |
case 'versions':
|
| 383 |
$versions = array();
|
| 384 |
|
| 385 |
foreach ($jurisdictions as $key => $value) {
|
| 386 |
$versions[$key] = $value['version'];
|
| 387 |
}
|
| 388 |
|
| 389 |
return $versions;
|
| 390 |
break;
|
| 391 |
default:
|
| 392 |
return $jurisdictions;
|
| 393 |
break;
|
| 394 |
}
|
| 395 |
}
|
| 396 |
|
| 397 |
/**
|
| 398 |
* Implementation of hook_nodeapi().
|
| 399 |
*/
|
| 400 |
function creativecommons_lite_nodeapi(&$node, $op, $a3, $a4) {
|
| 401 |
switch($op) {
|
| 402 |
case 'validate':
|
| 403 |
break;
|
| 404 |
case 'load':
|
| 405 |
if( variable_get("creativecommons_lite_$node->type", 0) ) {
|
| 406 |
$result = db_query("SELECT * FROM {creativecommons_lite} WHERE nid=%d", $node->nid);
|
| 407 |
$res = db_fetch_array($result);
|
| 408 |
$node->cc_lite_licence = $res['licence'];
|
| 409 |
}
|
| 410 |
|
| 411 |
break;
|
| 412 |
case 'view':
|
| 413 |
// added block view
|
| 414 |
break;
|
| 415 |
case 'insert':
|
| 416 |
if( variable_get("creativecommons_lite_$node->type", 0) ) {
|
| 417 |
$result = db_query("INSERT INTO {creativecommons_lite} (nid, licence) VALUES (%d, '%s')", $node->nid, $node->cc_lite_licence);
|
| 418 |
}
|
| 419 |
|
| 420 |
break;
|
| 421 |
case 'update':
|
| 422 |
if( variable_get("creativecommons_lite_$node->type", 0) ) {
|
| 423 |
//check to see if this node already has a licence
|
| 424 |
$result = db_query("SELECT * FROM {creativecommons_lite} WHERE nid = %d", $node->nid);
|
| 425 |
$licence = db_fetch_object($result);
|
| 426 |
|
| 427 |
if (!$licence) {
|
| 428 |
return creativecommons_lite_nodeapi($node, 'insert', $a3, $a4);
|
| 429 |
}
|
| 430 |
|
| 431 |
// update node licence
|
| 432 |
$result = db_query("UPDATE {creativecommons_lite} SET licence='%s' WHERE nid=%d ", $node->cc_lite_licence, $node->nid);
|
| 433 |
}
|
| 434 |
|
| 435 |
break;
|
| 436 |
case 'delete':
|
| 437 |
if (variable_get("creativecommons_lite_$node->type", 0)) {
|
| 438 |
db_query("DELETE FROM {creativecommons_lite} WHERE nid=%d", $node->nid);
|
| 439 |
}
|
| 440 |
|
| 441 |
break;
|
| 442 |
case 'rss item':
|
| 443 |
break;
|
| 444 |
}
|
| 445 |
|
| 446 |
return $output;
|
| 447 |
}
|
| 448 |
|
| 449 |
|
| 450 |
function get_licence_info($licence) {
|
| 451 |
$licence_info = array();
|
| 452 |
$images = array();
|
| 453 |
|
| 454 |
$uri = 'http://creativecommons.org/licenses/';
|
| 455 |
$jurisdiction = variable_get('creativecommons_lite_jurisdiction', '');
|
| 456 |
$icon_style = variable_get('creativecommons_lite_icon_style', 'buttons_large');
|
| 457 |
|
| 458 |
$types = creativecommons_lite_get_licence_array();
|
| 459 |
$versions = creativecommons_lite_get_jurisdiction_array('versions');
|
| 460 |
|
| 461 |
$licence_version = $versions[$jurisdiction] . '/' . ($jurisdiction != '' ? $jurisdiction . '/' : '');
|
| 462 |
|
| 463 |
$licence_info['licence_name'] = $types[$licence];
|
| 464 |
$licence_info['licence_uri'] = $uri . $licence . '/' . ($licence != 'publicdomain' ? $licence_version : '');
|
| 465 |
|
| 466 |
if ($icon_style != 'none') {
|
| 467 |
switch ($icon_style) {
|
| 468 |
case 'deed_icons':
|
| 469 |
$folder = $icon_style . '/';
|
| 470 |
|
| 471 |
$icons = explode('-', $licence);
|
| 472 |
|
| 473 |
foreach($icons as $value) {
|
| 474 |
$images[] = $value . '.png';
|
| 475 |
}
|
| 476 |
|
| 477 |
break;
|
| 478 |
case 'button_srr':
|
| 479 |
$folder = '';
|
| 480 |
|
| 481 |
$images[] = 'somerights20.png';
|
| 482 |
|
| 483 |
break;
|
| 484 |
default:
|
| 485 |
$folder = $icon_style . '/';
|
| 486 |
|
| 487 |
$images[] = $licence . '.png';
|
| 488 |
|
| 489 |
break;
|
| 490 |
}
|
| 491 |
|
| 492 |
foreach($images as $key => $image) {
|
| 493 |
$images[$key] = '<img alt="' . t('Creative Commons licence icon') . '" src="' . CC_LITE_IMAGE_PATH . $folder . $image . '" />';
|
| 494 |
}
|
| 495 |
|
| 496 |
$licence_info['images'] = $images;
|
| 497 |
}
|
| 498 |
|
| 499 |
return $licence_info;
|
| 500 |
}
|