public function _CommitCategory($CatID = 0)
 {
     include_once ISC_BASE_PATH . '/lib/api/category.api.php';
     /**
      * Set this here are the images are going to be handled outside the API
      */
     $_POST['catimagefile'] = '';
     $_POST['cathoverimagefile'] = '';
     $category = new API_CATEGORY();
     if (isset($_POST["wysiwyg_html"])) {
         $_POST['catdesc'] = ISC_ADMIN_PRODUCT::FormatWYSIWYGHTML($_POST['wysiwyg_html']);
     } elseif (isset($_POST["wysiwyg"])) {
         $_POST['catdesc'] = ISC_ADMIN_PRODUCT::FormatWYSIWYGHTML($_POST['wysiwyg']);
     }
     if (isset($_POST["wysiwyg1"])) {
         $_POST['categoryfooter'] = ISC_ADMIN_PRODUCT::FormatWYSIWYGHTML($_POST['wysiwyg1']);
         # Baskaran
     }
     if (isset($_POST["wysiwyg2"])) {
         $_POST['featurepoints'] = ISC_ADMIN_PRODUCT::FormatWYSIWYGHTML($_POST['wysiwyg2']);
         # vikas
     }
     if (isset($_POST["wysiwyg3"])) {
         $_POST['divdesc'] = ISC_ADMIN_PRODUCT::FormatWYSIWYGHTML($_POST['wysiwyg3']);
         # vikas
     }
     //wirror_20100810: store the two new fields into category table
     $_POST['customcontentid'] = $_POST['customContentId'];
     $_POST['pagecontenttype'] = $_POST['catpagecontent'];
     if ($CatID == 0) {
         $CatID = $category->create();
         if ($CatID) {
             $GLOBALS['NewCategoryId'] = $CatID;
         }
     } else {
         $category->load($CatID);
         $category->save();
     }
     /* Baskaran Added for combine */
     $rowcat = $GLOBALS["ISC_CLASS_DB"]->Fetch($GLOBALS["ISC_CLASS_DB"]->Query("SELECT * FROM [|PREFIX|]categories WHERE categoryid='" . (int) $CatID . "'"));
     $parentid = $rowcat['catparentid'];
     if ($parentid != 0) {
         $maincat = $GLOBALS["ISC_CLASS_DB"]->Fetch($GLOBALS["ISC_CLASS_DB"]->Query("SELECT * FROM [|PREFIX|]categories WHERE categoryid='" . (int) $parentid . "'"));
         $subcat = strtolower($rowcat['catname']);
         $cat = strtolower($maincat['catname']);
         $FolderName = $cat;
         $catcombine = '';
         if ($rowcat['catcombine'] == '' or empty($rowcat['catcombine'])) {
             $sc = explode(" ", $subcat);
             //process 1
             foreach ($sc as $value) {
                 $cat = str_ireplace($value, " ", $cat);
             }
             $c = str_word_count($cat, 1);
             foreach ($c as $value) {
                 $subcat = str_ireplace($value . "s", " ", $subcat);
                 $subcat = str_ireplace($value . "es", " ", $subcat);
             }
             if (trim($cat) == "s" || trim($cat) == "S") {
                 $cat = "";
             }
             $catcombine = ucwords(trim($subcat . " " . $cat));
         } else {
             $catcombine = $rowcat['catcombine'];
         }
         $GLOBALS["ISC_CLASS_DB"]->UpdateQuery('categories', array('catcombine' => $catcombine), "categoryid='" . (int) $CatID . "'");
     } else {
         $FolderName = $_POST['catname'];
     }
     /* Baskaran Ends */
     /**
      * Do all the image stuff outside the API
      */
     if (isId($CatID) && array_key_exists('catimagefile', $_FILES)) {
         $FolderName = preg_replace("#[^\\w.]#i", "", $FolderName);
         $FolderName = strtolower($FolderName);
         if ($file = $this->SaveCategoryImage($FolderName)) {
             $row = $GLOBALS["ISC_CLASS_DB"]->Fetch($GLOBALS["ISC_CLASS_DB"]->Query("SELECT * FROM [|PREFIX|]categories WHERE categoryid='" . (int) $CatID . "'"));
             if (!isset($GLOBALS['NewCategoryId']) && $row['catimagefile'] !== '') {
                 $this->DelCategoryImage($row['catimagefile']);
             }
             $GLOBALS["ISC_CLASS_DB"]->UpdateQuery('categories', array('catimagefile' => $file), "categoryid='" . (int) $CatID . "'");
         }
     }
     if (isId($CatID) && array_key_exists('catimagedel', $_REQUEST) && $_REQUEST['catimagedel']) {
         $row = $GLOBALS["ISC_CLASS_DB"]->Fetch($GLOBALS["ISC_CLASS_DB"]->Query("SELECT * FROM [|PREFIX|]categories WHERE categoryid='" . (int) $CatID . "'"));
         if ($row && $row['catimagefile'] !== '') {
             $this->DelCategoryImage($row['catimagefile']);
         }
         $GLOBALS["ISC_CLASS_DB"]->UpdateQuery('categories', array('catimagefile' => ''), "categoryid='" . (int) $CatID . "'");
     }
     /*
     	Added the below code to upload large hover image. - starts - vikas
     */
     if (isId($CatID) && array_key_exists('cathoverimagefile', $_FILES)) {
         $FolderName = preg_replace("#[^\\w.]#i", "", $FolderName);
         $FolderName = strtolower($FolderName);
         if ($file = $this->SaveCategoryHoverImage($FolderName)) {
             $row = $GLOBALS["ISC_CLASS_DB"]->Fetch($GLOBALS["ISC_CLASS_DB"]->Query("SELECT * FROM [|PREFIX|]categories WHERE categoryid='" . (int) $CatID . "'"));
             if (!isset($GLOBALS['NewCategoryId']) && $row['cathoverimagefile'] !== '') {
                 $this->DelCategoryHoverImage($row['cathoverimagefile']);
             }
             $GLOBALS["ISC_CLASS_DB"]->UpdateQuery('categories', array('cathoverimagefile' => $file), "categoryid='" . (int) $CatID . "'");
         }
     }
     if (isId($CatID) && array_key_exists('catimagedel', $_REQUEST) && $_REQUEST['catimagedel']) {
         $row = $GLOBALS["ISC_CLASS_DB"]->Fetch($GLOBALS["ISC_CLASS_DB"]->Query("SELECT * FROM [|PREFIX|]categories WHERE categoryid='" . (int) $CatID . "'"));
         if ($row && $row['cathoverimagefile'] !== '') {
             $this->DelCategoryHoverImage($row['cathoverimagefile']);
         }
         $GLOBALS["ISC_CLASS_DB"]->UpdateQuery('categories', array('cathoverimagefile' => ''), "categoryid='" . (int) $CatID . "'");
     }
     /* ------- ends -------- */
     if (isId($CatID)) {
         $this->UpdateAssociations($CatID);
     }
     return $category->error;
 }
 /**
  * Allow the quick creation of a new category from the create product page
  *
  * @return void
  **/
 private function SaveNewQuickCategory()
 {
     include_once APP_ROOT . "/../lib/api/category.api.php";
     $_POST['catpagetitle'] = '';
     $_POST['catmetakeywords'] = '';
     $_POST['catmetadesc'] = '';
     $_POST['catlayoutfile'] = '';
     $_POST['catsort'] = 0;
     $_POST['catimagefile'] = '';
     $category = new API_CATEGORY();
     $CatID = $category->create();
     if ($category->error) {
         $tags[] = $this->MakeXMLTag('status', 0);
         $tags[] = $this->MakeXMLTag('message', $category->error, true);
     } else {
         $tags[] = $this->MakeXMLTag('status', 1);
         // Log this action
         $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($CatID, $_POST['catname']);
         if (isset($_POST['selectedcats']) && is_array($_POST['selectedcats'])) {
             array_walk($_POST['selectedcats'], 'intval');
         } else {
             $_POST['selectedcats'] = array();
         }
         $_POST['selectedcats'][] = $CatID;
         $selectedCategories = $_POST['selectedcats'];
         require_once dirname(__FILE__) . "/class.category.php";
         $GLOBALS['ISC_CLASS_ADMIN_CATEGORY'] = GetClass('ISC_ADMIN_CATEGORY');
         $categories = sprintf("<select size=\"5\" id=\"category\" name=\"category[]\" class=\"Field400 ISSelectReplacement\" style=\"height:140px;\" multiple>%s</select>", $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptions($selectedCategories, "<option %s value='%d'>%s</option>", 'selected="selected"', "", false));
         $tags[] = $this->MakeXMLTag('catid', $CatID, true);
         $tags[] = $this->MakeXMLTag('categories', $categories, true);
     }
     $this->SendXMLHeader();
     $this->SendXMLResponse($tags);
     exit;
 }