diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2013-11-18 07:02:19 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2013-11-18 07:02:19 +0400 |
commit | 9060f0180cb935efd1925942d3a8ce1cf309459a (patch) | |
tree | b474d8758f3b45063e4bd430f5daa028b369c879 | |
parent | 4658d92891093982d979e7ec8343ee4ccc510a38 (diff) |
getting rid of the fetch parameter
43 files changed, 398 insertions, 440 deletions
diff --git a/core/Plugin/Controller.php b/core/Plugin/Controller.php index 0f50fd3ce4..9aab2584b3 100644 --- a/core/Plugin/Controller.php +++ b/core/Plugin/Controller.php @@ -56,7 +56,7 @@ use Piwik\API\Proxy; * { * $view = new View("@MyPlugin/index.twig"); * // ... setup view ... - * echo $view->render(); + * return $view->render(); * } * } * @@ -193,29 +193,22 @@ abstract class Controller * A helper method that renders a view either to the screen or to a string. * * @param ViewInterface $view The view to render. - * @param bool $fetch If true, the result is returned as a string. If false, - * the rendered string is echo'd to the screen. * @return string|void * @api */ - protected function renderView(ViewInterface $view, $fetch = false) + protected function renderView(ViewInterface $view) { - $rendered = $view->render(); - if ($fetch) { - return $rendered; - } - echo $rendered; + return $view->render(); } /** * Convenience method that creates and renders a ViewDataTable for a API method. * * @param string $apiAction The name of the API action (eg, getResolution). - * @param bool $fetch If true, the result is returned, if false it is echo'd. * @throws \Exception - * @return string|null See $fetch. + * @return string */ - protected function renderReport($apiAction, $fetch = true) + protected function renderReport($apiAction) { $pluginName = $this->pluginName; @@ -231,11 +224,7 @@ abstract class Controller $view = ViewDataTableFactory::build(null, $apiAction); $rendered = $view->render(); - if ($fetch) { - return $rendered; - } else { - echo $rendered; - } + return $rendered; } /** diff --git a/core/View.php b/core/View.php index 229de35dd9..6b8e5d9e94 100644 --- a/core/View.php +++ b/core/View.php @@ -346,15 +346,12 @@ class View implements ViewInterface * @param bool $fetch If true, return report contents as a string; otherwise echo to screen. * @return string|void The report contents if `$fetch` is true. */ - static public function singleReport($title, $reportHtml, $fetch = false) + static public function singleReport($title, $reportHtml) { $view = new View('@CoreHome/_singleReport'); $view->title = $title; $view->report = $reportHtml; - if ($fetch) { - return $view->render(); - } - echo $view->render(); + return $view->render(); } }
\ No newline at end of file @@ -53,5 +53,9 @@ if (!defined('PIWIK_ENABLE_ERROR_HANDLER') || PIWIK_ENABLE_ERROR_HANDLER) { if (!defined('PIWIK_ENABLE_DISPATCH') || PIWIK_ENABLE_DISPATCH) { $controller = FrontController::getInstance(); $controller->init(); - $controller->dispatch(); + $response = $controller->dispatch(); + + if (!is_null($response)) { + echo $response; + } } diff --git a/plugins/API/Controller.php b/plugins/API/Controller.php index 8e8842858d..0ef5f3fa17 100644 --- a/plugins/API/Controller.php +++ b/plugins/API/Controller.php @@ -31,13 +31,13 @@ class Controller extends \Piwik\Plugin\Controller $_GET['filter_limit'] = Config::getInstance()->General['API_datatable_default_limit']; } $request = new Request('token_auth=' . Common::getRequestVar('token_auth', 'anonymous', 'string')); - echo $request->process(); + return $request->process(); } public function listAllMethods() { $ApiDocumentation = new DocumentationGenerator(); - echo $ApiDocumentation->getAllInterfaceString($outputExampleUrls = true, $prefixUrls = Common::getRequestVar('prefixUrl', '')); + return $ApiDocumentation->getAllInterfaceString($outputExampleUrls = true, $prefixUrls = Common::getRequestVar('prefixUrl', '')); } public function listAllAPI() @@ -48,7 +48,7 @@ class Controller extends \Piwik\Plugin\Controller $ApiDocumentation = new DocumentationGenerator(); $view->countLoadedAPI = Proxy::getInstance()->getCountRegisteredClasses(); $view->list_api_methods_with_links = $ApiDocumentation->getAllInterfaceString(); - echo $view->render(); + return $view->render(); } public function listSegments() @@ -113,7 +113,7 @@ class Controller extends \Piwik\Plugin\Controller } } - echo " + return " <strong>Dimensions</strong> <table> $tableDimensions diff --git a/plugins/Actions/Controller.php b/plugins/Actions/Controller.php index c279ab5fbf..1bc9e97ed9 100644 --- a/plugins/Actions/Controller.php +++ b/plugins/Actions/Controller.php @@ -25,25 +25,25 @@ class Controller extends \Piwik\Plugin\Controller // Actions that render whole pages // - public function indexPageUrls($fetch = false) + public function indexPageUrls() { return View::singleReport( Piwik::translate('General_Pages'), - $this->getPageUrls(true), $fetch); + $this->getPageUrls(true)); } - public function indexEntryPageUrls($fetch = false) + public function indexEntryPageUrls() { return View::singleReport( Piwik::translate('Actions_SubmenuPagesEntry'), - $this->getEntryPageUrls(true), $fetch); + $this->getEntryPageUrls(true)); } - public function indexExitPageUrls($fetch = false) + public function indexExitPageUrls() { return View::singleReport( Piwik::translate('Actions_SubmenuPagesExit'), - $this->getExitPageUrls(true), $fetch); + $this->getExitPageUrls(true)); } public function indexSiteSearch() @@ -59,96 +59,96 @@ class Controller extends \Piwik\Plugin\Controller $view->categories = $this->getSiteSearchCategories(true); } - echo $view->render(); + return $view->render(); } - public function indexPageTitles($fetch = false) + public function indexPageTitles() { return View::singleReport( Piwik::translate('Actions_SubmenuPageTitles'), - $this->getPageTitles(true), $fetch); + $this->getPageTitles(true)); } - public function indexDownloads($fetch = false) + public function indexDownloads() { return View::singleReport( Piwik::translate('General_Downloads'), - $this->getDownloads(true), $fetch); + $this->getDownloads(true)); } - public function indexOutlinks($fetch = false) + public function indexOutlinks() { return View::singleReport( Piwik::translate('General_Outlinks'), - $this->getOutlinks(true), $fetch); + $this->getOutlinks(true)); } // // Actions that render individual reports // - public function getPageUrls($fetch = false) + public function getPageUrls() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getEntryPageUrls($fetch = false) + public function getEntryPageUrls() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getExitPageUrls($fetch = false) + public function getExitPageUrls() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getSiteSearchKeywords($fetch = false) + public function getSiteSearchKeywords() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getSiteSearchNoResultKeywords($fetch = false) + public function getSiteSearchNoResultKeywords() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getSiteSearchCategories($fetch = false) + public function getSiteSearchCategories() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getPageUrlsFollowingSiteSearch($fetch = false) + public function getPageUrlsFollowingSiteSearch() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getPageTitlesFollowingSiteSearch($fetch = false) + public function getPageTitlesFollowingSiteSearch() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getPageTitles($fetch = false) + public function getPageTitles() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getEntryPageTitles($fetch = false) + public function getEntryPageTitles() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getExitPageTitles($fetch = false) + public function getExitPageTitles() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getDownloads($fetch = false) + public function getDownloads() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getOutlinks($fetch = false) + public function getOutlinks() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } } diff --git a/plugins/Annotations/Controller.php b/plugins/Annotations/Controller.php index bc9ee5c5e8..f43b50480e 100755 --- a/plugins/Annotations/Controller.php +++ b/plugins/Annotations/Controller.php @@ -80,11 +80,7 @@ class Controller extends \Piwik\Plugin\Controller $view->canUserAddNotes = AnnotationList::canUserAddNotesFor($idSite); - if ($fetch) { - return $view->render(); - } else { - echo $view->render(); - } + return $view->render(); } /** @@ -115,7 +111,7 @@ class Controller extends \Piwik\Plugin\Controller // save the annotation $view->annotation = Request::processRequest("Annotations.save"); - echo $view->render(); + return $view->render(); } } @@ -156,7 +152,7 @@ class Controller extends \Piwik\Plugin\Controller $managerDate = Common::getRequestVar('managerDate', false); $managerPeriod = Common::getRequestVar('managerPeriod', false); - echo $this->getAnnotationManager($fetch = true, $managerDate, $managerPeriod); + return $this->getAnnotationManager($fetch = true, $managerDate, $managerPeriod); } } @@ -185,7 +181,7 @@ class Controller extends \Piwik\Plugin\Controller // delete annotation. NOTE: permissions checked in API method Request::processRequest("Annotations.delete"); - echo $this->getAnnotationManager($fetch = true); + return $this->getAnnotationManager($fetch = true); } } @@ -217,6 +213,6 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@Annotations/getEvolutionIcons'); $view->annotationCounts = reset($annotationCounts); // only one idSite allowed for this action - echo $view->render(); + return $view->render(); } } diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php index c7139239b8..e2d0267df8 100644 --- a/plugins/CoreAdminHome/Controller.php +++ b/plugins/CoreAdminHome/Controller.php @@ -89,7 +89,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->language = LanguagesManager::getLanguageCodeForCurrentUser(); $this->setBasicVariablesView($view); - echo $view->render(); + return $view->render(); } public function pluginSettings() @@ -105,7 +105,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $this->setBasicVariablesView($view); - echo $view->render(); + return $view->render(); } private function getPluginSettings() @@ -145,11 +145,10 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $nonce = Common::getRequestVar('nonce', null, 'string'); if (!Nonce::verifyNonce(static::SET_PLUGIN_SETTINGS_NONCE, $nonce)) { - echo json_encode(array( + return json_encode(array( 'result' => 'error', 'message' => Piwik::translate('General_ExceptionNonceMismatch') )); - return; } $pluginsSettings = SettingsManager::getPluginSettingsForCurrentUser(); @@ -173,12 +172,11 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } catch (Exception $e) { $message = html_entity_decode($e->getMessage(), ENT_QUOTES, 'UTF-8'); - echo json_encode(array('result' => 'error', 'message' => $message)); - return; + return json_encode(array('result' => 'error', 'message' => $message)); } Nonce::discardNonce(static::SET_PLUGIN_SETTINGS_NONCE); - echo json_encode(array('result' => 'success')); + return json_encode(array('result' => 'success')); } private function findSettingValueFromRequest($pluginName, $settingKey) @@ -244,7 +242,8 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } catch (Exception $e) { $toReturn = $response->getResponseException($e); } - echo $toReturn; + + return $toReturn; } /** @@ -281,7 +280,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->serverSideDoNotTrackEnabled = \Piwik\Plugins\PrivacyManager\Controller::isDntSupported(); - echo $view->render(); + return $view->render(); } /** @@ -305,7 +304,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->language = APILanguagesManager::getInstance()->isLanguageAvailable($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser(); - echo $view->render(); + return $view->render(); } public function uploadCustomLogo() @@ -314,14 +313,12 @@ class Controller extends \Piwik\Plugin\ControllerAdmin if (empty($_FILES['customLogo']) || !empty($_FILES['customLogo']['error']) ) { - echo '0'; - return; + return '0'; } $file = $_FILES['customLogo']['tmp_name']; if (!file_exists($file)) { - echo '0'; - return; + return '0'; } list($width, $height) = getimagesize($file); @@ -336,8 +333,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $image = imagecreatefromgif($file); break; default: - echo '0'; - return; + return '0'; } $widthExpected = round($width * self::LOGO_HEIGHT / $height); @@ -350,7 +346,6 @@ class Controller extends \Piwik\Plugin\ControllerAdmin imagepng($logo, PIWIK_DOCUMENT_ROOT . '/misc/user/logo.png', 3); imagepng($logoSmall, PIWIK_DOCUMENT_ROOT . '/misc/user/logo-header.png', 3); - echo '1'; - return; + return '1'; } } diff --git a/plugins/CoreHome/Controller.php b/plugins/CoreHome/Controller.php index aa5aa9df13..34bef570f8 100644 --- a/plugins/CoreHome/Controller.php +++ b/plugins/CoreHome/Controller.php @@ -67,7 +67,7 @@ class Controller extends \Piwik\Plugin\Controller } $view = $this->getDefaultIndexView(); $view->content = FrontController::getInstance()->fetchDispatch($controllerName, $actionName); - echo $view->render(); + return $view->render(); } public function markNotificationAsRead() @@ -113,7 +113,7 @@ class Controller extends \Piwik\Plugin\Controller { $this->setDateTodayIfWebsiteCreatedToday(); $view = $this->getDefaultIndexView(); - echo $view->render(); + return $view->render(); } // -------------------------------------------------------- @@ -127,7 +127,7 @@ class Controller extends \Piwik\Plugin\Controller { $rowEvolution = $this->makeRowEvolution($isMulti = false); $view = new View('@CoreHome/getRowEvolutionPopover'); - echo $rowEvolution->renderPopover($this, $view); + return $rowEvolution->renderPopover($this, $view); } /** Render the entire row evolution popover for multiple rows */ @@ -135,7 +135,7 @@ class Controller extends \Piwik\Plugin\Controller { $rowEvolution = $this->makeRowEvolution($isMulti = true); $view = new View('@CoreHome/getMultiRowEvolutionPopover'); - echo $rowEvolution->renderPopover($this, $view); + return $rowEvolution->renderPopover($this, $view); } /** Generic method to get an evolution graph or a sparkline for the row evolution popover */ @@ -150,7 +150,7 @@ class Controller extends \Piwik\Plugin\Controller } $view = $rowEvolution->getRowEvolutionGraph(); - return $this->renderView($view, $fetch); + return $this->renderView($view); } /** Utility function. Creates a RowEvolution instance. */ @@ -180,7 +180,7 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@CoreHome/checkForUpdates'); $this->setGeneralVariablesView($view); - echo $view->render(); + return $view->render(); } /** @@ -194,7 +194,7 @@ class Controller extends \Piwik\Plugin\Controller ) { $view->footerMessage = Piwik::translate('CoreHome_OnlyForAdmin'); } - echo $view->render(); + return $view->render(); } /** @@ -206,7 +206,7 @@ class Controller extends \Piwik\Plugin\Controller $view->shareText = Piwik::translate('CoreHome_SharePiwikShort'); $view->shareTextLong = Piwik::translate('CoreHome_SharePiwikLong'); $view->promoVideoUrl = 'http://www.youtube.com/watch?v=OslfF_EH81g'; - echo $view->render(); + return $view->render(); } /** diff --git a/plugins/CorePluginsAdmin/Controller.php b/plugins/CorePluginsAdmin/Controller.php index 8538521a5f..b681be1bab 100644 --- a/plugins/CorePluginsAdmin/Controller.php +++ b/plugins/CorePluginsAdmin/Controller.php @@ -69,7 +69,7 @@ class Controller extends Plugin\ControllerAdmin public function updatePlugin() { $view = $this->createUpdateOrInstallView('updatePlugin', static::UPDATE_NONCE); - echo $view->render(); + return $view->render(); } public function installPlugin() @@ -77,7 +77,7 @@ class Controller extends Plugin\ControllerAdmin $view = $this->createUpdateOrInstallView('installPlugin', static::INSTALL_NONCE); $view->nonce = Nonce::getNonce(static::ACTIVATE_NONCE); - echo $view->render(); + return $view->render(); } public function uploadPlugin() @@ -118,7 +118,7 @@ class Controller extends Plugin\ControllerAdmin 'isActivated' => \Piwik\Plugin\Manager::getInstance()->isPluginActivated($pluginMetadata->name) ); - echo $view->render(); + return $view->render(); } public function pluginDetails() @@ -136,7 +136,7 @@ class Controller extends Plugin\ControllerAdmin $view->errorMessage = $e->getMessage(); } - echo $view->render(); + return $view->render(); } private function dieIfMarketplaceIsDisabled() @@ -174,13 +174,13 @@ class Controller extends Plugin\ControllerAdmin public function browsePlugins() { $view = $this->createBrowsePluginsOrThemesView('browsePlugins', $themesOnly = false); - echo $view->render(); + return $view->render(); } public function browseThemes() { $view = $this->createBrowsePluginsOrThemesView('browseThemes', $themesOnly = true); - echo $view->render(); + return $view->render(); } function extend() @@ -191,7 +191,7 @@ class Controller extends Plugin\ControllerAdmin $view->installNonce = Nonce::getNonce(static::INSTALL_NONCE); $view->isSuperUser = Piwik::isUserIsSuperUser(); - echo $view->render(); + return $view->render(); } private function createPluginsOrThemesView($template, $themesOnly) @@ -226,13 +226,13 @@ class Controller extends Plugin\ControllerAdmin function plugins() { $view = $this->createPluginsOrThemesView('plugins', $themesOnly = false); - echo $view->render(); + return $view->render(); } function themes() { $view = $this->createPluginsOrThemesView('themes', $themesOnly = true); - echo $view->render(); + return $view->render(); } protected function configureView($template) diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php index d9065cb78e..b5eb986ead 100644 --- a/plugins/CoreUpdater/Controller.php +++ b/plugins/CoreUpdater/Controller.php @@ -67,7 +67,7 @@ class Controller extends \Piwik\Plugin\Controller $view->piwik_latest_version_url = self::getLatestZipUrl($newVersion); $view->can_auto_update = Filechecks::canAutoUpdate(); $view->makeWritableCommands = Filechecks::getAutoUpdateMakeWritableMessage(); - echo $view->render(); + return $view->render(); } public function oneClickUpdate() @@ -105,7 +105,7 @@ class Controller extends \Piwik\Plugin\Controller $view = new OneClickDone(Piwik::getCurrentUserTokenAuth()); $view->coreError = $errorMessage; $view->feedbackMessages = $messages; - echo $view->render(); + return $view->render(); } public function oneClickResults() @@ -116,7 +116,7 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@CoreUpdater/oneClickResults'); $view->coreError = Common::getRequestVar('error', '', 'string', $_POST); $view->feedbackMessages = safe_unserialize(Common::unsanitizeInputValue(Common::getRequestVar('messages', '', 'string', $_POST))); - echo $view->render(); + return $view->render(); } protected function redirectToDashboardWhenNoError($updater) @@ -271,7 +271,8 @@ class Controller extends \Piwik\Plugin\Controller if (!empty($language)) { LanguagesManager::setLanguageForSession($language); } - $this->runUpdaterAndExit(); + + return $this->runUpdaterAndExit(); } protected function runUpdaterAndExit() @@ -292,12 +293,15 @@ class Controller extends \Piwik\Plugin\Controller if (Common::isPhpCliMode()) { $this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile); - echo $viewWelcome->render(); + $output = $viewWelcome->render(); if (!$this->coreError && Piwik::getModule() == 'CoreUpdater') { $this->doExecuteUpdates($viewDone, $updater, $componentsWithUpdateFile); - echo $viewDone->render(); + $output .= $viewDone->render(); } + + return $output; + } else { if (Common::getRequestVar('updateCorePlugins', 0, 'integer') == 1) { $this->warningMessages = array(); @@ -305,12 +309,12 @@ class Controller extends \Piwik\Plugin\Controller $this->redirectToDashboardWhenNoError($updater); - echo $viewDone->render(); + return $viewDone->render(); } else { $viewWelcome->queries = $updater->getSqlQueriesToExecute(); $viewWelcome->isMajor = $updater->hasMajorDbUpdate(); $this->doWelcomeUpdates($viewWelcome, $componentsWithUpdateFile); - echo $viewWelcome->render(); + return $viewWelcome->render(); } } exit; diff --git a/plugins/CustomVariables/Controller.php b/plugins/CustomVariables/Controller.php index c7f55de4fa..35d1525cf9 100644 --- a/plugins/CustomVariables/Controller.php +++ b/plugins/CustomVariables/Controller.php @@ -19,21 +19,21 @@ use Piwik\ViewDataTable\Factory; */ class Controller extends \Piwik\Plugin\Controller { - public function index($fetch = false) + public function index() { return View::singleReport( Piwik::translate('CustomVariables_CustomVariables'), - $this->getCustomVariables(true), $fetch); + $this->getCustomVariables(true)); } - public function getCustomVariables($fetch = false) + public function getCustomVariables() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getCustomVariablesValuesFromNameId($fetch = false) + public function getCustomVariablesValuesFromNameId() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } } diff --git a/plugins/DBStats/Controller.php b/plugins/DBStats/Controller.php index 2cf1dcc0d7..22e95c23d6 100644 --- a/plugins/DBStats/Controller.php +++ b/plugins/DBStats/Controller.php @@ -44,91 +44,78 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->userCount = MetricsFormatter::getPrettyNumber($userCount); $view->totalSpaceUsed = MetricsFormatter::getPrettySizeFromBytes($totalSpaceUsed); - echo $view->render(); + return $view->render(); } /** * Shows a datatable that displays how much space the tracker tables, numeric * archive tables, report tables and other tables take up in the MySQL database. * - * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise, - * it is echoed. * @return string */ - public function getDatabaseUsageSummary($fetch = false) + public function getDatabaseUsageSummary() { Piwik::checkUserIsSuperUser(); - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** * Shows a datatable that displays the amount of space each individual log table * takes up in the MySQL database. - * - * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise, - * it is echoed. * @return string|void */ - public function getTrackerDataSummary($fetch = false) + public function getTrackerDataSummary() { Piwik::checkUserIsSuperUser(); - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** * Shows a datatable that displays the amount of space each numeric archive table * takes up in the MySQL database. * - * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise, - * it is echoed. * @return string|void */ - public function getMetricDataSummary($fetch = false) + public function getMetricDataSummary() { Piwik::checkUserIsSuperUser(); - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** * Shows a datatable that displays the amount of space each numeric archive table * takes up in the MySQL database, for each year of numeric data. * - * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise, - * it is echoed. * @return string|void */ - public function getMetricDataSummaryByYear($fetch = false) + public function getMetricDataSummaryByYear() { Piwik::checkUserIsSuperUser(); - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** * Shows a datatable that displays the amount of space each blob archive table * takes up in the MySQL database. * - * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise, - * it is echoed. * @return string|void */ - public function getReportDataSummary($fetch = false) + public function getReportDataSummary() { Piwik::checkUserIsSuperUser(); - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** * Shows a datatable that displays the amount of space each blob archive table * takes up in the MySQL database, for each year of blob data. * - * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise, - * it is echoed. * @return string|void */ - public function getReportDataSummaryByYear($fetch = false) + public function getReportDataSummaryByYear() { Piwik::checkUserIsSuperUser(); - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** @@ -137,14 +124,12 @@ class Controller extends \Piwik\Plugin\ControllerAdmin * * Goal reports and reports of the format: .*_[0-9]+ are grouped together. * - * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise, - * it is echoed. * @return string|void */ - public function getIndividualReportsSummary($fetch = false) + public function getIndividualReportsSummary() { Piwik::checkUserIsSuperUser(); - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** @@ -153,14 +138,12 @@ class Controller extends \Piwik\Plugin\ControllerAdmin * * Goal metrics, metrics of the format .*_[0-9]+ and 'done...' metrics are grouped together. * - * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise, - * it is echoed. * @return string|void */ - public function getIndividualMetricsSummary($fetch = false) + public function getIndividualMetricsSummary() { Piwik::checkUserIsSuperUser(); - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** @@ -170,13 +153,11 @@ class Controller extends \Piwik\Plugin\ControllerAdmin * An 'admin' table is a table that is not central to analytics functionality. * So any table that isn't an archive table or a log table is an 'admin' table. * - * @param bool $fetch If true, the rendered HTML datatable is returned, otherwise, - * it is echoed. * @return string|void */ - public function getAdminDataSummary($fetch = false) + public function getAdminDataSummary() { Piwik::checkUserIsSuperUser(); - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } } diff --git a/plugins/Dashboard/Controller.php b/plugins/Dashboard/Controller.php index 7fd5666bf7..d8bab8424d 100644 --- a/plugins/Dashboard/Controller.php +++ b/plugins/Dashboard/Controller.php @@ -54,7 +54,7 @@ class Controller extends \Piwik\Plugin\Controller { $view = $this->_getDashboardView('@Dashboard/embeddedIndex'); - echo $view->render(); + return $view->render(); } public function index() @@ -66,7 +66,7 @@ class Controller extends \Piwik\Plugin\Controller $view->dashboards = $this->dashboard->getAllDashboards($login); } - echo $view->render(); + return $view->render(); } public function getAvailableWidgets() @@ -74,7 +74,7 @@ class Controller extends \Piwik\Plugin\Controller $this->checkTokenInUrl(); Json::sendHeaderJSON(); - echo Common::json_encode(WidgetsList::get()); + return Common::json_encode(WidgetsList::get()); } public function getDashboardLayout() @@ -85,7 +85,7 @@ class Controller extends \Piwik\Plugin\Controller $layout = $this->getLayout($idDashboard); - echo $layout; + return $layout; } /** @@ -165,16 +165,14 @@ class Controller extends \Piwik\Plugin\Controller if (Piwik::isUserIsAnonymous()) { Json::sendHeaderJSON(); - echo '[]'; - - return; + return '[]'; } $login = Piwik::getCurrentUserLogin(); $dashboards = $this->dashboard->getAllDashboards($login); Json::sendHeaderJSON(); - echo Common::json_encode($dashboards); + return Common::json_encode($dashboards); } /** @@ -186,8 +184,7 @@ class Controller extends \Piwik\Plugin\Controller $this->checkTokenInUrl(); if (Piwik::isUserIsAnonymous()) { - echo '0'; - return; + return '0'; } $user = Piwik::getCurrentUserLogin(); $nextId = $this->getNextIdDashboard($user); @@ -205,7 +202,7 @@ class Controller extends \Piwik\Plugin\Controller Db::query($query, array($user, $nextId, $name, $layout)); Json::sendHeaderJSON(); - echo Common::json_encode($nextId); + return Common::json_encode($nextId); } private function getNextIdDashboard($login) @@ -226,8 +223,7 @@ class Controller extends \Piwik\Plugin\Controller $this->checkTokenInUrl(); if (!Piwik::isUserIsSuperUser()) { - echo '0'; - return; + return '0'; } $login = Piwik::getCurrentUserLogin(); $name = urldecode(Common::getRequestVar('name', '', 'string')); @@ -243,8 +239,7 @@ class Controller extends \Piwik\Plugin\Controller Db::query($query, array($user, $nextId, $name, $layout)); Json::sendHeaderJSON(); - echo Common::json_encode($nextId); - return; + return Common::json_encode($nextId); } } diff --git a/plugins/DevicesDetection/Controller.php b/plugins/DevicesDetection/Controller.php index 694b75ef30..511e648109 100644 --- a/plugins/DevicesDetection/Controller.php +++ b/plugins/DevicesDetection/Controller.php @@ -19,7 +19,7 @@ use UserAgentParserEnhanced; class Controller extends \Piwik\Plugin\Controller { - public function index($fetch = false) + public function index() { $view = new View('@DevicesDetection/index'); $view->deviceTypes = $view->deviceModels = $view->deviceBrands = $view->osReport = $view->browserReport = "blank"; @@ -28,42 +28,42 @@ class Controller extends \Piwik\Plugin\Controller $view->deviceModels = $this->getModel(true); $view->osReport = $this->getOsFamilies(true); $view->browserReport = $this->getBrowserFamilies(true); - echo $view->render(); + return $view->render(); } - public function getType($fetch = false) + public function getType() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getBrand($fetch = false) + public function getBrand() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getModel($fetch = false) + public function getModel() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getOsFamilies($fetch = false) + public function getOsFamilies() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getOsVersions($fetch = false) + public function getOsVersions() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getBrowserFamilies($fetch = false) + public function getBrowserFamilies() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getBrowserVersions($fetch = false) + public function getBrowserVersions() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** @@ -74,18 +74,23 @@ class Controller extends \Piwik\Plugin\Controller Piwik::checkUserIsSuperUser(); $q = "SELECT idvisit, config_debug_ua FROM " . Common::prefixTable("log_visit"); $res = Db::fetchAll($q); + + $output = ''; + foreach ($res as $rec) { $UAParser = new UserAgentParserEnhanced($rec['config_debug_ua']); $UAParser->parse(); - echo "Processing idvisit = " . $rec['idvisit'] . "<br/>"; - echo "UserAgent string: " . $rec['config_debug_ua'] . "<br/> Decoded values:"; + $output .= "Processing idvisit = " . $rec['idvisit'] . "<br/>"; + $output .= "UserAgent string: " . $rec['config_debug_ua'] . "<br/> Decoded values:"; $uaDetails = $this->getArray($UAParser); var_export($uaDetails); - echo "<hr/>"; + $output .= "<hr/>"; $this->updateVisit($rec['idvisit'], $uaDetails); unset($UAParser); } - echo "Please remember to truncate your archives !"; + $output .= "Please remember to truncate your archives !"; + + return $output; } private function getArray(UserAgentParserEnhanced $UAParser) diff --git a/plugins/ExamplePlugin/Controller.php b/plugins/ExamplePlugin/Controller.php index ed927a0638..460bcd9c0b 100644 --- a/plugins/ExamplePlugin/Controller.php +++ b/plugins/ExamplePlugin/Controller.php @@ -25,6 +25,6 @@ class Controller extends \Piwik\Plugin\Controller $this->setBasicVariablesView($view); $view->answerToLife = '42'; - echo $view->render(); + return $view->render(); } } diff --git a/plugins/ExampleRssWidget/Controller.php b/plugins/ExampleRssWidget/Controller.php index 12058ca7a9..fe3a7551a5 100644 --- a/plugins/ExampleRssWidget/Controller.php +++ b/plugins/ExampleRssWidget/Controller.php @@ -25,9 +25,9 @@ class Controller extends \Piwik\Plugin\Controller try { $rss = new RssRenderer('http://feeds.feedburner.com/Piwik'); $rss->showDescription(true); - echo $rss->get(); + return $rss->get(); } catch (Exception $e) { - $this->error($e); + return $this->error($e); } } @@ -38,9 +38,9 @@ class Controller extends \Piwik\Plugin\Controller $rss->setCountPosts(1); $rss->showDescription(true); $rss->showContent(false); - echo $rss->get(); + return $rss->get(); } catch (Exception $e) { - $this->error($e); + return $this->error($e); } } @@ -49,7 +49,7 @@ class Controller extends \Piwik\Plugin\Controller */ protected function error($e) { - echo '<div class="pk-emptyDataTable">' + return '<div class="pk-emptyDataTable">' . Piwik::translate('General_ErrorRequest') . ' - ' . $e->getMessage() . '</div>'; } diff --git a/plugins/ExampleUI/Controller.php b/plugins/ExampleUI/Controller.php index d2edc17ca9..8279334292 100644 --- a/plugins/ExampleUI/Controller.php +++ b/plugins/ExampleUI/Controller.php @@ -41,7 +41,7 @@ class Controller extends \Piwik\Plugin\Controller $view->config->max_graph_elements = 24; $view->config->metrics_documentation = array('value' => 'Documentation for temperature metric'); - echo $view->render(); + return $view->render(); } public function evolutionGraph() @@ -51,7 +51,7 @@ class Controller extends \Piwik\Plugin\Controller $this->setPeriodVariablesView($view); $view->evolutionGraph = $this->getEvolutionGraph(true, array('server1', 'server2')); - echo $view->render(); + return $view->render(); } public function notifications() @@ -78,7 +78,7 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@ExampleUI/notifications'); $this->setGeneralVariablesView($view); - echo $view->render(); + return $view->render(); } public function getEvolutionGraph($fetch = false, array $columns = array()) @@ -92,7 +92,7 @@ class Controller extends \Piwik\Plugin\Controller $selectableColumns = array('server1', 'server2'), 'My documentation', 'ExampleUI.getTemperaturesEvolution'); $view->requestConfig->filter_sort_column = 'label'; - return $this->renderView($view, $fetch); + return $this->renderView($view); } public function barGraph() @@ -106,7 +106,7 @@ class Controller extends \Piwik\Plugin\Controller $view->config->selectable_columns = array("value"); $view->config->max_graph_elements = 24; - echo $view->render(); + return $view->render(); } public function pieGraph() @@ -120,20 +120,22 @@ class Controller extends \Piwik\Plugin\Controller $view->config->selectable_columns = array("value"); $view->config->max_graph_elements = 10; - echo $view->render(); + return $view->render(); } public function tagClouds() { - echo "<h2>Simple tag cloud</h2>"; - $this->echoSimpleTagClouds(); + $output = "<h2>Simple tag cloud</h2>"; + $output .= $this->echoSimpleTagClouds(); - echo "<br /><br /><h2>Advanced tag cloud: with logos and links</h2> + $output .= "<br /><br /><h2>Advanced tag cloud: with logos and links</h2> <ul style='list-style-type:disc;margin-left:50px'> <li>The logo size is proportional to the value returned by the API</li> <li>The logo is linked to a specific URL</li> </ul><br /><br />"; - $this->echoAdvancedTagClouds(); + $output .= $this->echoAdvancedTagClouds(); + + return $output; } public function echoSimpleTagClouds() @@ -145,7 +147,7 @@ class Controller extends \Piwik\Plugin\Controller $view->config->translations['value'] = "times the diameter of Earth"; $view->config->show_footer = false; - echo $view->render(); + return $view->render(); } public function echoAdvancedTagClouds() @@ -157,7 +159,7 @@ class Controller extends \Piwik\Plugin\Controller $view->config->columns_to_display = array('label', 'value'); $view->config->translations['value'] = "times the diameter of Earth"; - echo $view->render(); + return $view->render(); } public function sparklines() @@ -166,7 +168,7 @@ class Controller extends \Piwik\Plugin\Controller $view->urlSparkline1 = $this->getUrlSparkline('generateSparkline', array('server' => 'server1', 'rand' => mt_rand())); $view->urlSparkline2 = $this->getUrlSparkline('generateSparkline', array('server' => 'server2', 'rand' => mt_rand())); - echo $view->render(); + return $view->render(); } public function generateSparkline() @@ -179,6 +181,6 @@ class Controller extends \Piwik\Plugin\Controller $view->config->columns_to_display = array($serverRequested); } - echo $view->render(); + return $view->render(); } } diff --git a/plugins/Feedback/Controller.php b/plugins/Feedback/Controller.php index 412cea69ab..30f420fecb 100644 --- a/plugins/Feedback/Controller.php +++ b/plugins/Feedback/Controller.php @@ -31,7 +31,7 @@ class Controller extends \Piwik\Plugin\Controller { $view = new View('@Feedback/index'); $view->nonce = Nonce::getNonce('Feedback.sendFeedback', 3600); - echo $view->render(); + return $view->render(); } /** @@ -81,6 +81,6 @@ class Controller extends \Piwik\Plugin\Controller $view->message = $body; } - echo $view->render(); + return $view->render(); } } diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php index 94e48dc25b..441cae6b85 100644 --- a/plugins/Goals/Controller.php +++ b/plugins/Goals/Controller.php @@ -74,14 +74,14 @@ class Controller extends \Piwik\Plugin\Controller { $view = $this->getGoalReportView($idGoal = Common::getRequestVar('idGoal', null, 'string')); $view->displayFullReport = false; - echo $view->render(); + return $view->render(); } public function goalReport() { $view = $this->getGoalReportView($idGoal = Common::getRequestVar('idGoal', null, 'string')); $view->displayFullReport = true; - echo $view->render(); + return $view->render(); } public function ecommerceReport() @@ -92,7 +92,7 @@ class Controller extends \Piwik\Plugin\Controller $view = $this->getGoalReportView($idGoal = Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER); $view->displayFullReport = true; - echo $view->render(); + return $view->render(); } public function getEcommerceLog($fetch = false) @@ -168,14 +168,14 @@ class Controller extends \Piwik\Plugin\Controller $view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite); $view->ecommerceEnabled = $this->site->isEcommerceEnabled(); $view->displayFullReport = true; - echo $view->render(); + return $view->render(); } public function widgetGoalsOverview() { $view = $this->getOverviewView(); $view->displayFullReport = false; - echo $view->render(); + return $view->render(); } protected function getOverviewView() @@ -214,22 +214,22 @@ class Controller extends \Piwik\Plugin\Controller return $view; } - public function getLastNbConversionsGraph($fetch = false) + public function getLastNbConversionsGraph() { $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getConversions'); - return $this->renderView($view, $fetch); + return $this->renderView($view); } - public function getLastConversionRateGraph($fetch = false) + public function getLastConversionRateGraph() { $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getConversionRate'); - return $this->renderView($view, $fetch); + return $this->renderView($view); } - public function getLastRevenueGraph($fetch = false) + public function getLastRevenueGraph() { $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getRevenue'); - return $this->renderView($view, $fetch); + return $this->renderView($view); } public function addNewGoal() @@ -238,10 +238,10 @@ class Controller extends \Piwik\Plugin\Controller $this->setGeneralVariablesView($view); $view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite); $view->onlyShowAddNewGoal = true; - echo $view->render(); + return $view->render(); } - public function getEvolutionGraph($fetch = false, array $columns = array(), $idGoal = false) + public function getEvolutionGraph(array $columns = array(), $idGoal = false) { if (empty($columns)) { $columns = Common::getRequestVar('columns'); @@ -294,7 +294,7 @@ class Controller extends \Piwik\Plugin\Controller $langString = $idGoal ? 'Goals_SingleGoalOverviewDocumentation' : 'Goals_GoalsOverviewDocumentation'; $view->config->documentation = Piwik::translate($langString, '<br />'); - return $this->renderView($view, $fetch); + return $this->renderView($view); } protected function getTopDimensions($idGoal) @@ -460,28 +460,28 @@ class Controller extends \Piwik\Plugin\Controller // Report rendering actions // - public function getItemsSku($fetch = false) + public function getItemsSku() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getItemsName($fetch = false) + public function getItemsName() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getItemsCategory($fetch = false) + public function getItemsCategory() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getVisitsUntilConversion($fetch = false) + public function getVisitsUntilConversion() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getDaysToConversion($fetch = false) + public function getDaysToConversion() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } } diff --git a/plugins/ImageGraph/Controller.php b/plugins/ImageGraph/Controller.php index 52cd75d013..de7186d79d 100644 --- a/plugins/ImageGraph/Controller.php +++ b/plugins/ImageGraph/Controller.php @@ -40,7 +40,7 @@ class Controller extends \Piwik\Plugin\Controller } $view = new View('@ImageGraph/index'); $view->titleAndUrls = $plot; - echo $view->render(); + return $view->render(); } // Draw graphs for all sizes (DEBUG) @@ -73,6 +73,6 @@ class Controller extends \Piwik\Plugin\Controller array(800, 150), // landscape mode array(600, 300, $fontSize = 18, 300, 150), // iphone requires bigger font, then it will be scaled down by ios ); - echo $view->render(); + return $view->render(); } } diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index d6cb3630f9..4001d99f05 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -116,7 +116,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $this->skipThisStep(__FUNCTION__); $view->showNextStep = $view->newInstall; $this->session->currentStepDone = __FUNCTION__; - echo $view->render(); + return $view->render(); } /** @@ -153,7 +153,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $this->session->currentStepDone = __FUNCTION__; - echo $view->render(); + return $view->render(); } /** @@ -197,7 +197,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } $view->addForm($form); - echo $view->render(); + return $view->render(); } /** @@ -255,7 +255,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin if ($error === false) { $this->redirectToNextStep(__FUNCTION__); } - echo $view->render(); + return $view->render(); } /** @@ -321,7 +321,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } $this->session->currentStepDone = __FUNCTION__; - echo $view->render(); + return $view->render(); } /** @@ -378,7 +378,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } $view->addForm($form); - echo $view->render(); + return $view->render(); } /** @@ -427,7 +427,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } } $view->addForm($form); - echo $view->render(); + return $view->render(); } /** @@ -464,7 +464,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->showNextStep = true; $this->session->currentStepDone = __FUNCTION__; - echo $view->render(); + return $view->render(); } /** @@ -490,9 +490,11 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->showNextStep = false; $this->session->currentStepDone = __FUNCTION__; - echo $view->render(); + $output = $view->render(); $this->session->unsetAll(); + + return $output; } /** @@ -521,7 +523,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $infos['extra'] = self::performAdminPageOnlySystemCheck(); $view->infos = $infos; - echo $view->render(); + return $view->render(); } /** @@ -596,7 +598,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin public function getBaseCss() { @header('Content-Type: text/css'); - echo AssetManager::getCompiledBaseCss(); + return AssetManager::getCompiledBaseCss(); } /** diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php index d89a8c549d..48c5ce49e8 100644 --- a/plugins/Live/Controller.php +++ b/plugins/Live/Controller.php @@ -27,12 +27,12 @@ class Controller extends \Piwik\Plugin\Controller { const SIMPLE_VISIT_COUNT_WIDGET_LAST_MINUTES_CONFIG_KEY = 'live_widget_visitor_count_last_minutes'; - function index($fetch = false) + function index() { - return $this->widget($fetch); + return $this->widget(); } - public function widget($fetch = false) + public function widget() { $view = new View('@Live/index'); $view->idSite = $this->idSite; @@ -40,10 +40,10 @@ class Controller extends \Piwik\Plugin\Controller $view->liveRefreshAfterMs = (int)Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000; $view->visitors = $this->getLastVisitsStart($fetchPlease = true); $view->liveTokenAuth = Piwik::getCurrentUserTokenAuth(); - return $this->render($view, $fetch); + return $this->render($view); } - public function getSimpleLastVisitCount($fetch = false) + public function getSimpleLastVisitCount() { $lastMinutes = Config::getInstance()->General[self::SIMPLE_VISIT_COUNT_WIDGET_LAST_MINUTES_CONFIG_KEY]; @@ -65,48 +65,46 @@ class Controller extends \Piwik\Plugin\Controller 'one_minute' => Piwik::translate('General_OneMinute'), 'minutes' => Piwik::translate('General_NMinutes') ); - return $this->render($view, $fetch); + return $this->render($view); } - public function ajaxTotalVisitors($fetch = false) + public function ajaxTotalVisitors() { $view = new View('@Live/ajaxTotalVisitors'); $view = $this->setCounters($view); $view->idSite = $this->idSite; - return $this->render($view, $fetch); + return $this->render($view); } - private function render(View $view, $fetch) + private function render(View $view) { $rendered = $view->render(); - if ($fetch) { - return $rendered; - } - echo $rendered; + + return $rendered; } public function indexVisitorLog() { $view = new View('@Live/indexVisitorLog.twig'); $view->filterEcommerce = Common::getRequestVar('filterEcommerce', 0, 'int'); - $view->visitorLog = $this->getLastVisitsDetails($fetch = true); - echo $view->render(); + $view->visitorLog = $this->getLastVisitsDetails(); + return $view->render(); } - public function getLastVisitsDetails($fetch = false) + public function getLastVisitsDetails() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** * @deprecated */ - public function getVisitorLog($fetch = false) + public function getVisitorLog() { - return $this->getLastVisitsDetails($fetch); + return $this->getLastVisitsDetails(); } - public function getLastVisitsStart($fetch = false) + public function getLastVisitsStart() { // hack, ensure we load today's visits by default $_GET['date'] = 'today'; @@ -118,7 +116,7 @@ class Controller extends \Piwik\Plugin\Controller $visitors = $api->process(); $view->visitors = $visitors; - return $this->render($view, $fetch); + return $this->render($view); } private function setCounters($view) @@ -157,7 +155,7 @@ class Controller extends \Piwik\Plugin\Controller $this->setWidgetizedVisitorProfileUrl($view); - echo $view->render(); + return $view->render(); } public function getSingleVisitSummary() @@ -173,7 +171,7 @@ class Controller extends \Piwik\Plugin\Controller $view->showLocation = true; $this->setWidgetizedVisitorProfileUrl($view); $view->exportLink = $this->getVisitorProfileExportLink(); - echo $view->render(); + return $view->render(); } public function getVisitList() @@ -194,7 +192,7 @@ class Controller extends \Piwik\Plugin\Controller $view->idSite = Common::getRequestVar('idSite', null, 'int'); $view->startCounter = Common::getRequestVar('filter_offset', 0, 'int') + 1; $view->visits = $nextVisits; - echo $view->render(); + return $view->render(); } private function getVisitorProfileExportLink() diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php index 09457414d9..7e94eb67b4 100644 --- a/plugins/Login/Controller.php +++ b/plugins/Login/Controller.php @@ -101,7 +101,8 @@ class Controller extends \Piwik\Plugin\Controller $view->addForm($form); $this->configureView($view); self::setHostValidationVariablesView($view); - echo $view->render(); + + return $view->render(); } /** @@ -212,7 +213,8 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@Login/resetPassword'); $view->infoMessage = $infoMessage; $view->formErrors = $formErrors; - echo $view->render(); + + return $view->render(); } /** diff --git a/plugins/MobileMessaging/Controller.php b/plugins/MobileMessaging/Controller.php index c6f7c62052..cce3fc5a16 100644 --- a/plugins/MobileMessaging/Controller.php +++ b/plugins/MobileMessaging/Controller.php @@ -76,6 +76,6 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $this->setBasicVariablesView($view); - echo $view->render(); + return $view->render(); } } diff --git a/plugins/MultiSites/Controller.php b/plugins/MultiSites/Controller.php index a48d86f1cc..0c16b07762 100644 --- a/plugins/MultiSites/Controller.php +++ b/plugins/MultiSites/Controller.php @@ -169,7 +169,7 @@ class Controller extends \Piwik\Plugin\Controller $this->setMaxDateView($maxDate, $view); $view->show_sparklines = Config::getInstance()->General['show_multisites_sparklines']; - echo $view->render(); + return $view->render(); } /** @@ -226,6 +226,6 @@ class Controller extends \Piwik\Plugin\Controller $api = "Goals.get"; } $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, $api); - return $this->renderView($view, $fetch); + return $this->renderView($view); } } diff --git a/plugins/Overlay/Controller.php b/plugins/Overlay/Controller.php index ee83bd0562..69ab26ec2b 100644 --- a/plugins/Overlay/Controller.php +++ b/plugins/Overlay/Controller.php @@ -46,7 +46,7 @@ class Controller extends \Piwik\Plugin\Controller $view->ssl = ProxyHttp::isHttps(); - echo $view->render(); + return $view->render(); } /** Render the area left of the iframe */ @@ -119,7 +119,7 @@ class Controller extends \Piwik\Plugin\Controller $view->idSite = $idSite; $view->period = $period; $view->date = $date; - echo $view->render(); + return $view->render(); } /** @@ -136,7 +136,7 @@ class Controller extends \Piwik\Plugin\Controller $urls = $sitesManager->getSiteUrlsFromId($idSite); @header('Content-Type: text/html; charset=UTF-8'); - echo ' + return ' <html><head><title></title></head><body> <script type="text/javascript"> function handleProtocol(url) { @@ -219,7 +219,7 @@ class Controller extends \Piwik\Plugin\Controller $view->troubleshoot = htmlentities(Piwik::translate('Overlay_RedirectUrlErrorUser')); } - echo $view->render(); + return $view->render(); } /** @@ -233,6 +233,6 @@ class Controller extends \Piwik\Plugin\Controller public function notifyParentIframe() { $view = new View('@Overlay/notifyParentIframe'); - echo $view->render(); + return $view->render(); } } diff --git a/plugins/PrivacyManager/Controller.php b/plugins/PrivacyManager/Controller.php index 5f9acc606f..f4f2a1b098 100644 --- a/plugins/PrivacyManager/Controller.php +++ b/plugins/PrivacyManager/Controller.php @@ -112,7 +112,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->dbStats = $this->getDeleteDBSizeEstimate($getSettingsFromQuery = true, $forceEstimate); $view->language = LanguagesManager::getLanguageCodeForCurrentUser(); - echo $view->render(); + return $view->render(); } /** @@ -142,7 +142,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->language = LanguagesManager::getLanguageCodeForCurrentUser(); $this->displayWarningIfConfigFileNotWritable(); $this->setBasicVariablesView($view); - echo $view->render(); + return $view->render(); } /** diff --git a/plugins/Provider/Controller.php b/plugins/Provider/Controller.php index bce277e6bf..3efa5ba1e6 100644 --- a/plugins/Provider/Controller.php +++ b/plugins/Provider/Controller.php @@ -20,12 +20,11 @@ class Controller extends \Piwik\Plugin\Controller { /** * Provider - * @param bool $fetch * @return string|void */ - public function getProvider($fetch = false) + public function getProvider() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } } diff --git a/plugins/Referrers/Controller.php b/plugins/Referrers/Controller.php index 48349f4e70..b5266b017e 100644 --- a/plugins/Referrers/Controller.php +++ b/plugins/Referrers/Controller.php @@ -90,7 +90,7 @@ class Controller extends \Piwik\Plugin\Controller $view->totalVisits = $totalVisits; $view->referrersReportsByDimension = $this->getReferrersReportsByDimensionView($totalVisits); - echo $view->render(); + return $view->render(); } /** @@ -134,12 +134,12 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@Referrers/getSearchEnginesAndKeywords'); $view->searchEngines = $this->getSearchEngines(true); $view->keywords = $this->getKeywords(true); - echo $view->render(); + return $view->render(); } - public function getReferrerType($fetch = false) + public function getReferrerType() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** @@ -150,78 +150,75 @@ class Controller extends \Piwik\Plugin\Controller * report is echo'd and nothing is returned. * @return string The report HTML or nothing if $fetch is set to false. */ - public function getAll($fetch = false) + public function getAll() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getKeywords($fetch = false) + public function getKeywords() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getSearchEnginesFromKeywordId($fetch = false) + public function getSearchEnginesFromKeywordId() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getSearchEngines($fetch = false) + public function getSearchEngines() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getKeywordsFromSearchEngineId($fetch = false) + public function getKeywordsFromSearchEngineId() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function indexWebsites($fetch = false) + public function indexWebsites() { $view = new View('@Referrers/indexWebsites'); $view->websites = $this->getWebsites(true); $view->socials = $this->getSocials(true); - if ($fetch) { - return $view->render(); - } else { - echo $view->render(); - } + + return $view->render(); } - public function getWebsites($fetch = false) + public function getWebsites() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getSocials($fetch = false) + public function getSocials() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getUrlsForSocial($fetch = false) + public function getUrlsForSocial() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function indexCampaigns($fetch = false) + public function indexCampaigns() { return View::singleReport( Piwik::translate('Referrers_Campaigns'), - $this->getCampaigns(true), $fetch); + $this->getCampaigns(true)); } - public function getCampaigns($fetch = false) + public function getCampaigns() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getKeywordsFromCampaignId($fetch = false) + public function getKeywordsFromCampaignId() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getUrlsFromWebsiteId($fetch = false) + public function getUrlsFromWebsiteId() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } protected function getReferrersVisitorsByType($date = false) @@ -309,39 +306,39 @@ class Controller extends \Piwik\Plugin\Controller . Piwik::translate('Referrers_EvolutionDocumentationMoreInfo', '"' . Piwik::translate('Referrers_DetailsByReferrerType') . '"'); - return $this->renderView($view, $fetch); + return $this->renderView($view); } - public function getLastDistinctSearchEnginesGraph($fetch = false) + public function getLastDistinctSearchEnginesGraph() { $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "Referrers.getNumberOfDistinctSearchEngines"); $view->config->translations['Referrers_distinctSearchEngines'] = ucfirst(Piwik::translate('Referrers_DistinctSearchEngines')); $view->config->columns_to_display = array('Referrers_distinctSearchEngines'); - return $this->renderView($view, $fetch); + return $this->renderView($view); } - public function getLastDistinctKeywordsGraph($fetch = false) + public function getLastDistinctKeywordsGraph() { $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "Referrers.getNumberOfDistinctKeywords"); $view->config->translations['Referrers_distinctKeywords'] = ucfirst(Piwik::translate('Referrers_DistinctKeywords')); $view->config->columns_to_display = array('Referrers_distinctKeywords'); - return $this->renderView($view, $fetch); + return $this->renderView($view); } - public function getLastDistinctWebsitesGraph($fetch = false) + public function getLastDistinctWebsitesGraph() { $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "Referrers.getNumberOfDistinctWebsites"); $view->config->translations['Referrers_distinctWebsites'] = ucfirst(Piwik::translate('Referrers_DistinctWebsites')); $view->config->columns_to_display = array('Referrers_distinctWebsites'); - return $this->renderView($view, $fetch); + return $this->renderView($view); } - public function getLastDistinctCampaignsGraph($fetch = false) + public function getLastDistinctCampaignsGraph() { $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "Referrers.getNumberOfDistinctCampaigns"); $view->config->translations['Referrers_distinctCampaigns'] = ucfirst(Piwik::translate('Referrers_DistinctCampaigns')); $view->config->columns_to_display = array('Referrers_distinctCampaigns'); - return $this->renderView($view, $fetch); + return $this->renderView($view); } function getKeywordsForPage() diff --git a/plugins/SEO/Controller.php b/plugins/SEO/Controller.php index 8483f7bbc3..153b3db868 100644 --- a/plugins/SEO/Controller.php +++ b/plugins/SEO/Controller.php @@ -45,6 +45,6 @@ class Controller extends \Piwik\Plugin\Controller $renderer = Renderer::factory('php'); $renderer->setSerialize(false); $view->ranks = $renderer->render($dataTable); - echo $view->render(); + return $view->render(); } } diff --git a/plugins/ScheduledReports/Controller.php b/plugins/ScheduledReports/Controller.php index 41c2e9a6f0..401e48e954 100644 --- a/plugins/ScheduledReports/Controller.php +++ b/plugins/ScheduledReports/Controller.php @@ -89,6 +89,6 @@ class Controller extends \Piwik\Plugin\Controller $view->segmentEditorActivated = true; } - echo $view->render(); + return $view->render(); } } diff --git a/plugins/SegmentEditor/Controller.php b/plugins/SegmentEditor/Controller.php index a71c844ff6..a3fd20fe8b 100644 --- a/plugins/SegmentEditor/Controller.php +++ b/plugins/SegmentEditor/Controller.php @@ -52,7 +52,7 @@ class Controller extends \Piwik\Plugin\Controller $view->segmentTranslations = Common::json_encode($this->getTranslations()); $out = $view->render(); - echo $out; + return $out; } public function sortSegmentCategories($a, $b) diff --git a/plugins/SitesManager/Controller.php b/plugins/SitesManager/Controller.php index 91d8688f91..f5350ad717 100644 --- a/plugins/SitesManager/Controller.php +++ b/plugins/SitesManager/Controller.php @@ -84,7 +84,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->showAddSite = (boolean)Common::getRequestVar('showaddsite', false); $this->setBasicVariablesView($view); - echo $view->render(); + return $view->render(); } /** @@ -120,7 +120,8 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } catch (Exception $e) { $toReturn = $response->getResponseException($e); } - echo $toReturn; + + return $toReturn; } /** @@ -138,7 +139,8 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $site = new Site($idSite); $view->displaySiteName = $site->getName(); $view->jsTag = $jsTag; - echo $view->render(); + + return $view->render(); } /** @@ -150,7 +152,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $filename = 'PiwikTracker.php'; header('Content-type: text/php'); header('Content-Disposition: attachment; filename="' . $filename . '"'); - echo file_get_contents($path . $filename); + return file_get_contents($path . $filename); } /** @@ -168,7 +170,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } $view->piwikUrlRequest = $url; $view->calledExternally = true; - echo $view->render(); + return $view->render(); } function getSitesForAutocompleter() diff --git a/plugins/Transitions/Controller.php b/plugins/Transitions/Controller.php index e4c80f2432..a135cf4394 100644 --- a/plugins/Transitions/Controller.php +++ b/plugins/Transitions/Controller.php @@ -80,7 +80,7 @@ class Controller extends \Piwik\Plugin\Controller { $view = new View('@Transitions/renderPopover'); $view->translations = $this->getTranslations(); - echo $view->render(); + return $view->render(); } public function getTranslations() diff --git a/plugins/UserCountry/Controller.php b/plugins/UserCountry/Controller.php index d3fb01889b..301d276f47 100644 --- a/plugins/UserCountry/Controller.php +++ b/plugins/UserCountry/Controller.php @@ -42,7 +42,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->dataTableRegion = $this->getRegion(true); $view->dataTableCity = $this->getCity(true); - echo $view->render(); + return $view->render(); } public function adminIndex() @@ -86,7 +86,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $this->setBasicVariablesView($view); $this->setBasicVariablesAdminView($view); - echo $view->render(); + return $view->render(); } /** @@ -134,9 +134,9 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $result['next_screen'] = $this->getGeoIpUpdaterManageScreen(); } - echo Common::json_encode($result); + return Common::json_encode($result); } catch (Exception $ex) { - echo Common::json_encode(array('error' => $ex->getMessage())); + return Common::json_encode(array('error' => $ex->getMessage())); } } } @@ -203,13 +203,12 @@ class Controller extends \Piwik\Plugin\ControllerAdmin // the browser so it can download it next $info = $this->getNextMissingDbUrlInfo(); if ($info !== false) { - echo Common::json_encode($info); - return; + return Common::json_encode($info); } else { - echo 1; + return 1; } } catch (Exception $ex) { - echo Common::json_encode(array('error' => $ex->getMessage())); + return Common::json_encode(array('error' => $ex->getMessage())); } } } @@ -263,14 +262,13 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $info = $this->getNextMissingDbUrlInfo(); if ($info !== false) { - echo Common::json_encode($info); - return; + return Common::json_encode($info); } } - echo Common::json_encode($result); + return Common::json_encode($result); } catch (Exception $ex) { - echo Common::json_encode(array('error' => $ex->getMessage())); + return Common::json_encode(array('error' => $ex->getMessage())); } } } @@ -295,7 +293,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin if ($provider === false) { throw new Exception("Invalid provider ID: '$providerId'."); } - echo 1; + return 1; } } @@ -322,51 +320,49 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $location = LocationProvider::prettyFormatLocation( $location, $newline = '<br/>', $includeExtra = true); - echo $location; + return $location; } - public function getCountry($fetch = false) + public function getCountry() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getContinent($fetch = false) + public function getContinent() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** * Echo's or returns an HTML view of the visits by region report. * - * @param bool $fetch If true, returns the HTML as a string, otherwise it is echo'd. * @return string */ - public function getRegion($fetch = false) + public function getRegion() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** * Echo's or returns an HTML view of the visits by city report. * - * @param bool $fetch If true, returns the HTML as a string, otherwise it is echo'd. * @return string */ - public function getCity($fetch = false) + public function getCity() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getNumberOfDistinctCountries($fetch = false) + public function getNumberOfDistinctCountries() { return $this->getNumericValue('UserCountry.getNumberOfDistinctCountries'); } - public function getLastDistinctCountriesGraph($fetch = false) + public function getLastDistinctCountriesGraph() { $view = $this->getLastUnitGraph('UserCountry', __FUNCTION__, "UserCountry.getNumberOfDistinctCountries"); $view->config->columns_to_display = array('UserCountry_distinctCountries'); - return $this->renderView($view, $fetch); + return $this->renderView($view); } /** diff --git a/plugins/UserCountryMap/Controller.php b/plugins/UserCountryMap/Controller.php index 182347b0c9..3f4b994f6b 100644 --- a/plugins/UserCountryMap/Controller.php +++ b/plugins/UserCountryMap/Controller.php @@ -29,7 +29,7 @@ class Controller extends \Piwik\Plugin\Controller // By default plot up to the last 30 days of visitors on the map, for low traffic sites const REAL_TIME_WINDOW = 'last30'; - public function visitorMap($fetch = false, $segmentOverride = false) + public function visitorMap($segmentOverride = false) { $this->checkUserCountryPluginEnabled(); @@ -95,11 +95,7 @@ class Controller extends \Piwik\Plugin\Controller $view->config = Common::json_encode($config); $view->noData = empty($config['visitsSummary']['nb_visits']); - if ($fetch) { - return $view->render(); - } else { - echo $view->render(); - } + return $view->render(); } /** @@ -189,11 +185,7 @@ class Controller extends \Piwik\Plugin\Controller 'forceNowValue' => Common::getRequestVar('forceNowValue', false, 'int') ); - if ($fetch) { - return $view->render(); - } else { - echo $view->render(); - } + return $view->render(); } private function getEnrichedRequest($params, $encode = true) diff --git a/plugins/UserSettings/Controller.php b/plugins/UserSettings/Controller.php index d0c7c42603..78b0836520 100644 --- a/plugins/UserSettings/Controller.php +++ b/plugins/UserSettings/Controller.php @@ -32,61 +32,61 @@ class Controller extends \Piwik\Plugin\Controller $view->dataTableMobileVsDesktop = $this->getMobileVsDesktop(true); $view->dataTableBrowserLanguage = $this->getLanguage(true); - echo $view->render(); + return $view->render(); } - public function getResolution($fetch = false) + public function getResolution() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getConfiguration($fetch = false) + public function getConfiguration() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getOS($fetch = false) + public function getOS() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getOSFamily($fetch = false) + public function getOSFamily() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getMobileVsDesktop($fetch = false) + public function getMobileVsDesktop() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getBrowserVersion($fetch = false) + public function getBrowserVersion() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getBrowser($fetch = false) + public function getBrowser() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getBrowserType($fetch = false) + public function getBrowserType() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getWideScreen($fetch = false) + public function getWideScreen() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getPlugin($fetch = false) + public function getPlugin() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getLanguage($fetch = false) + public function getLanguage() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } } diff --git a/plugins/UsersManager/Controller.php b/plugins/UsersManager/Controller.php index c00d18fd6a..28bb5ae091 100644 --- a/plugins/UsersManager/Controller.php +++ b/plugins/UsersManager/Controller.php @@ -97,7 +97,8 @@ class Controller extends \Piwik\Plugin\ControllerAdmin uasort($websites, array('Piwik\Plugins\UsersManager\Controller', 'orderByName')); $view->websites = $websites; $this->setBasicVariablesView($view); - echo $view->render(); + + return $view->render(); } private function hasAnonymousUserViewAccess($usersAccessByWebsite) @@ -173,7 +174,8 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $this->initViewAnonymousUserSettings($view); $view->piwikHost = Url::getCurrentHost(); $this->setBasicVariablesView($view); - echo $view->render(); + + return $view->render(); } public function setIgnoreCookie() @@ -251,7 +253,8 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } catch (Exception $e) { $toReturn = $response->getResponseException($e); } - echo $toReturn; + + return $toReturn; } /** @@ -329,6 +332,7 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } catch (Exception $e) { $toReturn = $response->getResponseException($e); } - echo $toReturn; + + return $toReturn; } }
\ No newline at end of file diff --git a/plugins/VisitFrequency/Controller.php b/plugins/VisitFrequency/Controller.php index 5117be02f6..f746553b3e 100644 --- a/plugins/VisitFrequency/Controller.php +++ b/plugins/VisitFrequency/Controller.php @@ -26,14 +26,14 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@VisitFrequency/index'); $view->graphEvolutionVisitFrequency = $this->getEvolutionGraph(true, array('nb_visits_returning')); $this->setSparklinesAndNumbers($view); - echo $view->render(); + return $view->render(); } public function getSparklines() { $view = new View('@VisitFrequency/getSparklines'); $this->setSparklinesAndNumbers($view); - echo $view->render(); + return $view->render(); } public function getEvolutionGraph($fetch = false, array $columns = array()) @@ -77,7 +77,7 @@ class Controller extends \Piwik\Plugin\Controller $view = $this->getLastUnitGraphAcrossPlugins($this->pluginName, __FUNCTION__, $columns, $selectableColumns, $documentation); - return $this->renderView($view, $fetch); + return $this->renderView($view); } protected function setSparklinesAndNumbers($view) diff --git a/plugins/VisitTime/Controller.php b/plugins/VisitTime/Controller.php index b16a6b6e5f..e43ce2d4c7 100644 --- a/plugins/VisitTime/Controller.php +++ b/plugins/VisitTime/Controller.php @@ -24,21 +24,21 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@VisitTime/index'); $view->dataTableVisitInformationPerLocalTime = $this->getVisitInformationPerLocalTime(true); $view->dataTableVisitInformationPerServerTime = $this->getVisitInformationPerServerTime(true); - echo $view->render(); + return $view->render(); } - public function getVisitInformationPerServerTime($fetch = false) + public function getVisitInformationPerServerTime() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getVisitInformationPerLocalTime($fetch = false) + public function getVisitInformationPerLocalTime() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getByDayOfWeek($fetch = false) + public function getByDayOfWeek() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } } diff --git a/plugins/VisitorInterest/Controller.php b/plugins/VisitorInterest/Controller.php index a17b2e74ca..d57650f3d7 100644 --- a/plugins/VisitorInterest/Controller.php +++ b/plugins/VisitorInterest/Controller.php @@ -25,40 +25,38 @@ class Controller extends \Piwik\Plugin\Controller $view->dataTableNumberOfVisitsPerPage = $this->getNumberOfVisitsPerPage(true); $view->dataTableNumberOfVisitsByVisitNum = $this->getNumberOfVisitsByVisitCount(true); $view->dataTableNumberOfVisitsByDaysSinceLast = $this->getNumberOfVisitsByDaysSinceLast(true); - echo $view->render(); + return $view->render(); } - public function getNumberOfVisitsPerVisitDuration($fetch = false) + public function getNumberOfVisitsPerVisitDuration() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } - public function getNumberOfVisitsPerPage($fetch = false) + public function getNumberOfVisitsPerPage() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** * Returns a report that lists the count of visits for different ranges of * a visitor's visit number. * - * @param bool $fetch Whether to return the rendered view as a string or echo it. * @return string The rendered report or nothing if $fetch is set to false. */ - public function getNumberOfVisitsByVisitCount($fetch = false) + public function getNumberOfVisitsByVisitCount() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } /** * Returns a rendered report that lists the count of visits for different ranges * of days since a visitor's last visit. * - * @param bool $fetch Whether to return the rendered view as a string or echo it. * @return string The rendered report or nothing if $fetch is set to false. */ - public function getNumberOfVisitsByDaysSinceLast($fetch = false) + public function getNumberOfVisitsByDaysSinceLast() { - return $this->renderReport(__FUNCTION__, $fetch); + return $this->renderReport(__FUNCTION__); } } diff --git a/plugins/VisitsSummary/Controller.php b/plugins/VisitsSummary/Controller.php index f434c6f6dc..d9e6549b04 100644 --- a/plugins/VisitsSummary/Controller.php +++ b/plugins/VisitsSummary/Controller.php @@ -31,7 +31,7 @@ class Controller extends \Piwik\Plugin\Controller $this->setPeriodVariablesView($view); $view->graphEvolutionVisitsSummary = $this->getEvolutionGraph(true, array('nb_visits')); $this->setSparklinesAndNumbers($view); - echo $view->render(); + return $view->render(); } public function getSparklines() @@ -39,7 +39,7 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@VisitsSummary/getSparklines'); $this->setPeriodVariablesView($view); $this->setSparklinesAndNumbers($view); - echo $view->render(); + return $view->render(); } public function getEvolutionGraph($fetch = false, array $columns = array()) @@ -94,7 +94,7 @@ class Controller extends \Piwik\Plugin\Controller $view = $this->getLastUnitGraphAcrossPlugins($this->pluginName, __FUNCTION__, $columns, $selectableColumns, $documentation); - return $this->renderView($view, $fetch); + return $this->renderView($view); } static public function getVisitsSummary() diff --git a/plugins/Widgetize/Controller.php b/plugins/Widgetize/Controller.php index 885a5b7983..bf0a9ac1bc 100644 --- a/plugins/Widgetize/Controller.php +++ b/plugins/Widgetize/Controller.php @@ -27,7 +27,7 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@Widgetize/index'); $view->availableWidgets = Common::json_encode(WidgetsList::get()); $this->setGeneralVariablesView($view); - echo $view->render(); + return $view->render(); } public function testJsInclude1() @@ -35,7 +35,7 @@ class Controller extends \Piwik\Plugin\Controller $view = new View('@Widgetize/testJsInclude1'); $view->url1 = '?module=Widgetize&action=js&moduleToWidgetize=UserSettings&actionToWidgetize=getBrowser&idSite=1&period=day&date=yesterday'; $view->url2 = '?module=Widgetize&action=js&moduleToWidgetize=API&actionToWidgetize=index&method=ExamplePlugin.getGoldenRatio&format=original'; - echo $view->render(); + return $view->render(); } public function testJsInclude2() @@ -44,7 +44,7 @@ class Controller extends \Piwik\Plugin\Controller $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'; - echo $view->render(); + return $view->render(); } public function iframe() @@ -63,6 +63,6 @@ class Controller extends \Piwik\Plugin\Controller $this->setGeneralVariablesView($view); $view->setXFrameOptions('allow'); $view->content = $outputDataTable; - echo $view->render(); + return $view->render(); } } |