Example #1
0
 /**
  * Dispatches a new event to all configured listeners
  *
  * @param string|CakeEvent $event the event key name or instance of CakeEvent
  * @return void
  */
 public function dispatch($event)
 {
     if (is_string($event)) {
         $event = new LocalEvent($event);
     }
     if (empty($this->_listeners[$event->name()])) {
         return;
     }
     foreach ($this->listeners($event->name()) as $listener) {
         if ($event->isStopped()) {
             break;
         }
         $result = call_user_func($listener['callable'], $event);
         if ($result === false) {
             $event->stopPropagation();
         }
         if ($result !== null) {
             $event->result = $result;
         }
         continue;
     }
 }
 /**
  * @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;
 }