FORMidable RAD Framework

class.mainrenderer.php

00001 <?php
00002 
00003         class formidable_mainrenderer extends formidable_mainobject {
00004 
00005                 var $aCustomHidden      = null;
00006                 var $bFormWrap          = TRUE;
00007                 var $bValidation        = TRUE;
00008                 var $bDisplayLabels     = TRUE;
00009 
00010                 function _init(&$oForm, $aElement, $aObjectType, $sXPath) {
00011 
00012                         parent::_init($oForm, $aElement, $aObjectType, $sXPath);
00013 
00014                         $this->_setDisplayLabels(!$this->oForm->_isFalse("/meta/displaylabels"));
00015                 }
00016 
00017                 function _render($aRendered) {
00018                         return $this->_wrapIntoForm(implode("<br />\n", $aRendered));
00019                 }
00020                 
00021                 function _includeLibraries() {
00022 
00023                         if($this->oForm->useJs()) {
00024                                 $this->oForm->oJs->_includeOnceLibs();
00025                                 $this->oForm->oJs->_includeThisFormDesc();
00026                         }
00027                         
00028                 }
00029 
00030                 function _wrapIntoDebugContainer($aHtmlBag, &$oRdt) {
00031 
00032                         $sName = $oRdt->_getName();
00033 
00034                         $sHtml = <<<TEMPLATE
00035 
00036                                 
00037                                 <div class="ameosformidable_debugcontainer_void">
00038                                         <div style="pointer: help;" class="ameosformidable_debughandler_void">{$oRdt->aElement["type"]}:{$sName}</div>
00039                                         {$aHtmlBag["__compiled"]}
00040                                 </div>
00041 TEMPLATE;
00042                         $aHtmlBag["__compiled"] = $sHtml;
00043 
00044                         if(array_key_exists("input", $aHtmlBag)) {
00045                                 
00046                                 $sInfos = rawurlencode($aHtmlBag["input"]);
00047                                 $sHtml = <<<TEMPLATE
00048 
00049                                 
00050                                 <div class="ameosformidable_debugcontainer_void">
00051                                         <div style="pointer: help;" class="ameosformidable_debughandler_void">{$sName}.input</div>
00052                                         {$aHtmlBag["input"]}
00053                                 </div>
00054 TEMPLATE;
00055                                 $aHtmlBag["input"] = $sHtml;
00056 
00057                         }
00058                         return $aHtmlBag;
00059                 }
00060 
00061                 function _wrapIntoForm($html) {
00062 
00063                         if(!empty($this->oForm->oDataHandler->newEntryId)) {
00064                                 $iEntryId = $this->oForm->oDataHandler->newEntryId;
00065                         } else {
00066                                 $iEntryId = $this->oForm->oDataHandler->_currentEntryId();
00067                         }
00068                         
00069                         $hidden_entryid         = $this->_getHiddenEntryId($iEntryId);
00070                         $hidden_custom          = $this->_getHiddenCustom();
00071                         $sSysHidden                     =       "<input type='hidden' name='" . $this->oForm->formid . "[AMEOSFORMIDABLE_SERVEREVENT]' id='" . $this->oForm->formid . "_AMEOSFORMIDABLE_SERVEREVENT' />" .
00072                                                                         "<input type='hidden' name='" . $this->oForm->formid . "[AMEOSFORMIDABLE_SERVEREVENT_PARAMS]' id='" . $this->oForm->formid . "_AMEOSFORMIDABLE_SERVEREVENT_PARAMS' />" .
00073                                                                         "<input type='hidden' name='" . $this->oForm->formid . "[AMEOSFORMIDABLE_SERVEREVENT_HASH]' id='" . $this->oForm->formid . "_AMEOSFORMIDABLE_SERVEREVENT_HASH' />" .
00074                                                                         "<input type='hidden' name='" . $this->oForm->formid . "[AMEOSFORMIDABLE_ADDPOSTVARS]' id='" . $this->oForm->formid . "_AMEOSFORMIDABLE_ADDPOSTVARS' />" .
00075                                                                         "<input type='hidden' name='" . $this->oForm->formid . "[AMEOSFORMIDABLE_VIEWSTATE]' id='" . $this->oForm->formid . "_AMEOSFORMIDABLE_VIEWSTATE' />" .
00076                                                                         "<input type='hidden' name='" . $this->oForm->formid . "[AMEOSFORMIDABLE_SUBMITTED]' id='" . $this->oForm->formid . "_AMEOSFORMIDABLE_SUBMITTED' value='" . AMEOSFORMIDABLE_EVENT_SUBMIT_FULL . "' />";
00077 
00078                         if(($sStepperId = $this->oForm->_getStepperId()) !== FALSE) {
00079                                 $sSysHidden .=  "<input type='hidden' name='AMEOSFORMIDABLE_STEP' id='AMEOSFORMIDABLE_STEP' value='" . $this->oForm->_getStep() . "' />" .
00080                                                                 "<input type='hidden' name='AMEOSFORMIDABLE_STEP_HASH' id='AMEOSFORMIDABLE_STEP_HASH' value='" . $this->oForm->_getSafeLock($this->oForm->_getStep()) . "' />";
00081                         }
00082                         
00083                         $aHtmlBag =
00084                                 array(
00085                                         "SCRIPT"                => "",
00086                                         "FORMBEGIN"             => "",
00087                                         "CONTENT"               => $html,
00088                                         /*"HIDDEN"              => $hidden_entryid . $hidden_custom . $sSysHidden,*/
00089                                         "HIDDEN"                => "<p style='position:absolute; top:-5000px; left:-5000px;'>" . $hidden_entryid . $hidden_custom . $sSysHidden . "</p>",       // in P for XHTML validation
00090                                         "FORMEND"               => "",
00091                                 );
00092                         
00093                         if($this->bFormWrap) {
00094                                 
00095                                 $formid                 = "";
00096                                 $formaction             = "";
00097                                 $formonsubmit   = "";
00098                                 $formmethod             = "";
00099                                 $formcustom             = "";
00100                                 
00101                                 /*$formid = " id=\"" . $this->oForm->formid . "\" name=\"" . $this->oForm->formid . "\" ";*/
00102                                 $formid = " id=\"" . $this->oForm->formid . "\" ";
00103 
00104                                 if(($sAction = $this->oForm->_navConf("/meta/form/action")) !== FALSE) {
00105                                         $formaction = " action=\"" . $this->oForm->xhtmlUrl($sAction) . "\" ";
00106                                 } else {
00107                                         $formaction = " action=\"" .  $this->oForm->xhtmlUrl(t3lib_div::getIndpEnv("TYPO3_REQUEST_URL")) . "\" ";
00108                                 }
00109 
00110                                 if(($sOnSubmit = $this->oForm->_navConf("/meta/form/onsubmit")) !== FALSE) {
00111                                         $formonsubmit = " onSubmit = \"" . $sOnSubmit . "\" ";
00112                                 }
00113 
00114                                 if(($sCustom = $this->oForm->_navConf("/meta/form/custom")) !== FALSE) {
00115                                         $formcustom = " " . $sCustom . " ";
00116                                 }
00117                                 
00118                                 $aHtmlBag["FORMBEGIN"]  =       "<form enctype=\"multipart/form-data\" " . $formid . $formaction . $formonsubmit . $formcustom . " method=\"post\">";
00119                                 $aHtmlBag["FORMEND"]    =       "</form>";
00120                         }
00121                         
00122                         reset($aHtmlBag);
00123                         return $aHtmlBag;
00124                 }
00125                 
00126                 function _getFullSubmitEvent() {
00127                         return "Formidable.f('" . $this->oForm->formid . "').submitFull();";
00128                 }
00129 
00130                 function _getRefreshSubmitEvent() {
00131                         return "Formidable.f('" . $this->oForm->formid . "').submitRefresh();";
00132                 }
00133 
00134                 function _getDraftSubmitEvent() {
00135                         return "Formidable.f('" . $this->oForm->formid . "').submitDraft();";
00136                 }
00137 
00138                 function _getTestSubmitEvent() {
00139                         return "Formidable.f('" . $this->oForm->formid . "').submitTest();";
00140                 }
00141 
00142                 function _getClearSubmitEvent() {
00143                         return "Formidable.f('" . $this->oForm->formid . "').submitClear();";
00144                 }
00145 
00146                 function _getSearchSubmitEvent() {
00147                         return "Formidable.f('" . $this->oForm->formid . "').submitSearch();";
00148                 }
00149 
00150                 function _getServerEvent($sRdtName, $aEvent, $aData = array()) {
00151 //debug($aData);
00152 //                      debug($sRdtName, "_getServerEvent");
00153 //                      debug(t3lib_div::debug_trail(), "_getServerEvent");
00154                         $sEventId = $this->oForm->_getServerEventId(
00155                                 $sRdtName,
00156                                 $aEvent
00157                         );
00158 
00159                         $sJsParam = "false";
00160                         $sHash = "false";
00161 
00162                         if(!empty($aData)) {
00163 //                              debug($aData, "params");
00164                                 $aFullEvent = $this->oForm->aServerEvents[$sEventId];
00165 //                              debug($aFullEvent, "aFullEvent");
00166 //                              debug($this->oForm->aServerEvents);
00167 
00168 //                              debug($this->oForm->aServerEvents[$sEventId], "event");
00169 //                              debug($aFullEvent["params"], "needed params");
00170 
00171 
00172                                 $aGrabbedParams = array();
00173                                 reset($aFullEvent["params"]);
00174                                 while(list(, $sParam) = each($aFullEvent["params"])) {
00175                                         if(array_key_exists($sParam, $aData)) {
00176                                                 $aGrabbedParams[$sParam] = $aData[$sParam];
00177                                         }
00178                                 }
00179 
00180 //                              debug($aGrabbedParams, "grabbed params");
00181                                 if(!empty($aGrabbedParams)) {
00182                                         $sJsParam = base64_encode(serialize($aGrabbedParams));
00183                                         $sHash = "'" . $this->oForm->_getSafeLock($sJsParam) . "'";
00184                                         $sJsParam = "'" . $sJsParam . "'";
00185                                 }
00186                         }
00187                         
00188                         $sConfirm = "false";
00189                         if(array_key_exists("confirm", $aEvent) && trim($aEvent["confirm"] !== "")) {
00190                                 $sConfirm = "'" . rawurlencode(
00191                                         $this->oForm->_getLLLabel(
00192                                                 $aEvent["confirm"]
00193                                         )
00194                                 ) . "'";
00195                         }
00196 
00197                         if(($sSubmitMode = $this->oForm->_navConf("submit", $aEvent)) !== FALSE) {
00198                                 switch($sSubmitMode) {
00199                                         case "full" : {
00200                                                 return "Formidable.f('" . $this->oForm->formid . "').executeServerEvent('" . $sEventId . "', Formidable.SUBMIT_FULL, " . $sJsParam . ", " . $sHash . ", " . $sConfirm . ");";
00201                                                 break;
00202                                         }
00203                                         case "refresh" : {
00204                                                 return "Formidable.f('" . $this->oForm->formid . "').executeServerEvent('" . $sEventId . "', Formidable.SUBMIT_REFRESH, " . $sJsParam . ", " . $sHash . ", " . $sConfirm . ");";
00205                                                 break;
00206                                         }
00207                                         case "draft" : {
00208                                                 return "Formidable.f('" . $this->oForm->formid . "').executeServerEvent('" . $sEventId . "', Formidable.SUBMIT_DRAFT, " . $sJsParam . ", " . $sHash . ", " . $sConfirm . ");";
00209                                                 break;
00210                                         }
00211                                         case "test" : {
00212                                                 return "Formidable.f('" . $this->oForm->formid . "').executeServerEvent('" . $sEventId . "', Formidable.SUBMIT_TEST, " . $sJsParam . ", " . $sHash . ", " . $sConfirm . ");";
00213                                                 break;
00214                                         }
00215                                 }
00216                         } else {
00217                                 // default: REFRESH
00218                                 return "Formidable.f('" . $this->oForm->formid . "').executeServerEvent('" . $sEventId . "', Formidable.SUBMIT_REFRESH , " . $sJsParam . ", " . $sHash . ", " . $sConfirm . ");";
00219                         }
00220                 }
00221                 
00222                 function _getAjaxEvent(&$oRdt, $aEvent, $sEvent) {
00223 
00224                         $sRdtName = $oRdt->_getName();
00225 
00226                         $sEventId = $this->oForm->_getAjaxEventId(
00227                                 $sRdtName,
00228                                 array($sEvent => $aEvent)
00229                         );
00230 
00231                         $sRdtId = $oRdt->_getElementHtmlId();
00232                         $sHash = $oRdt->_getSessionDataHashKey();
00233                         $bCache = $this->oForm->_defaultTrue("/cache", $aEvent);
00234                         $bPersist = $this->oForm->_defaultFalse("/persist", $aEvent);
00235 
00236                         $aParams = array();
00237                         $aRowParams = array();
00238 
00239                         if(($sParams = $this->oForm->_navConf("/params", $aEvent)) !== FALSE) {
00240                                 $aParams = t3lib_div::trimExplode(",", $sParams);
00241 
00242                                 // grabbing lister current row param
00243                                 $aTempParams = $aParams;
00244                                 reset($aTempParams);
00245                                 while(list($iKey, $sParam) = each($aTempParams)) {
00246                                         if(t3lib_div::isFirstPartOfStr($sParam, "rowData::")) {
00247                                                 unset($aParams[$iKey]);
00248                                                 $sParamName = substr($sParam, 9);
00249                                                 if(($sValue = $this->oForm->oDataHandler->_getListData($sParamName)) !== FALSE) {
00250                                                         $aRowParams[$sParamName] = $sValue;
00251                                                 } else {
00252                                                         $aRowParams[$sParamName] = "";
00253                                                 }
00254                                         } elseif(t3lib_div::isFirstPartOfStr($sParam, "rowInput::")) {
00255                                                 /* replacing *id* with *id for this row*; will be handled by JS framework */
00256                                                 $sParamName = substr($sParam, 10);
00257                                                 $aParams[$iKey] = "rowInput::" . $sParamName . "::" . $this->oForm->aORenderlets[$sParamName]->_getElementHtmlId();
00258                                                         // note: _getAjaxEvent() is called when in rows rendering for list
00259                                                                 // _getElementHtmlId() on a renderlet is designed to return the correct html id for the input of this row
00260                                                                 // in such a case
00261                                         }
00262                                 }
00263                         }
00264                         
00265                         $aAjaxEventParams = $oRdt->alterAjaxEventParams(array(
00266                                 "eventname" => $sEvent,
00267                                 "eventid" => $sEventId,
00268                                 "hash" => $sHash,
00269                                 "cache" => $bCache,
00270                                 "persist" => $bPersist,
00271                                 "params" => $aParams,
00272                                 "row" => $aRowParams
00273                         ));
00274 
00275                         $sJsonParams = $this->oForm->array2json($aAjaxEventParams["params"]);
00276                         $sJsonRowParams = $this->oForm->array2json($aAjaxEventParams["row"]);
00277 
00278                         return "Formidable.f('" . $this->oForm->formid . "').executeAjaxEvent('" . $aAjaxEventParams["eventname"] . "', '" . $sRdtId . "', '" . $aAjaxEventParams["eventid"] . "', '" . $aAjaxEventParams["hash"] . "', " . (($aAjaxEventParams["cache"]) ? "true" : "false") . ", " . (($aAjaxEventParams["persist"]) ? "true" : "false") . ", " . $sJsonParams . ", " . $sJsonRowParams . ", arguments);";
00279                 }
00280 
00281                 function wrapEventsForInlineJs($aEvents) {
00282                         
00283                         $aJson = array();
00284                         reset($aEvents);
00285                         while(list(, $sJs) = each($aEvents)) {
00286                                 $aJson[] = rawurlencode($sJs);
00287                         }
00288 
00289                         return "Formidable.executeInlineJs(" . $this->oForm->array2json($aJson) . ");";
00290                 }
00291 
00292                 function _getClientEvent($sObjectName, $aEvent = array(), $aEventData) {
00293 
00294                         if(array_key_exists($sObjectName, $this->oForm->aORenderlets)) {
00295                                 $sObjectId = $this->oForm->aORenderlets[$sObjectName]->_getElementHtmlId();
00296                         } elseif($sObjectName === $this->oForm->formid) {
00297                                 $sObjectId = $this->oForm->formid;
00298                         } else {
00299                                 $sObjectId = "tx_ameosformidable";
00300                         }
00301                         if(empty($aEventData)) {
00302                                 $aEventData = array();
00303                         }
00304 
00305                         $sData = $this->oForm->array2json(
00306                                 array(
00307                                         "init" => array(),                      // init and attachevents are here for majix-ajax compat
00308                                         "attachevents" => array(),
00309                                         "tasks" => $aEventData,
00310                                 )
00311                         );
00312 
00313                         $bPersist = $this->oForm->_defaultFalse("/persist", $aEvent);
00314 
00315                         return "Formidable.f('" . $this->oForm->formid . "').executeClientEvent('" . $sObjectId . "', " . (($bPersist) ? "true" : "false") . ", {$sData});";
00316                 }
00317 
00318                 function _getHiddenEntryId($entryId) {
00319                         
00320                         if(!empty($entryId)) {
00321                                 return "<input type = \"hidden\" id=\"" . $this->_getHiddenHtmlId("AMEOSFORMIDABLE_ENTRYID") . "\" name=\"" . $this->_getHiddenHtmlName("AMEOSFORMIDABLE_ENTRYID") . "\" value=\"" . $entryId . "\" />";
00322                         }
00323 
00324                         return "";
00325                 }
00326                 
00327                 function _getHiddenCustom() {
00328                         if(is_array($this->aCustomHidden) && sizeof($this->aCustomHidden) > 0)
00329                         { return implode("", $this->aCustomHidden);}
00330 
00331                         return "";
00332                 }
00333 
00334                 function _setHiddenCustom($name, $value) {
00335 
00336                         if(!is_array($this->aCustomHidden)) {
00337                                 $this->aCustomHidden = array();
00338                         }
00339                         
00340                         $this->aCustomHidden[$name] = "<input type=\"hidden\" id=\"" . $this->_getHiddenHtmlId($name) . "\" name=\"" . $this->_getHiddenHtmlName($name) . "\" value=\"" . $value . "\" />";
00341                 }
00342 
00343                 function _getHiddenHtmlName($sName) {
00344                         return $this->_getHtmlName($sName);
00345                 }
00346                 
00347                 function _getHiddenHtmlId($sName) {
00348                         return $this->_getHtmlId($sName);
00349                 }
00350 
00351                 function _getHtmlId($sName) {
00352                         return $this->oForm->formid . "_" . $sName;
00353                 }
00354                 
00355                 function _getHtmlName($sName) {
00356                         return $this->oForm->formid . "[" . $sName . "]";
00357                 }
00358                 
00359                 function _setFormWrap($bWrap) {
00360                         $this->bFormWrap = $bWrap;
00361                 }
00362 
00363                 function _setValidation($bValidation) {
00364                         $this->bValidation = $bValidation;
00365                 }
00366 
00367                 function _getThisFormId() {
00368                         return $this->oForm->formid;
00369                 }
00370 
00371                 function _setDisplayLabels($bDisplayLabels) {
00372                         $this->bDisplayLabels = $bDisplayLabels;
00373                 }
00374                 
00375                 /*function _displayLabel($label) {
00376                         return ($this->bDisplayLabels && (trim($label) != "")) ? "<div>" . $label . "</div>\n" : "";
00377                 }*/
00378 
00379                 function renderStyles() {
00380 
00381                         if(($mStyle = $this->_navConf("/style")) !== FALSE) {
00382 
00383                                 $sUrl = FALSE;
00384                                 $sStyle = FALSE;
00385 
00386                                 if($this->oForm->isUserObj($mStyle)) {
00387                                         $sStyle = $this->oForm->_callUserObj($mStyle);
00388                                 } elseif(is_array($mStyle) && array_key_exists("__value", $mStyle) && trim($mStyle["__value"]) != "") {
00389                                         $sStyle = $mStyle["__value"];
00390                                 } else {
00391                                         $sStyle = $mStyle;
00392                                 }
00393 
00394                                 if(is_array($mStyle) && array_key_exists("url", $mStyle)) {
00395                                         if($this->oForm->isUserObj($mStyle["url"])) {
00396                                                 $sUrl = $this->oForm->_callUserObj($mStyle["url"]);
00397                                         } else {
00398                                                 $sUrl = $mStyle["url"];
00399                                         }
00400 
00401                                         if($this->_defaultFalse("/style/rewrite") === TRUE) {
00402                                                 if(!$this->oForm->isAbsWebPath($sUrl)) {
00403                                                         $sUrl = $this->oForm->toServerPath($sUrl);
00404                                                         $sStyle = t3lib_div::getUrl($sUrl);
00405                                                         $sUrl = FALSE;
00406                                                 }
00407                                         }
00408                                 }
00409                                 
00410                                 if($sStyle !== FALSE) {
00411                                         reset($this->oForm->aORenderlets);
00412                                         while(list($sName, ) = each($this->oForm->aORenderlets)) {
00413                                                 $oRdt =& $this->oForm->aORenderlets[$sName];
00414                                                 $sStyle = str_replace(
00415                                                         array(
00416                                                                 "#" . $sName,
00417                                                                 "{PARENTPATH}"
00418                                                         ),
00419                                                         array(
00420                                                                 "#" . $oRdt->_getElementCssId(),
00421                                                                 $this->oForm->_getParentExtSitePath()
00422                                                         ),
00423                                                         $sStyle
00424                                                 );
00425                                         }
00426                                         
00427                                         //$sStyle = str_replace(";", " !important;", $sStyle);
00428 
00429                                         $this->oForm->additionalHeaderData(
00430                                                 $this->oForm->inline2TempFile(
00431                                                         $sStyle,
00432                                                         'css',
00433                                                         "Form '" . $this->oForm->formid . "' styles"
00434                                                 )
00435                                         );
00436                                 }
00437 
00438                                 if($sUrl !== FALSE) {
00439                                         $sUrl = $this->oForm->toWebPath($sUrl);
00440                                         $this->oForm->additionalHeaderData(
00441                                                 "<link rel='stylesheet' type='text/css' href='" . $sUrl . "' />"
00442                                         );
00443                                 }
00444                         }
00445                 }
00446 
00447                 function processHtmlBag($mHtml, &$oRdt) {
00448                         
00449                         $sLabel = array_key_exists("label", $oRdt->aElement) ? $this->oForm->_getLLLabel($oRdt->aElement["label"]) : "";
00450                         
00451                         if(is_string($mHtml)/* && (($mHtml = trim($mHtml)) !== "")*/) {         // can be empty with empty readonly 
00452                                 
00453                                 $mHtml = array(
00454                                         "__compiled"    => $mHtml
00455                                 );
00456                         }
00457 
00458                         if(!empty($mHtml) && array_key_exists("__compiled", $mHtml) && is_string($mHtml["__compiled"])/* && trim($mHtml["__compiled"]) !== ""*/) {
00459 
00460                                 if(($mWrap = $oRdt->_navConf("/wrap")) !== FALSE) {
00461                                         
00462                                         if($this->oForm->isUserObj($mWrap)) {
00463                                                 $mWrap = $this->oForm->_callUserObj($mWrap);
00464                                         }
00465 
00466                                         $mWrap = $this->oForm->_substLLLInHtml($mWrap);
00467 
00468                                         $mHtml["__compiled"] = str_replace("|", $mHtml["__compiled"], $mWrap);
00469                                         // wrap added for f.schossig    2006/08/29
00470                                 }
00471                                 
00472                                 if(!array_key_exists("label", $mHtml)) {
00473                                         $mHtml["label"] = $sLabel;
00474                                 }
00475 
00476                                 if(!array_key_exists("label.", $mHtml)) {
00477                                         $mHtml["label."] = array();
00478                                 }
00479 
00480                                 if(!array_key_exists("tag", $mHtml["label."])) {
00481                                         $mHtml["label."]["tag"] = "<label for=\"" . $oRdt->_getElementHtmlId() . "\" id=\"" . $oRdt->_getElementHtmlId() . "_label\">" . $sLabel . "</label>";
00482                                 }
00483 
00484                                 if(!array_key_exists("htmlname", $mHtml)) {
00485                                         $mHtml["htmlname"] = $oRdt->_getElementHtmlName();
00486                                 }
00487 
00488                                 if(!array_key_exists("htmlid", $mHtml)) {
00489                                         $mHtml["htmlid"] = $oRdt->_getElementHtmlId();
00490                                 }
00491 
00492 /*                              if(array_key_exists($oRdt->_getName(), $this->_aValidationErrors)) {
00493                                         $mHtml["error"] = $this->_aValidationErrors[$oRdt->_getName()];
00494                                 }
00495 
00496                                 debug($this->_aValidationErrors, $oRdt->_getName());
00497                                 debug($mHtml);*/
00498 
00499                                 $mHtml["help"] = t3lib_div::view_array($mHtml);
00500 
00501                                 $mHtml = $this->recombineHtmlBag(
00502                                         $mHtml,
00503                                         $oRdt
00504                                 );
00505                                 
00506                                 if($this->oForm->bDebug && $oRdt->_debugable()) {
00507                                         $mHtml = $this->_wrapIntoDebugContainer(
00508                                                 $mHtml,
00509                                                 $oRdt
00510                                         );
00511                                 }
00512                         } else {
00513                                 $mHtml = array();
00514                         }
00515 
00516                         reset($mHtml);
00517                         return $mHtml;
00518                 }
00519 
00520                 function recombineHtmlBag($mHtml, &$oRdt) {
00521                         
00522                         if(($mRecombine = $oRdt->_navConf("/recombine")) !== FALSE) {
00523 
00524                                 // we convert the aHtmlBag to something useable in TypoScript
00525                                 // creating sub-array for each xxx.yyy ( split on dot )
00526 
00527                                 $sTs = '';
00528                                 while(list($sCanal, $sHtml) = each($mHtml)) {
00529                                         $sTs .= '
00530                                                 params.' . $sCanal . ' (
00531                                                         ' . $sHtml . '
00532                                                 )
00533                                         ';
00534                                 }
00535 
00536                                 
00537 
00538                                 require_once(PATH_t3lib."class.t3lib_tsparser.php");
00539 
00540                                 $oParser = t3lib_div::makeInstance("t3lib_tsparser");
00541                                 $oParser->tt_track = 0; // Do not log time-performance information
00542                                 $oParser->parse($sTs);
00543 
00544                                 $aParams = $oParser->setup["params."];
00545                                 
00546                                 // recombining canals
00547                                 //reset($mHtml);
00548                                 $aCanals = array_keys($mHtml);
00549                                 while(list(, $sCanal) = each($aCanals)) {
00550 
00551                                         $sCanalPath = str_replace(".", "/", $sCanal);
00552 //                                      debug($sCanal, "ici");
00553 
00554                                         if(($mRecombineCanal = $oRdt->_navConf("/recombine/" . $sCanalPath)) !== FALSE) {
00555                                                 
00556                                                 if($this->oForm->isUserObj($mRecombineCanal)) {
00557 
00558                                                         // expecting userobj
00559 
00560                                                         $sValue = $this->oForm->_callUserObj(
00561                                                                 $mRecombineCanal,
00562                                                                 $aParams,
00563                                                                 FALSE,
00564                                                                 $this,
00565                                                                 FALSE           // do not add dots
00566                                                         );
00567 
00568                                                         $mHtml[$sCanal] = $sValue;
00569 
00570                                                         // reinjecting modified recombine into process for following recombines
00571                                                         reset($aParams);
00572                                                         $aSegments = explode(".", $sCanal);
00573                                                         $aPointer =& $aParams;
00574                                                         for($k = 0; $k < (count($aSegments) - 1); $k++) {
00575                                                                 $aPointer =& $aPointer[$aSegments[$k] . "."];
00576                                                         }
00577 
00578                                                         $aPointer[$aSegments[$k]] = $sValue;
00579                                                 }
00580                                         }
00581                                 }
00582 
00583                                 // recombining __compiled
00584 
00585                                 if($this->oForm->isUserObj($mRecombine)) {
00586                                         
00587                                         // expecting userobj
00588 
00589                                         $mHtml["__compiled"] = $this->oForm->_callUserObj(
00590                                                 $mRecombine,
00591                                                 $aParams,
00592                                                 FALSE,
00593                                                 $this,
00594                                                 FALSE           // do not add dots
00595                                         );
00596                                 }
00597                         }
00598 
00599                         reset($mHtml);
00600                         return $mHtml;
00601                 }
00602 
00603                 function displayOnlyIfJs($aRendered) {
00604 
00605                         $aRdts = array_keys($this->oForm->aORenderlets);
00606                         reset($aRdts);
00607                         while(list(, $sRdt) = each($aRdts)) {
00608                                 if($this->oForm->aORenderlets[$sRdt]->displayOnlyIfJs() === TRUE) {
00609                                         $sJson = $this->oForm->oJson->encode(
00610                                                 $aRendered[$sRdt]["__compiled"]
00611                                         );
00612 
00613                                         $sId = $this->oForm->aORenderlets[$sRdt]->_getElementHtmlId() . "_unobtrusive";
00614                                         $aRendered[$sRdt]["__compiled"] = "<span id='" . $sId . "'></span>";
00615 
00616                                         $this->oForm->attachInitTaskUnobtrusive('
00617                                                 if($("' . $sId . '")) {$("' . $sId . '").innerHTML=' . $sJson . ';}
00618                                         ');
00619                                 }
00620                         }
00621 
00622                         return $aRendered;
00623                 }
00624 
00625         }
00626         
00627         if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/ameos_formidable/api/class.mainrenderer.php"]) {
00628                 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/ameos_formidable/api/class.mainrenderer.php"]);
00629         }
00630 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6