/**
  * @return String Return html code for form fields representing images-related information :
  * <ul>
  * <li>Input text fields and "Browse..." button, if image has not been choosen.</li>
  * <li>Image and "Delete" link, otherwise.</li>
  * </ul>
  * @see $this->ViewState ("LargeImage" and "SmallImage" indices)
  */
 function outputCatImageControls($ViewState)
 {
     global $application;
     $this->MessageResources =& $application->getInstance('MessageResources');
     $obj =& $application->getInstance('MessageResources');
     $retval = "";
     loadCoreFile('html_form.php');
     $HtmlForm1 = new HtmlForm();
     $level1_template_contents = array();
     $level1_template_contents["Images"] = "";
     //        if(modApiFunc("application", "isImageUploaded", $ViewState["LargeImage"]) &&
     //           modApiFunc("application", "isImageUploaded", $ViewState["SmallImage"]))
     if ($ViewState["LargeImage"] != "" && $ViewState["SmallImage"] != "") {
         $level1_template_contents["UploadControl"] = "";
     } else {
         $this->_Template_Contents["ImagesUploadSubmit"] = $HtmlForm1->genInputSubmit("ImagesUploadSubmit", "Upload");
         $this->_Template_Contents["SubmitUploadImagesScript"] = "onClick=\" AddCatForm.FormSubmitValue.value = 'UploadImages'; AddCatForm.submit(); disableButtons(new Array('SaveButton1', 'SaveButton2', 'CancelButton1', 'CancelButton2', 'UploadButton'));\"";
         $this->_Template_Contents["ErrorMessage"] = $this->MessageResources->getMessage("SETUP_WARNING_IMAGE_FOLDER_IS_NOT_WRITABLE", array("0" => modApiFunc("Catalog", "getImagesDir")));
         $application->registerAttributes($this->_Template_Contents);
         if (modApiFunc("Catalog", "isImageFolderNotWritable")) {
             $level1_template_contents["UploadControl"] = $this->mTmplFiller->fill("catalog/add_cat/", "cat_images.upload_ctrl.error.tpl.html", array());
         } else {
             $level1_template_contents["UploadControl"] = $this->mTmplFiller->fill("catalog/add_cat/", "cat_images.upload_ctrl.tpl.html", array());
         }
     }
     $imagesUrl = $application->getAppIni('URL_IMAGES_DIR');
     if ($application->getCurrentProtocol() == "https" && $application->getAppIni('HTTPS_URL_IMAGES_DIR')) {
         $imagesUrl = $application->getAppIni('HTTPS_URL_IMAGES_DIR');
     }
     $pathImagesDir = $application->getAppIni('PATH_IMAGES_DIR');
     if ($ViewState["LargeImage"] != "") {
         $this->_Template_Contents["ImageTitle"] = $obj->getMessage(new ActionMessage('CAT_LRGIMG_NAME'));
         $this->_Template_Contents["ImageViewTag"] = "LargeImage";
         $this->_Template_Contents["LargeImageHref"] = $imagesUrl . $ViewState["LargeImage"];
         if ($ViewState['LargeImage']) {
             list($width, $height) = getimagesize($pathImagesDir . $ViewState['LargeImage']);
             $this->_Template_Contents["LargeImageHeight"] = $height;
             $this->_Template_Contents["LargeImageWeight"] = $width;
         }
         $this->_Template_Contents["DelImageHref"] = "#";
         $this->_Template_Contents["SubmitDeleteLargeImageScript"] = " onClick=\" AddCatForm.FormSubmitValue.value = 'DeleteLargeImage'; AddCatForm.submit();\"";
         $application->registerAttributes($this->_Template_Contents);
         $level1_template_contents["Images"] .= $this->mTmplFiller->fill("catalog/add_cat/", "image_delete.large.tpl.html", array());
     } else {
         $this->_Template_Contents["ImageTitle"] = $obj->getMessage(new ActionMessage('CAT_LRGIMG_NAME'));
         $this->_Template_Contents["ImageViewTag"] = "LargeImage";
         $this->_Template_Contents["InputField"] = $HtmlForm1->genInputFileName("LargeImage", 65);
         $this->_Template_Contents["ImageHint"] = '';
         //: move code to HtmlForm
         if (modApiFunc("Catalog", "isImageFolderNotWritable")) {
             $this->_Template_Contents["InputField"] .= " disabled ";
         }
         $this->_Template_Contents["AddEditCategoryUploadImageCtrlIndex"] = "1";
         $application->registerAttributes($this->_Template_Contents);
         $level1_template_contents["Images"] .= $this->mTmplFiller->fill("catalog/add_cat/", "image_upload.item.tpl.html", array());
     }
     if ($ViewState["SmallImage"] != "") {
         $this->_Template_Contents["ImageTitle"] = $obj->getMessage(new ActionMessage('CAT_SMLIMG_NAME'));
         $this->_Template_Contents["ImageViewTag"] = "SmallImage";
         $this->_Template_Contents["Image"] = '<img width="120" src="' . $imagesUrl . $ViewState["SmallImage"] . '">';
         $this->_Template_Contents["DelImageHref"] = "#";
         $this->_Template_Contents["SubmitDeleteSmallImageScript"] = " onClick=\" AddCatForm.FormSubmitValue.value = 'DeleteSmallImage'; AddCatForm.submit();\"";
         $application->registerAttributes($this->_Template_Contents);
         $level1_template_contents["Images"] .= $this->mTmplFiller->fill("catalog/add_cat/", "image_delete.small.tpl.html", array());
     } else {
         $this->_Template_Contents["ImageTitle"] = $obj->getMessage(new ActionMessage('CAT_SMLIMG_NAME'));
         $this->_Template_Contents["ImageViewTag"] = "SmallImage";
         $this->_Template_Contents["InputField"] = $HtmlForm1->genInputFileName("SmallImage", 65);
         $pi_settings = modApiFunc('Product_Images', 'getSettings');
         $this->_Template_Contents["ImageHint"] = isset($pi_settings['AUTO_GEN_CAT_SMALL_IMAGE']) && $pi_settings['AUTO_GEN_CAT_SMALL_IMAGE'] == 'Y' && function_exists('gd_info') ? $obj->getMessage(new ActionMessage('CAT_SMLIMG_HINT')) : '';
         //: move code to HtmlForm
         if (modApiFunc("Catalog", "isImageFolderNotWritable")) {
             $this->_Template_Contents["InputField"] .= " disabled ";
         }
         $this->_Template_Contents["AddEditCategoryUploadImageCtrlIndex"] = "2";
         $application->registerAttributes($this->_Template_Contents);
         $level1_template_contents["Images"] .= $this->mTmplFiller->fill("catalog/add_cat/", "image_upload.item.tpl.html", array());
     }
     $level1_template_contents["ImageDescription"] = $HtmlForm1->genInputTextField("256", "ImageDescription", "70", prepareHTMLDisplay($this->POST["ImageDescriptionText"]));
     $this->_Template_Contents = $level1_template_contents;
     $application->registerAttributes($this->_Template_Contents);
     $retval .= $this->mTmplFiller->fill("catalog/add_cat/", "cat_images.tpl.html", array());
     return $retval;
 }