"newsdetail", "detail_file" => $json ]); if(!empty($airQuery->error)){ $locationurl = $host . "/404.html"; header('Location: ' . $locationurl); exit(); } $restrictId = !empty($airQuery->detail["cms_news_access_restrict_id"]) ? $airQuery->detail["cms_news_access_restrict_id"] : ""; $restrictName = !empty($airQuery->detail["cms_news_access_restrict_name"]) ? $airQuery->detail["cms_news_access_restrict_name"] : ""; $ipAccessFlag = !empty($airQuery->detail["ip_access_flag"]) ? $airQuery->detail["ip_access_flag"] : "0"; $basicAuthFlag = !empty($airQuery->detail["basic_auth_flag"]) ? $airQuery->detail["basic_auth_flag"] : "0"; $basicAuthType = !empty($airQuery->detail["basic_auth_type"]) ? $airQuery->detail["basic_auth_type"] : "1"; if(!empty($restrictId) && $restrictId != "0" && !empty($restrictName)) { $restrited = new Air_Query([ "mode" => "newsdetail", "detail_file" => $json, "detail_restricted" => true, "detail_restricted_type" => $airQuery->detail["news_type"], "detail_restricted_id" => $restrictId, "detail_basic_auth_flag" => $basicAuthFlag, "detail_basic_auth_type" => $basicAuthType, "detail_ip_access_flag" => $ipAccessFlag, ]); if(empty($restrited->error)){ $airQuery = $restrited; } } $description = $airQuery->detail["description"]; $seoDescription = $airQuery->detail["description"]; $signature = $airQuery->detail["signature"]; $subjects = $airQuery->detail["subjects"]; $venue = $airQuery->detail["venue"]; $sponsorship = $airQuery->detail["sponsorship"]; $id = $airQuery->detail["cms_news_id"]; $category = $airQuery->detail["cms_news_category_class_name"]; $category2 = $airQuery->detail["cms_news_category_name"]; $categorySlug = $airQuery->detail["cms_news_category_class_slug"]; $category2Slug = $airQuery->detail["cms_news_category_slug"]; $categoryColor = $airQuery->detail["cms_news_category_class_color"]; $category2Color = $airQuery->detail["cms_news_category_color"]; $category2TextColor = $airQuery->detail["cms_news_category_text_color"]; $title = nl2br($airQuery->detail["title"]); $pageTitle = $airQuery->detail["title"]; $documentNumber = $airQuery->detail["document_number"]; $year = $airQuery->detail["year"]; $month = $airQuery->detail["month"]; $monthEn = $airQuery->detail["monthEn"]; $date = $airQuery->detail["date"]; $day = $airQuery->detail["day"]; $dayEn = $airQuery->detail["dayEn"]; $albumDir = $albumPath . $airQuery->detail["cms_news_id"] . "/"; $thumbnailImg = $airQuery->detail["thumbnail_file_name"] != null ? "" . $airQuery->detail["thumbnail_alt_text"] . "": ""; $thumbnailPath = $airQuery->detail["thumbnail_file_name"] != null ? $host . $albumDir . $airQuery->detail["thumbnail_file_name"] : ""; $tags = $airQuery->detail["cms_news_release_tags"]; $icons = $airQuery->detail["icons"]; $DAY_J_ARR = ["日","月","火","水","木","金","土"]; $orgSchedule = $airQuery->detail["event_schedule"]; $eventSchedule = []; foreach($orgSchedule as $org) { $schedule = []; $schedule["startYear"] = date('Y', strtotime($org["start_month_date"])); $schedule["startMonth"] = date('m', strtotime($org["start_month_date"])); $schedule["startMonthEn"] = date('M', strtotime($org["start_month_date"])); $schedule["startDate"] = date('d', strtotime($org["start_month_date"])); $schedule["startDay"] = $DAY_J_ARR[date('w', strtotime($org["start_month_date"]))]; $schedule["startDayEn"] = date('D', strtotime($org["start_month_date"])); $schedule["startHour"] = str_pad($org["start_hour"], 2, "0", STR_PAD_LEFT); $schedule["startMinutes"] = str_pad($org["start_minutes"], 2, "0", STR_PAD_LEFT); $schedule["endYear"] = !empty($org["end_month_date"]) ? date('Y', strtotime($org["end_month_date"])) : ""; $schedule["endMonth"] = !empty($org["end_month_date"]) ? date('m', strtotime($org["end_month_date"])): ""; $schedule["endMonthEn"] = !empty($org["end_month_date"]) ? date('M', strtotime($org["end_month_date"])): ""; $schedule["endDate"] = !empty($org["end_month_date"]) ? date('d', strtotime($org["end_month_date"])): ""; $schedule["endDay"] = !empty($org["end_month_date"]) ? $DAY_J_ARR[date('w', strtotime($org["end_month_date"]))]: ""; $schedule["endDayEn"] = !empty($org["end_month_date"]) ? date('D', strtotime($org["end_month_date"])): ""; $schedule["hasEndDate"] = !empty($org["end_month_date"]) ? "hasEndDate" : "noEndDate"; $schedule["endHour"] = str_pad($org["end_hour"], 2, "0", STR_PAD_LEFT); $schedule["endMinutes"] = str_pad($org["end_minutes"], 2, "0", STR_PAD_LEFT); $eventSchedule[] = $schedule; } $body = !empty($airQuery->detail["body"]) ? $airQuery->detail["body"] : ""; if (!empty($body) && $blankLinkTextFlag == "1") { $dom = new DOMDocument(); $html = '' . $body . ''; @$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $links = $dom->getElementsByTagName('a'); foreach ($links as $link) { if ($link->getAttribute('target') === '_blank') { $span = $dom->createElement('span'); $span->setAttribute('class', 'visually-hidden'); $textNode = $dom->createTextNode('(リンクを新しいタブで開きます)'); $span->appendChild($textNode); $link->appendChild($span); } } $body = ''; $bodyNode = $dom->getElementsByTagName('body')->item(0); if ($bodyNode) { foreach ($bodyNode->childNodes as $node) { $body .= $dom->saveHTML($node); } } } $style = !empty($airQuery->detail["style"]) ? $airQuery->detail["style"] : ""; $attrsOrg = !empty($airQuery->detail["news_attrs"]) ? $airQuery->detail["news_attrs"] : []; $attrs = []; foreach($attrsOrg as $org) { $attr = []; foreach($org["cms_relate_news_to_attrs"] as $value) { $item = []; $item["key_name"] = $org["news_attr_key_dto"]["key_name"]; $item["slug"] = $org["news_attr_key_dto"]["slug"]; $item["cms_news_attr_value_name"] = $value["cms_news_attr_value_name"]; $item["color"] = $value["color"]; $attr[] = $item; } $attrs[$org["news_attr_key_dto"]["slug"]] = $attr; } $news_body_str = trim(strip_tags($body)); $news_body_90 = mb_substr($news_body_str, 0, 90); if(empty($description)) { $seoDescription = trim($news_body_90); } function snakeToCamel($data) { $result = []; foreach ($data as $key => $value) { $newKey = is_string($key) ? lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $key)))) : $key; if (is_array($value) || is_object($value)) { $result[$newKey] = snakeToCamel((array) $value); } else { $result[$newKey] = $value; } } return $result; } $recommendsJson = []; if(!empty($airQuery->detail["recommends"])) { $recommends = $airQuery->detail["recommends"]; $recommendsJson = snakeToCamel($recommends); } $recommendsJson = json_encode($recommendsJson); $newsType = !empty($airQuery->detail["news_type"]) ? $airQuery->detail["news_type"] : "0"; $newsTypeStr = $newsType == "0" ? "news" : "event" ?> <?php echo $pageTitle; ?> | 国立科学博物館 National Museum of Nature and Science,Tokyo "> "> ">