Location: PHPKode > projects > Charray's CMS > ccms/module/image.php
<?php

// Charray's CMS (CCMS) Version 0.9.5
//
// Copyright (c) 2007, Kinson Chan
// charray[at]gmail.com / kchan[at]cs.hku.hk
// All rights reserved.
//
// Please refer to LICENSE.txt coming with this package for
// terms and conditions for redistribution and reuse.

if (!defined('CCMS_IN')) {
	die();
}

global $ccms_decoder_path;
require_once($ccms_decoder_path . '/gallery.php');

function ccms_module_image($file) {
	global $ccms_controller_url;
	$html_code = array();

	// Compute the directory name.
	$dir = substr($file, 0, strrpos($file, '/'));
	$filenames = ccms_list_directory($dir);
	natsort($filenames);

	// For each found files, display the image if it can be
	// shown on gallery decoder.
	foreach($filenames as $filename) {
		if (!ccms_decoder_gallery_displayable($filename, false,
		                                      false, $dummy))
		{
			continue;
		}

		$thumbnail = ccms_decoder_gallery_thumb($filename);
		$thumbnail_path = ccms_obtain_path($thumbnail, true);
		$picture_path = ccms_obtain_path($filename, true);
		$picture_alt = ccms_path_title($picture_path);
		$picture_alt = substr($picture_alt, 0, strrpos($picture_alt, '.'));
		$picture_alt = htmlentities($picture_alt, ENT_COMPAT, 'UTF-8');

		$html_code[] = '<p style="text-align: center;">' .
		               '<a href="' . $ccms_controller_url .
		               $picture_path . '"><img src="' .
			       $ccms_controller_url . $thumbnail_path .
			       '" style="width: 90%" alt="' .
		               $picture_alt . '" /></a><br />' .
			       $picture_alt . '</p>';
	}

	// Keep only 3 in the module display.
	if (count($html_code) > 3) {
		$popup_code = $html_code;
		$html_code = array();
		for ($i = 0; $i < 3; ++$i) {
			$html_code[] = $popup_code[$i];
		}
	}

	// If something was output (i.e. some picture identified),
	// output the module, otherwise be silent.
	if (count($html_code)) {
		$result['title'] = 'Images';
		$result['content'] = implode($html_code, "\n");
	} else {
		$result = false;
	}

	return $result;
}

?>
Return current item: Charray's CMS