예제 #1
0
파일: Search.php 프로젝트: arbi/MyCode
 /**
  *
  * @param array $data
  * @return array
  */
 public function getFixedDate($data)
 {
     $currentDate = date('Y-m-d');
     $cityDao = new City($this->getServiceLocator(), 'ArrayObject');
     if (isset($data['city']) && ClassicValidator::checkCityName($data['city'])) {
         $cityResp = $cityDao->getCityBySlug($data['city']);
         if ($cityResp) {
             $diffHousr = $this->getDiffHoursForDate();
             $currentDate = Helper::getCurrenctDateByTimezone($cityResp['timezone'], 'd-m-Y', $diffHousr);
         }
     }
     $arrival = isset($data['arrival']) && $data['arrival'] && ClassicValidator::validateDate($data['arrival']) ? date('Y-m-d', strtotime($data['arrival'])) : '';
     $departure = isset($data['departure']) && $data['departure'] && ClassicValidator::validateDate($data['departure']) ? date('Y-m-d', strtotime($data['departure'])) : '';
     if ($arrival && $departure && strtotime($arrival) > strtotime($departure)) {
         $arrival = $departure = '';
     } elseif ($arrival && strtotime($currentDate) > strtotime($arrival) || $departure && strtotime($currentDate) > strtotime($departure)) {
         $arrival = $departure = '';
     } elseif (!$arrival && $departure) {
         $departure = '';
     } elseif ($arrival && !$departure) {
         $departure = date('Y-m-d', strtotime($arrival . '+1 day'));
     }
     return ['arrival' => $arrival, 'departure' => $departure];
 }
예제 #2
0
파일: Apartment.php 프로젝트: arbi/MyCode
 /**
  * @param array $data
  * @return string
  */
 public function filterQueryData($data)
 {
     $currentDate = date('Y-m-d');
     $cityDao = new City($this->getServiceLocator(), 'ArrayObject');
     if (!isset($data['city'])) {
         $pageSlugExp = explode('--', $data['slug']);
         $citySlug = $pageSlugExp[1];
     } else {
         $citySlug = $data['city'];
     }
     if (isset($citySlug) && ClassicValidator::checkCityName($citySlug)) {
         $cityResp = $cityDao->getCityBySlug(Helper::urlForSearch($citySlug, TRUE));
         if ($cityResp) {
             /* @var $websiteSearchService \DDD\Service\Website\Search */
             $websiteSearchService = $this->getServiceLocator()->get('service_website_search');
             $diffHours = $websiteSearchService->getDiffHoursForDate();
             $currentDate = Helper::getCurrenctDateByTimezone($cityResp['timezone'], 'd-m-Y', $diffHours);
         }
     }
     if (!isset($data['arrival']) || !ClassicValidator::validateDate($data['arrival']) || !isset($data['departure']) || !ClassicValidator::validateDate($data['departure']) || strtotime($data['arrival']) < strtotime($currentDate) || strtotime($data['arrival']) >= strtotime($data['departure'])) {
         return false;
     }
     return true;
 }