<?php

/*
 * @author		Martijn Polak
 * @since		01-nov-2006
 * @name		Simple Ticker Tape
 */

require_once 'class.stdModule.php';

class simpleTickerTape extends stdModule {

	// Constructor
	function simpleTickerTape() {

		$this->stdModule('cstt0100');

		$this->_settings->templates->banner		= 'banner.tpl';

	}

	// Print banner
	function printBanner($code) {

		$this->_smrt->clear_all_assign();

		$rst = $this->_db->Query("
			select
				stt_id as id,
				stt_code as code,
				stt_name as name
			from
				stt_tickertapes
			where
				stt_code = '".$code."' and
				stt_org_id = ".$this->_variables->public->org_id." and
				stt_enabled = 1
		");

		$banner_id = null;
		if (!$rst->EOF()) {
			$this->_smrt->assign('banner', $rst->Row());
			$banner_id = $rst->Row('id');
		}
		$rst->Close();

		if (is_numeric($banner_id)) {

			$rst = $this->_db->Query("
				select
					tti_id as id,
					tti_title as title,
					tti_uli as uli
				from
					stt_items
				where
					tti_stt_id = ".$banner_id."
				order by
					tti_order
			");

			while (!$rst->EOF()) {

				$row = $rst->Row();
				$row['url'] = $this->_tcc->getFormattedHyperLink($row['uli']);

				$this->_smrt->append('items', $row);
				$rst->MoveNext();

			}

			$rst->Close();

		}

		$this->assignTemplateGlobals();
		$this->_smrt->display($this->_settings->templates->banner);

	}

}

?>