function testCreateMetaTemplateFigure()
 {
     $mt = createMetaTemplate("name", "description");
     $this->assertDBCount(1);
     createMetaTemplateFigure($mt, "test", 1, 1);
     createMetaTemplateFigure($mt, "test", 2, 1);
     createMetaTemplateFigure($mt, "test", 3, 1);
     $this->assertDBCount(4);
     deleteMetaTemplate($mt);
     $this->assertDBCount(0);
 }
Exemple #2
0
/**
 * Import XML-Code and create a Meta-Template
 * @param string XML-Code
 * @return integer new id
 */
function XmlImportMetaTemplate($xmlString)
{
    global $db;
    $xmlOptions = array(XML_OPTION_CASE_FOLDING => TRUE, XML_OPTION_SKIP_WHITE => TRUE);
    $xml =& new XPath(FALSE, $xmlOptions);
    $xml->importFromString($xmlString);
    $id = $xml->getAttributes('/NX:METATEMPLATE[1]', 'ID');
    $newId = translateXmlGUID($id);
    createMetaTemplate(urldecode($xml->getAttributes('/NX:METATEMPLATE[1]', 'NAME')), urldecode($xml->getAttributes('/NX:METATEMPLATE[1]', 'DESCRIPTION')), $newId);
    if ($xml->hasChildNodes('/NX:METATEMPLATE[1]')) {
        $i = 1;
        while ($xml->getNode("/NX:METATEMPLATE[1]/NX:METATEMPLATEITEM[{$i}]")) {
            createMetaTemplateFigure($newId, urldecode($xml->getAttributes("/NX:METATEMPLATE[1]/NX:METATEMPLATEITEM[{$i}]", "NAME")), $xml->getAttributes("/NX:METATEMPLATE[1]/NX:METATEMPLATEITEM[{$i}]", "POSITION"), $xml->getAttributes("/NX:METATEMPLATE[1]/NX:METATEMPLATEITEM[{$i}]", "TYPE"));
            $i++;
        }
    }
    return $newId;
}