コード例 #1
0
 public function hookInstall()
 {
     $db = get_db();
     $sql = "\n            CREATE TABLE IF NOT EXISTS `{$db->RecordRelationsVocabulary}` (\n                `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n                `name` varchar(100) NOT NULL,\n                `description` text,\n                `namespace_prefix` varchar(100) NOT NULL,\n                `namespace_uri` varchar(200) NOT NULL,\n                `custom` BOOLEAN NOT NULL,\n                PRIMARY KEY (`id`)\n            ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
     $db->query($sql);
     $sql = "\n            CREATE TABLE IF NOT EXISTS `{$db->RecordRelationsProperty}` (\n                `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n                `vocabulary_id` int(10) unsigned NOT NULL,\n                `local_part` varchar(100) NOT NULL,\n                `label` varchar(100) DEFAULT NULL,\n                `description` text,\n                PRIMARY KEY (`id`)\n            ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
     $db->query($sql);
     $sql = "\n            CREATE TABLE IF NOT EXISTS `{$db->RecordRelationsRelation}` (\n            `id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n            `subject_id` INT( 10 ) UNSIGNED NOT NULL ,\n            `property_id` INT( 10 ) UNSIGNED NOT NULL ,\n            `object_id` INT( 10 ) UNSIGNED NOT NULL ,\n            `subject_record_type` TINYTEXT NOT NULL ,\n            `object_record_type` TINYTEXT NOT NULL ,\n            `timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,\n            `user_id` INT( 10 ) UNSIGNED NOT NULL,\n            `public` INT( 1 ) UNSIGNED DEFAULT 1\n            ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;\n        ";
     $db->query($sql);
     $formalVocabularies = (include RECORD_RELATIONS_PLUGIN_DIR . '/formal_vocabularies.php');
     record_relations_install_properties($formalVocabularies);
 }
 /**
  * Install the plugin.
  */
 public function hookInstall()
 {
     $this->_installOptions();
     // Check props I need.
     if (!get_record_relations_property_id(DCTERMS, 'isPartOf')) {
         record_relations_install_properties(array(array('name' => 'Dublin Core', 'description' => 'Dublin Core Terms', 'namespace_uri' => DCTERMS, 'namespace_prefix' => 'dcterms', 'properties' => array(array('local_part' => 'isPartOf', 'label' => 'is part of', 'description' => '')))));
     }
     // Build existing Collection relations.
     $relationTable = $this->_db->getTable('RecordRelationsRelation');
     $props = self::defaultParams();
     $items = $this->_db->getTable('Item')->findAll();
     foreach ($items as $item) {
         $props['subject_id'] = $item->id;
         if (!is_null($item->collection_id) && $item->collection_id != 0) {
             $props['object_id'] = $item->collection_id;
             $relation = new RecordRelationsRelation();
             $relation->setProps($props);
             $relation->save();
         }
     }
 }