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 landingpage module configuration form and add install script
- Loading branch information
Jamie Snape
committed
Dec 5, 2014
1 parent
1e7f746
commit 6ccd95a
Showing
12 changed files
with
223 additions
and
190 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 |
---|---|---|
@@ -1,11 +1,8 @@ | ||
; MIDAS Server. Copyright Kitware SAS. Licensed under the Apache License 2.0. | ||
|
||
[global] | ||
; version of the module | ||
version = 1.0.0 | ||
; full name | ||
fullname = Landing Page | ||
; description | ||
description = Module for adding a custom landing page to the Midas instance | ||
; category | ||
category = Core | ||
; dependencies | ||
dependencies = | ||
fullname = "Landing Page" | ||
description = "Display a custom landing page" | ||
category = "Core" | ||
uuid = "00c52901-4892-41a3-9e24-dd9fa56ad1f8" | ||
version = "1.0.0" |
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,22 @@ | ||
<?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('LANDINGPAGE_TEXT_KEY', 'text'); | ||
define('LANDINGPAGE_TEXT_DEFAULT_VALUE', 'Welcome to __Midas Platform__.'); |
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,93 @@ | ||
<?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 landingpage module. | ||
* | ||
* @property Landingpage_TextModel $Landingpage_Text | ||
*/ | ||
class Landingpage_AdminController extends Landingpage_AppController | ||
{ | ||
/** @var array */ | ||
public $_models = array('Setting'); | ||
|
||
/** @var array */ | ||
public $_moduleDaos = array('Text'); | ||
|
||
/** @var array */ | ||
public $_moduleModels = array('Text'); | ||
|
||
/** Index action */ | ||
public function indexAction() | ||
{ | ||
$this->requireAdminPrivileges(); | ||
|
||
$this->view->pageTitle = 'Landing Page Module Configuration'; | ||
$form = new Landingpage_Form_Admin(); | ||
$textDaos = $this->Landingpage_Text->getAll(); | ||
|
||
if ($this->getRequest()->isPost()) { | ||
$data = $this->getRequest()->getPost(); | ||
|
||
if ($form->isValid($data)) { | ||
$values = $form->getValues(); | ||
|
||
if (count($textDaos) > 0) { | ||
$textDao = $textDaos[0]; | ||
} else { | ||
/** @var Landingpage_TextDao $textDao */ | ||
$textDao = MidasLoader::newDao('Text', $this->moduleName); | ||
} | ||
|
||
$textDao->setText($values[LANDINGPAGE_TEXT_KEY]); | ||
$this->Landingpage_Text->save($textDao); | ||
unset($values[LANDINGPAGE_TEXT_KEY]); | ||
|
||
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 === LANDINGPAGE_TEXT_KEY) { | ||
if (count($textDaos) > 0) { | ||
$value = $textDaos[0]->getText(); | ||
$form->setDefault($name, $value); | ||
} | ||
} elseif ($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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?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 landingpage module. */ | ||
class Landingpage_Form_Admin extends Zend_Form | ||
{ | ||
/** Initialize this form. */ | ||
public function init() | ||
{ | ||
$this->setName('landingpage_admin'); | ||
$this->setMethod('POST'); | ||
|
||
$csrf = new Midas_Form_Element_Hash('csrf'); | ||
$csrf->setSalt('kUjBumZdEykrY8JHB88uzZjv'); | ||
$csrf->setDecorators(array('ViewHelper')); | ||
|
||
$text = new Zend_Form_Element_Textarea(LANDINGPAGE_TEXT_KEY); | ||
$text->setLabel('Landing Page Text'); | ||
$text->setRequired(true); | ||
$text->addValidator('NotEmpty', true); | ||
$text->setAttrib('cols', '120'); | ||
$text->setAttrib('rows', '100'); | ||
|
||
$this->addDisplayGroup(array($text), 'global'); | ||
|
||
$submit = new Zend_Form_Element_Submit('submit'); | ||
$submit->setLabel('Save'); | ||
|
||
$this->addElements(array($csrf, $text, $submit)); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?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)); | ||
?> | ||
|
||
<div class="viewMain"> | ||
<h1><?php echo $this->escape($this->pageTitle); ?></h1> | ||
<?php echo $this->form; ?> | ||
<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.