93 lines
3.7 KiB
PHP
93 lines
3.7 KiB
PHP
<?php
|
|
|
|
require_once __DIR__.'/common.inc.php';
|
|
|
|
if (!isset($XOOPS_MODULE_PICO) || empty($XOOPS_MODULE_PICO)) {
|
|
exit('Not configured for pico module'.PHP_EOL);
|
|
}
|
|
|
|
$config_fpath = __DIR__.'/data/src/pico/assets/config.json';
|
|
|
|
if (!file_exists($config_fpath)) {
|
|
die('config file not found'.PHP_EOL);
|
|
}
|
|
$config = json_decode(file_get_contents($config_fpath), true);
|
|
|
|
MyDumpTool::makeDirectory('dist');
|
|
MyDumpTool::makeDirectory('dist/src');
|
|
MyDumpTool::makeDirectory('dist/src/custom');
|
|
MyDumpTool::makeDirectory('dist/src/custom/assets');
|
|
MyDumpTool::makeDirectory('dist/public');
|
|
MyDumpTool::makeDirectory('dist/public/uploads');
|
|
|
|
// news
|
|
$news = array_pop(array_filter($config, function ($module) {return $module['module']['dirname'] === 'news';}));
|
|
$data = [];
|
|
foreach ($news['contents'] as $meta) {
|
|
if ($meta['cat_id'] !== 1) {
|
|
continue;
|
|
}
|
|
$content = json_decode(file_get_contents(__DIR__.'/data/public/news/'.$meta['id'].'.json'), true);
|
|
$data[] = [
|
|
'id' => $meta['id'],
|
|
'title' => $meta['title'],
|
|
'date' => date('Y.m.d', $content['created']),
|
|
'content' => str_replace('/news/data/40/1/BSI-NI_access201803.pdf', '/uploads/BSI-NI_access201803.pdf', $content['content']),
|
|
];
|
|
}
|
|
$fname = '/uploads/BSI-NI_access201803.pdf';
|
|
$ifpath = XOOPS_ROOT_PATH.$fname;
|
|
$ofpath = __DIR__.'/data/dist/public'.$fname;
|
|
MyDumpTool::fileCopy($ifpath, $ofpath);
|
|
file_put_contents(__DIR__.'/data/dist/src/custom/assets/news.json', json_encode($data, JSON_UNESCAPED_UNICODE));
|
|
|
|
// dbtools
|
|
MyDumpTool::makeDirectory('dist/public/uploads/dbtools');
|
|
$dbtools = array_pop(array_filter($config, function ($module) {return $module['module']['dirname'] === 'dbtools';}));
|
|
$data = [];
|
|
foreach ($dbtools['contents'] as $meta) {
|
|
if ($meta['cat_id'] !== 1) {
|
|
continue;
|
|
}
|
|
$content = json_decode(file_get_contents(__DIR__.'/data/public/dbtools/'.$meta['id'].'.json'), true);
|
|
$summary = trim(preg_replace('/<\/?p[^>]*>/', '', $content['content']));
|
|
$summary = trim(preg_replace('/\s+/', ' ', $summary));
|
|
$summary = trim(preg_replace('/(?:\s+)?\[\/(ja|en)\]\s+\[(ja|en)\](?:\s+)?/', '[/\1][\2]', $summary));
|
|
$image0 = '/uploads/dbtools/imagefile_0_'.$content['extra']['imagefile'];
|
|
$ifpath = XOOPS_ROOT_PATH.$image0;
|
|
$ofpath = __DIR__.'/data/dist/public'.$image0;
|
|
MyDumpTool::fileCopy($ifpath, $ofpath);
|
|
$image1 = '/uploads/dbtools/imagefiles_1_'.$content['extra']['imagefiles'];
|
|
$ifpath = XOOPS_ROOT_PATH.$image1;
|
|
$ofpath = __DIR__.'/data/dist/public'.$image1;
|
|
MyDumpTool::fileCopy($ifpath, $ofpath);
|
|
$data[] = [
|
|
'id' => $meta['id'],
|
|
'title' => $meta['title'],
|
|
'summary' => $summary,
|
|
'type' => $content['extra']['databaseortool'] == 1 ? 'database' : 'tool',
|
|
'jnode' => $content['extra']['kind'] == 2 ? true : false,
|
|
'group' => $content['extra']['contactgroup'],
|
|
'person' => $content['extra']['contactperson'],
|
|
'email' => $content['extra']['contactemail'],
|
|
'url' => $content['extra']['url'],
|
|
'image0' => $image0,
|
|
'image1' => $image1,
|
|
];
|
|
}
|
|
file_put_contents(__DIR__.'/data/dist/src/custom/assets/dbtools.json', json_encode($data, JSON_UNESCAPED_UNICODE));
|
|
|
|
// page
|
|
MyDumpTool::makeDirectory('dist/public/uploads/page');
|
|
$page = array_pop(array_filter($config, function ($module) {return $module['module']['dirname'] === 'page';}));
|
|
foreach ($page['contents'] as $meta) {
|
|
$content = json_decode(file_get_contents(__DIR__.'/data/public/page/'.$meta['id'].'.json'), true);
|
|
$image0 = '/uploads/page/imagefile_0_'.$content['extra']['imagefile'];
|
|
$ifpath = XOOPS_ROOT_PATH.$image0;
|
|
$ofpath = __DIR__.'/data/dist/public'.$image0;
|
|
MyDumpTool::fileCopy($ifpath, $ofpath);
|
|
}
|
|
|
|
//var_dump($config);
|
|
//data/public/dbtools/15.json
|