blog->getCategory((integer) $cat_id); if ($c->isEmpty()) { http::redirect('categories.php?unknown=1'); } unset($c); try { # Delete category $core->blog->delCategory($cat_id); http::redirect('categories.php?del=1'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } # move post into a category if (!empty($_POST['mov']) && !empty($_POST['mov_cat'])) { try { # Check if category where to move posts exists $keys = array_keys($_POST['mov']); $cat_id = (int) $keys[0]; $mov_cat = (int) $_POST['mov_cat'][$cat_id]; $mov_cat = $mov_cat ? $mov_cat : null; if ($mov_cat !== null) { $c = $core->blog->getCategory($mov_cat); if ($c->isEmpty()) { throw new Exception(__('Category where to move posts does not exist')); } unset($c); } # Move posts if ($mov_cat != $cat_id) { $core->blog->changePostsCategory($cat_id,$mov_cat); } http::redirect('categories.php?move=1'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Update order if (!empty($_POST['save_order']) && !empty($_POST['categories_order'])) { $categories = json_decode($_POST['categories_order']); foreach ($categories as $category) { if (!empty($category->item_id)) { $core->blog->updCategoryPosition($category->item_id, $category->left, $category->right); } } http::redirect('categories.php?reord=1'); } # Reset order if (!empty($_POST['reset'])) { try { $core->blog->resetCategoriesOrder(); http::redirect('categories.php?reord=1'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } /* Display -------------------------------------------------------- */ $rs = $core->blog->getCategories(array('post_type'=>'post')); $starting_script = ""; if (!$core->auth->user_prefs->accessibility->nodragdrop && $core->auth->check('categories',$core->blog->id) && $rs->count()>1) { $starting_script .= dcPage::jsLoad('js/jquery/jquery-ui.custom.js'); $starting_script .= dcPage::jsLoad('js/jquery/jquery.mjs.nestedSortable.js'); } $starting_script .= dcPage::jsLoad('js/_categories.js'); dcPage::open(__('Categories'),$starting_script, dcPage::breadcrumb( array( html::escapeHTML($core->blog->name) => '', ''.__('Categories').'' => '' )) ); if (!empty($_GET['del'])) { dcPage::success(__('The category has been successfully removed.')); } if (!empty($_GET['reord'])) { dcPage::success(__('Categories have been successfully reordered.')); } if (!empty($_GET['unknown'])) { dcPage::success(__('This category does not exist.')); } if (!empty($_GET['move'])) { dcPage::success(__('Entries have been successfully moved to the category you choose.')); } $categories_combo = dcAdminCombos::getCategoriesCombo($rs); echo '
'; echo ''.__('No category so far.').'
'; } else { echo ''; } echo '