function launch() { global $interface; global $timer; global $logger; global $user; //Build the actual view $interface->setTemplate('view-series.tpl'); $id = $_REQUEST['id']; require_once ROOT_DIR . '/RecordDrivers/GroupedWorkDriver.php'; $recordDriver = new GroupedWorkDriver($id); if (!$recordDriver->isValid) { $logger->log("Did not find a record for id {$id} in solr.", PEAR_LOG_DEBUG); $interface->setTemplate('invalidRecord.tpl'); $interface->display('layout.tpl'); die; } $timer->logTime('Initialized the Record Driver'); $novelist = NovelistFactory::getNovelist(); $seriesData = $novelist->getSeriesTitles($id, $recordDriver->getISBNs()); //Loading the series title is not reliable. Do not try to load it. $seriesTitle = null; $seriesAuthors = array(); $resourceList = array(); $seriesTitles = $seriesData->seriesTitles; $recordIndex = 1; if (isset($seriesTitles) && is_array($seriesTitles)) { foreach ($seriesTitles as $key => $title) { if (isset($title['series']) && strlen($title['series']) > 0 && !isset($seriesTitle)) { $seriesTitle = $title['series']; $interface->assign('seriesTitle', $seriesTitle); } if (isset($title['author'])) { $author = preg_replace('/[^\\w]*$/i', '', $title['author']); $seriesAuthors[$author] = $author; } $interface->assign('recordIndex', $recordIndex); $interface->assign('resultIndex', $recordIndex++); if ($title['libraryOwned']) { /** @var GroupedWorkDriver $tmpRecordDriver */ $tmpRecordDriver = $title['recordDriver']; $resourceList[] = $interface->fetch($tmpRecordDriver->getSearchResult($user, null, false)); } else { $interface->assign('record', $title); $resourceList[] = $interface->fetch('RecordDrivers/Index/nonowned_result.tpl'); } } } $interface->assign('seriesAuthors', $seriesAuthors); $interface->assign('recordSet', $seriesTitles); $interface->assign('resourceList', $resourceList); $interface->assign('recordStart', 1); $interface->assign('recordEnd', count($seriesTitles)); $interface->assign('recordCount', count($seriesTitles)); $interface->assign('recordDriver', $recordDriver); $interface->assign('sidebar', 'GroupedWork/full-record-sidebar.tpl'); $interface->setPageTitle($seriesTitle); // Display Page $interface->display('layout.tpl'); }