Skip to content

Commit

Permalink
Refs matomo-org#472 Events controller with left menu selector
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Apr 10, 2014
1 parent b865e2f commit e5b28b3
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 117 deletions.
5 changes: 1 addition & 4 deletions core/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function __construct($templateFile)

$this->piwik_version = Version::VERSION;
$this->userLogin = Piwik::getCurrentUserLogin();
$this->isSuperUser = Access::getInstance()->hasSuperUserAccess(); // TODO: redundancy w/ userIsSuperUser
$this->isSuperUser = Access::getInstance()->hasSuperUserAccess();

try {
$this->piwikUrl = SettingsPiwik::getPiwikUrl();
Expand Down Expand Up @@ -320,7 +320,6 @@ public function addForm(QuickForm2 $form)

/**
* Assign value to a variable for use in a template
* ToDo: This is ugly.
* @param string|array $var
* @param mixed $value
* @ignore
Expand Down Expand Up @@ -354,15 +353,13 @@ static public function clearCompiledTemplates()
*
* @param string $title The report title.
* @param string $reportHtml The report body HTML.
* @param bool $fetch If true, return report contents as a string; otherwise echo to screen.
* @return string|void The report contents if `$fetch` is true.
*/
static public function singleReport($title, $reportHtml)
{
$view = new View('@CoreHome/_singleReport');
$view->title = $title;
$view->report = $reportHtml;

return $view->render();
}
}
2 changes: 1 addition & 1 deletion plugins/CustomAlerts
8 changes: 4 additions & 4 deletions plugins/Events/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ class API extends \Piwik\Plugin\API
/**
* @ignore
*/
public function getSubtableAction($api)
public function getSubtableAction($apiMethod)
{
return $this->mappingApiToApiLoadsubtables[$api];
return $this->mappingApiToApiLoadsubtables[$apiMethod];
}

protected function getRecordNameForAction($method)
protected function getRecordNameForAction($apiMethod)
{
return $this->mappingApiToRecord[$method];
return $this->mappingApiToRecord[$apiMethod];
}

protected function getDataTable($name, $idSite, $period, $date, $segment, $expanded = false, $idSubtable = null)
Expand Down
114 changes: 36 additions & 78 deletions plugins/Events/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,146 +6,104 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\Actions;
namespace Piwik\Plugins\Events;

use Piwik\Piwik;
use Piwik\Plugins\Events\Events;
use Piwik\View;
use Piwik\ViewDataTable\Factory;

/**
* Actions controller
* Events controller
*
*/
class Controller extends \Piwik\Plugin\Controller
{
//
// Actions that render whole pages
//

public function indexPageUrls()
{
return View::singleReport(
Piwik::translate('General_Pages'),
$this->getPageUrls(true));
}

public function indexEntryPageUrls()
{
return View::singleReport(
Piwik::translate('Actions_SubmenuPagesEntry'),
$this->getEntryPageUrls(true));
}

public function indexExitPageUrls()
public function index()
{
return View::singleReport(
Piwik::translate('Actions_SubmenuPagesExit'),
$this->getExitPageUrls(true));
}

public function indexSiteSearch()
{
$view = new View('@Actions/indexSiteSearch');

$view->keywords = $this->getSiteSearchKeywords(true);
$view->noResultKeywords = $this->getSiteSearchNoResultKeywords(true);
$view->pagesUrlsFollowingSiteSearch = $this->getPageUrlsFollowingSiteSearch(true);

$categoryTrackingEnabled = \Piwik\Plugin\Manager::getInstance()->isPluginActivated('CustomVariables');
if ($categoryTrackingEnabled) {
$view->categories = $this->getSiteSearchCategories(true);
}

$view = new View('@Events/index');
$view->leftMenuReports = $this->getLeftMenuReports();
return $view->render();
}

public function indexPageTitles()
private function getLeftMenuReports()
{
return View::singleReport(
Piwik::translate('Actions_SubmenuPageTitles'),
$this->getPageTitles(true));
}

public function indexDownloads()
{
return View::singleReport(
Piwik::translate('General_Downloads'),
$this->getDownloads(true));
}

public function indexOutlinks()
{
return View::singleReport(
Piwik::translate('General_Outlinks'),
$this->getOutlinks(true));
$reports = new View\ReportsByDimension('Events');
foreach(Events::getLabelTranslations() as $apiAction => $translations) {
// 'getCategory' is the API method, but we are loading 'indexCategory' which displays <h2>
$controllerAction = str_replace("get", "index", $apiAction, $count = 1);
$reports->addReport('Events_TopEvents', $translations[0], 'Events.' . $controllerAction);
}
return $reports->render();
}

//
// Actions that render individual reports
//

public function getPageUrls()
public function indexCategory()
{
return $this->renderReport(__FUNCTION__);
return $this->indexEvent(__FUNCTION__);
}

public function getEntryPageUrls()
public function indexAction()
{
return $this->renderReport(__FUNCTION__);
return $this->indexEvent(__FUNCTION__);
}

public function getExitPageUrls()
public function indexName()
{
return $this->renderReport(__FUNCTION__);
return $this->indexEvent(__FUNCTION__);
}

public function getSiteSearchKeywords()
public function getCategory()
{
return $this->renderReport(__FUNCTION__);
}

public function getSiteSearchNoResultKeywords()
public function getAction()
{
return $this->renderReport(__FUNCTION__);
}

public function getSiteSearchCategories()
public function getName()
{
return $this->renderReport(__FUNCTION__);
}

public function getPageUrlsFollowingSiteSearch()
public function getActionFromCategoryId()
{
return $this->renderReport(__FUNCTION__);
}

public function getPageTitlesFollowingSiteSearch()
public function getNameFromCategoryId()
{
return $this->renderReport(__FUNCTION__);
}

public function getPageTitles()
public function getCategoryFromActionId()
{
return $this->renderReport(__FUNCTION__);
}

public function getEntryPageTitles()
public function getNameFromActionId()
{
return $this->renderReport(__FUNCTION__);
}

public function getExitPageTitles()
public function getActionFromNameId()
{
return $this->renderReport(__FUNCTION__);
}

public function getDownloads()
public function getCategoryFromNameId()
{
return $this->renderReport(__FUNCTION__);
}

public function getOutlinks()
protected function indexEvent($controllerMethod)
{
return $this->renderReport(__FUNCTION__);
$apiMethod = str_replace('index', 'get', $controllerMethod, $count = 1);
$events = new Events;
return View::singleReport(
$events->getReportTitleTranslation($apiMethod),
$this->$apiMethod()
);
}
}
Loading

0 comments on commit e5b28b3

Please sign in to comment.