View lets you set properties that will be passed on to a Twig template. View will also set several properties that will be available in all Twig templates, including: - **currentModule**: The value of the **module** query parameter. - **currentAction**: The value of the **action** query parameter. - **userLogin**: The current user login name. - **sites**: List of site data for every site the current user has at least view access for. - **url**: The current URL (sanitized). - **token_auth**: The current user's token auth. - **userHasSomeAdminAccess**: True if the user has admin access to at least one site, false if otherwise. - **userIsSuperUser**: True if the user is the superuser, false if otherwise. - **latest_version_available**: The latest version of Piwik available. - **isWidget**: The value of the 'widget' query parameter. - **show_autocompleter**: Whether the site selector should be shown or not. - **loginModule**: The name of the currently used authentication module. - **userAlias**: The alias of the current user. ### Template Naming Convention Template files should be named after the controller method they are used in. If they are used in more than one controller method or are included by another template, they should describe the output they generate and be prefixed with an underscore, eg, **_dataTable.twig**. ### Twig Twig templates must exist in the **templates** folder in a plugin's root folder. The following filters are available to twig templates: - **translate**: Outputs internationalized text using a translation token, eg, {{ 'General_Date'|translate }}. sprintf parameters can be passed to the filter. - **urlRewriteWithParameters**: Modifies the current query string with the given set of parameters, eg, {{ {'module':'MyPlugin', 'action':'index'} | urlRewriteWithParameters }} - **sumTime**: Pretty formats an number of seconds. - **money**: Formats a numerical value as a monetary value using the currency of the supplied site (second arg is site ID). eg, {{ 23|money(site.idsite)|raw }} - **truncate**: Truncates the text to certain length (determined by first arg.) eg, {{ myReallyLongText|truncate(80) }} - **implode**: Calls implode. - **ucwords**: Calls ucwords. The following functions are available to twig templates: - **linkTo**: Modifies the current query string with the given set of parameters, eg {{ linkTo({'module':'MyPlugin', 'action':'index'}) }}. - **sparkline**: Outputs a sparkline image HTML element using the sparkline image src link. eg, {{ sparkline(sparklineUrl) }}. - **postEvent**: Posts an event that allows event observers to add text to a string which is outputted in the template, eg, {{ postEvent('MyPlugin.event') }} - **isPluginLoaded**: Returns true if the supplied plugin is loaded, false if otherwise. {% if isPluginLoaded('Goals') %}...{% endif %}` ### Examples **Basic usage** a controller method public function myView() { $view = new View("@MyPlugin/myView"); $view->property1 = "a view property"; $view->property2 = "another view property"; return $view->render(); }
상속: implements Piwik\View\ViewInterface
예제 #1
0
 public function index()
 {
     $view = new View('@VisitTime/index');
     $view->dataTableVisitInformationPerLocalTime = $this->renderReport(new GetVisitInformationPerLocalTime());
     $view->dataTableVisitInformationPerServerTime = $this->renderReport(new GetVisitInformationPerServerTime());
     return $view->render();
 }
예제 #2
0
파일: Sparklines.php 프로젝트: piwik/piwik
 /**
  * @see ViewDataTable::main()
  * @return mixed
  */
 public function render()
 {
     $view = new View('@CoreVisualizations/_dataTableViz_sparklines.twig');
     $columnsList = array();
     if ($this->config->hasSparklineMetrics()) {
         foreach ($this->config->getSparklineMetrics() as $cols) {
             $columns = $cols['columns'];
             if (!is_array($columns)) {
                 $columns = array($columns);
             }
             $columnsList = array_merge($columns, $columnsList);
         }
     }
     $view->allMetricsDocumentation = Metrics::getDefaultMetricsDocumentation();
     $this->requestConfig->request_parameters_to_modify['columns'] = $columnsList;
     $this->requestConfig->request_parameters_to_modify['format_metrics'] = '1';
     if (!empty($this->requestConfig->apiMethodToRequestDataTable)) {
         $this->fetchConfiguredSparklines();
     }
     $view->sparklines = $this->config->getSortedSparklines();
     $view->isWidget = Common::getRequestVar('widget', 0, 'int');
     $view->titleAttributes = $this->config->title_attributes;
     $view->footerMessage = $this->config->show_footer_message;
     $view->areSparklinesLinkable = $this->config->areSparklinesLinkable();
     $view->title = '';
     if ($this->config->show_title) {
         $view->title = $this->config->title;
     }
     return $view->render();
 }
예제 #3
0
 public function displayDbConnectionMessage($exception = null)
 {
     $view = new PiwikView("@Installation/cannotConnectToDb");
     $view->exceptionMessage = $exception->getMessage();
     $ex = new DatabaseConnectionFailedException($view->render());
     $ex->setIsHtmlMessage();
     throw $ex;
 }
 /**
  * Renders and returns the language selector HTML.
  *
  * @return string
  */
 public function getLanguagesSelector()
 {
     $view = new View("@LanguagesManager/getLanguagesSelector");
     $view->languages = API::getInstance()->getAvailableLanguageNames();
     $view->currentLanguageCode = self::getLanguageCodeForCurrentUser();
     $view->currentLanguageName = self::getLanguageNameForCurrentUser();
     return $view->render();
 }
예제 #5
0
파일: Widgets.php 프로젝트: diosmosis/piwik
 /**
  * Renders and echo's HTML that displays the Piwik promo video.
  */
 public function getPromoVideo()
 {
     $view = new View('@CoreHome/getPromoVideo');
     $view->shareText = $this->translator->translate('CoreHome_SharePiwikShort');
     $view->shareTextLong = $this->translator->translate('CoreHome_SharePiwikLong');
     $view->promoVideoUrl = 'https://www.youtube.com/watch?v=OslfF_EH81g';
     return $view->render();
 }
예제 #6
0
 public function testJsInclude2()
 {
     $view = new View('@Widgetize/testJsInclude2');
     $view->url1 = '?module=Widgetize&action=js&moduleToWidgetize=UserSettings&actionToWidgetize=getBrowser&idSite=1&period=day&date=yesterday';
     $view->url2 = '?module=Widgetize&action=js&moduleToWidgetize=UserCountry&actionToWidgetize=getCountry&idSite=1&period=day&date=yesterday&viewDataTable=cloud&show_footer=0';
     $view->url3 = '?module=Widgetize&action=js&moduleToWidgetize=Referrers&actionToWidgetize=getKeywords&idSite=1&period=day&date=yesterday&viewDataTable=table&show_footer=0';
     return $view->render();
 }
예제 #7
0
 public function promoPiwikPro()
 {
     $view = new View('@PiwikPro/promoPiwikProWidget');
     $promo = $this->promo->getContent();
     $view->ctaLinkUrl = $this->advertising->getPromoUrlForOnPremises('PromoWidget', $promo['campaignContent']);
     $view->ctaText = $promo['text'];
     $view->ctaLinkTitle = $this->promo->getLinkTitle();
     return $view->render();
 }
예제 #8
0
파일: Widgets.php 프로젝트: diosmosis/piwik
 public function promoServices()
 {
     $view = new View('@ProfessionalServices/promoServicesWidget');
     $promo = $this->promo->getContent();
     $view->ctaLinkUrl = $this->advertising->getPromoUrlForPiwikProUpgrade();
     $view->ctaText = $promo['text'];
     $view->ctaLinkTitle = $this->promo->getLinkTitle();
     return $view->render();
 }
예제 #9
0
 public function render()
 {
     $view = new View('@ProfessionalServices/promoServicesWidget');
     $promo = $this->promo->getContent();
     $view->ctaLinkUrl = $promo['url'];
     $view->ctaText = $promo['text'];
     $view->ctaLinkTitle = $this->promo->getLinkTitle();
     return $view->render();
 }
예제 #10
0
 public function index()
 {
     $view = new View('@VisitorInterest/index');
     $view->dataTableNumberOfVisitsPerVisitDuration = $this->getNumberOfVisitsPerVisitDuration(true);
     $view->dataTableNumberOfVisitsPerPage = $this->getNumberOfVisitsPerPage(true);
     $view->dataTableNumberOfVisitsByVisitNum = $this->getNumberOfVisitsByVisitCount(true);
     $view->dataTableNumberOfVisitsByDaysSinceLast = $this->getNumberOfVisitsByDaysSinceLast(true);
     return $view->render();
 }
예제 #11
0
파일: Controller.php 프로젝트: piwik/piwik
 /**
  * Echo's an HTML chunk describing the current database size, and the estimated space
  * savings after the scheduled data purge is run.
  */
 public function getDatabaseSize()
 {
     Piwik::checkUserHasSuperUserAccess();
     $view = new View('@PrivacyManager/getDatabaseSize');
     $forceEstimate = Common::getRequestVar('forceEstimate', 0);
     $view->dbStats = $this->getDeleteDBSizeEstimate($getSettingsFromQuery = true, $forceEstimate);
     $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
     return $view->render();
 }
예제 #12
0
파일: Controller.php 프로젝트: piwik/piwik
 public function goalConversionsOverview()
 {
     $view = new View('@Goals/conversionOverview');
     $idGoal = Common::getRequestVar('idGoal', null, 'string');
     $view->topDimensions = $this->getTopDimensions($idGoal);
     $goalMetrics = Request::processRequest('Goals.get', array('idGoal' => $idGoal));
     // conversion rate for new and returning visitors
     $view->conversion_rate_returning = $this->formatConversionRate($goalMetrics, 'conversion_rate_returning_visit');
     $view->conversion_rate_new = $this->formatConversionRate($goalMetrics, 'conversion_rate_new_visit');
     $view->idGoal = $idGoal;
     return $view->render();
 }
예제 #13
0
 public function render()
 {
     $lastMinutes = Config::getInstance()->General[Controller::SIMPLE_VISIT_COUNT_WIDGET_LAST_MINUTES_CONFIG_KEY];
     $lastNData = Request::processRequest('Live.getCounters', array('lastMinutes' => $lastMinutes));
     $view = new View('@Live/getSimpleLastVisitCount');
     $view->lastMinutes = $lastMinutes;
     $view->visitors = MetricsFormatter::getPrettyNumber($lastNData[0]['visitors']);
     $view->visits = MetricsFormatter::getPrettyNumber($lastNData[0]['visits']);
     $view->actions = MetricsFormatter::getPrettyNumber($lastNData[0]['actions']);
     $view->refreshAfterXSecs = Config::getInstance()->General['live_widget_refresh_after_seconds'];
     $view->translations = array('one_visitor' => Piwik::translate('Live_NbVisitor'), 'visitors' => Piwik::translate('Live_NbVisitors'), 'one_visit' => Piwik::translate('General_OneVisit'), 'visits' => Piwik::translate('General_NVisits'), 'one_action' => Piwik::translate('General_OneAction'), 'actions' => Piwik::translate('VisitsSummary_NbActionsDescription'), 'one_minute' => Piwik::translate('General_OneMinute'), 'minutes' => Piwik::translate('General_NMinutes'));
     return $view->render();
 }
예제 #14
0
파일: Widget.php 프로젝트: piwik/piwik
 /**
  * Assigns the given variables to the template and renders it.
  *
  * Example:
  *
  *     public function myControllerAction () {
  *        return $this->renderTemplate('index', array(
  *            'answerToLife' => '42'
  *        ));
  *     }
  *
  * This will render the 'index.twig' file within the plugin templates folder and assign the view variable
  * `answerToLife` to `42`.
  *
  * @param string $template   The name of the template file. If only a name is given it will automatically use
  *                           the template within the plugin folder. For instance 'myTemplate' will result in
  *                           '@$pluginName/myTemplate.twig'. Alternatively you can include the full path:
  *                           '@anyOtherFolder/otherTemplate'. The trailing '.twig' is not needed.
  * @param array $variables   For instance array('myViewVar' => 'myValue'). In template you can use {{ myViewVar }}
  * @return string
  * @api
  */
 protected function renderTemplate($template, array $variables = array())
 {
     if (false === strpos($template, '@') || false === strpos($template, '/')) {
         $aPluginName = explode('\\', get_class($this));
         $aPluginName = $aPluginName[2];
         $template = '@' . $aPluginName . '/' . $template;
     }
     $view = new View($template);
     foreach ($variables as $key => $value) {
         $view->{$key} = $value;
     }
     return $view->render();
 }
예제 #15
0
 public function index()
 {
     $view = new View('@UserSettings/index');
     $view->dataTablePlugin = $this->getPlugin(true);
     $view->dataTableResolution = $this->getResolution(true);
     $view->dataTableConfiguration = $this->getConfiguration(true);
     $view->dataTableOS = $this->getOS(true);
     $view->dataTableBrowser = $this->getBrowser(true);
     $view->dataTableBrowserType = $this->getBrowserType(true);
     $view->dataTableMobileVsDesktop = $this->getMobileVsDesktop(true);
     $view->dataTableBrowserLanguage = $this->getLanguage(true);
     return $view->render();
 }
예제 #16
0
파일: Sms.php 프로젝트: dorelljames/piwik
 public function renderReport($processedReport)
 {
     $isGoalPluginEnabled = Common::isGoalPluginEnabled();
     $prettyDate = $processedReport['prettyDate'];
     $reportData = $processedReport['reportData'];
     $evolutionMetrics = array();
     $multiSitesAPIMetrics = API::getApiMetrics($enhanced = true);
     foreach ($multiSitesAPIMetrics as $metricSettings) {
         $evolutionMetrics[] = $metricSettings[API::METRIC_EVOLUTION_COL_NAME_KEY];
     }
     $floatRegex = self::FLOAT_REGEXP;
     // no decimal for all metrics to shorten SMS content (keeps the monetary sign for revenue metrics)
     $reportData->filter('ColumnCallbackReplace', array(array_merge(array_keys($multiSitesAPIMetrics), $evolutionMetrics), function ($value) use($floatRegex) {
         return preg_replace_callback($floatRegex, function ($matches) {
             return round($matches[0]);
         }, $value);
     }));
     // evolution metrics formatting :
     //  - remove monetary, percentage and white spaces to shorten SMS content
     //    (this is also needed to be able to test $value != 0 and see if there is an evolution at all in SMSReport.twig)
     //  - adds a plus sign
     $reportData->filter('ColumnCallbackReplace', array($evolutionMetrics, function ($value) use($floatRegex) {
         $matched = preg_match($floatRegex, $value, $matches);
         $formatted = $matched ? sprintf("%+d", $matches[0]) : $value;
         return \Piwik\NumberFormatter::getInstance()->formatPercentEvolution($formatted);
     }));
     $dataRows = $reportData->getRows();
     $reportMetadata = $processedReport['reportMetadata'];
     $reportRowsMetadata = $reportMetadata->getRows();
     $siteHasECommerce = array();
     foreach ($reportRowsMetadata as $rowMetadata) {
         $idSite = $rowMetadata->getColumn('idsite');
         $siteHasECommerce[$idSite] = Site::isEcommerceEnabledFor($idSite);
     }
     $view = new View('@MobileMessaging/SMSReport');
     $view->assign("isGoalPluginEnabled", $isGoalPluginEnabled);
     $view->assign("reportRows", $dataRows);
     $view->assign("reportRowsMetadata", $reportRowsMetadata);
     $view->assign("prettyDate", $prettyDate);
     $view->assign("siteHasECommerce", $siteHasECommerce);
     $view->assign("displaySiteName", $processedReport['metadata']['action'] == 'getAll');
     // segment
     $segment = $processedReport['segment'];
     $displaySegment = $segment != null;
     $view->assign("displaySegment", $displaySegment);
     if ($displaySegment) {
         $view->assign("segmentName", $segment['name']);
     }
     $this->rendering .= $view->render();
 }
예제 #17
0
파일: Installation.php 프로젝트: cemo/piwik
 public function displayDbConnectionMessage($exception = null)
 {
     Common::sendResponseCode(500);
     $errorMessage = $exception->getMessage();
     if (Request::isApiRequest($_GET)) {
         $ex = new DatabaseConnectionFailedException($errorMessage);
         throw $ex;
     }
     $view = new PiwikView("@Installation/cannotConnectToDb");
     $view->exceptionMessage = $errorMessage;
     $ex = new DatabaseConnectionFailedException($view->render());
     $ex->setIsHtmlMessage();
     throw $ex;
 }
예제 #18
0
파일: Controller.php 프로젝트: Abine/piwik
 /**
  * @param bool $standalone When set to true, the Top controls will be hidden to provide better full screen view
  * @param bool $fetch
  * @param bool|string $segmentOverride
  *
  * @return string
  */
 public function realtimeMap($standalone = false, $fetch = false, $segmentOverride = false)
 {
     $this->checkUserCountryPluginEnabled();
     $idSite = Common::getRequestVar('idSite', 1, 'int');
     Piwik::checkUserHasViewAccess($idSite);
     $token_auth = Piwik::getCurrentUserTokenAuth();
     $view = new View('@UserCountryMap/realtimeMap');
     $view->mapIsStandaloneNotWidget = $standalone;
     $view->metrics = $this->getMetrics($idSite, 'range', self::REAL_TIME_WINDOW, $token_auth);
     $view->defaultMetric = 'nb_visits';
     $liveRefreshAfterMs = (int) Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000;
     $goals = APIGoals::getInstance()->getGoals($idSite);
     $site = new Site($idSite);
     $hasGoals = !empty($goals) || $site->isEcommerceEnabled();
     // maximum number of visits to be displayed in the map
     $maxVisits = Common::getRequestVar('filter_limit', 100, 'int');
     // some translations
     $locale = array('nb_actions' => Piwik::translate('VisitsSummary_NbActionsDescription'), 'local_time' => Piwik::translate('VisitTime_ColumnLocalTime'), 'from' => Piwik::translate('General_FromReferrer'), 'seconds' => Piwik::translate('UserCountryMap_Seconds'), 'seconds_ago' => Piwik::translate('UserCountryMap_SecondsAgo'), 'minutes' => Piwik::translate('UserCountryMap_Minutes'), 'minutes_ago' => Piwik::translate('UserCountryMap_MinutesAgo'), 'hours' => Piwik::translate('UserCountryMap_Hours'), 'hours_ago' => Piwik::translate('UserCountryMap_HoursAgo'), 'days_ago' => Piwik::translate('UserCountryMap_DaysAgo'), 'actions' => Piwik::translate('VisitsSummary_NbPageviewsDescription'), 'searches' => Piwik::translate('UserCountryMap_Searches'), 'goal_conversions' => Piwik::translate('UserCountryMap_GoalConversions'));
     $segment = $segmentOverride ?: Request::getRawSegmentFromRequest() ?: '';
     $params = array('period' => 'range', 'idSite' => $idSite, 'segment' => $segment, 'token_auth' => $token_auth);
     $realtimeWindow = Common::getRequestVar('realtimeWindow', self::REAL_TIME_WINDOW, 'string');
     if ($realtimeWindow != 'false') {
         // handle special value
         $params['date'] = $realtimeWindow;
     }
     $reqParams = $this->getEnrichedRequest($params, $encode = false);
     $view->config = array('metrics' => array(), 'svgBasePath' => $view->piwikUrl . 'plugins/UserCountryMap/svg/', 'liveRefreshAfterMs' => $liveRefreshAfterMs, '_' => $locale, 'reqParams' => $reqParams, 'siteHasGoals' => $hasGoals, 'maxVisits' => $maxVisits, 'changeVisitAlpha' => Common::getRequestVar('changeVisitAlpha', true, 'int'), 'removeOldVisits' => Common::getRequestVar('removeOldVisits', true, 'int'), 'showFooterMessage' => Common::getRequestVar('showFooterMessage', true, 'int'), 'showDateTime' => Common::getRequestVar('showDateTime', true, 'int'), 'doNotRefreshVisits' => Common::getRequestVar('doNotRefreshVisits', false, 'int'), 'enableAnimation' => Common::getRequestVar('enableAnimation', true, 'int'), 'forceNowValue' => Common::getRequestVar('forceNowValue', false, 'int'));
     return $view->render();
 }
예제 #19
0
 /**
  * Called on Core install, update, plugin enable/disable
  * Will clear all cache that could be affected by the change in configuration being made
  */
 public static function deleteAllCacheOnUpdate($pluginName = false)
 {
     AssetManager::getInstance()->removeMergedAssets($pluginName);
     View::clearCompiledTemplates();
     Cache::deleteTrackerCache();
     self::clearPhpCaches();
 }
예제 #20
0
 public function indexSiteSearch()
 {
     $view = new View('@Actions/indexSiteSearch');
     $keyword = Report::factory($this->pluginName, 'getSiteSearchKeywords');
     $noResult = Report::factory($this->pluginName, 'getSiteSearchNoResultKeywords');
     $pageUrls = Report::factory($this->pluginName, 'getPageUrlsFollowingSiteSearch');
     $view->keywords = $keyword->render();
     $view->noResultKeywords = $noResult->render();
     $view->pagesUrlsFollowingSiteSearch = $pageUrls->render();
     $categoryTrackingEnabled = Actions::isCustomVariablesPluginsEnabled();
     if ($categoryTrackingEnabled) {
         $categories = Report::factory($this->pluginName, 'getSiteSearchCategories');
         $view->categories = $categories->render();
     }
     return $view->render();
 }
예제 #21
0
 /**
  * @return View
  * @throws \Exception
  */
 public function getOptOutView()
 {
     if ($this->view) {
         return $this->view;
     }
     $trackVisits = !IgnoreCookie::isIgnoreCookieFound();
     $dntFound = $this->getDoNotTrackHeaderChecker()->isDoNotTrackFound();
     $setCookieInNewWindow = Common::getRequestVar('setCookieInNewWindow', false, 'int');
     if ($setCookieInNewWindow) {
         $reloadUrl = Url::getCurrentQueryStringWithParametersModified(array('showConfirmOnly' => 1, 'setCookieInNewWindow' => 0));
     } else {
         $reloadUrl = false;
         $nonce = Common::getRequestVar('nonce', false);
         if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) {
             Nonce::discardNonce('Piwik_OptOut');
             IgnoreCookie::setIgnoreCookie();
             $trackVisits = !$trackVisits;
         }
     }
     $language = Common::getRequestVar('language', '');
     $lang = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
     $this->view = new View("@CoreAdminHome/optOut");
     $this->view->setXFrameOptions('allow');
     $this->view->dntFound = $dntFound;
     $this->view->trackVisits = $trackVisits;
     $this->view->nonce = Nonce::getNonce('Piwik_OptOut', 3600);
     $this->view->language = $lang;
     $this->view->showConfirmOnly = Common::getRequestVar('showConfirmOnly', false, 'int');
     $this->view->reloadUrl = $reloadUrl;
     $this->view->javascripts = $this->getJavascripts();
     $this->view->stylesheets = $this->getStylesheets();
     $this->view->title = $this->getTitle();
     return $this->view;
 }
예제 #22
0
파일: Controller.php 프로젝트: piwik/piwik
 public function getConversionsOverview()
 {
     $view = new View('@Ecommerce/conversionOverview');
     $idGoal = Common::getRequestVar('idGoal', null, 'string');
     $goalMetrics = Request::processRequest('Goals.get', array('idGoal' => $idGoal));
     $dataRow = $goalMetrics->getFirstRow();
     $view->idSite = Common::getRequestVar('idSite', null, 'int');
     $view->idGoal = $idGoal;
     if ($dataRow) {
         $view->revenue = $dataRow->getColumn('revenue');
         $view->revenue_subtotal = $dataRow->getColumn('revenue_subtotal');
         $view->revenue_tax = $dataRow->getColumn('revenue_tax');
         $view->revenue_shipping = $dataRow->getColumn('revenue_shipping');
         $view->revenue_discount = $dataRow->getColumn('revenue_discount');
     }
     return $view->render();
 }
예제 #23
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct("@TestRunner/travis.yml");
     $this->setTestsToRun(array());
     $this->setTestsToExclude(array());
     $this->setTravisShScriptLocation("\$PIWIK_ROOT_DIR/tests/travis/travis.sh");
     $this->setTravisShCwd("tests/PHPUnit");
 }
예제 #24
0
 /**
  * @internal For Debugging only
  * Call metadata reports and draw the default graph for each report.
  */
 public function index()
 {
     Piwik::checkUserHasSomeAdminAccess();
     $idSite = Common::getRequestVar('idSite', 1, 'int');
     $period = Common::getRequestVar('period', 'day', 'string');
     $date = Common::getRequestVar('date', 'today', 'string');
     $_GET['token_auth'] = Piwik::getCurrentUserTokenAuth();
     $reports = APIPlugins::getInstance()->getReportMetadata($idSite, $period, $date);
     $plot = array();
     foreach ($reports as $report) {
         if (!empty($report['imageGraphUrl'])) {
             $plot[] = array($report['category'] . ' › ' . $report['name'], SettingsPiwik::getPiwikUrl() . $report['imageGraphUrl']);
         }
     }
     $view = new View('@ImageGraph/index');
     $view->titleAndUrls = $plot;
     return $view->render();
 }
예제 #25
0
 public function getMeasurableTypeSettings()
 {
     $idSite = Common::getRequestVar('idSite', 0, 'int');
     $idType = Common::getRequestVar('idType', '', 'string');
     if ($idSite >= 1) {
         Piwik::checkUserHasAdminAccess($idSite);
     } else {
         if ($idSite === 0) {
             Piwik::checkUserHasSomeAdminAccess();
         } else {
             throw new Exception('Invalid idSite parameter. IdSite has to be zero or higher');
         }
     }
     $view = new View('@SitesManager/measurable_type_settings');
     $propSettings = new MeasurableSettings($idSite, $idType);
     $view->settings = $propSettings->getSettingsForCurrentUser();
     return $view->render();
 }
예제 #26
0
 /**
  * Generate the reports for the dashboard
  * @return View
  */
 public function index()
 {
     $view = new View('@CampaignDetailed/index');
     $view->graphEvolutionCampaigns = $this->getCampaignEvolutionGraph();
     $view->graphPieCampaigns = $this->getCampaignPieReport();
     $view->graphKeywords = $this->getKeywordPieReport();
     $view->graphMediums = $this->getMediumBarReport();
     $view->graphContents = $this->getContentBarReport();
     $view->graphSources = $this->getSourcePieReport();
     $distinctMetrics = $this->getDistinctUtmMetrics();
     foreach ($distinctMetrics as $name => $value) {
         $view->{$name} = $value;
     }
     $view->sparklineCampaign = $this->getUrlSparkline('getNumberOfDistinctCampaignSparkline');
     $view->sparklineKeyword = $this->getUrlSparkline('getNumberOfDistinctKeywordSparkline');
     $view->sparklineMedium = $this->getUrlSparkline('getNumberOfDistinctMediumSparkline');
     $view->sparklineContent = $this->getUrlSparkline('getNumberOfDistinctContentSparkline');
     $view->sparklineSource = $this->getUrlSparkline('getNumberOfDistinctSourceSparkline');
     return $view->render();
 }
예제 #27
0
 function getRank()
 {
     $idSite = Common::getRequestVar('idSite');
     $site = new Site($idSite);
     $url = urldecode(Common::getRequestVar('url', '', 'string'));
     if (!empty($url) && strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
         $url = 'http://' . $url;
     }
     if (empty($url) || !UrlHelper::isLookLikeUrl($url)) {
         $url = $site->getMainUrl();
     }
     $dataTable = API::getInstance()->getRank($url);
     $view = new View('@SEO/getRank');
     $view->urlToRank = RankChecker::extractDomainFromUrl($url);
     /** @var \Piwik\DataTable\Renderer\Php $renderer */
     $renderer = Renderer::factory('php');
     $renderer->setSerialize(false);
     $view->ranks = $renderer->render($dataTable);
     return $view->render();
 }
예제 #28
0
 protected function indexEvent($controllerMethod)
 {
     $count = 1;
     $apiMethod = str_replace('index', 'get', $controllerMethod, $count);
     $events = new Events();
     $title = $events->getReportTitleTranslation($apiMethod);
     if (method_exists($this, $apiMethod)) {
         $content = $this->{$apiMethod}();
     } else {
         $content = $this->renderReport($apiMethod);
     }
     return View::singleReport($title, $content);
 }
예제 #29
0
 public function renderReportMenu(Report $report)
 {
     Piwik::checkUserHasSomeViewAccess();
     $this->checkSitePermission();
     $report->checkIsEnabled();
     $menuTitle = $report->getMenuTitle();
     if (empty($menuTitle)) {
         throw new Exception('This report is not supposed to be displayed in the menu, please define a $menuTitle in your report.');
     }
     $menuTitle = $this->translator->translate($menuTitle);
     $content = $this->renderReportWidget($report);
     return View::singleReport($menuTitle, $content);
 }
예제 #30
-1
 /**
  * send email to Piwik team and display nice thanks
  * @throws Exception
  */
 function sendFeedback()
 {
     $email = Common::getRequestVar('email', '', 'string');
     $body = Common::getRequestVar('body', '', 'string');
     $category = Common::getRequestVar('category', '', 'string');
     $nonce = Common::getRequestVar('nonce', '', 'string');
     $view = new View('@Feedback/sendFeedback');
     $view->feedbackEmailAddress = Config::getInstance()->General['feedback_email_address'];
     try {
         $minimumBodyLength = 40;
         if (strlen($body) < $minimumBodyLength || strpos($email, 'probe@') !== false || strpos($body, '&lt;probe') !== false) {
             throw new Exception(Piwik::translate('Feedback_ExceptionBodyLength', array($minimumBodyLength)));
         }
         if (!Piwik::isValidEmailString($email)) {
             throw new Exception(Piwik::translate('UsersManager_ExceptionInvalidEmail'));
         }
         if (preg_match('/https?:/i', $body)) {
             throw new Exception(Piwik::translate('Feedback_ExceptionNoUrls'));
         }
         if (!Nonce::verifyNonce('Feedback.sendFeedback', $nonce)) {
             throw new Exception(Piwik::translate('General_ExceptionNonceMismatch'));
         }
         Nonce::discardNonce('Feedback.sendFeedback');
         $mail = new Mail();
         $mail->setFrom(Common::unsanitizeInputValue($email));
         $mail->addTo($view->feedbackEmailAddress, 'Piwik Team');
         $mail->setSubject('[ Feedback form - Piwik ] ' . $category);
         $mail->setBodyText(Common::unsanitizeInputValue($body) . "\n" . 'Piwik ' . Version::VERSION . "\n" . 'IP: ' . IP::getIpFromHeader() . "\n" . 'URL: ' . Url::getReferrer() . "\n");
         @$mail->send();
     } catch (Exception $e) {
         $view->errorString = $e->getMessage();
         $view->message = $body;
     }
     return $view->render();
 }