From 0636144287f7acf89c633d3d2f5214e1d229e033 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Sat, 26 Jun 2010 15:59:59 +0200
Subject: [PATCH] Added license chooser to installer FS#1926

This adds a license chooser to the installer. The installer defaults to
the more free CC-BY-SA. CC-NC-BY-SA is still the default in dokuwiki.php
to keep backwards compatibility.

The license array was reordered and Non-Derivative licenses removed
(they don't make much sense for wiki content).
---
 conf/license.php     | 40 ++++++++++++++++------------------------
 inc/lang/en/lang.php |  1 +
 install.php          | 24 +++++++++++++++++++++++-
 3 files changed, 40 insertions(+), 25 deletions(-)

diff --git a/conf/license.php b/conf/license.php
index b97cb3cfd..89728ab57 100644
--- a/conf/license.php
+++ b/conf/license.php
@@ -5,30 +5,6 @@
  * 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'  => 'http://creativecommons.org/licenses/by-nd/3.0/',
-);
-$license['cc-by-sa'] = array(
-    'name' => 'CC Attribution-Share Alike 3.0 Unported',
-    'url'  => 'http://creativecommons.org/licenses/by-sa/3.0/',
-);
 $license['cc-zero'] = array(
     'name' => 'CC0 1.0 Universal',
     'url'  => 'http://creativecommons.org/publicdomain/zero/1.0/',
@@ -37,8 +13,24 @@ $license['publicdomain'] = array(
     'name' => 'Public Domain',
     'url'  => 'http://creativecommons.org/licenses/publicdomain/',
 );
+$license['cc-by'] = array(
+    'name' => 'CC Attribution 3.0 Unported',
+    'url'  => 'http://creativecommons.org/licenses/by/3.0/',
+);
+$license['cc-by-sa'] = array(
+    'name' => 'CC Attribution-Share Alike 3.0 Unported',
+    'url'  => 'http://creativecommons.org/licenses/by-sa/3.0/',
+);
 $license['gnufdl'] = array(
     'name' => 'GNU Free Documentation License 1.3',
     'url'  => 'http://www.gnu.org/licenses/fdl-1.3.html',
 );
+$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-sa'] = array(
+    'name' => 'CC Attribution-Noncommercial-Share Alike 3.0 Unported',
+    'url'  => 'http://creativecommons.org/licenses/by-nc-sa/3.0/',
+);
 
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index 4a96e373e..0dd6fd548 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -282,6 +282,7 @@ $lang['i_pol1']       = 'Public Wiki (read for everyone, write and upload for re
 $lang['i_pol2']       = 'Closed Wiki (read, write, upload for registered users only)';
 
 $lang['i_retry']      = 'Retry';
+$lang['i_license']    = 'Please choose the license you want to put your content under:';
 
 $lang['mu_intro']     = 'Here you can upload multiple files at once. Click the browse button to add them to the queue. Press upload when done.';
 $lang['js']['mu_btn'] = 'Upload multiple files at once';
diff --git a/install.php b/install.php
index a9edbd445..1ec822fd9 100644
--- a/install.php
+++ b/install.php
@@ -45,7 +45,8 @@ $dokuwiki_hash = array(
     '2007-06-26'   => 'b3ca19c7a654823144119980be73cd77',
     '2008-05-04'   => '1e5c42eac3219d9e21927c39e3240aad',
     '2009-02-14'   => 'ec8c04210732a14fdfce0f7f6eead865',
-    '2009-12-25' => '993c4b2b385643efe5abf8e7010e11f4',
+    '2009-12-25'   => '993c4b2b385643efe5abf8e7010e11f4',
+    'devel'        => 'f065247541c4041e5f103b41b393fcb3'
 );
 
 
@@ -68,6 +69,7 @@ header('Content-Type: text/html; charset=utf-8');
         fieldset { border: none }
         label { display: block; margin-top: 0.5em; }
         select.text, input.text { width: 30em; margin: 0 0.5em; }
+        a {text-decoration: none}
     </style>
     <script type="text/javascript" language="javascript">
         function acltoggle(){
@@ -150,6 +152,8 @@ function print_form($d){
     global $lang;
     global $LC;
 
+    include(DOKU_CONF.'license.php');
+
     if(!is_array($d)) $d = array();
     $d = array_map('htmlspecialchars',$d);
 
@@ -190,9 +194,26 @@ function print_form($d){
                     <option value="1" <?php echo ($d['policy'] == 1)?'selected="selected"':'' ?>><?php echo $lang['i_pol1']?></option>
                     <option value="2" <?php echo ($d['policy'] == 2)?'selected="selected"':'' ?>><?php echo $lang['i_pol2']?></option>
                 </select>
+
             </fieldset>
         </fieldset>
 
+        <fieldset>
+            <p><?php echo $lang['i_license']?></p>
+            <?php
+            array_unshift($license,array('name' => 'None', 'url'=>''));
+            if(!isset($d['license'])) $d['license'] = 'cc-by-sa';
+            foreach($license as $key => $lic){
+                echo '<label for="lic_'.$key.'">';
+                echo '<input type="radio" name="d[license]" value="'.htmlspecialchars($key).'" id="lic_'.$key.'"'.
+                     (($d['license'] == $key)?'checked="checked"':'').'>';
+                echo htmlspecialchars($lic['name']);
+                if($lic['url']) echo ' <a href="'.$lic['url'].'" target="_blank"><sup>[?]</sup></a>';
+                echo '</label>';
+            }
+            ?>
+        </fieldset>
+
     </fieldset>
     <fieldset id="process">
         <input class="button" type="submit" name="submit" value="<?php echo $lang['btn_save']?>" />
@@ -281,6 +302,7 @@ function store_data($d){
 EOT;
     $output .= '$conf[\'title\'] = \''.addslashes($d['title'])."';\n";
     $output .= '$conf[\'lang\'] = \''.addslashes($LC)."';\n";
+    $output .= '$conf[\'license\'] = \''.addslashes($d['license'])."';\n";
     if($d['acl']){
         $output .= '$conf[\'useacl\'] = 1'.";\n";
         $output .= "\$conf['superuser'] = '@admin';\n";
-- 
GitLab