/** * Обработчик действия: Изменение страницы. */ function EditPage() { $row = A::$DB->getRowById($_REQUEST['id'], SECTION); if (!$row) { return false; } $_REQUEST['date'] = time(); $_REQUEST['name'] = strip_tags($_REQUEST['name']); $_REQUEST['urlname'] = getUrlName($_REQUEST['name'], $_REQUEST['urlname'], SECTION, "type='page' AND idker={$row['idker']} AND id<>" . $row['id']); $_REQUEST['keywords'] = getkeywords($_REQUEST['content']); $_REQUEST['description'] = truncate($_REQUEST['content'], 350); $_REQUEST["template"] = preg_replace("/[^a-zA-Z0-9._-]+/i", "", $_REQUEST["template"]); $_REQUEST['active'] = isset($_REQUEST['active']) ? 'Y' : 'N'; $_REQUEST['inmap'] = isset($_REQUEST['inmap']) ? 'Y' : 'N'; $dataset = new A_DataSet(SECTION, true); $dataset->fields = array("date", "name", "urlname", "keywords", "description", "content", "tags", "template", "active", "inmap"); if ($row = $dataset->Update()) { $name = getTreePath(SECTION, $row['level'] == 0 || $row['urlname'] != 'index' ? $row['id'] : $row['idker'], " - "); if ($_REQUEST['active'] == 'Y') { A::$OBSERVER->Event('searchIndexUpdate', SECTION, array('id' => $row['id'], 'name' => $name, 'content' => $_REQUEST['content'], 'tags' => $_REQUEST['tags'])); } else { A::$OBSERVER->Event('searchIndexDelete', SECTION, array('id' => $row['id'])); } if (!empty($_REQUEST["template"])) { copyfile("modules/pages/templates/default/pages_page.tpl", "templates/" . DOMAIN . "/" . $_REQUEST["template"]); } while ($row['idker']) { if ($row = A::$DB->getRowById($row['idker'], SECTION)) { A::$DB->Update(SECTION, array('date' => $_REQUEST['date']), "id=" . $row['id']); } } return true; } else { return false; } }
/** * Обработчик действия: Изменение товара. */ function EditItem() { $_REQUEST['date'] = time(); $_REQUEST['name'] = strip_tags($_REQUEST['name']); $_REQUEST['idcat'] = (int) $_REQUEST['idcat']; $_REQUEST['idcat1'] = isset($_REQUEST['idcat1']) ? (int) $_REQUEST['idcat1'] : 0; $_REQUEST['idcat2'] = isset($_REQUEST['idcat2']) ? (int) $_REQUEST['idcat2'] : 0; $_REQUEST['art'] = trim($_REQUEST['art']); if (!empty($_REQUEST['art']) && A::$DB->existsRow("SELECT id FROM " . SECTION . "_catalog WHERE art=? AND id<>" . (int) $_REQUEST['id'], $_REQUEST['art'])) { $this->errors['doubleart'] = true; return false; } if (empty($_REQUEST['urlname']) && !empty(A::$OPTIONS['idrule'])) { $data = $_REQUEST; prepareValues(SECTION, $data); $litems = array(); $idrule = A::$OPTIONS['idrule']; $idrule = explode("+", $idrule); foreach ($idrule as $fname) { if (!empty($data[$fname])) { $litems[] = getURLName($data[$fname]); } } $_REQUEST['urlname'] = implode(!empty($GLOBALS['A_URL_SEPARATOR']) ? $GLOBALS['A_URL_SEPARATOR'] : "_", $litems); } $_REQUEST['urlname'] = getURLName($_REQUEST['name'], $_REQUEST['urlname'], SECTION . "_catalog", "idcat=" . (int) $_REQUEST['idcat'] . " AND id<>" . (int) $_REQUEST['id']); $_REQUEST['price'] = (double) str_replace(',', '.', $_REQUEST['price']); $_REQUEST['oldprice'] = (double) str_replace(',', '.', $_REQUEST['oldprice']); $_REQUEST['iscount'] = (int) $_REQUEST['iscount']; $_REQUEST['active'] = isset($_REQUEST['active']) ? "Y" : "N"; $_REQUEST['favorite'] = isset($_REQUEST['favorite']) ? "Y" : "N"; $_REQUEST['new'] = isset($_REQUEST['new']) ? "Y" : "N"; $_REQUEST['keywords'] = getkeywords($_REQUEST['content']); if (A::$OPTIONS['autoanons']) { $_REQUEST['description'] = truncate($_REQUEST['content'], A::$OPTIONS['anonslen']); } $dataset = new A_DataSet(SECTION . "_catalog", true); $dataset->fields = array("idcat", "idcat1", "idcat2", "name", "art", "tags", "urlname", "description", "keywords", "content", "price", "oldprice", "iscount", "favorite", "new", "active"); if (A::$OPTIONS['modprices']) { $mprices = array(); for ($i = 1; $i <= 10; $i++) { if (!empty($_REQUEST["mprice{$i}_text"]) && !empty($_REQUEST["mprice{$i}_price"])) { $mprices[] = array('name' => $_REQUEST["mprice{$i}_text"], 'price' => (double) $_REQUEST["mprice{$i}_price"]); } } if (count($mprices) > 0) { $_REQUEST['price'] = $mprices[0]['price']; $_REQUEST['mprices'] = serialize($mprices); } else { $_REQUEST['mprices'] = ""; } $dataset->fields[] = 'mprices'; } if ($row = $dataset->Update()) { $path = getTreePath(SECTION . "_categories", $_REQUEST['idcat'], " - "); $name = !empty($path) ? $path . ' - ' . $_REQUEST['name'] : $_REQUEST['name']; if ($_REQUEST['active'] == 'Y') { A::$OBSERVER->Event('searchIndexUpdate', SECTION, array('id' => $row['id'], 'name' => $name, 'content' => $_REQUEST['content'], 'tags' => $_REQUEST['tags'])); } else { A::$OBSERVER->Event('searchIndexDelete', SECTION, array('id' => $row['id'])); } if ($_REQUEST['idcat'] != $row['idcat']) { self::updateCategoryItems($_REQUEST['idcat']); self::updateCategoryItems($row['idcat']); } if ($_REQUEST['idcat1'] != $row['idcat1']) { self::updateCategoryItems($_REQUEST['idcat1']); self::updateCategoryItems($row['idcat1']); } if ($_REQUEST['idcat2'] != $row['idcat2']) { self::updateCategoryItems($_REQUEST['idcat2']); self::updateCategoryItems($row['idcat2']); } unset($_POST['idcat']); return true; } else { return false; } }
/** * Обработчик действия: Изменение записи. */ function EditItem() { $_REQUEST['name'] = strip_tags($_REQUEST['name']); $_REQUEST['idcat'] = (int) $_REQUEST['idcat']; $_REQUEST['urlname'] = getURLName($_REQUEST['name'], $_REQUEST['urlname'], SECTION . "_catalog", "idcat=" . (int) $_REQUEST['idcat'] . " AND id<>" . (int) $_REQUEST['id']); $_REQUEST['active'] = isset($_REQUEST['active']) ? "Y" : "N"; $_REQUEST['keywords'] = getkeywords($_REQUEST['content']); if (A::$OPTIONS['autoanons']) { $_REQUEST['description'] = truncate($_REQUEST['content'], A::$OPTIONS['anonslen']); } if (!A::$OPTIONS['usedate']) { $_REQUEST['date'] = time(); } $_REQUEST['mdate'] = time(); $dataset = new A_DataSet(SECTION . "_catalog", true); $dataset->fields = array("date", "mdate", "idcat", "name", "urlname", "description", "keywords", "content", "tags", "active"); if ($row = $dataset->Update()) { if ($_REQUEST['active'] == 'Y') { $path = getTreePath(SECTION . "_categories", $_REQUEST['idcat'], " - "); $name = !empty($path) ? $path . ' - ' . $_REQUEST['name'] : $_REQUEST['name']; A::$OBSERVER->Event('searchIndexUpdate', SECTION, array('id' => $row['id'], 'name' => $name, 'content' => $_REQUEST['content'], 'tags' => $_REQUEST['tags'])); } else { A::$OBSERVER->Event('searchIndexDelete', SECTION, array('id' => $row['id'])); } if ($_REQUEST['idcat'] != $row['idcat']) { self::updateCategoryItems($_REQUEST['idcat']); self::updateCategoryItems($row['idcat']); } unset($_POST['idcat']); return true; } else { return false; } }