2021-09-07 12:33:18 +00:00
|
|
|
<?php
|
2021-09-07 13:21:38 +00:00
|
|
|
/**
|
|
|
|
* @brief cinecturlink2, a plugin for Dotclear 2
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:21:38 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:21:38 +00:00
|
|
|
* @author Jean-Christian Denis and Contributors
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:21:38 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-09-07 12:33:18 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
2021-09-07 13:21:38 +00:00
|
|
|
return null;
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 22:43:02 +00:00
|
|
|
dcPage::check(dcCore::app()->auth->makePermissions([
|
|
|
|
dcAuth::PERMISSION_CONTENT_ADMIN,
|
|
|
|
]));
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$linkid = $_REQUEST['linkid'] ?? '';
|
|
|
|
$linktitle = $_POST['linktitle'] ?? '';
|
|
|
|
$linkdesc = $_POST['linkdesc'] ?? '';
|
2021-09-08 22:12:14 +00:00
|
|
|
$linkauthor = $_POST['linkauthor'] ?? '';
|
2021-11-02 22:55:41 +00:00
|
|
|
$linkurl = $_POST['linkurl'] ?? '';
|
|
|
|
$linkcat = $_POST['linkcat'] ?? null;
|
2022-11-17 21:01:00 +00:00
|
|
|
$linklang = $_POST['linklang'] ?? dcCore::app()->auth->getInfo('user_lang');
|
2021-11-02 22:55:41 +00:00
|
|
|
$linkimage = $_POST['linkimage'] ?? '';
|
|
|
|
$linknote = $_POST['linknote'] ?? '';
|
|
|
|
$catid = $_REQUEST['catid'] ?? '';
|
|
|
|
$cattitle = $_POST['cattitle'] ?? '';
|
|
|
|
$catdesc = $_POST['catdesc'] ?? '';
|
|
|
|
$redir = $_REQUEST['redir'] ?? '';
|
|
|
|
$part = $_REQUEST['part'] ?? 'links';
|
|
|
|
$entries = $_POST['entries'] ?? [];
|
|
|
|
$headers = '';
|
2021-09-07 23:49:50 +00:00
|
|
|
$breadcrumb = [
|
2021-11-02 22:55:41 +00:00
|
|
|
__('Plugins') => '',
|
2022-11-17 21:01:00 +00:00
|
|
|
__('My cinecturlink') => dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links']),
|
2021-09-07 23:49:50 +00:00
|
|
|
];
|
2021-09-08 22:12:14 +00:00
|
|
|
if (!in_array($part, ['links', 'link', 'cats', 'cat', 'dellinks', 'updlinksnote', 'updlinkscat'])) {
|
|
|
|
$part = 'links';
|
|
|
|
}
|
|
|
|
if (!is_array($entries)) {
|
|
|
|
$entries == [];
|
|
|
|
}
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2021-09-08 22:12:14 +00:00
|
|
|
try {
|
2022-11-17 21:01:00 +00:00
|
|
|
$C2 = new cinecturlink2();
|
2021-11-02 22:55:41 +00:00
|
|
|
$categories = $C2->getCategories();
|
2021-09-08 22:12:14 +00:00
|
|
|
$categories_combo = ['-' => ''];
|
2021-11-02 22:55:41 +00:00
|
|
|
while ($categories->fetch()) {
|
|
|
|
$cat_title = html::escapeHTML($categories->cat_title);
|
2021-09-08 22:12:14 +00:00
|
|
|
$categories_combo[$cat_title] = $categories->cat_id;
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-09-07 23:49:50 +00:00
|
|
|
}
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2021-09-08 22:12:14 +00:00
|
|
|
if ($part == 'dellinks') {
|
|
|
|
try {
|
|
|
|
// delete group of links
|
|
|
|
if (!empty($entries)) {
|
|
|
|
foreach ($entries as $id) {
|
|
|
|
$C2->delLink($id);
|
|
|
|
}
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-08 22:12:14 +00:00
|
|
|
__('Links successfully deleted.')
|
|
|
|
);
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
$breadcrumb[__('Delete links')] = '';
|
|
|
|
}
|
2021-09-07 23:49:50 +00:00
|
|
|
|
2021-09-08 22:12:14 +00:00
|
|
|
// get list of secleted links
|
|
|
|
if (in_array($part, ['updlinksnote', 'updlinkscat'])) {
|
|
|
|
try {
|
|
|
|
$links = $C2->getLinks(['link_id' => $entries]);
|
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-09-07 23:49:50 +00:00
|
|
|
}
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
2021-09-07 23:49:50 +00:00
|
|
|
|
2021-09-08 22:12:14 +00:00
|
|
|
if ($part == 'updlinksnote') {
|
|
|
|
try {
|
|
|
|
// update group of links note
|
|
|
|
if (!empty($entries) && isset($_POST['newlinknote'])) {
|
2021-11-02 22:55:41 +00:00
|
|
|
while ($links->fetch()) {
|
2021-09-08 22:12:14 +00:00
|
|
|
if (in_array($links->link_id, $entries)) {
|
2022-11-17 21:01:00 +00:00
|
|
|
$cur = dcCore::app()->con->openCursor($C2->table);
|
2021-11-02 22:55:41 +00:00
|
|
|
$cur->link_note = (int) $_POST['newlinknote'];
|
2021-09-08 22:12:14 +00:00
|
|
|
$C2->updLink($links->link_id, $cur);
|
|
|
|
}
|
|
|
|
}
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-08 22:12:14 +00:00
|
|
|
__('Links successfully updated.')
|
|
|
|
);
|
|
|
|
if (!empty($_POST['redir'])) {
|
|
|
|
http::redirect($redir);
|
|
|
|
} else {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
$breadcrumb[__('Update links rating')] = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($part == 'updlinkscat') {
|
|
|
|
try {
|
|
|
|
// update group of links category
|
|
|
|
if (!empty($entries) && !empty($_POST['newcatid'])) {
|
2021-11-02 22:55:41 +00:00
|
|
|
while ($links->fetch()) {
|
2021-09-08 22:12:14 +00:00
|
|
|
if (in_array($links->link_id, $entries)) {
|
2022-11-17 21:01:00 +00:00
|
|
|
$cur = dcCore::app()->con->openCursor($C2->table);
|
2021-11-02 22:55:41 +00:00
|
|
|
$cur->cat_id = (int) $_POST['newcatid'];
|
2021-09-08 22:12:14 +00:00
|
|
|
$C2->updLink($links->link_id, $cur);
|
|
|
|
}
|
|
|
|
}
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-08 22:12:14 +00:00
|
|
|
__('Links successfully updated.')
|
|
|
|
);
|
|
|
|
if (!empty($_POST['redir'])) {
|
|
|
|
http::redirect($redir);
|
|
|
|
} else {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
$breadcrumb[__('Update links category')] = '';
|
2021-11-02 22:55:41 +00:00
|
|
|
}
|
2021-09-08 22:12:14 +00:00
|
|
|
|
|
|
|
if ($part == 'links') {
|
|
|
|
$action_combo = [
|
2021-11-02 22:55:41 +00:00
|
|
|
__('Delete') => 'dellinks',
|
2021-09-08 22:12:14 +00:00
|
|
|
__('Change category') => 'updlinkscat',
|
2022-11-17 21:01:00 +00:00
|
|
|
__('Change rating') => 'updlinksnote',
|
2021-09-08 22:12:14 +00:00
|
|
|
];
|
|
|
|
|
2022-11-17 21:01:00 +00:00
|
|
|
$c2link_filter = new adminGenericFilterV2('c2link');
|
2021-10-09 15:27:02 +00:00
|
|
|
$c2link_filter->add('part', 'links');
|
|
|
|
$c2link_filter->add(dcAdminFilters::getPageFilter());
|
2021-11-04 01:03:49 +00:00
|
|
|
$c2link_filter->add(dcAdminFilters::getSearchFilter());
|
2021-10-09 15:27:02 +00:00
|
|
|
$c2link_filter->add(dcAdminFilters::getSelectFilter(
|
2021-11-02 22:55:41 +00:00
|
|
|
'catid',
|
|
|
|
__('Category:'),
|
|
|
|
$categories_combo,
|
|
|
|
'cat_id'
|
2021-10-09 15:27:02 +00:00
|
|
|
));
|
2021-09-28 23:01:25 +00:00
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$params = $c2link_filter->params();
|
|
|
|
$params['link_type'] = 'cinecturlink';
|
2021-09-08 22:12:14 +00:00
|
|
|
$params['no_content'] = true;
|
|
|
|
|
|
|
|
$links_list = null;
|
|
|
|
|
|
|
|
try {
|
2021-11-02 22:55:41 +00:00
|
|
|
$links = $C2->getLinks($params);
|
|
|
|
$links_counter = $C2->getLinks($params, true)->f(0);
|
2022-11-17 21:01:00 +00:00
|
|
|
$links_list = new adminlistCinecturlink2($links, $links_counter);
|
2021-09-08 22:12:14 +00:00
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$breadcrumb[__('My cinecturlink')] = '';
|
2022-11-17 21:01:00 +00:00
|
|
|
$headers .= dcPage::jsVars(['dotclear.filter_reset_url' => dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])]) .
|
2021-10-03 20:08:39 +00:00
|
|
|
dcPage::jsFilterControl($c2link_filter->show()) .
|
2021-09-08 22:12:14 +00:00
|
|
|
dcPage::jsLoad(dcPage::getPF('cinecturlink2/js/c2links.js'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($part == 'link') {
|
|
|
|
$langs_combo = l10n::getISOcodes(true);
|
|
|
|
$notes_combo = range(0, 20);
|
|
|
|
$media_combo = $tmp_media_combo = $dir = null;
|
2021-11-02 22:55:41 +00:00
|
|
|
|
2021-09-08 22:12:14 +00:00
|
|
|
try {
|
2022-11-17 21:01:00 +00:00
|
|
|
$allowed_media = ['png', 'jpg', 'gif', 'bmp', 'jpeg'];
|
|
|
|
dcCore::app()->media = new dcMedia();
|
|
|
|
dcCore::app()->media->chdir(dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_folder);
|
|
|
|
dcCore::app()->media->getDir();
|
|
|
|
$dir = & dcCore::app()->media->dir;
|
2021-09-08 22:12:14 +00:00
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
foreach ($dir['files'] as $file) {
|
2021-09-08 22:12:14 +00:00
|
|
|
if (!in_array(files::getExtension($file->relname), $allowed_media)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$tmp_media_combo[$file->media_title] = $file->file_url;
|
|
|
|
}
|
|
|
|
if (!empty($tmp_media_combo)) {
|
|
|
|
$media_combo = array_merge(['-' => ''], $tmp_media_combo);
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
//dcCore::app()->error->add($e->getMessage());
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($_POST['save'])) {
|
|
|
|
try {
|
2021-11-02 22:53:06 +00:00
|
|
|
cinecturlink2::makePublicDir(
|
2022-11-17 21:01:00 +00:00
|
|
|
DC_ROOT . '/' . dcCore::app()->blog->settings->system->public_path,
|
|
|
|
dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_folder
|
2021-09-08 22:12:14 +00:00
|
|
|
);
|
|
|
|
if (empty($linktitle)) {
|
|
|
|
throw new Exception(__('You must provide a title.'));
|
|
|
|
}
|
|
|
|
if (empty($linkauthor)) {
|
|
|
|
throw new Exception(__('You must provide an author.'));
|
|
|
|
}
|
|
|
|
if (!preg_match('/https?:\/\/.+/', $linkimage)) {
|
|
|
|
throw new Exception(__('You must provide a link to an image.'));
|
|
|
|
}
|
|
|
|
|
2022-11-17 21:01:00 +00:00
|
|
|
$cur = dcCore::app()->con->openCursor($C2->table);
|
2021-11-02 22:55:41 +00:00
|
|
|
$cur->link_title = $linktitle;
|
|
|
|
$cur->link_desc = $linkdesc;
|
2021-09-08 22:12:14 +00:00
|
|
|
$cur->link_author = $linkauthor;
|
2021-11-02 22:55:41 +00:00
|
|
|
$cur->link_url = $linkurl;
|
|
|
|
$cur->cat_id = $linkcat == '' ? null : $linkcat;
|
|
|
|
$cur->link_lang = $linklang;
|
|
|
|
$cur->link_img = $linkimage;
|
|
|
|
$cur->link_note = $linknote;
|
2021-09-08 22:12:14 +00:00
|
|
|
|
|
|
|
// create a link
|
|
|
|
if (empty($linkid)) {
|
|
|
|
$exists = $C2->getLinks(['link_title' => $linktitle], true)->f(0);
|
|
|
|
if ($exists) {
|
|
|
|
throw new Exception(__('Link with same name already exists.'));
|
|
|
|
}
|
|
|
|
$linkid = $C2->addLink($cur);
|
|
|
|
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-08 22:12:14 +00:00
|
|
|
__('Link successfully created.')
|
|
|
|
);
|
|
|
|
// update a link
|
|
|
|
} else {
|
|
|
|
$exists = $C2->getLinks(['link_id' => $linkid], true)->f(0);
|
|
|
|
if (!$exists) {
|
|
|
|
throw new Exception(__('Unknown link.'));
|
|
|
|
}
|
|
|
|
$C2->updLink($linkid, $cur);
|
|
|
|
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-08 22:12:14 +00:00
|
|
|
__('Link successfully updated.')
|
|
|
|
);
|
|
|
|
}
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->redirect(
|
2021-11-02 22:55:41 +00:00
|
|
|
'admin.plugin.cinecturlink2',
|
2021-09-08 22:12:14 +00:00
|
|
|
[
|
2021-11-02 22:55:41 +00:00
|
|
|
'part' => 'link',
|
2021-09-08 22:12:14 +00:00
|
|
|
'linkid' => $linkid,
|
2022-11-17 21:01:00 +00:00
|
|
|
'redir' => $redir,
|
2021-09-08 22:12:14 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($_POST['delete']) && !empty($linkid)) {
|
|
|
|
try {
|
|
|
|
$C2->delLink($linkid);
|
|
|
|
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-08 22:12:14 +00:00
|
|
|
__('Link successfully deleted.')
|
|
|
|
);
|
|
|
|
if (!empty($_POST['redir'])) {
|
|
|
|
http::redirect($redir);
|
|
|
|
} else {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'links']);
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($linkid)) {
|
|
|
|
$link = $C2->getLinks(['link_id' => $linkid]);
|
|
|
|
if (!$link->isEmpty()) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$linktitle = $link->link_title;
|
|
|
|
$linkdesc = $link->link_desc;
|
2021-09-08 22:12:14 +00:00
|
|
|
$linkauthor = $link->link_author;
|
2021-11-02 22:55:41 +00:00
|
|
|
$linkurl = $link->link_url;
|
|
|
|
$linkcat = $link->cat_id;
|
|
|
|
$linklang = $link->link_lang;
|
|
|
|
$linkimage = $link->link_img;
|
|
|
|
$linknote = $link->link_note;
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$breadcrumb[(empty($linkid) ? __('New link') : __('Edit link'))] = '';
|
2022-11-17 21:01:00 +00:00
|
|
|
$headers .= dcPage::jsVars(['dotclear.c2_lang' => dcCore::app()->auth->getInfo('user_lang')]) .
|
2021-09-08 22:12:14 +00:00
|
|
|
dcPage::jsLoad(dcPage::getPF('cinecturlink2/js/c2link.js'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($part == 'cats') {
|
2021-09-07 23:49:50 +00:00
|
|
|
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;
|
2021-11-02 22:55:41 +00:00
|
|
|
foreach ($catorder as $id) {
|
2021-09-07 23:49:50 +00:00
|
|
|
$i++;
|
2022-11-17 21:01:00 +00:00
|
|
|
$cur = dcCore::app()->con->openCursor($C2->table . '_cat');
|
2021-09-07 23:49:50 +00:00
|
|
|
$cur->cat_pos = $i;
|
2021-09-07 13:21:38 +00:00
|
|
|
$C2->updCategory($id, $cur);
|
|
|
|
}
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-07 13:21:38 +00:00
|
|
|
__('Categories successfully reordered.')
|
|
|
|
);
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-09-07 23:49:50 +00:00
|
|
|
// delete categories
|
|
|
|
if (!empty($_POST['delete']) && !empty($_POST['items_selected'])) {
|
|
|
|
foreach ($_POST['items_selected'] as $id) {
|
|
|
|
$C2->delCategory($id);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-08 22:12:14 +00:00
|
|
|
__('Categories successfully deleted.')
|
2021-09-07 13:21:38 +00:00
|
|
|
);
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-09-07 23:49:50 +00:00
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-09-08 22:12:14 +00:00
|
|
|
|
|
|
|
$breadcrumb[__('Categories')] = '';
|
|
|
|
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->auth->user_prefs->addWorkspace('accessibility');
|
|
|
|
if (!dcCore::app()->auth->user_prefs->accessibility->nodragdrop) {
|
2021-11-02 22:55:41 +00:00
|
|
|
$headers .= dcPage::jsLoad('js/jquery/jquery-ui.custom.js') .
|
2021-09-08 22:12:14 +00:00
|
|
|
dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') .
|
|
|
|
dcPage::jsLoad(dcPage::getPF('cinecturlink2/js/c2cats.js'));
|
|
|
|
}
|
2021-09-07 23:49:50 +00:00
|
|
|
}
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2021-09-07 23:49:50 +00:00
|
|
|
if ($part == 'cat') {
|
|
|
|
try {
|
|
|
|
// create category
|
|
|
|
if (!empty($_POST['save']) && empty($catid) && !empty($cattitle) && !empty($catdesc)) {
|
|
|
|
$exists = $C2->getCategories(['cat_title' => $cattitle], true)->f(0);
|
2021-09-07 13:21:38 +00:00
|
|
|
if ($exists) {
|
2021-09-07 23:49:50 +00:00
|
|
|
throw new Exception(__('Category with same name already exists.'));
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2022-11-17 21:01:00 +00:00
|
|
|
$cur = dcCore::app()->con->openCursor($C2->table . '_cat');
|
2021-09-07 23:49:50 +00:00
|
|
|
$cur->cat_title = $cattitle;
|
2021-11-02 22:55:41 +00:00
|
|
|
$cur->cat_desc = $catdesc;
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2021-09-07 23:49:50 +00:00
|
|
|
$catid = $C2->addCategory($cur);
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-07 23:49:50 +00:00
|
|
|
__('Category successfully created.')
|
2021-09-07 13:21:38 +00:00
|
|
|
);
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-09-07 23:49:50 +00:00
|
|
|
// 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.'));
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2022-11-17 21:01:00 +00:00
|
|
|
$cur = dcCore::app()->con->openCursor($C2->table . '_cat');
|
2021-09-07 23:49:50 +00:00
|
|
|
$cur->cat_title = $cattitle;
|
2021-11-02 22:55:41 +00:00
|
|
|
$cur->cat_desc = $catdesc;
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2021-09-07 23:49:50 +00:00
|
|
|
$C2->updCategory($catid, $cur);
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-07 23:49:50 +00:00
|
|
|
__('Category successfully updated.')
|
2021-09-07 13:21:38 +00:00
|
|
|
);
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-09-07 23:49:50 +00:00
|
|
|
// delete category
|
|
|
|
if (!empty($_POST['delete']) && !empty($catid)) {
|
|
|
|
$C2->delCategory($catid);
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2022-11-17 21:01:00 +00:00
|
|
|
dcAdminNotices::addSuccessNotice(
|
2021-09-07 23:49:50 +00:00
|
|
|
__('Category successfully deleted.')
|
|
|
|
);
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->redirect('admin.plugin.cinecturlink2', ['part' => 'cats']);
|
2021-09-07 23:49:50 +00:00
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2022-11-17 21:01:00 +00:00
|
|
|
$breadcrumb[__('Categories')] = dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']);
|
2021-09-08 22:12:14 +00:00
|
|
|
$breadcrumb[(empty($catid) ? __('New category') : __('Edit category'))] = '';
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
echo
|
|
|
|
'<html><head><title>' . __('Cinecturlink 2') . '</title>' .
|
2021-09-07 23:49:50 +00:00
|
|
|
$headers .
|
2021-11-02 22:55:41 +00:00
|
|
|
'</head><body>' .
|
2021-09-07 23:49:50 +00:00
|
|
|
dcPage::breadcrumb($breadcrumb) .
|
|
|
|
dcPage::notices();
|
|
|
|
|
2021-09-08 22:12:14 +00:00
|
|
|
if (!empty($redir)) {
|
2021-11-02 22:55:41 +00:00
|
|
|
echo '<p><a class="back" href="' . $redir . '">' . __('Back') . ' </a></p>';
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
if (!empty($title)) {
|
|
|
|
echo '<h3>' . $title . '</h3>';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($part == 'updlinksnote') {
|
|
|
|
if ($links->isEmpty()) {
|
2021-11-02 22:55:41 +00:00
|
|
|
echo '<p>' . __('There is no link') . '</p>';
|
2021-09-08 22:12:14 +00:00
|
|
|
} else {
|
|
|
|
echo '<h4>' . __('Links') . '</h4><ul>';
|
2021-11-02 22:55:41 +00:00
|
|
|
while ($links->fetch()) {
|
2021-11-03 23:37:43 +00:00
|
|
|
echo '<li><strong>' . $links->link_title . '</strong> - ' . $links->link_note . '/20</li>';
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
echo '</ul>';
|
|
|
|
|
|
|
|
echo '<h4>' . __('Rating') . '</h4>
|
2022-11-17 21:01:00 +00:00
|
|
|
<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '">' .
|
2021-09-08 22:12:14 +00:00
|
|
|
'<p><label for="newlinknote" class="ib">' . __('New rating:') . '</label> ' .
|
|
|
|
form::number('newlinknote', [
|
2021-11-02 22:55:41 +00:00
|
|
|
'min' => 0,
|
|
|
|
'max' => 20,
|
2022-11-17 21:01:00 +00:00
|
|
|
'default' => 10,
|
2021-09-08 22:12:14 +00:00
|
|
|
]) . '/20' . '</p>' .
|
|
|
|
'<p>' .
|
|
|
|
'<input type="submit" value="' . __('Save') . ' (s)" accesskey="s" name="save" /> ' .
|
2021-11-02 22:55:41 +00:00
|
|
|
'<a id="post-cancel" href="' . (
|
|
|
|
$redir ? $redir :
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])
|
2021-09-08 22:12:14 +00:00
|
|
|
) . '" class="button" accesskey="c">' . __('Cancel') . ' (c)</a> ';
|
2021-11-02 22:55:41 +00:00
|
|
|
foreach ($entries as $id) {
|
2021-09-08 22:12:14 +00:00
|
|
|
echo form::hidden(['entries[]'], $id);
|
|
|
|
}
|
2021-11-02 22:55:41 +00:00
|
|
|
echo
|
2021-09-08 22:12:14 +00:00
|
|
|
form::hidden('part', 'updlinksnote') .
|
|
|
|
form::hidden('redir', $redir) .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->formNonce() . '</p>' .
|
2021-09-08 22:12:14 +00:00
|
|
|
'</form>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($part == 'updlinkscat') {
|
|
|
|
if ($links->isEmpty()) {
|
2021-11-02 22:55:41 +00:00
|
|
|
echo '<p>' . __('There is no link') . '</p>';
|
2021-09-08 22:12:14 +00:00
|
|
|
} else {
|
|
|
|
echo '<h4>' . __('Links') . '</h4><ul>';
|
2021-11-02 22:55:41 +00:00
|
|
|
while ($links->fetch()) {
|
2021-11-03 23:37:43 +00:00
|
|
|
echo '<li><strong>' . $links->link_title . '</strong> - ' . ($links->cat_title ?? __('no categories')) . '</li>';
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
echo '</ul>';
|
|
|
|
|
|
|
|
echo '<h4>' . __('Category') . '</h4>
|
2022-11-17 21:01:00 +00:00
|
|
|
<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '">' .
|
2021-09-08 22:12:14 +00:00
|
|
|
'<p><label for="newcatid" class="ib">' . __('New category:') . '</label> ' .
|
|
|
|
form::combo('newcatid', $categories_combo, $catid) . '</p>' .
|
|
|
|
'<input type="submit" value="' . __('Save') . ' (s)" accesskey="s" name="save" /> ' .
|
2021-11-02 22:55:41 +00:00
|
|
|
'<a id="post-cancel" href="' . (
|
|
|
|
$redir ? $redir :
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links'])
|
2021-09-08 22:12:14 +00:00
|
|
|
) . '" class="button" accesskey="c">' . __('Cancel') . ' (c)</a> ';
|
2021-11-02 22:55:41 +00:00
|
|
|
foreach ($entries as $id) {
|
2021-09-08 22:12:14 +00:00
|
|
|
echo form::hidden(['entries[]'], $id);
|
|
|
|
}
|
2021-11-02 22:55:41 +00:00
|
|
|
echo
|
2021-09-08 22:12:14 +00:00
|
|
|
form::hidden('part', 'updlinkscat') .
|
|
|
|
form::hidden('redir', $redir) .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->formNonce() . '</p>' .
|
2021-09-08 22:12:14 +00:00
|
|
|
'</form>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
if ($part == 'links') {
|
2022-11-17 21:01:00 +00:00
|
|
|
$links_redir = dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', $c2link_filter->values());
|
2021-10-03 20:08:39 +00:00
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
echo
|
|
|
|
'<p class="top-add"><a class="button add" href="' .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'link', 'redir' => $links_redir]) .
|
2021-11-02 22:55:41 +00:00
|
|
|
'">' . __('New Link') . '</a> <a class="button add" href="' .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats', 'redir' => $links_redir]) .
|
2021-11-03 23:37:43 +00:00
|
|
|
'">' . __('Edit categories') . ' </a></p>';
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2021-10-09 15:27:02 +00:00
|
|
|
if ($links->isEmpty() && !$c2link_filter->show()) {
|
2021-11-02 22:55:41 +00:00
|
|
|
echo '<p>' . __('There is no link') . '</p>';
|
2021-09-08 22:12:14 +00:00
|
|
|
} else {
|
2021-11-02 22:55:41 +00:00
|
|
|
$c2link_filter->display(
|
|
|
|
'admin.plugin.cinecturlink2',
|
2021-10-03 20:08:39 +00:00
|
|
|
form::hidden('p', 'cinecturlink2') . form::hidden('part', 'links')
|
|
|
|
);
|
2021-09-08 22:12:14 +00:00
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$links_list->display(
|
|
|
|
$c2link_filter->page,
|
|
|
|
$c2link_filter->nb,
|
2022-11-17 21:01:00 +00:00
|
|
|
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '" method="post" id="form-entries">' .
|
2021-09-08 22:12:14 +00:00
|
|
|
|
|
|
|
'%s' .
|
|
|
|
|
|
|
|
'<div class="two-cols">' .
|
|
|
|
'<p class="col checkboxes-helpers"></p>' .
|
|
|
|
|
|
|
|
'<p class="col right"><label for="action" class="classic">' . __('Selected links action:') . '</label> ' .
|
|
|
|
form::combo('part', $action_combo) .
|
|
|
|
'<input id="do-action" type="submit" value="' . __('ok') . '" disabled /></p>' .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.cinecturlink2', array_diff_key($c2link_filter->values(), ['part' => ''])) .
|
2021-09-08 22:12:14 +00:00
|
|
|
form::hidden(['redir'], $links_redir) .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->formNonce() .
|
2021-09-08 22:12:14 +00:00
|
|
|
'</div>' .
|
|
|
|
'</form>',
|
2021-10-03 20:08:39 +00:00
|
|
|
$c2link_filter->show(),
|
2021-09-08 22:12:14 +00:00
|
|
|
$links_redir
|
|
|
|
);
|
|
|
|
}
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
if ($part == 'link') {
|
2021-09-08 22:12:14 +00:00
|
|
|
echo '
|
2022-11-17 21:01:00 +00:00
|
|
|
<form id="newlinkform" method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '">
|
2021-09-08 22:12:14 +00:00
|
|
|
|
|
|
|
<div class="two-cols clearfix">
|
|
|
|
<div class="col70">
|
|
|
|
<p><label for="linktitle">' . __('Title:') . ' ' .
|
|
|
|
form::field('linktitle', 60, 255, html::escapeHTML($linktitle), 'maximal') .
|
|
|
|
'</label></p>
|
|
|
|
<p><label for="linkdesc">' . __('Description:') . ' ' .
|
2021-11-02 22:55:41 +00:00
|
|
|
form::field('linkdesc', 60, 255, html::escapeHTML($linkdesc), 'maximal') .
|
2021-09-08 22:12:14 +00:00
|
|
|
'</label></p>
|
|
|
|
<p><label for="linkauthor">' . __('Author:') . ' ' .
|
2021-11-02 22:55:41 +00:00
|
|
|
form::field('linkauthor', 60, 255, html::escapeHTML($linkauthor), 'maximal') .
|
2021-09-08 22:12:14 +00:00
|
|
|
'</label></p>
|
|
|
|
<p><label for="linkurl">' . __('Details URL:') . ' ' .
|
2021-11-02 22:55:41 +00:00
|
|
|
form::field('linkurl', 60, 255, html::escapeHTML($linkurl), 'maximal') . '</label>' .
|
2021-10-25 20:43:01 +00:00
|
|
|
'<a class="modal hidden-if-no-js" href="http://google.com" id="newlinksearch">' .
|
2021-09-08 22:12:14 +00:00
|
|
|
__('Search with Google') . '</a>' .
|
|
|
|
'</p>
|
|
|
|
<p><label for="linkimage">' . __('Image URL:') . ' ' .
|
2021-11-02 22:55:41 +00:00
|
|
|
form::field('linkimage', 60, 255, html::escapeHTML($linkimage), 'maximal') . '</label>' .
|
2021-10-25 20:43:01 +00:00
|
|
|
'<a class="modal hidden-if-no-js"" href="http://amazon.com" id="newimagesearch">' .
|
2021-09-08 22:12:14 +00:00
|
|
|
__('Search with Amazon') . '</a>' .
|
|
|
|
'</p>';
|
|
|
|
|
|
|
|
if (empty($media_combo)) {
|
|
|
|
echo
|
|
|
|
'<p class="form-note">' . __('There is no image in cinecturlink media path.') . '</p>';
|
|
|
|
} else {
|
|
|
|
echo '
|
|
|
|
<p><label for="newimageselect">' . __('or select from repository:') . ' ' .
|
|
|
|
form::combo('newimageselect', $media_combo, '', 'maximal') .
|
|
|
|
'</label></p>' .
|
2021-11-02 22:55:41 +00:00
|
|
|
'<p class="form-note"><a href="' .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->get('admin.media', ['d' => (string) dcCore::app()->blog->settings->cinecturlink2->cinecturlink2_folder]) . '">' .
|
2021-11-02 22:55:41 +00:00
|
|
|
__('Go to media manager to add image to cinecturlink path.') .
|
2021-10-28 20:38:34 +00:00
|
|
|
'<a></p>';
|
2021-09-08 22:12:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
<div class="col30">
|
|
|
|
<p><label for="linkcat">' . __('Category:') . '</label> ' .
|
|
|
|
form::combo('linkcat', $categories_combo, $linkcat) .
|
|
|
|
'</p>
|
|
|
|
<p><label for="linklang">' . __('Lang:') . '</label> ' .
|
|
|
|
form::combo('linklang', $langs_combo, $linklang) .
|
|
|
|
'</p>
|
|
|
|
<p><label for="linknote">' . __('Rating:') . '</label> ' .
|
|
|
|
form::number('linknote', [
|
2021-11-02 22:55:41 +00:00
|
|
|
'min' => 0,
|
|
|
|
'max' => 20,
|
2022-11-17 21:01:00 +00:00
|
|
|
'default' => $linknote,
|
2021-09-08 22:12:14 +00:00
|
|
|
]) . '/20' . '</p>
|
|
|
|
</div></div>
|
|
|
|
|
|
|
|
<p class="border-top">' .
|
|
|
|
'<input type="submit" value="' . __('Save') . ' (s)" accesskey="s" name="save" /> ' .
|
2021-11-02 22:55:41 +00:00
|
|
|
'<a id="post-cancel" href="' .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'links']) .
|
2021-11-02 22:55:41 +00:00
|
|
|
'" class="button" accesskey="c">' . __('Cancel') . ' (c)</a> ' .
|
2021-09-08 22:12:14 +00:00
|
|
|
'<input type="submit" class="delete" value="' . __('Delete') . '" name="delete" />' .
|
|
|
|
form::hidden('linkid', $linkid) .
|
|
|
|
form::hidden('part', 'link') .
|
|
|
|
form::hidden('redir', $redir) .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->formNonce() . '
|
2021-09-08 22:12:14 +00:00
|
|
|
</p>
|
|
|
|
</form>';
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
if ($part == 'cats') {
|
|
|
|
echo
|
|
|
|
'<p class="top-add"><a class="button add" href="' .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->get(
|
2021-11-02 22:55:41 +00:00
|
|
|
'admin.plugin.cinecturlink2',
|
2021-09-08 22:12:14 +00:00
|
|
|
[
|
2021-11-02 22:55:41 +00:00
|
|
|
'part' => 'cat',
|
2022-11-17 21:01:00 +00:00
|
|
|
'redir' => dcCore::app()->adminurl->get(
|
2021-11-02 22:55:41 +00:00
|
|
|
'admin.plugin.cinecturlink2',
|
2021-09-08 22:12:14 +00:00
|
|
|
[
|
2021-11-02 22:55:41 +00:00
|
|
|
'part' => 'cats',
|
2021-09-08 22:12:14 +00:00
|
|
|
'redir' => $redir,
|
|
|
|
]
|
2022-11-17 21:01:00 +00:00
|
|
|
),
|
2021-09-08 22:12:14 +00:00
|
|
|
]
|
2021-11-02 22:55:41 +00:00
|
|
|
) .
|
|
|
|
'">' . __('New Category') . ' </a></p>';
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
if ($categories->isEmpty()) {
|
2021-11-02 22:55:41 +00:00
|
|
|
echo '<p>' . __('There is no category') . '</p>';
|
|
|
|
} else {
|
2021-09-07 13:21:38 +00:00
|
|
|
echo '
|
2022-11-17 21:01:00 +00:00
|
|
|
<form id="c2items" method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '">
|
2021-09-07 23:49:50 +00:00
|
|
|
<div class="table-outer">
|
|
|
|
<table class="dragable">
|
|
|
|
<caption>' . __('Categories list') . '</caption>
|
|
|
|
<thead><tr>
|
2021-11-02 22:55:41 +00:00
|
|
|
<th colspan="3" scope="col">' . __('name') . '</th>
|
|
|
|
<th scope="col">' . __('description') . '</th>
|
2021-09-07 23:49:50 +00:00
|
|
|
</tr></thead>
|
|
|
|
<tbody id="c2itemslist">';
|
2021-09-07 13:21:38 +00:00
|
|
|
|
|
|
|
$i = 0;
|
2021-11-02 22:55:41 +00:00
|
|
|
while ($categories->fetch()) {
|
2021-09-07 13:21:38 +00:00
|
|
|
$id = $categories->cat_id;
|
2021-09-07 23:49:50 +00:00
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
echo
|
2021-09-07 23:49:50 +00:00
|
|
|
'<tr class="line" id="l_' . $i . '">' .
|
|
|
|
'<td class="handle minimal">' .
|
|
|
|
form::number(['order[' . $id . ']'], [
|
|
|
|
'min' => 1,
|
|
|
|
'max' => $categories->count(),
|
2021-11-02 22:55:41 +00:00
|
|
|
'default' => $i + 1,
|
2021-09-07 23:49:50 +00:00
|
|
|
'class' => 'position',
|
2022-11-17 21:01:00 +00:00
|
|
|
'extra_html' => 'title="' . sprintf(__('position of %s'), html::escapeHTML($categories->cat_title)) . '"',
|
2021-09-07 23:49:50 +00:00
|
|
|
]) .
|
|
|
|
form::hidden(['dynorder[]', 'dynorder-' . $i], $id) . '</td>
|
|
|
|
<td class="minimal">' . form::checkbox(['items_selected[]', 'ims-' . $i], $id) . '</td>
|
2021-11-02 22:55:41 +00:00
|
|
|
<td class="nowrap"><a title="' . __('Edit') . '" href="' .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->get(
|
2021-11-02 22:55:41 +00:00
|
|
|
'admin.plugin.cinecturlink2',
|
2021-09-08 22:12:14 +00:00
|
|
|
[
|
2021-11-02 22:55:41 +00:00
|
|
|
'part' => 'cat',
|
|
|
|
'catid' => $id,
|
2022-11-17 21:01:00 +00:00
|
|
|
'redir' => dcCore::app()->adminurl->get(
|
2021-11-02 22:55:41 +00:00
|
|
|
'admin.plugin.cinecturlink2',
|
2021-09-08 22:12:14 +00:00
|
|
|
[
|
2021-11-02 22:55:41 +00:00
|
|
|
'part' => 'cats',
|
2022-11-17 21:01:00 +00:00
|
|
|
'redir' => $redir,
|
2021-09-08 22:12:14 +00:00
|
|
|
]
|
2022-11-17 21:01:00 +00:00
|
|
|
),
|
2021-09-08 22:12:14 +00:00
|
|
|
]
|
2021-11-02 22:55:41 +00:00
|
|
|
) .
|
2021-09-07 23:49:50 +00:00
|
|
|
'">' . html::escapeHTML($categories->cat_title) . '</a></td>
|
|
|
|
<td class="maximal">' . html::escapeHTML($categories->cat_desc) . '</td>
|
2021-09-07 13:21:38 +00:00
|
|
|
</tr>';
|
2021-09-07 23:49:50 +00:00
|
|
|
$i++;
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2021-09-07 23:49:50 +00:00
|
|
|
</div>
|
2021-11-02 22:55:41 +00:00
|
|
|
<p class="form-note">' . __('Check to delete') . '</p>
|
2021-09-07 23:49:50 +00:00
|
|
|
<p class="border-top">' .
|
|
|
|
'<input type="submit" value="' . __('Save order') . ' (s)" accesskey="s" name="save" /> ' .
|
2021-11-02 22:55:41 +00:00
|
|
|
'<a id="post-cancel" href="' .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']) .
|
2021-11-02 22:55:41 +00:00
|
|
|
'" class="button" accesskey="c">' . __('Cancel') . ' (c)</a> ' .
|
2021-09-07 23:49:50 +00:00
|
|
|
'<input type="submit" class="delete" value="' . __('Delete selection') . '" name="delete" />' .
|
|
|
|
form::hidden('im_order', '') .
|
2021-09-08 22:12:14 +00:00
|
|
|
form::hidden('part', 'cats') .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->formNonce() . '</p>' .
|
2021-09-07 23:49:50 +00:00
|
|
|
'</form>';
|
2021-09-07 13:21:38 +00:00
|
|
|
}
|
2021-09-07 23:49:50 +00:00
|
|
|
}
|
2021-09-07 13:21:38 +00:00
|
|
|
|
2021-09-07 23:49:50 +00:00
|
|
|
if ($part == 'cat') {
|
|
|
|
if (!empty($catid)) {
|
|
|
|
$category = $C2->getCategories(['cat_id' => $catid]);
|
|
|
|
if (!$category->isEmpty()) {
|
|
|
|
$cattitle = $category->cat_title;
|
2021-11-02 22:55:41 +00:00
|
|
|
$catdesc = $category->cat_desc;
|
2021-09-07 23:49:50 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-08 22:12:14 +00:00
|
|
|
|
|
|
|
if ($catid) {
|
|
|
|
$links = $C2->getLinks(['cat_id' => $catid], true)->f(0);
|
2021-11-02 22:55:41 +00:00
|
|
|
echo '<p class="info">' . (
|
|
|
|
empty($links) ?
|
2021-09-08 22:12:14 +00:00
|
|
|
__('No link uses this category.') :
|
|
|
|
sprintf(__('A link uses this category.', '%s links use this category.', $links), $links)
|
|
|
|
) . '</p>';
|
|
|
|
}
|
2021-09-07 13:21:38 +00:00
|
|
|
echo '
|
2022-11-17 21:01:00 +00:00
|
|
|
<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.cinecturlink2') . '">
|
2021-09-07 23:49:50 +00:00
|
|
|
<p><label for="cattitle">' . __('Title:') . ' ' .
|
|
|
|
form::field('cattitle', 60, 64, $cattitle, 'maximal') .
|
2021-09-07 13:21:38 +00:00
|
|
|
'</label></p>
|
2021-09-07 23:49:50 +00:00
|
|
|
<p><label for="catdesc">' . __('Description:') . ' ' .
|
|
|
|
form::field('catdesc', 60, 64, $catdesc, 'maximal') .
|
2021-09-07 13:21:38 +00:00
|
|
|
'</label></p>
|
2021-09-07 23:49:50 +00:00
|
|
|
<p class="border-top">' .
|
|
|
|
'<input type="submit" value="' . __('Save') . ' (s)" accesskey="s" name="save" /> ' .
|
2021-11-02 22:55:41 +00:00
|
|
|
'<a id="post-cancel" href="' .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->adminurl->get('admin.plugin.cinecturlink2', ['part' => 'cats']) .
|
2021-11-02 22:55:41 +00:00
|
|
|
'" class="button" accesskey="c">' . __('Cancel') . ' (c)</a> ' .
|
2021-09-07 23:49:50 +00:00
|
|
|
(!empty($catid) ? ' <input type="submit" class="delete" value="' . __('Delete') . '" name="delete" />' : '') .
|
|
|
|
form::hidden('catid', $catid) .
|
2021-09-08 22:12:14 +00:00
|
|
|
form::hidden('part', 'cat') .
|
2022-11-17 21:01:00 +00:00
|
|
|
dcCore::app()->formNonce() . '</p>' .
|
2021-09-07 23:49:50 +00:00
|
|
|
'</form>';
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dcPage::helpBlock('cinecturlink2');
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
echo '</body></html>';
|