<?php
include_once 'class/class.linker.php';

    class Toolbar {
        var $forum = 0;
		var $forum_name = '';
        var $topic_id = 0;
        var $topic_name = '';
         
        function ToolBar($forum, $forum_name, $topic_id = 0, $topic_name = '')
        {
            $this->forum = $forum;
			$this->forum_name = $forum_name;
            $this->topic_id = $topic_id;
            $this->topic_name = $topic_name;
        }
         
        function display()
        {
            global $bbPath, $HTTP_GET_VARS;
            include 'class/hover.css';
            if (intval($this->topic_id) == 0)
            {
?>
<table border="0" cellpadding="0" cellspacing="0" align="center" valign="top" width="100%"><tr><td class="bg2">
<table border="0" cellpadding="4" cellspacing="1" width="100%">
<tr class="bg4">
<td class="bg4" width="100%">
<b><?php echo $this->forum_name; ?></b>
</td>
<td class="bg4" align="right">
<?php echo $this->forum_tools_menu(); ?>
</td>
</tr></table>
</td></tr></table>
<?php
            }
			else
			{
?>
<table border="0" cellpadding="0" cellspacing="0" align="center" valign="top" width="100%"><tr><td class="bg2">
<table border="0" cellpadding="4" cellspacing="1" width="100%">
<tr class="bg4">
<td class="bg4" width="100%">
<b><?php echo $this->topic_name; ?></b>
</td>
<td class="bg4" width="100%">
<?php echo $this->topic_tools_menu(); ?>
</td>
<td class="bg4" width="100%">
<?php echo $this->display_modes_menu(); ?>
</td>
</tr></table>
</td></tr></table>
<?php
			}
        }

		function forum_tools_menu()
		{
			global $bbPath;
			$ftools  = '<div align=center>';
			$ftools .= '<ul class="level1">';	
			$ftools .= '	<li class="folder">';
			$ftools .= '	<div class="submenu"><b>'._MD_FORUM_TOOLS.'</b></div>';
			$ftools .= '	<ul class="level2">';
			$ftools .= '		<li class="bg3"><a href="newtopic.php?forum='.$this->forum.'" class="link"><img src="'.$bbPath['images'].'new.gif">&nbsp;'._MD_NEW_TOPIC.'</a></li>';
			$ftools .= '		<li class="bg3"><a href="viewforum.php?forum='.$this->forum.'&mark=topics" class="link"><img src="'.$bbPath['images'].'read.gif">&nbsp;'._MD_MARK_READ.'</a></li>';
//			$ftools .= '		<li class="bg3"><a href="#" class="link"><img src="'.$bbPath['images'].'topic_notifyon.gif">&nbsp;'._MD_SUBSCRIBE'</a></li>';
			$ftools .= '	</ul>';
			$ftools .= '	</li>';
			$ftools .= '</ul>';
			$ftools .= '</div>';
			return $ftools;
		}

		function topic_tools_menu()
		{
			global $bbPath, $topicnotif, $xoopsUser;
			
			$ttools  = '<div align=center>';
			$ttools .= '<ul class="level1">';
			$ttools .= '	<li class="folder">';
			$ttools .= '	<div class="submenu"><b>'._MD_TOPIC_TOOLS.'</b></div>';
			$ttools .= '	<ul class="level2">';
			$ttools .= '		<li class="bg3"><a  class="link" href="print.php?forum='.$this->forum.'&topic_id='.$this->topic_id.'"><img src="'.$bbPath['images'].'print.gif">&nbsp;'._MD_PRINT_TOPIC.'</a></li>';
			$ttools .= '		<li class="bg3"><a  class="link" href="'.Linker::mailto_topic_href($this->topic_id, $this->forum).'"><img src="'.$bbPath['images'].'email.gif">&nbsp;'._MD_EMAIL_TOPIC.'</a></li>';
			if ( $xoopsUser )
			{
				if ( $topicnotif ['email_notify'] == 1 )
				{
					$ttools .= '		<li class="bg3"><a  class="link" href="viewtopic.php?topic_id='.$this->topic_id.'&flag_mail=2&forum='.$this->forum.'"><img src="'.$bbPath['images'].'topic_notifyoff.gif">&nbsp;'._MD_UNSUBSCRIBE.'</a></li>';
				}
				else
				{
					$ttools .= '		<li class="bg3"><a  class="link" href="viewtopic.php?topic_id='.$this->topic_id.'&flag_mail=1&forum='.$this->forum.'"><img src="'.$bbPath['images'].'topic_notifyon.gif">&nbsp;'._MD_SUBSCRIBE.'</a></li>';
				} 
			}
			$ttools .= '	</ul>';
			$ttools .= '	</li>';
			$ttools .= '</ul>';
			$ttools .= '</div>';

			return $ttools;
		}

		function display_modes_menu()
		{
			global $bbPath, $HTTP_GET_VARS;
			
			$vars = '';
			foreach($HTTP_GET_VARS as $var=>$val)
			{
				if($var != 'viewmode')
					$vars .= $var.'='.$val.'&';
			}
			
			$modes  = '<div align=center>';
			$modes .= '<ul class="level1">';	
			$modes .= '	<li class="folder">';
			$modes .= '	<div class="submenu"><b>'._MD_DISPLAY_MODES.'</b></div>';
			$modes .= '	<ul class="level2">';
			$modes .= '		<li class="bg3" align=left><a class="link" href="viewtopic.php?'.$vars.'viewmode=flat"><img src="'.$bbPath['images'].'mode_flat.gif">&nbsp;'._MD_FLAT.'</a></li>';
			$modes .= '		<li class="bg3" align=left><a class="link" href="viewtopic.php?'.$vars.'viewmode=thread"><img src="'.$bbPath['images'].'mode_threaded.gif">&nbsp;'._MD_THREADED.'</a></li>';
			$modes .= '	</ul>';
			$modes .= '	</li>';
			$modes .= '</ul>';
			$modes .= '</div>';

			return $modes;
		}
    }
?>
