diff --git a/ItemRelationsPlugin.php b/ItemRelationsPlugin.php index c0819a3..e8e0590 100644 --- a/ItemRelationsPlugin.php +++ b/ItemRelationsPlugin.php @@ -43,6 +43,7 @@ class ItemRelationsPlugin extends Omeka_Plugin_AbstractPlugin */ protected $_options = array( 'item_relations_public_append_to_items_show' => 1, + 'item_relations_provide_relation_comments' => 0, 'item_relations_relation_format' => 'prefix_local_part' ); @@ -83,11 +84,13 @@ public function hookInstall() `subject_item_id` int(10) unsigned NOT NULL, `property_id` int(10) unsigned NOT NULL, `object_item_id` int(10) unsigned NOT NULL, + `relation_comment` varchar(60) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $db->query($sql); // Install the formal vocabularies and their properties. + self::hookInitialize(); // Make sure that the i18n file is already loaded $formalVocabularies = include 'formal_vocabularies.php'; foreach ($formalVocabularies as $formalVocabulary) { $vocabulary = new ItemRelationsVocabulary; @@ -112,8 +115,8 @@ public function hookInstall() // Install a custom vocabulary. $customVocabulary = new ItemRelationsVocabulary; - $customVocabulary->name = 'Custom'; - $customVocabulary->description = 'Custom vocabulary containing relations defined for this Omeka instance.'; + $customVocabulary->name = __('Custom'); + $customVocabulary->description = __('Custom vocabulary containing relations defined for this Omeka instance.'); $customVocabulary->namespace_prefix = ''; // cannot be NULL $customVocabulary->namespace_uri = null; $customVocabulary->custom = 1; @@ -150,6 +153,7 @@ public function hookUninstall() public static function hookConfigForm() { $publicAppendToItemsShow = get_option('item_relations_public_append_to_items_show'); + $provideRelationComments = get_option('item_relations_provide_relation_comments'); $relationFormat = get_option('item_relations_relation_format'); require dirname(__FILE__) . '/config_form.php'; @@ -162,6 +166,8 @@ public static function hookConfig() { set_option('item_relations_public_append_to_items_show', (int)(boolean) $_POST['item_relations_public_append_to_items_show']); + set_option('item_relations_provide_relation_comments', + (int)(boolean) $_POST['item_relations_provide_relation_comments']); set_option('item_relations_relation_format', $_POST['item_relations_relation_format']); } @@ -218,6 +224,13 @@ public function hookUpgrade($args) $db->query($sql); } } + + if ($oldVersion <= '2.21') { + // Insert relation_comment column + $sql = "ALTER TABLE `{$db->prefix}item_relations_relations` ADD `relation_comment` VARCHAR(60) NOT NULL DEFAULT '' AFTER `object_item_id`"; + $db->query($sql); + } + } /** @@ -304,7 +317,8 @@ public function hookAfterSaveItem($args) self::insertItemRelation( $record, $propertyId, - $post['item_relations_item_relation_object_item_id'][$key] + $post['item_relations_item_relation_object_item_id'][$key], + $post['item_relations_item_relation_relation_comment'][$key] ); } } @@ -402,7 +416,8 @@ public function hookItemsBatchEditCustom($args) self::insertItemRelation( $item, $custom['item_relations_property_id'], - $custom['item_relations_item_relation_object_item_id'] + $custom['item_relations_item_relation_object_item_id'], + $custom['item_relations_item_relation_relation_comment'] ); } @@ -463,6 +478,7 @@ public static function prepareSubjectRelations(Item $item) $subjectRelations[] = array( 'item_relation_id' => $subject->id, 'object_item_id' => $subject->object_item_id, + 'relation_comment' => $subject->relation_comment, 'object_item_title' => self::getItemTitle($item), 'relation_text' => $subject->getPropertyText(), 'relation_description' => $subject->property_description @@ -488,6 +504,7 @@ public static function prepareObjectRelations(Item $item) $objectRelations[] = array( 'item_relation_id' => $object->id, 'subject_item_id' => $object->subject_item_id, + 'relation_comment' => $object->relation_comment, 'subject_item_title' => self::getItemTitle($item), 'relation_text' => $object->getPropertyText(), 'relation_description' => $object->property_description @@ -519,7 +536,7 @@ public static function getItemTitle($item) * @param Item|int $objectItem * @return bool True: success; false: unsuccessful */ - public static function insertItemRelation($subjectItem, $propertyId, $objectItem) + public static function insertItemRelation($subjectItem, $propertyId, $objectItem, $relationComment) { // Only numeric property IDs are valid. if (!is_numeric($propertyId)) { @@ -545,6 +562,7 @@ public static function insertItemRelation($subjectItem, $propertyId, $objectItem $itemRelation->subject_item_id = $subjectItem->id; $itemRelation->property_id = $propertyId; $itemRelation->object_item_id = $objectItem->id; + $itemRelation->relation_comment = ( $relationComment ? $relationComment : ""); $itemRelation->save(); return true; diff --git a/config_form.php b/config_form.php index c849d01..1539461 100644 --- a/config_form.php +++ b/config_form.php @@ -12,6 +12,19 @@ formCheckbox('item_relations_public_append_to_items_show', null, array('checked' => $publicAppendToItemsShow)); ?> +
+
+ formLabel('item_relations_provide_relation_comments', __('Provide comment field for relations')); ?> +
+
+

+ +

+ formCheckbox('item_relations_provide_relation_comments', null, array('checked' => $provideRelationComments)); ?> +
+
formLabel('item_relations_relation_format', __('Relation Format')); ?> @@ -23,6 +36,6 @@ . 'prefer to show. If one is unavailable the other will be used.'); ?>

- formSelect('item_relations_relation_format', $relationFormat, null, array('prefix_local_part' => 'prefix:localPart', 'label' => 'label')); ?> + formSelect('item_relations_relation_format', $relationFormat, null, array('prefix_local_part' => __('prefix:localPart'), 'label' => __('label'))); ?>
diff --git a/formal_vocabularies.php b/formal_vocabularies.php index 2949eec..f171fca 100644 --- a/formal_vocabularies.php +++ b/formal_vocabularies.php @@ -8,598 +8,598 @@ return $formalVocabularies = array( array( 'name' => 'Dublin Core', - 'description' => 'Relations defined by DCMI Metadata Terms: http://dublincore.org/documents/dcmi-terms/', + 'description' => __('Relations defined by DCMI Metadata Terms: http://dublincore.org/documents/dcmi-terms/'), 'namespace_prefix' => 'dcterms', 'namespace_uri' => 'http://purl.org/dc/terms/', 'properties' => array( array( 'local_part' => 'relation', - 'label' => 'Relation', - 'description' => 'A related resource.' + 'label' => __('Relation'), + 'description' => __('A related resource.') ), array( 'local_part' => 'conformsTo', - 'label' => 'Conforms To', - 'description' => 'An established standard to which the described resource conforms.' + 'label' => __('Conforms To'), + 'description' => __('An established standard to which the described resource conforms.') ), array( 'local_part' => 'hasFormat', - 'label' => 'Has Format', - 'description' => 'A related resource that is substantially the same as the pre-existing described resource, but in another format.' + 'label' => __('Has Format'), + 'description' => __('A related resource that is substantially the same as the pre-existing described resource, but in another format.') ), array( 'local_part' => 'hasPart', - 'label' => 'Has Part', - 'description' => 'A related resource that is included either physically or logically in the described resource.' + 'label' => __('Has Part'), + 'description' => __('A related resource that is included either physically or logically in the described resource.') ), array( 'local_part' => 'hasVersion', - 'label' => 'Has Version', - 'description' => 'A related resource that is a version, edition, or adaptation of the described resource.' + 'label' => __('Has Version'), + 'description' => __('A related resource that is a version, edition, or adaptation of the described resource.') ), array( 'local_part' => 'isFormatOf', - 'label' => 'Is Format Of', - 'description' => 'A related resource that is substantially the same as the described resource, but in another format.' + 'label' => __('Is Format Of'), + 'description' => __('A related resource that is substantially the same as the described resource, but in another format.') ), array( 'local_part' => 'isPartOf', - 'label' => 'Is Part Of', - 'description' => 'A related resource in which the described resource is physically or logically included.' + 'label' => __('Is Part Of'), + 'description' => __('A related resource in which the described resource is physically or logically included.') ), array( 'local_part' => 'isReferencedBy', - 'label' => 'Is Referenced By', - 'description' => 'A related resource that references, cites, or otherwise points to the described resource.' + 'label' => __('Is Referenced By'), + 'description' => __('A related resource that references, cites, or otherwise points to the described resource.') ), array( 'local_part' => 'isReplacedBy', - 'label' => 'Is Replaced By', - 'description' => 'A related resource that supplants, displaces, or supersedes the described resource.' + 'label' => __('Is Replaced By'), + 'description' => __('A related resource that supplants, displaces, or supersedes the described resource.') ), array( 'local_part' => 'isRequiredBy', - 'label' => 'Is Required By', - 'description' => 'A related resource that requires the described resource to support its function, delivery, or coherence.' + 'label' => __('Is Required By'), + 'description' => __('A related resource that requires the described resource to support its function, delivery, or coherence.') ), array( 'local_part' => 'isVersionOf', - 'label' => 'Is Version Of', - 'description' => 'A related resource of which the described resource is a version, edition, or adaptation.' + 'label' => __('Is Version Of'), + 'description' => __('A related resource of which the described resource is a version, edition, or adaptation.') ), array( 'local_part' => 'references', - 'label' => 'References', - 'description' => 'A related resource that is referenced, cited, or otherwise pointed to by the described resource.' + 'label' => __('References'), + 'description' => __('A related resource that is referenced, cited, or otherwise pointed to by the described resource.') ), array( 'local_part' => 'replaces', - 'label' => 'Replaces', - 'description' => 'A related resource that is supplanted, displaced, or superseded by the described resource.' + 'label' => __('Replaces'), + 'description' => __('A related resource that is supplanted, displaced, or superseded by the described resource.') ), array( 'local_part' => 'requires', - 'label' => 'Requires', - 'description' => 'A related resource that is required by the described resource to support its function, delivery, or coherence.' + 'label' => __('Requires'), + 'description' => __('A related resource that is required by the described resource to support its function, delivery, or coherence.') ), array( 'local_part' => 'source', - 'label' => 'Source', - 'description' => 'A related resource from which the described resource is derived.' + 'label' => __('Source'), + 'description' => __('A related resource from which the described resource is derived.') ), array( 'local_part' => 'abstract', - 'label' => 'Abstract', - 'description' => 'A summary of the resource.' + 'label' => __('Abstract'), + 'description' => __('A summary of the resource.') ), array( 'local_part' => 'accessRights', - 'label' => 'Access Rights', - 'description' => 'Information about who can access the resource or an indication of its security status.' + 'label' => __('Access Rights'), + 'description' => __('Information about who can access the resource or an indication of its security status.') ), array( 'local_part' => 'accrualMethod', - 'label' => 'Accrual Method', - 'description' => 'The method by which items are added to a collection.' + 'label' => __('Accrual Method'), + 'description' => __('The method by which items are added to a collection.') ), array( 'local_part' => 'accrualPeriodicity', - 'label' => 'Accrual Periodicity', - 'description' => 'The frequency with which items are added to a collection.' + 'label' => __('Accrual Periodicity'), + 'description' => __('The frequency with which items are added to a collection.') ), array( 'local_part' => 'accrualPolicy', - 'label' => 'Accrual Policy', - 'description' => 'The policy governing the addition of items to a collection.' + 'label' => __('Accrual Policy'), + 'description' => __('The policy governing the addition of items to a collection.') ), array( 'local_part' => 'audience', - 'label' => 'Audience', - 'description' => 'A class of entity for whom the resource is intended or useful.' + 'label' => __('Audience'), + 'description' => __('A class of entity for whom the resource is intended or useful.') ), array( 'local_part' => 'contributor', - 'label' => 'Contributor', - 'description' => 'An entity responsible for making contributions to the resource.' + 'label' => __('Contributor'), + 'description' => __('An entity responsible for making contributions to the resource.') ), array( 'local_part' => 'coverage', - 'label' => 'Coverage', - 'description' => 'The spatial or temporal topic of the resource, the spatial applicability of the resource, or the jurisdiction under which the resource is relevant.' + 'label' => __('Coverage'), + 'description' => __('The spatial or temporal topic of the resource, the spatial applicability of the resource, or the jurisdiction under which the resource is relevant.') ), array( 'local_part' => 'creator', - 'label' => 'Creator', - 'description' => 'An entity primarily responsible for making the resource.' + 'label' => __('Creator'), + 'description' => __('An entity primarily responsible for making the resource.') ), array( 'local_part' => 'description', - 'label' => 'Description', - 'description' => 'An account of the resource.' + 'label' => __('Description'), + 'description' => __('An account of the resource.') ), array( 'local_part' => 'educationLevel', - 'label' => 'Audience Education Level', - 'description' => 'A class of entity, defined in terms of progression through an educational or training context, for which the described resource is intended.' + 'label' => __('Audience Education Level'), + 'description' => __('A class of entity, defined in terms of progression through an educational or training context, for which the described resource is intended.') ), array( 'local_part' => 'extent', - 'label' => 'Extent', - 'description' => 'The size or duration of the resource.' + 'label' => __('Extent'), + 'description' => __('The size or duration of the resource.') ), array( 'local_part' => 'format', - 'label' => 'Format', - 'description' => 'The file format, physical medium, or dimensions of the resource.' + 'label' => __('Format'), + 'description' => __('The file format, physical medium, or dimensions of the resource.') ), array( 'local_part' => 'instructionalMethod', - 'label' => 'Instructional Method', - 'description' => 'A process, used to engender knowledge, attitudes and skills, that the described resource is designed to support.' + 'label' => __('Instructional Method'), + 'description' => __('A process, used to engender knowledge, attitudes and skills, that the described resource is designed to support.') ), array( 'local_part' => 'language', - 'label' => 'Language', - 'description' => 'A language of the resource.' + 'label' => __('Language'), + 'description' => __('A language of the resource.') ), array( 'local_part' => 'license', - 'label' => 'License', - 'description' => 'A legal document giving official permission to do something with the resource.' + 'label' => __('License'), + 'description' => __('A legal document giving official permission to do something with the resource.') ), array( 'local_part' => 'mediator', - 'label' => 'Mediator', - 'description' => 'An entity that mediates access to the resource and for whom the resource is intended or useful.' + 'label' => __('Mediator'), + 'description' => __('An entity that mediates access to the resource and for whom the resource is intended or useful.') ), array( 'local_part' => 'medium', - 'label' => 'Medium', - 'description' => 'The material or physical carrier of the resource.' + 'label' => __('Medium'), + 'description' => __('The material or physical carrier of the resource.') ), array( 'local_part' => 'provenance', - 'label' => 'Provenance', - 'description' => 'A statement of any changes in ownership and custody of the resource since its creation that are significant for its authenticity, integrity, and interpretation.' + 'label' => __('Provenance'), + 'description' => __('A statement of any changes in ownership and custody of the resource since its creation that are significant for its authenticity, integrity, and interpretation.') ), array( 'local_part' => 'publisher', - 'label' => 'Publisher', - 'description' => 'An entity responsible for making the resource available.' + 'label' => __('Publisher'), + 'description' => __('An entity responsible for making the resource available.') ), array( 'local_part' => 'rights', - 'label' => 'Rights', - 'description' => 'Information about rights held in and over the resource.' + 'label' => __('Rights'), + 'description' => __('Information about rights held in and over the resource.') ), array( 'local_part' => 'rightsHolder', - 'label' => 'Rights Holder', - 'description' => 'A person or organization owning or managing rights over the resource.' + 'label' => __('Rights Holder'), + 'description' => __('A person or organization owning or managing rights over the resource.') ), array( 'local_part' => 'spatial', - 'label' => 'Spatial Coverage', - 'description' => 'Spatial characteristics of the resource.' + 'label' => __('Spatial Coverage'), + 'description' => __('Spatial characteristics of the resource.') ), array( 'local_part' => 'subject', - 'label' => 'Subject', - 'description' => 'The topic of the resource.' + 'label' => __('Subject'), + 'description' => __('The topic of the resource.') ), array( 'local_part' => 'tableOfContents', - 'label' => 'Table Of Contents', - 'description' => 'A list of subunits of the resource.' + 'label' => __('Table Of Contents'), + 'description' => __('A list of subunits of the resource.') ), array( 'local_part' => 'temporal', - 'label' => 'Temporal Coverage', - 'description' => 'Temporal characteristics of the resource.' + 'label' => __('Temporal Coverage'), + 'description' => __('Temporal characteristics of the resource.') ), array( 'local_part' => 'type', - 'label' => 'Type', - 'description' => 'The nature or genre of the resource.' + 'label' => __('Type'), + 'description' => __('The nature or genre of the resource.') ), ) ), array( 'name' => 'BIBO', - 'description' => 'Relations defined by the Bibliographic Ontology (BIBO): http://bibotools.googlecode.com/svn/bibo-ontology/trunk/doc/index.html', + 'description' => __('Relations defined by the Bibliographic Ontology (BIBO): http://bibotools.googlecode.com/svn/bibo-ontology/trunk/doc/index.html'), 'namespace_prefix' => 'bibo', 'namespace_uri' => 'http://purl.org/ontology/bibo/', 'properties' => array( array( 'local_part' => 'annotates', - 'label' => 'annotates', - 'description' => 'Critical or explanatory note for a Document.' + 'label' => __('annotates'), + 'description' => __('Critical or explanatory note for a Document.') ), array( 'local_part' => 'citedBy', - 'label' => 'cited by', - 'description' => 'Relates a document to another document that cites the first document.' + 'label' => __('cited by'), + 'description' => __('Relates a document to another document that cites the first document.') ), array( 'local_part' => 'cites', - 'label' => 'cites', - 'description' => 'Relates a document to another document that is cited by the first document as reference, comment, review, quotation or for another purpose.' + 'label' => __('cites'), + 'description' => __('Relates a document to another document that is cited by the first document as reference, comment, review, quotation or for another purpose.') ), array( 'local_part' => 'reviewOf', - 'label' => 'review of', - 'description' => 'Relates a review document to a reviewed thing (resource, item, etc.).' + 'label' => __('review of'), + 'description' => __('Relates a review document to a reviewed thing (resource, item, etc.).') ), array( 'local_part' => 'reproducedIn', - 'label' => 'reproduced in', - 'description' => 'The resource in which another resource is reproduced.' + 'label' => __('reproduced in'), + 'description' => __('The resource in which another resource is reproduced.') ), array( 'local_part' => 'affirmedBy', - 'label' => 'affirmed by', - 'description' => 'A legal decision that affirms a ruling.' + 'label' => __('affirmed by'), + 'description' => __('A legal decision that affirms a ruling.') ), array( 'local_part' => 'reversedBy', - 'label' => 'reversed by', - 'description' => 'A legal decision that reverses a ruling.' + 'label' => __('reversed by'), + 'description' => __('A legal decision that reverses a ruling.') ), array( 'local_part' => 'subsequentLegalDecision', - 'label' => 'subsequent legal decision', - 'description' => 'A legal decision on appeal that takes action on a case (affirming it, reversing it, etc.).' + 'label' => __('subsequent legal decision'), + 'description' => __('A legal decision on appeal that takes action on a case (affirming it, reversing it, etc.).') ), array( 'local_part' => 'transcriptOf', - 'label' => 'transcript of', - 'description' => 'Relates a document to some transcribed original.' + 'label' => __('transcript of'), + 'description' => __('Relates a document to some transcribed original.') ), array( 'local_part' => 'translationOf', - 'label' => 'translation of', - 'description' => 'Relates a translated document to the original document.' + 'label' => __('translation of'), + 'description' => __('Relates a translated document to the original document.') ), ) ), array( 'name' => 'FOAF', - 'description' => 'Relations defined by the Friend of a Friend vocabulary (FOAF): http://xmlns.com/foaf/spec/', + 'description' => __('Relations defined by the Friend of a Friend vocabulary (FOAF): http://xmlns.com/foaf/spec/'), 'namespace_prefix' => 'foaf', 'namespace_uri' => 'http://xmlns.com/foaf/0.1/', 'properties' => array( array( 'local_part' => 'based_near', - 'label' => 'based near', - 'description' => 'A location that something is based near, for some broadly human notion of near.' + 'label' => __('based near'), + 'description' => __('A location that something is based near, for some broadly human notion of near.') ), array( 'local_part' => 'depiction', - 'label' => 'depiction', - 'description' => 'A depiction of some thing.' + 'label' => __('depiction'), + 'description' => __('A depiction of some thing.') ), array( 'local_part' => 'depicts', - 'label' => 'depicts', - 'description' => 'A thing depicted in this representation.' + 'label' => __('depicts'), + 'description' => __('A thing depicted in this representation.') ), array( 'local_part' => 'fundedBy', - 'label' => 'funded by', - 'description' => 'An organization funding a project or person.' + 'label' => __('funded by'), + 'description' => __('An organization funding a project or person.') ), array( 'local_part' => 'img', - 'label' => 'image', - 'description' => 'An image that can be used to represent some thing (ie. those depictions which are particularly representative of something, eg. one\'s photo on a homepage).' + 'label' => __('image'), + 'description' => __('An image that can be used to represent some thing (ie. those depictions which are particularly representative of something, eg. one\'s photo on a homepage).') ), array( 'local_part' => 'isPrimaryTopicOf', - 'label' => 'is primary topic of', - 'description' => 'A document that this thing is the primary topic of.' + 'label' => __('is primary topic of'), + 'description' => __('A document that this thing is the primary topic of.') ), array( 'local_part' => 'knows', - 'label' => 'knows', - 'description' => 'A person known by this person (indicating some level of reciprocated interaction between the parties).' + 'label' => __('knows'), + 'description' => __('A person known by this person (indicating some level of reciprocated interaction between the parties).') ), array( 'local_part' => 'logo', - 'label' => 'logo', - 'description' => 'A logo representing some thing.' + 'label' => __('logo'), + 'description' => __('A logo representing some thing.') ), array( 'local_part' => 'made', - 'label' => 'made', - 'description' => 'Something that was made by this agent.' + 'label' => __('made'), + 'description' => __('Something that was made by this agent.') ), array( 'local_part' => 'maker', - 'label' => 'maker', - 'description' => 'An agent that made this thing.' + 'label' => __('maker'), + 'description' => __('An agent that made this thing.') ), array( 'local_part' => 'member', - 'label' => 'member', - 'description' => 'Indicates a member of a Group.' + 'label' => __('member'), + 'description' => __('Indicates a member of a Group.') ), array( 'local_part' => 'page', - 'label' => 'page', - 'description' => 'A page or document about this thing.' + 'label' => __('page'), + 'description' => __('A page or document about this thing.') ), array( 'local_part' => 'primaryTopic', - 'label' => 'primary topic', - 'description' => 'The primary topic of some page or document.' + 'label' => __('primary topic'), + 'description' => __('The primary topic of some page or document.') ), array( 'local_part' => 'thumbnail', - 'label' => 'thumbnail', - 'description' => 'A derived thumbnail image.' + 'label' => __('thumbnail'), + 'description' => __('A derived thumbnail image.') ), ) ), array( 'name' => 'FRBR', - 'description' => 'Relations defined by the Functional Requirements for Bibliographic Records (FRBR): http://vocab.org/frbr/core.html', + 'description' => __('Relations defined by the Functional Requirements for Bibliographic Records (FRBR): http://vocab.org/frbr/core.html'), 'namespace_prefix' => 'frbr', 'namespace_uri' => 'http://purl.org/vocab/frbr/core#', 'properties' => array( array( 'local_part' => 'abridgement', - 'label' => 'abridgement', - 'description' => 'A property representing an abridgment of an expression.' + 'label' => __('abridgement'), + 'description' => __('A property representing an abridgment of an expression.') ), array( 'local_part' => 'abridgementOf', - 'label' => 'abridgement of', - 'description' => 'A property representing an expression that is abridged.' + 'label' => __('abridgement of'), + 'description' => __('A property representing an expression that is abridged.') ), array( 'local_part' => 'adaption', - 'label' => 'adaption', - 'description' => 'A property representing an adaption of a work or expression.' + 'label' => __('adaption'), + 'description' => __('A property representing an adaption of a work or expression.') ), array( 'local_part' => 'adaptionOf', - 'label' => 'adaption of', - 'description' => 'A property representing a work or expression that is adapted.' + 'label' => __('adaption of'), + 'description' => __('A property representing a work or expression that is adapted.') ), array( 'local_part' => 'alternate', - 'label' => 'alternate', - 'description' => 'A property representing an alternative to a manifestation.' + 'label' => __('alternate'), + 'description' => __('A property representing an alternative to a manifestation.') ), array( 'local_part' => 'alternateOf', - 'label' => 'alternate of', - 'description' => 'A property representing a manifestation that is alternated.' + 'label' => __('alternate of'), + 'description' => __('A property representing a manifestation that is alternated.') ), array( 'local_part' => 'arrangement', - 'label' => 'arrangement', - 'description' => 'A property representing an arrangement of an expression.' + 'label' => __('arrangement'), + 'description' => __('A property representing an arrangement of an expression.') ), array( 'local_part' => 'arrangementOf', - 'label' => 'arrangement of', - 'description' => 'A property representing an expression that is arranged.' + 'label' => __('arrangement of'), + 'description' => __('A property representing an expression that is arranged.') ), array( 'local_part' => 'complement', - 'label' => 'complement', - 'description' => 'A property representing a complement to a work or expression.' + 'label' => __('complement'), + 'description' => __('A property representing a complement to a work or expression.') ), array( 'local_part' => 'complementOf', - 'label' => 'complement of', - 'description' => 'A property representing a work or expression that is complemented.' + 'label' => __('complement of'), + 'description' => __('A property representing a work or expression that is complemented.') ), array( 'local_part' => 'creator', - 'label' => 'creator', - 'description' => 'A property representing an entity in some way responsible for the creation of a work.' + 'label' => __('creator'), + 'description' => __('A property representing an entity in some way responsible for the creation of a work.') ), array( 'local_part' => 'creatorOf', - 'label' => 'creator of', - 'description' => 'A property representing a work that was in some way created by of an entity.' + 'label' => __('creator of'), + 'description' => __('A property representing a work that was in some way created by of an entity.') ), array( 'local_part' => 'embodiment', - 'label' => 'embodiment', - 'description' => 'A property representing a manifestation that embodies an expression.' + 'label' => __('embodiment'), + 'description' => __('A property representing a manifestation that embodies an expression.') ), array( 'local_part' => 'embodimentOf', - 'label' => 'embodiment of', - 'description' => 'A property representing an expression that is embodied by a manifestation.' + 'label' => __('embodiment of'), + 'description' => __('A property representing an expression that is embodied by a manifestation.') ), array( 'local_part' => 'exemplar', - 'label' => 'exemplar', - 'description' => 'A property representing an item that is an exemplar of a manifestation.' + 'label' => __('exemplar'), + 'description' => __('A property representing an item that is an exemplar of a manifestation.') ), array( 'local_part' => 'exemplarOf', - 'label' => 'exemplar of', - 'description' => 'A property representing the manifestation that is exemplified by a item.' + 'label' => __('exemplar of'), + 'description' => __('A property representing the manifestation that is exemplified by a item.') ), array( 'local_part' => 'imitation', - 'label' => 'imitation', - 'description' => 'A property representing an imitation of a work or expression.' + 'label' => __('imitation'), + 'description' => __('A property representing an imitation of a work or expression.') ), array( 'local_part' => 'imitationOf', - 'label' => 'imitation of', - 'description' => 'A property representing a work or expression that is imitated.' + 'label' => __('imitation of'), + 'description' => __('A property representing a work or expression that is imitated.') ), array( 'local_part' => 'owner', - 'label' => 'owner', - 'description' => 'A property representing an entity that owns an item.' + 'label' => __('owner'), + 'description' => __('A property representing an entity that owns an item.') ), array( 'local_part' => 'ownerOf', - 'label' => 'owner of', - 'description' => 'A property representing an item that is in some way owned an entity.' + 'label' => __('owner of'), + 'description' => __('A property representing an item that is in some way owned an entity.') ), array( 'local_part' => 'part', - 'label' => 'part', - 'description' => 'A property representing a part of an endeavour.' + 'label' => __('part'), + 'description' => __('A property representing a part of an endeavour.') ), array( 'local_part' => 'partOf', - 'label' => 'part of', - 'description' => 'A property representing an endeavour incorporating an endeavour.' + 'label' => __('part of'), + 'description' => __('A property representing an endeavour incorporating an endeavour.') ), array( 'local_part' => 'producer', - 'label' => 'producer', - 'description' => 'A property representing an entity in some way responsible for producing a manifestation.' + 'label' => __('producer'), + 'description' => __('A property representing an entity in some way responsible for producing a manifestation.') ), array( 'local_part' => 'producerOf', - 'label' => 'producer of', - 'description' => 'A property representing a manifestation that was in some way produced an entity.' + 'label' => __('producer of'), + 'description' => __('A property representing a manifestation that was in some way produced an entity.') ), array( 'local_part' => 'realization', - 'label' => 'realization', - 'description' => 'A property representing an expression that is an intellectual or artistic realization of a work.' + 'label' => __('realization'), + 'description' => __('A property representing an expression that is an intellectual or artistic realization of a work.') ), array( 'local_part' => 'realizationOf', - 'label' => 'realization of', - 'description' => 'A property representing the work that has been realized by an expression.' + 'label' => __('realization of'), + 'description' => __('A property representing the work that has been realized by an expression.') ), array( 'local_part' => 'realizer', - 'label' => 'realizer', - 'description' => 'A property representing an entity in some way responsible for realizing an expression.' + 'label' => __('realizer'), + 'description' => __('A property representing an entity in some way responsible for realizing an expression.') ), array( 'local_part' => 'realizerOf', - 'label' => 'realizer of', - 'description' => 'A property representing an expression that was in some way realized by an entity.' + 'label' => __('realizer of'), + 'description' => __('A property representing an expression that was in some way realized by an entity.') ), array( 'local_part' => 'reconfiguration', - 'label' => 'reconfiguration', - 'description' => 'A property representing a recongifuration of an item.' + 'label' => __('reconfiguration'), + 'description' => __('A property representing a recongifuration of an item.') ), array( 'local_part' => 'reconfigurationOf', - 'label' => 'reconfiguration of', - 'description' => 'A property representing an item that is reconfigured.' + 'label' => __('reconfiguration of'), + 'description' => __('A property representing an item that is reconfigured.') ), array( 'local_part' => 'relatedEndeavour', - 'label' => 'related endeavour', - 'description' => 'A property representing another endeavour that is related in some way to an endeavour.' + 'label' => __('related endeavour'), + 'description' => __('A property representing another endeavour that is related in some way to an endeavour.') ), array( 'local_part' => 'reproduction', - 'label' => 'reproduction', - 'description' => 'A property representing a reproduction of a manifestation or item.' + 'label' => __('reproduction'), + 'description' => __('A property representing a reproduction of a manifestation or item.') ), array( 'local_part' => 'reproductionOf', - 'label' => 'reproduction of', - 'description' => 'A property representing a manifestation or item that is reproduced.' + 'label' => __('reproduction of'), + 'description' => __('A property representing a manifestation or item that is reproduced.') ), array( 'local_part' => 'responsibleEntity', - 'label' => 'responsible entity', - 'description' => 'A property representing an entity in some way responsible for an endeavour.' + 'label' => __('responsible entity'), + 'description' => __('A property representing an entity in some way responsible for an endeavour.') ), array( 'local_part' => 'responsibleEntityOf', - 'label' => 'responsible entity of', - 'description' => 'A property representing an endeavour that is the responsibility of an entity.' + 'label' => __('responsible entity of'), + 'description' => __('A property representing an endeavour that is the responsibility of an entity.') ), array( 'local_part' => 'revision', - 'label' => 'revision', - 'description' => 'A property representing a revision of an expression.' + 'label' => __('revision'), + 'description' => __('A property representing a revision of an expression.') ), array( 'local_part' => 'revisionOf', - 'label' => 'revision of', - 'description' => 'A property representing an expression that is revised.' + 'label' => __('revision of'), + 'description' => __('A property representing an expression that is revised.') ), array( 'local_part' => 'successor', - 'label' => 'successor', - 'description' => 'A property representing a successor to a work or expression.' + 'label' => __('successor'), + 'description' => __('A property representing a successor to a work or expression.') ), array( 'local_part' => 'successorOf', - 'label' => 'successor of', - 'description' => 'A property representing a work or expression that is succeeded.' + 'label' => __('successor of'), + 'description' => __('A property representing a work or expression that is succeeded.') ), array( 'local_part' => 'summarization', - 'label' => 'summarization', - 'description' => 'A property representing a summarization of a work or expression.' + 'label' => __('summarization'), + 'description' => __('A property representing a summarization of a work or expression.') ), array( 'local_part' => 'summarizationOf', - 'label' => 'summarization of', - 'description' => 'A property representing a work or expression that is summarized.' + 'label' => __('summarization of'), + 'description' => __('A property representing a work or expression that is summarized.') ), array( 'local_part' => 'supplement', - 'label' => 'supplement', - 'description' => 'A property representing a supplement to a work or expression.' + 'label' => __('supplement'), + 'description' => __('A property representing a supplement to a work or expression.') ), array( 'local_part' => 'supplementOf', - 'label' => 'supplement of', - 'description' => 'A property representing a work or expression that is supplemented.' + 'label' => __('supplement of'), + 'description' => __('A property representing a work or expression that is supplemented.') ), array( 'local_part' => 'transformation', - 'label' => 'transformation', - 'description' => 'A property representing a transformation of a work or expression.' + 'label' => __('transformation'), + 'description' => __('A property representing a transformation of a work or expression.') ), array( 'local_part' => 'transformationOf', - 'label' => 'transformation of', - 'description' => 'A property representing a work or expression that is transformed.' + 'label' => __('transformation of'), + 'description' => __('A property representing a work or expression that is transformed.') ), array( 'local_part' => 'translation', - 'label' => 'translation', - 'description' => 'A property representing a translation of an expression.' + 'label' => __('translation'), + 'description' => __('A property representing a translation of an expression.') ), array( 'local_part' => 'translationOf', - 'label' => 'translation of', - 'description' => 'A property representing an expression that is translated.' + 'label' => __('translation of'), + 'description' => __('A property representing an expression that is translated.') ), ) ), diff --git a/item_relations_form.php b/item_relations_form.php index 5ee0fda..08ee6f2 100644 --- a/item_relations_form.php +++ b/item_relations_form.php @@ -1,3 +1,12 @@ +

' @@ -7,14 +16,16 @@ . 'relations. For descriptions of the relations, see the %s page. Invalid ' . 'item IDs will be ignored.', $link ); +$provideRelationComments = get_option('item_relations_provide_relation_comments'); ?>

- + + @@ -24,6 +35,7 @@ + @@ -32,26 +44,94 @@ + - - + + + + +
formSelect('item_relations_property_id[]', null, array('multiple' => false), $formSelectProperties); ?> formText('item_relations_item_relation_object_item_id[]', null, array('size' => 8)); ?>n/a + +
+ []
+ formText('item_relations_item_relation_object_item_id[]', null, array('size' => 8)); ?> +
+
formText('item_relations_item_relation_relation_comment[]', null, array('size' => 8)); ?>
- + + + + +\n"; + // --- 1. Fetch all item typs together with ther IDs and names + if (defined("SIMULATION")) { + $itemtypes=array(); + for($i=1; ($i<=SIM_CATEGORIES); $i++) { $itemtypes[]=array("id" => $i, "name" => substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, SIM_CATLEN)); } + } + else { + $sql = "SELECT id, name from {$db->Item_Types} ORDER BY id"; + $itemtypes = $db->fetchAll($sql); + } + $lines=array(); + $lines[]="0:'".__("[n/a]")."'"; + foreach($itemtypes as $itemtyp) { + $lines[]=$itemtyp["id"].":'".htmlspecialchars($itemtyp["name"], ENT_QUOTES)."'"; + } + // JavaScript object + echo "var itemTypes={\n". + implode(",\n",$lines)."\n". + "};\n"; + // --- 2. Fetch all items together with their IDs, titles, and item type IDs and names + if (defined("SIMULATION")) { + $items=array(); + for($i=1; ($i<=SIM_ITEMS); $i++) { + $items[]=array($i, substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, SIM_ITEMLEN), rand(0,SIM_CATEGORIES), time()-rand(0,3600)); + } + usort($items, function($a, $b) { return ( $a[2]!=$b[2] ? $a[2]-$b[2] : ( $a[1]!=$b[1] ? ($a[1]>$b[1] ? 1 : -1 ) : 0 ) ); } ); + } + else { + $item_id_suffix=($item->id ? "and items.id<>".$item->id : "" ); + $sql = "SELECT items.id, text, item_type_id, UNIX_TIMESTAMP(modified) + FROM {$db->Item} items + LEFT JOIN {$db->Element_Texts} elementtexts on (items.id=elementtexts.record_id) + WHERE elementtexts.element_id=50 $item_id_suffix + GROUP BY elementtexts.record_id + ORDER BY items.item_type_id ASC, text ASC"; + $items = $db->fetchAll($sql); + } + // For efficiency, we use a regular JavaScript array notation instead of JSON + $lines=array(); + foreach($items as $item) { + foreach (array_keys($item) as $key) { + if (!$item[$key]) { $item[$key]=0; } # Transform all empty values to zero + if (intval($item[$key])!==$item[$key]) { $item[$key]="'".htmlspecialchars($item[$key], ENT_QUOTES)."'"; } # Non-ints i.e. string into apostrophes + } + $lines[]="[[".implode("],[", $item)."]]"; # Item as a new array element - with its components in another array + } + echo "var allItemsArr=[\n". + implode(",\n",$lines)."\n". + "];\n"; + // -------- + echo "var itemTypesTxt='".__("Item Types")."';\n"; + echo "var allTxt='".__("All")."';\n"; + echo "var itemTypeTxt='".__("Item Type")."';\n"; + echo "var sortWithinItemTypeByTxt='".__("Sort within item types by")."';\n"; + echo "var updDateDescTxt='".__("Last Update (desc)")."';\n"; + echo "var nameAscTxt='".__("Name (asc)")."';\n"; + echo "var searchTermTxt='".__("Search Term")."';\n"; + echo "var resetTxt='".__("Reset")."';\n"; + echo "\n"; + # echo "$sql
\n"; +?> +
\ No newline at end of file diff --git a/item_relations_script.js b/item_relations_script.js new file mode 100644 index 0000000..1f37a80 --- /dev/null +++ b/item_relations_script.js @@ -0,0 +1,187 @@ +jQuery(document).ready(function () { + + var $ = jQuery; // use noConflict version of jQuery as the short $ within this block + var lightbox = lity(); // Lity lightbox for item selector "popup" + + var my_input = null; // Reference to currently active input + var allItemsSortedArr = null; // Room for a pre-sorted array + var filterItemTyp = null; // Room for filter by type + var curListOrder = null; // Room for sort order + var curFilter = null; // Room for filter word + + // --- START: moved from