Пример #1
0
echo "Create Content tag type\n";
$query = "\n  INSERT INTO " . Type::getTableName() . " (\n    parent_id,\n    qname,\n    caption,\n    datecreation\n  ) VALUES (\n    " . $rootTypeNode->getId() . ",\n    'content',\n    'Contenu',\n    NOW()\n  )\n";
$tagDataSource->query($query);
$tagTypeContent = new Type($tagDataSource);
$tagTypeContent->loadBy('qname', 'content');
$tagTypeContent->setValue('data', '{
    "attributes": {
        "image": {
            "caption": "Image",
            "mandatory": false,
            "type": "image",
            "default": null,
            "enable": true
        }
    },
    "rules": []
}');
$tagTypeContent->update();
$tree = new Type();
$tree->setSource($tagDataSource);
$tree->buildTree();
echo "Create root tag \n";
$contentTagType = new Type($tagDataSource);
$contentTagType->loadBy('qname', 'default');
$tag = new Tag();
$tag->setSource($tagDataSource);
$tag->setValue('type_id', $contentTagType->getId());
$tag->setCaption('Tags');
$tag->insert();
$tagDataSource->commit();
$tag->buildTree();
Пример #2
0
    $tag = new Tag();
    $tag->setSource($newModel);
    $tag->loadById($newId);
    if ($oldTags[$oldId]['main_tag_id']) {
        $oldParentId = $oldTags[$oldId]['main_tag_id'];
    } else {
        $oldParentId = $oldTags[$oldId]['parent_id'];
    }
    $parentTagId = false;
    if (isset($newTagMapping[$oldParentId])) {
        $parentTagId = $newTagMapping[$oldParentId];
    }
    if (!$parentTagId) {
        $parentTagId = $rootTag->getId();
    }
    echo $oldParentId . "\t" . $parentTagId . "\t" . $oldTags[$oldId]['keyword'] . "\n";
    if ($oldTags[$oldId]['main_tag_id']) {
        $oldMasterTagId = $oldTags[$oldId]['main_tag_id'];
        $tag->setMasterTagId($newTagMapping[$oldMasterTagId]);
    }
    $tag->setParentId($parentTagId);
    $tag->update();
}
$startTime = microtime(true);
$tagTree = new Tag();
$tagTree->setSource($newModel);
$tagTree->reset();
$tagTree->buildTree();
$newModel->commit();
$elapsed = microtime(true) - $startTime;
echo "Tag tree building duration : " . $elapsed . "\n";