本文整理汇总了PHP中TikiLib::unparse_url方法的典型用法代码示例。如果您正苦于以下问题:PHP TikiLib::unparse_url方法的具体用法?PHP TikiLib::unparse_url怎么用?PHP TikiLib::unparse_url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TikiLib
的用法示例。
在下文中一共展示了TikiLib::unparse_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wikiplugin_piwik
function wikiplugin_piwik($data, $params)
{
global $prefs;
$plugininfo = wikiplugin_piwik_info();
$default = array();
foreach ($plugininfo['params'] as $key => $param) {
$default["{$key}"] = $param['default'];
}
$params = array_merge($default, $params);
if (empty($params['piwikserverurl'])) {
$params['piwikserverurl'] = $prefs['site_piwik_analytics_server_url'];
}
if (empty($params['piwikserverurl'])) {
return tra('Plugin Piwik error:') . ' ' . tra('Piwik server url is required.');
}
if (empty($params['idSite'])) {
$params['idSite'] = $prefs['site_piwik_site_id'];
}
if (empty($params['idSite'])) {
return tra('Plugin Piwik error:') . ' ' . tra('Site Id is required.');
}
if (empty($params['moduleToWidgetize'])) {
return tra('Plugin Piwik error:') . ' ' . tra('moduleToWidgetize is required.');
} else {
$arr = explode(',', $params['moduleToWidgetize']);
$params['moduleToWidgetize'] = $arr[0];
$params['actionToWidgetize'] = $arr[1];
}
if ($params['period'] === 'range') {
if ($params['enddate']) {
$params['date'] .= ',' . $params['enddate'];
unset($params['enddate']);
} else {
return tra('Plugin Piwik error:') . ' ' . tra('Period set to range but no end date provided.');
}
}
// grab out the params that aren't going to be part of the url, they will be iframe attributes and start with an underscore
$attributes = '';
foreach ($params as $key => $value) {
if (strpos($key, '_') === 0) {
if ($value) {
$attributes .= ' ' . substr($key, 1) . '="' . $value . '"';
}
unset($params[$key]);
}
}
// parse the main url param and unset it
$url_parts = parse_url($params['piwikserverurl']);
unset($params['piwikserverurl']);
// add the fixed query params
$params['module'] = 'Widgetize';
$params['action'] = 'iframe';
$params['disableLink'] = 1;
$params['widget=1'] = 1;
// parse the query part of the url into an array
parse_str($url_parts['query'], $query);
// merge the params and the fixed ones
$query = array_merge($params, $query);
// convert back to a string and replace in the parts array
$url_parts['query'] = http_build_query($query, '', '&');
$url = TikiLib::unparse_url($url_parts);
$iframe = '<iframe src="' . $url . '" ' . $attributes . ' frameborder="0"></iframe>';
return $iframe;
}