2021-09-10 19:06:49 +00:00
|
|
|
<?php
|
2021-09-10 19:18:51 +00:00
|
|
|
/**
|
|
|
|
* @brief postWidgetText, a plugin for Dotclear 2
|
|
|
|
*
|
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
|
|
|
*
|
|
|
|
* @author Jean-Christian Denis and Contributors
|
|
|
|
*
|
|
|
|
* @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 {
|
|
|
|
foreach($_POST['widgets'] as $k => $id) {
|
|
|
|
$id = (integer) $id;
|
|
|
|
$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-09-10 19:18:51 +00:00
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
|
|
|
$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-09-10 19:18:51 +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-09-10 19:06:49 +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([
|
|
|
|
__('Plugins') => '',
|
|
|
|
__('Posts widgets') => ''
|
|
|
|
]).
|
|
|
|
dcPage::notices();
|
|
|
|
|
|
|
|
$filter->display('admin.plugin.postWidgetText', form::hidden('p', 'postWidgetText'));
|
|
|
|
|
|
|
|
$posts_list->display($filter->page, $filter->nb,
|
|
|
|
'<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>' .
|
|
|
|
$core->adminurl->getHiddenFormFields('admin.plugin.postWidgetText', array_merge(['p' => 'postWidgetText'], $filter->values(true))) .
|
|
|
|
$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-10-29 22:36:04 +00:00
|
|
|
echo '</body></html>';
|