$info .= lng('CAT_EXIST'); } } elseif ($id and Filter::input('delete', 'post', 'bool')) { $category = new Category($id); if ($category->Delete()) { $info .= lng('CAT_DELETED'); } else { $info .= lng('CAT_NOT_EXIST'); } $id = false; } $cat_list = CategoryManager::GetList($id); include View::Get('category_header.html', $st_subdir . 'category/'); if ($id) { $cat_item = new Category($id); if ($cat_item->Exist()) { $cat_name = $cat_item->GetName(); $cat_desc = $cat_item->GetDescription(); $cat_priority = $cat_item->GetPriority(); include View::Get('category_edit.html', $st_subdir . 'category/'); if (!$cat_item->IsSystem()) { include View::Get('category_delete.html', $st_subdir . 'category/'); } } unset($cat_item); } else { include View::Get('category_add.html', $st_subdir . 'category/'); } break; case 'group': // Пустое название группы
public static function ExistByID($id) { $cat_id = (int) $id; $cat_item = new Category($id); return $cat_item->Exist(); }
$message = $e->getMessage(); $message_type = 'error'; } } /******************************* Handle move/delete category form *******************************/ if (isset($_POST['submitted_edit'])) { // Validate move category if (isset($_POST['move']) && is_numeric($_POST['move']) && Category::Exist(array('cat_id' => $_POST['move']))) { $data['move'] = $_POST['move']; } else { $errors['move'] = 'Invalid receiving (move to) category'; } // Validate category if (isset($_POST['category']) && is_numeric($_POST['category']) && Category::Exist(array('cat_id' => $_POST['category']))) { $data['category'] = $_POST['category']; } else { $errors['category'] = 'Invalid source category'; } // Verify videos aren't moved to same category if (isset($data['category'], $data['move'])) { if ($data['category'] == $data['move']) { $errors['category'] = "Can't move videos to the same category"; } } // Validate action if (!empty($_POST['action']) && in_array($_POST['action'], array('move', 'delete'))) { $data['action'] = $_POST['action']; } else { $errors['action'] = 'Invalid category action';
View::$vars->sub_header = null; View::$vars->category_list = array(); $records_per_page = 9; $url = HOST . '/videos'; // Retrieve Categories $query = "SELECT cat_id FROM " . DB_PREFIX . "categories ORDER BY cat_name ASC"; $result_cats = $db->Query($query); while ($row = $db->FetchObj($result_cats)) { View::$vars->category_list[] = $row->cat_id; } // Prepare for default sorting ('Most Recent Videos') View::$vars->sub_header = Language::GetText('most_recent'); $query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' ORDER BY video_id DESC"; // Retrieve videos if (isset($_GET['category']) && preg_match('/[a-z0-9\\-]+/i', $_GET['category'])) { $id = Category::Exist(array('slug' => $_GET['category'])); if ($id) { $category = new Category($id); $query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' AND cat_id = {$id} ORDER BY video_id DESC"; View::$vars->sub_header = $category->cat_name; $url .= '/' . $_GET['category']; } } elseif (isset($_GET['load']) && in_array($_GET['load'], $load)) { switch ($_GET['load']) { case 'most-viewed': View::$vars->sub_header = Language::GetText('most_viewed'); $query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE status = 'approved' AND private = '0' ORDER BY views DESC"; $url .= '/most-viewed'; break; case 'most-discussed': View::$vars->sub_header = Language::GetText('most_discussed');