Skip to content
Snippets Groups Projects
Commit 06800c59 authored by Demian Katz's avatar Demian Katz
Browse files

Defined static routes; adjusted parameter lists to URL view helper to use them.

parent 6b688a47
No related merge requests found
Showing
with 190 additions and 180 deletions
<?php
return array(
namespace VuFind\Module\Configuration;
$config = array(
'router' => array(
'routes' => array(
'default' => array(
......@@ -16,100 +18,6 @@ return array(
),
),
),
'record' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/Record/[:id[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Record',
'action' => 'Home',
),
),
),
'missingrecord' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/MissingRecord/[:id[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'MissingRecord',
'action' => 'Home',
),
),
),
'summonrecord' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/SummonRecord/[:id[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'MissingRecord',
'action' => 'Home',
),
),
),
'worldcatrecord' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/WorldCatRecord/[:id[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'WorldCatRecord',
'action' => 'Home',
),
),
),
'userList' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/MyResearch/MyList/[:id]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'MyResearch',
'action' => 'MyList',
),
),
),
'editList' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/MyResearch/EditList/[:id]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'MyResearch',
'action' => 'EditList',
),
),
),
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'index',
'action' => 'Home',
),
),
),
),
),
'controller' => array(
......@@ -127,3 +35,110 @@ return array(
'template_path_stack' => array(),
),
);
// Define record view routes -- route name => controller
$recordRoutes = array(
'record' => 'Record',
'missingrecord' => 'MissingRecord',
'summonrecord' => 'SummonRecord',
'worldcatrecord' => 'WorldCatRecord'
);
// Define list-related routes -- route name => MyResearch action
$listRoutes = array('userList' => 'MyList', 'editList' => 'EditList');
// Define static routes -- Controller/Action strings
$staticRoutes = array(
'Admin/Config', 'Admin/DeleteExpiredSearches', 'Admin/EnableAutoConfig',
'Admin/Maintenance', 'Admin/Statistics', 'AlphaBrowse/Home',
'AlphaBrowse/Results',
'Author/Home', 'Author/Search',
'Authority/Home', 'Authority/Record', 'Authority/Search',
'Browse/Author', 'Browse/Dewey', 'Browse/Era', 'Browse/Genre', 'Browse/Home',
'Browse/LCC', 'Browse/Region', 'Browse/Tag', 'Browse/Topic',
'Cart/Email', 'Cart/Export', 'Cart/Home', 'Cart/MyResearchBulk', 'Cart/Save',
'Cover/Unavailable', 'Help/Home',
'Install/Done', 'Install/FixBasicConfig', 'Install/FixCache',
'Install/FixDatabase', 'Install/FixDependencies', 'Install/FixILS',
'Install/FixSolr', 'Install/Home',
'MyResearch/Account', 'MyResearch/CheckedOut', 'MyResearch/Delete',
'MyResearch/DeleteList', 'MyResearch/Edit', 'MyResearch/Email',
'MyResearch/Export', 'MyResearch/Favorites', 'MyResearch/Holds',
'MyResearch/Home', 'MyResearch/Logout', 'MyResearch/Profile',
'MyResearch/SaveSearch',
'OAI/Server', 'Records/Home',
'Search/Advanced', 'Search/Email', 'Search/History', 'Search/Home',
'Search/NewItem', 'Search/OpenSearch', 'Search/Reserves', 'Search/Results',
'Search/Suggest',
'Summon/Advanced', 'Summon/Home', 'Summon/Search',
'Tag/Home',
'Upgrade/Home', 'Upgrade/FixAnonymousTags', 'Upgrade/FixMetadata',
'Upgrade/GetDBCredentials', 'Upgrade/GetSourceDir', 'Upgrade/Reset',
'WorldCat/Advanced', 'WorldCat/Home', 'WorldCat/Search'
);
// Build record routes
foreach ($recordRoutes as $routeName => $controller) {
$config['router']['routes'][$routeName] = array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/' . $controller . '/[:id[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => $controller,
'action' => 'Home',
)
)
);
}
// Build list routes
foreach ($listRoutes as $routeName => $action) {
$config['router']['routes'][$routeName] = array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/MyResearch/' . $action . '/[:id]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'MyResearch',
'action' => $action,
)
)
);
}
// Build static routes
foreach ($staticRoutes as $route) {
list($controller, $action) = explode('/', $route);
$routeName = str_replace('/', '-', strtolower($route));
$config['router']['routes'][$routeName] = array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/' . $route,
'defaults' => array(
'controller' => $controller,
'action' => $action,
)
)
);
}
// Add the home route last
$config['router']['routes']['home'] = array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'index',
'action' => 'Home',
)
)
);
return $config;
\ No newline at end of file
......@@ -337,19 +337,30 @@ abstract class Options
}
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
abstract public function getSearchAction();
/**
* Return an array describing the action used for performing advanced searches
* (same format as expected by the URL view helper). Return false if the feature
* is not supported.
* Return the route name for the search home action.
*
* @return string
*/
public function getSearchHomeAction()
{
// Assume the home action is the same as the search action, only with
// a "-home" suffix in place of the search action.
$basicSearch = $this->getSearchAction();
return substr($basicSearch, 0, strpos($basicSearch, '-')) . '-home';
}
/**
* Return the route name of the action used for performing advanced searches.
* Returns false if the feature is not supported.
*
* @return array|bool
* @return string|bool
*/
public function getAdvancedSearchAction()
{
......
......@@ -54,13 +54,12 @@ class VF_Search_Favorites_Options extends VF_Search_Base_Options
}
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
public function getSearchAction()
{
return array('controller' => 'MyResearch', 'action' => 'Favorites');
return 'myresearch-favorites';
}
}
\ No newline at end of file
......@@ -38,13 +38,12 @@
class VF_Search_MixedList_Options extends VF_Search_Base_Options
{
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
public function getSearchAction()
{
return array('controller' => 'Records', 'action' => 'Home');
return 'records-home';
}
}
\ No newline at end of file
......@@ -293,26 +293,25 @@ class Options extends BaseOptions
}
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
public function getSearchAction()
{
return array('controller' => 'Search', 'action' => 'Results');
return 'search-results';
}
/**
* Return an array describing the action used for performing advanced searches
* (same format as expected by the URL view helper). Return false if the feature
* is not supported.
* Return the route name of the action used for performing advanced searches.
* Returns false if the feature is not supported.
*
* @return array|bool
* @return string|bool
*/
public function getAdvancedSearchAction()
{
return array('controller' => 'Search', 'action' => 'Advanced');
return 'search-advanced';
}
/**
......
......@@ -50,22 +50,20 @@ class VF_Search_SolrAuth_Options extends VF_Search_Solr_Options
}
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
public function getSearchAction()
{
return array('controller' => 'Authority', 'action' => 'Search');
return 'authority-search';
}
/**
* Return an array describing the action used for performing advanced searches
* (same format as expected by the URL view helper). Return false if the feature
* is not supported.
* Return the route name of the action used for performing advanced searches.
* Returns false if the feature is not supported.
*
* @return array|bool
* @return string|bool
*/
public function getAdvancedSearchAction()
{
......
......@@ -49,13 +49,12 @@ class VF_Search_SolrAuthor_Options extends VF_Search_Solr_Options
}
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
public function getSearchAction()
{
return array('controller' => 'Author', 'action' => 'Home');
return 'author-home';
}
}
\ No newline at end of file
......@@ -58,13 +58,12 @@ class VF_Search_SolrAuthorFacets_Options extends VF_Search_Solr_Options
}
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
public function getSearchAction()
{
return array('controller' => 'Author', 'action' => 'Search');
return 'author-search';
}
}
\ No newline at end of file
......@@ -52,22 +52,20 @@ class VF_Search_SolrReserves_Options extends VF_Search_Solr_Options
}
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
public function getSearchAction()
{
return array('controller' => 'Search', 'action' => 'Reserves');
return 'search-reserves';
}
/**
* Return an array describing the action used for performing advanced searches
* (same format as expected by the URL view helper). Return false if the feature
* is not supported.
* Return the route name of the action used for performing advanced searches.
* Returns false if the feature is not supported.
*
* @return array|bool
* @return string|bool
*/
public function getAdvancedSearchAction()
{
......
......@@ -117,26 +117,24 @@ class VF_Search_Summon_Options extends VF_Search_Base_Options
}
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
public function getSearchAction()
{
return array('controller' => 'Summon', 'action' => 'Search');
return 'summon-search';
}
/**
* Return an array describing the action used for performing advanced searches
* (same format as expected by the URL view helper). Return false if the feature
* is not supported.
* Return the route name of the action used for performing advanced searches.
* Returns false if the feature is not supported.
*
* @return array|bool
* @return string|bool
*/
public function getAdvancedSearchAction()
{
return array('controller' => 'Summon', 'action' => 'Advanced');
return 'summon-advanced';
}
/**
......
......@@ -54,13 +54,12 @@ class VF_Search_Tags_Options extends VF_Search_Base_Options
}
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
public function getSearchAction()
{
return array('controller' => 'Tag', 'action' => 'Home');
return 'tag-home';
}
}
\ No newline at end of file
......@@ -82,25 +82,23 @@ class VF_Search_WorldCat_Options extends VF_Search_Base_Options
}
/**
* Return an array describing the action used for rendering search results
* (same format as expected by the URL view helper).
* Return the route name for the search results action.
*
* @return array
* @return string
*/
public function getSearchAction()
{
return array('controller' => 'WorldCat', 'action' => 'Search');
return 'worldcat-search';
}
/**
* Return an array describing the action used for performing advanced searches
* (same format as expected by the URL view helper). Return false if the feature
* is not supported.
* Return the route name of the action used for performing advanced searches.
* Returns false if the feature is not supported.
*
* @return array|bool
* @return string|bool
*/
public function getAdvancedSearchAction()
{
return array('controller' => 'WorldCat', 'action' => 'Advanced');
return 'worldcat-advanced';
}
}
\ No newline at end of file
......@@ -60,14 +60,12 @@ class VuFind_Theme_Root_Helper_RecordLink extends Zend_View_Helper_Abstract
{
switch ($link['type']) {
case 'bib':
$url = $this->view->url(array('id' => $link['value']), 'record');
$url = $this->view->url('record', array('id' => $link['value']));
break;
case 'oclc':
$url = $this->view->url(
array('controller' => 'Search', 'action' => 'Results'), 'default'
);
$url .= '?lookfor=' . urlencode($link['value']) .
'&type=oclc_num&jumpto=1';
$url = $this->view->url('search-results');
. '?lookfor=' . urlencode($link['value'])
. '&type=oclc_num&jumpto=1';
break;
default:
throw new Exception('Unexpected link type: ' . $link['type']);
......@@ -90,7 +88,7 @@ class VuFind_Theme_Root_Helper_RecordLink extends Zend_View_Helper_Abstract
if (!empty($action)) {
$params['action'] = $action;
}
return $this->view->url($params, $driver->getRecordRoute(), true);
return $this->view->url($driver->getRecordRoute(), $params);
}
/**
......
......@@ -6,11 +6,11 @@
<div class="span-5">
<? foreach($similarAuthors['list'] as $i => $author): ?>
<? if ($i == 5): ?>
<a href="<?=$this->url(array('action' => 'Search', 'controller' => 'Author'), 'default', true) . '?lookfor=' . urlencode($this->recommend->getSearchTerm()) ?>"><strong><?=$this->transEsc("see all") ?> <?=(isset($similarAuthors['count']) && $similarAuthors['count']) ? $similarAuthors['count'] : ''?> &raquo;</strong></a>
<a href="<?=$this->url('author-search') . '?lookfor=' . urlencode($this->recommend->getSearchTerm()) ?>"><strong><?=$this->transEsc("see all") ?> <?=(isset($similarAuthors['count']) && $similarAuthors['count']) ? $similarAuthors['count'] : ''?> &raquo;</strong></a>
</div>
<div class="span-5 last">
<? endif; ?>
<a style="display:inline-block;text-indent:-10px;padding-left:10px;" href="<?=$this->url(array('controller' => 'Author'), 'default', true) . '?author=' . urlencode($author['value'])?>"><?=$author['value'] ?><? /* count disabled -- uncomment to add: echo ' - ' . $author['count']; */ ?></a>
<a style="display:inline-block;text-indent:-10px;padding-left:10px;" href="<?=$this->url('author-home') . '?author=' . urlencode($author['value'])?>"><?=$author['value'] ?><? /* count disabled -- uncomment to add: echo ' - ' . $author['count']; */ ?></a>
<? if ($i+1<count($similarAuthors['list'])): ?>
<br/>
<? endif; ?>
......
......@@ -7,7 +7,7 @@
<img src="<?=$this->info['image'] ?>" alt="<?=$this->escape($this->info['altimage']) ?>" width="150px" class="alignleft recordcover"/>
<? endif; ?>
<?=$this->truncate(preg_replace('/___baseurl___/', $this->url(array('controller' => 'Search', 'action' => 'Results'), 'default', true), $this->info['description']), 4500, "...") ?>
<?=$this->truncate(preg_replace('/___baseurl___/', $this->url('search-results'), $this->info['description']), 4500, "...") ?>
<div class="providerLink"><a class="wikipedia" href="http://<?=$this->info['wiki_lang'] ?>.wikipedia.org/wiki/<?=$this->escape($this->info['name']/*url*/) ?>" target="new"><?=$this->translate('wiki_link') ?></a></div>
......
......@@ -5,7 +5,7 @@
<? for ($i = 0; $i < count($data); $i++): ?>
<?
// Generate a new search URL that replaces the user's current term with the authority term:
$url = $this->url($this->results->getSearchAction(), 'default', true)
$url = $this->url($this->results->getSearchAction())
. $this->results->getUrl()->replaceTerm($this->results->getDisplayQuery(), $data[$i]['heading']);
?>
<a href="<?=$url?>"><?=$this->escape($data[$i]['heading'])?></a><? if ($i != count($data) - 1): ?>, <? endif; ?>
......
......@@ -35,6 +35,6 @@
</li>
<? endforeach; ?>
</ul>
<p><a href="<?=$this->url($searchObject->getSearchAction(), 'default', true) . $searchObject->getUrl()->setLimit($searchObject->getDefaultLimit())?>"><?=$this->transEsc('More catalog results')?>...</a></p>
<p><a href="<?=$this->url($searchObject->getSearchAction()) . $searchObject->getUrl()->setLimit($searchObject->getDefaultLimit())?>"><?=$this->transEsc('More catalog results')?>...</a></p>
</div>
<? endif ?>
\ No newline at end of file
......@@ -9,7 +9,7 @@
<h4><?=$this->translate($cluster['label']) ?></h4>
<ul class="bulleted">
<? foreach ($cluster['list'] as $thisFacet): ?>
<li><a href="<?=$this->url(array('controller'=>'Search','action'=>'Results'),'default',true) . $blankResults->getUrl()->addFacet($title, $thisFacet['value'])?>"><?=$this->escape($thisFacet['displayText'])?></a></li>
<li><a href="<?=$this->url('search-results') . $blankResults->getUrl()->addFacet($title, $thisFacet['value'])?>"><?=$this->escape($thisFacet['displayText'])?></a></li>
<? endforeach; ?>
</ul>
<? endforeach; ?>
......
......@@ -10,7 +10,7 @@
<? if ($current['isApplied']): ?>
<strong><?=$this->escape($current['displayText'])?></strong>
<? else: ?>
<a href="<?=$this->url(array('id' => $current['value']), 'userList')?>"><?=$this->escape($current['displayText'])?></a>
<a href="<?=$this->url('userList', array('id' => $current['value']))?>"><?=$this->escape($current['displayText'])?></a>
<? endif; ?>
(<?=$this->escape($current['count'])?>)
</li>
......
......@@ -32,7 +32,7 @@
<? foreach ($sideFacetSet as $title => $cluster): ?>
<? if (isset($dateFacets[$title])): ?>
<? /* Load the publication date slider UI widget */ $this->headScript()->appendFile('pubdate_slider.js'); ?>
<form action="<?=$this->url()?>" name="<?=$this->escape($title)?>Filter" id="<?=$this->escape($title)?>Filter">
<form action="" name="<?=$this->escape($title)?>Filter" id="<?=$this->escape($title)?>Filter">
<?=$this->results->getUrl()->asHiddenFields(array('filter' => "/^{$title}:.*/"))?>
<input type="hidden" name="daterange[]" value="<?=$this->escape($title)?>"/>
<fieldset class="publishDateLimit" id="<?=$this->escape($title)?>">
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment