public function executeSave(sfWebRequest $request) { $items = $request->getParameter('events'); $config = $request->getParameter('config'); $place = PlaceTable::getInstance()->findOneById((int) $config['place_id']); $user = $this->getUser()->getGuardUser(); $this->events = array(); foreach ($items as $item) { $event = new Event(); $event->fromArray(array('icon' => $config['icon'], 'title' => $item['title'], 'description' => $item['description'], 'fire_at' => date('Y-m-d H:i:s', strtotime($item['fire_at'])), 'place_id' => (int) $config['place_id'], 'user_id' => $user->id, 'geo_lat' => $place->geo_lat, 'geo_lng' => $place->geo_lng)); $event->save(); $this->events[] = $event; } }
public function configure() { $importers = array(); foreach (sfConfig::get('app_import_sources') as $name => $import) { $importers[$name] = $import['name']; } $this->widgetSchema['importer'] = new sfWidgetFormChoice(array('choices' => $importers)); $this->validatorSchema['importer'] = new sfValidatorChoice(array('choices' => array_keys($importers))); $this->widgetSchema['place_id'] = new sfWidgetFormDoctrineChoice(array('model' => 'Place', 'query' => PlaceTable::getInstance()->createQuery('p')->orderBy('p.title'))); $this->validatorSchema['place_id'] = new sfValidatorDoctrineChoice(array('model' => 'Place')); $this->widgetSchema['icon'] = new myWidgetFormIcon(array('icons' => sfConfig::get('app_marker_icons'), 'path' => '/images/marker', 'target' => '#icon')); $this->validatorSchema['icon'] = new sfValidatorChoice(array('choices' => sfConfig::get('app_marker_icons'))); $this->widgetSchema->setNameFormat('import[%s]'); $this->disableLocalCSRFProtection(); }
/** * Добавить */ public function executeNew(sfWebRequest $request) { $user = $this->getUser()->getGuardUser(); $this->event = new Event(); $this->event->setUser($user); $this->event->setFireAt(date('Y-m-d H:i:s')); if ($request->hasParameter('place') && ($placeId = (int) $request->getParameter('place'))) { $this->place = PlaceTable::getInstance()->findOneById($placeId); $this->forward404Unless($this->place); $this->event->setPlace($this->place); $this->event->setGeoLat($this->place->getGeoLat()); $this->event->setGeoLng($this->place->getGeoLng()); } else { $this->event->setGeoLat($request->getParameter('geo_lat')); $this->event->setGeoLng($request->getParameter('geo_lng')); } $this->form = new EventForm($this->event); }
/** * Перестать следить */ public function executeUnfollow(sfWebRequest $request) { $place = $this->getRoute()->getObject(); $user = $this->getUser()->getGuardUser(); if ($accept = $place->hasFollower($user->id)) { $accept->delete(); } // обновить событие $place = PlaceTable::getInstance()->findOneById($place->id); if ($request->isXmlHttpRequest()) { return $this->renderPartial('place/show', array('place' => $place, 'move' => false)); } else { return $this->redirect('place_show', $place); } }
/** * Места */ public function executePlaces() { $places = PlaceTable::getInstance()->queryFeed()->limit(sfConfig::get('app_feeds_places_count', 30))->execute(array(), Doctrine::HYDRATE_ARRAY); $this->buildFeed($places, array('title' => 'Новые места | НеСкучайк!', 'permalink_url' => 'place_show')); }