use Dotclear Helper
parent
6fa20dbf48
commit
f269e109bd
|
@ -23,9 +23,19 @@ use dcPage;
|
|||
use dcPostsActions;
|
||||
use dcRecord;
|
||||
use dcSettings;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
Div,
|
||||
Form,
|
||||
Hidden,
|
||||
Label,
|
||||
Para,
|
||||
Select,
|
||||
Submit,
|
||||
Text
|
||||
};
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Exception;
|
||||
use form;
|
||||
use html;
|
||||
|
||||
/**
|
||||
* @ingroup DC_PLUGIN_PERIODICAL
|
||||
|
@ -46,24 +56,28 @@ class BackendBehaviors
|
|||
$s = $blog_settings->get('periodical');
|
||||
|
||||
echo
|
||||
'<div class="fieldset"><h4 id="periodical_params">' . __('Periodical') . '</h4>' .
|
||||
'<div class="two-cols">' .
|
||||
'<div class="col">' .
|
||||
'<p><label class="classic" for="periodical_active">' .
|
||||
form::checkbox('periodical_active', 1, (bool) $s->get('periodical_active')) .
|
||||
__('Enable periodical on this blog') . '</label></p>' .
|
||||
'</div>' .
|
||||
'<div class="col">' .
|
||||
'<p><label for="periodical_upddate">' .
|
||||
form::checkbox('periodical_upddate', 1, (bool) $s->get('periodical_upddate')) .
|
||||
__('Update post date when publishing it') . '</label></p>' .
|
||||
'<p><label for="periodical_updurl">' .
|
||||
form::checkbox('periodical_updurl', 1, (bool) $s->get('periodical_updurl')) .
|
||||
__('Update post url when publishing it') . '</label></p>' .
|
||||
'</div>' .
|
||||
'</div>' .
|
||||
'<br class="clear" />' .
|
||||
'</div>';
|
||||
(new Div())->class('fieldset')->items([
|
||||
(new Text('h4', __('Periodical')))->id('periodical_params'),
|
||||
(new Div())->class('two-cols')->items([
|
||||
(new Div())->class('col')->items([
|
||||
(new Para())->items([
|
||||
(new Checkbox('periodical_active', (bool) $s->get('periodical_active')))->value(1),
|
||||
(new Label(__('Enable periodical on this blog'), Label::OUTSIDE_LABEL_AFTER))->for('periodical_active')->class('classic'),
|
||||
]),
|
||||
]),
|
||||
(new Div())->class('col')->items([
|
||||
(new Para())->items([
|
||||
(new Checkbox('periodical_upddate', (bool) $s->get('periodical_upddate')))->value(1),
|
||||
(new Label(__('Update post date when publishing it'), Label::OUTSIDE_LABEL_AFTER))->for('periodical_upddate')->class('classic'),
|
||||
]),
|
||||
(new Para())->items([
|
||||
(new Checkbox('periodical_updurl', (bool) $s->get('periodical_updurl')))->value(1),
|
||||
(new Label(__('Update post url when publishing it'), Label::OUTSIDE_LABEL_AFTER))->for('periodical_updurl')->class('classic'),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
(new Text('br'))->class('clear'),
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,7 +159,7 @@ class BackendBehaviors
|
|||
$name = '-';
|
||||
} else {
|
||||
$url = dcCore::app()->adminurl->get('admin.plugin.periodical', ['part' => 'period', 'period_id' => $r->f('periodical_id')]);
|
||||
$name = '<a href="' . $url . '#period" title="' . __('edit period') . '">' . html::escapeHTML($r->f('periodical_title')) . '</a>';
|
||||
$name = '<a href="' . $url . '#period" title="' . __('edit period') . '">' . Html::escapeHTML($r->f('periodical_title')) . '</a>';
|
||||
}
|
||||
$cols['period'] = '<td class="nowrap">' . $name . '</td>';
|
||||
}
|
||||
|
@ -274,24 +288,25 @@ class BackendBehaviors
|
|||
else {
|
||||
$pa->beginPage(
|
||||
dcPage::breadcrumb([
|
||||
html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
Html::escapeHTML(dcCore::app()->blog->name) => '',
|
||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||
__('Add a period to this selection') => '',
|
||||
])
|
||||
);
|
||||
|
||||
echo
|
||||
'<form action="' . $pa->getURI() . '" method="post">' .
|
||||
$pa->getCheckboxes() .
|
||||
|
||||
self::formPeriod() .
|
||||
|
||||
'<p>' .
|
||||
dcCore::app()->formNonce() .
|
||||
$pa->getHiddenFields() .
|
||||
form::hidden(['action'], 'periodical_add') .
|
||||
'<input type="submit" value="' . __('Save') . '" /></p>' .
|
||||
'</form>';
|
||||
(new Form('periodicaladd'))->method('post')->action($pa->getURI())->fields([
|
||||
(new Text('', $pa->getCheckboxes())),
|
||||
self::formPeriod(0),
|
||||
(new Para())->items(array_merge(
|
||||
[
|
||||
dcCore::app()->formNonce(false),
|
||||
(new Hidden(['action'], 'periodical_add')),
|
||||
(new Submit(['do']))->value(__('Save')),
|
||||
],
|
||||
$pa->hiddenFields()
|
||||
)),
|
||||
])->render();
|
||||
|
||||
$pa->endPage();
|
||||
}
|
||||
|
@ -314,7 +329,7 @@ class BackendBehaviors
|
|||
}
|
||||
|
||||
# Set linked period form items
|
||||
$sidebar_items['options-box']['items']['period'] = self::formPeriod((int) $period);
|
||||
$sidebar_items['options-box']['items']['period'] = (string) self::formPeriod((int) $period)?->render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -340,21 +355,16 @@ class BackendBehaviors
|
|||
* Posts period form field
|
||||
*
|
||||
* @param int $period Period
|
||||
* @return string Period form content
|
||||
* @return null|Para Period form object
|
||||
*/
|
||||
private static function formPeriod(int $period = 0): string
|
||||
private static function formPeriod(int $period = 0): ?Para
|
||||
{
|
||||
$combo = self::comboPeriod();
|
||||
|
||||
if (empty($combo)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return
|
||||
'<p><label for="periodical">' .
|
||||
__('Periodical') . '</label>' .
|
||||
form::combo('periodical', $combo, $period) .
|
||||
'</p>';
|
||||
return empty($combo) ? null : (new Para())->items([
|
||||
(new Label(__('Period:')))->for('periodical'),
|
||||
(new Select('periodical'))->default((string) $period)->items($combo),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -370,7 +380,7 @@ class BackendBehaviors
|
|||
if (!$periods->isEmpty()) {
|
||||
$combo = ['-' => ''];
|
||||
while ($periods->fetch()) {
|
||||
$combo[html::escapeHTML($periods->f('periodical_title'))] = $periods->f('periodical_id');
|
||||
$combo[Html::escapeHTML($periods->f('periodical_title'))] = $periods->f('periodical_id');
|
||||
}
|
||||
self::$combo_period = $combo;
|
||||
}
|
||||
|
|
|
@ -19,9 +19,12 @@ use dcAuth;
|
|||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcPage;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Hidden,
|
||||
Select
|
||||
};
|
||||
use Dotclear\Helper\Network\Http;
|
||||
use Exception;
|
||||
use form;
|
||||
use http;
|
||||
|
||||
/**
|
||||
* Admin page for periods
|
||||
|
@ -71,7 +74,7 @@ class Manage extends dcNsProcess
|
|||
);
|
||||
|
||||
if (!empty($vars->redir)) {
|
||||
http::redirect($vars->redir);
|
||||
Http::redirect($vars->redir);
|
||||
} else {
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['part' => 'periods']);
|
||||
}
|
||||
|
@ -92,7 +95,7 @@ class Manage extends dcNsProcess
|
|||
);
|
||||
|
||||
if (!empty($vars->redir)) {
|
||||
http::redirect($vars->redir);
|
||||
Http::redirect($vars->redir);
|
||||
} else {
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['part' => 'periods']);
|
||||
}
|
||||
|
@ -153,7 +156,7 @@ class Manage extends dcNsProcess
|
|||
|
||||
if (isset($period_list)) {
|
||||
# Filters
|
||||
$p_filter->display('admin.plugin.' . My::id(), form::hidden('p', My::id()) . form::hidden('part', 'periods'));
|
||||
$p_filter->display('admin.plugin.' . My::id(), (new Hidden('p', My::id()))->render() . (new Hidden('part', 'periods'))->render());
|
||||
|
||||
# Periods list
|
||||
$period_list->periodDisplay(
|
||||
|
@ -166,7 +169,7 @@ class Manage extends dcNsProcess
|
|||
'<p class="col checkboxes-helpers"></p>' .
|
||||
|
||||
'<p class="col right">' . __('Selected periods action:') . ' ' .
|
||||
form::combo('action', My::periodsActionCombo()) .
|
||||
(new Select('action'))->items(My::periodsActionCombo())->render() .
|
||||
'<input type="submit" value="' . __('ok') . '" /></p>' .
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . My::id(), array_merge(['p' => My::id()], $p_filter->values(true))) .
|
||||
dcCore::app()->formNonce() .
|
||||
|
|
|
@ -22,9 +22,9 @@ use dcAuth;
|
|||
use dcBlog;
|
||||
use dcCore;
|
||||
use dcPager;
|
||||
use Dotclear\Helper\Html\Form\Checkbox;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use dt;
|
||||
use html;
|
||||
use form;
|
||||
|
||||
/**
|
||||
* @ingroup DC_PLUGIN_PERIODICAL
|
||||
|
@ -90,7 +90,7 @@ class ManageList extends adminGenericList
|
|||
$nb_posts = Utils::getPosts(['periodical_id' => $this->rs->f('periodical_id')], true)->f(0);
|
||||
$url = dcCore::app()->adminurl->get('admin.plugin.periodical', ['part' => 'period', 'period_id' => $this->rs->f('periodical_id')]);
|
||||
|
||||
$name = '<a href="' . $url . '#period" title="' . __('edit period') . '">' . html::escapeHTML($this->rs->periodical_title) . '</a>';
|
||||
$name = '<a href="' . $url . '#period" title="' . __('edit period') . '">' . Html::escapeHTML($this->rs->periodical_title) . '</a>';
|
||||
|
||||
$posts = $nb_posts ?
|
||||
'<a href="' . $url . '#posts" title="' . __('view related entries') . '">' . $nb_posts . '</a>' :
|
||||
|
@ -100,7 +100,7 @@ class ManageList extends adminGenericList
|
|||
__((string) array_search($this->rs->f('periodical_pub_int'), My::periodCombo())) : __('Unknow frequence');
|
||||
|
||||
$cols = new ArrayObject([
|
||||
'check' => '<td class="nowrap">' . form::checkbox(['periods[]'], $this->rs->f('periodical_id'), ['checked' => $checked]) . '</td>',
|
||||
'check' => '<td class="nowrap">' . (new Checkbox(['periods[]'], $checked))->value($this->rs->f('periodical_id'))->render() . '</td>',
|
||||
'name' => '<td class="maximal">' . $name . '</td>',
|
||||
'curdt' => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('periodical_curdt'), dcCore::app()->auth->getInfo('user_tz')) . '</td>',
|
||||
'pub_int' => '<td class="nowrap">' . $interval . '</td>',
|
||||
|
@ -191,7 +191,7 @@ class ManageList extends adminGenericList
|
|||
$cat_title = sprintf(
|
||||
$cat_link,
|
||||
$this->rs->f('cat_id'),
|
||||
html::escapeHTML($this->rs->f('cat_title'))
|
||||
Html::escapeHTML($this->rs->f('cat_title'))
|
||||
);
|
||||
} else {
|
||||
$cat_title = __('None');
|
||||
|
@ -239,9 +239,9 @@ class ManageList extends adminGenericList
|
|||
}
|
||||
|
||||
$cols = [
|
||||
'check' => '<td class="minimal">' . form::checkbox(['periodical_entries[]'], $this->rs->f('post_id'), ['checked' => $checked]) . '</td>',
|
||||
'check' => '<td class="minimal">' . (new Checkbox(['periodical_entries[]'], $checked))->value($this->rs->f('post_id'))->render() . '</td>',
|
||||
'title' => '<td class="maximal"><a href="' . dcCore::app()->getPostAdminURL($this->rs->f('post_type'), $this->rs->f('post_id')) . '" ' .
|
||||
'title="' . html::escapeHTML($this->rs->getURL()) . '">' . html::escapeHTML($this->rs->post_title) . '</a></td>',
|
||||
'title="' . Html::escapeHTML($this->rs->getURL()) . '">' . Html::escapeHTML($this->rs->post_title) . '</a></td>',
|
||||
'date' => '<td class="nowrap">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('post_dt')) . '</td>',
|
||||
'category' => '<td class="nowrap">' . $cat_title . '</td>',
|
||||
'author' => '<td class="nowrap">' . $this->rs->f('user_id') . '</td>',
|
||||
|
|
|
@ -19,10 +19,22 @@ use dcAuth;
|
|||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcPage;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Datetime,
|
||||
Div,
|
||||
Form,
|
||||
Hidden,
|
||||
Input,
|
||||
Label,
|
||||
Number,
|
||||
Para,
|
||||
Select,
|
||||
Submit,
|
||||
Text
|
||||
};
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Helper\Network\Http;
|
||||
use Exception;
|
||||
use form;
|
||||
use html;
|
||||
use http;
|
||||
|
||||
/**
|
||||
* Admin page for a period
|
||||
|
@ -205,47 +217,46 @@ class ManagePeriod extends dcNsProcess
|
|||
dcPage::notices();
|
||||
|
||||
# Period form
|
||||
echo '
|
||||
<div id="period"><h3>' . (null === $vars->period_id ? __('New period') : __('Edit period')) . '</h3>
|
||||
<form method="post" action="' . dcCore::app()->admin->getPageURL() . '">
|
||||
echo
|
||||
(new Div('period'))->items([
|
||||
(new Text('h3', null === $vars->period_id ? __('New period') : __('Edit period'))),
|
||||
(new Form('periodicalbhv'))->method('post')->action(dcCore::app()->admin->getPageURL())->fields([
|
||||
(new Para())->items([
|
||||
(new Label(__('Title:')))->for('period_title'),
|
||||
(new Input('period_title'))->size(65)->maxlenght(255)->class('maximal')->value(Html::escapeHTML($vars->period_title)),
|
||||
]),
|
||||
(new Div())->class('two-boxes')->items([
|
||||
(new Para())->items([
|
||||
(new Label(__('Next update:')))->for('period_curdt'),
|
||||
(new Datetime('period_curdt', Html::escapeHTML(Dater::toUser($vars->period_curdt))))->class($vars->bad_period_curdt ? 'invalid' : ''),
|
||||
]),
|
||||
(new Para())->items([
|
||||
(new Label(__('End date:')))->for('period_enddt'),
|
||||
(new Datetime('period_enddt', Html::escapeHTML(Dater::toUser($vars->period_enddt))))->class($vars->bad_period_enddt ? 'invalid' : ''),
|
||||
]),
|
||||
]),
|
||||
(new Div())->class('two-boxes')->items([
|
||||
(new Para())->items([
|
||||
(new Label(__('Publication frequency:'), Label::OUTSIDE_LABEL_BEFORE))->for('period_pub_int'),
|
||||
(new Select('period_pub_int'))->default($vars->period_pub_int)->items(My::periodCombo()),
|
||||
]),
|
||||
(new Para())->items([
|
||||
(new Label(__('Number of entries to publish every time:'), Label::OUTSIDE_LABEL_BEFORE))->for('period_pub_nb'),
|
||||
(new Number('period_pub_nb'))->min(1)->max(20)->value($vars->period_pub_nb),
|
||||
]),
|
||||
]),
|
||||
|
||||
<p><label for="period_title">' . __('Title:') . '</label>' .
|
||||
form::field('period_title', 60, 255, html::escapeHTML($vars->period_title), 'maximal') . '</p>
|
||||
|
||||
<div class="two-boxes">
|
||||
|
||||
<p><label for="period_curdt">' . __('Next update:') . '</label>' .
|
||||
form::datetime('period_curdt', [
|
||||
'default' => html::escapeHTML(Dater::toUser($vars->period_curdt)),
|
||||
'class' => ($vars->bad_period_curdt ? 'invalid' : ''),
|
||||
]) . '</p>
|
||||
|
||||
<p><label for="period_enddt">' . __('End date:') . '</label>' .
|
||||
form::datetime('period_enddt', [
|
||||
'default' => html::escapeHTML(Dater::toUser($vars->period_enddt)),
|
||||
'class' => ($vars->bad_period_enddt ? 'invalid' : ''),
|
||||
]) . '</p>
|
||||
|
||||
</div><div class="two-boxes">
|
||||
|
||||
<p><label for="period_pub_int">' . __('Publication frequency:') . '</label>' .
|
||||
form::combo('period_pub_int', My::periodCombo(), $vars->period_pub_int) . '</p>
|
||||
|
||||
<p><label for="period_pub_nb">' . __('Number of entries to publish every time:') . '</label>' .
|
||||
form::number('period_pub_nb', ['min' => 1, 'max' => 20, 'default' => $vars->period_pub_nb]) . '</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="clear">
|
||||
<p><input type="submit" name="save" value="' . __('Save') . '" />' .
|
||||
dcCore::app()->formNonce() .
|
||||
form::hidden(['action'], 'setperiod') .
|
||||
form::hidden(['period_id'], $vars->period_id) .
|
||||
form::hidden(['part'], 'period') . '
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>';
|
||||
(new Div())->class('clear')->items([
|
||||
(new Para())->items([
|
||||
(new Submit(['save']))->value(__('Save')),
|
||||
dcCore::app()->formNonce(false),
|
||||
(new Hidden(['action'], 'setperiod')),
|
||||
(new Hidden(['period_id'], (string) $vars->period_id)),
|
||||
(new Hidden(['part'], 'period')),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
])->render();
|
||||
|
||||
if ($vars->period_id && isset($post_filter) && isset($post_list) && !dcCore::app()->error->flag()) {
|
||||
$base_url = dcCore::app()->admin->getPageURL() .
|
||||
|
@ -288,7 +299,7 @@ class ManagePeriod extends dcNsProcess
|
|||
'<p class="col checkboxes-helpers"></p>' .
|
||||
|
||||
'<p class="col right">' . __('Selected entries action:') . ' ' .
|
||||
form::combo('action', My::entriesActionsCombo()) .
|
||||
(new Select('action'))->items(My::entriesActionsCombo())->redner() .
|
||||
'<input type="submit" value="' . __('ok') . '" /></p>' .
|
||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.periodical', array_merge($post_filter->values(), [
|
||||
'period_id' => $vars->period_id,
|
||||
|
@ -313,7 +324,7 @@ class ManagePeriod extends dcNsProcess
|
|||
dcPage::addSuccessNotice($msg);
|
||||
|
||||
if (!empty($redir)) {
|
||||
http::redirect($redir);
|
||||
Http::redirect($redir);
|
||||
} else {
|
||||
dcCore::app()->adminurl->redirect('admin.plugin.' . My::id(), ['part' => 'period', 'period_id' => $id], $tab);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ use dcBlog;
|
|||
use dcCore;
|
||||
use dcMeta;
|
||||
use dcRecord;
|
||||
use Dotclear\Helper\File\Files;
|
||||
use Dotclear\Helper\File\Path;
|
||||
use Exception;
|
||||
use files;
|
||||
use path;
|
||||
|
||||
/**
|
||||
* Manage records
|
||||
|
@ -363,13 +363,13 @@ class Utils
|
|||
$f_md5
|
||||
);
|
||||
# Real path
|
||||
$cached_file = path::real($cached_file, false);
|
||||
$cached_file = Path::real($cached_file, false);
|
||||
if (is_bool($cached_file)) {
|
||||
throw new Exception("Can't write in cache fodler");
|
||||
}
|
||||
# Make dir
|
||||
if (!is_dir(dirname($cached_file))) {
|
||||
files::makeDir(dirname($cached_file), true);
|
||||
Files::makeDir(dirname($cached_file), true);
|
||||
}
|
||||
# Make file
|
||||
if (!file_exists($cached_file)) {
|
||||
|
|
Loading…
Reference in New Issue