<?cs include:"util.cs" ?>
	
<?cs ### produces the img tag used to mark unread messages ## ?>
<?cs def:red_star_img(topic_star) ?><img src="<?cs var:image_path ?>redstar.gif" <?cs if:!topic_star ?>alt="<?cs var:lang.news_topic.redstar_title ?>" title="<?cs var:lang.news_topic.redstar_title ?>"<?cs else ?>alt="<?cs var:lang.news_topic.redstar_topic_title ?>" title="<?cs var:lang.news_topic.redstar_topic_title ?>"<?cs /if ?> /><?cs /def ?>

<?cs ### produces a blank gif image the same dimensions as a 'red star' ### ?>
<?cs def:blank_star_img() ?><img src="<?cs var:image_path ?>spacer.gif" width="10" height="12" alt="" /><?cs /def ?>



<?cs ### selects, from the .lang file, one of three strings 
         that will be an 'alt' tag for the new item button 
## ?>
<?cs def:new_item_title() ?><?cs if:new_topic_url ?><?cs if:!no_topic_type  && (grp != #6) ?><?cs var:lang.news_topic.new_topic_title ?><?cs else ?><?cs var:lang.news_topic.new_item_title ?><?cs /if ?><?cs else ?><?cs var:lang.news_topic.command_disabled ?><?cs /if ?><?cs /def ?>





<?cs ###
     ### For the Assignments module (grp == 6) and any module that doesn't 
     ### support topics, e.g Handouts/Notices,
     ### Lectures etc, show a button that reads "New Item",
     ### else show the "New Topic" button
?>

<?cs def:new_item_img() ?><?cs if:!no_topic_type  && (grp != #6) ?><img src="<?cs var:image_path ?>new_topic.gif" width="50" height="34" alt="<?cs call:new_item_title() ?>" title="<?cs call:new_item_title() ?>" /><?cs else ?><img src="<?cs var:image_path ?>new_item.gif" width="50" height="34" alt="<?cs call:new_item_title() ?>" title="<?cs call:new_item_title() ?>" /><?cs /if ?><?cs /def ?>


<?cs def:insert_exit_button() ?><a href="<?cs var:exit_classroom_url ?>" title="<?cs var:lang.exit_classroom_title ?>"><img src="<?cs var:image_path ?>square_exit.gif" width="50" height="34" alt="<?cs var:lang.main_menu_title ?>"  /></a><?cs /def ?>

<?cs ### prints a button linked to the main menu for the classroom ### ?>
<?cs def:print_go_back_button() ?><?cs with:lang=lang.news_topic ?><?cs if:only_handouts_enabled ?><?cs call:insert_exit_button() ?><?cs elif:is_fac_teamteach ?><a href="news_team_list?crs=<?cs var:crs ?>&amp;id=<?cs var:key?>" title="<?cs var:lang.news_team_list_title ?>"><img src="<?cs var:image_path ?>back_arrow.gif" width="50" height="34" alt="<?cs var:lang.news_team_list_title ?>"  /></a><?cs else ?><a href="<?cs var:main_menu_url ?>" title="<?cs var:lang.main_menu_title ?>"><img src="<?cs var:image_path ?>main.gif" width="50" height="34" alt="<?cs var:lang.main_menu_title ?>"  /></a><?cs /if ?><?cs /with ?><?cs /def ?>


<?cs ### prints a (non-linked) graphic that shows the name of this module ### ?>
<?cs def:print_module_name() ?><?cs with:lng=lang.news_topic.module ?><img src="<?cs var:image_path ?><?cs var:grp ?>_label.gif" alt="<?cs var:lng[grp].description ?>" title="<?cs var:lng[grp].description ?>" /><?cs /with ?><?cs /def ?>





<?cs ### prints a (hyperlinked) button used to add a new item or topic to this module (if one should be printed) ## ?>
<?cs def:print_new_item_button() ?><?cs if:is_faculty || new_topic_url ?><?cs if:new_topic_url ?><a href="<?cs var:new_topic_url ?>" title="<?cs call:new_item_title() ?>"><?cs /if ?><?cs call:new_item_img() ?><?cs if:new_topic_url ?></a><?cs /if ?><?cs /if ?><?cs /def ?>

<?cs ### prints a button linked to the url that shows the user how to subscribe to a podcast  ## ?>
<?cs def:print_podcast_subscribe_button() ?>
<?cs if:podcast_subscribe_url ?>
<span style="float:right;"><form action="">
<div>
<input name="newwin" type="button" value="<?cs var:lang.news_topic.podcast_subscribe_button ?>"
   title="<?cs var:lang.news_topic.podcast_subscribe_button_title ?>"
   onclick="window.open('<?cs var:podcast_subscribe_url ?>','newwin','resizable=yes,width=600,height=250,top=50,left=50,scrollbars=yes,toolbar=yes,menubar=yes'); newwin.focus()" />
 </div>
</form></span>
<?cs /if ?>
<?cs /def ?>



<?cs ### prints a button to launch the wimpy media player ?>
<?cs def:print_wimpy_link() ?>
<?cs if:launch_wimpy_url ?>
<span style="float:right;"><form action="">
<div>
<input name="newwin" type="button" value="<?cs var:lang.news_topic.listen_now_button ?>"
   title="<?cs var:lang.news_topic.listen_now_button_button_title ?>"
   onclick="window.open('<?cs var:launch_wimpy_url ?>','newwin','resizable=yes,width=550,height=330,top=50,left=50,scrollbars=yes,toolbar=no'); newwin.focus()" />
 </div>
</form></span>
<?cs /if ?>
<?cs /def ?>

<?cs def:print_framaplayer_link() ?>
<span style="float:right;"><form action="">
<div>
<input name="newwin" type="button" value="<?cs var:lang.news_topic.listen_now_button ?>"
   title="<?cs var:lang.news_topic.listen_now_button_button_title ?>"
   onclick="window.open('<?cs var:launch_frama_url ?>','newwin','resizable=yes,width=550,height=330,top=50,left=50,scrollbars=yes,toolbar=no'); newwin.focus()" />
 </div>
</form></span>
<?cs /def ?>





<?cs ### prints , for e.g. [Msg# 43]  ## ?>
<?cs def:msg_number(msg_id)?>
 <?cs if:!no_topic_type && !is_fac_assignments ?>
      [<?cs var:lang.news_topic.msg_number_label?> <?cs var:msg_id ?>]
 <?cs /if ?>
<?cs /def ?>





<?cs def:flag_image(is_flagged, topic_flag) ?><img src="<?cs var:image_path ?><?cs if:is_flagged ?>flag.gif" <?cs if:topic_flag ?>alt="<?cs var:lang.news_topic.flag_topic_title ?>" title="<?cs var:lang.news_topic.flag_topic_title ?>"<?cs else ?> alt="<?cs var:lang.news_topic.flag_title ?>"<?cs /if ?> width="14" height="14"  /><?cs else ?>noflag.gif" alt="<?cs var:lang.news_topic.noflag_title ?>" width="14" height="15" /><?cs /if ?><?cs /def ?>





<?cs ### produces a blank gif image the same dimensions as a flag' ### ?>
<?cs def:blank_flag_img() ?><img src="<?cs var:image_path ?>spacer.gif" width="14" height="15" alt="" /><?cs /def ?>






<?cs def:print_flag(item) ?><a href="<?cs var:item.flag_url ?>" title="<?cs var:lang.news_topic.flag_link_title ?>" ><?cs call:flag_image(item.is_flagged,#0) ?></a><?cs /def ?>



<?cs def:print_one_topic(item) ?>
 <a name="<?cs var:item.msg_id?>"></a>
 <div class=<?cs if:item.teacher_hidden ?>"hidden_topic_listing"<?cs elif:item.read_only?>"readonly_topic_listing"<?cs else ?>"topic_listing"<?cs /if ?>>

<?cs ### print + or - to expand/collapse topic #### ?>

  <?cs if:item.expand_url && !capture_mode && !is_fac_assignments ?>
    <?cs if:item.is_expanded ?>
            <?cs set:title=lang.news_topic.collapse_topic_title ?>
            <?cs set:image="minus.gif" ?>
    <?cs else ?>
           <?cs set:title=lang.news_topic.expand_topic_title ?>
           <?cs set:image="plus.gif" ?>
    <?cs /if ?>

    <a href="<?cs var:item.expand_url ?>"  title="<?cs var:title ?>"><img src="<?cs var:image_path ?><?cs var:image ?>" alt="<?cs var:title ?>" width="10" height="10" /></a>
  
  <?cs else ?>
     <img src="<?cs var:image_path ?>spacer.gif" alt="" width="10" height="10" />
  <?cs /if ?>

<?cs ### print total msgs in topic and a red star if there's at least one unread msg in the topic,
         and a flag if there's at least one flagged msg in the topic
  ## ?> 
  <?cs if:!no_topic_type ?>(<?cs if:item.total_msgs < #10 ?>&nbsp;&nbsp;<?cs /if ?><?cs if:item.gather_url ?><a href="<?cs var:item.gather_url ?>" title="<?cs var:lang.news_topic.gather_topic_title ?>"><?cs /if ?><?cs var:item.total_msgs ?><?cs if:item.gather_url ?></a><?cs /if ?><?cs if:item.total_unread ?><?cs call:red_star_img(1) ?><?cs /if ?><?cs if:item.total_flagged ?><?cs call:flag_image(#1, #1) ?><?cs /if ?>)<?cs if:!item.total_unread ?><?cs call:blank_star_img() ?><?cs /if ?><?cs if:!item.total_flagged ?><?cs call:blank_flag_img() ?><?cs /if ?><?cs /if ?>


<?cs ### handle sleepy/normal/wired images with associated links ### ?>
  <?cs if:allow_user_hidden ?>
    <?cs if:item.hide_url ?>
     <a href="<?cs var:item.hide_url ?>" title="<?cs var:lang.news_topic.mark_sleepy_title ?>"><img src="<?cs var:image_path ?>topic_normal.gif" alt="<?cs var:lang.news_topic.mark_sleepy_title ?>" width="15" height="15" /></a>
    <?cs elif:item.unhide_url ?>
          <a href="<?cs var:item.unhide_url ?>" title="<?cs var:lang.news_topic.mark_normal_title ?>"><img src="<?cs var:image_path ?>topic_tired.gif" alt="<?cs var:lang.news_topic.mark_normal_title ?>" width="15" height="15" /></a>
    <?cs else ?>
      <img src="<?cs var:image_path ?>topic_wired.gif" alt="<?cs var:lang.news_topic.wired_topic_title ?>" title="<?cs var:lang.news_topic.wired_topic_title ?>"  width="15" height="15" />          
    <?cs /if ?>
  <?cs /if ?>

<?cs ## handle the flag and  show a '?' linked to the news_info program, and paperclip, and red star ### ?>
  <?cs call:print_flag(item) ?><a href="<?cs var:item.info_url ?>" title="<?cs var:lang.news_topic.info_title ?>">?</a><?cs if:item.attachments ?><img src="<?cs var:image_path ?>pclip.gif" width="13" height="15" alt="<?cs var:lang.news_topic.pclip_title ?>" title="<?cs var:lang.news_topic.pclip_title ?>" /><?cs /if ?><?cs if:item.is_unread ?><?cs call:red_star_img(0) ?><?cs /if ?>

  


  <a href="<?cs var:item.read_msg_url ?>" title="<?cs var:lang.news_topic.read_msg_title ?>"><?cs var:item.subject ?></a>
  <?cs var:item.sender ?> 
  <?cs var:item.time_sent ?> 
  <span class="small">
  <?cs call:msg_number(item.msg_id) ?>
  <?cs if:item.teacher_hidden ?>
          <?cs var:lang.news_topic.teacher_hidden ?>
  <?cs elif:item.read_only ?>
          <?cs var:lang.news_topic.read_only ?>
  <?cs /if ?>
  </span>
 </div>

<?cs each:message=item.msg ?>
<a name="<?cs var:message.msg_id ?>"></a>
 <?cs set:indent_level = message.indent * #2 ?>
 <div style="text-indent:<?cs var:indent_level ?>em">
 <?cs if:item.teacher_hidden ?><span class="hidden_message_listing"><?cs elif:item.read_only ?><span class="readonly_message_listing"><?cs /if ?>
 <?cs call:print_flag(message) ?> <a href="<?cs var:message.info_url ?>" title="<?cs var:lang.news_topic.info_title ?>">?</a><?cs if:message.attachments ?><img src="<?cs var:image_path ?>pclip.gif" alt="<?cs var:lang.news_topic.pclip_title ?>" title="<?cs var:lang.news_topic.pclip_title ?>" /><?cs else ?><img src="<?cs var:image_path ?>spacer.gif" width="13" height="15" alt=""/><?cs /if ?><?cs if:message.is_unread ?><?cs call:red_star_img(0) ?><?cs else ?><?cs call:blank_star_img() ?><?cs /if ?>
 <?cs if:item.teacher_hidden ?><i><?cs /if ?>
 <a href="<?cs var:message.read_msg_url ?>"><?cs var:message.subject ?></a> 
  <?cs var:message.sender ?> 
  <?cs var:message.time_sent ?> 
  <span class="small">[<?cs var:lang.news_topic.msg?> <?cs var:message.msg_id ?>, <?cs var:lang.news_topic.re ?><?cs var:message.re_msg_id ?>]
 <?cs if:item.teacher_hidden ?>
          <?cs var:lang.news_topic.teacher_hidden ?>
  <?cs elif:item.read_only ?>
          <?cs var:lang.news_topic.read_only ?>
  <?cs /if ?>
 </span>
 <?cs if:item.teacher_hidden ?></i><?cs /if ?>
 <?cs if:item.teacher_hidden || item.read_only?></span><?cs /if ?>
 </div>
<?cs /each ?>
<?cs /def ?>



<?cs def:locked_classroom_msg() ?>
<div>
 <fieldset style="width:25%">
 <?cs var:lang.news_topic.classroom_locked ?>
 </fieldset>
</div>
<?cs /def ?>



<?cs ####
     HTML STARTS HERE
     ####
?>
<?cs call:html_heading() ?>
<head>
<title><?cs var:course_no ?> <?cs var:lang.news_topic.module[grp].name ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="StyleSheet" href="<?cs var:image_path ?>common.css" type="text/css"  />
<link rel="StyleSheet" href="<?cs var:image_path ?>topic_listing.css" type="text/css"  />
</head>

<?cs call:define_body() ?>
<?cs if:only_handouts_enabled && (classroom_locked || config_url) ?>
<table width="100%">
<tr>
<?cs if:classroom_locked ?><td align="left"><?cs call:locked_classroom_msg() ?></td><?cs /if ?>
<?cs if:config_url ?><td align="right"><div style="text-align:right"><a href="<?cs var:config_url ?>" title="<?cs var:lang.news_topic.configuration ?>"><img src="<?cs var:image_path ?>config.gif" alt="<?cs var:lang.news_topic.configuration ?>" width="202" height="27"></a></div></td><?cs /if ?>
</tr>
</table>
<?cs /if ?>

<?cs if:podcast_subscribe_url ?>
  <?cs call:print_podcast_subscribe_button() ?>
  <?cs  if:launch_wimpy_url ?>
     <?cs  call:print_wimpy_link() ?>
  <?cs  elif:launch_frama_url ?>
     <?cs call:print_framaplayer_link() ?>
  <?cs /if ?>
<?cs /if ?>

<?cs ## start table to center entire page  ?>
<table width="100%">
<tr><td align="center">

<?cs ## start gather form ## ?>
<?cs if:!capture_mode ?><form  method="post" action="<?cs var:gather_form_action ?>"><?cs /if ?>



<?cs ## print main menu button, module label, new item (topic) button ## ?>
<div><?cs call:print_go_back_button() ?><?cs call:print_module_name() ?><?cs call:print_new_item_button() ?>
</div>

<?cs if:!capture_mode ?>

<?cs ### print 'Manage Topics" links and related links for teacher-eyes only ### ?>
<?cs if:is_faculty ?>
 <div class="manage_topic_text">
  <?cs if:manage_topics_url ?><a href="<?cs var:manage_topics_url ?>"  class="manage_topic" title="<?cs var:lang.news_topic.manage_topics_title ?>"><?cs var:lang.news_topic.manage_topics ?></a>,<?cs /if ?>
  <?cs if:teacher_list_only_visible_url ?>
     <?cs var:lang.news_topic.list_all_topics ?> / 
       <a href="<?cs var:teacher_list_only_visible_url ?>"  class="manage_topic" title="<?cs var:lang.news_topic.list_only_visible_title ?>"><?cs var:lang.news_topic.list_only_visible ?></a>
  <?cs elif:teacher_list_all_topics_url ?>
     <a href="<?cs var:teacher_list_all_topics_url ?>" class="manage_topic" title="<?cs var:lang.news_topic.list_all_topics_title ?>" ><?cs var:lang.news_topic.list_all_topics ?></a> /
         <?cs var:lang.news_topic.list_only_visible ?>
  <?cs /if ?>
 </div>
<?cs /if ?>




<?cs ## if a link to page listing team members was provided, show the link ## ?>
<?cs if:team_members_url ?>
   <?cs var:lang.news_topic.your_team_label ?> <?cs var:team_name ?>.  <i><?cs var:lang.news_topic.team_members_link_label ?> <a href="<?cs var:team_members_url ?>" title="<?cs var:lang.news_topic.team_members_link_title ?>"><?cs var:lang.news_topic.team_members_link ?></a>
<?cs /if ?>
 
<div>
<?cs ### handle gather form ### ?>
<input type="hidden" name="crs" value="<?cs var:crs ?>" />
<input type="hidden" name="id" value="<?cs var:key ?>" />
<input type="hidden" name="grp" value="<?cs var:grp ?>" />
<?cs if:grp == 7 ?>
<input type="hidden" name="team" value="<?cs var:team ?>" />
<?cs /if ?>
<input type="hidden" name="fixed" value="<?cs var:fixed_font ?>" />
<input type="submit" value="<?cs var:lang.news_topic.gather_button?>" title="<?cs var:lang.news_topic.gather_button_title ?>" />
<select name="gather" title="<?cs var:lang.news_topic.gather_select_title ?>">
<option value="_unread_" selected="selected" >&lt;<?cs var:lang.news_topic.gather_unread ?>&gt;</option>
<option value="_flagged_" >&lt;<?cs var:lang.news_topic.gather_flagged ?>&gt;</option>
<option value="_all_">&lt;<?cs var:lang.news_topic.gather_all ?>&gt;</option>
<?cs each:this=gather ?>
   <option value="<?cs var:this.value ?>"><?cs var:this.name ?></option>
<?cs /each ?>
</select>


<?cs ### print 'Reverse Order' button ### ?>
<a href="<?cs var:sort_order_url ?>" title="<?cs var:lang.news_topic.sort_title ?>"><img src="<?cs var:image_path ?>newest_sm.gif" alt="<?cs var:lang.news_topic.sort_title ?>"  width="135" height="17" /></a> 

<?cs ## print "+ all" and "- all" buttons ### ?>
<?cs if:expand_all_url ?><a href="<?cs var:expand_all_url ?>" title="<?cs var:lang.news_topic.expand_all ?>"><img src="<?cs var:image_path ?>expand_all_sm.gif" alt="<?cs var:lang.news_topic.expand_all ?>" width="53" height="17" /></a><?cs /if ?>
<?cs if:collapse_all_url ?><a href="<?cs var:collapse_all_url ?>" title="<?cs var:lang.news_topic.collapse_all ?>"><img src="<?cs var:image_path ?>collapse_all_sm.gif" alt="<?cs var:lang.news_topic.collapse_all ?>" width="53" height="17" /></a><?cs /if ?>
</div>

<?cs ## show hide/unhide sleepy topics links ## ?>
<?cs if:allow_user_hidden ?>
  <div>
  <?cs if:list_all_url ?>
      <?cs if:sleepy_count ?>
         <span class="hide_unhide_warning"><?cs var:sleepy_count ?> <?cs var:lang.news_topic.topics_not_listed ?></span>
      <?cs else ?>
          <span class="hide_unhide_text"><?cs var:lang.news_topic.no_sleepy_topics ?></span>
      <?cs /if ?>
      <a href="<?cs var:list_all_url ?>" class="hide_unhide" title="<?cs var:lang.news_topic.list_all_topics_link_title ?>"><?cs var:lang.news_topic.list_all_topics_link ?></a>
  <?cs else ?>
     <span class="hide_unhide_text"><?cs var:lang.news_topic.listing_all_topics ?></span> <a href="<?cs var:hide_sleepy_url ?>" class="hide_unhide" title="<?cs var:lang.news_topic.hide_sleepy_topics_link_title ?>" ><?cs var:lang.news_topic.hide_sleepy_topics_link ?></a>  
  <?cs /if ?>
  </div>
<?cs /if ?>

</form>
<?cs /if ?>    <?cs #####   if !capture_mode ?>


<table>
 <tr>
<td align="left">
<?cs each:item=topic ?>
  <?cs call:print_one_topic(item)?>
<?cs /each ?>
</td>
</tr>
</table>



<?cs ##end table used to center entire page  ?>
</td></tr></table>
</body>
</html>

<?cs call:runtime() ?> 
