function &_callCodeBehind($aCB) { if (array_key_exists("exec", $aCB)) { $aArgs = func_get_args(); $bCbRdt = FALSE; $bStatic = FALSE; $aExecInfo = $aCB; $sCBRef = $aCB["exec"]; $bFlip = FALSE; if (substr($sCBRef, -10) == '.isFalse()') { $bFlip = TRUE; $sCBRef = str_replace('.isFalse()', '', $sCBRef); } $aExec = tx_ameosformidable::parseForTemplate($sCBRef); $aInlineArgs = tx_ameosformidable::parseTemplateMethodArgs($aExec[1]["args"]); if (t3lib_div::isFirstPartOfStr($sCBRef, "rdt(")) { $bCbRdt = TRUE; $aCbRdtArgs = tx_ameosformidable::parseTemplateMethodArgs($aExec[0]["args"]); if (($oRdt =& $this->rdt($aCbRdtArgs[0])) === FALSE) { $this->mayday("CodeBehind " . $sCBRef . ": Refers to an undefined renderlet"); } } if (preg_match('/(.*)::(.*)/i', $sCBRef) === 1) { $bStatic = TRUE; } if (count($aInlineArgs) > 0) { reset($aInlineArgs); while (list($sKey, ) = each($aInlineArgs)) { if (is_object($aInlineArgs[$sKey])) { $aArgs[] =& $aInlineArgs[$sKey]; } else { $aArgs[] = $aInlineArgs[$sKey]; } } } $iNbParams = count($aArgs) - 1; // without the runneable itself $sName = $aExec[0]["expr"]; $sMethod = $aExec[1]["expr"]; $aTemp = $aArgs; array_shift($aTemp); if ($iNbParams === 1) { $this->pushUserObjParam($aTemp[0]); // back compat with revisions when only one single array-parameter was allowed } else { $this->pushUserObjParam($aTemp); } unset($aTemp); if (array_key_exists($sName, $this->aCodeBehinds["php"])) { $sType = "php"; } elseif (array_key_exists($sName, $this->aCodeBehinds["js"])) { $sType = "js"; } else { if ($bCbRdt !== TRUE && $bStatic !== TRUE) { $this->mayday("CodeBehind " . $sCBRef . ": " . $sName . " is not a declared CodeBehind"); } } if ($bCbRdt === TRUE) { $sType = "php"; $oCbObj =& $oRdt; $sClass = get_class($oCbObj); } else { if ($sType === "php") { $aCB =& $this->aCodeBehinds[$sType][$sName]; $oCbObj =& $aCB["object"]; $sClass = $aCB["class"]; } elseif ($sType === "js") { $aCB =& $this->aCodeBehinds[$sType][$sName]["object"]->aConf; $oCbObj =& $this->aCodeBehinds[$sType][$sName]["object"]; $sClass = $aCB["class"]; } } switch ($sType) { case "php": if (is_object($oCbObj) && method_exists($oCbObj, $sMethod)) { if (count($aArgs) > 1) { $mRes = call_user_func_array(array($oCbObj, $sMethod), array_slice($aArgs, 1)); // omitting the first param (ref to the codebehind descriptor) } else { $mRes = call_user_func_array(array($oCbObj, $sMethod), array()); // no params } } else { if (!is_object($oCbObj)) { $this->mayday("CodeBehind " . $sCBRef . ": " . $sClass . " is not a valid PHP class"); } else { $this->mayday("CodeBehind " . $sCBRef . ": <b>" . $sMethod . "()</b> method does not exists on object <b>" . $sClass . "</b>"); } } break; case "js": if (count($aArgs) > 1) { // calls to non existing PHP methods will be intercepted by __call on the jscb PHP object // and passed to majixExec of the same object $mRes = call_user_func_array(array($oCbObj, $sMethod), array_slice($aArgs, 1)); // omitting the first param (ref to the codebehind descriptor) } else { $mRes = call_user_func_array(array($oCbObj, $sMethod), array()); // no params } } if ($bStatic === TRUE) { $aStaticExec = tx_ameosformidable::parseForTemplate($sCBRef); $aStaticArgs = explode(',', $aStaticExec[0]['args']); foreach ($aStaticArgs as $iKey => $mArg) { if (trim($mArg) === 'TRUE') { $aStaticArgs[$iKey] = TRUE; } if (trim($mArg) === 'FALSE') { $aStaticArgs[$iKey] = FALSE; } } if (($iBracket = strpos($sCBRef, '(')) !== FALSE) { $sCBRef = trim(substr($sCBRef, 0, $iBracket)); } $aMethod = explode('::', $sCBRef); if (!class_exists($aMethod[0], FALSE)) { $this->mayday('Class ' . $aMethod[0] . ' not exist'); } if (!method_exists($aMethod[0], $aMethod[1])) { $this->mayday('Method ' . $sCBRef . ' not exist'); } if (count($aStaticArgs) >= 1) { $mRes = call_user_func_array($sCBRef, $aStaticArgs); } else { $mRes = call_user_func_array($sCBRef, array()); // no params } } $this->pullUserObjParam(); if ($bFlip) { return !$mRes; } return $mRes; } }