示例#1
0
function wikiplugin_carousel($body, $params)
{
    static $id = 0;
    $plugininfo = wikiplugin_carousel_info();
    foreach ($plugininfo['params'] as $key => $param) {
        $default["{$key}"] = $param['default'];
    }
    $params = array_merge($default, $params);
    $unique = 'wpcarousel-' . ++$id;
    $filegallib = TikiLib::lib('filegal');
    $files = $filegallib->get_files(0, -1, $params['sort_mode'], '', $params['fgalId']);
    if (empty($files['cant'])) {
        return '';
    }
    unset($params['fgalId'], $params['sort_mode']);
    $params['displayProgressRing'] = $params['displayProgressBar'] == 1;
    if (empty($params['thumbnailType'])) {
        $displayThumbnails = $params['displayThumbnails'] == 1;
        $displayThumbnailNumbers = $params['displayThumbnailNumbers'] == 1;
        $displayThumbnailBackground = $params['displayThumbnailBackground'] == 1;
        if ($displayThumbnailNumbers) {
            $params['thumbnailType'] = 'numbers';
        }
        if ($displayThumbnails) {
            $params['thumbnailType'] = 'images';
        }
    }
    foreach ($params as &$param) {
        if (is_numeric($param)) {
            $param = (double) $param;
            // seems to leave ints as ints
        }
    }
    if ($params['thumbnailType'] === 'images') {
        TikiLib::lib('header')->add_css(".ic_button { float: left; width: {$params['thumbnailWidth']}; height: {$params['thumbnailHeight']};}");
    }
    unset($params['displayProgressBar'], $params['displayThumbnails'], $params['displayThumbnailNumbers'], $params['displayThumbnailBackground'], $params['thumbnailWidth'], $params['thumbnailHeight'], $params['thumbnailFontSize']);
    TikiLib::lib('header')->add_jq_onready('setTimeout( function() { $("#' . $unique . '").tiki("carousel", "", ' . json_encode($params) . '); }, 1000);');
    if (empty($params['displaySize'])) {
        $size = 'width: 1px; height: 1px;';
    } else {
        if ($params['displaySize'] > 10) {
            $size = "width: {$params['displaySize']}px; height: {$params['displaySize']}px;";
        }
    }
    $html = '<div id="' . $unique . '" class="clearfix carousel" style="' . $size . ' overflow: hidden"><ul>';
    foreach ($files['data'] as $file) {
        $html .= '<li><img src="tiki-download_file.php?fileId=' . $file['fileId'] . '&amp;display';
        if (!empty($params['displaySize'])) {
            if ($params['displaySize'] > 10) {
                $html .= '&amp;max=' . $params['displaySize'];
            } elseif ($params['displaySize'] <= 1) {
                $html .= '&amp;scale=' . $params['displaySize'];
            }
        }
        $html .= '" alt="' . htmlentities($file['description']) . '" />';
        $caption = '';
        if (!empty($file['name'])) {
            $caption .= '<strong>' . htmlentities($file['name']) . '</strong>';
            if (!empty($file['description'])) {
                $caption .= '<br />';
            }
        }
        if (!empty($file['description'])) {
            $caption .= htmlentities($file['description']);
        }
        if (!empty($caption)) {
            $caption = '<p style="display:none;">' . $caption . '</p>';
            TikiLib::lib('header')->add_css('.textholder { padding: .5em .8em; }');
        }
        $html .= $caption . '</li>';
    }
    $html .= '</ul></div>';
    return "~np~{$html}~/np~";
}
示例#2
0
function wikiplugin_carousel($body, $params)
{
    static $id = 0;
    $plugininfo = wikiplugin_carousel_info();
    foreach ($plugininfo['params'] as $key => $param) {
        $default["{$key}"] = $param['default'];
    }
    $params = array_merge($default, $params);
    $unique = 'wpcarousel-' . ++$id;
    $uniqueId = 'carousel' . $id;
    $filegallib = TikiLib::lib('filegal');
    $files = $filegallib->get_files(0, -1, $params['sort_mode'], '', $params['fgalId']);
    if (empty($files['cant'])) {
        return '';
    }
    unset($params['fgalId'], $params['sort_mode']);
    $params['displayProgressRing'] = $params['displayProgressBar'] == 1;
    if (empty($params['thumbnailType'])) {
        $displayThumbnails = $params['displayThumbnails'] == 1;
        $displayThumbnailNumbers = $params['displayThumbnailNumbers'] == 1;
        $displayThumbnailBackground = $params['displayThumbnailBackground'] == 1;
        if ($displayThumbnailNumbers) {
            $params['thumbnailType'] = 'numbers';
        }
        if ($displayThumbnails) {
            $params['thumbnailType'] = 'images';
        }
    }
    foreach ($params as &$param) {
        if (is_numeric($param)) {
            $param = (double) $param;
            // seems to leave ints as ints
        }
    }
    if ($params['thumbnailType'] === 'images') {
        TikiLib::lib('header')->add_css(".ic_button { float: left; width: {$params['thumbnailWidth']}; height: {$params['thumbnailHeight']};}");
    }
    if (isset($params['clickable']) && $params['clickable'] == 1) {
        $jq_clickable = '
function carousel_callback(){
	$("#' . $uniqueId . ' div.ic_tray div.ic_caption").each(function(){
		var $this = $(this);
		//console.log("JML" + $this.text());
		var source = $this.text();
		var regexToken = /https?:\\/\\/[\\-\\w@:%_\\+.~#?,&\\/\\/=]+/;
		var matchArray;
		if ( (matchArray = regexToken.exec( source )) !== null) {
			//console.log("JJJ" + matchArray[0]);
			$this.parent().click(function(){
				window.location = matchArray[0];
			}).css("cursor", "pointer");
		};
	});
};
	';
    } else {
        $jq_clickable = '
function carousel_callback(){ };
	';
    }
    TikiLib::lib('header')->add_jq_onready($jq_clickable);
    unset($params['displayProgressBar'], $params['displayThumbnails'], $params['displayThumbnailNumbers'], $params['displayThumbnailBackground'], $params['thumbnailWidth'], $params['thumbnailHeight'], $params['thumbnailFontSize']);
    TikiLib::lib('header')->add_jq_onready('setTimeout( function() { $("#' . $unique . '").tiki("carousel", "", ' . json_encode($params) . '); carousel_callback();}, 1000);');
    if (empty($params['displaySize'])) {
        $size = 'width: 1px; height: 1px;';
    } else {
        if ($params['displaySize'] > 10) {
            $size = "width: {$params['displaySize']}px; height: {$params['displaySize']}px;";
        }
    }
    $html = '<div id="' . $uniqueId . '" ><div id="' . $unique . '" class="clearfix carousel" style="' . $size . ' overflow: hidden"><ul>';
    foreach ($files['data'] as $file) {
        $html .= '<li><img src="tiki-download_file.php?fileId=' . $file['fileId'] . '&amp;display';
        if (!empty($params['displaySize'])) {
            if ($params['displaySize'] > 10) {
                $html .= '&amp;max=' . $params['displaySize'];
            } elseif ($params['displaySize'] <= 1) {
                $html .= '&amp;scale=' . $params['displaySize'];
            }
        }
        $html .= '" alt="' . htmlentities($file['description']) . '" />';
        $caption = '';
        if (!empty($file['name'])) {
            $caption .= '<strong>' . htmlentities($file['name']) . '</strong>';
            if (!empty($file['description'])) {
                $caption .= '<br />';
            }
        }
        if (!empty($file['description'])) {
            $caption .= htmlentities($file['description']);
        }
        if (!empty($caption)) {
            $caption = '<p style="display:none;">' . $caption . '</p>';
            TikiLib::lib('header')->add_css('.textholder { padding: .5em .8em; }');
        }
        $html .= $caption . '</li>';
    }
    $html .= '</ul></div></div>';
    return "~np~{$html}~/np~";
}