Beispiel #1
0
		public function _CommitCategory($catID = 0, $updateCache = true)
		{
			if (isId($catID)) {
				$this->categoryAPI->load($catID);
			}

			// Handle the image first
			$catData = $this->_GetCatData(ISC_SOURCE_FORM);
			$catImage = $this->categoryAPI->catimagefile;

			if ($this->categoryAPI->catimagefile !== '') {

				// Are we deleting the existing image?
				if (array_key_exists('delcatimagefile', $_POST) && $_POST['delcatimagefile']) {
					$this->DelCategoryImage($this->categoryAPI->catimagefile);
					$catImage = '';
				}

				// Also forcefully delete the image if it is a root category
				if ($catData['category'] == "0") {
					$this->DelCategoryImage($this->categoryAPI->catimagefile);
					$catImage = '';
				}

				// Delete the image if we do uncheck the image selection.
				if (empty ($_POST['YesUseImage'])) {
					$this->DelCategoryImage($this->categoryAPI->catimagefile);
					$catImage = '';
				}
			}

			// Saving a new image
			if (array_key_exists('catimagefile', $_FILES) && (int)$_FILES['catimagefile']['error'] == 0 && !empty ($_POST['YesUseImage'])) {

				// Delete the old image if we are uploading a new one
				if ($this->categoryAPI->catimagefile !== '') {
					$this->DelCategoryImage($this->categoryAPI->catimagefile);
				}

				$catImage = $this->SaveCategoryImage();
			}

			$_POST['catimagefile'] = $catImage;

			// Clean up the description
			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["catenableoptimizer"])) {
				$_POST['cat_enable_optimizer'] = 1;
			}
			else {
				$_POST['cat_enable_optimizer'] = 0;
			}

			// Now we save using the API
			if (!isId($catID)) {
				$catID = $this->categoryAPI->create($updateCache);
				if($catID) {
					$GLOBALS['NewCategoryId'] = $catID;
				}
			} else {
				$this->categoryAPI->save();
			}

			if(empty($this->categoryAPI->error)) {
				// Save shopping comparison category mappings
				$shoppingComparisonModules = Isc_ShoppingComparison::getModulesWithTaxonomies();
				$altCategoriesCache = (array)json_decode($this->categoryAPI->cataltcategoriescache);
				foreach($shoppingComparisonModules as $module) {
					$id = $_POST[$module->getId().'_categoryid'];
					if(isset($altCategoriesCache[$module->getId()]))
						$oldid = $altCategoriesCache[$module->getId()]->categoryid;
					else
						$oldid = '';

					if($oldid == $id)
						continue;
					else if($oldid && $id === '') {
						$module->deleteCategoryMappings($catID);
						continue;
					}
					else
					{
						//@todo: efficiency tweak - need to map multiple categories
						//in one go, rather than in seperate mapCategories calls, also
						//should not rely on the $path passed in the form.
						$path = $_POST[$module->getId().'_categorypath'];
						$module->mapCategories($catID, $id, $path);
					}
				}

				// Save optimizer settings for this category
				$optimizer = getClass('ISC_ADMIN_OPTIMIZER');
				if(isset($_POST["catenableoptimizer"])) {
					$optimizer->savePerItemOptimizerConfig('category', $catID);
				} else {
					$optimizer->deletePerItemOptimizerConfig('category', array($catID));
				}
			}

			return $this->categoryAPI->error;
		}
 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;
 }
 private function _CommitCustomProducts($ItemID = 0)
 {
     $itemdesc = '';
     if (isset($_POST["wysiwyg"])) {
         $itemdesc = ISC_ADMIN_PRODUCT::FormatWYSIWYGHTML($_POST['wysiwyg']);
     }
     $visiturl = GetConfig('ShopPath') . '/';
     if (isset($_POST["categorybox"]) && $_POST["categorybox"] != 0) {
         $visiturl .= MakeURLSafe(strtolower($_POST["categoryname"])) . '/';
     } else {
         $_POST["categoryname"] = '';
     }
     if (isset($_POST["subcategorybox"]) && $_POST["subcategorybox"] != 0) {
         $visiturl .= 'subcategory/' . MakeURLSafe(strtolower($_POST["subcategoryname"])) . '/';
     } else {
         $_POST["subcategoryname"] = '';
     }
     if (isset($_POST["brandbox"]) && $_POST["brandbox"] != 0) {
         $visiturl .= 'brand/' . MakeURLSafe(strtolower($_POST["brandname"])) . '/';
     } else {
         $_POST["brandname"] = '';
     }
     if (isset($_POST["seriesbox"]) && $_POST["seriesbox"] != 0) {
         $visiturl .= 'series/' . MakeURLSafe(strtolower($_POST["seriesname"])) . '/';
     } else {
         $_POST["seriesname"] = '';
     }
     if (isset($_POST['ISSelectReplacement_productResults']) && is_array($_POST['ISSelectReplacement_productResults'])) {
         if (count($_POST['ISSelectReplacement_productResults']) > 0) {
             $productIds = implode(',', $_POST['ISSelectReplacement_productResults']);
         } else {
             $productIds = '-1';
         }
     } else {
         $productIds = '0';
     }
     $enabled = $_POST["enabled"] == 'on' ? true : false;
     $customItem = array('pageid' => (int) $_POST['pid'], 'itemtitle' => $_POST['itemTitle'], 'productids' => $productIds, 'description' => $itemdesc, 'enabled' => $enabled, 'contentid' => $_POST['contentId'], 'visiturl' => $visiturl, 'catename' => $_POST["categoryname"], 'subcatename' => $_POST["subcategoryname"], 'brandname' => $_POST["brandname"], 'seriesname' => $_POST["seriesname"], 'categoryid' => $_POST["categorybox"], 'subcategoryid' => $_POST["subcategorybox"], 'brandid' => $_POST["brandbox"], 'seriesid' => $_POST["seriesbox"]);
     if ($ItemID == 0) {
         $ItemID = $this->createCustomProducts($customItem);
         if ($ItemID) {
             $GLOBALS['NewComtentPageId'] = $ItemID;
         }
     } else {
         $this->updateCustomProducts($ItemID, $customItem);
     }
     return true;
 }