本文整理匯總了PHP中Cx\Core\Routing\Url::array2params方法的典型用法代碼示例。如果您正苦於以下問題:PHP Url::array2params方法的具體用法?PHP Url::array2params怎麽用?PHP Url::array2params使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cx\Core\Routing\Url
的用法示例。
在下文中一共展示了Url::array2params方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: appendParameters
/**
* Callback method for appending preview and appview parameter to href and action attributes.
*
* @access private
* @param array $matches regex matches
* @return string replacement string
*/
private function appendParameters($matches)
{
$before = $matches[1];
$quote = $matches[2];
$value = $matches[3];
$after = $matches[4];
if (strpos($value, '?') !== false) {
list($path, $query) = explode('?', $value);
$query = \Cx\Core\Routing\Url::params2array($query);
} else {
$path = $value;
$query = array();
}
$extension = pathinfo($path, PATHINFO_EXTENSION);
if (!empty($extension) && $extension != 'php') {
return $matches[0];
}
if (!empty($_GET['preview']) && !isset($query['preview'])) {
$query['preview'] = $_GET['preview'];
}
if (!empty($_GET['templateEditor']) && !isset($query['templateEditor'])) {
$query['templateEditor'] = $_GET['templateEditor'];
}
if (isset($_GET['appview']) && $_GET['appview'] == 1 && !isset($query['appview'])) {
$query['appview'] = $_GET['appview'];
}
$query = \Cx\Core\Routing\Url::array2params($query);
// replace & with & but only & (not followed by amp;)
$query = preg_replace('/&(?!amp;)/', '&', $query);
return $before . $quote . $path . '?' . $query . $quote . $after;
}