/** * @param $id * @param string $mode * @throws CHttpException */ public function actionShowMap($id, $mode = 'map') { $this->layout = '//layouts/popup-iframe'; $localEvent = $this->loadModel($id); if (!$localEvent->address->latitude || !$localEvent->address->longitude) { throw new CHttpException(404, 'Event map not defined'); } $criteria = new CDbCriteria(); // $criteria->condition = "dateTo >= '" . date("Y-m-d") . "' OR (dateTo is NULL AND dateFrom >= '" . date("Y-m-d") . "')"; $criteria->order = 'dateFrom'; $criteria->scopes = ['onlyActive', 'published']; $localEvents = LocalEvent::model()->findAll($criteria); $properties = Deal::model()->publicAvailable()->notUnderTheRadar()->with('property')->findAll(); $this->render("//MapView/default", array('id' => $id, 'latitude' => $localEvent->address->latitude, 'longitude' => $localEvent->address->longitude, 'type' => 'localEvent', 'mode' => $mode, 'mapDim' => ['w' => '80%', 'h' => ''], 'properties' => $properties, 'localEvents' => $localEvents, 'nearestTransport' => true)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = LocalEvent::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }