# HG changeset patch
# User Dan
# Date 1239848294 14400
# Node ID 142a29b583f9b80be3f3528dc5dbf154d6d89791
# Parent 9ef3ccac13de7f54f85b0bfe45bc79ec5dc83300
Installer default content is now modular, and can pivot between starting with a blank site and installing a tutorial site.
diff -r 9ef3ccac13de -r 142a29b583f9 install/includes/cli-core.php
--- a/install/includes/cli-core.php Wed Apr 15 20:24:51 2009 -0400
+++ b/install/includes/cli-core.php Wed Apr 15 22:18:14 2009 -0400
@@ -601,19 +601,6 @@
installer_fail($lang->get('cli_err_schema_load'));
}
-$wkt = ENANO_ROOT . "/language/{$languages[$lang_id]['dir']}/install/mainpage-default.wkt";
-if ( !file_exists( $wkt ) )
-{
- if ( !$silent )
- echo "\n";
- installer_fail($lang->get('cli_err_mainpage_load'));
-}
-$wkt = @file_get_contents($wkt);
-if ( empty($wkt) )
- return false;
-
-$wkt = $db->escape($wkt);
-
$vars = array(
'TABLE_PREFIX' => table_prefix,
'SITE_NAME' => $db->escape($sitename),
@@ -629,7 +616,6 @@
'REAL_NAME' => '', // This has always been stubbed.
'ADMIN_EMBED_PHP' => strval(AUTH_DISALLOW),
'UNIX_TIME' => strval(time()),
- 'MAIN_PAGE_CONTENT' => $wkt,
'IP_ADDRESS' => $_SERVER['REMOTE_ADDR']
);
@@ -700,7 +686,11 @@
if ( !$silent )
echo parse_shellcolor_string($lang->get('cli_msg_ok')) . "\n";
+$_POST['username'] =& $user;
+$_POST['default_content_type'] = ( isset($start_with) ) ? $start_with : 'blank';
+
run_installer_stage('importlang', 'importing_language', 'stg_language_setup', $lang->get('install_stg_importlang_body'));
+run_installer_stage('importcontent', 'importing_content', 'stg_add_content', $lang->get('install_stg_importcontent_body'));
run_installer_stage('initlogs', 'initting_logs', 'stg_init_logs', $lang->get('install_stg_initlogs_body'));
run_installer_stage('cleanup', 'cleaning_up', 'stg_aes_cleanup', $lang->get('install_stg_cleanup_body'), false);
run_installer_stage('buildindex', 'initting_index', 'stg_build_index', $lang->get('install_stg_buildindex_body'));
diff -r 9ef3ccac13de -r 142a29b583f9 install/includes/payload.php
--- a/install/includes/payload.php Wed Apr 15 20:24:51 2009 -0400
+++ b/install/includes/payload.php Wed Apr 15 22:18:14 2009 -0400
@@ -115,18 +115,6 @@
return false;
}
- $wkt = ENANO_ROOT . "/language/{$languages[$lang_id]['dir']}/install/mainpage-default.wkt";
- if ( !file_exists( $wkt ) )
- {
- echo '
Error: could not locate wikitext for main page (' . $wkt . ')
';
- return false;
- }
- $wkt = @file_get_contents($wkt);
- if ( empty($wkt) )
- return false;
-
- $wkt = $db->escape($wkt);
-
$vars = array(
'TABLE_PREFIX' => table_prefix,
'SITE_NAME' => $db->escape($_POST['site_name']),
@@ -143,7 +131,6 @@
'REAL_NAME' => '', // This has always been stubbed.
'ADMIN_EMBED_PHP' => strval(AUTH_DISALLOW),
'UNIX_TIME' => strval(time()),
- 'MAIN_PAGE_CONTENT' => $wkt,
'IP_ADDRESS' => $db->escape($_SERVER['REMOTE_ADDR'])
);
@@ -346,6 +333,93 @@
return true;
}
+function stg_add_content()
+{
+ global $db, $session, $paths, $template, $plugins; // Common objects
+ global $cache;
+
+ global $languages;
+ global $lang_id;
+ $lang_info =& $languages[$lang_id];
+ if ( !is_array($lang_info) )
+ return false;
+
+ if ( $_POST['default_content_type'] === 'tutorial' )
+ {
+ $dir = ENANO_ROOT . "/language/{$lang_info['dir']}/install/default-tutorial";
+ }
+ else
+ {
+ $dir = ENANO_ROOT . "/language/{$lang_info['dir']}/install/default-blank";
+ }
+
+ if ( !$dr = @opendir($dir) )
+ return false;
+
+ while ( $dh = @readdir($dr) )
+ {
+ if ( !preg_match('/\.txt$/', $dh) )
+ continue;
+
+ $page_contents = @file_get_contents("$dir/$dh");
+ if ( empty($page_contents) )
+ return false;
+
+ $page_name = preg_replace('/\.txt$/', '', $dh);
+
+ if ( !install_primitive_page_creator($page_name, 'Article', $page_contents) )
+ return false;
+ }
+
+ closedir($dr);
+
+ $cache->purge('page_meta');
+
+ return true;
+}
+
+function install_primitive_page_creator($page_id, $namespace, $content)
+{
+ global $db, $session, $paths, $template, $plugins; // Common objects
+
+ $page_title = $db->escape(str_replace('_', ' ', dirtify_page_id($page_id)));
+ $author = $db->escape($_POST['username']);
+ $page_id = $db->escape($page_id);
+ $namespace = $db->escape($namespace);
+ // yes, we do probably want strip_all_php ON.
+ $content = RenderMan::preprocess_text($content, true, true);
+ $now = time();
+
+ // query 1: logs
+ $q = $db->sql_query('INSERT INTO ' . table_prefix . "logs(time_id, date_string, log_type, action, page_id, namespace, author, page_text) VALUES\n"
+ . " ( $now, 'DEPRECATED', 'page', 'edit', '$page_id', '$namespace', '$author', '$content');");
+ if ( !$q )
+ {
+ echo $db->get_error();
+ return false;
+ }
+
+ // query 2: page_text
+ $q = $db->sql_query('INSERT INTO ' . table_prefix . "page_text(page_id, namespace, page_text) VALUES\n"
+ . " ( '$page_id', '$namespace', '$content');");
+ if ( !$q )
+ {
+ echo $db->get_error();
+ return false;
+ }
+
+ // query 3: pages
+ $q = $db->sql_query('INSERT INTO ' . table_prefix . "pages(page_order, name, urlname, namespace, special, visible, comments_on, protected, delvotes, delvote_ips) VALUES\n"
+ . " (NULL, '$page_title', '$page_id', '$namespace', 0, 1, 1, 1, 0, '');");
+ if ( !$q )
+ {
+ echo $db->get_error();
+ return false;
+ }
+
+ return true;
+}
+
function stg_init_logs()
{
global $db, $session, $paths, $template, $plugins; // Common objects
diff -r 9ef3ccac13de -r 142a29b583f9 install/includes/stages/install.php
--- a/install/includes/stages/install.php Wed Apr 15 20:24:51 2009 -0400
+++ b/install/includes/stages/install.php Wed Apr 15 22:18:14 2009 -0400
@@ -108,6 +108,9 @@
error_reporting(E_ALL | E_STRICT);
run_installer_stage('importlang', $lang->get('install_stg_importlang_title'), 'stg_language_setup', $lang->get('install_stg_importlang_body'));
+// Pull in default content
+run_installer_stage('importcontent', $lang->get('install_stg_importcontent_title'), 'stg_add_content', $lang->get('install_stg_importcontent_body'));
+
// Init logs
run_installer_stage('initlogs', $lang->get('install_stg_initlogs_title'), 'stg_init_logs', $lang->get('install_stg_initlogs_body'));
diff -r 9ef3ccac13de -r 142a29b583f9 install/includes/stages/website.php
--- a/install/includes/stages/website.php Wed Apr 15 20:24:51 2009 -0400
+++ b/install/includes/stages/website.php Wed Apr 15 22:18:14 2009 -0400
@@ -225,6 +225,41 @@
get('website_field_urlscheme'); ?>
get('website_field_urlscheme_hint'); ?>
@@ -234,7 +269,7 @@
-
+
|
| |