Commit 496ded0b authored by spoinsar's avatar spoinsar
Browse files

rss: fix descr and add add featured selection mode


git-svn-id: http://subversion.utc/svn/webtv@199 6dbbdbe0-869d-41b9-a499-9a762c387331
parent 6d080b04
...@@ -823,6 +823,58 @@ ...@@ -823,6 +823,58 @@
return $data; return $data;
} }
function video_clean_description($vdetails) {
$preg = array(
'/(?<!\\\\)\[color(?::\w+)?=(.*?)\](.*?)\[\/color(?::\w+)?\]/si' => "\\2",
'/(?<!\\\\)\[size(?::\w+)?=(.*?)\](.*?)\[\/size(?::\w+)?\]/si' => "\\2",
'/(?<!\\\\)\[font(?::\w+)?=(.*?)\](.*?)\[\/font(?::\w+)?\]/si' => "\\2",
'/(?<!\\\\)\[align(?::\w+)?=(.*?)\](.*?)\[\/align(?::\w+)?\]/si' => "\\2",
'/(?<!\\\\)\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si' => "\\1",
'/(?<!\\\\)\[i(?::\w+)?\](.*?)\[\/i(?::\w+)?\]/si' => "\\1",
'/(?<!\\\\)\[u(?::\w+)?\](.*?)\[\/u(?::\w+)?\]/si' => "\\1",
'/(?<!\\\\)\[center(?::\w+)?\](.*?)\[\/center(?::\w+)?\]/si' => "\\1",
// [code] & [php]
'/(?<!\\\\)\[code(?::\w+)?\](.*?)\[\/code(?::\w+)?\]/si' => "\\1",
'/(?<!\\\\)\[php(?::\w+)?\](.*?)\[\/php(?::\w+)?\]/si' => "\\1",
// [email]
'/(?<!\\\\)\[email(?::\w+)?\](.*?)\[\/email(?::\w+)?\]/si' => "\\1",
'/(?<!\\\\)\[email(?::\w+)?=(.*?)\](.*?)\[\/email(?::\w+)?\]/si' => "\\2",
// [url]
'/(?<!\\\\)\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si' => "\\1",
'/(?<!\\\\)\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si' => "\\1",
'/(?<!\\\\)\[url(?::\w+)?=(.*?)?\](.*?)\[\/url(?::\w+)?\]/si' => "\\2",
// [img]
'/(?<!\\\\)\[img(?::\w+)?\](.*?)\[\/img(?::\w+)?\]/si' => "",
'/(?<!\\\\)\[img(?::\w+)?=(.*?)x(.*?)\](.*?)\[\/img(?::\w+)?\]/si' => "",
// [quote]
'/(?<!\\\\)\[quote(?::\w+)?\](.*?)\[\/quote(?::\w+)?\]/si' => "\\1",
'/(?<!\\\\)\[quote(?::\w+)?=(?:&quot;|"|\')?(.*?)["\']?(?:&quot;|"|\')?\](.*?)\[\/quote\]/si' => "\\2",
// [list]
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\*(?::\w+)?\](.*?)(?=(?:\s*<br\s*\/?>\s*)?\[\*|(?:\s*<br\s*\/?>\s*)?\[\/?list)/si' => "\\1\n<br>",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list(:(?!u|o)\w+)?\](?:<br\s*\/?>)?/si' => "\n<br>",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:u(:\w+)?\](?:<br\s*\/?>)?/si' => "\n<br>",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:o(:\w+)?\](?:<br\s*\/?>)?/si' => "\n<br>",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(:(?!u|o)\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:u(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:o(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=1\]\s*(?:<br\s*\/?>)?/si' => "\n",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=i\]\s*(?:<br\s*\/?>)?/s' => "\n",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=I\]\s*(?:<br\s*\/?>)?/s' => "\n",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=a\]\s*(?:<br\s*\/?>)?/s' => "\n",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=A\]\s*(?:<br\s*\/?>)?/s' => "\n",
// escaped tags like \[b], \[color], \[url], ...
'/\\\\(\[\/?\w+(?::\w+)*\])/' => "\\1",
'/(?<!\\\\)&lt;b(?::\w+)?&gt;(.*?)&lt;\/b(?::\w+)?&gt;/si' => "\\1",
// change quotes
'/&quot;/s' => "\"",
'/&#8217;/s' => "’",
'/\n/s' => "<br>"
);
$message = preg_replace(array_keys($preg), array_values($preg), $vdetails['description']);
return $message;
}
/** /**
* Function used to get video link * Function used to get video link
* @param ARRAY video details * @param ARRAY video details
......
...@@ -13,44 +13,67 @@ header ("Content-type: text/xml; charset=utf-8"); ...@@ -13,44 +13,67 @@ header ("Content-type: text/xml; charset=utf-8");
echo '<?xml version=\'1.0\' encoding=\'UTF-8\'?>'."\n"; echo '<?xml version=\'1.0\' encoding=\'UTF-8\'?>'."\n";
$limit = 20; $limit = 20;
/*
// page code is dead... add it back in query if needed
$page = $_GET['page']; $page = $_GET['page'];
if($page<1 || !is_numeric ) if($page<1 || !is_numeric($page))
$page = 1; $page = 1;
if($page) if($page)
{ {
$from = ($page-1)*$limit; $from = ($page-1)*$limit;
$limit = "$from,$limit"; $limit = "$from,$limit";
}*/
$cat = $_GET['cat'];
if($cat<1 && !is_numeric($cat)) {
$cat='all';
} }
$mode = $_GET['mode']; $mode = $_GET['mode'];
switch($mode) switch($mode)
{ {
case 'recent': case 'recent':
default: default:
{ {
$videos = get_videos(array('limit'=>$limit,'order'=>'date_added DESC')); $videos = get_videos(array('limit'=>$limit,'order'=>'date_added DESC', 'category'=>$cat));
$title = "Recently Added Videos"; $title = "Vidéos récentes";
}
break;
case 'featured':
{
$videos = get_videos(array('limit'=>$limit,'featured'=>'yes','order'=>'featured_date DESC', 'category'=>$cat));
$title = "Vidéos à la une";
}
break;
case 'homepage':
{
$videos = get_videos(array('limit'=>$limit,'featured'=>'yes', 'tags'=>'homepage','order'=>'featured_date DESC', 'category'=>$cat));
$title = "Vidéos en page d'Accueil";
} }
break; break;
case 'views': case 'views':
{ {
$videos = get_videos(array('limit'=>$limit,'order'=>'views DESC')); $videos = get_videos(array('limit'=>$limit,'order'=>'views DESC', 'category'=>$cat));
$title = "Most Viewed Videos"; $title = "Most Viewed Videos";
} }
break; break;
case 'rating': case 'rating':
{ {
$videos = get_videos(array('limit'=>$limit,'order'=>'rating DESC')); $videos = get_videos(array('limit'=>$limit,'order'=>'rating DESC', 'category'=>$cat));
$title = "Top Rated Videos"; $title = "Top Rated Videos";
} }
break; break;
case 'watching': case 'watching':
{ {
$videos = get_videos(array('limit'=>$limit,'order'=>'last_viewed DESC')); $videos = get_videos(array('limit'=>$limit,'order'=>'last_viewed DESC', 'category'=>$cat));
$title = "Videos Being Watched"; $title = "Videos Being Watched";
} }
break; break;
...@@ -60,7 +83,7 @@ switch($mode) ...@@ -60,7 +83,7 @@ switch($mode)
//Get userid from username //Get userid from username
$uid = $userquery->get_user_field_only($user,'userid'); $uid = $userquery->get_user_field_only($user,'userid');
$uid = $uid ? $uid : 'x'; $uid = $uid ? $uid : 'x';
$videos = get_videos(array('limit'=>$limit,'user'=>$uid,'order'=>'date_added DESC')); $videos = get_videos(array('limit'=>$limit,'user'=>$uid,'order'=>'date_added DESC', 'category'=>$cat));
//Count Total Videos of this user //Count Total Videos of this user
$total_vids = get_videos(array('count_only'=>true,'user'=>$uid)); $total_vids = get_videos(array('count_only'=>true,'user'=>$uid));
$title = "Videos uploaded by ".$user; $title = "Videos uploaded by ".$user;
...@@ -113,28 +136,24 @@ subtitle($title); ...@@ -113,28 +136,24 @@ subtitle($title);
<title><?=substr($video['title'],0,250)?></title> <title><?=substr($video['title'],0,250)?></title>
<link><?=video_link($video)?></link> <link><?=video_link($video)?></link>
<description> <description>
<![CDATA[ <![CDATA[
<table width="600" border="0" cellspacing="0" cellpadding="2"> <table width="600" border="0" cellspacing="0" cellpadding="2">
<tr> <tr>
<td width="130" height="90" align="center" valign="middle"><img src="<?=get_thumb($video)?>" border="0"/></td> <td width="130" height="90" align="center" valign="middle"><img src="<?=get_thumb($video)?>" border="0"/></td>
<td valign="top"> <td valign="top">
<a href="<?=video_link($video)?>"><?=$video['title']?></a><br /> <?=video_clean_description($video)?>
<?=$video['description']?>
</td> </td>
<td width="100" valign="top" align="right"> <td width="100" valign="top" align="right">
<?=$video['views']?> Vues<br /> <?=$video['views']?> Vues<br />
<?=SetTime($video['duration'])?> <?=SetTime($video['duration'])?>
</tr> </tr>
</table> </table>
]]> ]]></description>
</description>
<category><?=strip_tags(categories($video['category'],'video'))?></category> <category><?=strip_tags(categories($video['category'],'video'))?></category>
<guid isPermaLink="true"><?=video_link($video)?></guid> <guid isPermaLink="true"><?=video_link($video)?></guid>
<pubDate><?=date_format(date_create($video['date_added']),DateTime::RSS)?></pubDate> <pubDate><?=date_format(date_create($video['date_added']),DateTime::RSS)?></pubDate>
<media:player url="<?=video_link($video)?>" /> <media:player url="<?=video_link($video)?>" />
<media:thumbnail url="<?=get_thumb($video)?>" /> <media:thumbnail url="<?=get_thumb($video, 'med')?>" />
<media:title><?=substr($video['title'],0,250)?></media:title> <media:title><?=substr($video['title'],0,250)?></media:title>
<media:category label="Tags"><?=strip_tags(tags($video['tags'],'video'))?></media:category> <media:category label="Tags"><?=strip_tags(tags($video['tags'],'video'))?></media:category>
<media:credit><?=$video['username']?></media:credit> <media:credit><?=$video['username']?></media:credit>
...@@ -142,6 +161,6 @@ subtitle($title); ...@@ -142,6 +161,6 @@ subtitle($title);
<?php <?php
} }
?> ?>
<!-- si vous développez des outils qui exploitent ce flux et que vous avez des demandes pour modifier les infos qu'il contient, laissez un mail à stephane.poinsart@utc.fr -->
</channel> </channel>
</rss> </rss>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment