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); }
/** * Class constructor */ public function __construct($tpls) { parent::__construct('edit-template-form'); $this->setAction(OW::getRouter()->urlFor('VIRTUALGIFTS_CTRL_Admin', 'editTemplate')); $single = count($tpls) == 1; $this->setEnctype('multipart/form-data'); $language = OW::getLanguage(); $giftService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance(); if ($single) { $file = new FileField('file'); $file->setLabel($language->text('virtualgifts', 'gift_image')); $this->addElement($file); $tpl = $giftService->findTemplateById($tpls[0]); } $tplId = new HiddenField('tplId'); $tplId->setRequired(true); $tplId->setValue(implode('|', $tpls)); $this->addElement($tplId); if ($giftService->categoriesSetup()) { $categories = new Selectbox('category'); $categories->setLabel($language->text('virtualgifts', 'category')); $categories->setOptions($giftService->getCategories()); if ($single && isset($tpl)) { $categories->setValue($tpl->categoryId); } $this->addElement($categories); } if (OW::getPluginManager()->isPluginActive('usercredits')) { $price = new TextField('price'); $price->setLabel($language->text('virtualgifts', 'gift_price')); if ($single && isset($tpl)) { $price->setValue($tpl->price); } $this->addElement($price); } // submit $submit = new Submit('save'); $submit->setValue($language->text('virtualgifts', 'btn_save')); $this->addElement($submit); }
public function __construct() { parent::__construct('import'); $this->setMethod('post'); $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); $commandHidden = new HiddenField('command'); $this->addElement($commandHidden->setValue('upload-lp')); $fileField = new FileField('file'); $fileField->setLabel(OW::getLanguage()->text('admin', 'lang_file')); $this->addElement($fileField); $submit = new Submit('submit'); $this->addElement($submit->setValue(OW::getLanguage()->text('admin', 'clone_form_lbl_submit'))); }
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 page() { if (!OW::getRequest()->isAjax()) { OW::getNavigation()->activateMenuItem(OW_Navigation::ADMIN_SETTINGS, 'admin', 'sidebar_menu_item_main_settings'); } $language = OW::getLanguage(); $menu = $this->getMenu(); $this->addComponent('menu', $menu); if (!OW::getRequest()->isAjax()) { OW::getDocument()->setHeading(OW::getLanguage()->text('admin', 'heading_page_settings')); OW::getDocument()->setHeadingIconClass('ow_ic_file'); } $form = new Form('page_settings'); $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); $this->addForm($form); $headCode = new Textarea('head_code'); $headCode->setLabel($language->text('admin', 'page_settings_form_headcode_label')); $headCode->setDescription($language->text('admin', 'page_settings_form_headcode_desc')); $form->addElement($headCode); $bottomCode = new Textarea('bottom_code'); $bottomCode->setLabel($language->text('admin', 'page_settings_form_bottomcode_label')); $bottomCode->setDescription($language->text('admin', 'page_settings_form_bottomcode_desc')); $form->addElement($bottomCode); $favicon = new FileField('favicon'); $favicon->setLabel($language->text('admin', 'page_settings_form_favicon_label')); $favicon->setDescription($language->text('admin', 'page_settings_form_favicon_desc')); $form->addElement($favicon); $enableFavicon = new CheckboxField('enable_favicon'); $form->addElement($enableFavicon); $submit = new Submit('save'); $submit->setValue($language->text('admin', 'save_btn_label')); $form->addElement($submit); $faviconPath = OW::getPluginManager()->getPlugin('base')->getUserFilesDir() . 'favicon.ico'; $faviconUrl = OW::getPluginManager()->getPlugin('base')->getUserFilesUrl() . 'favicon.ico'; $this->assign('faviconSrc', $faviconUrl); if (OW::getRequest()->isPost()) { if ($form->isValid($_POST)) { $data = $form->getValues(); OW::getConfig()->saveConfig('base', 'html_head_code', $data['head_code']); OW::getConfig()->saveConfig('base', 'html_prebody_code', $data['bottom_code']); if (!empty($_FILES['favicon']['name'])) { if ((int) $_FILES['favicon']['error'] === 0 && is_uploaded_file($_FILES['favicon']['tmp_name']) && UTIL_File::getExtension($_FILES['favicon']['name']) === 'ico') { if (file_exists($faviconPath)) { @unlink($faviconPath); } @move_uploaded_file($_FILES['favicon']['tmp_name'], $faviconPath); if (file_exists($_FILES['favicon']['tmp_name'])) { @unlink($_FILES['favicon']['tmp_name']); } } else { OW::getFeedback()->error($language->text('admin', 'page_settings_favicon_submit_error_message')); } } OW::getConfig()->saveConfig('base', 'favicon', !empty($data['enable_favicon'])); OW::getFeedback()->info($language->text('admin', 'settings_submit_success_message')); } else { OW::getFeedback()->error($language->text('admin', 'settings_submit_error_message')); } $this->redirect(); } $headCode->setValue(OW::getConfig()->getValue('base', 'html_head_code')); $bottomCode->setValue(OW::getConfig()->getValue('base', 'html_prebody_code')); $enableFavicon->setValue((int) OW::getConfig()->getValue('base', 'favicon')); $this->assign('faviconEnabled', OW::getConfig()->getValue('base', 'favicon')); $script = "\$('#{$enableFavicon->getId()}').change(function(){ if(this.checked){ \$('#favicon_enabled').show();\$('#favicon_desabled').hide(); \$('{$favicon->getId()}').attr('disabled', true);}else{ \$('#favicon_enabled').hide();\$('#favicon_desabled').show(); \$('{$favicon->getId()}').attr('disabled', false);} });"; OW::getDocument()->addOnloadScript($script); }
private function addLastStepQuestions($controller) { $displayPhoto = false; $displayPhotoUpload = OW::getConfig()->getValue('base', 'join_display_photo_upload'); $photoValidator = new photoValidator(false); switch ($displayPhotoUpload) { case BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD: $photoValidator = new photoValidator(true); case BOL_UserService::CONFIG_JOIN_DISPLAY_PHOTO_UPLOAD: $userPhoto = new FileField('userPhoto'); $userPhoto->setLabel(OW::getLanguage()->text('base', 'questions_question_user_photo_label')); $userPhoto->addValidator($photoValidator); $this->addElement($userPhoto); $displayPhoto = true; } $displayTermsOfUse = false; if (OW::getConfig()->getValue('base', 'join_display_terms_of_use')) { $termOfUse = new CheckboxField('termOfUse'); $termOfUse->setLabel(OW::getLanguage()->text('base', 'questions_question_user_terms_of_use_label')); $termOfUse->setRequired(); $this->addElement($termOfUse); $displayTermsOfUse = true; } $this->setEnctype('multipart/form-data'); $event = new OW_Event('join.get_captcha_field'); OW::getEventManager()->trigger($event); $captchaField = $event->getData(); $displayCaptcha = false; if (!empty($captchaField) && $captchaField instanceof FormElement) { $captchaField->setName('captchaField'); $this->addElement($captchaField); $displayCaptcha = true; } //$captchaField = new CaptchaField('captchaField'); //$this->addElement($captchaField); $controller->assign('display_captcha', $displayCaptcha); $controller->assign('display_photo', $displayPhoto); $controller->assign('display_terms_of_use', $displayTermsOfUse); if (OW::getRequest()->isPost()) { if (!empty($captchaField) && $captchaField instanceof FormElement) { $captchaField->setValue(null); } if (isset($userPhoto) && isset($_FILES[$userPhoto->getName()]['name'])) { $_POST[$userPhoto->getName()] = $_FILES[$userPhoto->getName()]['name']; } } }
/** * Class constructor */ public function __construct() { parent::__construct('add-template-form'); $this->setEnctype('multipart/form-data'); $language = OW::getLanguage(); $file = new FileField('file'); $file->setLabel($language->text('virtualgifts', 'gift_image')); $this->addElement($file); $giftService = VIRTUALGIFTS_BOL_VirtualGiftsService::getInstance(); if ($giftService->categoriesSetup()) { $categories = new Selectbox('category'); $categories->setLabel($language->text('virtualgifts', 'category')); $categories->setOptions($giftService->getCategories()); $this->addElement($categories); } if (OW::getPluginManager()->isPluginActive('usercredits')) { $price = new TextField('price'); $price->setLabel($language->text('virtualgifts', 'gift_price')); $this->addElement($price); } // submit $submit = new Submit('add'); $submit->setValue($language->text('virtualgifts', 'btn_add')); $this->addElement($submit); }
public function __construct($name) { parent::__construct($name); $militaryTime = Ow::getConfig()->getValue('base', 'military_time'); $language = OW::getLanguage(); $currentYear = date('Y', time()); $title = new TextField('title'); $title->setRequired(); $title->setLabel($language->text('event', 'add_form_title_label')); $event = new OW_Event(self::EVENT_NAME, array('name' => 'title'), $title); OW::getEventManager()->trigger($event); $title = $event->getData(); $this->addElement($title); $startDate = new DateField('start_date'); $startDate->setMinYear($currentYear); $startDate->setMaxYear($currentYear + 5); $startDate->setRequired(); $event = new OW_Event(self::EVENT_NAME, array('name' => 'start_date'), $startDate); OW::getEventManager()->trigger($event); $startDate = $event->getData(); $this->addElement($startDate); $startTime = new EventTimeField('start_time'); $startTime->setMilitaryTime($militaryTime); if (!empty($_POST['endDateFlag'])) { $startTime->setRequired(); } $event = new OW_Event(self::EVENT_NAME, array('name' => 'start_time'), $startTime); OW::getEventManager()->trigger($event); $startTime = $event->getData(); $this->addElement($startTime); $endDate = new DateField('end_date'); $endDate->setMinYear($currentYear); $endDate->setMaxYear($currentYear + 5); $event = new OW_Event(self::EVENT_NAME, array('name' => 'end_date'), $endDate); OW::getEventManager()->trigger($event); $endDate = $event->getData(); $this->addElement($endDate); $endTime = new EventTimeField('end_time'); $endTime->setMilitaryTime($militaryTime); $event = new OW_Event(self::EVENT_NAME, array('name' => 'end_time'), $endTime); OW::getEventManager()->trigger($event); $endTime = $event->getData(); $this->addElement($endTime); $location = new TextField('location'); $location->setRequired(); $location->setLabel($language->text('event', 'add_form_location_label')); $event = new OW_Event(self::EVENT_NAME, array('name' => 'location'), $location); OW::getEventManager()->trigger($event); $location = $event->getData(); $this->addElement($location); $whoCanView = new RadioField('who_can_view'); $whoCanView->setRequired(); $whoCanView->addOptions(array('1' => $language->text('event', 'add_form_who_can_view_option_anybody'), '2' => $language->text('event', 'add_form_who_can_view_option_invit_only'))); $whoCanView->setLabel($language->text('event', 'add_form_who_can_view_label')); $event = new OW_Event(self::EVENT_NAME, array('name' => 'who_can_view'), $whoCanView); OW::getEventManager()->trigger($event); $whoCanView = $event->getData(); $this->addElement($whoCanView); $whoCanInvite = new RadioField('who_can_invite'); $whoCanInvite->setRequired(); $whoCanInvite->addOptions(array(EVENT_BOL_EventService::CAN_INVITE_PARTICIPANT => $language->text('event', 'add_form_who_can_invite_option_participants'), EVENT_BOL_EventService::CAN_INVITE_CREATOR => $language->text('event', 'add_form_who_can_invite_option_creator'))); $whoCanInvite->setLabel($language->text('event', 'add_form_who_can_invite_label')); $event = new OW_Event(self::EVENT_NAME, array('name' => 'who_can_invite'), $whoCanInvite); OW::getEventManager()->trigger($event); $whoCanInvite = $event->getData(); $this->addElement($whoCanInvite); $submit = new Submit('submit'); $submit->setValue($language->text('event', 'add_form_submit_label')); $this->addElement($submit); $desc = new WysiwygTextarea('desc'); $desc->setLabel($language->text('event', 'add_form_desc_label')); $desc->setRequired(); $event = new OW_Event(self::EVENT_NAME, array('name' => 'desc'), $desc); OW::getEventManager()->trigger($event); $desc = $event->getData(); $this->addElement($desc); $imageField = new FileField('image'); $imageField->setLabel($language->text('event', 'add_form_image_label')); $this->addElement($imageField); $event = new OW_Event(self::EVENT_NAME, array('name' => 'image'), $imageField); OW::getEventManager()->trigger($event); $imageField = $event->getData(); $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); }
public function __construct() { parent::__construct('image-upload'); $this->setEnctype('multipart/form-data'); $hidden = new HiddenField('command'); $hidden->setValue('image-upload'); $this->addElement($hidden); $hiddenMaxSize = new HiddenField('MAX_FILE_SIZE'); $hiddenMaxSize->setValue(intval(OW::getConfig()->getValue('base', 'tf_max_pic_size')) * 1000000); $fileInput = new FileField('file'); $fileInput->setLabel(OW::getLanguage()->text('base', 'tf_img_choose_file'))->setRequired(true); $this->addElement($fileInput); $submit = new Submit('submit'); $submit->setValue(OW::getLanguage()->text('base', 'upload')); $this->addElement($submit); return $this; }
public function index($params) { $filevernew = array(); $file = array(); $flag = false; $this->setPageTitle(OW::getLanguage()->text('spdownload', 'index_upload_title')); $this->setPageHeading(OW::getLanguage()->text('spdownload', 'index_upload_heading')); $arrayCheckCategory = array(); if (!empty($params) && isset($params['fileId'])) { if (!stripos($params['fileId'], "-")) { throw new Redirect404Exception(); } $check = $params['fileId']; $params['fileId'] = substr($params['fileId'], 0, stripos($params['fileId'], "-")); $file = SPDOWNLOAD_BOL_FileService::getInstance()->getFileId($params['fileId']); if ($file->id . '-' . $file->slug != $check) { throw new Redirect404Exception(); } $CategoryIdList = SPDOWNLOAD_BOL_FileCategoryService::getInstance()->getCategoryId($params['fileId']); foreach ($CategoryIdList as $key => $value) { array_push($arrayCheckCategory, $value->categoryId); } $flag = true; $file = SPDOWNLOAD_BOL_FileService::getInstance()->getFileId($params['fileId']); if ($file === NULL) { throw new Redirect404Exception(); } $filevernew = SPDOWNLOAD_BOL_VersionService::getInstance()->getFileVerNew($params['fileId']); $url = OW::getPluginManager()->getPlugin('spdownload')->getUserFilesUrl(); $file->icon = $url . 'icon_small_' . $params['fileId'] . '.png'; $thumbnails = SPDOWNLOAD_BOL_FileService::getInstance()->getThumbnailList($params['fileId']); foreach ($thumbnails as $key => $value) { $value->image = $url . $value->fileId . '_thumb_small_' . $value->uri . '.jpg'; } $this->assign('file', $file); $this->assign('thumbnails', $thumbnails); } $form = new Form('upload_form'); $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); $cmpCategories = new SPDOWNLOAD_CMP_Category(false, $arrayCheckCategory); $this->addComponent('cmpCategories', $cmpCategories); $fieldName = new TextField('upname'); $fieldName->setLabel($this->text('spdownload', 'form_label_name_up')); $fieldName->setRequired(); if (!empty($params) && isset($params['fileId'])) { $fieldName->setValue($file->name); } $form->addElement($fieldName); $fieldSlug = new TextField('upslug'); $fieldSlug->setLabel($this->text('spdownload', 'form_label_slug_up')); $fieldSlug->setRequired(); if (!empty($params) && isset($params['fileId'])) { $fieldSlug->setValue($file->slug); } $form->addElement($fieldSlug); $fieldFile = new FileField('upfile'); $fieldFile->setLabel($this->text('spdownload', 'form_label_file_up')); $form->addElement($fieldFile); $fieldIcon = new FileField('upicon'); $fieldIcon->setLabel($this->text('spdownload', 'form_label_icon_up')); $form->addElement($fieldIcon); $fieldThumb = new MultiFileField('upthumb', 5); $fieldThumb->setLabel($this->text('spdownload', 'form_label_thumb_up')); $form->addElement($fieldThumb); $fieldDescription = new Textarea('updescription'); $fieldDescription->setLabel($this->text('spdownload', 'form_label_description_up')); if (!empty($params) && isset($params['fileId'])) { $fieldDescription->setValue($file->description); } $form->addElement($fieldDescription); $fieldCategory = new CheckboxGroup('ct'); $form->addElement($fieldCategory); $submit = new Submit('upload'); $submit->setValue($this->text('spdownload', 'form_label_submit_up')); $form->addElement($submit); $this->addForm($form); $this->assign('flag', $flag); if (OW::getRequest()->isPost()) { if ($form->isValid($_POST)) { if (!empty($params) && isset($params['fileId'])) { if (!empty($_POST['ct'])) { $arrayAdd = array_diff($_POST['ct'], $arrayCheckCategory); $arrayDelete = array_diff($arrayCheckCategory, $_POST['ct']); foreach ($arrayDelete as $key => $value) { SPDOWNLOAD_BOL_FileCategoryService::getInstance()->deleteId($params['fileId'], $value); } foreach ($arrayAdd as $key => $value) { SPDOWNLOAD_BOL_FileCategoryService::getInstance()->addFileCategory($params['fileId'], $value); } } else { SPDOWNLOAD_BOL_FileCategoryService::getInstance()->deleteId($params['fileId'], null); } } $arrayFile = array(); $arrayFile['id'] = null; if (!empty($params) && isset($params['fileId'])) { $arrayFile['id'] = $params['fileId']; } $arrayFile['name'] = $_POST['upname']; $arrayFile['description'] = $_POST['updescription']; $arrayFile['slug'] = $_POST['upslug']; $arrayFile['authorId'] = OW::getUser()->getId(); $arrayFile['addedTime'] = time(); SPDOWNLOAD_BOL_FileService::getInstance()->addFile($arrayFile); if (isset($arrayFile['id']) && !empty($arrayFile['id'])) { } else { $fileNew = SPDOWNLOAD_BOL_FileService::getInstance()->getIdNew($arrayFile); $arrayFile['id'] = $fileNew[0]->id; } if (empty($params) && !isset($params['fileId'])) { if (isset($_POST['ct']) && !empty($_POST['ct'])) { foreach ($_POST['ct'] as $key => $value) { SPDOWNLOAD_BOL_FileCategoryService::getInstance()->addFileCategory($arrayFile['id'], $value); } } } $arrayInputFile = array(); $arrayInputFile['size'] = $_FILES['upfile']['size']; $arrayInputFile['name'] = $_FILES['upfile']['name']; $arrayInputFile['type'] = $_FILES['upfile']['type']; $arrayInputFile['tmp_name'] = $_FILES['upfile']['tmp_name']; $arrayInputFile['error'] = $_FILES['upfile']['error']; $arrayInputFile['addedTime'] = $arrayFile['addedTime']; $arrayInputFile['fileId'] = $arrayFile['id']; $path = SPDOWNLOAD_BOL_FileService::getInstance()->getFilePath(); if ($arrayInputFile['error'] == 0) { SPDOWNLOAD_BOL_VersionService::getInstance()->addVersion($arrayInputFile); $verNew = SPDOWNLOAD_BOL_VersionService::getInstance()->getIdVer($arrayInputFile); $arrayInputFile['id'] = $verNew[0]->id; SPDOWNLOAD_BOL_FileService::getInstance()->move_file($arrayInputFile['tmp_name'], $path, $arrayInputFile['id']); } if ($_FILES['upicon']['error'] == 0 && !empty($_FILES['upicon']['name'])) { SPDOWNLOAD_BOL_FileService::getInstance()->copy_resize_image($_FILES['upicon']['tmp_name'], 'icon_small', $arrayFile['id'], 'png', 48, 48); SPDOWNLOAD_BOL_FileService::getInstance()->copy_resize_image($_FILES['upicon']['tmp_name'], 'icon_large', $arrayFile['id'], 'png', 128, 128); } foreach ($_FILES['upthumb']['tmp_name'] as $key => $value) { if ($_FILES['upthumb']['error'][$key] == 0 && !empty($_FILES['upthumb']['name'][$key])) { SPDOWNLOAD_BOL_FileThumbService::getInstance()->addThumb($arrayFile['id'], $key); SPDOWNLOAD_BOL_FileService::getInstance()->copy_resize_image($_FILES['upthumb']['tmp_name'][$key], $arrayFile['id'] . '_thumb_small', $key, 'jpg', 360, 180); SPDOWNLOAD_BOL_FileService::getInstance()->copy_resize_image($_FILES['upthumb']['tmp_name'][$key], $arrayFile['id'] . '_thumb_large', $key, 'jpg', 720, 360); } } } $this->redirect(OW::getRouter()->urlForRoute('spdownload.up_myfile', array('userId' => OW::getUser()->getId()))); } }
public function toplinklist($curr = null) { OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('toplink')->getStaticCssUrl() . 'style.css'); OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('toplink')->getStaticJsUrl() . 'toplink.js'); $currId = @$curr['id']; $topForm = new Form("topForm"); $topForm->setEnctype('multipart/form-data'); $topSubmit = new Submit("topSubmit"); $topForm->addElement($topSubmit); $topName = new TextField("topName"); $topUrl = new TextField("topUrl"); $topIcon = new TextField("topIcon"); $topId = new HiddenField("topId"); $uploadIcon = new FileField('topIconFile'); $uploadIcon->setLabel($this->text('toplink', 'new_icon')); $topOrder = new TextField('toporder'); $topTarget = new CheckboxField('toptarget'); $topPermission = new CheckboxGroup('toppermission'); $topPermission->setColumnCount(1); $topPermission->setLabel($this->text('toplink', 'new_permission')); $availableDesc = TOPLINK_BOL_Service::$visibility; $topPermission->addOptions($availableDesc); $topOrder->setLabel($this->text('toplink', 'new_order')); $topOrder->setRequired(); $topTarget->setLabel($this->text('toplink', 'new_target')); $topName->setLabel($this->text('toplink', 'new_name')); //$topName->setRequired(); $topUrl->setLabel($this->text('toplink', 'new_url')); $topUrl->setRequired(); $topIcon->setLabel($this->text('toplink', 'new_icon')); if (!empty($currId) && !OW::getRequest()->isPost()) { $theTopLink = $this->myService->getTopLinkById($currId); $topName->setValue($theTopLink->itemname); $topId->setValue($currId); $topUrl->setValue($theTopLink->url); $topIcon->setValue($theTopLink->icon); $topTarget->setValue($theTopLink->target); $topOrder->setValue($theTopLink->order); $theTopLinkChild = $this->myService->getTopLinkChildObjectByParentId($currId); $theTopLinkPermission = $this->myService->getTopLinkPermissionById($currId); if (!empty($theTopLinkPermission)) { $i = 1; foreach ($theTopLinkPermission as $topLinkPermission) { $permissionOption[$i] = $topLinkPermission->availablefor; $i++; } $topPermission->setValue($permissionOption); } } $topForm->addElement($topName); $topForm->addElement($topUrl); $topForm->addElement($topIcon); $topForm->addElement($topId); $topForm->addElement($topTarget); $topForm->addElement($topOrder); $topForm->addElement($uploadIcon); $topForm->addElement($topPermission); $this->addForm($topForm); /* --- form submit --- */ $childrenNameList = @$_REQUEST['menuchildname']; $childrenUrlList = @$_REQUEST['menuchildurl']; $childrenIDList = @$_REQUEST['menuchildid']; if (OW::getRequest()->isPost()) { if ($topForm->isValid($_POST)) { $fdata = $topForm->getValues(); $newtoplink = new TOPLINK_BOL_Toplink(); $newtoplink->id = $fdata['topId']; $newtoplink->itemname = $fdata['topName']; $theurl = $fdata['topUrl']; if (!empty($theurl)) { $theurl = preg_match("/^http/", $theurl) ? $theurl : "http://" . $theurl; } else { $theurl = "#"; } $newtoplink->url = $theurl; /* check file exist */ if (!empty($fdata['topIcon']) && preg_match("/^\\//", $fdata['topIcon'])) { $newtoplink->icon = $fdata['topIcon']; $iconFileName = preg_replace("/^\\//", "", $newtoplink->icon); if (!file_exists($this->iconDir . $iconFileName)) { $newtoplink->icon = null; } } /* end */ $newtoplink->target = $fdata['toptarget']; $newtoplink->order = empty($fdata['toporder']) ? 5 : $fdata['toporder']; $loadedExts = get_loaded_extensions(); if (in_array('imagick', $loadedExts)) { $this->iMagicInstalled = true; } if ($_FILES['topIconFile']['error'] == 0) { $ext = explode('.', $_FILES['topIconFile']['name']); $ext = end($ext); if ($this->iMagicInstalled) { $image = new Imagick($_FILES['topIconFile']['tmp_name']); $image->thumbnailImage(16, 0); file_put_contents($this->iconDir . $_FILES['topIconFile']['name'] . '.png', $image); $uploadresult = $_FILES['topIconFile']['name'] . '.png'; } else { try { $image = new UTIL_Image($_FILES['topIconFile']['tmp_name'], 'PNG'); $image->resizeImage(16, 16, false)->saveImage($this->iconDir . $_FILES['topIconFile']['name'] . '.png'); $uploadresult = $_FILES['topIconFile']['name'] . '.png'; } catch (Exception $e) { $uploadresult = null; } } if ($uploadresult) { $newtoplink->icon = "/" . $uploadresult; } /* check file exist AGAIN AFTER UPLOAD */ if ($newtoplink->icon && preg_match("/^\\//", $newtoplink->icon)) { $iconFileName = preg_replace("/^\\//", "", $newtoplink->icon); if (!file_exists($this->iconDir . $iconFileName)) { $newtoplink->icon = null; } } /* end */ } $permission = $fdata['toppermission']; //save link $newid = $this->myService->saveToplink($newtoplink, $permission); $toplinkid = !empty($newtoplink->id) ? $newtoplink->id : $newid; $childIds = $this->myService->getTopLinkChildIdByParentId($toplinkid); if (!empty($childIds)) { if (!empty($childrenIDList)) { foreach ($childIds as $cid) { if (!in_array($cid, $childrenIDList)) { $this->myService->removeToplinkChild($cid); } } } else { foreach ($childIds as $cid) { $this->myService->removeToplinkChild($cid); } } } //process children if any if (!empty($childrenNameList) && !empty($childrenUrlList)) { foreach ($childrenNameList as $childIndex => $childName) { if (!empty($childName) && !empty($childrenUrlList[$childIndex])) { $childDoa = new TOPLINK_BOL_ToplinkChildren(); $childDoa->childof = $toplinkid; $childDoa->name = $childName; if (!empty($childrenUrlList[$childIndex])) { $thecurl = preg_match("/^http/", $childrenUrlList[$childIndex]) ? $childrenUrlList[$childIndex] : "http://" . $childrenUrlList[$childIndex]; } else { $thecurl = "#"; } $childDoa->url = $thecurl; if (!empty($childrenIDList[$childIndex])) { $childDoa->id = $childrenIDList[$childIndex]; } $this->myService->saveTopLinkChild($childDoa); } } } OW::getFeedback()->info($this->text('toplink', 'save_success_message')); $this->redirect(OW::getRouter()->urlForRoute('toplink.admin')); } } $alltoplink = $this->myService->getTopLink(true); $updatelink = array(); if (!empty($alltoplink)) { foreach ($alltoplink as $toplinkId => $toplink) { $toplink->itemname = empty($toplink->itemname) ? $this->text('toplink', 'top_link_no_name') : $toplink->itemname; $permissionx = array(); $theTopLinkPermission = $this->myService->getTopLinkPermissionById($toplink->id); foreach ($theTopLinkPermission as $topLinkPermission) { $permissionx[] = ucwords($availableDesc[$topLinkPermission->availablefor]); } $toplink->permission = !empty($permissionx) ? implode(',', $permissionx) : ''; $toplink->updateurl = OW::getRouter()->urlForRoute('toplink.admin2', array('id' => $toplink->id)); $toplink->removeurl = OW::getRouter()->urlForRoute('toplink.remove', array('id' => $toplink->id)); $alltoplink[$toplinkId] = $toplink; } } if (!empty($theTopLinkChild)) { $this->assign('children', $theTopLinkChild); } $this->assign('alltoplink', $alltoplink); }
public function __construct($name) { parent::__construct($name); $militaryTime = Ow::getConfig()->getValue('base', 'military_time'); $language = OW::getLanguage(); $currentYear = date('Y', time()); $title = new TextField('title'); $title->setRequired(); $title->setLabel($language->text('eventx', 'add_form_title_label')); $event = new OW_Event(self::EVENTX_NAME, array('name' => 'title'), $title); OW::getEventManager()->trigger($event); $title = $event->getData(); $this->addElement($title); $startDate = new DateField('start_date'); $startDate->setMinYear($currentYear); $startDate->setMaxYear($currentYear + 5); $startDate->setRequired(); $event = new OW_Event(self::EVENTX_NAME, array('name' => 'start_date'), $startDate); OW::getEventManager()->trigger($event); $startDate = $event->getData(); $this->addElement($startDate); $startTime = new EventTimeField('start_time'); $startTime->setMilitaryTime($militaryTime); if (!empty($_POST['endDateFlag'])) { $startTime->setRequired(); } $event = new OW_Event(self::EVENTX_NAME, array('name' => 'start_time'), $startTime); OW::getEventManager()->trigger($event); $startTime = $event->getData(); $this->addElement($startTime); $endDate = new DateField('end_date'); $endDate->setMinYear($currentYear); $endDate->setMaxYear($currentYear + 5); $event = new OW_Event(self::EVENTX_NAME, array('name' => 'end_date'), $endDate); OW::getEventManager()->trigger($event); $endDate = $event->getData(); $this->addElement($endDate); $endTime = new EventTimeField('end_time'); $endTime->setMilitaryTime($militaryTime); $event = new OW_Event(self::EVENTX_NAME, array('name' => 'end_time'), $endTime); OW::getEventManager()->trigger($event); $endTime = $event->getData(); $this->addElement($endTime); if (OW::getConfig()->getValue('eventx', 'enableCategoryList') == '1') { if (OW::getConfig()->getValue('eventx', 'enableMultiCategories') == 1) { $element = new CheckboxGroup('event_category'); $element->setColumnCount(3); } else { $element = new SelectBox('event_category'); } $element->setRequired(true); $element->setLabel($language->text('eventx', 'event_category_label')); foreach (EVENTX_BOL_EventService::getInstance()->getCategoriesList() as $category) { $element->addOption($category->id, $category->name); } $this->addElement($element); } $maxInvites = new TextField('max_invites'); $maxInvites->setRequired(); $validator = new IntValidator(0); $validator->setErrorMessage($language->text('eventx', 'invalid_integer_value')); $maxInvites->addValidator($validator); $maxInvites->setLabel($language->text('eventx', 'add_form_maxinvites_label')); $this->addElement($maxInvites); $location = new TextField('location'); $location->setRequired(); $location->setId('location'); $location->setLabel($language->text('eventx', 'add_form_location_label')); $event = new OW_Event(self::EVENTX_NAME, array('name' => 'location'), $location); OW::getEventManager()->trigger($event); $location = $event->getData(); $this->addElement($location); $whoCanView = new RadioField('who_can_view'); $whoCanView->setRequired(); $whoCanView->addOptions(array('1' => $language->text('eventx', 'add_form_who_can_view_option_anybody'), '2' => $language->text('eventx', 'add_form_who_can_view_option_invit_only'))); $whoCanView->setLabel($language->text('eventx', 'add_form_who_can_view_label')); $event = new OW_Event(self::EVENTX_NAME, array('name' => 'who_can_view'), $whoCanView); OW::getEventManager()->trigger($event); $whoCanView = $event->getData(); $this->addElement($whoCanView); $whoCanInvite = new RadioField('who_can_invite'); $whoCanInvite->setRequired(); $whoCanInvite->addOptions(array(EVENTX_BOL_EventService::CAN_INVITE_PARTICIPANT => $language->text('eventx', 'add_form_who_can_invite_option_participants'), EVENTX_BOL_EventService::CAN_INVITE_CREATOR => $language->text('eventx', 'add_form_who_can_invite_option_creator'))); $whoCanInvite->setLabel($language->text('eventx', 'add_form_who_can_invite_label')); $event = new OW_Event(self::EVENTX_NAME, array('name' => 'who_can_invite'), $whoCanInvite); OW::getEventManager()->trigger($event); $whoCanInvite = $event->getData(); $this->addElement($whoCanInvite); $desc = new WysiwygTextarea('desc'); $desc->setLabel($language->text('eventx', 'add_form_desc_label')); $desc->setRequired(); $event = new OW_Event(self::EVENTX_NAME, array('name' => 'desc'), $desc); OW::getEventManager()->trigger($event); $desc = $event->getData(); $this->addElement($desc); $imageField = new FileField('image'); $imageField->setLabel($language->text('eventx', 'add_form_image_label')); $this->addElement($imageField); if (OW::getConfig()->getValue('eventx', 'enableTagsList') == '1') { $tags = new TagsInputField('tags'); $tags->setId('tags'); $tags->setLabel($language->text('base', 'tags_cloud_cap_label')); $this->addElement($tags); } $submit = new Submit('submit'); $submit->setValue($language->text('eventx', 'add_form_submit_label')); $this->addElement($submit); $event = new OW_Event(self::EVENTX_NAME, array('name' => 'image'), $imageField); OW::getEventManager()->trigger($event); $imageField = $event->getData(); $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); }
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'); }