function ExecMethod($method, $functionparams = '_UNDEF_', $loglevel = 3, $classparams = '_UNDEF_')
{
    /* Need to make sure this is working against a single dimensional object */
    $partscount = count(explode('.', $method)) - 1;
    if ($partscount == 2) {
        list($appname, $classname, $functionname) = explode(".", $method);
        if (!is_object($GLOBALS[$classname])) {
            if ($classparams != '_UNDEF_' && ($classparams || $classparams != 'True')) {
                $GLOBALS[$classname] = CreateObject($appname . '.' . $classname, $classparams);
            } else {
                $GLOBALS[$classname] = CreateObject($appname . '.' . $classname);
            }
        }
        if (!method_exists($GLOBALS[$classname], $functionname)) {
            echo "<p><b>" . function_backtrace() . "</b>: no methode '{$functionname}' in class '{$classname}'</p>\n";
            return False;
        }
        if ((is_array($functionparams) || $functionparams != '_UNDEF_') && ($functionparams || $functionparams != 'True')) {
            return $GLOBALS[$classname]->{$functionname}($functionparams);
        } else {
            return $GLOBALS[$classname]->{$functionname}();
        }
    } elseif ($partscount >= 3) {
        $GLOBALS['methodparts'] = explode(".", $method);
        $classpartnum = $partscount - 1;
        $appname = $GLOBALS['methodparts'][0];
        $classname = $GLOBALS['methodparts'][$classpartnum];
        $functionname = $GLOBALS['methodparts'][$partscount];
        /* Now we clear these out of the array so that we can do a proper */
        /* loop and build the $parentobject */
        unset($GLOBALS['methodparts'][0]);
        unset($GLOBALS['methodparts'][$classpartnum]);
        unset($GLOBALS['methodparts'][$partscount]);
        reset($GLOBALS['methodparts']);
        $firstparent = 'True';
        //			while (list ($key, $val) = each ($GLOBALS['methodparts']))
        foreach ($GLOBALS['methodparts'] as $val) {
            if ($firstparent == 'True') {
                $parentobject = '$GLOBALS["' . $val . '"]';
                $firstparent = False;
            } else {
                $parentobject .= '->' . $val;
            }
        }
        unset($GLOBALS['methodparts']);
        $code = '$isobject = is_object(' . $parentobject . '->' . $classname . ');';
        eval($code);
        if (!$isobject) {
            if ($classparams != '_UNDEF_' && ($classparams || $classparams != 'True')) {
                if (is_string($classparams)) {
                    eval($parentobject . '->' . $classname . ' = CreateObject("' . $appname . '.' . $classname . '", "' . $classparams . '");');
                } else {
                    eval($parentobject . '->' . $classname . ' = CreateObject("' . $appname . '.' . $classname . '", ' . $classparams . ');');
                }
            } else {
                eval($parentobject . '->' . $classname . ' = CreateObject("' . $appname . '.' . $classname . '");');
            }
        }
        if ($functionparams != '_UNDEF_' && ($functionparams || $functionparams != 'True')) {
            eval('$returnval = ' . $parentobject . '->' . $classname . '->' . $functionname . '(' . $functionparams . ');');
            return $returnval;
        } else {
            eval('$returnval = ' . $parentobject . '->' . $classname . '->' . $functionname . '();');
            return $returnval;
        }
    } else {
        return 'error in parts';
    }
}
Ejemplo n.º 2
0
 /**
  * creates table from array of rows
  *
  * abstracts the html stuff for the table creation
  * Example: $rows = array (
  *	'1'  => array(
  *		1 => 'cell1', '.1' => 'colspan=3',
  *		2 => 'cell2',
  *		3 => 'cell3', '.3' => 'width="10%"'
  *	),'.1' => 'BGCOLOR="#0000FF"' );
  *	table($rows,'width="100%"') = '<table width="100%"><tr><td colspan=3>cell1</td><td>cell2</td><td width="10%">cell3</td></tr></table>'
  *
  * @param array $rows with rows, each row is an array of the cols
  * @param string $options options for the table-tag
  * @param boolean $no_table_tr dont return the table- and outmost tr-tabs, default false=return table+tr
  * @return string with html-code of the table
  */
 static function table($rows, $options = '', $no_table_tr = False)
 {
     $html = $no_table_tr ? '' : "<table {$options}>\n";
     foreach ($rows as $key => $row) {
         if (!is_array($row)) {
             continue;
             // parameter
         }
         $html .= $no_table_tr && $key == 1 ? '' : "\t<tr " . $rows['.' . $key] . ">\n";
         foreach ($row as $key => $cell) {
             if ($key[0] == '.') {
                 continue;
                 // parameter
             }
             $table_pos = strpos($cell, '<table');
             $td_pos = strpos($cell, '<td');
             if ($td_pos !== False && ($table_pos === False || $td_pos < $table_pos)) {
                 $html .= $cell;
             } else {
                 $html .= "\t\t<td " . $row['.' . $key] . ">{$cell}</td>\n";
             }
         }
         $html .= "\t</tr>\n";
     }
     if (!is_array($rows)) {
         echo "<p>" . function_backtrace() . "</p>\n";
     }
     $html .= "</table>\n";
     if ($no_table_tr) {
         $html = substr($html, 0, -16);
     }
     return $html;
 }
 /**
  * Error handler
  *
  * @param string $msg error message
  * @param int $line line of calling method/function (optional)
  * @param string $file file of calling method/function (optional)
  */
 function halt($msg, $line = '', $file = '')
 {
     if ($this->Link_ID) {
         $this->Error = $this->Link_ID->ErrorMsg();
         // need to be BEFORE unlock,
         $this->Errno = $this->Link_ID->ErrorNo();
         // else we get its error or none
         $this->unlock();
         /* Just in case there is a table currently locked */
     }
     if ($this->Halt_On_Error == "no") {
         return;
     }
     $this->haltmsg($msg);
     if ($file) {
         printf("<br><b>File:</b> %s", $file);
     }
     if ($line) {
         printf("<br><b>Line:</b> %s", $line);
     }
     printf("<br><b>Function:</b> %s\n", function_backtrace(2));
     if ($this->Halt_On_Error != "report") {
         echo "<p><b>Session halted.</b>";
         if (is_object($GLOBALS['phpgw']->common)) {
             $GLOBALS['phpgw']->common->phpgw_exit(True);
         } else {
             exit;
         }
     }
 }
 function haltmsg($msg)
 {
     printf("<b>Template Error:</b> %s<br>\n", $msg);
     echo "<b>Backtrace</b>: " . function_backtrace(2) . "<br>\n";
 }