Пример #1
0
 /**
  * @see FormElement::renderInput()
  *
  * @param array $params
  * @return string
  */
 public function renderInput($params = null)
 {
     parent::renderInput($params);
     if ($this->options === null || empty($this->options)) {
         return '';
     }
     $columnWidth = floor(100 / $this->columnsCount);
     $renderedString = '<ul class="ow_checkbox_group clearfix">';
     $noValue = true;
     foreach ($this->options as $key => $value) {
         if ($this->value !== null && is_array($this->value) && in_array($key, $this->value)) {
             $this->addAttribute(FormElement::ATTR_CHECKED, 'checked');
             $noValue = false;
         }
         $this->setId(UTIL_HtmlTag::generateAutoId('input'));
         $this->addAttribute('value', $key);
         $renderedString .= '<li style="width:' . $columnWidth . '%">' . UTIL_HtmlTag::generateTag('input', $this->attributes) . '&nbsp;<label for="' . $this->getId() . '">' . $value . '</label></li>';
         $this->removeAttribute(FormElement::ATTR_CHECKED);
     }
     $language = OW::getLanguage();
     $attributes = $this->attributes;
     $attributes['id'] = $this->getName() . '_unimportant';
     $attributes['name'] = $this->getName() . '_unimportant';
     if ($noValue) {
         $attributes[FormElement::ATTR_CHECKED] = 'checked';
     }
     $renderedString .= '<li class="matchmaking_unimportant_checkbox" style="display:block;border-top: 1px solid #bbb; margin-top: 12px;padding-top:6px; width:100%">' . UTIL_HtmlTag::generateTag('input', $attributes) . '&nbsp;<label for="' . $this->getId() . '">' . $language->text('matchmaking', 'this_is_unimportant') . '</label></li>';
     return $renderedString . '</ul>';
 }
 public function __construct(BOL_MenuItem $menuItem, $custom = false)
 {
     parent::__construct("settingForm");
     $this->menuItem = $menuItem;
     $language = OW::getLanguage();
     $this->setAjax();
     $this->setAction(OW::getRouter()->urlFor("ADMIN_CTRL_MobileNavigation", "saveItemSettings"));
     $item = new HiddenField("key");
     $item->setValue($menuItem->prefix . ':' . $menuItem->key);
     $this->addElement($item);
     $settings = BOL_MobileNavigationService::getInstance()->getItemSettings($this->menuItem);
     // Mail Settings
     $item = new TextField(BOL_MobileNavigationService::SETTING_LABEL);
     $item->setLabel($language->text("mobile", "admin_nav_item_label_field"));
     $item->setValue($settings[BOL_MobileNavigationService::SETTING_LABEL]);
     $this->addElement($item);
     if ($custom) {
         $item = new TextField(BOL_MobileNavigationService::SETTING_TITLE);
         $item->setLabel($language->text("mobile", "admin_nav_item_title_field"));
         $item->setValue($settings[BOL_MobileNavigationService::SETTING_TITLE]);
         $this->addElement($item);
         $item = new Textarea(BOL_MobileNavigationService::SETTING_CONTENT);
         $item->setLabel($language->text("mobile", "admin_nav_item_content_field"));
         $item->setValue($settings[BOL_MobileNavigationService::SETTING_CONTENT]);
         $this->addElement($item);
         $item = new CheckboxGroup(BOL_MobileNavigationService::SETTING_VISIBLE_FOR);
         $visibleFor = empty($settings[BOL_MobileNavigationService::SETTING_VISIBLE_FOR]) ? 0 : $settings[BOL_MobileNavigationService::SETTING_VISIBLE_FOR];
         $options = array('1' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_guests'), '2' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_members'));
         $values = array();
         foreach ($options as $value => $option) {
             if (!($value & $visibleFor)) {
                 continue;
             }
             $values[] = $value;
         }
         $this->addElement($item->setOptions($options)->setValue($values)->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_visible_for')));
     }
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'save_btn_label'));
     $this->addElement($submit);
 }
Пример #3
0
 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));
 }
Пример #4
0
 public function __construct($name, BOL_MenuItem $menu)
 {
     parent::__construct($name);
     $navigationService = BOL_NavigationService::getInstance();
     $document = $navigationService->findDocumentByKey($menu->getDocumentKey());
     $language = OW_Language::getInstance();
     $adminPlugin = OW::getPluginManager()->getPlugin('admin');
     $nameTextField = new TextField('name');
     $this->addElement($nameTextField->setValue($language->text($menu->getPrefix(), $menu->getKey()))->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_menu_name'))->setRequired());
     $visibleForCheckboxGroup = new CheckboxGroup('visible-for');
     $visibleFor = $menu->getVisibleFor();
     $options = array('1' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_guests'), '2' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_members'));
     $values = array();
     foreach ($options as $value => $option) {
         if (!($value & $visibleFor)) {
             continue;
         }
         $values[] = $value;
     }
     $this->addElement($visibleForCheckboxGroup->setOptions($options)->setValue($values)->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_visible_for')));
     $submit = new Submit('save');
     $this->addElement($submit->setValue(OW::getLanguage()->text('admin', 'save_btn_label')));
 }
Пример #5
0
 /**
  * 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;
 }
Пример #6
0
 public function sitemap()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $form = new Form('sitemap_form');
     $sitemapUrl = new TextField('sitemap_url');
     $sitemapUrl->setLabel($language->text('oaseo', 'sitemap_url_label'));
     $sitemapUrl->setDescription($language->text('oaseo', 'sitemap_url_desc'));
     $sitemapUrl->setValue(OW_URL_HOME . $config->getValue('oaseo', 'sitemap_url'));
     $form->addElement($sitemapUrl);
     //        $rorUrl = new TextField('ror_url');
     //        $rorUrl->setLabel($language->text('oaseo', 'ror_url_label'));
     //        $rorUrl->setDescription($language->text('oaseo', 'ror_url_desc'));
     //        $rorUrl->setValue(OW_URL_HOME . $config->getValue('oaseo', 'ror_url'));
     //        $form->addElement($rorUrl);
     $imageUrl = new TextField('imagemap_url');
     $imageUrl->setLabel($language->text('oaseo', 'imagemap_url_label'));
     $imageUrl->setDescription($language->text('oaseo', 'imagemap_url_desc'));
     $imageUrl->setValue(OW_URL_HOME . $config->getValue('oaseo', 'imagemap_url'));
     $form->addElement($imageUrl);
     $undateFreq = new Selectbox('update_freq');
     $options = array('86400' => 'Daily', '604800' => 'Weekly', '2419200' => 'Monthly');
     $undateFreq->setHasInvitation(false);
     $undateFreq->addOptions($options);
     $undateFreq->setLabel($language->text('oaseo', 'update_freq_label'));
     $undateFreq->setDescription($language->text('oaseo', 'update_freq_desc'));
     $form->addElement($undateFreq);
     $undateFreq->setValue($config->getValue('oaseo', 'update_freq'));
     //        $prio = new CheckboxField('prio');
     //        $prio->setLabel($language->text('oaseo', 'prio_label'));
     //        $prio->setDescription($language->text('oaseo', 'prio_desc'));
     //        $form->addElement($prio);
     //        $email = new TextField('email');
     //        $email->setLabel($language->text('oaseo', 'email_label'));
     //        $email->setDescription($language->text('oaseo', 'email_desc'));
     //        $form->addElement($email);
     $inform = new CheckboxGroup('inform');
     $inform->setLabel($language->text('oaseo', 'inform_label'));
     $inform->setDescription($language->text('oaseo', 'inform_desc'));
     $inform->setOptions(array('google' => 'Google', 'bing' => 'Bing', 'yahoo' => 'Yahoo', 'ask' => 'Ask'));
     $form->addElement($inform);
     $inform->setValue(json_decode($config->getValue('oaseo', 'inform')));
     //        $extlink = new CheckboxField('extlink');
     //        $extlink->setLabel($language->text('oaseo', 'extlink_label'));
     //        $extlink->setDescription($language->text('oaseo', 'extlink_desc'));
     //        $form->addElement($extlink);
     //
     //        $brock = new CheckboxField('brock_link');
     //        $brock->setLabel($language->text('oaseo', 'brock_link_label'));
     //        $brock->setDescription($language->text('oaseo', 'brock_link_desc'));
     //        $form->addElement($brock);
     $submit = new Submit('submit');
     $submit->setValue(OW::getLanguage()->text('admin', 'save_btn_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
         $data = $form->getValues();
         $config->saveConfig('oaseo', 'sitemap_url', str_replace(OW_URL_HOME, '', $data['sitemap_url']));
         $config->saveConfig('oaseo', 'imagemap_url', str_replace(OW_URL_HOME, '', $data['imagemap_url']));
         $config->saveConfig('oaseo', 'update_freq', (int) $data['update_freq']);
         $config->saveConfig('oaseo', 'inform', json_encode($data['inform'] ? $data['inform'] : array()));
     }
 }
Пример #7
0
 public function index($params = array())
 {
     $userService = BOL_UserService::getInstance();
     $language = OW::getLanguage();
     $this->setPageHeading($language->text('admin', 'massmailing'));
     $this->setPageHeadingIconClass('ow_ic_script');
     $massMailingForm = new Form('massMailingForm');
     $massMailingForm->setId('massMailingForm');
     $rolesList = BOL_AuthorizationService::getInstance()->getRoleList();
     $userRoles = new CheckboxGroup('userRoles');
     $userRoles->setLabel($language->text('admin', 'massmailing_user_roles_label'));
     foreach ($rolesList as $role) {
         if ($role->name != 'guest') {
             $userRoles->addOption($role->name, $language->text('base', 'authorization_role_' . $role->name));
         }
     }
     $massMailingForm->addElement($userRoles);
     $emailFormat = new Selectbox('emailFormat');
     $emailFormat->setLabel($language->text('admin', 'massmailing_email_format_label'));
     $emailFormat->setOptions(array(self::EMAIL_FORMAT_TEXT => $language->text('admin', 'massmailing_email_format_text'), self::EMAIL_FORMAT_HTML => $language->text('admin', 'massmailing_email_format_html')));
     $emailFormat->setValue(self::EMAIL_FORMAT_TEXT);
     $emailFormat->setHasInvitation(false);
     if (!empty($_POST['emailFormat'])) {
         $emailFormat->setValue($_POST['emailFormat']);
     }
     $massMailingForm->addElement($emailFormat);
     $subject = new TextField('subject');
     $subject->addAttribute('class', 'ow_text');
     $subject->addAttribute('style', 'width: auto;');
     $subject->setRequired();
     $subject->setLabel($language->text('admin', 'massmailing_subject_label'));
     if (!empty($_POST['subject'])) {
         $subject->setValue($_POST['subject']);
     }
     $massMailingForm->addElement($subject);
     $body = new Textarea('body');
     if ($emailFormat->getValue() == self::EMAIL_FORMAT_HTML) {
         $body = new WysiwygTextarea('body');
         $body->forceAddButtons(array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_HTML));
     }
     $body->addAttribute('class', 'ow_text');
     $body->addAttribute('style', 'width: auto;');
     $body->setRequired();
     $body->setLabel($language->text('admin', 'massmailing_body_label'));
     if (!empty($_POST['body'])) {
         $body->setValue($_POST['body']);
     }
     $massMailingForm->addElement($body);
     $submit = new Submit('startMailing');
     $submit->addAttribute('class', 'ow_button');
     $submit->setValue($language->text('admin', 'massmailing_start_mailing_button'));
     $massMailingForm->addElement($submit);
     $this->addForm($massMailingForm);
     $ignoreUnsubscribe = false;
     $isActive = true;
     if (defined('OW_PLUGIN_XP')) {
         $massMailingTimestamp = OW::getConfig()->getValue('admin', 'mass_mailing_timestamp');
         $timeout = $massMailingTimestamp + 60 * 60 * 24 - time();
         if ($timeout > 0) {
             $isActive = false;
             $this->assign('expireText', $language->text('admin', 'massmailing_expire_text', array('hours' => (int) ceil($timeout / (60 * 60)))));
         }
     }
     $this->assign('isActive', $isActive);
     $total = $userService->findMassMailingUserCount($ignoreUnsubscribe);
     if (OW::getRequest()->isPost() && $isActive && isset($_POST['startMailing'])) {
         if ($massMailingForm->isValid($_POST)) {
             $data = $massMailingForm->getValues();
             $start = 0;
             $count = self::MAILS_ARRAY_MAX_RECORDS;
             $mailCount = 0;
             $total = $userService->findMassMailingUserCount($ignoreUnsubscribe, $data['userRoles']);
             while ($start < $total) {
                 $result = $this->userService->findMassMailingUsers($start, $count, $ignoreUnsubscribe, $data['userRoles']);
                 $mails = array();
                 $userIdList = array();
                 foreach ($result as $user) {
                     $userIdList[] = $user->id;
                 }
                 $displayNameList = $this->userService->getDisplayNamesForList($userIdList);
                 $event = new BASE_CLASS_EventCollector('base.add_global_lang_keys');
                 OW::getEventManager()->trigger($event);
                 $vars = call_user_func_array('array_merge', $event->getData());
                 foreach ($result as $key => $user) {
                     $vars['user_email'] = $user->email;
                     $mail = OW::getMailer()->createMail();
                     $mail->addRecipientEmail($user->email);
                     $vars['user_name'] = $displayNameList[$user->id];
                     $code = md5($user->username . $user->password);
                     $link = OW::getRouter()->urlForRoute('base_massmailing_unsubscribe', array('id' => $user->id, 'code' => $code));
                     $subjectText = UTIL_String::replaceVars($data['subject'], $vars);
                     $mail->setSubject($subjectText);
                     if ($data['emailFormat'] === self::EMAIL_FORMAT_HTML) {
                         $htmlContent = UTIL_String::replaceVars($data['body'], $vars);
                         $htmlContent .= $language->text('admin', 'massmailing_unsubscribe_link_html', array('link' => $link));
                         $mail->setHtmlContent($htmlContent);
                         $textContent = preg_replace("/\\<br\\s*[\\/]?\\s*\\>/", "\n", $htmlContent);
                         $textContent = strip_tags($textContent);
                         $mail->setTextContent($textContent);
                     } else {
                         $textContent = UTIL_String::replaceVars($data['body'], $vars);
                         $textContent .= "\n\n" . $language->text('admin', 'massmailing_unsubscribe_link_text', array('link' => $link));
                         $mail->setTextContent($textContent);
                     }
                     $mails[] = $mail;
                     $mailCount++;
                 }
                 $start += $count;
                 //printVar($mails);
                 OW::getMailer()->addListToQueue($mails);
             }
             OW::getFeedback()->info($language->text('admin', 'massmailing_send_mails_message', array('count' => $mailCount)));
             if (defined('OW_PLUGIN_XP')) {
                 OW::getConfig()->saveConfig('admin', 'mass_mailing_timestamp', time());
             }
             $this->redirect();
         }
     }
     $this->assign('userCount', $total);
     $language->addKeyForJs('admin', 'questions_empty_lang_value');
     $language->addKeyForJs('admin', 'massmailing_total_members');
     $script = ' window.massMailing = new MassMailing(\'' . $this->ajaxResponderUrl . '\'); ';
     OW::getDocument()->addOnloadScript($script);
     $jsDir = OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl();
     OW::getDocument()->addScript($jsDir . "mass_mailing.js");
 }
Пример #8
0
 /**
  *
  * @param string $name
  * @return Form
  */
 private function getManageForm($name)
 {
     if ($this->banners === null) {
         $banners = $this->adsService->findAllBanners();
         $bannerInfo = array();
         foreach ($banners as $banner) {
             /* @var $banner ADS_BOL_Banner */
             $this->banners[$banner->getId()] = $banner->getLabel();
         }
     }
     $form = new Form($name);
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('ADS_CTRL_Admin', 'processBannerForm'));
     $form->setAjaxResetOnSuccess(false);
     $form->bindJsFunction(Form::BIND_SUCCESS, "function(data){OW.info(data.message);window.adsForm.close();\$('#'+data.id).html(data.html);}");
     $multiCheckbox = new CheckboxGroup('banners');
     $multiCheckbox->setOptions($this->banners === null ? array() : $this->banners);
     $form->addElement($multiCheckbox);
     $submit = new Submit('submit');
     $submit->setValue(OW::getLanguage()->text('ads', 'banner_position_submit_label'));
     $form->addElement($submit);
     $pluginHidden = new HiddenField('plugin_key');
     $form->addElement($pluginHidden);
     return $form;
 }
Пример #9
0
 protected function init($params = array())
 {
     $accountTypes = $this->questionService->findAllAccountTypes();
     $serviceLang = BOL_LanguageService::getInstance();
     $language = OW::getLanguage();
     $currentLanguageId = OW::getLanguage()->getCurrentId();
     $accounts = array();
     /* @var $value BOL_QuestionAccount */
     foreach ($accountTypes as $value) {
         $accounts[$value->name] = $this->questionService->getAccountTypeLang($value->name);
     }
     $sections = $this->questionService->findSortedSectionList();
     // need to hide sections select box
     if (empty($sections)) {
         $this->assign('no_sections', true);
     }
     $sectionsArray = array();
     /* @var $section BOL_QuestionSection */
     foreach ($sections as $section) {
         $sectionsArray[$section->name] = $language->text('base', 'questions_section_' . $section->name . '_label');
     }
     $event = new OW_Event('base.question.add_question_form.on_get_available_sections', $sectionsArray, $sectionsArray);
     OW::getEventManager()->trigger($event);
     $sectionsArray = $event->getData();
     $presentationList = array_keys($this->presentations2types);
     $presentations = array();
     $presentationsLabel = array();
     foreach ($presentationList as $item) {
         $presentations[$item] = $item;
         $presentationsLabel[$item] = $language->text('base', 'questions_question_presentation_' . $item . '_label');
     }
     $presentation = $presentationList[0];
     if (isset($_POST['qst_answer_type']) && isset($presentations[$_POST['qst_answer_type']])) {
         $presentation = $presentations[$_POST['qst_answer_type']];
     }
     $qstName = new TextField('qst_name');
     $qstName->setLabel($language->text('admin', 'questions_question_name_label'));
     //$qstName->addValidator(new StringValidator(0, 24000));
     $qstName->setRequired();
     $this->addElement($qstName);
     $qstName = new TextField('qst_description');
     $qstName->setLabel($language->text('admin', 'questions_question_description_label'));
     //$qstName->addValidator(new StringValidator(0, 24000));
     $this->addElement($qstName);
     if (count($accountTypes) > 1) {
         $qstAccountType = new CheckboxGroup('qst_account_type');
         $qstAccountType->setLabel($language->text('admin', 'questions_for_account_type_label'));
         $qstAccountType->setRequired();
         $qstAccountType->setDescription($language->text('admin', 'questions_for_account_type_description'));
         $qstAccountType->setOptions($accounts);
         $this->addElement($qstAccountType);
     }
     if (!empty($sectionsArray)) {
         $qstSection = new Selectbox('qst_section');
         $qstSection->setLabel($language->text('admin', 'questions_question_section_label'));
         $qstSection->setOptions($sectionsArray);
         $qstSection->setHasInvitation(false);
         $this->addElement($qstSection);
     }
     $qstAnswerType = new Selectbox('qst_answer_type');
     $qstAnswerType->setLabel($language->text('admin', 'questions_answer_type_label'));
     $qstAnswerType->addAttribute('class', $qstAnswerType->getName());
     $qstAnswerType->setOptions($presentationsLabel);
     $qstAnswerType->setRequired();
     $qstAnswerType->setHasInvitation(false);
     $qstAnswerType->setValue($presentation);
     $this->addElement($qstAnswerType);
     //        if ( $displayPossibleValues )
     //        {
     $qstPossibleValues = new addValueField('qst_possible_values');
     //$qstPossibleValues->addAttribute('class', $qstPossibleValues->getName());
     $qstPossibleValues->setLabel($language->text('admin', 'questions_possible_values_label'));
     $qstPossibleValues->setDescription($language->text('admin', 'questions_possible_values_description'));
     //$qstPossibleValues->setValue( array( '1' => 'aaa', '2' => 'bbbb', '4' => 'ccc' ) );
     $this->addElement($qstPossibleValues);
     //        }
     $configList = $this->questionConfigs;
     foreach ($configList as $config) {
         $className = $config->presentationClass;
         /* @var $qstConfig OW_FormElement */
         $qstConfig = OW::getClassInstance($className, $config->name);
         $qstConfig->setLabel($language->text('admin', 'questions_config_' . $config->name . '_label'));
         if (!empty($config->description)) {
             $qstConfig->setDescription($config->description);
         }
         $this->addElement($qstConfig);
     }
     $qstColumnCount = new Selectbox('qst_column_count');
     $qstColumnCount->addAttribute('class', $qstColumnCount->getName());
     $qstColumnCount->setLabel($language->text('admin', 'questions_columns_count_label'));
     $qstColumnCount->setOptions($this->qstColumnCountValues);
     $qstColumnCount->setValue(1);
     $this->addElement($qstColumnCount);
     $qstRequired = new CheckboxField('qst_required');
     $qstRequired->setLabel($language->text('admin', 'questions_required_label'));
     $qstRequired->setDescription($language->text('admin', 'questions_required_description'));
     $this->addElement($qstRequired);
     $qstOnSignUp = new CheckboxField('qst_on_sign_up');
     $qstOnSignUp->setLabel($language->text('admin', 'questions_on_sing_up_label'));
     $qstOnSignUp->setDescription($language->text('admin', 'questions_on_sing_up_description'));
     $this->addElement($qstOnSignUp);
     $qstOnEdit = new CheckboxField('qst_on_edit');
     $qstOnEdit->setLabel($language->text('admin', 'questions_on_edit_label'));
     $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description'));
     $this->addElement($qstOnEdit);
     $qstOnView = new CheckboxField('qst_on_view');
     $qstOnView->setLabel($language->text('admin', 'questions_on_view_label'));
     $qstOnView->setDescription($language->text('admin', 'questions_on_view_description'));
     $this->addElement($qstOnView);
     $qstOnSearch = new CheckboxField('qst_on_search');
     $qstOnSearch->setLabel($language->text('admin', 'questions_on_search_label'));
     $qstOnSearch->setDescription($language->text('admin', 'questions_on_search_description'));
     $this->addElement($qstOnSearch);
     $qstSubmit = new Submit('qst_submit');
     $qstSubmit->setValue($language->text('admin', 'save_btn_label'));
     $qstSubmit->addAttribute('class', 'ow_button ow_ic_save');
     $this->addElement($qstSubmit);
     $this->addElement($qstSubmit);
 }
Пример #10
0
 public function __construct($name, BOL_MenuItem $menu)
 {
     parent::__construct($name);
     $language = OW_Language::getInstance();
     $plugin = OW::getPluginManager()->getPlugin('base');
     $adminPlugin = OW::getPluginManager()->getPlugin('admin');
     $nameTextField = new TextField('name');
     $this->addElement($nameTextField->setValue($language->text($plugin->getKey(), $menu->getKey()))->setLabel(OW::getLanguage()->text('admin', 'pages_edit_external_menu_name_label'))->setRequired(true));
     $urlTextField = new TextField('url');
     $urlTextField->addValidator(new ADMIN_CLASS_ExternalPageUrlValidator());
     $this->addElement($urlTextField->setValue($menu->getExternalUrl())->setLabel(OW::getLanguage()->text('admin', 'pages_edit_external_url_label'))->setRequired(true));
     $extOpenInNewWindow = new CheckboxField('ext-open-in-new-window');
     $this->addElement($extOpenInNewWindow->setLabel(OW::getLanguage()->text('admin', 'pages_edit_external_url_open_in_new_window'))->setValue($menu->getNewWindow()));
     $visibleForCheckboxGroup = new CheckboxGroup('visible-for');
     $visibleFor = $menu->getVisibleFor();
     $options = array('1' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_guests'), '2' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_members'));
     $values = array();
     foreach ($options as $value => $option) {
         if (!($value & $visibleFor)) {
             continue;
         }
         $values[] = $value;
     }
     $this->addElement($visibleForCheckboxGroup->setOptions($options)->setValue($values)->setLabel(OW::getLanguage()->text('admin', 'pages_edit_external_visible_for')));
     $saveSubmit = new Submit('save');
     $this->addElement($saveSubmit->setValue($language->text($adminPlugin->getKey(), 'save_btn_label')));
 }
Пример #11
0
 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);
 }
Пример #12
0
 public function __construct(OW_Renderable $rendrable)
 {
     parent::__construct('page-add-form');
     $titleTextField = new TextField('title');
     $titleTextField->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_page_title'))->addAttribute('class', 'ow_text');
     $titleTextField->setId('title');
     $isLocal = true;
     if (OW::getRequest()->isPost()) {
         $isLocal = $_POST['type'] == 'local' ? true : false;
     }
     $titleTextField->addValidator(new PageTitleValidator());
     $this->addElement($titleTextField);
     $nameTextField = new TextField('name');
     $nameTextField->setLabel(OW::getLanguage()->text('admin', 'pages_add_menu_name'))->setRequired(true)->addAttribute('class', 'ow_text');
     $this->addElement($nameTextField);
     $visibleForCheckboxGroup = new CheckboxGroup('visible-for');
     $opts = array('1' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_guests'), '2' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_members'));
     $visibleForCheckboxGroup->setOptions($opts);
     $visibleForCheckboxGroup->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_visible_for'));
     $this->addElement($visibleForCheckboxGroup);
     $metaTagsTextarea = new Textarea('meta-tags');
     $metaTagsTextarea->setLabel('Page meta tags')->setId('meta-tags')->setDescription(OW::getLanguage()->text('admin', 'pages_page_field_meta_desc'));
     $this->addElement($metaTagsTextarea);
     $contentTextArea = new Textarea('content');
     $contentTextArea->setLabel(OW::getLanguage()->text('admin', 'pages_add_page_content'))->setId('content')->setDescription(OW::getLanguage()->text('admin', 'pages_page_field_content_desc', array('src' => OW::getThemeManager()->getCurrentTheme()->getStaticImagesUrl() . 'question.png', 'url' => '#')));
     $this->addElement($contentTextArea);
     $typeHiddenField = new TextField('type');
     $type = OW::getRequest()->isPost() && $_POST['type'] ? $_POST['type'] : 'local';
     $rendrable->assign('isLocal', $isLocal);
     $typeHiddenField->setValue($type);
     $typeHiddenField->setId('type');
     $typeHiddenField->setLabel(OW::getLanguage()->text('admin', 'page_add_page_address'));
     $this->addElement($typeHiddenField);
     $localUrlTextField = new TextField('local-url');
     $localUrlTextField->addValidator(new LocalPageUrlValidator())->addValidator(new LocalPageUniqueValidator());
     $localUrlTextField->setId('url1');
     $this->addElement($localUrlTextField);
     $externalUrl = new TextField('external-url');
     $externalUrl->setInvitation('http://www.example.com')->setHasInvitation(true)->addValidator(new ADMIN_CLASS_ExternalPageUrlValidator())->setId('url2');
     $this->addElement($externalUrl);
     $extOpenInNewWindow = new CheckboxField('ext-open-in-new-window');
     $extOpenInNewWindow->setLabel(OW::getLanguage()->text('admin', 'pages_edit_external_url_open_in_new_window'));
     $this->addElement($extOpenInNewWindow);
     $submit = new Submit('submit');
     $this->addElement($submit->setValue(OW::getLanguage()->text('base', 'pages_add_submit')));
 }
Пример #13
0
 public function __construct($configs)
 {
     parent::__construct('YNSOCIALSTREAM_LevelSettingsForm');
     $language = OW::getLanguage();
     $field = new CheckboxGroup('level_id');
     $field->setLabel($language->text('ynsocialstream', 'admin_level_id_label'));
     $field->setValue($configs['get_feed']);
     $field->addOptions(array('1' => $language->text('admin', 'permissions_index_yes'), '0' => $language->text('admin', 'permissions_index_no')));
     $this->addElement($field);
     $field = new RadioField('get_feed');
     $field->setLabel($language->text('ynsocialstream', 'admin_get_feed_label'));
     $field->setValue($configs['get_feed']);
     $field->addOptions(array('1' => $language->text('admin', 'permissions_index_yes'), '0' => $language->text('admin', 'permissions_index_no')));
     $this->addElement($field);
     $btn = new Submit('save');
     $btn->setValue($language->text('ynsocialstream', 'save_customization_btn_label'));
     $this->addElement($btn);
 }
 public function __construct(BOL_MenuItem $menuItem, $custom = false, $addUrlValidator = true)
 {
     parent::__construct("settingForm");
     $this->menuItem = $menuItem;
     $language = OW::getLanguage();
     $this->setAjax();
     $this->setAction(OW::getRouter()->urlFor("ADMIN_CTRL_MobileNavigation", "saveItemSettings"));
     $item = new HiddenField("key");
     $item->setValue($menuItem->prefix . ':' . $menuItem->key);
     $this->addElement($item);
     $settings = BOL_MobileNavigationService::getInstance()->getItemSettings($this->menuItem);
     // Mail Settings
     $item = new TextField(BOL_MobileNavigationService::SETTING_LABEL);
     $item->setLabel($language->text("mobile", "admin_nav_item_label_field"));
     $item->setValue($settings[BOL_MobileNavigationService::SETTING_LABEL]);
     $item->setRequired();
     $this->addElement($item);
     if ($custom) {
         $typeField = new RadioField(BOL_MobileNavigationService::SETTING_TYPE);
         $typeField->setLabel($language->text("mobile", "admin_nav_item_type_field"));
         $typeField->setValue($settings[BOL_MobileNavigationService::SETTING_TYPE]);
         $typeField->addOption("local", $language->text("mobile", "admin_nav_item_type_local"));
         $typeField->addOption("external", $language->text("mobile", "admin_nav_item_type_external"));
         $this->addElement($typeField);
         $item = new TextField(BOL_MobileNavigationService::SETTING_TITLE);
         $item->setLabel($language->text("mobile", "admin_nav_item_title_field"));
         $item->setValue($settings[BOL_MobileNavigationService::SETTING_TITLE]);
         $item->setRequired();
         $this->addElement($item);
         $item = new Textarea(BOL_MobileNavigationService::SETTING_CONTENT);
         $item->setLabel($language->text("mobile", "admin_nav_item_content_field"));
         $item->setValue($settings[BOL_MobileNavigationService::SETTING_CONTENT]);
         $this->addElement($item);
         $item = new TextField(BOL_MobileNavigationService::SETTING_URL);
         if ($addUrlValidator) {
             $item->addValidator(new UrlValidator());
             $item->setRequired();
         }
         $item->setLabel($language->text("mobile", "admin_nav_item_url_field"));
         $item->setValue($settings[BOL_MobileNavigationService::SETTING_URL]);
         $this->addElement($item);
         $item = new CheckboxGroup(BOL_MobileNavigationService::SETTING_VISIBLE_FOR);
         $visibleFor = empty($settings[BOL_MobileNavigationService::SETTING_VISIBLE_FOR]) ? 0 : $settings[BOL_MobileNavigationService::SETTING_VISIBLE_FOR];
         $options = array('1' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_guests'), '2' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_members'));
         $values = array();
         foreach ($options as $value => $option) {
             if (!($value & $visibleFor)) {
                 continue;
             }
             $values[] = $value;
         }
         $this->addElement($item->setOptions($options)->setValue($values)->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_visible_for')));
         $js = UTIL_JsGenerator::newInstance();
         $js->addScript('var url = owForms[{$name}].elements["url"]; var validators = url.validators; url.validators = []; $("input[name=type]", "#" + {$id}).change(function() { ' . 'if ($(this).val() == "local") { ' . '$("#mp-content").show(); $("#mp-url").hide(); url.validators = []; ' . '} else { ' . '$("#mp-content").hide(); $("#mp-url").show(); url.validators = validators; } ' . '});', array("id" => $this->getId(), "name" => $this->getName()));
         OW::getDocument()->addOnloadScript($js);
     }
     // submit
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'save_btn_label'));
     $this->addElement($submit);
 }
Пример #15
0
 public function __construct($name, BOL_MenuItem $menu)
 {
     parent::__construct($name);
     $navigationService = BOL_NavigationService::getInstance();
     $document = $navigationService->findDocumentByKey($menu->getDocumentKey());
     if ($document === null) {
         $document = new BOL_Document();
         $document->setKey($menu->getDocumentKey());
     }
     $language = OW_Language::getInstance();
     $languageService = BOL_LanguageService::getInstance();
     $currentLanguageId = $languageService->getCurrent()->getId();
     $plugin = OW::getPluginManager()->getPlugin('base');
     $adminPlugin = OW::getPluginManager()->getPlugin('admin');
     $nameTextField = new TextField('name');
     $langValueDto = $languageService->getValue($currentLanguageId, $plugin->getKey(), $menu->getKey());
     $langValue = $langValueDto === null ? '' : $language->text($plugin->getKey(), $menu->getKey());
     $this->addElement($nameTextField->setValue($langValue)->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_menu_name'))->setRequired());
     $titleTextField = new TextField('title');
     $langValueDto = $languageService->getValue($currentLanguageId, $plugin->getKey(), 'local_page_title_' . $menu->getKey());
     $langValue = $langValueDto === null ? '' : $language->text($plugin->getKey(), 'local_page_title_' . $menu->getKey());
     $this->addElement($titleTextField->setValue($langValue)->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_page_title'))->setRequired(true));
     $urlTextField = new TextField('url');
     $urlTextField->addValidator(new LocalPageUniqueValidator($document->getUri()));
     $this->addElement($urlTextField->setValue($document->getUri())->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_page_url'))->setRequired(true));
     $visibleForCheckboxGroup = new CheckboxGroup('visible-for');
     $visibleFor = $menu->getVisibleFor();
     $options = array('1' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_guests'), '2' => OW::getLanguage()->text('admin', 'pages_edit_visible_for_members'));
     $values = array();
     foreach ($options as $value => $option) {
         if (!($value & $visibleFor)) {
             continue;
         }
         $values[] = $value;
     }
     $this->addElement($visibleForCheckboxGroup->setOptions($options)->setValue($values)->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_visible_for')));
     $metaTagsTextarea = new Textarea('meta-tags');
     $langValueDto = $languageService->getValue($currentLanguageId, $plugin->getKey(), 'local_page_meta_tags_' . $menu->getKey());
     $langValue = $langValueDto === null ? '' : $language->text($plugin->getKey(), 'local_page_meta_tags_' . $menu->getKey());
     $this->addElement($metaTagsTextarea->setLabel('Page meta tags')->setValue($langValue)->setDescription(OW::getLanguage()->text('admin', 'pages_page_field_meta_desc'))->setId('meta-tags'));
     $contentTextArea = new Textarea('content');
     $contentTextArea->setDescription(OW::getLanguage()->text('admin', 'pages_page_field_content_desc', array('src' => OW::getThemeManager()->getCurrentTheme()->getStaticImagesUrl() . 'question.png', 'url' => '#')));
     $langValueDto = $languageService->getValue($currentLanguageId, $plugin->getKey(), 'local_page_content_' . $menu->getKey());
     $langValue = $langValueDto === null ? '' : $language->text($plugin->getKey(), 'local_page_content_' . $menu->getKey());
     $this->addElement($contentTextArea->setLabel(OW::getLanguage()->text('admin', 'pages_edit_local_page_content'))->setValue($langValue)->setId('content'));
     $saveSubmit = new Submit('save');
     $this->addElement($saveSubmit->setValue($language->text($adminPlugin->getKey(), 'save_btn_label')));
 }
Пример #16
0
 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);
 }
Пример #17
0
 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);
 }