예제 #1
0
 public function __construct(Gpf_DateTime $from, Gpf_DateTime $to, $timeGroupBy)
 {
     $dateCurrent = clone $from->getClientTime();
     if ($timeGroupBy == Gpf_Common_DateUtils::DAY) {
         $this->makeDayLabels($dateCurrent, $to->getClientTime());
         return;
     } else {
         if ($timeGroupBy == Gpf_Common_DateUtils::MONTH) {
             $this->makeMonthLabels($dateCurrent, $to->getClientTime());
             return;
         }
     }
     $this->makeWeekLabels($dateCurrent, $to->getClientTime());
 }
 protected function checkDates(Pap_Db_BannerInRotator $banner){
     $from = $this->form->getFieldValue(Pap_Db_Table_BannersInRotators::VALID_FROM);
     $to = $this->form->getFieldValue(Pap_Db_Table_BannersInRotators::VALID_UNTIL);
     
     
     if ($from == null && $to == null) {
         throw(new Gpf_Exception($this->_("Rotator banner can not contain same banner twice")));
     }
             
     $fromDb = $banner->getValidFrom();
     $toDb = $banner->getValidUntil();
     
     if ($fromDb == null && $toDb == null) {
         throw(new Gpf_Exception($this->_("Rotator banner can not contain same banner twice")));
     }
     
     $dateFrom = new Gpf_DateTime($fromDb);
     $dateFrom->getClientTime()->toDateTime();
     
     $dateUntil = new Gpf_DateTime($toDb);
     $dateUntil->getClientTime()->toDateTime();
     
     $errorMsg = "Date is coliding with other date: ".$dateFrom->getClientTime()->toDateTime()." -> ".$dateUntil->getClientTime()->toDateTime();
     
     if ($from == null && $to != null){
         if ($to < $fromDb) {
             return;
         }
         throw(new Gpf_Exception($this->_($errorMsg)));
     }
     
     if ($from != null && $to == null){
         if ($from > $toDb) {
             return;
         }
         throw(new Gpf_Exception($this->_($errorMsg)));
     }
     
     if ($fromDb == null && $toDb != null){
         if ($from > $toDb) {
             return;
         }
         throw(new Gpf_Exception($this->_($errorMsg)));
     }
     
     if ($fromDb != null && $toDb == null){
         if ($to < $fromDb) {
             return;
         }
         throw(new Gpf_Exception($this->_($errorMsg)));
     }
     
     if (($from < $fromDb && $to < $fromDb) || ($from > $toDb && $to > $toDb)) {
         return;
     }
     throw(new Gpf_Exception($this->_($errorMsg)));
 }