This repository has been archived by the owner on Sep 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revise solr module configuration form and add install script
- Loading branch information
Jamie Snape
committed
Dec 8, 2014
1 parent
ed2aac5
commit b8bae79
Showing
11 changed files
with
214 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE | ||
All rights reserved. | ||
More information http://www.kitware.com | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
define('SOLR_HOST_KEY', 'solrHost'); | ||
define('SOLR_HOST_DEFAULT_VALUE', 'localhost'); | ||
define('SOLR_PORT_KEY', 'solrPort'); | ||
define('SOLR_PORT_DEFAULT_VALUE', 8983); | ||
define('SOLR_WEBROOT_KEY', 'solrWebroot'); | ||
define('SOLR_WEBROOT_DEFAULT_VALUE', '/solr/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE | ||
All rights reserved. | ||
More information http://www.kitware.com | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
/** Admin controller for the solr module. */ | ||
class Solr_AdminController extends Solr_AppController | ||
{ | ||
/** @var array */ | ||
public $_models = array('Setting'); | ||
|
||
/** Index action */ | ||
public function indexAction() | ||
{ | ||
$this->requireAdminPrivileges(); | ||
|
||
$this->view->pageTitle = 'Solr Module Configuration'; | ||
$form = new Solr_Form_Admin(); | ||
|
||
if ($this->getRequest()->isPost()) { | ||
$data = $this->getRequest()->getPost(); | ||
|
||
if ($form->isValid($data)) { | ||
$values = $form->getValues(); | ||
|
||
foreach ($values as $key => $value) { | ||
$this->Setting->setConfig($key, $value, $this->moduleName); | ||
} | ||
} | ||
|
||
$form->populate($data); | ||
} else { | ||
$elements = $form->getElements(); | ||
|
||
foreach ($elements as $element) { | ||
$name = $element->getName(); | ||
|
||
if ($name !== 'csrf' && $name !== 'submit') { | ||
$value = $this->Setting->getValueByName($name, $this->moduleName); | ||
|
||
if (!is_null($value)) { | ||
$form->setDefault($name, $value); | ||
} | ||
} | ||
} | ||
} | ||
|
||
$this->view->form = $form; | ||
session_start(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE | ||
All rights reserved. | ||
More information http://www.kitware.com | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
/** Admin form for the solr module. */ | ||
class Solr_Form_Admin extends Zend_Form | ||
{ | ||
/** Initialize this form. */ | ||
public function init() | ||
{ | ||
$this->setName('solr_admin'); | ||
$this->setMethod('POST'); | ||
|
||
$csrf = new Midas_Form_Element_Hash('csrf'); | ||
$csrf->setSalt('VhyLUG4sRzUwa43P96W7kVM8'); | ||
$csrf->setDecorators(array('ViewHelper')); | ||
|
||
$host = new Zend_Form_Element_Text(SOLR_HOST_KEY); | ||
$host->setLabel('Solr Host'); | ||
$host->setRequired(true); | ||
$host->addValidator('NotEmpty', true); | ||
$host->addValidator('Hostname', true); | ||
|
||
$port = new Zend_Form_Element_Text(SOLR_PORT_KEY); | ||
$port->setLabel('Solr Port'); | ||
$port->setRequired(true); | ||
$port->addValidator('NotEmpty', true); | ||
$port->addValidator('Digits', true); | ||
$port->addValidator('Between', true, array('min' => 1, 'max' => 65535)); | ||
$port->setAttrib('maxlength', 5); | ||
|
||
$webroot = new Zend_Form_Element_Text(SOLR_WEBROOT_KEY); | ||
$webroot->setLabel('Solr Webroot'); | ||
$webroot->setRequired(true); | ||
$webroot->addValidator('NotEmpty', true); | ||
|
||
$this->addDisplayGroup(array($host, $port, $webroot), 'global'); | ||
|
||
$submit = new Zend_Form_Element_Submit('submit'); | ||
$submit->setLabel('Save'); | ||
|
||
$this->addElements(array($csrf, $host, $port, $webroot, $submit)); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
...solr/public/scss/config/config.index.scss → ...s/solr/public/scss/admin/admin.index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/*========================================================================= | ||
MIDAS Server | ||
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE | ||
All rights reserved. | ||
More information http://www.kitware.com | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
$this->declareVars('form', 'pageTitle'); | ||
$this->headTitle($this->escape($this->pageTitle)); | ||
$this->headLink()->appendStylesheet($this->baseUrl('modules/solr/public/css/admin/admin.index.css')); | ||
$this->headScript()->appendFile($this->baseUrl('modules/solr/public/js/admin/admin.index.js')); | ||
?> | ||
|
||
<div class="viewMain"> | ||
<h1><?php echo $this->escape($this->pageTitle); ?></h1> | ||
<div class="instructionContainer"> | ||
This module requires you to run a specially configured Apache Solr server. Install instructions and a link to | ||
download the server are hosted <a href="http://midas3.kitware.com/midas/item/19589">here</a>. If you have | ||
existing content in this instance, make sure to rebuild the index using the link at the bottom of this page | ||
once the Solr server is installed and running. | ||
</div> | ||
<?php echo $this->form; ?> | ||
<div class="rebuildIndexContainer"> | ||
<p>Click the button below to rebuild the Lucene index on all items.</p> | ||
<div> | ||
<input class="globalButton" type="button" id="rebuildIndexButton" value="Rebuild index" /> | ||
</div> | ||
<div id="rebuildProgressBar"></div> | ||
<div id="rebuildProgressMessage"></div> | ||
</div> | ||
<p><a href="<?php echo $this->url(array('controller' => 'admin', 'action' => 'index'), 'default'); ?>#tabs-modules">« Back to Modules Administration</a></p> | ||
</div> |
Oops, something went wrong.