- <?
- /**
- * @package component
- * @filesource
- * @see HTML_COMPONENT_PAGE_PATH.'/Imagerotator.php'
- * @copyright (c) http://Finn-Rasmussen.com
- * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
- * @author http://Finn-Rasmussen.com
- * @version 1.9
- * @since 21-oct-2005
- */
-
- /**
- * The required files
- */
- require_once(HTML_PATH.'/Html.php');
- require_once(HTML_BASE_UTIL_PATH.'/Image.php');
- require_once(HTML_BASE_UTIL_PATH.'/Link.php');
-
- /**
- * Image Rotator. An image is shown in an round robin fasion
- * <code>
- * Usage:
- * $imagerotator = new Imagerotator($path,$image);
- * print $imagerotator->getHtml();
- * Or
- * Imagerotator::display($path,$image);
- * </code>
- * @package component
- */
-
- class Imagerotator extends Html {
- var $MAX = '61'; // The last name of picture to rotate
-
- var $path = '';
- var $image = '';
-
- /**
- * Constructor
- * @param String $path The path to the images
- * @param String $image The image to use for now
- */
- function Imagerotator($path='',$image='') {
- $this->Html();
- $this->path = $path!=''?$path:IMAGE_ROTATOR_PATH;
- $this->image = $image!=''?$image:'';
- }
-
- /**
- * Get the name of the image to rotate
- * @return String The name
- */
- function getName() {
- $name = date('d'); // Default, day of the month
- $s = date('s');
- if ($s<=$this->MAX) {
- $name = $s; // Use seconds as rAndomizer
- }
- return $name;
- }
-
- /**
- * Builds the html, and return it for an Image Rotator object
- * @return String The html
- */
- function getHtml() {
- $html = $this->html;
- if (defined('COMPONENT_SHOW') && COMPONENT_SHOW & COMPONENT_SHOW_IMAGEROTATOR && HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) {
- if (defined('CREATE_RUNTIME_KERNEL') && CREATE_RUNTIME_KERNEL) {
- $html .= '<?$imagerotator = new Imagerotator();print $imagerotator->getHtml();?>';
- } else {
- $link = new Link('', IMAGE_ROTATOR_LINK,CSS_LINK_COLOR);
- $name = $this->getName();
- //if (file_exists(PROJECT_PATH.$this->path.'/'.$name.'.jpg')) {
- $image = new Image($this->path.'/'.$name.'.jpg','','',IMAGE_ROTATOR_LINK.' ('.$name.')',CSS_LINK_COLOR);
- $link->add($image);
- //} else {
- // print $this->getClassName()."->getHtml(), Unable to find image=".PORTAL_PATH.$this->path.'/'.$name.".jpg<br />\r\n";
- //}
- $html .= $link->getHtml()."<hr />\r\n";
- }
- } else {
- $html .= "<!-- No Image Rotator object -->\n";
- }
- return $html;
- }
-
- /**
- * Display html
- * <code>
- * Usage:
- * Imagerotator::display($path,$image);
- * </code>
- * @static
- * @param String $path The path to the images to rotate
- * @param String $image The image to use for now
- */
- function display($path='',$image='') {
- $html = new Imagerotator($path,$image);
- $html->addHtml();
- }
- }
- ?>