Ejemplo n.º 1
0
 /**
  * Class constructor
  *
  */
 public function __construct()
 {
     parent::__construct('configSaveForm');
     $language = OW::getLanguage();
     $configs = OW::getConfig()->getValues('googlelocation');
     $element = new TextField('api_key');
     $element->setValue($configs['api_key']);
     $validator = new StringValidator(0, 40);
     $validator->setErrorMessage($language->text('googlelocation', 'api_key_too_long'));
     $element->addValidator($validator);
     $this->addElement($element);
     $options = array(GOOGLELOCATION_BOL_LocationService::DISTANCE_UNITS_MILES => $language->text('googlelocation', 'miles'), GOOGLELOCATION_BOL_LocationService::DISTANCE_UNITS_KM => $language->text('googlelocation', 'kms'));
     $distanseUnits = new Selectbox('distanse_units');
     $distanseUnits->setOptions($options);
     $distanseUnits->setValue(GOOGLELOCATION_BOL_LocationService::getInstance()->getDistanseUnits());
     $distanseUnits->setHasInvitation(false);
     $this->addElement($distanseUnits);
     $restrictions = new Selectbox('country_restriction');
     $restrictions->setValue(!empty($configs['country_restriction']) ? $configs['country_restriction'] : null);
     $restrictions->setOptions($this->countryList);
     $restrictions->setInvitation(OW::getLanguage()->text('googlelocation', 'no_country_restriction'));
     $this->addElement($restrictions);
     $autofill = OW::getConfig()->getValue('googlelocation', 'auto_fill_location_on_search');
     $autoFillLocationOnSearch = new CheckboxField('auto_fill_location_on_search');
     $autoFillLocationOnSearch->setValue(empty($autofill) || $autofill == '0' ? false : $autofill);
     $this->addElement($autoFillLocationOnSearch);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('base', 'edit_button'));
     $this->addElement($submit);
 }
Ejemplo n.º 2
0
 public function __construct($configs, $features)
 {
     parent::__construct('MCOMPOSE_ConfigForm');
     $this->configs = $configs;
     $language = OW::getLanguage();
     $field = new TextField('max_users');
     $field->setRequired();
     $field->setValue($configs['max_users']);
     $this->addElement($field);
     if ($features["friends"]) {
         $field = new CheckboxField('friends_enabled');
         $field->setValue($configs['friends_enabled']);
         $this->addElement($field);
     }
     if ($features["groups"]) {
         $field = new CheckboxField('groups_enabled');
         $field->setValue($configs['groups_enabled']);
         $this->addElement($field);
     }
     if ($features["events"]) {
         $field = new CheckboxField('events_enabled');
         $field->setValue($configs['events_enabled']);
         $this->addElement($field);
     }
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('mcompose', 'admin_save_btn'));
     $this->addElement($submit);
 }
Ejemplo n.º 3
0
 /**
  * Class constructor
  *
  */
 public function __construct($plugins)
 {
     parent::__construct('configForm');
     $language = OW::getLanguage();
     $values = OW::getConfig()->getValues('attachments');
     if ($plugins['video']) {
         $field = new CheckboxField('video_share');
         $field->setValue($values['video_share']);
         $this->addElement($field);
     }
     if ($plugins['links']) {
         $field = new CheckboxField('link_share');
         $field->setValue($values['link_share']);
         $this->addElement($field);
     }
     if ($plugins['photo']) {
         $field = new CheckboxField('photo_share');
         $field->setId('photo_share_check');
         $field->setValue($values['photo_share']);
         $this->addElement($field);
         $field = new TextField('photo_album_name');
         $field->setValue(OW::getLanguage()->text('attachments', 'default_photo_album_name'));
         $field->setRequired();
         $this->addElement($field);
     }
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('attachments', 'config_save_label'));
     $this->addElement($submit);
 }
Ejemplo n.º 4
0
 /**
  * Class constructor
  *
  */
 public function __construct()
 {
     parent::__construct('configSaveForm');
     $language = OW::getLanguage();
     $field = new TextField('public_key');
     $field->addValidator(new ConfigRequireValidator());
     $this->addElement($field);
     $field = new CheckboxField('billing_enabled');
     $this->addElement($field);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'save_btn_label'));
     $this->addElement($submit);
     $promoUrl = new TextField('app_url');
     $promoUrl->setRequired();
     $promoUrl->addValidator(new UrlValidator());
     $promoUrl->setLabel($language->text('skandroid', 'app_url_label'));
     $promoUrl->setDescription($language->text('skandroid', 'app_url_desc'));
     $promoUrl->setValue(OW::getConfig()->getValue('skandroid', 'app_url'));
     $this->addElement($promoUrl);
     $smartBanner = new CheckboxField('smart_banner');
     $smartBanner->setLabel($language->text('skandroid', 'smart_banner_label'));
     $smartBanner->setDescription($language->text('skandroid', 'smart_banner_desc'));
     $smartBanner->setValue(OW::getConfig()->getValue('skandroid', 'smart_banner'));
     $this->addElement($smartBanner);
 }
 /**
  * @param IRSVP $rsvp
  * @param IRSVPQuestionTemplate $question
  * @param IRSVPAnswer $answer
  * @return FormField
  */
 public function build(IRSVP $rsvp, IRSVPQuestionTemplate $question, IRSVPAnswer $answer)
 {
     $field = new CheckboxField($question->name(), $question->label());
     $field->setValue($question->initialValue());
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     $field->setFieldHolderTemplate('RSVPCheckboxField_holder');
     return $field;
 }
 function __construct($controller, $name)
 {
     $fields = new FieldList(array($t1 = new TextField('ExternalOrderId', 'Eventbrite Order #'), $checkbox = new CheckboxField('SharedContactInfo', 'Allow to share contact info?')));
     $t1->setAttribute('placeholder', 'Enter your Eventbrite order #');
     $t1->addExtraClass('event-brite-order-number');
     $attendees = Session::get('attendees');
     if (count($attendees) > 0) {
         $t1->setValue(Session::get('ExternalOrderId'));
         $t1->setReadonly(true);
         $checkbox->setValue(intval(Session::get('SharedContactInfo')) === 1);
         $fields->add(new LiteralField('ctrl1', 'Current Order has following registered attendees, please select one:'));
         $options = array();
         foreach ($attendees as $attendee) {
             $ticket_external_id = intval($attendee['ticket_class_id']);
             $ticket_type = SummitTicketType::get()->filter('ExternalId', $ticket_external_id)->first();
             if (is_null($ticket_type)) {
                 continue;
             }
             $options[$attendee['id']] = $attendee['profile']['name'] . ' (' . $ticket_type->Name . ')';
         }
         $attendees_ctrl = new OptionSetField('SelectedAttendee', '', $options);
         $fields->add($attendees_ctrl);
         $validator = new RequiredFields(array('ExternalOrderId'));
         // Create action
         $actions = new FieldList($btn_clear = new FormAction('clearSummitAttendeeInfo', 'Clear'), $btn = new FormAction('saveSummitAttendeeInfo', 'Done'));
         $btn->addExtraClass('btn btn-default active');
         $btn_clear->addExtraClass('btn btn-danger active');
     } else {
         $validator = new RequiredFields(array('ExternalOrderId'));
         // Create action
         $actions = new FieldList($btn = new FormAction('saveSummitAttendeeInfo', 'Get Order'));
         $btn->addExtraClass('btn btn-default active');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 /**
  * @param ISurveyStep $current_step
  * @param ISurveyQuestionTemplate $question
  * @param ISurveyAnswer $answer
  * @return FormField
  */
 public function build(ISurveyStep $current_step, ISurveyQuestionTemplate $question, ISurveyAnswer $answer)
 {
     $field = new CheckboxField($question->name(), $question->label());
     $field->setValue($question->initialValue());
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     $this->buildDependantRules($current_step, $question, $field);
     return $field;
 }
Ejemplo n.º 8
0
 /**
  * Class constructor
  *
  */
 public function __construct($plugins)
 {
     parent::__construct('configForm');
     $language = OW::getLanguage();
     $values = OW::getConfig()->getValues('uheader');
     if ($plugins['photo']) {
         $field = new CheckboxField('photo_share');
         $field->setId('photo_share_check');
         $field->setValue($values['photo_share']);
         $this->addElement($field);
         $field = new TextField('photo_album_name');
         $field->setValue(OW::getLanguage()->text('uheader', 'default_photo_album_name'));
         $field->setRequired();
         $this->addElement($field);
     }
     $field = new TextField('cover_height');
     $field->setValue($values['cover_height']);
     $field->addValidator(new IntValidator(self::COVER_MIN_HEIGHT, self::COVER_MAX_HEIGHT));
     $field->setRequired();
     $this->addElement($field);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('uheader', 'config_save_label'));
     $this->addElement($submit);
 }
Ejemplo n.º 9
0
 /**
  * Class constructor
  *
  */
 public function __construct($configs)
 {
     parent::__construct('configSaveForm');
     $language = OW::getLanguage();
     $field = new RadioField('itunes_mode');
     $field->setOptions(array("test" => $language->text("skadateios", "itunes_mode_test"), "live" => $language->text("skadateios", "itunes_mode_live")));
     $field->setValue($configs["itunes_mode"]);
     $this->addElement($field);
     $field = new CheckboxField('billing_enabled');
     $field->setValue($configs["billing_enabled"]);
     $this->addElement($field);
     $field = new TextField('itunes_secret');
     $field->addValidator(new ConfigRequireValidator());
     $field->setValue($configs["itunes_secret"]);
     $this->addElement($field);
     $promoUrl = new TextField('app_url');
     $promoUrl->setRequired();
     $promoUrl->addValidator(new UrlValidator());
     $promoUrl->setLabel($language->text('skadateios', 'app_url_label'));
     $promoUrl->setDescription($language->text('skadateios', 'app_url_desc'));
     $promoUrl->setValue($configs['app_url']);
     $this->addElement($promoUrl);
     $smartBanner = new CheckboxField('smart_banner');
     $smartBanner->setLabel($language->text('skadateios', 'smart_banner_label'));
     $smartBanner->setDescription($language->text('skadateios', 'smart_banner_desc'));
     $smartBanner->setValue($configs['smart_banner']);
     $this->addElement($smartBanner);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'save_btn_label'));
     $this->addElement($submit);
 }
Ejemplo n.º 10
0
 /**
  * Constructor.
  */
 public function __construct($ajax = false)
 {
     parent::__construct();
     $form = new Form('sign-in');
     $form->setAction("");
     $username = new TextField('identity');
     $username->setRequired(true);
     $username->setHasInvitation(true);
     $username->setInvitation(OW::getLanguage()->text('base', 'component_sign_in_login_invitation'));
     $form->addElement($username);
     $password = new PasswordField('password');
     $password->setHasInvitation(true);
     $password->setInvitation('password');
     $password->setRequired(true);
     $form->addElement($password);
     $remeberMe = new CheckboxField('remember');
     $remeberMe->setValue(true);
     $remeberMe->setLabel(OW::getLanguage()->text('base', 'sign_in_remember_me_label'));
     $form->addElement($remeberMe);
     $submit = new Submit('submit');
     $submit->setValue(OW::getLanguage()->text('base', 'sign_in_submit_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if ($ajax) {
         $form->setAjaxResetOnSuccess(false);
         $form->setAjax();
         $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_User', 'ajaxSignIn'));
         $form->bindJsFunction(Form::BIND_SUCCESS, 'function(data){if( data.result ){if(data.message){OW.info(data.message);}setTimeout(function(){window.location.reload();}, 1000);}else{OW.error(data.message);}}');
         $this->assign('forgot_url', OW::getRouter()->urlForRoute('base_forgot_password'));
     }
     $this->assign('joinUrl', OW::getRouter()->urlForRoute('base_join'));
 }
Ejemplo n.º 11
0
 public function settings()
 {
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     $contentMenu = new BASE_CMP_PreferenceContentMenu();
     $contentMenu->getElement('email_notifications')->setActive(true);
     $this->addComponent('contentMenu', $contentMenu);
     OW::getDocument()->setHeading(OW::getLanguage()->text('notifications', 'setup_page_heading'));
     OW::getDocument()->setHeadingIconClass('ow_ic_mail');
     OW::getDocument()->setTitle(OW::getLanguage()->text('notifications', 'setup_page_title'));
     $actions = $this->service->collectActionList();
     $settings = $this->service->findRuleList($this->userId);
     $form = new NOTIFICATIONS_SettingForm();
     $this->addForm($form);
     $processActions = array();
     foreach ($actions as $action) {
         $field = new CheckboxField($action['action']);
         $field->setValue(!empty($action['selected']));
         if (isset($settings[$action['action']])) {
             $field->setValue((bool) $settings[$action['action']]->checked);
         }
         $form->addElement($field);
         $processActions[] = $action['action'];
     }
     if (OW::getRequest()->isPost()) {
         $result = $form->process($_POST, $processActions, $settings);
         if ($result) {
             OW::getFeedback()->info(OW::getLanguage()->text('notifications', 'settings_changed'));
         } else {
             OW::getFeedback()->warning(OW::getLanguage()->text('notifications', 'settings_not_changed'));
         }
         $this->redirect();
     }
     $tplActions = array();
     foreach ($actions as $action) {
         if (empty($tplActions[$action['section']])) {
             $tplActions[$action['section']] = array('label' => $action['sectionLabel'], 'icon' => empty($action['sectionIcon']) ? '' : $action['sectionIcon'], 'actions' => array());
         }
         $tplActions[$action['section']]['actions'][$action['action']] = $action;
     }
     $this->assign('actions', $tplActions);
 }
Ejemplo n.º 12
0
 /**
  * (non-PHPdoc)
  * @see framework/forms/FormField#Field()
  */
 function Field($properties = array())
 {
     if ($this->isReadonly()) {
         $nullableCheckbox = new CheckboxField_Readonly($this->getIsNullId());
     } else {
         $nullableCheckbox = new CheckboxField($this->getIsNullId());
     }
     $nullableCheckbox->setValue(is_null($this->dataValue()));
     return $this->valueField->Field() . ' ' . $nullableCheckbox->Field() . '&nbsp;<span>' . $this->getIsNullLabel() . '</span>';
 }
Ejemplo n.º 13
0
 function testFieldValueSettingFalse()
 {
     /* Create the field, and set the value as NULL */
     $field = new CheckboxField('IsChecked', 'Checked');
     $field->setValue(false);
     /* dataValue() for the field is 0 */
     $this->assertEquals($field->dataValue(), 0, 'dataValue() returns a 0');
     /* Value() returns 0 as well */
     $this->assertEquals($field->Value(), 0, 'Value() returns a 0');
 }
Ejemplo n.º 14
0
 public function __construct()
 {
     parent::__construct('EQUESTIONS_SetupForm');
     $language = OW::getLanguage();
     $field = new CheckboxField('copyData');
     $field->setValue(true);
     $field->setLabel($language->text('equestions', 'admin_setup_copy_data_label'));
     $this->addElement($field);
     $button = new Submit('upgrade');
     $button->setValue($language->text('equestions', 'admin_setup_upgrade_label'));
     $this->addElement($button);
 }
 function __construct($controller, $name)
 {
     $current_user = Member::currentUser();
     $fields = new FieldList($this->first_name_field = new TextField('FirstName', 'First name / Given name', $current_user->FirstName), $this->last_name_field = new TextField('Surname', 'Last name / Family name', $current_user->Surname), $os_activity = new CustomCheckboxSetField('OpenStackActivity', 'Which of the following do you yourself personally do?<BR>Select All That Apply', DeploymentSurveyOptions::$activities_options), $os_relationship = new TextAreaField('OpenStackRelationship', 'Please describe your relationship with OpenStack'), $this->email_field = new TextField('Email', 'Your Email', $current_user->Email), $ok_2_contact = new CheckboxField('OkToContact', 'The OpenStack Foundation and User Committee may communicate with me in the future about my usage.'));
     $os_relationship->addExtraClass('hidden');
     $os_relationship->setColumns(30);
     $ok_2_contact->setValue(0);
     $this->email_field->setDisabled(true);
     $nextButton = new FormAction('NextStep', '  Next Step  ');
     $actions = new FieldList($nextButton);
     $validator = new RequiredFields();
     Requirements::javascript('surveys/js/deployment_survey_aboutyou_form.js');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
Ejemplo n.º 16
0
 public function __construct($configs)
 {
     parent::__construct('EQUESTIONS_ConfigSaveForm');
     $this->configs = $configs;
     $language = OW::getLanguage();
     $field = new CheckboxField('allow_comments');
     $field->setLabel($language->text('equestions', 'admin_allow_comments_label'));
     $field->setValue($configs['allow_comments']);
     $this->addElement($field);
     $field = new CheckboxField('ask_friends');
     $field->setLabel($language->text('equestions', 'admin_enable_ask_friends_label'));
     $field->setValue($configs['ask_friends']);
     $this->addElement($field);
     $field = new Selectbox('list_order');
     foreach (array(EQUESTIONS_CMP_Feed::ORDER_LATEST, EQUESTIONS_CMP_Feed::ORDER_POPULAR) as $v) {
         $field->addOption($v, $language->text('equestions', 'feed_order_' . $v));
     }
     $field->setHasInvitation(false);
     $field->setLabel($language->text('equestions', 'admin_list_order_label'));
     $field->setValue($configs['list_order']);
     $this->addElement($field);
     $field = new CheckboxField('enable_follow');
     $field->setLabel($language->text('equestions', 'admin_enable_follow_label'));
     $field->setValue($configs['enable_follow']);
     $this->addElement($field);
     $field = new CheckboxField('allow_popups');
     $field->setLabel($language->text('equestions', 'admin_allow_popups_label'));
     $field->setValue($configs['allow_popups']);
     $this->addElement($field);
     $field = new CheckboxField('attachments');
     $field->setLabel($language->text('equestions', 'admin_enable_attachments_label'));
     $field->setValue($configs['attachments']);
     $this->addElement($field);
     $field = new CheckboxField('attachments_video');
     $field->setLabel($language->text('equestions', 'admin_attachments_video_enable_label'));
     $field->setValue($configs['attachments_video']);
     $this->addElement($field);
     $field = new CheckboxField('attachments_image');
     $field->setLabel($language->text('equestions', 'admin_attachments_image_enable_label'));
     $field->setValue($configs['attachments_image']);
     $this->addElement($field);
     $field = new CheckboxField('attachments_link');
     $field->setLabel($language->text('equestions', 'admin_attachments_link_enable_label'));
     $field->setValue($configs['attachments_link']);
     $this->addElement($field);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('equestions', 'admin_save_btn'));
     $this->addElement($submit);
 }
Ejemplo n.º 17
0
 /**
  * Constructor.
  * 
  * @param array $itemsList
  */
 public function __construct($langId)
 {
     parent::__construct();
     $this->service = BOL_LanguageService::getInstance();
     if (empty($langId)) {
         $this->setVisible(false);
         return;
     }
     $languageDto = $this->service->findById($langId);
     if ($languageDto === null) {
         $this->setVisible(false);
         return;
     }
     $language = OW::getLanguage();
     $form = new Form('lang_edit');
     $form->setAjax();
     $form->setAction(OW::getRouter()->urlFor('ADMIN_CTRL_Languages', 'langEditFormResponder'));
     $form->setAjaxResetOnSuccess(false);
     $labelTextField = new TextField('label');
     $labelTextField->setLabel($language->text('admin', 'clone_form_lbl_label'));
     $labelTextField->setDescription($language->text('admin', 'clone_form_descr_label'));
     $labelTextField->setRequired();
     $labelTextField->setValue($languageDto->getLabel());
     $form->addElement($labelTextField);
     $tagTextField = new TextField('tag');
     $tagTextField->setLabel($language->text('admin', 'clone_form_lbl_tag'));
     $tagTextField->setDescription($language->text('admin', 'clone_form_descr_tag'));
     $tagTextField->setRequired();
     $tagTextField->setValue($languageDto->getTag());
     if ($languageDto->getTag() == 'en') {
         $tagTextField->addAttribute('disabled', 'disabled');
     }
     $form->addElement($tagTextField);
     $rtl = new CheckboxField('rtl');
     $rtl->setLabel($language->text('admin', 'lang_edit_form_rtl_label'));
     $rtl->setDescription($language->text('admin', 'lang_edit_form_rtl_desc'));
     $rtl->setValue((bool) $languageDto->getRtl());
     $form->addElement($rtl);
     $hiddenField = new HiddenField('langId');
     $hiddenField->setValue($languageDto->getId());
     $form->addElement($hiddenField);
     $submit = new Submit('submit');
     $submit->setValue($language->text('admin', 'btn_label_edit'));
     $form->addElement($submit);
     $form->bindJsFunction(Form::BIND_SUCCESS, "function(data){if(data.result){OW.info(data.message);setTimeout(function(){window.location.reload();}, 1000);}else{OW.error(data.message);}}");
     $this->addForm($form);
 }
Ejemplo n.º 18
0
 public function index(array $params = array())
 {
     $config = OW::getConfig();
     $configs = $config->getValues('antibruteforce');
     $form = new Form('settings');
     $form->setAjax();
     $form->setAjaxResetOnSuccess(false);
     $form->setAction(OW::getRouter()->urlForRoute('antibruteforce.admin'));
     $form->bindJsFunction(Form::BIND_SUCCESS, 'function(data){if(data.result){OW.info("Settings successfuly saved");}else{OW.error("Parser error");}}');
     $auth = new CheckboxField('auth');
     $auth->setValue($configs['authentication']);
     $form->addElement($auth);
     $reg = new CheckboxField('reg');
     $reg->setValue($configs['registration']);
     $form->addElement($reg);
     $tryCount = new TextField('tryCount');
     $tryCount->setRequired();
     $tryCount->addValidator(new IntValidator(1));
     $tryCount->setValue($configs['try_count']);
     $form->addElement($tryCount);
     $expTime = new TextField('expTime');
     $expTime->setRequired();
     $expTime->setValue($configs['expire_time']);
     $expTime->addValidator(new IntValidator(1));
     $form->addElement($expTime);
     $title = new TextField('title');
     $title->setRequired();
     $title->setValue($configs['lock_title']);
     $form->addElement($title);
     $desc = new Textarea('desc');
     $desc->setValue($configs['lock_desc']);
     $form->addElement($desc);
     $submit = new Submit('save');
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isAjax()) {
         if ($form->isValid($_POST)) {
             $config->saveConfig('antibruteforce', 'authentication', $form->getElement('auth')->getValue());
             $config->saveConfig('antibruteforce', 'registration', $form->getElement('reg')->getValue());
             $config->saveConfig('antibruteforce', 'try_count', $form->getElement('tryCount')->getValue());
             $config->saveConfig('antibruteforce', 'expire_time', $form->getElement('expTime')->getValue());
             $config->saveConfig('antibruteforce', 'lock_title', strip_tags($form->getElement('title')->getValue()));
             $config->saveConfig('antibruteforce', 'lock_desc', strip_tags($form->getElement('desc')->getValue()));
             exit(json_encode(array('result' => true)));
         }
     }
 }
Ejemplo n.º 19
0
 public function __construct()
 {
     parent::__construct('paypal-config-form');
     $language = OW::getLanguage();
     $billingService = BOL_BillingService::getInstance();
     $gwKey = BILLINGPAYPAL_CLASS_PaypalAdapter::GATEWAY_KEY;
     $business = new TextField('business');
     $business->setValue($billingService->getGatewayConfigValue($gwKey, 'business'));
     $this->addElement($business);
     $sandboxMode = new CheckboxField('sandboxMode');
     $sandboxMode->setValue($billingService->getGatewayConfigValue($gwKey, 'sandboxMode'));
     $this->addElement($sandboxMode);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('billingpaypal', 'btn_save'));
     $this->addElement($submit);
 }
Ejemplo n.º 20
0
 public function index()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $adminForm = new Form('adminForm');
     $element = new Selectbox('actionMember');
     $element->setLabel($language->text('grouprss', 'action_member_label'));
     $element->setDescription($language->text('grouprss', 'action_member_desc'));
     $element->setValue($config->getValue('grouprss', 'actionMember'));
     $element->setRequired();
     $element->addOption('admin', $language->text('grouprss', 'site_admin'));
     $element->addOption('owner', $language->text('grouprss', 'group_owner'));
     $element->addOption('both', $language->text('grouprss', 'both_admin_owner'));
     $adminForm->addElement($element);
     $element = new Selectbox('postLocation');
     $element->setLabel($language->text('grouprss', 'post_location_label'));
     $element->setDescription($language->text('grouprss', 'post_location_desc'));
     $element->setValue($config->getValue('grouprss', 'postLocation'));
     $element->setRequired();
     $element->addOption('wall', $language->text('grouprss', 'wall_location'));
     $element->addOption('newsfeed', $language->text('grouprss', 'newsfeed_location'));
     $adminForm->addElement($element);
     $element = new CheckboxField('disablePosting');
     $element->setLabel($language->text('grouprss', 'disable_posting_label'));
     $element->setDescription($language->text('grouprss', 'disable_posting_desc'));
     $element->setValue($config->getValue('grouprss', 'disablePosting'));
     $adminForm->addElement($element);
     $element = new Submit('saveSettings');
     $element->setValue(OW::getLanguage()->text('grouprss', 'admin_save_settings'));
     $adminForm->addElement($element);
     if (OW::getRequest()->isPost()) {
         if ($adminForm->isValid($_POST)) {
             $values = $adminForm->getValues();
             $config->saveConfig('grouprss', 'actionMember', $values['actionMember']);
             $config->saveConfig('grouprss', 'postLocation', $values['postLocation']);
             $config->saveConfig('grouprss', 'disablePosting', $values['disablePosting']);
             GROUPRSS_BOL_FeedService::getInstance()->addAllGroupFeed();
             //OW::getFeedback()->info($language->text('grouprss', 'user_save_success'));
         }
     }
     $this->addForm($adminForm);
 }
Ejemplo n.º 21
0
 public function index()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $adminForm = new Form('adminForm');
     $element = new TextField('logsPerPage');
     $element->setRequired(true);
     $element->setValue($config->getValue('credits', 'logsPerPage'));
     $element->setLabel($language->text('credits', 'logs_per_page'));
     $element->addValidator(new IntValidator(1));
     $adminForm->addElement($element);
     $element = new CheckboxField('enableEmail');
     $element->setLabel(OW::getLanguage()->text('credits', 'admin_enable_email'));
     $element->setDescription(OW::getLanguage()->text('credits', 'admin_enable_email_desc'));
     $element->setValue($config->getValue('credits', 'enableEmail'));
     $adminForm->addElement($element);
     $element = new CheckboxField('enablePM');
     $element->setLabel(OW::getLanguage()->text('credits', 'admin_enable_pm'));
     $element->setDescription(OW::getLanguage()->text('credits', 'admin_enable_pm_desc'));
     $element->setValue($config->getValue('credits', 'enablePM'));
     $adminForm->addElement($element);
     $element = new CheckboxField('enableNotification');
     $element->setLabel(OW::getLanguage()->text('credits', 'admin_enable_notification'));
     $element->setDescription(OW::getLanguage()->text('credits', 'admin_enable_notification_desc'));
     $element->setValue($config->getValue('credits', 'enableNotification'));
     $adminForm->addElement($element);
     $element = new Submit('saveSettings');
     $element->setValue(OW::getLanguage()->text('credits', 'admin_save_settings'));
     $adminForm->addElement($element);
     if (OW::getRequest()->isPost()) {
         if ($adminForm->isValid($_POST)) {
             $values = $adminForm->getValues();
             $config->saveConfig('credits', 'logsPerPage', $values['logsPerPage']);
             $config->saveConfig('credits', 'enableEmail', $values['enableEmail']);
             $config->saveConfig('credits', 'enablePM', $values['enablePM']);
             $config->saveConfig('credits', 'enableNotification', $values['enableNotification']);
             OW::getFeedback()->info($language->text('credits', 'save_sucess_msg'));
         }
     }
     $this->addForm($adminForm);
 }
Ejemplo n.º 22
0
 /**
  * Class constructor
  *
  */
 public function __construct()
 {
     parent::__construct('configForm');
     $language = OW::getLanguage();
     $values = OW::getConfig()->getValues('utags');
     $field = new CheckboxField('copy_photo');
     $field->setId('copy_photo_check');
     $field->setValue($values['copy_photo']);
     $this->addElement($field);
     $field = new TextField('photo_album_name');
     $field->setValue(OW::getLanguage()->text('utags', 'default_photo_album_name'));
     $field->setRequired();
     $this->addElement($field);
     $field = new CheckboxField('crop_photo');
     $field->setValue($values['crop_photo']);
     $this->addElement($field);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('utags', 'config_save_label'));
     $this->addElement($submit);
 }
Ejemplo n.º 23
0
 public function __construct()
 {
     parent::__construct('moneybookers-config-form');
     $language = OW::getLanguage();
     $billingService = BOL_BillingService::getInstance();
     $gwKey = OCSBILLINGMONEYBOOKERS_CLASS_MoneybookersAdapter::GATEWAY_KEY;
     $merchantId = new TextField('merchantId');
     $merchantId->setValue($billingService->getGatewayConfigValue($gwKey, 'merchantId'));
     $merchantId->setRequired(true);
     $merchantId->setLabel($language->text('ocsbillingmoneybookers', 'merchant_id'));
     $this->addElement($merchantId);
     $merchantEmail = new TextField('merchantEmail');
     $merchantEmail->setValue($billingService->getGatewayConfigValue($gwKey, 'merchantEmail'));
     $merchantEmail->setRequired(true);
     $merchantEmail->setLabel($language->text('ocsbillingmoneybookers', 'merchant_email'));
     $this->addElement($merchantEmail);
     $secret = new TextField('secret');
     $secret->setValue($billingService->getGatewayConfigValue($gwKey, 'secret'));
     $secret->setRequired(true);
     $secret->setLabel($language->text('ocsbillingmoneybookers', 'secret'));
     $this->addElement($secret);
     $sandboxMode = new CheckboxField('sandboxMode');
     $sandboxMode->setValue($billingService->getGatewayConfigValue($gwKey, 'sandboxMode'));
     $sandboxMode->setLabel($language->text('ocsbillingmoneybookers', 'sandbox_mode'));
     $this->addElement($sandboxMode);
     $desc = new TextField('recipientDescription');
     $desc->setValue($billingService->getGatewayConfigValue($gwKey, 'recipientDescription'));
     $desc->setLabel($language->text('ocsbillingmoneybookers', 'recipient_description'));
     $this->addElement($desc);
     $lang = new Selectbox('language');
     $lang->setLabel($language->text('ocsbillingmoneybookers', 'language'));
     $lang->addOptions(array('EN' => 'EN', 'DE' => 'DE', 'ES' => 'ES', 'FR' => 'FR', 'IT' => 'IT', 'PL' => 'PL', 'GR' => 'GR', 'RO' => 'PO', 'RU' => 'RU', 'TR' => 'TR', 'CN' => 'CN', 'CZ' => 'CZ', 'NL' => 'NL', 'DA' => 'DA', 'SV' => 'SV', 'FI' => 'FI'));
     $lang->setRequired(true);
     $lang->setValue($billingService->getGatewayConfigValue($gwKey, 'language'));
     $this->addElement($lang);
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('ocsbillingmoneybookers', 'btn_save'));
     $this->addElement($submit);
 }
Ejemplo n.º 24
0
 /**
  * @param integer $userId
  */
 public function __construct($userId)
 {
     parent::__construct();
     $user = BOL_UserService::getInstance()->findUserById((int) $userId);
     if (!OW::getUser()->isAuthorized('base') || $user === null) {
         $this->setVisible(false);
         return;
     }
     $aService = BOL_AuthorizationService::getInstance();
     $roleList = $aService->findNonGuestRoleList();
     $form = new Form('give-role');
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_User', 'updateUserRoles'));
     $hidden = new HiddenField('userId');
     $form->addElement($hidden->setValue($userId));
     $userRoles = $aService->findUserRoleList($user->getId());
     $userRolesIdList = array();
     foreach ($userRoles as $role) {
         $userRolesIdList[] = $role->getId();
     }
     $tplRoleList = array();
     /* @var $role BOL_AuthorizationRole */
     foreach ($roleList as $role) {
         $field = new CheckboxField('roles[' . $role->getId() . ']');
         $field->setLabel(OW::getLanguage()->text('base', 'authorization_role_' . $role->getName()));
         $field->setValue(in_array($role->getId(), $userRolesIdList));
         if (in_array($role->getId(), $userRolesIdList) && $role->getSortOrder() == 1) {
             $field->addAttribute('disabled', 'disabled');
         }
         $form->addElement($field);
         $tplRoleList[$role->sortOrder] = $role;
     }
     ksort($tplRoleList);
     $form->addElement(new Submit('submit'));
     OW::getDocument()->addOnloadScript("owForms['{$form->getName()}'].bind('success', function(data){\n                if( data.result ){\n                    if( data.result == 'success' ){\n                         window.baseChangeUserRoleFB.close();\n                         window.location.reload();\n                         //OW.info(data.message);\n                    }\n                    else if( data.result == 'error'){\n                        OW.error(data.message);\n                    }\n                }\n\t\t})");
     $this->addForm($form);
     $this->assign('list', $tplRoleList);
 }
Ejemplo n.º 25
0
 public function photoCollectExtendedSettings(BASE_CLASS_EventCollector $event)
 {
     $input = new CheckboxField('matching_only');
     $input->setLabel(OW::getLanguage()->text('skadate', 'photo_setting_matching_label'));
     $input->setDescription(OW::getLanguage()->text('skadate', 'photo_setting_matching_desc'));
     $input->setValue((bool) OW::getConfig()->getValue('skadate', 'photo_filter_setting_matching'));
     $event->add(array('section' => 'filter_settings', 'section_lang' => 'skadate+photo_filter_section_label', 'settings' => array('matching_only' => $input)));
 }
Ejemplo n.º 26
0
 public function __construct($controller)
 {
     parent::__construct('QuickSearchForm');
     $this->questionService = BOL_QuestionService::getInstance();
     $this->searchService = USEARCH_BOL_Service::getInstance();
     $lang = OW::getLanguage();
     $this->setAjax(true);
     $this->setAction(OW::getRouter()->urlForRoute('usearch.quick_search_action'));
     $this->setAjaxResetOnSuccess(false);
     $questionNameList = $this->searchService->getQuickSerchQuestionNames();
     $questionValueList = $this->questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     $sessionData = OW::getSession()->get(self::FORM_SESSEION_VAR);
     if ($sessionData === null) {
         $sessionData = array();
         if (OW::getUser()->isAuthenticated()) {
             $data = BOL_QuestionService::getInstance()->getQuestionData(array(OW::getUser()->getId()), array('sex', 'match_sex'));
             if (!empty($data[OW::getUser()->getId()]['sex'])) {
                 $sessionData['sex'] = $data[OW::getUser()->getId()]['sex'];
             }
             if (!empty($data[OW::getUser()->getId()]['match_sex'])) {
                 for ($i = 0; $i < 31; $i++) {
                     if (pow(2, $i) & $data[OW::getUser()->getId()]['match_sex']) {
                         $sessionData['match_sex'] = pow(2, $i);
                         break;
                     }
                 }
             }
             $sessionData['googlemap_location']['distance'] = 50;
             OW::getSession()->set(self::FORM_SESSEION_VAR, $sessionData);
         }
     }
     if (!empty($sessionData['match_sex'])) {
         if (is_array($sessionData['match_sex'])) {
             $sessionData['match_sex'] = array_shift($sessionData['match_sex']);
         } else {
             for ($i = 0; $i < 31; $i++) {
                 if (pow(2, $i) & $sessionData['match_sex']) {
                     $sessionData['match_sex'] = pow(2, $i);
                     break;
                 }
             }
         }
     }
     /* ------------------------- */
     $questionDtoList = BOL_QuestionService::getInstance()->findQuestionByNameList($questionNameList);
     $questions = array();
     $questionList = array();
     $orderedQuestionList = array();
     /* @var $question BOL_Question */
     foreach ($questionDtoList as $key => $question) {
         $dataList = (array) $question;
         $questions[$question->name] = $dataList;
         $isRequired = in_array($question->name, array('googlemap_location', 'match_sex')) ? 1 : 0;
         $questions[$question->name]['required'] = $isRequired;
         if ($question->name == 'sex' || $question->name == 'match_sex') {
             unset($questions[$question->name]);
         } else {
             $questionList[$question->name] = $dataList;
         }
     }
     foreach ($questionNameList as $questionName) {
         if (!empty($questionDtoList[$questionName])) {
             $orderedQuestionList[] = $questionDtoList[$questionName];
         }
     }
     $controller->assign('displayGender', false);
     $accounts = $this->getAccountTypes();
     $this->addQuestions($questions, $questionValueList, array());
     $locationField = $this->getElement('googlemap_location');
     if ($locationField) {
         $value = $locationField->getValue();
         if (empty($value['distance'])) {
             $locationField->setDistance(50);
         }
     }
     if (count($accounts) > 1) {
         $this->displayAccountType = true;
         $controller->assign('displayGender', true);
         $sex = new Selectbox('sex');
         $sex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('sex'));
         $sex->setHasInvitation(false);
         $sex->setRequired();
         //$accountType->setHasInvitation(false);
         $this->setFieldOptions($sex, 'sex', $questionValueList['sex']);
         if (!empty($sessionData['sex'])) {
             $sex->setValue($sessionData['sex']);
         }
         $this->addElement($sex);
         $matchSex = new Selectbox('match_sex');
         $matchSex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('match_sex'));
         $matchSex->setRequired();
         $matchSex->setHasInvitation(false);
         //$accountType->setHasInvitation(false);
         $this->setFieldOptions($matchSex, 'match_sex', $questionValueList['sex']);
         if (!empty($sessionData['match_sex']) && !is_array($sessionData['match_sex'])) {
             $matchSex->setValue($sessionData['match_sex']);
         }
         $this->addElement($matchSex);
     }
     $controller->assign('questionList', $orderedQuestionList);
     $controller->assign('displayAccountType', $this->displayAccountType);
     // 'online' field
     $onlineField = new CheckboxField('online');
     if (is_array($sessionData) && array_key_exists('online', $sessionData)) {
         $onlineField->setValue((int) $sessionData['online']);
     }
     $onlineField->setLabel($lang->text('usearch', 'online_only'));
     $this->addElement($onlineField);
     //        if ( OW::getPluginManager()->isPluginActive('photo') )
     //        {
     // with photo
     $withPhoto = new CheckboxField('with_photo');
     if (is_array($sessionData) && array_key_exists('with_photo', $sessionData)) {
         $withPhoto->setValue((int) $sessionData['with_photo']);
     }
     $withPhoto->setLabel($lang->text('usearch', 'with_photo'));
     $this->addElement($withPhoto);
     //        }
     // submit
     $submit = new Submit('search');
     $submit->setValue(OW::getLanguage()->text('base', 'user_search_submit_button_label'));
     $this->addElement($submit);
     $this->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n            if ( data.result ) {\n                document.location.href = data.url;\n            }\n            else {\n                OW.warning(data.error);\n            }\n        }");
 }
Ejemplo n.º 27
0
 /**
  * Generates Add Topic Form.
  *
  * @param array $groupSelect
  * @param int $groupId
  * @return Form
  */
 private function generateForm($groupSelect, $groupId, $isHidden)
 {
     $form = new Form('add-topic-form');
     $form->setEnctype("multipart/form-data");
     $lang = OW::getLanguage();
     $title = new TextField('title');
     $title->setRequired(true);
     $sValidator = new StringValidator(1, 255);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 255)));
     $title->addValidator($sValidator);
     $form->addElement($title);
     if ($isHidden) {
         $group = new HiddenField('group');
         $group->setValue($groupId);
     } else {
         $group = new ForumSelectBox('group');
         $group->setOptions($groupSelect);
         if ($groupId) {
             $group->setValue($groupId);
         }
         $group->setRequired(true);
         $group->addValidator(new IntValidator());
     }
     $form->addElement($group);
     $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML);
     $text = new WysiwygTextarea('text', $btnSet);
     $text->setRequired(true);
     $sValidator = new StringValidator(1, 50000);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 50000)));
     $text->addValidator($sValidator);
     $form->addElement($text);
     $subscribe = new CheckboxField('subscribe');
     $subscribe->setLabel($lang->text('forum', 'subscribe'));
     $subscribe->setValue(true);
     $form->addElement($subscribe);
     $post = new Submit('post');
     $post->setValue($lang->text('forum', 'add_post_btn'));
     $form->addElement($post);
     $attachmentField = new MultiFileField('attachments', 5);
     $form->addElement($attachmentField);
     $this->addForm($form);
     return $form;
 }
Ejemplo n.º 28
0
 /**
  * @param string $formName
  * @param string $submitDecorator
  * @return Form
  */
 public function getSignInForm($formName = 'sign-in', $submitDecorator = 'button')
 {
     $form = new Form($formName);
     $username = new TextField('identity');
     $username->setRequired(true);
     $username->setHasInvitation(true);
     $username->setInvitation(OW::getLanguage()->text('base', 'component_sign_in_login_invitation'));
     $form->addElement($username);
     $password = new PasswordField('password');
     $password->setHasInvitation(true);
     $password->setInvitation('password');
     $password->setRequired(true);
     $form->addElement($password);
     $remeberMe = new CheckboxField('remember');
     $remeberMe->setLabel(OW::getLanguage()->text('base', 'sign_in_remember_me_label'));
     $remeberMe->setValue(true);
     $form->addElement($remeberMe);
     $submit = new Submit('submit', $submitDecorator);
     $submit->setValue(OW::getLanguage()->text('base', 'sign_in_submit_label'));
     $form->addElement($submit);
     return $form;
 }
Ejemplo n.º 29
0
 protected function initForm($controller)
 {
     $this->controller = $controller;
     $controller->assign('section_prefix', self::SECTION_TR_PREFIX);
     $controller->assign('question_prefix', self::QUESTION_TR_PREFIX);
     $questionService = BOL_QuestionService::getInstance();
     $this->setId('MainSearchForm');
     $submit = new Submit(self::SUBMIT_NAME);
     $submit->setValue(OW::getLanguage()->text('base', 'user_search_submit_button_label'));
     $this->addElement($submit);
     // get default question values
     $questionData = $this->getQuestionData();
     // prepare account types list
     $accountList = $this->getAccountTypes();
     $keys = array_keys($accountList);
     // get default account type
     $accountType = $keys[0];
     $matchSexValue = USEARCH_BOL_Service::getInstance()->getGenderByAccounType($accountType);
     if (isset($questionData['match_sex'])) {
         $aType = USEARCH_BOL_Service::getInstance()->getAccounTypeByGender($questionData['match_sex']);
         if (!empty($aType)) {
             $accountType = $aType;
             $matchSexValue = $questionData['match_sex'];
         }
     }
     //-- end --
     // get search question list
     $questions = $questionService->findSearchQuestionsForAccountType('all');
     // prepare questions list
     $this->mainSearchQuestionList = array();
     $questionNameList = array('sex' => 'sex', 'match_sex' => 'match_sex');
     $accounTypeToQuestionList = array();
     foreach ($questions as $key => $question) {
         $sectionName = $question['sectionName'];
         $questionNameList[] = $question['name'];
         $isRequired = in_array($question['name'], array('googlemap_location', 'match_sex')) ? 1 : 0;
         $questions[$key]['required'] = $isRequired;
         if ($question['name'] == 'sex' || $question['name'] == 'match_sex') {
             unset($questions[$key]);
         } else {
             $this->mainSearchQuestionList[$sectionName][] = $question;
         }
     }
     // -- end --
     $visibilityList = $this->getVisibilityList($accountType, $this->mainSearchQuestionList);
     $controller->assign('visibilityList', $visibilityList);
     // get question values list
     $questionValueList = $questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     // prepare add sex and match sex questions
     $this->addGenderQuestions($controller, $accountList, $questionValueList, $questionData);
     $this->addQuestions($questions, $questionValueList, $questionData);
     $locationField = $this->getElement('googlemap_location');
     if ($locationField) {
         $value = $locationField->getValue();
         if (empty($value['json'])) {
             $locationField->setDistance(50);
         }
     }
     $controller->assign('questionList', $this->mainSearchQuestionList);
     // add 'online' field
     $onlineField = new CheckboxField('online');
     if (!empty($questionData) && is_array($questionData) && array_key_exists('online', $questionData)) {
         $onlineField->setValue($questionData['online']);
     }
     $onlineField->setLabel(OW::getLanguage()->text('usearch', 'online_only'));
     $this->addElement($onlineField);
     // add with photo field
     $withPhoto = new CheckboxField('with_photo');
     if (!empty($questionData) && is_array($questionData) && array_key_exists('with_photo', $questionData)) {
         $withPhoto->setValue($questionData['with_photo']);
     }
     $withPhoto->setLabel(OW::getLanguage()->text('usearch', 'with_photo'));
     $this->addElement($withPhoto);
     $this->addOnloadJs($matchSexValue, $visibilityList['sections']);
 }
Ejemplo n.º 30
0
 function __construct($controller, $name, $article = null, bool $is_manager, $use_actions = true)
 {
     $IDField = new HiddenField('newsID');
     //madatory fields
     $HeadlineField = new TextField('headline', 'Headline (150 character max)', '', $maxLength = 150);
     $HeadlineField->addExtraClass('headline');
     $SummaryField = new HtmlEditorField('summary', 'Summary (300 character max)');
     $SummaryField->addExtraClass('summary');
     $SummaryField->setAttribute('max_chars', 300);
     $CityField = new TextField('city', 'City');
     $StateField = new TextField('state', 'State');
     $CountryField = new CountryDropdownField('country', 'Country');
     $TagsField = new TextField('tags', 'Tags');
     $DateEmbargoField = new TextField('date_embargo', 'Desired release date/time: Time zone is Central Time. Please ensure your release date is in Central Time
         (<a target="_blank" href="http://www.timeanddate.com/worldclock/converter.html">time converter</a>)');
     $DateEmbargoField->addExtraClass('datefield');
     if ($is_manager) {
         $DateExpireField = new TextField('date_expire', 'Expire Date');
         $DateExpireField->addExtraClass('datefield');
     }
     $UpdatedField = new DatetimeField_Readonly('date_updated', 'Last Updated');
     //$UpdatedField->addExtraClass('inline');
     //optional fields
     $BodyField = new HtmlEditorField('body', 'Body');
     $LinkField = new TextField('link', 'Link');
     $DocumentField = new CustomUploadField('Document', 'Document');
     $DocumentField->addExtraClass('hidden');
     $DocumentField->setCanAttachExisting(false);
     $DocumentField->setAllowedMaxFileNumber(1);
     $DocumentField->setAllowedFileCategories('doc');
     $DocumentField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $DocumentField->setFolderName('news-documents');
     $sizeMB = 1;
     // 1 MB
     $size = $sizeMB * 1024 * 1024;
     // 1 MB in bytes
     $DocumentField->getValidator()->setAllowedMaxFileSize($size);
     $DocumentField->setCanPreviewFolder(false);
     // Don't show target filesystem folder on upload field
     $DocumentField->setRecordClass('File');
     $ImageField = new CustomUploadField('Image', 'Image (Max size 2Mb - Suggested size 300x250px)');
     $ImageField->setCanAttachExisting(false);
     $ImageField->setAllowedMaxFileNumber(1);
     $ImageField->setAllowedFileCategories('image');
     $ImageField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $ImageField->setFolderName('news-images');
     $ImageField->setRecordClass('BetterImage');
     $ImageField->getUpload()->setReplaceFile(false);
     $ImageField->setOverwriteWarning(false);
     $sizeMB = 2;
     // 2 MB
     $size = $sizeMB * 1024 * 1024;
     // 2 MB in bytes
     $ImageField->getValidator()->setAllowedMaxFileSize($size);
     $ImageField->setCanPreviewFolder(false);
     // Don't show target filesystem folder on upload field
     if ($is_manager) {
         $IsLandscapeField = new CheckboxField('is_landscape', 'Is Banner? (landscape image)');
         $IsLandscapeField->addExtraClass('is_landscape');
     }
     if ($article) {
         $IDField->setValue($article->ID);
         $HeadlineField->setValue($article->Headline);
         $SummaryField->setValue($article->Summary);
         $CityField->setValue($article->City);
         $StateField->setValue($article->State);
         $CountryField->setValue($article->Country);
         $TagsField->setValue($article->getTagsCSV());
         if ($article->DateEmbargo) {
             $DateEmbargoField->setValue(date('m/d/Y g:i a', strtotime($article->DateEmbargo)));
         } else {
             $DateEmbargoField->setValue(gmdate('m/d/Y g:i a'));
         }
         $UpdatedField->setValue($article->LastEdited);
         $BodyField->setValue($article->Body);
         $LinkField->setValue($article->Link);
         if ($article->DateExpire) {
             $DateExpireField->setValue(date('m/d/Y g:i a', strtotime($article->DateExpire)));
         }
         $IsLandscapeField->setValue($article->IsLandscape);
         //submitter read only
         $SubmitterFirstNameField = new ReadonlyField('submitter_first_name', 'First Name');
         $SubmitterLastNameField = new ReadonlyField('submitter_last_name', 'Last Name');
         $SubmitterEmailField = new ReadonlyField('submitter_email', 'Email');
         $SubmitterCompanyField = new ReadonlyField('submitter_company', 'Company');
         $SubmitterPhoneField = new ReadonlyField('submitter_phone', 'Phone');
         $SubmitterFirstNameField->setValue($article->getSubmitter()->FirstName);
         $SubmitterLastNameField->setValue($article->getSubmitter()->LastName);
         $SubmitterEmailField->setValue($article->getSubmitter()->Email);
         $SubmitterCompanyField->setValue($article->getSubmitter()->Company);
         $SubmitterPhoneField->setValue($article->getSubmitter()->Phone);
     } else {
         // submitter fields
         $SubmitterFirstNameField = new TextField('submitter_first_name', 'First Name');
         $SubmitterLastNameField = new TextField('submitter_last_name', 'Last Name');
         $SubmitterEmailField = new TextField('submitter_email', 'Email');
         $SubmitterCompanyField = new TextField('submitter_company', 'Company');
         $SubmitterPhoneField = new TextField('submitter_phone', 'Phone');
         $LinkField->setValue('http://');
     }
     $fields = new FieldList($IDField, $HeadlineField, $SummaryField, $CityField, $StateField, $CountryField, $TagsField, $DateEmbargoField);
     if ($is_manager) {
         $fields->push($DateExpireField);
         $fields->push($UpdatedField);
     }
     $fields->push(new LiteralField('clear', '<div class="clear"></div>'));
     $fields->push($BodyField);
     $fields->push($LinkField);
     $fields->push($DocumentField);
     if ($article) {
         $image = $article->Image();
         $document = $article->Document();
         if ($document->exists()) {
             $fields->push(new LiteralField('image_preview', $document->CMSThumbnail()));
         }
         $fields->push(new LiteralField('break', '<br/>'));
         $fields->push($ImageField);
         if ($image->exists()) {
             $ImageField->setValue(null, $article);
         }
     } else {
         $fields->push(new LiteralField('break', '<br/>'));
         $fields->push($ImageField);
     }
     if ($is_manager) {
         $fields->push($IsLandscapeField);
         $fields->push(new LiteralField('break', '<br/>'));
     }
     $fields->push(new LiteralField('break', '<br/><hr/>'));
     $fields->push(new LiteralField('title', '<h2>Submitter</h2>'));
     $fields->push($SubmitterFirstNameField);
     $fields->push($SubmitterLastNameField);
     $fields->push($SubmitterEmailField);
     $fields->push($SubmitterCompanyField);
     $fields->push($SubmitterPhoneField);
     // Create action
     $actions = new FieldList();
     $actions->push(new FormAction('saveNewsArticle', 'Save'));
     $this->addExtraClass('news-registration-form');
     parent::__construct($controller, $name, $fields, $actions, $validator = null);
 }