Make license selectable from config FS#312
darcs-hash:20081012113150-7ad00-6408da058bdb6c923159d445e03b76f54b579362.gz
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
);
|
||||
|
|
@ -24,6 +24,7 @@ function act_dispatch(){
|
|||
global $QUERY;
|
||||
global $lang;
|
||||
global $conf;
|
||||
global $license;
|
||||
|
||||
$preact = $ACT;
|
||||
|
||||
|
|
|
@ -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 :
|
||||
|
|
10
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;
|
||||
}
|
||||
|
|
10
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));
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -1290,5 +1290,39 @@ function tpl_actiondropdown($empty='',$button='>'){
|
|||
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 :
|
||||
|
||||
|
|
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 958 B |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 688 B |
After Width: | Height: | Size: 697 B |
After Width: | Height: | Size: 672 B |
After Width: | Height: | Size: 665 B |
After Width: | Height: | Size: 672 B |
After Width: | Height: | Size: 640 B |
After Width: | Height: | Size: 802 B |
After Width: | Height: | Size: 629 B |
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -128,6 +128,8 @@ if (!defined('DOKU_INC')) die();
|
|||
|
||||
</div>
|
||||
|
||||
<?php tpl_license(false);?>
|
||||
|
||||
</div>
|
||||
<?php /*old includehook*/ @include(dirname(__FILE__).'/footer.html')?>
|
||||
|
||||
|
|