From: Hendrik B. <nh...@us...> - 2011-11-30 07:18:53
|
Update of /cvsroot/arianne/website/content In directory vz-cvs-4.sog:/tmp/cvs-serv21624/content Modified Files: news.php Log Message: moved news specific code from WriteHTML.php to news.php Index: news.php =================================================================== RCS file: /cvsroot/arianne/website/content/news.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** news.php 29 Nov 2011 22:43:19 -0000 1.16 --- news.php 30 Nov 2011 07:18:51 -0000 1.17 *************** *** 1,3 **** --- 1,99 ---- <?php + + + function WriteNewsHTML($website, $all) { + $maxNewsItems=5; + + echo '<ul class="newslist">'; + + foreach ($website['website'][0]['item'] as $key=>$item) { + if ($maxNewsItems==0) { + break; + } + if (!$all) { + $maxNewsItems--; + } + WriteNewsItemHtml($item); + } + + echo '</ul>'; + } + + + function WriteNewsHTMLHeaderForFirstItem($website, $title) { + foreach ($website['website'][0]['item'] as $key=>$item) { + if ($title == getNiceURL($item['title'][0])) { + echo '<title>'.$item['title'][0].ARIANNE_TITLE.'</title>'."\r\n"; + // meta title is for facebook + echo '<meta name="title" content="'.$item['title'][0].'">'."\r\n"; + $description = trim($item['content'][0]); + $pos = strpos($description, '<p>', 10); + if ($pos) { + $description = substr($description, 0, $pos); + } + $description = preg_replace('/(\r\n|\r|\n|")/s',' ', preg_replace('/<[^>]*>/', '', $description)); + echo '<meta name="description" content="'.$description.'">'."\r\n"; + + if (isset($item['images'])) { + foreach ($item['images'][0]['image'] as $key=>$image) { + if (is_array($image)) { + echo '<link rel="image_src" href="http://arianne.sourceforge.net/'.$image['url'].'">'; + return; + } + } + } + + break; + } + } + } + + + function WriteNewsHTMLForNamedItem($website, $title) { + echo '<ul class="newslist">'; + + foreach ($website['website'][0]['item'] as $key=>$item) { + if ($title == getNiceURL($item['title'][0])) { + WriteNewsItemHtml($item); + } + } + + echo '</ul>'; + } + + function WriteNewsItemHtml($item) + { + $strippedTitle = getNiceURL($item['title'][0]); + echo '<li class="clearright"><div class="newsitem"><div class="newstitle">' + .'<h2 style="padding:0; margin:0; margin-top:1em; font-weight: bold"><a class="newsitemtitle" href="/news/'.$strippedTitle.'.html">'.$item['title'][0].'</a></h2>' + .'</div><p class="itemdate">'.$item['date'][0].'</p>'; + + if (isset($item['images'])) { + + foreach ($item['images'][0]['image'] as $key=>$image) { + if (is_array($image)) { + echo '<img class="news_image" src="/'.$image['url'].'" alt="Game screenshot">'."\r\n"; + } + } + if (isset($item['playnow'])) { + echo '<a href="'.$item['playnow']['0 attr']['url'].'" style="display:block;float:right;width:250px;height:42;clear:right">'; + echo '<img style="margin-right:40px; width:170px; height:42" class="news_image" src="/'.$item['playnow']['0 attr']['image'].'"></a>'."\r\n"; + } + echo '<div class="newscontent_image">'.$item['content'][0].'</div>'; + echo '</div>'; + } else { + echo '<div class="newscontent_noimage">'.$item['content'][0].'</div></div>'; + } + // the sharing buttons should go here + echo '<div id="social_buttons">'; + $urlToPost = 'http://arianne.sourceforge.net/news/'.$strippedTitle.'.htm'; + // echo buildTweetButton($urlToPost, '@stendhalgame'); + // echo buildFacebookButton($item['title'][0], $urlToPost); + // echo buildGoogleBuzzButton($urlToPost); + echo '</div>'; + echo '</li>'; + } + + class News extends Page { private $all; |