com web/pres2: Link to the generated reveal.js presentation if it exists: index.php

[email protected] (Rasmus Lerdorf)
Newsgroups php.pres
Message-ID <[email protected]>
Commit:    8c1c24043c008eee731fa6da1d5767cc5c9a995a
Author:    Rasmus Lerdorf <[email protected]>         Sun, 30 Mar 2014 06:11:07 -0700
Parents:   153e820b8ecd0a81326b916573c03d134afb3bcf
Branches:  master

Link:       http://git.php.net/?p=web/pres2.git;a=commitdiff;h=8c1c24043c008eee731fa6da1d5767cc5c9a995a

Log:
Link to the generated reveal.js presentation if it exists

Changed paths:
  M  index.php


Diff:
diff --git a/index.php b/index.php
index 345ef61..a331c4a 100644
--- a/index.php
+++ b/index.php
@@ -37,7 +37,13 @@
 		$p->setErrorHandling(PEAR_ERROR_DIE,"%s\n");
 		$p->parse();
 		$pres = $p->getObjects();
-		
+	
+		// Do we have a generated reveal.js version of this presentation?	
+		if(file_exists(substr($filename,0,strrpos($filename,'.')).".html")) {
+			$pr[$i]['generated'] = basename(substr($filename,0,strrpos($filename,'.')));
+		} else {
+			$pr[$i]['generated'] = false;
+		}
 		$pr[$i]['id'] = $pres_id;
 		$pr[$i]['slidecount'] = count($pres[1]->slides);
 		$pr[$i]['title'] = $pres[1]->title;
@@ -86,7 +92,7 @@
 <head>
 <base href="<?php echo "http://".htmlspecialchars($_SERVER['HTTP_HOST']).$baseDir?>">
 <title>PHP Presents</title>
-<?php include("css.php"); ?>
+<?php include "css.php"; ?>
 <script language="JavaScript1.2" type="text/javascript">
 <!--
 function change_mode() {
@@ -220,8 +226,12 @@ usort($pr,'cmp');
 for($j=0; $j < $prnum; $j++) {
 
 	if(strtolower($pr[$j]['topic']) == strtolower($topic)) {
-		print("<tr><td class='index'><a href=\"$baseDir$showScript/{$pr[$j]['id']}\">{$pr[$j]['title']}</a></td><td class='index'>{$pr[$j]['date']}</td><td class='index'>{$pr[$j]['location']}</td><td class='index'>{$pr[$j]['speaker']}</td><td class='index'>{$pr[$j]['slidecount']}</td></tr>");
+		if(!$pr[$j]['generated']) {
+			echo "<tr><td class='index'><a href=\"$baseDir$showScript/{$pr[$j]['id']}\">{$pr[$j]['title']}</a></td><td class='index'>{$pr[$j]['date']}</td><td class='index'>{$pr[$j]['location']}</td><td class='index'>{$pr[$j]['speaker']}</td><td class='index'>{$pr[$j]['slidecount']}</td></tr>";
+		} else {
+			echo "<tr><td class='index'><a href=\"$baseDir{$pr[$j]['generated']}\">{$pr[$j]['title']}</a></td><td class='index'>{$pr[$j]['date']}</td><td class='index'>{$pr[$j]['location']}</td><td class='index'>{$pr[$j]['speaker']}</td><td class='index'>{$pr[$j]['slidecount']}</td></tr>";
 
+		}
 	}
 
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.