Skip to content

Commit

Permalink
https://github.com/opencart/opencart/issues/1915
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel kerr committed Oct 7, 2014
1 parent fe4bb21 commit 69d6252
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 10 deletions.
20 changes: 19 additions & 1 deletion upload/admin/controller/catalog/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,13 @@ protected function getForm() {
} else {
$data['error_meta_title'] = array();
}


if (isset($this->error['keyword'])) {
$data['error_keyword'] = $this->error['keyword'];
} else {
$data['error_keyword'] = '';
}

$url = '';

if (isset($this->request->get['sort'])) {
Expand Down Expand Up @@ -532,6 +538,18 @@ protected function validateForm() {
}
}

$this->load->model('catalog/url_alias');

$url_alias_info = $this->model_url_alas->getUrlAlias($this->request->post['keyword']);

if ($url_alias_info && isset($this->request->get['category_id']) && $url_alias_info['query'] != 'category_id=' . $this->request->get['category_id']) {
$this->error['keyword'] = sprintf($this->language->get('error_keyword'));
}

if ($url_alias_info && !isset($this->request->get['category_id'])) {
$this->error['keyword'] = sprintf($this->language->get('error_keyword'));
}

if ($this->error && !isset($this->error['warning'])) {
$this->error['warning'] = $this->language->get('error_warning');
}
Expand Down
20 changes: 19 additions & 1 deletion upload/admin/controller/catalog/information.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,13 @@ protected function getForm() {
} else {
$data['error_meta_title'] = array();
}


if (isset($this->error['keyword'])) {
$data['error_keyword'] = $this->error['keyword'];
} else {
$data['error_keyword'] = '';
}

$url = '';

if (isset($this->request->get['sort'])) {
Expand Down Expand Up @@ -446,7 +452,19 @@ protected function validateForm() {
$this->error['meta_title'][$language_id] = $this->language->get('error_meta_title');
}
}

$this->load->model('catalog/url_alias');

$url_alias_info = $this->model_url_alas->getUrlAlias($this->request->post['keyword']);

if ($url_alias_info && isset($this->request->get['information_id']) && $url_alias_info['query'] != 'information_id=' . $this->request->get['information_id']) {
$this->error['keyword'] = sprintf($this->language->get('error_keyword'));
}

if ($url_alias_info && !isset($this->request->get['information_id'])) {
$this->error['keyword'] = sprintf($this->language->get('error_keyword'));
}

if ($this->error && !isset($this->error['warning'])) {
$this->error['warning'] = $this->language->get('error_warning');
}
Expand Down
20 changes: 19 additions & 1 deletion upload/admin/controller/catalog/manufacturer.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,13 @@ protected function getForm() {
} else {
$data['error_name'] = '';
}


if (isset($this->error['keyword'])) {
$data['error_keyword'] = $this->error['keyword'];
} else {
$data['error_keyword'] = '';
}

$url = '';

if (isset($this->request->get['sort'])) {
Expand Down Expand Up @@ -405,6 +411,18 @@ protected function validateForm() {
$this->error['name'] = $this->language->get('error_name');
}

$this->load->model('catalog/url_alias');

$url_alias_info = $this->model_url_alas->getUrlAlias($this->request->post['keyword']);

if ($url_alias_info && isset($this->request->get['manufacturer_id']) && $url_alias_info['query'] != 'manufacturer_id=' . $this->request->get['manufacturer_id']) {
$this->error['keyword'] = sprintf($this->language->get('error_keyword'));
}

if ($url_alias_info && !isset($this->request->get['manufacturer_id'])) {
$this->error['keyword'] = sprintf($this->language->get('error_keyword'));
}

return !$this->error;
}

Expand Down
20 changes: 19 additions & 1 deletion upload/admin/controller/catalog/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,13 @@ protected function getForm() {
} else {
$data['error_date_available'] = '';
}


if (isset($this->error['keyword'])) {
$data['error_keyword'] = $this->error['keyword'];
} else {
$data['error_keyword'] = '';
}

$url = '';

if (isset($this->request->get['filter_name'])) {
Expand Down Expand Up @@ -1316,7 +1322,19 @@ protected function validateForm() {
if ((utf8_strlen($this->request->post['model']) < 1) || (utf8_strlen($this->request->post['model']) > 64)) {
$this->error['model'] = $this->language->get('error_model');
}

$this->load->model('catalog/url_alias');

$url_alias_info = $this->model_url_alas->getUrlAlias($this->request->post['keyword']);

if ($url_alias_info && isset($this->request->get['product_id']) && $url_alias_info['query'] != 'product_id=' . $this->request->get['product_id']) {
$this->error['keyword'] = sprintf($this->language->get('error_keyword'));
}

if ($url_alias_info && !isset($this->request->get['product_id'])) {
$this->error['keyword'] = sprintf($this->language->get('error_keyword'));
}

if ($this->error && !isset($this->error['warning'])) {
$this->error['warning'] = $this->language->get('error_warning');
}
Expand Down
3 changes: 2 additions & 1 deletion upload/admin/language/english/catalog/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
$_['error_warning'] = 'Warning: Please check the form carefully for errors!';
$_['error_permission'] = 'Warning: You do not have permission to modify categories!';
$_['error_name'] = 'Category Name must be between 2 and 32 characters!';
$_['error_meta_title'] = 'Meta Title must be greater than 3 and less than 255 characters!';
$_['error_meta_title'] = 'Meta Title must be greater than 3 and less than 255 characters!';
$_['error_keyword'] = 'SEO keyword already in use!';
1 change: 1 addition & 0 deletions upload/admin/language/english/catalog/information.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
$_['error_title'] = 'Information Title must be between 3 and 64 characters!';
$_['error_description'] = 'Description must be more than 3 characters!';
$_['error_meta_title'] = 'Meta Title must be greater than 3 and less than 255 characters!';
$_['error_keyword'] = 'SEO keyword already in use!';
$_['error_account'] = 'Warning: This information page cannot be deleted as it is currently assigned as the store account terms!';
$_['error_checkout'] = 'Warning: This information page cannot be deleted as it is currently assigned as the store checkout terms!';
$_['error_affiliate'] = 'Warning: This information page cannot be deleted as it is currently assigned as the store affiliate terms!';
Expand Down
1 change: 1 addition & 0 deletions upload/admin/language/english/catalog/manufacturer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
// Error
$_['error_permission'] = 'Warning: You do not have permission to modify manufacturers!';
$_['error_name'] = 'Manufacturer Name must be between 2 and 64 characters!';
$_['error_keyword'] = 'SEO keyword already in use!';
$_['error_product'] = 'Warning: This manufacturer cannot be deleted as it is currently assigned to %s products!';
3 changes: 2 additions & 1 deletion upload/admin/language/english/catalog/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,5 @@
$_['error_permission'] = 'Warning: You do not have permission to modify products!';
$_['error_name'] = 'Product Name must be greater than 3 and less than 255 characters!';
$_['error_meta_title'] = 'Meta Title must be greater than 3 and less than 255 characters!';
$_['error_model'] = 'Product Model must be greater than 1 and less than 64 characters!';
$_['error_model'] = 'Product Model must be greater than 1 and less than 64 characters!';
$_['error_keyword'] = 'SEO keyword already in use!';
4 changes: 2 additions & 2 deletions upload/admin/model/catalog/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ public function getTotalCategories() {

return $query->row['total'];
}

public function getTotalCategoriesByLayoutId($layout_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "category_to_layout WHERE layout_id = '" . (int)$layout_id . "'");

return $query->row['total'];
}
}
}
8 changes: 8 additions & 0 deletions upload/admin/model/catalog/url_alias.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
class ModelCatalogUrlAlias extends Model {
public function getUrlAlias($keyword) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($keyword) . "'");

return $query->row;
}
}
3 changes: 3 additions & 0 deletions upload/admin/view/template/catalog/category_form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
<label class="col-sm-2 control-label" for="input-keyword"><span data-toggle="tooltip" title="<?php echo $help_keyword; ?>"><?php echo $entry_keyword; ?></span></label>
<div class="col-sm-10">
<input type="text" name="keyword" value="<?php echo $keyword; ?>" placeholder="<?php echo $entry_keyword; ?>" id="input-keyword" class="form-control" />
<?php if ($error_keyword) { ?>
<div class="text-danger"><?php echo $error_keyword; ?></div>
<?php } ?>
</div>
</div>
<div class="form-group">
Expand Down
3 changes: 3 additions & 0 deletions upload/admin/view/template/catalog/information_form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<label class="col-sm-2 control-label" for="input-keyword"><span data-toggle="tooltip" title="<?php echo $help_keyword; ?>"><?php echo $entry_keyword; ?></span></label>
<div class="col-sm-10">
<input type="text" name="keyword" value="<?php echo $keyword; ?>" placeholder="<?php echo $entry_keyword; ?>" id="input-keyword" class="form-control" />
<?php if ($error_keyword) { ?>
<div class="text-danger"><?php echo $error_keyword; ?></div>
<?php } ?>
</div>
</div>
<div class="form-group">
Expand Down
6 changes: 4 additions & 2 deletions upload/admin/view/template/catalog/manufacturer_form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@
<label class="col-sm-2 control-label" for="input-keyword"><span data-toggle="tooltip" title="<?php echo $help_keyword; ?>"><?php echo $entry_keyword; ?></span></label>
<div class="col-sm-10">
<input type="text" name="keyword" value="<?php echo $keyword; ?>" placeholder="<?php echo $entry_keyword; ?>" id="input-keyword" class="form-control" />
<?php if ($error_keyword) { ?>
<div class="text-danger"><?php echo $error_keyword; ?></div>
<?php } ?>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="input-image"><?php echo $entry_image; ?></label>
<div class="col-sm-10">
<a href="" id="thumb-image" data-toggle="image" class="img-thumbnail"><img src="<?php echo $thumb; ?>" alt="" title="" data-placeholder="<?php echo $placeholder; ?>" /></a>
<div class="col-sm-10"> <a href="" id="thumb-image" data-toggle="image" class="img-thumbnail"><img src="<?php echo $thumb; ?>" alt="" title="" data-placeholder="<?php echo $placeholder; ?>" /></a>
<input type="hidden" name="image" value="<?php echo $image; ?>" id="input-image" />
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions upload/admin/view/template/catalog/product_form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@
<label class="col-sm-2 control-label" for="input-keyword"><span data-toggle="tooltip" title="<?php echo $help_keyword; ?>"><?php echo $entry_keyword; ?></span></label>
<div class="col-sm-10">
<input type="text" name="keyword" value="<?php echo $keyword; ?>" placeholder="<?php echo $entry_keyword; ?>" id="input-keyword" class="form-control" />
<?php if ($error_keyword) { ?>
<div class="text-danger"><?php echo $error_keyword; ?></div>
<?php } ?>
</div>
</div>
<div class="form-group">
Expand Down

0 comments on commit 69d6252

Please sign in to comment.