diff options
author | Guillaume Mazoyer <gmazoyer@gravitons.in> | 2016-03-14 12:53:55 +0100 |
---|---|---|
committer | Guillaume Mazoyer <gmazoyer@gravitons.in> | 2016-03-14 12:53:55 +0100 |
commit | b1bb5fdc0ab52342ae17da470f8368e75d9172c8 (patch) | |
tree | b953fc5c90ab1fa061b67e8a967b73394659df49 | |
parent | 30a0e57a35215cf4efcaa5c3ab1e4cd4eba4e4cc (diff) |
Peering Policy configuration options.
Add configuration variable to set the path to a file containing a peering
policy. This file must be readable by the webserver and must contain HTML
formatted text (on which CSS rules will be applied).
If the variable is set to null, no peering policy will be displayed.
-rw-r--r-- | docs/configuration.md | 7 | ||||
-rw-r--r-- | includes/config.defaults.php | 2 | ||||
-rw-r--r-- | index.php | 39 |
3 files changed, 46 insertions, 2 deletions
diff --git a/docs/configuration.md b/docs/configuration.md index d237231..47ef38e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -54,6 +54,13 @@ Sets the link used in the header of the page. If set to null no link will be used and the header will not be clickable. ```php +$config['frontpage']['peering_policy_file'] = null; +``` +Sets the path to the peering policy file. If set to null no peering policy +will be able to be shown. The peering policy file must be located in a +readable location and must contain only HTML formatted text. + +```php $config['frontpage']['disclaimer'] = 'Disclaimer example'; ``` Sets the disclaimer that should displayed. If set to null no disclaimer will diff --git a/includes/config.defaults.php b/includes/config.defaults.php index 9e44343..25eaf6f 100644 --- a/includes/config.defaults.php +++ b/includes/config.defaults.php @@ -46,6 +46,8 @@ $config = array( 'image' => null, // Link for the title/image 'header_link' => null, + // Peering Policy file (null for no peering policy) + 'peering_policy_file' => null, // Disclaimer (null for no disclaimer) 'disclaimer' => 'Disclaimer example', // Display the title @@ -171,12 +171,17 @@ final class LookingGlass { } } - if ($this->frontpage['disclaimer'] != null) { + if ($this->frontpage['disclaimer']) { print($this->frontpage['disclaimer']); print('<br /><br />'); } - if (($this->contact['name'] != null) && ($this->contact['mail'] != null)) { + if ($this->frontpage['peering_policy_file']) { + print('<button type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#peering-policy"><span class="glyphicon glyphicon-list-alt"></span> Peering Policy</button>'); + print('<br/><br/>'); + } + + if ($this->contact['name'] && $this->contact['mail']) { print('Contact: '); print('<a href="mailto:'.$this->contact['mail'].'">'. htmlentities($this->contact['name']).'</a>'); @@ -188,6 +193,33 @@ final class LookingGlass { print('</div>'); } + private function render_peering_policy_modal() { + print('<div id="peering-policy" class="modal fade">'); + print('<div class="modal-dialog">'); + print('<div class="modal-content">'); + print('<div class="modal-header">'); + print('<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>'); + print('<h4 class="modal-title">Peering Policy</h4>'); + print('</div>'); + print('<div class="modal-body">'); + if (!file_exists($this->frontpage['peering_policy_file'])) { + print('The peering policy file ('. + $this->frontpage['peering_policy_file'].') does not exist.'); + } else if (!is_readable($this->frontpage['peering_policy_file'])) { + print('The peering policy file ('. + $this->frontpage['peering_policy_file'].') is not readable.'); + } else { + include($this->frontpage['peering_policy_file']); + } + print('</div>'); + print('<div class="modal-footer">'); + print('<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>'); + print('</div>'); + print('</div>'); + print('</div>'); + print('</div>'); + } + private function render_help_modal() { print('<div id="help" class="modal fade">'); print('<div class="modal-dialog">'); @@ -234,6 +266,9 @@ final class LookingGlass { $this->render_content(); $this->render_footer(); $this->render_help_modal(); + if ($this->frontpage['peering_policy_file']) { + $this->render_peering_policy_modal(); + } print('</body>'); print('<script src="libs/jquery-2.2.0.min.js"></script>'); print('<script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>'); |