Exemplo n.º 1
0
 /**
  * Add elements to config form
  * no need to add "time" controls
  */
 protected function createForm()
 {
     $form = new Am_Form_Admin('form-' . $this->getId());
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array($this->getFormDefaults()));
     $form->setAction(REL_ROOT_URL . '/admin-reports/run/report_id/' . $this->getId());
     if ($this->getPointFieldType() == self::POINT_DATE) {
         $start = $form->addElement('Date', 'start')->setLabel(___('Start'));
         $start->addRule('required');
         $stop = $form->addElement('Date', 'stop')->setLabel(___('End'));
         $stop->addRule('required');
         $form->addRule('callback', 'Start Date cannot be later than the End Date', array($this, 'checkStopDate'));
         $quant = $form->addElement('Select', 'quant')->setLabel(___('Quantity'));
         $quant->addRule('required');
         $quant->loadOptions($this->getQuantityOptions());
     }
     $this->_initConfigForm($form);
     $form->addSubmit('save', array('value' => ___('Run Report')));
     return $form;
 }
Exemplo n.º 2
0
    function askRemoteAccess()
    {
        $form = new Am_Form_Admin();
        $info = $this->loadRemoteAccess();
        if ($info && !empty($info['_tested'])) {
            return true;
        }
        if ($info) {
            $form->addDataSource(new Am_Request($info));
        }
        $method = $form->addSelect('method', null, array('options' => array('ftp' => 'FTP', 'sftp' => 'SFTP')))->setLabel(___('Access Method'));
        $gr = $form->addGroup('hostname')->setLabel(___('Hostname'));
        $gr->addText('host')->addRule('required')->addRule('regex', 'Incorrect hostname value', '/^[\\w\\._-]+$/');
        $gr->addHTML('port-label')->setHTML('&nbsp;<b>Port</b>');
        $gr->addText('port', array('size' => 3));
        $gr->addHTML('port-notice')->setHTML('&nbsp;leave empty if default');
        $form->addText('user')->setLabel(___('Username'))->addRule('required');
        $form->addPassword('pass')->setLabel(___('Password'));
        //        $form->addTextarea('ssh_public_key')->setLabel(___('SSH Public Key'));
        //        $form->addTextarea('ssh_private_key')->setLabel(___('SSH Private Key'));
        $form->addSubmit('', array('value' => ___('Continue')));
        $form->addScript()->setScript(<<<CUT
\$(function(){
    \$('#method-0').change(function(){
        \$('#ssh_public_key-0,#ssh_private_key-0').closest('.row').toggle( \$(this).val() == 'ssh' );
    }).change();
});
CUT
);
        $error = null;
        $vars = $form->getValue();
        if ($form->isSubmitted() && $form->validate() && !($error = $this->tryConnect($vars))) {
            $vars['_tested'] = true;
            $this->storeRemoteAccess($vars);
            return true;
        } else {
            //$this->view->title = ___("File Access Credentials Required");
            $this->view->title = ___('Upgrade');
            $this->view->content = "";
            $this->outStepHeader();
            if ($error) {
                $method->setError($error);
            }
            $this->view->content .= (string) $form;
            $this->view->display('admin/layout.phtml');
            $this->noDisplay = true;
        }
    }
Exemplo n.º 3
0
 /**
  * Add elements to config form
  * no need to add "time" controls
  */
 protected function createForm()
 {
     $form = new Am_Form_Admin('form-' . $this->getId());
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array($this->getFormDefaults()));
     $form->setAction(REL_ROOT_URL . '/admin-reports/run/report_id/' . $this->getId());
     $this->_initConfigForm($form);
     $this->_afterInitConfigForm($form);
     $form->addSubmit('save', array('value' => ___('Run Report')));
     return $form;
 }
 /** @return Am_Form_Admin */
 function createMysqlForm()
 {
     $form = new Am_Form_Admin();
     $el = $form->addText('host')->setLabel('Wordpress  MySQL Hostname');
     $el->addRule('required', 'This field is required');
     $form->addText('user')->setLabel('Wordpress  MySQL Username')->addRule('required', 'This field is required');
     $form->addPassword('pass')->setLabel('Wordpress MySQL Password');
     $form->addText('db')->setLabel('Wordpress MySQL Database Name')->addRule('required', 'This field is required');
     $form->addText('prefix')->setLabel('Wordpress Tables Prefix');
     $dbConfig = $this->getDi()->getParameter('db');
     $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array('host' => $dbConfig['mysql']['host'], 'user' => $dbConfig['mysql']['user'], 'prefix' => 'wp_')));
     $el->addRule('callback2', '-', array($this, 'validateDbConnect'));
     $form->addSubmit(null, array('value' => 'Continue...'));
     return $form;
 }