Skip to content

Commit

Permalink
MDL-15249 improving cli installer
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jun 15, 2008
1 parent c3175af commit 9d068cd
Show file tree
Hide file tree
Showing 4 changed files with 585 additions and 647 deletions.
12 changes: 4 additions & 8 deletions admin/cliupgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,17 @@

// include standard Moodle libraries

require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/installlib.php');
require_once($CFG->libdir.'/clilib.php'); //cli-library
require_once($CFG->libdir.'/setuplib.php');
require_once($CFG->libdir.'/adminlib.php');
require_once($CFG->libdir.'/moodlelib.php');
require_once($CFG->libdir.'/weblib.php');
require_once($CFG->libdir.'/adodb/adodb.inc.php');
require_once($CFG->libdir.'/environmentlib.php');
require_once($CFG->libdir.'/xmlize.php');
require_once($CFG->libdir.'/componentlib.class.php');
require_once($CFG->libdir.'/installlib.php'); //cli-library
require_once($CFG->dirroot.'/version.php');

//include PEAR Console libraries
set_include_path($CFG->libdir . PATH_SEPARATOR . $CFG->libdir . '/pear/');
require_once('Console/Getopt.php');
error('TODO fix CLI installer'); //TODO: fix cli installer


/// Set default values - things that require the libraries
Expand Down Expand Up @@ -464,7 +461,6 @@
$errormsg = get_string('dbwronghostserver', 'install');
}

error('fix cml installer'); //TODO: fix cli installer
if (empty($errormsg)) {

/// Have the $db object ready because we are going to use it often
Expand Down
77 changes: 1 addition & 76 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
/// Include some moodle libraries

require_once($CFG->libdir.'/setuplib.php');
require_once($CFG->libdir.'/installlib.php');
require_once($CFG->libdir.'/weblib.php');
require_once($CFG->libdir.'/deprecatedlib.php');
require_once($CFG->libdir.'/moodlelib.php');
Expand Down Expand Up @@ -945,74 +946,6 @@ function print_install_help($help) {
}
}


//==========================================================================//

function get_memory_limit() {
if ($limit = ini_get('memory_limit')) {
return $limit;
} else {
return get_cfg_var('memory_limit');
}
}

//==========================================================================//

function check_memory_limit() {

/// if limit is already 40 or more then we don't care if we can change it or not
if ((int)str_replace('M', '', get_memory_limit()) >= 40) {
return true;
}

/// Otherwise, see if we can change it ourselves
@ini_set('memory_limit', '40M');
return ((int)str_replace('M', '', get_memory_limit()) >= 40);
}

//==========================================================================//

function inst_check_php_version() {
return check_php_version("5.2.0");
}
//==========================================================================//

/* This function returns a list of languages and their full names. The
* list of available languages is fetched from install/lang/xx/installer.php
* and it's used exclusively by the installation process
* @return array An associative array with contents in the form of LanguageCode => LanguageName
*/
function get_installer_list_of_languages() {

global $CFG;

$languages = array();

/// Get raw list of lang directories
$langdirs = get_list_of_plugins('install/lang');
asort($langdirs);
/// Get some info from each lang
foreach ($langdirs as $lang) {
if (file_exists($CFG->dirroot .'/install/lang/'. $lang .'/installer.php')) {
include($CFG->dirroot .'/install/lang/'. $lang .'/installer.php');
if (substr($lang, -5) == '_utf8') { //Remove the _utf8 suffix from the lang to show
$shortlang = substr($lang, 0, -5);
} else {
$shortlang = $lang;
}
if ($lang == 'en') { //Explain this is non-utf8 en
$shortlang = 'non-utf8 en';
}
if (!empty($string['thislanguage'])) {
$languages[$lang] = $string['thislanguage'] .' ('. $shortlang .')';
}
unset($string);
}
}
/// Return array
return $languages;
}

//==========================================================================//

function css_styles($databases) {
Expand Down Expand Up @@ -1241,12 +1174,4 @@ function toggledbinfo() {
<?php
}

/**
* Add slashes for single quotes and backslashes
* so they can be included in single quoted string
* (for config.php)
*/
function addsingleslashes($input){
return preg_replace("/(['\\\])/", "\\\\$1", $input);
}
?>
Loading

0 comments on commit 9d068cd

Please sign in to comment.