Ejemplo n.º 1
0
 public function executeTooltipTest()
 {
     $bbox = $this->getRequestParameter('bbox');
     $layers = $this->getRequestParameter('layers');
     // TODO check params
     $this->nb_items = 0;
     foreach (explode(',', $layers) as $layer) {
         list($module, $model, $type_where) = self::_getTooltipParamFromLayer($layer);
         $where = gisQuery::getQueryByBbox($bbox, 'geom', $module);
         $q = Doctrine_Query::create()->from("{$model} m")->where('m.redirects_to IS NULL')->addWhere($where['where_string']);
         if ($type_where) {
             $q->addWhere($type_where);
         }
         //$this->nb_items += $q->count(); TODO is it quickier to use directly count?
         $results = $q->execute();
         $this->nb_items += count($results);
         // save information that can be useful in next steps
         if ($results->getFirst()) {
             $sav_model = $model;
             $sav_id = $results->getFirst()->getId();
         }
     }
     // if only one result, directly display its name
     if ($this->nb_items == 1) {
         // specific behaviour for users: we don't want to display user name if profile
         // is private and user is not connected
         if ($sav_model == 'User' && !$this->getUser()->isConnected() && !UserPrivateData::hasPublicProfile($sav_id)) {
             $this->name = $this->__('not available');
         } else {
             $langs = sfContext::getInstance()->getUser()->getPreferedLanguageList();
             $i18n = Doctrine_Query::create()->select('m.culture, m.name')->from("{$sav_model}I18n m")->where('m.id = ?', array($sav_id))->execute();
             $old_lang = 200;
             foreach ($i18n as $name) {
                 $lang_pos = array_search($name->get('culture'), $langs);
                 if ($lang_pos === false) {
                     $lang_pos = 10;
                 }
                 // test if language is prefered over the older
                 if ($lang_pos < $old_lang) {
                     $old_lang = $lang_pos;
                     $uname = $name->get('name');
                 }
             }
             $this->name = $uname;
         }
     }
     $this->setJsonResponse();
 }
Ejemplo n.º 2
0
 public function executePopup()
 {
     $id = $this->getRequestParameter('id');
     // if user is not connected, we don't want to display user's popup
     if (!$this->getUser()->isConnected() && !UserPrivateData::hasPublicProfile($id)) {
         $this->raw = $this->getRequestParameter('raw', false);
         if ($this->raw) {
             $this->setLayout(false);
         }
         // deactivate automatic inclusion of js and css files by symfony
         $response = $this->getResponse();
         $response->setParameter('javascripts_included', true, 'symfony/view/asset');
         $response->setParameter('stylesheets_included', true, 'symfony/view/asset');
         $this->setCacheControl();
         // we call users/popupError template
         return sfView::ERROR;
     } else {
         parent::executePopup();
     }
 }