From 823d71ced9b4947b1a5a5ade7245d521ed490061 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 7 Jun 2016 15:17:49 +0200 Subject: * renaming php directory --- app/frontend/controls/AddToFilter.php | 41 ++++++ app/frontend/controls/AddToFilter.tpl | 8 ++ app/frontend/controls/CalendarDetails.php | 7 + app/frontend/controls/CalendarDetails.tpl | 13 ++ app/frontend/controls/CalendarGrid.php | 59 +++++++++ app/frontend/controls/CalendarGrid.tpl | 28 ++++ app/frontend/controls/CalendarGroupFilter.php | 21 +++ app/frontend/controls/CalendarGroupFilter.tpl | 16 +++ app/frontend/controls/CalendarLabel.php | 13 ++ app/frontend/controls/CalendarLabel.tpl | 12 ++ app/frontend/controls/CalendarScaffold.php | 142 +++++++++++++++++++++ app/frontend/controls/CalendarScaffold.tpl | 81 ++++++++++++ app/frontend/controls/CalendarSelection.php | 17 +++ app/frontend/controls/CalendarSelection.tpl | 8 ++ app/frontend/controls/EventList.php | 59 +++++++++ app/frontend/controls/EventList.tpl | 6 + app/frontend/controls/EventRepeater.php | 25 ++++ app/frontend/controls/EventRepeater.tpl | 12 ++ app/frontend/controls/HeaderMenu.php | 26 ++++ app/frontend/controls/HeaderMenu.tpl | 36 ++++++ app/frontend/controls/LoginBox.php | 39 ++++++ app/frontend/controls/LoginBox.tpl | 33 +++++ app/frontend/controls/PasswordChange.php | 44 +++++++ app/frontend/controls/PasswordChange.tpl | 59 +++++++++ app/frontend/controls/RegistrationForm.php | 28 ++++ app/frontend/controls/RegistrationForm.tpl | 66 ++++++++++ app/frontend/controls/TimezoneSelect.php | 58 +++++++++ app/frontend/controls/TimezoneSelect.tpl | 5 + app/frontend/controls/UpcomingEvents.php | 33 +++++ app/frontend/controls/UpcomingEvents.tpl | 5 + app/frontend/controls/UrlBasedCalendarControl.php | 40 ++++++ app/frontend/controls/UserSelection.php | 45 +++++++ app/frontend/controls/UserSelection.tpl | 29 +++++ app/frontend/controls/config.xml | 6 + app/frontend/controls/scripts/AddToFilter.js | 5 + .../controls/scripts/CalendarGroupFilter.js | 29 +++++ app/frontend/controls/scripts/CalendarLabel.js | 11 ++ app/frontend/controls/scripts/CalendarScaffold.js | 8 ++ app/frontend/controls/styles/CalendarGrid.css | 16 +++ app/frontend/controls/styles/CalendarScaffold.css | 11 ++ 40 files changed, 1200 insertions(+) create mode 100644 app/frontend/controls/AddToFilter.php create mode 100644 app/frontend/controls/AddToFilter.tpl create mode 100644 app/frontend/controls/CalendarDetails.php create mode 100644 app/frontend/controls/CalendarDetails.tpl create mode 100644 app/frontend/controls/CalendarGrid.php create mode 100644 app/frontend/controls/CalendarGrid.tpl create mode 100644 app/frontend/controls/CalendarGroupFilter.php create mode 100644 app/frontend/controls/CalendarGroupFilter.tpl create mode 100644 app/frontend/controls/CalendarLabel.php create mode 100644 app/frontend/controls/CalendarLabel.tpl create mode 100644 app/frontend/controls/CalendarScaffold.php create mode 100644 app/frontend/controls/CalendarScaffold.tpl create mode 100644 app/frontend/controls/CalendarSelection.php create mode 100644 app/frontend/controls/CalendarSelection.tpl create mode 100644 app/frontend/controls/EventList.php create mode 100644 app/frontend/controls/EventList.tpl create mode 100644 app/frontend/controls/EventRepeater.php create mode 100644 app/frontend/controls/EventRepeater.tpl create mode 100644 app/frontend/controls/HeaderMenu.php create mode 100644 app/frontend/controls/HeaderMenu.tpl create mode 100644 app/frontend/controls/LoginBox.php create mode 100644 app/frontend/controls/LoginBox.tpl create mode 100644 app/frontend/controls/PasswordChange.php create mode 100644 app/frontend/controls/PasswordChange.tpl create mode 100644 app/frontend/controls/RegistrationForm.php create mode 100644 app/frontend/controls/RegistrationForm.tpl create mode 100644 app/frontend/controls/TimezoneSelect.php create mode 100644 app/frontend/controls/TimezoneSelect.tpl create mode 100644 app/frontend/controls/UpcomingEvents.php create mode 100644 app/frontend/controls/UpcomingEvents.tpl create mode 100644 app/frontend/controls/UrlBasedCalendarControl.php create mode 100644 app/frontend/controls/UserSelection.php create mode 100644 app/frontend/controls/UserSelection.tpl create mode 100644 app/frontend/controls/config.xml create mode 100644 app/frontend/controls/scripts/AddToFilter.js create mode 100644 app/frontend/controls/scripts/CalendarGroupFilter.js create mode 100644 app/frontend/controls/scripts/CalendarLabel.js create mode 100644 app/frontend/controls/scripts/CalendarScaffold.js create mode 100644 app/frontend/controls/styles/CalendarGrid.css create mode 100644 app/frontend/controls/styles/CalendarScaffold.css (limited to 'app/frontend/controls') diff --git a/app/frontend/controls/AddToFilter.php b/app/frontend/controls/AddToFilter.php new file mode 100644 index 0000000..9146f3b --- /dev/null +++ b/app/frontend/controls/AddToFilter.php @@ -0,0 +1,41 @@ +setViewState('Description', TPropertyValue::ensureString($val)); + } + + public function getDescription() { + return $this->getViewState('Description'); + } + + public function setUserPreference($sender, $param) { + $user = $this->getUserToManage(); + if ($user && !$user->IsGuest) { + if ($sender->Checked) { + $this->getFacade()->addToPreference($user, $this->getCalendar()->ID); + } else { + $this->getFacade()->removeFromPreference($user, $this->getCalendar()->ID); + } + $this->Page->CallbackClient->jQuery($this->Box, 'removeAttr', 'disabled'); + } + } + + public function getUserToManage() { + return $this->getControlState('user'); + } + + public function setUserToManage($user) { + $this->setControlState('user', $user); + } + + public function getPradoScriptDependencies() { + return ['jquery']; + } + +} + +?> diff --git a/app/frontend/controls/AddToFilter.tpl b/app/frontend/controls/AddToFilter.tpl new file mode 100644 index 0000000..a202aa7 --- /dev/null +++ b/app/frontend/controls/AddToFilter.tpl @@ -0,0 +1,8 @@ + + <%= !$this->UserToManage->IsGuest %> + <%= $this->Facade->isCalendarPreferred($this->UserToManage, $this->getCalendar()->ID) %> + <%= $this->UserToManage->IsGuest ? Prado::localize('log in to manage your selections') : '' %> + + + <%= $this->getDescription() %> + diff --git a/app/frontend/controls/CalendarDetails.php b/app/frontend/controls/CalendarDetails.php new file mode 100644 index 0000000..95ee563 --- /dev/null +++ b/app/frontend/controls/CalendarDetails.php @@ -0,0 +1,7 @@ + diff --git a/app/frontend/controls/CalendarDetails.tpl b/app/frontend/controls/CalendarDetails.tpl new file mode 100644 index 0000000..2fd755c --- /dev/null +++ b/app/frontend/controls/CalendarDetails.tpl @@ -0,0 +1,13 @@ + + <%= $this->getCalendar()->Name %> + + + <%= $this->getCalendar()->Image %> + + + <%[ Source website ]%> + <%= $this->getCalendar()->Website %> + +

+ <%[ Last updated: ]%> <%= $this->getCalendar()->LastUpdated %> +

diff --git a/app/frontend/controls/CalendarGrid.php b/app/frontend/controls/CalendarGrid.php new file mode 100644 index 0000000..4ebfacd --- /dev/null +++ b/app/frontend/controls/CalendarGrid.php @@ -0,0 +1,59 @@ +setControlState('Month', $month); + } + + public function getMonth() { + return $this->getControlState('Month'); + } + + public function setYear($year) { + $this->setControlState('Year', $year); + } + + public function getYear() { + return $this->getControlState('Year'); + } + + public function setUserToDisplay(DbUser $user) { + $this->setControlState('User', $user); + } + + public function getUserToDisplay() { + return $this->getControlState('User'); + } + + private function _getGrid() { + return $this->getFacade()->getCalendarListForUser( + $this->UserToDisplay, + $this->Month, + $this->Year + ); + } + + public function onPreRender($param) { + parent::onPreRender($param); + $this->Weeks->DataSource = $this->_getGrid()->Weeks; + $this->Weeks->dataBind(); + } + + public function weekDataBind($sender, $param) { + $param->Item->Days->DataSource = $param->Item->Data; + $param->Item->Days->dataBind(); + } + + public function dayDataBind($sender, $param) { + $param->Item->Events->DataSource = $param->Item->Data->Events; + $param->Item->Events->dataBind(); + } + +} + +?> diff --git a/app/frontend/controls/CalendarGrid.tpl b/app/frontend/controls/CalendarGrid.tpl new file mode 100644 index 0000000..2b3ada8 --- /dev/null +++ b/app/frontend/controls/CalendarGrid.tpl @@ -0,0 +1,28 @@ + + +
+ + +
+ <%# $this->Data->Date %> + + + + + + gridEvent <%# $this->Parent->Parent->Data->Date == $this->Data->DateFrom ? 'beginDate' : '' %> <%# $this->Parent->Parent->Data->Date == $this->Data->DateTo ? 'endDate' : '' %> + <%# $this->Data->Name %> + + + +
 
+
+
+
+
+
+
+
+
+
+
diff --git a/app/frontend/controls/CalendarGroupFilter.php b/app/frontend/controls/CalendarGroupFilter.php new file mode 100644 index 0000000..6f19bcd --- /dev/null +++ b/app/frontend/controls/CalendarGroupFilter.php @@ -0,0 +1,21 @@ +Categories->DataSource = $this->Facade->getCategories(); + $this->Categories->dataBind(); + } + + public function getPradoScriptDependencies() { + return ['jquery']; + } + +} + +?> diff --git a/app/frontend/controls/CalendarGroupFilter.tpl b/app/frontend/controls/CalendarGroupFilter.tpl new file mode 100644 index 0000000..ac82465 --- /dev/null +++ b/app/frontend/controls/CalendarGroupFilter.tpl @@ -0,0 +1,16 @@ + + +
+ <%[ All ]%> + +
+
+ +
+ <%# $this->Data->Name %> + + <%# $this->Data->ID %> + +
+
+
diff --git a/app/frontend/controls/CalendarLabel.php b/app/frontend/controls/CalendarLabel.php new file mode 100644 index 0000000..667e847 --- /dev/null +++ b/app/frontend/controls/CalendarLabel.php @@ -0,0 +1,13 @@ + diff --git a/app/frontend/controls/CalendarLabel.tpl b/app/frontend/controls/CalendarLabel.tpl new file mode 100644 index 0000000..69e0147 --- /dev/null +++ b/app/frontend/controls/CalendarLabel.tpl @@ -0,0 +1,12 @@ + + <%= $this->Calendar->GroupID %> + + <%= $this->Service->constructUrl('Calendar', ['calendar' => $this->Calendar->Url]) %> + <%= $this->Calendar->Name %> + + + <%= $this->Facade %> + <%= $this->Calendar->Url %> + <%= $this->User %> + + diff --git a/app/frontend/controls/CalendarScaffold.php b/app/frontend/controls/CalendarScaffold.php new file mode 100644 index 0000000..7f15a32 --- /dev/null +++ b/app/frontend/controls/CalendarScaffold.php @@ -0,0 +1,142 @@ +Page->IsPostBack && !$this->Page->IsCallBack) { + $this->_rebindData(); + } + } + + private function _rebindCalendars(array $calendars) { + $this->Calendars->DataSource = $calendars; + $this->Calendars->dataBind(); + } + + private function _rebindCategoryList(array $categories) { + foreach ($this->Calendars->Columns as $column) { + if ($column->ID === 'Category' + && $column instanceof TActiveDropDownListColumn) { + $column->ListDataSource = $categories; + } + } + } + + private function _rebindData(bool $refresh = FALSE) { + $this->_rebindCategoryList( + $this->_getCategories() + ); + $this->_rebindCalendars( + $this->_getCalendars($refresh) + ); + } + + private function _getCalendars(bool $refresh = FALSE) { + if ($refresh) { + $this->clearViewState('Calendars'); + } + $calendars = $this->getViewState( + 'Calendars', + $this->getFacade()->getAll() + ); + $this->setViewState('Calendars', $calendars); + return $calendars; + } + + private function _getCategories() { + $categories = $this->getViewState( + 'Categories', + $this->getFacade()->getCategories() + ); + $this->setViewState('Categories', $categories); + return $categories; + } + + public function editRow($sender, $param) { + $this->Calendars->EditItemIndex = $param->Item->ItemIndex; + $this->_rebindData(); + } + + private function _compileSaveData(TDataGridItem $item) { + return [ + 'CategoryID' => $item->Category->DropDownList->SelectedValue, + 'Visible' => $item->Visible->CheckBox->Checked, + 'CustomName' => $item->CustomName->TextBox->SafeText, + 'CustomUrl' => $item->CustomUrl->TextBox->SafeText, + 'CustomImage' => $item->CustomImage->Value->SafeText + ]; + } + + public function saveRow($sender, $param) { + $calendar = $this->getFacade()->get( + $sender->DataKeys[$param->Item->ItemIndex] + ); + if ($calendar) { + foreach ($calendar as $c) { + $c->saveData($this->_compileSaveData($param->Item)); + } + } else { + throw new TInvalidDataValueException( + Prado::localize('Calendar not found') + ); + } + $this->Calendars->EditItemIndex = -1; + $this->_rebindData(TRUE); + } + + public function cancelRowEdit($sender, $param) { + $this->Calendars->EditItemIndex = -1; + $this->_rebindData(); + } + + public function toggleDefaultState($sender, $param) { + $calendar = $this->getFacade()->get($sender->CustomData); + if ($calendar) { + $calendar[0]->Visible = $sender->Checked; + $calendar[0]->save(); + $this->_rebindData(TRUE); + } + } + + public function uploadRowFile($sender, $param) { + $fileType = $sender->getFileType(); + if (preg_match('/^image\//', $fileType)) { + $calendar = $this->getFacade()->get($sender->CustomData); + if ($calendar) { + $targetFile = $calendar[0]->getCustomImagePath( + $sender->getLocalName(), + $fileType + ); + if ($sender->saveAs($targetFile)) { + $sender->NamingContainer->CustomImage->Value->Text = basename( + $targetFile + ); + } + } else { + throw new TInvalidDataValueException( + Prado::localize('Calendar not found') + ); + } + } else { + throw new TInvalidDataTypeException( + Prado::localize('Invalid file type') + ); + } + } + + protected function getPradoScriptDependencies() { + return ['jquery']; + } + +} + +?> diff --git a/app/frontend/controls/CalendarScaffold.tpl b/app/frontend/controls/CalendarScaffold.tpl new file mode 100644 index 0000000..6a22bc2 --- /dev/null +++ b/app/frontend/controls/CalendarScaffold.tpl @@ -0,0 +1,81 @@ + + + + <%[ Calendar ]%> + + + <%[ WWW ]%> + <%[ [www] ]%> + + + <%[ ICS ]%> + <%[ [ics] ]%> + + + <%[ Category ]%> + + + <%[ Default ]%> + + + <%# $this->Parent->Data->Visible %> + <%# $this->Parent->Data->UID %> + + + + + <%# $this->Parent->Data->Visible %> + + + + + <%[ Custom name ]%> + + + <%[ URL ]%> + + + <%[ Image ]%> + + + <%# $this->Parent->Data->CustomImageUrl %> + + + + + <%# $this->Parent->Data->CustomImage %> +
+ + <%# $this->Parent->Data->UID %> + +
+
+ + <%[ Edit ]%> + <%[ Save ]%> + <%[ Cancel ]%> + +
+
diff --git a/app/frontend/controls/CalendarSelection.php b/app/frontend/controls/CalendarSelection.php new file mode 100644 index 0000000..e53aa36 --- /dev/null +++ b/app/frontend/controls/CalendarSelection.php @@ -0,0 +1,17 @@ +Page->IsCallBack) { + $this->Calendars->DataSource = $this->Facade->getAll(); + $this->Calendars->dataBind(); + } + } + +} + +?> diff --git a/app/frontend/controls/CalendarSelection.tpl b/app/frontend/controls/CalendarSelection.tpl new file mode 100644 index 0000000..d6bdd83 --- /dev/null +++ b/app/frontend/controls/CalendarSelection.tpl @@ -0,0 +1,8 @@ + + + + <%# $this->SourceTemplateControl->Facade %> + <%# $this->Data->CustomUrl %> + + + diff --git a/app/frontend/controls/EventList.php b/app/frontend/controls/EventList.php new file mode 100644 index 0000000..d40e000 --- /dev/null +++ b/app/frontend/controls/EventList.php @@ -0,0 +1,59 @@ + $date]) + ); + } + $this->setViewState($key, $datetime); + } + + public function setDateFrom($date) { + $this->_setDate('DateFrom', $date); + } + + public function getDateFrom() { + return $this->getViewState('DateFrom'); + } + + public function setDateTo($date) { + $this->_setDate('DateTo', $date); + } + + public function getDateTo() { + return $this->getViewState('DateTo'); + } + + public function setHeaderText($text) { + $this->setViewState('HeaderText', TPropertyValue::ensureString($text)); + } + + public function getHeaderText() { + return $this->getViewState('HeaderText'); + } + + public function setReverse($value) { + $this->setViewState('Reverse', TPropertyValue::ensureBoolean($value)); + } + + public function getReverse() { + return $this->getViewState('Reverse'); + } + + public function getEvents() { + return $this->getFacade()->getEventsForTimeframe( + $this->getCalendar(), + $this->getDateFrom() ?: new DateTime('0000-00-00'), + $this->getDateTo() ?: new DateTime('9999-99-99'), + $this->getReverse() ? 'DESC' : 'ASC' + ); + } + +} + +?> diff --git a/app/frontend/controls/EventList.tpl b/app/frontend/controls/EventList.tpl new file mode 100644 index 0000000..5881ce7 --- /dev/null +++ b/app/frontend/controls/EventList.tpl @@ -0,0 +1,6 @@ + + <%= $this->getHeaderText() %> + + + <%= $this->getEvents() %> + diff --git a/app/frontend/controls/EventRepeater.php b/app/frontend/controls/EventRepeater.php new file mode 100644 index 0000000..4fb2812 --- /dev/null +++ b/app/frontend/controls/EventRepeater.php @@ -0,0 +1,25 @@ +Events->DataSource = $events; + $this->Events->dataBind(); + } + + public function setCalendarLinkVisible($value) { + $this->setViewState( + 'CalendarLinkVisible', + TPropertyValue::ensureBoolean($value) + ); + } + + public function getCalendarLinkVisible() { + return $this->getViewState('CalendarLinkVisible', TRUE); + } + +} + +?> diff --git a/app/frontend/controls/EventRepeater.tpl b/app/frontend/controls/EventRepeater.tpl new file mode 100644 index 0000000..69aaabf --- /dev/null +++ b/app/frontend/controls/EventRepeater.tpl @@ -0,0 +1,12 @@ + + + <%# $this->Data->DateString %> + <%# $this->Data->Name %> + + <%# $this->SourceTemplateControl->CalendarLinkVisible %> + (<%# $this->Data->Calendar->Name %>) + <%# $this->Service->constructUrl('Calendar', ['calendar' => $this->Data->Calendar->Url]) %> + +
+
+
diff --git a/app/frontend/controls/HeaderMenu.php b/app/frontend/controls/HeaderMenu.php new file mode 100644 index 0000000..2488629 --- /dev/null +++ b/app/frontend/controls/HeaderMenu.php @@ -0,0 +1,26 @@ +Application->getModule('auth'); + $authModule->setReturnUrl($this->Request->RequestUri); + $this->Response->redirect( + $this->Service->ConstructUrl($authModule->LoginPage) + ); + } + + public function logoutUser($sender, $param) { + $this->Application->getModule('auth')->logout(); + $this->Response->redirect( + $this->Service->ConstructUrl(NULL) + ); + } + +} + +?> diff --git a/app/frontend/controls/HeaderMenu.tpl b/app/frontend/controls/HeaderMenu.tpl new file mode 100644 index 0000000..a760588 --- /dev/null +++ b/app/frontend/controls/HeaderMenu.tpl @@ -0,0 +1,36 @@ + diff --git a/app/frontend/controls/LoginBox.php b/app/frontend/controls/LoginBox.php new file mode 100644 index 0000000..1136a79 --- /dev/null +++ b/app/frontend/controls/LoginBox.php @@ -0,0 +1,39 @@ +Page->IsPostBack && !$this->User->IsGuest) { + $this->_afterLoginRedirect(); + } + } + + private function _afterLoginRedirect() { + $authModule = $this->Application->getModule('auth'); + $redirUrl = $authModule->ReturnUrl; + if (!$redirUrl + || $redirUrl == $this->Service->constructUrl($authModule->LoginPage)) { + $redirUrl = $this->Service->constructUrl(NULL); + } + $this->Response->redirect($redirUrl); + } + + public function loginUser($sender, $param) { + if ($this->Page->IsValid) { + $this->_afterLoginRedirect(); + } + } + + public function validatePassword($sender, $param) { + $param->IsValid = $this->Application->getModule('auth')->login( + $this->Login->Text, + $this->Password->Text + ); + } + +} + +?> diff --git a/app/frontend/controls/LoginBox.tpl b/app/frontend/controls/LoginBox.tpl new file mode 100644 index 0000000..070ab86 --- /dev/null +++ b/app/frontend/controls/LoginBox.tpl @@ -0,0 +1,33 @@ +<%[ Username: ]%> + + + <%[ Username cannot be empty ]%> + +
+<%[ Password: ]%> + + + <%[ Password cannot be empty ]%> + + + <%[ Username and password don't match ]%> + +
+ + <%[ Login ]%> + diff --git a/app/frontend/controls/PasswordChange.php b/app/frontend/controls/PasswordChange.php new file mode 100644 index 0000000..45ce656 --- /dev/null +++ b/app/frontend/controls/PasswordChange.php @@ -0,0 +1,44 @@ +getControlState('user'); + } + + public function setUserToChange(DbUser $user) { + if ($user->IsGuest && !$this->Page->IsCallBack) { + throw new TInvalidDataValueException( + Prado::localize( + 'Password change impossible for guest user' + ) + ); + } + $this->setControlState('user', $user); + } + + public function checkPassword($sender, $param) { + $param->IsValid = $this->getFacade()->verifyUserPassword( + $this->Password->Text, $this->UserToChange + ); + } + + public function changePassword($sender, $param) { + $this->SuccessMessage->Visible = FALSE; + if ($this->Page->IsValid) { + $this->getFacade()->changePassword( + $this->UserToChange, + $this->NewPassword->Text + ); + $this->SuccessMessage->Visible = TRUE; + } + } + +} + +?> diff --git a/app/frontend/controls/PasswordChange.tpl b/app/frontend/controls/PasswordChange.tpl new file mode 100644 index 0000000..4eb9a8e --- /dev/null +++ b/app/frontend/controls/PasswordChange.tpl @@ -0,0 +1,59 @@ +<%[ Change password ]%>
+<%[ Current password: ]%> + + + <%[ Current password cannot be empty ]%> + + + <%[ Password is incorrect ]%> + +
+<%[ New password: ]%> + + + <%[ New password cannot be empty ]%> + +
+<%[ Repeat password: ]%> + + + <%[ New password cannot be empty ]%> + + + <%[ Passwords don't match ]%> + +
+ + <%[ Change password ]%> + + + <%[ Your password has been changed ]%> + diff --git a/app/frontend/controls/RegistrationForm.php b/app/frontend/controls/RegistrationForm.php new file mode 100644 index 0000000..46494e3 --- /dev/null +++ b/app/frontend/controls/RegistrationForm.php @@ -0,0 +1,28 @@ +IsValid = $this->getFacade()->checkForUsername($this->Login->SafeText); + } + + public function registerUser($sender, $param) { + if ($this->Page->IsValid) { + $this->getFacade()->registerUser( + $this->Login->SafeText, + $this->Password->Text, + $this->Admin->Checked + ); + $this->Response->redirect( + $this->Service->constructUrl(NULL) + ); + } + } + +} + +?> diff --git a/app/frontend/controls/RegistrationForm.tpl b/app/frontend/controls/RegistrationForm.tpl new file mode 100644 index 0000000..9defe54 --- /dev/null +++ b/app/frontend/controls/RegistrationForm.tpl @@ -0,0 +1,66 @@ +<%[ Username: ]%> + + + <%[ Username cannot be empty ]%> + + + <%[ Username must contain 6-255 characters, all Latin alphanumeric or underscore ]%> + + + <%[ Username already exists ]%> + +
+<%[ Password: ]%> + + + <%[ Password cannot be empty ]%> + +
+<%[ Repeat password: ]%> + + + <%[ Password cannot be empty ]%> + + + <%[ Passwords don't match ]%> + +
+<%[ Admin: ]%> + +
+ + <%[ Create ]%> + + diff --git a/app/frontend/controls/TimezoneSelect.php b/app/frontend/controls/TimezoneSelect.php new file mode 100644 index 0000000..25af453 --- /dev/null +++ b/app/frontend/controls/TimezoneSelect.php @@ -0,0 +1,58 @@ +getControlState('user'); + } + + public function setUserToChange(DbUser $user) { + if ($user->IsGuest && !$this->Page->IsCallBack) { + throw new TInvalidDataValueException( + Prado::localize( + 'Timezone preference change impossible for guest user' + ) + ); + } + $this->setControlState('user', $user); + } + + public function onPreRender($param) { + parent::onPreRender($param); + $this->Timezones->DataSource = $this->_getTimezones(); + $this->Timezones->DataValueField = 'Name'; + $this->Timezones->DataTextField = 'Label'; + $this->Timezones->dataBind(); + $this->Timezones->setSelectedValue( + $this->getFacade()->getTimezonePreference($this->UserToChange)->Name + ); + } + + public function saveTimezone($sender, $param) { + $this->getFacade()->setTimezonePreference( + $this->UserToChange, + $this->Timezones->SelectedValue + ); + } + + private function _getTimezones() { + $timezones = array_map( + function($tz) { + return new TimezoneDTO($tz); + }, + DateTimeZone::listIdentifiers() + ); + usort($timezones, ['TimezoneDTO', '__compare']); + return $timezones; + } + +} + +?> diff --git a/app/frontend/controls/TimezoneSelect.tpl b/app/frontend/controls/TimezoneSelect.tpl new file mode 100644 index 0000000..ee703d6 --- /dev/null +++ b/app/frontend/controls/TimezoneSelect.tpl @@ -0,0 +1,5 @@ + + + <%[ Save timezone ]%> + diff --git a/app/frontend/controls/UpcomingEvents.php b/app/frontend/controls/UpcomingEvents.php new file mode 100644 index 0000000..27fc723 --- /dev/null +++ b/app/frontend/controls/UpcomingEvents.php @@ -0,0 +1,33 @@ +getControlState('user'); + } + + public function setUserToDisplay(DbUser $user) { + $this->setControlState('user', $user); + } + + public function getEvents() { + return $this->_getEventsForUser($this->UserToDisplay); + } + + private function _getEventsForUser(DbUser $user) { + $utc = new DateTimeZone('UTC'); + $dateFrom = new DateTime('now', $utc); + $dateTo = new DateTime('+7 days', $utc); + return $this->getFacade()->getTimeframeListForUser( + $user, + $dateFrom, $dateTo + ); + } + +} + +?> diff --git a/app/frontend/controls/UpcomingEvents.tpl b/app/frontend/controls/UpcomingEvents.tpl new file mode 100644 index 0000000..ac5f60c --- /dev/null +++ b/app/frontend/controls/UpcomingEvents.tpl @@ -0,0 +1,5 @@ +<%[ Upcoming events: ]%> +
+ + <%= $this->getEvents() %> + diff --git a/app/frontend/controls/UrlBasedCalendarControl.php b/app/frontend/controls/UrlBasedCalendarControl.php new file mode 100644 index 0000000..a5be82e --- /dev/null +++ b/app/frontend/controls/UrlBasedCalendarControl.php @@ -0,0 +1,40 @@ +getFacade()->resolveUrl($url); + if ($calendar) { + $this->setControlState('Calendar', $calendar); + return; + } + } + if ($this->getRaiseException()) { + throw new THttpException( + 404, + Prado::localize('Page not found') + ); + } else { + $this->Visible = FALSE; + } + } + + public function getCalendar() { + return $this->getControlState('Calendar'); + } + + public function setRaiseException($value) { + $this->setControlState('RaiseException', TPropertyValue::ensureBoolean($value)); + } + + public function getRaiseException() { + return $this->getControlState('RaiseException', FALSE); + } + +} + +?> diff --git a/app/frontend/controls/UserSelection.php b/app/frontend/controls/UserSelection.php new file mode 100644 index 0000000..233f0bf --- /dev/null +++ b/app/frontend/controls/UserSelection.php @@ -0,0 +1,45 @@ +getControlState('user'); + } + + public function setUserToDisplay(DbUser $user = NULL) { + $this->setControlState('user', $user); + } + + public function onPreRender($param) { + parent::onPreRender($param); + $this->Categories->setDataSource( + $this->_getUserSelection($this->UserToDisplay) + ); + $this->Categories->dataBind(); + } + + public function categoryDataBind($sender, $param) { + $param->Item->Calendars->setDataSource($param->Item->Data->Calendars); + $param->Item->Calendars->dataBind(); + } + + public function removeFromSelection($sender, $param) { + if (!$this->UserToDisplay->IsGuest) { + return $this->getFacade()->removeFromPreference( + $this->UserToDisplay, + $param->CommandParameter + ); + } + } + + private function _getUserSelection(DbUser $user) { + return $this->getFacade()->getPreferenceList($user); + } + +} + +?> diff --git a/app/frontend/controls/UserSelection.tpl b/app/frontend/controls/UserSelection.tpl new file mode 100644 index 0000000..8d20365 --- /dev/null +++ b/app/frontend/controls/UserSelection.tpl @@ -0,0 +1,29 @@ +<%[ Selected calendars: ]%> +
+ + + <%# $this->Data->Name %>
+ + + + <%# $this->Data->ID %> + <%# !$this->SourceTemplateControl->UserToDisplay->IsGuest %> + + <%# $this->Data->Name %> + + <%[ (details) ]%> + <%# $this->Service->constructUrl('Calendar', ['calendar' => $this->Data->Url]) %> + + + <%# $this->Data->Website %> + +
+
+
+
+
+
diff --git a/app/frontend/controls/config.xml b/app/frontend/controls/config.xml new file mode 100644 index 0000000..61d7e5b --- /dev/null +++ b/app/frontend/controls/config.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/app/frontend/controls/scripts/AddToFilter.js b/app/frontend/controls/scripts/AddToFilter.js new file mode 100644 index 0000000..e6d7b39 --- /dev/null +++ b/app/frontend/controls/scripts/AddToFilter.js @@ -0,0 +1,5 @@ +$(document).on('ready', function() { + $('input.addToFilterBox').on('change', function() { + $(this).attr('disabled', true); + }); +}); diff --git a/app/frontend/controls/scripts/CalendarGroupFilter.js b/app/frontend/controls/scripts/CalendarGroupFilter.js new file mode 100644 index 0000000..e6c1d73 --- /dev/null +++ b/app/frontend/controls/scripts/CalendarGroupFilter.js @@ -0,0 +1,29 @@ +$(document).on('ready', function() { + var selectBoxes = $('.selectGroup input.box'); + var selectAllBox = $('.selectAllGroups input.box'); + selectBoxes.on('change', function() { + var groups = []; + var allSelected = true; + $('.selectGroup input.box').each(function() { + var box = $(this); + if (box.is(':checked')) { + groups.push(box.val()); + } else { + allSelected = false; + } + }); + if (allSelected) { + selectAllBox.prop('checked', true); + } else { + selectAllBox.removeAttr('checked'); + } + $(document).trigger('Application.calendarGroupFilterChanged', {groups: groups}); + }); + selectAllBox.on('change', function() { + if ($(this).is(':checked')) { + selectBoxes.prop('checked', true).trigger('change'); + } else { + selectBoxes.removeAttr('checked').trigger('change'); + } + }); +}); diff --git a/app/frontend/controls/scripts/CalendarLabel.js b/app/frontend/controls/scripts/CalendarLabel.js new file mode 100644 index 0000000..8193e56 --- /dev/null +++ b/app/frontend/controls/scripts/CalendarLabel.js @@ -0,0 +1,11 @@ +$(document).on('Application.calendarGroupFilterChanged', function(event, args) { + var selectedGroups = args.groups || []; + $('.calendar').each(function() { + var label = $(this); + if (selectedGroups.indexOf(label.attr('data-group')) >= 0) { + label.show(); + } else { + label.hide(); + } + }); +}); diff --git a/app/frontend/controls/scripts/CalendarScaffold.js b/app/frontend/controls/scripts/CalendarScaffold.js new file mode 100644 index 0000000..d4b8ec5 --- /dev/null +++ b/app/frontend/controls/scripts/CalendarScaffold.js @@ -0,0 +1,8 @@ +$('body').on( + 'click', + 'main .calendarScaffold tbody a[href^="javascript:;//"], main .calendarScaffold tbody input.visibilityToggle', + function(e) { + var loader = $('
').addClass('calendarScaffoldLoader'); + $('main .calendarScaffold div[id$="_Container"]').append(loader); + } +); diff --git a/app/frontend/controls/styles/CalendarGrid.css b/app/frontend/controls/styles/CalendarGrid.css new file mode 100644 index 0000000..4710993 --- /dev/null +++ b/app/frontend/controls/styles/CalendarGrid.css @@ -0,0 +1,16 @@ +div.gridWeek { + clear: both; + display: flex; + flex-flow: row nowrap; +} +div.gridDay { + width: 14%; + min-height: 8em; + flex: 1 1 auto; +} +div.gridEvent, div.gridItem { height: 1.5em; padding: 0.3em 0.5em; margin: 0.1em 0; } +div.gridEvent { overflow: hidden; white-space: nowrap; background: #ddd } +div.gridEvent.beginDate { border-top-left-radius: 1.5em; + border-bottom-left-radius: 1.5em } +div.gridEvent.endDate { border-top-right-radius: 1.5em; + border-bottom-right-radius: 1.5em } diff --git a/app/frontend/controls/styles/CalendarScaffold.css b/app/frontend/controls/styles/CalendarScaffold.css new file mode 100644 index 0000000..071f672 --- /dev/null +++ b/app/frontend/controls/styles/CalendarScaffold.css @@ -0,0 +1,11 @@ +.calendarScaffold { + position: relative; +} +.calendarScaffold .calendarScaffoldLoader { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: url(preloader.gif) no-repeat center 5% rgba(255,255,255,0.8); +} -- cgit v1.2.3