/** * FormHandler::getAsMailBody() * * Returns the values of the form as mail body * * @param string $mask: The mask which should be used for creating the mail body * @return string * @access public * @author Teye Heimans * @since 25/11/2005 */ function getAsMailBody($mask = null) { // TODO // replacement of %field% and of %{fieldname}% $loader = new MaskLoader(); $loader->setMask($mask); // create the search and replace strings $search = array(); $replace = array(); // walk all elements in this form reset($this->_fields); $mail = ''; while (list($name, $fld) = each($this->_fields)) { // only use it in the mail if it has a view value (the fields) if (is_object($fld[1]) && method_exists($fld[1], 'getViewValue') && $name != $this->_name . '_submit') { // search and replace the %field% %value% items $loader->setSearch(array('/%field%/', '/%value%/')); $mail .= $loader->fill(array($name, $fld[1]->getViewValue())); // add the %{fieldname}% seach item to the search string for later... $search[] = '/%' . $name . '%/'; $replace[] = $fld[1]->getViewValue(); } } // add the user added values to the search and replace arrays foreach ($this->_add as $name => $value) { $search[] = '/%' . $name . '%/'; $replace[] = $value; } $loader->setSearch($search); // check if there is still something to fill if (!$loader->isFull()) { $mail .= $loader->fill($replace, -1); } // get possible half filled mask $mail .= $loader->fill(); return $mail; }