Skip to content

Commit

Permalink
pkp/pkp-lib#5199 Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jan 26, 2024
1 parent 0488910 commit 8bffcd4
Show file tree
Hide file tree
Showing 2 changed files with 576 additions and 572 deletions.
87 changes: 44 additions & 43 deletions plugins/themes/default/DefaultThemePlugin.php
Expand Up @@ -17,13 +17,10 @@
use APP\core\Application;
use APP\file\PublicFileManager;
use PKP\config\Config;
use PKP\session\SessionManager;
use PKP\plugins\Hook;

use APP\facades\Repo;
use APP\issue\Collector;
use APP\services\NavigationMenuService;
use PKP\plugins\ThemePlugin;
use PKP\plugins\Hook;
use PKP\session\SessionManager;

class DefaultThemePlugin extends ThemePlugin
{
Expand Down Expand Up @@ -217,7 +214,7 @@ public function init()
// Add navigation menu areas for this theme
$this->addMenuArea(['primary', 'user']);

Hook::add('TemplateManager::display', array($this, 'checkCurrentPage'));
Hook::add('TemplateManager::display', [$this, 'checkCurrentPage']);
}

/**
Expand Down Expand Up @@ -263,48 +260,52 @@ public function getDescription()
}


/**
* @param $hookname string
* @param $args array
*/
public function checkCurrentPage($hookname, $args) {
$templateMgr = $args[0];
// TODO check the issue with multiple calls of the hook on settings/website
if (!isset($templateMgr->registered_plugins["function"]["default_item_active"])) {
$templateMgr->registerPlugin('function', 'default_item_active', array($this, 'isActiveItem'));
}

}

/**
* @param $params array
* @param $smarty Smarty_Internal_Template
* @return string
*/
public function isActiveItem($params, $smarty) {

$navigationMenuItem = $params['item'];
$emptyMarker = '';
$activeMarker = ' active';

// Get URL of the current page
$request = $this->getRequest();
$currentUrl = $request->getCompleteUrl();
$currentPage = $request->getRequestedPage();

// Do not add an active marker if it's a dropdown menu
if ($navigationMenuItem->getIsChildVisible()) return $emptyMarker;
/**
* @param $hookname string
* @param $args array
*/
public function checkCurrentPage($hookname, $args)
{
$templateMgr = $args[0];
// TODO check the issue with multiple calls of the hook on settings/website
if (!isset($templateMgr->registered_plugins['function']['default_item_active'])) {
$templateMgr->registerPlugin('function', 'default_item_active', [$this, 'isActiveItem']);
}
}

// Retrieve URL and its components for a menu item
$itemUrl = $navigationMenuItem->getUrl();
/**
* @param $params array
* @param $smarty Smarty_Internal_Template
*
* @return string
*/
public function isActiveItem($params, $smarty)
{
$navigationMenuItem = $params['item'];
$emptyMarker = '';
$activeMarker = ' active';

// Get URL of the current page
$request = $this->getRequest();
$currentUrl = $request->getCompleteUrl();
$currentPage = $request->getRequestedPage();

// Do not add an active marker if it's a dropdown menu
if ($navigationMenuItem->getIsChildVisible()) {
return $emptyMarker;
}

if ($currentUrl === $itemUrl) return $activeMarker;
// Retrieve URL and its components for a menu item
$itemUrl = $navigationMenuItem->getUrl();

return $emptyMarker;
}
if ($currentUrl === $itemUrl) {
return $activeMarker;
}

return $emptyMarker;
}
}

if (!PKP_STRICT_MODE) {
class_alias('\APP\plugins\themes\default\DefaultThemePlugin', '\DefaultThemePlugin');
}
}

0 comments on commit 8bffcd4

Please sign in to comment.