Ejemplo n.º 1
0
 public function __construct($name = null)
 {
     parent::__construct($name);
     $year = $name . '[year]';
     $month = $name . '[month]';
     $day = $name . '[day]';
     $year = Select::create($year, null, true);
     $month = Select::create($month, null, true);
     $day = Select::create($day, null, true);
     $yearOptions = [];
     for ($i = date('Y') - 100; $i < date('Y'); $i++) {
         $yearOptions[$i] = $i;
     }
     $monthOptions = [1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December'];
     $dayOptions = [];
     for ($i = 1; $i <= 31; $i++) {
         $dayOptions[$i] = $i;
     }
     $year->setOptions($yearOptions);
     $month->setOptions($monthOptions);
     $day->setOptions($dayOptions);
     $this->addField($year);
     $this->addField($month);
     $this->addField($day);
 }
Ejemplo n.º 2
0
 /**
  * Create add / edit project form.
  */
 protected function projectForm($values, $type = 'add')
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'project/' . $type);
     $form->addField(new Form\Element\Csrf('csrf'));
     $form->addField(new Form\Element\Hidden('pubkey'));
     $options = array('choose' => Lang::get('select_repository_type'), 'github' => Lang::get('github'), 'bitbucket' => Lang::get('bitbucket'), 'gitlab' => Lang::get('gitlab'), 'remote' => Lang::get('remote'), 'local' => Lang::get('local'), 'hg' => Lang::get('hg'), 'svn' => Lang::get('svn'));
     $field = Form\Element\Select::create('type', Lang::get('where_hosted'), true);
     $field->setPattern('^(github|bitbucket|gitlab|remote|local|hg|svn)');
     $field->setOptions($options);
     $field->setClass('form-control')->setContainerClass('form-group');
     $form->addField($field);
     $container = new Form\ControlGroup('github-container');
     $container->setClass('github-container');
     $field = Form\Element\Select::create('github', Lang::get('choose_github'), false);
     $field->setClass('form-control')->setContainerClass('form-group');
     $container->addField($field);
     $form->addField($container);
     $field = Form\Element\Text::create('reference', Lang::get('repo_name'), true);
     $field->setValidator($this->getReferenceValidator($values));
     $field->setClass('form-control')->setContainerClass('form-group');
     $form->addField($field);
     $field = Form\Element\Text::create('title', Lang::get('project_title'), true);
     $field->setClass('form-control')->setContainerClass('form-group');
     $form->addField($field);
     $field = Form\Element\TextArea::create('key', Lang::get('project_private_key'), false);
     $field->setClass('form-control')->setContainerClass('form-group');
     $field->setRows(6);
     $form->addField($field);
     $field = Form\Element\TextArea::create('build_config', Lang::get('build_config'), false);
     $field->setClass('form-control')->setContainerClass('form-group');
     $field->setRows(6);
     $form->addField($field);
     $field = Form\Element\Text::create('branch', Lang::get('default_branch'), true);
     $field->setClass('form-control')->setContainerClass('form-group')->setValue('master');
     $form->addField($field);
     $field = Form\Element\Select::create('group_id', 'Project Group', true);
     $field->setClass('form-control')->setContainerClass('form-group')->setValue(1);
     $groups = array();
     $groupStore = b8\Store\Factory::getStore('ProjectGroup');
     $groupList = $groupStore->getWhere(array(), 100, 0, array(), array('title' => 'ASC'));
     foreach ($groupList['items'] as $group) {
         $groups[$group->getId()] = $group->getTitle();
     }
     $field->setOptions($groups);
     $form->addField($field);
     $field = Form\Element\Checkbox::create('allow_public_status', Lang::get('allow_public_status'), false);
     $field->setContainerClass('form-group');
     $field->setCheckedValue(1);
     $field->setValue(0);
     $form->addField($field);
     $field = Form\Element\Checkbox::create('archived', Lang::get('archived'), false);
     $field->setContainerClass('form-group');
     $field->setCheckedValue(1);
     $field->setValue(0);
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue(Lang::get('save_project'));
     $field->setContainerClass('form-group');
     $field->setClass('btn-success');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }
Ejemplo n.º 3
0
 /**
  * Create add / edit project form.
  */
 protected function projectForm($values, $type = 'add')
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'project/' . $type);
     $form->addField(new Form\Element\Csrf('csrf'));
     $form->addField(new Form\Element\Hidden('pubkey'));
     $options = array('choose' => 'Select repository type...', 'github' => 'Github', 'bitbucket' => 'Bitbucket', 'gitlab' => 'Gitlab', 'remote' => 'Remote URL', 'local' => 'Local Path', 'hg' => 'Mercurial');
     $field = Form\Element\Select::create('type', 'Where is your project hosted?', true);
     $field->setPattern('^(github|bitbucket|gitlab|remote|local|hg)');
     $field->setOptions($options);
     $field->setClass('form-control')->setContainerClass('form-group');
     $form->addField($field);
     $container = new Form\ControlGroup('github-container');
     $container->setClass('github-container');
     $field = Form\Element\Select::create('github', 'Choose a Github repository:', false);
     $field->setClass('form-control')->setContainerClass('form-group');
     $container->addField($field);
     $form->addField($container);
     $field = Form\Element\Text::create('reference', 'Repository Name / URL (Remote) or Path (Local)', true);
     $field->setValidator($this->getReferenceValidator($values));
     $field->setClass('form-control')->setContainerClass('form-group');
     $form->addField($field);
     $field = Form\Element\Text::create('title', 'Project Title', true);
     $field->setClass('form-control')->setContainerClass('form-group');
     $form->addField($field);
     $title = 'Private key to use to access repository (leave blank for local and/or anonymous remotes)';
     $field = Form\Element\TextArea::create('key', $title, false);
     $field->setClass('form-control')->setContainerClass('form-group');
     $field->setRows(6);
     $form->addField($field);
     $label = 'PHPCI build config for this project (if you cannot add a phpci.yml file in the project repository)';
     $field = Form\Element\TextArea::create('build_config', $label, false);
     $field->setClass('form-control')->setContainerClass('form-group');
     $field->setRows(6);
     $form->addField($field);
     $field = Form\Element\Text::create('branch', 'Default branch name', true);
     $field->setValidator($this->getReferenceValidator($values));
     $field->setClass('form-control')->setContainerClass('form-group')->setValue('master');
     $form->addField($field);
     $label = 'Enable public status page and image for this project?';
     $field = Form\Element\Checkbox::create('allow_public_status', $label, false);
     $field->setContainerClass('form-group');
     $field->setCheckedValue(1);
     $field->setValue(1);
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue('Save Project');
     $field->setContainerClass('form-group');
     $field->setClass('btn-success');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }