Francois Gouget : news: Let the news items specify where they should link to.

Jeremy Newman jnewman at winehq.org
Tue Aug 5 11:22:12 CDT 2008


Module: website
Branch: master
Commit: 09db9cce69efe8c1fe9657d66d80da94813c2031
URL:    http://source.winehq.org/git/website.git/?a=commit;h=09db9cce69efe8c1fe9657d66d80da94813c2031

Author: Francois Gouget <fgouget at free.fr>
Date:   Mon Aug  4 15:21:36 2008 +0200

news: Let the news items specify where they should link to.

---

 site |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/site b/site
index 0efcec2..4feefe8 100644
--- a/site
+++ b/site
@@ -209,9 +209,11 @@ function view_news ($where)
         // get data from XML file
         $vars = array();
         if (file_exists($config->news_xml_path.'/'.$html->lang.'/'.$item))
-            list($vars['date'], $vars['title'], $vars['body']) = get_xml_tags($config->news_xml_path.'/'.$html->lang.'/'.$item, array('date', 'title', 'body'));
+            list($vars['date'], $vars['title'], $vars['link'], $vars['body']) = get_xml_tags($config->news_xml_path.'/'.$html->lang.'/'.$item, array('date', 'title', 'link', 'body'));
         else
-            list($vars['date'], $vars['title'], $vars['body']) = get_xml_tags($config->news_xml_path.'/'.$config->lang.'/'.$item, array('date', 'title', 'body'));
+            list($vars['date'], $vars['title'], $vars['link'], $vars['body']) = get_xml_tags($config->news_xml_path.'/'.$config->lang.'/'.$item, array('date', 'title', 'link', 'body'));
+        if ($vars['link'] != '')
+            $vars['title'] = '<a href="'.$vars['link'].'">'.$vars['title'].'</a>';
 
         // add to news body
         $news_body .= $html->template('base', 'news_row', $vars);
@@ -283,13 +285,17 @@ function view_rss ()
         
         // get data from XML file
         if (file_exists($config->news_xml_path.'/'.$html->lang.'/'.$item))
-            list($date, $title, $body) = get_xml_tags($config->news_xml_path.'/'.$html->lang.'/'.$item, array('date', 'title', 'body'));
+            list($date, $title, $link, $body) = get_xml_tags($config->news_xml_path.'/'.$html->lang.'/'.$item, array('date', 'title', 'link', 'body'));
         else
-            list($date, $title, $body) = get_xml_tags($config->news_xml_path.'/'.$config->lang.'/'.$item, array('date', 'title', 'body'));
-        
+            list($date, $title, $link, $body) = get_xml_tags($config->news_xml_path.'/'.$config->lang.'/'.$item, array('date', 'title', 'link', 'body'));
+
         // fix filename for urls
         $item = str_replace(".xml", "", $item);
-        
+
+        // compute where to link to if unspecified
+        if ($link == '')
+            $link = $config->base_url.'?news='.$item;
+
         // fix relative URLs
         $body = str_replace("<a href=\"?", "<a href=\"{$config->base_url}/?", $body);
         $body = str_replace("<a href=\"/site", "<a href=\"{$config->base_url}/site", $body);
@@ -298,7 +304,7 @@ function view_rss ()
         $rss_row = array(
                             'item_title' => strip_tags($title),
                             'item_desc'  => htmlentities($body),
-                            'item_link'  => $config->base_url.'?news='.$item,
+                            'item_link'  => $link,
                             'item_guid'  => $config->base_url.'?news='.$item,
                             'item_date'  => date("r", strtotime($date))
                         );




More information about the wine-cvs mailing list