diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-07-23 11:52:15 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-07-23 11:52:15 +0400 |
commit | 5104d94f3b2250f766b9c520e2da8da9b4cab2e9 (patch) | |
tree | 5f30daf7bc14373fb1bbd0504ce11a771dafc02f /core/ReportRenderer | |
parent | ae4b1f4e38077b174e4df5b7d4513d63fe026a24 (diff) |
Refs #4059 Work in progress: Conversion to use Namespaces of dozen more classes
Removed many Piwik_ functions, in Piwik 2 it is best practise to use the methods calls instead
Todo: finish converting core/ classes + convert plugins/ classes to use \Piwik\Plugin namespace + fix build + Merge master
Diffstat (limited to 'core/ReportRenderer')
-rw-r--r-- | core/ReportRenderer/Html.php | 38 | ||||
-rw-r--r-- | core/ReportRenderer/Pdf.php | 37 |
2 files changed, 42 insertions, 33 deletions
diff --git a/core/ReportRenderer/Html.php b/core/ReportRenderer/Html.php index 0f72de2aaf..e1d30734c4 100644 --- a/core/ReportRenderer/Html.php +++ b/core/ReportRenderer/Html.php @@ -6,16 +6,20 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * * @category Piwik - * @package Piwik_ReportRenderer + * @package ReportRenderer */ -use Piwik\Piwik; +namespace Piwik\ReportRenderer; +use Piwik\Piwik; +use Piwik\View; +use Piwik\ReportRenderer; +use Piwik_API_API; /** * - * @package Piwik_ReportRenderer + * @package ReportRenderer */ -class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer +class Html extends ReportRenderer { const IMAGE_GRAPH_WIDTH = 700; const IMAGE_GRAPH_HEIGHT = 200; @@ -53,21 +57,21 @@ class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer { $this->epilogue(); - return Piwik_ReportRenderer::writeFile($filename, self::HTML_FILE_EXTENSION, $this->rendering); + return ReportRenderer::writeFile($filename, self::HTML_FILE_EXTENSION, $this->rendering); } public function sendToBrowserDownload($filename) { $this->epilogue(); - Piwik_ReportRenderer::sendToBrowser($filename, self::HTML_FILE_EXTENSION, self::HTML_CONTENT_TYPE, $this->rendering); + ReportRenderer::sendToBrowser($filename, self::HTML_FILE_EXTENSION, self::HTML_CONTENT_TYPE, $this->rendering); } public function sendToBrowserInline($filename) { $this->epilogue(); - Piwik_ReportRenderer::inlineToBrowser(self::HTML_CONTENT_TYPE, $this->rendering); + ReportRenderer::inlineToBrowser(self::HTML_CONTENT_TYPE, $this->rendering); } public function getRenderedReport() @@ -79,13 +83,13 @@ class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer private function epilogue() { - $view = new Piwik_View('@CoreHome/ReportRenderer/_htmlReportFooter'); + $view = new View('@CoreHome/ReportRenderer/_htmlReportFooter'); $this->rendering .= $view->render(); } public function renderFrontPage($reportTitle, $prettyDate, $description, $reportMetadata, $segment) { - $frontPageView = new Piwik_View('@CoreHome/ReportRenderer/_htmlReportHeader'); + $frontPageView = new View('@CoreHome/ReportRenderer/_htmlReportHeader'); $this->assignCommonParameters($frontPageView); // todo rename 'websiteName' to 'reportTitle' once branch twig is merged @@ -104,15 +108,15 @@ class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer $this->rendering .= $frontPageView->render(); } - private function assignCommonParameters(Piwik_View $view) + private function assignCommonParameters(View $view) { - $view->assign("reportTitleTextColor", Piwik_ReportRenderer::REPORT_TITLE_TEXT_COLOR); + $view->assign("reportTitleTextColor", ReportRenderer::REPORT_TITLE_TEXT_COLOR); $view->assign("reportTitleTextSize", self::REPORT_TITLE_TEXT_SIZE); - $view->assign("reportTextColor", Piwik_ReportRenderer::REPORT_TEXT_COLOR); - $view->assign("tableHeaderBgColor", Piwik_ReportRenderer::TABLE_HEADER_BG_COLOR); - $view->assign("tableHeaderTextColor", Piwik_ReportRenderer::TABLE_HEADER_TEXT_COLOR); - $view->assign("tableCellBorderColor", Piwik_ReportRenderer::TABLE_CELL_BORDER_COLOR); - $view->assign("tableBgColor", Piwik_ReportRenderer::TABLE_BG_COLOR); + $view->assign("reportTextColor", ReportRenderer::REPORT_TEXT_COLOR); + $view->assign("tableHeaderBgColor", ReportRenderer::TABLE_HEADER_BG_COLOR); + $view->assign("tableHeaderTextColor", ReportRenderer::TABLE_HEADER_TEXT_COLOR); + $view->assign("tableCellBorderColor", ReportRenderer::TABLE_CELL_BORDER_COLOR); + $view->assign("tableBgColor", ReportRenderer::TABLE_BG_COLOR); $view->assign("reportTableHeaderTextSize", self::REPORT_TABLE_HEADER_TEXT_SIZE); $view->assign("reportTableRowTextSize", self::REPORT_TABLE_ROW_TEXT_SIZE); $view->assign("reportBackToTopTextSize", self::REPORT_BACK_TO_TOP_TEXT_SIZE); @@ -122,7 +126,7 @@ class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer public function renderReport($processedReport) { - $reportView = new Piwik_View('@CoreHome/ReportRenderer/_htmlReportBody'); + $reportView = new View('@CoreHome/ReportRenderer/_htmlReportBody'); $this->assignCommonParameters($reportView); $reportMetadata = $processedReport['metadata']; diff --git a/core/ReportRenderer/Pdf.php b/core/ReportRenderer/Pdf.php index 7e7e6069f0..192a7f9133 100644 --- a/core/ReportRenderer/Pdf.php +++ b/core/ReportRenderer/Pdf.php @@ -6,9 +6,14 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * * @category Piwik - * @package Piwik_ReportRenderer + * @package ReportRenderer */ +namespace Piwik\ReportRenderer; + use Piwik\Common; +use Piwik\TCPDF; +use Piwik\ReportRenderer; +use Piwik_API_API; /** * @see libs/tcpdf @@ -19,9 +24,9 @@ require_once PIWIK_INCLUDE_PATH . '/core/TCPDF.php'; /** * - * @package Piwik_ReportRenderer + * @package ReportRenderer */ -class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer +class Pdf extends ReportRenderer { const IMAGE_GRAPH_WIDTH_LANDSCAPE = 1050; const IMAGE_GRAPH_WIDTH_PORTRAIT = 760; @@ -71,19 +76,19 @@ class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer private $reportColumns; private $reportRowsMetadata; private $currentPage = 0; - private $reportFont = Piwik_ReportRenderer::DEFAULT_REPORT_FONT; + private $reportFont = ReportRenderer::DEFAULT_REPORT_FONT; private $TCPDF; private $orientation = self::PORTRAIT; public function __construct() { - $this->TCPDF = new Piwik_TCPDF(); - $this->headerTextColor = preg_split("/,/", Piwik_ReportRenderer::REPORT_TITLE_TEXT_COLOR); - $this->reportTextColor = preg_split("/,/", Piwik_ReportRenderer::REPORT_TEXT_COLOR); - $this->tableHeaderBackgroundColor = preg_split("/,/", Piwik_ReportRenderer::TABLE_HEADER_BG_COLOR); - $this->tableHeaderTextColor = preg_split("/,/", Piwik_ReportRenderer::TABLE_HEADER_TEXT_COLOR); - $this->tableCellBorderColor = preg_split("/,/", Piwik_ReportRenderer::TABLE_CELL_BORDER_COLOR); - $this->tableBackgroundColor = preg_split("/,/", Piwik_ReportRenderer::TABLE_BG_COLOR); + $this->TCPDF = new TCPDF(); + $this->headerTextColor = preg_split("/,/", ReportRenderer::REPORT_TITLE_TEXT_COLOR); + $this->reportTextColor = preg_split("/,/", ReportRenderer::REPORT_TEXT_COLOR); + $this->tableHeaderBackgroundColor = preg_split("/,/", ReportRenderer::TABLE_HEADER_BG_COLOR); + $this->tableHeaderTextColor = preg_split("/,/", ReportRenderer::TABLE_HEADER_TEXT_COLOR); + $this->tableCellBorderColor = preg_split("/,/", ReportRenderer::TABLE_CELL_BORDER_COLOR); + $this->tableBackgroundColor = preg_split("/,/", ReportRenderer::TABLE_BG_COLOR); } public function setLocale($locale) @@ -111,7 +116,7 @@ class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer case 'en': default: - $reportFont = Piwik_ReportRenderer::DEFAULT_REPORT_FONT; + $reportFont = ReportRenderer::DEFAULT_REPORT_FONT; break; } $this->reportFont = $reportFont; @@ -119,8 +124,8 @@ class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer public function sendToDisk($filename) { - $filename = Piwik_ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE); - $outputFilename = Piwik_ReportRenderer::getOutputPath($filename); + $filename = ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE); + $outputFilename = ReportRenderer::getOutputPath($filename); $this->TCPDF->Output($outputFilename, 'F'); @@ -129,13 +134,13 @@ class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer public function sendToBrowserDownload($filename) { - $filename = Piwik_ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE); + $filename = ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE); $this->TCPDF->Output($filename, 'D'); } public function sendToBrowserInline($filename) { - $filename = Piwik_ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE); + $filename = ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE); $this->TCPDF->Output($filename, 'I'); } |