00001 <?
00006 class MBasePainter
00007 {
00008 private static $count;
00009
00010
00011
00012
00013 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00014 # A helper function, which generates an array of theme elements.
00015 # This function is called recursively, when an array elements
00016 # contains another array.
00017 #----------------------------------------------------------------------
00018
00029 function GenerateElements($elements, $separator = '', $method = 'Generate')
00030 {
00031 if (is_array($elements))
00032 {
00033 foreach ($elements as $e)
00034 {
00035 $this->GenerateElements($e, $separator);
00036 }
00037 }
00038 else if (is_object($elements))
00039 {
00040 if (method_exists($elements, 'generate'))
00041 {
00042 if ($html = $elements->$method())
00043 {
00044 $this->GenerateElements($html, $separator);
00045 }
00046 else
00047 echo $separator;
00048 }
00049 else
00050 {
00051 echo "BasePainter Error: Method Generate not defined to " . get_class($elements);
00052 }
00053 }
00054 else if ($elements)
00055 {
00056 echo $elements . $separator;
00057 }
00058 }
00059
00060 #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00061 # Convenience function to capture the output of an element's
00062 # <code>Generate</code> function as HTML string.
00063 #----------------------------------------------------------------------
00064
00074 function GenerateToString($element, $separator = '')
00075 {
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 if (is_array($element))
00086 {
00087 foreach ($element as $e)
00088 {
00089 $html .= $this->GenerateToString($e, $separator);
00090 }
00091 }
00092 elseif (is_object($element))
00093 {
00094 if ( method_exists($element, 'generate') )
00095 {
00096 $MIOLO = MIOLO::getInstance();
00097
00098 if ( MUtil::getBooleanValue( $MIOLO->getConf('options.loading.show') ) &&
00099 MUtil::getBooleanValue( $MIOLO->getConf('options.loading.generating') ) )
00100 {
00101 if ( $element->name )
00102 {
00103 MIOLO::updateLoading("Generating... {$element->name}");
00104 }
00105 }
00106
00107 $html = $element->generate() . $separator;
00108 }
00109 else
00110 {
00111 $html = "BasePainter Error: Method Generate not defined to " . get_class($elements);
00112 }
00113 }
00114 else
00115 {
00116 $html = (string)$element;
00117 }
00118
00119 return $html;
00120 }
00121 }
00122 ?>