99 lines
3.8 KiB
PHP
99 lines
3.8 KiB
PHP
<?php
|
|
|
|
require_once __DIR__.'/common.inc.php';
|
|
require_once __DIR__.'/extra.inc.php';
|
|
|
|
if (!isset($XOOPS_MODULE_BULLETIN) || empty($XOOPS_MODULE_BULLETIN)) {
|
|
exit('Not configured for bulletin module'.PHP_EOL);
|
|
}
|
|
|
|
$mytrustdirname = 'bulletin';
|
|
$mytrustdirpath = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname;
|
|
$langmanpath = XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php';
|
|
if (!file_exists($langmanpath)) {
|
|
die('install the latest altsys');
|
|
}
|
|
require_once $langmanpath;
|
|
$langman = &D3LanguageManager::getInstance();
|
|
|
|
$root = XCube_Root::getSingleton();
|
|
$ts = MyTextSanitizer::sGetInstance();
|
|
$configHandler = xoops_gethandler('config');
|
|
|
|
foreach ($XOOPS_MODULE_BULLETIN as $mydirname) {
|
|
$data = [];
|
|
// get module info
|
|
$module = MyDumpTool::getModule($mydirname);
|
|
$moduleConfig = $configHandler->getConfigsByDirname($mydirname);
|
|
$data['module'] = [];
|
|
foreach (['name', 'dirname'] as $key) {
|
|
$data['module'][$key] = $module[$key];
|
|
}
|
|
foreach (['storyhome', 'displaynav', 'disp_list_of_cat', 'stories_of_cat', 'use_pankuzu'] as $key) {
|
|
$data['module'][$key] = intval($moduleConfig[$key]);
|
|
}
|
|
$langman->read('main.php', $mydirname, $mytrustdirname);
|
|
$mydirpath = XOOPS_ROOT_PATH.'/modules/'.$mydirname;
|
|
$mydirurl = XOOPS_URL.'/modules/'.$mydirname;
|
|
include "$mytrustdirpath/main/header.php";
|
|
$gperm = BulletinGP::getInstance($mydirname);
|
|
$can_read_topic_ids = $gperm->makeOnTopics('can_read');
|
|
// get topics
|
|
$table = $xoopsDB->prefix($mydirname.'_topics');
|
|
$topic_ids_sql = implode(', ', $can_read_topic_ids);
|
|
$sql = <<< SQL
|
|
SELECT
|
|
`topic_id`, `topic_pid`, `topic_title`
|
|
FROM `${table}`
|
|
WHERE `topic_id` IN (${topic_ids_sql})
|
|
ORDER BY `topic_id` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$data['topics'] = [];
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['topic_id', 'topic_pid']);
|
|
$data['topics'][] = [
|
|
'id' => $row['topic_id'],
|
|
'pid' => $row['topic_pid'],
|
|
'title' => $row['topic_title'],
|
|
];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
// get all stories
|
|
$articles = Bulletin::getAllPublished($mydirname, 0, 0, 0, 1, true, true, true);
|
|
foreach ($articles as $article) {
|
|
$article->unifyHomeTextAndBodyText();
|
|
$story = [];
|
|
$story['id'] = intval($article->getVar('storyid', 'n'));
|
|
$url = $mydirurl.'/index.php?page=article&storyid='.$story['id'];
|
|
$story['posttime'] = formatTimestamp($article->getVar('published'), $bulletin_date_format);
|
|
$story['topic_id'] = intval($article->getVar('topicid', 'n'));
|
|
$story['title'] = $article->getVar('title', 'n');
|
|
$text = $article->getVar('text', 'n');
|
|
$doHtml = $article->getVar('html', 'n');
|
|
$doSmiley = $article->getVar('smiley', 'n');
|
|
$doBr = $article->getVar('br', 'n');
|
|
$doXcode = $article->getVar('xcode', 'n');
|
|
$story['text'] = [
|
|
'en' => normalizeHtml($ts->displayTarea(MyDumpTool::mlang($text, $url, 'en'), $doHtml, $doSmiley, $doXcode, 0, $doBr), $url),
|
|
'ja' => normalizeHtml($ts->displayTarea(MyDumpTool::mlang($text, $url, 'ja'), $doHtml, $doSmiley, $doXcode, 0, $doBr), $url),
|
|
];
|
|
$type = $article->getVar('type', 'n');
|
|
if (1 != $type) {
|
|
echo 'Error: other type is unsupported'.PHP_EOL;
|
|
exit();
|
|
}
|
|
if (!empty($article->getRelated())) {
|
|
echo 'Error: related article feature is unsupported'.PHP_EOL;
|
|
exit();
|
|
}
|
|
$data['stories'][] = $story;
|
|
}
|
|
MyDumpTool::makeDirectory('public/modules/'.$mydirname);
|
|
MyDumpTool::saveJson('public/modules/'.$mydirname.'/index.json', $data);
|
|
}
|