<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
  
  // load viewer library
  $libraryPath = 'cmsb/lib/viewer_functions.php';
  $dirsToCheck = array('/Applications/XAMPP/xamppfiles/htdocs/kunsyodo/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  // load record from 'basic'
  list($basicRecords, $basicMetaData) = getRecords(array(
    'tableName'   => 'basic',
    'where'       => '', // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $basicRecord = @$basicRecords[0]; // get first record
  if (!$basicRecord) { dieWith404("Record not found!"); } // show error message if no record found
  
  // load record from 'policy'
  list($policyRecords, $policyMetaData) = getRecords(array(
    'tableName'   => 'policy',
    'where'       => '', // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $policyRecord = @$policyRecords[0]; // get first record
  if (!$policyRecord) { dieWith404("Record not found!"); } // show error message if no record found
  
  // load records from 'gnav'
  list($gnavRecords, $selectedGnav) = getCategories(array(
    'tableName'            => 'gnav', //
    'categoryFormat'       => 'showall',  // showall, onelevel, twolevel, breadcrumb
    'defaultCategory'      => '1',    // Enter 'first', a category number, or leave blank '' for none
  ));
  
  // load records from 'socials'
  list($socialsRecords, $socialsMetaData) = getRecords(array(
    'tableName'   => 'socials',
    'loadUploads' => true,
    'allowSearch' => false,
  ));
  
  // load records from 'news'
  list($newsRecords, $newsMetaData) = getRecords(array(
    'tableName'   => 'news',
    'loadUploads' => false,
    'allowSearch' => false,
	'limit'       => '4',
  ));
  
  // load records from 'blog_category'
  list($blog_categoryRecords, $selectedBlog_category) = getCategories(array(
    'tableName'            => 'blog_category', //
    'categoryFormat'       => 'showall',  // showall, onelevel, twolevel, breadcrumb
    'defaultCategory'      => '',    // Enter 'first', a category number, or leave blank '' for none
  ));

  
  // load records from 'blog'
  list($blogRecords, $blogMetaData) = getRecords(array(
    'tableName'   => 'blog',
    'perPage'     => '6',
    'loadUploads' => true,
    'allowSearch' => true,
	'where' => 'category',
  ));
  
  // load records from 'item_each'
  list($item_eachRecords, $selectedIitem_each) = getCategories(array(
    'tableName'            => 'item_each', //
    'categoryFormat'       => 'showall',  // showall, onelevel, twolevel, breadcrumb
    'defaultCategory'      => '',    // Enter 'first', a category number, or leave blank '' for none
  ));
  
  // load record from 'top'
  list($topRecords, $topMetaData) = getRecords(array(
    'tableName'   => 'top',
    'where'       => '', // load first record
    'loadUploads' => true,
    'allowSearch' => false,
    'limit'       => '1',
  ));
  $topRecord = @$topRecords[0]; // get first record
  if (!$topRecord) { dieWith404("Record not found!"); } // show error message if no record found
  
?><?php permalinks_301redirectToPermalink(); ?>
<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie10 lt-ie9 lt-ie8 lt-ie7" lang="ja"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie10 lt-ie9 lt-ie8" lang="ja"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie10 lt-ie9" lang="ja"> <![endif]-->
<!--[if IE 9 ]>         <html class="no-js lt-ie10" lang="ja"> <![endif]-->
<!--[if gt IE 9]><!-->
<html class="no-js" lang="ja" xml:lang="ja">
<!--<![endif]-->

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title><?php echo htmlencode($basicRecord['title']) ?> | <?php echo htmlencode($selectedBlog_category['name']) ?></title>
<meta name="title" content="<?php echo htmlencode($basicRecord['title']) ?> | <?php echo htmlencode($selectedBlog_category['name']) ?>" />
<meta name="keywords" content="<?php echo $selectedBlog_category['keywords'] ?>" />
<meta name="description" content="<?php echo $selectedBlog_category['description'] ?>" />
<meta name="author" content="古美術 薫匠堂">
<meta name="copyright" content="kunsyodo.com">
<link rel="alternate" hreflang="ja-jp" href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--Favicon/apple-touch/android-->
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png?v=Ryyw9EJz5l">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png?v=Ryyw9EJz5l">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png?v=Ryyw9EJz5l">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png?v=Ryyw9EJz5l">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png?v=Ryyw9EJz5l">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png?v=Ryyw9EJz5l">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png?v=Ryyw9EJz5l">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png?v=Ryyw9EJz5l">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png?v=Ryyw9EJz5l">
<link rel="icon" type="image/png" href="/favicon-32x32.png?v=Ryyw9EJz5l" sizes="32x32">
<link rel="icon" type="image/png" href="/android-chrome-192x192.png?v=Ryyw9EJz5l" sizes="192x192">
<link rel="icon" type="image/png" href="/favicon-96x96.png?v=Ryyw9EJz5l" sizes="96x96">
<link rel="icon" type="image/png" href="/favicon-16x16.png?v=Ryyw9EJz5l" sizes="16x16">
<link rel="manifest" href="/manifest.json?v=Ryyw9EJz5l">
<link rel="shortcut icon" href="/favicon.ico?v=Ryyw9EJz5l">
<meta name="apple-mobile-web-app-title" content="古美術薫匠堂">
<meta name="application-name" content="古美術薫匠堂">
<meta name="msapplication-TileColor" content="#761a1c">
<meta name="msapplication-TileImage" content="/mstile-144x144.png?v=Ryyw9EJz5l">
<meta name="theme-color" content="#ffffff">
<!--/Favicon/apple-touch/android-->
<!--Stylesheets-->
<link href="<?php echo PREFIX_URL ?>/css/normalize3_0_3.css" rel="stylesheet" type="text/css">
<link href="<?php echo PREFIX_URL ?>/css/main5_2.css" rel="stylesheet" type="text/css">
<link href="<?php echo PREFIX_URL ?>/css/layout.css" rel="stylesheet" type="text/css">
<link href="<?php echo PREFIX_URL ?>/css/layout.css.php" rel="stylesheet" type="text/css">
<link href="<?php echo PREFIX_URL ?>/slick/slick.css" rel="stylesheet" type="text/css">
<link href="<?php echo PREFIX_URL ?>/slick/slick-theme.css" rel="stylesheet" type="text/css">
<!--Stylesheets-->
<!--JavaScript-->
<script src="<?php echo PREFIX_URL ?>/js/vendor/modernizr-2.8.3.min.js"></script>
<!--jquery will always be in head when using NailThumb. Delete jquery from script.php at bottom. Do not use jquery-migrate-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 
<script>window.jQuery || document.write('<script src="<?php echo PREFIX_URL ?>/js/vendor/jquery-1.11.3.min.js"><\/script>')</script>
<script type="text/javascript" src="<?php echo PREFIX_URL ?>/js/jquery.metadata.js"></script> 
<script type="text/javascript" src="<?php echo PREFIX_URL ?>/js/jquery.nailthumb.1.1.min.js"></script>
<!--Morisawa Typesquare-->
<script type="text/javascript" src="//typesquare.com/accessor/script/typesquare.js?NbLDqvvFB78%3D&fadein=10" charset="utf-8"></script>
<!--/Morisawa Typesquare-->
<!--/JavaScript-->
<!--NailThumb-->
<style type="text/css" media="screen">
.blog-thumb {
	width: 280px;
	height: 280px;
}
}
</style>
<!--/NailThumb-->
</head>

<body>
<?php include_once("analyticstracking.php") ?>
<?php include_once("head_nav.php") ?>
<!--Main Content-->
<div class="content_center">
  <div id="mainContent_blogList">
  <?php if ($selectedBlog_category): ?>
  <h1><?php echo htmlencode($selectedBlog_category['name']) ?></h1>
  <?php endif ?>
  <?php foreach ($blogRecords as $record): ?>
  
    <section class="blogList">
      <?php foreach ($record['eyecatch'] as $index => $upload): ?>
      <div class="figure_blogList nailthumb-container-metadata">
      <div class="nailthumb-container blog-thumb" {method:'crop'}><a href="<?php echo $record['_link'] ?>"><img src="<?php echo htmlencode($upload['urlPath']) ?>" /></a></div></div>
      <?php endforeach ?>
      <h1><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></h1>
      <p><?php echo mb_substr(strip_tags($record['content']), 0, 60);?> ...</p>
      <p>カテゴリー：<a href="$selectedBlog_category"><?php echo $record['category:label'] ?></a></p>
      <div class="blogList_read"><a href="<?php echo $record['_link'] ?>">この記事を読む</a></div>
    </section>

    <?php endforeach ?>
    <section class="mainContent" id="pageNav">
    <!-- Page Nav -->
    <?php if ($blogMetaData['prevPage']): ?>
      <a href="<?php echo $blogMetaData['prevPageLink'] ?>">&laquo; 前へ</a>
    <?php else: ?>
    <?php endif ?>
    <?php
     if (@!$_GET['page']): $current_page = "1";
     else: $current_page = $_GET['page'];
     endif; ?>
     <?php
	 $onePage = ($blogMetaData['totalPages'] < 2);
	 ?>
        <?php foreach (range(1,$blogMetaData['totalPages']) as $page): ?>
        <?php if ($onePage): ?>
        <?php elseif ($page == $current_page): ?>
        <span class="pageNo"><?php echo $page; ?></span>
        <?php else: ?>
        <span class="pageNo"><a href="<?php echo $blogMetaData['nextPageLink'] ?>"><?php echo $page; ?></a></span>
        <?php endif ?>
        <?php endforeach; ?>

     <?php if ($blogMetaData['nextPage']): ?>
      <a href="<?php echo $blogMetaData['nextPageLink'] ?>">次へ &raquo;</a>
    <?php else: ?>
    <?php endif ?>
  <!-- /Page Nav -->
    </section>
  </div>
  <!--/Main Content-->
  <?php include_once("sidebar.php") ?>
</div>
<?php include_once("footer.php") ?>
<?php include_once("script2.php") ?>
</body>
</html>
