Back to PhocaGalleryImageFront class

Method renderMosaic

public static
renderMosaic
(mixed $images, mixed $size = 0, mixed $extImg = 0, mixed $w = 100, mixed $h = 100)

Method renderMosaic - Source code

public static function renderMosaic($images, $size = 0, $extImg = 0, $w = 100, $h = 100)
{
    $o = '';
    phocagalleryimport('phocagallery.file.filethumbnail');
    $count = count($images);
    $m1 = mt_rand(0, 1);
    switch ($count) {
        case 1:
            $a = 1;
            //array(1);
            break;
        case 2:
            $a = 2;
            //array(2);
            break;
        case 3:
            $at = array(3, 4);
            $ar = array_rand($at);
            $a = $at[$ar];
            break;
        case 4:
            $at = array(3, 4, 5);
            $ar = array_rand($at);
            $a = $at[$ar];
            break;
        case 5:
            $at = array(3, 4, 5, 6, 7);
            $ar = array_rand($at);
            $a = $at[$ar];
            break;
    }
    // NOT ACCESS
    if (isset($images[0]->notaccess) && $images[0]->notaccess == 1) {
        $stNA = 'width: ' . $w . 'px; height: ' . $h . 'px; margin: 0 auto;';
        $o .= '<div style="text-align: center;' . $stNA . '">';
        $o .= '<div class="pg-multi-img" style="margin: 0 auto;' . $stNA . '" ><img src="' . Uri::base(true) . '/media/com_phocagallery/images/icon-folder-medium-key.png" style="margin: 0 auto;' . $stNA . '" alt="" /></div>';
        $o .= '</div>';
        return $o;
    }
    if (isset($a)) {
        $i = self::getMosaicFields($a, $images, $size, $extImg, $w, $h);
        $m2 = mt_rand(0, 1);
        $o .= '<div style="width: ' . $i['w'] . 'px; height: ' . $i['h'] . 'px">';
        if ($m2 == 1) {
            $o .= '<div style="float:left;width:' . $i['w1'] . 'px;">';
            $o .= $i['b1'];
            $o .= '</div>';
            $o .= '<div style="float:left;width:' . $i['w2'] . 'px;">';
            $o .= $i['b2'];
            $o .= '</div>';
        } else {
            $o .= '<div style="float:right;width:' . $i['w1'] . 'px;">';
            $o .= $i['b1'];
            $o .= '</div>';
            $o .= '<div style="float:right;width:' . $i['w2'] . 'px;">';
            $o .= $i['b2'];
            $o .= '</div>';
        }
        $o .= '</div>';
    } else {
        $o .= '<div></div>';
    }
    return $o;
}