diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-07-03 03:54:27 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2015-10-06 18:25:13 +0300 |
commit | 9ba8f216fd7856ce5fef06bf82ecb8f8a2e7e630 (patch) | |
tree | 6ce07d18a85d00b39ab720abe042361c0775aead /plugins/Goals/Widgets | |
parent | 8ccc9dc05da021325cdbf141a548637fa52f16b2 (diff) |
generate pages instead of implementing them in each controller
Diffstat (limited to 'plugins/Goals/Widgets')
-rw-r--r-- | plugins/Goals/Widgets/AddNewGoal.php | 38 | ||||
-rw-r--r-- | plugins/Goals/Widgets/EditGoals.php | 37 |
2 files changed, 75 insertions, 0 deletions
diff --git a/plugins/Goals/Widgets/AddNewGoal.php b/plugins/Goals/Widgets/AddNewGoal.php new file mode 100644 index 0000000000..b692309b9d --- /dev/null +++ b/plugins/Goals/Widgets/AddNewGoal.php @@ -0,0 +1,38 @@ +<?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\Goals\Widgets; + +use Piwik\Common; +use Piwik\Piwik; +use Piwik\Plugins\Goals\API; +use Piwik\Widget\WidgetConfig; + +class AddNewGoal extends \Piwik\Widget\Widget +{ + public static function configure(WidgetConfig $config) + { + $idSite = Common::getRequestVar('idSite', null, 'int'); + $goals = API::getInstance()->getGoals($idSite); + + $config->setCategoryId('Goals_Goals'); + $config->setSubcategoryId('Goals_AddNewGoal'); + $config->setParameters(array('idGoal' => '')); + $config->setIsNotWidgetizable(); + + if (Piwik::isUserHasAdminAccess($idSite)) { + $config->setName('Goals_AddNewGoal'); + } else { + $config->setName('Goals_CreateNewGOal'); + } + + if (count($goals) !== 0) { + $config->disable(); + } + } +} diff --git a/plugins/Goals/Widgets/EditGoals.php b/plugins/Goals/Widgets/EditGoals.php new file mode 100644 index 0000000000..d0bb52667c --- /dev/null +++ b/plugins/Goals/Widgets/EditGoals.php @@ -0,0 +1,37 @@ +<?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\Goals\Widgets; + +use Piwik\Common; +use Piwik\Piwik; +use Piwik\Plugins\Goals\API; +use Piwik\Widget\WidgetConfig; + +class EditGoals extends \Piwik\Widget\Widget +{ + public static function configure(WidgetConfig $config) + { + $idSite = Common::getRequestVar('idSite', null, 'int'); + $goals = API::getInstance()->getGoals($idSite); + + $config->setCategoryId('Goals_Goals'); + $config->setSubcategoryId('Goals_ManageGoals'); + $config->setIsNotWidgetizable(); + + if (Piwik::isUserHasAdminAccess($idSite)) { + $config->setName('Goals_ManageGoals'); + } else { + $config->setName('Goals_CreateNewGOal'); + } + + if (count($goals) === 0) { + $config->disable(); + } + } +} |