103 lines
4.0 KiB
PHP
103 lines
4.0 KiB
PHP
|
<?php
|
||
|
|
||
|
require_once __DIR__.'/common.inc.php';
|
||
|
require_once __DIR__.'/extras.inc.php';
|
||
|
|
||
|
if (!isset($XOOPS_MODULE_PICO) || empty($XOOPS_MODULE_PICO)) {
|
||
|
exit('Not configured for pico module'.PHP_EOL);
|
||
|
}
|
||
|
|
||
|
error_reporting(0);
|
||
|
require_once XOOPS_TRUST_PATH.'/modules/pico/include/main_functions.php';
|
||
|
require_once XOOPS_TRUST_PATH.'/modules/pico/include/common_functions.php';
|
||
|
require_once XOOPS_TRUST_PATH.'/modules/pico/class/pico.textsanitizer.php';
|
||
|
require_once XOOPS_TRUST_PATH.'/modules/pico/class/PicoUriMapper.class.php';
|
||
|
require_once XOOPS_TRUST_PATH.'/modules/pico/class/PicoPermission.class.php';
|
||
|
require_once XOOPS_TRUST_PATH.'/modules/pico/class/PicoModelCategory.class.php';
|
||
|
require_once XOOPS_TRUST_PATH.'/modules/pico/class/PicoModelContent.class.php';
|
||
|
require_once XOOPS_TRUST_PATH.'/libs/altsys/class/AltsysBreadcrumbs.class.php';
|
||
|
error_reporting(E_ALL);
|
||
|
|
||
|
foreach ($XOOPS_MODULE_PICO as $pico) {
|
||
|
dumpPico($pico);
|
||
|
}
|
||
|
|
||
|
function dumpPico($pico)
|
||
|
{
|
||
|
global $xoopsDB;
|
||
|
$prefix = $xoopsDB->prefix();
|
||
|
$table = $pico.'_contents';
|
||
|
if (!MyDumpTool::tableExists($table)) {
|
||
|
exit('pico('.$pico.') module not found'.PHP_EOL);
|
||
|
}
|
||
|
MyDumpTool::makeDirectory('public/modules/'.$pico);
|
||
|
$moduleHandler = xoops_gethandler('module');
|
||
|
$module = $moduleHandler->getByDirname($pico);
|
||
|
$moduleConfigHandler = xoops_gethandler('config');
|
||
|
$moduleConfig = $moduleConfigHandler->getConfigsByDirname($pico);
|
||
|
$permObj = PicoPermission::getInstance();
|
||
|
$perms = $permObj->getPermissions($pico);
|
||
|
$categoryHandler = new PicoCategoryHandler($pico, $perms);
|
||
|
$contentHandler = new PicoContentHandler($pico);
|
||
|
$cats = $categoryHandler->getAllCategories();
|
||
|
$confContents = [];
|
||
|
$confCategories = [];
|
||
|
$dataMap = [];
|
||
|
$dataSeq = 1;
|
||
|
foreach ($cats as $cat) {
|
||
|
$catData = $cat->getData();
|
||
|
$modConfig = $cat->getOverriddenModConfig();
|
||
|
$link = pico_common_make_category_link4html($modConfig, $catData, $pico);
|
||
|
MyDumpTool::decode($catData);
|
||
|
$confCategories[] = [
|
||
|
'id' => $catData['id'],
|
||
|
'title' => $catData['cat_title'],
|
||
|
'desc' => (string) $catData['cat_desc'],
|
||
|
'pid' => (int) $catData['pid'],
|
||
|
'weight' => (int) $catData['cat_weight'],
|
||
|
'link' => $link,
|
||
|
];
|
||
|
$contents = $contentHandler->getCategoryContents($cat);
|
||
|
foreach ($contents as $content) {
|
||
|
$data = $content->getData();
|
||
|
$link = pico_common_make_content_link4html($modConfig, $data);
|
||
|
MyDumpTool::decode($data);
|
||
|
$url = XOOPS_URL.'/modules/'.$pico.'/'.$link;
|
||
|
$content_en = normalizeHtml(MyDumpTool::mlang($data['body_cached'], $url, 'en'), $url);
|
||
|
$content_ja = normalizeHtml(MyDumpTool::mlang($data['body_cached'], $url, 'ja'), $url);
|
||
|
$item = [
|
||
|
'id' => $data['id'],
|
||
|
'title' => $data['subject_raw'],
|
||
|
'content' => [
|
||
|
'en' => $content_en,
|
||
|
'ja' => $content_ja,
|
||
|
],
|
||
|
];
|
||
|
MyDumpTool::saveJson('public/modules/'.$pico.'/'.$data['id'].'.json', $item);
|
||
|
$confContents[] = [
|
||
|
'id' => $item['id'],
|
||
|
'title' => $data['subject_raw'],
|
||
|
'cat_id' => (int) $data['cat_id'],
|
||
|
'weight' => (int) $data['weight'],
|
||
|
'link' => $link,
|
||
|
];
|
||
|
}
|
||
|
}
|
||
|
$moduleinfo = [
|
||
|
'name' => $module->get('name'),
|
||
|
'dirname' => $pico,
|
||
|
'message' => $moduleConfig['top_message'],
|
||
|
'show_menuinmoduletop' => (int) $moduleConfig['show_menuinmoduletop'],
|
||
|
'show_listasindex' => (int) $moduleConfig['show_listasindex'],
|
||
|
'show_breadcrumbs' => (int) $moduleConfig['show_breadcrumbs'],
|
||
|
'show_pagenavi' => (int) $moduleConfig['show_pagenavi'],
|
||
|
];
|
||
|
MyDumpTool::decode($moduleinfo);
|
||
|
$config = [
|
||
|
'module' => $moduleinfo,
|
||
|
'categories' => $confCategories,
|
||
|
'contents' => $confContents,
|
||
|
];
|
||
|
MyDumpTool::saveJson('public/modules/'.$pico.'/index.json', $config);
|
||
|
}
|