<?php
	require_once( $GLOBALS["site_root"] . "/includes/widgets/AdminSelect.inc.php" );

	class AdminTreeSelect extends AdminSelect {

		protected function renderTreeOptionTitle( $level , $title ) {
			$num = 1 + ($level-1)*2;
			return str_repeat( "&nbsp;" , $num ) . $title;
		}

		public function addTreeOption( $id , $level , $title ) {
			$this->addOption( $id , $this->renderTreeOptionTitle( $level , $title ) );
		}

		public function setTreeDatasetOptions( $dataset , $idfield , $levelfield , $titlefield ) {
			foreach ($dataset as $row)
				$this->addTreeOption(
					$row[$idfield],
					$row[$levelfield],
					$row[$titlefield]
			);
		}
	}
?>
