Пример #1
0
 /**
  * Render gallery images list
  * @param string $materialFieldId Material identifier
  * @return string html representation of image list
  */
 public function getHTML($materialFieldId)
 {
     // Get all material images
     $items_html = '';
     /** @var array $images List of gallery images */
     $images = null;
     // there are gallery images
     if ($this->query->entity(CMS::MATERIAL_IMAGES_RELATION_ENTITY)->where('materialFieldId', $materialFieldId)->orderBy('priority')->exec($images)) {
         /** @var \samson\cms\CMSGallery $image */
         foreach ($images as $image) {
             // Get image size string
             $size = ', ';
             // Get image path
             $path = $this->formImagePath($image->Path, $image->Src);
             // if file doesn't exist
             if (!$this->imageExists($path)) {
                 $path = ResourceMap::find('www/img/no-img.png', $this);
             }
             // set image size string representation, if it is not 0
             $size = $image->size == 0 ? '' : $size . $this->humanFileSize($image->size);
             // Render gallery image tumb
             $items_html .= $this->view('tumbs/item')->set($image, 'image')->set(utf8_limit_string($image->Description, 25, '...'), 'description')->set(utf8_limit_string($image->Name, 18, '...'), 'name')->set($path, 'imgpath')->set($size, 'size')->set($materialFieldId, 'material_id')->output();
         }
     }
     // Render content into inner content html
     return $this->view('tumbs/index')->set($items_html, 'images')->set($materialFieldId, 'material_id')->output();
 }