<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: edittemplate.php,v 1.5.2.2 2004/04/18 12:46:51 ajvwaay Exp $



function edittemplate($tid) {
    global
        $adminurl,
        $module_name,
        $imagepath,
        $gallerypath,
        $adminpath,
        $languagepath,
        $baseurl,
        $adminurl,
        $version,
        $bgcolor1,
        $bgcolor2,
        $bgcolor3,
        $bgcolor4,
        $textcolor1,
        $textcolor2,
        $hlpfile,
        $xtype,
        $mpnTables
    ;
    if(isset($tid) && $tid) {
        $trow = mysql_fetch_array(mysql_query("SELECT id, title, type, templateCategory, templatePictures, templateCSS FROM ".$mpnTables['gallery_template_types']." WHERE id=$tid"));
        $optype = 'save';
        $navtitle = _GALEDITTEMPLATE." &gt; " . $trow['title'];
    }
    else {
        $trow = mysql_fetch_array(mysql_query("SELECT id, type, templateCategory, templatePictures, templateCSS FROM ".$mpnTables['gallery_template_types']." WHERE id=$xtype"));
        $optype = 'create';
        $navtitle = _GALCREATETEMPLATE;
    }

    if (!isset($trow['title']))
    {
        $trow['title'] = null;
    }

    $trow['templateCategory'] = stripslashes($trow['templateCategory']);
    $trow['templatePictures'] = stripslashes($trow['templatePictures']);
    $trow['templateCSS'] = stripslashes($trow['templateCSS']);
    if($trow['type'] == 1) {
        $cattext = _GALTEMPLMAIN;
        $catdesc = _GALTEMPLMAINDESC;
    }
    else {
        $cattext = _GALTEMPLCAT;
        $catdesc = _GALTEMPLCATDESC;
    }

    // Start Of Output
#   include 'header.php';
#   GraphicAdmin($hlpfile);
  OpenTable();
    print '<center><font size="4"><b>'._GALADMIN.'</b></font></center>';
    CloseTable();
    print '<br>';
    OpenTable();
    print
    '<table border="0" width="100%" cellspacing="0" cellpadding="0">'
        .'<tr><td>'
            ."<form method=\"post\" action=\"$adminurl\">"
                .'<input type="hidden" name="op" value="doedittemplate">'
            ."<input type=\"hidden\" name=\"type\" value=\"$optype\">"
            ."<input type=\"hidden\" name=\"xtype\" value=\"" . $trow['type'] . "\">"
            ."<input type=\"hidden\" name=\"templateid\" value=\"$tid\">"
    ;
    // Table Header
    print
                '<table border="0" width="100%" cellpadding="3" cellspacing="1" bgcolor="#000000">'
                    .'<tr>'
                        ."<td bgcolor=\"$bgcolor2\">"
                            .'<table border="0" width="100%" cellspacing="0" cellpadding="0">'
                                .'<tr>'
                                    ."<td width=\"50%\"><strong><font color=\"$textcolor1\">"
                                        ."<a href=\"$adminurl\"><font color=\"$textcolor1\">"._GALCONFIG.'</font></a> &gt;'
                                        ."<a href=\"$adminurl&amp;op=editalltemplate\"><font color=\"$textcolor1\">"._GALEDITALLTEMPLATES.'</font></a> &gt; '
                                        .$navtitle
                                    .'</font></strong></td>'
                                .'</tr>'
                            .'</table>'
                        .'</td>'
                    .'</tr>'
                    .'<tr>'
                        ."<td bgcolor=\"$bgcolor3\" width=\"100%\">"
                            .'<table border="0" width="100%">'
                                .'<tr>'
                                    .'<td width="50%" valign="top">'
                                        .'<b>'._GALTEMPLATENAME.'</b><br>'
                                        .'<table border="0" width="100%">'
                                            .'<tr><td width="10%">&nbsp;</td>'
                                                .'<td width="90%">'
                                                    ._GALTEMPLATENAMEDESC
                                                .'</td>'
                                            .'</tr>'
                                        .'</table>'
                                    .'</td>'
                                    .'<td width="50%" valign="middle">'
                                        ."<input type=\"text\" width=\"30\" name=\"xtemplatename\" value=\"" . $trow['title'] . "\">"
                                    .'</td>'
                                .'</tr>'
                            .'</table>'
                        .'</td>'
                    .'</tr>'
    ;
    // Start Of For Fields
    print
                    '<tr>'
                        ."<td bgcolor=\"$bgcolor3\">"
                            .'<table border="0" width="100%" cellspacing="0" cellpadding="0">'
    ;
    // Category Template
    print
                                    '<tr>'
                                        ."<td bgcolor=\"$bgcolor3\">"
                                            .'<table border="0" width="100%">'
                                                .'<tr>'
                                                    .'<td width="50%" valign="top">'
                                                        ."<b>$cattext</b><br>"
                                                        .'<table border="0" width="100%">'
                                                            .'<tr><td width="10%">&nbsp;</td>'
                                                                .'<td width="90%">'
                                                                    ."<font size=\"2\">$catdesc</font>"
                                                                .'</td>'
                                                            .'</tr>'
                                                        .'</table>'
                                                    .'</td>'
                                                    .'<td width="50%" valign="middle">'
                                                        ."<textarea name=\"xtemplateCat\" cols=\"50\" rows=\"30\" wrap=\"soft\">" . $trow['templateCategory'] . "</textarea>"
                                                    .'</td>'
                                                .'</tr>'
                                            .'</table>'
                                        .'</td>'
                                    .'</tr>'
    ;
    // Pictures Template
    if($trow['type'] != 1) {
        print
                                    '<tr>'
                                        ."<td bgcolor=\"$bgcolor3\">"
                                            .'<table border="0" width="100%">'
                                                .'<tr>'
                                                    .'<td width="50%" valign="top">'
                                                        .'<b>'._GALTEMPLPIC.'</b><br>'
                                                        .'<table border="0" width="100%">'
                                                            .'<tr><td width="10%">&nbsp;</td>'
                                                                .'<td width="90%">'
                                                                    .'<font size="2">'._GALTEMPLPICDESC.'</font>'
                                                                .'</td>'
                                                            .'</tr>'
                                                        .'</table>'
                                                    .'</td>'
                                                    .'<td width="50%" valign="middle">'
                                                        ."<textarea name=\"xtemplatePic\" cols=\"50\" rows=\"30\" wrap=\"soft\">" . $trow['templatePictures'] . "</textarea>"
                                                    .'</td>'
                                                .'</tr>'
                                            .'</table>'
                                        .'</td>'
                                    .'</tr>'
        ;
    }
    // CSS Template
    print
                                    '<tr>'
                                        ."<td bgcolor=\"$bgcolor3\">"
                                            .'<table border="0" width="100%">'
                                                .'<tr>'
                                                    .'<td width="50%" valign="top">'
                                                        .'<b>'._GALTEMPLCSS.'</b><br>'
                                                        .'<table border="0" width="100%">'
                                                            .'<tr><td width="10%">&nbsp;</td>'
                                                                .'<td width="90%">'
                                                                    .'<font size="2">'._GALTEMPLCSSDESC.'</font>'
                                                                .'</td>'
                                                            .'</tr>'
                                                        .'</table>'
                                                    .'</td>'
                                                    .'<td width="50%" valign="middle">'
                                                        ."<textarea name=\"xtemplateCSS\" cols=\"50\" rows=\"30\" wrap=\"soft\">" . $trow['templateCSS'] . "</textarea>"
                                                    .'</td>'
                                                .'</tr>'
                                            .'</table>'
                                        .'</td>'
                                    .'</tr>'
    ;
    // Save / Reset
    print
                                    '<tr>'
                                        ."<td bgcolor=\"$bgcolor3\">"
                                            .'<table border="0" width="100%">'
                                                .'<tr>'
                                                    .'<td width="100%" align="center">'
                                                        .'<input class="button" type="submit" name="save" value="'._GALSAVECHANGES.'"> <input class="button" type="reset" name="reset" value="Reset">'
                                                    .'</td>'
                                                .'</tr>'
                                            .'</table>'
                                        .'</td>'
                                    .'</tr>'
    ;
    // Copyright
    print  '</table>'
                                    .'</td>'
                                .'</tr>'
    ;
    // End Of Form Fields
    print
                '</table>'
                .'</form>'
            .'</td></tr>'
        .'</table>'
    ;
    CloseTable();
    print '<br>';
    // Start Of Footer
    OpenTable();
    print '
    <table><tr>
    <td>'
      ."<font face=\"Verdana,Arial\" color=\"$textcolor1\">mpn eGallery Version - $version<br>"._GALVISITUPDATE.'</font>
    </td>
    </tr></table>';
    CloseTable();
#   include 'footer.php';
}
?>
