/** * @param RokUpdater_Uri $uri * @param array $components * @param bool $esc * * @return string */ private static function getRelativeComponents(RokUpdater_Uri $uri, $components, $esc) { $result = ''; if ($components & RokUpdater_Uri_Components::PATH) { $cmp = $uri->getPath(); $result .= '/'; if ($esc) { foreach (explode('/', $cmp) as $key => $value) { $result .= ($key === 0 ? '' : '/') . rawurlencode($value); } } else { $result .= $cmp; } } if ($components & RokUpdater_Uri_Components::QUERY) { $cmp = $uri->getQuery(); if (!empty($cmp)) { if ($esc) { parse_str($cmp, $cmp); $result .= '?' . str_replace('+', '%20', http_build_query($cmp, null, '&')); } else { $result .= "?{$cmp}"; } } } //FRAGMENT: if ($components & RokUpdater_Uri_Components::FRAGMENT) { $cmp = $uri->getFragment(); if (!empty($cmp)) { if ($esc) { $result .= '#' . rawurlencode($cmp); } else { $result .= "#{$cmp}"; } } } // RESULT: return $result; }