getCategories(); $breadcrumb = [ html::escapeHTML($core->blog->name) => '', __('My cinecturlink') => $part != 'links' ? $core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links']) : '' ]; if ($part == 'link') { $breadcrumb[__('Link')] = ''; } if ($part == 'cats') { $breadcrumb[__('Categories')] = ''; $core->auth->user_prefs->addWorkspace('accessibility'); if (!$core->auth->user_prefs->accessibility->nodragdrop) { $headers .= dcPage::jsLoad('js/jquery/jquery-ui.custom.js') . dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') . dcPage::jsLoad(dcPage::getPF('cinecturlink2/js/cinecturlink2.js')); } try { // reorder categories if (!empty($_POST['save'])) { $catorder = []; if (empty($_POST['im_order']) && !empty($_POST['order'])) { $catorder = $_POST['order']; asort($catorder); $catorder = array_keys($catorder); } elseif (!empty($_POST['im_order'])) { $catorder = $_POST['im_order']; if (substr($catorder, -1) == ',') { $catorder = substr($catorder, 0, strlen($catorder) - 1); } $catorder = explode(',', $catorder); } $i = 0; foreach($catorder as $id) { $i++; $cur = $core->con->openCursor($C2->table . '_cat'); $cur->cat_pos = $i; $C2->updCategory($id, $cur); } dcPage::addSuccessNotice( __('Categories successfully reordered.') ); $core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']); } // delete categories if (!empty($_POST['delete']) && !empty($_POST['items_selected'])) { foreach ($_POST['items_selected'] as $id) { $C2->delCategory($id); } dcPage::addSuccessNotice( __('Category successfully deleted.') ); $core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']); } } catch (Exception $e) { $core->error->add($e->getMessage()); } } if ($part == 'cat') { $breadcrumb[__('Categories')] = $core->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']); $breadcrumb[__('Category')] = ''; try { // create category if (!empty($_POST['save']) && empty($catid) && !empty($cattitle) && !empty($catdesc)) { $exists = $C2->getCategories(['cat_title' => $cattitle], true)->f(0); if ($exists) { throw new Exception(__('Category with same name already exists.')); } $cur = $core->con->openCursor($C2->table . '_cat'); $cur->cat_title = $cattitle; $cur->cat_desc = $catdesc; $catid = $C2->addCategory($cur); dcPage::addSuccessNotice( __('Category successfully created.') ); $core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']); } // update category if (!empty($_POST['save']) && !empty($catid) && !empty($cattitle) && !empty($catdesc)) { $exists = $C2->getCategories(['cat_title' => $cattitle, 'exclude_cat_id' => $catid], true)->f(0); if ($exists) { throw new Exception(__('Category with same name already exists.')); } $cur = $core->con->openCursor($C2->table . '_cat'); $cur->cat_title = $cattitle; $cur->cat_desc = $catdesc; $C2->updCategory($catid, $cur); dcPage::addSuccessNotice( __('Category successfully updated.') ); $core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']); } // delete category if (!empty($_POST['delete']) && !empty($catid)) { $C2->delCategory($catid); dcPage::addSuccessNotice( __('Category successfully deleted.') ); $core->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']); } } catch (Exception $e) { $core->error->add($e->getMessage()); } } echo '
'.__('There is no category').'
'; } else { echo ' '; } } if ($part == 'cat') { if (!empty($catid)) { $category = $C2->getCategories(['cat_id' => $catid]); if (!$category->isEmpty()) { $cattitle = $category->cat_title; $catdesc = $category->cat_desc; } } echo '