public function assignDisplayVariables()
 {
     $display = CoreServices2::getDisplay();
     $modules = CoreServices2::getModules();
     $display->assign('controllerModule', $modules->getControllerModule());
     $display->assign('controllerMode', $modules->getControllerMode());
     $display->assign('url', CoreServices2::getUrl());
 }
 public function initSubpage()
 {
     $this->subpage = $this->subpageDAO->getRecordById(CoreServices2::getRequest()->getFromGet('id'));
     $modules = CoreServices2::getModules();
     if ($this->subpage['subpageModule'] != $modules->getControllerModule() || $this->subpage['subpageMode'] != $modules->getControllerMode() || $this->subpage['subpageState'] != 'visible') {
         $this->layout->handleInvalidAddress();
     }
 }
 protected function initBannerList()
 {
     // tworzymy nazwę modułu według której w configu będziemy odszukiwać ilość banerów do wyświetlenia
     $modules = CoreServices2::getModules();
     $subpageModuleAndMode = $modules->getControllerModule() . $modules->getControllerMode();
     $subpageBannerLocationsAndAmounts = CoreConfig::get('Data', 'subpageBannerLocationsAndAmounts');
     if (!empty($subpageBannerLocationsAndAmounts[$subpageModuleAndMode])) {
         // jeśli odnajdziemy w configu ustawienia specyficzne dla danej podstrony serwisu, to odczytujemy je
         $bannerAmount = $subpageBannerLocationsAndAmounts[$subpageModuleAndMode];
     } else {
         // w przeciwnym wypadku pobieramy ustawienia domyślne
         $bannerAmount = $subpageBannerLocationsAndAmounts['default'];
     }
     // Można tu zacząć tranzakcję b.d. ale jak baner się wyświetli raz za dużo
     // to nic się strasznego nie stanie - wydajność ważniejsza
     // pobieramy losową listę banerów pochodzących z aktywnych kampanii, indeksowanych według ich położeń
     $this->bannerList = $this->bannerDAO->getBannerListIndexedByLocation();
     $bannerList = array();
     // skracamy listę wylosowanych banerów do ilości potrzebnej w widoku (UWAGA, na niektórych pozycjach może nie być banerów)
     foreach ($bannerAmount as $bannerLocation => $bannerAmount) {
         if (!empty($this->bannerList[$bannerLocation])) {
             $bannerList[$bannerLocation] = array_slice($this->bannerList[$bannerLocation], 0, $bannerAmount);
         } else {
             $bannerList[$bannerLocation] = array();
         }
     }
     $this->bannerList = $bannerList;
     // pobieramy tablicę ID banerów
     $bannerIds = $this->getBannerIds();
     // pobieramy listę plików banerów
     $bannerImageList = $this->fileDAO->getListByRecordList('banner', $bannerIds, null, 'banner');
     $this->bannerImageList = array();
     foreach ($bannerImageList as $bannerId => $files) {
         $fileIds = array_keys($files);
         if (!empty($files[$fileIds[0]])) {
             $this->bannerImageList[$bannerId] = $files[$fileIds[0]];
         }
     }
     $this->updateBannerCampaigns();
 }