phpDocumentor component
[ class tree: component ] [ index: component ] [ all elements ]

Source for file Imagerotator.php

Documentation is available at Imagerotator.php

  1. <?
  2. /**
  3. * @package component
  4. * @filesource
  5. * @see HTML_COMPONENT_PAGE_PATH.'/Imagerotator.php'
  6. * @copyright (c) http://Finn-Rasmussen.com
  7. * @license http://Finn-Rasmussen.com/license/ myPHP License conditions
  8. * @author http://Finn-Rasmussen.com
  9. * @version 1.9
  10. * @since 21-oct-2005
  11. */
  12.  
  13. /**
  14. * The required files
  15. */
  16. require_once(HTML_PATH.'/Html.php');
  17. require_once(HTML_BASE_UTIL_PATH.'/Image.php');
  18. require_once(HTML_BASE_UTIL_PATH.'/Link.php');
  19.  
  20. /**
  21. * Image Rotator. An image is shown in an round robin fasion
  22. * <code>
  23. * Usage:
  24. * $imagerotator = new Imagerotator($path,$image);
  25. * print $imagerotator->getHtml();
  26. * Or
  27. * Imagerotator::display($path,$image);
  28. * </code>
  29. * @package component
  30. */
  31.  
  32. class Imagerotator extends Html {
  33. var $MAX = '61'; // The last name of picture to rotate
  34. var $path = '';
  35. var $image = '';
  36.  
  37. /**
  38. * Constructor
  39. * @param String $path The path to the images
  40. * @param String $image The image to use for now
  41. */
  42. function Imagerotator($path='',$image='') {
  43. $this->Html();
  44. $this->path = $path!=''?$path:IMAGE_ROTATOR_PATH;
  45. $this->image = $image!=''?$image:'';
  46. }
  47.  
  48. /**
  49. * Get the name of the image to rotate
  50. * @return String The name
  51. */
  52. function getName() {
  53. $name = date('d'); // Default, day of the month
  54. $s = date('s');
  55. if ($s<=$this->MAX) {
  56. $name = $s; // Use seconds as rAndomizer
  57. }
  58. return $name;
  59. }
  60.  
  61. /**
  62. * Builds the html, and return it for an Image Rotator object
  63. * @return String The html
  64. */
  65. function getHtml() {
  66. $html = $this->html;
  67. if (defined('COMPONENT_SHOW') && COMPONENT_SHOW & COMPONENT_SHOW_IMAGEROTATOR && HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) {
  68. if (defined('CREATE_RUNTIME_KERNEL') && CREATE_RUNTIME_KERNEL) {
  69. $html .= '<?$imagerotator = new Imagerotator();print $imagerotator->getHtml();?>';
  70. } else {
  71. $link = new Link('', IMAGE_ROTATOR_LINK,CSS_LINK_COLOR);
  72. $name = $this->getName();
  73. //if (file_exists(PROJECT_PATH.$this->path.'/'.$name.'.jpg')) {
  74. $image = new Image($this->path.'/'.$name.'.jpg','','',IMAGE_ROTATOR_LINK.' ('.$name.')',CSS_LINK_COLOR);
  75. $link->add($image);
  76. //} else {
  77. // print $this->getClassName()."->getHtml(), Unable to find image=".PORTAL_PATH.$this->path.'/'.$name.".jpg<br />\r\n";
  78. //}
  79. $html .= $link->getHtml()."<hr />\r\n";
  80. }
  81. } else {
  82. $html .= "<!-- No Image Rotator object -->\n";
  83. }
  84. return $html;
  85. }
  86.  
  87. /**
  88. * Display html
  89. * <code>
  90. * Usage:
  91. * Imagerotator::display($path,$image);
  92. * </code>
  93. * @static
  94. * @param String $path The path to the images to rotate
  95. * @param String $image The image to use for now
  96. */
  97. function display($path='',$image='') {
  98. $html = new Imagerotator($path,$image);
  99. $html->addHtml();
  100. }
  101. }
  102. ?>

Documentation generated on Thu, 22 Dec 2005 17:10:06 +0100 by phpDocumentor 1.3.0RC3