Add categorylinks table to separately list category relationships. Actual
[lhc/web/wiklou.git] / config / index.php
index 9eab263..2c189a4 100644 (file)
@@ -42,7 +42,7 @@ header( "Content-type: text/html; charset=utf-8" );
        dl.setup dd {
                margin-left: 0;
        }
-       dl.setup dd label {
+       dl.setup dd label.column {
                clear: left;
                font-weight: bold;
                width: 12em;
@@ -60,6 +60,11 @@ header( "Content-type: text/html; charset=utf-8" );
        .error {
                color: red;
        }
+       ul.plain {
+               list-style: none;
+               clear: both;
+               margin-left: 12em;
+       }
        </style>
 </head>
 
@@ -68,7 +73,7 @@ header( "Content-type: text/html; charset=utf-8" );
 <div id="credit">
  <center>
   <a href="http://www.mediawiki.org/"><img
-    src="../images/wiki.png" width="135" height="135" alt="" border="0" /></a>
+    src="../stylesheets/images/wiki.png" width="135" height="135" alt="" border="0" /></a>
  </center>
  
  <b><a href="http://www.mediawiki.org/">MediaWiki</a></b> is
@@ -99,8 +104,11 @@ header( "Content-type: text/html; charset=utf-8" );
 </div>
 
 <?php
+
 $IP = ".."; # Just to suppress notices, not for anything useful
-include( "../includes/DefaultSettings.php" );
+define( "MEDIAWIKI", true );
+define( "MEDIAWIKI_INSTALL", true );
+require( "../includes/DefaultSettings.php" );
 ?>
 
 <h1>MediaWiki <?php print $wgVersion ?> installation</h1>
@@ -143,8 +151,8 @@ if( !is_writable( "." ) ) {
 }
 
 
-include( "../install-utils.inc" );
-include( "../maintenance/updaters.inc" );
+require( "../install-utils.inc" );
+require( "../maintenance/updaters.inc" );
 class ConfigData {
        function getEncoded( $data ) {
                # Hackish
@@ -162,6 +170,7 @@ class ConfigData {
 
 ?>
 
+<p><i>Please include all of the lines below when reporting installation problems.</i></p>
 
 <h2>Checking environment...</h2>
 <ul>
@@ -178,10 +187,12 @@ $conf->prettyURLs = true;
 print "<li>PHP server API is $sapi; ";
 switch( $sapi ) {
 case "apache":
+case "apache2handler":
        print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
        break;
 case "cgi":
 case "cgi-fcgi":
+case "apache2filter":
        print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
        $conf->prettyURLs = false;
        break;
@@ -222,6 +233,7 @@ $conf->UseImageResize = $conf->HaveGD || $conf->ImageMagick;
 # $conf->IP = "/Users/brion/Sites/inplace";
 chdir( ".." );
 $conf->IP = getcwd();
+$conf->IP = preg_replace( "/\\\\/","\\\\\\\\",$conf->IP );  // For Windows, \ -> \\ 
 chdir( "config" );
 print "<li>Installation directory: <tt>" . htmlspecialchars( $conf->IP ) . "</tt></li>\n";
 
@@ -264,6 +276,21 @@ if( $conf->SysopPass != $conf->SysopPass2 ) {
        $errs["SysopPass2"] = "Passwords don't match!";
 }
 
+$conf->License = importPost( "License", "none" );
+if( $conf->License == "gfdl" ) {
+       $conf->RightsUrl = "http://www.gnu.org/copyleft/fdl.html";
+       $conf->RightsText = "GNU Free Documentation License 1.2";
+       $conf->RightsCode = "gfdl";
+       $conf->RightsIcon = "{$conf->ScriptPath}/stylesheets/images/gnu-fdl.png";
+} elseif( $conf->License == "none" ) {
+       $conf->RightsUrl = $conf->RightsText = $conf->RightsCode = $conf->RightsIcon = "";
+} else {
+       $conf->RightsUrl = importPost( "RightsUrl", "" );
+       $conf->RightsText = importPost( "RightsText", "" );
+       $conf->RightsCode = importPost( "RightsCode", "" );
+       $conf->RightsIcon = importPost( "RightsIcon", "" );
+}
+
 if( $conf->posted && ( 0 == count( $errs ) ) ) {
        do { /* So we can 'continue' to end prematurely */
                $conf->Root = ($conf->RootPW != "");
@@ -271,21 +298,26 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                /* Load up the settings and get installin' */
                $local = writeLocalSettings( $conf );
                $wgCommandLineMode = false;
+               chdir( ".." );
                eval($local);
-
                $wgDBadminuser = $wgDBuser;
                $wgDBadminpassword = $wgDBpassword;
                $wgCommandLineMode = true;
                $wgUseDatabaseMessages = false; /* FIXME: For database failure */
-               include_once( "Setup.php" );
-               include_once( "../maintenance/InitialiseMessages.inc" );
+               require_once( "includes/Setup.php" );
+               chdir( "config" );
+
+               require_once( "../maintenance/InitialiseMessages.inc" );
 
                $wgTitle = Title::newFromText( "Installation script" );
                $wgDatabase = Database::newFromParams( $wgDBserver, "root", $conf->RootPW, "", 1 );
                $wgDatabase->mIgnoreErrors = true;
                
                @$myver = mysql_get_server_info( $wgDatabase->mConn );
-               if( !$myver ) {
+               if( $myver ) {
+                       $conf->Root = true;
+                       print "<li>Connected as root (automatic)</li>\n";
+               } else {
                        print "<li>MySQL error " . ($err = mysql_errno() ) .
                                ": " . htmlspecialchars( mysql_error() );
                        $ok = false;
@@ -307,7 +339,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                                                $errs["RootPW"] = "Got root?";
                                                print " need password.</li>\n";
                                        } else {
-                                               $conf->Root = true;
+                                               $conf->Root = false;
                                                $conf->RootPW = "";
                                                print " ok.</li>\n";
                                                # And keep going...
@@ -367,6 +399,11 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        do_linkscc_update(); flush();
                        do_hitcounter_update(); flush();
                        do_recentchanges_update(); flush();
+                       echo "FIXME: need the link table change here\n";
+                       do_user_real_name_update(); flush();
+                       do_querycache_update(); flush();
+                       do_objectcache_update(); flush();
+                       do_categorylinks_update(); flush();
                        initialiseMessages(); flush();
                        chdir( "config" );
                        
@@ -424,7 +461,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        $title = $titleobj->getDBkey();
                        $sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_timestamp,inverse_timestamp,cur_touched) " .
                          "VALUES (0,'$title','" .
-                         wfStrencode( wfMsg( "mainpagetext" ) ) . "','$now','$won','$now')";
+                         wfStrencode( wfMsg( "mainpagetext" ) . "\n\n" . wfMsg( "mainpagedocfooter" ) ) . "','$now','$won','$now')";
                        $wgDatabase->query( $sql, $fname );
                        
                        print "<li><pre>";
@@ -432,7 +469,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                        print "</pre></li>\n";
                        
                        if( $conf->Root ) {
-                               # Grant user permissions
+                               print "<li>Granting user permissions...</li>\n";
                                dbsource( "../maintenance/users.sql", $wgDatabase );
                        }
                }
@@ -449,7 +486,7 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                $f = fopen( "LocalSettings.php", $xt );
                
                if( $f == false ) {
-                       dieout( "Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" .
+                       dieout( "<p>Couldn't write out LocalSettings.php. Check that the directory permissions are correct and that there isn't already a file of that name here...</p>\n" .
                        "<p>Here's the file that would have been written, try to paste it into place manually:</p>\n" .
                        "<pre>\n" . htmlspecialchars( $localSettings ) . "</pre>\n" );
                }
@@ -506,7 +543,7 @@ if( count( $errs ) ) {
        </dt>
 
        <dd>
-               <label for="LanguageCode">Language</label>
+               <label class='column' for="LanguageCode">Language</label>
                <select id="LanguageCode" name="LanguageCode">
                <?php
                        $list = getLanguageList();
@@ -525,6 +562,35 @@ if( count( $errs ) ) {
                be used where not specified otherwise.
        </dt>
        
+       <dd>
+               <label class='column'>Copyright/license metadata</label>
+               <div>Select one:</div>
+
+               <ul class="plain">
+               <li><?php aField( $conf, "License", "no license metadata", "radio", "none" ); ?></li>
+               <li><?php aField( $conf, "License", "GNU Free Documentation License 1.2 (Wikipedia-compatible)", "radio", "gfdl" ); ?></li>
+               <li><?php
+                       aField( $conf, "License", "a Creative Commons license...", "radio", "cc" ); 
+                       $partner = "MediaWiki";
+                       $exit = urlencode( "$wgServer{$conf->ScriptPath}/config/index.php?License=cc&RightsUrl=[license_url]&RightsText=[license_name]&RightsCode=[license_code]&RightsIcon=[license_button]" );
+                       $icon = urlencode( "$wgServer$wgUploadPath/wiki.png" );
+                       $ccApp = htmlspecialchars( "http://creativecommons.org/license/?partner=$partner&exit_url=$exit&partner_icon_url=$icon" );
+                       print "<a href=\"$ccApp\">choose</a>";
+                       ?></li>
+               <li><?php aField( $conf, "RightsUrl", $conf->RightsUrl, "hidden" ); ?></li>
+               <li><?php aField( $conf, "RightsText", $conf->RightsText, "hidden" ); ?></li>
+               <li><?php aField( $conf, "RightsCode", $conf->RightsCode, "hidden" ); ?></li>
+               <li><?php aField( $conf, "RightsIcon", $conf->RightsIcon, "hidden" ); ?></li>
+               </ul>
+       </dd>
+       <dt>
+               MediaWiki can include a basic license notice, icon, and machine-reable
+               copyright metadata if your wiki's content is to be licensed under
+               the GNU FDL or a Creative Commons license. If you're not sure, leave
+               it at "none".
+       </dt>
+       
+       
        <dd>
                <?php aField( $conf, "SysopName", "Sysop account name:", "" ) ?>
        </dd>
@@ -586,7 +652,7 @@ if( count( $errs ) ) {
        </dt>
 
        <dd>
-               <label>&nbsp;</label>
+               <label class='column'>&nbsp;</label>
                <input type="submit" value="Install!" />
        </dd>
 </dl>
@@ -619,6 +685,9 @@ function writeLocalSettings( $conf ) {
        $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
        $pretty = ($conf->prettyURLs ? "" : "# ");
        $ugly = ($conf->prettyURLs ? "# " : "");
+       $rights = ($conf->RightsUrl) ? "" : "# ";
+
+#      $proxyKey = Parser::getRandomString() . Parser::getRandomString();
        
        $sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
        return "
@@ -627,11 +696,12 @@ function writeLocalSettings( $conf ) {
 # recreate them later.
 
 \$IP = \"{$conf->IP}\";
-ini_set( \"include_path\", \"\$IP/includes$sep\$IP/languages$sep\" . ini_get(\"include_path\") );
-include_once( \"DefaultSettings.php\" );
+require_once( \"includes/DefaultSettings.php\" );
 
-if( \$wgCommandLineMode ) {
-       die( \"Can't use command-line utils with in-place install yet, sorry.\" );
+if ( \$wgCommandLineMode ) {
+       if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
+               die( \"This script must be run from the command line\\n\" );
+       }
 } else {
        ## Compress output if the browser supports it
        {$zlib}if( !ini_get( 'zlib.output_compression' ) ) ob_start( 'ob_gzhandler' );
@@ -647,15 +717,15 @@ if( \$wgCommandLineMode ) {
 {$pretty}\$wgArticlePath      = \"\$wgScript/\$1\";
 {$ugly}\$wgArticlePath      = \"\$wgScript?title=\$1\";
 
-\$wgStyleSheetPath   = \"\$wgScriptPath/stylesheets\";
-\$wgStyleSheetDirectory = \"\$IP/stylesheets\";
+\$wgStylePath        = \"\$wgScriptPath/stylesheets\";
+\$wgStyleDirectory   = \"\$IP/stylesheets\";
+\$wgLogo             = \"\$wgStylePath/images/wiki.png\";
 
 \$wgUploadPath       = \"\$wgScriptPath/images\";
-\$wgUploadDirectory    = \"\$IP/images\";
-\$wgLogo                               = \"\$wgUploadPath/wiki.png\";
+\$wgUploadDirectory  = \"\$IP/images\";
 
 \$wgEmergencyContact = \"{$conf->EmergencyContact}\";
-\$wgPasswordSender     = \"{$conf->PasswordSender}\";
+\$wgPasswordSender   = \"{$conf->PasswordSender}\";
 
 \$wgDBserver         = \"{$conf->DBserver}\";
 \$wgDBname           = \"{$conf->DBname}\";
@@ -688,21 +758,27 @@ if( \$wgCommandLineMode ) {
 \$wgMathDirectory    = \"{\$wgUploadDirectory}/math\";
 \$wgTmpDirectory     = \"{\$wgUploadDirectory}/tmp\";
 
-## Experimental layout template subsystems
-\$wgUsePHPTal = false;
-\$wgUseSmarty = false;
-if ( \$wgUsePHPTal ) {
-      ini_set( \"include_path\", \"\$IP/PHPTAL-NP-0.7.0/libs$sep\" . ini_get(\"include_path\") );
-}
-if ( \$wgUseSmarty ) {
-      ini_set( \"include_path\", \"\$IP/Smarty-2.6.2/libs$sep\" . ini_get(\"include_path\") );
-}
-
 \$wgLocalInterwiki   = \$wgSitename;
 
 \$wgLanguageCode = \"{$conf->LanguageCode}\";
 " . ($conf->Encoding ? "\$wgInputEncoding = \$wgOutputEncoding = \"{$conf->Encoding}\";" : "" ) . "
 
+## Default skin: you can change the default skin. Use the internal symbolic
+## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook':
+# \$wgDefaultSkin = 'monobook';
+
+## This is incomplete, ignore it:
+#\$wgProxyKey = $proxyKey;
+
+## For attaching licensing metadata to pages, and displaying an
+## appropriate copyright notice / icon. GNU Free Documentation
+## License and Creative Commons licenses are supported so far.
+{$rights}\$wgEnableCreativeCommonsRdf = true;
+\$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright
+\$wgRightsUrl = \"{$conf->RightsUrl}\";
+\$wgRightsText = \"{$conf->RightsText}\";
+\$wgRightsIcon = \"{$conf->RightsIcon}\";
+# \$wgRightsCode = \"{$conf->RightsCode}\"; # Not yet used
 ";
 }
 
@@ -711,19 +787,43 @@ function dieout( $text ) {
 }
 
 function importPost( $name, $default = "" ) {
-       if( isset( $_POST[$name] ) ) {
-               return $_POST[$name];
+       if( isset( $_REQUEST[$name] ) ) {
+               return $_REQUEST[$name];
        } else {
                return $default;
        }
 }
 
-function aField( &$conf, $field, $text, $type = "" ) {
-       if( $type != "" ) $type = "type=\"$type\"";
-       echo "\t\t<label for=\"$field\">$text</label>\n";
-       echo "\t\t<input $type name=\"$field\" id=\"$field\" value=\"";
-       echo htmlspecialchars( $conf->$field );
+function aField( &$conf, $field, $text, $type = "", $value = "" ) {
+       if( $type != "" ) {
+               $xtype = "type=\"$type\"";
+       } else {
+               $xtype = "";
+       }
+       
+       if(!(isset($id)) or ($id == "") ) $id = $field;
+       $nolabel = ($type == "radio") || ($type == "hidden");
+       if( $nolabel ) {
+               echo "\t\t<label>";
+       } else {
+               echo "\t\t<label class='column' for=\"$id\">$text</label>\n";
+       }
+       
+       if( $type == "radio" && $value == $conf->$field ) {
+               $checked = "checked='checked'";
+       } else {
+               $checked = "";
+       }
+       echo "\t\t<input $xtype name=\"$field\" id=\"$id\" $checked value=\"";
+       if( $type == "radio" ) {
+               echo htmlspecialchars( $value );
+       } else {
+               echo htmlspecialchars( $conf->$field );
+       }
        echo "\" />\n";
+       if( $nolabel ) {
+               echo " $text</label>\n";
+       }
        
        global $errs;
        if(isset($errs[$field])) echo "<span class='error'>" . $errs[$field] . "</span>\n";
@@ -735,7 +835,7 @@ function getLanguageList() {
                $wgLanguageCode = "xxx";
                function wfLocalUrl( $x ) { return $x; }
                function wfLocalUrlE( $x ) { return $x; }
-               include( "../languages/Language.php" );
+               require( "../languages/Language.php" );
        }
        
        $codes = array();