コード例 #1
0
ファイル: Application.php プロジェクト: samsoncms/gallery
 /**
  * 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 = \samson\resourcer\ResourceRouter::url('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();
 }
コード例 #2
0
ファイル: global.php プロジェクト: onysko/php_resourcer
 /**
  * SRC(Source) - Источник - сгенерирвать URL к ресурсу веб-приложения
  * Данный метод определяет текущее место работы веб-приложения
  * и строит УНИКАЛЬНЫЙ путь к требуемому ресурсу.
  *
  *  Это позволяет подключать CSS/JS/Image ресурсы в HTML/CSS не пережевая
  *  за их физическое месторасположение относительно веб-приложения, что
  *  в свою очередь дает возможность выносить модули(делать их внешними),
  *  а так же и целые веб-приложения.
  *
  * @param string $src Путь к ресурсу модуля
  * @param string $module Имя модуля которому принадлежит ресурс
  * @param string $return Флаг необходимо ли возвращать значение
  * @return string Возвращает сгенерированный адресс ссылки на получение ресурса для браузера
  */
 function src($src = '', $module = null)
 {
     echo ResourceRouter::url($src, $module);
 }