Пример #1
0
 public function Step6()
 {
     // Form to collect the library location and server key
     $formFields = array();
     $formFields[] = FormManager::AddHidden('step', 7);
     $formFields[] = FormManager::AddText('library_location', __('Library Location'), NULL, sprintf(__('%s needs somewhere to store the things you upload to be shown. Ideally, this should be somewhere outside the root of your web server - that is such that is not accessible by a web browser. Please input the full path to this folder. If the folder does not already exist, we will attempt to create it for you.'), Theme::GetConfig('app_name')), 'n');
     $formFields[] = FormManager::AddText('server_key', __('Server Key'), Install::gen_secret(6), sprintf(__('%s needs you to choose a "key". This will be required each time you set-up a new client. It should be complicated, and hard to remember. It is visible in the CMS interface, so it need not be written down separately.'), Theme::GetConfig('app_name')), 'n');
     $formFields[] = FormManager::AddCheckbox('stats', __('Statistics'), 1, sprintf(__('We\'d love to know you\'re running %s. If you\'re happy for us to collect anonymous statistics (version number, number of displays) then please leave the box ticked. Please un tick the box if your server does not have direct access to the internet.'), Theme::GetConfig('app_name')), 'n');
     // Put up an error message if one has been set (and then unset it)
     if ($this->errorMessage != '') {
         Theme::Set('message', $this->errorMessage);
         Theme::Set('prepend', Theme::RenderReturn('message_box'));
         $this->errorMessage == '';
     }
     // Return a rendered form
     Theme::Set('form_action', 'install.php');
     Theme::Set('form_fields', $formFields);
     Theme::Set('form_buttons', array(FormManager::AddButton(__('Next'))));
     return Theme::RenderReturn('form_render');
 }
Пример #2
0
 public function Step2()
 {
     Kit::ClassLoader('install');
     // Work out what is involved in this upgrade
     $_SESSION['upgradeFrom'] = Config::Version('DBVersion');
     if ($_SESSION['upgradeFrom'] < 1) {
         $_SESSION['upgradeFrom'] = 1;
     }
     // Get a list of .sql and .php files for the upgrade
     $sql_files = Install::ls('*.sql', 'install/database', false, array('return_files'));
     $php_files = Install::ls('*.php', 'install/database', false, array('return_files'));
     // Sort by natural filename (eg 10 is bigger than 2)
     natcasesort($sql_files);
     natcasesort($php_files);
     $_SESSION['phpFiles'] = $php_files;
     $_SESSION['sqlFiles'] = $sql_files;
     $max_sql = Kit::ValidateParam(substr(end($sql_files), 0, -4), _INT);
     $max_php = Kit::ValidateParam(substr(end($php_files), 0, -4), _INT);
     $_SESSION['upgradeTo'] = max($max_sql, $max_php);
     if (!$_SESSION['upgradeTo']) {
         throw new Exception(__('Unable to calculate the upgradeTo value. Check for non-numeric SQL and PHP files in the "install / database" directory.'));
     }
     if ($_SESSION['upgradeTo'] < $_SESSION['upgradeFrom']) {
         $_SESSION['upgradeTo'] = $_SESSION['upgradeFrom'];
     }
     // Form to collect some information.
     $formFields = array();
     $formButtons = array();
     // Put up an error message if one has been set (and then unset it)
     if ($this->errorMessage != '') {
         Theme::Set('message', $this->errorMessage);
         Theme::Set('prepend', Theme::RenderReturn('message_box'));
         $this->errorMessage == '';
     }
     $formFields[] = FormManager::AddHidden('step', 3);
     $formFields[] = FormManager::AddHidden('upgradeFrom', $_SESSION['upgradeFrom']);
     $formFields[] = FormManager::AddHidden('upgradeTo', $_SESSION['upgradeTo']);
     $formFields[] = FormManager::AddHidden('includes', true);
     $formFields[] = FormManager::AddMessage(sprintf(__('Upgrading from database version %d to %d'), $_SESSION['upgradeFrom'], $_SESSION['upgradeTo']));
     // Loop for $i between upgradeFrom + 1 and upgradeTo.
     // If a php file exists for that upgrade, make an instance of it and call Questions so we can
     // Ask the user for input.
     for ($i = $_SESSION['upgradeFrom'] + 1; $i <= $_SESSION['upgradeTo']; $i++) {
         if (file_exists('install/database/' . $i . '.php')) {
             include_once 'install/database/' . $i . '.php';
             $stepName = 'Step' . $i;
             // Check that a class called Step$i exists
             if (class_exists($stepName)) {
                 $_SESSION['Step' . $i] = new $stepName($this->db);
                 // Call Questions on the object and send the resulting hash to createQuestions routine
                 $questionFields = $this->createQuestions($i, $_SESSION['Step' . $i]->Questions());
                 $formFields = array_merge($formFields, $questionFields);
             } else {
                 $formFields[] = FormManager::AddMessage(sprintf(__('Warning: We included %s.php, but it did not include a class of appropriate name.'), $i));
             }
         }
     }
     $formFields[] = FormManager::AddCheckbox('doBackup', 'I agree I have a valid database backup and can restore it should the upgrade process fail', 0, __('It is important to take a database backup before running the upgrade wizard. A backup is essential for recovering your CMS should there be a problem with the upgrade.'), 'b');
     // Return a rendered form
     Theme::Set('form_action', 'index.php?p=upgrade');
     Theme::Set('form_fields', $formFields);
     Theme::Set('form_buttons', array(FormManager::AddButton(__('Next'))));
     return Theme::RenderReturn('form_render');
 }