diff options
Diffstat (limited to 'plugins/CoreHome')
-rw-r--r-- | plugins/CoreHome/SystemSummary/Item.php | 94 | ||||
-rw-r--r-- | plugins/CoreHome/Widgets/GetSystemSummary.php | 79 | ||||
-rw-r--r-- | plugins/CoreHome/lang/fi.json | 8 | ||||
-rw-r--r-- | plugins/CoreHome/lang/ja.json | 2 | ||||
-rw-r--r-- | plugins/CoreHome/lang/sr.json | 7 | ||||
-rw-r--r-- | plugins/CoreHome/lang/zh-cn.json | 23 | ||||
-rw-r--r-- | plugins/CoreHome/templates/_dataTable.twig | 2 | ||||
-rw-r--r-- | plugins/CoreHome/templates/getSystemSummary.twig | 48 |
8 files changed, 210 insertions, 53 deletions
diff --git a/plugins/CoreHome/SystemSummary/Item.php b/plugins/CoreHome/SystemSummary/Item.php new file mode 100644 index 0000000000..7664b84124 --- /dev/null +++ b/plugins/CoreHome/SystemSummary/Item.php @@ -0,0 +1,94 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\Plugins\CoreHome\SystemSummary; + +/** + * This class can be used to add a new entry / item to the system summary widget. + * + * @api + */ +class Item +{ + private $key; + private $label; + private $value; + private $urlParams; + private $icon; + private $order; + + /** + * Item constructor. + * @param string $key The key or ID for this item. The entry in the widget will have this class so it is possible + * to style it individually and other plugins can use this key to for example remove this item + * from the list of system summary items. + * @param string $label The label that will be displayed for this item. The label may already include the value such as "5 segments" + * @param string|null $value Optional label. If given, the value will be displayed after the label separated by a colon, eg: "Segments: 5" + * @param array|null $urlParams Optional URL to make the item clickable. Accepts an array of URL parameters that need to be modfified. + * @param string $icon Optional icon css class, eg "icon-user". + * @param int $order Optional sort order. The lower the value, the higher up the entry will be shown + */ + public function __construct($key, $label, $value = null, $urlParams = null, $icon = '', $order = 99) + { + $this->key = $key; + $this->label = $label; + $this->value = $value; + $this->urlParams = $urlParams; + $this->icon = $icon; + $this->order = $order; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getLabel() + { + return $this->label; + } + + /** + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * @return array|null + */ + public function getUrlParams() + { + return $this->urlParams; + } + + /** + * @return string + */ + public function getIcon() + { + return $this->icon; + } + + /** + * @return int + */ + public function getOrder() + { + return $this->order; + } + +} diff --git a/plugins/CoreHome/Widgets/GetSystemSummary.php b/plugins/CoreHome/Widgets/GetSystemSummary.php index f68ce36d4f..a90d7b0586 100644 --- a/plugins/CoreHome/Widgets/GetSystemSummary.php +++ b/plugins/CoreHome/Widgets/GetSystemSummary.php @@ -12,11 +12,11 @@ use Piwik\API\Request; use Piwik\Db; use Piwik\Piwik; use Piwik\Plugin; +use Piwik\Plugins\CoreHome\SystemSummary\Item; use Piwik\Plugins\SegmentEditor\Services\StoredSegmentService; use Piwik\Version; use Piwik\Widget\Widget; use Piwik\Widget\WidgetConfig; -use Piwik\View; class GetSystemSummary extends Widget { @@ -46,39 +46,70 @@ class GetSystemSummary extends Widget public function render() { - $userLogins = Request::processRequest('UsersManager.getUsersLogin', array('filter_limit' => '-1')); - $websites = Request::processRequest('SitesManager.getAllSites', array('filter_limit' => '-1')); + $mysqlVersion = $this->getMySqlVersion(); - $numUsers = count($userLogins); - if (in_array('anonymous', $userLogins)) { - $numUsers--; - } + $systemSummary = array(); + + /** + * Triggered to add system summary items that are shown in the System Summary widget. + * + * **Example** + * + * public function addSystemSummaryItem(&$systemSummary) + * { + * $numUsers = 5; + * $systemSummary[] = new SystemSummary\Item($key = 'users', Piwik::translate('General_NUsers', $numUsers), $value = null, array('module' => 'UsersManager', 'action' => 'index'), $icon = 'icon-user'); + * } + * + * @param Item[] &$systemSummary An array containing system summary items. + */ + Piwik::postEvent('System.addSystemSummaryItems', array(&$systemSummary)); + + $systemSummary[] = new Item($key = 'piwik-version', Piwik::translate('CoreHome_SystemSummaryPiwikVersion'), Version::VERSION, $url = null, $icon = '', $order = 21); + $systemSummary[] = new Item($key = 'php-version', Piwik::translate('CoreHome_SystemSummaryMysqlVersion'), $mysqlVersion, $url = null, $icon = '', $order = 22); + $systemSummary[] = new Item($key = 'mysql-version', Piwik::translate('CoreHome_SystemSummaryPhpVersion'), phpversion(), $url = null, $icon = '', $order = 23); + + $systemSummary = array_filter($systemSummary); + usort($systemSummary, function ($itemA, $itemB) { + if ($itemA->getOrder() == $itemB->getOrder()) { + return 0; + } + if ($itemA->getOrder() > $itemB->getOrder()) { + return 1; + } + return -1; + }); + + /** + * Triggered to filter system summary items that are shown in the System Summary widget. A plugin might also + * sort the system summary items differently. + * + * **Example** + * + * public function filterSystemSummaryItems(&$systemSummary) + * { + * foreach ($systemSummaryItems as $index => $item) { + * if ($item && $item->getKey() === 'users') { + * $systemSummaryItems[$index] = null; + * } + * } + * } + * + * @param Item[] &$systemSummary An array containing system summary items. + */ + Piwik::postEvent('System.filterSystemSummaryItems', array(&$systemSummary)); + + $systemSummary = array_filter($systemSummary); return $this->renderTemplate('getSystemSummary', array( - 'numWebsites' => count($websites), - 'numUsers' => $numUsers, - 'numSegments' => $this->getNumSegments(), - 'numPlugins' => $this->getNumActivatedPlugins(), - 'piwikVersion' => Version::VERSION, - 'mySqlVersion' => $this->getMySqlVersion(), - 'phpVersion' => phpversion() + 'items' => $systemSummary )); } - private function getNumSegments() - { - $segments = $this->storedSegmentService->getAllSegmentsAndIgnoreVisibility(); - return count($segments); - } - private function getMySqlVersion() { $db = Db::get(); return $db->getServerVersion(); } - private function getNumActivatedPlugins() - { - return $this->pluginManager->getNumberOfActivatedPluginsExcludingAlwaysActivated(); - } }
\ No newline at end of file diff --git a/plugins/CoreHome/lang/fi.json b/plugins/CoreHome/lang/fi.json index 09f0c2d4d6..9095afeda8 100644 --- a/plugins/CoreHome/lang/fi.json +++ b/plugins/CoreHome/lang/fi.json @@ -4,7 +4,9 @@ "CheckForUpdates": "Tarkista päivitykset", "CheckPiwikOut": "Tutustu Piwikiin!", "ClickToEditX": "Muokkaa %s klikkaamalla", + "CloseSearch": "Sulje haku", "CloseWidgetDirections": "Voit sulkea tämän widget-käyttöliittymän klikkaamalla \"X\"-ikonia käyttöliittymän yläreunassa.", + "ChooseX": "Valitse %1$s", "DataForThisReportHasBeenPurged": "Tämän raportin data on yli %s kuukautta vanhaa ja on poistettu.", "DataTableExcludeAggregateRows": "Yhdistetyt rivit ovat näkyvillä %s Piilota", "DataTableIncludeAggregateRows": "Yhdistetyt rivit on piilotettu %s Näytä", @@ -46,8 +48,14 @@ "YouAreUsingTheLatestVersion": "Käytössäsi on uusin versio Piwikistä!", "ClickRowToExpandOrContract": "Klikkaa tätä riviä avataksesi tai sulkeaksesi alataulukon.", "UndoPivotBySubtable": "Tämä raportti on käännetty %s:llä. Kumoa kääntö", + "NoSuchPage": "Tätä sivua ei ole olemassa", "PivotBySubtable": "Tämä raportti ei ole käännetty %1$s:n mukaan. Käännetty %2$s:llä.", + "SystemSummaryNWebsites": "%d verkkosivustoa", + "SystemSummaryNSegments": "%d segmenttiä", "SystemSummaryNActivatedPlugins": "%d lisäosaa käytössä", + "SystemSummaryPiwikVersion": "Piwik-versio", + "SystemSummaryMysqlVersion": "MySQL-versio", + "SystemSummaryPhpVersion": "PHP-versio", "QuickAccessTitle": "Hae %s:llä. Käytä nuolia navigointiin. Oikotie: haku aukeaa painamalla f-näppäintä.", "MenuEntries": "Valikon sisältö", "Segments": "Segmentit", diff --git a/plugins/CoreHome/lang/ja.json b/plugins/CoreHome/lang/ja.json index c3fb0d4ab2..cdc7506921 100644 --- a/plugins/CoreHome/lang/ja.json +++ b/plugins/CoreHome/lang/ja.json @@ -1,6 +1,7 @@ { "CoreHome": { "CategoryNoData": "このカテゴリにデータはありません。 \"すべての母集団(統計の対象とする集団)を含める\" を試してみてください。", + "ChangeVisualization": "ビジュアルの変更", "CheckForUpdates": "アップデートの確認", "CheckPiwikOut": "Piwik をチェック!", "ClickToEditX": "クリックして %s を編集", @@ -15,6 +16,7 @@ "Default": "デフォルト", "DonateCall1": "Piwik を使用するのに費用はかかりません。しかし、 Piwik の制作に費用がかかっていないと言う意味ではありません", "DonateCall2": "Piwik が成長し、成功するには、あなたの継続的なサポートが必要です", + "DonateCall3": "Piwikがビジネスや努力に重大な付加価値を感じる場合は、%3$sプレミアム機能を購入%4$sまたは%1$s寄付する%2$sことをご検討ください。 すべての寄付金が助けになるでしょう。", "DonateFormInstructions": "スライダで寄付する金額を選択して寄付するをクリック", "ExcludeRowsWithLowPopulation": "全ての行を表示 %s 少ない数の行を除く", "ExternalHelp": "ヘルプ(新しいタブで開きます)", diff --git a/plugins/CoreHome/lang/sr.json b/plugins/CoreHome/lang/sr.json index fd620f3956..1d7492fd6c 100644 --- a/plugins/CoreHome/lang/sr.json +++ b/plugins/CoreHome/lang/sr.json @@ -5,8 +5,10 @@ "CheckForUpdates": "Proveri da li se pojavila nova verzija", "CheckPiwikOut": "Proverite!", "ClickToEditX": "Kliknite kako biste izmenili %s", + "ClickToSeeFullInformation": "Kliknite ovde za više informacija", "CloseSearch": "Zatvori pretragu", "CloseWidgetDirections": "Možete zatvoriti ovaj vidžet tako što ćete kliknuti na sličicu 'X' na vrhu.", + "ChooseX": "Izaberite %1$s", "DataForThisReportHasBeenPurged": "Podaci za ovaj izveštaj su više od %s meseci stari te su obrisani.", "DataTableExcludeAggregateRows": "Zbirni redovi su prikazani %s Sakrij ih", "DataTableIncludeAggregateRows": "Zbirni redovi su sakriveni %s Prikaži ih", @@ -14,6 +16,7 @@ "Default": "podrazumevano", "DonateCall1": "Piwik vas nikada neće ništa koštati ali to ne znači da nas Piwik ništa ne košta dok ga pravimo.", "DonateCall2": "Piwiku je potrebna vaša stalna podrška kako bi rastao i napredovao.", + "DonateCall3": "Ukoliko imate osećaj da je Piwik u znatnoj meri dodao vrednost vašem biznisu, %1$smolimo vas da razmislite o donaciji%2$s ili %3$snaručivanju premium usluga%4$s. Svaki dinar je od pomoći.", "DonateFormInstructions": "Kliknite na klizač kako biste odabrali iznos pa onda kliknite na \"subscribe\"", "ExcludeRowsWithLowPopulation": "Svi redovi su prikazani %s Sakrij slabu populaciju", "ExternalHelp": "Pomoć (otvara se u novom tabu)", @@ -62,7 +65,9 @@ "QuickAccessTitle": "Pretraga za %s. Koristite tastere sa strelicama kako biste se kretali kroz rezultate pretrage. Prečica: pritisnite 'f' za pretragu.", "MenuEntries": "Stavke menija", "Segments": "Segmenti", + "OneClickUpdateNotPossibleAsMultiServerEnvironment": "Nadogradnja jednim klikom nije moguća zato što koristite Piwik na više servera. Molimo vas da preuzmete poslednju verziju sa %1$s kako biste nastavili.", "AdblockIsMaybeUsed": "Ukoliko koristite bloker reklama, molimo vas da ga isključite na ovom sajtu kako biste bili sigurni da Piwik radi bez ikakvih problema.", - "ChangeCurrentWebsite": "Izaberite sajt, trenutno izabrani sajt je %s" + "ChangeCurrentWebsite": "Izaberite sajt, trenutno izabrani sajt je %s", + "LeadingAnalyticsPlatformRespectsYourPrivacy": "Vodeća otvorena analitička platforma koja poštuje vašu privatnost." } }
\ No newline at end of file diff --git a/plugins/CoreHome/lang/zh-cn.json b/plugins/CoreHome/lang/zh-cn.json index 6cf13a4a4d..39e812881a 100644 --- a/plugins/CoreHome/lang/zh-cn.json +++ b/plugins/CoreHome/lang/zh-cn.json @@ -1,21 +1,27 @@ { "CoreHome": { "CategoryNoData": "该分类没有数据! 请试试 \"包含所有数据\"!", + "ChangeVisualization": "转换可视化", "CheckForUpdates": "检查更新", "CheckPiwikOut": "访问 Piwik", "ClickToEditX": "点击编辑 %s", + "ClickToSeeFullInformation": "点击查看完整信息", + "CloseSearch": "关闭搜索", "CloseWidgetDirections": "点击右上角的 'X' 图标可关闭这个小窗口", + "ChooseX": "选择 %1$s", "DataForThisReportHasBeenPurged": "本报表数据超过 %s 个月已被清空。", "DataTableExcludeAggregateRows": "汇总行已显示 %s 隐藏汇总", "DataTableIncludeAggregateRows": "汇总行已隐藏 %s 显示汇总", + "DataTableHowToSearch": "按回车或者点击搜索图标进行搜索", "Default": "默认", "DonateCall1": "Piwik 对您来说可以免费使用,但对我们来说并非零成本。", "DonateCall2": "Piwik 的茁壮成长离不开您的支持。", + "DonateCall3": "如果你觉得Piwik对你的商业有价值的话,%1$s请考虑资助%2$s 或者 %3$s购买会员%4$s。任何一分都会有帮助。", "DonateFormInstructions": "点击下面的滑动条设定金额,然后点 Subscribe 按钮捐款", "ExcludeRowsWithLowPopulation": "显示了所有的数据 %s 不显示低密度数据", "ExternalHelp": "帮助(在新标签页打开)", "FlattenDataTable": "本报表已分级显示 %s 改为不分级显示", - "HowMuchIsPiwikWorth": "您觉得 Piwik 值多少?", + "HowMuchIsPiwikWorth": "对于您来说Piwik的价值?", "IncludeRowsWithLowPopulation": "没有显示低密度数据 %s 显示所有数据", "InjectedHostEmailBody": "您好,我今天访问 Piwik 时遇到未知主机名的警告。", "InjectedHostEmailSubject": "访问 Piwik 的主机名未知: %s", @@ -26,7 +32,8 @@ "MainNavigation": "主导航", "MakeOneTimeDonation": "一次性捐款", "Menu": "菜单", - "NoPrivilegesAskPiwikAdmin": "您当前登录用户是 '%1$s' 但是没有 Piwik 权限。%2$s 联系 Piwik 管理员 (点击发送邮件)%3$s 获得 '查看' 权限。", + "NoPrivilegesAskPiwikAdmin": "您当前登录用户是'%1$s' ,但是没有任何Piwik权限。%2$s 联系 Piwik 管理员 (点击发送邮件)%3$s 获得 '查看' 权限。", + "OnlyForSuperUserAccess": "这个小工具仅仅显示在有超级用户权限的面板里。", "PageOf": "%1$s,总共 %2$s", "PeriodRange": "时间段", "ReportGeneratedOn": "本报表生成时间 %s", @@ -46,11 +53,21 @@ "YouAreUsingTheLatestVersion": "您正在使用最新版的 Piwik!", "ClickRowToExpandOrContract": "点击这行可以扩展或压缩小工作台。", "UndoPivotBySubtable": "这个报表被 pivot 了 %s 撤销 Pivot", + "NoSuchPage": "页面不存在。", "PivotBySubtable": "这个报表尚未 pivot %1$s 以 %2$s 的身份 pivot", + "SystemSummaryWidget": "系统概要", + "SystemSummaryNWebsites": "%d网站", + "SystemSummaryNSegments": "%d段", + "SystemSummaryNActivatedPlugins": "%d激活的插件", + "SystemSummaryPiwikVersion": "Piwik版本", + "SystemSummaryMysqlVersion": "MySQL版本", + "SystemSummaryPhpVersion": "PHP版本", "QuickAccessTitle": "搜索 %s,使用上下键在搜索结果中导航。快捷键:按“F”进行搜索。", "MenuEntries": "菜单项", "Segments": "段", + "OneClickUpdateNotPossibleAsMultiServerEnvironment": "由于你在多个服务器上部署Piwik,所以一键升级不可用。请直接从%1$s下周最新版本。", "AdblockIsMaybeUsed": "如果您使用的是广告拦截,请禁用此网站,以确保Piwik工作没有任何问题。", - "ChangeCurrentWebsite": "选择一个网站,当前选择的网站: %s" + "ChangeCurrentWebsite": "选择一个网站,当前选择的网站: %s", + "LeadingAnalyticsPlatformRespectsYourPrivacy": "领先的开源分析平台尊重你的隐私。" } }
\ No newline at end of file diff --git a/plugins/CoreHome/templates/_dataTable.twig b/plugins/CoreHome/templates/_dataTable.twig index b43337a906..b5635d9921 100644 --- a/plugins/CoreHome/templates/_dataTable.twig +++ b/plugins/CoreHome/templates/_dataTable.twig @@ -53,6 +53,8 @@ <div class="pk-emptyDataTable"> {% if showReportDataWasPurgedMessage is defined and showReportDataWasPurgedMessage %} {{ 'CoreHome_DataForThisReportHasBeenPurged'|translate(deleteReportsOlderThan) }} + {% elseif properties.no_data_message %} + {{ properties.no_data_message|raw }} {% else %} {{ 'CoreHome_ThereIsNoDataForThisReport'|translate }} {% endif %} diff --git a/plugins/CoreHome/templates/getSystemSummary.twig b/plugins/CoreHome/templates/getSystemSummary.twig index 264162c180..aeaa07caed 100644 --- a/plugins/CoreHome/templates/getSystemSummary.twig +++ b/plugins/CoreHome/templates/getSystemSummary.twig @@ -1,28 +1,26 @@ <div class="widgetBody systemSummary"> - <div> - <span class="icon icon-user"></span> - <a href="{{ linkTo({'module': 'UsersManager', 'action': 'index'}) }}">{{ 'General_NUsers'|translate(numUsers) }}</a> - </div> - <div> - <span><span class="icon icon-segment"></span> {{ 'CoreHome_SystemSummaryNSegments'|translate(numSegments) }}</span> - </div> - <div> - <a href="{{ linkTo({'module': 'SitesManager', 'action': 'index'}) }}">{{ 'CoreHome_SystemSummaryNWebsites'|translate(numWebsites) }}</a> - </div> - <div> - <a href="{{ linkTo({'module': 'CorePluginsAdmin', 'action': 'plugins'}) }}">{{ 'CoreHome_SystemSummaryNActivatedPlugins'|translate(numPlugins) }}</a> - </div> - <div> - <span>{{ 'CoreHome_SystemSummaryPiwikVersion'|translate }}:</span> - <span class="piwik-version">{{ piwikVersion }}</span> - </div> - <div> - <span>{{ 'CoreHome_SystemSummaryMysqlVersion'|translate }}:</span> - <span>{{ mySqlVersion }}</span> - </div> - <div> - <span>{{ 'CoreHome_SystemSummaryPhpVersion'|translate }}:</span> - <span>{{ phpVersion }}</span> - </div> + {% for item in items %} + {% if item is not empty %} + <div class="systemSummaryItem {% if item.getKey %}{{ item.getKey }}{% endif %}"> + {% if item.getIcon %}<span class="icon {{ item.getIcon }}"></span>{% endif %} + + {% if item.getUrlParams -%} + <a href="{{ linkTo(item.getUrlParams) }}" class="itemLabel"> + {% else -%} + <span class="itemLabel"> + {% endif -%} + + {{ item.getLabel }}{% if item.getValue %}:{% endif %} + + {%- if item.getUrlParams %} + </a> + {%- else %} + </span> + {%- endif %} + + {% if item.getValue %}<span class="itemValue">{{ item.getValue }}</span>{% endif %} + </div> + {% endif %} + {% endfor %} <br /> </div>
\ No newline at end of file |