|
1 | 1 | #!/usr/bin/php
|
2 | 2 | <?php
|
3 | 3 |
|
4 |
| -#The following files must exist in the same directory as this-here local_mamp.php script: |
| 4 | +# INTERNAL SETTINGS ########################################################### |
| 5 | +define('MYSQL_BIN', '/Applications/MAMP/Library/bin/mysql'); |
| 6 | + |
| 7 | +define('STARTING_POINT_NAME_SAMPLE_CONTENT', 'standard'); |
| 8 | +define('STARTING_POINT_NAME_EMPTY_CONTENT', 'blank'); |
| 9 | + |
| 10 | +//The following files must exist in the same directory as this-here local_mamp.php script: |
5 | 11 | define('FILENAME_SETTINGS', 'settings.php'); //required
|
6 | 12 | define('FILENAME_INSTALL_C5_CLI', 'install-concrete5.php'); //required
|
7 | 13 | define('FILENAME_ADD_TO_CONFIG', 'append_to_config_site_php.txt'); //optional (use empty string if none)
|
8 | 14 | define('FILENAME_CLI_LOGIN', 'temp_cli_login.html'); //optional (use empty string if none)
|
9 |
| -define('FILENAME_ZENDLOCALEDATA_BLACKLIST', 'remove_zend_locale_data.txt'); //required if REMOVE_NONENGLIGH_ZEND_LOCALE_DATA is TRUE |
10 |
| - |
11 |
| -require(dirname(__FILE__) . '/' . FILENAME_SETTINGS); |
12 |
| -define('STARTING_POINT_NAME_SAMPLE_CONTENT', 'standard'); |
13 |
| -define('STARTING_POINT_NAME_EMPTY_CONTENT', 'blank'); |
14 |
| -define('MYSQL_BIN', '/Applications/MAMP/Library/bin/mysql'); |
| 15 | +define('FILENAME_ZENDLOCALEDATA_BLACKLIST', 'remove_zend_locale_data.txt'); //optional (use empty string if none). |
15 | 16 |
|
16 | 17 | //Available C5 versions for installation (note that 5.5.1 was the first version to allow CLI installation).
|
17 | 18 | //First one in list becomes default option.
|
|
52 | 53 | );
|
53 | 54 |
|
54 | 55 |
|
| 56 | +# LOAD USER SETTINGS ########################################################## |
| 57 | +$settings_file_path = dirname(__FILE__) . '/' . FILENAME_SETTINGS; |
| 58 | +if (!is_file($settings_file_path)) { |
| 59 | + echo "ABORTING INSTALLATION: CANNOT LOCATE SETTINGS FILE ({$settings_file_path})!\n"; |
| 60 | + exit; |
| 61 | +} |
| 62 | +require($settings_file_path); |
| 63 | + |
| 64 | + |
55 | 65 | # VALIDATE CONFIG SETTINGS ####################################################
|
56 | 66 | $c5_cli_script_path = dirname(__FILE__) . '/' . FILENAME_INSTALL_C5_CLI;
|
57 | 67 | if (!is_file($c5_cli_script_path)) {
|
|
64 | 74 | exit;
|
65 | 75 | }
|
66 | 76 |
|
| 77 | +$zend_locale_data_blacklist = ''; |
| 78 | +if (FILENAME_ZENDLOCALEDATA_BLACKLIST !== '') { |
| 79 | + $zend_locale_data_blacklist = dirname(__FILE__) . '/' . FILENAME_ZENDLOCALEDATA_BLACKLIST; |
| 80 | + if (!is_file($zend_locale_data_blacklist)) { |
| 81 | + echo "ABORTING INSTALLATION: CANNOT LOCATE ZEND LOCALE DATA BLACKLIST ({$zend_locale_data_blacklist})!\n"; |
| 82 | + exit; |
| 83 | + } |
| 84 | +} |
| 85 | + |
67 | 86 |
|
68 | 87 | # ASK USER FOR PARAMS #########################################################
|
69 | 88 | system('clear');
|
|
86 | 105 | # Get target directory
|
87 | 106 | $htdocs_dir = '/' . trim(HTDOCS_DIR, '/') . '/';
|
88 | 107 | $htdocs_url = rtrim(BASE_URL, '/') . '/';
|
89 |
| -$target = stdin("Enter target directory (trailing slash will be stripped):\n" . $htdocs_dir); |
90 |
| -$target_dir = $htdocs_dir . trim($target, '/'); |
91 |
| -$target_url = $htdocs_url . trim($target, '/'); |
| 108 | +$response = stdin("Enter target directory (trailing slash will be stripped):\n" . $htdocs_dir); |
| 109 | +$target_dir = $htdocs_dir . trim($response, '/'); |
| 110 | +$target_url = $htdocs_url . trim($response, '/'); |
92 | 111 | if (is_dir($target_dir)) {
|
93 | 112 | echo "ABORTING INSTALLATION: TARGET DIRECTORY ({$target_dir}) ALREADY EXISTS!\n";
|
94 | 113 | exit;
|
|
104 | 123 | $site = strip_unsafe_cli_chars($site);
|
105 | 124 |
|
106 | 125 | # Ask for sample content or blank
|
107 |
| -$do_install_sample_content = stdin("Install C5 sample content (Y/n)?\ny/n (default y): ", false); |
108 |
| -if (strtolower($do_install_sample_content) == "n") { |
109 |
| - $starting_point = STARTING_POINT_NAME_EMPTY_CONTENT; |
| 126 | +$response = stdin("Install C5 sample content (Y/n)?\ny/n (default y): ", false); |
| 127 | +$starting_point = (strtolower($response) == "n") ? STARTING_POINT_NAME_EMPTY_CONTENT : STARTING_POINT_NAME_SAMPLE_CONTENT; |
| 128 | + |
| 129 | +# Ask about optional functionality |
| 130 | +$response = stdin("Remove empty top-level folders (y/N)?\ny/n (default: n): ", false); |
| 131 | +$remove_empty_toplevel_folders = (strtolower($response) == 'y'); |
| 132 | + |
| 133 | +if (empty($zend_locale_data_blacklist)) { |
| 134 | + echo "Zend Locale Data: All files will remain in the installation because no blacklist file was specified.\n\n"; |
110 | 135 | } else {
|
111 |
| - $starting_point = STARTING_POINT_NAME_SAMPLE_CONTENT; |
| 136 | + $response = stdin("Remove non-english Zend Locale Data (y/N)?\ny/n (default: n): ", false); |
| 137 | + $remove_nonengligh_zend_locale_data = (strtolower($response) == 'y'); |
112 | 138 | }
|
113 | 139 |
|
114 | 140 |
|
|
196 | 222 |
|
197 | 223 |
|
198 | 224 | # REMOVE NON-ENGLISH ZEND_LOCALE_DATA #########################################
|
199 |
| -if (REMOVE_NONENGLIGH_ZEND_LOCALE_DATA) { |
| 225 | +if ($remove_nonengligh_zend_locale_data) { |
200 | 226 | echo "Removing non-english Zend/Locale/Data files...\n";
|
201 | 227 |
|
202 |
| - $blacklist_file = dirname(__FILE__) . '/' . FILENAME_ZENDLOCALEDATA_BLACKLIST; |
203 |
| - $blacklist_contents = file_get_contents($blacklist_file); |
| 228 | + $blacklist_contents = file_get_contents($zend_locale_data_blacklist); |
204 | 229 | $blacklist_contents = str_replace("\r\n", "\n", $blacklist_contents);
|
205 | 230 | $blacklist_contents = str_replace("\r", "\n", $blacklist_contents);
|
206 | 231 | $remove_filenames = explode("\n", $blacklist_contents);
|
|
216 | 241 |
|
217 | 242 |
|
218 | 243 | # REMOVE EMPTY TOP-LEVEL FOLDERS ##############################################
|
219 |
| -if (REMOVE_EMPTY_TOPLEVEL_FOLDERS) { |
| 244 | +if ($remove_empty_toplevel_folders) { |
220 | 245 | echo "Removing empty top-level folders...\n";
|
221 | 246 | rmdir("{$target_dir}/controllers");
|
222 | 247 | rmdir("{$target_dir}/css");
|
|
0 commit comments