コード例 #1
0
ファイル: Type.php プロジェクト: ElBiniou/superbok
 public function purge()
 {
     $deletedChildren = $this->deleteChildren();
     $typeIds = array();
     foreach ($deletedChildren as $child) {
         $typeIds[] = $this->escape($child->getId());
     }
     $typeIds[] = $this->escape($this->getId());
     $query = "\n            SELECT id FROM " . Tag::getTableName() . " tag\n            WHERE type_id IN (" . implode($typeIds) . ")\n        ";
     $rows = $this->queryAndFetch($query);
     $tagsId = array();
     foreach ($rows as $values) {
         $tagsId[] = $this->escape($values['id']);
     }
     $query = "\n            SELECT id FROM " . Tag::getTableName() . " tag\n            WHERE tag.mastertag_id IN (" . implode(',', $tagsId) . ")\n        ";
     $rows = $this->queryAndFetch($query);
     foreach ($rows as $values) {
         $tagsId[] = $this->escape($values['id']);
     }
     //suppression des tags
     $query = "\n            DELETE tag FROM " . Tag::getTableName() . " tag\n            WHERE\n                tag.mastertag_id IN (" . implode(',', $tagsId) . ")\n                OR tag.id IN (" . implode(',', $tagsId) . ")\n        ";
     $this->query($query);
     //suppression des associations
     $query = "\n            DELETE association FROM " . Association::getTableName() . " association\n            WHERE association.tag_id IN (" . implode(',', $tagsId) . ")\n        ";
     $this->query($query);
     //supression des types
     $query = "\n            DELETE type FROM " . Type::getTableName() . " type\n            WHERE type.id IN (" . implode(',', $typeIds) . ")\n        ";
     $this->query($query);
 }
コード例 #2
0
ファイル: associatetag.php プロジェクト: ElBiniou/superbok
<?php

use PMD\Capital\Configuration\DataSource;
use PMD\Capital\Module\Tag\Model\Tag;
use PMD\Capital\Model\ObjectType;
use PMD\Capital\Module\Tag\Model\Type;
use PMD\Capital\Module\Tag\Model\Association;
use PMD\Capital\Module\Tag\Model\AssociationType;
ini_set('memory_limit', '-1');
$oldModel = DataSource::get('old');
$newModel = DataSource::get('new');
$ezObjectType = new ObjectType($newModel);
$ezObjectType->loadBy('qname', 'ezobject');
$defaultAssociation = new AssociationType($newModel);
$defaultAssociation->loadBy('qname', 'default');
$query = "\n    SELECT DISTINCT\n      tag.keyword,\n      association.object_id\n    FROM eztags_attribute_link association\n    JOIN eztags tag\n      ON tag.id=association.keyword_id\n\n";
$rows = $oldModel->queryAndFetch($query);
$newModel->autocommit(false);
foreach ($rows as $row) {
    $tag = new Tag($newModel);
    $tag->loadBy('caption', $row['keyword']);
    $association = new Association($newModel);
    $association->setValue('tag_id', $tag->getId());
    $association->setValue('object_id', $row['object_id']);
    $association->setObjectType($ezObjectType);
    $association->setType($defaultAssociation);
    $association->insert();
    echo $tag->getValue('caption') . "\t" . $row['object_id'] . "\n";
}
$newModel->commit();
//print_r($rows);
コード例 #3
0
ファイル: Tag.php プロジェクト: ElBiniou/superbok
 public function deleteAssociation()
 {
     //suppression de toutes les associations
     $query = "\n            SELECT * FROM " . Association::getTableName() . " association\n            WHERE tag_id='" . $this->escape($this->getId()) . "'\n        ";
     $rows = $this->queryAndFetch($query);
     foreach ($rows as $values) {
         $association = new Association($this->getSource());
         $association->setValues($values);
         $association->delete();
     }
     return $this;
 }
コード例 #4
0
//selection de toutes les relations pagehub/tag de l'ancien système
$query = "SELECT * FROM eztags";
$rows = $tagDataSource->queryAndFetch($query);
$relatedAssociation = new AssociationType('new');
$relatedAssociation->loadBy('qname', 'related');
$tagType = new ObjectType('new');
$tagType->loadBy('qname', 'tag');
foreach ($rows as $values) {
    $query = "\n    SELECT\n        DISTINCT\n            originTag.id as tagId,\n            originTag.remote_id as pagehubId,\n            originTag.keyword as fromKeyword,\n            destinationTag.id as destinationId,\n            destinationTag.keyword as destinationKeyword\n    FROM eztags originTag\n    JOIN eztags_attribute_link link\n        ON link.object_id=originTag.remote_id\n    JOIN eztags destinationTag\n        ON destinationTag.id=link.keyword_id\n    WHERE originTag.id=" . $values['id'] . "\n    ";
    $relationData = $tagDataSource->queryAndFetch($query);
    if (!empty($relationData)) {
        foreach ($relationData as $values) {
            //récupération du tag d'origine dans la nouvelle bdd
            $fromTag = new Tag('new');
            $fromTag->loadBy('caption', $values['fromKeyword']);
            $relatedTag = new Tag('new');
            $relatedTag->loadBy('caption', $values['destinationKeyword']);
            //récupération pour le related tag
            if ($fromTag->getId() && $relatedTag->getId()) {
                $association = new Association('new');
                $association->setType($relatedAssociation);
                $association->setObjectType($tagType);
                $association->setValue('tag_id', $fromTag->getId());
                $association->setValue('object_id', $relatedTag->getId());
                $association->insert();
                echo $values['tagId'] . "\t" . $values['fromKeyword'] . "\t" . $values['destinationId'] . "\t" . $values['destinationKeyword'] . "\n";
            }
            //echo $value[]"\n"
        }
    }
}
コード例 #5
0
ファイル: installdatabase.php プロジェクト: ElBiniou/superbok
<?php

use PMD\Capital\Configuration\DataSource;
use PMD\Capital\Module\Tag\Model\Tag;
use PMD\Capital\Model\ObjectType;
use PMD\Capital\Module\Tag\Model\Type;
use PMD\Capital\Module\Tag\Model\Association;
use PMD\Capital\Module\Tag\Model\AssociationType;
$tagDataSource = DataSource::get('new');
$tagDataSource->query('DROP TABLE ' . Tag::getTableName() . '');
$tagDataSource->query('DROP TABLE ' . ObjectType::getTableName() . '');
$tagDataSource->query('DROP TABLE ' . Type::getTableName() . '');
$tagDataSource->query('DROP TABLE ' . Association::getTableName() . '');
$tagDataSource->query('DROP TABLE ' . AssociationType::getTableName() . '');
echo "Create pmd_tag table\n";
$query = "\n        CREATE TABLE `" . Tag::getTableName() . "` (\n        `id` INT(32) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `parent_id` INT(32),\n        `mastertag_id` INT(32),\n        `type_id` INT(32) UNSIGNED,\n        `caption` VARCHAR(100) NOT NULL,\n        `leftbound` INT(32) UNSIGNED,\n        `rightbound` INT(32) UNSIGNED,\n        `datecreation` DATETIME,\n        `datemodification` DATETIME,\n        `slug` VARCHAR(100) NOT NULL,\n        `data` TEXT,\n        PRIMARY KEY (`id`),\n        INDEX `pmdtag_parentid` (`parent_id`),\n        INDEX `pmdtag_mastertagid` (`mastertag_id`),\n        INDEX `pmdtag_bounds` (`leftbound`, `rightbound`),\n        INDEX `pmdtag_keyword` (`caption`),\n        INDEX `pmdtag_slug` (`slug`)\n    )\n    COLLATE='utf8_general_ci'\n    ENGINE=InnoDB\n;\n";
$tagDataSource->query($query);
echo "Create pmd_tagtype table\n";
$query = "\n        CREATE TABLE `" . Type::getTableName() . "` (\n        `id` INT(32) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `parent_id` INT(32),\n        `caption` VARCHAR(100) NOT NULL,\n        `qname` VARCHAR(100) NOT NULL,\n        `leftbound` INT(32) UNSIGNED,\n        `rightbound` INT(32) UNSIGNED,\n        `datecreation` DATETIME,\n        `datemodification` DATETIME,\n        `data` TEXT,\n        PRIMARY KEY (`id`),\n        INDEX `pmdtagtype_parentid` (`parent_id`),\n        INDEX `pmdtagtype_qname` (`qname`),\n        INDEX `pmdtagtype_bounds` (`leftbound`, `rightbound`),\n        INDEX `pmdtagtype_caption` (`caption`)\n    )\n    COLLATE='utf8_general_ci'\n    ENGINE=InnoDB\n;\n";
$tagDataSource->query($query);
echo "Create pmd_tagassociation table\n";
$query = "\n        CREATE TABLE `" . Association::getTableName() . "` (\n        `id` INT(32) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `tag_id` INT(32) UNSIGNED NOT NULL,\n        `object_id` INT(32) UNSIGNED NOT NULL,\n        `objecttype_id` INT(32) UNSIGNED NOT NULL,\n        `type_id` INT(32) UNSIGNED NOT NULL,\n        `datecreation` DATETIME,\n        `datemodification` DATETIME,\n        PRIMARY KEY (`id`),\n        INDEX `pmdtagassociation_tagid` (`tag_id`),\n        INDEX `pmdtagassociation_objectid` (`object_id`),\n        INDEX `pmdtagassociation_objecttypeid` (`objecttype_id`)\n    )\n    COLLATE='utf8_general_ci'\n    ENGINE=InnoDB\n;\n";
$tagDataSource->query($query);
echo "Create pmd_objecttype table\n";
$query = "\n        CREATE TABLE `" . ObjectType::getTableName() . "` (\n        `id` INT(32) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `parent_id` INT(32),\n        `qname` VARCHAR(100) NOT NULL,\n        `caption` VARCHAR(100) NOT NULL,\n        `leftbound` INT(32) UNSIGNED,\n        `rightbound` INT(32) UNSIGNED,\n        `datecreation` DATETIME,\n        `datemodification` DATETIME,\n        `data` TEXT,\n        PRIMARY KEY (`id`),\n        INDEX `pmdobjecttype_parentid` (`parent_id`),\n        INDEX `pmdobjecttype_qname` (`qname`),\n        INDEX `pmdobjecttype_caption` (`caption`),\n        INDEX `pmdobjecttype_bounds` (`leftbound`, `rightbound`)\n    )\n    COLLATE='utf8_general_ci'\n    ENGINE=InnoDB\n;\n";
$tagDataSource->query($query);
echo "Create pmd_tagassociationtype table\n";
$query = "\n        CREATE TABLE `" . AssociationType::getTableName() . "` (\n        `id` INT(32) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `qname` VARCHAR(100) NOT NULL,\n        `caption` VARCHAR(100) NOT NULL,\n        `datecreation` DATETIME,\n        `datemodification` DATETIME,\n        PRIMARY KEY (`id`),\n        INDEX `pmdassociationtype_qname` (`qname`),\n        INDEX `pmdassociationtype_caption` (`caption`)\n    )\n    COLLATE='utf8_general_ci'\n    ENGINE=InnoDB\n;\n";
$tagDataSource->query($query);
コード例 #6
0
<?php

use PMD\Capital\Configuration\DataSource;
use PMD\Capital\Module\Tag\Model\Tag;
use PMD\Capital\Model\ObjectType;
use PMD\Capital\Module\Tag\Model\Type;
use PMD\Capital\Module\Tag\Model\Association;
use PMD\Capital\Module\Tag\Model\AssociationType;
$tagDataSource = DataSource::get('old');
$query = "\n    SELECT\n      tag.id as tagId,\n      tag.keyword as caption,\n      tag.remote_id as pagehubId\n    FROM eztags tag\n    JOIN ezcontentobject object\n      ON tag.remote_id=object.id\n\n";
$rows = $tagDataSource->queryAndFetch($query);
//récupération du type d'association pagehub
$associationType = new AssociationType('new');
$associationType->loadBy('qname', 'pagehub');
//récupération du type d'objet ezpublich
$objectType = new ObjectType('new');
$objectType->loadBy('qname', 'ezobject');
foreach ($rows as $values) {
    $tag = new Tag('new');
    $tag->loadBy('caption', $values['caption']);
    $tagValues = $tag->getValues();
    if (!empty($tagValues)) {
        $association = new Association('new');
        $association->setValue('tag_id', $tag->getId());
        $association->setValue('object_id', $values['pagehubId']);
        $association->setObjectType($objectType);
        $association->setType($associationType);
        $association->insert();
        echo $values['caption'] . "\t" . $values['pagehubId'] . "\n";
    }
}