/framework/experimental/graphic/GraphicContainer.php

http://zoop.googlecode.com/ · PHP · 32 lines · 28 code · 4 blank · 0 comment · 1 complexity · 997e73dcbaa96917e866418fe898e372 MD5 · raw file

  1. <?php
  2. abstract class GraphicContainer extends GraphicObject
  3. {
  4. protected $children = array();
  5. function getNewChild($type)
  6. {
  7. $newChild = new $type($this);
  8. assert(is_a($newChild, 'GraphicObject'));
  9. $this->children[] = $newChild;
  10. return $newChild;
  11. }
  12. function isInline()
  13. {
  14. return false;
  15. }
  16. function getObjectTree($indentLevel = 0)
  17. {
  18. $tabs = '';
  19. for($i = 0; $i < $indentLevel; $i++)
  20. $tabs .= '&nbsp;&nbsp;&nbsp;&nbsp;';
  21. echo $tabs . '&lt;' . get_class($this) . '&gt;<br>';
  22. foreach($this->children as $thisChild)
  23. {
  24. $thisChild->getObjectTree($indentLevel + 1);
  25. }
  26. echo $tabs . '&lt;/' . get_class($this) . '&gt;<br>';
  27. }
  28. }