Advertisement
Guest User

ProductCatalogView.class.php

a guest
Jul 20th, 2014
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.98 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Product catalog
  4.  *
  5.  * @version    1.0
  6.  * @package    samples
  7.  * @subpackage tutor
  8.  * @author     Pablo Dall'Oglio
  9.  * @copyright  Copyright (c) 2006-2014 Adianti Solutions Ltd. (http://www.adianti.com.br)
  10.  * @license    http://www.adianti.com.br/framework-license
  11.  */
  12. class ProductCatalogView extends TPage
  13. {
  14.     /**
  15.      * Constructor method
  16.      */
  17.     public function __construct()
  18.     {
  19.         parent::__construct();
  20.        
  21.         // load the styles
  22.         TPage::include_css('app/resources/catalog.css');
  23.        
  24.         // create the HTML Renderer
  25.         $this->html = new THtmlRenderer('app/resources/catalog.html');
  26.  
  27.         // define replacements for the main section
  28.         $replace = array();
  29.         $this->html->enableSection('main', $replace);
  30.         try
  31.         {
  32.             // load the products
  33.             TTransaction::open('samples');
  34.             $criteria = new TCriteria;
  35.             $criteria->add(new TFilter('photo_path', '<>', ''));
  36.             $products = Product::getObjects($criteria);
  37.             TTransaction::close();
  38.            
  39.             $replace_detail = array();
  40.             if ($products)
  41.             {
  42.                 // iterate products
  43.                 foreach ($products as $product)
  44.                 {
  45.                     $replace_detail[] = $product->toArray(); // array of replacements
  46.                 }
  47.             }
  48.            
  49.             // enable products section as repeatable
  50.             $this->html->enableSection('products', $replace_detail, TRUE);
  51.            
  52.             // wrap the page content using vertical box
  53.             $vbox = new TVBox;
  54.             $vbox->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  55.             $vbox->add($this->html);
  56.    
  57.             $this->html->enableSection('manage');
  58.  
  59.             parent::add($vbox);            
  60.         }
  61.         catch (Exception $e)
  62.         {
  63.             new TMessage('error', $e->getMessage());
  64.         }
  65.     }
  66.    
  67. }
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement