1<?php
2	// open plplot rss news feed via simplepie
3	include('simplepie.inc');
4
5	// Substring without losing word meaning and
6	// tiny words (length 3 by default) are included on the result.
7	// "..." is added if result do not reach original string length
8	// taken from http://www.php.net/manual/en/function.substr.php#93963
9	function _substr($str, $length, $minword = 3)
10	{
11    $sub = '';
12    $len = 0;
13
14    foreach(explode(' ', $str) as $word) {
15	    $part = (($sub != '') ? ' ' : '') . $word;
16	    $sub .= $part;
17	    $len += strlen($part);
18
19	    if(strlen($word) > $minword && strlen($sub) >= $length) {
20	    	break;
21	    }
22    }
23
24    return $sub . (($len < strlen($str)) ? '...' : '');
25	}
26
27	//
28	// Print standard page header
29	//
30	function pageHeader($title="Main")
31	{
32		echo <<<END
33<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
34<html xmlns="http://www.w3.org/1999/xhtml">
35
36<!--
37Copyright 2008-2010 Werner Smekal
38Copyright 2008-2011 Hazen Babcock
39Copyright 2008-2013 Alan W. Irwin
40-->
41
42<head>
43  <title>PLplot Home Page - $title</title>
44	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
45  <meta name="description" content="Homepage of the open source PLplot project" />
46  <meta name="keywords" content="plot,library,c++,python" />
47  <link rel="stylesheet" title="liquid" href="css/style_liquid.css" type="text/css" media="screen,projection" />
48  <link rel="alternate stylesheet" title="static" href="css/style_static.css" type="text/css" media="screen,projection" />
49  <script type="text/javascript" src="js/slimbox.js"></script>
50  <link rel="stylesheet" href="css/slimbox.css" type="text/css" media="screen" />
51</head>
52
53END;
54	}
55
56	//
57	// Print menu code with selected element
58	// $item might be: index, downloads, examples, development, credits
59	//
60	function pageMenu($item)#
61	{
62		echo "	<div id=\"pageheader\">\n";
63		echo "	</div>\n";
64
65		echo '	<div id="menubar">';
66		echo '		<ul>';
67		echo '		  <li><a href="index.php" ' . (($item=='index') ? ('id="selected"') : ('')) .'>Home</a></li>';
68		echo '		  <li><a href="http://sourceforge.net/p/plplot/news" ' . (($item=='news') ? ('id="selected"') : ('')) .'>News</a></li>';
69		echo '		  <li><a href="downloads.php" ' . (($item=='downloads') ? ('id="selected"') : ('')) .'>Downloads</a></li>';
70		echo '		  <li><a href="examples.php" ' . (($item=='examples') ? ('id="selected"') : ('')) .'>Examples</a></li>';
71		echo '		  <li><a href="documentation.php" ' . (($item=='documentation') ? ('id="selected"') : ('')) .'>Documentation</a></li>';
72//		echo '		  <li><a href="development.php" ' . (($item=='development') ? ('id="selected"') : ('')) .'>Development</a></li>';
73		echo '		  <li><a href="credits.php" ' . (($item=='credits') ? ('id="selected"') : ('')) .'>Credits</a></li>';
74		echo '		</ul>';
75		echo '	</div>';
76	}
77
78	//
79	// Print a standard page footer
80	//
81	function pageFooter()
82	{
83		echo '		<div id="pagefooter">';
84		echo '			<p>Original design by <a href="http://DesignsByDarren.com">DesignsByDarren.com</a>, Some Rights Reserved.<br/>Design modifications &copy; 2008-2015 Plplot developer community.<br /><br/>';
85		echo '			<a href="http://validator.w3.org/check?uri=referer"><img style="border:0;width:88px;height:31px" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" /></a>';
86		echo '      <a href="http://jigsaw.w3.org/css-validator/check?uri=referer"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /></a>';
87		echo '      </p>';
88		echo '		</div>';
89	}
90
91	//
92	// Print News from project page
93	// $newscount - number of news itmes to be shown
94	// $contentlength - defines the length in characters of the news content
95	//
96	function pageNews($newscount, $contentlength)
97	{
98		// Open the PLplot News RSS feed and parse it (rss link taken from the plplot project page)
99		$feed = new SimplePie();
100		$feed->enable_cache(false);  // disable cache
101		$feed->set_feed_url("http://sourceforge.net/p/plplot/news/feed");
102		$feed->init();
103		$feed->handle_content_type();
104
105		// In case of error show error
106		//if($feed->error())
107		//	echo $feed->error();
108
109		// show news items
110		if($feed->data) {
111			$items = $feed->get_items();
112			$i = 0;
113			foreach($items as $item) {
114				echo '<h4><a href="' . $item->get_permalink() . '">' . $item->get_title() . '</a></h4>' . "\n";
115				echo '<p>' . _substr(strip_tags($item->get_content()), $contentlength) . ' ';
116				echo '<a href="' . $item->get_permalink() . '">Read more</a> (' . $item->get_date('j M Y') . ')</p>' . "\n";
117
118				$i = $i + 1;
119				if( $i >= $newscount )
120					break;
121			}
122		} else
123			echo '<p>Could not open <a href="' . $url . '">News feed</a>!</p>';
124	}
125
126	//
127	// Print a standard sidebar
128	//
129	function pageSidebar($news=0)
130	{
131		echo <<<END
132		<!-- Sidebar -->
133		<div id="rightside">
134END;
135//			Permanently disable and do another way (see above)
136//                      because pageNews calls SF php script that returns
137//			bad URL's.
138		echo "<h3>News</h3>\n";
139		pageNews(3, 100);
140
141		echo <<<END
142			<h3>Resources</h3>
143			<ul class="arrowlist">
144				<li><a href="documentation.php">Documentation</a></li>
145				<li><a href="http://sourceforge.net/p/plplot/wiki">Wiki</a></li>
146				<li><a href="http://sourceforge.net/projects/plplot">SourceForge Project Page</a></li>
147				<li><a href="http://sourceforge.net/projects/plplot/support">Project Support Page</a></li>
148				<li><a href="http://sourceforge.net/p/plplot/mailman/">Mailing Lists</a></li>
149				<li><a href="http://sourceforge.net/p/plplot/bugs/">Bug Tracker</a></li>
150			</ul>
151			<h3>Source Code</h3>
152			<ul class="arrowlist">
153				<li><a href="http://sourceforge.net/projects/plplot/files/plplot/">Releases</a></li>
154				<li>git repository is git://git.code.sf.net/p/plplot/plplot</li>
155				<li><a href="http://sourceforge.net/p/plplot/plplot/ci/master/tree/">Browse git repository</a></li>
156			</ul>
157
158		</div>
159END;
160	}
161
162?>
163