<?php

/**
* $Id: admin.badwords2.html.php,v 1.16 2005/09/05 15:35:47 walb Exp $
*
* Badwords2 Text Filtering Component!
* @ Copyright (C) 2005 - 2006 Wim Albers, Niels Vandekeybus, Robert Anthony Pitera
* @ Based on the initial work Badword by Pravin Hegde
* @ All rights reserved
* @ Badwords2 Text Filter component is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
*
**/

# ensure this file is being included by a parent file
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

class HTML_badword {

	function showBadwordData( &$badword_data, $task) {

		if ($task == 'admins') {
			$header = _BW2_ADMIN_USER_HDR;
			$col_title = _BW2_ADMIN_USER;
			$edit_link = 'edit_admin';
		} else if ($task == 'regexps') {
			$header = _BW2_ADMIN_REGEX_HDR;
			$col_title = _BW2_ADMIN_REGEX;
			$edit_link = 'edit_regexp';
		} else {
			$header = _BW2_ADMIN_BWLIST_HDR;
			$col_title = _BW2_ADMIN_BW;
			$edit_link = 'edit_badword';
		}
?>
	<form action="index2.php" method="POST" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
	    <td width="80%" valign="bottom"><span class="sectionname"><img border="0" src="components/com_badwords2/images/BW2logoMED.png" width="185" height="88" align="left"/><?php echo _BW2_ADMIN_MANAGE_HDR . ' ' .$header; ?></span></td>
		</tr>
	</table>
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
		<tr>
			<th width="20" align="center">#</th>
			<th width="10" align="center"><input type="checkbox" name="toggle" value="" onClick="checkAll(<?php echo count( $badword_data ); ?>);" /></th>
			<th align="left" nowrap><?php echo $col_title; ?></th>
		</tr>
<?php
		$k = 0;
		for ($i=0, $n=count( $badword_data ); $i < $n; $i++) {
			$row = &$badword_data[$i];
			$selValue = $i;
?>
		<tr class="<?php echo "row$k"; ?>">
			<td width="20" align="center"><?php echo $i+1;?></td>
			<td width="10" align="center">
				<input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $selValue; ?>" onClick="isChecked(this.checked);" />
			</td>
			<td width="80%" align="left"><a href="#edit" onclick="return listItemTask('cb<?php echo $i; ?>','<?php echo $edit_link; ?>')">
			<?php echo $badword_data[$i]; ?></a></td>
			<?php		$k = 1 - $k; ?>
		</tr>
<?php	}
?>
	</table>

	<input type="hidden" name="option" value="com_badwords2">
	<input type="hidden" name="act" value="<?php echo $task; ?>">
	<input type="hidden" name="task" value="">
	<input type="hidden" name="boxchecked" value="0">
	</form>
<?php
	}

	function editBwRow( &$row, $option , $id, $task) {
		global $mosConfig_live_site;
		if ($task == 'edit_admin' || $task == 'new_admin') {
			$header = _BW2_ADMIN_USER;
			$save_task = 'save_admin';
			$save_alert = _BW2_ADMIN_PROV_USER;
		} else if ($task == 'edit_regexp' || $task == 'new_regexp') {
			$header = _BW2_ADMIN_REGEX;
			$save_task = 'save_regexp';
			$save_alert = _BW2_ADMIN_PROV_REGEX;
		} else {
			$header = _BW2_ADMIN_BW;
			$save_task = 'save_badword';
			$save_alert = _BW2_ADMIN_PROV_WORD;
		}

?>
	<link rel="stylesheet" type="text/css" media="all" href="<?php echo $mosConfig_live_site; ?>/includes/js/calendar/calendar-mos.css" title="green" />
	<!-- import the calendar script -->
	<script type="text/javascript" src="<?php echo $mosConfig_live_site; ?>/includes/js/calendar/calendar.js"></script>
	<!-- import the language module -->
	<script type="text/javascript" src="<?php echo $mosConfig_live_site; ?>/includes/js/calendar/lang/calendar-en.js"></script>
	<div id="overDiv" style="position:absolute; visibility:hidden; z-index:10000;"></div>
	<script language="Javascript" src="<?php echo $mosConfig_live_site; ?>/includes/js/overlib_mini.js"></script>
	<script language="javascript" src="<?php echo $mosConfig_live_site; ?>/includes/js/dhtml.js"></script>
	<script language="javascript">
	<!--
		function submitbutton(pressbutton) {
			var form = document.adminForm;
			if (pressbutton == 'cancel') {
				submitform( pressbutton );
				return;
			}
			// do field validation
			if ( form.word.value == '' && pressbutton == <?php echo"'" . $save_task . "'";?> ){
				alert( <?php echo "'" . $save_alert . "'";?> );
			} else {
				submitform( pressbutton );
			}
		}
	//-->
	</script>
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td width="100%"><span class="sectionname"><?php echo ($id >= 0) ? _BW2_ADMIN_PROV_EDIT : _BW2_ADMIN_PROV_ADD;?> <?php echo $header; ?> </span></td>
		</tr>
	</table>
	<form action="index2.php" method="POST" name="adminForm">
	<table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform">
		<tr>
			<td valign="top"><br /><?php echo $header; ?>:</td>
			<td align="left" valign="top"><br /><input class="inputbox" type="text" name="word" size="20" maxlength="50" value="<?php echo $row; ?>"></td>
			<?php
			if ($task == 'edit_badword' || $task == 'new_badword') {
                           echo "<td valign=\"top\">" . _BW2_ADMIN_EDIT_BW_HELP . "</td>";
                        } elseif ($task == 'edit_regexp' || $task == 'new_regexp') {
                           echo "<td valign=\"top\">" . _BW2_ADMIN_EDIT_REGEX_HELP . "</td>";
                        } else {
                           echo "<td valign=\"top\">" . _BW2_ADMIN_EDIT_USER_HELP . "</td>";
                        }
                        ?>
		</tr>
	</table>

	<input type="hidden" name="option" value="<?php echo $option; ?>">
	<input type="hidden" name="id" value="<?php echo $id; ?>">
	<input type="hidden" name="task" value="<?php echo $save_task; ?>">
	</form>
<?php
	}

	function showAbout( $option, $readme_lines ) {
		global $bw_version;
		?>
<br />
		<?php 
include ("aboutBW2.html"); 
?> 
		<?php
	}

	function showSettings( $row, $lists, $option ) {
	?>
<table cellpadding="4" cellspacing="0" border="0" width="100%">
  <tr>
    <td width="100%" class="sectionname" valign="bottom"><img border="0" src="components/com_badwords2/images/BW2logoMED.png" width="185" height="88" align="left"/><?php echo _BW2_ADMIN_COMP_SETTINGS;?><span class="componentheading"><br><?php echo _BW2_ADMIN_COMP_SETTINGS_CONF_FILE_IS;?>
      <?php echo is_writable( 'components/com_badwords2/settings.badwords2.php' ) ? '<b><font color="green">' . _BW2_ADMIN_COMP_SETTINGS_WRITEABLE . '</font></b>' : '<b><font color="red">' . _BW2_ADMIN_COMP_SETTINGS_UNWRITEABLE . '</font></b>' ?>
</span></td>
  </tr>
</table>
<script language="javascript" src="js/dhtml.js"></script>
<script language="javascript" type="text/javascript">

	function submitbutton(pressbutton) {
		var form = document.adminForm;
			if (pressbutton == 'saveSettings') {
					submitform( pressbutton );
			} else {
				document.location.href = 'index2.php';
			}
	}
</script>
<form action="index2.php" method="POST" name="adminForm">
	<table cellpadding="2" cellspacing="4" border="0" width="100%" class="adminform">
		<tr>
			<td align="left" width="185"><?php echo _BW2_ADMIN_PERF_FILTER;?></td>
			<td align="left"> <?php echo $lists['perform_filter']; ?> </td>
			<td align="left" class="error">
			<?php echo _BW2_ADMIN_YES_FILTER . "<br />" . _BW2_ADMIN_NO_FILTER; ?>
			</td>
		</tr>

		<tr>
			<td align="left" width="185"><?php echo _BW2_ADMIN_APPLY_REGEX;?></td>
			<td align="left"> <?php echo $lists['perform_regexp']; ?> </td>
			<td align="left" class="error">
                        <?php echo _BW2_ADMIN_YES_REGEX . "<br />" . _BW2_ADMIN_NO_REGEX; ?>
			</td>
		</tr>

		<tr>
			<td align="left" width="185"><?php echo _BW2_ADMIN_ALLOW_USER_BW;?></td>
			<td align="left"> <?php echo $lists['allow_admin']; ?> </td>
			<td align="left" class="error">
                        <?php echo _BW2_ADMIN_YES_USER_BW . "<br />" . _BW2_ADMIN_NO_USER_BW; ?>
			</td>
		</tr>

	</table>
  <input type="hidden" name="option" value="<?php echo $option; ?>">
  <input type="hidden" name="task" value="">
</form>
	<?php
	}
}


?>
