summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2008-10-12 13:31:50 +0200
committerAndreas Gohr <andi@splitbrain.org>2008-10-12 13:31:50 +0200
commit066fee3089513b988d1beac2040e32a365921310 (patch)
treee20413f725f57ec6071c66b745fc25bea2e08b55
parent7aedde2e62651d550e6213d3852447b26255e8de (diff)
downloadrpg-066fee3089513b988d1beac2040e32a365921310.tar.gz
rpg-066fee3089513b988d1beac2040e32a365921310.tar.bz2
Make license selectable from config FS#312
darcs-hash:20081012113150-7ad00-6408da058bdb6c923159d445e03b76f54b579362.gz
-rw-r--r--conf/dokuwiki.php3
-rw-r--r--conf/license.php40
-rw-r--r--inc/actions.php1
-rw-r--r--inc/common.php27
-rw-r--r--inc/html.php10
-rw-r--r--inc/init.php10
-rw-r--r--inc/lang/en/lang.php3
-rw-r--r--inc/template.php34
-rw-r--r--lib/images/license/badge/cc-by-nc-nd.pngbin0 -> 5281 bytes
-rw-r--r--lib/images/license/badge/cc-by-nc-sa.pngbin0 -> 5460 bytes
-rw-r--r--lib/images/license/badge/cc-by-nc.pngbin0 -> 5145 bytes
-rw-r--r--lib/images/license/badge/cc-by-nd.pngbin0 -> 4880 bytes
-rw-r--r--lib/images/license/badge/cc-by-sa.pngbin0 -> 5083 bytes
-rw-r--r--lib/images/license/badge/cc-by.pngbin0 -> 4739 bytes
-rw-r--r--lib/images/license/badge/cc.pngbin0 -> 958 bytes
-rw-r--r--lib/images/license/badge/publicdomain.pngbin0 -> 4962 bytes
-rw-r--r--lib/images/license/button/cc-by-nc-nd.pngbin0 -> 688 bytes
-rw-r--r--lib/images/license/button/cc-by-nc-sa.pngbin0 -> 697 bytes
-rw-r--r--lib/images/license/button/cc-by-nc.pngbin0 -> 672 bytes
-rw-r--r--lib/images/license/button/cc-by-nd.pngbin0 -> 665 bytes
-rw-r--r--lib/images/license/button/cc-by-sa.pngbin0 -> 672 bytes
-rw-r--r--lib/images/license/button/cc-by.pngbin0 -> 640 bytes
-rw-r--r--lib/images/license/button/cc.pngbin0 -> 802 bytes
-rw-r--r--lib/images/license/button/publicdomain.pngbin0 -> 629 bytes
-rw-r--r--lib/plugins/config/lang/en/lang.php3
-rw-r--r--lib/plugins/config/settings/config.class.php1
-rw-r--r--lib/plugins/config/settings/config.metadata.php1
-rw-r--r--lib/plugins/config/settings/extra.class.php19
-rw-r--r--lib/tpl/default/design.css11
-rw-r--r--lib/tpl/default/main.php2
30 files changed, 162 insertions, 3 deletions
diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php
index 5e25c4456..ab4d71387 100644
--- a/conf/dokuwiki.php
+++ b/conf/dokuwiki.php
@@ -25,7 +25,8 @@ $conf['allowdebug'] = 0; //allow debug output, enable if needed
$conf['start'] = 'start'; //name of start page
$conf['title'] = 'DokuWiki'; //what to show in the title
-$conf['template'] = 'default'; //see tpl directory
+$conf['template'] = 'default'; //see lib/tpl directory
+$conf['license'] = 'cc-by-nc-sa'; //see conf/license.php
$conf['fullpath'] = 0; //show full path of the document or relative to datadir only? 0|1
$conf['recent'] = 20; //how many entries to show in recent
$conf['breadcrumbs'] = 10; //how many recent visited pages to show
diff --git a/conf/license.php b/conf/license.php
new file mode 100644
index 000000000..9a753baa7
--- /dev/null
+++ b/conf/license.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * This file defines multiple available licenses you can license your
+ * wiki contents under. Do not change this file, but create a
+ * license.local.php instead.
+ */
+
+$license['cc-by'] = array(
+ 'name' => 'CC Attribution 3.0 Unported',
+ 'url' => 'http://creativecommons.org/licenses/by/3.0/',
+);
+$license['cc-by-nc'] = array(
+ 'name' => 'CC Attribution-Noncommercial 3.0 Unported',
+ 'url' => 'http://creativecommons.org/licenses/by-nc/3.0/',
+);
+$license['cc-by-nc-nd'] = array(
+ 'name' => 'CC Attribution-Noncommercial-No Derivative Works 3.0 Unported',
+ 'url' => 'http://creativecommons.org/licenses/by-nc-nd/3.0/',
+);
+$license['cc-by-nc-sa'] = array(
+ 'name' => 'CC Attribution-Noncommercial-Share Alike 3.0 Unported',
+ 'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/',
+);
+$license['cc-by-nd'] = array(
+ 'name' => 'CC Attribution-No Derivative Works 3.0 Unported',
+ 'url' => 'cc-by-nd',
+);
+$license['cc-by-sa'] = array(
+ 'name' => 'CC Attribution-Share Alike 3.0 Unported',
+ 'url' => 'http://creativecommons.org/licenses/by-sa/3.0/',
+);
+$license['publicdomain'] = array(
+ 'name' => 'Public Domain',
+ 'url' => 'http://creativecommons.org/licenses/publicdomain/',
+);
+$license['gnufdl'] = array(
+ 'name' => 'GNU Free Documentation License 1.2',
+ 'url' => 'http://www.gnu.org/licenses/fdl-1.2.html',
+);
+
diff --git a/inc/actions.php b/inc/actions.php
index af2399983..694f78208 100644
--- a/inc/actions.php
+++ b/inc/actions.php
@@ -24,6 +24,7 @@ function act_dispatch(){
global $QUERY;
global $lang;
global $conf;
+ global $license;
$preact = $ACT;
diff --git a/inc/common.php b/inc/common.php
index 82a5b7086..a8a6dd5ff 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -1314,8 +1314,33 @@ function editorinfo($username){
return hsc($username);
}
} else {
- return hsc($username);
+ return hsc($username);
+ }
+}
+
+/**
+ * Returns the path to a image file for the currently chosen license.
+ * When no image exists, returns an empty string
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @param string $type - type of image 'badge' or 'button'
+ */
+function license_img($type){
+ global $license;
+ global $conf;
+ if(!$conf['license']) return '';
+ if(!is_array($license[$conf['license']])) return '';
+ $lic = $license[$conf['license']];
+ $try = array();
+ $try[] = 'lib/images/license/'.$type.'/'.$conf['license'].'.png';
+ $try[] = 'lib/images/license/'.$type.'/'.$conf['license'].'.gif';
+ if(substr($conf['license'],0,3) == 'cc-'){
+ $try[] = 'lib/images/license/'.$type.'/cc.png';
+ }
+ foreach($try as $src){
+ if(@file_exists(DOKU_INC.$src)) return $src;
}
+ return '';
}
//Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/inc/html.php b/inc/html.php
index f97cd6f1e..ae09c7496 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -1011,6 +1011,7 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
global $SUM;
global $lang;
global $conf;
+ global $license;
//set summary default
if(!$SUM){
@@ -1111,6 +1112,15 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
$form->addElement(form_makeCloseTag('div'));
}
$form->addElement(form_makeCloseTag('div'));
+ if($conf['license']){
+ $form->addElement(form_makeOpenTag('div', array('class'=>'license')));
+ $out = $lang['licenseok'];
+ $out .= '<a href="'.$license[$conf['license']]['url'].'" rel="license" class="urlextern"';
+ if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"';
+ $out .= '> '.$license[$conf['license']]['name'].'</a>';
+ $form->addElement($out);
+ $form->addElement(form_makeCloseTag('div'));
+ }
html_form('edit', $form);
print '</div>'.NL;
}
diff --git a/inc/init.php b/inc/init.php
index 6c3f54e16..703fd4a38 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -60,6 +60,16 @@
require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php');
}
+ //prepare license array()
+ global $license;
+ $license = array();
+
+ // load the license file(s)
+ require_once(DOKU_CONF.'license.php');
+ if(@file_exists(DOKU_CONF.'license.php')){
+ require_once(DOKU_CONF.'license.php');
+ }
+
// define baseURL
if(!defined('DOKU_REL')) define('DOKU_REL',getBaseURL(false));
if(!defined('DOKU_URL')) define('DOKU_URL',getBaseURL(true));
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index aaa0ea92b..8ee81ed18 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -89,6 +89,9 @@ $lang['resendpwdbadauth'] = 'Sorry, this auth code is not valid. Make sure you u
$lang['resendpwdconfirm'] = 'A confirmation link has been sent by email.';
$lang['resendpwdsuccess'] = 'Your new password has been sent by email.';
+$lang['license'] = 'Except where otherwise noted, content on this wiki is licensed under the following license:';
+$lang['licenseok'] = 'Note: By editing this page you agree to license your content under the following license:';
+
$lang['txt_upload'] = 'Select file to upload';
$lang['txt_filename'] = 'Upload as (optional)';
$lang['txt_overwrt'] = 'Overwrite existing file';
diff --git a/inc/template.php b/inc/template.php
index 5db135a84..3f7badf93 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1290,5 +1290,39 @@ function tpl_actiondropdown($empty='',$button='&gt;'){
echo '</form>';
}
+/**
+ * Print a informational line about the used license
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @param string $img - print image? (|button|badge)
+ * @param bool $return - when true don't print, but return HTML
+ */
+function tpl_license($img='badge',$return=false){
+ global $license;
+ global $conf;
+ global $lang;
+ if(!$conf['license']) return '';
+ if(!is_array($license[$conf['license']])) return '';
+ $lic = $license[$conf['license']];
+
+ $out = '<p class="license">';
+ if($img){
+ $src = license_img($img);
+ if($src){
+ $out .= '<a href="'.$lic['url'].'" rel="license"';
+ if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"';
+ $out .= '><img src="'.DOKU_BASE.$src.'" class="lic'.$button.'" alt="'.$lic['name'].'" align="left" /></a>';
+ }
+ }
+ $out .= $lang['license'];
+ $out .= '<a href="'.$lic['url'].'" rel="license" class="urlextern"';
+ if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"';
+ $out .= '> '.$lic['name'].'</a>';
+ $out .= '</p>';
+
+ if($return) return $out;
+ echo $out;
+}
+
//Setup VIM: ex: et ts=4 enc=utf-8 :
diff --git a/lib/images/license/badge/cc-by-nc-nd.png b/lib/images/license/badge/cc-by-nc-nd.png
new file mode 100644
index 000000000..49f272f82
--- /dev/null
+++ b/lib/images/license/badge/cc-by-nc-nd.png
Binary files differ
diff --git a/lib/images/license/badge/cc-by-nc-sa.png b/lib/images/license/badge/cc-by-nc-sa.png
new file mode 100644
index 000000000..0f2a0f107
--- /dev/null
+++ b/lib/images/license/badge/cc-by-nc-sa.png
Binary files differ
diff --git a/lib/images/license/badge/cc-by-nc.png b/lib/images/license/badge/cc-by-nc.png
new file mode 100644
index 000000000..5f9821470
--- /dev/null
+++ b/lib/images/license/badge/cc-by-nc.png
Binary files differ
diff --git a/lib/images/license/badge/cc-by-nd.png b/lib/images/license/badge/cc-by-nd.png
new file mode 100644
index 000000000..8f317035e
--- /dev/null
+++ b/lib/images/license/badge/cc-by-nd.png
Binary files differ
diff --git a/lib/images/license/badge/cc-by-sa.png b/lib/images/license/badge/cc-by-sa.png
new file mode 100644
index 000000000..f0a944e0b
--- /dev/null
+++ b/lib/images/license/badge/cc-by-sa.png
Binary files differ
diff --git a/lib/images/license/badge/cc-by.png b/lib/images/license/badge/cc-by.png
new file mode 100644
index 000000000..822491edb
--- /dev/null
+++ b/lib/images/license/badge/cc-by.png
Binary files differ
diff --git a/lib/images/license/badge/cc.png b/lib/images/license/badge/cc.png
new file mode 100644
index 000000000..a66f4d1a0
--- /dev/null
+++ b/lib/images/license/badge/cc.png
Binary files differ
diff --git a/lib/images/license/badge/publicdomain.png b/lib/images/license/badge/publicdomain.png
new file mode 100644
index 000000000..cedc39c62
--- /dev/null
+++ b/lib/images/license/badge/publicdomain.png
Binary files differ
diff --git a/lib/images/license/button/cc-by-nc-nd.png b/lib/images/license/button/cc-by-nc-nd.png
new file mode 100644
index 000000000..072f8cda0
--- /dev/null
+++ b/lib/images/license/button/cc-by-nc-nd.png
Binary files differ
diff --git a/lib/images/license/button/cc-by-nc-sa.png b/lib/images/license/button/cc-by-nc-sa.png
new file mode 100644
index 000000000..ed028fed9
--- /dev/null
+++ b/lib/images/license/button/cc-by-nc-sa.png
Binary files differ
diff --git a/lib/images/license/button/cc-by-nc.png b/lib/images/license/button/cc-by-nc.png
new file mode 100644
index 000000000..54ebdfbd8
--- /dev/null
+++ b/lib/images/license/button/cc-by-nc.png
Binary files differ
diff --git a/lib/images/license/button/cc-by-nd.png b/lib/images/license/button/cc-by-nd.png
new file mode 100644
index 000000000..35eca20cc
--- /dev/null
+++ b/lib/images/license/button/cc-by-nd.png
Binary files differ
diff --git a/lib/images/license/button/cc-by-sa.png b/lib/images/license/button/cc-by-sa.png
new file mode 100644
index 000000000..c67509f12
--- /dev/null
+++ b/lib/images/license/button/cc-by-sa.png
Binary files differ
diff --git a/lib/images/license/button/cc-by.png b/lib/images/license/button/cc-by.png
new file mode 100644
index 000000000..ecd2abc73
--- /dev/null
+++ b/lib/images/license/button/cc-by.png
Binary files differ
diff --git a/lib/images/license/button/cc.png b/lib/images/license/button/cc.png
new file mode 100644
index 000000000..7c0ea70ce
--- /dev/null
+++ b/lib/images/license/button/cc.png
Binary files differ
diff --git a/lib/images/license/button/publicdomain.png b/lib/images/license/button/publicdomain.png
new file mode 100644
index 000000000..f6ba77b54
--- /dev/null
+++ b/lib/images/license/button/publicdomain.png
Binary files differ
diff --git a/lib/plugins/config/lang/en/lang.php b/lib/plugins/config/lang/en/lang.php
index 3de0bbd7d..6d942c290 100644
--- a/lib/plugins/config/lang/en/lang.php
+++ b/lib/plugins/config/lang/en/lang.php
@@ -57,6 +57,7 @@ $lang['savedir'] = 'Directory for saving data';
$lang['start'] = 'Start page name';
$lang['title'] = 'Wiki title';
$lang['template'] = 'Template';
+$lang['license'] = 'Under which license should your content be released?';
$lang['fullpath'] = 'Reveal full path of pages in the footer';
$lang['recent'] = 'Recent changes';
$lang['breadcrumbs'] = 'Number of breadcrumbs';
@@ -162,6 +163,8 @@ $lang['ftp____user'] = 'FTP user name for safemode hack';
$lang['ftp____pass'] = 'FTP password for safemode hack';
$lang['ftp____root'] = 'FTP root directory for safemode hack';
+$lang['license_o_'] = 'None chosen';
+
/* typography options */
$lang['typography_o_0'] = 'none';
$lang['typography_o_1'] = 'Double quotes only';
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index faa8c5e7e..011335913 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -631,6 +631,7 @@ if (!class_exists('setting_multichoice')) {
foreach ($this->_choices as $choice) {
$selected = ($value == $choice) ? ' selected="selected"' : '';
$option = $plugin->getLang($this->_key.'_o_'.$choice);
+ if (!$option && isset($this->lang[$this->_key.'_o_'.$choice])) $option = $this->lang[$this->_key.'_o_'.$choice];
if (!$option) $option = $choice;
$choice = htmlspecialchars($choice);
diff --git a/lib/plugins/config/settings/config.metadata.php b/lib/plugins/config/settings/config.metadata.php
index c087cd767..56a1c43ff 100644
--- a/lib/plugins/config/settings/config.metadata.php
+++ b/lib/plugins/config/settings/config.metadata.php
@@ -84,6 +84,7 @@ $meta['title'] = array('string');
$meta['start'] = array('string','_pattern' => '!^[^:;/]+$!'); // don't accept namespaces
$meta['lang'] = array('dirchoice','_dir' => DOKU_INC.'inc/lang/');
$meta['template'] = array('dirchoice','_dir' => DOKU_INC.'lib/tpl/','_pattern' => '/^[\w-]+$/');
+$meta['license'] = array('license');
$meta['savedir'] = array('savedir');
$meta['basedir'] = array('string');
$meta['baseurl'] = array('string');
diff --git a/lib/plugins/config/settings/extra.class.php b/lib/plugins/config/settings/extra.class.php
index 40c919a12..12e176f35 100644
--- a/lib/plugins/config/settings/extra.class.php
+++ b/lib/plugins/config/settings/extra.class.php
@@ -116,6 +116,25 @@ if (!class_exists('setting_compression')) {
}
}
+if (!class_exists('setting_license')) {
+ class setting_license extends setting_multichoice {
+
+ var $_choices = array(''); // none choosen
+
+ function initialize($default,$local,$protected) {
+ global $license;
+
+ foreach($license as $key => $data){
+ $this->_choices[] = $key;
+ $this->lang[$this->_key.'_o_'.$key] = $data['name'];
+ }
+
+ parent::initialize($default,$local,$protected);
+ }
+ }
+}
+
+
if (!class_exists('setting_renderer')) {
class setting_renderer extends setting_multichoice {
var $_prompts = array();
diff --git a/lib/tpl/default/design.css b/lib/tpl/default/design.css
index cadc78c2c..03751b879 100644
--- a/lib/tpl/default/design.css
+++ b/lib/tpl/default/design.css
@@ -171,8 +171,17 @@ div.dokuwiki div#draft__status {
color: __text_alt__;
}
-/* --------- buttons ------------------- */
+div.dokuwiki form#dw__editform div.license {
+ clear: left;
+ font-size: 90%;
+}
+
+div.dokuwiki p.license {
+ font-size: 90%;
+ text-align: center;
+}
+/* --------- buttons ------------------- */
div.dokuwiki input.button,
div.dokuwiki button.button {
diff --git a/lib/tpl/default/main.php b/lib/tpl/default/main.php
index 3982618df..5fd3dba65 100644
--- a/lib/tpl/default/main.php
+++ b/lib/tpl/default/main.php
@@ -128,6 +128,8 @@ if (!defined('DOKU_INC')) die();
</div>
+ <?php tpl_license(false);?>
+
</div>
<?php /*old includehook*/ @include(dirname(__FILE__).'/footer.html')?>