From 4b42e3a3b0bfec440d36b16c7af5974fe77b120f Mon Sep 17 00:00:00 2001
From: Jaime Perez <jaime.perez@uninett.no>
Date: Thu, 7 Aug 2014 20:10:35 +0200
Subject: [PATCH] aggregator2: add an index page that lists the available
 aggregates and links to them.

---
 modules/aggregator2/templates/list.php | 33 ++++++++++++++++++++++++++
 modules/aggregator2/www/index.php      | 11 +++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 modules/aggregator2/templates/list.php
 create mode 100644 modules/aggregator2/www/index.php

diff --git a/modules/aggregator2/templates/list.php b/modules/aggregator2/templates/list.php
new file mode 100644
index 000000000..fbe350c21
--- /dev/null
+++ b/modules/aggregator2/templates/list.php
@@ -0,0 +1,33 @@
+<?php
+$this->includeAtTemplateBase('includes/header.php');
+?>
+    <h1><?php echo $this->t('{aggregator2:aggregator:header}'); ?></h1>
+
+<?php
+if (count($this->data['sources']) === 0) {
+    echo "    <p>".$this->t('{aggregator2:aggregator:no_aggregators}')."</p>\n";
+} else {
+    echo "    <ul>";
+
+    foreach ($this->data['sources'] as $id => $source) {
+        $encId = urlencode($id);
+        $params = array(
+            'id' => $encId,
+        );
+        echo str_repeat(' ', 8)."<li>\n";
+        echo str_repeat(' ', 12).'<a href="';
+        echo SimpleSAML_Module::getModuleURL('aggregator2/get.php', $params).'">'.htmlspecialchars($id)."</a>\n";
+        echo str_repeat(' ', 12).'<a href="';
+        $params['mimetype'] = 'text/plain';
+        echo SimpleSAML_Module::getModuleURL('aggregator2/get.php', $params).'">['.
+            $this->t('{aggregator2:aggregator:text}')."]</a>\n";
+        echo str_repeat(' ', 12).'<a href="';
+        $params['mimetype'] = 'application/xml';
+        echo SimpleSAML_Module::getModuleURL('aggregator2/get.php', $params)."\">[XML]</a>\n";
+        echo str_repeat(' ', 8)."</li>\n";
+    }
+
+    echo "    </ul>\n";
+}
+
+$this->includeAtTemplateBase('includes/footer.php');
diff --git a/modules/aggregator2/www/index.php b/modules/aggregator2/www/index.php
new file mode 100644
index 000000000..17764c58e
--- /dev/null
+++ b/modules/aggregator2/www/index.php
@@ -0,0 +1,11 @@
+<?php
+
+$ssp_cf = SimpleSAML_Configuration::getInstance();
+$mod_cf = SimpleSAML_Configuration::getConfig('module_aggregator2.php');
+
+// get list of sources
+$sources = $mod_cf->toArray();
+
+$t = new SimpleSAML_XHTML_Template($ssp_cf, 'aggregator2:list.php');
+$t->data['sources'] = $sources;
+$t->show();
-- 
GitLab