$x['label'] = ''; } } // delete labels of empty entries to make mandatory entries optional foreach ($_POST['phone'] as &$x) { if (empty($x['value']) && ($x['label'] == 'mobile' || $x['label'] == 'fax')) { $x['label'] = ''; } } // delete labels of empty entries to make mandatory entries optional foreach ($_POST['other'] as &$x) { if (empty($x['value'])) { $x['label'] = ''; } } $_POST['contact']['notes'] = XSLTUtility::arrayToXMLraw($_POST['contact']['notes'], $h = false); $save = $contact->saveContactFromArray($_POST); break; case 'contact_NoMandatoryEntries': if ($_POST['duplicateContact'] == 1) { unset($contact->contact['id']); foreach ($_POST['address'] as &$x) { unset($x['refid']); } } // delete labels of empty entries to make mandatory entries optional foreach ($_POST['www'] as &$x) { if (empty($x['value'])) { $x['label'] = ''; } }
/** * creates the XSLT generated output */ function createXSLTContact($transformationFile) { $xml = ContactImportExport::xmlExport($this->contact); $x = new XSLTUtility($xml); return $x->transform($transformationFile); }
/** * Array to XML transformation * @param string $xslt if string starts with less-than character XSLT is passed as string **OTHERWISE** filename!! * @param boolean $suppressOuter this RETURN(!) value is set to true by recursion if outer lablel would be incorrect * @param string $outerLabel is used if suppressOuter is true default is '!--' * @return string html-content */ function arrayToXMLraw(&$array, &$suppressOuter, $outerLabel = '!--') { $x = ''; foreach ($array as $k => &$v) { if (is_numeric($k)) { $k = $outerLabel; $suppressOuter = TRUE; } else { $suppressOuter = FALSE; } if (is_array($v)) { $h = XSLTUtility::arrayToXMLraw($v, $suppress, $k); if ($suppress) { $x .= $h; } else { // echo "=$k=$h=$k=\n"; $x .= "<{$k}>{$h}</{$k}>\n"; } } else { $x .= "<{$k}>" . htmlspecialchars($v, ENT_NOQUOTES, 'UTF-8') . "</{$k}>\n"; } } return $x; }