Пример #1
0
 private function SaveUpdatedCategory()
 {
     $catData = $this->_GetCatData(ISC_SOURCE_FORM);
     $existingData = $this->_GetCatData(0, $catData['oldCatId']);
     //Added by Simha to check for duplication
     $query = "select COUNT(categoryid) from [|PREFIX|]categories where catname = '" . $catData['catname'] . "' and catparentid='" . $catData['category'] . "' and categoryid != '" . (int) $catData['oldCatId'] . "'";
     $result = $GLOBALS["ISC_CLASS_DB"]->Query($query);
     $cnt = $GLOBALS["ISC_CLASS_DB"]->FetchOne($result);
     //Loop for checking the duplication starts right here
     if ($cnt != 0) {
         FlashMessage(sprintf(GetLang('NameAlreadyExists'), $catData['catname']), MSG_ERROR, 'index.php?ToDo=editCategory&catId=' . (int) $catData['oldCatId']);
     } else {
         if (!$this->BrandSeriesDuplicationExists($catData['catname'])) {
             $this->UpdateAssociations($catData['oldCatId']);
             /* Baskaran added. To combine the category and subcategory if the combine name is not entered*/
             $catid = $catData['category'];
             $name_query = "SELECT * FROM [|PREFIX|]categories where categoryid = {$catid}";
             $name_result = $GLOBALS['ISC_CLASS_DB']->Query($name_query);
             $catname = '';
             while ($name_row = $GLOBALS['ISC_CLASS_DB']->Fetch($name_result)) {
                 $catname = $name_row['catname'];
                 $FolderName = $catname;
             }
             $subcat = strtolower($catData['catname']);
             $cat = strtolower($catname);
             $catcombine = '';
             if ($catData['category'] != 0 and empty($catData['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 = $catData['catcombine'];
             }
             /* Baskaran code ends */
             // Log this action
             $GLOBALS['ISC_CLASS_LOG']->LogAdminAction($catData['oldCatId'], $catData['category']);
             /* To update the combine name in the Product table for select category */
             $oldname = '';
             $combinedname = '';
             $catsubid = $catData['oldCatId'];
             $cat_query = "SELECT * FROM [|PREFIX|]categories where categoryid = {$catsubid}";
             $cat_result = $GLOBALS['ISC_CLASS_DB']->Query($cat_query);
             while ($cat_row = $GLOBALS['ISC_CLASS_DB']->Fetch($cat_result)) {
                 $oldname = $cat_row['catcombine'];
             }
             # If the combined name is empty
             if ($catData['catcombine'] == '' || empty($catData['catcombine'])) {
                 $combinedname = $catcombine;
             } else {
                 # Checking whether the combined name is changed or not
                 if ($oldname == '' || $oldname == $catData['catcombine']) {
                     $combinedname = $oldname;
                 } else {
                     # When the combined name is changed with the old one means new combined name is updated in category and related category in products table
                     $combinedname = $catData['catcombine'];
                     $updateprodname = "UPDATE [|PREFIX|]products SET prodname = REPLACE(prodname, '{$oldname}','{$combinedname}') WHERE prodcatids = {$catsubid}";
                     $GLOBALS['ISC_CLASS_DB']->Query($updateprodname);
                 }
             }
             $thriblespace = str_replace("   ", " ", $combinedname);
             $doublespace = str_replace("  ", " ", $thriblespace);
             /* Code ends */
             /* To update all the deptid of sub category when the root category deptid changed -- Baskaran */
             $catdeptid = '';
             $deptid = $catData['catdeptid'];
             $catdeptquery = $GLOBALS['ISC_CLASS_DB']->Query("SELECT catdeptid FROM [|PREFIX|]categories where categoryid = {$catsubid} and catparentid = 0");
             $catdeptrow = $GLOBALS['ISC_CLASS_DB']->Fetch($catdeptquery);
             $dbdeptid = $catdeptrow['catdeptid'];
             if ($GLOBALS["ISC_CLASS_DB"]->CountResult($catdeptquery) == 1) {
                 if ($deptid != $dbdeptid) {
                     $updatedept = array("catdeptid" => $deptid);
                     $GLOBALS['ISC_CLASS_DB']->UpdateQuery("categories", $updatedept, "catparentid={$catsubid}");
                     $catdeptid = $deptid;
                 } else {
                     $catdeptid = $catData['catdeptid'];
                 }
             } else {
                 $catdeptid = $catData['catdeptid'];
             }
             /* Code Ends */
             $updatedCategory = array("catparentid" => $catData['category'], "catname" => $catData['catname'], "catdesc" => $catData['catdesc'], "catsort" => (int) $catData['catsort'], "catpagetitle" => $catData['catpagetitle'], "catmetakeywords" => $catData['catmetakeywords'], "catmetadesc" => $catData['catmetadesc'], "catlayoutfile" => $catData['catlayoutfile'], "catdeptid" => $catdeptid, "cataltkeyword" => $catData['cataltkeyword'], "catcombine" => $doublespace, "StartPrice" => $catData['StartPrice'], "EndPrice" => $catData['EndPrice'], "Productname" => $catData['Productname'], "categoryfooter" => $catData['categoryfooter'], "controlscript" => $catData['controlscript'], "trackingscript" => $catData['trackingscript'], "catimagealt" => $catData['catimagealt'], "featurepoints" => $catData['featurepoints'], "divdesc" => $catData['divdesc'], "displayproducts" => $catData['displayproducts'], "pagecontenttype" => $catData['catpagecontent'], "customcontentid" => $catData['customContentId']);
             if ($FolderName == '') {
                 $FolderName = $catData['catname'];
             }
             $GLOBALS['ISC_CLASS_DB']->UpdateQuery("categories", $updatedCategory, "categoryid='" . $GLOBALS['ISC_CLASS_DB']->Quote((int) $catData['oldCatId']) . "'");
         } else {
             FlashMessage(sprintf(GetLang('NameAlreadyExists'), $catData['catname']), MSG_ERROR, 'index.php?ToDo=editCategory&catId=' . (int) $catData['oldCatId']);
         }
     }
     //Loop for checking the duplication ends right here
     if ($GLOBALS['ISC_CLASS_DB']->GetErrorMsg() == '') {
         $FolderName = preg_replace("#[^\\w.]#i", "", $FolderName);
         $FolderName = strtolower($FolderName);
         if (array_key_exists('delcatimagefile', $_POST) && $_POST['delcatimagefile']) {
             $this->DelCategoryImage($catData['oldCatId']);
             $GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('catimagefile' => ''), "categoryid='" . (int) $catData['oldCatId'] . "'");
         } else {
             if (array_key_exists('catimagefile', $_FILES) && ($catimagefile = $this->SaveCategoryImage($FolderName))) {
                 $GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('catimagefile' => $catimagefile), "categoryid='" . (int) $catData['oldCatId'] . "'");
             }
         }
         if (array_key_exists('delcathoverimagefile', $_POST) && $_POST['delcathoverimagefile']) {
             $this->DelCategoryHoverImage($catData['oldCatId']);
             $GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('cathoverimagefile' => ''), "categoryid='" . (int) $catData['oldCatId'] . "'");
         } else {
             if (array_key_exists('cathoverimagefile', $_FILES) && ($cathoverimagefile = $this->SaveCategoryHoverImage($FolderName))) {
                 $GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('cathoverimagefile' => $cathoverimagefile), "categoryid='" . (int) $catData['oldCatId'] . "'");
             }
         }
         /*
         				// Also forcefully delete the image if it is not a root category
         				if ($catData['category'] == "0") {
         					$this->DelCategoryImage($catData['oldCatId']);
         					$GLOBALS['ISC_CLASS_DB']->UpdateQuery('categories', array('catimagefile' => ''), "categoryid='" . (int)$catData['oldCatId'] . "'");
         				}
         */
         // If the category doesn't have a parent, rebuild the root categories cache
         $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateRootCategories();
         # Below line is left in interspire old version, from new version it has been placed -- Baskaran
         //				if($existingData['category'] != $catData['category']) {
         if ($existingData['catparentid'] != $catData['category']) {
             include_once ISC_BASE_PATH . '/lib/api/category.api.php';
             $category = new API_CATEGORY();
             // Rebuild the parent list
             $parentList = $category->BuildParentList($catData['oldCatId']);
             $updatedCategory = array("catparentlist" => $parentList);
             $GLOBALS['ISC_CLASS_DB']->UpdateQuery("categories", $updatedCategory, "categoryid='" . $GLOBALS['ISC_CLASS_DB']->Quote((int) $catData['oldCatId']) . "'");
             // Now we also need to update the parent list of all child pages for this category
             $query = sprintf("SELECT categoryid FROM [|PREFIX|]categories WHERE CONCAT(',', catparentlist, ',') LIKE '%%,%s,%%'", $GLOBALS['ISC_CLASS_DB']->Quote($catData['oldCatId']));
             $result = $GLOBALS['ISC_CLASS_DB']->Query($query);
             while ($child = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
                 $parentList = $category->BuildParentList($child['categoryid']);
                 // Update the parent list for this child
                 $updatedCategory = array("catparentlist" => $parentList);
                 $GLOBALS['ISC_CLASS_DB']->UpdateQuery("categories", $updatedCategory, "categoryid='" . $GLOBALS['ISC_CLASS_DB']->Quote($child['categoryid']) . "'");
             }
             // Rebuild the group pricing caches
             $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateCustomerGroupsCategoryDiscounts();
         }
         if (isset($_POST['AddAnother'])) {
             $location = 'index.php?ToDo=editCategory&catId=' . (int) $catData['oldCatId'];
         } else {
             $location = 'index.php?ToDo=viewCategories&deptid=' . $catdeptid;
         }
         FlashMessage(GetLang('CatUpdateSuccessfully'), MSG_SUCCESS, $location);
     } else {
         FlashMessage($GLOBALS['ISC_CLASS_DB']->GetErrorMsg(), MSG_ERROR, 'index.php?ToDo=editCategory&catId=' . (int) $catData['oldCatId']);
     }
 }
 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();
         }
     }
 }
Пример #3
0
 /**
  * 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;
 }
Пример #4
0
	public function deleteCategoryMappings($categories)
	{
		$db = $GLOBALS['ISC_CLASS_DB'];

		$taxonomyId = $db->Quote($this->getId());
		$ids = API_CATEGORY::getSubCategories($categories);

		foreach($ids as $categoryId) {
			$query = '
				DELETE FROM [|PREFIX|]]shopping_comparison_category_associations
				WHERE
					category_id='.$categoryId.' AND shopping_comparison_id="'.$taxonomyId.'";';

			$db->Query($query);

			$query = '
				SELECT cataltcategoriescache
				FROM [|PREFIX|]categories
				WHERE categoryid='.$categoryId.';';

			$cataltcategoriescache = (array)json_decode($db->FetchOne($query));
			unset($cataltcategoriescache[$taxonomyId]);

			$query = '
				UPDATE [|PREFIX|]categories
				SET
					cataltcategoriescache = "'.$db->Quote(isc_json_encode($cataltcategoriescache)).'"
				WHERE
					categoryid='.$categoryId.';';

			$db->Query($query);
		}
	}