Example #1
0
 /**
  * The backend index hanlder.
  * 
  * @access public
  * @return string The HTML code.
  */
 public function index()
 {
     $Item = new Gallery_Item();
     $Product = new Product();
     $Article = new Article();
     $this->getView()->set(array('Articles' => $Article->findShortList(array('Type = ' . Article::ARTICLE), 'PostedAt desc', 0, 5), 'News' => $Article->findShortList(array('Type = ' . Article::NEWS), 'PostedAt desc', 0, 5), 'Gallery' => $Item->findList(array(), 'PostedAt desc, Id desc', 0, 10), 'Products' => $Product->findShortList(array(), 'Id desc', 0, 10), 'Updated' => $Product->findShortList(array(), 'UpdatedAt desc', 0, 10)));
     return $this->getView()->render();
 }
Example #2
0
 /**
  * The function returns Products in current Category.
  * 
  * @access public
  * @param bool $assoc If TRUE returns products in associated array.
  * @return array The Products.
  */
 public function getProducts($assoc = false)
 {
     $Product = new Product();
     $params = array();
     $params[] = 'CategoryId = ' . $this->Id;
     $arr = $Product->findShortList($params, 'Position asc');
     if (!$assoc) {
         return $arr;
     }
     return self::convertArray($arr, 'Id', 'Name');
 }
Example #3
0
 /**
  * The function returns part of HTML code depends on method.
  * 
  * @access public
  * @return string The JSON response.
  */
 public function json()
 {
     switch (Request::get('method')) {
         case 'colors':
             $Layout = new Product_Layout_Standard();
             $Product = new Product();
             $Params = array();
             $params[] = 'CategoryId = ' . $Layout->getCategory()->Id;
             if (Request::get('brand')) {
                 $params[] = 'BrandId = ' . Request::get('brand');
             }
             return $this->getView()->htmlColors($Product->findShortList($params, 'Name asc'));
         case 'units':
             $Unit = new Product_Unit();
             $params = array();
             $params[] = 'ProductId = ' . Request::get('id');
             return $this->getView()->htmlUnits($Unit->findList($params, 'Position asc'));
         case 'order':
             $response = array('result' => 0);
             return $this->outputJSON($response);
     }
 }
Example #4
0
 /**
  * The function returns JSON responses for different methods.
  * 
  * @access public
  * @param string $method THe method.
  * @return string The JSON response.
  */
 public function json($method = null)
 {
     $response = array();
     switch ($method) {
         case 'tags':
             $Tag = new Tag();
             $params = array();
             $params[] = $Tag->getParam('search', Request::get('term'));
             foreach ($Tag->findList($params, 'Name asc', 0, 20) as $Tag) {
                 $response[] = $Tag->Name;
             }
             break;
         case 'ref':
             $Object = null;
             $params = array();
             if (Request::get('field') == 'Reference[Page]') {
                 $Object = new Content_Page();
             } else {
                 if (Request::get('field') == 'Reference[Product]') {
                     $Object = new Product();
                 }
             }
             if ($Object) {
                 $params[] = $Object->getParam('search', Request::get('term'));
                 foreach ($Object->findShortList($params, 'Name asc', 0, 10) as $Object) {
                     printf("%d|%s\n", $Object->Id, $Object->Name);
                 }
             }
             exit;
             break;
     }
     return $this->outputJSON($response);
 }