2021-09-07 12:33:18 +00:00
|
|
|
<?php
|
2021-09-07 13:20:04 +00:00
|
|
|
/**
|
|
|
|
* @brief cinecturlink2, a plugin for Dotclear 2
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:20:04 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:20:04 +00:00
|
|
|
* @author Jean-Christian Denis and Contributors
|
2021-11-02 22:55:41 +00:00
|
|
|
*
|
2021-09-07 13:20:04 +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_MODULE')) {
|
2021-09-07 13:20:04 +00:00
|
|
|
return null;
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:59:13 +00:00
|
|
|
# Check user perms
|
|
|
|
dcPage::check('admin');
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
$redir = empty($_REQUEST['redir']) ?
|
|
|
|
$list->getURL() . '#plugins' : $_REQUEST['redir'];
|
2021-09-07 12:33:18 +00:00
|
|
|
|
|
|
|
$core->blog->settings->addNamespace('cinecturlink2');
|
2021-11-02 22:55:41 +00:00
|
|
|
$s = $core->blog->settings->cinecturlink2;
|
|
|
|
$cinecturlink2_active = (bool) $s->cinecturlink2_active;
|
|
|
|
$cinecturlink2_widthmax = abs((int) $s->cinecturlink2_widthmax);
|
|
|
|
$cinecturlink2_folder = (string) $s->cinecturlink2_folder;
|
|
|
|
$cinecturlink2_triggeronrandom = (bool) $s->cinecturlink2_triggeronrandom;
|
|
|
|
$cinecturlink2_public_active = (bool) $s->cinecturlink2_public_active;
|
|
|
|
$cinecturlink2_public_title = (string) $s->cinecturlink2_public_title;
|
2021-09-07 13:20:04 +00:00
|
|
|
$cinecturlink2_public_description = (string) $s->cinecturlink2_public_description;
|
2021-11-02 22:55:41 +00:00
|
|
|
$cinecturlink2_public_nbrpp = (int) $s->cinecturlink2_public_nbrpp;
|
2021-09-07 12:33:18 +00:00
|
|
|
if ($cinecturlink2_public_nbrpp < 1) {
|
2021-09-07 13:20:04 +00:00
|
|
|
$cinecturlink2_public_nbrpp = 10;
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
2021-11-02 22:53:06 +00:00
|
|
|
$combo_dirs = cinecturlink2::getPublicDirs($core);
|
|
|
|
|
2021-09-07 12:33:18 +00:00
|
|
|
if (!empty($_POST['save'])) {
|
2021-09-07 13:20:04 +00:00
|
|
|
try {
|
2021-11-02 22:55:41 +00:00
|
|
|
$cinecturlink2_active = !empty($_POST['cinecturlink2_active']);
|
|
|
|
$cinecturlink2_widthmax = abs((int) $_POST['cinecturlink2_widthmax']);
|
|
|
|
$cinecturlink2_newdir = (string) files::tidyFileName($_POST['cinecturlink2_newdir']);
|
|
|
|
$cinecturlink2_folder = empty($cinecturlink2_newdir) ?
|
2021-11-02 22:53:06 +00:00
|
|
|
(string) files::tidyFileName($_POST['cinecturlink2_folder']) :
|
|
|
|
$cinecturlink2_newdir;
|
2021-11-02 22:55:41 +00:00
|
|
|
$cinecturlink2_triggeronrandom = !empty($_POST['cinecturlink2_triggeronrandom']);
|
|
|
|
$cinecturlink2_public_active = !empty($_POST['cinecturlink2_public_active']);
|
|
|
|
$cinecturlink2_public_title = (string) $_POST['cinecturlink2_public_title'];
|
2021-09-07 13:20:04 +00:00
|
|
|
$cinecturlink2_public_description = (string) $_POST['cinecturlink2_public_description'];
|
2021-11-02 22:55:41 +00:00
|
|
|
$cinecturlink2_public_nbrpp = (int) $_POST['cinecturlink2_public_nbrpp'];
|
2021-09-07 13:20:04 +00:00
|
|
|
if ($cinecturlink2_public_nbrpp < 1) {
|
|
|
|
$cinecturlink2_public_nbrpp = 10;
|
|
|
|
}
|
|
|
|
if (empty($cinecturlink2_folder)) {
|
|
|
|
throw new Exception(__('You must provide a specific folder for images.'));
|
|
|
|
}
|
2021-11-02 22:53:06 +00:00
|
|
|
cinecturlink2::makePublicDir(
|
2021-09-07 13:20:04 +00:00
|
|
|
DC_ROOT . '/' . $core->blog->settings->system->public_path,
|
|
|
|
$cinecturlink2_folder,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
$s->put('cinecturlink2_active', $cinecturlink2_active);
|
|
|
|
$s->put('cinecturlink2_public_active', $cinecturlink2_public_active);
|
|
|
|
$s->put('cinecturlink2_public_title', $cinecturlink2_public_title);
|
|
|
|
$s->put('cinecturlink2_public_description', $cinecturlink2_public_description);
|
|
|
|
$s->put('cinecturlink2_public_nbrpp', $cinecturlink2_public_nbrpp);
|
|
|
|
$s->put('cinecturlink2_widthmax', $cinecturlink2_widthmax);
|
|
|
|
$s->put('cinecturlink2_folder', $cinecturlink2_folder);
|
|
|
|
$s->put('cinecturlink2_triggeronrandom', $cinecturlink2_triggeronrandom);
|
|
|
|
|
|
|
|
dcPage::addSuccessNotice(
|
2021-09-08 22:13:02 +00:00
|
|
|
__('Configuration successfully updated.')
|
2021-09-07 13:20:04 +00:00
|
|
|
);
|
|
|
|
$core->adminurl->redirect(
|
2021-11-02 22:55:41 +00:00
|
|
|
'admin.plugins',
|
2021-09-07 13:20:04 +00:00
|
|
|
['module' => 'cinecturlink2', 'conf' => 1, 'redir' => $list->getRedir()]
|
|
|
|
);
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$core->error->add($e->getMessage());
|
|
|
|
}
|
2021-09-07 12:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<div class="fieldset">
|
2021-09-07 13:20:04 +00:00
|
|
|
<h4>' . __('General') . '</h4>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-09-07 13:20:04 +00:00
|
|
|
<p><label class="classic" for="cinecturlink2_active">' .
|
|
|
|
form::checkbox('cinecturlink2_active', 1, $cinecturlink2_active) .
|
2021-09-08 22:13:02 +00:00
|
|
|
__('Enable plugin') . '</label></p>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
<p><label for="cinecturlink2_folder">' . __('Public folder of images (under public folder of blog):') . '</label>' .
|
2021-11-02 22:53:06 +00:00
|
|
|
form::combo('cinecturlink2_folder', $combo_dirs, $cinecturlink2_folder) . '</p>
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
<p><label for="cinecturlink2_newdir">' . __('Or create a new public folder of images:') . '</label>' .
|
2021-11-02 22:53:06 +00:00
|
|
|
form::field('cinecturlink2_newdir', 60, 64, '', 'maximal') . '</p>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-11-02 22:53:06 +00:00
|
|
|
<p><label for="cinecturlink2_widthmax">' . __('Maximum width of images (in pixel):') . '</label>' .
|
|
|
|
form::number('cinecturlink2_widthmax', 10, 512, $cinecturlink2_widthmax) . '</p>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="fieldset">
|
2021-09-07 13:20:04 +00:00
|
|
|
<h4>' . __('Widget') . '</h4>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-09-07 13:20:04 +00:00
|
|
|
<p><label class="classic" for="cinecturlink2_triggeronrandom">' .
|
|
|
|
form::checkbox('cinecturlink2_triggeronrandom', 1, $cinecturlink2_triggeronrandom) .
|
|
|
|
__('Update cache when use "Random" or "Number of view" order on widget (Need reload of widgets on change)') . '</label></p>
|
|
|
|
<p class="form-note">' . __('This increases the random effect, but updates the cache of the blog whenever the widget is displayed, which reduces the perfomances of your blog.') . '</p>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="fieldset">
|
2021-09-07 13:20:04 +00:00
|
|
|
<h4>' . __('Public page') . '</h4>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-09-07 13:20:04 +00:00
|
|
|
<p><label class="classic" for="cinecturlink2_public_active">' .
|
|
|
|
form::checkbox('cinecturlink2_public_active', 1, $cinecturlink2_public_active) .
|
|
|
|
__('Enable public page') . '</label></p>
|
2021-11-02 22:55:41 +00:00
|
|
|
<p class="form-note">' . sprintf(__('Public page has url: %s'), '<a href="' . $core->blog->url . $core->url->getBase('cinecturlink2') . '" title="public page">' . $core->blog->url . $core->url->getBase('cinecturlink2') . '</a>') . '</p>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-11-02 22:53:06 +00:00
|
|
|
<p><label for="cinecturlink2_public_title">' . __('Title of the public page:') . '</label>' .
|
|
|
|
form::field('cinecturlink2_public_title', 60, 255, $cinecturlink2_public_title, 'maximal') . '</p>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-11-02 22:53:06 +00:00
|
|
|
<p><label for="cinecturlink2_public_description">' . __('Description of the public page:') . '</label>' .
|
|
|
|
form::field('cinecturlink2_public_description', 60, 255, $cinecturlink2_public_description, 'maximal') . '</p>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
2021-11-02 22:53:06 +00:00
|
|
|
<p><label for="cinecturlink2_public_nbrpp">' . __('Limit number of entries per page on pulic page to:') . '</label>' .
|
|
|
|
form::number('cinecturlink2_public_nbrpp', 1, 100, $cinecturlink2_public_nbrpp) . '</p>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="fieldset">
|
2021-09-07 13:20:04 +00:00
|
|
|
<h4>' . __('Informations') . '</h4>
|
2021-09-07 12:33:18 +00:00
|
|
|
|
|
|
|
<ul>
|
2021-09-07 13:20:04 +00:00
|
|
|
<li>' . __('Once the extension has been configured and your links have been created, you can place one of the cinecturlink widgets in the sidebar.') . '</li>
|
|
|
|
<li>' . sprintf(__('In order to open links in new window you can use plugin %s.'), '<a href="http://plugins.dotaddict.org/dc2/details/externalLinks">External Links</a>') . '</li>
|
|
|
|
<li>' . sprintf(__('In order to change URL of public page you can use plugin %s.'), '<a href="http://lab.dotclear.org/wiki/plugin/myUrlHandlers">My URL handlers</a>') . '</li>
|
|
|
|
<li>' . sprintf(__('You can add public pages of cinecturlink to the plugin %s.'), '<a href="http://plugins.dotaddict.org/dc2/details/sitemaps">sitemaps</a>') . '</li>
|
|
|
|
<li>' . sprintf(__('The plugin Cinecturlink2 is compatible with plugin %s.'), '<a href="http://plugins.dotaddict.org/dc2/details/rateIt">Rate it</a>') . '</li>
|
|
|
|
<li>' . sprintf(__('The plugin Cinecturlink2 is compatible with plugin %s.'), '<a href="http://plugins.dotaddict.org/dc2/details/activityReport">Activity report</a>') . '</li>
|
2021-09-07 12:33:18 +00:00
|
|
|
</ul>
|
|
|
|
|
2021-11-02 22:55:41 +00:00
|
|
|
</div>';
|