| <?php |
|
|
| |
| |
| |
| |
| |
| |
|
|
| namespace Piwik\Plugins\DevicePlugins; |
|
|
| use Piwik\Cache; |
| use Piwik\CacheId; |
| use Piwik\Columns\Dimension; |
| use Piwik\Piwik; |
| use Piwik\Plugin; |
|
|
| class DevicePlugins extends \Piwik\Plugin |
| { |
| |
| |
| |
| public function registerEvents() |
| { |
| return array( |
| 'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations', |
| ); |
| } |
|
|
| public function addMetricTranslations(&$translations) |
| { |
| $metrics = array( |
| 'nb_visits_percentage' => Piwik::translate('General_ColumnPercentageVisits'), |
| ); |
|
|
| $translations = array_merge($translations, $metrics); |
| } |
|
|
|
|
| |
| |
| |
| |
| |
| |
| public static function getAllPluginColumns() |
| { |
| $cacheId = CacheId::pluginAware('DevicePluginColumns'); |
| $cache = Cache::getTransientCache(); |
| $removedDimensions = Dimension::getRemovedDimensions(); |
|
|
| if (!$cache->contains($cacheId)) { |
| $instances = []; |
|
|
| foreach (self::getAllDevicePluginsColumnClasses() as $className) { |
| if (!in_array($className, $removedDimensions)) { |
| $instances[] = new $className(); |
| } |
| } |
|
|
| $cache->save($cacheId, $instances); |
| } |
|
|
| return $cache->fetch($cacheId); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| protected static function getAllDevicePluginsColumnClasses() |
| { |
| return Plugin\Manager::getInstance()->findMultipleComponents('Columns', 'Piwik\Plugins\DevicePlugins\Columns\DevicePluginColumn'); |
| } |
| } |
|
|