本文整理汇总了PHP中kString::getCommonPostfix方法的典型用法代码示例。如果您正苦于以下问题:PHP kString::getCommonPostfix方法的具体用法?PHP kString::getCommonPostfix怎么用?PHP kString::getCommonPostfix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kString
的用法示例。
在下文中一共展示了kString::getCommonPostfix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateMultiUrl
protected static function generateMultiUrl(array $flavors)
{
$urls = array();
foreach ($flavors as $flavor) {
$urls[] = $flavor['url'];
}
$urls = array_unique($urls);
if (count($urls) == 1) {
$baseUrl = reset($urls);
return '/' . ltrim($baseUrl, '/');
}
$prefix = kString::getCommonPrefix($urls);
$prefixLen = strlen($prefix);
$postfix = kString::getCommonPostfix($urls);
$postfixLen = strlen($postfix);
$middlePart = ',';
foreach ($urls as $url) {
$middlePart .= substr($url, $prefixLen, strlen($url) - $prefixLen - $postfixLen) . ',';
}
$baseUrl = $prefix . $middlePart . $postfix;
return '/' . ltrim($baseUrl, '/') . '.urlset';
}
示例2: generateMultiUrl
protected static function generateMultiUrl(array $flavors, entry $entry)
{
$urls = array();
foreach ($flavors as $flavor) {
$urls[] = $flavor['url'];
}
$urls = array_unique($urls);
if (count($urls) == 1) {
$baseUrl = reset($urls);
return '/' . ltrim($baseUrl, '/');
}
$prefix = kString::getCommonPrefix($urls);
$postfix = kString::getCommonPostfix($urls);
if ($entry->getType() == entryType::PLAYLIST) {
// in case of a playlist, need to merge the flavor params of the urls
// instead of using a urlset, since nginx-vod does not support urlsets of
// non-trivial mapping responses.
// so instead of building:
// /p/123/serveFlavor/entryId/0_abc/flavorParamIds/100,1,2,3,/forceproxy/true/name/a.mp4.urlset
// we build:
// /p/123/serveFlavor/entryId/0_abc/flavorParamIds/1001,1002,1003/forceproxy/true/name/a.mp4.urlset
$prefix = substr($prefix, 0, strrpos($prefix, '/') + 1);
$postfix = substr($postfix, strpos($postfix, '/'));
}
$prefixLen = strlen($prefix);
$postfixLen = strlen($postfix);
$middlePart = ',';
foreach ($urls as $url) {
$middlePart .= substr($url, $prefixLen, strlen($url) - $prefixLen - $postfixLen) . ',';
}
if ($entry->getType() == entryType::PLAYLIST && strpos($middlePart, '/') === false) {
$middlePart = rtrim(ltrim($middlePart, ','), ',');
$result = $prefix . $middlePart . $postfix;
} else {
$result = $prefix . $middlePart . $postfix . '.urlset';
}
return '/' . ltrim($result, '/');
}