Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #5192 added generator for menus, updated more plugins to use men…
…u class, fixed some bugs, improved design, fixed tests, ...
- Loading branch information
Showing
51 changed files
with
635 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* Piwik - Open source web analytics | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
|
||
namespace Piwik\Plugins\CoreConsole\Commands; | ||
|
||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
*/ | ||
class GenerateMenu extends GeneratePluginBase | ||
{ | ||
protected function configure() | ||
{ | ||
$this->setName('generate:menu') | ||
->setDescription('Adds a plugin menu class to an existing plugin') | ||
->addOption('pluginname', null, InputOption::VALUE_REQUIRED, 'The name of an existing plugin which does not have a menu defined yet'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$pluginName = $this->getPluginName($input, $output); | ||
|
||
$exampleFolder = PIWIK_INCLUDE_PATH . '/plugins/ExamplePlugin'; | ||
$replace = array('ExamplePlugin' => $pluginName); | ||
$whitelistFiles = array('/Menu.php'); | ||
|
||
$this->copyTemplateToPlugin($exampleFolder, $pluginName, $replace, $whitelistFiles); | ||
|
||
$this->writeSuccessMessage($output, array( | ||
sprintf('Menu.php for %s generated.', $pluginName), | ||
'You can now start defining your plugin menu', | ||
'Enjoy!' | ||
)); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* @return array | ||
* @throws \RunTimeException | ||
*/ | ||
protected function getPluginName(InputInterface $input, OutputInterface $output) | ||
{ | ||
$pluginNames = $this->getPluginNamesHavingNotSpecificFile('Menu.php'); | ||
$invalidName = 'You have to enter the name of an existing plugin which does not already have a menu defined'; | ||
|
||
return $this->askPluginNameAndValidate($input, $output, $pluginNames, $invalidName); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Piwik - Open source web analytics | ||
* | ||
* @link http://piwik.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
namespace Piwik\Plugins\ExamplePlugin; | ||
|
||
use Piwik\Menu\MenuAdmin; | ||
use Piwik\Menu\MenuReporting; | ||
use Piwik\Menu\MenuTop; | ||
use Piwik\Menu\MenuUser; | ||
|
||
/** | ||
* This class allows you to add, remove or rename menu items. | ||
* To configure a menu (such as Admin Menu, Reporting Menu, User Menu...) simply call the corresponding methods as | ||
* described in the API-Reference http://developer.piwik.org/api-reference/Piwik/Menu/MenuAbstract | ||
*/ | ||
class Menu extends \Piwik\Plugin\Menu | ||
{ | ||
public function configureReportingMenu(MenuReporting $menu) | ||
{ | ||
// $menu->add('UI Framework', '', array('module' => 'ExamplePlugin', 'action' => ''), true, $orderId = 30); | ||
// $menu->add('UI Framework', 'Report 1', array('module' => 'ExamplePlugin', 'action' => 'report1'), true, $orderId = 30); | ||
} | ||
|
||
public function configureAdminMenu(MenuAdmin $menu) | ||
{ | ||
// $menu->add('General_Settings', 'My Admin Item', array('module' => 'ExamplePlugin', 'action' => ''), true, $orderId = 30); | ||
} | ||
|
||
public function configureTopMenu(MenuTop $menu) | ||
{ | ||
// $menu->add('My Top Item', null, array('module' => 'ExamplePlugin', 'action' => ''), true, $orderId = 30); | ||
} | ||
|
||
public function configureUserMenu(MenuUser $menu) | ||
{ | ||
// $menu->add('CoreAdminHome_MenuManage', 'My User Item', array('module' => 'ExamplePlugin', 'action' => ''), true, $orderId = 30); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.