/** * Proxify WMS URL depending on user rights * * @param $properties * @param $user * @param $baseUrl * @return string relative path in the form of YYYYMMdd/thumbnail_filename with YYYYMMdd is the formated startDate parameter */ private function proxifyWMSUrl($properties, $user, $baseUrl) { if (!isset($properties['wms'])) { return null; } $wmsUrl = RestoUtil::restoUrl($baseUrl, '/collections/' . $properties['collection'] . '/' . $properties['identifier'] . '/wms') . '?'; if (isset($user->token)) { $wmsUrl .= '_bearer=' . $user->token . '&'; } $wmsUrl .= substr($properties['wms'], strpos($properties['wms'], '?') + 1); /* * If the feature has a license check authentication */ if (isset($properties['license']) && $properties['license'] != null) { /* * User is not authenticated * Returns wms url only if license has a 'public' view service */ if ($user->profile['userid'] === -1) { return $properties['license']['viewService'] === 'public' ? $wmsUrl : null; } } return $wmsUrl; }
/** * Return template url for format * * @param string $format * @return string */ private function getUrlTemplate($format) { /* * HTML output is based on htmlEndpoint */ $url = ($format === 'html' ? $this->context->htmlSearchUrl : RestoUtil::restoUrl($this->context->baseUrl, '/api/collections' . (isset($this->collection) ? '/' . $this->collection->name : '') . '/search', $format)) . '?' . $this->clientId; $count = 0; foreach ($this->model->searchFilters as $filterName => $filter) { if (isset($filter)) { if ($format === 'html' && (!isset($filter['htmlFilter']) || $filter['htmlFilter'] === false)) { continue; } $optional = isset($filter['minimum']) && $filter['minimum'] === 1 ? '' : '?'; $url .= ($count > 0 ? '&' : '') . $filter['osKey'] . '={' . $filterName . $optional . '}'; $count++; } } return $url; }
/** * Return collection url * * @param string $format : output format for url */ public function getUrl($format = '') { return RestoUtil::restoUrl($this->context->baseUrl, '/collections/' . $this->name, $format); }