本文整理匯總了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'));
}