postWidgetText/index.php

91 lines
2.4 KiB
PHP
Raw Normal View History

2021-09-10 19:06:49 +00:00
<?php
2021-09-10 19:18:51 +00:00
/**
* @brief postWidgetText, a plugin for Dotclear 2
2021-11-06 15:11:19 +00:00
*
2021-09-10 19:18:51 +00:00
* @package Dotclear
* @subpackage Plugin
2021-11-06 15:11:19 +00:00
*
2021-09-10 19:18:51 +00:00
* @author Jean-Christian Denis and Contributors
2021-11-06 15:11:19 +00:00
*
2021-09-10 19:18:51 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
2021-09-10 19:06:49 +00:00
if (!defined('DC_CONTEXT_ADMIN')) {
2021-09-10 19:18:51 +00:00
return null;
2021-09-10 19:06:49 +00:00
}
dcPage::check('usage,contentadmin');
$pwt = new postWidgetText($core);
# Delete widgets
if (!empty($_POST['save']) && !empty($_POST['widgets'])) {
2021-09-10 19:18:51 +00:00
try {
2021-11-06 15:11:19 +00:00
foreach ($_POST['widgets'] as $k => $id) {
$id = (int) $id;
2021-09-10 19:18:51 +00:00
$pwt->delWidget($id);
}
dcPage::addSuccessNotice(
__('Posts widgets successfully delete.')
);
2021-10-29 22:36:04 +00:00
if (!empty($_POST['redir'])) {
http::redirect($_POST['redir']);
} else {
$core->adminurl->redirect('admin.plugin.postWidgetText');
}
2021-11-06 15:11:19 +00:00
} catch (Exception $e) {
2021-09-10 19:18:51 +00:00
$core->error->add($e->getMessage());
}
2021-09-10 19:06:49 +00:00
}
2021-10-29 22:36:04 +00:00
# filters
$filter = new adminGenericFilter($core, 'pwt');
$filter->add(dcAdminFilters::getPageFilter());
$params = $filter->params();
2021-09-10 19:06:49 +00:00
# Get posts with text widget
try {
2021-11-06 15:11:19 +00:00
$posts = $pwt->getWidgets($params);
$counter = $pwt->getWidgets($params, true);
2021-10-30 08:30:01 +00:00
$posts_list = new listPostWidgetText($core, $posts, $counter->f(0));
2021-11-06 15:11:19 +00:00
} catch (Exception $e) {
2021-09-10 19:18:51 +00:00
$core->error->add($e->getMessage());
2021-09-10 19:06:49 +00:00
}
# Display
echo '
2021-10-29 22:36:04 +00:00
<html><head><title>' . __('Post widget text') . '</title>' .
dcPage::jsLoad(dcPage::getPF('postWidgetText/js/index.js')) .
$filter->js($core->adminurl->get('admin.plugin.postWidgetText')) . '
2021-09-10 19:06:49 +00:00
</head>
2021-10-29 22:36:04 +00:00
<body>' .
dcPage::breadcrumb([
2021-11-06 15:11:19 +00:00
__('Plugins') => '',
2021-10-29 22:36:04 +00:00
__('Posts widgets') => ''
2021-11-06 15:11:19 +00:00
]) .
2021-10-29 22:36:04 +00:00
dcPage::notices();
$filter->display('admin.plugin.postWidgetText', form::hidden('p', 'postWidgetText'));
2021-11-06 15:11:19 +00:00
$posts_list->display(
$filter->page,
$filter->nb,
2021-10-29 22:36:04 +00:00
'<form action="' . $core->adminurl->get('admin.plugin.postWidgetText') . '" method="post" id="form-entries">' .
'%s' .
'<div class="two-cols">' .
'<p class="col checkboxes-helpers"></p>' .
'<p class="col right">' .
'<input id="do-action" type="submit" name="save" value="' . __('Delete selected widgets') . '" /></p>' .
2021-11-06 15:11:19 +00:00
$core->adminurl->getHiddenFormFields('admin.plugin.postWidgetText', array_merge(['p' => 'postWidgetText'], $filter->values(true))) .
2021-10-29 22:36:04 +00:00
$core->formNonce() .
'</div>' .
2021-09-10 19:18:51 +00:00
'</form>'
2021-09-10 19:06:49 +00:00
);
# Footer
dcPage::helpBlock('postWidgetText');
2021-11-06 15:11:19 +00:00
echo '</body></html>';