/** * iterates through string to replace every * {placeholder} with row data * (added by hugh, does the same thing as parseMessageForPlaceHolder in parent * class, but for rows instead of forms) * @param string text to parse * @param array of row data * @param bool add slashes to the replaced data (default = false) set to true in fabrikcalc element */ function parseMessageForRowHolder($msg, &$row, $addslashes = false) { $this->_aRow = $row; if (!strstr($msg, '{')) { return $msg; } $this->_parseAddSlases = $addslashes; $msg = FabrikWorker::_replaceWithUserData($msg); $msg = FabrikWorker::_replaceWithGlobals($msg); $msg = preg_replace("/{}/", "", $msg); $this->_rowIdentifierAdded = false; /* replace {element name} with form data */ // $$$ hugh - testing changing the regex so we don't blow away PHP structures! Added the \s so // we only match non-space chars in {}'s. So unless you have some code like "if (blah) {foo;}", PHP // block level {}'s should remain unmolested. $msg = preg_replace_callback("/{[^}\\s]+}/i", array($this, '_replaceWithRowData'), $msg); return $msg; }
/** * iterates through string to replace every * {placeholder} with posted data * @param string text to parse * @param array data to search for placeholders (default $_REQUEST) * @param bool if no data found for the place holder do we keep the {...} string in the message * @param bool add slashed to the text? * @param object user to use in replaceWithUserData (defaults to logged in user) */ function parseMessageForPlaceHolder($msg, $searchData = null, $keepPlaceholders = true, $addslashes = false, $theirUser = null) { $this->_parseAddSlases = $addslashes; if ($msg == '' || is_array($msg) || strpos($msg, '{') === false) { return $msg; } $msg = str_replace(array('%7B', '%7D'), array('{', '}'), $msg); if (is_object($searchData)) { $searchData = JArrayHelper::fromObject($searchData); } //$post = JRequest::get('post'); //$$$ rob changed to allow request variables to be parsed as well. I have a sneaky feeling this // was set to post for a good reason, but I can't see why now. $post = JRequest::get('request'); $this->_searchData = is_null($searchData) ? $post : array_merge($post, $searchData); $this->_searchData['JUtility::getToken'] = JUtility::getToken(); $msg = FabrikWorker::_replaceWithUserData($msg); if (!is_null($theirUser)) { $msg = FabrikWorker::_replaceWithUserData($msg, $theirUser, 'your'); } $msg = FabrikWorker::_replaceWithGlobals($msg); $msg = preg_replace("/{}/", "", $msg); /* replace {element name} with form data */ $msg = preg_replace_callback("/{[^}\\s]+}/i", array($this, '_replaceWithFormData'), $msg); if (!$keepPlaceholders) { $msg = preg_replace("/{[^}\\s]+}/i", '', $msg); } return $msg; }
/** * iterates through string to replace every * {placeholder} with posted data * @param string text to parse * @param array data to search for placeholders (default $_REQUEST) * @param bool if no data found for the place holder do we keep the {...} string in the message * @param bool add slashed to the text? * @param object user to use in replaceWithUserData (defaults to logged in user) */ function parseMessageForPlaceHolder($msg, $searchData = null, $keepPlaceholders = true, $addslashes = false, $theirUser = null) { $this->_parseAddSlases = $addslashes; if ($msg == '' || is_array($msg) || strpos($msg, '{') === false) { return $msg; } $msg = str_replace(array('%7B', '%7D'), array('{', '}'), $msg); if (is_object($searchData)) { $searchData = JArrayHelper::fromObject($searchData); } //$post = JRequest::get('post'); //$$$ rob changed to allow request variables to be parsed as well. I have a sneaky feeling this // was set to post for a good reason, but I can't see why now. // $$$ hugh - for reasons I don't understand, merging request just doesn't seem to work // in some situations, so I'm adding a replaceRequest call here as a bandaid. // Nope, this won't work, as it'll pick up original request data, instead of processed data // FabrikWorker::replaceRequest($msg); $post = JRequest::get('request'); $this->_searchData = is_null($searchData) ? $post : array_merge($post, $searchData); $this->_searchData['JUtility::getToken'] = JUtility::getToken(); $msg = FabrikWorker::_replaceWithUserData($msg); if (!is_null($theirUser)) { $msg = FabrikWorker::_replaceWithUserData($msg, $theirUser, 'your'); } $msg = FabrikWorker::_replaceWithGlobals($msg); $msg = preg_replace("/{}/", "", $msg); /* replace {element name} with form data */ $msg = preg_replace_callback("/{[^}\\s]+}/i", array($this, '_replaceWithFormData'), $msg); if (!$keepPlaceholders) { $msg = preg_replace("/{[^}\\s]+}/i", '', $msg); } return $msg; }