本文整理汇总了PHP中Piwik\Site::getNameFor方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::getNameFor方法的具体用法?PHP Site::getNameFor怎么用?PHP Site::getNameFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Site
的用法示例。
在下文中一共展示了Site::getNameFor方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: configureTopMenu
public function configureTopMenu(MenuTop $menu)
{
$userPreferences = new UserPreferences();
$idSite = $userPreferences->getDefaultWebsiteId();
$tooltip = Piwik::translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite));
$urlParams = array('module' => 'CoreHome', 'action' => 'index', 'idSite' => $idSite);
$menu->add('Dashboard_Dashboard', null, $urlParams, true, 1, $tooltip);
}
示例2: configureTopMenu
public function configureTopMenu(MenuTop $menu)
{
$userPreferences = new UserPreferences();
$idSite = $userPreferences->getDefaultWebsiteId();
$tooltip = Piwik::translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite));
$urlParams = $this->urlForModuleActionWithDefaultUserParams('CoreHome', 'index');
$menu->addItem('Dashboard_Dashboard', null, $urlParams, 1, $tooltip);
}
示例3: configureTopMenu
public function configureTopMenu(MenuTop $menu)
{
$tooltip = false;
try {
$idSite = Common::getRequestVar('idSite');
$tooltip = Piwik::translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite));
} catch (Exception $ex) {
// if no idSite parameter, show no tooltip
}
$urlParams = array('module' => 'CoreHome', 'action' => 'index');
$menu->add('Dashboard_Dashboard', null, $urlParams, true, 1, $tooltip);
}
示例4: 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();
}
示例5: userSettings
/**
* The "User Settings" admin UI screen view
*/
public function userSettings()
{
Piwik::checkUserIsNotAnonymous();
$view = new View('@UsersManager/userSettings');
$userLogin = Piwik::getCurrentUserLogin();
$user = APIUsersManager::getInstance()->getUser($userLogin);
$view->userAlias = $user['alias'];
$view->userEmail = $user['email'];
$view->ignoreSalt = $this->getIgnoreCookieSalt();
$userPreferences = new UserPreferences();
$defaultReport = $userPreferences->getDefaultReport();
if ($defaultReport === false) {
$defaultReport = $userPreferences->getDefaultWebsiteId();
}
$view->defaultReport = $defaultReport;
if ($defaultReport == 'MultiSites') {
$defaultSiteId = $userPreferences->getDefaultWebsiteId();
$view->defaultReportIdSite = $defaultSiteId;
$view->defaultReportSiteName = Site::getNameFor($defaultSiteId);
} else {
$view->defaultReportIdSite = $defaultReport;
$view->defaultReportSiteName = Site::getNameFor($defaultReport);
}
$view->defaultDate = $this->getDefaultDateForUser($userLogin);
$view->availableDefaultDates = $this->getDefaultDates();
$view->languages = APILanguagesManager::getInstance()->getAvailableLanguageNames();
$view->currentLanguageCode = LanguagesManager::getLanguageCodeForCurrentUser();
$view->ignoreCookieSet = IgnoreCookie::isIgnoreCookieFound();
$view->piwikHost = Url::getCurrentHost();
$this->setBasicVariablesView($view);
return $view->render();
}
示例6: findSiteName
private function findSiteName($alert)
{
$idSite = $this->findSiteId($alert);
if (!empty($idSite)) {
return Site::getNameFor($idSite);
}
}
示例7: 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();
}
示例8: generateReport
//.........这里部分代码省略.........
foreach ($reportMetadata as $action) {
$apiModule = $action['module'];
$apiAction = $action['action'];
$apiParameters = array();
if (isset($action['parameters'])) {
$apiParameters = $action['parameters'];
}
$mustRestoreGET = false;
// all Websites dashboard should not be truncated in the report
if ($apiModule == 'MultiSites') {
$mustRestoreGET = $_GET;
$_GET['enhanced'] = true;
if ($apiAction == 'getAll') {
$_GET['filter_truncate'] = false;
// when a view/admin user created a report, workaround the fact that "Super User"
// is enforced in Scheduled tasks, and ensure Multisites.getAll only return the websites that this user can access
$userLogin = $report['login'];
if (!empty($userLogin) && !Piwik::hasTheUserSuperUserAccess($userLogin)) {
$_GET['_restrictSitesToLogin'] = $userLogin;
}
}
}
$processedReport = \Piwik\Plugins\API\API::getInstance()->getProcessedReport($idSite, $period, $date, $apiModule, $apiAction, $segment != null ? urlencode($segment['definition']) : false, $apiParameters, $idGoal = false, $language);
$processedReport['segment'] = $segment;
// TODO add static method getPrettyDate($period, $date) in Period
$prettyDate = $processedReport['prettyDate'];
if ($mustRestoreGET) {
$_GET = $mustRestoreGET;
}
$processedReports[] = $processedReport;
}
// restore filter truncate parameter value
if ($initialFilterTruncate !== false) {
$_GET['filter_truncate'] = $initialFilterTruncate;
}
/**
* Triggered when generating the content of scheduled reports.
*
* This event can be used to modify the report data or report metadata of one or more reports
* in a scheduled report, before the scheduled report is rendered and delivered.
*
* TODO: list data available in $report or make it a new class that can be documented (same for
* all other events that use a $report)
*
* @param array &$processedReports The list of processed reports in the scheduled
* report. Entries includes report data and metadata for each report.
* @param string $reportType A string ID describing how the scheduled report will be sent, eg,
* `'sms'` or `'email'`.
* @param string $outputType The output format of the report, eg, `'html'`, `'pdf'`, etc.
* @param array $report An array describing the scheduled report that is being
* generated.
*/
Piwik::postEvent(self::PROCESS_REPORTS_EVENT, array(&$processedReports, $reportType, $outputType, $report));
$reportRenderer = null;
/**
* Triggered when obtaining a renderer instance based on the scheduled report output format.
*
* Plugins that provide new scheduled report output formats should use this event to
* handle their new report formats.
*
* @param ReportRenderer &$reportRenderer This variable should be set to an instance that
* extends {@link Piwik\ReportRenderer} by one of the event
* subscribers.
* @param string $reportType A string ID describing how the report is sent, eg,
* `'sms'` or `'email'`.
* @param string $outputType The output format of the report, eg, `'html'`, `'pdf'`, etc.
* @param array $report An array describing the scheduled report that is being
* generated.
*/
Piwik::postEvent(self::GET_RENDERER_INSTANCE_EVENT, array(&$reportRenderer, $reportType, $outputType, $report));
if (is_null($reportRenderer)) {
throw new Exception("A report renderer was not supplied in the event " . self::GET_RENDERER_INSTANCE_EVENT);
}
// init report renderer
$reportRenderer->setLocale($language);
// render report
$description = str_replace(array("\r", "\n"), ' ', $report['description']);
list($reportSubject, $reportTitle) = self::getReportSubjectAndReportTitle(Site::getNameFor($idSite), $report['reports']);
$filename = "{$reportTitle} - {$prettyDate} - {$description}";
$reportRenderer->renderFrontPage($reportTitle, $prettyDate, $description, $reportMetadata, $segment);
array_walk($processedReports, array($reportRenderer, 'renderReport'));
switch ($outputType) {
case self::OUTPUT_SAVE_ON_DISK:
$outputFilename = strtoupper($reportFormat) . ' ' . ucfirst($reportType) . ' Report - ' . $idReport . '.' . $date . '.' . $idSite . '.' . $language;
$outputFilename = $reportRenderer->sendToDisk($outputFilename);
$additionalFiles = $this->getAttachments($reportRenderer, $report, $processedReports, $prettyDate);
return array($outputFilename, $prettyDate, $reportSubject, $reportTitle, $additionalFiles);
break;
case self::OUTPUT_INLINE:
$reportRenderer->sendToBrowserInline($filename);
break;
case self::OUTPUT_RETURN:
return $reportRenderer->getRenderedReport();
break;
default:
case self::OUTPUT_DOWNLOAD:
$reportRenderer->sendToBrowserDownload($filename);
break;
}
}
示例9: userSettings
/**
* The "User Settings" admin UI screen view
*/
public function userSettings()
{
Piwik::checkUserIsNotAnonymous();
$view = new View('@UsersManager/userSettings');
$userLogin = Piwik::getCurrentUserLogin();
$user = Request::processRequest('UsersManager.getUser', array('userLogin' => $userLogin));
$view->userAlias = $user['alias'];
$view->userEmail = $user['email'];
$view->userTokenAuth = Piwik::getCurrentUserTokenAuth();
$view->ignoreSalt = $this->getIgnoreCookieSalt();
$userPreferences = new UserPreferences();
$defaultReport = $userPreferences->getDefaultReport();
if ($defaultReport === false) {
$defaultReport = $userPreferences->getDefaultWebsiteId();
}
$view->defaultReport = $defaultReport;
if ($defaultReport == 'MultiSites') {
$defaultSiteId = $userPreferences->getDefaultWebsiteId();
$reportOptionsValue = $defaultSiteId;
$view->defaultReportIdSite = $defaultSiteId;
$view->defaultReportSiteName = Site::getNameFor($defaultSiteId);
} else {
$reportOptionsValue = $defaultReport;
$view->defaultReportIdSite = $defaultReport;
$view->defaultReportSiteName = Site::getNameFor($defaultReport);
}
$view->defaultReportOptions = array(array('key' => 'MultiSites', 'value' => Piwik::translate('General_AllWebsitesDashboard')), array('key' => $reportOptionsValue, 'value' => Piwik::translate('General_DashboardForASpecificWebsite')));
$view->defaultDate = $this->getDefaultDateForUser($userLogin);
$view->availableDefaultDates = $this->getDefaultDates();
$languages = APILanguagesManager::getInstance()->getAvailableLanguageNames();
$languageOptions = array();
foreach ($languages as $language) {
$languageOptions[] = array('key' => $language['code'], 'value' => $language['name']);
}
$view->languageOptions = $languageOptions;
$view->currentLanguageCode = LanguagesManager::getLanguageCodeForCurrentUser();
$view->currentTimeformat = (int) LanguagesManager::uses12HourClockForCurrentUser();
$view->ignoreCookieSet = IgnoreCookie::isIgnoreCookieFound();
$view->piwikHost = Url::getCurrentHost();
$this->setBasicVariablesView($view);
$view->timeFormats = array('1' => Piwik::translate('General_12HourClock'), '0' => Piwik::translate('General_24HourClock'));
return $view->render();
}
示例10: 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();
}
示例11: userSettings
/**
* The "User Settings" admin UI screen view
*/
public function userSettings()
{
Piwik::checkUserIsNotAnonymous();
$view = new View('@UsersManager/userSettings');
$userLogin = Piwik::getCurrentUserLogin();
if (Piwik::isUserIsSuperUser()) {
$view->userAlias = $userLogin;
$view->userEmail = Piwik::getSuperUserEmail();
$this->displayWarningIfConfigFileNotWritable();
} else {
$user = APIUsersManager::getInstance()->getUser($userLogin);
$view->userAlias = $user['alias'];
$view->userEmail = $user['email'];
}
$defaultReport = APIUsersManager::getInstance()->getUserPreference($userLogin, APIUsersManager::PREFERENCE_DEFAULT_REPORT);
if ($defaultReport === false) {
$defaultReport = $this->getDefaultWebsiteId();
}
$view->defaultReport = $defaultReport;
if ($defaultReport == 'MultiSites') {
$view->defaultReportSiteName = Site::getNameFor($this->getDefaultWebsiteId());
} else {
$view->defaultReportSiteName = Site::getNameFor($defaultReport);
}
$view->defaultDate = $this->getDefaultDateForUser($userLogin);
$view->availableDefaultDates = array('today' => Piwik::translate('General_Today'), 'yesterday' => Piwik::translate('General_Yesterday'), 'previous7' => Piwik::translate('General_PreviousDays', 7), 'previous30' => Piwik::translate('General_PreviousDays', 30), 'last7' => Piwik::translate('General_LastDays', 7), 'last30' => Piwik::translate('General_LastDays', 30), 'week' => Piwik::translate('General_CurrentWeek'), 'month' => Piwik::translate('General_CurrentMonth'), 'year' => Piwik::translate('General_CurrentYear'));
$view->ignoreCookieSet = IgnoreCookie::isIgnoreCookieFound();
$this->initViewAnonymousUserSettings($view);
$view->piwikHost = Url::getCurrentHost();
$this->setBasicVariablesView($view);
return $view->render();
}
示例12: getSitesForAutocompleter
function getSitesForAutocompleter()
{
$pattern = Common::getRequestVar('term');
$sites = API::getInstance()->getPatternMatchSites($pattern);
$pattern = str_replace('%', '', $pattern);
if (!count($sites)) {
$results[] = array('label' => Piwik::translate('SitesManager_NotFound') . " <span class='autocompleteMatched'>{$pattern}</span>.", 'id' => '#');
} else {
if (strpos($pattern, '/') !== false && strpos($pattern, '\\/') === false) {
$pattern = str_replace('/', '\\/', $pattern);
}
foreach ($sites as $s) {
$siteName = Site::getNameFor($s['idsite']);
$label = $siteName;
if (strlen($pattern) > 0) {
@preg_match_all("/{$pattern}+/i", $label, $matches);
if (is_array($matches[0]) && count($matches[0]) >= 1) {
foreach ($matches[0] as $match) {
$label = str_replace($match, '<span class="autocompleteMatched">' . $match . '</span>', $siteName);
}
}
}
$results[] = array('label' => $label, 'id' => $s['idsite'], 'name' => $siteName);
}
}
Json::sendHeaderJSON();
print Common::json_encode($results);
}
示例13: sendAlertsPerEmailToRecipient
/**
* @param array $alerts
* @param Mail $mail
* @param string[] $recipient Email addresses
* @param $period
* @param $idSite
*/
protected function sendAlertsPerEmailToRecipient($alerts, Mail $mail, $recipient, $period, $idSite)
{
if (empty($recipient) || empty($alerts)) {
return;
}
$prettyDate = $this->getPrettyDateForSite($period, $idSite);
$websiteName = Site::getNameFor($idSite);
$mail->setDefaultFromPiwik();
$mail->addTo($recipient);
$mail->setSubject(Piwik::translate('CustomAlerts_MailAlertSubject', array($websiteName, $prettyDate)));
$controller = new Controller();
$viewHtml = new View('@CustomAlerts/alertHtmlMail');
$viewHtml->assign('triggeredAlerts', $controller->formatAlerts($alerts, 'html'));
$mail->setBodyHtml($viewHtml->render());
$viewText = new View('@CustomAlerts/alertTextMail');
$viewText->assign('triggeredAlerts', $controller->formatAlerts($alerts, 'text'));
$viewText->setContentType('text/plain');
$mail->setBodyText($viewText->render());
$mail->send();
}