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/View.php | |
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/View.php')
-rw-r--r-- | core/View.php | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/core/View.php b/core/View.php index 6d01d36329..7b5ea6d073 100644 --- a/core/View.php +++ b/core/View.php @@ -8,9 +8,23 @@ * @category Piwik * @package Piwik */ +namespace Piwik; + +use Exception; use Piwik\Config; use Piwik\Piwik; use Piwik\Common; +use Piwik\AssetManager; +use Piwik\Version; +use Piwik\Url; +use Piwik\UpdateCheck; +use Piwik\Twig; +use Piwik\QuickForm2; +use Piwik_SitesManager_API; +use Piwik_UsersManager_API; +use Piwik_View_Interface; +use Twig_Environment; +use Zend_Registry; /** * Transition for pre-Piwik 0.4.4 @@ -24,7 +38,7 @@ if (!defined('PIWIK_USER_PATH')) { * * @package Piwik */ -class Piwik_View implements Piwik_View_Interface +class View implements Piwik_View_Interface { private $template = ''; @@ -40,15 +54,15 @@ class Piwik_View implements Piwik_View_Interface public function __construct($templateFile) { $templateExt = '.twig'; - if(substr($templateFile, -strlen($templateExt)) !== $templateExt) { + if (substr($templateFile, -strlen($templateExt)) !== $templateExt) { $templateFile .= $templateExt; } $this->template = $templateFile; $this->initializeTwig(); - $this->piwik_version = Piwik_Version::VERSION; - $this->piwikUrl = Common::sanitizeInputValue(Piwik_Url::getCurrentUrlWithoutFileName()); + $this->piwik_version = Version::VERSION; + $this->piwikUrl = Common::sanitizeInputValue(Url::getCurrentUrlWithoutFileName()); } /** @@ -77,7 +91,7 @@ class Piwik_View implements Piwik_View_Interface public function initializeTwig() { - $piwikTwig = new Piwik_Twig(); + $piwikTwig = new Twig(); $this->twig = $piwikTwig->getTwigEnvironment(); } @@ -99,11 +113,11 @@ class Piwik_View implements Piwik_View_Interface $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess($count); usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1["name"], $site2["name"]);')); $this->sites = $sites; - $this->url = Common::sanitizeInputValue(Piwik_Url::getCurrentUrl()); + $this->url = Common::sanitizeInputValue(Url::getCurrentUrl()); $this->token_auth = Piwik::getCurrentUserTokenAuth(); $this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess(); $this->userIsSuperUser = Piwik::isUserIsSuperUser(); - $this->latest_version_available = Piwik_UpdateCheck::isNewestVersionAvailable(); + $this->latest_version_available = UpdateCheck::isNewestVersionAvailable(); $this->disableLink = Common::getRequestVar('disableLink', 0, 'int'); $this->isWidget = Common::getRequestVar('widget', 0, 'int'); if (Config::getInstance()->General['autocomplete_min_sites'] <= count($sites)) { @@ -116,7 +130,6 @@ class Piwik_View implements Piwik_View_Interface $user = Piwik_UsersManager_API::getInstance()->getUser($userLogin); $this->userAlias = $user['alias']; - } catch (Exception $e) { // can fail, for example at installation (no plugin loaded yet) } @@ -146,7 +159,7 @@ class Piwik_View implements Piwik_View_Interface protected function applyFilter_cacheBuster($output) { - $cacheBuster = Piwik_AssetManager::generateAssetsCacheBuster(); + $cacheBuster = AssetManager::generateAssetsCacheBuster(); $tag = 'cb=' . $cacheBuster; $pattern = array( @@ -195,9 +208,9 @@ class Piwik_View implements Piwik_View_Interface /** * Add form to view * - * @param Piwik_QuickForm2 $form + * @param QuickForm2 $form */ - public function addForm(Piwik_QuickForm2 $form) + public function addForm(QuickForm2 $form) { // assign array with form data @@ -227,7 +240,7 @@ class Piwik_View implements Piwik_View_Interface */ static public function clearCompiledTemplates() { - $view = new Piwik_View(null); + $view = new View(null); $view->twig->clearTemplateCache(); } @@ -241,7 +254,7 @@ class Piwik_View implements Piwik_View_Interface */ static public function singleReport($title, $reportHtml, $fetch = false) { - $view = new Piwik_View('@CoreHome/_singleReport'); + $view = new View('@CoreHome/_singleReport'); $view->title = $title; $view->report = $reportHtml; @@ -256,6 +269,6 @@ class Piwik_View implements Piwik_View_Interface */ static public function factory($templateName = null) { - throw new Exception("Piwik_View::factory is deprecated. Use 'new Piwik_View(\$templateFile)' instead."); + throw new Exception("View::factory is deprecated. Use 'new View(\$templateFile)' instead."); } } |