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=D0=B1=D0=B5=D0=B7=20=D0=B7?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/comments/actions/delete.php | 33 ++++++++++--------- .../controllers/content/actions/item_add.php | 30 +++++++++-------- system/libs/html.helper.php | 10 ++++-- .../content/default_list_tiles.tpl.php | 6 ---- 4 files changed, 41 insertions(+), 38 deletions(-) diff --git a/system/controllers/comments/actions/delete.php b/system/controllers/comments/actions/delete.php index be135a536..9f1bd3f25 100755 --- a/system/controllers/comments/actions/delete.php +++ b/system/controllers/comments/actions/delete.php @@ -7,38 +7,39 @@ public function run(){ if (!$this->request->isAjax()){ cmsCore::error404(); } if (!cmsUser::isAllowed('comments', 'delete')){ cmsCore::error404(); } - $comment_id = $this->request->get('id'); + $comment = $this->model->getComment((int)$this->request->get('id')); - // Проверяем валидность - $is_valid = is_numeric($comment_id); + // Проверяем + if (!$comment){ - if (!$is_valid){ - $result = array( + cmsTemplate::getInstance()->renderJSON($result = array( 'error' => true, 'message' => LANG_ERROR - ); - cmsTemplate::getInstance()->renderJSON($result); + )); + } $user = cmsUser::getInstance(); - $comment = $this->model->getComment($comment_id); - if (!cmsUser::isAllowed('comments', 'edit', 'all')) { if (cmsUser::isAllowed('comments', 'edit', 'own') && $comment['user']['id'] != $user->id) { - $result = array('error' => true, 'message' => LANG_ERROR); - cmsTemplate::getInstance()->renderJSON($result); + + cmsTemplate::getInstance()->renderJSON(array( + 'error' => true, + 'message' => LANG_ERROR + )); + } } - $this->model->deleteComment($comment_id); + $this->model->deleteComment($comment['id']); + + cmsEventsManager::hook('comments_after_hide', $comment['id']); - $result = array( + cmsTemplate::getInstance()->renderJSON(array( 'error' => false, 'message' => LANG_COMMENT_DELETED - ); - - cmsTemplate::getInstance()->renderJSON($result); + )); } diff --git a/system/controllers/content/actions/item_add.php b/system/controllers/content/actions/item_add.php index 5f7c8092d..45f8f3053 100755 --- a/system/controllers/content/actions/item_add.php +++ b/system/controllers/content/actions/item_add.php @@ -124,6 +124,21 @@ public function run(){ list($item, $errors) = cmsEventsManager::hook('content_validate', array($item, $errors)); } + // несколько категорий + if (!empty($ctype['options']['is_cats_multi'])){ + $add_cats = $this->request->get('add_cats'); + if (is_array($add_cats)){ + foreach($add_cats as $index=>$cat_id){ + if (!is_numeric($cat_id) || !$cat_id){ + unset($add_cats[$index]); + } + } + if ($add_cats){ + $item['add_cats'] = $add_cats; + } + } + } + if (!$errors){ unset($item['ctype_name']); @@ -185,20 +200,6 @@ public function run(){ if (!isset($item['is_pub'])) { $item['is_pub'] = $is_pub; } if (!empty($item['is_pub'])) { $item['is_pub'] = $is_pub; } - if (!empty($ctype['options']['is_cats_multi'])){ - $add_cats = $this->request->get('add_cats'); - if (is_array($add_cats)){ - foreach($add_cats as $index=>$cat_id){ - if (!is_numeric($cat_id) || !$cat_id){ - unset($add_cats[$index]); - } - } - if ($add_cats){ - $item['add_cats'] = $add_cats; - } - } - } - $item = cmsEventsManager::hook("content_before_add", $item); $item = cmsEventsManager::hook("content_{$ctype['name']}_before_add", $item); @@ -251,6 +252,7 @@ public function run(){ 'is_moderator' => $is_moderator, 'is_premoderation' => $is_premoderation, 'is_load_props' => !isset($errors), + 'add_cats' => isset($add_cats) ? $add_cats : array(), 'errors' => isset($errors) ? $errors : false )); diff --git a/system/libs/html.helper.php b/system/libs/html.helper.php index 5c5a27161..5f4fc28c5 100755 --- a/system/libs/html.helper.php +++ b/system/libs/html.helper.php @@ -260,6 +260,12 @@ function html_attr_str($attributes){ unset($attributes['class']); if (sizeof($attributes)){ foreach($attributes as $key=>$val){ + if(is_bool($val)){ + if($val === true){ + $attr_str .= "{$key} "; + } + continue; + } $attr_str .= "{$key}=\"{$val}\" "; } } @@ -560,10 +566,10 @@ function html_select($name, $items, $selected = '', $attributes = array()){ if($optgroup !== false){ $html .= "\t".''."\n"; } - + $html .= ''."\n"; return $html; - + } function html_select_range($name, $start, $end, $step, $add_lead_zero=false, $selected='', $attributes=array()){ diff --git a/templates/default/content/default_list_tiles.tpl.php b/templates/default/content/default_list_tiles.tpl.php index 43335ec8b..bec242a01 100755 --- a/templates/default/content/default_list_tiles.tpl.php +++ b/templates/default/content/default_list_tiles.tpl.php @@ -83,12 +83,6 @@ - -