diff options
Diffstat (limited to 'app/php')
104 files changed, 0 insertions, 3850 deletions
diff --git a/app/php/application.xml b/app/php/application.xml deleted file mode 100644 index 6937e53..0000000 --- a/app/php/application.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<application id="http" mode="Normal"> - - <include file="Application.caches" /> - - <include file="Application.db.config" /> - <include file="Application.model.config" /> - <include file="Application.facades.config" /> - - <include file="Application.user.config" /> - - <include file="Application.url.config" /> - - <include file="Application.i18n.config" /> - - <include file="Application.web.config" /> - <include file="Application.pages.config" /> - <include file="Application.controls.config" /> - - <include file="Application.events.config" /> - - <modules> - <!-- <module id="log" class="System.Util.TLogRouter"> - <route class="TBrowserLogRoute" - Levels="Debug" - Categories="System" /> - </module> --> - </modules> - -</application> diff --git a/app/php/caches.xml b/app/php/caches.xml deleted file mode 100644 index 8a88717..0000000 --- a/app/php/caches.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <modules> - <module id="cache" class="System.Caching.TDbCache" /> - </modules> -</configuration> diff --git a/app/php/components/FileUploadSecureFileSize.php b/app/php/components/FileUploadSecureFileSize.php deleted file mode 100644 index 1e60c9a..0000000 --- a/app/php/components/FileUploadSecureFileSize.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -Prado::using('Application.components.FileUploadSecureOption'); - -trait FileUploadSecureFileSize { - - use FileUploadSecureOption; - - public function getFileSize() { - if ($this->getIsSecure()) { - return filesize($this->getLocalName()); - } - return parent::getFileSize(); - } - -} - -?> diff --git a/app/php/components/FileUploadSecureFileType.php b/app/php/components/FileUploadSecureFileType.php deleted file mode 100644 index ce16501..0000000 --- a/app/php/components/FileUploadSecureFileType.php +++ /dev/null @@ -1,19 +0,0 @@ -<?php - -Prado::using('Application.components.FileUploadSecureOption'); - -trait FileUploadSecureFileType { - - use FileUploadSecureOption; - - public function getFileType() { - if ($this->getIsSecure()) { - $fileInfo = new finfo(FILEINFO_MIME_TYPE); - return $fileInfo->file($this->getLocalName()); - } - return parent::getFileType(); - } - -} - -?> diff --git a/app/php/components/FileUploadSecureMethods.php b/app/php/components/FileUploadSecureMethods.php deleted file mode 100644 index 8a42240..0000000 --- a/app/php/components/FileUploadSecureMethods.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -Prado::using('Application.components.FileUploadSecureOption'); -Prado::using('Application.components.FileUploadSecureFileSize'); -Prado::using('Application.components.FileUploadSecureFileType'); - -trait FileUploadSecureMethods { - use FileUploadSecureOption, FileUploadSecureFileSize, FileUploadSecureFileType { - FileUploadSecureOption::getIsSecure - insteadof FileUploadSecureFileType, FileUploadSecureFileSize; - FileUploadSecureOption::setIsSecure - insteadof FileUploadSecureFileType, FileUploadSecureFileSize; - } -} - -?> diff --git a/app/php/components/FileUploadSecureOption.php b/app/php/components/FileUploadSecureOption.php deleted file mode 100644 index 3550e21..0000000 --- a/app/php/components/FileUploadSecureOption.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -trait FileUploadSecureOption { - - protected $_isSecure = TRUE; - - public function getIsSecure() { - return $this->_isSecure; - } - - public function setIsSecure($bool) { - $this->_isSecure = $bool; - } - -} - -?> diff --git a/app/php/components/SafeActiveFileUpload.php b/app/php/components/SafeActiveFileUpload.php deleted file mode 100644 index 69bffab..0000000 --- a/app/php/components/SafeActiveFileUpload.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -Prado::using('System.Web.UI.ActiveControls.TActiveFileUpload'); - -Prado::using('Application.components.FileUploadSecureMethods'); - -class SafeActiveFileUpload extends TActiveFileUpload { - - use FileUploadSecureMethods; - -} - -?> diff --git a/app/php/components/SafeFileUpload.php b/app/php/components/SafeFileUpload.php deleted file mode 100644 index a8cbcae..0000000 --- a/app/php/components/SafeFileUpload.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -Prado::using('Application.components.FileUploadSecureMethods'); - -class SafeFileUpload extends TFileUpload { - - use FileUploadSecureMethods; - -} - -?> diff --git a/app/php/controls/AddToFilter.php b/app/php/controls/AddToFilter.php deleted file mode 100644 index 9146f3b..0000000 --- a/app/php/controls/AddToFilter.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -Prado::using('System.Web.UI.ActiveControls.TActiveCheckBox'); - -class AddToFilter extends UrlBasedCalendarControl { - - public function setDescription($val) { - $this->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/php/controls/AddToFilter.tpl b/app/php/controls/AddToFilter.tpl deleted file mode 100644 index a202aa7..0000000 --- a/app/php/controls/AddToFilter.tpl +++ /dev/null @@ -1,8 +0,0 @@ -<com:TActiveCheckBox ID="Box" OnCheckedChanged="setUserPreference" CssClass="addToFilterBox"> - <prop:Enabled><%= !$this->UserToManage->IsGuest %></prop:Enabled> - <prop:Checked><%= $this->Facade->isCalendarPreferred($this->UserToManage, $this->getCalendar()->ID) %></prop:Checked> - <prop:ToolTip><%= $this->UserToManage->IsGuest ? Prado::localize('log in to manage your selections') : '' %></prop:ToolTip> -</com:TActiveCheckBox> -<com:TLabel ForControl="Box"> - <prop:Text><%= $this->getDescription() %></prop:Text> -</com:TLabel> diff --git a/app/php/controls/CalendarDetails.php b/app/php/controls/CalendarDetails.php deleted file mode 100644 index 95ee563..0000000 --- a/app/php/controls/CalendarDetails.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php - -class CalendarDetails extends UrlBasedCalendarControl { - -} - -?> diff --git a/app/php/controls/CalendarDetails.tpl b/app/php/controls/CalendarDetails.tpl deleted file mode 100644 index 2fd755c..0000000 --- a/app/php/controls/CalendarDetails.tpl +++ /dev/null @@ -1,13 +0,0 @@ -<com:THeader2> - <%= $this->getCalendar()->Name %> -</com:THeader2> -<com:TImage> - <prop:ImageUrl><%= $this->getCalendar()->Image %></prop:ImageUrl> -</com:TImage> -<com:THyperLink Target="_blank"> - <prop:Text><%[ Source website ]%></prop:Text> - <prop:NavigateUrl><%= $this->getCalendar()->Website %></prop:NavigateUrl> -</com:THyperLink> -<p> - <%[ Last updated: ]%> <%= $this->getCalendar()->LastUpdated %> -</p> diff --git a/app/php/controls/CalendarGrid.php b/app/php/controls/CalendarGrid.php deleted file mode 100644 index 4ebfacd..0000000 --- a/app/php/controls/CalendarGrid.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - -Prado::using('Application.web.FacadeTemplateControl'); -Prado::using('Application.facades.EventFacade'); -Prado::using('Application.user.DbUser'); - -class CalendarGrid extends FacadeTemplateControl { - - public function setMonth($month) { - $this->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/php/controls/CalendarGrid.tpl b/app/php/controls/CalendarGrid.tpl deleted file mode 100644 index 2b3ada8..0000000 --- a/app/php/controls/CalendarGrid.tpl +++ /dev/null @@ -1,28 +0,0 @@ -<com:TRepeater ID="Weeks" OnItemDataBound="weekDataBind"> - <prop:ItemTemplate> - <div class="gridWeek"> - <com:TRepeater ID="Days" OnItemDataBound="SourceTemplateControl.dayDataBind"> - <prop:ItemTemplate> - <div class="gridDay"> - <%# $this->Data->Date %> - <com:TRepeater ID="Events"> - <prop:ItemTemplate> - <com:TConditional Condition="$this->Data"> - <prop:TrueTemplate> - <com:THtmlElement TagName="div"> - <prop:CssClass>gridEvent <%# $this->Parent->Parent->Data->Date == $this->Data->DateFrom ? 'beginDate' : '' %> <%# $this->Parent->Parent->Data->Date == $this->Data->DateTo ? 'endDate' : '' %></prop:CssClass> - <%# $this->Data->Name %> - </com:THtmlElement> - </prop:TrueTemplate> - <prop:FalseTemplate> - <div class="gridItem"> </div> - </prop:FalseTemplate> - </com:TConditional> - </prop:ItemTemplate> - </com:TRepeater> - </div> - </prop:ItemTemplate> - </com:TRepeater> - </div> - </prop:ItemTemplate> -</com:TRepeater> diff --git a/app/php/controls/CalendarGroupFilter.php b/app/php/controls/CalendarGroupFilter.php deleted file mode 100644 index 6f19bcd..0000000 --- a/app/php/controls/CalendarGroupFilter.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -Prado::using('Application.web.FacadeTemplateControl'); - -Prado::using('Application.facades.CalendarFacade'); - -class CalendarGroupFilter extends FacadeTemplateControl { - - public function onPreRender($param) { - parent::onPreRender($param); - $this->Categories->DataSource = $this->Facade->getCategories(); - $this->Categories->dataBind(); - } - - public function getPradoScriptDependencies() { - return ['jquery']; - } - -} - -?> diff --git a/app/php/controls/CalendarGroupFilter.tpl b/app/php/controls/CalendarGroupFilter.tpl deleted file mode 100644 index ac82465..0000000 --- a/app/php/controls/CalendarGroupFilter.tpl +++ /dev/null @@ -1,16 +0,0 @@ -<com:TRepeater ID="Categories"> - <prop:HeaderTemplate> - <div class="selectAllGroups"> - <%[ All ]%> - <com:TCheckBox CssClass="box" Checked="True" /> - </div> - </prop:HeaderTemplate> - <prop:ItemTemplate> - <div class="selectGroup"> - <%# $this->Data->Name %> - <com:TCheckBox CssClass="box" Checked="True"> - <prop:Value><%# $this->Data->ID %></prop:Value> - </com:TCheckBox> - </div> - </prop:ItemTemplate> -</com:TRepeater> diff --git a/app/php/controls/CalendarLabel.php b/app/php/controls/CalendarLabel.php deleted file mode 100644 index 667e847..0000000 --- a/app/php/controls/CalendarLabel.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -Prado::using('Application.controls.UrlBasedCalendarControl'); - -class CalendarLabel extends UrlBasedCalendarControl { - - public function getPradoScriptDependencies() { - return ['jquery']; - } - -} - -?> diff --git a/app/php/controls/CalendarLabel.tpl b/app/php/controls/CalendarLabel.tpl deleted file mode 100644 index 69e0147..0000000 --- a/app/php/controls/CalendarLabel.tpl +++ /dev/null @@ -1,12 +0,0 @@ -<com:TPanel CssClass="calendar"> - <prop:Attributes.data-group><%= $this->Calendar->GroupID %></prop:Attributes.data-group> - <com:THyperLink> - <prop:NavigateUrl><%= $this->Service->constructUrl('Calendar', ['calendar' => $this->Calendar->Url]) %></prop:NavigateUrl> - <prop:Text><%= $this->Calendar->Name %></prop:Text> - </com:THyperLink> - <com:AddToFilter> - <prop:Facade><%= $this->Facade %></prop:Facade> - <prop:CalendarUrl><%= $this->Calendar->Url %></prop:CalendarUrl> - <prop:UserToManage><%= $this->User %></prop:UserToManage> - </com:AddToFilter> -</com:TPanel> diff --git a/app/php/controls/CalendarScaffold.php b/app/php/controls/CalendarScaffold.php deleted file mode 100644 index 7f15a32..0000000 --- a/app/php/controls/CalendarScaffold.php +++ /dev/null @@ -1,142 +0,0 @@ -<?php - -Prado::using('Application.web.FacadeTemplateControl'); - -Prado::using('System.Web.UI.ActiveControls.TActiveDataGrid'); -Prado::using('System.Web.UI.ActiveControls.TActiveTextBox'); -Prado::using('Application.components.SafeActiveFileUpload'); - -Prado::using('Application.facades.CalendarFacade'); - -class CalendarScaffold extends FacadeTemplateControl { - - public function onPreRender($param) { - parent::onPreRender($param); - if (!$this->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/php/controls/CalendarScaffold.tpl b/app/php/controls/CalendarScaffold.tpl deleted file mode 100644 index 6a22bc2..0000000 --- a/app/php/controls/CalendarScaffold.tpl +++ /dev/null @@ -1,81 +0,0 @@ -<com:TPanel - CssClass="calendarScaffold"> - <com:TActiveDataGrid ID="Calendars" - DataKeyField="UID" - AutoGenerateColumns="false" - OnEditCommand="editRow" - OnCancelCommand="cancelRowEdit" - OnUpdateCommand="saveRow"> - <com:TActiveBoundColumn ID="Name" - ReadOnly="true" - DataField="Name"> - <prop:HeaderText><%[ Calendar ]%></prop:HeaderText> - </com:TActiveBoundColumn> - <com:TActiveHyperLinkColumn ID="Website" - Target="_blank" - DataNavigateUrlField="Website"> - <prop:HeaderText><%[ WWW ]%></prop:HeaderText> - <prop:Text><%[ [www] ]%></prop:Text> - </com:TActiveHyperLinkColumn> - <com:TActiveHyperLinkColumn ID="Url" - Target="_blank" - DataNavigateUrlField="Url"> - <prop:HeaderText><%[ ICS ]%></prop:HeaderText> - <prop:Text><%[ [ics] ]%></prop:Text> - </com:TActiveHyperLinkColumn> - <com:TActiveDropDownListColumn ID="Category" - DataTextField="Category.Name" - DataValueField="CategoryID" - ListValueField="ID" - ListTextField="Name"> - <prop:HeaderText><%[ Category ]%></prop:HeaderText> - </com:TActiveDropDownListColumn> - <com:TActiveTemplateColumn ID="Visible"> - <prop:HeaderText><%[ Default ]%></prop:HeaderText> - <prop:ItemTemplate> - <com:TActiveCheckBox - OnCheckedChanged="SourceTemplateControl.toggleDefaultState" - CssClass="visibilityToggle"> - <prop:Checked><%# $this->Parent->Data->Visible %></prop:Checked> - <prop:CustomData><%# $this->Parent->Data->UID %></prop:CustomData> - </com:TActiveCheckBox> - </prop:ItemTemplate> - <prop:EditItemTemplate> - <com:TCheckBox ID="CheckBox"> - <prop:Checked><%# $this->Parent->Data->Visible %></prop:Checked> - </com:TCheckBox> - </prop:EditItemTemplate> - </com:TActiveTemplateColumn> - <com:TActiveBoundColumn ID="CustomName" - DataField="CustomName"> - <prop:HeaderText><%[ Custom name ]%></prop:HeaderText> - </com:TActiveBoundColumn> - <com:TActiveBoundColumn ID="CustomUrl" - DataField="CustomUrl"> - <prop:HeaderText><%[ URL ]%></prop:HeaderText> - </com:TActiveBoundColumn> - <com:TActiveTemplateColumn ID="CustomImage"> - <prop:HeaderText><%[ Image ]%></prop:HeaderText> - <prop:ItemTemplate> - <com:TImage> - <prop:ImageUrl><%# $this->Parent->Data->CustomImageUrl %></prop:ImageUrl> - </com:TImage> - </prop:ItemTemplate> - <prop:EditItemTemplate> - <com:TActiveTextBox ID="Value"> - <prop:Text><%# $this->Parent->Data->CustomImage %></prop:Text> - </com:TActiveTextBox><br /> - <com:SafeActiveFileUpload - OnFileUpload="SourceTemplateControl.uploadRowFile"> - <prop:CustomData><%# $this->Parent->Data->UID %></prop:CustomData> - </com:SafeActiveFileUpload> - </prop:EditItemTemplate> - </com:TActiveTemplateColumn> - <com:TActiveEditCommandColumn - HeaderText=""> - <prop:EditText><%[ Edit ]%></prop:EditText> - <prop:UpdateText><%[ Save ]%></prop:UpdateText> - <prop:CancelText><%[ Cancel ]%></prop:CancelText> - </com:TActiveEditCommandColumn> - </com:TActiveDataGrid> -</com:TPanel> diff --git a/app/php/controls/CalendarSelection.php b/app/php/controls/CalendarSelection.php deleted file mode 100644 index e53aa36..0000000 --- a/app/php/controls/CalendarSelection.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -Prado::using('Application.controls.FacadeTemplateControl'); - -class CalendarSelection extends FacadeTemplateControl { - - public function onPreRender($param) { - parent::onPreRender($param); - if (!$this->Page->IsCallBack) { - $this->Calendars->DataSource = $this->Facade->getAll(); - $this->Calendars->dataBind(); - } - } - -} - -?> diff --git a/app/php/controls/CalendarSelection.tpl b/app/php/controls/CalendarSelection.tpl deleted file mode 100644 index d6bdd83..0000000 --- a/app/php/controls/CalendarSelection.tpl +++ /dev/null @@ -1,8 +0,0 @@ -<com:TRepeater ID="Calendars"> - <prop:ItemTemplate> - <com:CalendarLabel> - <prop:Facade><%# $this->SourceTemplateControl->Facade %></prop:Facade> - <prop:CalendarUrl><%# $this->Data->CustomUrl %></prop:CalendarUrl> - </com:CalendarLabel> - </prop:ItemTemplate> -</com:TRepeater> diff --git a/app/php/controls/EventList.php b/app/php/controls/EventList.php deleted file mode 100644 index d40e000..0000000 --- a/app/php/controls/EventList.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - -class EventList extends UrlBasedCalendarControl { - - private function _setDate($key, $date) { - $datetime = new DateTime($date, new DateTimeZone('UTC')); - if (!$datetime) { - throw new TInvalidDataValueException( - Prado::localize('Invalid date string: {date}', - ['date' => $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/php/controls/EventList.tpl b/app/php/controls/EventList.tpl deleted file mode 100644 index 5881ce7..0000000 --- a/app/php/controls/EventList.tpl +++ /dev/null @@ -1,6 +0,0 @@ -<com:THeader3> - <%= $this->getHeaderText() %> -</com:THeader3> -<com:EventRepeater CalendarLinkVisible="false"> - <prop:Events><%= $this->getEvents() %></prop:Events> -</com:EventRepeater> diff --git a/app/php/controls/EventRepeater.php b/app/php/controls/EventRepeater.php deleted file mode 100644 index 4fb2812..0000000 --- a/app/php/controls/EventRepeater.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -Prado::using('Application.web.TemplateControl'); - -class EventRepeater extends TemplateControl { - - public function setEvents($events) { - $this->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/php/controls/EventRepeater.tpl b/app/php/controls/EventRepeater.tpl deleted file mode 100644 index 69aaabf..0000000 --- a/app/php/controls/EventRepeater.tpl +++ /dev/null @@ -1,12 +0,0 @@ -<com:TRepeater ID="Events"> - <prop:ItemTemplate> - <%# $this->Data->DateString %> - <%# $this->Data->Name %> - <com:THyperLink> - <prop:Visible><%# $this->SourceTemplateControl->CalendarLinkVisible %></prop:Visible> - <prop:Text>(<%# $this->Data->Calendar->Name %>)</prop:Text> - <prop:NavigateUrl><%# $this->Service->constructUrl('Calendar', ['calendar' => $this->Data->Calendar->Url]) %></prop:NavigateUrl> - </com:THyperLink> - <br /> - </prop:ItemTemplate> -</com:TRepeater> diff --git a/app/php/controls/HeaderMenu.php b/app/php/controls/HeaderMenu.php deleted file mode 100644 index 2488629..0000000 --- a/app/php/controls/HeaderMenu.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -Prado::using('Application.web.TemplateControl'); - -Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton'); - -class HeaderMenu extends TemplateControl { - - public function loginUser($sender, $param) { - $authModule = $this->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/php/controls/HeaderMenu.tpl b/app/php/controls/HeaderMenu.tpl deleted file mode 100644 index a760588..0000000 --- a/app/php/controls/HeaderMenu.tpl +++ /dev/null @@ -1,36 +0,0 @@ -<nav role="navigation"> - <com:TActiveLinkButton OnCommand="loginUser"> - <prop:Text><%[ Login ]%></prop:Text> - <prop:Visible><%= $this->User->IsGuest %></prop:Visible> - <prop:ClientSide.OnFailure>window.location.replace('<%= $this->Service->constructUrl('Login') %>')</prop:ClientSide.OnFailure> - <prop:ClientSide.OnException>window.location.replace('<%= $this->Service->constructUrl('Login') %>')</prop:ClientSide.OnException> - </com:TActiveLinkButton> - <com:THyperLink> - <prop:Text><%[ Profile ]%></prop:Text> - <prop:NavigateUrl><%= $this->Service->constructUrl('Profile') %></prop:NavigateUrl> - <prop:Visible><%= !$this->User->IsGuest %></prop:Visible> - </com:THyperLink> - <com:THyperLink> - <prop:Text><%[ Calendar list ]%></prop:Text> - <prop:NavigateUrl><%= $this->Service->constructUrl('Select') %></prop:NavigateUrl> - </com:THyperLink> - <com:TActiveLinkButton OnCommand="logoutUser"> - <com:TTranslate> - Logout ({name}) - <com:TTranslateParameter Key="name"><%= $this->User->Name %></com:TTranslateParameter> - </com:TTranslate> - <prop:Visible><%= !$this->User->IsGuest %></prop:Visible> - <prop:ClientSide.OnFailure>window.location.reload()</prop:ClientSide.OnFailure> - <prop:ClientSide.OnException>window.location.reload()</prop:ClientSide.OnException> - </com:TActiveLinkButton> - <com:THyperLink> - <prop:Text><%[ New user ]%></prop:Text> - <prop:NavigateUrl><%= $this->Service->constructUrl('Signup') %></prop:NavigateUrl> - <prop:Visible><%= $this->User->getIsAdmin() %></prop:Visible> - </com:THyperLink> - <com:THyperLink> - <prop:Text><%[ Admin calendars ]%></prop:Text> - <prop:NavigateUrl><%= $this->Service->constructUrl('Admin') %></prop:NavigateUrl> - <prop:Visible><%= $this->User->getIsAdmin() %></prop:Visible> - </com:THyperLink> -</nav> diff --git a/app/php/controls/LoginBox.php b/app/php/controls/LoginBox.php deleted file mode 100644 index 1136a79..0000000 --- a/app/php/controls/LoginBox.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - -Prado::using('Application.web.TemplateControl'); - -class LoginBox extends TemplateControl { - - public function onInit($param) { - parent::onInit($param); - if (!$this->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/php/controls/LoginBox.tpl b/app/php/controls/LoginBox.tpl deleted file mode 100644 index 070ab86..0000000 --- a/app/php/controls/LoginBox.tpl +++ /dev/null @@ -1,33 +0,0 @@ -<%[ Username: ]%> -<com:TTextBox ID="Login" - ValidationGroup="LoginGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="Login" - Display="Dynamic" - ValidationGroup="LoginGroup"> - <prop:ErrorMessage><%[ Username cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<br /> -<%[ Password: ]%> -<com:TTextBox ID="Password" - TextMode="Password" - ValidationGroup="LoginGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="Password" - Display="Dynamic" - ValidationGroup="LoginGroup"> - <prop:ErrorMessage><%[ Password cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<com:TCustomValidator - ControlToValidate="Password" - OnServerValidate="validatePassword" - Display="Dynamic" - ValidationGroup="LoginGroup"> - <prop:ErrorMessage><%[ Username and password don't match ]%></prop:ErrorMessage> -</com:TCustomValidator> -<br /> -<com:TButton - OnCommand="loginUser" - ValidationGroup="LoginGroup"> - <prop:Text><%[ Login ]%></prop:Text> -</com:TButton> diff --git a/app/php/controls/PasswordChange.php b/app/php/controls/PasswordChange.php deleted file mode 100644 index 45ce656..0000000 --- a/app/php/controls/PasswordChange.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -Prado::using('Application.web.FacadeTemplateControl'); - -Prado::using('Application.user.DbUser'); -Prado::using('Application.facades.UserFacade'); - -class PasswordChange extends FacadeTemplateControl { - - public function getUserToChange() { - return $this->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/php/controls/PasswordChange.tpl b/app/php/controls/PasswordChange.tpl deleted file mode 100644 index 4eb9a8e..0000000 --- a/app/php/controls/PasswordChange.tpl +++ /dev/null @@ -1,59 +0,0 @@ -<%[ Change password ]%><br /> -<%[ Current password: ]%> -<com:TTextBox ID="Password" - TextMode="Password" - ValidationGroup="ChangePasswordGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="Password" - Display="Dynamic" - ValidationGroup="ChangePasswordGroup"> - <prop:ErrorMessage><%[ Current password cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<com:TCustomValidator - ControlToValidate="Password" - OnServerValidate="checkPassword" - Display="Dynamic" - ValidationGroup="ChangePasswordGroup"> - <prop:ErrorMessage><%[ Password is incorrect ]%></prop:ErrorMessage> -</com:TCustomValidator> -<br /> -<%[ New password: ]%> -<com:TTextBox ID="NewPassword" - TextMode="Password" - ValidationGroup="ChangePasswordGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="NewPassword" - Display="Dynamic" - ValidationGroup="ChangePasswordGroup"> - <prop:ErrorMessage><%[ New password cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<br /> -<%[ Repeat password: ]%> -<com:TTextBox ID="ReNewPassword" - TextMode="Password" - ValidationGroup="ChangePasswordGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="ReNewPassword" - Display="Dynamic" - ValidationGroup="ChangePasswordGroup"> - <prop:ErrorMessage><%[ New password cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<com:TCompareValidator - ControlToValidate="ReNewPassword" - ControlToCompare="NewPassword" - DataType="String" - Operator="Equal" - Display="Dynamic" - ValidationGroup="ChangePasswordGroup"> - <prop:ErrorMessage><%[ Passwords don't match ]%></prop:ErrorMessage> -</com:TCompareValidator> -<br /> -<com:TButton - OnCommand="changePassword" - ValidationGroup="ChangePasswordGroup"> - <prop:Text><%[ Change password ]%></prop:Text> -</com:TButton> -<com:TLabel ID="SuccessMessage" - Visible="false"> - <prop:Text><%[ Your password has been changed ]%></prop:Text> -</com:TLabel> diff --git a/app/php/controls/RegistrationForm.php b/app/php/controls/RegistrationForm.php deleted file mode 100644 index 46494e3..0000000 --- a/app/php/controls/RegistrationForm.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -Prado::using('Application.web.FacadeTemplateControl'); - -Prado::using('Application.facades.UserFacade'); - -class RegistrationForm extends FacadeTemplateControl { - - public function checkUsername($sender, $param) { - $param->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/php/controls/RegistrationForm.tpl b/app/php/controls/RegistrationForm.tpl deleted file mode 100644 index 9defe54..0000000 --- a/app/php/controls/RegistrationForm.tpl +++ /dev/null @@ -1,66 +0,0 @@ -<%[ Username: ]%> -<com:TTextBox ID="Login" - ValidationGroup="SignupGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="Login" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Username cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<com:TRegularExpressionValidator - ControlToValidate="Login" - RegularExpression="[a-zA-Z0-9_]{6,255}" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Username must contain 6-255 characters, all Latin alphanumeric or underscore ]%></prop:ErrorMessage> -</com:TRegularExpressionValidator> -<com:TCustomValidator - ControlToValidate="Login" - OnServerValidate="checkUsername" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Username already exists ]%></prop:ErrorMessage> -</com:TCustomValidator> -<br /> -<%[ Password: ]%> -<com:TTextBox ID="Password" - TextMode="Password" - ValidationGroup="SignupGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="Password" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Password cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<br /> -<%[ Repeat password: ]%> -<com:TTextBox ID="RePassword" - TextMode="Password" - ValidationGroup="SignupGroup" /> -<com:TRequiredFieldValidator - ControlToValidate="RePassword" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Password cannot be empty ]%></prop:ErrorMessage> -</com:TRequiredFieldValidator> -<com:TCompareValidator - ControlToValidate="RePassword" - ControlToCompare="Password" - DataType="String" - Operator="Equal" - Display="Dynamic" - ValidationGroup="SignupGroup"> - <prop:ErrorMessage><%[ Passwords don't match ]%></prop:ErrorMessage> -</com:TCompareValidator> -<br /> -<%[ Admin: ]%> -<com:TCheckBox ID="Admin" - ValidationGroup="SignupGroup" /> -<br /> -<com:TButton - OnCommand="registerUser" - ValidationGroup="SignupGroup"> - <prop:Text><%[ Create ]%></prop:Text> -</com:TButton> -<com:TValidationSummary - ValidationGroup="SignupGroup" /> diff --git a/app/php/controls/TimezoneSelect.php b/app/php/controls/TimezoneSelect.php deleted file mode 100644 index 25af453..0000000 --- a/app/php/controls/TimezoneSelect.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php - -Prado::using('Application.web.FacadeTemplateControl'); - -Prado::using('Application.user.DbUser'); -Prado::using('Application.facades.UserFacade'); - -Prado::using('Application.dto.TimezoneDTO'); - -class TimezoneSelect extends FacadeTemplateControl { - - public function getUserToChange() { - return $this->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/php/controls/TimezoneSelect.tpl b/app/php/controls/TimezoneSelect.tpl deleted file mode 100644 index ee703d6..0000000 --- a/app/php/controls/TimezoneSelect.tpl +++ /dev/null @@ -1,5 +0,0 @@ -<com:TDropDownList ID="Timezones" /> -<com:TButton - OnCommand="saveTimezone"> - <prop:Text><%[ Save timezone ]%></prop:Text> -</com:TButton> diff --git a/app/php/controls/UpcomingEvents.php b/app/php/controls/UpcomingEvents.php deleted file mode 100644 index 27fc723..0000000 --- a/app/php/controls/UpcomingEvents.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -Prado::using('Application.web.FacadeTemplateControl'); -Prado::using('Application.user.DbUser'); -Prado::using('Application.facades.EventFacade'); - -class UpcomingEvents extends FacadeTemplateControl { - - public function getUserToDisplay() { - return $this->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/php/controls/UpcomingEvents.tpl b/app/php/controls/UpcomingEvents.tpl deleted file mode 100644 index ac5f60c..0000000 --- a/app/php/controls/UpcomingEvents.tpl +++ /dev/null @@ -1,5 +0,0 @@ -<%[ Upcoming events: ]%> -<br /> -<com:EventRepeater ID="Events"> - <prop:Events><%= $this->getEvents() %></prop:Events> -</com:EventRepeater> diff --git a/app/php/controls/UrlBasedCalendarControl.php b/app/php/controls/UrlBasedCalendarControl.php deleted file mode 100644 index a5be82e..0000000 --- a/app/php/controls/UrlBasedCalendarControl.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -Prado::using('Application.web.FacadeTemplateControl'); -Prado::using('Application.facades.CalendarFacade'); - -class UrlBasedCalendarControl extends FacadeTemplateControl { - - public function setCalendarUrl(string $url = NULL) { - if ($url) { - $calendar = $this->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/php/controls/UserSelection.php b/app/php/controls/UserSelection.php deleted file mode 100644 index 233f0bf..0000000 --- a/app/php/controls/UserSelection.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -Prado::using('Application.web.FacadeTemplateControl'); -Prado::using('Application.user.DbUser'); -Prado::using('Application.facades.CalendarFacade'); - -class UserSelection extends FacadeTemplateControl { - - public function getUserToDisplay() { - return $this->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/php/controls/UserSelection.tpl b/app/php/controls/UserSelection.tpl deleted file mode 100644 index 8d20365..0000000 --- a/app/php/controls/UserSelection.tpl +++ /dev/null @@ -1,29 +0,0 @@ -<%[ Selected calendars: ]%> -<br /> -<com:TRepeater ID="Categories" OnItemDataBound="categoryDataBind"> - <prop:ItemTemplate> - <%# $this->Data->Name %><br /> - <com:TRepeater ID="Calendars"> - <prop:ItemTemplate> - <com:TLinkButton - Text="[X]" - OnCommand="SourceTemplateControl.removeFromSelection"> - <prop:CommandParameter><%# $this->Data->ID %></prop:CommandParameter> - <prop:Visible><%# !$this->SourceTemplateControl->UserToDisplay->IsGuest %></prop:Visible> - </com:TLinkButton> - <%# $this->Data->Name %> - <com:THyperLink> - <prop:Text><%[ (details) ]%></prop:Text> - <prop:NavigateUrl><%# $this->Service->constructUrl('Calendar', ['calendar' => $this->Data->Url]) %></prop:NavigateUrl> - </com:THyperLink> - <com:THyperLink - Text="(www)" - Target="_blank"> - <prop:NavigateUrl><%# $this->Data->Website %></prop:NavigateUrl> - </com:THyperLink> - <br /> - </prop:ItemTemplate> - </com:TRepeater> - <br /> - </prop:ItemTemplate> -</com:TRepeater> diff --git a/app/php/controls/config.xml b/app/php/controls/config.xml deleted file mode 100644 index 61d7e5b..0000000 --- a/app/php/controls/config.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <paths> - <using namespace="Application.controls.*" /> - </paths> -</configuration> diff --git a/app/php/controls/scripts/AddToFilter.js b/app/php/controls/scripts/AddToFilter.js deleted file mode 100644 index e6d7b39..0000000 --- a/app/php/controls/scripts/AddToFilter.js +++ /dev/null @@ -1,5 +0,0 @@ -$(document).on('ready', function() { - $('input.addToFilterBox').on('change', function() { - $(this).attr('disabled', true); - }); -}); diff --git a/app/php/controls/scripts/CalendarGroupFilter.js b/app/php/controls/scripts/CalendarGroupFilter.js deleted file mode 100644 index e6c1d73..0000000 --- a/app/php/controls/scripts/CalendarGroupFilter.js +++ /dev/null @@ -1,29 +0,0 @@ -$(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/php/controls/scripts/CalendarLabel.js b/app/php/controls/scripts/CalendarLabel.js deleted file mode 100644 index 8193e56..0000000 --- a/app/php/controls/scripts/CalendarLabel.js +++ /dev/null @@ -1,11 +0,0 @@ -$(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/php/controls/scripts/CalendarScaffold.js b/app/php/controls/scripts/CalendarScaffold.js deleted file mode 100644 index d4b8ec5..0000000 --- a/app/php/controls/scripts/CalendarScaffold.js +++ /dev/null @@ -1,8 +0,0 @@ -$('body').on( - 'click', - 'main .calendarScaffold tbody a[href^="javascript:;//"], main .calendarScaffold tbody input.visibilityToggle', - function(e) { - var loader = $('<div>').addClass('calendarScaffoldLoader'); - $('main .calendarScaffold div[id$="_Container"]').append(loader); - } -); diff --git a/app/php/controls/styles/CalendarGrid.css b/app/php/controls/styles/CalendarGrid.css deleted file mode 100644 index 4710993..0000000 --- a/app/php/controls/styles/CalendarGrid.css +++ /dev/null @@ -1,16 +0,0 @@ -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/php/controls/styles/CalendarScaffold.css b/app/php/controls/styles/CalendarScaffold.css deleted file mode 100644 index 071f672..0000000 --- a/app/php/controls/styles/CalendarScaffold.css +++ /dev/null @@ -1,11 +0,0 @@ -.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); -} diff --git a/app/php/db/ActiveRecord.php b/app/php/db/ActiveRecord.php deleted file mode 100644 index 1176767..0000000 --- a/app/php/db/ActiveRecord.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php - -class ActiveRecord extends TActiveRecord { - - private function _getMappedPropertyName($name) { - if (isset(static::$COLUMN_MAPPING[$name])) { - return static::$COLUMN_MAPPING[$name]; - } - return $name; - } - - const DYNAMIC_METHODS = [ - 'findby', - 'findallby', - 'deleteby', - 'deleteallby' - ]; - - private function _getMappedMethodName($method) { - if (static::$COLUMN_MAPPING) { - $methodParts = []; - if (preg_match('/^(' . implode('|', self::DYNAMIC_METHODS) . ')(.*)$/i', $method, $methodParts)) { - $methodParameters = []; - $columnString = implode( - '|', - array_merge( - array_keys(static::$COLUMN_MAPPING), - array_values(static::$COLUMN_MAPPING) - ) - ); - $parameterRegex = '/(' . $columnString . ')(and|_and_|or|_or_)?/i'; - $method = $methodParts[1]; - if (preg_match_all($parameterRegex, $methodParts[2], $methodParameters, PREG_SET_ORDER)) { - foreach ($methodParameters as $parameter) { - $mappedColumn = array_search($parameter[1], static::$COLUMN_MAPPING); - $method .= ($mappedColumn !== FALSE) ? $mappedColumn : $parameter[1]; - if (count($parameter) > 2) { - $method .= $parameter[2]; - } - } - } - } - } - return $method; - } - - public function __get($name) { - $name = $this->_getMappedPropertyName($name); - if (property_exists($this, $name)) { - return $this->$name; - } - return parent::__get($name); - } - - public function __set($name, $value) { - $name = $this->_getMappedPropertyName($name); - if (property_exists($this, $name)) { - return $this->$name = $value; - } - return parent::__set($name, $value); - } - - public function __call($method, $args) { - return parent::__call($this->_getMappedMethodName($method), $args); - } - -} - -?> diff --git a/app/php/db/DBConnection.php b/app/php/db/DBConnection.php deleted file mode 100644 index 92ab0fb..0000000 --- a/app/php/db/DBConnection.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -Prado::using('Application.db.DBTransaction'); -Prado::using('System.Data.TDbConnection'); - -class DBConnection extends TDbConnection { - - private $_transaction = NULL; - public function getCurrentTransaction() { - if (!$this->_transaction->getActive()) { - $this->_transaction = NULL; - } - return $this->_transaction; - } - - public function beginTransaction() { - if ($this->_transaction && $this->_transaction->getActive()) { - $this->_transaction->beginNestedTransaction(); - } - else { - $this->_transaction = parent::beginTransaction(); - } - return $this->_transaction; - } - -} - -?> diff --git a/app/php/db/DBModule.php b/app/php/db/DBModule.php deleted file mode 100644 index 462b6f6..0000000 --- a/app/php/db/DBModule.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -Prado::using('System.Data.TDataSourceConfig'); - -class DBModule extends TDataSourceConfig { - - private $_config; - - public function init($xml) { - $newXML = new TXmlElement('module'); - foreach ($xml->getAttributes() as $attr => $val) { - $newXML->setAttribute($attr, $val); - } - $dbXML = new TXmlElement('database'); - $config = json_decode(file_get_contents( - Prado::getPathOfNamespace($this->_config, '.json') - )); - if (isset($config->cset)) { - $dbXML->setAttribute('Charset', $config->cset); - } - $dbXML->setAttribute('Username', $config->user); - $dbXML->setAttribute('Password', $config->pass); - $dbXML->setAttribute( - 'ConnectionString', - sprintf( - '%s:host=%s;dbname=%s', - $config->type, $config->host, $config->name - ) - ); - $newXML->Elements[] = $dbXML; - parent::init($newXML); - } - - public function setConfig($config) { - $this->_config = TPropertyValue::ensureString($config); - } - -} - -?> diff --git a/app/php/db/DBTransaction.php b/app/php/db/DBTransaction.php deleted file mode 100644 index b176453..0000000 --- a/app/php/db/DBTransaction.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -Prado::using('Application.db.DBConnection'); -Prado::using('System.Data.TDbTransaction'); - -class DBTransaction extends TDbTransaction { - - private $_nestedCount = 0; - private $_rolledBack = FALSE; - - public function beginNestedTransaction() { - if ($this->getActive()) { - $this->_nestedCount++; - } - } - - public function commit() { - if ($this->_rolledBack) { - $childTransaction = (bool)($this->_nestedCount); - $this->rollback(); - if (!$childTransaction) { - throw new TDbException('Nested transaction was rolled back, unable to commit.'); - } - } - else { - if ($this->_nestedCount) { - $this->_nestedCount--; - } - else { - parent::commit(); - } - } - } - - public function rollback() { - if (!$this->getActive()) { - $this->_nestedCount = 0; - return; - } - if ($this->_nestedCount) { - $this->_rolledBack = TRUE; - $this->_nestedCount--; - } - else { - parent::rollback(); - $this->_nestedCount = 0; - $this->_rolledBack = FALSE; - } - } - -} - -?> diff --git a/app/php/db/config.json b/app/php/db/config.json deleted file mode 120000 index 89a492f..0000000 --- a/app/php/db/config.json +++ /dev/null @@ -1 +0,0 @@ -../../../config/db.json
\ No newline at end of file diff --git a/app/php/db/config.xml b/app/php/db/config.xml deleted file mode 100644 index 3210593..0000000 --- a/app/php/db/config.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <modules> - <module id="db" - class="Application.db.DBModule" - config="Application.db.config" - ConnectionClass="Application.db.DBConnection" - DbConnection.TransactionClass="Application.db.DBTransaction" /> - </modules> -</configuration> diff --git a/app/php/dto/CalendarDTO.php b/app/php/dto/CalendarDTO.php deleted file mode 100644 index 4468941..0000000 --- a/app/php/dto/CalendarDTO.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php - -Prado::using('Application.model.Calendar'); - -class CalendarDTO { - - public $ID; - public $Name; - public $Website; - public $Image; - public $Url; - public $LastUpdated; - public $GroupID; - - public function loadRecord(Calendar $calendarRecord) { - $this->ID = $calendarRecord->UID; - $this->Name = $calendarRecord->CustomName ?: $calendarRecord->Name; - $this->Website = $calendarRecord->Website; - $this->Image = $calendarRecord->CustomImageUrl; - $this->Url = $calendarRecord->CustomUrl; - $this->LastUpdated = $calendarRecord->LastUpdated; - $this->GroupID = $calendarRecord->CategoryID; - } - - public static function __compare(CalendarDTO $cal1, CalendarDTO $cal2) { - return strcmp($cal1->Name, $cal2->Name); - } - -} - -?> diff --git a/app/php/dto/CalendarGridDTO.php b/app/php/dto/CalendarGridDTO.php deleted file mode 100644 index f5d91a5..0000000 --- a/app/php/dto/CalendarGridDTO.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php - -Prado::using('Application.dto.CalendarGridDayDTO'); -Prado::using('Application.dto.GridEventDTO'); - -class CalendarGridDTO { - - public $DateFrom; - public $DateTo; - public $Weeks = []; - - public function __construct($events, DateTime $dateFrom, DateTime $dateTo) { - $this->DateFrom = DateTimeImmutable::createFromMutable($dateFrom); - $this->DateTo = DateTimeImmutable::createFromMutable($dateTo); - $date = $this->DateFrom; - $days = []; - $previousDay = NULL; - while ($date <= $this->DateTo) { - $day = $this->_getGridDay($date, $events, $previousDay); - $days[] = $day; - $previousDay = $day; - $date = $date->modify('+1 day'); - } - $this->Weeks = array_chunk($days, 7); - } - - private function _getContinuedEventGridPositions( - CalendarGridDayDTO $day, - CalendarGridDayDTO $previousDay = NULL) { - $eventPositions = []; - if ($previousDay) { - foreach ($day->Events as $event) { - if (in_array($event, $previousDay->Events)) { - $eventPositions[] = $event->GridPosition; - } - } - } - return $eventPositions; - } - - private function _alignEvents(array $eventPositions, array $events) { - $previousCount = count($eventPositions); - foreach ($events as $event) { - if ($event->GridPosition === NULL) { - $event->GridPosition = min( - array_diff( - range(0, count($events) + $previousCount), - $eventPositions - ) - ); - $eventPositions[] = $event->GridPosition; - } - } - usort($events, ['GridEventDTO', '__compare']); - return $events; - } - - private function _fillEventGrid(array $events) { - $previousEvent = -1; - foreach ($events as $event) { - $eventStep = $event->GridPosition - $previousEvent; - if ($eventStep > 1) { - array_splice( - $events, $previousEvent + 1, 0, array_fill(0, $eventStep - 1, NULL) - ); - } - $previousEvent = $event->GridPosition; - } - return $events; - } - - private function _getGridDay(DateTimeImmutable $date, - array $events, - CalendarGridDayDTO $previousDay = NULL) { - $day = new CalendarGridDayDTO($date, $events); - $eventPositions = $this->_getContinuedEventGridPositions($day, $previousDay); - $day->Events = $this->_alignEvents($eventPositions, $day->Events); - $day->Events = $this->_fillEventGrid($day->Events); - return $day; - } - -} - -?> diff --git a/app/php/dto/CalendarGridDayDTO.php b/app/php/dto/CalendarGridDayDTO.php deleted file mode 100644 index ba65eb9..0000000 --- a/app/php/dto/CalendarGridDayDTO.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -Prado::using('Application.dto.EventDTO'); -Prado::using('Application.dto.GridEventDTO'); - -class CalendarGridDayDTO { - - public $Date; - public $Events; - - public function __construct(DateTimeImmutable $date, array $events) { - $this->Date = $date->format('Y-m-d'); - $this->Events = array_filter($events, [$this, '_checkEventDate']); - // initial sort (date and calendar name) - // events are going to be re-sorted after assigning grid priorities - usort($this->Events, ['EventDTO', '__compare']); - } - - private function _checkEventDate(GridEventDTO $event) { - if (!$this->Date) { - return FALSE; - } - return ($this->Date >= $event->DateFrom) && ($this->Date <= $event->DateTo); - } - -} - -?> diff --git a/app/php/dto/CalendarGroupDTO.php b/app/php/dto/CalendarGroupDTO.php deleted file mode 100644 index 7b64c6e..0000000 --- a/app/php/dto/CalendarGroupDTO.php +++ /dev/null @@ -1,44 +0,0 @@ -<?php - -Prado::using('Application.model.Category'); -Prado::using('Application.dto.CalendarDTO'); - -class CalendarGroupDTO { - - public $Name; - public $ID; - public $Priority; - public $Calendars = []; - - public function loadRecord(Category $categoryRecord, array $calendars) { - $this->Name = $categoryRecord->Name; - $this->ID = $categoryRecord->ID; - $this->Priority = $categoryRecord->Priority; - $this->Calendars = array_map( - function($calendarRecord) { - $dto = new CalendarDTO(); - $dto->loadRecord($calendarRecord); - return $dto; - }, - array_filter( - $calendars, - function($calendarRecord) use($categoryRecord) { - return $categoryRecord->ID == $calendarRecord->CategoryID; - } - ) - ); - usort($this->Calendars, ['CalendarDTO', '__compare']); - } - - public static function __compare(CalendarGroupDTO $cat1, - CalendarGroupDTO $cat2) { - $cmp = ($cat1->Priority ?: PHP_MAX_INT) - ($cat2->Priority ?: PHP_MAX_INT); - if ($cmp !== 0) { - return $cmp; - } - return strcmp($cat1->Name, $cat2->Name); - } - -} - -?> diff --git a/app/php/dto/EventDTO.php b/app/php/dto/EventDTO.php deleted file mode 100644 index 8f5cdf5..0000000 --- a/app/php/dto/EventDTO.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php - -Prado::using('Application.model.Entry'); -Prado::using('Application.dto.CalendarDTO'); -Prado::using('Application.facades.UserFacade'); - -class EventDTO { - - public $DateString; - public $Name; - public $Location; - public $Calendar; - - private $_utc; - private $_targetTZ; - - public function __construct(TimezoneDTO $tz = NULL) { - $this->_utc = new DateTimeZone('UTC'); - $this->_targetTZ = new DateTimeZone( - $tz - ? $tz->Name - : UserFacade::getInstance()->getTimezonePreference( - Prado::getApplication()->getUser() - )->Name - ); - } - - private $_beginDate; - protected function getBeginDate(Entry $event) { - if (!$this->_beginDate) { - $this->_beginDate = new DateTime($event->BeginDate, $this->_utc); - } - return $this->_beginDate; - } - - private $_endDate; - protected function getEndDate(Entry $event) { - if (!$this->_endDate) { - $this->_endDate = new DateTime($event->EndDate, $this->_utc); - if ($event->AllDay) { - $this->_endDate = $this->_endDate->modify('-1 day'); - } - } - return $this->_endDate; - } - - public function loadRecord(Entry $event, array $calendars) { - $this->Name = $event->Name; - $this->Location = $event->Location; - - if ($event->AllDay) { - $this->DateString = $this->getBeginDate($event)->format('Y-m-d'); - if ($this->getBeginDate($event) != $this->getEndDate($event)) { - $this->DateString .= sprintf( - ' - %s', - $this->getEndDate($event)->format('Y-m-d') - ); - } - } else { - $beginDate = $this->getBeginDate($event)->setTimezone($this->_targetTZ); - $this->DateString = $beginDate->format('Y-m-d H:i'); - } - - $calendars = array_filter( - $calendars, - function ($calendar) use($event) { - return $calendar->UID == $event->CalendarID; - } - ); - $this->Calendar = new CalendarDTO(); - $this->Calendar->loadRecord( - $calendars ? array_values($calendars)[0] : $event->Calendar - ); - } - - public static function __compare(EventDTO $ev1, EventDTO $ev2) { - if ($ev1->DateString === $ev2->DateString) { - return strcmp($ev1->Calendar->Name, $ev2->Calendar->Name); - } - return strcmp($ev1->DateString, $ev2->DateString); - } - -} - -?> diff --git a/app/php/dto/GridEventDTO.php b/app/php/dto/GridEventDTO.php deleted file mode 100644 index 0d2bb37..0000000 --- a/app/php/dto/GridEventDTO.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -Prado::using('Application.dto.EventDTO'); - -class GridEventDTO extends EventDTO { - - public $DateFrom; - public $DateTo; - public $AllDay; - public $GridPosition; - - public function loadRecord(Entry $event, array $calendars) { - parent::loadRecord($event, $calendars); - $this->AllDay = TPropertyValue::ensureBoolean($event->AllDay); - $this->DateFrom = $this->getBeginDate($event)->format('Y-m-d'); - $this->DateTo = $this->getEndDate($event)->format('Y-m-d'); - } - - public static function __compare(EventDTO $ev1, EventDTO $ev2) { - if ($ev1->GridPosition === NULL || $ev2->GridPosition === NULL) { - return parent::__compare($ev1, $ev2); - } - return $ev1->GridPosition - $ev2->GridPosition; - } - -} - -?> diff --git a/app/php/dto/TimezoneDTO.php b/app/php/dto/TimezoneDTO.php deleted file mode 100644 index e4078e6..0000000 --- a/app/php/dto/TimezoneDTO.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php - -class TimezoneDTO { - - public $Label; - public $Name; - public $Offset; - public $OffsetHours; - public $OffsetMinutes; - public $Location; - public $FirstDayOfTheWeek; - - public function __construct(string $name) { - $tz = new DateTimeZone($name); - $this->Name = $tz->getName(); - $this->Offset = $tz->getOffset(new DateTime()); - $this->OffsetHours = $this->Offset / 3600; - $this->OffsetMinutes = $this->Offset % 3600 / 60; - $this->Location = $tz->getLocation()['country_code']; - $this->FirstDayOfTheWeek = $this->_getFirstDayOfTheWeek(); - $this->Label = sprintf('UTC%+03d:%02d %s', $this->OffsetHours, $this->OffsetMinutes, $this->Name); - } - - private function _getFirstDayOfTheWeek() { - $dayMapping = json_decode( - file_get_contents( - Prado::getPathOfNamespace('Application.dto.weekdays', '.json') - ), - TRUE - ); - if ($this->Location && isset($dayMapping[$this->Location])) { - return ucfirst($dayMapping[$this->Location]); - } - return ucfirst($dayMapping['001']); - } - - - - public static function __compare(TimezoneDTO $tz1, TimezoneDTO $tz2) { - $diff = $tz1->Offset - $tz2->Offset; - return ($diff == 0) ? strcmp($tz1->Name, $tz2->Name) : $diff; - } - -} - -?> diff --git a/app/php/dto/weekdays.json b/app/php/dto/weekdays.json deleted file mode 120000 index 325c801..0000000 --- a/app/php/dto/weekdays.json +++ /dev/null @@ -1 +0,0 @@ -../../../config/weekdays.json
\ No newline at end of file diff --git a/app/php/events/CalendarPreferenceEvents.php b/app/php/events/CalendarPreferenceEvents.php deleted file mode 100644 index 76fa071..0000000 --- a/app/php/events/CalendarPreferenceEvents.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php - -Prado::using('Application.events.EventModule'); -Prado::using('Application.model.User'); -Prado::using('Application.facades.CalendarFacade'); - -class CalendarPreferenceEvents extends EventModule { - - public function onUserRegistered(User $user) { - $facade = CalendarFacade::getInstance(); - $facade->setPreferredCalendars($user, $facade->getDefaultPreference()); - } - -} - -?> diff --git a/app/php/events/EventModule.php b/app/php/events/EventModule.php deleted file mode 100644 index 6474523..0000000 --- a/app/php/events/EventModule.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -class EventModule extends TModule { - - public function init($config) { - $reflection = new ReflectionClass($this); - foreach ($reflection->getMethods() as $method) { - if (is_a($method->class, get_class(), TRUE)) { - $eventPattern = []; - if (preg_match('/^on(.*)/', $method->name, $eventPattern)) { - $this->_registerEventHandler( - $eventPattern[1], - $method->getClosure($this) - ); - } - } - } - if (get_class() === get_called_class()) { - $directory = dirname(__FILE__); - foreach (scandir($directory) as $dirEntry) { - $classNameMatch = []; - if (preg_match('/(.*)\.php$/', $dirEntry, $classNameMatch)) { - $className = $classNameMatch[1]; - include_once($directory . DIRECTORY_SEPARATOR . $dirEntry); - if ($className != get_class() - && is_a($className, get_class(), TRUE)) { - $class = new $className(); - $class->init(NULL); - } - } - } - } - } - - protected static $_handlers = []; - private function _registerEventHandler($event, $handler) { - if (!isset(self::$_handlers[$event])) { - self::$_handlers[$event] = []; - } - self::$_handlers[$event][] = $handler; - } - - public function raiseApplicationEvent($event, ...$params) { - if (isset(self::$_handlers[$event])) { - foreach (self::$_handlers[$event] as $handler) { - call_user_func_array($handler, $params); - } - } - } - -} - -?> diff --git a/app/php/events/config.xml b/app/php/events/config.xml deleted file mode 100644 index d1c1e3f..0000000 --- a/app/php/events/config.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <modules> - <module id="events" class="Application.events.EventModule" /> - </modules> -</configuration> diff --git a/app/php/facades/CalendarFacade.php b/app/php/facades/CalendarFacade.php deleted file mode 100644 index 1f78594..0000000 --- a/app/php/facades/CalendarFacade.php +++ /dev/null @@ -1,212 +0,0 @@ -<?php - -Prado::using('Application.facades.Facade'); -Prado::using('Application.facades.EventFacade'); -Prado::using('Application.dto.CalendarDTO'); -Prado::using('Application.dto.CalendarGroupDTO'); -Prado::using('Application.dto.TimezoneDTO'); -Prado::using('Application.model.Calendar'); -Prado::using('Application.model.Category'); -Prado::using('Application.model.UserPreference'); -Prado::using('Application.user.DbUser'); - -class CalendarFacade extends Facade { - - private function _getCategoriesForCalendars(array $calendars) { - return Category::finder()->findAllByPks( - array_map( - function($calendar) { - return $calendar->CategoryID; - }, - $calendars - ) - ); - } - - private $_defaultPreference = NULL; - public function getDefaultPreference() { - if ($this->_defaultPreference === NULL) { - $this->_defaultPreference = Calendar::finder()->findAllByIsVisible(1); - } - return $this->_defaultPreference; - } - - public function getCalendarPreference(DbUser $user) { - if ($user->IsGuest) { - return $this->getDefaultPreference(); - } else { - return $user->DbRecord->Calendars; - } - } - - public function getPreferenceList(DbUser $user) { - $calendars = $this->getCalendarPreference($user); - if ($calendars) { - $categories = array_map( - function($category) use($calendars) { - $dto = new CalendarGroupDTO(); - $dto->loadRecord($category, $calendars); - return $dto; - }, - $this->_getCategoriesForCalendars($calendars) - ); - usort($categories, ['CalendarGroupDTO', '__compare']); - return $categories; - } - return []; - } - - public function isCalendarPreferred(DbUser $user, $calendarID) { - return in_array( - $calendarID, - array_map( - function($calendar) { - return $calendar->UID; - }, - $this->getCalendarPreference($user) - ) - ); - } - - public function addToPreference(DbUser $user, $calendarID) { - if (!$user->IsGuest) { - $calendar = Calendar::finder()->findByPk($calendarID); - if ($calendar) { - $this->setPreferredCalendar($user->DbRecord, $calendar); - } - } - } - - public function removeFromPreference(DbUser $user, $calendarID) { - if (!$user->IsGuest) { - $preferenceRecord = UserPreference::finder()->find( - '_user = ? AND _calendar = ?', - $user->DbRecord->ID, - $calendarID - ); - if ($preferenceRecord) { - $preferenceRecord->delete(); - } - } - } - - public function setPreferredCalendar(User $user, Calendar $calendar) { - $preference = new UserPreference(); - $preference->CalendarID = $calendar->UID; - $preference->UserID = $user->ID; - $preference->save(); - } - - public function setPreferredCalendars(User $user, array $calendars) { - //TODO: remove old preference, optionally - $transaction = $this->beginTransaction(); - try { - foreach ($calendars as $calendar) { - $this->setPreferredCalendar($user, $calendar); - } - $transaction->commit(); - } catch (Exception $e) { - $transaction->rollback(); - throw $e; - } - } - - public function getEventsForTimeframe(CalendarDTO $calendar, - DateTime $dateFrom, - DateTime $dateTo, - string $order = 'ASC') { - $calendar = Calendar::finder()->findAllByUID($calendar->ID); - if ($calendar) { - $events = EventFacade::getInstance()->getEventList( - $dateFrom->format('Y-m-d H:i:s'), - $dateTo->format('Y-m-d H:i:s'), - $calendar, - $order - ); - return array_map( - function($event) use($calendar) { - $dto = new EventDTO(); - $dto->loadRecord($event, $calendar); - return $dto; - }, - $events - ); - } - return []; - } - - public function getAll() { - $records = Calendar::finder()->withCategory()->findAll('ORDER BY name ASC'); - foreach ($records as $record) { - $this->_fillUrlCache($record); - } - return $records; - } - - public function getCategories() { - $categories = array_map( - function($record) { - $dto = new CalendarGroupDTO(); - $dto->loadRecord($record, []); - return $dto; - }, - Category::finder()->findAll() - ); - usort($categories, ['CalendarGroupDTO', '__compare']); - return $categories; - } - - public function get($uid) { - $records = Calendar::finder()->withCategory()->findAllByPks($uid); - foreach ($records as $record) { - $this->_fillUrlCache($record); - } - return $records; - } - - private $_urlCache = []; - private function _fillUrlCache(Calendar $record = NULL) { - if ($record && $record->CustomUrl - && !isset($this->_urlCache[$record->CustomUrl])) { - $dto = new CalendarDTO(); - if ($record) { - $dto->loadRecord($record); - } else { - $dto = NULL; - } - return $this->_urlCache[$record->CustomUrl] = $dto; - } - } - - public function resolveUrl(string $url = NULL) { - if ($url) { - if (isset($this->_urlCache[$url])) { - return $this->_urlCache[$url]; - } - $record = Calendar::finder()->findByCustomUrl($url); - if ($record) { - return $this->_fillUrlCache($record); - } - } - return NULL; - } - - public function getCalendarBoundaries($year, $month, TimezoneDTO $timezone) { - $firstDay = new DateTime(sprintf('%d-%02d', $year, $month), - new DateTimeZone($timezone->Name)); - $firstDayAfter = clone $firstDay; - $firstDayAfter->modify('last day of this month')->modify('+1 day'); - $firstDayOfTheWeek = $timezone->FirstDayOfTheWeek; - if ($firstDay->format('D') !== $firstDayOfTheWeek) { - $firstDay->modify('last ' . $firstDayOfTheWeek); - } - if ($firstDayAfter->format('D') !== $firstDayOfTheWeek) { - $firstDayAfter->modify('next ' . $firstDayOfTheWeek); - } - $firstDayAfter->modify('-1 day'); - return [$firstDay, $firstDayAfter]; - } - -} - -?> diff --git a/app/php/facades/EventFacade.php b/app/php/facades/EventFacade.php deleted file mode 100644 index 14f809d..0000000 --- a/app/php/facades/EventFacade.php +++ /dev/null @@ -1,115 +0,0 @@ -<?php - -Prado::using('Application.facades.Facade'); -Prado::using('Application.dto.EventDTO'); -Prado::using('Application.dto.TimezoneDTO'); -Prado::using('Application.dto.GridEventDTO'); -Prado::using('Application.dto.CalendarGridDTO'); -Prado::using('Application.model.Calendar'); -Prado::using('Application.facades.CalendarFacade'); -Prado::using('Application.user.DbUser'); - -class EventFacade extends Facade { - - public function getEventList(string $dateFrom=NULL, string $dateTo=NULL, - array $calendars=NULL, string $order='ASC') { - $calendarClause = '1=1'; - if ($calendars) { - $calendarClause = sprintf( - '_calendar IN (%s)', - implode( - ',', - array_map( - function($calendar) { - return $this->quoteString($calendar->UID); - }, - $calendars - ) - ) - ); - } - return $this->fetchList( - 'getEvents', - [ - 'date_from' => $dateFrom ?: '0000-00-00 00:00:00', - 'date_to' => $dateTo ?: '9999-99-99', - 'calendar_clause' => $calendarClause, - 'order_clause' => $order - ] - ); - } - - private function _compileEventObjects(array $events, array $calendars, - TimezoneDTO $tz, - string $class = 'Application.dto.EventDTO') { - return array_map( - function($event) use($calendars, $class, $tz) { - $dto = Prado::createComponent($class, $tz); - $dto->loadRecord($event, $calendars); - return $dto; - }, - $events - ); - } - - public function getTimeframeListForUser( - DbUser $user, - DateTime $dateFrom, DateTime $dateTo, - string $returnClass = 'Application.dto.EventDTO') { - $calendars = CalendarFacade::getInstance()->getCalendarPreference($user); - if ($calendars) { - $events = $this->getEventList( - $dateFrom->format('Y-m-d H:i:s'), - $dateTo->format('Y-m-d H:i:s'), - $calendars - ); - $calendars = $this->_getCalendarsForEvents($events); - return $this->_compileEventObjects( - $events, $calendars, - UserFacade::getInstance()->getTimezonePreference($user), - $returnClass); - } - return []; - } - - public function getCalendarListForUser(DbUser $user, - $month, $year) { - if (!$year) { - $year = intval(date('Y')); - } - if (!$month) { - $month = intval(date('m')); - } - $timezone = $user - ? UserFacade::getInstance()->getTimezonePreference($user) - : new TimezoneDTO(date_default_timezone_get()); - $timeframe = CalendarFacade::getInstance()->getCalendarBoundaries( - $year, $month, $timezone - ); - return new CalendarGridDTO( - $this->getTimeframeListForUser( - $user, - $timeframe[0], $timeframe[1], - 'Application.dto.GridEventDTO' - ), - ...$timeframe - ); - } - - private function _getCalendarsForEvents(array $events) { - if ($events) { - return Calendar::finder()->findAllByPks( - array_map( - function($event) { - return $event->CalendarID; - }, - $events - ) - ); - } - return []; - } - -} - -?> diff --git a/app/php/facades/Facade.php b/app/php/facades/Facade.php deleted file mode 100644 index 346024a..0000000 --- a/app/php/facades/Facade.php +++ /dev/null @@ -1,62 +0,0 @@ -<?php - -Prado::using('System.Data.SqlMap.TSqlMapGateway'); - -class Facade { - - protected static $_instances = []; - - protected $_sqlMap; - - protected function __construct() { - } - - public function __sleep() { - $this->_sqlMap = NULL; - return array(); - } - - public static function getInstance() { - $className = get_called_class(); - if (!isset(static::$_instances[$className])) { - static::$_instances[$className] = new static(); - } - return static::$_instances[$className]; - } - - protected function getClient() { - if (!$this->_sqlMap) { - $this->_sqlMap = Prado::getApplication()->getModule('sqlmap')->Client; - } - return $this->_sqlMap; - } - - protected function quoteString($string) { - return $this->getClient()->DbConnection->quoteString($string); - } - - protected function fetch($sqlMap, $params) { - return $this->getClient()->queryForObject($sqlMap, $params); - } - - protected function fetchList($sqlMap, $params) { - return $this->getClient()->queryForList($sqlMap, $params); - } - - protected function fetchMap($sqlMap, $params, $key, $value=NULL) { - return $this->getClient()->queryForMap($sqlMap, $params, $key, $value); - } - - protected function beginTransaction() { - return $this->getClient()->DbConnection->beginTransaction(); - } - - protected function raiseEvent($event, ...$params) { - return Prado::getApplication()->getModule('events')->raiseApplicationEvent( - $event, ...$params - ); - } - -} - -?> diff --git a/app/php/facades/UserFacade.php b/app/php/facades/UserFacade.php deleted file mode 100644 index 1604a70..0000000 --- a/app/php/facades/UserFacade.php +++ /dev/null @@ -1,78 +0,0 @@ -<?php - -Prado::using('Application.facades.Facade'); -Prado::using('Application.user.DbUser'); -Prado::using('Application.model.User'); -Prado::using('Application.dto.TimezoneDTO'); - -class UserFacade extends Facade { - - public function findByLogin(string $login) { - return User::finder()->findByLogin($login); - } - - public function checkForUsername(string $login) { - return !User::finder()->count('login = ?', $login); - } - - public function registerUser(string $login, string $password, bool $admin) { - $transaction = $this->beginTransaction(); - try { - $newUser = new User(); - $newUser->Login = $login; - $newUser->Password = $this->generatePassword($password); - $newUser->IsAdmin = $admin; - $newUser->save(); - $this->raiseEvent('UserRegistered', $newUser); - $transaction->commit(); - return $newUser; - } catch (Exception $e) { - $transaction->rollback(); - throw $e; - } - } - - public function changePassword(DbUser $user, string $pass) { - if (!$user->IsGuest) { - $user->DbRecord->Password = $this->generatePassword($pass); - $user->DbRecord->save(); - } - } - - public function verifyUserPassword(string $password, DbUser $user) { - $dbPassword = $user->IsGuest ? '' : $user->DbRecord->Password; - return $this->verifyPassword($password, $dbPassword); - } - - public function generatePassword(string $password) { - return password_hash($password, PASSWORD_DEFAULT); - } - - public function verifyPassword(string $password, string $dbPassword) { - return password_verify($password, $dbPassword); - } - - public function setTimezonePreference(DbUser $user, string $timezone) { - if ($user->IsGuest) { - throw new TInvalidDataException( - Prado::localize( - 'Timezone preference change impossible for guest user' - ) - ); - } - $user->DbRecord->Timezone = $timezone; - $user->DbRecord->save(); - } - - public function getTimezonePreference(DbUser $user) { - if (!$user->IsGuest) { - try { - return new TimezoneDTO($user->DbRecord->Timezone); - } catch(Exception $e) {} - } - return new TimezoneDTO(date_default_timezone_get()); - } - -} - -?> diff --git a/app/php/facades/config.xml b/app/php/facades/config.xml deleted file mode 100644 index 8d5a298..0000000 --- a/app/php/facades/config.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <modules> - <module id="sqlmap" - class="System.Data.SqlMap.TSqlMapConfig" - ConnectionID="db" - ConfigFile="Application.sqlmap.config" - EnableCache="true" /> - </modules> -</configuration> diff --git a/app/php/i18n/config.xml b/app/php/i18n/config.xml deleted file mode 100644 index c80b46d..0000000 --- a/app/php/i18n/config.xml +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <paths> - <using namespace="System.I18N.*" /> - </paths> - <modules> - <module id="globalization" class="System.I18N.TGlobalization"> - <translation type="gettext" - source="Application.i18n" - autosave="true" - cache="true" /> - </module> - </modules> -</configuration> diff --git a/app/php/layouts/Layout.php b/app/php/layouts/Layout.php deleted file mode 100644 index 324c69f..0000000 --- a/app/php/layouts/Layout.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -class Layout extends TTemplateControl { - - public function generateViewID() { - return $this->ViewID->Value ?: md5(mt_rand()); - } - -} - -?> diff --git a/app/php/layouts/MainLayout.php b/app/php/layouts/MainLayout.php deleted file mode 100644 index 5843952..0000000 --- a/app/php/layouts/MainLayout.php +++ /dev/null @@ -1,9 +0,0 @@ -<?php - -Prado::using('Application.layouts.Layout'); - -class MainLayout extends Layout { - -} - -?> diff --git a/app/php/layouts/MainLayout.tpl b/app/php/layouts/MainLayout.tpl deleted file mode 100644 index 0deb816..0000000 --- a/app/php/layouts/MainLayout.tpl +++ /dev/null @@ -1,22 +0,0 @@ -<!DOCTYPE html> -<html> - <com:THead> - <com:TMetaTag HttpEquiv="Content-Type" Content="text/html; charset=utf-8" /> - <title><com:TContentPlaceHolder ID="Title" /></title> - </com:THead> - <body> - <com:TForm> - <header role="banner"> - <com:HeaderMenu /> - </header> - <main role="main"> - <com:TContentPlaceHolder ID="Content" /> - </main> - <footer role="contentinfo"> - </footer> - <com:THiddenField ID="ViewID"> - <prop:Value><%= $this->generateViewID() %></prop:Value> - </com:THiddenField> - </com:TForm> - </body> -</html> diff --git a/app/php/model/Calendar.php b/app/php/model/Calendar.php deleted file mode 100644 index b49bf92..0000000 --- a/app/php/model/Calendar.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php - -Prado::using('Application.db.ActiveRecord'); -Prado::using('Application.model.Entry'); -Prado::using('Application.model.Category'); - -class Calendar extends ActiveRecord { - - const TABLE = 'calendars'; - - public $UID; - public $Url; - public $Name; - public $Website; - public $Visible; - public $CustomName; - public $CustomImage; - public $CustomUrl; - public $LastUpdated; - - public $CategoryID; - - public static $COLUMN_MAPPING = [ - 'uid' => 'UID', - 'url' => 'Url', - 'name' => 'Name', - 'website' => 'Website', - 'visible' => 'Visible', - 'last_updated' => 'LastUpdated', - 'custom_name' => 'CustomName', - 'custom_image' => 'CustomImage', - 'custom_url' => 'CustomUrl', - '_category' => 'CategoryID' - ]; - - public static $RELATIONS = [ - 'Entries' => [self::HAS_MANY, 'Entry', '_calendar'], - 'Category' => [self::BELONGS_TO, 'Category', '_category'] - ]; - - public static function finder($className=__CLASS__) { - return parent::finder($className); - } - - const CUSTOM_IMAGE_PATH = 'resources/images/calendars'; - - public function getCustomImageUrl() { - if ($this->CustomImage) { - if (!preg_match('#^//#', $this->CustomImage)) { - return Prado::getApplication()->getAssetManager()->publishFilePath( - implode( - DIRECTORY_SEPARATOR, - [ - Prado::getApplication()->getBasePath(), - self::CUSTOM_IMAGE_PATH, - $this->CustomImage - ] - ), - TRUE - ); - } - return $this->CustomImage; - } - } - - public function getCustomImagePath($forFile = NULL, $type = '') { - $pathParts = [ - Prado::getApplication()->getBasePath(), - self::CUSTOM_IMAGE_PATH - ]; - if ($forFile) { - $pathParts[] = $this->_getCustomImageHash($forFile, $type); - } - return implode(DIRECTORY_SEPARATOR, $pathParts); - } - - private function _getCustomImageHash($file, $type) { - $hash = md5($file . md5_file($file) . filemtime($file)); - if ($type) { - $hash .= '.' . preg_replace('#^image/#', '', $type); - } - return $hash; - } - - public function saveData($data) { - $this->copyFrom($data); - return $this->save(); - } - -} - -?> diff --git a/app/php/model/Category.php b/app/php/model/Category.php deleted file mode 100644 index 87b97b6..0000000 --- a/app/php/model/Category.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -Prado::using('Application.db.ActiveRecord'); -Prado::using('Application.model.Calendar'); - -class Category extends ActiveRecord { - - const TABLE = 'categories'; - - public $ID; - public $Name; - public $Priority; - - public static $COLUMN_MAPPING = [ - 'id' => 'ID', - 'name' => 'Name', - 'priority' => 'Priority' - ]; - - public static $RELATIONS = [ - 'Calendars' => [self::HAS_MANY, 'Calendar', '_category'] - ]; - - public static function finder($className=__CLASS__) { - return parent::finder($className); - } - -} - -?> diff --git a/app/php/model/Entry.php b/app/php/model/Entry.php deleted file mode 100644 index 4b93f04..0000000 --- a/app/php/model/Entry.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - -Prado::using('Application.db.ActiveRecord'); -Prado::using('Application.model.Calendar'); - -class Entry extends ActiveRecord { - - const TABLE = 'entries'; - - public $ID; - public $UID; - public $BeginDate; - public $EndDate; - public $AllDay; - public $Name; - public $Location; - public $LastModified; - - public $CalendarID; - - public static $COLUMN_MAPPING = [ - 'id' => 'ID', - 'uid' => 'UID', - 'begin_date' => 'BeginDate', - 'end_date' => 'EndDate', - 'all_day' => 'AllDay', - 'name' => 'Name', - 'location' => 'Location', - 'last_modified' => 'LastModified', - '_calendar' => 'CalendarID' - ]; - - public static $RELATIONS = [ - 'Calendar' => [self::BELONGS_TO, 'Calendar', '_calendar'] - ]; - - public static function finder($className=__CLASS__) { - return parent::finder($className); - } - -} - -?> diff --git a/app/php/model/User.php b/app/php/model/User.php deleted file mode 100644 index d431183..0000000 --- a/app/php/model/User.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -Prado::using('Application.db.ActiveRecord'); -Prado::using('Application.model.Calendar'); - -class User extends ActiveRecord { - - const TABLE = 'users'; - - public $ID; - public $Login; - public $Password; - public $IsAdmin; - public $Timezone; - public $LastLogin; - - public static $COLUMN_MAPPING = [ - 'id' => 'ID', - 'login' => 'Login', - 'password' => 'Password', - 'is_admin' => 'IsAdmin', - 'timezone' => 'Timezone', - 'last_login' => 'LastLogin' - ]; - - public static $RELATIONS = [ - 'Calendars' => [self::MANY_TO_MANY, 'Calendar', 'user_selections'] - ]; - - public static function finder($className=__CLASS__) { - return parent::finder($className); - } - -} - -?> diff --git a/app/php/model/UserPreference.php b/app/php/model/UserPreference.php deleted file mode 100644 index 90fa221..0000000 --- a/app/php/model/UserPreference.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -Prado::using('Application.db.ActiveRecord'); - -class UserPreference extends ActiveRecord { - - const TABLE = 'user_selections'; - - public $UserID; - public $CalendarID; - - public static $COLUMN_MAPPING = [ - '_user' => 'UserID', - '_calendar' => 'CalendarID' - ]; - - public static function finder($className=__CLASS__) { - return parent::finder($className); - } - -} - -?> diff --git a/app/php/model/config.xml b/app/php/model/config.xml deleted file mode 100644 index a729150..0000000 --- a/app/php/model/config.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <modules> - <module id="active-record" - class="System.Data.ActiveRecord.TActiveRecordConfig" - ConnectionID="db" - EnableCache="true" /> - </modules> -</configuration> diff --git a/app/php/pages/Admin.page b/app/php/pages/Admin.page deleted file mode 100644 index b130583..0000000 --- a/app/php/pages/Admin.page +++ /dev/null @@ -1,5 +0,0 @@ -<com:TContent ID="Content"> - <com:CalendarScaffold> - <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade> - </com:CalendarScaffold> -</com:TContent> diff --git a/app/php/pages/Calendar.page b/app/php/pages/Calendar.page deleted file mode 100644 index f414dae..0000000 --- a/app/php/pages/Calendar.page +++ /dev/null @@ -1,28 +0,0 @@ -<com:TContent ID="Content"> - <com:CalendarDetails RaiseException="True"> - <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade> - <prop:CalendarUrl><%= $this->Request->itemAt('calendar') %></prop:CalendarUrl> - </com:CalendarDetails> - <com:AddToFilter> - <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade> - <prop:UserToManage><%= $this->getUser() %></prop:UserToManage> - <prop:CalendarUrl><%= $this->Request->itemAt('calendar') %></prop:CalendarUrl> - <prop:Description> - <%[ calendar visible in current filter selection ]%> - </prop:Description> - </com:AddToFilter> - <com:EventList DateFrom="now" DateTo="+1 year"> - <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade> - <prop:CalendarUrl><%= $this->Request->itemAt('calendar') %></prop:CalendarUrl> - <prop:HeaderText> - <%[ Upcoming events in the calendar: ]%> - </prop:HeaderText> - </com:EventList> - <com:EventList DateTo="now" Reverse="true"> - <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade> - <prop:CalendarUrl><%= $this->Request->itemAt('calendar') %></prop:CalendarUrl> - <prop:HeaderText> - <%[ Past events in the calendar: ]%> - </prop:HeaderText> - </com:EventList> -</com:TContent> diff --git a/app/php/pages/Home.page b/app/php/pages/Home.page deleted file mode 100644 index fb60066..0000000 --- a/app/php/pages/Home.page +++ /dev/null @@ -1,8 +0,0 @@ -<com:TContent ID="Content"> - <com:CalendarGrid> - <prop:Facade><%= EventFacade::getInstance() %></prop:Facade> - <prop:Month><%= $this->Request->itemAt('month') %></prop:Month> - <prop:Year><%= $this->Request->itemAt('year') %></prop:Year> - <prop:UserToDisplay><%= $this->User %></prop:UserToDisplay> - </com:CalendarGrid> -</com:TContent> diff --git a/app/php/pages/Login.page b/app/php/pages/Login.page deleted file mode 100644 index 15bc93e..0000000 --- a/app/php/pages/Login.page +++ /dev/null @@ -1,3 +0,0 @@ -<com:TContent ID="Content"> - <com:LoginBox /> -</com:TContent> diff --git a/app/php/pages/Profile.page b/app/php/pages/Profile.page deleted file mode 100644 index 163d3fa..0000000 --- a/app/php/pages/Profile.page +++ /dev/null @@ -1,21 +0,0 @@ -<com:TContent ID="Content"> - <com:PasswordChange> - <prop:Facade><%= UserFacade::getInstance() %></prop:Facade> - <prop:UserToChange><%= $this->User %></prop:UserToChange> - </com:PasswordChange> - <br /> - <com:TimezoneSelect> - <prop:Facade><%= UserFacade::getInstance() %></prop:Facade> - <prop:UserToChange><%= $this->User %></prop:UserToChange> - </com:TimezoneSelect> - <br /> - <com:UserSelection> - <prop:UserToDisplay><%= $this->User %></prop:UserToDisplay> - <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade> - </com:UserSelection> - <br /> - <com:UpcomingEvents> - <prop:UserToDisplay><%= $this->User %></prop:UserToDisplay> - <prop:Facade><%= EventFacade::getInstance() %></prop:Facade> - </com:UpcomingEvents> -</com:TContent> diff --git a/app/php/pages/Select.page b/app/php/pages/Select.page deleted file mode 100644 index 5e1f232..0000000 --- a/app/php/pages/Select.page +++ /dev/null @@ -1,8 +0,0 @@ -<com:TContent ID="Content"> - <com:CalendarGroupFilter> - <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade> - </com:CalendarGroupFilter> - <com:CalendarSelection> - <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade> - </com:CalendarSelection> -</com:TContent> diff --git a/app/php/pages/Signup.page b/app/php/pages/Signup.page deleted file mode 100644 index 834b7cf..0000000 --- a/app/php/pages/Signup.page +++ /dev/null @@ -1,5 +0,0 @@ -<com:TContent ID="Content"> - <com:RegistrationForm> - <prop:Facade><%= UserFacade::getInstance() %></prop:Facade> - </com:RegistrationForm> -</com:TContent> diff --git a/app/php/pages/config.xml b/app/php/pages/config.xml deleted file mode 100644 index 305651e..0000000 --- a/app/php/pages/config.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - - <services> - <service id="page" - class="TPageService" - ClientScriptManagerClass="Application.web.ClientScriptManager"> - <modules> - <module id="theme" - class="Application.web.ThemeManager" - BasePath="Web._themes" /> - </modules> - </service> - </services> - - <pages MasterClass="Application.layouts.MainLayout" - Theme="default" - StatePersisterClass="System.Web.UI.TCachePageStatePersister" - StatePersister.CacheModuleID="cache" - StatePersister.CacheTimeout="3600" /> - - <authorization> - <allow pages="Admin,Signup" roles="Admin" /> - <deny pages="Admin,Signup" /> - <deny pages="Profile" users="?" /> - </authorization> - -</configuration> diff --git a/app/php/resources b/app/php/resources deleted file mode 120000 index bc76415..0000000 --- a/app/php/resources +++ /dev/null @@ -1 +0,0 @@ -../../resources
\ No newline at end of file diff --git a/app/php/runtime b/app/php/runtime deleted file mode 120000 index 2cee2e0..0000000 --- a/app/php/runtime +++ /dev/null @@ -1 +0,0 @@ -../../cache/prado
\ No newline at end of file diff --git a/app/php/sqlmap/config.xml b/app/php/sqlmap/config.xml deleted file mode 100644 index 101e1b7..0000000 --- a/app/php/sqlmap/config.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<sqlMapConfig> - <provider class="TAdodbProvider"> - <datasource ConnectionID="db" /> - </provider> - <sqlMaps> - <sqlMap name="events" resource="events.xml" /> - </sqlMaps> -</sqlMapConfig> diff --git a/app/php/sqlmap/events.xml b/app/php/sqlmap/events.xml deleted file mode 100644 index 030a773..0000000 --- a/app/php/sqlmap/events.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<sqlMapConfig> - <select id="getEvents" resultClass="Entry"> - <![CDATA[ - SELECT * FROM entries - WHERE end_date >= #date_from# AND begin_date <= #date_to# - AND $calendar_clause$ - ORDER BY begin_date $order_clause$; - ]]> - </select> -</sqlMapConfig> diff --git a/app/php/themes/default/preloader.gif b/app/php/themes/default/preloader.gif Binary files differdeleted file mode 100644 index 6505467..0000000 --- a/app/php/themes/default/preloader.gif +++ /dev/null diff --git a/app/php/url/UrlManager.php b/app/php/url/UrlManager.php deleted file mode 100644 index a33d98e..0000000 --- a/app/php/url/UrlManager.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -Prado::using('System.Web.TUrlMapping'); - -class UrlManager extends TUrlMapping { - - public function constructUrl($serviceID, $serviceParam, $getItems, $encodeAmpersand, $encodeGetItems) { - $url = parent::constructUrl( - $serviceID, - $serviceParam, - $getItems, - $encodeAmpersand, - $encodeGetItems - ); - return rtrim( - preg_replace( - '#^/' . $serviceParam . '#', - '/' . $this->_convertServiceParam($serviceParam), - preg_replace('#^/' . $serviceID . '#', '', $url) - ), - '/' - ) . '/'; - } - - public function parseUrl() { - $params = parent::parseUrl(); - if ($this->MatchingPattern) { - $serviceID = $this->MatchingPattern->ServiceID; - if (isset($params[$serviceID])) { - $params[$serviceID] = $this->_parseServiceParam($params[$serviceID]); - } - } - return $params; - } - - /** - * Convert service param from camelCase to hyphenated-form. - **/ - private function _convertServiceParam($param) { - return implode( - '-', - array_map('mb_strtolower', array_filter(preg_split('/(?=[A-Z])/', $param))) - ); - } - - /** - * Convert service param from hyphenated-form to camelCase. - **/ - private function _parseServiceParam($param) { - return implode( - '', - array_map('ucfirst', explode('-', $param)) - ); - } -} - -?> diff --git a/app/php/url/config.xml b/app/php/url/config.xml deleted file mode 100644 index b072b2d..0000000 --- a/app/php/url/config.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <modules> - <module id="url" - class="Application.url.UrlManager" - UrlPrefix="/" - EnableCustomUrl="True"> - - <url ServiceParameter="Home" - UrlFormat="HiddenPath" - pattern="{month}/{year}/" - parameters.month="\d{2}" - parameters.year="\d{4}" /> - <url ServiceParameter="Home" - UrlFormat="HiddenPath" - pattern="{month}/" - parameters.month="\d{2}" /> - <url ServiceParameter="Home" - UrlFormat="HiddenPath" - EnableCustomUrl="false" - pattern="" /> - - <url ServiceParameter="Calendar" - UrlFormat="HiddenPath" - pattern="calendar/{calendar}/" - parameters.calendar=".*" /> - - <url ServiceParameter="*" - UrlFormat="HiddenPath" - EnableCustomUrl="false" - pattern="{*}" /> - </module> - - <module id="request" - class="THttpRequest" - UrlFormat="HiddenPath" - UrlParamSeparator="/" - UrlManager="url" /> - <module id="response" - class="THttpResponse" - CacheControl="public" - CacheExpire="10" /> - </modules> -</configuration> diff --git a/app/php/user/DbUser.php b/app/php/user/DbUser.php deleted file mode 100644 index d636e8b..0000000 --- a/app/php/user/DbUser.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -Prado::using('System.Security.TDbUserManager'); -Prado::using('Application.model.User'); -Prado::using('Application.facades.UserFacade'); - -class DbUser extends TDbUser { - - private $_record; - - public function setDbRecord(User $record) { - $this->_record = $record; - } - - public function getDbRecord() { - if (!$this->_record) { - $this->_record = UserFacade::getInstance()->findByLogin($this->Name); - } - return $this->_record; - } - - public function createUser($username) { - $dbUser = UserFacade::getInstance()->findByLogin($username); - if (!$dbUser) { - return NULL; - } - $user = new DbUser($this->Manager); - $user->setDbRecord($dbUser); - $user->Name = $dbUser->Login; - if ($dbUser->IsAdmin) { - $user->Roles = 'Admin'; - } - $user->IsGuest = FALSE; - return $user; - } - - public function validateUser($login, $password) { - $user = UserFacade::getInstance()->findByLogin($login); - $dbPassword = $user ? $user->Password : ''; - if (UserFacade::getInstance()->verifyPassword($password, $dbPassword) - && $user) { - $user->LastLogin = date('Y-m-d H:i:s'); - $user->save(); - return TRUE; - } else { - return FALSE; - } - } - - public function __call($name, $args) { - $match = []; - if (preg_match('/^getIs(.+)$/', $name, $match)) { - return $this->isInRole($match[1]); - } - throw new Exception('Unimplemented CustomDbUser method'); - } - -} - -?> diff --git a/app/php/user/config.xml b/app/php/user/config.xml deleted file mode 100644 index 80027e5..0000000 --- a/app/php/user/config.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <modules> - <module id="auth" class="System.Security.TAuthManager" - UserManager="users" LoginPage="Login" /> - <module id="users" class="System.Security.TDbUserManager" - UserClass="Application.user.DbUser" /> - </modules> -</configuration> diff --git a/app/php/web/AssetManager.php b/app/php/web/AssetManager.php deleted file mode 100644 index 2677585..0000000 --- a/app/php/web/AssetManager.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -Prado::using('Application.web.BaseUrlDerivedFromBasePath'); - -class AssetManager extends TAssetManager { - - use BaseUrlDerivedFromBasePath; - -} - -?> diff --git a/app/php/web/BaseUrlDerivedFromBasePath.php b/app/php/web/BaseUrlDerivedFromBasePath.php deleted file mode 100644 index 2da277f..0000000 --- a/app/php/web/BaseUrlDerivedFromBasePath.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -trait BaseUrlDerivedFromBasePath { - - public function init($config) { - if ($this->BaseUrl === NULL && $this->BasePath !== NULL) { - $appWebPath = preg_replace( - '#' . $this->Application->Request->ApplicationUrl . '$#', - '', - $this->Application->Request->ApplicationFilePath - ); - $appBaseUrl = preg_replace( - '#^' . $appWebPath . '#', - '', - dirname($this->Application->Request->ApplicationFilePath) - ); - $this->BaseUrl = $appBaseUrl - . preg_replace( - '#^' . Prado::getPathOfNamespace('Web') . '#', - '', - $this->BasePath - ); - } - parent::init($config); - } - -} - -?> diff --git a/app/php/web/ClientScriptManager.php b/app/php/web/ClientScriptManager.php deleted file mode 100644 index 223c6e2..0000000 --- a/app/php/web/ClientScriptManager.php +++ /dev/null @@ -1,572 +0,0 @@ -<?php - -Prado::using('Application.layouts.Layout'); - -class ClientScriptManager extends TClientScriptManager { - - private $_page; - public function __construct(TPage $page) { - $this->_page = $page; - parent::__construct($page); - } - - // Base path of the entire application - private function _getBasePath() { - return Prado::getPathOfNamespace('Web'); - } - - // Translate URLs to filesystem paths, index return array by URLs - private function _getBasePaths(array $urls) { - $basePath = $this->_getBasePath(); - return array_combine( - $urls, - array_map( - function($path) use($basePath) { - return $basePath . DIRECTORY_SEPARATOR . $path; - }, - $urls - ) - ); - } - - // Base cache path, suffixed with subdirectory, create on demand - private function _getCachePath(string $subdir = 'assets') { - $cachePath = $this->Application->RuntimePath - . DIRECTORY_SEPARATOR - . $subdir; - if (!is_dir($cachePath)) { - if (file_exists($cachePath)) { - throw new TIOException( - sprintf( - 'Client script manager cache path "%s" exists and is not a directory', - $cachePath - ) - ); - } else { - mkdir($cachePath); - } - } - return $cachePath; - } - - // Cache path for a file of specified type - private function _getCacheFilePath($path, $type) { - return $this->_getCachePath($type) - . DIRECTORY_SEPARATOR - . $path; - } - - // Cache key for specific file set, including current theme - private function _getFileCollectionCacheKey(array $files) { - sort($files); - if ($this->_page->Theme) { - $files[] = $this->_page->Theme->Name; - } - return md5(implode(PHP_EOL, $files)); - } - - // Last modification time of a file set - private function _getFileCollectionMTime(array $files) { - return max(array_map('filemtime', $files)); - } - - // Storage (application cache) key for list of rendered assets of specified type - // Rendered[ASSET_TYPE].[VIEW_ID] (VIEW_ID as rendered in Layout hidden field) - private function _getRenderedAssetsStoreKey($type) { - $template = $this->_page->Master; - if (!$template instanceof Layout) { - throw new TNotSupportedException( - 'Compiled assets may only be used within Layout master class controls' - ); - } - return sprintf('Rendered%s.%s', $type, $template->generateViewID()); - } - - // Shorthand for JS assets cache key - private function _getRenderedScriptsStoreKey() { - return $this->_getRenderedAssetsStoreKey('Scripts'); - } - - // Shorthand for CSS assets cache key - private function _getRenderedSheetsStoreKey() { - return $this->_getRenderedAssetsStoreKey('Sheets'); - } - - // Application (primary) cache module, required to keep track of assets rendered on current page - private function _getCache() { - $cache = $this->Application->Cache; - if (!$cache) { - throw new TNotSupportedException( - 'Compiled assets require cache to be configured' - ); - } - return $cache; - } - - // Check cache file validity, comparing to source file set - private function _isCacheValid($cacheFile, array $paths) { - return file_exists($cacheFile) - && (filemtime($cacheFile) >= $this->_getFileCollectionMTime($paths)); - } - - // Determine whether specific URL points to a local asset (i.e. existing on the filesystem) - private function _isFileLocal($file) { - $basePath = $this->_getBasePath(); - return file_exists($basePath . DIRECTORY_SEPARATOR . $file); - } - - // Filter URL set to leave only local assets - private function _determineLocalFiles($files) { - return array_filter( - $files, [$this, '_isFileLocal'] - ); - } - - // Scripts - internal methods - - private $_renderedScriptsInitialized = FALSE; - - // Retrieve scripts already rendered on current page from application cache, - // maintaining the state over callbacks - private function _getRenderedScripts() { - $sessionKey = $this->_getRenderedScriptsStoreKey(); - if ($this->_page->IsCallBack || $this->_renderedScriptsInitialized) { - return $this->_getCache()->get($sessionKey) ?: []; - } else { - $this->_getCache()->delete($sessionKey); - $this->_renderedScriptsInitialized = TRUE; - return []; - } - } - - // Store information on rendered scripts in application cache - private function _appendRenderedScripts(array $newScripts, $compiledFileKey) { - $scripts = $this->_getRenderedScripts(); - if (!isset($scripts[$compiledFileKey])) { - $scripts[$compiledFileKey] = []; - } - $scripts[$compiledFileKey] = array_unique( - array_merge( - $scripts[$compiledFileKey], - $newScripts - ) - ); - $this->_getCache()->set( - $this->_getRenderedScriptsStoreKey(), - $scripts - ); - } - - // Compress JS file and return its content - private function _getCompressedScript($path) { - return trim(TJavaScript::JSMin( - file_get_contents($path) - )); - } - - // Join multiple script files into single asset, mark all of them as rendered in parent - private function _compileScriptFiles(array $files) { - foreach ($files as $file) { - $this->markScriptFileAsRendered($file); - } - $paths = $this->_getBasePaths($files); - $cacheFile = $this->_getCacheFilePath( - $this->_getFileCollectionCacheKey($paths) . '.js', - 'scripts' - ); - $this->_appendRenderedScripts($files, $cacheFile); - if (!$this->_isCacheValid($cacheFile, $paths)) { - $scriptContent = implode( - PHP_EOL, - array_map( - [$this, '_getCompressedScript'], - $paths - ) - ); - file_put_contents($cacheFile, $scriptContent); - } - return $this->Application->AssetManager->publishFilePath($cacheFile); - } - - // Write output tag for a single, compiled JS asset, consisting of multiple local assets - private function _renderLocalScriptFiles(THtmlWriter $writer, array $localFiles) { - if ($localFiles) { - $assetPath = $this->_compileScriptFiles($localFiles); - $writer->write(TJavascript::renderScriptFile($assetPath)); - } - } - - // Keep track of external JS scripts rendered on the page - private function _renderExternalScriptFiles(THtmlWriter $writer, array $externalFiles) { - if ($externalFiles) { - foreach ($externalFiles as $file) { - $this->markScriptFileAsRendered($file); - $this->_appendRenderedScripts([$file], $file); - } - parent::renderScriptFiles($writer, $externalFiles); - } - } - - // Determine actual asset URL that a source JS file was rendered as (after compilation/compression) - // FALSE means script wasn't rendered at all (i.e. was just registered in current callback) - private function _getRenderedScriptUrl($registeredScript) { - $renderedScripts = $this->_getRenderedScripts(); - foreach ($renderedScripts as $compiledFile => $scripts) { - if (in_array($registeredScript, $scripts)) { - if (file_exists($compiledFile)) { - return $this->Application->AssetManager->getPublishedUrl( - $compiledFile - ); - } else { - return $registeredScript; - } - } - } - return FALSE; - } - - // Scripts - public interface overrides - - // In application modes "higher" than Debug, compile JS assets to as few files as possible - public function renderScriptFiles($writer, Array $files) { - if ($this->getApplication()->getMode() !== TApplicationMode::Debug) { - if ($files) { - $localFiles = $this->_determineLocalFiles($files); - $this->_renderLocalScriptFiles($writer, $localFiles); - $externalFiles = array_diff($files, $localFiles); - $this->_renderExternalScriptFiles($writer, $externalFiles); - } - } else { - parent::renderScriptFiles($writer, $files); - } - } - - // When above compilation occurs, list of JS URLs a callback requires - // significantly deviates from parent implementation. - // Also, new scripts that have been registered in current callback may need compiling, too. - public function getScriptUrls() { - if ($this->getApplication()->getMode() !== TApplicationMode::Debug) { - $registeredScripts = array_unique( - array_merge( - $this->_scripts, $this->_headScripts - ) - ); - $scriptUrls = []; - $newScripts = []; - foreach ($registeredScripts as $registeredScript) { - $renderedScriptUrl = $this->_getRenderedScriptUrl($registeredScript); - if ($renderedScriptUrl) { - $scriptUrls[] = $renderedScriptUrl; - } else { - $newScripts[] = $registeredScript; - } - } - $newLocalScripts = $this->_determineLocalFiles($newScripts); - $newRemoteScripts = array_diff($newScripts, $newLocalScripts); - if ($newLocalScripts) { - $scriptUrls[] = $this->_compileScriptFiles($newLocalScripts); - } - $scriptUrls = array_values( - array_unique(array_merge($scriptUrls, $newRemoteScripts)) - ); - return $scriptUrls; - } - return parent::getScriptUrls(); - } - - private $_scripts = []; - private $_headScripts = []; - - // Keep track of what we're registering - public function registerScriptFile($key, $file) { - $this->_scripts[$key] = $file; - return parent::registerScriptFile($key, $file); - } - - // Keep track of what we're registering - public function registerHeadScriptFile($key, $file) { - $this->_headScripts[$key] = $file; - return parent::registerHeadScriptFile($key, $file); - } - - // Stylesheets - internal methods - - private $_renderedSheetsInitialized = FALSE; - - // Retrieve stylesheets already rendered on current page from application cache, - // maintaining the state over callbacks - private function _getRenderedSheets() { - $sessionKey = $this->_getRenderedSheetsStoreKey(); - if ($this->_page->IsCallBack || $this->_renderedSheetsInitialized) { - return $this->_getCache()->get($sessionKey) ?: []; - } else { - $this->_getCache()->delete($sessionKey); - $this->_renderedSheetsInitialized = TRUE; - return []; - } - } - - // Store information on rendered stylesheets in application cache - private function _appendRenderedSheets(array $newSheets, $compiledFileKey) { - $sheets = $this->_getRenderedSheets(); - if (!isset($sheets[$compiledFileKey])) { - $sheets[$compiledFileKey] = []; - } - $sheets[$compiledFileKey] = array_merge( - $sheets[$compiledFileKey], - $newSheets - ); - $this->_getCache()->set( - $this->_getRenderedSheetsStoreKey(), - $sheets - ); - } - - // Resolve all "url(FILE)" CSS directives pointing - // to relative resources to specified path - private function _fixStyleSheetPaths($content, $originalUrl) { - $originalDir = dirname($originalUrl . '.'); - return preg_replace_callback( - '/url\s*\([\'"]?(.*?)[\'"]?\)/', - function($matches) use($originalDir) { - $url = parse_url($matches[1]); - // ignore absolute URLs and paths - if (isset($url['scheme']) - || isset($url['host']) - || $url['path'][0] == '/') { - return $matches[0]; - } - // resolve relative paths - return str_replace( - $matches[1], - $originalDir . '/' . $matches[1], - $matches[0] - ); - }, - $content - ); - } - - // Compress CSS file and return its content - private function _getCompressedSheet($origPath, $path) { - Prado::using('Lib.cssmin.CssMin'); - return trim(CssMin::minify( - $this->_fixStyleSheetPaths( - file_get_contents($path), - $origPath - ) - )); - } - - // Join multiple stylesheet files into single asset - private function _compileSheetFiles(array $files) { - $paths = $this->_getBasePaths( - array_map('reset', $files) - ); - // determine if file was registered as a themed sheet - $correctedPaths = []; - foreach ($paths as $url => $path) { - $correctedPaths[ - in_array($url, $this->_themeStyles) && $this->_page->Theme - ? $this->_page->Theme->BaseUrl . DIRECTORY_SEPARATOR - : $url - ] = $path; - } - $cacheFile = $this->_getCacheFilePath( - $this->_getFileCollectionCacheKey($paths) . '.css', - 'styles' - ); - $this->_appendRenderedSheets($files, $cacheFile); - if (!$this->_isCacheValid($cacheFile, $paths)) { - $styleContent = implode( - PHP_EOL, - array_map( - [$this, '_getCompressedSheet'], - array_keys($correctedPaths), - $correctedPaths - ) - ); - file_put_contents($cacheFile, $styleContent); - } - return $this->Application->AssetManager->publishFilePath($cacheFile); - } - - // Filter only local stylesheet file entries - private function _determineLocalSheetFiles(array $files) { - $basePath = $this->_getBasePath(); - return array_filter( - $files, - function($file) use($basePath) { - return file_exists($basePath . DIRECTORY_SEPARATOR . $file[0]); - } - ); - } - - // Write HTML markup for CSS stylesheet - private function _renderSheetFileTag(THtmlWriter $writer, $href, $media) { - $writer->addAttribute('rel', 'stylesheet'); - $writer->addAttribute('type', 'text/css'); - $writer->addAttribute('media', $media); - $writer->addAttribute('href', $href); - $writer->renderBeginTag('link'); - $writer->write(PHP_EOL); - } - - // Group registered local CSS assets by media query string and render markup for compiled sheets - private function _renderLocalSheetFiles(THtmlWriter $writer, array $localFiles) { - if ($localFiles) { - $fileTypes = []; - foreach ($localFiles as $file) { - $type = $file[1] ?: 'all'; - if (!isset($fileTypes[$type])) { - $fileTypes[$type] = []; - } - $fileTypes[$type][] = $file; - } - foreach ($fileTypes as $type => $files) { - $assetPath = $this->_compileSheetFiles($files); - $this->_renderSheetFileTag($writer, $assetPath, $type); - } - } - } - - // Render markup for external stylesheets - private function _renderExternalSheetFiles(THtmlWriter $writer, array $externalFiles) { - if ($externalFiles) { - foreach ($externalFiles as $file) { - $this->_appendRenderedSheets([$file], $file[0]); - $this->_renderSheetFileTag($writer, $file[0], $file[1] ?: 'all'); - } - } - } - - // Determine actual asset URL that a source CSS file was rendered as (after compilation/compression) - // FALSE means sheet wasn't rendered at all (i.e. was just registered in current callback) - // Media query types can easily be ignored in a callback request, only URLs matter - private function _getRenderedSheetUrl($registeredSheet) { - $renderedSheets = $this->_getRenderedSheets(); - foreach ($renderedSheets as $compiledFile => $sheets) { - foreach ($sheets as $sheet) { - if ($registeredSheet[0] == $sheet[0]) { - if (file_exists($compiledFile)) { - return $this->Application->AssetManager->getPublishedUrl( - $compiledFile - ); - } else { - return $registeredSheet[0]; - } - } - } - } - return FALSE; - } - - // Stylesheets - public interface overrides - - // In application modes "higher" than Debug, compile CSS assets to as few files as possible - public function renderStyleSheetFiles($writer) { - if ($this->getApplication()->getMode() !== TApplicationMode::Debug) { - $files = $this->_styles; - if ($files) { - $localFiles = $this->_determineLocalSheetFiles($files); - $this->_renderLocalSheetFiles($writer, $localFiles); - $externalFiles = array_diff_key($files, $localFiles); - $this->_renderExternalSheetFiles($writer, $externalFiles); - } - } else { - parent::renderStyleSheetFiles($writer); - } - } - - // When above compilation occurs, list of CSS URLs a callback requires - // significantly deviates from parent implementation. - // New stylesheets may need compiling, as well. - public function getStyleSheetUrls() { - if ($this->getApplication()->getMode() !== TApplicationMode::Debug) { - $registeredSheets = $this->_styles; - $sheetUrls = []; - $newSheets = []; - foreach ($registeredSheets as $registeredSheet) { - $renderedSheetUrl = $this->_getRenderedSheetUrl( - $registeredSheet - ); - if ($renderedSheetUrl) { - $sheetUrls[] = $renderedSheetUrl; - } else { - $newSheets[] = $registeredSheet; - } - } - $newLocalSheets = $this->_determineLocalSheetFiles($newSheets); - $newLocalUrls = array_map('reset', $newLocalSheets); - $newRemoteSheets = array_filter( - $newSheets, - function($sheet) use($newLocalUrls) { - return !in_array($sheet[0], $newLocalUrls); - } - ); - $newRemoteUrls = array_map('reset', $newRemoteSheets); - if ($newLocalSheets) { - $sheetUrls[] = $this->_compileSheetFiles($newLocalSheets); - } - $sheetUrls = array_values( - array_unique(array_merge($sheetUrls, $newRemoteUrls)) - ); - return $sheetUrls; - } - // And even in Debug mode, theme sheets before fixing paths - // might also have been published via assets manager, - // so we have to discard these from parent list. - return array_diff( - parent::getStyleSheetUrls(), - $this->_fixedStyleFiles - ); - } - - private $_styles = []; - - // Keep track of what we're registering - public function registerStyleSheetFile($key, $file, $media = '') { - $this->_styles[$key] = [$file, $media]; - return parent::registerStyleSheetFile($key, $file, $media ?: 'all'); - } - - private $_themeStyles = []; - private $_fixedStyleFiles = []; - - // New method, automatically corrects URLs within stylesheet to current page theme - // when sheets are not compiled (when they are, it's done on compilation anyways). - // Such files are rewritten (not in place, though) and registered so that they don't show up - // within published assets returned from asset manager, as they don't end up in the markup. - public function registerThemeStyleSheetFile($key, $file, $media = '') { - if ($this->getApplication()->getMode() !== TApplicationMode::Debug) { - $this->_themeStyles[$key] = $file; - } else { - if ($this->_isFileLocal($file) && $this->_page->Theme) { - $tempFile = $this->_getCacheFilePath( - $this->_getFileCollectionCacheKey([ - $this->_getBasePath() - . DIRECTORY_SEPARATOR - . $file - ]) - . '.' . basename($file), - $this->_page->Theme->Name - ); - file_put_contents( - $tempFile, - $this->_fixStyleSheetPaths( - file_get_contents( - $this->_getBasePath() . DIRECTORY_SEPARATOR . $file - ), - $this->_page->Theme->BaseUrl . DIRECTORY_SEPARATOR - ) - ); - $this->_fixedStyleFiles[] = $file; - $file = $this->Application->AssetManager->publishFilePath($tempFile); - } - } - return $this->registerStyleSheetFile($key, $file, $media ?: 'all'); - } - -} - -?> diff --git a/app/php/web/FacadeTemplateControl.php b/app/php/web/FacadeTemplateControl.php deleted file mode 100644 index 05d148c..0000000 --- a/app/php/web/FacadeTemplateControl.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -Prado::using('Application.facades.Facade'); -Prado::using('Application.web.TemplateControl'); - -class FacadeTemplateControl extends TemplateControl { - - public function setFacade(Facade $facade) { - $this->setControlState('Facade', $facade); - } - - public function getFacade() { - return $this->getControlState('Facade'); - } - - public function onPreRender($param) { - parent::onPreRender($param); - if (!$this->getFacade()) { - throw new TInvalidDataValueException( - 'FacadeTemplateControl requires a Facade instance' - ); - } - } - -} - -?> diff --git a/app/php/web/TemplateControl.php b/app/php/web/TemplateControl.php deleted file mode 100644 index aa95d75..0000000 --- a/app/php/web/TemplateControl.php +++ /dev/null @@ -1,176 +0,0 @@ -<?php - -class TemplateControl extends TTemplateControl { - - public function onPreRender($param) { - parent::onPreRender($param); - $scriptFile = $this->_getControlScriptPath(get_class($this)); - if (file_exists($scriptFile)) { - $this->_registerScriptFile($scriptFile); - } - $styleFile = $this->_getControlStylePath(get_class($this)); - if (file_exists($styleFile)) { - $this->_registerStyleFile($styleFile); - } - } - - protected function getExternalScriptDependencies() { - return []; - } - - protected function getLibScriptDependencies() { - return []; - } - - protected function getPradoScriptDependencies() { - return []; - } - - protected function getControlScriptDependencies() { - return []; - } - - protected function getExternalStyleDependencies() { - return []; - } - - protected function getLibStyleDependencies() { - return []; - } - - protected function getControlStyleDependencies() { - return []; - } - - private function _getControlScriptPath($className) { - return Prado::getPathOfNamespace('Application.controls.scripts') - . DIRECTORY_SEPARATOR - . $className - . '.js'; - } - - private function _getControlStylePath($className) { - return Prado::getPathOfNamespace('Application.controls.styles') - . DIRECTORY_SEPARATOR - . $className - . '.css'; - } - - private function _getLibPath($identifier, $extension = '') { - return Prado::getPathOfNamespace('Lib') - . DIRECTORY_SEPARATOR - . $identifier - . $extension; - } - - private function _registerScriptFile($scriptFile) { - $this->_registerExternalScriptDependencies( - $this->getExternalScriptDependencies() - ); - $this->_registerLibScriptDependencies( - $this->getLibScriptDependencies() - ); - $this->_registerPradoScriptDependencies( - $this->getPradoScriptDependencies() - ); - $this->_registerControlScriptDependencies( - $this->getControlScriptDependencies() - ); - $this->Page->ClientScript->registerScriptFile( - 'TemplateControl.' . get_class($this), - $this->Application->AssetManager->publishFilePath($scriptFile) - ); - } - - private function _registerExternalScriptDependencies(array $dependencies) { - foreach ($dependencies as $dependency) { - $this->Page->ClientScript->registerHeadScriptFile( - $dependency, $dependency - ); - } - } - - private function _registerLibScriptDependencies(array $dependencies) { - foreach ($dependencies as $dependency) { - $this->Page->ClientScript->registerScriptFile( - 'LibScript.' . $dependency, - $this->Application->AssetManager->publishFilePath( - $this->_getLibPath($dependency, '.js') - ) - ); - } - } - - private function _registerPradoScriptDependencies(array $dependencies) { - foreach ($dependencies as $dependency) { - $this->Page->ClientScript->registerPradoScript($dependency); - } - } - - private function _registerControlScriptDependencies(array $dependencies) { - foreach ($dependencies as $dependency) { - $this->Page->ClientScript->registerScriptFile( - 'TemplateControl.' . $dependency, - $this->Application->AssetManager->publishFilePath( - $this->_getControlScriptPath($dependency) - ) - ); - } - } - - private function _registerStyleFile($styleFile) { - $this->_registerExternalStyleDependencies( - $this->getExternalStyleDependencies() - ); - $this->_registerLibStyleDependencies( - $this->getLibStyleDependencies() - ); - $this->_registerControlStyleDependencies( - $this->getControlStyleDependencies() - ); - if (method_exists($this->Page->ClientScript, 'registerThemeStyleSheetFile')) { - $this->Page->ClientScript->registerThemeStyleSheetFile( - 'TemplateControl.' . get_class($this), - $this->Application->AssetManager->publishFilePath($styleFile) - ); - } else { - $this->Page->ClientScript->registerStyleSheetFile( - 'TemplateControl.' . get_class($this), - $this->Application->AssetManager->publishFilePath($styleFile) - ); - } - } - - private function _registerExternalStyleDependencies(array $dependencies) { - foreach ($dependencies as $dependency) { - $this->Page->ClientScript->registerStyleSheetFile( - $dependency, $dependency - ); - } - } - - private function _registerLibStyleDependencies(array $dependencies) { - foreach ($dependencies as $dependency) { - $this->Page->ClientScript->registerStyleSheetFile( - 'LibStyle.' . $dependency, - $this->Application->AssetManager->publishFilePath( - $this->_getLibPath($dependency, '.css') - ) - ); - } - } - - private function _registerControlStyleDependencies(array $dependencies) { - foreach ($dependencies as $dependency) { - $this->Page->ClientScript->registerStyleSheetFile( - 'TemplateControl.' . $dependency, - $this->Application->AssetManager->publishFilePath( - $this->_getControlStylePath($dependency) - ) - ); - } - } - -} - -?> diff --git a/app/php/web/ThemeManager.php b/app/php/web/ThemeManager.php deleted file mode 100644 index 9dcae76..0000000 --- a/app/php/web/ThemeManager.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php - -Prado::using('Application.web.BaseUrlDerivedFromBasePath'); - -class ThemeManager extends TThemeManager { - - use BaseUrlDerivedFromBasePath; - -} - -?> diff --git a/app/php/web/config.xml b/app/php/web/config.xml deleted file mode 100644 index 49bbcc6..0000000 --- a/app/php/web/config.xml +++ /dev/null @@ -1,7 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<configuration> - <modules> - <module id="asset" class="Application.web.AssetManager" - BasePath="Web._assets" /> - </modules> -</configuration> |