本文整理汇总了PHP中Piwik_Common::getPathAndQueryFromUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::getPathAndQueryFromUrl方法的具体用法?PHP Piwik_Common::getPathAndQueryFromUrl怎么用?PHP Piwik_Common::getPathAndQueryFromUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::getPathAndQueryFromUrl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Piwik_getPathFromUrl
function Piwik_getPathFromUrl($url)
{
$path = Piwik_Common::getPathAndQueryFromUrl($url);
if (empty($path)) {
return 'index';
}
return $path;
}
示例2: generateInfo
/**
* Generates the name of the action from the URL or the specified name.
* Sets the name as $this->finalActionName
*
* @return void
*/
private function generateInfo()
{
$actionName = '';
if (!empty($this->downloadUrl)) {
$this->actionType = self::TYPE_DOWNLOAD;
$url = $this->downloadUrl;
//$actionName = $this->nameDownloadOutlink;
$actionName = $url;
} elseif (!empty($this->outlinkUrl)) {
$this->actionType = self::TYPE_OUTLINK;
$url = $this->outlinkUrl;
//remove the last '/' character if it's present
if (substr($url, -1) == '/') {
$url = substr($url, 0, -1);
}
$actionName = $this->nameDownloadOutlink;
if (empty($actionName)) {
$actionName = $url;
}
} else {
$this->actionType = self::TYPE_ACTION;
$url = $this->url;
$actionName = $this->actionName;
}
// the ActionName wasn't specified
if (empty($actionName)) {
$actionName = trim(Piwik_Common::getPathAndQueryFromUrl($url));
// in case the $actionName is ending with a slash,
// which means that it is the index page of a category
// we append the defaultActionName
// toto/tata/ becomes toto/tata/index
if (strlen($actionName) > 0 && $actionName[strlen($actionName) - 1] == '/') {
$actionName .= $this->defaultActionName;
}
}
/*
* Clean the action name
*/
// get the delimiter, by default '/'
$actionCategoryDelimiter = Piwik_LogStats_Config::getInstance()->General['action_category_delimiter'];
// case the name is an URL we dont clean the name the same way
if (Piwik_Common::isLookLikeUrl($actionName)) {
$actionName = trim($actionName);
} else {
// create an array of the categories delimited by the delimiter
$split = explode($actionCategoryDelimiter, $actionName);
// trim every category
$split = array_map('trim', $split);
// remove empty categories
$split = array_filter($split);
// rebuild the name from the array of cleaned categories
$actionName = implode($actionCategoryDelimiter, $split);
}
// remove the extra bad characters if any (shouldn't be any at this point...)
$actionName = str_replace(array("\n", "\r"), '', $actionName);
if (empty($actionName)) {
$actionName = $this->defaultActionName;
}
$this->finalActionName = $actionName;
}
示例3: extractUrlAndActionNameFromRequest
/**
* Generates the name of the action from the URL or the specified name.
* Sets the name as $this->actionName
*
* @return void
*/
protected function extractUrlAndActionNameFromRequest()
{
// download?
$downloadVariableName = Piwik_Tracker_Config::getInstance()->Tracker['download_url_var_name'];
$downloadUrl = Piwik_Common::getRequestVar($downloadVariableName, '', 'string', $this->request);
if (!empty($downloadUrl)) {
$actionType = self::TYPE_DOWNLOAD;
$url = $downloadUrl;
}
// outlink?
if (empty($actionType)) {
$outlinkVariableName = Piwik_Tracker_Config::getInstance()->Tracker['outlink_url_var_name'];
$outlinkUrl = Piwik_Common::getRequestVar($outlinkVariableName, '', 'string', $this->request);
if (!empty($outlinkUrl)) {
$actionType = self::TYPE_OUTLINK;
$url = $outlinkUrl;
}
}
// defaults to page view
if (empty($actionType)) {
$actionType = self::TYPE_ACTION;
$url = Piwik_Common::getRequestVar('url', '', 'string', $this->request);
$actionName = Piwik_Common::getRequestVar('action_name', '', 'string', $this->request);
if (empty($actionName)) {
$cleanedUrl = str_replace(array("\n", "\r", "\t"), "", $url);
$actionName = Piwik_Common::getPathAndQueryFromUrl($cleanedUrl);
// in case the $actionName is empty or ending with a slash,
// we append the defaultActionName: a/b/ becomes a/b/index
if (empty($actionName) || substr($actionName, -1) == '/') {
$actionName .= $this->getDefaultActionName();
}
}
// get the delimiter, by default '/'
$actionCategoryDelimiter = Piwik_Tracker_Config::getInstance()->General['action_category_delimiter'];
// create an array of the categories delimited by the delimiter
$split = explode($actionCategoryDelimiter, $actionName);
// trim every category
$split = array_map('trim', $split);
// remove empty categories
$split = array_filter($split, 'strlen');
// rebuild the name from the array of cleaned categories
$actionName = implode($actionCategoryDelimiter, $split);
}
$url = trim($url);
$url = str_replace(array("\n", "\r"), "", $url);
if (empty($actionName)) {
$actionName = $url;
}
return array('name' => $actionName, 'type' => $actionType, 'url' => $url);
}
示例4: testGetPathAndQueryFromUrl
/**
* @group Core
* @group Common
* @group getPathAndQueryFromUrl
*/
public function testGetPathAndQueryFromUrl()
{
$this->assertEquals('test/index.php?module=CoreHome', Piwik_Common::getPathAndQueryFromUrl('http://piwik.org/test/index.php?module=CoreHome'));
}