+
-
\n";
+ \n";
$e_forms->add_plain_html($output);
$this->finish_form();
$e_forms->add_button("submit", LANINS_035);
$this->template->SetTag("stage_content", $e_forms->return_form());
}
- function stage_7()
+ private function stage_7()
{
global $e_forms;
@@ -781,8 +791,8 @@ class e_install
$this->previous_steps['prefs']['sitename'] = $_POST['sitename'];
$this->previous_steps['prefs']['sitetheme'] = $_POST['sitetheme'];
- $this->previous_steps['prefs']['generate_content'] = $_POST['generate_content'];
-
+ $this->previous_steps['generate_content'] = $_POST['generate_content'];
+ $this->previous_steps['install_plugins'] = $_POST['install_plugins'];
$this->template->SetTag("installation_heading", LANINS_001);
$this->template->SetTag("stage_pre", LANINS_002);
@@ -798,9 +808,9 @@ class e_install
}
- function stage_8()
+ private function stage_8()
{
-
+
global $e_forms;
$this->stage = 8;
@@ -855,8 +865,10 @@ class e_install
$page = $config_result."
";
}
else
- {
+ {
$errors = $this->create_tables();
+ $this->import_configuration();
+
if ($errors == true)
{
$page = $errors."
";
@@ -871,10 +883,123 @@ class e_install
$this->template->SetTag("stage_content", $page.$e_forms->return_form());
}
+ /**
+ * Import and Generate Preferences and default content.
+ * @return
+ */
+ private function import_configuration()
+ {
+ define("E107_INSTALL",TRUE); //FIXME - remove the need for this - ie. make the MySQL class work without it.
+
+ $themeImportFile = $this->e107->e107_dirs['THEMES_DIRECTORY'].$this->previous_steps['prefs']['sitetheme']."/install.xml";
+ if($this->previous_steps['generate_content']==1 && is_readable($themeImportFile))
+ {
+ $XMLImportfile = $themeImportFile;
+ }
+ else
+ {
+ $XMLImportfile = $this->e107->e107_dirs['FILES_DIRECTORY']. "default_install.xml";
+ }
+
+ // Insert Defaults.
+ $udirs = "admin/|plugins/|temp";
+ $e_SELF = $_SERVER['PHP_SELF'];
+ $e_HTTP = preg_replace("#".$udirs."#i", "", substr($e_SELF, 0, strrpos($e_SELF, "/"))."/");
- // Check a DB name or table prefix - anything starting with a numeric followed by 'e' causes problems.
- // Return TRUE if acceptable, FALSE if unacceptable
- // Empty string returns the value of $blank_ok (caller should set TRUE for prefix, FALSE for DB name)
+ $pref_language = isset($this->previous_steps['language']) ? $this->previous_steps['language'] : "English";
+
+ if (is_readable($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$pref_language."/lan_prefs.php"))
+ {
+ include_once($this->e107->e107_dirs['LANGUAGES_DIRECTORY'].$pref_language."/lan_prefs.php");
+ }
+ else
+ {
+ include_once($this->e107->e107_dirs['LANGUAGES_DIRECTORY']."English/lan_prefs.php");
+ }
+
+ require_once("{$this->e107->e107_dirs['FILES_DIRECTORY']}def_e107_prefs.php"); // could be deprecated if need be
+ include_once("{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}arraystorage_class.php");
+
+ $tmp = ArrayData::WriteArray($pref);
+
+ $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('SitePrefs', '{$tmp}')");
+ $this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('SitePrefs_Backup', '{$tmp}')");
+
+ //Create default plugin-table entries.
+ // e107::getSingleton('e107plugin')->update_plugins_table(); //FIXME - also relies on pref class.
+
+ // Install Theme-required plugins
+ if($this->previous_steps['install_plugins']==1)
+ {
+ if($themeInfo = $this->get_theme_xml($this->previous_steps['prefs']['sitetheme']))
+ {
+ foreach($themeInfo['pluginOptions']['plugin'] as $k=>$plug) //TODO refactor pluginOptions as 'plugins' in theme.xml etc
+ {
+ $this->install_plugin($plug['@attributes']['name']);
+ }
+ }
+ }
+
+ // Import Site-Data from XML.
+ //FIXME remove 'database' from the function below, once the pref handler is working.
+ e107::getSingleton('xmlClass')->e107Import($XMLImportfile,'database'); // includes non-core preferences
+
+ // Set Preferences defined during install - overwriting those that may exist in the XML.
+
+ $this->previous_steps['prefs']['sitelanguage'] = $this->previous_steps['language'];
+ $this->previous_steps['prefs']['sitelang_init'] = $this->previous_steps['language'];
+
+ $this->previous_steps['prefs']['siteadmin'] = $this->previous_steps['admin']['display'];
+ $this->previous_steps['prefs']['siteadminemail'] = $this->previous_steps['admin']['email'];
+ $this->previous_steps['prefs']['install_date'] = time();
+ $this->previous_steps['prefs']['siteurl'] = $e_HTTP;
+
+ $this->previous_steps['prefs']['sitetag'] = LAN_PREF_2;
+ $this->previous_steps['prefs']['sitedisclaimer'] = LAN_PREF_3;
+
+ $this->previous_steps['prefs']['replyto_name'] = $this->previous_steps['admin']['display'];
+ $this->previous_steps['prefs']['replyto_email'] = $this->previous_steps['admin']['email'];
+
+
+ foreach($this->previous_steps['prefs'] as $key=>$val)
+ {
+ // e107::getConfig('core')->set($key, $val); //FIXME - pref class issues.
+ }
+ // e107::getConfig('core')->save(FALSE); //FIXME - pref class issues.
+
+ // Create the admin user - replacing any that may be been included in the XML.
+ $ip = $_SERVER['REMOTE_ADDR'];
+ $userp = "1, '{$this->previous_steps['admin']['display']}', '{$this->previous_steps['admin']['user']}', '', '".md5($this->previous_steps['admin']['password'])."', '', '{$this->previous_steps['admin']['email']}', '', '', 0, ".time().", 0, 0, 0, 0, 0, '{$ip}', 0, '', 0, 1, '', '', '0', '', ".time().", ''";
+ $this->dbqry("REPLACE INTO {$this->previous_steps['mysql']['prefix']}user VALUES ({$userp})" );
+
+ mysql_close();
+ return false;
+
+ }
+
+ /**
+ * Install a Theme required plugin.
+ * @param string $plugpath - plugin folder name
+ * @return
+ */
+ private function install_plugin($plugpath) //FIXME - requires default plugin table entries, see above.
+ {
+ return; // remove once fixed.
+ e107::getDb()->db_Select('plugin','plugin_id',"plugin_path='".$plugpath." LIMIT 1");
+ $row = e107::getDb()->db_Fetch(MYSQL_ASSOC);
+ e107::getSingleton('e107plugin')->install_plugin($row['plugin_id']);
+ return;
+ }
+
+
+ /**
+ * Check a DB name or table prefix - anything starting with a numeric followed by 'e' causes problems.
+ * Return TRUE if acceptable, FALSE if unacceptable
+ * Empty string returns the value of $blank_ok (caller should set TRUE for prefix, FALSE for DB name)
+ * @param object $str
+ * @param object $blank_ok [optional]
+ * @return boolean
+ */
function check_name($str, $blank_ok = FALSE)
{
if ($str == '')
@@ -943,12 +1068,16 @@ class e_install
function get_theme_xml($theme_folder)
{
- require_once($this->e107->e107_dirs['HANDLERS_DIRECTORY']."xml_class.php");
- $xml = new xmlClass;
-
$path = $this->e107->e107_dirs['THEMES_DIRECTORY'].$theme_folder."/theme.xml";
+
+ if(!is_readable($path))
+ {
+ return FALSE;
+ }
+ require_once($this->e107->e107_dirs['HANDLERS_DIRECTORY']."xml_class.php");
+ $xml = new xmlClass;
$xmlArray = $xml->loadXMLfile($path,'advanced');
- return $xmlArray;
+ return (is_array($xmlArray)) ? $xmlArray : FALSE;
}
@@ -986,8 +1115,11 @@ class e_install
return $bad_files;
}
-
- function create_tables()
+ /**
+ * Create Core MySQL tables
+ * @return
+ */
+ private function create_tables()
{
$link = mysql_connect($this->previous_steps['mysql']['server'], $this->previous_steps['mysql']['user'], $this->previous_steps['mysql']['password']);
@@ -1031,6 +1163,13 @@ class e_install
}
}
+ return FALSE;
+
+
+
+ //FIXME - remove - Everything below this point should no longer be required. See import_configuration();
+
+ /*
$datestamp = time();
$this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}news VALUES (0, '".LANINS_063."', '".LANINS_062."', '', '{$datestamp}', '0', '1', 1, 0, 0, 0, 0, '0', '', 'welcome.png', 0) ");
@@ -1062,15 +1201,7 @@ class e_install
require_once("{$this->e107->e107_dirs['FILES_DIRECTORY']}def_e107_prefs.php");
include_once("{$this->e107->e107_dirs['HANDLERS_DIRECTORY']}arraystorage_class.php");
-
- // Set User Preferences.
- foreach($this->previous_steps['prefs'] as $key=>$val)
- {
- $pref[$key] = $val;
- }
-
- //TODO - Cameron - create 2 seperate methods. One for old inserts using the code below. And another using external XML files.
-
+
$tmp = ArrayData::WriteArray($pref);
$this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}core VALUES ('SitePrefs', '{$tmp}')");
@@ -1139,27 +1270,27 @@ class e_install
$this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}banner VALUES (0, 'e107', 'e107login', 'e107password', 'banner2.png', 'http://e107.org', 0, 0, 0, 0, 0, 0, '', 'campaign_one') ");
$this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}banner VALUES (0, 'e107', 'e107login', 'e107password', 'banner3.png', 'http://e107.org', 0, 0, 0, 0, 0, 0, '', 'campaign_one') ");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (1, 'login_menu', 1, 1, '0', '', 'login_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (3, 'online_menu', 0, 0, '0', '', 'online/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (4, 'blogcalendar_menu', 0, 0, '0', '', 'blogcalendar_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (5, 'tree_menu', 0, 0, '0', '', 'tree_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (6, 'search_menu', 0, 0, '0', '', 'search_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (7, 'compliance_menu', 0, 0, '0', '', 'siteinfo_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (8, 'userlanguage_menu', 0, 0, '0', '', 'user_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (9, 'powered_by_menu', 2, 2, '0', '', 'siteinfo_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (10, 'counter_menu', 0, 0, '0', '', 'siteinfo_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (11, 'usertheme_menu', 0, 0, '0', '', 'user_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (12, 'banner_menu', 0, 0, '0', '', 'banner_menu/', '')");
-// $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (13, 'online_extended_menu', 2, 1, '0', '', 'online_extended_menu/')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (14, 'clock_menu', 0, 0, '0', '', 'clock_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (15, 'sitebutton_menu', 0, 0, '0', '', 'siteinfo_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (16, 'comment_menu', 0, 0, '0', '', 'comment_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (17, 'lastseen_menu', 0, 0, '0', '', 'online/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (18, 'other_news_menu', 0, 0, '0', '', 'other_news_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (19, 'other_news2_menu', 0, 0, '0', '', 'other_news_menu/', '')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (20, 'admin_menu', 0, 0, '0', '', 'admin_menu/', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (1, 'login_menu', 1, 1, '0', '', 'login_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (3, 'online_menu', 0, 0, '0', '', 'online/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (4, 'blogcalendar_menu', 0, 0, '0', '', 'blogcalendar_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (5, 'tree_menu', 0, 0, '0', '', 'tree_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (6, 'search_menu', 0, 0, '0', '', 'search_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (7, 'compliance_menu', 0, 0, '0', '', 'siteinfo_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (8, 'userlanguage_menu', 0, 0, '0', '', 'user_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (9, 'powered_by_menu', 2, 2, '0', '', 'siteinfo_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (10, 'counter_menu', 0, 0, '0', '', 'siteinfo_menu/', '', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (11, 'usertheme_menu', 0, 0, '0', '', 'user_menu/', '', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (12, 'banner_menu', 0, 0, '0', '', 'banner_menu/', '', '')");
+// $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (13, 'online_extended_menu', 2, 1, '0', '', 'online_extended_menu/', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (14, 'clock_menu', 0, 0, '0', '', 'clock_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (15, 'sitebutton_menu', 0, 0, '0', '', 'siteinfo_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (16, 'comment_menu', 0, 0, '0', '', 'comment_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (17, 'lastseen_menu', 0, 0, '0', '', 'online/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (18, 'other_news_menu', 0, 0, '0', '', 'other_news_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (19, 'other_news2_menu', 0, 0, '0', '', 'other_news_menu/', '', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (20, 'admin_menu', 0, 0, '0', '', 'admin_menu/', '', '')");
// $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (21, 'rss_menu', 5, 1, '0', '', 'rss_menu/')");
- $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (22, 'PCMag', 2, 1, '0', '', '1', '')");
+ $this->dbqry("INSERT INTO `{$this->previous_steps['mysql']['prefix']}menus` VALUES (22, 'PCMag', 2, 1, '0', '', '1', '', '')");
$this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}userclass_classes VALUES (1, 'PRIVATEMENU', '".LANINS_093."',".e_UC_ADMIN.", 0, '', 0, 0, '')");
$this->dbqry("INSERT INTO {$this->previous_steps['mysql']['prefix']}userclass_classes VALUES (2, 'PRIVATEFORUM1', '".LANINS_094."',".e_UC_ADMIN.", 0, '', 0, 0, '')");
@@ -1178,6 +1309,8 @@ class e_install
mysql_close();
return false;
+
+ */
}
function write_config($data)
@@ -1356,7 +1489,7 @@ function template_data()
$data = "
-
{installation_heading}
+
{installation_heading} :: {stage_pre}{stage_num} - {stage_title}