Exemplo n.º 1
0
 public function body()
 {
     print "Wizard Test<hr>";
     $wizard = $this->init_module(Utils_Wizard::module_name());
     //get form
     $f =& $wizard->begin_page();
     $f->addElement('header', null, 'Welcome Page... ');
     $f->addElement('select', 'select_0', 'Jump to page', array(1 => '1', 2 => '2'));
     //method decides about jump to page
     $wizard->next_page(array($this, 'jump_page0'));
     //call method that generates form named 'test2'
     $this->page1($wizard->begin_page('page1'));
     //always jump to page 3
     $wizard->next_page(3);
     $f =& $wizard->begin_page();
     $f->addElement('header', null, 'Page 2');
     $f->addElement('text', 'page_2_input', 'page_2_input');
     $f->addRule('page_2_input', 'Required!', 'required');
     //jump to next page
     $wizard->next_page();
     $f =& $wizard->begin_page();
     $f->addElement('header', null, 'Yeah! you came from page 1 or 2');
     $wizard->next_page();
     //call wizard with process function specified as third arg
     $this->display_module($wizard, array(array($this, 'display_results')));
     //------------------------------ print out src
     print '<hr><b>Install</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Wizard/WizardInstall.php');
     print '<hr><b>Main</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Wizard/Wizard_0.php');
     print '<hr><b>Common</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Wizard/WizardCommon_0.php');
 }
Exemplo n.º 2
0
 public function body()
 {
     // init lang from install process
     $install_lang_code =& $_GET['install_lang'];
     if (isset($install_lang_code)) {
         // set anonymous setup to true at very first run to allow use admin tools.
         Variable::set('anonymous_setup', true);
         //
         Variable::set('default_lang', $install_lang_code);
         Epesi::redirect('index.php');
         return;
     }
     Base_LangCommon::load();
     $th = $this->init_module(Base_Theme::module_name());
     ob_start();
     print '<center>';
     $post_install =& $_SESSION['first-run_post-install'];
     if (!empty($post_install)) {
         foreach ($post_install as $i => $v) {
             $i = str_replace('/', '_', $i);
             ModuleManager::include_install($i);
             $f = array($i . 'Install', 'post_install');
             $fs = array($i . 'Install', 'post_install_process');
             if (!is_callable($f) || !is_callable($fs)) {
                 unset($post_install[$i]);
                 continue;
             }
             $ret = call_user_func($f);
             $form = $this->init_module(Libs_QuickForm::module_name(), null, $i);
             $form->addElement('header', null, __('Post installation of %s', array(str_replace('_', '/', $i))));
             $form->add_array($ret);
             $form->addElement('submit', null, 'OK');
             if ($form->validate()) {
                 $form->process($fs);
                 unset($post_install[$i]);
             } else {
                 $form->display();
                 break;
             }
         }
         if (ModuleManager::is_installed('Base') >= 0 && empty($post_install)) {
             Variable::set('default_module', 'Base_Box');
             Epesi::redirect();
         }
     }
     if (empty($post_install) && ModuleManager::is_installed('Base') < 0) {
         $wizard = $this->init_module(Utils_Wizard::module_name());
         /////////////////////////////////////////////////////////////
         $this->ini = parse_ini_file('modules/FirstRun/distros.ini', true);
         if (count($this->ini) > 1) {
             $f =& $wizard->begin_page();
             $f->addElement('header', null, __('Welcome to EPESI first run wizard'));
             $f->setDefaults(array('setup_type' => key($this->ini)));
             foreach ($this->ini as $name => $pkgs) {
                 switch ($name) {
                     case 'CRM installation':
                         $label = __('CRM installation');
                         break;
                     case 'CRM and Sales Opportunity':
                         $label = __('CRM and Sales Opportunity');
                         break;
                     case 'CRM and Bug Tracker installation':
                         $label = __('CRM and Bug Tracker installation');
                         break;
                     default:
                         $label = $name . ' (* missing translation)';
                         break;
                 }
                 $f->addElement('radio', 'setup_type', '', $label, $name);
             }
             $f->addElement('html', '<tr><td colspan=2><br /><strong>If you are not sure which package to choose select CRM Installation.<br>You can customize your installation later.</strong><br><br></td></tr>');
             $wizard->next_page();
         }
         /////////////////////////////////////////////////////////////////
         $f = $wizard->begin_page('simple_user');
         $f->addElement('header', null, __('Please enter administrator user login and password'));
         $f->addElement('text', 'login', __('Login'));
         $f->addRule('login', __('A username must be between 3 and 32 chars'), 'rangelength', array(3, 32));
         $f->addRule('login', __('Field required'), 'required');
         $f->addElement('text', 'mail', __('E-mail'));
         $f->addRule('mail', __('Field required'), 'required');
         $f->addRule('mail', __('Invalid e-mail address'), 'email');
         $f->addElement('password', 'pass', __('Password'));
         $f->addElement('password', 'pass_c', __('Confirm Password'));
         $f->addRule('pass', __('Field required'), 'required');
         $f->addRule('pass_c', __('Field required'), 'required');
         $f->addRule(array('pass', 'pass_c'), __('Passwords don\'t match'), 'compare');
         $f->addRule('pass', __('Your password must be longer then 5 chars'), 'minlength', 5);
         $wizard->next_page();
         /////////////////////////////////////////////////////
         $f = $wizard->begin_page('simple_mail');
         $f->addElement('header', null, __('Mail settings'));
         $f->addElement('html', '<tr><td colspan=2>' . __('If you are on a hosted server it probably should stay as it is now.') . '</td></tr>');
         $f->addElement('select', 'mail_method', __('Choose method'), array('smtp' => __('remote smtp server'), 'mail' => __('local php.ini settings')));
         $f->setDefaults(array('mail_method' => 'mail'));
         $wizard->next_page(array($this, 'choose_mail_method'));
         //////////////////////
         $f = $wizard->begin_page('simple_mail_smtp');
         $f->addElement('header', null, __('Mail settings'));
         $f->addElement('text', 'mail_host', __('SMTP host address'));
         $f->addRule('mail_host', __('Field required'), 'required');
         $f->addElement('header', null, __('If your server needs authorization...'));
         $f->addElement('text', 'mail_user', __('Login'));
         $f->addElement('password', 'mail_password', __('Password'));
         $wizard->next_page();
         ////////////////////////////////////////////////////////////
         $f = $wizard->begin_page('setup_warning');
         $f->addElement('header', null, __('Warning'));
         $f->addElement('html', '<tr><td colspan=2><br />' . __('Setup will now check for available modules and will install them.') . '<br>' . __('This operation may take several minutes.') . '<br><br></td></tr>');
         $wizard->next_page();
         /////////////////////////////////////////
         $this->display_module($wizard, array(array($this, 'done')));
     }
     print '</center>';
     $th->assign('wizard', ob_get_clean());
     $th->display();
 }