function launch() { global $interface; global $configArray; global $library; global $locationSingleton; global $timer; global $user; $currentPage = isset($_GET['page']) ? intval($_GET['page']) : 1; //Pagination $pag = new Pagination(); $pag->setPagination($currentPage, 30); //Most Popular $listAPI = new ListAPI(); $listTitlesFE = $listAPI->getListTitles('freeEbooks', $pag); $interface->assign('LIST', !empty($listTitlesFE['titles']) ? $listTitlesFE['titles'] : ""); $pag->setPagination($currentPage + 1, 30); $moreTitles = $listAPI->getListTitles('freeEbooks', $pag); if (!empty($moreTitles['titles'])) { $interface->assign('NEXTPAGE', $currentPage + 1); $interface->assign('ACTION', "FreeEbooks"); } $interface->assign('ButtonBack', true); $interface->assign('ButtonHome', true); $interface->caching = 0; $cacheId = 'homepage|' . $interface->lang; //Disable Home page caching for now. if (!$interface->is_cached('layout.tpl', $cacheId)) { $interface->setPageTitle('Free eBooks'); $interface->assign('MobileTitle', 'Free eBooks'); $interface->setTemplate('listecontents.tpl'); } $interface->display('layout.tpl', $cacheId); }
function launch() { global $interface; global $configArray; global $library; global $locationSingleton; global $timer; global $user; //Most Popular $listAPI = new ListAPI(); $listTitlesMP = $listAPI->getListTitles('EContentStrands:home_4'); //Check success key $interface->assign('LIST', $listTitlesMP['success'] ? $listTitlesMP['titles'] : ""); $interface->assign('ButtonBack', true); $interface->assign('ButtonHome', true); $interface->caching = 0; $cacheId = 'homepage|' . $interface->lang; //Disable Home page caching for now. if (!$interface->is_cached('layout.tpl', $cacheId)) { $interface->setPageTitle('Most Popular'); $interface->assign('MobileTitle', 'Most Popular'); $interface->setTemplate('listecontents.tpl'); } $interface->display('layout.tpl', $cacheId); }
function fullListLink() { require_once ROOT_DIR . '/services/API/ListAPI.php'; $listAPI = new ListAPI(); $cacheInfo = $listAPI->getCacheInfoForListId($this->source); $link = $cacheInfo['fullListLink']; //Get the widget for the list $widget = new ListWidget(); $widget->id = $this->listWidgetId; if ($widget->find(true)) { if ($widget->viewMoreLinkMode == 'covers') { $cacheInfo['fullListLink'] .= '&view=covers'; } } return $cacheInfo['fullListLink']; }
function launch() { global $interface; global $configArray; global $library; global $locationSingleton; global $timer; global $user; // Include Search Engine Class require_once ROOT_DIR . '/sys/' . $configArray['Index']['engine'] . '.php'; $timer->logTime('Include search engine'); if ($user) { $catalog = new CatalogConnection($configArray['Catalog']['driver']); $patron = $catalog->patronLogin($user->cat_username, $user->cat_password); $profile = $catalog->getMyProfile($patron); if (!PEAR_Singleton::isError($profile)) { $interface->assign('profile', $profile); } } //Get AVG Rating eContent $listAPI = new ListAPI(); //New Ebooks $listTitlesNE = $listAPI->getListTitles('newebooks'); //Check if the list is empty or not //Assign lists to Smarty var $interface->assign('NE', !empty($listTitlesNE['titles']) ? $listTitlesNE['titles'] : ""); // Cache homepage $interface->caching = 0; $cacheId = 'homepage|' . $interface->lang; //Disable Home page caching for now. if (!$interface->is_cached('layout.tpl', $cacheId)) { $interface->setPageTitle('iDCLReader Catalog Home'); $interface->setTemplate('home.tpl'); } $interface->display('layout.tpl', $cacheId); }
function GetListTitles() { global $memCache; global $configArray; global $timer; $listId = $_REQUEST['listId']; $_REQUEST['id'] = 'list:' . $listId; $listName = strip_tags(isset($_GET['scrollerName']) ? $_GET['scrollerName'] : 'List' . $listId); $scrollerName = isset($_GET['scrollerName']) ? strip_tags($_GET['scrollerName']) : $listName; //Determine the caching parameters require_once ROOT_DIR . '/services/API/ListAPI.php'; $listAPI = new ListAPI(); $cacheInfo = $listAPI->getCacheInfoForList(); $listData = $memCache->get($cacheInfo['cacheName']); if (!$listData || isset($_REQUEST['reload']) || isset($listData['titles']) && count($listData['titles'] == 0)) { global $interface; $titles = $listAPI->getListTitles(); $timer->logTime("getListTitles"); $addStrandsTracking = false; if ($titles['success'] == true) { if (isset($titles['strands'])) { $addStrandsTracking = true; $strandsInfo = $titles['strands']; } $titles = $titles['titles']; if (is_array($titles)) { foreach ($titles as $key => $rawData) { $interface->assign('description', $rawData['description']); $interface->assign('length', $rawData['length']); $interface->assign('publisher', $rawData['publisher']); $descriptionInfo = $interface->fetch('Record/ajax-description-popup.tpl'); $formattedTitle = "<div id=\"scrollerTitle{$scrollerName}{$key}\" class=\"scrollerTitle\">"; $shortId = $rawData['id']; if (preg_match('/econtentRecord\\d+/i', $rawData['id'])) { $recordId = substr($rawData['id'], 14); $formattedTitle .= '<a href="' . $configArray['Site']['path'] . "/EcontentRecord/" . $recordId . ($addStrandsTracking ? "?strandsReqId={$strandsInfo['reqId']}&strandsTpl={$strandsInfo['tpl']}" : '') . '" id="descriptionTrigger' . $rawData['id'] . '">'; } else { $shortId = str_replace('.b', 'b', $shortId); $formattedTitle .= '<a href="' . $configArray['Site']['path'] . "/Record/" . $rawData['id'] . ($addStrandsTracking ? "?strandsReqId={$strandsInfo['reqId']}&strandsTpl={$strandsInfo['tpl']}" : '') . '" id="descriptionTrigger' . $shortId . '">'; } $formattedTitle .= "<img src=\"{$rawData['image']}\" class=\"scrollerTitleCover\" alt=\"{$rawData['title']} Cover\"/>" . "</a></div>" . "<div id='descriptionPlaceholder{$shortId}' style='display:none' class='loaded'>" . $descriptionInfo . "</div>"; $rawData['formattedTitle'] = $formattedTitle; $titles[$key] = $rawData; } } $currentIndex = count($titles) > 5 ? floor(count($titles) / 2) : 0; $return = array('titles' => $titles, 'currentIndex' => $currentIndex); $listData = json_encode($return); } else { $return = array('titles' => array(), 'currentIndex' => 0); $listData = json_encode($return); } $memCache->set($cacheInfo['cacheName'], $listData, 0, $cacheInfo['cacheLength']); } return $listData; }
public function validateLists() { //Setup validation return array $validationResults = array('validatedOk' => true, 'errors' => array()); $listNames = array(); require_once ROOT_DIR . '/services/API/ListAPI.php'; $listAPI = new ListAPI(); $allListIds = $listAPI->getAllListIds(); foreach ($this->lists as $list) { //Check to make sure that all list names are unique if (in_array($list->name, $listNames)) { $validationResults['errors'][] = "This name {$list->name} was used mulitple times. Please make sure that each name is unique."; } $listNames[] = $list->name; //Check to make sure that each list source is valid $source = $list->source; //The source is valid if it is in the all lists array or if it starts with strands: or review: if (preg_match('/^(strands:|review:|search:).*/', $source)) { //source is valid } elseif (in_array($source, $allListIds)) { //source is valid } else { //source is not valid $validationResults['errors'][] = "This source {$list->source} is not valid. Please enter a valid list source."; } } //Make sure there aren't errors if (count($validationResults['errors']) > 0) { $validationResults['validatedOk'] = false; } return $validationResults; }
/** * @return string JSON encoded data representing the list information */ function GetListTitles() { /** @var Memcache $memCache */ global $memCache; global $configArray; global $timer; $listName = strip_tags(isset($_GET['scrollerName']) ? $_GET['scrollerName'] : 'List' . $_GET['id']); //Determine the caching parameters require_once ROOT_DIR . '/services/API/ListAPI.php'; $listAPI = new ListAPI(); $cacheInfo = $listAPI->getCacheInfoForList(); $cacheName = $cacheInfo['cacheName']; if (isset($_REQUEST['coverSize']) && $_REQUEST['coverSize'] == 'medium') { $cacheName .= '_medium'; } $listData = $memCache->get($cacheName); if (!$listData || isset($_REQUEST['reload']) || isset($listData['titles']) && count($listData['titles']) == 0) { global $interface; $interface->assign('listName', $listName); $showRatings = isset($_REQUEST['showRatings']) && $_REQUEST['showRatings']; $interface->assign('showRatings', $showRatings); // overwrite values that come from library settings $titles = $listAPI->getListTitles(); $timer->logTime("getListTitles"); if ($titles['success'] == true) { $titles = $titles['titles']; if (is_array($titles)) { foreach ($titles as $key => $rawData) { $interface->assign('key', $key); // 20131206 James Staub: bookTitle is in the list API and it removes the final frontslash, but I didn't get $rawData['bookTitle'] to load $titleShort = preg_replace(array('/\\:.*?$/', '/\\s*\\/$\\s*/'), '', $rawData['title']); // $titleShort = preg_replace('/\:.*?$/','', $rawData['title']); // $titleShort = preg_replace('/\s*\/$\s*/','', $titleShort); $interface->assign('title', $titleShort); $interface->assign('description', isset($rawData['description']) ? $rawData['description'] : null); $interface->assign('length', isset($rawData['length']) ? $rawData['length'] : null); $interface->assign('publisher', isset($rawData['publisher']) ? $rawData['publisher'] : null); $interface->assign('shortId', $rawData['shortId']); $interface->assign('id', $rawData['id']); $rawData['titleURL'] = $configArray['Site']['path'] . '/GroupedWork/' . $rawData['id']; // assumes all are grouped works $interface->assign('titleURL', $rawData['titleURL']); $imageUrl = $rawData['small_image']; if (isset($_REQUEST['coverSize']) && $_REQUEST['coverSize'] == 'medium') { $imageUrl = $rawData['image']; } $interface->assign('imageUrl', $imageUrl); if ($showRatings) { $interface->assign('ratingData', $rawData['ratingData']); $interface->assign('showNotInterested', false); } $rawData['formattedTitle'] = $interface->fetch('ListWidget/formattedTitle.tpl'); $titles[$key] = $rawData; } } $currentIndex = count($titles) > 5 ? floor(count($titles) / 2) : 0; $listData = array('titles' => $titles, 'currentIndex' => $currentIndex); $memCache->set($cacheInfo['cacheName'], $listData, 0, $cacheInfo['cacheLength']); } else { $listData = array('titles' => array(), 'currentIndex' => 0); if ($titles['message']) { $listData['error'] = $titles['message']; } // send error message to widget javascript } } return $listData; }