Plugins can implement the configureTopMenu() method of the Menu plugin class to add, rename of remove items. If your plugin does not have a Menu class yet you can create one using ./console generate:menu.
Inheritance: extends MenuAbstract
Beispiel #1
0
 public function configureTopMenu(MenuTop $menu)
 {
     if (Piwik::isUserIsAnonymous() || !SettingsPiwik::isPiwikInstalled()) {
         $langManager = new LanguagesManager();
         $menu->addHtml('LanguageSelector', $langManager->getLanguagesSelector(), true, $order = 30, false);
     }
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 public function configureTopMenu(MenuTop $menu)
 {
     if (Piwik::isUserHasSomeAdminAccess()) {
         $url = $this->urlForModuleAction('SitesManager', 'index');
         if (Piwik::hasUserSuperUserAccess()) {
             $url = $this->urlForAction('generalSettings');
         }
         $menu->addItem('CoreAdminHome_Administration', null, $url, 10);
     }
 }
Beispiel #5
0
 public function configureTopMenu(MenuTop $menu)
 {
     $module = $this->getLoginModule();
     if (Piwik::isUserIsAnonymous()) {
         $menu->registerMenuIcon('Login_LogIn', 'icon-sign-in');
         $menu->addItem('Login_LogIn', null, array('module' => $module, 'action' => false), 1000, Piwik::translate('Login_LogIn'));
     } else {
         $menu->registerMenuIcon('General_Logout', 'icon-sign-out');
         $menu->addItem('General_Logout', null, array('module' => $module, 'action' => 'logout', 'idSite' => null), 1000, Piwik::translate('General_Logout'));
     }
 }
Beispiel #6
0
 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);
 }
Beispiel #7
0
 private function addTopMenuMobileApp(MenuTop $menu)
 {
     if (empty($_SERVER['HTTP_USER_AGENT'])) {
         return;
     }
     if (!class_exists("DeviceDetector")) {
         throw new \Exception("DeviceDetector could not be found, maybe you are using Piwik from git and need to have update Composer. <br>php composer.phar update");
     }
     $ua = new \DeviceDetector($_SERVER['HTTP_USER_AGENT']);
     $ua->parse();
     $os = $ua->getOs('short_name');
     if ($os && in_array($os, array('AND', 'IOS'))) {
         $menu->add('Piwik Mobile App', null, array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
     }
 }
Beispiel #8
0
 private function addTopMenuMobileApp(MenuTop $menu)
 {
     if (empty($_SERVER['HTTP_USER_AGENT'])) {
         return;
     }
     if (!class_exists("DeviceDetector\\DeviceDetector")) {
         throw new \Exception("DeviceDetector could not be found, maybe you are using Piwik from git and need to update Composer. Execute this command: php composer.phar update");
     }
     $ua = new OperatingSystem($_SERVER['HTTP_USER_AGENT']);
     $ua->setCache(new DeviceDetectorCache('tracker', 86400));
     $parsedOS = $ua->parse();
     if (!empty($parsedOS['short_name']) && in_array($parsedOS['short_name'], array(self::DD_SHORT_NAME_ANDROID, self::DD_SHORT_NAME_IOS))) {
         $menu->add('Piwik Mobile App', null, array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
     }
 }
Beispiel #9
0
 public function configureTopMenu(MenuTop $menu)
 {
     $login = Piwik::getCurrentUserLogin();
     $user = APIUsersManager::getInstance()->getUser($login);
     if (!empty($user['alias'])) {
         $login = $user['alias'];
     }
     if (Plugin\Manager::getInstance()->isPluginActivated('Feedback')) {
         $menu->addItem('General_Help', null, array('module' => 'Feedback', 'action' => 'index'));
     }
     if (Piwik::isUserIsAnonymous()) {
         if (Plugin\Manager::getInstance()->isPluginActivated('Feedback')) {
             $menu->addItem($login, null, array('module' => 'Feedback', 'action' => 'index'), 998);
         } else {
             $menu->addItem($login, null, array('module' => 'API', 'action' => 'listAllAPI'), 998);
         }
     } else {
         $menu->addItem($login, null, array('module' => 'UsersManager', 'action' => 'userSettings'), 998);
     }
     $module = $this->getLoginModule();
     if (Piwik::isUserIsAnonymous()) {
         $menu->addItem('Login_LogIn', null, array('module' => $module, 'action' => false), 999);
     } else {
         $menu->addItem('General_Logout', null, array('module' => $module, 'action' => 'logout', 'idSite' => null), 999);
     }
 }
 public function index()
 {
     Piwik::checkUserHasSuperUserAccess();
     $view = new View('@IP2Location/index');
     $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
     $this->setBasicVariablesView($view);
     $view->adminMenu = MenuAdmin::getInstance()->getMenu();
     $view->topMenu = MenuTop::getInstance()->getMenu();
     $view->notifications = NotificationManager::getAllNotificationsToDisplay();
     $view->userMenu = MenuUser::getInstance()->getMenu();
     $view->phpVersion = phpversion();
     $view->phpIsNewEnough = version_compare($view->phpVersion, '5.3.0', '>=');
     $view->assign('userMenu', 'IP2Location');
     $view->assign('dbNotFound', false);
     $view->assign('dbOutDated', false);
     $view->assign('showResults', false);
     $view->assign('fileName', '-');
     $view->assign('date', '-');
     $view->assign('country', '');
     $view->assign('regionName', '');
     $view->assign('cityName', '');
     $view->assign('position', '');
     $ipAddress = trim(Common::getRequestVar('ipAddress', $_SERVER['REMOTE_ADDR']));
     $view->assign('ipAddress', $ipAddress);
     $dbPath = PIWIK_INCLUDE_PATH . '/plugins/IP2Location/data/';
     $dbFile = '';
     if ($handle = opendir($dbPath)) {
         while (false !== ($file = readdir($handle))) {
             if (strtoupper(substr($file, -4)) == '.BIN') {
                 $dbFile = $dbPath . $file;
                 break;
             }
         }
         closedir($handle);
     }
     if (!$dbFile) {
         $view->assign('dbNotFound', true);
     }
     if ($dbFile) {
         $view->assign('fileName', $file);
         if (filemtime($dbFile) < strtotime('-2 months')) {
             $view->assign('dbOutDated', true);
         } else {
             $view->assign('date', date('d M, Y', filemtime($dbFile)));
         }
         if (!empty($_POST)) {
             $view->assign('showResults', true);
             $result = IP2LocationAPI::lookup($ipAddress, $dbFile);
             $view->assign('country', $result['countryCode'] != '-' ? $result['countryName'] . ' (' . $result['countryCode'] . ')' : '-');
             $view->assign('regionName', !preg_match('/not supported/', $result['regionName']) ? $result['regionName'] : '-');
             $view->assign('cityName', !preg_match('/not supported/', $result['cityName']) ? $result['cityName'] : '-');
             $view->assign('position', !preg_match('/not supported/', $result['latitude']) && $result['latitude'] != '-' ? $result['latitude'] . ', ' . $result['longitude'] : '-');
         }
     }
     echo $view->render();
 }
Beispiel #11
0
 public function configureTopMenu(MenuTop $menu)
 {
     $login = Piwik::getCurrentUserLogin();
     $user = APIUsersManager::getInstance()->getUser($login);
     if (!empty($user['alias'])) {
         $login = $user['alias'];
     }
     if (Plugin\Manager::getInstance()->isPluginActivated('Feedback')) {
         $menu->registerMenuIcon('General_Help', 'icon-help');
         $menu->addItem('General_Help', null, array('module' => 'Feedback', 'action' => 'index'), $order = 990, Piwik::translate('General_Help'));
     }
     $menu->registerMenuIcon($login, 'icon-user');
     if (Piwik::isUserIsAnonymous()) {
         if (Plugin\Manager::getInstance()->isPluginActivated('ScheduledReports')) {
             $menu->addItem($login, null, array('module' => 'ScheduledReports', 'action' => 'index'), 970, Piwik::translate('ScheduledReports_PersonalEmailReports'));
         } else {
             $menu->addItem($login, null, array('module' => 'API', 'action' => 'listAllAPI'), 970, Piwik::translate('API_ReportingApiReference'));
         }
     } else {
         $tooltip = sprintf('%s: %s', Piwik::translate('UsersManager_PersonalSettings'), $login);
         $menu->addItem($login, null, array('module' => 'UsersManager', 'action' => 'userSettings'), 970, $tooltip);
     }
     $module = $this->getLoginModule();
     if (Piwik::isUserIsAnonymous()) {
         $menu->registerMenuIcon('Login_LogIn', 'icon-sign-in');
         $menu->addItem('Login_LogIn', null, array('module' => $module, 'action' => false), 1000, Piwik::translate('Login_LogIn'));
     } else {
         $menu->registerMenuIcon('General_Logout', 'icon-sign-out');
         $menu->addItem('General_Logout', null, array('module' => $module, 'action' => 'logout', 'idSite' => null), 1000, Piwik::translate('General_Logout'));
     }
 }
 /**
  * Assigns view properties that would be useful to views that render admin pages.
  *
  * Assigns the following variables:
  *
  * - **statisticsNotRecorded** - Set to true if the `[Tracker] record_statistics` INI
  *                               config is `0`. If not `0`, this variable will not be defined.
  * - **topMenu** - The result of `MenuTop::getInstance()->getMenu()`.
  * - **currentAdminMenuName** - The currently selected admin menu name.
  * - **enableFrames** - The value of the `[General] enable_framed_pages` INI config option. If
  *                    true, {@link Piwik\View::setXFrameOptions()} is called on the view.
  * - **isSuperUser** - Whether the current user is a superuser or not.
  * - **usingOldGeoIPPlugin** - Whether this Piwik install is currently using the old GeoIP
  *                             plugin or not.
  * - **invalidPluginsWarning** - Set if some of the plugins to load (determined by INI configuration)
  *                               are invalid or missing.
  * - **phpVersion** - The current PHP version.
  * - **phpIsNewEnough** - Whether the current PHP version is new enough to run Piwik.
  * - **adminMenu** - The result of `MenuAdmin::getInstance()->getMenu()`.
  *
  * @param View $view
  * @api
  */
 public static function setBasicVariablesAdminView(View $view)
 {
     self::notifyWhenTrackingStatisticsDisabled();
     $view->topMenu = MenuTop::getInstance()->getMenu();
     $view->currentAdminMenuName = MenuAdmin::getInstance()->getCurrentAdminMenuName();
     $view->isDataPurgeSettingsEnabled = self::isDataPurgeSettingsEnabled();
     $view->enableFrames = PiwikConfig::getInstance()->General['enable_framed_settings'];
     if (!$view->enableFrames) {
         $view->setXFrameOptions('sameorigin');
     }
     $view->isSuperUser = Piwik::isUserIsSuperUser();
     self::notifyAnyInvalidPlugin();
     self::checkPhpVersion($view);
     $adminMenu = MenuAdmin::getInstance()->getMenu();
     $view->adminMenu = $adminMenu;
     $view->notifications = NotificationManager::getAllNotificationsToDisplay();
     NotificationManager::cancelAllNonPersistent();
 }
 /**
  * Assigns view properties that would be useful to views that render admin pages.
  *
  * Assigns the following variables:
  *
  * - **statisticsNotRecorded** - Set to true if the `[Tracker] record_statistics` INI
  *                               config is `0`. If not `0`, this variable will not be defined.
  * - **topMenu** - The result of `MenuTop::getInstance()->getMenu()`.
  * - **currentAdminMenuName** - The currently selected admin menu name.
  * - **enableFrames** - The value of the `[General] enable_framed_pages` INI config option. If
  *                    true, {@link Piwik\View::setXFrameOptions()} is called on the view.
  * - **isSuperUser** - Whether the current user is a superuser or not.
  * - **usingOldGeoIPPlugin** - Whether this Piwik install is currently using the old GeoIP
  *                             plugin or not.
  * - **invalidPluginsWarning** - Set if some of the plugins to load (determined by INI configuration)
  *                               are invalid or missing.
  * - **phpVersion** - The current PHP version.
  * - **phpIsNewEnough** - Whether the current PHP version is new enough to run Piwik.
  * - **adminMenu** - The result of `MenuAdmin::getInstance()->getMenu()`.
  *
  * @param View $view
  * @api
  */
 public static function setBasicVariablesAdminView(View $view)
 {
     self::notifyWhenTrackingStatisticsDisabled();
     self::notifyIfEAcceleratorIsUsed();
     $view->topMenu = MenuTop::getInstance()->getMenu();
     $view->userMenu = MenuUser::getInstance()->getMenu();
     $view->currentAdminMenuName = MenuAdmin::getInstance()->getCurrentAdminMenuName();
     $view->isDataPurgeSettingsEnabled = self::isDataPurgeSettingsEnabled();
     $view->enableFrames = PiwikConfig::getInstance()->General['enable_framed_settings'];
     if (!$view->enableFrames) {
         $view->setXFrameOptions('sameorigin');
     }
     $view->isSuperUser = Piwik::hasUserSuperUserAccess();
     self::notifyAnyInvalidPlugin();
     self::checkPhpVersion($view);
     if (Piwik::hasUserSuperUserAccess() && self::isPhpVersion53()) {
         $notification = new Notification(Piwik::translate('General_WarningPhpVersionXIsTooOld', '5.3'));
         $notification->title = Piwik::translate('General_Warning');
         $notification->priority = Notification::PRIORITY_LOW;
         $notification->context = Notification::CONTEXT_WARNING;
         $notification->type = Notification::TYPE_TRANSIENT;
         $notification->flags = Notification::FLAG_NO_CLEAR;
         NotificationManager::notify('PHP53VersionCheck', $notification);
     }
     $adminMenu = MenuAdmin::getInstance()->getMenu();
     $view->adminMenu = $adminMenu;
     $notifications = $view->notifications;
     if (empty($notifications)) {
         $view->notifications = NotificationManager::getAllNotificationsToDisplay();
         NotificationManager::cancelAllNonPersistent();
     }
 }
Beispiel #14
0
 public function configureTopMenu(MenuTop $menu)
 {
     $urlParams = array('module' => 'ExampleUI', 'action' => 'notifications');
     $menu->add('UI Notifications', null, $urlParams, $displayedForCurrentUser = true, $order = 3);
 }
Beispiel #15
0
 protected function addTopMenuMobileApp()
 {
     if (empty($_SERVER['HTTP_USER_AGENT'])) {
         return;
     }
     require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php';
     $os = \UserAgentParser::getOperatingSystem($_SERVER['HTTP_USER_AGENT']);
     if ($os && in_array($os['id'], array('AND', 'IPD', 'IPA', 'IPH'))) {
         MenuTop::addEntry('Piwik Mobile App', array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
     }
 }
Beispiel #16
0
 /**
  * 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();
 }
Beispiel #17
0
 public function configureTopMenu(MenuTop $menu)
 {
     $urlParams = array('module' => 'MultiSites', 'action' => 'index', 'segment' => false);
     $tooltip = Piwik::translate('MultiSites_TopLinkTooltip');
     $menu->add('General_MultiSitesSummary', null, $urlParams, true, 3, $tooltip);
 }
Beispiel #18
0
 /**
  * @deprecated since version 2.4.0. See {@link Piwik\Plugin\Menu} for new implementation.
  */
 public static function removeEntry($menuName, $subMenuName = false)
 {
     MenuTop::getInstance()->remove($menuName, $subMenuName);
 }
Beispiel #19
0
 public function configureTopMenu(MenuTop $menu)
 {
     $urlParams = $this->urlForActionWithDefaultUserParams('index', array('segment' => false, 'idSite' => false));
     $tooltip = Piwik::translate('MultiSites_TopLinkTooltip');
     $menu->add('General_MultiSitesSummary', null, $urlParams, true, 3, $tooltip);
 }
Beispiel #20
0
 /**
  * Assigns variables to {@link Piwik\View} instances that display an entire page.
  *
  * The following variables assigned:
  *
  * **date** - The value of the **date** query parameter.
  * **idSite** - The value of the **idSite** query parameter.
  * **rawDate** - The value of the **date** query parameter.
  * **prettyDate** - A pretty string description of the current period.
  * **siteName** - The current site's name.
  * **siteMainUrl** - The URL of the current site.
  * **startDate** - The start date of the current period. A {@link Piwik\Date} instance.
  * **endDate** - The end date of the current period. A {@link Piwik\Date} instance.
  * **language** - The current language's language code.
  * **config_action_url_category_delimiter** - The value of the `[General] action_url_category_delimiter`
  *                                            INI config option.
  * **topMenu** - The result of `MenuTop::getInstance()->getMenu()`.
  *
  * As well as the variables set by {@link setPeriodVariablesView()}.
  *
  * Will exit on error.
  *
  * @param View $view
  * @return void
  * @api
  */
 protected function setGeneralVariablesView($view)
 {
     $view->idSite = $this->idSite;
     $this->checkSitePermission();
     $this->setPeriodVariablesView($view);
     $view->siteName = $this->site->getName();
     $view->siteMainUrl = $this->site->getMainUrl();
     $siteTimezone = $this->site->getTimezone();
     $datetimeMinDate = $this->site->getCreationDate()->getDatetime();
     $minDate = Date::factory($datetimeMinDate, $siteTimezone);
     $this->setMinDateView($minDate, $view);
     $maxDate = Date::factory('now', $siteTimezone);
     $this->setMaxDateView($maxDate, $view);
     $rawDate = Common::getRequestVar('date');
     Period::checkDateFormat($rawDate);
     $periodStr = Common::getRequestVar('period');
     if ($periodStr != 'range') {
         $date = Date::factory($this->strDate);
         $validDate = $this->getValidDate($date, $minDate, $maxDate);
         $period = Period\Factory::build($periodStr, $validDate);
         if ($date->toString() !== $validDate->toString()) {
             // we to not always change date since it could convert a strDate "today" to "YYYY-MM-DD"
             // only change $this->strDate if it was not valid before
             $this->setDate($validDate);
         }
     } else {
         $period = new Range($periodStr, $rawDate, $siteTimezone);
     }
     // Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected
     $dateStart = $period->getDateStart();
     $dateStart = $this->getValidDate($dateStart, $minDate, $maxDate);
     $dateEnd = $period->getDateEnd();
     $dateEnd = $this->getValidDate($dateEnd, $minDate, $maxDate);
     if ($periodStr == 'range') {
         // make sure we actually display the correct calendar pretty date
         $newRawDate = $dateStart->toString() . ',' . $dateEnd->toString();
         $period = new Range($periodStr, $newRawDate, $siteTimezone);
     }
     $view->date = $this->strDate;
     $view->prettyDate = self::getCalendarPrettyDate($period);
     $view->prettyDateLong = $period->getLocalizedLongString();
     $view->rawDate = $rawDate;
     $view->startDate = $dateStart;
     $view->endDate = $dateEnd;
     $language = LanguagesManager::getLanguageForSession();
     $view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
     $this->setBasicVariablesView($view);
     $view->topMenu = MenuTop::getInstance()->getMenu();
     $view->adminMenu = MenuAdmin::getInstance()->getMenu();
     $notifications = $view->notifications;
     if (empty($notifications)) {
         $view->notifications = NotificationManager::getAllNotificationsToDisplay();
         NotificationManager::cancelAllNonPersistent();
     }
 }
 public function addTopMenu()
 {
     $urlParams = array('module' => 'MultiSites', 'action' => 'index', 'segment' => false);
     $tooltip = Piwik::translate('MultiSites_TopLinkTooltip');
     MenuTop::addEntry('General_MultiSitesSummary', $urlParams, true, 3, $isHTML = false, $tooltip);
 }
Beispiel #22
0
 public function configureTopMenu(MenuTop $menu)
 {
     $menu->registerMenuIcon('General_Help', 'icon-info2');
     $menu->addItem('General_Help', null, array('module' => 'Feedback', 'action' => 'index'), $order = 990, Piwik::translate('General_Help'));
 }
Beispiel #23
0
 public function configureTopMenu(MenuTop $menu)
 {
     $url = $this->urlForModuleAction('CoreAdminHome', 'home');
     $menu->registerMenuIcon('CoreAdminHome_Administration', 'icon-settings');
     $menu->addItem('CoreAdminHome_Administration', null, $url, 980, Piwik::translate('CoreAdminHome_Administration'));
 }
 public function showLanguagesSelector()
 {
     MenuTop::addEntry('LanguageSelector', $this->getLanguagesSelector(), true, $order = 30, true);
 }
Beispiel #25
0
 /**
  * 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();
 }
 public function addTopMenu()
 {
     $tooltip = Piwik::translate('Widgetize_TopLinkTooltip');
     $urlParams = array('module' => 'Widgetize', 'action' => 'index', 'segment' => false);
     MenuTop::addEntry('General_Widgets', $urlParams, true, 5, $isHTML = false, $tooltip);
 }
Beispiel #27
0
 /**
  * Assigns variables to {@link Piwik\View} instances that display an entire page.
  * 
  * The following variables assigned:
  * 
  * **date** - The value of the **date** query parameter.
  * **idSite** - The value of the **idSite** query parameter.
  * **rawDate** - The value of the **date** query parameter.
  * **prettyDate** - A pretty string description of the current period.
  * **siteName** - The current site's name.
  * **siteMainUrl** - The URL of the current site.
  * **startDate** - The start date of the current period. A {@link Piwik\Date} instance.
  * **endDate** - The end date of the current period. A {@link Piwik\Date} instance.
  * **language** - The current language's language code.
  * **config_action_url_category_delimiter** - The value of the `[General] action_url_category_delimiter`
  *                                            INI config option.
  * **topMenu** - The result of `MenuTop::getInstance()->getMenu()`.
  * 
  * As well as the variables set by {@link setPeriodVariablesView()}.
  * 
  * Will exit on error.
  * 
  * @param View $view
  * @return void
  * @api
  */
 protected function setGeneralVariablesView($view)
 {
     $view->date = $this->strDate;
     try {
         $view->idSite = $this->idSite;
         if (empty($this->site) || empty($this->idSite)) {
             throw new Exception("The requested website idSite is not found in the request, or is invalid.\n\t\t\t\tPlease check that you are logged in Piwik and have permission to access the specified website.");
         }
         $this->setPeriodVariablesView($view);
         $rawDate = Common::getRequestVar('date');
         $periodStr = Common::getRequestVar('period');
         if ($periodStr != 'range') {
             $date = Date::factory($this->strDate);
             $period = Period\Factory::build($periodStr, $date);
         } else {
             $period = new Range($periodStr, $rawDate, $this->site->getTimezone());
         }
         $view->rawDate = $rawDate;
         $view->prettyDate = self::getCalendarPrettyDate($period);
         $view->siteName = $this->site->getName();
         $view->siteMainUrl = $this->site->getMainUrl();
         $datetimeMinDate = $this->site->getCreationDate()->getDatetime();
         $minDate = Date::factory($datetimeMinDate, $this->site->getTimezone());
         $this->setMinDateView($minDate, $view);
         $maxDate = Date::factory('now', $this->site->getTimezone());
         $this->setMaxDateView($maxDate, $view);
         // Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected
         $dateStart = $period->getDateStart();
         if ($dateStart->isEarlier($minDate)) {
             $dateStart = $minDate;
         }
         $dateEnd = $period->getDateEnd();
         if ($dateEnd->isLater($maxDate)) {
             $dateEnd = $maxDate;
         }
         $view->startDate = $dateStart;
         $view->endDate = $dateEnd;
         $language = LanguagesManager::getLanguageForSession();
         $view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
         $this->setBasicVariablesView($view);
         $view->topMenu = MenuTop::getInstance()->getMenu();
         $view->userMenu = MenuUser::getInstance()->getMenu();
         $notifications = $view->notifications;
         if (empty($notifications)) {
             $view->notifications = NotificationManager::getAllNotificationsToDisplay();
             NotificationManager::cancelAllNonPersistent();
         }
     } catch (Exception $e) {
         Piwik_ExitWithMessage($e->getMessage(), $e->getTraceAsString());
     }
 }
Beispiel #28
0
 /**
  * Assigns view properties that would be useful to views that render admin pages.
  *
  * Assigns the following variables:
  *
  * - **statisticsNotRecorded** - Set to true if the `[Tracker] record_statistics` INI
  *                               config is `0`. If not `0`, this variable will not be defined.
  * - **topMenu** - The result of `MenuTop::getInstance()->getMenu()`.
  * - **enableFrames** - The value of the `[General] enable_framed_pages` INI config option. If
  *                    true, {@link Piwik\View::setXFrameOptions()} is called on the view.
  * - **isSuperUser** - Whether the current user is a superuser or not.
  * - **usingOldGeoIPPlugin** - Whether this Piwik install is currently using the old GeoIP
  *                             plugin or not.
  * - **invalidPluginsWarning** - Set if some of the plugins to load (determined by INI configuration)
  *                               are invalid or missing.
  * - **phpVersion** - The current PHP version.
  * - **phpIsNewEnough** - Whether the current PHP version is new enough to run Piwik.
  * - **adminMenu** - The result of `MenuAdmin::getInstance()->getMenu()`.
  *
  * @param View $view
  * @api
  */
 public static function setBasicVariablesAdminView(View $view)
 {
     self::notifyWhenTrackingStatisticsDisabled();
     self::notifyIfEAcceleratorIsUsed();
     $view->topMenu = MenuTop::getInstance()->getMenu();
     $view->userMenu = MenuUser::getInstance()->getMenu();
     $view->isDataPurgeSettingsEnabled = self::isDataPurgeSettingsEnabled();
     $enableFrames = PiwikConfig::getInstance()->General['enable_framed_settings'];
     $view->enableFrames = $enableFrames;
     if (!$enableFrames) {
         $view->setXFrameOptions('sameorigin');
     }
     $view->isSuperUser = Piwik::hasUserSuperUserAccess();
     self::notifyAnyInvalidPlugin();
     self::checkPhpVersion($view);
     self::notifyWhenPhpVersionIsEOL();
     self::notifyWhenDebugOnDemandIsEnabled('debug');
     self::notifyWhenDebugOnDemandIsEnabled('debug_on_demand');
     $adminMenu = MenuAdmin::getInstance()->getMenu();
     $view->adminMenu = $adminMenu;
     $notifications = $view->notifications;
     if (empty($notifications)) {
         $view->notifications = NotificationManager::getAllNotificationsToDisplay();
         NotificationManager::cancelAllNonPersistent();
     }
 }
 public function configureTopMenu(MenuTop $menu)
 {
     $menu->remove('General_Logout');
 }
 function addTopMenu()
 {
     MenuTop::addEntry($this->getTopMenuTranslationKey(), array('module' => 'ScheduledReports', 'action' => 'index', 'segment' => false), true, 13, $isHTML = false, $tooltip = Piwik::translate(\Piwik\Plugin\Manager::getInstance()->isPluginActivated('MobileMessaging') ? 'MobileMessaging_TopLinkTooltip' : 'ScheduledReports_TopLinkTooltip'));
 }