Your IP : 216.73.216.201


Current Path : /home/balossw/www/temp/common/cms/includes/classes/
Upload File :
Current File : /home/balossw/www/temp/common/cms/includes/classes/table.class.php

<?php
/*---------------------------------------------------------------------------
		File name ............ includes/classes/table.class.php
		Project .............. Owebia CMS
		Author ............... Antoine Lemoine
		Creation date ........ 31.12.2007
		Modification date .... 18.03.2009
---------------------------------------------------------------------------*/

include_once $global->realpath('common/cms/includes/classes/fields.class.php');

class Table
{
	var $label;
	var $name;
	var $fields;
	var $visible_fields;
	var $id_field;
	var $ordering_field;
	var $order;
	var $allow_menu;

	function Table()
	{
		$args = func_get_args();
		if (count($args)>1)
		{
			$args = array(
				'name' => $args[0],
				'fields' => $args[1],
				'id_field' => $args[2],
				'ordering_field' => $args[3],
				'order' => isset($args[4]) ? $args[4] : 'A',
				'allow_menu' => isset($args[5]) ? $args[5] : true,
			);
		}
		else
		{
			$args = $args[0];
		}

		$this->label = isset($args['label']) ? $args['label'] : null;
		$this->name = $args['name'];
		$this->id_field = $args['id_field'];
		$this->ordering_field = $args['ordering_field'];
		$this->order = isset($args['order']) && $args['order']=='D' ? 'DESC' : 'ASC';
		$this->visible_fields = array();
		$this->display_fields = isset($args['display_fields']) ? $args['display_fields'] : null;
		$this->fields = array();
		foreach ($args['fields'] as $field)
		{
			if (in_array($field->type,array('self_reference','hierarchical_self_reference')))
			{
				$field->referenced_table = $this;
			}
			if ($field->visible) { $this->visible_fields[] = $field; }
			$this->fields[$field->field_name] = $field;
		}
		$this->allow_menu = isset($args['allow_menu']) ? $args['allow_menu'] : true;
	}
	
	function &getField($field_name)
	{
		foreach ($this->fields as $key => $field)
		{
			if ($field->field_name==$field_name)
			{
				return $this->fields[$key];
			}
		}
		return null;
	}
}

?>