/**
  * Return Link
  * 
  * @param string $rel
  * @param string $title
  * @param array $params
  * @return array
  */
 private function getLink($rel, $title, $params)
 {
     /*
      * Do not set count if equal to default limit
      */
     if (isset($params['count']) && $params['count'] === $this->context->dbDriver->resultsPerPage) {
         unset($params['count']);
     }
     return array('rel' => $rel, 'type' => RestoUtil::$contentTypes['json'], 'title' => $this->context->dictionary->translate($title), 'href' => RestoUtil::updateUrl($this->context->getUrl(false), $this->writeRequestParams(array_merge($this->context->query, $params))));
 }
Esempio n. 2
0
 /**
  * 
  * Update keywords - i.e. translate name and add url endpoint
  * 
  * @param array $keywords
  * @param RestoCollection $collection
  * 
  * @return array
  */
 private function correctKeywords($keywords, $collection)
 {
     if (!isset($keywords)) {
         return null;
     }
     $corrected = array();
     foreach ($keywords as $key => $value) {
         /*
          * Do not display landuse_details
          */
         if ($value['type'] === 'landuse_details') {
             continue;
         }
         /*
          * Clone keyword array
          */
         $corrected[$key] = $keywords[$key];
         /*
          * Value format is urlencode(json)
          */
         $corrected[$key]['name'] = trim($this->context->dictionary->getKeywordFromValue(isset($value['normalized']) ? $value['normalized'] : $value['name'], $value['type']));
         if (empty($corrected[$key]['name'])) {
             $corrected[$key]['name'] = ucwords($value['name']);
         }
         $corrected[$key]['href'] = RestoUtil::updateUrl($this->searchUrl, array($collection->model->searchFilters['language']['osKey'] => $this->context->dictionary->language, $collection->model->searchFilters['searchTerms']['osKey'] => count(explode(' ', $corrected[$key]['name'])) > 1 ? '"' . $corrected[$key]['name'] . '"' : $corrected[$key]['name']));
     }
     return $corrected;
 }