/** * @param Controller $controller * @param Job $job (optional) */ public function __construct($controller, $job = null) { if ($job) { $fields = $job->getFields(); $required = $job->getValidator(); } else { $fields = singleton('Job')->getFields(); $required = singleton('Job')->getValidator(); } $fields->merge(new FieldList(new LiteralField('Conditions', $controller->TermsAndConditionsText), new HiddenField('BackURL', '', $controller->Link('thanks')), new HiddenField('EmailFrom', '', $controller->getJobEmailFromAddress()), new HiddenField('EmailSubject', '', $controller->getJobEmailSubject()), $jobId = new HiddenField('JobID'))); if ($job) { $jobId->setValue($job->ID); $actions = new FieldList(new FormAction('doEditJob', _t('Jobboard.EDITLISTING', 'Edit Listing'))); } else { $actions = new FieldList(new FormAction('doAddJob', _t('JobBoard.CONFIRM', 'Confirm'))); } parent::__construct($controller, 'AddJobForm', $fields, $actions, $required); $this->setFormAction('JobBoardFormProcessor/doJobForm'); $this->setFormMethod('POST'); if ($job) { $this->loadDataFrom($job); } else { $this->enableSpamProtection(); } }
function __construct($controller, $name, $speakerID, $use_actions = true) { $fields = new FieldList(); //point of contact $speakerIDfield = new HiddenField('speaker_id'); $speakerIDfield->setValue($speakerID); $fields->push($speakerIDfield); $fields->push(new TextField('org_name', 'Name of Organizer')); $fields->push(new EmailField('org_email', 'Email')); $fields->push(new TextField('event_name', 'Event')); $fields->push(new TextField('event_format', 'Format/Length')); $fields->push(new TextField('event_attendance', 'Expected Attendance (number)')); $fields->push(new TextField('event_date', 'Date of Event')); $fields->push(new TextField('event_location', 'Location')); $fields->push(new TextField('event_topic', 'Topic(s)')); $request = new HtmlEditorField('general_request', 'General Request'); $request->setRows(10); $fields->push($request); $sec_field = new TextField('field_98438688', 'field_98438688'); $sec_field->addExtraClass('honey'); $fields->push($sec_field); // Create action $actions = new FieldList(); if ($use_actions) { $actions->push(new FormAction('sendSpeakerEmail', 'Send')); } parent::__construct($controller, $name, $fields, $actions); }
public function __construct() { parent::__construct(); $language = OW::getLanguage(); $serviceLang = BOL_LanguageService::getInstance(); $addSectionForm = new Form('qst_add_section_form'); $addSectionForm->setAjax(); $addSectionForm->setAjaxResetOnSuccess(true); $addSectionForm->setAction(OW::getRouter()->urlFor("ADMIN_CTRL_Questions", "ajaxResponder")); $input = new HiddenField('command'); $input->setValue('addSection'); $addSectionForm->addElement($input); $qstSectionName = new TextField('section_name'); $qstSectionName->addAttribute('class', 'ow_text'); $qstSectionName->addAttribute('style', 'width: auto;'); $qstSectionName->setRequired(); $qstSectionName->setLabel($language->text('admin', 'questions_new_section_label')); $addSectionForm->addElement($qstSectionName); $this->addForm($addSectionForm); $addSectionForm->bindJsFunction('success', ' function (result) { if ( result.result ) { OW.info(result.message); } else { OW.error(result.message); } window.location.reload(); } '); }
public function __construct($opponentId) { parent::__construct('composeMessageForm'); $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); $field = new HiddenField('uid'); $field->setValue(UTIL_HtmlTag::generateAutoId('mailbox_new_message_' . $opponentId)); $this->addElement($field); $field = new HiddenField('opponentId'); $field->setValue($opponentId); $this->addElement($field); $field = new TextField('subject'); $field->setInvitation(OW::getLanguage()->text('mailbox', 'subject')); $field->setHasInvitation(true); $field->setRequired(); $this->addElement($field); $field = new Textarea('message'); $field->setInvitation(OW::getLanguage()->text('mailbox', 'text_message_invitation')); $field->setHasInvitation(true); $field->setRequired(); $this->addElement($field); $field = new HiddenField('attachment'); $this->addElement($field); $submit = new Submit('sendBtn'); $submit->setId('sendBtn'); $submit->setValue(OW::getLanguage()->text('mailbox', 'add_button')); $this->addElement($submit); if (!OW::getRequest()->isAjax()) { $js = UTIL_JsGenerator::composeJsString(' owForms["composeMessageForm"].bind( "submit", function( r ) { $("#newmessage-mail-send-btn").addClass("owm_preloader_circle"); });'); OW::getDocument()->addOnloadScript($js); } }
public function __construct($conversationId, $opponentId) { parent::__construct('newMailMessageForm'); $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); $field = new TextField('newMessageText'); $field->setValue(OW::getLanguage()->text('mailbox', 'text_message_invitation')); $field->setId('newMessageText'); $this->addElement($field); $field = new HiddenField('attachment'); $this->addElement($field); $field = new HiddenField('conversationId'); $field->setValue($conversationId); $this->addElement($field); $field = new HiddenField('opponentId'); $field->setValue($opponentId); $this->addElement($field); $field = new HiddenField('uid'); $field->setValue(UTIL_HtmlTag::generateAutoId('mailbox_conversation_' . $conversationId . '_' . $opponentId)); $this->addElement($field); $submit = new Submit('newMessageSendBtn'); $submit->setId('newMessageSendBtn'); $submit->setName('newMessageSendBtn'); $submit->setValue(OW::getLanguage()->text('mailbox', 'add_button')); $this->addElement($submit); if (!OW::getRequest()->isAjax()) { $js = UTIL_JsGenerator::composeJsString(' owForms["newMailMessageForm"].bind( "submit", function( r ) { $("#newmessage-mail-send-btn").addClass("owm_preloader_circle"); });'); OW::getDocument()->addOnloadScript($js); } $this->setAction(OW::getRouter()->urlFor('MAILBOX_MCTRL_Messages', 'newmessage')); }
public function __construct($albumId) { parent::__construct(self::FORM_NAME); $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId); $this->setAction(OW::getRouter()->urlForRoute('photo.ajax_update_photo')); $this->setAjax(true); $this->setAjaxResetOnSuccess(false); $albumIdField = new HiddenField(self::ELEMENT_ALBUM_ID); $albumIdField->setValue($album->id); $albumIdField->setRequired(); $albumIdField->addValidator(new PHOTO_CLASS_AlbumOwnerValidator()); $this->addElement($albumIdField); $albumNameField = new TextField(self::ELEMENT_ALBUM_NAME); $albumNameField->setValue($album->name); $albumNameField->setRequired(); if ($album->name != trim(OW::getLanguage()->text('photo', 'newsfeed_album'))) { $albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(true, null, $album->name)); } $albumNameField->addAttribute('class', 'ow_photo_album_name_input'); $this->addElement($albumNameField); $desc = new Textarea(self::ELEMENT_DESC); $desc->setValue(!empty($album->description) ? $album->description : NULL); $desc->setHasInvitation(TRUE); $desc->setInvitation(OW::getLanguage()->text('photo', 'describe_photo')); $desc->addAttribute('class', 'ow_photo_album_description_textarea'); $this->addElement($desc); $this->triggerReady(array('albumId' => $albumId)); }
public function __construct(BASE_CommentsParams $params, $id, $formName) { parent::__construct(); $language = OW::getLanguage(); $form = new Form($formName); $textArea = new Textarea('commentText'); $textArea->setHasInvitation(true); $textArea->setInvitation($language->text('base', 'comment_form_element_invitation_text')); $form->addElement($textArea); $hiddenEls = array('entityType' => $params->getEntityType(), 'entityId' => $params->getEntityId(), 'displayType' => $params->getDisplayType(), 'pluginKey' => $params->getPluginKey(), 'ownerId' => $params->getOwnerId(), 'cid' => $id, 'commentCountOnPage' => $params->getCommentCountOnPage(), 'isMobile' => 1); foreach ($hiddenEls as $name => $value) { $el = new HiddenField($name); $el->setValue($value); $form->addElement($el); } $submit = new Submit('comment-submit'); $submit->setValue($language->text('base', 'comment_add_submit_label')); $form->addElement($submit); $form->setAjax(true); $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment')); // $form->bindJsFunction(Form::BIND_SUBMIT, "function(){ $('#comments-" . $id . " .comments-preloader').show();}"); // $form->bindJsFunction(Form::BIND_SUCCESS, "function(){ $('#comments-" . $id . " .comments-preloader').hide();}"); $this->addForm($form); OW::getDocument()->addOnloadScript("window.owCommentCmps['{$id}'].initForm('" . $textArea->getId() . "', '" . $submit->getId() . "');"); $this->assign('form', true); $this->assign('id', $id); }
public function __construct() { parent::__construct('add-album'); $this->setAjax(); $this->setAjaxResetOnSuccess(FALSE); $this->setAction(OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxResponder')); $ajaxFunc = new HiddenField('ajaxFunc'); $ajaxFunc->setValue('ajaxMoveToAlbum'); $ajaxFunc->setRequired(); $this->addElement($ajaxFunc); $fromAlbum = new HiddenField('from-album'); $fromAlbum->setRequired(); $fromAlbum->addValidator(new PHOTO_CLASS_AlbumOwnerValidator()); $this->addElement($fromAlbum); $toAlbum = new HiddenField('to-album'); $this->addElement($toAlbum); $photos = new HiddenField('photos'); $photos->setRequired(); $this->albumPhotosValidator = new AlbumPhotosValidator(); $photos->addValidator($this->albumPhotosValidator); $this->addElement($photos); $albumName = new TextField('album-name'); $albumName->setRequired(); $albumName->addValidator(new PHOTO_CLASS_AlbumNameValidator(FALSE)); $albumName->setHasInvitation(TRUE); $albumName->setInvitation(OW::getLanguage()->text('photo', 'album_name')); $albumName->addAttribute('class', 'ow_smallmargin'); $this->addElement($albumName); $desc = new Textarea('desc'); $desc->setHasInvitation(TRUE); $desc->setInvitation(OW::getLanguage()->text('photo', 'album_desc')); $this->addElement($desc); $this->addElement(new Submit('add')); }
public function Field($properties = array()) { $titleArray = $itemIDs = array(); $titleList = $itemIDsList = ""; if ($items = $this->getItems()) { foreach ($items as $item) { $titleArray[] = $item->Title; } foreach ($items as $item) { $itemIDs[] = $item->ID; } if ($titleArray) { $titleList = implode(", ", $titleArray); } if ($itemIDs) { $itemIDsList = implode(",", $itemIDs); } } $field = new ReadonlyField($this->name . '_ReadonlyValue', $this->title); $field->setValue($titleList); $field->setForm($this->form); $valueField = new HiddenField($this->name); $valueField->setValue($itemIDsList); $valueField->setForm($this->form); return $field->Field() . $valueField->Field(); }
/** * @param FieldList $fields */ public function updateCMSFields(FieldList $fields) { // Add timepicker functionality // @see https://github.com/trentrichardson/jQuery-Timepicker-Addon Requirements::css(ADVANCED_WORKFLOW_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-timepicker-addon.css'); Requirements::css(ADVANCED_WORKFLOW_DIR . '/css/WorkflowFieldTimePicker.css'); Requirements::javascript(ADVANCED_WORKFLOW_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-sliderAccess.js'); Requirements::javascript(ADVANCED_WORKFLOW_DIR . '/thirdparty/javascript/jquery-ui/timepicker/jquery-ui-timepicker-addon.js'); Requirements::javascript(ADVANCED_WORKFLOW_DIR . '/javascript/WorkflowField.js'); $this->setIsWorkflowInEffect(); if ($this->getIsWorkflowInEffect()) { $fields->addFieldsToTab('Root.PublishingSchedule', array(new HeaderField('PublishDateHeader', _t('WorkflowEmbargoExpiryExtension.REQUESTED_PUBLISH_DATE_H3', 'Expiry and Embargo'), 3), new LiteralField('PublishDateIntro', $this->getIntroMessage('PublishDateIntro')), $dt = new Datetimefield('DesiredPublishDate', _t('WorkflowEmbargoExpiryExtension.REQUESTED_PUBLISH_DATE', 'Requested publish date')), $ut = new Datetimefield('DesiredUnPublishDate', _t('WorkflowEmbargoExpiryExtension.REQUESTED_UNPUBLISH_DATE', 'Requested un-publish date')), Datetimefield::create('PublishOnDate', _t('WorkflowEmbargoExpiryExtension.PUBLISH_ON', 'Scheduled publish date'))->setDisabled(true), Datetimefield::create('UnPublishOnDate', _t('WorkflowEmbargoExpiryExtension.UNPUBLISH_ON', 'Scheduled un-publish date'))->setDisabled(true), $uth = new HiddenField('PublishOnDateOwner'))); // Set a value to our hidden field $uth->setValue($this->owner->PublishOnDate); } else { $fields->addFieldsToTab('Root.PublishingSchedule', array(new HeaderField('PublishDateHeader', _t('WorkflowEmbargoExpiryExtension.REQUESTED_PUBLISH_DATE_H3', 'Expiry and Embargo'), 3), new LiteralField('PublishDateIntro', $this->getIntroMessage('PublishDateIntro')), $dt = new Datetimefield('PublishOnDate', _t('WorkflowEmbargoExpiryExtension.PUBLISH_ON', 'Scheduled publish date')), $ut = new Datetimefield('UnPublishOnDate', _t('WorkflowEmbargoExpiryExtension.UNPUBLISH_ON', 'Scheduled un-publish date')))); } $dt->getDateField()->setConfig('showcalendar', true); $ut->getDateField()->setConfig('showcalendar', true); $dt->getTimeField()->setConfig('timeformat', 'HH:mm:ss'); $ut->getTimeField()->setConfig('timeformat', 'HH:mm:ss'); // Enable a jQuery-UI timepicker widget if (self::$showTimePicker) { $dt->getTimeField()->addExtraClass('hasTimePicker'); $ut->getTimeField()->addExtraClass('hasTimePicker'); } }
/** * Initiate the standard Metadata catalogue search form. The * additional parameter $defaults defines the default values for the form. * * @param Controller $controller The parent controller, necessary to create the appropriate form action tag. * @param String $name The method on the controller that will return this form object. * @param FieldSet $fields All of the fields in the form - a {@link FieldSet} of {@link FormField} objects. * @param FieldSet $actions All of the action buttons in the form - a {@link FieldSet} of {@link FormAction} objects * @param Validator $validator Override the default validator instance (Default: {@link RequiredFields}) * @param Array $defaults Override the default values of the form. */ function __construct($controller, $name, FieldSet $fields = null, FieldSet $actions = null, $validator = null, $defaults = null) { $format = $defaults['format']; $searchTerm = $defaults['searchTerm']; $bboxUpper = $bboxLower = null; if (isset($defaults['bboxUpper']) && isset($defaults['bboxLower'])) { $bboxUpper = $defaults['bboxUpper']; $bboxLower = $defaults['bboxLower']; } $values = CataloguePage_Controller::get_standard_names(); $upperField = new HiddenField('bboxUpper', _t('SearchForm.SEARCH', 'bboxUpper'), $bboxUpper); $upperField->addExtraClass('upper'); $lowerField = new HiddenField('bboxLower', _t('SearchForm.SEARCH', 'bboxLower'), $bboxLower); $lowerField->addExtraClass('lower'); if (!$fields) { $fields = new FieldSet(new TextField('searchTerm', _t('SearchForm.SEARCH', 'Search'), $searchTerm), $upperField, $lowerField, new OptionsetField('format', _t('SearchForm.MetadataStandard', 'Metadata Standard'), $values, $format)); } if (singleton('SiteTree')->hasExtension('Translatable')) { $fields->push(new HiddenField('locale', 'locale', Translatable::get_current_locale())); } if (!$actions) { $actions = new FieldSet(new FormAction("submit", _t('SearchForm.Search', 'Search'))); } parent::__construct($controller, $name, $fields, $actions); $this->setFormMethod('get'); }
public function __construct() { parent::__construct('set-credits-form'); $this->setAjax(true); $this->setAction(OW::getRouter()->urlFor('USERCREDITS_CTRL_Ajax', 'setCredits')); $lang = OW::getLanguage(); $userIdField = new HiddenField('userId'); $userIdField->setRequired(true); $this->addElement($userIdField); $balance = new TextField('balance'); $this->addElement($balance); $submit = new Submit('save'); $submit->setValue($lang->text('base', 'edit_button')); $this->addElement($submit); $js = 'owForms["' . $this->getName() . '"].bind("success", function(data){ if ( data.error ){ OW.error(data.error); } if ( data.message ) { OW.info(data.message); } _scope.floatBox && _scope.floatBox.close(); _scope.callBack && _scope.callBack(data); });'; OW::getDocument()->addOnloadScript($js); }
public function __construct() { parent::__construct('delete-membership-form'); $this->setAjaxResetOnSuccess(false); $this->setAjax(true); $this->setAction(OW::getRouter()->urlForRoute('membership_delete_type')); $lang = OW::getLanguage(); $typeId = new HiddenField('typeId'); $typeId->setRequired(true); $this->addElement($typeId); $newTypeId = new Selectbox('newTypeId'); $newTypeId->setHasInvitation(false); $this->addElement($newTypeId); $types = new RadioGroupItemField('type'); $types->setRequired(true); $types->setLabel($lang->text('membership', 'set_membership')); $this->addElement($types); $this->bindJsFunction(Form::BIND_SUCCESS, "function( data ) {\n if ( data.result ) {\n document.location.reload();\n }\n }"); $script = '$("#btn-confirm-type-delete").click(function(){ if ( confirm(' . json_encode($lang->text('membership', 'type_delete_confirm')) . ') ) { $(this).parents("form:eq(0)").submit(); } }); '; OW::getDocument()->addOnloadScript($script); }
public function render() { $name = $this->getName(); $hidden = new HiddenField($name, $this->getValue()); $id = $this->getId(); $hidden->addAttribute("id", $id); $ret = $hidden->render(); if ($this->storedFieldSet === false) { $this->addSearchField($this->storedField); $this->storedFieldSet = true; } $object = array("model" => $this->model->package, "format" => "json", "fields" => $this->searchFields, "limit" => 20, "conditions" => "", "and_conditions" => $this->andConditions); $jsonSearchFields = array_reverse($this->searchFields); $object = base64_encode(serialize($object)); $path = Application::$prefix . "/lib/models/urlaccess.php?object={$object}"; $fields = urlencode(json_encode($jsonSearchFields)); $text = new TextField(); $text->addAttribute("onkeyup", "fapiUpdateSearchField('{$id}','{$path}','{$fields}',this," . ($this->boldFirst ? "true" : "false") . ",'{$this->onChangeAttribute}')"); $text->addAttribute("autocomplete", "off"); if ($this->getValue() != "") { $data = $this->model[$this->getValue()]; for ($i = 2; $i < count($jsonSearchFields); $i++) { $val .= $data[0][$jsonSearchFields[$i]] . " "; } $text->setValue($val); } $text->setId($id . "_search_entry"); $ret .= $text->render(); $ret .= "<div class='fapi-popup' id='{$id}_search_area'></div>"; return $ret; }
public function updateLinkForm($form) { Requirements::javascript("linkableobjects/javascript/CustomHtmlEditorField.js"); $count = 0; foreach ($form->Fields() as $field) { $count++; if ($count == 2) { $linkType = $field->fieldByName('LinkType'); $types = $linkType->getSource(); $link = new HtmlEditorField_LinkObjects(); $linkableObjects = $link->getLinkableObjects(); foreach ($linkableObjects as $object => $title) { $types[$object] = $title; $picker = new DataObjectPicker($object . 'LinkID', $title); $picker->setConfig('limit', 5); $picker->setConfig('classToPick', $object); $picker->setForm($form); $field->insertBefore($picker, 'Description'); } $linkMap = new HiddenField('LinkableObjects'); $linkMap->setAttribute('data-map', json_encode($linkableObjects)); $field->push($linkMap); $linkType->setSource($types); } } }
public function __construct($albumId) { parent::__construct('albumEditForm'); $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId); $this->setAction(OW::getRouter()->urlForRoute('photo.ajax_update_photo')); $this->setAjax(TRUE); $this->setAjaxResetOnSuccess(FALSE); $albumIdField = new HiddenField('album-id'); $albumIdField->setValue($album->id); $albumIdField->setRequired(); $albumIdField->addValidator(new PHOTO_CLASS_AlbumOwnerValidator()); $this->addElement($albumIdField); $albumNameField = new TextField('albumName'); $albumNameField->setValue($album->name); $albumNameField->setRequired(); if ($album->name != trim(OW::getLanguage()->text('photo', 'newsfeed_album'))) { $albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(TRUE, NULL, $album->name)); } $albumNameField->addAttribute('class', 'ow_photo_album_name_input'); $this->addElement($albumNameField); $desc = new Textarea('desc'); $desc->setValue(!empty($album->description) ? $album->description : NULL); $desc->setHasInvitation(TRUE); $desc->setInvitation(OW::getLanguage()->text('photo', 'describe_photo')); $desc->addAttribute('class', 'ow_photo_album_description_textarea'); $this->addElement($desc); }
public function __construct($userId) { parent::__construct(); $data = OW::getEventManager()->call("photo.entity_albums_find", array("entityType" => "user", "entityId" => $userId)); $albums = empty($data["albums"]) ? array() : $data["albums"]; $source = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_source", $userId); $this->assign("source", $source == "album" ? "album" : "all"); $selectedAlbum = BOL_PreferenceService::getInstance()->getPreferenceValue("pcgallery_album", $userId); $form = new Form("pcGallerySettings"); $form->setEmptyElementsErrorMessage(null); $form->setAction(OW::getRouter()->urlFor("PCGALLERY_CTRL_Gallery", "saveSettings")); $element = new HiddenField("userId"); $element->setValue($userId); $form->addElement($element); $element = new Selectbox("album"); $element->setHasInvitation(true); $element->setInvitation(OW::getLanguage()->text("pcgallery", "settings_album_invitation")); $validator = new PCGALLERY_AlbumValidator(); $element->addValidator($validator); $albumsPhotoCount = array(); foreach ($albums as $album) { $element->addOption($album["id"], $album["name"] . " ({$album["photoCount"]})"); $albumsPhotoCount[$album["id"]] = $album["photoCount"]; if ($album["id"] == $selectedAlbum) { $element->setValue($album["id"]); } } OW::getDocument()->addOnloadScript(UTIL_JsGenerator::composeJsString('window.pcgallery_settingsAlbumCounts = {$albumsCount};', array("albumsCount" => $albumsPhotoCount))); $element->setLabel(OW::getLanguage()->text("pcgallery", "source_album_label")); $form->addElement($element); $submit = new Submit("save"); $submit->setValue(OW::getLanguage()->text("pcgallery", "save_settings_btn_label")); $form->addElement($submit); $this->addForm($form); }
public function __construct($providerName) { parent::__construct('login-form'); $language = OW::getLanguage(); $this->setAction(""); $label = $language->text('yncontactimporter', 'login_email'); if ($providerName == 'hyves') { $label = $language->text('yncontactimporter', 'login_username'); } // email $email = new TextField('email'); $email->setLabel($label)->setRequired(true); $this->addElement($email); //pass $password = new PasswordField('password'); $password->setLabel($language->text('yncontactimporter', 'login_password'))->setRequired(true); $this->addElement($password); //providerName $hiddenProviderName = new HiddenField('providerName'); $hiddenProviderName->setValue($providerName); $this->addElement($hiddenProviderName); // button submit $submit = new Submit('submit'); $submit->setValue($language->text('yncontactimporter', 'submit_btn_label')); $this->addElement($submit); }
/** * Class constructor */ public function __construct() { parent::__construct('update-question-form'); $this->setAction(OW::getRouter()->urlFor('OCSFAQ_CTRL_Admin', 'editQuestion')); $lang = OW::getLanguage(); $questionId = new HiddenField('questionId'); $questionId->setRequired(true); $this->addElement($questionId); $question = new TextField('question'); $question->setRequired(true); $question->setLabel($lang->text('ocsfaq', 'question')); $this->addElement($question); $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML); $answer = new WysiwygTextarea('answer', $btnSet); $answer->setRequired(true); $answer->setLabel($lang->text('ocsfaq', 'answer')); $this->addElement($answer); $isFeatured = new CheckboxField('isFeatured'); $isFeatured->setLabel($lang->text('ocsfaq', 'is_featured')); $this->addElement($isFeatured); $categories = OCSFAQ_BOL_FaqService::getInstance()->getCategories(); if ($categories) { $category = new Selectbox('category'); foreach ($categories as $cat) { $category->addOption($cat->id, $cat->name); } $category->setLabel($lang->text('ocsfaq', 'category')); $this->addElement($category); } // submit $submit = new Submit('update'); $submit->setValue($lang->text('ocsfaq', 'btn_save')); $this->addElement($submit); }
public function getCMSFields() { Requirements::javascript(LINK_EDIT_TOOLS_PATH . '/javascript/linkedit.js'); $localeField = new HiddenField('Locale'); $localeField->setValue($this->LinksFolder()->Locale); $fields = new FieldList(new TextField('Title', 'Link title'), new DropdownField('LinkType', 'Internal or External Link', singleton('Link')->dbObject('LinkType')->enumValues()), new TextField('URL'), new TreeDropdownField('InternalPageID', 'Choose an internal link', 'SiteTree'), new HtmlEditorField('Description'), $localeField); return $fields; }
/** * @param string $message * @param string $messageType */ public function setError($message, $messageType) { // show the manual fields $this->manualToggle->setValue('1'); $name = $this->getName(); $field = $this->manualFields->dataFieldByName("{$name}[{$messageType}]"); if ($field) { $field->setError($message, 'validation'); } }
public function __construct($interlocutorId) { $language = OW::getLanguage(); parent::__construct('mailbox-create-conversation-form'); $this->setAction(OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'sendMessageAjaxResponder', array('userId' => $interlocutorId))); $this->setId('mailbox-create-conversation-form'); $this->setEnctype('multipart/form-data'); $this->setAjax(); $this->setAjaxResetOnSuccess(false); $hidden = new HiddenField('userId'); $hidden->setValue($interlocutorId); $this->addElement($hidden); //thickbox $validatorSubject = new StringValidator(0, 2048); $validatorSubject->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 2048))); $subject = new TextField('subject'); $subject->setLabel($language->text('mailbox', 'subject'))->addAttribute('class', 'ow_text'); $subject->addValidator($validatorSubject); $subject->setRequired(true); $this->addElement($subject); $validatorTextarea = new StringValidator(0, 24000); $validatorTextarea->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 24000))); $message = new WysiwygTextarea('message', array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO), false); $message->setLabel($language->text('mailbox', 'text'))->addAttribute('class', 'ow_text'); $message->addAttribute('rows', '10'); $message->addValidator($validatorTextarea); $message->setRequired(true); $this->addElement($message); if (OW::getConfig()->getValue('mailbox', 'enable_attachments')) { $multiUpload = new MAILBOX_CLASS_AjaxFileUpload('attachments'); $multiUpload->setId('attachments'); $this->addElement($multiUpload); } $captcha = new MailboxCaptchaField('captcha'); $captcha->addValidator(new MailboxCaptchaValidator($captcha->getId())); $LastSendStamp = BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_create_conversation_stamp', OW::getUser()->getId()); $this->displayCapcha = BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_create_conversation_display_capcha', OW::getUser()->getId()); if (!$this->displayCapcha && $LastSendStamp + self::DISPLAY_CAPTCHA_TIMEOUT > time()) { BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_display_capcha', true, OW::getUser()->getId()); $this->displayCapcha = true; } $captcha->addAttribute('disabled', 'disabled'); $this->addElement($captcha); $submit = new Submit('send'); $submit->setValue($language->text('mailbox', 'send_button')); $submit->addAttribute('class', 'ow_button ow_ic_mail'); $this->addElement($submit); if (!OW::getRequest()->isAjax()) { $messageError = $language->text('mailbox', 'create_conversation_fail_message'); $messageSuccess = $language->text('mailbox', 'create_conversation_message'); $js = " owForms['mailbox-create-conversation-form'].bind( 'success',\n function( json )\n {\n var from = \$('#mailbox-create-conversation-form');\n var captcha = from.find('input[name=captcha]');\n\n if ( json.result == 'permission_denied' )\n {\n if ( json.message != undefined )\n {\n OW.error(json.message);\n }\n else\n {\n OW.error(" . json_encode(OW::getLanguage()->text('mailbox', 'write_permission_denied')) . ");\n }\n }\n else if ( json.result == 'display_captcha' )\n \t{\n window." . $captcha->jsObjectName . ".refresh();\n\n if ( captcha.attr('disabled') != 'disabled' )\n {\n owForms['mailbox-create-conversation-form'].getElement('captcha').showError(" . json_encode(OW::getLanguage()->text('base', 'form_validator_captcha_error_message')) . ");\n }\n else\n {\n captcha.removeAttr('disabled');\n }\n\n from.find('tr.captcha').show();\n from.find('tr.mailbox_conversation').hide();\n }\n else if ( json.result == true )\n \t{\n \t window.mailbox_send_message_floatbox.close();\n \$('#attach_file_inputs').hide();\n\n captcha.attr('disabled','disabled');\n from.find('tr.captcha').hide();\n owForms['mailbox-create-conversation-form'].resetForm();\n window." . $captcha->jsObjectName . ".refresh();\n\n \t OW.info('{$messageSuccess}');\n from.find('tr.captcha').hide();\n from.find('tr.mailbox_conversation').show();\n }\n else\n {\n OW.error('{$messageError}');\n }\n\n \$('#mailbox-create-conversation-form input[name=userId]').val(" . $interlocutorId . ");\n\n \t} ); "; OW::getDocument()->addOnloadScript($js); } }
public function __construct($feedAutoId, $feedType, $feedId, $actionVisibility) { $this->feedAutoId = $feedAutoId; parent::__construct(); $field = new HiddenField('feedType'); $field->setValue($feedType); $this->addElement($field); $field = new HiddenField('feedId'); $field->setValue($feedId); $this->addElement($field); $field = new HiddenField('visibility'); $field->setValue($actionVisibility); $this->addElement($field); $this->setAction(OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlFor('QUESTIONS_CTRL_Questions', 'newsfeedAdd'))); }
/** * Form constructor. * @param string */ public function __construct($name = NULL) { $this->element = Html::el('form'); $this->element->action = ''; // RFC 1808 -> empty uri means 'this' $this->element->method = self::POST; $this->element->id = $name === NULL ? NULL : 'frm-' . $name; $this->monitor(__CLASS__); if ($name !== NULL) { $tracker = new HiddenField($name); $tracker->unmonitor(__CLASS__); $this[self::TRACKER_ID] = $tracker; } parent::__construct(NULL, $name); }
public function __construct() { parent::__construct('goal-edit-form'); $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); $lang = OW::getLanguage(); $id = new HiddenField('projectId'); $id->setRequired(true); $this->addElement($id); $name = new TextField('name'); $name->setRequired(true); $name->setLabel($lang->text('ocsfundraising', 'name')); $this->addElement($name); $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML); $desc = new WysiwygTextarea('description', $btnSet); $desc->setRequired(true); $sValidator = new StringValidator(1, 50000); $desc->addValidator($sValidator); $desc->setLabel($lang->text('ocsfundraising', 'description')); $this->addElement($desc); $category = new Selectbox('category'); $category->setLabel($lang->text('ocsfundraising', 'category')); $list = OCSFUNDRAISING_BOL_Service::getInstance()->getCategoryList(); if ($list) { foreach ($list as $cat) { $category->addOption($cat->id, $lang->text('ocsfundraising', 'category_' . $cat->id)); } } $this->addElement($category); $target = new TextField('target'); $target->setRequired(true); $target->setLabel($lang->text('ocsfundraising', 'target_amount')); $this->addElement($target); $min = new TextField('min'); $min->setLabel($lang->text('ocsfundraising', 'min_amount')); $min->setValue(1); $this->addElement($min); $end = new DateField('end'); $end->setMinYear(date('Y')); $end->setMaxYear(date('Y') + 2); $end->setLabel($lang->text('ocsfundraising', 'end_date')); $this->addElement($end); $imageField = new FileField('image'); $imageField->setLabel($lang->text('ocsfundraising', 'image_label')); $this->addElement($imageField); $submit = new Submit('edit'); $submit->setLabel($lang->text('ocsfundraising', 'edit')); $this->addElement($submit); }
public function FieldHolder($properties = array()) { Requirements::css(LINKABLE_PATH . '/css/embeddedobjectfield.css'); Requirements::javascript(LINKABLE_PATH . '/javascript/embeddedobjectfield.js'); if ($this->object && $this->object->ID) { $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL')); if (strlen($this->object->SourceURL)) { $properties['ObjectTitle'] = TextField::create($this->getName() . '[title]', _t('Linkable.TITLE', 'Title')); $properties['Width'] = TextField::create($this->getName() . '[width]', _t('Linkable.WIDTH', 'Width')); $properties['Height'] = TextField::create($this->getName() . '[height]', _t('Linkable.HEIGHT', 'Height')); $properties['ThumbURL'] = HiddenField::create($this->getName() . '[thumburl]', ''); $properties['Type'] = HiddenField::create($this->getName() . '[type]', ''); $properties['EmbedHTML'] = HiddenField::create($this->getName() . '[embedhtml]', ''); $properties['ObjectDescription'] = TextAreaField::create($this->getName() . '[description]', _t('Linkable.DESCRIPTION', 'Description')); $properties['ExtraClass'] = TextField::create($this->getName() . '[extraclass]', _t('Linkable.CSSCLASS', 'CSS class')); foreach ($properties as $key => $field) { if ($key == 'ObjectTitle') { $key = 'Title'; } elseif ($key == 'ObjectDescription') { $key = 'Description'; } $field->setValue($this->object->{$key}); } if ($this->object->ThumbURL) { $properties['ThumbImage'] = LiteralField::create($this->getName(), '<img src="' . $this->object->ThumbURL . '" />'); } } } else { $properties['SourceURL'] = TextField::create($this->getName() . '[sourceurl]', '')->setAttribute('placeholder', _t('Linkable.SOURCEURL', 'Source URL')); } $field = parent::FieldHolder($properties); return $field; }
/** * A simple form for creating blog entries */ function FrontEndPostForm() { if ($this->owner->request->latestParam('ID')) { $id = (int) $this->owner->request->latestParam('ID'); } else { $id = 0; } $membername = Member::currentUser() ? Member::currentUser()->getName() : ""; // Set image upload $uploadfield = UploadField::create('FeaturedImage', _t('BlogFrontEnd.ShareImage', "Share an image")); $uploadfield->setCanAttachExisting(false); $uploadfield->setCanPreviewFolder(false); $uploadfield->setAllowedFileCategories('image'); $uploadfield->relationAutoSetting = false; if (BlogFrontEnd::config()->allow_wysiwyg_editing) { $content_field = TrumbowygHTMLEditorField::create("Content", _t("BlogFrontEnd.Content")); } else { $content_field = TextareaField::create("Content", _t("BlogFrontEnd.Content")); } $form = new Form($this->owner, 'FrontEndPostForm', $fields = new FieldList(HiddenField::create("ID", "ID"), TextField::create("Title", _t('BlogFrontEnd.Title', "Title")), $uploadfield, $content_field), $actions = new FieldList(FormAction::create('doSavePost', _t('BlogFrontEnd.PostEntry', 'Post Entry'))), new RequiredFields('Title')); $uploadfield->setForm($form); if ($this->owner->Categories()->exists()) { $fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.PostUnderCategories", "Post this in a category? (optional)"), $this->owner->Categories()->map())); } if ($this->owner->Tags()->exists()) { $fields->add(CheckboxsetField::create("Categories", _t("BlogFrontEnd.AddTags", "Add a tag? (optional)"), $this->owner->Tags()->map())); } if ($id && ($post = BlogPost::get()->byID($id))) { $form->loadDataFrom($post); } $this->owner->extend("updateFrontEndPostForm", $form); return $form; }
public function AddNewListboxForm() { $action = FormAction::create('doSave', 'Save')->setUseButtonTag('true'); if (!$this->isFrontend) { $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'); } $model = $this->getModel(); $link = singleton($model); $fields = $link->getCMSFields(); $title = $this->getDialogTitle() ? $this->getDialogTitle() : 'New Item'; $fields->insertBefore(HeaderField::create('AddNewHeader', $title), $fields->first()->getName()); $actions = FieldList::create($action); $form = Form::create($this, 'AddNewListboxForm', $fields, $actions); $fields->push(HiddenField::create('model', 'model', $model)); /* if($link){ $form->loadDataFrom($link); $fields->push(HiddenField::create('LinkID', 'LinkID', $link->ID)); } // Chris Bolt, fixed this //$this->owner->extend('updateLinkForm', $form); $this->extend('updateLinkForm', $form); // End Chris Bolt */ return $form; }
/** * * @param type $value */ public function setValue($value) { if (is_string($value)) { $this->gridStateData = new GridState_Data(json_decode($value, true)); } parent::setValue($value); }
/** * The LinkForm for the dialog window * * @return Form **/ public function LinkForm() { $link = $this->getLinkObject(); $action = FormAction::create('doSaveLink', _t('Linkable.SAVE', 'Save'))->setUseButtonTag('true'); if (!$this->isFrontend) { $action->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept'); } $link = null; if ($linkID = (int) $this->request->getVar('LinkID')) { $link = Link::get()->byID($linkID); } $link = $link ? $link : singleton('Link'); $link->setAllowedTypes($this->getAllowedTypes()); $fields = $link->getCMSFields(); $title = $link ? _t('Linkable.EDITLINK', 'Edit Link') : _t('Linkable.ADDLINK', 'Add Link'); $fields->insertBefore(HeaderField::create('LinkHeader', $title), _t('Linkable.TITLE', 'Title')); $actions = FieldList::create($action); $form = Form::create($this, 'LinkForm', $fields, $actions); if ($link) { $form->loadDataFrom($link); $fields->push(HiddenField::create('LinkID', 'LinkID', $link->ID)); } $this->owner->extend('updateLinkForm', $form); return $form; }