Skip to content

Commit

Permalink
*8094* Move header/sidebar structures into PKP
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Feb 4, 2013
1 parent 05b3b44 commit 9ebb64a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 139 deletions.
58 changes: 0 additions & 58 deletions classes/template/TemplateManager.inc.php
Expand Up @@ -98,65 +98,7 @@ function TemplateManager($request = null) {

$this->assign('siteTitle', $site->getLocalizedTitle());
}

// Check for multiple presses.
$pressDao = DAORegistry::getDAO('PressDAO');

$user = $this->request->getUser();
if (is_a($user, 'User')) {
$presses = $pressDao->getAll();
} else {
$presses = $pressDao->getEnabledPresses();
}

$multipleContexts = false;
if ($presses->getCount() > 1) {
$this->assign('multipleContexts', true);
$multipleContexts = true;
} else {
if ($presses->getCount() == 0) { // no presses configured
$this->assign('noContextsConfigured', true);
}
}

if ($multipleContexts) {
$this->_assignContextSwitcherData($presses, $context);
}
}
}


//
// Private helper methods.
//
/**
* Get the press switcher data and assign it to
* the template manager.
* @param $contexts ItemIterator
* @param $currentContext Context
*/
function _assignContextSwitcherData(&$contexts, $currentContext = null) {
$workingContexts = $contexts->toArray();

$dispatcher = $this->request->getDispatcher();
$contextsNameAndUrl = array();
foreach ($workingContexts as $workingContext) {
$contextUrl = $dispatcher->url($this->request, ROUTE_PAGE, $workingContext->getPath());
$contextsNameAndUrl[$contextUrl] = $workingContext->getLocalizedName();
};

// Get the current context switcher value. We don´t need to worry about the
// value when there is no current context, because then the switcher will not
// be visible.
$currentContextUrl = null;
if ($currentContext) {
$currentContextUrl = $dispatcher->url($this->request, ROUTE_PAGE, $currentContext->getPath());
} else {
$contextsNameAndUrl = array(__('press.select')) + $contextsNameAndUrl;
}

$this->assign('currentContextUrl', $currentContextUrl);
$this->assign('contextsNameAndUrl', $contextsNameAndUrl);
}
}

Expand Down
29 changes: 17 additions & 12 deletions pages/header/HeaderHandler.inc.php
@@ -1,7 +1,7 @@
<?php

/**
* @file pages/index/HeaderHandler.inc.php
* @file pages/header/HeaderHandler.inc.php
*
* Copyright (c) 2003-2012 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
Expand All @@ -12,30 +12,35 @@
* @brief Handle site header requests.
*/

import('lib.pkp.pages.header.PKPHeaderHandler');

import('classes.handler.Handler');

class HeaderHandler extends Handler {
class HeaderHandler extends PKPHeaderHandler {
/**
* Constructor
*/
function HeaderHandler() {
parent::Handler();
parent::PKPHeaderHandler();
}


//
// Public handler operations
// Private methods
//
/**
* Display the header.
* @param $args array
* Get the iterator of working contexts.
* @param $request PKPRequest
* @return ItemIterator
*/
function index($args, &$request) {
$this->setupTemplate($request);
$templateMgr =& TemplateManager::getManager($request);
return $templateMgr->fetchJson('header/index.tpl');
function _getWorkingContexts($request) {
// Check for multiple presses.
$pressDao = DAORegistry::getDAO('PressDAO');

$user = $request->getUser();
if (is_a($user, 'User')) {
return $pressDao->getAll();
} else {
return $pressDao->getEnabledPresses();
}
}
}

Expand Down
42 changes: 0 additions & 42 deletions pages/sidebar/SidebarHandler.inc.php

This file was deleted.

2 changes: 1 addition & 1 deletion pages/sidebar/index.php
Expand Up @@ -19,7 +19,7 @@
switch ($op) {
case 'index':
define('HANDLER_CLASS', 'SidebarHandler');
import('pages.sidebar.SidebarHandler');
import('lib.pkp.pages.sidebar.SidebarHandler');
break;
}

Expand Down
26 changes: 0 additions & 26 deletions templates/sidebar/sidebar.tpl

This file was deleted.

0 comments on commit 9ebb64a

Please sign in to comment.