/** * Return the select field widget as object * @param mixed * @return object */ protected function getEventTypeWidget($value = null) { $widget = new SelectMenu(); $widget->id = 'event_type'; $widget->name = 'event_type'; $widget->mandatory = false; $widget->options = array(array('value' => '0', 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['event_type']['label'][0]), array('value' => '1', 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['event_type']['label'][1]), array('value' => '2', 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['event_type']['label'][2]), array('value' => '3', 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['event_type']['label'][3]), array('value' => '4', 'label' => $GLOBALS['TL_LANG']['tl_calendar_events']['event_type']['label'][4])); $widget->value = $value; $widget->label = $GLOBALS['TL_LANG']['tl_calendar_events']['event_type'][0]; if ($GLOBALS['TL_CONFIG']['showHelp'] && strlen($GLOBALS['TL_LANG']['tl_calendar_events']['event_type'][1])) { $widget->help = $GLOBALS['TL_LANG']['tl_calendar_events']['event_type'][1]; } // Valiate input if (\Input::post('FORM_SUBMIT') == 'tl_importExt_calendar') { $widget->validate(); if ($widget->hasErrors()) { $this->blnSave = false; } } return $widget; }
public function compile() { \System::loadLanguageFile('tl_iso_gallery'); $strBuffer = ' <table style="width:100%"> <thead> <tr> <th>' . $GLOBALS['TL_LANG']['tl_iso_gallery']['name'][0] . '</th> <th>' . $GLOBALS['TL_LANG']['tl_iso_gallery']['lightbox_template'][0] . '<span class="mandatory">*</span></th> </tr> </thead> <tbody>'; foreach ($this->objGaleries as $objGallery) { $objSelect = new \SelectMenu(\Widget::getAttributesFromDca(array('options' => array_merge(\Controller::getTemplateGroup('moo_'), \Controller::getTemplateGroup('j_')), 'eval' => array('includeBlankOption' => true, 'mandatory' => true)), 'gallery[' . $objGallery->id . ']')); if (\Input::post('FORM_SUBMIT') == 'tl_iso_upgrade_20010000') { $objSelect->validate(); if (!$objSelect->hasErrors()) { $objGallery->lightbox_template = serialize(array($objSelect->value)); $objGallery->save(); } } $strBuffer .= ' <tr> <td>' . $objGallery->name . '</td> <td>' . $objSelect->generateWithError() . '</td> </tr>'; } $strBuffer .= ' </tbody> </table>'; $this->Template->formSubmit = 'tl_iso_upgrade_20010000'; $this->Template->fields = $strBuffer; $this->Template->matter = $GLOBALS['TL_LANG']['UPG']['20010000']; if (\Input::post('FORM_SUBMIT') == 'tl_iso_upgrade_20010000') { \Controller::reload(); } }
/** * Return the progress widget as object * @param mixed * @return Widget */ protected function getProgressWidget($value=null) { $widget = new SelectMenu(); $widget->id = 'progress'; $widget->name = 'progress'; $widget->mandatory = true; $widget->value = $value; $widget->label = $GLOBALS['TL_LANG']['tl_task']['progress'][0]; if ($GLOBALS['TL_CONFIG']['showHelp'] && $GLOBALS['TL_LANG']['tl_task']['progress'][1] != '') { $widget->help = $GLOBALS['TL_LANG']['tl_task']['progress'][1]; } $arrOptions = array(); $arrProgress = array(0,10,20,30,40,50,60,70,80,90,100); // Get all active users foreach ($arrProgress as $v) { $arrOptions[] = array('value'=>$v, 'label'=>$v . '%'); } $widget->options = $arrOptions; // Valiate input if ($this->Input->post('FORM_SUBMIT') == 'tl_tasks') { $widget->validate(); if ($widget->hasErrors()) { $this->blnSave = false; } } return $widget; }
/** * {@inheritdoc} */ public function handle(\Input $input) { /** @var RootPackage $rootPackage */ $rootPackage = $this->composer->getPackage(); /** @var Config $config */ $config = $this->composer->getConfig(); $minimumStability = new \SelectMenu(array('id' => 'minimum-stability', 'name' => 'minimum-stability', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_minimum_stability'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_minimum_stability'][1], 'options' => array(array('value' => 'stable', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_stable']), array('value' => 'RC', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_rc']), array('value' => 'beta', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_beta']), array('value' => 'alpha', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_alpha']), array('value' => 'dev', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_dev'])), 'value' => $rootPackage->getMinimumStability(), 'class' => 'minimum-stability', 'required' => true)); $preferStable = new \CheckBox(array('id' => 'prefer-stable', 'name' => 'prefer-stable', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][1], 'options' => array(array('value' => '1', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][0])), 'value' => $rootPackage->getPreferStable(), 'class' => 'prefer-stable', 'required' => true)); $preferredInstall = new \SelectMenu(array('id' => 'preferred-install', 'name' => 'preferred-install', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_preferred_install'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_preferred_install'][1], 'options' => array(array('value' => 'source', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_source']), array('value' => 'dist', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_dist']), array('value' => 'auto', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_auto'])), 'value' => $config->get('preferred-install'), 'class' => 'preferred-install', 'required' => true)); $configGithubOauth = $config->get('github-oauth'); $githubOauth = new \TextField(array('id' => 'github-oauth', 'name' => 'github-oauth', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_github_oauth'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_github_oauth'][1], 'value' => $configGithubOauth['github.com'], 'class' => 'github-oauth')); $discardChanges = new \SelectMenu(array('id' => 'discard-changes', 'name' => 'discard-changes', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_discard_changes'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_discard_changes'][1], 'options' => array(array('value' => '', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_no']), array('value' => '1', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_yes']), array('value' => 'stash', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_stash'])), 'value' => (string) $config->get('discard-changes'), 'class' => 'github-oauth')); if ($input->post('FORM_SUBMIT') == 'tl_composer_settings') { $doSave = false; $json = new JsonFile(TL_ROOT . '/' . $this->configPathname); $config = $json->read(); $minimumStability->validate(); $preferStable->validate(); $preferredInstall->validate(); $githubOauth->validate(); $discardChanges->validate(); if (!$minimumStability->hasErrors()) { $config['minimum-stability'] = $minimumStability->value; $doSave = true; } if (!$preferStable->hasErrors()) { $config['prefer-stable'] = (bool) $preferStable->value; $doSave = true; } if (!$preferredInstall->hasErrors()) { $config['config']['preferred-install'] = $preferredInstall->value; $doSave = true; } if (!$githubOauth->hasErrors()) { if ($githubOauth->value) { $config['config']['github-oauth']['github.com'] = $githubOauth->value; } else { unset($config['config']['github-oauth']['github.com']); if (empty($config['config']['github-oauth'])) { unset($config['config']['github-oauth']); } } $doSave = true; } if (!$discardChanges->hasErrors()) { if ($discardChanges->value) { $config['config']['discard-changes'] = $discardChanges->value == 'stash' ? 'stash' : (bool) $discardChanges->value; } else { unset($config['config']['discard-changes']); } $doSave = true; } if ($doSave) { // make a backup copy(TL_ROOT . '/' . $this->configPathname, TL_ROOT . '/' . $this->configPathname . '~'); // update config file $json->write($config); } $this->redirect('contao/main.php?do=composer&settings=dialog'); } $template = new \BackendTemplate('be_composer_client_settings'); $template->composer = $this->composer; $template->minimumStability = $minimumStability; $template->preferStable = $preferStable; $template->preferredInstall = $preferredInstall; $template->githubOauth = $githubOauth; $template->discardChanges = $discardChanges; return $template->parse(); }