public static function getSettingList() { $language = OW::getLanguage(); $pluginManager = OW::getPluginManager(); return array('banners' => array('presentation' => self::PRESENTATION_CUSTOM, 'label' => $language->text('skadate', 'banners_label'), 'render' => function ($uniqName, $name, $value) { OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('skadate')->getStaticJsUrl() . 'mobile_experience.js'); OW::getDocument()->addOnloadScript(UTIL_JsGenerator::composeJsString(';window.SKADATE_ME_SETTINGS({$params});', array('params' => array('iosActive' => OW::getPluginManager()->isPluginActive(SKADATE_CMP_MobileExperience::IOS), 'androidActive' => OW::getPluginManager()->isPluginActive(SKADATE_CMP_MobileExperience::ANDROID))))); $input = new CheckboxGroup('banners'); $input->setOptions(array(SKADATE_CMP_MobileExperience::IOS => OW::getLanguage()->text('skadate', 'ios_label'), SKADATE_CMP_MobileExperience::ANDROID => OW::getLanguage()->text('skadate', 'android_label'))); $input->setColumnCount(2); $input->setValue(!empty($value) ? array_keys($value) : null); return $input->renderInput(); }, 'value' => array(self::IOS => $pluginManager->isPluginActive(self::IOS), self::ANDROID => $pluginManager->isPluginActive(self::ANDROID))), 'show_first' => array('presentation' => self::PRESENTATION_CUSTOM, 'label' => $language->text('skadate', 'show_first_label'), 'render' => function ($uniqName, $name, $value) { $input = new RadioField('show_first[]'); $input->setOptions(array(SKADATE_CMP_MobileExperience::IOS => OW::getLanguage()->text('skadate', 'ios_label'), SKADATE_CMP_MobileExperience::ANDROID => OW::getLanguage()->text('skadate', 'android_label'))); $input->setValue($value); $input->setColumnCount(2); return $input->renderInput(); }, 'value' => $pluginManager->isPluginActive(self::IOS) ? self::IOS : self::ANDROID)); }
/** * Generates edit group form * * @param string $action * @return Form */ private function generateEditGroupForm($action) { $form = new Form('edit-group-form'); $form->setAction($action); $lang = OW::getLanguage(); $groupName = new TextField('group-name'); $groupName->setRequired(true); $sValidator = new StringValidator(1, 255); $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 255))); $groupName->addValidator($sValidator); $form->addElement($groupName); $description = new Textarea('description'); $description->setRequired(true); $sValidator = new StringValidator(1, 50000); $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 50000))); $description->addValidator($sValidator); $form->addElement($description); $groupId = new HiddenField('group-id'); $groupId->setRequired(true); $form->addElement($groupId); $isPrivate = new CheckboxField('is-private'); $form->addElement($isPrivate); $roles = new CheckboxGroup('roles'); $authService = BOL_AuthorizationService::getInstance(); $roleList = $authService->getRoleList(); $options = array(); foreach ($roleList as $role) { $options[$role->id] = $authService->getRoleLabel($role->name); } $roles->addOptions($options); $roles->setColumnCount(2); $form->addElement($roles); $submit = new Submit('save'); $submit->setValue($lang->text('forum', 'edit_group_btn')); $form->addElement($submit); $form->setAjax(true); return $form; }
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 index() { $language = OW::getLanguage(); $config = OW::getConfig(); $adminForm = new Form('adminForm'); $element = new Selectbox('itemApproval'); $element->setRequired(true); $element->setValue($config->getValue('eventx', 'itemApproval')); $element->setLabel($language->text('eventx', 'admin_event_approval')); $element->addOption('auto', $language->text('eventx', 'auto_approve')); $element->addOption('admin', $language->text('eventx', 'admin_approve')); $adminForm->addElement($element); $element = new CheckboxGroup('eventDelete'); $element->setRequired(true); $element->setColumnCount(3); $element->setValue(explode(",", $config->getValue('eventx', 'eventDelete'))); $element->setLabel($language->text('eventx', 'admin_event_delete')); $element->addOption(1, $language->text('eventx', 'admin')); $element->addOption(2, $language->text('eventx', 'moderator')); $element->addOption(3, $language->text('eventx', 'creator_del')); $adminForm->addElement($element); $element = new TextField('resultsPerPage'); $element->setRequired(true); $element->setLabel($language->text('eventx', 'admin_results_per_page')); $element->setValue($config->getValue('eventx', 'resultsPerPage')); $validator = new IntValidator(1); $validator->setErrorMessage($language->text('eventx', 'invalid_numeric_format')); $element->addValidator($validator); $adminForm->addElement($element); $element = new TextField('mapWidth'); $element->setRequired(true); $element->setValue($config->getValue('eventx', 'mapWidth')); $validator = new IntValidator(0); $validator->setErrorMessage($language->text('eventx', 'invalid_numeric_format')); $element->addValidator($validator); $adminForm->addElement($element); $element = new TextField('mapHeight'); $element->setRequired(true); $element->setValue($config->getValue('eventx', 'mapHeight')); $validator = new IntValidator(0); $validator->setErrorMessage($language->text('eventx', 'invalid_numeric_format')); $element->addValidator($validator); $adminForm->addElement($element); $element = new CheckboxField('enableCategoryList'); $element->setLabel($language->text('eventx', 'admin_enable_category_listing')); $element->setValue($config->getValue('eventx', 'enableCategoryList')); $adminForm->addElement($element); $element = new CheckboxField('enableCalendar'); $element->setLabel($language->text('eventx', 'admin_enable_calendar')); $element->setValue($config->getValue('eventx', 'enableCalendar')); $adminForm->addElement($element); $element = new CheckboxField('enableTagsList'); $element->setLabel($language->text('eventx', 'admin_enable_tag_listing')); $element->setValue($config->getValue('eventx', 'enableTagsList')); $adminForm->addElement($element); $element = new CheckboxField('enableMultiCategories'); $element->setLabel($language->text('eventx', 'enable_multi_categories')); $element->setValue($config->getValue('eventx', 'enableMultiCategories')); $adminForm->addElement($element); $element = new CheckboxField('enable3DTagCloud'); $element->setLabel($language->text('eventx', 'enable_3d_cloud_categories')); $element->setValue($config->getValue('eventx', 'enable3DTagCloud')); $adminForm->addElement($element); $element = new CheckboxField('enableMapSuggestion'); $element->setLabel($language->text('eventx', 'enable_map_suggestion')); $element->setValue($config->getValue('eventx', 'enableMapSuggestion')); $adminForm->addElement($element); $element = new Submit('saveSettings'); $element->setValue(OW::getLanguage()->text('eventx', 'admin_save_settings')); $adminForm->addElement($element); if (OW::getRequest()->isPost()) { if ($adminForm->isValid($_POST)) { $values = $adminForm->getValues(); $config->saveConfig('eventx', 'resultsPerPage', $values['resultsPerPage']); $config->saveConfig('eventx', 'itemApproval', $values['itemApproval']); $config->saveConfig('eventx', 'enableCategoryList', $values['enableCategoryList']); $config->saveConfig('eventx', 'enableMultiCategories', $values['enableMultiCategories']); $config->saveConfig('eventx', 'enable3DTagCloud', $values['enable3DTagCloud']); $config->saveConfig('eventx', 'enableMapSuggestion', $values['enableMapSuggestion']); $config->saveConfig('eventx', 'mapWidth', $values['mapWidth']); $config->saveConfig('eventx', 'mapHeight', $values['mapHeight']); $config->saveConfig('eventx', 'eventDelete', implode(",", $values['eventDelete'])); $config->saveConfig('eventx', 'enableTagsList', $values['enableTagsList']); $config->saveConfig('eventx', 'enableCalendar', $values['enableCalendar']); OW::getFeedback()->info($language->text('eventx', 'user_save_success')); $this->redirect(OW::getRouter()->urlForRoute('eventx_admin_index')); } } $this->addForm($adminForm); }