1242 lines
36 KiB
PHP
1242 lines
36 KiB
PHP
<?php
|
|
|
|
require_once __DIR__.'/common.inc.php';
|
|
|
|
$prefix = $xoopsDB->prefix();
|
|
|
|
$table = 'xoonips_item_basic';
|
|
if (!MyDumpTool::tableExists($table)) {
|
|
exit('xoonips module not found'.PHP_EOL);
|
|
}
|
|
MyDumpTool::makeDirectory('src/xoonips');
|
|
MyDumpTool::makeDirectory('src/xoonips/assets');
|
|
MyDumpTool::makeDirectory('public/modules/xoonips');
|
|
MyDumpTool::makeDirectory('public/modules/xoonips/file');
|
|
|
|
// xoonips config
|
|
$sql = <<< SQL
|
|
SELECT
|
|
*
|
|
FROM `${prefix}_xoonips_config`
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$xoonipsConfigs = [];
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['item_id', 'last_update_date']);
|
|
$xoonipsConfigs[$row['name']] = $row['value'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
|
|
// Recent Contents
|
|
$ranking = [];
|
|
$limit = $xoonipsConfigs['ranking_new_num_rows'];
|
|
$sql = <<< SQL
|
|
SELECT
|
|
`ib`.`item_id`, `ib`.`doi`, `ib`.`last_update_date`,
|
|
GROUP_CONCAT(DISTINCT `it`.`title` ORDER BY `it`.`title_id` ASC SEPARATOR '\n') AS `title`
|
|
FROM `${prefix}_xoonips_ranking_new_item` AS `ri`
|
|
INNER JOIN `${prefix}_xoonips_item_basic` AS `ib` ON `ri`.`item_id`=`ib`.`item_id`
|
|
INNER JOIN `${prefix}_xoonips_index_item_link` AS `iil` ON `ib`.`item_id`=`iil`.`item_id`
|
|
INNER JOIN `${prefix}_xoonips_item_title` AS `it` ON `ib`.`item_id`=`it`.`item_id`
|
|
WHERE `iil`.`certify_state`=2
|
|
GROUP BY `ib`.`item_id`
|
|
ORDER BY `ib`.`last_update_date` DESC
|
|
LIMIT $limit
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['item_id', 'last_update_date']);
|
|
$ranking[] = $row;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
MyDumpTool::saveJson('public/modules/xoonips/recent-contents.json', $ranking);
|
|
unset($ranking);
|
|
|
|
// Rankings
|
|
$ranking = [];
|
|
$limit = $xoonipsConfigs['ranking_num_rows'];
|
|
$rankingOrder = array_map('trim', explode(',', $xoonipsConfigs['ranking_order']));
|
|
$rankingVisible = array_map('trim', explode(',', $xoonipsConfigs['ranking_visible']));
|
|
$rankingKey2Index = [
|
|
'accessed' => 0,
|
|
'downloaded' => 1,
|
|
'contributed' => 2,
|
|
'searched' => 3,
|
|
'groups' => 4,
|
|
];
|
|
function rankingSortFunc($a, $b)
|
|
{
|
|
global $rankingOrder;
|
|
global $rankingKey2Index;
|
|
$na = $rankingOrder[$rankingKey2Index[$a]];
|
|
$nb = $rankingOrder[$rankingKey2Index[$b]];
|
|
|
|
return $na === $nb ? 0 : $na > $nb;
|
|
}
|
|
$limit = $xoonipsConfigs['ranking_num_rows'];
|
|
// - most accessed items
|
|
$ranking['accessed'] = [];
|
|
if ($rankingVisible[$rankingKey2Index['accessed']]) {
|
|
$sql = <<< SQL
|
|
SELECT
|
|
`ib`.`item_id`, `ib`.`doi`,
|
|
GROUP_CONCAT(DISTINCT `it`.`title` ORDER BY `it`.`title_id` ASC SEPARATOR '\n') AS `title`,
|
|
`vi`.`count`
|
|
FROM `${prefix}_xoonips_ranking_viewed_item` AS `vi`
|
|
INNER JOIN `${prefix}_xoonips_item_basic` AS `ib` ON `vi`.`item_id`=`ib`.`item_id`
|
|
INNER JOIN `${prefix}_xoonips_item_title` AS `it` ON `ib`.`item_id`=`it`.`item_id`
|
|
INNER JOIN `${prefix}_xoonips_index_item_link` AS `iil` ON `ib`.`item_id`=`iil`.`item_id`
|
|
WHERE `iil`.`certify_state`=2
|
|
GROUP BY `ib`.`item_id`
|
|
ORDER BY `vi`.`count` DESC
|
|
LIMIT $limit
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['item_id', 'count']);
|
|
$ranking['accessed'][] = $row;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
// - most accessed items
|
|
$ranking['downloaded'] = [];
|
|
if ($rankingVisible[$rankingKey2Index['downloaded']]) {
|
|
$sql = <<< SQL
|
|
SELECT
|
|
`ib`.`item_id`, `ib`.`doi`,
|
|
GROUP_CONCAT(DISTINCT `it`.`title` ORDER BY `it`.`title_id` ASC SEPARATOR '\n') AS `title`,
|
|
`di`.`count`
|
|
FROM `${prefix}_xoonips_ranking_downloaded_item` AS `di`
|
|
INNER JOIN `${prefix}_xoonips_item_basic` AS `ib` ON `di`.`item_id`=`ib`.`item_id`
|
|
INNER JOIN `${prefix}_xoonips_item_title` AS `it` ON `ib`.`item_id`=`it`.`item_id`
|
|
INNER JOIN `${prefix}_xoonips_index_item_link` AS `iil` ON `ib`.`item_id`=`iil`.`item_id`
|
|
WHERE `iil`.`certify_state`=2
|
|
GROUP BY `ib`.`item_id`
|
|
ORDER BY `di`.`count` DESC
|
|
LIMIT $limit
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['item_id', 'count']);
|
|
$ranking['downloaded'][] = $row;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
// - most contributed users
|
|
$ranking['contributed'] = [];
|
|
if ($rankingVisible[$rankingKey2Index['contributed']]) {
|
|
$sql = <<< SQL
|
|
SELECT
|
|
`u`.`uid`, `u`.`uname`, `u`.`name`, COUNT(`cu`.`item_id`) AS `count`
|
|
FROM `${prefix}_xoonips_ranking_contributing_user` AS `cu`
|
|
INNER JOIN `${prefix}_users` AS `u` ON `cu`.`uid`=`u`.`uid`
|
|
GROUP BY `u`.`uid`
|
|
ORDER BY `count` DESC
|
|
LIMIT $limit
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['uid', 'count']);
|
|
$ranking['contributed'][] = $row;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
// - most searched keywords
|
|
$ranking['searched'] = [];
|
|
if ($rankingVisible[$rankingKey2Index['searched']]) {
|
|
$sql = <<< SQL
|
|
SELECT
|
|
`sk`.`keyword`, `sk`.`count`
|
|
FROM `${prefix}_xoonips_ranking_searched_keyword` AS `sk`
|
|
ORDER BY `sk`.`count` DESC
|
|
LIMIT $limit
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['count']);
|
|
$ranking['searched'][] = $row;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
uksort($ranking, 'rankingSortFunc');
|
|
MyDumpTool::saveJson('public/modules/xoonips/rankings.json', $ranking);
|
|
unset($ranking);
|
|
|
|
// get public index with certified item count
|
|
$sql = <<< SQL
|
|
SELECT
|
|
`idx`.*,
|
|
`it`.`title`,
|
|
(SELECT COUNT(*)
|
|
FROM `${prefix}_xoonips_index_item_link` AS `iil`
|
|
INNER JOIN `${prefix}_xoonips_item_basic` AS `ib` ON `iil`.`item_id`=`ib`.`item_id`
|
|
WHERE `iil`.`index_id`=`idx`.`index_id` AND `iil`.`certify_state`=2
|
|
) AS `num_items`
|
|
FROM `${prefix}_xoonips_index` AS `idx`
|
|
INNER JOIN `${prefix}_xoonips_item_title` AS `it` ON `idx`.`index_id`=`it`.`item_id`
|
|
WHERE `it`.`title_id`=0
|
|
AND `idx`.`open_level`=1
|
|
SQL;
|
|
|
|
$limitItems = [];
|
|
$limitFiles = [];
|
|
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$tree = [];
|
|
$root = [];
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
$tree[$row['index_id']] = $row;
|
|
$root[$row['parent_index_id']][$row['sort_number']] = $row['index_id'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
foreach ($root as &$node) {
|
|
ksort($node);
|
|
}
|
|
unset($node);
|
|
|
|
$data[] = getTreeNode($tree, $root, 3);
|
|
MyDumpTool::saveJson('src/xoonips/assets/tree.json', $data);
|
|
unset($data, $root);
|
|
|
|
// get simpf link data
|
|
$simpflink = parseSimPFLinkFile();
|
|
$simpfurls = [];
|
|
|
|
// get public items
|
|
$sql = <<< SQL
|
|
SELECT
|
|
`ib`.*,
|
|
GROUP_CONCAT(DISTINCT `it`.`title` ORDER BY `it`.`title_id` ASC SEPARATOR '\n') AS `title`,
|
|
`ity`.`display_name` AS `item_type_display_name`, `ity`.`name` AS `item_type_name`,
|
|
`u`.`uname`, `u`.`name`, `u`.`email`
|
|
FROM `${prefix}_xoonips_item_basic` AS `ib`
|
|
INNER JOIN `${prefix}_xoonips_item_title` AS `it` ON `ib`.`item_id`=`it`.`item_id`
|
|
INNER JOIN `${prefix}_xoonips_item_type` AS `ity` ON `ib`.`item_type_id`=`ity`.`item_type_id`
|
|
INNER JOIN `${prefix}_xoonips_index_item_link` AS `iil` ON `ib`.`item_id`=`iil`.`item_id`
|
|
INNER JOIN `${prefix}_xoonips_index` AS `idx` ON `iil`.`index_id`=`idx`.`index_id`
|
|
LEFT JOIN `${prefix}_users` AS `u` ON `ib`.`uid`=`u`.`uid`
|
|
WHERE `ity`.`display_name` != 'Index'
|
|
AND `iil`.`certify_state`=2
|
|
AND `idx`.`open_level`=1
|
|
GROUP BY `ib`.`item_id`
|
|
ORDER BY `ib`.`item_id` ASC
|
|
SQL;
|
|
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$items = [];
|
|
$itemIds = [];
|
|
$baseItemIds = [];
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['item_id', 'item_type_id', 'uid', 'last_update_date', 'creation_date', 'publication_year', 'publication_month', 'publication_mday']);
|
|
$row['index'] = getIndexes($tree, $row['item_id']);
|
|
if (0 === count($row['index'])) {
|
|
// no public indexes found.
|
|
continue;
|
|
}
|
|
$row['changelog'] = getChangeLogs($row['item_id']);
|
|
$row['related_to'] = getRelatedTo($row['item_id']);
|
|
$row['keyword'] = getKeyword($row['item_id']);
|
|
$row['file'] = getFile($row['item_id']);
|
|
switch ($row['item_type_name']) {
|
|
case 'xnpbinder':
|
|
appendBinderInfo($row);
|
|
break;
|
|
case 'xnpbook':
|
|
appendBookInfo($row);
|
|
break;
|
|
case 'xnpconference':
|
|
appendConferenceInfo($row);
|
|
break;
|
|
case 'xnpdata':
|
|
appendDataInfo($row);
|
|
break;
|
|
case 'xnpfiles':
|
|
appendFilesInfo($row);
|
|
break;
|
|
case 'xnpmemo':
|
|
appendMemoInfo($row);
|
|
break;
|
|
case 'xnpmodel':
|
|
appendModelInfo($row);
|
|
break;
|
|
case 'xnppaper':
|
|
appendPaperInfo($row);
|
|
break;
|
|
case 'xnppresentation':
|
|
appendPresentationInfo($row);
|
|
break;
|
|
case 'xnpsimulator':
|
|
appendSimulatorInfo($row);
|
|
break;
|
|
case 'xnpstimulus':
|
|
appendStimulusInfo($row);
|
|
break;
|
|
case 'xnptool':
|
|
appendToolInfo($row);
|
|
break;
|
|
case 'xnpurl':
|
|
appendUrlInfo($row);
|
|
break;
|
|
case 'xnpnimgcenter':
|
|
appendNimgcenterInfo($row);
|
|
break;
|
|
default:
|
|
exit('Unsupported item type: '.$row['item_type_name']);
|
|
}
|
|
if (isset($row['attachment_dl_limit']) && $row['attachment_dl_limit']) {
|
|
$found = false;
|
|
foreach ($row['file'] as $file) {
|
|
if ('preview' !== $file['file_type_name']) {
|
|
$limitFiles[] = $file['file_id'];
|
|
$found = true;
|
|
}
|
|
}
|
|
if ($found) {
|
|
$limitItems[] = [
|
|
'uname' => $row['uname'],
|
|
'name' => $row['name'],
|
|
'email' => $row['email'],
|
|
'item_id' => $row['item_id'],
|
|
'doi' => $row['doi'],
|
|
];
|
|
}
|
|
}
|
|
MyDumpTool::dropColumn($row, ['email', 'item_type_id']);
|
|
if (isset($row['rights']) && isset($row['use_cc']) && isset($row['cc_commercial_use']) && isset($row['cc_modification']) && 1 == $row['use_cc']) {
|
|
$label = 'Creative Commons Attribution';
|
|
if (0 == $row['cc_commercial_use']) {
|
|
$label .= '-NonCommercial';
|
|
}
|
|
switch ($row['cc_modification']) {
|
|
case 0:
|
|
$label .= '-NoDerivatives';
|
|
break;
|
|
case 1:
|
|
$label .= '-ShareAlike';
|
|
break;
|
|
}
|
|
$label .= ' 4.0 International License.';
|
|
$row['rights'] = $label;
|
|
}
|
|
$items[] = $row;
|
|
|
|
$simpfurl = '';
|
|
if ('' != $row['doi'] && isset($simpflink['id'][$row['doi']])) {
|
|
$simpfurl = $simpflink['id'][$row['doi']];
|
|
} elseif (isset($simpflink['item_id'][$row['item_id']])) {
|
|
$simpfurl = $simpflink['item_id'][$row['item_id']];
|
|
}
|
|
if ('' !== $simpfurl) {
|
|
$simpfurls[] = [
|
|
'id' => $row['item_id'],
|
|
'url' => $simpfurl,
|
|
];
|
|
}
|
|
$itemIds[] = $row['item_id'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
MyDumpTool::saveJson('public/modules/xoonips/items.json', $items);
|
|
MyDumpTool::saveJson('src/xoonips/assets/simpf-links.json', $simpfurls);
|
|
foreach ($baseItemIds as $bid) {
|
|
if (!in_array($bid, $itemIds)) {
|
|
echo 'Warning: baseitem_id('.$bid.') not found'.PHP_EOL;
|
|
}
|
|
}
|
|
|
|
$fp = fopen(MYDUMPTOOL_OUTPUTDIR.'/dl-limit-items.csv', 'w');
|
|
foreach ($limitItems as $row) {
|
|
$data = [
|
|
$row['item_id'],
|
|
$row['uname'],
|
|
$row['name'],
|
|
$row['email'],
|
|
getItemUrl($row),
|
|
];
|
|
fputcsv($fp, $data);
|
|
}
|
|
fclose($fp);
|
|
|
|
// get files
|
|
$fileutil = xoonips_getutility('file');
|
|
|
|
$basePath = $xoonipsConfigs['upload_dir'];
|
|
$sql = <<< SQL
|
|
SELECT
|
|
`f`.`file_id`, `f`.`item_id`, `f`.`original_file_name`,
|
|
`ft`.`name` AS `file_type_name`
|
|
FROM `${prefix}_xoonips_file` AS `f`
|
|
INNER JOIN `${prefix}_xoonips_file_type` AS `ft` ON `f`.`file_type_id`=`ft`.`file_type_id`
|
|
INNER JOIN `${prefix}_xoonips_index_item_link` AS `iil` ON `f`.`item_id`=`iil`.`item_id`
|
|
INNER JOIN `${prefix}_xoonips_index` AS `idx` ON `iil`.`index_id`=`idx`.`index_id`
|
|
WHERE `f`.`is_deleted`=0
|
|
AND `ft`.`name` NOT IN('readme' , 'license', 'rights')
|
|
AND `iil`.`certify_state`=2
|
|
AND `idx`.`open_level`=1
|
|
GROUP BY `f`.`file_id`
|
|
ORDER BY `f`.`file_id` ASC
|
|
SQL;
|
|
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$filesDir = MYDUMPTOOL_OUTPUTDIR.'/public/modules/xoonips/file';
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['file_id', 'item_id']);
|
|
$file_id = $row['file_id'];
|
|
$item_id = $row['item_id'];
|
|
$file_name = $row['original_file_name'];
|
|
$file_type = $row['file_type_name'];
|
|
if (in_array($file_id, $limitFiles)) {
|
|
echo "download limit file found.. skip to copy.. item_id:$item_id, file_id:$file_id".PHP_EOL;
|
|
continue;
|
|
}
|
|
$file_dir = $filesDir.'/'.$file_id;
|
|
$src_file = $basePath.'/'.$file_id;
|
|
if (!is_dir($file_dir)) {
|
|
@mkdir($file_dir);
|
|
}
|
|
//if (!file_exists($file_dir.'/'.$file_name)) {
|
|
if (!MyDumpTool::fileCopy($src_file, $file_dir.'/'.$file_name)) {
|
|
echo 'failed to copy file: '.$basePath.'/'.$file_id.PHP_EOL;
|
|
}
|
|
$htaccess = $file_dir.'/.htaccess';
|
|
$xfilename = str_replace(' ', '\\ ', $file_name);
|
|
$data = "RewriteEngine On\nRewriteBase /database/file/$file_id\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteRule .* $xfilename [R=301,L]\n";
|
|
file_put_contents($htaccess, $data);
|
|
//}
|
|
if ('preview' == $file_type) {
|
|
$thumbnail_file = $file_dir.'.png';
|
|
if (!file_exists($thumbnail_file)) {
|
|
$mimetype = $fileutil->get_mimetype($src_file, $file_name);
|
|
$thumbnail = $fileutil->get_thumbnail($src_file, $mimetype);
|
|
if (null !== $thumbnail) {
|
|
file_put_contents($thumbnail_file, $thumbnail);
|
|
} else {
|
|
createThumbnail($src_file, $mimetype, $thumbnail_file);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
|
|
// functions
|
|
|
|
function getItemUrl($row)
|
|
{
|
|
$url = XOONIPS_URL.'/detail.php?';
|
|
if ('' != $row['doi']) {
|
|
$url .= XNP_CONFIG_DOI_FIELD_PARAM_NAME.'='.$row['doi'];
|
|
} else {
|
|
$url .= 'item_id='.$row['item_id'];
|
|
}
|
|
|
|
return $url;
|
|
}
|
|
|
|
function getTreeNode($tree, $root, $index_id)
|
|
{
|
|
$children = [];
|
|
if (isset($root[$index_id])) {
|
|
foreach ($root[$index_id] as $child_index_id) {
|
|
$children[] = getTreeNode($tree, $root, $child_index_id);
|
|
}
|
|
}
|
|
|
|
return [
|
|
'id' => (int) $tree[$index_id]['index_id'],
|
|
'title' => $tree[$index_id]['title'],
|
|
'num_of_items' => (int) $tree[$index_id]['num_items'],
|
|
'children' => $children,
|
|
];
|
|
}
|
|
|
|
function getIndexes($tree, $item_id)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$sql = <<< SQL
|
|
SELECT
|
|
`iil`.`index_id`
|
|
FROM `${prefix}_xoonips_index_item_link` AS `iil`
|
|
WHERE `iil`.`item_id`=$item_id
|
|
ORDER BY `iil`.`index_id`
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$indexes = [];
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
$index_id = $row['index_id'];
|
|
if (isset($tree[$index_id])) {
|
|
$idxes = [];
|
|
$idxes[] = $tree[$index_id]['title'];
|
|
$parent_id = $tree[$index_id]['parent_index_id'];
|
|
while (1 != $parent_id) {
|
|
$idxes[] = $tree[$parent_id]['title'];
|
|
$parent_id = $tree[$parent_id]['parent_index_id'];
|
|
}
|
|
$idxes[] = '';
|
|
$indexes[] = [
|
|
'index_id' => (int) $index_id,
|
|
'title' => trim(implode(' / ', array_reverse($idxes))),
|
|
];
|
|
}
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
|
|
return $indexes;
|
|
}
|
|
|
|
function getChangeLogs($item_id)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$sql = <<< SQL
|
|
SELECT `log_date`, `log`
|
|
FROM `${prefix}_xoonips_changelog`
|
|
WHERE `item_id`=$item_id
|
|
ORDER BY `log_date` DESC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$ret = [];
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['log_date']);
|
|
$ret[] = $row;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
|
|
return $ret;
|
|
}
|
|
|
|
function getRelatedTo($item_id)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$sql = <<< SQL
|
|
SELECT `item_id`
|
|
FROM `${prefix}_xoonips_related_to`
|
|
WHERE `parent_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$ret = [];
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
$ret[] = (int) $row['item_id'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
|
|
return $ret;
|
|
}
|
|
|
|
function getKeyword($item_id)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xoonips_item_keyword`
|
|
WHERE `item_id`=$item_id
|
|
ORDER BY `keyword_id` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$ret = [];
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
$ret[] = $row['keyword'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
|
|
return $ret;
|
|
}
|
|
|
|
function getFile($item_id)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$sql = <<< SQL
|
|
SELECT `f`.`file_id`, `f`.`original_file_name`, `f`.`mime_type`, `f`.`file_size`, `f`.`caption`, `f`.`timestamp`,
|
|
`ft`.`name` AS `file_type_name`, `ft`.`display_name` AS `file_type_display_name`
|
|
FROM `${prefix}_xoonips_file` AS `f`
|
|
INNER JOIN `${prefix}_xoonips_file_type` AS `ft` ON `f`.`file_type_id`=`ft`.`file_type_id`
|
|
WHERE `item_id`=$item_id
|
|
AND `is_deleted`=0
|
|
ORDER BY `ft`.`name` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$ret = [];
|
|
while ($row = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row);
|
|
MyDumpTool::convertToInt($row, ['file_id', 'file_size']);
|
|
$ret[] = $row;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
|
|
return $ret;
|
|
}
|
|
|
|
function appendBinderInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpbinder_item_detail`
|
|
WHERE `binder_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['binder_id']);
|
|
MyDumpTool::dropColumn($detail, ['binder_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpbinder_binder_item_link`
|
|
WHERE `binder_id`=$item_id
|
|
ORDER BY `item_id` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['item_link'] = [];
|
|
while ($row2 = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($row2);
|
|
$row['item_link'][] = (int) $row2['item_id'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendBookInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpbook_item_detail`
|
|
WHERE `book_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['book_id', 'attachment_dl_limit', 'attachment_dl_notify']);
|
|
MyDumpTool::convertToInt($detail, ['volume', 'number']); // for CBSN
|
|
MyDumpTool::dropColumn($detail, ['book_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpbook_author`
|
|
WHERE `book_id`=$item_id
|
|
ORDER BY `author_order` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['author'] = [];
|
|
while ($author = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($author);
|
|
$row['author'][] = $author['author'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendConferenceInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpconference_item_detail`
|
|
WHERE `conference_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['conference_id', 'conference_from_year', 'conference_from_month', 'conference_from_mday', 'conference_to_year', 'conference_to_month', 'conference_to_mday', 'attachment_dl_limit', 'attachment_dl_notify']);
|
|
MyDumpTool::dropColumn($detail, ['conference_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpconference_author`
|
|
WHERE `conference_id`=$item_id
|
|
ORDER BY `author_order` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['author'] = [];
|
|
while ($author = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($author);
|
|
$row['author'][] = $author['author'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendDataInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpdata_item_detail`
|
|
WHERE `data_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['data_id', 'use_cc', 'cc_commercial_use', 'cc_modification', 'attachment_dl_limit', 'attachment_dl_notify']);
|
|
MyDumpTool::dropColumn($detail, ['data_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpdata_experimenter`
|
|
WHERE `data_id`=$item_id
|
|
ORDER BY `experimenter_order` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['experimenter'] = [];
|
|
while ($author = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($author);
|
|
$row['experimenter'][] = $author['experimenter'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendFilesInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpfiles_item_detail`
|
|
WHERE `files_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['files_id']);
|
|
MyDumpTool::dropColumn($detail, ['files_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendMemoInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpmemo_item_detail`
|
|
WHERE `memo_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['memo_id']);
|
|
MyDumpTool::dropColumn($detail, ['memo_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendModelInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpmodel_item_detail`
|
|
WHERE `model_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['model_id', 'use_cc', 'cc_commercial_use', 'cc_modification', 'attachment_dl_limit', 'attachment_dl_notify']);
|
|
MyDumpTool::dropColumn($detail, ['model_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpmodel_creator`
|
|
WHERE `model_id`=$item_id
|
|
ORDER BY `creator_order` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['creator'] = [];
|
|
while ($author = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($author);
|
|
$row['creator'][] = $author['creator'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendPaperInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnppaper_item_detail`
|
|
WHERE `paper_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['paper_id', 'volume', 'number']);
|
|
MyDumpTool::dropColumn($detail, ['paper_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnppaper_author`
|
|
WHERE `paper_id`=$item_id
|
|
ORDER BY `author_order` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['author'] = [];
|
|
while ($author = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($author);
|
|
$row['author'][] = $author['author'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendPresentationInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnppresentation_item_detail`
|
|
WHERE `presentation_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['presentation_id', 'use_cc', 'cc_commercial_use', 'cc_modification', 'attachment_dl_limit', 'attachment_dl_notify']);
|
|
MyDumpTool::dropColumn($detail, ['presentation_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnppresentation_creator`
|
|
WHERE `presentation_id`=$item_id
|
|
ORDER BY `creator_order` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['creator'] = [];
|
|
while ($author = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($author);
|
|
$row['creator'][] = $author['creator'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendSimulatorInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpsimulator_item_detail`
|
|
WHERE `simulator_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['simulator_id', 'use_cc', 'cc_commercial_use', 'cc_modification', 'attachment_dl_limit', 'attachment_dl_notify']);
|
|
MyDumpTool::dropColumn($detail, ['simulator_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpsimulator_developer`
|
|
WHERE `simulator_id`=$item_id
|
|
ORDER BY `developer_order` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['developer'] = [];
|
|
while ($author = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($author);
|
|
$row['developer'][] = $author['developer'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendStimulusInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpstimulus_item_detail`
|
|
WHERE `stimulus_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['stimulus_id', 'use_cc', 'cc_commercial_use', 'cc_modification', 'attachment_dl_limit', 'attachment_dl_notify']);
|
|
MyDumpTool::dropColumn($detail, ['stimulus_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpstimulus_developer`
|
|
WHERE `stimulus_id`=$item_id
|
|
ORDER BY `developer_order` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['developer'] = [];
|
|
while ($author = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($author);
|
|
$row['developer'][] = $author['developer'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendToolInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnptool_item_detail`
|
|
WHERE `tool_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['tool_id', 'use_cc', 'cc_commercial_use', 'cc_modification', 'attachment_dl_limit', 'attachment_dl_notify']);
|
|
MyDumpTool::dropColumn($detail, ['tool_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnptool_developer`
|
|
WHERE `tool_id`=$item_id
|
|
ORDER BY `developer_order` ASC
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['developer'] = [];
|
|
while ($author = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($author);
|
|
$row['developer'][] = $author['developer'];
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendUrlInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpurl_item_detail`
|
|
WHERE `url_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['url_id', 'url_count']);
|
|
MyDumpTool::dropColumn($detail, ['url_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
}
|
|
|
|
function appendNimgcenterInfo(&$row)
|
|
{
|
|
global $xoopsDB;
|
|
$prefix = $xoopsDB->prefix();
|
|
$coord_type_names = [
|
|
0 => 'Talairach',
|
|
1 => 'NMI',
|
|
2 => 'Unclear',
|
|
];
|
|
$item_id = $row['item_id'];
|
|
$sql = <<< SQL
|
|
SELECT `id`.*,
|
|
`ity`.`display_name` AS `base_type_display_name`
|
|
FROM `${prefix}_xnpnimgcenter_item_detail` AS `id`
|
|
INNER JOIN `${prefix}_xoonips_item_type` AS `ity` ON `id`.`base_type_name`=`ity`.`name`
|
|
WHERE `id`.`nimgcenter_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
while ($detail = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::decode($detail);
|
|
MyDumpTool::convertToInt($detail, ['baseitem_id', 'coord_type']);
|
|
$detail['coord_type_name'] = $coord_type_names[$detail['coord_type']];
|
|
MyDumpTool::dropColumn($detail, ['nimgcenter_id']);
|
|
$row += $detail;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
$sql = <<< SQL
|
|
SELECT *
|
|
FROM `${prefix}_xnpnimgcenter_talairach_list`
|
|
WHERE `nimgcenter_id`=$item_id
|
|
SQL;
|
|
if (!($res = $xoopsDB->query($sql))) {
|
|
var_dump($xoopsDB);
|
|
exit();
|
|
}
|
|
$row['coordinate'] = [];
|
|
while ($t = $xoopsDB->fetchArray($res)) {
|
|
MyDumpTool::dropColumn($t, ['nimgcenter_id']);
|
|
MyDumpTool::convertToInt($t, ['x', 'y', 'z']);
|
|
$row['coordinate'][] = $t;
|
|
}
|
|
$xoopsDB->freeRecordSet($res);
|
|
global $baseItemIds;
|
|
$baseItemIds[$row['item_id']] = $row['baseitem_id'];
|
|
}
|
|
|
|
function createThumbnail($inputFile, $mime_type, $outputFile)
|
|
{
|
|
$finfo = finfo_open(FILEINFO_NONE);
|
|
$label = finfo_file($finfo, $inputFile);
|
|
finfo_close($finfo);
|
|
if (preg_match('/^([^\\/]*)\\/(.*)$/', $mime_type, $matches)) {
|
|
if ('audio' == $matches[1]) {
|
|
$img_type = 'audio';
|
|
} elseif ('image' == $matches[1]) {
|
|
$img_type = 'image';
|
|
} elseif ('video' == $matches[1]) {
|
|
$img_type = 'video';
|
|
} elseif ('text' == $matches[1]) {
|
|
$img_type = 'text';
|
|
} elseif ('application' == $matches[1]) {
|
|
$text_types = ['pdf', 'xml', 'msword', 'vnd.ms-excel'];
|
|
$image_types = ['vnd.ms-powerpoint', 'postscript'];
|
|
$audio_types = ['vnd.rn-realmedia'];
|
|
if (in_array($matches[2], $text_types)) {
|
|
$img_type = 'text';
|
|
} elseif (in_array($matches[2], $audio_types)) {
|
|
$img_type = 'audio';
|
|
} elseif (in_array($matches[2], $image_types)) {
|
|
$img_type = 'image';
|
|
} else {
|
|
$img_type = 'application';
|
|
}
|
|
} else {
|
|
$img_type = 'unknown';
|
|
}
|
|
} else {
|
|
$img_type = 'unknown';
|
|
}
|
|
$img_file = XOOPS_ROOT_PATH.'/modules/xoonips/images/thumbnail_'.$img_type.'.png';
|
|
// create image resource
|
|
$w = 100;
|
|
$h = 100;
|
|
$im = imagecreatetruecolor($w, $h);
|
|
// label setting
|
|
$f = 2;
|
|
// font number
|
|
$lp = 5;
|
|
// label padding
|
|
$fw = imagefontwidth($f);
|
|
// font width
|
|
$fh = imagefontheight($f);
|
|
// font height
|
|
$fmaxlen = ($w - $lp * 2) / $fw;
|
|
// max label length
|
|
$labels = explode(',', $label);
|
|
$label = $labels[0];
|
|
$llen = strlen($label);
|
|
if ($llen > $fmaxlen) {
|
|
$label = substr($label, 0, $fmaxlen - 3);
|
|
$label .= '...';
|
|
$llen = strlen($label);
|
|
}
|
|
$lx = ($w - $llen * $fw) / 2;
|
|
$ly = $h - $fh - $lp;
|
|
// change alpha attributes and create transparent color
|
|
imageantialias($im, true);
|
|
imagealphablending($im, false);
|
|
imagesavealpha($im, true);
|
|
$transparent = imagecolorallocatealpha($im, 255, 255, 255, 0);
|
|
$col_white = imagecolorallocate($im, 255, 255, 255);
|
|
$col_gray = imagecolorallocate($im, 127, 127, 127);
|
|
$col_black = imagecolorallocate($im, 0, 0, 0);
|
|
// fill all area with transparent color
|
|
imagefill($im, 0, 0, $col_white);
|
|
imagealphablending($im, true);
|
|
$imicon = imagecreatefrompng($img_file);
|
|
imagecopy($im, $imicon, $w / 2 - 48 / 2, $h / 2 - 48 / 2, 0, 0, 48, 48);
|
|
imagepolygon($im, [0, 0, $w - 1, 0, $w - 1, $h - 1, 0, $h - 1], 4, $col_gray);
|
|
if (0 != strlen($label)) {
|
|
imagestring($im, $f, $lx, $ly, $label, $col_black);
|
|
}
|
|
imagepng($im, $outputFile);
|
|
imagedestroy($imicon);
|
|
imagedestroy($im);
|
|
|
|
return true;
|
|
}
|
|
|
|
function parseSimPFLinkFile()
|
|
{
|
|
global $XOONIPS_SIMPF_LINKFILE;
|
|
$xoops_url_path = parse_url(XOOPS_URL, PHP_URL_PATH);
|
|
$ret = [];
|
|
if (isset($XOONIPS_SIMPF_LINKFILE) && file_exists($XOONIPS_SIMPF_LINKFILE)) {
|
|
$lines = file($XOONIPS_SIMPF_LINKFILE);
|
|
foreach ($lines as $line) {
|
|
list($pfname, $pfurl, $simpfurl) = explode(',', $line);
|
|
if (preg_match('/^'.preg_quote(XOOPS_URL, '/').'/', $pfurl)) {
|
|
$pUrl = parse_url($pfurl);
|
|
if ($pUrl['path'] != $xoops_url_path.'/modules/xoonips/detail.php') {
|
|
echo 'not xoonips url found in simpf link file. URL:'.$pfurl.PHP_EOL;
|
|
continue;
|
|
}
|
|
if (preg_match('/(?:^|&)(id|item_id)=([^$&]+)/', $pUrl['query'], $matches)) {
|
|
$key = $matches[1];
|
|
$value = $matches[2];
|
|
$ret[$key][$value] = trim($simpfurl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return $ret;
|
|
}
|