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 ''.__('Cinecturlink 2').'' . $headers . ''. dcPage::breadcrumb($breadcrumb) . dcPage::notices(); if ($part == "links") { echo '

' . __('Edit categories') .'

' . '

' . __('New Link') .'

'; } if ($part == "link") { } if ($part == "cats") { echo '

' . __('New Category') .'

'; if ($categories->isEmpty()) { echo '

'.__('There is no category').'

'; } else { echo '
'; $i = 0; while($categories->fetch()) { $id = $categories->cat_id; echo '' . ''; $i++; } echo '
' . __('Categories list') . '
'.__('name').' '.__('description').'
' . form::number(['order[' . $id . ']'], [ 'min' => 1, 'max' => $categories->count(), 'default' => $i +1, 'class' => 'position', 'extra_html' => 'title="' . sprintf(__('position of %s'), html::escapeHTML($categories->cat_title)) . '"' ]) . form::hidden(['dynorder[]', 'dynorder-' . $i], $id) . ' ' . form::checkbox(['items_selected[]', 'ims-' . $i], $id) . ' ' . html::escapeHTML($categories->cat_title) . ' ' . html::escapeHTML($categories->cat_desc) . '

'.__('Check to delete').'

' . ' ' . '' . __('Cancel') . ' (c) '. '' . form::hidden('im_order', '') . $core->formNonce() . '

' . '
'; } } if ($part == 'cat') { if (!empty($catid)) { $category = $C2->getCategories(['cat_id' => $catid]); if (!$category->isEmpty()) { $cattitle = $category->cat_title; $catdesc = $category->cat_desc; } } echo '

' . (empty($catid) ? __('Add categorie') : __('Edit categorie')) . '

' . ' ' . '' . __('Cancel') . ' (c) '. (!empty($catid) ? ' ' : '') . form::hidden('catid', $catid) . $core->formNonce() . '

' . '
'; } dcPage::helpBlock('cinecturlink2'); echo '';