about summary refs log tree commit diff
path: root/page.php
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@gmail.com>2018-03-20 12:08:43 -0400
committerZach DeCook <zachdecook@gmail.com>2018-03-20 12:08:43 -0400
commitb01ad1d9123ab8f497ce78fcab0c5caebc0cc993 (patch)
tree2f3e81f50a665b8316eb774b7deba4ba023954e5 /page.php
parentf3c77eac34d58d3e3c3173419a9b2c82d2141740 (diff)
downloadprosongsa-b01ad1d9123ab8f497ce78fcab0c5caebc0cc993.tar.gz
* Allow sorting by bible book and by key
Diffstat (limited to 'page.php')
-rw-r--r--page.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/page.php b/page.php
index d710b28..94d0317 100644
--- a/page.php
+++ b/page.php
@@ -8,7 +8,7 @@
 /**
  * @brief Go through the file inputfile.txt and return each song with a link to it.
  */
-function toc(){
+function toc( $sort ){
 	$handle = fopen("inputfile.txt", "r");
 	$entries = array();
 	$number = 0;
@@ -42,6 +42,15 @@ function toc(){
 	}
 	$toc = '<form><input type="text" id="toc-filter" placeholder="Filter by song title"/></form>';
 	$toc .= '<ul id="toc">';
+	if ( $sort ){
+		include 'sort.php';
+		if ( $sort == 'key' ){
+			usort( $entries, 'tocKeysort' );
+		}
+		else if ( $sort == 'verse' ){
+			usort( $entries, 'tocBooksort' );
+		}
+	}
 	foreach( $entries as $item ){
 		$toc .= tocentry($item);
 	}