Example #1
0
 public function create($parentId, $caption)
 {
     $tagCategory = new Type($this->getDataSource());
     $tagCategory->setValue('parent_id', $parentId);
     $tagCategory->setValue('caption', $caption);
     $tagCategory->insert();
     $rootCategory = new Type($this->getDataSource());
     $rootCategory->loadBy('qname', 'default');
     $tagCategory->buildTree($rootCategory->getId(), true);
     return $tagCategory->getValues();
 }
Example #2
0
$query = "\n  INSERT INTO " . Type::getTableName() . " (\n    parent_id,\n    qname,\n    caption,\n    datecreation\n  ) VALUES (\n    " . $rootTypeNode->getId() . ",\n    'flag',\n    'Flag',\n    NOW()\n  )\n";
$tagDataSource->query($query);
echo "Create Category tag type\n";
$query = "\n  INSERT INTO " . Type::getTableName() . " (\n    parent_id,\n    qname,\n    caption,\n    datecreation\n  ) VALUES (\n    " . $rootTypeNode->getId() . ",\n    'category',\n    'Catégorie',\n    NOW()\n  )\n";
$tagDataSource->query($query);
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());