HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers59/ferrumbv.nl/wwwroot/lib/ui/product_thumb.class.php
<?php
/**
 * Created by PhpStorm.
 * User: mike
 * Date: 08/10/14
 * Time: 11:55
 */

class UI_Product_Thumb
{
    // English name of the page
    private $_pageName;

    // Language array
    private $_lang;

    public function __construct($pageName)
    {
        $this->_pageName = $pageName;

        // Translate
        $Translator = new Translator(URL_LANG);
        $this->_lang = $Translator->get();
    }
    /*
     * Create image list for gallery
     */
    public function create($data)
    {
        $output = '';

        // Loop trough data
        foreach($data['entity'] as $entity)
        {
            $root = isset( $entity['@attributes']['root']);
            if( ! $root)
            {
                // Build URL
                $urlTitle = Fn::encodeUrl($entity['title']);
                $url = SITE_ROOT . Fn::encodeUrl($this->_lang[$this->_pageName]) . '/' . Fn::encodeUrl($entity['title']);

                // Prepare thumb
                $images = $entity['images'][key($entity['images'])];
                $firstKey = (string)key($images);
                // In case of one item
                if($firstKey == '@attributes')
                {
                    $images = array($images);
                }

                // First image
                $image = $images[0]['@attributes'];
                isset($image['thumb']) ? $thumb = $image['thumb'] : $thumb = $image['src'];


                $output .='<li>
                                <a href="' . $url . '">
                                    <span class="image"><img src="' . $thumb . '" alt="' . $entity['title'] . '" /></span>
                                    <div class="triangle">
                                        <span class="arrow"></span>
                                    </div>
                                    <span class="title">' . $entity['title'] . '</span>
                                </a>
                            </li>';
            }
        }
        return $output;
    }
}