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 __construct() { parent::__construct('upload-form'); $language = OW::getLanguage(); $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); $fileField = new FileField('photo'); //$fileField->setRequired(true); $this->addElement($fileField); // album Field $albumField = new TextField('album'); $albumField->setRequired(true); $albumField->setHasInvitation(true); $albumField->setId('album_input'); $albumField->setInvitation($language->text('photo', 'create_album')); $this->addElement($albumField); // description Field $descField = new Textarea('description'); $descField->setHasInvitation(true); $descField->setInvitation($language->text('photo', 'describe_photo')); $this->addElement($descField); $cancel = new Submit('cancel', false); $cancel->setValue($language->text('base', 'cancel_button')); $this->addElement($cancel); $submit = new Submit('submit', false); $this->addElement($submit); }
/** * 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')); }
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($name, $senderId, $context = MCOMPOSE_BOL_Service::CONTEXT_USER, $initJs = true, $inPopup = true) { parent::__construct($name); $language = OW::getLanguage(); $this->userId = $senderId; $this->context = $context; $this->setAction(OW::getRouter()->urlFor('MCOMPOSE_CTRL_Compose', 'send', array('userId' => $senderId, 'formName' => $this->getName()))); $this->setMethod(self::METHOD_POST); $this->setId($this->getName()); $this->setEnctype('multipart/form-data'); $this->setAjax(); $this->setAjaxResetOnSuccess(false); $to = new MCOMPOSE_CLASS_UserSelectField('recipients', OW::getLanguage()->text('mcompose', 'selector_invitation_label')); $to->setRequired(); $this->addElement($to); //thickbox $validatorSubject = new StringValidator(0, 2048); $validatorSubject->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 2048))); $subject = new TextField('subject'); $subject->setInvitation('Subject'); $subject->setHasInvitation(true); $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), true); $message->setLabel($language->text('mailbox', 'text'))->addAttribute('class', 'ow_text'); $message->setSize(300); $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 $captcha = new MailboxCaptchaField('captcha'); $captcha->addValidator(new MailboxCaptchaValidator($captcha->getId())); $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 ($initJs) { $js = "owForms['" . $this->getName() . "'].bind( 'success',\n function( json )\n {\n var _complete = function(){ \n if ( _scope.floatBox ) _scope.floatBox.close();\n };\n\n var form = \$('#" . $this->getName() . "');\n var captcha = form.find('input[name=captcha]');\n\n if ( json.result == 'permission_denied' )\n {\n if ( json.message )\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 _complete();\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['" . $this->getName() . "'].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 form.find('tr.captcha').show();\n form.find('tr.mailbox_conversation').hide();\n }\n else if ( json.result == true )\n \t{\n captcha.attr('disabled','disabled');\n form.find('tr.captcha').hide();\n window." . $captcha->jsObjectName . ".refresh();\n\n form.find('tr.captcha').hide();\n form.find('tr.mailbox_conversation').show();\n\n owForms['" . $this->getName() . "'].resetForm();\n form.find('textarea[name=message]').get(0).htmlareaRefresh();\n\n if ( json.error )\n OW.error(json.error);\n\n if ( json.warning )\n OW.warning(json.warning);\n\n if ( json.message )\n OW.info(json.message);\n \n _complete();\n }\n else if ( json.error )\n {\n OW.error(json.error);\n \n _complete();\n }\n\n }); "; OW::getDocument()->addOnloadScript($js); } }
public function index($params) { $this->setPageTitle(OW::getLanguage()->text('spdownload', 'category_index_page_title')); $this->setPageHeading(OW::getLanguage()->text('spdownload', 'category_index_page_heading')); $category = array(); if (!empty($params) && isset($params['categoryId'])) { $category = SPDOWNLOAD_BOL_CategoryDao::getInstance()->findById($params['categoryId']); } $downloads = SPDOWNLOAD_BOL_CategoryService::getInstance()->getCategoryList(); $downloadCategories = array(); foreach ($downloads as $key => $value) { $downloadCategories[$value->id] = $value->name; } $form = new Form('add_category'); $this->addForm($form); // Create selectbox $fieldTo = new SelectBox('parent_category'); foreach ($downloadCategories as $key => $label) { $fieldTo->addOption($key, $label); } if (!empty($params) && isset($params['categoryId'])) { $fieldTo->setValue($category->parentId); } $fieldTo->setLabel(OW::getLanguage()->text('spdownload', 'ad_parent_category')); $form->addElement($fieldTo); $fieldCate = new TextField('category'); $fieldCate->setLabel(OW::getLanguage()->text('spdownload', 'ad_label_category')); if (!empty($params) && isset($params['categoryId'])) { $fieldCate->setValue($category->name); } $fieldCate->setRequired(); $fieldCate->setHasInvitation(true); $form->addElement($fieldCate); $submit = new Submit('add'); $submit->setValue(OW::getLanguage()->text('spdownload', 'form_add_category_submit')); $form->addElement($submit); if (OW::getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); if ($data['parent_category'] == null) { $data['parent_category'] = 0; } if (!empty($params) && isset($params['categoryId'])) { SPDOWNLOAD_BOL_CategoryService::getInstance()->addCategory($data['category'], $data['parent_category'], $params['categoryId']); } else { SPDOWNLOAD_BOL_CategoryService::getInstance()->addCategory($data['category'], $data['parent_category']); } $this->redirect(OW::getRouter()->urlForRoute('spdownload.category_list')); } } }
public function __construct($photoId = NULL) { parent::__construct('photo-edit-form'); $this->setAjax(TRUE); $this->setAction(OW::getRouter()->urlFor('PHOTO_CTRL_Photo', 'ajaxUpdatePhoto')); $this->bindJsFunction('success', 'function( data ) { OW.trigger("photo.afterPhotoEdit", data); }'); $photo = PHOTO_BOL_PhotoService::getInstance()->findPhotoById($photoId); $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($photo->albumId); $photoIdField = new HiddenField('photoId'); $photoIdField->setRequired(TRUE); $photoIdField->setValue($photo->id); $photoIdField->addValidator(new PHOTO_CLASS_PhotoOwnerValidator()); $this->addElement($photoIdField); $albumField = new TextField('album'); $albumField->setId('ajax-upload-album'); $albumField->setRequired(); $albumField->setValue($album->name); $albumField->setLabel(OW::getLanguage()->text('photo', 'create_album')); $albumField->addAttribute('class', 'ow_dropdown_btn ow_inputready ow_cursor_pointer'); $albumField->addAttribute('autocomplete', 'off'); $albumField->addAttribute('readonly'); $this->addElement($albumField); $albumNameField = new TextField('album-name'); $albumNameField->setRequired(); $albumNameField->setValue($album->name); $albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(FALSE, NULL, $album->name)); $albumNameField->setHasInvitation(TRUE); $albumNameField->setInvitation(OW::getLanguage()->text('photo', 'album_name')); $albumNameField->addAttribute('class', 'ow_smallmargin invitation'); $this->addElement($albumNameField); $desc = new Textarea('description'); $desc->setHasInvitation(TRUE); $desc->setInvitation(OW::getLanguage()->text('photo', 'album_desc')); $this->addElement($desc); $photoDesc = new PHOTO_CLASS_HashtagFormElement('photo-desc'); $photoDesc->setValue($photo->description); $photoDesc->setLabel(OW::getLanguage()->text('photo', 'album_desc')); $this->addElement($photoDesc); $submit = new Submit('edit'); $submit->setValue(OW::getLanguage()->text('photo', 'btn_edit')); $this->addElement($submit); }
public function __construct($name, $affiliateId = null) { parent::__construct($name); $this->setAction(OW::getRouter()->urlForRoute('ocsaffiliates.action_assign_user')); $this->setAjax(); $this->setAjaxResetOnSuccess(false); $lang = OW::getLanguage(); $user = new TextField('user'); $user->setLabel($lang->text('ocsaffiliates', 'assign_to_username')); $user->setInvitation($lang->text('ocsaffiliates', 'username')); $user->setHasInvitation(true); $user->setRequired(true); $this->addElement($user); $affiliate = new HiddenField('affiliateId'); $affiliate->setRequired(true); $this->addElement($affiliate); $submit = new Submit('assign'); $submit->setValue($lang->text('ocsaffiliates', 'assign_btn')); $this->addElement($submit); $this->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n if ( data.result == 'false' ) {\n OW.error(data.error);\n }\n else {\n document.location.reload();\n }\n }"); }
public function dept() { $this->setPageTitle(OW::getLanguage()->text('contactus', 'admin_dept_title')); $this->setPageHeading(OW::getLanguage()->text('contactus', 'admin_dept_heading')); $contactEmails = array(); $deleteUrls = array(); $contacts = CONTACTUS_BOL_Service::getInstance()->getDepartmentList(); foreach ($contacts as $contact) { /* @var $contact CONTACTUS_BOL_Department */ $contactEmails[$contact->id]['name'] = $contact->id; $contactEmails[$contact->id]['email'] = $contact->email; $contactEmails[$contact->id]['label'] = CONTACTUS_BOL_Service::getInstance()->getDepartmentLabel($contact->id); $deleteUrls[$contact->id] = OW::getRouter()->urlFor(__CLASS__, 'delete', array('id' => $contact->id)); } $this->assign('contacts', $contactEmails); $this->assign('deleteUrls', $deleteUrls); $form = new Form('add_dept'); $this->addForm($form); $fieldEmail = new TextField('email'); $fieldEmail->setRequired(); $fieldEmail->addValidator(new EmailValidator()); $fieldEmail->setInvitation(OW::getLanguage()->text('contactus', 'label_invitation_email')); $fieldEmail->setHasInvitation(true); $form->addElement($fieldEmail); $fieldLabel = new TextField('label'); $fieldLabel->setRequired(); $fieldLabel->setInvitation(OW::getLanguage()->text('contactus', 'label_invitation_label')); $fieldLabel->setHasInvitation(true); $form->addElement($fieldLabel); $submit = new Submit('add'); $submit->setValue(OW::getLanguage()->text('contactus', 'form_add_dept_submit')); $form->addElement($submit); if (OW::getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); CONTACTUS_BOL_Service::getInstance()->addDepartment($data['email'], $data['label']); $this->redirect(); } } }
public function categories() { $adminForm = new Form('categoriesForm'); $language = OW::getLanguage(); $element = new TextField('categoryName'); $element->setRequired(); $element->setInvitation($language->text('advancedphoto', 'admin_category_name')); $element->setHasInvitation(true); $adminForm->addElement($element); $element = new Submit('addCategory'); $element->setValue($language->text('advancedphoto', 'admin_add_category')); $adminForm->addElement($element); if (OW::getRequest()->isPost()) { if ($adminForm->isValid($_POST)) { $values = $adminForm->getValues(); $name = ucwords(strtolower($values['categoryName'])); $desc = ucwords(strtolower($values['categoryDesc'])); if (ADVANCEDPHOTO_BOL_CategoryService::getInstance()->addCategory($name, $desc)) { OW::getFeedback()->info($language->text('advancedphoto', 'admin_add_category_success')); } else { OW::getFeedback()->error($language->text('advancedphoto', 'admin_add_category_error')); } $this->redirect(); } } $this->addForm($adminForm); $allCategories = array(); $deleteUrls = array(); $categories = ADVANCEDPHOTO_BOL_CategoryService::getInstance()->getCategoriesList(); foreach ($categories as $category) { $allCategories[$category->id]['id'] = $category->id; $allCategories[$category->id]['name'] = $category->name; $deleteUrls[$category->id] = OW::getRouter()->urlFor(__CLASS__, 'delete', array('id' => $category->id)); } $this->assign('allCategories', $allCategories); $this->assign('deleteUrls', $deleteUrls); }
/** * Class constructor * */ public function __construct($maxUploadMaxFilesize) { parent::__construct('userSettingsForm'); $this->setEnctype("multipart/form-data"); $language = OW::getLanguage(); // avatar size Field $avatarSize = new TextField('avatarSize'); $avatarSize->setRequired(true); $validator = new IntValidator(40, 150); $validator->setErrorMessage($language->text('admin', 'user_settings_avatar_size_error', array('max' => 150))); $avatarSize->addValidator($validator); $this->addElement($avatarSize->setLabel($language->text('admin', 'user_settings_avatar_size_label'))); // big avatar size Field $bigAvatarSize = new TextField('bigAvatarSize'); $bigAvatarSize->setRequired(true); $validator = new IntValidator(150, 250); $validator->setErrorMessage($language->text('admin', 'user_settings_big_avatar_size_error', array('max' => 250))); $bigAvatarSize->addValidator($validator); $this->addElement($bigAvatarSize->setLabel($language->text('admin', 'user_settings_big_avatar_size_label'))); // --- avatar max size $maxUploadMaxFilesizeValidator = new FloatValidator(0, $maxUploadMaxFilesize); $maxUploadMaxFilesizeValidator->setErrorMessage($language->text('admin', 'settings_max_upload_size_error')); $avatarMaxUploadSize = new TextField('avatar_max_upload_size'); $avatarMaxUploadSize->setLabel($language->text('admin', 'input_settings_avatar_max_upload_size_label')); $avatarMaxUploadSize->addValidator($maxUploadMaxFilesizeValidator); $this->addElement($avatarMaxUploadSize); // --- avatar max size if (!defined('OW_PLUGIN_XP')) { // confirm Email $confirmEmail = new CheckboxField('confirmEmail'); $confirmEmail->setValue(OW::getConfig()->getValue('base', 'confirm_email')); $this->addElement($confirmEmail->setLabel($language->text('admin', 'user_settings_confirm_email'))); } // display name Field $displayNameField = new Selectbox('displayName'); $displayNameField->setRequired(true); $questions = array('username' => $language->text('base', 'questions_question_username_label'), 'realname' => $language->text('base', 'questions_question_realname_label')); $displayNameField->setHasInvitation(false); $displayNameField->setOptions($questions); $this->addElement($displayNameField->setLabel($language->text('admin', 'user_settings_display_name'))); $avatar = new FileField('avatar'); $this->addElement($avatar); $bigAvatar = new FileField('bigAvatar'); $this->addElement($bigAvatar); // -- $joinConfigField = new Selectbox('join_display_photo_upload'); $options = array(BOL_UserService::CONFIG_JOIN_DISPLAY_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_display_label'), BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_display_and_require_label'), BOL_UserService::CONFIG_JOIN_NOT_DISPLAY_PHOTO_UPLOAD => $language->text('base', 'config_join_display_photo_upload_not_display_label')); $joinConfigField->addOptions($options); $joinConfigField->setHasInvitation(false); $joinConfigField->setValue(OW::getConfig()->getValue('base', 'join_display_photo_upload')); $this->addElement($joinConfigField); // -- $joinConfigField = new CheckboxField('join_display_terms_of_use'); $joinConfigField->setValue(OW::getConfig()->getValue('base', 'join_display_terms_of_use')); $this->addElement($joinConfigField); //--- privacy -----/// $config = OW::getConfig(); $baseConfigs = $config->getValues('base'); $userApprove = new CheckboxField('user_approve'); $userApprove->setLabel($language->text('admin', 'permissions_index_user_approve')); $this->addElement($userApprove); $whoCanJoin = new RadioField('who_can_join'); $whoCanJoin->addOptions(array('1' => $language->text('admin', 'permissions_index_anyone_can_join'), '2' => $language->text('admin', 'permissions_index_by_invitation_only_can_join'))); $whoCanJoin->setLabel($language->text('admin', 'permissions_index_who_can_join')); $this->addElement($whoCanJoin); $whoCanInvite = new RadioField('who_can_invite'); $whoCanInvite->addOptions(array('1' => $language->text('admin', 'permissions_index_all_users_can_invate'), '2' => $language->text('admin', 'permissions_index_admin_only_can_invate'))); $whoCanInvite->setLabel($language->text('admin', 'permissions_index_who_can_invite')); $this->addElement($whoCanInvite); $guestsCanView = new RadioField('guests_can_view'); $guestsCanView->addOptions(array('1' => $language->text('admin', 'permissions_index_yes'), '2' => $language->text('admin', 'permissions_index_no'), '3' => $language->text('admin', 'permissions_index_with_password'))); $guestsCanView->setLabel($language->text('admin', 'permissions_index_guests_can_view_site')); $guestsCanView->setDescription($language->text('admin', 'permissions_idex_if_not_yes_will_override_settings')); $this->addElement($guestsCanView); $password = new TextField('password'); $password->setHasInvitation(true); if ($baseConfigs['guests_can_view'] == 3) { $password->setInvitation($language->text('admin', 'change_password')); } else { $password->setInvitation($language->text('admin', 'add_password')); } $this->addElement($password); // --- // //-- profile questions --// $userViewPresentationnew = new CheckboxField("user_view_presentation"); $userViewPresentationnew->setLabel($language->text('base', 'questions_config_user_view_presentation_label')); $userViewPresentationnew->setDescription($language->text('base', 'questions_config_user_view_presentation_description')); $this->addElement($userViewPresentationnew); // --- // // submit $submit = new Submit('save'); $submit->setValue($language->text('admin', 'save_btn_label')); $this->addElement($submit); }
public function __construct($link) { parent::__construct('save'); $language = OW::getLanguage()->getInstance(); $this->link = $link; $urlField = new TextField('url'); $urlField->setHasInvitation(true)->setInvitation('http://www.example.com'); $this->addElement($urlField->setRequired(true)->addValidator(new UrlValidator())->setLabel($language->text('links', 'save_form_url_field_label'))->setValue($this->link->getUrl())); $titleField = new TextField('title'); $this->addElement($titleField->setRequired(true)->setLabel($language->text('links', 'save_form_title_field_label'))->setValue($this->link->getTitle())); $descriptionTextArea = new WysiwygTextarea('description'); $descriptionTextArea->setLabel($language->text('links', 'save_form_desc_field_label')); $descriptionTextArea->setValue($this->link->getDescription()); $descriptionTextArea->setRequired(true); $this->addElement($descriptionTextArea); $tagService = BOL_TagService::getInstance(); $tags = array(); if (intval($this->link->getId()) > 0) { $arr = $tagService->findEntityTags($this->link->getId(), 'link'); foreach (!empty($arr) ? $arr : array() as $dto) { $tags[] = $dto->getLabel(); } } $tagsField = new TagsInputField('tags'); $tagsField->setLabel($language->text('links', 'save_form_tags_field_label')); $tagsField->setValue($tags); $tagsField->setDelimiterChars(array('.')); $this->addElement($tagsField); // $tagsField = new TagsField('tags', $tags); // $this->addElement($tagsField->setLabel($language->text('links', 'save_form_tags_field_label'))); $submit = new Submit('submit'); $this->addElement($submit); }
public function sponsor() { $language = OW::getLanguage(); $config = OW::getConfig(); $sponsorForm = new Form('sponsorForm'); $sponsorForm->setEnctype('multipart/form-data'); $element = new TextField('sponsorName'); $element->setRequired(true); $element->setLabel($language->text('sponsors', 'sponsor_name')); $element->setInvitation($language->text('sponsors', 'sponsor_name_desc')); $element->setHasInvitation(true); $sponsorForm->addElement($element); $element = new TextField('sponsorEmail'); $element->setRequired(true); $validator = new EmailValidator(); $validator->setErrorMessage($language->text('sponsors', 'invalid_email_format')); $element->addValidator($validator); $element->setLabel($language->text('sponsors', 'sponsor_email')); $element->setInvitation($language->text('sponsors', 'sponsor_email_desc')); $element->setHasInvitation(true); $sponsorForm->addElement($element); $element = new TextField('sponsorWebsite'); $element->setRequired(true); $validator = new UrlValidator(); $validator->setErrorMessage($language->text('sponsors', 'invalid_url_format')); $element->addValidator($validator); $element->setLabel($language->text('sponsors', 'sponsor_website')); $element->setInvitation($language->text('sponsors', 'sponsor_website_desc')); $element->setHasInvitation(true); $sponsorForm->addElement($element); if ($config->getValue('sponsors', 'minimumPayment') > 0) { $element = new TextField('sponsorAmount'); $element->setRequired(true); $element->setValue($config->getValue('sponsors', 'minimumPayment')); $minAmount = $config->getValue('sponsors', 'minimumPayment'); $validator = new FloatValidator($minAmount); $validator->setErrorMessage($language->text('sponsors', 'invalid_sponsor_amount', array('minAmount' => $minAmount))); $element->addValidator($validator); $element->setLabel($language->text('sponsors', 'sponsor_payment_amount')); $element->setInvitation($language->text('sponsors', 'sponsor_payment_amount_desc', array('minAmount' => $minAmount))); $element->setHasInvitation(true); $sponsorForm->addElement($element); } $element = new FileField('sponsorImage'); $element->setLabel($language->text('sponsors', 'sponsorsh_image_file')); $sponsorForm->addElement($element); if ($config->getValue('sponsors', 'minimumPayment') > 0) { $element = new BillingGatewaySelectionField('gateway'); $element->setRequired(true); $element->setLabel($language->text('sponsors', 'payment_gatway_selection')); $sponsorForm->addElement($element); } $element = new Submit('becomeSponsor'); $element->setValue(OW::getLanguage()->text('sponsors', 'become_sponsor_btn')); $sponsorForm->addElement($element); if (OW::getRequest()->isPost()) { if ($sponsorForm->isValid($_POST)) { $values = $sponsorForm->getValues(); if (isset($_FILES['sponsorImage']) && in_array(UTIL_File::getExtension($_FILES['sponsorImage']['name']), $this->allowedImageExtensions)) { $backupPath = OW::getPluginManager()->getPlugin('sponsors')->getUserFilesDir() . $_FILES['sponsorImage']['name']; move_uploaded_file($_FILES['sponsorImage']['tmp_name'], $backupPath); $sponsorImageFile = $_FILES['sponsorImage']['name']; } else { $sponsorImageFile = "defaultSponsor.jpg"; } if (isset($values['sponsorAmount']) && $values['gateway']) { $billingService = BOL_BillingService::getInstance(); if (empty($values['gateway']['url']) || empty($values['gateway']['key']) || !($gateway = $billingService->findGatewayByKey($values['gateway']['key']) || !$gateway->active)) { OW::getFeedback()->error($language->text('base', 'billing_gateway_not_found')); $this->redirect(); } $productAdapter = new SPONSORS_CLASS_SponsorProductAdapter(); $sale = new BOL_BillingSale(); $sale->pluginKey = 'sponsors'; $sale->entityDescription = $language->text('sponsors', 'sponsor_payment_gateway_text'); $sale->entityKey = $productAdapter->getProductKey(); $sale->entityId = time(); $sale->price = floatval($values['sponsorAmount']); $sale->period = null; $sale->userId = OW::getUser()->getId() ? OW::getUser()->getId() : 0; $sale->recurring = 0; $extraData = array(); $extraData['sponsorName'] = $values['sponsorName']; $extraData['sponsorEmail'] = $values['sponsorEmail']; $extraData['sponsorWebsite'] = $values['sponsorWebsite']; $extraData['sponsorAmount'] = $values['sponsorAmount']; $extraData['sponsorImage'] = $sponsorImageFile; $extraData['status'] = $config->getValue('sponsors', 'autoApprove') == '1' ? 1 : 0; $extraData['validity'] = $config->getValue('sponsors', 'sponsorValidity'); $sale->setExtraData($extraData); $saleId = $billingService->initSale($sale, $values['gateway']['key']); if ($saleId) { $billingService->storeSaleInSession($saleId); $billingService->setSessionBackUrl($productAdapter->getProductOrderUrl()); OW::getApplication()->redirect($values['gateway']['url']); } } else { $sponsor = new SPONSORS_BOL_Sponsor(); $sponsor->name = $values['sponsorName']; $sponsor->email = $values['sponsorEmail']; $sponsor->website = $values['sponsorWebsite']; $sponsor->price = 0; $sponsor->image = $sponsorImageFile; $sponsor->userId = OW::getUser()->getId() ? OW::getUser()->getId() : 0; $sponsor->status = $config->getValue('sponsors', 'autoApprove') == '1' ? 1 : 0; $sponsor->validity = $config->getValue('sponsors', 'sponsorValidity'); $sponsor->timestamp = time(); if (SPONSORS_BOL_Service::getInstance()->addSponsor($sponsor)) { if ($sponsor->status == 1) { OW::getFeedback()->info(OW::getLanguage()->text('sponsors', 'sponsor_live_notification')); } else { OW::getFeedback()->info(OW::getLanguage()->text('sponsors', 'sponsor_live_notification_after_approval')); } } else { OW::getFeedback()->error(OW::getLanguage()->text('sponsors', 'sponsor_add_error')); } } } } $this->addForm($sponsorForm); $fields = array(); foreach ($sponsorForm->getElements() as $element) { if (!$element instanceof HiddenField) { $fields[$element->getName()] = $element->getName(); } } $this->assign('formData', $fields); $this->setPageHeading(OW::getLanguage()->text('sponsors', 'become_sponsor_heading')); $this->setPageTitle(OW::getLanguage()->text('sponsors', 'become_sponsor_title')); $this->setPageHeadingIconClass('ow_ic_gear_wheel'); }
public function __construct() { parent::__construct(self::FORM_NAME); $language = OW::getLanguage(); $this->setAjax(); $this->setAjaxResetOnSuccess(false); $this->setAction(OW::getRouter()->urlFor('PHOTO_CTRL_AjaxUpload', 'checkFakeAlbumData')); $this->bindJsFunction(self::BIND_SUCCESS, UTIL_JsGenerator::composeJsString('function( data ) { if ( !data.result ) { var form = owForms[this.name]; Object.keys(data.errors).forEach(function( item ) { var arr = data.errors[item]; if ( arr.length !== 0 ) { form.getElement(item).showError(arr.shift()); } }); return; } if ( OW.getActiveFloatBox() ) OW.getActiveFloatBox().close(); var formData = data.data; var params = { albumId: 0, albumName: formData[{$album_name}], albumDescription: formData[{$album_desc}], url: "", data: formData }; var ajaxUploadPhotoFB = OW.ajaxFloatBox("PHOTO_CMP_AjaxUpload", params, { title: {$title}, width: "746px", onLoad: function() { OW.trigger("photo.ready_fake_album", [formData]); } }); ajaxUploadPhotoFB.bind("close", function() { if ( ajaxPhotoUploader.isHasData() ) { if ( confirm({$confirm}) ) { OW.trigger("photo.onCloseUploaderFloatBox"); return true; } return false; } else { OW.trigger("photo.onCloseUploaderFloatBox"); } }); }', array('album_name' => self::ELEMENT_ALBUM_NAME, 'album_desc' => self::ELEMENT_ALBUM_DESC, 'title' => $language->text('photo', 'upload_photos'), 'confirm' => $language->text('photo', 'close_alert')))); $albumNameInput = new TextField(self::ELEMENT_ALBUM_NAME); $albumNameInput->setRequired(); $albumNameInput->addValidator(new PHOTO_CLASS_AlbumNameValidator(false)); $albumNameInput->setHasInvitation(true); $albumNameInput->setInvitation($language->text('photo', 'album_name')); $this->addElement($albumNameInput); $albumDescInput = new Textarea(self::ELEMENT_ALBUM_DESC); $albumDescInput->setHasInvitation(true); $albumDescInput->setInvitation($language->text('photo', 'album_desc')); $this->addElement($albumDescInput); $submit = new Submit(self::SUBMIT_SUBMIT); $submit->setValue($language->text('photo', 'add_photos')); $this->addElement($submit); $this->triggerReady(); }
public function edit($params) { if (!isset($params['id']) || !($id = (int) $params['id'])) { throw new Redirect404Exception(); return; } $language = OW::getLanguage(); $config = OW::getConfig(); $sponsor = SPONSORS_BOL_Service::getInstance()->findSponsorById($id); if (!$sponsor->id) { throw new Redirect404Exception(); return; } $sponsorForm = new Form('sponsorForm'); $sponsorForm->setEnctype('multipart/form-data'); $element = new TextField('sponsorName'); $element->setRequired(true); $element->setLabel($language->text('sponsors', 'sponsor_name')); $element->setInvitation($language->text('sponsors', 'sponsor_name_desc')); $element->setValue($sponsor->name); $element->setHasInvitation(true); $sponsorForm->addElement($element); $element = new TextField('sponsorEmail'); $element->setRequired(true); $validator = new EmailValidator(); $validator->setErrorMessage($language->text('sponsors', 'invalid_email_format')); $element->addValidator($validator); $element->setLabel($language->text('sponsors', 'sponsor_email')); $element->setInvitation($language->text('sponsors', 'sponsor_email_desc')); $element->setValue($sponsor->email); $element->setHasInvitation(true); $sponsorForm->addElement($element); $element = new TextField('sponsorWebsite'); $element->setRequired(true); $validator = new UrlValidator(); $validator->setErrorMessage($language->text('sponsors', 'invalid_url_format')); $element->addValidator($validator); $element->setLabel($language->text('sponsors', 'sponsor_website')); $element->setInvitation($language->text('sponsors', 'sponsor_website_desc')); $element->setHasInvitation(true); $element->setValue($sponsor->website); $sponsorForm->addElement($element); $element = new TextField('sponsorAmount'); $element->setRequired(true); $minAmount = $config->getValue('sponsors', 'minimumPayment'); $validator = new FloatValidator(0); $validator->setErrorMessage($language->text('sponsors', 'invalid_amount_value')); $element->addValidator($validator); $element->setLabel($language->text('sponsors', 'sponsor_payment_amount')); $element->setInvitation($language->text('sponsors', 'admin_payment_amount_desc')); $element->setHasInvitation(true); $element->setValue($sponsor->price); $sponsorForm->addElement($element); $element = new TextField('sponsorValidity'); $element->setRequired(true); $element->setValue($sponsor->validity); $validator = new IntValidator(0); $validator->setErrorMessage($language->text('sponsors', 'invalid_numeric_format')); $element->addValidator($validator); $element->setLabel($language->text('sponsors', 'sponsorship_validatity')); $element->setInvitation($language->text('sponsors', 'sponsorship_validatity_desc')); $element->setHasInvitation(true); $sponsorForm->addElement($element); $element = new FileField('sponsorImage'); $element->setLabel($language->text('sponsors', 'sponsorsh_image_file')); $sponsorForm->addElement($element); $element = new Submit('editSponsor'); $element->setValue(OW::getLanguage()->text('sponsors', 'edit_sponsor_btn')); $sponsorForm->addElement($element); if (OW::getRequest()->isPost()) { if ($sponsorForm->isValid($_POST)) { $values = $sponsorForm->getValues(); $allowedImageExtensions = array('jpg', 'jpeg', 'gif', 'png', 'tiff'); $sponsorImageFile = ""; if (isset($_FILES['sponsorImage']) && in_array(UTIL_File::getExtension($_FILES['sponsorImage']['name']), $allowedImageExtensions)) { $backupPath = OW::getPluginManager()->getPlugin('sponsors')->getUserFilesDir() . $_FILES['sponsorImage']['name']; move_uploaded_file($_FILES['sponsorImage']['tmp_name'], $backupPath); $sponsorImageFile = $_FILES['sponsorImage']['name']; } $sponsor->name = $values['sponsorName']; $sponsor->email = $values['sponsorEmail']; $sponsor->website = $values['sponsorWebsite']; $sponsor->price = $values['sponsorAmount']; if (!empty($sponsorImageFile)) { $sponsor->image = $sponsorImageFile; } $sponsor->userId = $sponsor->userId; $sponsor->status = $sponsor->status; $sponsor->validity = $values['sponsorValidity']; if (SPONSORS_BOL_Service::getInstance()->addSponsor($sponsor)) { OW::getFeedback()->info(OW::getLanguage()->text('sponsors', 'sponsor_edit_ok')); } else { OW::getFeedback()->error(OW::getLanguage()->text('sponsors', 'sponsor_edit_error')); } } } $this->addForm($sponsorForm); $fields = array(); foreach ($sponsorForm->getElements() as $element) { if (!$element instanceof HiddenField) { $fields[$element->getName()] = $element->getName(); } } $this->assign('formData', $fields); $this->assign('currentLogoImage', OW::getPluginManager()->getPlugin('sponsors')->getUserFilesUrl() . $sponsor->image); $this->setPageHeading(OW::getLanguage()->text('sponsors', 'edit_sponsor_heading')); $this->setPageTitle(OW::getLanguage()->text('sponsors', 'edit_sponsor_heading')); $this->setPageHeadingIconClass('ow_ic_edit'); }
public function __construct() { parent::__construct('add-category-form'); $lang = OW::getLanguage(); $category = new TextField('category'); $category->setRequired(true); $category->setHasInvitation(true); $category->setInvitation($lang->text('ocsfaq', 'category')); $category->setId("category_input"); $this->addElement($category); $submit = new Submit('add'); $submit->setValue($lang->text('ocsfaq', 'btn_add_category')); $this->addElement($submit); }
public function ftpAttrs() { $this->checkXP(); $language = OW::getLanguage(); $this->setPageHeading($language->text('admin', 'page_title_manage_plugins_ftp_info')); $this->setPageHeadingIconClass('ow_ic_gear_wheel'); $form = new Form('ftp'); $login = new TextField('host'); $login->setValue('localhost'); $login->setRequired(true); $login->setLabel($language->text('admin', 'plugins_manage_ftp_form_host_label')); $form->addElement($login); $login = new TextField('login'); $login->setHasInvitation(true); $login->setInvitation('login'); $login->setRequired(true); $login->setLabel($language->text('admin', 'plugins_manage_ftp_form_login_label')); $form->addElement($login); $password = new PasswordField('password'); $password->setHasInvitation(true); $password->setInvitation('password'); $password->setRequired(true); $password->setLabel($language->text('admin', 'plugins_manage_ftp_form_password_label')); $form->addElement($password); $port = new TextField('port'); $port->setValue(21); $port->addValidator(new IntValidator()); $port->setLabel($language->text('admin', 'plugins_manage_ftp_form_port_label')); $form->addElement($port); $submit = new Submit('submit'); $submit->setValue($language->text('admin', 'plugins_manage_ftp_form_submit_label')); $form->addElement($submit); $this->addForm($form); if (OW::getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); OW::getSession()->set('ftpAttrs', array('host' => trim($data['host']), 'login' => trim($data['login']), 'password' => trim($data['password']), 'port' => (int) $data['port'])); if (!empty($_GET['back_uri'])) { $this->redirect(OW_URL_HOME . urldecode($_GET['back_uri'])); } else { $this->redirectToAction('index'); } } } }
public function index() { $language = OW::getLanguage(); $config = OW::getConfig(); $baseConfigs = $config->getValues('base'); $form = new Form('privacy_settings'); $userApprove = new CheckboxField('user_approve'); $userApprove->setLabel($language->text('admin', 'permissions_index_user_approve')); $form->addElement($userApprove); $whoCanJoin = new RadioField('who_can_join'); $whoCanJoin->addOptions(array('1' => $language->text('admin', 'permissions_index_anyone_can_join'), '2' => $language->text('admin', 'permissions_index_by_invitation_only_can_join'))); $whoCanJoin->setLabel($language->text('admin', 'permissions_index_who_can_join')); $form->addElement($whoCanJoin); $whoCanInvite = new RadioField('who_can_invite'); $whoCanInvite->addOptions(array('1' => $language->text('admin', 'permissions_index_all_users_can_invate'), '2' => $language->text('admin', 'permissions_index_admin_only_can_invate'))); $whoCanInvite->setLabel($language->text('admin', 'permissions_index_who_can_invite')); $form->addElement($whoCanInvite); $guestsCanView = new RadioField('guests_can_view'); $guestsCanView->addOptions(array('1' => $language->text('admin', 'permissions_index_yes'), '2' => $language->text('admin', 'permissions_index_no'), '3' => $language->text('admin', 'permissions_index_with_password'))); $guestsCanView->setLabel($language->text('admin', 'permissions_index_guests_can_view_site')); $guestsCanView->setDescription($language->text('admin', 'permissions_idex_if_not_yes_will_override_settings')); $form->addElement($guestsCanView); $password = new TextField('password'); $password->setHasInvitation(true); if ($baseConfigs['guests_can_view'] == 3) { $password->setInvitation($language->text('admin', 'change_password')); } else { $password->setInvitation($language->text('admin', 'add_password')); } $form->addElement($password); $submit = new Submit('save'); $submit->setValue($language->text('admin', 'permissions_index_save')); $form->addElement($submit); $this->addForm($form); if (OW::getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); $config->saveConfig('base', 'who_can_join', (int) $data['who_can_join']); $config->saveConfig('base', 'who_can_invite', (int) $data['who_can_invite']); $config->saveConfig('base', 'mandatory_user_approve', (bool) $data['user_approve'] ? 1 : 0); if ((int) $data['guests_can_view'] === 3 && empty($data['password'])) { OW::getFeedback()->error($language->text('admin', 'permission_global_privacy_empty_pass_error_message')); return; } else { if ((int) $data['guests_can_view'] === 3 && strlen(trim($data['password'])) < 4) { OW::getFeedback()->error($language->text('admin', 'permission_global_privacy_pass_length_error_message')); return; } else { $adminEmail = OW::getUser()->getEmail(); $senderMail = $config->getValue('base', 'site_email'); $mail = OW::getMailer()->createMail(); $mail->addRecipientEmail($adminEmail); $mail->setSender($senderMail); $mail->setSenderSuffix(false); $mail->setSubject(OW::getLanguage()->text('admin', 'site_password')); $mail->setTextContent(OW::getLanguage()->text('admin', 'admin_password', array('password' => $data['password']))); try { OW::getMailer()->send($mail); } catch (Exception $e) { $logger = OW::getLogger('admin.send_password_message'); $logger->addEntry($e->getMessage()); $logger->writeLog(); } $data['password'] = crypt($data['password'], OW_PASSWORD_SALT); $config->saveConfig('base', 'guests_can_view', (int) $data['guests_can_view']); $config->saveConfig('base', 'guests_can_view_password', $data['password']); } } OW::getFeedback()->info($language->text('admin', 'permission_global_privacy_settings_success_message')); $this->redirect(); } } $baseConfigs = $config->getValues('base'); $form->getElement('who_can_join')->setValue($baseConfigs['who_can_join']); $form->getElement('who_can_invite')->setValue($baseConfigs['who_can_invite']); $form->getElement('guests_can_view')->setValue($baseConfigs['guests_can_view']); $form->getElement('user_approve')->setValue($baseConfigs['mandatory_user_approve']); }
public function getResetForm($formName = 'forgot-password') { $language = OW::getLanguage(); $form = new Form($formName); $email = new TextField('email'); $email->setRequired(true); $email->addValidator(new EmailValidator()); $email->setHasInvitation(true); $email->setInvitation($language->text('base', 'forgot_password_email_invitation_message')); $form->addElement($email); $submit = new Submit('submit'); $submit->setValue($language->text('base', 'forgot_password_submit_label')); $form->addElement($submit); return $form; }
/** * Requests local FTP attributes to update items/platform source code. */ public function ftpAttrs() { $language = OW::getLanguage(); $this->setPageHeading($language->text("admin", "page_title_manage_plugins_ftp_info")); $this->setPageHeadingIconClass("ow_ic_gear_wheel"); $form = new Form("ftp"); $login = new TextField("host"); $login->setValue("localhost"); $login->setRequired(true); $login->setLabel($language->text("admin", "plugins_manage_ftp_form_host_label")); $form->addElement($login); $login = new TextField("login"); $login->setHasInvitation(true); $login->setInvitation("login"); $login->setRequired(true); $login->setLabel($language->text("admin", "plugins_manage_ftp_form_login_label")); $form->addElement($login); $password = new PasswordField("password"); $password->setHasInvitation(true); $password->setInvitation("password"); $password->setRequired(true); $password->setLabel($language->text("admin", "plugins_manage_ftp_form_password_label")); $form->addElement($password); $port = new TextField("port"); $port->setValue(21); $port->addValidator(new IntValidator()); $port->setLabel($language->text("admin", "plugins_manage_ftp_form_port_label")); $form->addElement($port); $submit = new Submit("submit"); $submit->setValue($language->text("admin", "plugins_manage_ftp_form_submit_label")); $form->addElement($submit); $this->addForm($form); if (OW::getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); $ftpAttrs = array("host" => trim($data["host"]), "login" => trim($data["login"]), "password" => trim($data["password"]), "port" => (int) $data["port"]); OW::getSession()->set("ftpAttrs", $ftpAttrs); $this->redirectToBackUri($_GET); $this->redirectToAction('index'); } } }