Пример #1
0
 public function __construct($name)
 {
     $this->name = $name;
     $this->dayBox = new SelectBox($name . '[day]', date('j') - 1);
     $this->dayBox->setCSSClass('day');
     for ($i = 1; $i <= 31; $i++) {
         $this->dayBox->addOption($i, $i);
     }
     $this->monthBox = new SelectBox($name . '[month]', date('n') - 1);
     $this->monthBox->setCSSClass('month');
     $months = array('januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december');
     for ($i = 0; $i < 12; $i++) {
         $this->monthBox->addOption($months[$i], $i + 1);
     }
     $this->yearBox = new SelectBox($name . '[year]', 2010);
     $this->yearBox->setCSSClass('year');
     for ($i = date('Y'); $i >= date('Y') - 5; $i--) {
         $this->yearBox->addOption($i, $i);
     }
 }
Пример #2
0
 public function index($params)
 {
     $this->setPageTitle(OW::getLanguage()->text('spdownload', 'category_index_page_title'));
     $this->setPageHeading(OW::getLanguage()->text('spdownload', 'category_index_page_heading'));
     $category = array();
     if (!empty($params) && isset($params['categoryId'])) {
         $category = SPDOWNLOAD_BOL_CategoryDao::getInstance()->findById($params['categoryId']);
     }
     $downloads = SPDOWNLOAD_BOL_CategoryService::getInstance()->getCategoryList();
     $downloadCategories = array();
     foreach ($downloads as $key => $value) {
         $downloadCategories[$value->id] = $value->name;
     }
     $form = new Form('add_category');
     $this->addForm($form);
     // Create selectbox
     $fieldTo = new SelectBox('parent_category');
     foreach ($downloadCategories as $key => $label) {
         $fieldTo->addOption($key, $label);
     }
     if (!empty($params) && isset($params['categoryId'])) {
         $fieldTo->setValue($category->parentId);
     }
     $fieldTo->setLabel(OW::getLanguage()->text('spdownload', 'ad_parent_category'));
     $form->addElement($fieldTo);
     $fieldCate = new TextField('category');
     $fieldCate->setLabel(OW::getLanguage()->text('spdownload', 'ad_label_category'));
     if (!empty($params) && isset($params['categoryId'])) {
         $fieldCate->setValue($category->name);
     }
     $fieldCate->setRequired();
     $fieldCate->setHasInvitation(true);
     $form->addElement($fieldCate);
     $submit = new Submit('add');
     $submit->setValue(OW::getLanguage()->text('spdownload', 'form_add_category_submit'));
     $form->addElement($submit);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             if ($data['parent_category'] == null) {
                 $data['parent_category'] = 0;
             }
             if (!empty($params) && isset($params['categoryId'])) {
                 SPDOWNLOAD_BOL_CategoryService::getInstance()->addCategory($data['category'], $data['parent_category'], $params['categoryId']);
             } else {
                 SPDOWNLOAD_BOL_CategoryService::getInstance()->addCategory($data['category'], $data['parent_category']);
             }
             $this->redirect(OW::getRouter()->urlForRoute('spdownload.category_list'));
         }
     }
 }
Пример #3
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);
 }