/** * Construct a new awgraph * * @param int $width Graph width * @param int $height Graph height * @param string $name Graph name for the cache (must be unique). Let it null to not use the cache. * @param int $timeout Cache timeout (unix timestamp) */ function awGraph($width = NULL, $height = NULL, $name = NULL, $timeout = 0) { parent::awImage(); $this->setSize($width, $height); if (ARTICHOW_CACHE) { $this->name = $name; $this->timeout = $timeout; // Clean sometimes all the cache if (mt_rand(0, 5000) === 0) { awGraph::cleanCache(); } if ($this->name !== NULL) { $file = ARTICHOW . "/cache/" . $this->name . "-time"; if (is_file($file)) { $type = awGraph::cleanGraphCache($file); if ($type === NULL) { awGraph::deleteFromCache($this->name); } else { header("Content-Type: image/" . $type); readfile(ARTICHOW . "/cache/" . $this->name . ""); exit; } } } } $this->title = new awLabel(NULL, new awTuffy(16), NULL, 0); $this->title->setAlign(LABEL_CENTER, LABEL_BOTTOM); }
/** * Construct a new graph * * @param int $width Graph width * @param int $height Graph height * @param string $name Graph name for the cache (must be unique). Let it null to not use the cache. * @param int $timeout Cache timeout (unix timestamp) */ public function __construct($width = NULL, $height = NULL, $name = NULL, $timeout = 0) { parent::__construct(); $this->setSize($width, $height); if (ARTICHOW_CACHE) { $this->name = $name; $this->timeout = $timeout; // Clean sometimes all the cache if (mt_rand(0, 5000) === 0) { awGraph::cleanCache(); } // Take the graph from the cache if possible if ($this->name !== NULL) { $this->fileCache = ARTICHOW_CACHE_DIRECTORY . "/" . $this->name; $this->fileCacheTime = $this->fileCache . "-time"; if (is_file($this->fileCache)) { $type = awGraph::cleanGraphCache($this->fileCacheTime); if ($type === NULL) { awGraph::deleteFromCache($this->name); } else { header("Content-Type: image/" . $type); echo file_get_contents($this->fileCache); exit; } } } } $this->title = new awLabel(NULL, new awTuffy(16), NULL, 0); $this->title->setAlign(awLabel::CENTER, awLabel::BOTTOM); }
/** * Construct a new graph * * @param int $width Graph width * @param int $height Graph height * @param string $name Graph name for the cache (must be unique). Let it null to not use the cache. * @param int $timeout Cache timeout (unix timestamp) */ public function __construct($width = NULL, $height = NULL, $name = NULL, $timeout = 0, $alternativeSize = 0) { parent::__construct(); $this->setSize($width, $height, $alternativeSize); $this->name = $name; $this->timeout = $timeout; // Clean sometimes all the cache if (mt_rand(0, 5000) === 0) { awGraph::cleanCache(); } if ($this->name !== NULL) { $file = ARTICHOW . "/cache/" . $this->name . "-time"; if (is_file($file)) { $type = awGraph::cleanGraphCache($file); if ($type === NULL) { awGraph::deleteFromCache($this->name); } else { header("Content-Type: image/" . $type); readfile(ARTICHOW . "/cache/" . $this->name . ""); exit; } } } $this->title = new awLabel(NULL, new awTuffy(16), NULL, 0); $this->title->setAlign(awLabel::CENTER, awLabel::BOTTOM); }