Re: [PHP] nested objects

2007-12-07 Thread Victor Matherly
Thanks that fixed it. That was so simple no wonder I was banging my head on the 
wall :-).




- Original Message -
From: Cesar D. Rodas [EMAIL PROTECTED]
To: Victor Matherly [EMAIL PROTECTED]
Sent: Friday, December 7, 2007 2:37:23 PM (GMT-0500) America/New_York
Subject: Re: [PHP] nested objects

Hello 

I hope this help you! 


On 07/12/2007, Victor Matherly  [EMAIL PROTECTED]  wrote: 



Hello list, 

I want to create a new object and nest the objects variable in an array of 
another object. I think I am going about it the correct way but the variable is 
not being stored or retrieved correctly from the main function. I can't figure 
out what I am doing wrong. Can anyone help? Here is an example of what I am 
trying to do: 



?php 


$html = table border='1' \n; 

$row = new htmlTableRow(); 

$cell1 = new htmlTableCell(); 
$cell1-setContent(test1); 
$cell1-setName(Left test); 
$row-AddCell($cell1); 

$cell2 = new htmlTableCell(); 
$cell2-setContent(test2); 
$cell2-setName(right test); 
$row-AddCell($cell2); 



$html .= $row-buildRow(); 


$html .= table\n; 

print HERE 
html 
body 

$html 

/body 
/html 



HERE; 



class htmlTableRow { 

var $class; 
var $cell_arr; 
var $the_row; 

function htmlTableRow(){ 
$this-cell_arr = array(); 

}//end construct 

function AddCell($cell) { 
$this-cell_arr = $cell; 

$this-cell_arr[] = $cell; 



} 

function buildRow(){ 
$temp = tr\n; 

foreach($this-cell_arr as $rowdata){ 

$temp .= \ttd . $rowdata-cell_content . /td\n; 

}//end foreach 
$temp .= /tr\n; 
return $temp; 
}//end build row funtion 

}// end htmlTableRow class 



class htmlTableCell { 
var $cell_width; 
var $cell_height; 
var $cell_colspan; 
var $cell_rowspan; 
var $css_class; 
var $cell_content; 
var $cell_name; 


function __construct($content = nbsp;){ 

$this-cell_content = $content; 


}// end construct 

function setContent($content){ 
$this-cell_content = $content; 

}//end setContent function 

function setName($name){ 
$this-cell_name = $name; 

}//end setContent function 


function getContent(){ 
return $this-cell_content; 

}//end setContent function 

} //end TableCell class 






? 

Best regards 



Victor J. Matherly 
Technical Services 
Wave Communications, Inc 
http://www.wave-communications.com 

-- 
PHP General Mailing List ( http://www.php.net/ ) 
To unsubscribe, visit: http://www.php.net/unsub.php 




-- 


Cesar D. Rodas 
http://www.cesarodas.com 
http://www.thyphp.com 
http://www.phpajax.org 
Phone: +595-961-974165 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] nested objects

2007-12-07 Thread Victor Matherly
Actually it is academic intro to OO programing, the overkill html was just 
helping me understand the concept. Now I can put it to good use :-).


- Original Message - 
From: Jochem Maas [EMAIL PROTECTED]
To: Victor Matherly [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Friday, December 7, 2007 10:20:47 PM (GMT-0500) America/New_York
Subject: Re: [PHP] nested objects

Victor Matherly wrote:
 
 Hello list,
 
 I want to create a new object and nest the objects variable in an array of 
 another object.   
 I think I am going about it the correct way 


I think you are trying to swat a fly with a nuclear missle. in practice 
abstracting an HTML
table into a big collection of objects is total overkill (although it might 
make an interesting
accademic introduction into OO coding)

...

 
 class htmlTableCell {
  var $cell_width;
  var $cell_height;
  var $cell_colspan;
  var $cell_rowspan;
  var $css_class;
  var $cell_content;
  var $cell_name;
  
   
 function __construct($content = nbsp;){
 
  $this-cell_content = $content; 
   
   
 }// end construct 
 
 function setContent($content){
  $this-cell_content = $content;  
   
 }//end setContent function
 
 function setName($name){
  $this-cell_name = $name;
   
 }//end setContent function
 
 
 function getContent(){
  return $this-cell_content;  
   
 }//end setContent function
 
 } //end TableCell class
 
 
 
 
 
 
 ?
 
 
 
 
 
 
 Victor J. Matherly
 Technical Services
 Wave Communications, Inc
 http://www.wave-communications.com
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] nested objects

2007-12-07 Thread Jochem Maas
Victor Matherly wrote:
 
 Hello list,
 
 I want to create a new object and nest the objects variable in an array of 
 another object.   
 I think I am going about it the correct way 


I think you are trying to swat a fly with a nuclear missle. in practice 
abstracting an HTML
table into a big collection of objects is total overkill (although it might 
make an interesting
accademic introduction into OO coding)

...

 
 class htmlTableCell {
  var $cell_width;
  var $cell_height;
  var $cell_colspan;
  var $cell_rowspan;
  var $css_class;
  var $cell_content;
  var $cell_name;
  
   
 function __construct($content = nbsp;){
 
  $this-cell_content = $content; 
   
   
 }// end construct 
 
 function setContent($content){
  $this-cell_content = $content;  
   
 }//end setContent function
 
 function setName($name){
  $this-cell_name = $name;
   
 }//end setContent function
 
 
 function getContent(){
  return $this-cell_content;  
   
 }//end setContent function
 
 } //end TableCell class
 
 
 
 
 
 
 ?
 
 
 
 
 
 
 Victor J. Matherly
 Technical Services
 Wave Communications, Inc
 http://www.wave-communications.com
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] nested objects

2007-12-07 Thread Cesar D. Rodas
No problem,

Just ask your doubts, we're here to help and get help :-)

On 07/12/2007, Victor Matherly [EMAIL PROTECTED] wrote:

 Thanks that fixed it. That was so simple no wonder I was banging my head
 on the wall :-).




 - Original Message -
 From: Cesar D. Rodas [EMAIL PROTECTED]
 To: Victor Matherly [EMAIL PROTECTED]
 Sent: Friday, December 7, 2007 2:37:23 PM (GMT-0500) America/New_York
 Subject: Re: [PHP] nested objects

 Hello

 I hope this help you!


 On 07/12/2007, Victor Matherly  [EMAIL PROTECTED] 
 wrote:



 Hello list,

 I want to create a new object and nest the objects variable in an array of
 another object. I think I am going about it the correct way but the variable
 is not being stored or retrieved correctly from the main function. I can't
 figure out what I am doing wrong. Can anyone help? Here is an example of
 what I am trying to do:



 ?php


 $html = table border='1' \n;

 $row = new htmlTableRow();

 $cell1 = new htmlTableCell();
 $cell1-setContent(test1);
 $cell1-setName(Left test);
 $row-AddCell($cell1);

 $cell2 = new htmlTableCell();
 $cell2-setContent(test2);
 $cell2-setName(right test);
 $row-AddCell($cell2);



 $html .= $row-buildRow();


 $html .= table\n;

 print HERE
 html
 body

 $html

 /body
 /html



 HERE;



 class htmlTableRow {

 var $class;
 var $cell_arr;
 var $the_row;

 function htmlTableRow(){
 $this-cell_arr = array();

 }//end construct

 function AddCell($cell) {
 $this-cell_arr = $cell;

 $this-cell_arr[] = $cell;



 }

 function buildRow(){
 $temp = tr\n;

 foreach($this-cell_arr as $rowdata){

 $temp .= \ttd . $rowdata-cell_content . /td\n;

 }//end foreach
 $temp .= /tr\n;
 return $temp;
 }//end build row funtion

 }// end htmlTableRow class



 class htmlTableCell {
 var $cell_width;
 var $cell_height;
 var $cell_colspan;
 var $cell_rowspan;
 var $css_class;
 var $cell_content;
 var $cell_name;


 function __construct($content = nbsp;){

 $this-cell_content = $content;


 }// end construct

 function setContent($content){
 $this-cell_content = $content;

 }//end setContent function

 function setName($name){
 $this-cell_name = $name;

 }//end setContent function


 function getContent(){
 return $this-cell_content;

 }//end setContent function

 } //end TableCell class






 ?

 Best regards



 Victor J. Matherly
 Technical Services
 Wave Communications, Inc
 http://www.wave-communications.com

 --
 PHP General Mailing List ( http://www.php.net/ )
 To unsubscribe, visit: http://www.php.net/unsub.php




 --


 Cesar D. Rodas
 http://www.cesarodas.com
 http://www.thyphp.com
 http://www.phpajax.org
 Phone: +595-961-974165




-- 
Best Regards

Cesar D. Rodas
http://www.cesarodas.com
http://www.thyphp.com
http://www.phpajax.org
Phone: +595-961-974165