/** * Edit the product - shows the edit form * * @return html Full page edit form */ function editForm() { $cat_id = (int) $this->request('cat_id'); if ($cat_id) { $this->setVar('cat_id', $cat_id); $model = rad_instances::get('model_coremenus_tree'); $model->setState('pid', $this->request('pid', $this->_pid))->setState('lang', $this->getContentLangID()); $this->setVar('trees', $model->getItems(true)); $model->setState('pid', $this->_pid_types); $producttypes = $model->getItems(true); $firest_el = new struct_coremenus_tree(); $firest_el->tre_name = $this->lang('-pleaseselect'); array_unshift($producttypes, $firest_el); $this->setVar('producttypes', $producttypes); $this->setVar('currencys', rad_instances::get('model_corecatalog_currency')->getItems()); /** FOR MEASUREMENT IN RIGHT PANEL WHITCH NAMED "MAGAZINE" $model = new model_core_table('measurement','corecatalog'); $model->setState('order by','ms_position,ms_value'); $measurements = $model->getItems(); $this->setVar( 'measurements', $measurements ); */ $model_product = rad_instances::get('model_corecatalog_catalog'); if ($this->_have_downloads) { $model_product->setState('with_download_files', true); } if ($this->_have_tags) { $model_product->setState('with_tags', true); } $product = $model_product->getItem($cat_id); $this->addBC('product', $product->cat_name); $model->clearState(); $tree_link = $this->product ? $this->product->tree_link : $product->tree_catin_link; if (count($tree_link)) { $curr_cat = $model->getItem($tree_link[0]->cit_tre_id); $this->addBC('curr_cat', $curr_cat); $cat_path = $model->getCategoryPath($curr_cat, $this->_pid, 0); unset($cat_path[0]); $this->addBC('parents', $cat_path); $mas = array(); foreach ($tree_link as $id) { $mas[] = $id->cit_tre_id; } $this->setVar('selected_tree', $mas); } //if count catin_link $model = rad_instances::get('model_corecatalog_brands'); $this->setVar('brands', $model->getListBrands()); $this->setVar('product', $product); $this->setVar('cleanurl_enabled', rad_config::getParam('cleanurl.on')); if ($cat_id && rad_config::getParam('cleanurl.on')) { $this->setVar('url_alias', rad_cleanurl::getAlias('product', $cat_id)); } include_once 'helpers' . DS . 'fileuploader.php'; $uploader = new fileuploader($this); $imageWidgets = array($uploader->initWidget('images', array(), '', CORECATALOG_IMG_PATH, 'catalog', true)); $this->setVar('widgets', $imageWidgets); $this->get3DBinItems($cat_id); } else { //if $cat_id $this->securityHoleAlert(__FILE__, __LINE__, $this->getClassName()); } }
/** * Makes the url from standart params * @param string $context * @param bool $url_aliases_enabled * @return string * @example makeURL('alias=index.html&page=2&itemsperpage=10&category=754') */ public static function makeURL($context, $url_aliases_enabled = false) { static $alias_plugins = null; static $search = null; static $replace = null; if (!$alias_plugins) { $alias_plugins = rad_loader::getAliasInputClasses(); } if (!$search) { $search = array('SITE_URL'); $replace = array(SITE_URL); if (defined('SITE_ALIAS')) { $search[] = 'SITE_ALIAS'; $replace[] = SITE_ALIAS; } } $c = str_replace($search, $replace, $context); if (is_link_external($c)) { return $c; } $r = strstr($c, '?'); if ($r) { $c = substr($r, 1); } $r = explode('&', $c); $get = array(); foreach ($r as $id) { $r1 = explode('=', $id); if (count($r1) >= 2) { $get[$r1[0]] = $r1[1]; } else { $get[$r1[0]] = ''; } } if (!isset($get['alias'])) { $get['alias'] = SITE_ALIAS; } if ($url_aliases_enabled && rad_config::getParam('cleanurl.on')) { if ($alias = rad_cleanurl::getAliasByParams($get)) { return SITE_URL . $alias; } } if (isset($alias_plugins[$get['alias']])) { $model = rad_instances::get($alias_plugins[$get['alias']]); $string = $model->makeurl($get); } else { if ((!count($get) or count($get) == 1 and isset($get['alias'])) and trim($get['alias']) == rad_config::getParam('defaultAlias')) { $string = SITE_URL; } else { if (rad_config::getParam('lang.location_show')) { $string = SITE_URL . rad_lang::getCurrentLanguage() . '/' . $get['alias'] . '/'; } else { $string = SITE_URL . $get['alias'] . '/'; } if (strlen($context)) { foreach ($get as $prmname => $prmvalue) { if ($prmname != 'alias') { $string .= $prmname . '/' . $prmvalue . '/'; } } if (strpos($prmvalue, '.')) { if ($string[strlen($string) - 1] == '/') { $string = substr($string, 0, -1); } } } } } return $string; }
/** * Deletes the product and all it entries and files from DB and FS * * @param integer $id * @return number of deleted entries */ function deleteProductById($id = '') { if ((int) $id) { $itemCat = new struct_corecatalog_catalog(array('cat_id' => $id)); $itemCat->load(); rad_instances::get('model_core_image')->deleteItemsByCat($id); $modelTags = rad_instances::get('model_coreresource_tags')->setState('tag_type', 'product'); $modelTags->deleteTagsInItem($id); $res = $this->query('DELETE FROM ' . RAD . 'cat_in_tree where cit_cat_id=?', array($id)); $res += $this->query('DELETE FROM ' . RAD . 'cat_special where cs_catid=?', array($id)); $res += $this->query('DELETE FROM ' . RAD . 'cat_val_values where vv_cat_id=?', array($id)); $res += $this->query('DELETE FROM ' . RAD . 'cat_files where rcf_cat_id=?', array($id)); //DELETE COMMENTS $itemsComments = rad_instances::get('model_coreresource_comments')->setState('rcm_type', model_coreresource_comments::TYPE_PRODUCT)->setState('item_id', $id)->getItems(); if (!empty($itemsComments)) { foreach ($itemsComments as $itemComment) { $res += $itemComment->remove(); } } $res += $itemCat->remove(); rad_cleanurl::removeAlias('product', $id); return $res; } }