page = false; $this->productTypeId = $options['productTypeId']; $this->returnPage = (isset($options['returnPage'])) ? $options['returnPage'] : 1; $this->urlBase = $options['urlBase']; } public function load($productPage, $productMetadata = NULL) { $this->page = $productPage; $this->pageMetadata = $productMetadata; $this->pageNum = $this->page->getPageNum(); $this->pageProducts = $this->page->getPageProducts(); $this->pageSize = $this->page->getPageSize(); $this->totalPages = $this->page->getTotalPages(); } public function render($bEcho = true) { $str = ''; if ($this->page) { $str .= ""; $displayedElements = App::Get()->settings['browser_products_met']; foreach($displayedElements as $elementName){ $str .= ""; } $str .= ""; if ( !App::Get()->settings['browser_private_products_visibility'] ) { // Get a CAS-Browser XML/RPC client $browser = new CasBrowser(); $client = $browser->getClient(); foreach ($this->pageMetadata as $key => $value) { if ( $browser->getProductVisibilityLevel($key) == "deny") { unset($this->pageMetadata[$key]); foreach ($this->pageProducts as $product) { if ($product->id == $key) { $productKey = array_search($product, $this->pageProducts); unset($this->pageProducts[$productKey]); } } } } } foreach($this->pageProducts as $product){ $str .= ""; foreach($displayedElements as $elementName){ $str .= ""; } $str .= ""; } $str .= "
Product Name{$elementName}
urlBase."/product/{$product->getId()}/{$this->returnPage}\">" . urlDecode(basename($product->getName())) . "" . $this->pageMetadata[$product->getId()]->getMetadata($elementName) . "
"; } if ($bEcho) { echo $str; } else { return $str; } } public function renderPageDetails($bEcho = true) { // Variables to determine product range displayed and total count $pageNum = ($this->pageNum == -1) ? 0 : $this->pageNum; $totalPages = ($this->totalPages == -1) ? 0 : $this->totalPages; $displayCountStart = ($totalPages == 0) ? 0 : $this->pageSize * ($pageNum - 1) + 1; $displayCountEnd = ($totalPages == 0) ? 0 : $displayCountStart + count($this->pageProducts) - 1; $displayCountStart = ($totalPages > 0 && $displayCountStart == 0) ? 1 : $displayCountStart; // 'Previous' and 'Next' page links $linkBase = App::Get()->loadModule()->moduleRoot . "/products/{$this->productTypeId}/page"; $prevPageNum = $this->pageNum -1; $nextPageNum = $this->pageNum +1; $prevPageLink = ($prevPageNum >= 1) ? "<< Previous Page" : ''; $nextPageLink = ($nextPageNum <= $this->totalPages) ? "Next Page >>" : ''; $rangeInfo = "Page {$pageNum} of {$totalPages} " ."(products {$displayCountStart} - {$displayCountEnd})"; $str = "
{$rangeInfo}  {$prevPageLink}  {$nextPageLink}
\r\n"; if ($bEcho) { echo $str; } else { return $str; } } }