diff options
author | Andreas Gohr <andi@splitbrain.org> | 2008-10-12 13:31:50 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2008-10-12 13:31:50 +0200 |
commit | 066fee3089513b988d1beac2040e32a365921310 (patch) | |
tree | e20413f725f57ec6071c66b745fc25bea2e08b55 /inc | |
parent | 7aedde2e62651d550e6213d3852447b26255e8de (diff) | |
download | rpg-066fee3089513b988d1beac2040e32a365921310.tar.gz rpg-066fee3089513b988d1beac2040e32a365921310.tar.bz2 |
Make license selectable from config FS#312
darcs-hash:20081012113150-7ad00-6408da058bdb6c923159d445e03b76f54b579362.gz
Diffstat (limited to 'inc')
-rw-r--r-- | inc/actions.php | 1 | ||||
-rw-r--r-- | inc/common.php | 27 | ||||
-rw-r--r-- | inc/html.php | 10 | ||||
-rw-r--r-- | inc/init.php | 10 | ||||
-rw-r--r-- | inc/lang/en/lang.php | 3 | ||||
-rw-r--r-- | inc/template.php | 34 |
6 files changed, 84 insertions, 1 deletions
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='>'){ 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 : |