00001 <?php 00002 class MAreaContainer extends MControl 00003 { 00004 var $top = array(); 00005 var $left = array(); 00006 var $center = array(); 00007 var $right = array(); 00008 var $bottom = array(); 00009 00010 function __construct($name = null) 00011 { 00012 parent::__construct($name); 00013 } 00014 00015 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00016 # Adds an element at the specified position 00017 #--------------------------------------------------------------------- 00018 function AddElement($element, $where = 'center') 00019 { 00020 global $MIOLO; 00021 00022 if ($where == 'top') 00023 { 00024 $this->top[] = $element; 00025 } 00026 else if ($where == 'left') 00027 { 00028 $this->left[] = $element; 00029 } 00030 else if ($where == 'center') 00031 { 00032 $this->center[] = $element; 00033 } 00034 else if ($where == 'right') 00035 { 00036 $this->right[] = $element; 00037 } 00038 else if ($where == 'bottom') 00039 { 00040 $this->bottom[] = $element; 00041 } 00042 else 00043 { 00044 $MIOLO->Error("Container: Illegal positioning '$where' parameter!"); 00045 } 00046 } 00047 00048 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00049 # Obtains the number of table rows 00050 #--------------------------------------------------------------------- 00051 function GetRowCount() 00052 { 00053 $num_rows = 0; 00054 00055 if ($this->top) 00056 { 00057 $num_rows++; 00058 } 00059 00060 if ($this->left || $this->center || $this->right) 00061 { 00062 $num_rows++; 00063 } 00064 00065 if ($this->bottom) 00066 { 00067 $num_rows++; 00068 } 00069 00070 return $num_rows; 00071 } 00072 00073 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00074 # Obtains the number of table columns 00075 #--------------------------------------------------------------------- 00076 function GetColumnCount() 00077 { 00078 $num_cols = 0; 00079 00080 if ($this->left) 00081 { 00082 $num_cols++; 00083 } 00084 00085 if ($this->center) 00086 { 00087 $num_cols++; 00088 } 00089 00090 if ($this->right) 00091 { 00092 $num_cols++; 00093 } 00094 00095 if (!$num_cols) 00096 { 00097 if ($this->top) 00098 { 00099 $num_cols++; 00100 } 00101 else if ($this->bottom) 00102 { 00103 $num_cols++; 00104 } 00105 } 00106 00107 return $num_cols; 00108 } 00109 00110 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00111 # Generate HTML 00112 #---------------------------------------------------------------------- 00113 function GenerateInner() 00114 { 00115 $num_rows = $this->GetRowCount(); 00116 $num_cols = $this->GetColumnCount(); 00117 00118 if ($num_rows && $num_cols) 00119 { 00120 $table = new MSimpleTable($obj->name); 00121 $table->SetAttribute('width', '100%'); 00122 $table->SetCell(0, 0, $this->top, "align=\"center\" colspan=$num_rows"); 00123 $table->SetCell(1, 0, $this->left, "align=\"center\" valign=\"top\""); 00124 $table->SetCell(1, 1, $this->center, "align=\"center\" valign=\"top\" width=\"100%\""); 00125 $table->SetCell(1, 2, $this->right, "align=\"center\" valign=\"top\""); 00126 $table->SetCell(2, 0, $this->bottom, "align=\"center\" colspan=$num_rows"); 00127 $this->inner = $table; 00128 } 00129 } 00130 } 00131 ?>