/** * Remove trailing slashes from URL * * @param string $url URL to prepare * * @return string */ public static function trimTrailingSlashes($url) { return \Includes\Utils\Converter::trimTrailingChars($url, '/'); }
/** * Prepare file path * * @param string $dir Dir to prepare * @param boolean $check Flag OPTIONAL * * @return string */ public static function getCanonicalDir($dir, $check = true) { if ($check) { $dir = static::getRealPath($dir); } if (!$check || !empty($dir) && static::isDir($dir)) { $dir = \Includes\Utils\Converter::trimTrailingChars($dir, LC_DS) . LC_DS; } return $dir ?: null; }
/** * Get enpoint URL for certain action * * @param string $action Action name * * @return string */ protected function getMarketplaceActionURL($action) { return \Includes\Utils\Converter::trimTrailingChars($this->getMarketplaceURL(), '/') . '/' . $action; }
/** * Get purchase page URL * * :FIXME: is it really needed? * * @return string */ protected function getPurchaseURL() { $apiURL = trim(\Includes\Utils\Converter::trimTrailingChars(\XLite\Core\Marketplace::getInstance()->getMarketplaceURL(), '/')); // Remove 'api' directory $apiURL = preg_replace('/\\?q=.+/Ss', '', $apiURL); $apiURL = preg_replace('/\\/api$/Ss', '/', $apiURL); return $apiURL; }