postWidgetText/inc/lib.pwt.backup.php

121 lines
3.9 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
*
* @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
}
/**
* @ingroup DC_PLUGIN_POSTWIDGETTEXT
* @brief postWidgetText - backup methods.
* @since 2.6
*/
class postWidgetTextBackup
{
2021-09-10 19:18:51 +00:00
public static function exportSingle(dcCore $core, $exp, $blog_id)
{
$exp->export('postwidgettext',
2021-10-29 23:12:43 +00:00
'SELECT option_type, option_content, ' .
'option_content_xhtml, W.post_id ' .
'FROM ' . $core->prefix . 'post_option W ' .
'LEFT JOIN ' . $core->prefix . 'post P ' .
'ON P.post_id = W.post_id ' .
"WHERE P.blog_id = '" . $blog_id . "' " .
2021-09-10 19:18:51 +00:00
"AND W.option_type = 'postwidgettext' "
);
}
2021-09-10 19:06:49 +00:00
2021-09-10 19:18:51 +00:00
public static function exportFull(dcCore $core, $exp)
{
$exp->export('postwidgettext',
2021-10-29 23:12:43 +00:00
'SELECT option_type, option_content, ' .
2021-09-10 19:18:51 +00:00
'option_content_xhtml, W.post_id '.
2021-10-29 23:12:43 +00:00
'FROM ' . $core->prefix . 'post_option W ' .
'LEFT JOIN ' . $core->prefix . 'post P ' .
'ON P.post_id = W.post_id ' .
2021-09-10 19:18:51 +00:00
"WHERE W.option_type = 'postwidgettext' "
);
}
2021-09-10 19:06:49 +00:00
2021-09-10 19:18:51 +00:00
public static function importInit($bk, dcCore $core)
{
$bk->cur_postwidgettext = $core->con->openCursor(
2021-10-29 23:12:43 +00:00
$core->prefix . 'post_option'
2021-09-10 19:18:51 +00:00
);
$bk->postwidgettext = new postWidgetText($core);
}
2021-09-10 19:06:49 +00:00
2021-09-10 19:18:51 +00:00
public static function importSingle($line, $bk, dcCore $core)
{
if ($line->__name == 'postwidgettext'
&& isset($bk->old_ids['post'][(integer) $line->post_id])
) {
$line->post_id = $bk->old_ids['post'][(integer) $line->post_id];
2021-09-10 19:06:49 +00:00
2021-10-29 23:12:43 +00:00
$exists = $bk->postwidgettext->getWidgets([
'post_id' => $line->post_id
]);
2021-09-10 19:06:49 +00:00
2021-09-10 19:18:51 +00:00
if ($exists->isEmpty()) {
$bk->cur_postwidgettext->clean();
2021-09-10 19:06:49 +00:00
2021-09-10 19:18:51 +00:00
$bk->cur_postwidgettext->post_id =
(integer) $line->post_id;
$bk->cur_postwidgettext->option_type =
(string) $line->option_type;
$bk->cur_postwidgettext->option_lang =
(string) $line->option_lang;
$bk->cur_postwidgettext->option_format =
(string) $line->option_format;
$bk->cur_postwidgettext->option_content =
(string) $line->option_content;
$bk->cur_postwidgettext->option_content_xhtml =
(string) $line->option_content_xhtml;
2021-09-10 19:06:49 +00:00
2021-09-10 19:18:51 +00:00
$bk->postwidgettext->addWidget(
$bk->cur_postwidgettext
);
}
}
}
2021-09-10 19:06:49 +00:00
2021-10-29 23:12:43 +00:00
public static function importFull($line, $bk, dcCore $core)
2021-09-10 19:18:51 +00:00
{
if ($line->__name == 'postwidgettext') {
2021-10-29 23:12:43 +00:00
$exists = $bk->postwidgettext->getWidgets([
'post_id' => $line->post_id
]);
2021-09-10 19:06:49 +00:00
2021-09-10 19:18:51 +00:00
if ($exists->isEmpty()) {
$bk->cur_postwidgettext->clean();
2021-09-10 19:06:49 +00:00
2021-09-10 19:18:51 +00:00
$bk->cur_postwidgettext->post_id =
(integer) $line->post_id;
$bk->cur_postwidgettext->option_type =
(string) $line->option_type;
$bk->cur_postwidgettext->option_format =
(string) $line->option_format;
$bk->cur_postwidgettext->option_content =
(string) $line->option_content;
$bk->cur_postwidgettext->option_content =
(string) $line->option_content;
$bk->cur_postwidgettext->option_content_xhtml =
(string) $line->option_content_xhtml;
$bk->postwidgettext->addWidget(
$bk->cur_postwidgettext
);
}
}
}
}