private function EditCategory()
 {
     $GLOBALS['Message'] = GetFlashMessageBoxes();
     if (isset($_GET['catId'])) {
         $catId = (int) $_GET['catId'];
         include_once ISC_BASE_PATH . '/lib/api/category.api.php';
         $category = new API_CATEGORY();
         $category->load($catId);
         //wirror_20100804: remove the cookie CustomContentId, and fetch current CustomContentId from table category
         if ($category->customcontentid != 0) {
             $contentId = isc_html_escape($category->customcontentid);
         } else {
             if (isset($_COOKIE['CustomContentId']) && is_numeric($_COOKIE['CustomContentId'])) {
                 $contentId = $_COOKIE['CustomContentId'];
             } else {
                 $customItem = array('contenttype' => 1, 'description' => "custom products content for category#{$catId}");
                 $contentId = GetClass('ISC_ADMIN_CUSTOMCONTENTS')->createCustomContens($customItem);
             }
         }
         setcookie("CustomContentId", $contentId, time() + 3600);
         //wirror_20100806: show the custom content options
         $GLOBALS['ContentOptions'] = $this->_GetContentTypeOptions($category->pagecontenttype);
         $GLOBALS['CustomPageAction'] = "listCateCustomcontents&customContentId={$contentId}&catId={$catId}";
         $GLOBALS['CategoryName'] = isc_html_escape($category->catname);
         $GLOBALS['CategoryOptions'] = $this->GetCategoryParentOptions($catId, array($category->catparentid));
         $GLOBALS['CategorySort'] = isc_html_escape($category->catsort);
         $GLOBALS['CategoryPageTitle'] = isc_html_escape($category->catpagetitle);
         $GLOBALS['CategoryMetaKeywords'] = isc_html_escape($category->catmetakeywords);
         $GLOBALS['CategoryMetaDesc'] = isc_html_escape($category->catmetadesc);
         $GLOBALS['CatDepartment'] = $this->getDepartment($category->catdeptid);
         $GLOBALS['AltKeyword'] = isc_html_escape($category->cataltkeyword);
         $GLOBALS['catcombine'] = isc_html_escape($category->catcombine);
         $GLOBALS['CatDeptid'] = isc_html_escape($category->catdeptid);
         $GLOBALS['StartPrice'] = isc_html_escape($category->StartPrice);
         $GLOBALS['EndPrice'] = isc_html_escape($category->EndPrice);
         $GLOBALS['CatImageAlt'] = isc_html_escape($category->catimagealt);
         if (strtolower($category->displayproducts) == 'on') {
             $GLOBALS['DisplayProducts'] = 'checked="checked"';
         }
         $GLOBALS['CategorySelect'] = '<input type="hidden" name="catparentid" id="catparentid" value="' . $category->catparentid . '">
             <select size="5" name="catparent_id" id="catparent_id" class="Field750" style="height:115" onchange="HandleRootCategory();SelectDept();" disabled="disabled">';
         # Added because when we disable the category list, id cant be get while saving, so hidden field is added and the id is changed to catparentid. -- Baskaran
         $temp = '';
         $pnamearray = array('Category Name', 'Sub Category Name', 'Brand Name', 'Series Name', 'Part Number', 'Product Code', 'Product color', 'Product Material', 'Product Style');
         $savedarray = explode(",", $category->Productname);
         foreach ($pnamearray as $key => $value) {
             if (in_array($key, $savedarray)) {
                 $temp .= "<option  value='" . $key . "' selected='selected' >" . $value . "</option>";
             } else {
                 $temp .= "<option  value='" . $key . "' >" . $value . "</option>";
             }
         }
         $GLOBALS['Productname'] = $temp;
         $congocatname = '';
         if ($category->catparentid == 0) {
             $space1 = str_replace(" ", "", isc_html_escape($category->catname));
             $hypen1 = str_replace("-", "", $space1);
             $amp1 = str_replace("&", "", $hypen1);
             $slash1 = str_replace("/", "", $amp1);
             $congocatname = str_replace(",", "", $slash1);
         } else {
             $query = "SELECT * from [|PREFIX|]categories where categoryid = {$category->catparentid}";
             $result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
             $row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result);
             $space2 = str_replace(" ", "", $row['catname']);
             $hypen2 = str_replace("-", "", $space2);
             $amp2 = str_replace("&", "", $hypen2);
             $slash2 = str_replace("/", "", $amp2);
             $congocatname = str_replace(",", "", $slash2);
         }
         $_SESSION['congocatname'] = $congocatname;
         $wysiwygOptions = array('id' => 'wysiwyg', 'width' => '750px', 'height' => '500px', 'value' => $category->catdesc);
         $wysiwygOptions1 = array('id' => 'wysiwyg1', 'width' => '60%', 'height' => '300px', 'value' => $category->categoryfooter);
         $wysiwygOptions2 = array('id' => 'wysiwyg2', 'width' => '60%', 'height' => '300px', 'value' => $category->featurepoints);
         $wysiwygOptions3 = array('id' => 'wysiwyg3', 'width' => '60%', 'height' => '300px', 'value' => $category->divdesc);
         $GLOBALS['WYSIWYG'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor($wysiwygOptions);
         $GLOBALS['WYSIWYG1'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor1($wysiwygOptions1);
         $GLOBALS['WYSIWYG2'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor1($wysiwygOptions2);
         $GLOBALS['WYSIWYG3'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor1($wysiwygOptions3);
         $GLOBALS['ControlScript'] = $category->controlscript;
         $GLOBALS['TrackingScript'] = $category->trackingscript;
         $GLOBALS['FormAction'] = "saveUpdatedCategory";
         $GLOBALS['CatTitle'] = GetLang('EditCatTitle');
         $GLOBALS['CatIntro'] = GetLang('EditCatIntro');
         $GLOBALS['CancelMessage'] = GetLang('CancelEditCategory');
         $GLOBALS['hiddenFields'] = sprintf("<input type='hidden' name='categoryId' value='%d'>", $catId);
         #wirror_20100805: hide the custom content id
         $GLOBALS['hiddenFields'] .= sprintf("<input type='hidden' name='customContentId' value='%d'>", $contentId);
         if ($category->catparentid == '0') {
             //$GLOBALS['DisableFileUpload'] = 'disabled="disabled"';
             $GLOBALS['ShowFileUploadMessage'] = '';
             $GLOBALS['ShowHidecatCombine'] = 'none';
             $GLOBALS['disabledept'] = '';
         } else {
             //$GLOBALS['DisableFileUpload'] = '';
             $GLOBALS['ShowFileUploadMessage'] = 'none';
             $GLOBALS['ShowHidecatCombine'] = '';
             $GLOBALS['disabledept'] = 'disabled="disabled"';
         }
         // Get a list of all layout files
         $layoutFile = 'category.html';
         if ($category->catlayoutfile != '') {
             $layoutFile = $category->catlayoutfile;
         }
         $GLOBALS['LayoutFiles'] = GetCustomLayoutFilesAsOptions("category.html", $layoutFile);
         $GLOBALS["CatImageMessage"] = '';
         if ($category->catimagefile !== '') {
             $image = '../' . 'category_images' . '/' . $category->catimagefile;
             $GLOBALS["CatImageMessage"] = sprintf(GetLang('CatImageDesc'), $image, $category->catimagefile);
         }
         $GLOBALS["CatHoverImageMessage"] = '';
         if ($category->cathoverimagefile !== '') {
             $image = '../' . 'category_images' . '/' . $category->cathoverimagefile;
             $GLOBALS["CatHoverImageMessage"] = sprintf(GetLang('CatHoverImageDesc'), $image, $category->cathoverimagefile);
         }
         $SelectedQualifiers = $this->GetSelectedQualifiers($catId);
         $GLOBALS['QualifierOptions'] = $this->GetQualifierOptions($SelectedQualifiers, "<option %s value='%d'>%s</option>", "selected=\"selected\"", "", false);
         $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndContinueEditing');
         $GLOBALS["ISC_CLASS_TEMPLATE"]->SetTemplate("category.form");
         $GLOBALS["ISC_CLASS_TEMPLATE"]->ParseTemplate();
     } else {
         if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Categories)) {
             $this->ManageCategories();
         } else {
             $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR);
         }
     }
 }
 private function EditCustomPage()
 {
     if (isset($_GET["itemId"])) {
         $item = $this->GetCustomItemById($_GET["itemId"]);
         if ($item != NULL) {
             $GLOBALS["FormAction"] = "updatecateabtestingcustom";
             $GLOBALS["CustomItemId"] = $_GET["itemId"];
             $GLOBALS["ContentId"] = $_GET['contentId'];
             $GLOBALS["VisitURL"] = $item['visiturl'];
             $GLOBALS["Enabled"] = $item['enabled'];
             $GLOBALS["ItemTitle"] = $item['itemtitle'];
             $categoryid = $item['categoryid'];
             $catename = $item['catename'];
             $subcategoryid = $item['subcategoryid'];
             $subcatename = $item['subcatename'];
             $brandid = $item['brandid'];
             $brandname = $item['brandname'];
             $seriesid = $item['seriesid'];
             $seriesname = $item['seriesname'];
             $GLOBALS["CatId"] = $categoryid;
             $GLOBALS["SubCatId"] = $subcategoryid;
             $GLOBALS["BrandId"] = $brandid;
             $GLOBALS["SeriesId"] = $seriesid;
             $GLOBALS["PageId"] = isset($_GET["pid"]) ? (int) $_GET["pid"] : 0;
             //wirror_20100728: add a html editor for the item products on edit category
             $wysiwygOptions = array('id' => 'wysiwyg', 'width' => '750px', 'height' => '500px', 'value' => $item['description']);
             $GLOBALS['WYSIWYG'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor($wysiwygOptions);
             $GLOBALS['ISC_CLASS_ADMIN_CATEGORIES'] = GetClass('ISC_ADMIN_CATEGORY');
             include_once ISC_BASE_PATH . '/lib/api/category.api.php';
             $category = new API_CATEGORY();
             $category->load($categoryid);
             $GLOBALS['RootCategoryOptions'] = sprintf("<option %s value='%d'>%s</option>", 'readonly', $category->categoryid, $category->catname);
             //$GLOBALS['ISC_CLASS_ADMIN_CATEGORIES']->GetFlatCategories($categoryid, "<option %s value='%d'>%s</option>", "selected=\"selected\"", 0);
             $GLOBALS['SubCategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORIES']->GetFlatCategories(0, "<option %s value='%d'>%s</option>", "selected=\"selected\"", $category->categoryid);
             $GLOBALS['ISC_CLASS_ADMIN_BRANDS'] = GetClass('ISC_ADMIN_BRANDS');
             $GLOBALS['BrandNameOptions'] = $GLOBALS["ISC_CLASS_ADMIN_BRANDS"]->GetBrandOptions(array($brandid), "<option %s value='%d'>%s</option>", 'selected="selected"', " ", false);
             //$GLOBALS['SubCategoryOptions'] = $subcatename == NULL ? "" : "<option value=\"$subcategoryid\" selected=\"selected\">$subcatename</option>";
             //$GLOBALS['SeriesNameOptions'] = $seriesname == NULL ? "" : "<option value=\"$seriesid\" selected=\"selected\">$seriesname</option>";
             $_GET['category'] = $categoryid;
             $_GET['subscategory'] = $subcategoryid;
             $_GET['brand'] = $brandid;
             $_GET['series'] = $seriesid;
             $GLOBALS['ProductResults'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORIES']->GetProductOptions(explode(',', $item['productids']), "<option %s value='%d'>%s</option>", 'selected="selected"', " ", false);
             $GLOBALS['SnippetCustomPageItem'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CategoryCustomPageItem');
             $GLOBALS["ISC_CLASS_TEMPLATE"]->SetTemplate("abtesting.category.custompage");
             $GLOBALS["ISC_CLASS_TEMPLATE"]->ParseTemplate();
         }
     }
 }