Skip to content

Commit 17080ed

Browse files
committed
Added an option to change the url of the repository.
1 parent f8917ea commit 17080ed

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

OaiPmhRepositoryPlugin.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
* @package OaiPmhRepository
66
*/
77

8-
define('OAI_PMH_BASE_URL',WEB_ROOT.'/oai-pmh-repository/request');
8+
define('OAI_PMH_BASE_URL',
9+
WEB_ROOT . '/'
10+
. (($baseUrl = get_option('oaipmh_repository_base_url'))
11+
? $baseUrl
12+
: 'oai-pmh-repository/request'));
913
define('OAI_PMH_REPOSITORY_PLUGIN_DIRECTORY',dirname(__FILE__));
1014

1115
/**
@@ -21,13 +25,15 @@ class OaiPmhRepositoryPlugin extends Omeka_Plugin_AbstractPlugin
2125
'config',
2226
'uninstall',
2327
'initialize',
28+
'define_routes',
2429
);
2530

2631
protected $_filters = array(
2732
'admin_dashboard_panels'
2833
);
2934

3035
protected $_options = array(
36+
'oaipmh_repository_base_url' => 'oai-pmh-repository/request',
3137
'oaipmh_repository_name',
3238
'oaipmh_repository_namespace_id',
3339
'oaipmh_repository_expose_files' => 1,
@@ -113,6 +119,35 @@ public function hookInitialize()
113119
add_translation_source(dirname(__FILE__) . '/languages');
114120
}
115121

122+
/**
123+
* Define routes.
124+
*
125+
* @param Zend_Controller_Router_Rewrite $router
126+
*/
127+
public function hookDefineRoutes($args)
128+
{
129+
if (is_admin_theme()) {
130+
return;
131+
}
132+
133+
// If base url is not set, use the default module/controller/action.
134+
$route = get_option('oaipmh_repository_base_url');
135+
if (empty($route) || $route == 'oai-pmh-repository/request') {
136+
return;
137+
}
138+
139+
$args['router']->addRoute('oai-pmh-repository', new Zend_Controller_Router_Route(
140+
$route,
141+
array(
142+
'module' => 'oai-pmh-repository',
143+
'controller' => 'request',
144+
'action' => 'index',
145+
)));
146+
}
147+
148+
/**
149+
* Filter to add a dashboard panel.
150+
*/
116151
public function filterAdminDashboardPanels($panels)
117152
{
118153
ob_start();

config_form.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
<p><?php echo __('Harvester can access metadata from this site') . ' '; ?>
1717
<a href="<?php echo OAI_PMH_BASE_URL; ?>"><?php echo OAI_PMH_BASE_URL; ?></a></p>
1818

19+
<div class="field">
20+
<div class="two columns alpha">
21+
<?php echo $view->formLabel('oaipmh_repository_base_url',
22+
__('Repository base url')); ?>
23+
</div>
24+
<div class="inputs five columns omega">
25+
<p class="explanation">
26+
<?php echo __('Base URL for this OAI-PMH repository.');
27+
echo ' ' . __('Default is "oai-pmh-repository/request" (always available), but it can be "oai/request" or simply "oai-pmh".'); ?>
28+
</p>
29+
<p class="explanation">
30+
<?php echo __('Currently, harvesters can access metadata from this url: %s.', sprintf('<a href="%s">%s</a>', OAI_PMH_BASE_URL, OAI_PMH_BASE_URL)); ?></p>
31+
</p>
32+
<?php echo $view->formText('oaipmh_repository_base_url', get_option('oaipmh_repository_base_url')); ?>
33+
</div>
34+
</div>
1935
<div class="field">
2036
<div class="two columns alpha">
2137
<label for="oaipmh_repository_name"><?php echo __('Repository name'); ?></label>
@@ -95,4 +111,3 @@
95111
array('checked' => (boolean) get_option('oaipmh_repository_add_human_stylesheet'))); ?>
96112
</div>
97113
</div>
98-

0 commit comments

Comments
 (0)