/**
  * Gets the data for editing a category via category manager
  * then calls Joom_ShowEditCategory_HTML()
  * @param    integer   $uid: id of category e.g. 10
  */
 function Joom_ShowEditCategory($uid)
 {
     $config = Joom_getConfig();
     $database =& JFactory::getDBO();
     //new object from mosCatgs
     $row = new mosCatgs($database);
     //lod row
     $row->load($uid);
     $parent = $row->parent;
     // DropDown category list for die parent category
     $Lists['catgs'] = Joom_ShowDropDownCategoryList($parent, 'parent', '', $uid);
     // liste of ACL groups (public, registered, special)
     $database->setQuery("SELECT id AS value, name AS text\n        FROM #__groups\n        ORDER BY id");
     $groups = $database->loadObjectList();
     //list of access
     $glist = JHTML::_('select.genericlist', $groups, 'access', 'class="inputbox" size="1"', 'value', 'text', intval($row->access));
     //list for ordering the category
     $orders = JHTML::_('list.genericordering', "SELECT ordering AS value, name AS text\n        FROM #__joomgallery_catg\n        ORDER BY ordering");
     $orderlist = JHTML::_('select.genericlist', $orders, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval($row->ordering));
     //list of thumbnail position
     $align[] = JHTML::_('select.option', '0', JText::_('JGA_LEFT'));
     $align[] = JHTML::_('select.option', '1', JText::_('JGA_RIGHT'));
     $align[] = JHTML::_('select.option', '2', JText::_('JGA_CENTER'));
     $align_list = JHTML::_('select.genericlist', $align, 'img_position', 'class="inputbox" size="1"', 'value', 'text', $row->img_position);
     //list of available thumbails of category
     $database->setQuery("SELECT imgthumbname\n        FROM #__joomgallery\n        WHERE catid={$uid}\n        ORDER BY imgthumbname");
     $thuFiles2 = $database->loadObjectList();
     $thumbs2 = array(JHTML::_('select.option', '', JText::_('JGA_PLEASE_SELECT_THUMBNAIL')));
     foreach ($thuFiles2 as $tfile2) {
         if (eregi("bmp|gif|jpg|jpeg|jpe|png", $tfile2->imgthumbname)) {
             $thumbs2[] = JHTML::_('select.option', $tfile2->imgthumbname);
         }
     }
     //catpath of category
     $catpath = Joom_GetCatPath($row->cid);
     //list for choosing thumbnail
     $thumblist2 = JHTML::_('select.genericlist', $thumbs2, 'catimage', 'class=\\"inputbox\\" size=\\"1\\"' . " onchange=\"javascript:" . "if (document.forms[0].catimage.options[selectedIndex].value!='') {" . "document.imagelib.src='../" . $config->jg_paththumbs . $catpath . "' " . "+ document.forms[0].catimage.options[selectedIndex].value" . "} else {" . "document.imagelib.src='../images/M_images/blank.png'}\"", 'value', 'text', $row->catimage);
     // Possible owners list
     $ownerlist = JHTML::_('list.users', 'owner', $row->owner, 1, NULL, 'name', 0);
     HTML_Joom_AdminCategories::Joom_ShowEditCategory_HTML($row, $publist, $glist, $Lists, $orderlist, $thumblist2, $align_list, $config->jg_paththumbs, $catpath, $config->jg_wrongvaluecolor, $ownerlist);
 }
 /**
 * Upload eines oder mehrerer Bilder
 */
 function Joom_User_ShowUpload()
 {
     //fuer Admin/SuperAdmin werden alle Kategorien angezeigt
     if ($this->adminlogged) {
         $clist = Joom_ShowDropDownCategoryList(0, 'catid', ' class="inputbox"');
     } else {
         //wenn $config->jg_userowncatsupload=true, duerfen user nur in eigens erstellte
         //User-Kategorien hochladen
         $clist = $this->Joom_User_ShowDropDownCategoryList(0, null, 'catid', true);
     }
     HTML_Joom_UserPanel::Joom_User_ShowUpload_HTML($clist);
 }
    /**
     * HTML output of the mini thumbnails for the JoomBu
     *
     *@param array DB result
     */
    function Joom_ShowMinis_HTML($rows)
    {
        $mainframe =& JFactory::getApplication('site');
        $document =& JFactory::getDocument();
        $config = Joom_getConfig();
        // template CSS is usually not loaded now, but it's better to have it
        $load_template_css = true;
        // make available in the plugin params?
        if ($load_template_css) {
            $template = $mainframe->getTemplate();
            $template_file = false;
            if (is_file(JPATH_THEMES . DS . $template . DS . 'css' . DS . 'template.css')) {
                $template_file = 'templates/' . $template . '/css/template.css';
            } else {
                if (is_file(JPATH_THEMES . DS . $template . DS . 'css' . DS . 'template_css.css')) {
                    $template_file = 'templates/' . $template . '/css/template_css.css';
                }
            }
            if ($load_template_css) {
                $document->addStyleSheet(_JOOM_LIVE_SITE . $template_file);
                // to avoid scroll bar with some templates
                $document->addStyleDeclaration("    body{\n      height:90%;\n    }");
            }
        }
        // for overlib effect # at the moment always loaded by joom.javascript.php
        #$document->addScript(_JOOM_LIVE_SITE.'includes/js/overlib_mini.js');
        // for accordion
        $document->addStyleSheet('components/com_joomgallery/assets/css/joom_detail.css');
        JHTML::_('behavior.mootools');
        #$document->addScript('components/com_joomgallery/assets/js/accordion/js/accordion.js');
        $script = "\n    window.addEvent('domready', function(){ \n      new Accordion(\$\$('h4.joomgallery-toggler'), \$\$('div.joomgallery-slider'), \n        {onActive: function(toggler, i) { \n          toggler.addClass('joomgallery-toggler-down'); \n          toggler.removeClass('joomgallery-toggler'); },\n         onBackground: function(toggler, i) { \n          toggler.addClass('joomgallery-toggler'); \n          toggler.removeClass('joomgallery-toggler-down'); },\n          duration: 300,display:-1,show:1,opacity: false,alwaysHide: true}); });";
        $document->addScriptDeclaration($script);
        // JavaScript for inserting the tag
        $script = "\n    function insertJoomPluWithId(jg_id) {\n      jg_detail = document.getElementById('jg_bu_detail').checked;\n      jg_linked = document.getElementById('jg_bu_linked').checked;\n      jg_align  = document.getElementById('jg_bu_align').value;\n      if(jg_detail) {\n        jg_detail = ' detail';\n      } else {\n        jg_detail = '';\n      }\n      if(jg_linked) {\n        jg_linked = '';\n      } else {\n        jg_linked = ' not linked';\n      }\n      if(jg_align) {\n        jg_align  = ' ' + jg_align;\n      } else {\n        jg_align  = '';\n      }\n      jg_plu_tag  = '{joomplu:' + jg_id + jg_detail + jg_linked + jg_align + '}';\n      window.parent.jInsertEditorText(jg_plu_tag, 'text');\n      window.parent.document.getElementById('sbox-window').close();\n    }";
        $document->addScriptDeclaration($script);
        ?>
<div class="gallery minigallery">
  <div class="jg_header">
    <?php 
        echo JText::_('JGS_BU_INTRO');
        ?>
  </div>
  <div class="sectiontableheader">
    <h4 class="joomgallery-toggler">
      <?php 
        echo JText::_('JGS_BU_EXTENDED');
        ?>
&nbsp;
    </h4>
  </div>
  <div class="joomgallery-slider">
    <div class="jg_bu_extended_options">
      <span class="jg_bu_extended_option_left">
        <?php 
        echo JText::_('JGS_BU_DETAIL');
        ?>
&nbsp;
        <input type="checkbox" id="jg_bu_detail">
      </span>
      <span class="jg_bu_extended_option_middle">
        <?php 
        echo JText::_('JGS_BU_LINKED');
        ?>
&nbsp;
        <input type="checkbox" id="jg_bu_linked" checked="checked">
      </span>
      <span class="jg_bu_extended_option_right">
        <?php 
        echo JText::_('JGS_BU_ALIGN');
        ?>
        <select id="jg_bu_align">
          <option value="">
          </option>
          <option value="right">
            <?php 
        echo JText::_('JGS_BU_ALIGN_RIGHT');
        ?>
&nbsp;
          </option>
          <option value="left">
            <?php 
        echo JText::_('JGS_BU_ALIGN_LEFT');
        ?>
&nbsp;
          </option>
        </select>
      </span>
    </div>
  </div>
  <div class="sectiontableheader">
    <h4 class="joomgallery-toggler">
      <?php 
        echo JText::_('JGS_BU_SEARCH');
        ?>
    </h4>
  </div>
  <div class="joomgallery-slider">
    <div class="jg_bu_search">
    <form action="index.php?option=com_joomgallery&func=joomplu&tmpl=component&e_name=text" method="post">
<?php 
        echo $this->_pagination->getListFooter();
        ?>
      <div class="jg_bu_filter">
        <?php 
        echo Jtext::_('JGS_FILTER_BY_CATEGORY');
        ?>
&nbsp;
<?php 
        echo Joom_ShowDropDownCategoryList($this->catid, 'catid', 'onchange="this.form.submit();"');
        ?>
      </div>
    </form>
    </div>
  </div>
  <div class="jg_bu_minis">
<?php 
        foreach ($rows as $row) {
            if (!$this->catid) {
                $catpath = Joom_GetCatPath($row->catid);
                $cat_name = true;
            } else {
                $catpath = $this->catpath;
                $cat_name = false;
            }
            ?>
    <div class="jg_bu_mini">
<?php 
            if ($row->imgthumbname != '' && is_file(JPath::clean(JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $row->imgthumbname))) {
                $tnfile = JPath::clean(JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $row->imgthumbname);
                $tnfile = str_replace(' ', '%20', $tnfile);
                $imginfo = getimagesize($tnfile);
                $srcLink = _JOOM_LIVE_SITE . $config->jg_paththumbs . $catpath . $row->imgthumbname;
                $srcWidth = $imginfo[0];
                $srcHeight = $imginfo[1];
                $overlib = Joom_ShowMiniJoom_HTML::getOverlibHtml($row, $srcLink, $cat_name);
                ?>
      <a href="javascript:insertJoomPluWithId('<?php 
                echo $row->id;
                ?>
');" onmouseover="return overlib('<?php 
                echo $overlib;
                ?>
',WIDTH,<?php 
                echo $srcWidth;
                ?>
,<?php 
                /* HEIGHT,<?php echo $srcHeight; ?>,*/
                ?>
ABOVE)" onmouseout="return nd()" >
        <img src="<?php 
                echo _JOOM_LIVE_SITE . $config->jg_paththumbs . $catpath . $row->imgthumbname;
                ?>
" border="0" height="40" width="40" alt="Thumbnail" /></a>
<?php 
            } else {
                ?>
      <div class="jg_bu_no_mini" onmouseover="return overlib('<?php 
                echo sprintf(JText::_('JGS_NO_THUMB_TOOLTIP_TEXT', true), $row->id, $row->imgtitle);
                ?>
', CAPTION, '<?php 
                echo JText::_('JGS_NO_THUMB');
                ?>
', BELOW, RIGHT)" onmouseout="return nd()" >
        <?php 
                echo JText::_('JGS_NO_THUMB');
                ?>
&nbsp;
      </div>
<?php 
            }
            ?>
    </div>
<?php 
        }
        if (!count($rows)) {
            ?>
    <div class="jg_bu_no_images">
      <?php 
            echo JText::_('JGS_NO_IMAGES');
            ?>
&nbsp;
    </div>
<?php 
        }
        ?>
  </div>
</div>
<?php 
    }
    /**
     * JAVA upload
     *
     */
    function Joom_ShowJUpload_HTML($cookieNavigator)
    {
        $config = Joom_getConfig();
        $mainframe =& JFactory::getApplication('administrator');
        $database =& JFactory::getDBO();
        $user =& JFactory::getUser();
        //cpanel
        echo "<script language = \"javascript\" type = \"text/javascript\">\n";
        echo "<!--\n";
        echo "function submitbutton(pressbutton) {\n";
        echo "  var form = document.adminForm;\n";
        echo "  if (pressbutton == 'cpanel') {\n";
        echo "    location.href = \"index.php?option=" . _JOOM_OPTION . "\";\n";
        echo "  }\n";
        echo "}\n";
        echo "//-->\n";
        echo "</script>\n";
        echo "</form>";
        ?>
<!-- --------------------------------------------------------------------------------------------------- -->
<!-- --------     A DUMMY APPLET, THAT ALLOWS THE NAVIGATOR TO CHECK THAT JAVA IS INSTALLED   ---------- -->
<!-- --------               If no Java: Java installation is prompted to the user.            ---------- -->
<!-- --------------------------------------------------------------------------------------------------- -->
<!--"CONVERTED_APPLET"-->
<!-- HTML CONVERTER -->
<script language="JavaScript" type="text/javascript"><!--
    var _info = navigator.userAgent;
    var _ns = false;
    var _ns6 = false;
    var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
//--></script>
    <comment>
        <script language="JavaScript" type="text/javascript"><!--
        var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX") > 0)));
        var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
//--></script>
    </comment>

<script language="JavaScript" type="text/javascript"><!--
    if (_ie == true) document.writeln('<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH = "0" HEIGHT = "0" NAME = "JUploadApplet"  codebase="http://java.sun.com/update/1.5.0/jinstall-1_5-windows-i586.cab#Version=5,0,0,3"><noembed><xmp>');
    else if (_ns == true && _ns6 == false) document.writeln('<embed ' +
      'type="application/x-java-applet;version=1.5" \
            CODE = "wjhk.jupload2.EmptyApplet" \
            ARCHIVE = "<?php 
        echo _JOOM_LIVE_SITE;
        ?>
administrator/components/<?php 
        echo _JOOM_OPTION;
        ?>
/assets/java/wjhk.jupload.jar" \
            NAME = "JUploadApplet" \
            WIDTH = "0" \
            HEIGHT = "0" \
            type ="application/x-java-applet;version=1.6" \
            scriptable ="false" ' +
      'scriptable=false ' +
      'pluginspage="http://java.sun.com/products/plugin/index.html#download"><noembed><xmp>');
//--></script>
<applet  code = "wjhk.jupload2.EmptyApplet" ARCHIVE = "<?php 
        echo _JOOM_LIVE_SITE;
        ?>
administrator/components/<?php 
        echo _JOOM_OPTION;
        ?>
/assets/java/wjhk.jupload.jar" WIDTH = "0" HEIGHT = "0" NAME = "JUploadApplet"></xmp>
    <param name = CODE VALUE = "wjhk.jupload2.EmptyApplet" >
    <param name = ARCHIVE VALUE = "<?php 
        echo _JOOM_LIVE_SITE;
        ?>
administrator/components/<?php 
        echo _JOOM_OPTION;
        ?>
/assets/java/wjhk.jupload.jar" >
    <param name = NAME VALUE = "JUploadApplet" >
    <param name = "type" value="application/x-java-applet;version=1.5">
    <param name = "scriptable" value="false">
    <param name = "type" VALUE="application/x-java-applet;version=1.6">
    <param name = "scriptable" VALUE="false">
</xmp>
Java 1.5 or higher plugin required.
</applet>
</noembed>
</embed>
</object>
<form name="adminForm">
<input type="hidden" name="option" value="<?php 
        echo _JOOM_OPTION;
        ?>
" />
<input type="hidden" name="approved" value="1" />
<input type="hidden" name="owner" value="<?php 
        echo $user->get('username');
        ?>
" />
<input type="hidden" name="debug" value="<?php 
        echo $this->debug;
        ?>
" />
<table width="100%" border="0" cellpadding="4" cellspacing="2" class="adminlist">
  <tr>
    <td colspan="2">
      <div align="center">
        <?php 
        echo JText::_('JGA_JUPLOAD_NOTE');
        ?>
      </div>
    </td>
  </tr>
  <tr>
    <td align="right" width="50%">
      <div align="right">
        <?php 
        echo JText::_('JGA_PICTURE_ASSIGN_TO_CATEGORY');
        ?>
      </div>
    </td>
    <td align="left"  width="50%">
<?php 
        $clist = Joom_ShowDropDownCategoryList(0, 'catid', ' class="inputbox" size="1" style="width:228;"');
        echo $clist;
        ?>
    </td>
  </tr>
<?php 
        if ($config->jg_delete_original == 2) {
            $sup1 = '&sup1;';
            $sup2 = '&sup2;';
        } else {
            $sup2 = '&sup1;';
        }
        if (!$config->jg_useorigfilename) {
            ?>
  <tr>
    <td align="right">
      <div align="right">
        <?php 
            echo JText::_('JGA_GENERIC_TITLE');
            ?>
      </div>
    </td>
    <td align="left">
      <input type="text" name="gentitle" size="34" maxlength="256" value="" />
    </td>
  </tr>
<?php 
        }
        ?>
  <tr>
    <td align="right">
      <div align="right">
        <?php 
        echo JText::_('JGA_GENERIC_DESCRIPTION') . ' ' . JText::_('JGA_OPTION');
        ?>
      </div>
    </td>
    <td align="left">
      <input type="text" name="gendesc" size="34" maxlength="1000" />
    </td>
  </tr>
  <tr>
    <td align="right">
      <div align="right">
        <?php 
        echo JText::_('JGA_AUTHOR') . ' ' . JText::_('JGA_OPTION');
        ?>
      </div>
    </td>
    <td align="left">
      <input type="text" name="photocred" size="34" maxlength="256" />
    </td>
  </tr>
<?php 
        if ($config->jg_delete_original == 2) {
            ?>
  <tr>
    <td align="right">
        <?php 
            echo JText::_('JGA_DELETE_ORIGINAL_AFTER_UPLOAD');
            ?>
&nbsp;&sup1;
    </td>
    <td align="left">
      <input type="checkbox" name="original_delete" value="1" />
    </td>
  </tr>
<?php 
        }
        ?>
  <tr>
    <td align="right">
      <div align="right">
        <?php 
        echo JText::_('JGA_CREATE_SPECIAL_GIF');
        ?>
&nbsp;<?php 
        echo $sup2;
        ?>
      </div>
    </td>
    <td align="left">
      <input type="checkbox" name="create_special_gif" value="1" />
    </td>
  </tr>
  <tr>
    <td colspan="2" align="center">
      <div align="center" class="smallgrey">
<?php 
        if ($config->jg_delete_original == 2) {
            ?>
        <br /><?php 
            echo $sup1;
            ?>
&nbsp;<?php 
            echo JText::_('JGA_DELETE_ORIGINAL_AFTER_UPLOAD_ASTERISK');
        }
        ?>
        <br /><?php 
        echo $sup2;
        ?>
&nbsp;<?php 
        echo JText::_('JGA_CREATE_SPECIAL_GIF_ASTERISK');
        ?>
      </div>
    </td>
  </tr>
  <tr>
  <?php 
        //If 'originals deleted' setted in backend AND the picture has to be resized
        //this will be done local within in the applet, so only the detail picture
        //will be uploaded
        ?>
    <td colspan="2" align="center">
      <applet name="JUpload" code="wjhk.jupload2.JUploadApplet" archive="<?php 
        echo _JOOM_LIVE_SITE;
        ?>
administrator/components/<?php 
        echo _JOOM_OPTION;
        ?>
/assets/java/wjhk.jupload.jar" width="800" height="600" mayscript>
      <param name="postURL" value="<?php 
        echo _JOOM_LIVE_SITE;
        ?>
administrator/index.php?option=<?php 
        echo _JOOM_OPTION;
        ?>
&task=juploadhandler_receive">
      <param name="lookAndFeel" value="system">
      <param name="showLogWindow" value=false>
      <param name="showStatusBar" value="true">
      <param name="formdata" value="adminForm">
      <param name="debugLevel" value="0">
      <param name="afterUploadURL" value="javascript:alert('<?php 
        echo JText::_('JGA_UPLOAD_COMPLETE', true);
        ?>
');">
      <param name="nbFilesPerRequest" value="4">
      <param name="stringUploadSuccess" value="JOOMGALLERYUPLOADSUCCESS">
      <param name="stringUploadError" value="JOOMGALLERYUPLOADERROR (.*)">
      <param name="uploadPolicy" value="PictureUploadPolicy">
      <param name="allowedFileExtensions" value="jpg/jpeg/jpe/png/gif">
<?php 
        if ($config->jg_delete_original && $config->jg_resizetomaxwidth) {
            ?>
      <param name="maxPicHeight" value="<?php 
            echo $config->jg_maxwidth;
            ?>
">
      <param name="maxPicWidth" value="<?php 
            echo $config->jg_maxwidth;
            ?>
">
      <param name="pictureCompressionQuality" value="<?php 
            echo $config->jg_picturequality / 100;
            ?>
">
<?php 
        } else {
            //set picture quality to 1 to override the applet default of 0.8
            ?>
      <param name="pictureCompressionQuality" value="1">
<?php 
        }
        ?>
      <param name="fileChooserImagePreview" value="false">
      <param name="fileChooserIconFromFileContent" value="-1">
<?php 
        if (!$cookieNavigator) {
            ?>
      <param name="readCookieFromNavigator" value="false">
      <param name="specificHeaders" value="Cookie: <?php 
            echo $this->sessionname . '=' . $this->sessiontoken;
            ?>
">
<?php 
        }
        ?>
      Java 1.5 or higher plugin required.
      </applet>
    </td>
  </tr>
</table>
</form>
<?php 
    }
 /**
  * Shows the form to move picture(s)
  *
  * @param int/array $id id(s) of picture
  */
 function Joom_ShowMovePictures($id)
 {
     $mainframe =& JFactory::getApplication('administrator');
     $database =& JFactory::getDBO();
     $catid = $mainframe->getUserStateFromRequest("catid", 'catid', 0);
     //query to list items from pictures
     $ids = implode(',', $id);
     $query = "SELECT *\n        FROM #__joomgallery\n        WHERE id IN ( " . $ids . " )\n        ORDER BY id, imgtitle";
     $database->setQuery($query);
     $items = $database->loadObjectList();
     //category select list
     $options = array(JHTML::_('select.option', '1', JText::_('JGA_SELECT_CATEGORY')));
     //TODO: need of $options?
     $Lists['catgs'] = Joom_ShowDropDownCategoryList($catid, 'catid', 'class="inputbox" size="1" ');
     HTML_Joom_AdminPictures::Joom_ShowMovePictures_HTML($id, $Lists, $items);
 }