first commit.
This commit is contained in:
44
etc/dumpNimgdocsBulletin.php
Normal file
44
etc/dumpNimgdocsBulletin.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/common.inc.php';
|
||||
require_once __DIR__.'/extras.inc.php';
|
||||
|
||||
$prefix = $xoopsDB->prefix();
|
||||
$table = 'nimgdocs_bulletin';
|
||||
if (!MyDumpTool::tableExists($table)) {
|
||||
exit('nimgdocs module not found'.PHP_EOL);
|
||||
}
|
||||
$sql = <<< SQL
|
||||
SELECT
|
||||
`b`.*
|
||||
FROM `${prefix}_${table}` AS `b`
|
||||
WHERE `b`.`accepted`=1
|
||||
ORDER BY `b`.`post_date` DESC
|
||||
SQL;
|
||||
if (!($res = $xoopsDB->query($sql))) {
|
||||
var_dump($xoopsDB);
|
||||
exit();
|
||||
}
|
||||
|
||||
$data = [];
|
||||
while ($row = $xoopsDB->fetchArray($res)) {
|
||||
$row['tags'] = urldecode($row['tags']);
|
||||
$row['text_en'] = urldecode($row['text_en']);
|
||||
$row['text_jp'] = urldecode($row['text_jp']);
|
||||
MyDumpTool::decode($row);
|
||||
MyDumpTool::convertToInt($row, ['id', 'accepted']);
|
||||
$row['text'] = [
|
||||
'en' => $row['text_en'],
|
||||
'ja' => $row['text_jp'],
|
||||
];
|
||||
MyDumpTool::dropColumn($row, ['accepted', 'text_en', 'text_jp']);
|
||||
$row['tags'] = explode(' ', $row['tags']);
|
||||
$row['post_date'] = strtotime($row['post_date']);
|
||||
$row['end_date'] = strtotime($row['end_date']);
|
||||
$data[] = $row;
|
||||
}
|
||||
$xoopsDB->freeRecordSet($res);
|
||||
|
||||
MyDumpTool::makeDirectory('src/nimgdocs/assets');
|
||||
MyDumpTool::saveJson('src/nimgdocs/assets/bulletin.json', $data);
|
||||
|
Reference in New Issue
Block a user