<?

/************************************************************************/
/* 4nAlbum Version 0.9                                                  */
/* ==================================================================== */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

function editallcategories() {
        global $prefix, $font, $imagepath, $gallerypath, $adminurl, $bgcolor1, $bgcolor3;

        galleryHeader();
        print '<br>';
        navigationAdmin("<a class=\"".$font['title']."\" href=\"$adminurl\">"._GALCONFIG."</a><font class=\"".$font['title']."\"> &gt; "._GALEDITALLCATEGORIES."</font>");
        print '<br>';
        OpenTable();
          echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"$bgcolor3\" width=\"100%\">
          <tr>
                <td><font class=\"".$font['normal']."\">"._GALECDCATEGORIESDESC."</font>
                <p></p>

                <hr size=\"1\" color=\"#000000\">

                <p></p>
                  <table border=\"0\" width=\"100%\" cellpadding=\"1\" cellspacing=\"0\" bgcolor=\"#000000\">
                <tr>
                        <td>
                        <table border=\"0\" width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"$bgcolor1\">
                        <tr>
                                <td>
                                <a class=\"".$font['normal']."\" href=\"$adminurl&amp;do=editcategory&amp;parent=-1\">"._GALCLICK2CREATECAT."</a>.
                                </td>
                        </tr>
                        </table>
                        </td>
                </tr>
                </table>
                <br>";


        list($numcategories) = mysql_fetch_array(mysql_query("SELECT count(*) from $prefix"._4nalbum_categories.""));
        if ($numcategories>0)
        {
        $categories = listcategories("$gallerypath");
        $categories = explode(" ", trim($categories));
        $cpt = 0;

        while(list($key, $val) = each($categories)) {
                //echo "*$val*<br>";
                $result = mysql_query("select gallid, galloc, gallname, parent, visible, gallimg from $prefix"._4nalbum_categories." where gallid=".$val);
                list ($gid, $galloc, $name, $parent, $visible, $gallimg) = mysql_fetch_row($result);
                //echo "$gid : $galloc : $namle : $parent : $visible<br>";

                $tab = indent($gid)*50;
                list($count) = mysql_fetch_row(mysql_query("SELECT count(*) FROM $prefix"._4nalbum_pictures." WHERE gid=$gid"));
                //echo "*$count*";
                echo "
                        <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
                        <tr>
                                <td>
                                          <img src=\"$imagepath/blank.gif\" height=\"20\" width=\"$tab\">
                                </td>
                                <td>
                                 <table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" bgcolor=\"#000000\">
                                    <tr>
                                          <td>
                                          <table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"$bgcolor1\">
                                          <tr>
                                                  <td>
                                                        <font class=\"".$font['normal']."\">
                                                        $name        [<a class=\"".$font['normal']."\" href=\"$adminurl&amp;do=editcategory&amp;category=$gid\">"._GALCATEDIT."</a>]
                                                        [<a class=\"".$font['normal']."\"href=\"$adminurl&amp;do=editcategory&type=move&category=$gid\">"._GALCATMOVE."</a>]
                                                        [<a class=\"".$font['normal']."\"href=\"$adminurl&amp;do=editcategory&type=delete&category=$gid\" onClick=\"return confirm('"._GALSURE2DELETECAT."')\">"._GALCATDELETE."</a>]
                                                        [<a class=\"".$font['normal']."\"href=\"$adminurl&amp;do=editcategory&parent=$gid\">"._GALCATCREATESUB."</a>]
                                                        </font>
                                                        <hr color=\"#000000\" height=\"1\">
                                                            <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
                                                        <tr>
                                                                <td align=\"left\">
                                                                        <img src=\"$gallerypath/$galloc/$gallimg\" border=\"0\">
                                                                </td>
                                                                <td align=\"right\"><font class=\"".$font['normal']."\">
                                                                        "._GALCATMEDIACOUNT." $count<br>
                                                                        "._GALCATSTATE. "</font> ";
                                                                        switch ($visible)
                                                                        {
                                                                        case 0:
                                                                                print "<a class=\"".$font['normal']."\" href=\"$adminurl&amp;do=editcategory&amp;type=status&amp;visible=1&amp;category=$gid\" title=\""._GALVISIBLEADMIN.'">'._GALVISIBLEADMIN."&nbsp;<img src=\"$imagepath/red_dot.gif\" border=\"0\" width=\"10\" height=\"10\" alt=\""._GALVISIBLEADMIN.'"></a>&nbsp;';
                                                                                break;
                                                                        case 1:
                                                                                print "<a class=\"".$font['normal']."\" href=\"$adminurl&amp;do=editcategory&amp;type=status&amp;visible=2&amp;category=$gid\" title=\""._GALVISIBLEMEMBER.'">'._GALVISIBLEMEMBER."&nbsp;<img src=\"$imagepath/yellow_dot.gif\" border=\"0\" width=\"10\" height=\"10\" alt=\""._GALVISIBLEMEMBER.'"></a>&nbsp;';
                                                                                break;
                                                                        default:
                                                                                print "<a class=\"".$font['normal']."\" href=\"$adminurl&amp;do=editcategory&amp;type=status&amp;visible=0&amp;category=$gid\" title=\""._GALVISIBLEPUBLIC.'">'._GALVISIBLEPUBLIC."&nbsp;<img src=\"$imagepath/green_dot.gif\" border=\"0\" width=\"10\" height=\"10\" alt=\""._GALVISIBLEPUBLIC.'"></a>&nbsp;';
                                                                                break;
                                                                        }
                                print "</td>
                                                        </tr>
                                                        </table>
                                                   </td>
                                           </tr>
                                           </table>
                                          </td>
                                  </tr>
                                  </table>
                                </td>
                        </tr>
                        </table>
                        <br>";
        }// While
        }
        echo "
                          <hr size=\"1\" color=\"#000000\">
                          </td>
                  </tr>
                  </table>";
  CloseTable();
  print '<br>';
        adminFooter();

}

?>