function &_fetchData()
 {
     if (($mData = $this->_navConf("/data")) === FALSE || !tx_ameosformidable::isRunneable($mData)) {
         $this->oForm->mayday("RENDERLET JSTREE <b>" . $this->_getName() . "</b> - requires <b>/data</b> to be properly set with a runneable. Check your XML conf.");
     }
     return $this->oForm->callRunneable($mData);
 }
 function &_getRowsSubpart($sTemplate)
 {
     $aRowsTmpl = array();
     if (($sAltRows = $this->_navConf("/template/alternaterows")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($sAltRows)) {
             $sAltRows = tx_ameosformidable::isRunneable($sAltRows);
         }
         if (!is_string($sAltRows)) {
             $sAltRows = FALSE;
         } else {
             $sAltRows = trim($sAltRows);
         }
     }
     $aAltList = t3lib_div::trimExplode(",", $sAltRows);
     if (sizeof($aAltList) > 0) {
         $sRowsPart = t3lib_parsehtml::getSubpart($sTemplate, "###ROWS###");
         reset($aAltList);
         while (list(, $sAltSubpart) = each($aAltList)) {
             $sHtml = t3lib_parsehtml::getSubpart($sRowsPart, $sAltSubpart);
             if (empty($sHtml)) {
                 $this->oForm->mayday("renderlet:" . $this->_getType() . "[name=" . $this->getName() . "] - The given template with subpart marquer <b>'" . $sAltSubpart . "'</b> returned an empty string - Please check your template!");
             }
             $aRowsTmpl[] = $sHtml;
         }
     }
     return $aRowsTmpl;
 }
Example #3
0
 function _doTheMagic($bShouldProcess = TRUE)
 {
     if ($bShouldProcess && $this->_allIsValid()) {
         $aData = $this->_getFormData();
         // calling back
         $callback = $this->oForm->_navConf($this->oForm->sXpathToControl . "datahandler/");
         if (tx_ameosformidable::isRunneable($callback)) {
             $this->callRunneable($callback, $aData);
         } else {
             $callback = $this->oForm->_navConf($this->oForm->sXpathToControl . "datahandler/parentcallback/");
             if ($callback === FALSE) {
                 $callback = $this->oForm->_navConf($this->oForm->sXpathToControl . "datahandler/callback/");
             }
             if ($callback !== FALSE) {
                 if (tx_ameosformidable::isRunneable($callback)) {
                     $this->callRunneable($callback, $aData);
                 } elseif (is_string($callback)) {
                     if (method_exists($this->oForm->_oParent, $callback)) {
                         $this->oForm->_oParent->{$callback}($aData);
                     } else {
                         $this->oForm->mayday("DATAHANDLER RAW : the callback method " . $callback . " doesn't exists in the definition of the Parent object");
                     }
                 }
             } else {
                 $this->oForm->mayday("DATAHANDLER RAW : you MUST declare a callback method on the Parent Object <b>" . get_class($this->oForm->_oParent) . "</b> in the section <b>/control/datahandler/parentcallback/</b> of the XML conf for this DATAHANDLER ( RAW )");
             }
         }
     }
 }
 function main($content, $conf)
 {
     $this->conf = $conf;
     $this->pi_setPiVarDefaults();
     $this->pi_loadLL();
     $sConfPath = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'tspath'));
     require_once PATH_formidableapi;
     if ($sConfPath !== "") {
         $aCurZone =& $GLOBALS["TSFE"]->tmpl->setup;
         $aPath = explode(".", $sConfPath);
         reset($aPath);
         while (list(, $sSegment) = each($aPath)) {
             if (array_key_exists($sSegment . ".", $aCurZone)) {
                 $aCurZone =& $aCurZone[$sSegment . "."];
             } else {
                 return "<strong>Formidable: TS path not found in template</strong>";
             }
         }
         $this->aFormConf = $aCurZone;
     } else {
         $sConfPath = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'xmlpath'));
         if ($sConfPath !== "") {
             $this->sXmlPath = tx_ameosformidable::toServerPath($sConfPath);
         } else {
             if (array_key_exists("xmlpath", $this->conf)) {
                 $this->sXmlPath = tx_ameosformidable::toServerPath($this->conf["xmlpath"]);
             } else {
                 return "<strong>Formidable: TS or XML pathes not defined</strong>";
             }
         }
     }
     return TRUE;
 }
 function wrapScriptTag($sPath, $bPathOnly = 0)
 {
     $sWebPath = tx_ameosformidable::toWebPath($sPath);
     if (intval($bPathOnly) === 1) {
         return $sWebPath;
     }
     return '<script type="text/javascript" src="' . $sWebPath . '"></script>';
 }
 function getValue()
 {
     $mValue = $this->_navConf("/data/value");
     if (tx_ameosformidable::isRunneable($mValue)) {
         $mValue = $this->oForm->callRunneable($mValue);
     }
     return $mValue;
 }
 private function getTemplatePath()
 {
     $sPath = $this->_navConf("/template/path/");
     if (tx_ameosformidable::isRunneable($sPath)) {
         $sPath = $this->callRunneable($sPath);
     }
     if (is_string($sPath)) {
         return $this->oForm->toServerPath($sPath);
     }
     return FALSE;
 }
 function getSubmitMode()
 {
     $sMode = $this->_navConf("/mode");
     if (tx_ameosformidable::isRunneable($sMode)) {
         $sMode = $this->callRunneable($sMode);
     }
     if (is_string($sMode)) {
         return strtolower(trim($sMode));
     }
     return "full";
 }
 function _getPathReload()
 {
     if (($sPath = $this->_navConf("/reloadpic/")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($sPath)) {
             $sPath = $this->callRunneable($sPath);
         }
         if (t3lib_div::isFirstPartOfStr($sPath, "EXT:")) {
             $sPath = t3lib_div::getIndpEnv("TYPO3_SITE_URL") . str_replace(t3lib_div::getIndpEnv("TYPO3_DOCUMENT_ROOT"), "", t3lib_div::getFileAbsFileName($sPath));
         }
     }
     return $sPath;
 }
 function _initBinding()
 {
     if (tx_ameosformidable::isRunneable($aBindsTo = $this->_navConf("/bindsto"))) {
         $this->aSource =& $this->callRunneable($aBindsTo);
         $this->iTotalRows = count($this->aSource);
         if (!is_array($this->aSource)) {
             $this->aSource = array();
             $this->iTotalRows = 0;
         }
     } else {
         $this->oForm->mayday("DATASOURCE PHPARRAY \"" . $this->aElement["name"] . "\" - requires /bindsTo. Check your XML conf.");
     }
     $this->_sortSource();
     $this->_limitSource();
 }
Example #11
0
 function &_fetchData($aConfig = array(), $aFilters = array())
 {
     $aResults = array();
     $iNumRows = 0;
     if (($aGet = $this->_navConf("/get")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($aGet)) {
             $aResults = $this->callRunneable($aGet);
             if (is_array($aResults)) {
                 $iNumRows = count($aResults);
             } else {
                 $aResults = array();
             }
         } else {
             $this->oForm->mayday("datasource:PHP[name='" . $this->getName() . "'] /get has to be runnable (userobj, or reference to a code-behind).");
         }
     } else {
         $this->oForm->mayday("datasource:PHP[name='" . $this->getName() . "'] You have to provide a runnable on <b>/get</b>.");
     }
     return array("numrows" => $iNumRows, "results" => &$aResults);
 }
 function _doTheMagic($aRendered, $sForm)
 {
     $sUrl = "";
     if ($this->oForm->oDataHandler->_allIsValid()) {
         if (($mPage = $this->_navConf("/pageid")) !== FALSE) {
             if (tx_ameosformidable::isRunneable($mPage)) {
                 $mPage = $this->callRunneable($mPage);
             }
             $sUrl = $this->oForm->cObj->typolink_URL(array("parameter" => $mPage));
             if (!t3lib_div::isFirstPartOfStr($sUrl, "http://") && trim($GLOBALS["TSFE"]->baseUrl) !== "") {
                 $sUrl = $this->oForm->_removeEndingSlash($GLOBALS["TSFE"]->baseUrl) . "/" . $sUrl;
             }
         } else {
             $sUrl = $this->_navConf("/url");
             if (tx_ameosformidable::isRunneable($sUrl)) {
                 $sUrl = $this->callRunneable($sUrl);
             }
         }
         if (is_string($sUrl) && trim($sUrl) !== "") {
             header("Location: " . $sUrl);
             exit;
         }
     }
 }
Example #13
0
 function _getTimeFormat()
 {
     $bTime = $this->oForm->defaultFalse("/data/datetime/displaytime/", $this->aElement);
     if (!$bTime) {
         return '';
     }
     $mFormat = $this->_navConf("/data/datetime/timeformat/");
     if (tx_ameosformidable::isRunneable($mFormat)) {
         $mFormat = $this->callRunneable($mFormat);
     }
     if (!$mFormat) {
         $mFormat = "%H/%M";
     }
     return $mFormat;
 }
 function handleDam()
 {
     if ($this->useDam()) {
         $bSimulatedUser = FALSE;
         global $BE_USER;
         if (!isset($BE_USER) || !is_object($BE_USER) || intval($GLOBALS["BE_USER"]->user["uid"]) === 0) {
             // no be_user available
             // we are using the one created for formidable+dam, named _formidable+dam
             $rSql = $GLOBALS["TYPO3_DB"]->exec_SELECTquery("uid", "be_users", "LOWER(username)='_formidable+dam'");
             if (($aRs = $GLOBALS["TYPO3_DB"]->sql_fetch_assoc($rSql)) !== FALSE) {
                 // we found user _formidable+dam
                 // simulating user
                 unset($BE_USER);
                 $BE_USER = t3lib_div::makeInstance('t3lib_beUserAuth');
                 $BE_USER->OS = TYPO3_OS;
                 $BE_USER->setBeUserByUid($aRs["uid"]);
                 $BE_USER->fetchGroupData();
                 $BE_USER->backendSetUC();
                 $GLOBALS['BE_USER'] = $BE_USER;
                 $bSimulatedUser = TRUE;
             } else {
                 $this->oForm->mayday("renderlet:UPLOAD[name=" . $this->_getName() . "] /dam/use is enabled; for DAM to operate properly, you have to create a backend-user named '_formidable+dam' with permissions on dam tables");
             }
         }
         if ($this->isMultiple()) {
             $aFiles = t3lib_div::trimExplode(",", $this->getValue());
         } else {
             $aFiles = array($this->getValue());
         }
         reset($aFiles);
         while (list(, $sFileName) = each($aFiles)) {
             $sFilePath = $this->getServerPath($sFileName);
             tx_dam::notify_fileChanged($sFilePath);
             $oMedia = tx_dam::media_getForFile($sFilePath);
             if (($mTitle = $this->_navConf("/dam/addtitle")) !== FALSE) {
                 if (tx_ameosformidable::isRunneable($mTitle)) {
                     $mTitle = $this->callRunneable($mTitle, array("filename" => $sFileName, "filepath" => $sFilePath, "media" => $oMedia, "currentcats" => $aCurCats, "files" => $aFiles));
                 }
                 $oMedia->meta["title"] = $mTitle;
                 if (trim($mTitle) !== '') {
                     $oMedia->meta["title"] = $mTitle;
                 }
             }
             if (($mDescription = $this->_navConf("/dam/adddescription")) !== FALSE) {
                 if (tx_ameosformidable::isRunneable($mDescription)) {
                     $mDescription = $this->callRunneable($mDescription, array("filename" => $sFileName, "filepath" => $sFilePath, "media" => $oMedia, "currentcats" => $aCurCats, "files" => $aFiles));
                 }
                 $oMedia->meta["description"] = $mDescription;
                 if (trim($mDescription) !== '') {
                     $oMedia->meta["description"] = $mDescription;
                 }
             }
             if (($mCaption = $this->_navConf("/dam/addcaption")) !== FALSE) {
                 if (tx_ameosformidable::isRunneable($mCaption)) {
                     $mCaption = $this->callRunneable($mCaption, array("filename" => $sFileName, "filepath" => $sFilePath, "media" => $oMedia, "currentcats" => $aCurCats, "files" => $aFiles));
                 }
                 if (trim($mCaption) !== '') {
                     $oMedia->meta["caption"] = $mCaption;
                 }
             }
             if (($mCategories = $this->_navConf("/dam/addcategories")) !== FALSE) {
                 require_once PATH_txdam . "lib/class.tx_dam_db.php";
                 $aCurCats = $GLOBALS["TYPO3_DB"]->exec_SELECTgetRows("uid_foreign", "tx_dam_mm_cat", "uid_local='" . $oMedia->meta["uid"] . "'", "", "sorting ASC");
                 if (!is_array($aCurCats)) {
                     $aCurCats = array();
                 }
                 reset($aCurCats);
                 while (list($sKey, ) = each($aCurCats)) {
                     $aCurCats[$sKey] = $aCurCats[$sKey]["uid_foreign"];
                 }
                 if (tx_ameosformidable::isRunneable($mCategories)) {
                     $mCategories = $this->callRunneable($mCategories, array("filename" => $sFileName, "filepath" => $sFilePath, "media" => $oMedia, "currentcats" => $aCurCats, "files" => $aFiles));
                 }
                 $aCategories = array();
                 if (!is_array($mCategories)) {
                     if (trim($mCategories) !== "") {
                         $aCategories = t3lib_div::trimExplode(",", trim($mCategories));
                     }
                 } else {
                     $aCategories = $mCategories;
                 }
                 if (count($aCategories) > 0) {
                     reset($aCurCats);
                     $aCategories = array_unique(array_merge($aCurCats, $aCategories));
                     if (!empty($aCategories)) {
                         $oMedia->meta["category"] = implode(",", $aCategories);
                     }
                 }
             }
             tx_dam_db::insertUpdateData($oMedia->meta);
         }
         if ($bSimulatedUser === TRUE) {
             unset($BE_USER);
             unset($GLOBALS["BE_USER"]);
         }
     }
 }
 function getPxWidth()
 {
     $mWidth = FALSE;
     if (($mWidth = $this->_navConf("/width")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($mWidth)) {
             $mWidth = intval($this->oForm->callRunneable($mWidth));
         }
         if (($mWidth = intval($mWidth)) === 0) {
             $mWidth = FALSE;
         }
     }
     return $mWidth;
 }
Example #16
0
 function _processAfterEdition($aData)
 {
     if (($aUserObj = $this->_navConf("/process/afteredition/")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($aUserObj)) {
             $this->oForm->callRunneable($aUserObj, $aData);
         }
     }
 }
Example #17
0
 function _getAddInputParamsArray()
 {
     $aAddParams = parent::_getAddInputParamsArray();
     if (($mUseMap = $this->_navConf("/usemap")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($mUseMap)) {
             $mUseMap = $this->callRunneable($mUseMap);
         }
         if ($mUseMap !== FALSE) {
             $aAddParams[] = " usemap=\"" . $mUseMap . "\" ";
         }
     }
     if (($mAlt = $this->_navConf("/alt")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($mAlt)) {
             $mAlt = $this->callRunneable($mAlt);
         }
         if ($mAlt !== FALSE) {
             $aAddParams[] = " alt=\"" . $mAlt . "\" ";
         }
     }
     reset($aAddParams);
     return $aAddParams;
 }
Example #18
0
 function minified()
 {
     return tx_ameosformidable::__getEnvExecMode() !== "BE" && intval($this->oForm->conf["minify."]["enabled"]) === 1 && (file_exists($this->oForm->toServerPath(t3lib_extMgm::siteRelPath("ameos_formidable") . "res/jsfwk/minified/formidable.minified.prototype.js")) || file_exists($this->oForm->toServerPath(t3lib_extMgm::siteRelPath("ameos_formidable") . "res/jsfwk/minified/formidable.minified.jquery.js")));
 }
Example #19
0
 function isFalseVal($mVal)
 {
     if (tx_ameosformidable::isRunneable($mVal)) {
         $mVal = $this->callRunneable($mVal);
     }
     return $mVal == FALSE || strtoupper($mVal) == "FALSE";
 }
Example #20
0
 function _getAdditionalWheres($aWheres, $sPrefix = "")
 {
     $sTempWhere = "";
     if ($aWheres !== FALSE && is_array($aWheres) && count($aWheres) > 0) {
         $aClauses = array();
         $bClauses = FALSE;
         reset($aWheres);
         while (list($sType, $aWhere) = each($aWheres)) {
             $aTemp = explode("-", $sType);
             $sType = trim(strtoupper($aTemp[0]));
             $bProcess = TRUE;
             if (is_array($aWhere) && array_key_exists("process", $aWhere)) {
                 if (tx_ameosformidable::isRunneable($aWhere["process"])) {
                     $bProcess = $this->callRunneable($aWhere["process"]);
                 } else {
                     if ($this->oForm->isFalseVal($aWhere["process"])) {
                         $bProcess = FALSE;
                     }
                 }
             }
             if ($bProcess) {
                 switch ($sType) {
                     case "WHERE":
                         if (($mProcess = $this->oForm->defaultTrue("/process", $aWhere)) !== FALSE) {
                             if (tx_ameosformidable::isRunneable($mProcess)) {
                                 $mProcess = $this->callRunneable($mProcess);
                             }
                         }
                         if ($mProcess === TRUE) {
                             if (array_key_exists("value", $aWhere)) {
                                 $mValue = $aWhere["value"];
                             } else {
                                 $mValue = "";
                             }
                             if (tx_ameosformidable::isRunneable($mValue)) {
                                 $mValue = $this->callRunneable($mValue);
                             }
                             if ($mValue == "") {
                                 $mValue = "''";
                             }
                             if (tx_ameosformidable::isRunneable($aWhere["comparison"])) {
                                 $aWhere["comparison"] = $this->callRunneable($aWhere["comparison"]);
                             }
                             $sComparison = strtoupper(trim($aWhere["comparison"]));
                             if ($bClauses && ($mLogic = $this->oForm->_navConf("/logic", $aWhere)) !== FALSE) {
                                 if (tx_ameosformidable::isRunneable($mLogic)) {
                                     $mLogic = $this->callRunneable($mLogic);
                                 }
                                 $aClauses[] = in_array(trim(strtoupper($mLogic)), array("AND", "OR")) ? trim(strtoupper($mLogic)) : "AND";
                             }
                             $aClauses[] = " " . $sPrefix . $aWhere["term"] . " " . $sComparison . ($sComparison == "IN" || $sComparison == "NOT IN" ? " (" : " '") . $mValue . ($sComparison == "IN" || $sComparison == "NOT IN" ? ") " : "'");
                             $bClauses = TRUE;
                             break;
                         }
                     case "BEGINBRACE":
                         $aClauses[] = "(";
                         break;
                     case "ENDBRACE":
                         $aClauses[] = ")";
                         break;
                     case "LOGIC":
                         if ($bClauses) {
                             if (is_array($aWhere) && array_key_exists("value", $aWhere)) {
                                 $mValue = $aWhere["value"];
                             } else {
                                 $mValue = $aWhere;
                             }
                             if (tx_ameosformidable::isRunneable($mValue)) {
                                 $mValue = $this->callRunneable($mValue);
                             }
                             $aClauses[] = in_array(trim(strtoupper($mValue)), array("AND", "OR")) ? trim(strtoupper($mValue)) : "";
                         }
                         break;
                 }
             }
         }
         $sTempWhere = implode(" ", $aClauses);
     }
     if ($bClauses && trim($sTempWhere) != "") {
         return " AND (" . $sTempWhere . ")";
     }
     return "";
 }
Example #21
0
 function _renderReadOnly()
 {
     $sValue = $this->getValue();
     if ($this->isTrue("/typolink")) {
         $sUrl = $this->oForm->cObj->typolink_URL(array("parameter" => $sValue, "additionalParams" => ""));
     } elseif (($iPageId = $this->_navConf("pageid")) !== FALSE || ($iPageId = $this->_navConf("pid")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($iPageId)) {
             $iPageId = $this->callRunneable($iPageId);
         }
         $sUrl = $this->oForm->cObj->typolink_URL(array("parameter" => $iPageId, "additionalParams" => ""));
     } else {
         $sUrl = $this->_navConf("/href");
         if ($sUrl === FALSE) {
             $sUrl = $this->_navConf("/url");
         }
         if (tx_ameosformidable::isRunneable($sUrl)) {
             $sUrl = $this->callRunneable($sUrl);
         }
         if (!$sUrl) {
             $sValue = trim($sValue);
             $aParsedURL = @parse_url($sValue);
             if (t3lib_div::inList('ftp,ftps,http,https,gopher,telnet', $aParsedURL['scheme'])) {
                 $sUrl = $sValue;
             } else {
                 $sUrl = FALSE;
             }
         }
     }
     if (($sAnchor = $this->_navConf("/anchor")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($sAnchor)) {
             $sAnchor = $this->callRunneable($sAnchor);
         }
         if (is_string($sAnchor) && $sAnchor !== "") {
             $sAnchor = str_replace("#", "", $sAnchor);
         } else {
             $sAnchor = "";
         }
         if ($sAnchor !== "") {
             if ($sUrl === FALSE) {
                 $sUrl = t3lib_div::getIndpEnv("REQUEST_URI");
             }
             if (array_key_exists($sAnchor, $this->oForm->aORenderlets)) {
                 $sAnchor = $this->oForm->aORenderlets[$sAnchor]->_getElementHtmlId();
             }
             $sAnchor = "#" . $sAnchor;
         }
     }
     if ($sUrl !== FALSE) {
         if ($sAnchor !== FALSE) {
             $sHref = $sUrl . $sAnchor;
         } else {
             $sHref = $sUrl;
         }
     } else {
         $sHref = FALSE;
     }
     $aHtmlBag = array("url" => $sUrl, "href" => $sHref, "anchor" => $sAnchor, "tag." => array("begin" => "", "innerhtml" => "", "end" => ""));
     if (!$this->oForm->isTrue("/urlonly", $this->aElement)) {
         if ($this->hasChilds()) {
             $aChilds = $this->renderChildsBag();
             $sCaption = $this->renderChildsCompiled($aChilds);
         } else {
             if (!$this->_emptyFormValue($sValue)) {
                 $sCaption = $sValue;
             } else {
                 $sCaption = $sHref;
             }
             if (($sLabel = $this->getLabel()) !== "") {
                 $sCaption = $sLabel;
             } else {
                 $aItems = $this->_getItems();
                 if (count($aItems) > 0) {
                     reset($aItems);
                     while (list($itemindex, $aItem) = each($aItems)) {
                         if ($aItem["value"] == $value) {
                             $sCaption = $aItem["caption"];
                         }
                     }
                 }
             }
         }
         if ($sCaption === FALSE) {
             $sCaption = "";
         }
         $aHtmlBag["caption"] = $sCaption;
         if ($sHref !== FALSE) {
             $aHtmlBag["tag."]["begin"] = "<a " . ($sHref != "" ? "href=\"" . $sHref . "\"" : "") . " id=\"" . $this->_getElementHtmlId() . "\"" . $this->_getAddInputParams() . ">";
             $aHtmlBag["tag."]["innerhtml"] = $sCaption;
             $aHtmlBag["tag."]["end"] = "</a>";
         } else {
             $aHtmlBag["tag."]["begin"] = "<span id=\"" . $this->_getElementHtmlId() . "\" " . $this->_getAddInputParams() . ">";
             $aHtmlBag["tag."]["innerhtml"] = $sCaption;
             $aHtmlBag["tag."]["end"] = "</span>";
         }
         $sCompiled = $aHtmlBag["tag."]["begin"] . $aHtmlBag["tag."]["innerhtml"] . $aHtmlBag["tag."]["end"];
         $aHtmlBag["wrap"] = $aHtmlBag["tag."]["begin"] . "|" . $aHtmlBag["tag."]["end"];
     } else {
         $sCompiled = $sHref;
     }
     $aHtmlBag["__compiled"] = $sCompiled;
     return $aHtmlBag;
 }
Example #22
0
 /**
  * Shows a modalbox containing a form for editing an existing target group
  * record.
  *
  * @param tx_ameosformidable $formidable the FORMidable object
  * @param int $targetGroupUid
  *        the UID of the target group to edit, must be > 0
  *
  * @return array calls to be executed on the client
  */
 public static function showEditTargetGroupModalBox(tx_ameosformidable $formidable, $targetGroupUid)
 {
     if ($targetGroupUid <= 0) {
         return $formidable->majixExecJs('alert("$targetGroupUid must be >= 0.");');
     }
     /** @var tx_seminars_Mapper_TargetGroup $targetGroupMapper */
     $targetGroupMapper = tx_oelib_MapperRegistry::get('tx_seminars_Mapper_TargetGroup');
     try {
         /** @var tx_seminars_Model_TargetGroup $targetGroup */
         $targetGroup = $targetGroupMapper->find((int) $targetGroupUid);
     } catch (tx_oelib_Exception_NotFound $exception) {
         return $formidable->majixExecJs('alert("A target group with the given UID does not exist.");');
     }
     $frontEndUser = self::getLoggedInUser();
     if ($targetGroup->getOwner() !== $frontEndUser) {
         return $formidable->majixExecJs('alert("You are not allowed to edit this target group.");');
     }
     $minimumAge = $targetGroup->getMinimumAge() > 0 ? $targetGroup->getMinimumAge() : '';
     $maximumAge = $targetGroup->getMaximumAge() > 0 ? $targetGroup->getMaximumAge() : '';
     $fields = array('uid' => $targetGroup->getUid(), 'title' => $targetGroup->getTitle(), 'minimum_age' => $minimumAge, 'maximum_age' => $maximumAge);
     foreach ($fields as $key => $value) {
         $formidable->aORenderlets['editTargetGroup_' . $key]->setValue($value);
     }
     $formidable->oRenderer->_setDisplayLabels(TRUE);
     $result = $formidable->aORenderlets['editTargetGroupModalBox']->majixShowBox();
     $formidable->oRenderer->_setDisplayLabels(FALSE);
     return $result;
 }
 function &_fetchData($aConfig = array())
 {
     if ($this->defaultFalse('/keepalllistidinsession')) {
         $aListUidConfig = array('page' => 0, 'sortcolumn' => $aConfig['sortcolumn'], 'sortdirection' => $aConfig['sortdirection']);
         $aRecords = $this->oDataSource->_fetchData($aListUidConfig, $this->_getFilters());
         if (($mCol = $this->_navConf('/columnforlist')) !== FALSE) {
             if (tx_ameosformidable::isRunneable($mCol)) {
                 $mCol = $this->oForm->callRunneable($mCol);
             }
         } else {
             $mCol = 'uid';
         }
         foreach ($aRecords['results'] as $aRecord) {
             if (!empty($aRecord[$mCol])) {
                 $aList[] = $aRecord[$mCol];
             }
         }
         $aData =& $GLOBALS["_SESSION"]["ameos_formidable"]["applicationdata"]["rdt_lister"][$this->getSearchHash()][$this->getAbsName()]["infos"];
         $aData["list"] = $aList;
     }
     $aResults = $this->processAfterSearch($this->oDataSource->_fetchData($aConfig, $this->_getFilters()));
     if ($this->defaultFalse("/keepresultsinsession") === TRUE) {
         $this->storeResultsInSession($aResults);
     }
     reset($aResults);
     return $aResults;
 }
Example #24
0
 function validate($oRdt)
 {
     $sAbsName = $oRdt->getAbsName();
     $sFileName = $oRdt->getValue();
     $bError = FALSE;
     $this->oFileFunc = t3lib_div::makeInstance("t3lib_basicFileFunctions");
     if ($oRdt->_getType() === "FILE") {
         // renderlet:FILE
         $sFileName = strtolower($this->oFileFunc->cleanFileName($sFileName));
     } elseif ($oRdt->_getType() === "UPLOAD") {
         // managing multiple, if set
         if ($sFileName !== "") {
             if ($oRdt->isMultiple()) {
                 $aFileList = t3lib_div::trimExplode(",", $sFileName);
                 $sFileName = array_pop($aFileList);
                 // last one, and remove from list; will be added later if valid
             }
         }
     }
     if ($sFileName === "") {
         // never evaluate if value is empty
         // as this is left to STANDARD:required
         return "";
     }
     $aKeys = array_keys($this->_navConf("/"));
     reset($aKeys);
     while (!$oRdt->hasError() && (list(, $sKey) = each($aKeys))) {
         /***********************************************************************
          *
          *	/extension
          *
          ***********************************************************************/
         if ($sKey[0] === "e" && t3lib_div::isFirstPartOfStr($sKey, "extension")) {
             $sFileExts = $this->_navConf("/" . $sKey . "/value");
             if (tx_ameosformidable::isRunneable($sFileExts)) {
                 $sFileExts = $this->callRunneable($sFileExts);
             }
             $aExtensions = t3lib_div::trimExplode(",", $sFileExts);
             if (!$this->_checkFileExt($sFileName, $aExtensions, $sAbsName)) {
                 $this->oForm->_declareValidationError($sAbsName, "FILE:extension", $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message")), $sFileName);
                 $bError = TRUE;
                 break;
             }
         }
         /***********************************************************************
          *
          *	/filesize
          *
          ***********************************************************************/
         if ($sKey[0] === "f" && t3lib_div::isFirstPartOfStr($sKey, "filesize") && t3lib_div::isFirstPartOfStr($sKey, "filesizekb") && t3lib_div::isFirstPartOfStr($sKey, "filesizemb")) {
             $mSize = $this->_navConf("/" . $sKey . "/value");
             if (tx_ameosformidable::isRunneable($mSize)) {
                 $mSize = $this->callRunneable($mSize);
             }
             if (!$this->_checkFileSize($sFileName, $mSize, $sAbsName)) {
                 $this->oForm->_declareValidationError($sAbsName, "FILE:filesize", $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message")), $sFileName);
                 $bError = TRUE;
                 break;
             }
         }
         /***********************************************************************
          *
          *	/filesizekb
          *
          ***********************************************************************/
         if ($sKey[0] === "f" && t3lib_div::isFirstPartOfStr($sKey, "filesizekb")) {
             $mSize = $this->_navConf("/" . $sKey . "/value");
             if (tx_ameosformidable::isRunneable($mSize)) {
                 $mSize = $this->callRunneable($mSize);
             }
             if (!$this->_checkFileSizeKb($sFileName, $mSize, $sAbsName)) {
                 $this->oForm->_declareValidationError($sAbsName, "FILE:filesizekb", $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message")), $sFileName);
                 $bError = TRUE;
                 break;
             }
         }
         /***********************************************************************
          *
          *	/filesizemb
          *
          ***********************************************************************/
         if ($sKey[0] === "f" && t3lib_div::isFirstPartOfStr($sKey, "filesizemb")) {
             $mSize = $this->_navConf("/" . $sKey . "/value");
             if (tx_ameosformidable::isRunneable($mSize)) {
                 $mSize = $this->callRunneable($mSize);
             }
             if (!$this->_checkFileSizeMb($sFileName, $mSize, $sAbsName)) {
                 $this->oForm->_declareValidationError($sAbsName, "FILE:filesizemb", $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message")), $sFileName);
                 $bError = TRUE;
                 break;
             }
         }
     }
     if ($bError === TRUE && $oRdt->_getType() === "UPLOAD") {
         if ($oRdt->isMultiple()) {
             // current filenamehas been remove from aFileList by previous array_pop
             $oRdt->setValue(implode(", ", $aFileList));
         } else {
             $oRdt->setValue("");
         }
     }
 }
 function method_stripSomeTags($mData, $aParams)
 {
     if (!array_key_exists(1, $aParams)) {
         // $bKeepInnerHtml
         $aParams[1] = FALSE;
     }
     if (!array_key_exists(2, $aParams)) {
         // $sReplaceEndTagBy
         $aParams[2] = FALSE;
     }
     return tx_ameosformidable::div_stripSomeTags(tx_ameosformidable::templateDataAsString($mData), $aParams[0], $aParams[1], $aParams[2]);
 }
 function validate(&$oRdt)
 {
     $sAbsName = $oRdt->getAbsName();
     $mValue = $oRdt->getValue();
     $aKeys = array_keys($this->_navConf("/"));
     reset($aKeys);
     while (!$oRdt->hasError() && (list(, $sKey) = each($aKeys))) {
         /***********************************************************************
          *
          *	/required
          *
          ***********************************************************************/
         if ($sKey[0] === "r" && t3lib_div::isFirstPartOfStr($sKey, "required")) {
             if ($this->_isEmpty($oRdt, $mValue)) {
                 if (($mMessage = $this->_navConf("/" . $sKey . "/message")) !== FALSE && tx_ameosformidable::isRunneable($mMessage)) {
                     $mMessage = $oRdt->callRunneable($mMessage);
                 }
                 $this->oForm->_declareValidationError($sAbsName, "STANDARD:required", $this->oForm->_getLLLabel($mMessage));
                 break;
             }
         }
         /***********************************************************************
          *
          *	/authentified
          *
          ***********************************************************************/
         if ($sKey[0] === "a" && t3lib_div::isFirstPartOfStr($sKey, "authentified")) {
             if (!$this->_isAuthentified()) {
                 $message = $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message/"));
                 $this->oForm->_declareValidationError($sAbsName, "STANDARD:authentified", $message);
                 break;
             }
         }
         /***********************************************************************
          *
          *	/maxsize
          *
          ***********************************************************************/
         if ($sKey[0] === "m" && t3lib_div::isFirstPartOfStr($sKey, "maxsize")) {
             $iMaxSize = intval($this->_navConf("/" . $sKey . "/value/"));
             if ($this->_isTooLong($mValue, $iMaxSize)) {
                 $message = $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message/"));
                 $this->oForm->_declareValidationError($sAbsName, "STANDARD:maxsize", $message, $mValue);
                 break;
             }
         }
         /***********************************************************************
          *
          *	/minsize
          *
          ***********************************************************************/
         if ($sKey[0] === "m" && t3lib_div::isFirstPartOfStr($sKey, "minsize")) {
             $iMinSize = intval($this->_navConf("/" . $sKey . "/value/"));
             if ($this->_isTooSmall($mValue, $iMinSize)) {
                 $message = $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message/"));
                 $this->oForm->_declareValidationError($sAbsName, "STANDARD:minsize", $message, $mValue);
                 break;
             }
         }
         /***********************************************************************
          *
          *	/size
          *
          ***********************************************************************/
         if ($sKey[0] === "s" && t3lib_div::isFirstPartOfStr($sKey, "size")) {
             $iSize = intval($this->_navConf("/" . $sKey . "/value/"));
             if (!$this->_sizeIs($mValue, $iSize)) {
                 $message = $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message/"));
                 $this->oForm->_declareValidationError($sAbsName, "STANDARD:size", $message, $mValue);
                 break;
             }
         }
         /***********************************************************************
          *
          *	/sameas
          *
          ***********************************************************************/
         if ($sKey[0] === "s" && t3lib_div::isFirstPartOfStr($sKey, "sameas")) {
             $sameas = trim($this->_navConf("/" . $sKey . "/value/"));
             if (array_key_exists($sameas, $this->oForm->aORenderlets)) {
                 $samevalue = $this->oForm->aORenderlets[$sameas]->getValue();
                 if (!$this->_isSameAs($mValue, $samevalue)) {
                     $message = $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message/"));
                     $this->oForm->_declareValidationError($sAbsName, "STANDARD:sameas", $message, $samevalue);
                     break;
                 }
             }
         }
         /***********************************************************************
          *
          *	/email
          *
          ***********************************************************************/
         if ($sKey[0] === "e" && t3lib_div::isFirstPartOfStr($sKey, "email")) {
             if (!$this->_isEmail($mValue)) {
                 $message = $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message/"));
                 $this->oForm->_declareValidationError($sAbsName, "STANDARD:email", $message, $mValue);
                 break;
             }
         }
         /***********************************************************************
          *
          *	/userobj
          *	@deprecated; use custom instead
          *
          ***********************************************************************/
         if ($sKey[0] === "u" && t3lib_div::isFirstPartOfStr($sKey, "userobj")) {
             $this->oForm->mayday("[" . $oRdt->getName() . "] <b>/validator:STANDARD/userobj is deprecated.</b> Use /validator:STANDARD/custom instead.");
         }
         /***********************************************************************
          *
          *	/unique
          *
          ***********************************************************************/
         if ($sKey[0] === "u" && t3lib_div::isFirstPartOfStr($sKey, "unique")) {
             // field value has to be unique in the database
             // checking this
             if (!$this->_isUnique($oRdt, $mValue)) {
                 $this->oForm->_declareValidationError($sAbsName, "STANDARD:unique", $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message/")), $mValue);
                 break;
             }
         }
         /***********************************************************************
          *
          *	/custom
          *
          ***********************************************************************/
         if ($sKey[0] === "c" && t3lib_div::isFirstPartOfStr($sKey, "custom")) {
             $mCustom = $this->_navconf("/" . $sKey);
             if (tx_ameosformidable::isRunneable($mCustom)) {
                 if ($this->oForm->isUserObj($mCustom)) {
                     $mResult = $this->oForm->_callUserObj($mCustom, array("value" => $mValue));
                 } else {
                     $mResult = $this->oForm->callRunneable($mCustom, $mValue);
                 }
                 if ($mResult !== TRUE) {
                     if (is_string($mResult)) {
                         $message = $this->oForm->_getLLLabel($mResult);
                     } else {
                         $message = $this->oForm->_getLLLabel($this->_navConf("/" . $sKey . "/message/"));
                     }
                     $this->oForm->_declareValidationError($sAbsName, "STANDARD:custom", $message, $mValue);
                     break;
                 }
             }
         }
     }
 }
 function validateByPath($sPath)
 {
     if (!$this->hasError()) {
         $aConf = $this->_navConf($sPath);
         if (is_array($aConf) && !empty($aConf)) {
             $sAbsName = $this->getAbsName();
             while (!$this->hasError() && (list($sKey, $aValidator) = each($aConf))) {
                 if ($sKey[0] === "v" && $sKey[1] === "a" && t3lib_div::isFirstPartOfStr($sKey, "validator") && !t3lib_div::isFirstPartOfStr($sKey, "validators")) {
                     // the conf section exists
                     // call validator
                     $oValidator = $this->oForm->_makeValidator($aValidator);
                     if ($oValidator->_matchConditions()) {
                         $bHasToValidate = TRUE;
                         $aValidMap = $this->oForm->_navConf($this->oForm->sXpathToControl . "factorize/switchvalidation");
                         if (tx_ameosformidable::isRunneable($aValidMap)) {
                             $aValidMap = $this->callRunneable($aValidMap);
                         }
                         if (is_array($aValidMap) && array_key_exists($sAbsName, $aValidMap)) {
                             $bHasToValidate = $aValidMap[$sAbsName];
                         }
                         if ($bHasToValidate === TRUE) {
                             $oValidator->validate($this);
                         }
                     }
                 }
             }
         }
     }
 }
 function wrapErrorMessage($sMessage)
 {
     if ($this->isTrue("/template/errortagcompilednowrap")) {
         return $sMessage;
     }
     if (($sErrWrap = $this->_navConf("/template/errortagwrap")) !== FALSE) {
         if (tx_ameosformidable::isRunneable($sErrWrap)) {
             $sErrWrap = $this->callRunneable($sErrWrap);
         }
         $sErrWrap = $this->oForm->_substLLLInHtml($sErrWrap);
     } else {
         $sErrWrap = "<span class='errors'>|</span>";
     }
     return str_replace("|", $sMessage, $sErrWrap);
 }
 function &_getRowsSubpart($sTemplate)
 {
     $aRowsTmpl = array();
     if (($sAltRows = $this->_navConf("/template/alternaterows")) !== FALSE && tx_ameosformidable::isRunneable($sAltRows)) {
         $sAltList = $this->callRunneable($sAltRows);
     } elseif (($sAltList = $this->_navConf("/template/alternaterows")) === FALSE) {
         $this->oForm->mayday("RENDERLET TICKER <b>" . $this->_getName() . "</b> requires /template/alternaterows to be properly set. Please check your XML configuration");
     }
     $aAltList = t3lib_div::trimExplode(",", $sAltList);
     if (sizeof($aAltList) > 0) {
         $sRowsPart = t3lib_parsehtml::getSubpart($sTemplate, "###ROWS###");
         reset($aAltList);
         while (list(, $sAltSubpart) = each($aAltList)) {
             $aRowsTmpl[] = t3lib_parsehtml::getSubpart($sRowsPart, $sAltSubpart);
         }
     }
     return $aRowsTmpl;
 }
Example #30
0
 function _render()
 {
     $sHtml = tx_ameosformidable::isRunneable($this->aElement["html"]) ? $this->callRunneable($this->aElement["html"]) : $this->_navConf("/html");
     $sHtml = $this->oForm->_substLLLInHtml($sHtml);
     $sMode = $this->_navConf("/mode");
     if ($sMode === FALSE) {
         $sMode = "div";
     } else {
         $sMode = strtolower(trim($sMode));
         if ($sMode === "") {
             $sMode = "div";
         } elseif ($sMode === "none" || $sMode === "inline") {
             $sMode = "inline";
         }
     }
     if ($this->hasData()) {
         $sValue = $this->getValue();
         if (!$this->_emptyFormValue($sValue) && $this->hasData() && !$this->hasValue()) {
             $sHtml = $this->getValueForHtml($sValue);
         }
         $sName = $this->_getElementHtmlName();
         $sId = $this->_getElementHtmlId() . "_value";
         $sHidden = "<input type=\"hidden\" name=\"" . $sName . "\" id=\"" . $sId . "\" value=\"" . $this->getValueForHtml($sValue) . "\" />";
     } elseif ($this->isDataBridge()) {
         $sDBridgeName = $this->_getElementHtmlName() . "[databridge]";
         $sDBridgeId = $this->_getElementHtmlId() . "_databridge";
         $sSignature = $this->dbridge_getCurrentDsetSignature();
         $sHidden = "<input type=\"hidden\" name=\"" . $sDBridgeName . "\" id=\"" . $sDBridgeId . "\" value=\"" . htmlspecialchars($sSignature) . "\" />";
         #$sHidden .= "<input type=\"hidden\" name=\"" . $this->oForm->formid . "[_databridge][" . base64_encode($this->_getElementHtmlIdWithoutFormId()) . "]\" value=\"" . base64_encode($this->oDataSource->getName()) . "\" />";
         #debug($sHidden2, "hidden2");
     }
     if ($sMode !== "inline") {
         $sBegin = "<" . $sMode . " id='" . $this->_getElementHtmlId() . "' " . $this->_getAddInputParams() . ">";
         $sEnd = "</" . $sMode . ">" . $sHidden;
     } else {
         $sBegin = "<!--BEGIN:BOX:inline:" . $this->_getElementHtmlId() . "-->";
         $sEnd = "<!--END:BOX:inline:" . $this->_getElementHtmlId() . "-->";
     }
     $aChilds = $this->renderChildsBag();
     $sCompiledChilds = '';
     if (!empty($aChilds)) {
         $sCompiledChilds = $this->renderChildsCompiled($aChilds);
     }
     // allowed because of $bCustomIncludeScript = TRUE
     $this->includeScripts(array("hasdata" => $this->hasData()));
     if (($mDraggable = $this->_navConf("/draggable")) !== FALSE) {
         $aConf = array();
         if (is_array($mDraggable)) {
             if ($this->defaultTrue("/draggable/use") === TRUE) {
                 $bDraggable = TRUE;
                 $aConf["revert"] = $this->defaultFalse("/draggable/revert");
                 if (($sHandle = $this->_navConf("/draggable/handle")) !== FALSE) {
                     $aConf["handle"] = $this->oForm->aORenderlets[$sHandle]->_getElementHtmlId();
                 }
                 if (($sConstraint = $this->_navConf("/draggable/constraint")) !== FALSE) {
                     $aConf["constraint"] = strtolower($sConstraint);
                 }
             }
         } else {
             $bDraggable = TRUE;
         }
         if ($bDraggable === TRUE) {
             $sHtmlId = $this->_getElementHtmlId();
             $sJson = $this->oForm->array2json($aConf);
             /*
             				$sScript = '
             new Draggable("' . $sHtmlId . '", ' . $sJson . ');
             ';
             */
             $sScript = 'Formidable.draggable("#' . $sHtmlId . '", ' . $sJson . ');';
             $this->oForm->attachInitTask($sScript);
         }
     }
     if (($mDroppable = $this->_navConf("/droppable")) !== FALSE) {
         $aConf = array();
         if (is_array($mDroppable)) {
             if ($this->defaultTrue("/droppable/use") === TRUE) {
                 $bDroppable = TRUE;
                 if (($sAccept = $this->_navConf("/droppable/accept")) !== FALSE) {
                     //$aConf["accept"] = t3lib_div::trimExplode(",", $sAccept);
                     $aConf["accept"] = $sAccept;
                 }
                 if (($sContainment = $this->_navConf("/droppable/containment")) !== FALSE) {
                     $aConf["containment"] = t3lib_div::trimExplode($sContainment);
                     reset($aConf["containment"]);
                     while (list($iKey, ) = each($aConf["containment"])) {
                         $aConf["containment"][$iKey] = $this->oForm->aORenderlets[$aConf["containment"][$iKey]]->_getElementHtmlId();
                     }
                 }
                 if (($sHoverClass = $this->_navConf("/droppable/hoverclass")) !== FALSE) {
                     $aConf["hoverclass"] = $sHoverClass;
                 }
                 if (($sOverlap = $this->_navConf("/droppable/overlap")) !== FALSE) {
                     $aConf["overlap"] = $sOverlap;
                 }
                 if (($bGreedy = $this->defaultFalse("/droppable/greedy")) !== FALSE) {
                     $aConf["greedy"] = $bGreedy;
                 }
             }
         } else {
             $bDroppable = TRUE;
         }
         if ($bDroppable === TRUE) {
             $aTemp = array();
             $sHtmlId = $this->_getElementHtmlId();
             if (array_key_exists("ondragdrop", $this->aCustomEvents)) {
                 $sJs = implode("\n", $this->aCustomEvents["ondragdrop"]);
                 $sRandKey = md5(rand());
                 $aTemp["###" . $sRandKey . "###"] = "function() {" . $sJs . "}";
                 $aConf["onDrop"] = "###" . $sRandKey . "###";
             }
             if (array_key_exists("ondraghover", $this->aCustomEvents)) {
                 $sJs = implode("\n", $this->aCustomEvents["ondraghover"]);
                 $sRandKey = md5(rand());
                 $aTemp["###" . $sRandKey . "###"] = "function() {" . $sJs . "}";
                 $aConf["onHover"] = "###" . $sRandKey . "###";
             }
             $sJson = $this->oForm->array2json($aConf);
             reset($aTemp);
             while (list($sKey, ) = each($aTemp)) {
                 $sJson = str_replace('"' . $sKey . '"', $aTemp[$sKey], $sJson);
             }
             /*
             				$sScript = '
             Droppables.add("' . $sHtmlId . '", ' . $sJson . ');
             ';
             */
             $sScript = 'Formidable.droppable("#' . $sHtmlId . '", ' . $sJson . ');';
             $this->oForm->attachInitTask($sScript);
         }
     }
     //debug($this->aCustomEvents);
     $aHtmlBag = array("__compiled" => $this->_displayLabel($sLabel) . $sBegin . $sHtml . $sCompiledChilds . $sEnd, "html" => $sHtml, "box." => array("begin" => $sBegin, "end" => $sEnd, "mode" => $sMode), "childs" => $aChilds);
     return $aHtmlBag;
 }