Exemple #1
0
 public function render($bEcho = true)
 {
     $str = '';
     if ($this->page) {
         $str .= "<table><tr><th>Product Name</th>";
         $displayedElements = App::Get()->settings['browser_products_met'];
         foreach ($displayedElements as $elementName) {
             $str .= "<th>{$elementName}</th>";
         }
         $str .= "</tr>";
         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 .= "<tr><td><a href=\"" . $this->urlBase . "/product/{$product->getId()}/{$this->returnPage}\">" . urlDecode(basename($product->getName())) . "</a></td>";
             foreach ($displayedElements as $elementName) {
                 $str .= "<td>" . $this->pageMetadata[$product->getId()]->getMetadata($elementName) . "</td>";
             }
             $str .= "</tr>";
         }
         $str .= "</table>";
     }
     if ($bEcho) {
         echo $str;
     } else {
         return $str;
     }
 }
Exemple #2
0
require_once $module->modulePath . "/scripts/widgets/MetadataDisplayWidget.php";
require_once $module->modulePath . "/scripts/widgets/ProductDownloadWidget.php";
// Get a CAS-Browser XML/RPC client
$browser = new CasBrowser();
$client = $browser->getClient();
// Get the specified product
$productId = App::Get()->request->segments[0];
$product = $client->getProductById($productId);
$productName = $product->getName();
$productTypeName = $product->getType()->getName();
$productTypeId = $product->getType()->getId();
$productMetadata = $client->getMetadata($product);
// Get metadata for product and productType as associative arrays
$productTypeInfo = $product->getType()->toAssocArray();
$productInfo = $productMetadata->toAssocArray();
$productVisibilityLevel = $browser->getProductVisibilityLevel($productId);
// Redirect the user if they are not authorized
if ($productVisibilityLevel == CasBrowser::VIS_NONE) {
    App::Get()->redirect(SITE_ROOT . '/errors/403');
}
// Create and load a MetadataDisplay widget wit the visible metadata
$metadataWidget = new MetadataDisplayWidget(array());
$metadataWidget->loadMetadata($browser->getVisibleMetadataForProduct($productId));
// Record the product page to send the user back to, if provided
$returnPage = isset(App::Get()->request->segments[1]) ? App::Get()->request->segments[1] : 1;
// Create a ProductDownloadWidget
$productDownloadWidget = new ProductDownloadWidget(array("dataDeliveryUrl" => App::Get()->settings['browser_datadeliv_url']));
$productDownloadWidget->setClient($client);
$productDownloadWidget->load($product);
// Add the cas-browser styles
App::Get()->response->addStylesheet($module->moduleStatic . '/css/cas-browser.css');