Whitespace cleanup and inline docs. Props nacin. see #12027

git-svn-id: https://develop.svn.wordpress.org/trunk@12865 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-01-27 13:48:37 +00:00
parent 27ae64ead2
commit 7da5c09cdc
1 changed files with 107 additions and 71 deletions

View File

@ -2,7 +2,9 @@
/**
* Network settings administration panel.
*
* @since 3.0
* A multi-step process allowing the user to enable a network of WordPress sites.
*
* @since 3.0.0
*
* @package WordPress
* @subpackage Administration
@ -20,12 +22,8 @@ $parent_file = 'tools.php';
add_contextual_help( $current_screen, __( '<a href="http://codex.wordpress.org/Settings_Network_SubPanel" target="_blank">Network Settings</a>') );
include( './admin-header.php' );
/*
This option panel does not save data to the options table.
It contains a multi-step process allowing the user to enable a network of WordPress sites.
*/
$dirs = array( substr( ABSPATH, 0, -1), ABSPATH . "wp-content" );
$dirs = array( substr( ABSPATH, 0, -1 ), ABSPATH . 'wp-content' );
?>
<div class="wrap">
<?php screen_icon(); ?>
@ -33,15 +31,20 @@ $dirs = array( substr( ABSPATH, 0, -1), ABSPATH . "wp-content" );
<form method="post" action="network.php">
<?php
/**
* Prints summary of server statistics in preparation for setting up a network.
*
* @since 3.0.0
*/
function filestats( $err ) {
?>
<h2><?php esc_html_e( 'Server Summary' ); ?></h2>
<p><?php _e( 'If you post a message to the WordPress support forum at <a target="_blank" href="http://wordpress.org/support/">http://wordpress.org/support/</a> then copy and paste the following information into your message:' ); ?></p>
<blockquote style="background: #eee; border: 1px solid #333; padding: 5px;">
<br /><strong><?php echo __('ERROR:') . " $err"; ?></strong><br />
<br /><strong><?php printf( __( 'ERROR: %s' ), $err ); ?></strong><br />
<?php
clearstatcache();
$files = array( "htaccess.dist", ".htaccess" );
$files = array( 'htaccess.dist', '.htaccess' );
$indent = '&nbsp;&nbsp;&nbsp;&nbsp;';
foreach ( (array) $files as $val ) {
@ -65,14 +68,19 @@ function filestats( $err ) {
echo "</blockquote>";
}
/**
* Prints .htaccess component of step 2 for network settings.
*
* @since 3.0.0
*/
function step2_htaccess() {
global $base;
// remove ending slash from $base and $url
$htaccess = '';
if( substr($base, -1 ) == '/') {
if ( substr( $base, -1 ) == '/' )
$base = substr( $base, 0, -1 );
}
$htaccess_sample = ABSPATH . 'wp-admin/includes/htaccess.ms';
if ( ! file_exists( $htaccess_sample ) )
wp_die( sprintf( __( 'Sorry, I need a %s to work from. Please re-upload this file to your WordPress installation.' ), $htaccess_sample ) );
@ -93,12 +101,18 @@ function step2_htaccess() {
?>
<li><p><?php _e( 'Replace the contents of your <code>.htaccess</code> with the following:' ); ?></p>
<textarea name="htaccess" cols="120" rows="20">
<?php echo $htaccess_file; ?>
<?php echo wp_htmledit_pre( $htaccess_file ); ?>
</textarea>
</li>
<?php
}
/**
* Prints part of step 1 for network settings and checks for mod_rewrite.
*
* @since 3.0.0
* @return bool Whether mod_rewrite is enabled.
*/
function step1() {
$rewrite_enabled = false;
?>
@ -112,7 +126,7 @@ function step1() {
<li><?php _e( "Wildcard dns records if you're going to use the virtual host (sub-domain) functionality. Check the <a href='http://trac.mu.wordpress.org/browser/trunk/README.txt'>README</a> for further details." ); ?></li>
</ul>
<?php
$mod_rewrite_msg = "\n<p>" . __( "If the <code>mod_rewrite</code> module is disabled ask your administrator to enable that module, or look at the <a href='http://httpd.apache.org/docs/mod/mod_rewrite.html'>Apache documentation</a> or <a href='http://www.google.com/search?q=apache+mod_rewrite'>elsewhere</a> for help setting it up." ) . '</p>';
$mod_rewrite_msg = "\n<p>" . __( 'If the <code>mod_rewrite</code> module is disabled ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p>';
if ( function_exists( 'apache_get_modules' ) ) {
$modules = apache_get_modules();
@ -126,6 +140,12 @@ function step1() {
return $rewrite_enabled;
}
/**
* Prints most of step 1 for network settings.
*
* @since 3.0.0
* @param bool $rewrite_enabled Whether mod_rewrite is enabled. Default false.
*/
function printstep1form( $rewrite_enabled = false ) {
$weblog_title = sprintf( __( '%s Sites' ), ucfirst( get_option( 'blogname' ) ) );
$email = get_option( 'admin_email' );
@ -182,6 +202,11 @@ function printstep1form( $rewrite_enabled = false ) {
<?php
}
/**
* Prints step 2 for network settings.
*
* @since 3.0.0
*/
function step2() {
?>
<h2><?php esc_html_e( 'Enabling WordPress Sites' ); ?></h2>
@ -194,6 +219,11 @@ function step2() {
<?php
}
/**
* Prints configuration file component of step 2 for network settings.
*
* @since 3.0.0
*/
function step2_config() {
global $base, $wpdb, $vhost;
@ -263,6 +293,11 @@ function step2_config() {
<?php
}
/**
* Gets base domain of network.
*
* @since 3.0.0
*/
function get_clean_basedomain() {
global $wpdb;
$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
@ -272,14 +307,15 @@ function get_clean_basedomain() {
}
$action = isset( $_POST[ 'action' ] ) ? $_POST[ 'action' ] : null;
switch( $action ) {
case "step2":
case 'step2':
check_admin_referer( 'install-network-1' );
// Install!
$base = stripslashes( dirname( dirname($_SERVER["SCRIPT_NAME"]) ) );
if( $base != "/")
$base .= "/";
$base = stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) );
if ( $base != '/' )
$base .= '/';
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
// create network tables
@ -292,7 +328,7 @@ switch($action) {
default:
//@todo: give an informative screen instead
if ( is_multisite() ) {
_e('Network already enabled');
_e( 'Network already enabled.' );
} else {
$rewrite_enabled = step1();
printstep1form( $rewrite_enabled );