Ejemplo n.º 1
0
 public function rename($tagId, $caption)
 {
     $tag = new Tag($this->getDataSource());
     $tag->loadById((int) $tagId);
     $tag->setValue('caption', $caption);
     $tag->setValue('slug', slugify($caption));
     $tag->setInheritableAttributesValues(array('attributes' => array('title' => $caption)), true);
     $tag->update();
     return $tag;
 }
Ejemplo n.º 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";