예제 #1
0
 /**
  * Fetch the next set of results
  *
  * @return void
  */
 protected function fetchNext()
 {
     $this->query->setStart($this->start)->setRows($this->getPrefetch());
     $this->result = $this->client->execute($this->query, $this->getOption('endpoint'));
     $this->documents = $this->result->getDocuments();
     $this->start += $this->getPrefetch();
 }
예제 #2
0
 /**
  * @param \Solarium\QueryType\Select\Result\Result $ergebnisse
  * @return array();
  */
 public static function ergebnisse2FeedData($ergebnisse)
 {
     $data = array();
     $dokumente = $ergebnisse->getDocuments();
     $highlighting = $ergebnisse->getHighlighting();
     $purifier = new CHtmlPurifier();
     $purifier->options = array('URI.AllowedSchemes' => array('http' => true, 'https' => true));
     foreach ($dokumente as $dokument) {
         $model = Dokument::getDocumentBySolrId($dokument->id);
         $risitem = $model->getRISItem();
         if (!$risitem) {
             continue;
         }
         $link = $risitem->getLink();
         $highlightedDoc = $highlighting->getResult($dokument->id);
         $item = array("title" => $model->name . " (zu " . $risitem->getTypName() . " \"" . $risitem->getName() . "\"", "link" => $link, "content" => "", "dateCreated" => RISTools::date_iso2timestamp(str_replace("T", " ", str_replace("Z", "", $dokument->sort_datum))), "aenderung_guid" => $link);
         if ($highlightedDoc && count($highlightedDoc) > 0) {
             foreach ($highlightedDoc as $highlight) {
                 $item["content"] .= $purifier->purify(implode(' (...) ', $highlight)) . '<br/>';
             }
         }
         $data[] = $item;
     }
     return $data;
 }
 /**
  * @param RISSucheKrits $krits
  * @param \Solarium\QueryType\Select\Result\Result $ergebnisse
  * @return array
  */
 protected function getJSGeodata($krits, $ergebnisse)
 {
     $geo = $krits->getGeoKrit();
     /** @var RISSolrDocument[] $solr_dokumente */
     $solr_dokumente = $ergebnisse->getDocuments();
     $dokument_ids = [];
     foreach ($solr_dokumente as $dokument) {
         $x = explode(":", $dokument->id);
         $dokument_ids[] = IntVal($x[1]);
     }
     $geodata = [];
     if (count($dokument_ids) > 0) {
         $lat = FloatVal($geo["lat"]);
         $lng = FloatVal($geo["lng"]);
         $dist_field = "(((acos(sin(({$lat}*pi()/180)) * sin((lat*pi()/180))+cos(({$lat}*pi()/180)) * cos((lat*pi()/180)) * cos((({$lng}- lon)*pi()/180))))*180/pi())*60*1.1515*1.609344) <= " . FloatVal($geo["radius"] / 1000);
         $SQL = "select a.dokument_id, b.* FROM antraege_orte a JOIN orte_geo b ON a.ort_id = b.id WHERE a.dokument_id IN (" . implode(", ", $dokument_ids) . ") AND b.to_hide = 0 AND {$dist_field}";
         $result = Yii::app()->db->createCommand($SQL)->queryAll();
         foreach ($result as $geo) {
             /** @var Dokument $dokument */
             $dokument = Dokument::model()->findByPk($geo["dokument_id"]);
             if ($dokument->antrag) {
                 $link = $dokument->antrag->getLink();
                 $name = $dokument->antrag->getName();
             } elseif ($dokument->termin) {
                 $link = $dokument->termin->getLink();
                 $name = $dokument->termin->getName();
             } else {
                 $link = $name = "";
             }
             if (strlen($name) > 150) {
                 $name = mb_substr($name, 0, 148) . "...";
             }
             if ($link != "") {
                 $link = "<div class='antraglink'>" . CHtml::link($name, $link) . "</div>";
             }
             $str = $link;
             $str .= "<div class='ort_dokument'>";
             $str .= "<div class='ort'>" . CHtml::encode($geo["ort"]) . "</div>";
             $str .= "<div class='dokument'>" . CHtml::link($dokument->name, $this->createUrl("index/dokument", ["id" => $dokument->id])) . "</div>";
             $str .= "</div>";
             $geodata[] = [FloatVal($geo["lat"]), FloatVal($geo["lon"]), $str];
         }
     }
     return $geodata;
 }
예제 #4
0
 public function getIterator()
 {
     $this->execute();
     return new \ArrayIterator($this->selectResult->getDocuments());
 }