<?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: editcategory.php,v 1.7.2.2 2004/04/18 12:46:51 ajvwaay Exp $



function editcategory($gid, $parent) {
  global $adminurl, $module_name, $imagepath, $gallerypath, $adminpath, $languagepath, $baseurl, $adminurl;
  global $version, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $mpnTables, $textcolor1;

#  include ("header.php");
#  GraphicAdmin($hlpfile);
  OpenTable();
  echo "<center><font size=\"4\"><b>"._GALADMIN."</b></font></center>";
  CloseTable();
  echo "<br>";
  OpenTable();

  echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">
        <tr><td>";

    $name = $img = $galloc = $description = $visible = $templateID = $numcol = null;

    if (isset($gid) && $gid!="") {
        $sql = "select gallname, gallimg, galloc,description, parent, visible, template, numcol from ".$mpnTables['gallery_categories']." where gallid=$gid";
        //echo $sql;
        $result = mysql_query($sql);
        list ($name, $img, $galloc, $description, $parent, $visible, $templateID, $numcol) = mysql_fetch_row($result);
    }

    if (isset($parent) && $parent!="" && $parent!=-1) {
        $sql = "select galloc from ".$mpnTables['gallery_categories']." where gallid=$parent";
        //echo $sql;
        $result = mysql_query($sql);
        list ($parentloc) = mysql_fetch_row($result);
    }
    else
    {
        $parentloc = null;
    }

    if (isset($gid) && $gid!="")
        echo "<form method=\"POST\" action=\"$adminurl\">";
    else
        echo "<form method=\"POST\" action=\"$adminurl\"  enctype=\"multipart/form-data\">";
    echo "
    <input type=\"hidden\" name=\"op\" value=\"editcategory\">";
    if (isset($gid) && $gid!="") {
        echo "<input type=\"hidden\" name=\"type\" value=\"save\">";
    }
    else {
        echo "<input type=\"hidden\" name=\"type\" value=\"create\">";
    }
    echo "
    <input type=\"hidden\" name=\"parent\" value=\"$parent\">
    <input type=\"hidden\" name=\"parentloc\" value=\"$parentloc\">
    <input type=\"hidden\" name=\"category\" value=\"$gid\">";

    echo "
    <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>
      <a href=\"$adminurl\">"._GALCONFIG."</a> &gt;
      <a href=\"$adminurl&amp;op=editallcategories\">"._GALEDITALLCATEGORIES."</a> &gt; ";
         if (isset($gid) && $gid!="")
        echo _GALEDITCATEGORY;
         else
        echo _GALCREATECATEGORY;
         echo "
      </strong></td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
      <td bgcolor=\"$bgcolor3\" width=\"100%\">
    <!-- Start of Body -->
      <table border=\"0\" width=\"100%\">
      <tr>
        <td width=\"50%\" valign=\"top\">
        <b>"._GALCATAEGOYNAME."</b><br>
        <table border=\"0\" width=\"100%\">
        <tr><td width=\"10%\">&nbsp;</td>
        <td width=\"90%\">
        "._GALCATAEGOYNAMEDESC."
        </td>
        </tr>
        </table>
        </td>
        <td width=\"50%\" valign=\"middle\">
        <input type=\"text\" width=\"30\" name=\"categoryname\" value=\"$name\">
        </td>
      </tr>
      </table>
      </td>
    </tr>

    <tr>
      <td bgcolor=\"$bgcolor4\" width=\"100%\">
      <table border=\"0\" width=\"100%\">     <tr>
        <td width=\"50%\" valign=\"top\">
        <b>"._GALCATLOC."</b><br>
        <table border=\"0\" width=\"100%\">
        <tr><td width=\"10%\">&nbsp;</td>
        <td width=\"90%\">
        "._GALCATLOCDESC."
        </td>
        </tr>
        </table>
        </td>
        <td width=\"50%\" valign=\"middle\">";
        if (isset($gid) && $gid!="")
            echo "$galloc";
        else
            echo "
        <input type=\"text\" width=\"30\" name=\"categoryloc\" value=\"$galloc\">";
        echo "
        </td>
      </tr>
      </table>
      </td>
    </tr>

    <tr>
    <td bgcolor=\"$bgcolor3\">
      <table border=\"0\" width=\"100%\">
      <tr>
        <td width=\"50%\" valign=\"top\">
        <b>"._GALCATDESC."</b><br>
        <table border=\"0\" width=\"100%\">
        <tr><td width=\"10%\">&nbsp;</td>
        <td width=\"90%\">
        "._GALCATDESCDESC."
        </td>
        </tr>
        </table>
        </td>
        <td width=\"50%\" valign=\"middle\">
        <textarea rows=\"8\" name=\"description\" cols=\"30\" wrap=\"virtual\">$description</textarea>
        </td>
      </tr>
      </table>
    </td>
    </tr>

    <tr>
    <td bgcolor=\"$bgcolor4\">
      <table border=\"0\" width=\"100%\">
      <tr>
        <td width=\"50%\" valign=\"top\">
        <b>"._GALCATICON."</b><br>
        <table border=\"0\" width=\"100%\">
        <tr><td width=\"10%\">&nbsp;</td>
        <td width=\"90%\">
        "._GALCATICONDESC."
        </td>
        </tr>
        </table>
        </td>
        <td width=\"50%\" valign=\"middle\">";
        if (isset($gid) && $gid!="")
            echo "<input type=\"text\" width=\"20\" name=\"image\" value=\"$img\">";
        else {
            echo "<INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1000000\">";
            echo "<input type=\"file\" width=\"20\" name=\"userfile\" >";
        }

        echo "
        </td>
      </tr>
      </table>
    </td>
    </tr>

    <tr>
      <td bgcolor=\"$bgcolor3\" width=\"100%\">
      <table border=\"0\" width=\"100%\">     <tr>
        <td width=\"50%\" valign=\"top\">
        <b>"._GALNUMCOLCAT."</b><br>
        <table border=\"0\" width=\"100%\">
        <tr><td width=\"10%\">&nbsp;</td>
        <td width=\"90%\">
        "._GALNUMCOLCATDESC."
        </td>
        </tr>
        </table>
        </td>
        <td width=\"50%\" valign=\"middle\">
        <select name=\"numcol\">";
        for ($k=1; $k<=3; $k++) {
           if ($k==$numcol)
            echo "<option selected value=\"$k\">$k</option>";
           else
            echo "<option value=\"$k\">$k</option>";
        }
        echo "
        </select>
        </td>
      </tr>
      </table>
      </td>
    </tr>

    <tr>
      <td bgcolor=\"$bgcolor4\" width=\"100%\">
       <table border=\"0\" width=\"100%\"><tr>
         <td width=\"50%\" valign=\"top\">
           <b>"._GALTEMPLATETYPE."</b><br>
           <table border=\"0\" width=\"100%\">
           <tr><td width=\"10%\">&nbsp;</td>
           <td width=\"90%\">
           "._GALTEMPLATETYPEDESC."
           </td>
           </tr>
           </table>
           </td>
         <td width=\"50%\" valign=\"middle\">
         <select name=\"xtemplate\">";
$sel_template[$templateID] = ' selected';
$tempres = mysql_query("SELECT id, title FROM ".$mpnTables['gallery_template_types']." WHERE id>1 AND type=2 ORDER BY title");
while($row = mysql_fetch_array($tempres)) {
    $sel = $sel_template[$row['id']];
    print '<option value="' . $row['id'] . '" ' . $sel . '>' . $row['title'] . '</option>' . "\n";
}
print "</select>
    </td>
    </tr>
    </table>
    </td>
    </tr>";
print "<tr>
    <td bgcolor=\"$bgcolor3\">
      <table border=\"0\" width=\"100%\">
      <tr>
        <td width=\"50%\" valign=\"top\">
        <b>"._GALCATVISIBLE."</b><br>
        <table border=\"0\" width=\"100%\">
        <tr><td width=\"10%\">&nbsp;</td>
        <td width=\"90%\">
        "._GALCATVISIBLEDESC."
        </td>
        </tr>
        </table>
        </td>
        <td width=\"50%\" valign=\"middle\">
        <select name=\"visible\">";
        switch ($visible)
        {
        case 0:
            print "<option value=\"0\" selected>"._GALVISIBLEADMIN."</option>
            <option value=\"1\">"._GALVISIBLEMEMBER."</option>
            <option value=\"2\">"._GALVISIBLEPUBLIC."</option>";
            break;
        case 1:
            print "<option value=\"0\">"._GALVISIBLEADMIN."</option>
            <option value=\"1\" selected>"._GALVISIBLEMEMBER."</option>
            <option value=\"2\">"._GALVISIBLEPUBLIC."</option>";
            break;
        default:
            print "<option value=\"0\">"._GALVISIBLEADMIN."</option>
            <option value=\"1\">"._GALVISIBLEMEMBER."</option>
            <option value=\"2\" selected>"._GALVISIBLEPUBLIC."</option>";
            break;
        }
        print "
        </select>
        </td>
      </tr>
      </table>
    </td>
    </tr>";
    if (isset($gid) && $gid!="") {
        list($nb) = mysql_fetch_row(mysql_query("SELECT count(*) FROM ".$mpnTables['gallery_pictures']." WHERE gid=$gid"));
        list($sub) = mysql_fetch_row(mysql_query("SELECT count(*) FROM ".$mpnTables['gallery_categories']." WHERE parent=$gid"));
        echo "
        <tr>
        <td bgcolor=\"$bgcolor4\">
          <table border=\"0\" width=\"100%\">
          <tr>
            <td width=\"50%\" valign=\"top\">
            <b>"._GALCATDETAILS."</b><br>
            <table border=\"0\" width=\"100%\">
            <tr><td width=\"10%\">&nbsp;</td>
            <td width=\"90%\">
            "._GALCATDETAILSDESC."
            </td>
            </tr>
            </table>
            </td>
            <td width=\"50%\" valign=\"middle\">
            "._GALCATMEDIACOUNT." $nb<br>
            "._GALSUBCATEGORIES." $sub<br>
            </td>
          </tr>
          </table>
        </td>
        </tr>";
    }
    echo "
    <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 type=\"reset\" name=\"reset\" value=\"Reset\"></form>
        </td>
      </tr>
      </table>
    </td>
    </tr>
    </table>";

  echo "</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");
}
?>
