本文整理汇总了PHP中Piwik\Site::getMainUrlFor方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::getMainUrlFor方法的具体用法?PHP Site::getMainUrlFor怎么用?PHP Site::getMainUrlFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Site
的用法示例。
在下文中一共展示了Site::getMainUrlFor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatQueryLabelForDisplay
private function formatQueryLabelForDisplay($idSite, $apiModule, $apiAction, $label)
{
// rows with subtables do not contain URL metadata. this hack makes sure the label titles in row
// evolution popovers look like URLs.
if ($apiModule == 'Actions' && in_array($apiAction, self::$actionsUrlReports)) {
$mainUrl = Site::getMainUrlFor($idSite);
$mainUrlHost = @parse_url($mainUrl, PHP_URL_HOST);
$replaceRegex = "/\\s*" . preg_quote(LabelFilter::SEPARATOR_RECURSIVE_LABEL) . "\\s*/";
$cleanLabel = preg_replace($replaceRegex, '/', $label);
return $mainUrlHost . '/' . $cleanLabel . '/';
} else {
return str_replace(LabelFilter::SEPARATOR_RECURSIVE_LABEL, ' - ', $label);
}
}
示例2: trackingCodeGenerator
/**
* Renders and echo's an admin page that lets users generate custom JavaScript
* tracking code and custom image tracker links.
*/
public function trackingCodeGenerator()
{
$view = new View('@CoreAdminHome/trackingCodeGenerator');
$this->setBasicVariablesView($view);
$view->topMenu = MenuTop::getInstance()->getMenu();
$view->userMenu = MenuUser::getInstance()->getMenu();
$viewableIdSites = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
$defaultIdSite = reset($viewableIdSites);
$view->idSite = Common::getRequestVar('idSite', $defaultIdSite, 'int');
$view->defaultReportSiteName = Site::getNameFor($view->idSite);
$view->defaultSiteRevenue = \Piwik\MetricsFormatter::getCurrencySymbol($view->idSite);
$view->maxCustomVariables = CustomVariables::getMaxCustomVariables();
$allUrls = APISitesManager::getInstance()->getSiteUrlsFromId($view->idSite);
if (isset($allUrls[1])) {
$aliasUrl = $allUrls[1];
} else {
$aliasUrl = 'x.domain.com';
}
$view->defaultReportSiteAlias = $aliasUrl;
$mainUrl = Site::getMainUrlFor($view->idSite);
$view->defaultReportSiteDomain = @parse_url($mainUrl, PHP_URL_HOST);
// get currencies for each viewable site
$view->currencySymbols = APISitesManager::getInstance()->getCurrencySymbols();
$view->serverSideDoNotTrackEnabled = \Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker::isActive();
return $view->render();
}
示例3: enrichValues
private function enrichValues($sites)
{
foreach ($sites as &$site) {
if (!isset($site['idsite'])) {
continue;
}
$site['main_url'] = Site::getMainUrlFor($site['idsite']);
$this->formatMetrics($site);
}
return $sites;
}
示例4: enrichValues
private function enrichValues($sites)
{
$formatter = new Formatter();
foreach ($sites as &$site) {
if (!isset($site['idsite'])) {
continue;
}
if (isset($site['revenue'])) {
$site['revenue'] = $formatter->getPrettyMoney($site['revenue'], $site['idsite']);
}
$site['main_url'] = Site::getMainUrlFor($site['idsite']);
}
return $sites;
}
示例5: getSitesInfo
public function getSitesInfo($isWidgetized = false)
{
Piwik::checkUserHasSomeViewAccess();
$displayRevenueColumn = Common::isGoalPluginEnabled();
$date = Common::getRequestVar('date', 'today');
$period = Common::getRequestVar('period', 'day');
$siteIds = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
list($minDate, $maxDate) = Site::getMinMaxDateAcrossWebsites($siteIds);
// overwrites the default Date set in the parent controller
// Instead of the default current website's local date,
// we set "today" or "yesterday" based on the default Piwik timezone
$piwikDefaultTimezone = APISitesManager::getInstance()->getDefaultTimezone();
if ($period != 'range') {
$date = $this->getDateParameterInTimezone($date, $piwikDefaultTimezone);
$this->setDate($date);
$date = $date->toString();
}
$dataTable = APIMultiSites::getInstance()->getAll($period, $date, $segment = false);
// put data into a form the template will understand better
$digestableData = array();
foreach ($siteIds as $idSite) {
$isEcommerceEnabled = Site::isEcommerceEnabledFor($idSite);
$digestableData[$idSite] = array('idsite' => $idSite, 'main_url' => Site::getMainUrlFor($idSite), 'name' => Site::getNameFor($idSite), 'visits' => 0, 'pageviews' => 0);
if ($period != 'range') {
$digestableData[$idSite]['visits_evolution'] = 0;
$digestableData[$idSite]['pageviews_evolution'] = 0;
}
if ($displayRevenueColumn) {
$revenueDefault = $isEcommerceEnabled ? 0 : "'-'";
if ($period != 'range') {
$digestableData[$idSite]['revenue_evolution'] = $revenueDefault;
}
}
}
foreach ($dataTable->getRows() as $row) {
$idsite = (int) $row->getMetadata('idsite');
$site =& $digestableData[$idsite];
$site['visits'] = (int) $row->getColumn('nb_visits');
$site['pageviews'] = (int) $row->getColumn('nb_pageviews');
if ($displayRevenueColumn) {
if ($row->getColumn('revenue') !== false) {
$site['revenue'] = $row->getColumn('revenue');
}
}
if ($period != 'range') {
$site['visits_evolution'] = $row->getColumn('visits_evolution');
$site['pageviews_evolution'] = $row->getColumn('pageviews_evolution');
if ($displayRevenueColumn) {
$site['revenue_evolution'] = $row->getColumn('revenue_evolution');
}
}
}
$this->applyPrettyMoney($digestableData);
$view = new View("@MultiSites/getSitesInfo");
$view->isWidgetized = $isWidgetized;
$view->sitesData = array_values($digestableData);
$view->evolutionBy = $this->evolutionBy;
$view->period = $period;
$view->page = $this->page;
$view->limit = $this->limit;
$view->orderBy = $this->orderBy;
$view->order = $this->order;
$view->totalVisits = $dataTable->getMetadata('total_nb_visits');
$view->totalRevenue = $dataTable->getMetadata('total_revenue');
$view->displayRevenueColumn = $displayRevenueColumn;
$view->totalPageviews = $dataTable->getMetadata('total_nb_pageviews');
$view->pastTotalVisits = $dataTable->getMetadata('last_period_total_nb_visits');
$view->totalVisitsEvolution = $dataTable->getMetadata('total_visits_evolution');
if ($view->totalVisitsEvolution > 0) {
$view->totalVisitsEvolution = '+' . $view->totalVisitsEvolution;
}
if ($period != 'range') {
$lastPeriod = Period::factory($period, $dataTable->getMetadata('last_period_date'));
$view->pastPeriodPretty = self::getCalendarPrettyDate($lastPeriod);
}
$params = $this->getGraphParamsModified();
$view->dateSparkline = $period == 'range' ? $date : $params['date'];
$view->autoRefreshTodayReport = false;
// if the current date is today, or yesterday,
// in case the website is set to UTC-12), or today in UTC+14, we refresh the page every 5min
if (in_array($date, array('today', date('Y-m-d'), 'yesterday', Date::factory('yesterday')->toString('Y-m-d'), Date::factory('now', 'UTC+14')->toString('Y-m-d')))) {
$view->autoRefreshTodayReport = Config::getInstance()->General['multisites_refresh_after_seconds'];
}
$this->setGeneralVariablesView($view);
$this->setMinDateView($minDate, $view);
$this->setMaxDateView($maxDate, $view);
$view->show_sparklines = Config::getInstance()->General['show_multisites_sparklines'];
return $view->render();
}
示例6: setSiteAliasUrls
/**
* Set the list of alias Urls for the given idSite
*
* Completely overwrites the current list of URLs with the provided list.
* The 'main_url' of the website won't be affected by this method.
*
* @return int the number of inserted URLs
*/
public function setSiteAliasUrls($idSite, $urls = array())
{
Piwik::checkUserHasAdminAccess($idSite);
$mainUrl = Site::getMainUrlFor($idSite);
array_unshift($urls, $mainUrl);
$urlsProperty = new Urls($idSite);
$urlsProperty->setValue($urls);
$urlsProperty->save();
$inserted = array_diff($urlsProperty->getValue(), $urls);
$this->postUpdateWebsite($idSite);
return count($inserted);
}
示例7: trackingCodeGenerator
/**
* Renders and echo's an admin page that lets users generate custom JavaScript
* tracking code and custom image tracker links.
*/
public function trackingCodeGenerator()
{
Piwik::checkUserHasSomeViewAccess();
$view = new View('@CoreAdminHome/trackingCodeGenerator');
$this->setBasicVariablesView($view);
$view->topMenu = MenuTop::getInstance()->getMenu();
$viewableIdSites = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
$defaultIdSite = reset($viewableIdSites);
$view->idSite = Common::getRequestVar('idSite', $defaultIdSite, 'int');
$view->defaultReportSiteName = Site::getNameFor($view->idSite);
$view->defaultSiteRevenue = Site::getCurrencySymbolFor($view->idSite);
$view->maxCustomVariables = CustomVariables::getNumUsableCustomVariables();
$view->defaultSite = array('id' => $view->idSite, 'name' => $view->defaultReportSiteName);
$allUrls = APISitesManager::getInstance()->getSiteUrlsFromId($view->idSite);
if (isset($allUrls[1])) {
$aliasUrl = $allUrls[1];
} else {
$aliasUrl = 'x.domain.com';
}
$view->defaultReportSiteAlias = $aliasUrl;
$mainUrl = Site::getMainUrlFor($view->idSite);
$view->defaultReportSiteDomain = @parse_url($mainUrl, PHP_URL_HOST);
$dntChecker = new DoNotTrackHeaderChecker();
$view->serverSideDoNotTrackEnabled = $dntChecker->isActive();
return $view->render();
}