Ejemplo n.º 1
0
 public static function getMetroItemView($name, $images, $itemId, $pageNumber, $num, $key, $valueToSearch, $type, $trimName, $isHighLightElement)
 {
     $blackOut = new Div();
     $blackOut->addStyleClasses(["blackout", "catalog_item_button_container"]);
     $blackOut->addAttributes(["itemscope" => "", "itemtype" => "http://data-vocabulary.org/Product"]);
     $mainDiv = new Div();
     $blackOut->addChild($mainDiv);
     TagUtils::createShadow($mainDiv);
     $mainDiv->addStyleClasses(["simple_item_metro", "ciic"]);
     $imageCount = min(count($images), Constants::MAX_IMAGE_COUNT_METRO_VIEW);
     $brPosition = $imageCount > 2 ? floor(($imageCount - 1) / 2) + 1 : -1;
     $row0 = new Div();
     $row0->addStyleClass("images_row");
     $row1 = new Div();
     $row1->addStyleClasses(["images_row_last"]);
     $rows = [$row0, $row1];
     for ($imgIndex = 0; $imgIndex < count($images); $imgIndex++) {
         if ($imgIndex == $imageCount) {
             break;
         }
         $imgView = new Img();
         $imgView->addAttributes(["itemprop" => "image", TagLabels::ON_CLICK => "openSimpleImg(arguments[0])", "src" => "/" . addslashes($images[$imgIndex]), "alt" => $name]);
         $imgView->addStyleClass($imgIndex > 0 ? "simple_item_image_half" : "simple_item_image");
         if ($imgIndex == 0) {
             $mainDiv->addChild($imgView);
         } elseif ($imgIndex >= $brPosition) {
             $rows[0]->addChild($imgView);
         } else {
             $rows[1]->addChild($imgView);
         }
     }
     $mainDiv->addChildList($rows);
     if ($type == 'HARD') {
         $url = URLBuilder::getCatalogLinkForSingleItem($pageNumber, $num, $itemId, array(UrlParameters::KEY => $key, UrlParameters::SEARCH_VALUE => $valueToSearch));
         $mainDiv->addStyleClass("cursor_pointer");
         $link = TagUtils::createNote($trimName, "");
         $link->addAttribute("itemprop", "name");
         $blackOut->addChild($link);
         $blackOut->addChild(self::getItemButton($url));
     } elseif ($type == 'SIMPLE') {
         $text = TagUtils::createNote($trimName, "");
         $mainDiv->addChild($text);
     }
     return $blackOut;
 }