function normalize_work($work, $resolve_references = true) { /* handle "materials" */ if (!@is_array($work['materials'])) { $work['materials'] = array(); } /* handle "reference" */ if (!@is_array($work['reference'])) { $work['reference'] = array(); } if ($resolve_references) { $resolved = array(); foreach ($work['reference'] as $reference) { // get title for each reference $referenced = load_work($reference, false); if ($referenced === false) { // reference not found continue; } $resolved[] = array('name' => $reference, 'title' => $referenced['title'], 'url' => get_url_from_name($reference)); } $work['reference'] = $resolved; } /* handle "sortYear" */ if (!isset($work['sortYear'])) { echo 'Field sortYear is not set in ' . $work['name'] . '/meta.txt'; exit(3); } else { if ($work['sortYear'] === 'ongoing') { // add one to the current year, so that "ongoing" works are always most recent $work['sortYear'] = intval(date('Y')) + 1; } else { // force integer $work['sortYear'] = intval($work['sortYear']); } } /* handle "title" */ if (!@is_string($work['title'])) { $work['title'] = $work['name']; } /* handle "type" */ if (!@is_string($work['type'])) { echo 'Field type is not set in ' . $work['name'] . '/meta.txt'; exit(4); } /* handle "url_work" */ if (!@is_array($work['url_work'])) { $work['url_work'] = array(); } /* handle "year" */ if (!@is_string($work['year'])) { $work['year'] = ''; } return $work; }
<p class="json"></p> <pre> $container.jodi({ filterBy: <span class="jsonstring filterBystring">null</span>, sortBy: <span class="jsonstring sortBystring">null</span> }); </pre> <p></p> <div id="container" class="isotope"> <div class="block stamp"></div> <?php foreach ($data as $work) { ?> <a href="<?php echo get_url_from_name($work['name']); ?> "> <div class="item <?php echo format_class($work['type']); ?> "> <h1 class="title"><?php echo $work['title']; ?> </h1> <p class="year"><?php echo $work['year']; ?> </p> <p class="sortYear" style="display: none;"><?php