本文整理汇总了PHP中SEOEncode函数的典型用法代码示例。如果您正苦于以下问题:PHP SEOEncode函数的具体用法?PHP SEOEncode怎么用?PHP SEOEncode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SEOEncode函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editManufacturer
/**
* @param int $manufacturer_id
* @param array $data
*/
public function editManufacturer($manufacturer_id, $data)
{
$fields = array('name', 'sort_order');
$update = array();
foreach ($fields as $f) {
if (isset($data[$f])) {
$update[] = $f . " = '" . $this->db->escape($data[$f]) . "'";
}
}
if (!empty($update)) {
$this->db->query("UPDATE " . $this->db->table("manufacturers") . " SET " . implode(',', $update) . " WHERE manufacturer_id = '" . (int) $manufacturer_id . "'");
}
if (isset($data['manufacturer_store'])) {
$this->db->query("DELETE FROM " . $this->db->table("manufacturers_to_stores") . " WHERE manufacturer_id = '" . (int) $manufacturer_id . "'");
foreach ($data['manufacturer_store'] as $store_id) {
$this->db->query("INSERT INTO " . $this->db->table("manufacturers_to_stores") . " SET manufacturer_id = '" . (int) $manufacturer_id . "', store_id = '" . (int) $store_id . "'");
}
}
if (isset($data['keyword'])) {
$data['keyword'] = SEOEncode($data['keyword'], 'manufacturer_id', $manufacturer_id);
if ($data['keyword']) {
$this->language->replaceDescriptions('url_aliases', array('query' => "manufacturer_id=" . (int) $manufacturer_id), array((int) $this->session->data['content_language_id'] => array('keyword' => $data['keyword'])));
} else {
$this->db->query("DELETE\n\t\t\t\t\t\t\t\tFROM " . $this->db->table("url_aliases") . " \n\t\t\t\t\t\t\t\tWHERE query = 'manufacturer_id=" . (int) $manufacturer_id . "'\n\t\t\t\t\t\t\t\t\tAND language_id = '" . (int) $this->session->data['content_language_id'] . "'");
}
}
$this->cache->delete('manufacturer');
}
示例2: getSeoKeyword
/**
* function for getting auto-generated unique seo keyword
*/
public function getSeoKeyword()
{
//init controller data
$this->extensions->hk_InitData($this, __FUNCTION__);
$seo_key = SEOEncode($this->request->get['seo_name'], $this->request->get['object_key_name'], (int) $this->request->get['id'], (int) $this->language->getContentLanguageID());
//update controller data
$this->extensions->hk_UpdateData($this, __FUNCTION__);
$this->response->setOutput($seo_key);
}
示例3: updateProduct
/**
* @param int $product_id
* @param array $data
*/
public function updateProduct($product_id, $data)
{
$fields = array("model", "sku", "location", "quantity", "minimum", "maximum", "subtract", "stock_status_id", "date_available", "manufacturer_id", "shipping", "ship_individually", "free_shipping", "shipping_price", "call_to_order", "price", "cost", "weight", "weight_class_id", "length", "width", "height", "length_class_id", "status", "tax_class_id", "sort_order");
$preformat_fields = array("shipping_price", "price", "cost", "weight", "length", "width", "height");
$update = array('date_modified = NOW()');
foreach ($fields as $f) {
if (isset($data[$f])) {
if (in_array($f, $preformat_fields)) {
$data[$f] = preformatFloat($data[$f], $this->language->get('decimal_point'));
}
$update[] = $f . " = '" . $this->db->escape($data[$f]) . "'";
}
}
if (!empty($update)) {
$this->db->query("UPDATE `" . $this->db->table("products`") . " SET " . implode(',', $update) . " WHERE product_id = '" . (int) $product_id . "'");
}
if (!empty($data['product_description'])) {
foreach ($data['product_description'] as $field => $value) {
$fields = array('name', 'description', 'meta_keywords', 'meta_description', 'blurb');
$update = array();
foreach ($fields as $f) {
if ($f == $field) {
$update[$f] = $value;
}
}
if (!empty($update)) {
$this->language->replaceDescriptions('product_descriptions', array('product_id' => (int) $product_id), array((int) $this->language->getContentLanguageID() => $update));
}
}
}
if (isset($data['featured'])) {
$this->setFeatured($product_id, $data['featured'] ? true : false);
}
if (isset($data['keyword'])) {
$data['keyword'] = SEOEncode($data['keyword'], 'product_id', $product_id);
if ($data['keyword']) {
$this->language->replaceDescriptions('url_aliases', array('query' => "product_id=" . (int) $product_id), array((int) $this->language->getContentLanguageID() => array('keyword' => $data['keyword'])));
} else {
$this->db->query("DELETE\n\t\t\t\t\t\t\t\tFROM " . $this->db->table("url_aliases") . " \n\t\t\t\t\t\t\t\tWHERE query = 'product_id=" . (int) $product_id . "'\n\t\t\t\t\t\t\t\t\tAND language_id = '" . (int) $this->language->getContentLanguageID() . "'");
}
}
if (isset($data['product_tags'])) {
$language_id = $this->language->getContentLanguageID();
$tags = explode(',', $data['product_tags']);
foreach ($tags as &$tag) {
$tag = $this->db->escape(trim($tag));
}
$this->language->replaceMultipleDescriptions('product_tags', array('product_id' => (int) $product_id), array((int) $language_id => array('tag' => array_unique($tags))));
}
$this->cache->remove('product');
}
示例4: isSEOkeywordExists
/**
* function returns text error or empty
* @param string $query
* @param string $keyword
* @return string
*/
public function isSEOkeywordExists($query, $keyword = '')
{
if (!$keyword) {
return '';
}
$seo_key = SEOEncode($keyword);
$db = $this->registry->get('db');
$sql = "SELECT * FROM " . DB_PREFIX . "url_aliases WHERE query<>'" . $db->escape($query) . "' AND keyword='" . $db->escape($seo_key) . "'";
$result = $db->query($sql);
if ($result->num_rows) {
$url = HTTP_CATALOG . $seo_key;
return sprintf($this->registry->get('language')->get('error_seo_keyword'), $url, $seo_key);
}
return '';
}
示例5: _getForm
private function _getForm()
{
$this->view->assign('error_warning', $this->error['warning']);
$this->view->assign('error_name', $this->error['name']);
$this->data['categories'] = $this->model_catalog_category->getCategories(0);
$categories = array(0 => $this->language->get('text_none'));
foreach ($this->data['categories'] as $c) {
$categories[$c['category_id']] = $c['name'];
}
if (isset($this->request->get['category_id'])) {
$category_id = $this->request->get['category_id'];
$this->data['category_id'] = $category_id;
unset($categories[$category_id]);
}
$this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
$this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/category'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
$this->view->assign('cancel', $this->html->getSecureURL('catalog/category'));
if ($category_id && $this->request->is_GET()) {
$category_info = $this->model_catalog_category->getCategory($category_id);
}
foreach ($this->fields as $f) {
if (isset($this->request->post[$f])) {
$this->data[$f] = $this->request->post[$f];
} elseif (isset($category_info) && isset($category_info[$f])) {
$this->data[$f] = $category_info[$f];
} else {
$this->data[$f] = '';
}
}
if (isset($this->request->post['category_description'])) {
$this->data['category_description'] = $this->request->post['category_description'];
} elseif (isset($category_info)) {
$this->data['category_description'] = $this->model_catalog_category->getCategoryDescriptions($category_id);
} else {
$this->data['category_description'] = array();
}
if ($this->data['status'] == '') {
$this->data['status'] = 1;
}
if ($this->data['parent_id'] == '') {
$this->data['parent_id'] = 0;
}
$this->loadModel('setting/store');
$this->data['stores'] = $this->model_setting_store->getStores();
if (isset($this->request->post['category_store'])) {
$this->data['category_store'] = $this->request->post['category_store'];
} elseif (isset($category_info)) {
$this->data['category_store'] = $this->model_catalog_category->getCategoryStores($category_id);
} else {
$this->data['category_store'] = array(0);
}
$stores = array(0 => $this->language->get('text_default'));
foreach ($this->data['stores'] as $s) {
$stores[$s['store_id']] = $s['name'];
}
if (!$category_id) {
$this->data['action'] = $this->html->getSecureURL('catalog/category/insert');
$this->data['heading_title'] = $this->language->get('text_insert') . ' ' . $this->language->get('text_category');
$this->data['update'] = '';
$form = new AForm('ST');
} else {
$this->data['action'] = $this->html->getSecureURL('catalog/category/update', '&category_id=' . $category_id);
$this->data['heading_title'] = $this->language->get('text_edit') . ' ' . $this->language->get('text_category') . ' - ' . $this->data['category_description'][$this->session->data['content_language_id']]['name'];
$this->data['update'] = $this->html->getSecureURL('listing_grid/category/update_field', '&id=' . $category_id);
$form = new AForm('HS');
}
$this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['heading_title'], 'separator' => ' :: ', 'current' => true));
$form->setForm(array('form_name' => 'editFrm', 'update' => $this->data['update']));
$this->data['form']['id'] = 'editFrm';
$this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'editFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $this->data['action']));
$this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
$this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
$this->data['form']['fields']['general']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => $this->data['status'], 'style' => 'btn_switch', 'help_url' => $this->gen_help_url('status')));
$this->data['form']['fields']['general']['parent_category'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'parent_id', 'value' => $this->data['parent_id'], 'options' => $categories, 'style' => 'chosen'));
$this->data['form']['fields']['general']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'category_description[' . $this->session->data['content_language_id'] . '][name]', 'value' => $this->data['category_description'][$this->session->data['content_language_id']]['name'], 'required' => true, 'style' => 'large-field', 'attr' => ' maxlength="255" ', 'help_url' => $this->gen_help_url('name')));
$this->data['form']['fields']['general']['description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'category_description[' . $this->session->data['content_language_id'] . '][description]', 'value' => $this->data['category_description'][$this->session->data['content_language_id']]['description'], 'style' => 'xl-field', 'help_url' => $this->gen_help_url('description')));
$this->data['form']['fields']['data']['meta_keywords'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'category_description[' . $this->session->data['content_language_id'] . '][meta_keywords]', 'value' => $this->data['category_description'][$this->session->data['content_language_id']]['meta_keywords'], 'style' => 'xl-field', 'help_url' => $this->gen_help_url('meta_keywords')));
$this->data['form']['fields']['data']['meta_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'category_description[' . $this->session->data['content_language_id'] . '][meta_description]', 'value' => $this->data['category_description'][$this->session->data['content_language_id']]['meta_description'], 'style' => 'xl-field', 'help_url' => $this->gen_help_url('meta_description')));
$this->data['keyword_button'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'generate_seo_keyword', 'text' => $this->language->get('button_generate'), 'attr' => 'type="button"', 'style' => 'btn btn-info'));
$this->data['generate_seo_url'] = $this->html->getSecureURL('common/common/getseokeyword', '&object_key_name=category_id&id=' . $category_id);
$this->data['form']['fields']['data']['keyword'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'keyword', 'value' => $this->data['keyword'], 'help_url' => $this->gen_help_url('seo_keyword'), 'attr' => ' gen-value="' . SEOEncode($this->data['category_description']['name']) . '" '));
$this->data['form']['fields']['data']['store'] = $form->getFieldHtml(array('type' => 'checkboxgroup', 'name' => 'category_store[]', 'value' => $this->data['category_store'], 'options' => $stores, 'style' => 'chosen'));
$this->data['form']['fields']['data']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'value' => $this->data['sort_order'], 'style' => 'small-field'));
$this->data['active'] = 'general';
//load tabs controller
$tabs_obj = $this->dispatch('pages/catalog/category_tabs', array($this->data));
$this->data['category_tabs'] = $tabs_obj->dispatchGetOutput();
unset($tabs_obj);
if ($category_id && $this->config->get('config_embed_status')) {
$this->data['embed_url'] = $this->html->getSecureURL('common/do_embed/categories', '&category_id=' . $category_id);
}
$this->view->batchAssign($this->data);
$this->view->assign('form_language_switch', $this->html->getContentLanguageSwitcher());
$this->view->assign('language_id', $this->session->data['content_language_id']);
$this->view->assign('language_code', $this->session->data['language']);
$this->addChild('responses/common/resource_library/get_resources_html', 'resources_html', 'responses/common/resource_library_scripts.tpl');
$resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'categories', 'object_id' => $category_id, 'types' => array('image')));
$this->view->assign('current_url', $this->html->currentURL());
$this->view->assign('resources_scripts', $resources_scripts->dispatchGetOutput());
$this->view->assign('rl', $this->html->getSecureURL('common/resource_library', '&object_name=&object_id&type=image&mode=single'));
//.........这里部分代码省略.........
示例6: editCategory
/**
* @param int $category_id
* @param array $data
*/
public function editCategory($category_id, $data)
{
$fields = array('parent_id', 'sort_order', 'status');
$update = array('date_modified = NOW()');
foreach ($fields as $f) {
if (isset($data[$f])) {
$update[] = $f . " = '" . $this->db->escape($data[$f]) . "'";
}
}
if (!empty($update)) {
$this->db->query("UPDATE " . $this->db->table("categories") . " SET " . implode(',', $update) . " WHERE category_id = '" . (int) $category_id . "'");
}
if (!empty($data['category_description'])) {
foreach ($data['category_description'] as $language_id => $value) {
$update = array();
if (isset($value['name'])) {
$update["name"] = $value['name'];
}
if (isset($value['description'])) {
$update["description"] = $value['description'];
}
if (isset($value['meta_keywords'])) {
$update["meta_keywords"] = $value['meta_keywords'];
}
if (isset($value['meta_description'])) {
$update["meta_description"] = $value['meta_description'];
}
if (!empty($update)) {
// insert or update
$this->language->replaceDescriptions('category_descriptions', array('category_id' => (int) $category_id), array($language_id => $update));
}
}
}
if (isset($data['category_store'])) {
$this->db->query("DELETE FROM " . $this->db->table("categories_to_stores") . " WHERE category_id = '" . (int) $category_id . "'");
foreach ($data['category_store'] as $store_id) {
$this->db->query("INSERT INTO " . $this->db->table("categories_to_stores") . " SET category_id = '" . (int) $category_id . "', store_id = '" . (int) $store_id . "'");
}
}
if (isset($data['keyword'])) {
$data['keyword'] = SEOEncode($data['keyword']);
if ($data['keyword']) {
$this->language->replaceDescriptions('url_aliases', array('query' => "category_id=" . (int) $category_id), array((int) $this->language->getContentLanguageID() => array('keyword' => $data['keyword'])));
} else {
$this->db->query("DELETE\n\t\t\t\t\t\t\t\tFROM " . $this->db->table("url_aliases") . " \n\t\t\t\t\t\t\t\tWHERE query = 'category_id=" . (int) $category_id . "'\n\t\t\t\t\t\t\t\t\tAND language_id = '" . (int) $this->language->getContentLanguageID() . "'");
}
}
$this->cache->delete('category');
}
示例7: migrateProducts
//.........这里部分代码省略.........
}
$manufacturer_id = $this->db->getLastId();
$manufacturer_id_map[$data['manufacturer_id']] = $manufacturer_id;
//IMAGE PROCESSING
$this->_migrateImages($data, 'manufacturers', $manufacturer_id);
$result = $this->db->query("INSERT INTO " . DB_PREFIX . "manufacturers_to_stores\n SET manufacturer_id = '" . (int) $manufacturer_id . "', store_id = '" . (int) $store_id . "'", true);
if ($result === false) {
$this->addLog($this->db->error);
}
}
$this->addLog(count($manufacturers) . ' brands imported (' . $this->pic_count . ' pictures)', 'success');
// import products
$this->pic_count = 0;
foreach ($products as $data) {
$data['manufacturer_id'] = empty($manufacturer_id_map[$data['manufacturer_id']]) ? '' : $manufacturer_id_map[$data['manufacturer_id']];
$date_added = has_value($data['date_added']) ? "'" . $this->db->escape($data['date_added']) . "'" : 'NOW()';
$date_modified = has_value($data['date_modified']) ? "'" . $this->db->escape($data['date_modified']) . "'" : 'NOW()';
$result = $this->db->query("INSERT INTO " . DB_PREFIX . "products\n\t\t\t\t\t\t\t\t\t\tSET model = '" . $this->db->escape($data['model']) . "',\n\t\t\t\t\t\t\t\t\t\t\tsku\t= '" . $this->db->escape($data['sku']) . "',\n\t\t\t\t\t\t\t\t\t\t\tlocation = '" . $this->db->escape($data['location']) . "',\n\t\t\t\t\t\t\t\t\t\t\tquantity = '" . (int) $data['quantity'] . "',\n\t\t\t\t\t\t\t\t\t\t\tstock_status_id = '" . (int) $data['stock_status_id'] . "',\n\t\t\t\t\t\t\t\t\t\t\tdate_available = '" . $this->db->escape($data['date_available']) . "',\n\t\t\t\t\t\t\t\t\t\t\tmanufacturer_id = '" . (int) $data['manufacturer_id'] . "',\n\t\t\t\t\t\t\t\t\t\t\tshipping = '" . (int) $data['shipping'] . "',\n\t\t\t\t\t\t\t\t\t\t\tprice = '" . (double) $data['price'] . "',\n\t\t\t\t\t\t\t\t\t\t\tweight = '" . (double) $data['weight'] . "',\n\t\t\t\t\t\t\t\t\t\t\tweight_class_id = '" . (int) $data['weight_class_id'] . "',\n\t\t\t\t\t\t\t\t\t\t\tlength = '" . (double) $data['length'] . "',\n\t\t\t\t\t\t\t\t\t\t\tlength_class_id = '" . (int) $data['length_class_id'] . "',\n\t\t\t\t\t\t\t\t\t\t\theight = '" . (double) $data['height'] . "',\n\t\t\t\t\t\t\t\t\t\t\tstatus = '" . (int) $data['status'] . "',\n\t\t\t\t\t\t\t\t\t\t\tviewed = '" . (int) $data['viewed'] . "',\n\t\t\t\t\t\t\t\t\t\t\tminimum = '" . (int) $data['minimum'] . "',\n\t\t\t\t\t\t\t\t\t\t\tsubtract = '" . (int) $data['subtract'] . "',\n\t\t\t\t\t\t\t\t\t\t\ttax_class_id = '" . (int) $data['tax_class_id'] . "',\n\t\t\t\t\t\t\t\t\t\t\tsort_order = '" . (int) $data['sort_order'] . "',\n\t\t\t\t\t\t\t\t\t\t\tdate_added = " . $date_added . ",\n\t\t\t\t\t\t\t\t\t\t\tdate_modified = " . $date_modified . "", true);
if ($result === false) {
$this->addLog($this->db->error);
}
$product_id = $this->db->getLastId();
$product_id_map[$data['product_id']] = $product_id;
$product_prices_map[$data['product_id']] = (double) $data['price'];
//IMAGE PROCESSING
$this->_migrateImages($data, 'products', $product_id);
$result = $this->db->query("INSERT INTO " . DB_PREFIX . "product_descriptions\n\t\t\t\t\t\t\t\t\t\t SET product_id = '" . (int) $product_id . "',\n\t\t\t\t\t\t\t\t\t\t \t language_id = '" . (int) $language_id . "',\n\t\t\t\t\t\t\t\t\t\t\t name = '" . $this->db->escape($data['name']) . "',\n\t\t\t\t\t\t\t\t\t\t\t meta_keywords = '" . $this->db->escape($data['meta_keyword']) . "',\n\t\t\t\t\t\t\t\t\t\t\t meta_description = '" . $this->db->escape($data['meta_description']) . "',\n\t\t\t\t\t\t\t\t\t\t\t description = '" . $this->db->escape($data['description']) . "'", true);
if ($result === false) {
$this->addLog($this->db->error);
}
// add seo keyword
if ($this->config->get('enable_seo_url')) {
if (!$data['seo_keyword']) {
$seo_key = SEOEncode($data['name'], 'product_id', $product_id);
} else {
$seo_key = SEOEncode($data['seo_keyword'], 'product_id', $product_id);
}
$this->language->replaceDescriptions('url_aliases', array('query' => "product_id=" . (int) $product_id), array((int) $language_id => array('keyword' => $seo_key)));
}
$result = $this->db->query("INSERT INTO " . DB_PREFIX . "products_to_stores\n\t\t\t SET product_id = '" . (int) $product_id . "', store_id = '" . (int) $store_id . "'", true);
if ($result === false) {
$this->addLog($this->db->error);
}
if (isset($data['product_category'])) {
foreach ($data['product_category'] as $category_id) {
if (!(int) $category_id_map[$category_id]) {
continue;
}
$result = $this->db->query("INSERT INTO " . DB_PREFIX . "products_to_categories\n (product_id,category_id)\n VALUES ('" . (int) $product_id . "', '" . (int) $category_id_map[$category_id] . "')", true);
if ($result === false) {
$this->addLog($this->db->error);
}
}
}
// products review
if ($data['reviews']) {
foreach ($data['reviews'] as $review) {
if (!(int) $product_id_map[(int) $review['product_id']]) {
continue;
}
$sql = "INSERT INTO " . DB_PREFIX . "reviews\n\t (`product_id`, `customer_id`, `author`,\n\t `text`,`rating`,`status`,`date_added`,`date_modified`)\n\t VALUES ('" . (int) $product_id_map[$review['product_id']] . "',\n\t \t\t'" . (int) $customer_id_map[$data['review_customer_id']] . "',\n\t \t\t'" . $this->db->escape($review['review_author']) . "',\n\t \t\t'" . $this->db->escape($review['review_text']) . "',\n\t \t\t'" . (int) $review['review_rating'] . "',\n\t \t\t'" . (int) $review['review_status'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $this->db->escape($review['review_date_added']) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $this->db->escape($review['review_date_modified']) . "'\n\t \t\t);";
$result = $this->db->query($sql, true);
if ($result === false) {
$this->addLog($this->db->error);
}
}
示例8: _getForm
//.........这里部分代码省略.........
if ($this->data['quantity'] == '') {
$this->data['quantity'] = 1;
}
if ($this->data['minimum'] == '') {
$this->data['minimum'] = 1;
}
if ($this->data['sort_order'] == '') {
$this->data['sort_order'] = 1;
}
$this->data['active'] = 'details';
if (!isset($product_id)) {
$this->data['action'] = $this->html->getSecureURL('catalog/product/insert');
$this->data['form_title'] = $this->language->get('text_insert') . $this->language->get('text_product');
$this->data['update'] = '';
$form = new AForm('ST');
$this->data['summary_form'] = '';
} else {
$this->data['action'] = $this->html->getSecureURL('catalog/product/update', '&product_id=' . $product_id);
$this->data['form_title'] = $this->language->get('text_edit') . ' ' . $this->language->get('text_product');
$this->data['update'] = $this->html->getSecureURL('listing_grid/product/update_field', '&id=' . $product_id);
$form = new AForm('HS');
$this->data['active'] = 'general';
//load tabs controller
$tabs_obj = $this->dispatch('pages/catalog/product_tabs', array($this->data));
$this->data['product_tabs'] = $tabs_obj->dispatchGetOutput();
unset($tabs_obj);
$this->addChild('pages/catalog/product_summary', 'summary_form', 'pages/catalog/product_summary.tpl');
}
$form->setForm(array('form_name' => 'productFrm', 'update' => $this->data['update']));
$this->data['form']['id'] = 'productFrm';
$this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'productFrm', 'action' => $this->data['action'], 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"'));
$this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
$this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
$this->data['form']['fields']['general']['status'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'status', 'value' => $this->data['status'], 'style' => 'btn_switch btn-group-sm', 'help_url' => $this->gen_help_url('?p=62')));
$this->data['form']['fields']['general']['featured'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'featured', 'value' => $this->data['featured'], 'style' => 'btn_switch btn-group-sm', 'help_url' => $this->gen_help_url('?p=62')));
$this->data['form']['fields']['general']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'product_description[name]', 'value' => $this->data['product_description']['name'], 'required' => true, 'help_url' => $this->gen_help_url('?p=62')));
$this->data['form']['fields']['general']['description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'product_description[description]', 'value' => $this->data['product_description']['description']));
$this->data['form']['fields']['general']['meta_keywords'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'product_description[meta_keywords]', 'value' => $this->data['product_description']['meta_keywords'], 'help_url' => $this->gen_help_url('?p=62')));
$this->data['form']['fields']['general']['meta_description'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'product_description[meta_description]', 'value' => $this->data['product_description']['meta_description']));
$this->data['form']['fields']['general']['blurb'] = $form->getFieldHtml(array('type' => 'textarea', 'name' => 'product_description[blurb]', 'value' => $this->data['product_description']['blurb']));
$this->data['form']['fields']['general']['tags'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'product_tags', 'value' => $this->data['product_tags']));
$this->data['form']['fields']['general']['category'] = $form->getFieldHtml(array('type' => 'checkboxgroup', 'name' => 'product_category[]', 'value' => $this->data['product_category'], 'options' => $this->data['categories'], 'style' => 'chosen', 'placeholder' => $this->language->get('text_select_category')));
$this->data['form']['fields']['general']['store'] = $form->getFieldHtml(array('type' => 'checkboxgroup', 'name' => 'product_store[]', 'value' => $this->data['product_store'], 'options' => $this->data['stores'], 'style' => 'chosen', 'placeholder' => $this->language->get('entry_store')));
$this->data['form']['fields']['data']['manufacturer'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'manufacturer_id', 'value' => $this->data['manufacturer_id'], 'options' => $this->data['manufacturers'], 'style' => 'chosen', 'placeholder' => $this->language->get('entry_manufacturer')));
$this->data['form']['fields']['data']['model'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'model', 'value' => $this->data['model'], 'required' => false));
$this->data['form']['fields']['data']['call_to_order'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'call_to_order', 'value' => $this->data['call_to_order'], 'style' => 'btn_switch btn-group-sm', 'help_url' => $this->gen_help_url('?p=62')));
$this->data['form']['fields']['data']['price'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'price', 'value' => moneyDisplayFormat($this->data['price']), 'style' => 'small-field'));
$this->data['form']['fields']['data']['cost'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'cost', 'value' => moneyDisplayFormat($this->data['cost']), 'style' => 'small-field'));
$this->data['form']['fields']['data']['tax_class'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'tax_class_id', 'value' => $this->data['tax_class_id'], 'options' => $this->data['tax_classes'], 'help_url' => $this->gen_help_url('?p=62'), 'style' => 'medium-field'));
$this->data['form']['fields']['data']['subtract'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'subtract', 'value' => $this->data['subtract'], 'options' => array(1 => $this->language->get('text_yes'), 0 => $this->language->get('text_no')), 'help_url' => $this->gen_help_url('?p=62'), 'style' => 'medium-field'));
$this->data['form']['fields']['data']['quantity'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'quantity', 'value' => (int) $this->data['quantity'], 'style' => 'col-xs-1 small-field'));
$this->data['form']['fields']['data']['minimum'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'minimum', 'value' => (int) $this->data['minimum'], 'style' => 'small-field'));
$this->data['form']['fields']['data']['maximum'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'maximum', 'value' => (int) $this->data['maximum'], 'style' => 'small-field'));
$this->data['form']['fields']['data']['stock_status'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'stock_status_id', 'value' => $this->data['stock_status_id'], 'options' => $this->data['stock_statuses'], 'style' => 'small-field'));
$this->data['form']['fields']['data']['sku'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sku', 'value' => $this->data['sku'], 'help_url' => $this->gen_help_url('?p=62')));
$this->data['form']['fields']['data']['location'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'location', 'value' => $this->data['location']));
//prepend button to generate keyword
$this->data['keyword_button'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'generate_seo_keyword', 'text' => $this->language->get('button_generate'), 'attr' => 'type="button"', 'style' => 'btn btn-info'));
$this->data['generate_seo_url'] = $this->html->getSecureURL('common/common/getseokeyword', '&object_key_name=product_id&id=' . $product_id);
$this->data['form']['fields']['data']['keyword'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'keyword', 'value' => $this->data['keyword'], 'help_url' => $this->gen_help_url('?p=62'), 'attr' => ' gen-value="' . SEOEncode($this->data['product_description']['name']) . '" '));
$this->data['form']['fields']['data']['date_available'] = $form->getFieldHtml(array('type' => 'date', 'name' => 'date_available', 'value' => dateISO2Display($this->data['date_available']), 'default' => dateNowDisplay(), 'dateformat' => format4Datepicker($this->language->get('date_format_short')), 'highlight' => 'future', 'style' => 'small-field'));
$this->data['form']['fields']['data']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'value' => $this->data['sort_order'], 'style' => 'tiny-field'));
$this->data['form']['fields']['data']['shipping'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'shipping', 'style' => 'btn_switch btn-group-sm', 'value' => isset($this->data['shipping']) ? $this->data['shipping'] : 1));
$this->data['form']['fields']['data']['free_shipping'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'free_shipping', 'style' => 'btn_switch btn-group-sm', 'value' => isset($this->data['free_shipping']) ? $this->data['free_shipping'] : 0));
$this->data['form']['fields']['data']['ship_individually'] = $form->getFieldHtml(array('type' => 'checkbox', 'name' => 'ship_individually', 'style' => 'btn_switch btn-group-sm', 'value' => isset($this->data['ship_individually']) ? $this->data['ship_individually'] : 0));
$this->data['form']['fields']['data']['shipping_price'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'shipping_price', 'value' => moneyDisplayFormat($this->data['shipping_price']), 'style' => 'tiny-field'));
$this->data['form']['fields']['data']['length'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'length', 'value' => $this->data['length'], 'style' => 'tiny-field'));
$this->data['form']['fields']['data']['width'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'width', 'value' => $this->data['width'], 'attr' => ' autocomplete="false"', 'style' => 'tiny-field'));
$this->data['form']['fields']['data']['height'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'height', 'value' => $this->data['height'], 'attr' => ' autocomplete="false"', 'style' => 'tiny-field'));
if ($product_id && !$this->data['length_class_id']) {
$this->data['length_classes'][0] = $this->language->get('text_none');
}
$this->data['form']['fields']['data']['length_class'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'length_class_id', 'value' => $this->data['length_class_id'], 'options' => $this->data['length_classes'], 'style' => 'small-field'));
if ($product_id && $this->data['shipping'] && (!(double) $this->data['weight'] || !$this->data['weight_class_id']) && !(double) $this->data['shipping_price']) {
if (!$this->data['weight_class_id']) {
$this->data['error']['weight_class'] = $this->language->get('error_weight_class');
}
if (!(double) $this->data['weight']) {
$this->data['error']['weight'] = $this->language->get('error_weight_value');
}
}
if ($product_id && !$this->data['weight_class_id']) {
$this->data['weight_classes'][0] = $this->language->get('text_none');
}
$this->data['form']['fields']['data']['weight'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'weight', 'value' => $this->data['weight'], 'attr' => ' autocomplete="false"', 'style' => 'tiny-field'));
$this->data['form']['fields']['data']['weight_class'] = $form->getFieldHtml(array('type' => 'selectbox', 'name' => 'weight_class_id', 'value' => $this->data['weight_class_id'], 'options' => $this->data['weight_classes'], 'style' => 'small-field'));
$this->data['product_id'] = $product_id;
if ($product_id && $this->config->get('config_embed_status')) {
$this->data['embed_url'] = $this->html->getSecureURL('common/do_embed/product', '&product_id=' . $product_id);
}
$this->data['text_clone'] = $this->language->get('text_clone');
$this->data['clone_url'] = $this->html->getSecureURL('catalog/product/copy', '&product_id=' . $this->request->get['product_id']);
$this->data['form_language_switch'] = $this->html->getContentLanguageSwitcher();
$this->data['language_id'] = $this->session->data['content_language_id'];
$this->data['language_code'] = $this->session->data['language'];
$this->data['help_url'] = $this->gen_help_url('?p=62');
$this->data['rl'] = $this->html->getSecureURL('common/resource_library', '&object_name=&object_id&type=image&mode=url');
$this->view->batchAssign($this->data);
$this->processTemplate('pages/catalog/product_form.tpl');
}
示例9: _getForm
private function _getForm()
{
$this->view->assign('token', $this->session->data['token']);
$this->view->assign('error_warning', $this->error['warning']);
$this->view->assign('error_name', $this->error['name']);
$this->document->initBreadcrumb(array('href' => $this->html->getSecureURL('index/home'), 'text' => $this->language->get('text_home'), 'separator' => FALSE));
$this->document->addBreadcrumb(array('href' => $this->html->getSecureURL('catalog/manufacturer'), 'text' => $this->language->get('heading_title'), 'separator' => ' :: '));
$this->view->assign('cancel', $this->html->getSecureURL('catalog/manufacturer'));
if (isset($this->request->get['manufacturer_id']) && $this->request->is_GET()) {
$manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
}
foreach ($this->fields as $f) {
if (isset($this->request->post[$f])) {
$this->data[$f] = $this->request->post[$f];
} elseif (isset($manufacturer_info) && isset($manufacturer_info[$f])) {
$this->data[$f] = $manufacturer_info[$f];
} else {
$this->data[$f] = '';
}
}
$this->loadModel('setting/store');
$this->data['stores'] = $this->model_setting_store->getStores();
if (isset($this->request->post['manufacturer_store'])) {
$this->data['manufacturer_store'] = $this->request->post['manufacturer_store'];
} elseif (isset($manufacturer_info)) {
$this->data['manufacturer_store'] = $this->model_catalog_manufacturer->getManufacturerStores($this->request->get['manufacturer_id']);
} else {
$this->data['manufacturer_store'] = array(0);
}
$stores = array(0 => $this->language->get('text_default'));
foreach ($this->data['stores'] as $s) {
$stores[$s['store_id']] = $s['name'];
}
if (!isset($this->request->get['manufacturer_id'])) {
$this->data['action'] = $this->html->getSecureURL('catalog/manufacturer/insert');
$this->data['heading_title'] = $this->language->get('text_insert') . $this->language->get('text_manufacturer');
$this->data['update'] = '';
$form = new AForm('ST');
} else {
$this->data['action'] = $this->html->getSecureURL('catalog/manufacturer/update', '&manufacturer_id=' . $this->request->get['manufacturer_id']);
$this->data['heading_title'] = $this->language->get('text_edit') . $this->language->get('text_manufacturer') . ' - ' . $this->data['name'];
$this->data['update'] = $this->html->getSecureURL('listing_grid/manufacturer/update_field', '&id=' . $this->request->get['manufacturer_id']);
$form = new AForm('HS');
$this->data['manufacturer_edit'] = $this->html->getSecureURL('catalog/manufacturer/update', '&manufacturer_id=' . $this->request->get['manufacturer_id']);
$this->data['tab_edit'] = $this->language->get('entry_edit');
$this->data['tab_layout'] = $this->language->get('entry_layout');
$this->data['manufacturer_layout'] = $this->html->getSecureURL('catalog/manufacturer_layout', '&manufacturer_id=' . $this->request->get['manufacturer_id']);
}
$this->document->addBreadcrumb(array('href' => $this->data['action'], 'text' => $this->data['heading_title'], 'separator' => ' :: ', 'current' => true));
$form->setForm(array('form_name' => 'editFrm', 'update' => $this->data['update']));
$this->data['form']['id'] = 'editFrm';
$this->data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form', 'name' => 'editFrm', 'attr' => 'data-confirm-exit="true" class="aform form-horizontal"', 'action' => $this->data['action']));
$this->data['form']['submit'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'submit', 'text' => $this->language->get('button_save'), 'style' => 'button1'));
$this->data['form']['cancel'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'cancel', 'text' => $this->language->get('button_cancel'), 'style' => 'button2'));
$this->data['form']['fields']['general']['name'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'name', 'value' => $this->data['name'], 'required' => true, 'style' => 'large-field', 'help_url' => $this->gen_help_url('name')));
$this->data['form']['fields']['general']['manufacturer_store'] = $form->getFieldHtml(array('type' => 'checkboxgroup', 'name' => 'manufacturer_store[]', 'value' => $this->data['manufacturer_store'], 'options' => $stores, 'style' => 'chosen', 'help_url' => $this->gen_help_url('manufacturer_store')));
$this->data['form']['fields']['general']['keyword'] = $form->getFieldHtml(array('type' => 'button', 'name' => 'generate_seo_keyword', 'text' => $this->language->get('button_generate'), 'attr' => 'type="button"', 'style' => 'btn btn-info'));
$this->data['generate_seo_url'] = $this->html->getSecureURL('common/common/getseokeyword', '&object_key_name=category_id&id=' . $category_id);
$this->data['form']['fields']['general']['keyword'] .= $form->getFieldHtml(array('type' => 'input', 'name' => 'keyword', 'value' => $this->data['keyword'], 'help_url' => $this->gen_help_url('seo_keyword'), 'attr' => ' gen-value="' . SEOEncode($this->data['category_description']['name']) . '" '));
$this->data['form']['fields']['general']['sort_order'] = $form->getFieldHtml(array('type' => 'input', 'name' => 'sort_order', 'value' => $this->data['sort_order'], 'style' => 'small-field'));
$this->view->assign('help_url', $this->gen_help_url('manufacturer_edit'));
$this->view->batchAssign($this->data);
$this->addChild('responses/common/resource_library/get_resources_html', 'resources_html', 'responses/common/resource_library_scripts.tpl');
$resources_scripts = $this->dispatch('responses/common/resource_library/get_resources_scripts', array('object_name' => 'manufacturers', 'object_id' => $this->request->get['manufacturer_id'], 'types' => array('image', 'audio', 'video', 'pdf')));
$this->view->assign('resources_scripts', $resources_scripts->dispatchGetOutput());
$this->processTemplate('pages/catalog/manufacturer_form.tpl');
}
示例10: editContentField
/**
* @param int $content_id
* @param string $field
* @param mixed $value
* @param null|int $parent_content_id
* @return bool
*/
public function editContentField($content_id, $field, $value, $parent_content_id = null)
{
$content_id = (int) $content_id;
$language_id = (int) $this->language->getContentLanguageID();
if (!$language_id) {
return false;
}
switch ($field) {
case 'status':
$this->db->query("UPDATE " . $this->db->table("contents") . " \n\t\t\t\t\t\t\t\t\tSET `status` = '" . (int) $value . "'\n\t\t\t\t\t\t\t\t\tWHERE content_id = '" . (int) $content_id . "'");
break;
case 'sort_order':
$this->db->query("UPDATE " . $this->db->table("contents") . " \n\t\t\t\t\t\t\t\tSET `sort_order` = '" . (int) $value . "'\n\t\t\t\t\t\t\t\tWHERE content_id = '" . (int) $content_id . "'\n\t\t\t\t\t\t\t\t\tAND parent_content_id='" . (int) $parent_content_id . "'");
break;
case 'title':
case 'description':
case 'content':
$this->language->replaceDescriptions('content_descriptions', array('content_id' => (int) $content_id), array((int) $language_id => array($field => $value)));
break;
case 'keyword':
$value = SEOEncode($value, 'content_id', $content_id);
if ($value) {
$this->language->replaceDescriptions('url_aliases', array('query' => "content_id=" . (int) $content_id), array((int) $this->language->getContentLanguageID() => array('keyword' => $value)));
} else {
$this->db->query("DELETE\n\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("url_aliases") . " \n\t\t\t\t\t\t\t\t\tWHERE query = 'content_id=" . (int) $content_id . "'\n\t\t\t\t\t\t\t\t\t\tAND language_id = '" . (int) $this->language->getContentLanguageID() . "'");
}
break;
case 'parent_content_id':
// prevent deleting while updating with parent_id==content_id
$value = (array) $value;
foreach ($value as $k => $v) {
list($void, $parent_id) = explode('_', $v);
if ($parent_id == $content_id) {
continue;
}
$tmp[$parent_id] = $parent_id;
}
$value = $tmp;
if (sizeof($value) == 1 && current($value) == $content_id) {
break;
}
$query = "SELECT parent_content_id, sort_order, status\n\t\t\t\t\t\t\tFROM " . $this->db->table("contents") . " \n\t\t\t\t\t\t\tWHERE content_id='" . $content_id . "'";
$result = $this->db->query($query);
if ($result->num_rows) {
$status = $result->row['status'];
foreach ($result->rows as $row) {
$sort_orders[$row['parent_content_id']] = $row['sort_order'];
}
}
$query = "DELETE FROM " . $this->db->table("contents") . " WHERE content_id='" . $content_id . "'";
$this->db->query($query);
$value = !$value ? array(0) : $value;
foreach ($value as $parent_content_id) {
$parent_content_id = (int) $parent_content_id;
if ($parent_content_id == $content_id) {
continue;
}
$query = "INSERT INTO " . $this->db->table("contents") . " (content_id,parent_content_id, sort_order, status)\n\t\t\t\t\t\t\t\t\tVALUES ('" . $content_id . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $parent_content_id . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . (int) $sort_orders[$parent_content_id] . "',\n\t\t\t\t\t\t\t\t\t\t\t'" . $status . "');";
$this->db->query($query);
}
break;
case 'store_id':
$query = "DELETE FROM " . $this->db->table("contents_to_stores") . " WHERE content_id='" . $content_id . "'";
$this->db->query($query);
foreach ($value as $store_id) {
if (has_value($store_id)) {
$query = "INSERT INTO " . $this->db->table("contents_to_stores") . " (content_id,store_id)\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . $content_id . "','" . (int) $store_id . "')";
$this->db->query($query);
}
}
break;
}
$this->cache->delete('contents');
return true;
}