本文整理汇总了PHP中Piwik_Site::getNameFor方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Site::getNameFor方法的具体用法?PHP Piwik_Site::getNameFor怎么用?PHP Piwik_Site::getNameFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Site
的用法示例。
在下文中一共展示了Piwik_Site::getNameFor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTopMenu
public function addTopMenu()
{
$tooltip = false;
try {
$idSite = Piwik_Common::getRequestVar('idSite');
$tooltip = Piwik_Translate('Dashboard_TopLinkTooltip', Piwik_Site::getNameFor($idSite));
} catch (Exception $ex) {
// if no idSite parameter, show no tooltip
}
$urlParams = array('module' => 'CoreHome', 'action' => 'index');
Piwik_AddTopMenu('General_Dashboard', $urlParams, true, 1, $isHTML = false, $tooltip);
}
示例2: generate
public function generate()
{
Piwik::checkUserIsSuperUser();
$nonce = Piwik_Common::getRequestVar('form_nonce', '', 'string', $_POST);
if (Piwik_Common::getRequestVar('choice', 'no') != 'yes' || !Piwik_Nonce::verifyNonce('Piwik_VisitorGenerator.generate', $nonce)) {
Piwik::redirectToModule('VisitorGenerator', 'index');
}
Piwik_Nonce::discardNonce('Piwik_VisitorGenerator.generate');
$daysToCompute = Piwik_Common::getRequestVar('daysToCompute', 1, 'int');
// get idSite from POST with fallback to GET
$idSite = Piwik_Common::getRequestVar('idSite', false, 'int', $_GET);
$idSite = Piwik_Common::getRequestVar('idSite', $idSite, 'int', $_POST);
Piwik::setMaxExecutionTime(0);
$timer = new Piwik_Timer();
$time = time() - ($daysToCompute - 1) * 86400;
// Update site.ts_created if we generate visits on days before the website was created
$site = new Piwik_Site($idSite);
$minGeneratedDate = Piwik_Date::factory($time);
if ($minGeneratedDate->isEarlier($site->getCreationDate())) {
// direct access to the website table (bad practise but this is a debug / dev plugin)
Zend_Registry::get('db')->update(Piwik_Common::prefixTable("site"), array('ts_created' => $minGeneratedDate->getDatetime()), "idsite = {$idSite}");
}
$nbActionsTotal = 0;
while ($time <= time()) {
$nbActionsTotalThisDay = $this->generateVisits($time, $idSite);
$time += 86400;
$nbActionsTotal += $nbActionsTotalThisDay;
}
// Init view
$view = Piwik_View::factory('generate');
$this->setBasicVariablesView($view);
$view->menu = Piwik_GetAdminMenu();
$view->assign('timer', $timer);
$view->assign('days', $daysToCompute);
$view->assign('nbActionsTotal', $nbActionsTotal);
$view->assign('nbRequestsPerSec', round($nbActionsTotal / $timer->getTime(), 0));
$view->assign('siteName', Piwik_Site::getNameFor($idSite));
echo $view->render();
}
示例3: generateReport
//.........这里部分代码省略.........
$report['parameters'] = Piwik_Common::json_decode(self::validateReportParameters($reportType, $parameters), true);
} else {
$parameters = $report['parameters'];
}
// decode report list
$reportUniqueIds = $report['reports'];
// available reports
$availableReportMetadata = Piwik_API_API::getInstance()->getReportMetadata($idSite);
// we need to lookup which reports metadata are registered in this report
$reportMetadata = array();
foreach ($availableReportMetadata as $metadata) {
if (in_array($metadata['uniqueId'], $reportUniqueIds)) {
$reportMetadata[] = $metadata;
}
}
// the report will be rendered with the first 23 rows and will aggregate other rows in a summary row
// 23 rows table fits in one portrait page
$initialFilterTruncate = Piwik_Common::getRequestVar('filter_truncate', false);
$_GET['filter_truncate'] = self::REPORT_TRUNCATE;
$prettyDate = null;
$processedReports = array();
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
if (!empty($userLogin) && $userLogin != Piwik_Config::getInstance()->superuser['login']) {
$_GET['_restrictSitesToLogin'] = $userLogin;
}
}
}
$processedReport = Piwik_API_API::getInstance()->getProcessedReport($idSite, $period, $date, $apiModule, $apiAction, $segment = false, $apiParameters, $idGoal = false, $language);
// TODO add static method getPrettyDate($period, $date) in Piwik_Period
$prettyDate = $processedReport['prettyDate'];
if ($mustRestoreGET) {
$_GET = $mustRestoreGET;
}
$processedReports[] = $processedReport;
}
// restore filter truncate parameter value
if ($initialFilterTruncate !== false) {
$_GET['filter_truncate'] = $initialFilterTruncate;
}
$notificationInfo = array(self::REPORT_TYPE_INFO_KEY => $reportType, self::REPORT_KEY => $report);
// allow plugins to alter processed reports
Piwik_PostEvent(self::PROCESS_REPORTS_EVENT, $processedReports, $notificationInfo);
// retrieve report renderer instance
$reportRenderer = null;
Piwik_PostEvent(self::GET_RENDERER_INSTANCE_EVENT, $reportRenderer, $notificationInfo);
// init report renderer
$reportRenderer->setLocale($language);
$reportRenderer->setRenderImageInline($outputType != self::OUTPUT_SAVE_ON_DISK);
// render report
$websiteName = Piwik_Site::getNameFor($idSite);
$description = str_replace(array("\r", "\n"), ' ', $report['description']);
$reportRenderer->renderFrontPage($websiteName, $prettyDate, $description, $reportMetadata);
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 = array();
if ($reportRenderer instanceof Piwik_ReportRenderer_Html) {
foreach ($processedReports as &$report) {
if ($report['displayGraph']) {
$additionalFile = array();
$additionalFile['filename'] = $report['metadata']['name'] . '.png';
$additionalFile['cid'] = $report['metadata']['uniqueId'];
$additionalFile['content'] = Piwik_ReportRenderer::getStaticGraph($report['metadata']['imageGraphUrl'], Piwik_ReportRenderer_Html::IMAGE_GRAPH_WIDTH, Piwik_ReportRenderer_Html::IMAGE_GRAPH_HEIGHT);
$additionalFile['mimeType'] = 'image/png';
$additionalFile['encoding'] = Zend_Mime::ENCODING_BASE64;
$additionalFiles[] = $additionalFile;
}
}
}
return array($outputFilename, $prettyDate, $websiteName, $additionalFiles);
break;
case self::OUTPUT_INLINE:
$reportRenderer->sendToBrowserInline("{$websiteName} - {$prettyDate} - {$description}");
break;
case self::OUTPUT_RETURN:
return $reportRenderer->getRenderedReport();
break;
default:
case self::OUTPUT_DOWNLOAD:
$reportRenderer->sendToBrowserDownload("{$websiteName} - {$prettyDate} - {$description}");
break;
}
}
示例4: getSitesInfo
public function getSitesInfo($view)
{
Piwik::checkUserHasSomeViewAccess();
$displayRevenueColumn = Piwik_Common::isGoalPluginEnabled();
// 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 = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
$dateRequest = Piwik_Common::getRequestVar('date', 'today');
$period = Piwik_Common::getRequestVar('period', 'day');
$date = $dateRequest;
if ($period != 'range') {
$date = $this->getDateParameterInTimezone($dateRequest, $piwikDefaultTimezone);
$date = $date->toString();
}
$siteIds = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
$dataTable = Piwik_MultiSites_API::getInstance()->getAll($period, $date, $segment = false);
list($minDate, $maxDate) = $this->getMinMaxDateAcrossWebsites($siteIds);
$totalVisits = $totalActions = $totalRevenue = 0;
// put data into a form the template will understand better
$digestableData = array();
foreach ($siteIds as $idSite) {
$isEcommerceEnabled = Piwik_Site::isEcommerceEnabledFor($idSite);
$digestableData[$idSite] = array('idsite' => $idSite, 'main_url' => Piwik_Site::getMainUrlFor($idSite), 'name' => Piwik_Site::getNameFor($idSite), 'visits' => 0, 'actions' => 0);
if ($period != 'range') {
$digestableData[$idSite]['visits_evolution'] = 0;
$digestableData[$idSite]['actions_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');
$totalVisits += $site['visits'];
$site['actions'] = (int) $row->getColumn('nb_actions');
$totalActions += $site['actions'];
if ($displayRevenueColumn) {
if ($row->getColumn('revenue') !== false) {
$site['revenue'] = $row->getColumn('revenue');
$totalRevenue += $site['revenue'];
}
}
if ($period != 'range') {
$site['visits_evolution'] = $row->getColumn('visits_evolution');
$site['actions_evolution'] = $row->getColumn('actions_evolution');
if ($displayRevenueColumn) {
$site['revenue_evolution'] = $row->getColumn('revenue_evolution');
}
}
}
$this->applyPrettyMoney($digestableData);
$view->sitesData = array_values($digestableData);
$view->evolutionBy = $this->evolutionBy;
$view->period = $period;
$view->dateRequest = $dateRequest;
$view->page = $this->page;
$view->limit = $this->limit;
$view->orderBy = $this->orderBy;
$view->order = $this->order;
$view->totalVisits = $totalVisits;
$view->totalRevenue = $totalRevenue;
$view->displayRevenueColumn = $displayRevenueColumn;
$view->totalActions = $totalActions;
$params = $this->getGraphParamsModified();
$view->dateSparkline = $period == 'range' ? $dateRequest : $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', Piwik_Date::factory('yesterday')->toString('Y-m-d'), Piwik_Date::factory('now', 'UTC+14')->toString('Y-m-d')))) {
$view->autoRefreshTodayReport = Piwik_Config::getInstance()->General['multisites_refresh_after_seconds'];
}
$this->setGeneralVariablesView($view);
$this->setMinDateView($minDate, $view);
$this->setMaxDateView($maxDate, $view);
$view->show_sparklines = Piwik_Config::getInstance()->General['show_multisites_sparklines'];
echo $view->render();
}
示例5: userSettings
/**
* The "User Settings" admin UI screen view
*/
public function userSettings()
{
Piwik::checkUserIsNotAnonymous();
$view = Piwik_View::factory('userSettings');
$userLogin = Piwik::getCurrentUserLogin();
if (Piwik::isUserIsSuperUser()) {
$view->userAlias = $userLogin;
$view->userEmail = Piwik::getSuperUserEmail();
if (!Piwik_Config::getInstance()->isFileWritable()) {
$view->configFileNotWritable = true;
}
} else {
$user = Piwik_UsersManager_API::getInstance()->getUser($userLogin);
$view->userAlias = $user['alias'];
$view->userEmail = $user['email'];
}
$defaultReport = Piwik_UsersManager_API::getInstance()->getUserPreference($userLogin, Piwik_UsersManager_API::PREFERENCE_DEFAULT_REPORT);
if ($defaultReport === false) {
$defaultReport = $this->getDefaultWebsiteId();
}
$view->defaultReport = $defaultReport;
if ($defaultReport == 'MultiSites') {
$view->defaultReportSiteName = Piwik_Site::getNameFor($this->getDefaultWebsiteId());
} else {
$view->defaultReportSiteName = Piwik_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 = Piwik_Tracker_IgnoreCookie::isIgnoreCookieFound();
$this->initViewAnonymousUserSettings($view);
$view->piwikHost = Piwik_Url::getCurrentHost();
$this->setBasicVariablesView($view);
$view->menu = Piwik_GetAdminMenu();
echo $view->render();
}