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
|
|
|
|
*/
|
2022-11-15 21:05:23 +00:00
|
|
|
$records = dcCore::app()->con->select(
|
|
|
|
'SELECT W.*, P.post_lang, P.post_format FROM ' . dcCore::app()->prefix . 'post_wtext W ' .
|
|
|
|
'LEFT JOIN ' . dcCore::app()->prefix . 'post P ON P.post_id=W.post_id '
|
2021-09-10 19:06:49 +00:00
|
|
|
);
|
2021-11-06 15:11:19 +00:00
|
|
|
if (!$records->isEmpty()) {
|
2022-11-15 21:05:23 +00:00
|
|
|
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . 'post_option');
|
2021-11-06 15:11:19 +00:00
|
|
|
while ($records->fetch()) {
|
2022-11-15 21:05:23 +00:00
|
|
|
dcCore::app()->con->writeLock(dcCore::app()->prefix . 'post_option');
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2021-11-06 15:11:19 +00:00
|
|
|
try {
|
2022-11-15 21:05:23 +00:00
|
|
|
$id = dcCore::app()->con->select(
|
|
|
|
'SELECT MAX(option_id) FROM ' . dcCore::app()->prefix . 'post_option'
|
2021-09-10 19:18:51 +00:00
|
|
|
)->f(0) + 1;
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2021-09-10 19:18:51 +00:00
|
|
|
$cur->clean();
|
|
|
|
$cur->option_creadt = date('Y-m-d H:i:s');
|
2021-11-06 15:11:19 +00:00
|
|
|
$cur->option_upddt = date('Y-m-d H:i:s');
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2021-11-06 15:11:19 +00:00
|
|
|
$cur->option_id = $id;
|
|
|
|
$cur->post_id = $records->post_id;
|
|
|
|
$cur->option_type = $records->wtext_type;
|
|
|
|
$cur->option_lang = $records->post_lang;
|
|
|
|
$cur->option_format = $records->post_format;
|
|
|
|
$cur->option_title = $records->wtext_title;
|
|
|
|
$cur->option_content = $records->wtext_content;
|
|
|
|
$cur->option_content_xhtml = $records->wtext_content_xhtml;
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2021-09-10 19:18:51 +00:00
|
|
|
$cur->insert();
|
2022-11-15 21:05:23 +00:00
|
|
|
dcCore::app()->con->unlock();
|
2021-11-06 15:11:19 +00:00
|
|
|
} catch (Exception $e) {
|
2022-11-15 21:05:23 +00:00
|
|
|
dcCore::app()->con->unlock();
|
2021-11-06 15:11:19 +00:00
|
|
|
|
2021-09-10 19:18:51 +00:00
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
}
|
2021-11-06 15:11:19 +00:00
|
|
|
}
|