<?php
// $Id: admin.templates.html.php,v 1.18 2003/12/09 02:41:55 eddieajau Exp $
/**
* Template admin HTML
* @package Mambo Open Source
* @Copyright (C) 2000 - 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License: http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.18 $
**/

class HTML_templates {

	function showTemplates( &$rows, &$pageNav, $option ) {
		global $my;
		if (isset($row->authorurl) && $row->authorurl != "") {
			$row->authorurl = str_replace("http://","",$row->authorurl);
		}
?>
	<form action="index2.php" method="post" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td width="100%"><span class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle">Installed Templates</span></td>
			<td nowrap>Display #</td>
			<td> <?php echo $pageNav->writeLimitBox(); ?> </td>
		</tr>
	</table>
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
		<tr>
			<th width="20">#</th>
			<!--<th width="20"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" /></th> -->
			<th width="30">&nbsp;</th>
			<th width="35%" class="title">Name</th>
			<th width="5%">Published</th>
			<th width="20%" align="left">Author</th>
			<th width="20%" align="center">Version</th>
			<th width="20%" align="center">Date</th>
			<th width="20%" align="left">Author Email</th>
			<th width="20%" align="left">Author URL</th>
		</tr>
<?php
		$k = 0;
		for ($i=0, $n=count( $rows ); $i < $n; $i++) {
			$row = &$rows[$i];
?>
		<tr class="<?php echo "row$k"; ?>">
			<td width="20"><?php echo $i+$pageNav->limitstart+1;?></td>
			<td width="20">
<?php		if ($row->checked_out && $row->checked_out != $my->id) { ?>
				&nbsp;
<?php		} else { ?>
				<input type="radio" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->directory; ?>" onClick="isChecked(this.checked);" />
<?php		} ?>
			</td>
			<td><?php echo $row->name;?> <a href="#view" onClick="return listItemTask('cb<?php echo $i;?>','view')">[info]</a> </td>
			<td align="center">
<?php		if ($row->published == 1) { ?>
				<img src="images/tick.png">
<?php		} else { ?>
				&nbsp;
<?php		} ?>
			</td>
			<td><?php echo $row->author; ?></td>
			<td align="center"><?php echo $row->version; ?></td>
			<td align="center"><?php echo $row->creationdate; ?></td>
			<td><?php echo $row->authoremail; ?></td>
			<td><a href="http://<?php echo $row->authorurl; ?>" target="_blank"><?php echo $row->authorurl; ?></a></td>
		</tr>
<?php
		}
	?>
		<tr>
			<th align="center" colspan="9"> <?php echo $pageNav->writePagesLinks(); ?></th>
		</tr>
		<tr>
			<td align="center" colspan="9"> <?php echo $pageNav->writePagesCounter(); ?></td>
		</tr>
	</table>

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

	function showTemplateInfo( &$row, $option ) {
?>
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td width="100%"><span class="sectionname"><img src="images/mos_gel.png" width="70" height="67" align="middle">Template Information :: <?php echo $row->name; ?></span></td>
		</tr>
	</table>

	<script language="javascript" src="js/dhtml.js"></script>
	<form action="index2.php" method="post" name="adminForm">
	<table cellspacing="0" cellpadding="4" border="0" width="100%">
		<tr>
			<td width="" class="tabpadding">&nbsp; </td>
			<td id="tab1" class="offtab" onClick="dhtml.cycleTab(this.id);document.adminForm.tab.value=this.id" nowrap="nowrap">Information</td>
			<td id="tab2" class="offtab" onClick="dhtml.cycleTab(this.id);document.adminForm.tab.value=this.id" nowrap="nowrap">Source</td>
			<td id="tab3" class="offtab" onClick="dhtml.cycleTab(this.id);document.adminForm.tab.value=this.id" nowrap="nowrap">Style Sheet</td>
			<td width="90%" class="tabpadding">&nbsp;</td>
		</tr>
		</table>

	<div id="page1" class="pagetext">

	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminform">
		<tr class="row0">
			<td>Author:</td>
			<td><?php echo $row->author; ?></td>
			<td width="200" rowspan="6" valign="top" align="right"><img border="1" src="../templates/<?php echo $row->templatedir; ?>/template_thumbnail.png" name="imagelib" alt="<?php echo $row->name; ?>" />
		</tr>
		<tr class="row1">
			<td>Author Email:</td>
			<td><?php echo $row->authoremail; ?></td>
		</tr>
		<tr class="row0">
			<td>Author Url:</td>
			<td><?php echo $row->authorurl; ?></td>
		</tr>
		<tr class="row1">
			<td>Copyright:</td>
			<td><?php echo $row->copyright; ?></td>
		</tr>
		<tr class="row0">
			<td>Description:</td>
			<td><?php echo $row->description; ?></td>
		</tr>
		<tr class="row1">
			<td>Version:</td>
			<td><?php echo $row->version; ?></td>
		</tr>
	</table>
	</div>

	<div id="page2" class="pagetext">
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminform">
		<tr>
			<td><?php echo $row->source;?></td>
		</tr>
	</table>
	</div>

	<div id="page3" class="pagetext">
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminform">
		<tr>
			<td><?php echo $row->source_css;?></td>
		</tr>
	</table>
	</div>
  	<input type="hidden" name="tab" value="<?php echo $tab;?>" />
	</form>

	<script language="javascript" type="text/javascript">
		dhtml.cycleTab('tab1');
	</script>

<?php
	}

	function DEL_showtemplates($cur_template, $col_main, $tn, $cd, $author, $cr, $ae, $au, &$templateList, &$previews ) { ?>
	<script language="javascript">
	var previews = new Array();
<?php
	foreach ($previews as $k=>$v) {
		echo "\npreviews['$k']='$v';";
	}
?>
	</script>

	<table cellpadding="4" cellspacing="0" border="0" width="100%">
    <tr>
      <td width="100%"><span class="sectionname">Template Manager</span></td>
    </tr>
  </table>
<form action="index2.php" method="POST" name="adminForm">
  <table cellpadding="5" cellspacing="1" width="100%" class="adminform">
    <tr valign="top">
      <td width="125">Select Template:</td>
      <td width="174"><?php echo $templateList;?></td>
      <td width="151" rowspan="2">Template Preview:</td>
      <td colspan="2" rowspan="2"><img border="1" src="../templates/<?php echo $cur_template; ?>/template_thumbnail.png" name="imagelib" alt="<?php echo $cur_template; ?>" /></td>
    </tr>
    <tr valign="top">
      <td width="125">No. of Columns:</td>
      <td>
        <?php if ($col_main == "1") {
        	echo "<input type=\"radio\" name=\"col_main\" value=\"1\" checked />";
        	echo "1&nbsp;&nbsp; <input type=\"radio\" name=\"col_main\" value=\"2\" />2";
        } else {
        	echo "<input type=\"radio\" name=\"col_main\" value=\"1\" />";
        	echo "1&nbsp;&nbsp; <input type=\"radio\" name=\"col_main\" value=\"2\" checked />2";
      } ?>
      </td>
    </tr>
    <tr valign="top">
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>Current Template Info:</td>
      <td width="115">Name : </td>
      <td width="364"><?php echo $tn; ?></td>
    </tr>
    <tr valign="top">
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>Creation Date : </td>
      <td><?php echo $cd; ?></td>
    </tr>
    <tr valign="top">
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>Author : </td>
      <td><?php echo $author; ?></td>
    </tr>
    <tr valign="top">
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>Copyright : </td>
      <td><?php echo $cr; ?></td>
    </tr>
    <tr valign="top">
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>Author e-mail : </td>
      <td><?php echo $ae; ?></td>
    </tr>
    <tr valign="top">
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>Author URL :</td>
      <td>http://<?php echo $au; ?></td>
    </tr>
    <tr>
      <td> </td>
    </tr>
  </table>
  <input type="hidden" name="option" value="templates" />
  <input type="hidden" name="task" value="" />
</form>
<?php }

	function editTemplateSource( $template, &$content, $option ) {
?>
	<form action="index2.php" method="POST" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td class="sectionname" width="100%">Template Editor</td>
		</tr>
	</table>
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminform">
		<tr>
			<th colspan="4">Path: templates/<?php echo $template; ?>/index.php
      		<?php
      		$template_path = "../templates/".$template."/index.php";
      		echo is_writable( $template_path ) ? '<b><font color="green">
			 - Writeable</font></b>' : '<b><font color="red"> - Unwriteable</font></b>' ?>
			</th>
		</tr>
		<tr>
			<td><textarea cols="110" rows="25" name="filecontent" class="inputbox"><?php echo $content; ?></textarea></td>
		</tr>
	</table>
	<input type="hidden" name="template" value="<?php echo $template; ?>" />
	<input type="hidden" name="option" value="<?php echo $option;?>" />
	<input type="hidden" name="task" value="" />
	</form>
<?php
	}

	function editCSSSource( $template, &$content, $option ) {
?>
	<form action="index2.php" method="POST" name="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td class="sectionname" width="100%">Template Stylesheet Editor</td>
		</tr>
	</table>
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminform">
		<tr>
			<th colspan="4">Path: templates/<?php echo $template; ?>/css/template_css.php
			<?php
      		$css_path = "../templates/".$template."/css/template_css.css";
      		echo is_writable( $css_path ) ? '<b><font color="green">
			 - Writeable</font></b>' : '<b><font color="red"> - Unwriteable</font></b>' ?>
			</th>
		</tr>
		<tr>
			<td><textarea cols="110" rows="25" name="filecontent" class="inputbox"><?php echo $content; ?></textarea></td>
		</tr>
	</table>
	<input type="hidden" name="template" value="<?php echo $template; ?>" />
	<input type="hidden" name="option" value="<?php echo $option;?>" />
	<input type="hidden" name="task" value="" />
	</form>
<?php
	}
}
?>