diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-11-20 08:45:56 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-11-20 08:45:56 +0400 |
commit | d87c9a6bef0eea8f459d1d95e18bd706c567ec03 (patch) | |
tree | bf60602b8a1e43b113830dbe388dd3b0846c150c /plugins/SitesManager/Controller.php | |
parent | 0cd6734c2d4c39937910e755f53774be96e85ac7 (diff) |
Refs #4325 Making the new Site hook used piwik wide so that when eg. a site name is decorated, it appears in most places decorated.
Diffstat (limited to 'plugins/SitesManager/Controller.php')
-rw-r--r-- | plugins/SitesManager/Controller.php | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/plugins/SitesManager/Controller.php b/plugins/SitesManager/Controller.php index f5350ad717..a26bb7db63 100644 --- a/plugins/SitesManager/Controller.php +++ b/plugins/SitesManager/Controller.php @@ -36,13 +36,16 @@ class Controller extends \Piwik\Plugin\ControllerAdmin { $view = new View('@SitesManager/index'); + Site::clearCache(); if (Piwik::isUserIsSuperUser()) { - $sites = API::getInstance()->getAllSites(); - Site::setSites($sites); - $sites = array_values($sites); + $sitesRaw = API::getInstance()->getAllSites(); } else { - $sites = API::getInstance()->getSitesWithAdminAccess(); - Site::setSitesFromArray($sites); + $sitesRaw = API::getInstance()->getSitesWithAdminAccess(); + } + // Gets sites after Site.setSite hook was called + $sites = array_values( Site::getSites() ); + if(count($sites) != count($sitesRaw)) { + throw new Exception("One or more website are missing or invalid."); } foreach ($sites as &$site) { @@ -187,16 +190,17 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $pattern = str_replace('/', '\\/', $pattern); } foreach ($sites as $s) { - $hl_name = $s['name']; + $siteName = Site::getNameFor($s['idsite']); + $label = $siteName; if (strlen($pattern) > 0) { - @preg_match_all("/$pattern+/i", $hl_name, $matches); + @preg_match_all("/$pattern+/i", $label, $matches); if (is_array($matches[0]) && count($matches[0]) >= 1) { foreach ($matches[0] as $match) { - $hl_name = str_replace($match, '<span class="autocompleteMatched">' . $match . '</span>', $s['name']); + $label = str_replace($match, '<span class="autocompleteMatched">' . $match . '</span>', $siteName); } } } - $results[] = array('label' => $hl_name, 'id' => $s['idsite'], 'name' => $s['name']); + $results[] = array('label' => $label, 'id' => $s['idsite'], 'name' => $siteName); } } |