/[drupal]/contributions/modules/rdf/rdf.theme.inc
ViewVC logotype

Contents of /contributions/modules/rdf/rdf.theme.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.9 - (show annotations) (download) (as text)
Mon Feb 16 13:27:09 2009 UTC (9 months, 1 week ago) by arto
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-ALPHA6, DRUPAL-6--1-0-ALPHA7, HEAD
Changes since 1.8: +2 -2 lines
File MIME type: text/x-php
Merged latest changes from http://github.com/bendiken/drupal-rdf.

Changelog:
- #330541 by jmiccolis: Views integration.
- Cache rdf_db_get_repository_tables() and rdf_db_count_repository_triples() results (by alex.k).
- Refactored rdf_db_get_repository_tables() and rdf_db_count_repository_triples().
- Prevent duplicate RDF statements from being inserted (in accordance with repository settings).
- Merge any duplicated RDF statements on cron runs (in accordance with repository settings).
- Implemented support for CCK Fieldgroup fields when outputting RSS feeds from the Views plugin.
- Honor Location module content-type-specific RSS settings when outputting RSS feeds from the Views plugin.
- Folded the RDF Schema module back into the base module, leaving a placeholder (for the time being) in order to allow users to cleanly uninstall the submodule.
- Renamed the 'RDF API' module to 'RDF'.
- Minor coding conventions cleanup.
- Updated the information in README.txt and INSTALL.txt; added contributors to README.txt.
1 <?php
2 // $Id$
3
4 //////////////////////////////////////////////////////////////////////////////
5 // Theme callbacks: Property-value tables
6
7 function theme_rdf_property_table($data) {
8 $rows = array();
9
10 if (!empty($data)) {
11 $data = is_object($data) ? rdf_normalize($data) : $data;
12
13 foreach ($data as $subject => $predicates) {
14 foreach ($predicates as $predicate => $objects) {
15 foreach ($objects as $object) {
16 $rows[] = array(
17 array('data' => theme('rdf_triple_cell', $predicate), 'header' => TRUE),
18 theme('rdf_triple_cell', $object),
19 );
20 }
21 }
22 }
23 }
24
25 if (empty($rows)) {
26 $rows[] = array(array('data' => t('No data.'), 'colspan' => 2));
27 }
28
29 return theme('table', array(), $rows, array('class' => 'rdf-properties'));
30 }
31
32 //////////////////////////////////////////////////////////////////////////////
33 // Theme callbacks: Triple tables
34
35 function theme_rdf_triple_table($data, array $options = array()) {
36 $head = array(t('Subject'), t('Predicate'), t('Object'));
37 $rows = array();
38
39 if (!empty($data)) {
40 $data = is_object($data) ? rdf_normalize($data) : $data;
41
42 foreach ($data as $subject => $predicates) {
43 foreach ($predicates as $predicate => $objects) {
44 foreach ($objects as $object) {
45 $rows[] = theme('rdf_triple_row', $subject, $predicate, $object, $options);
46 }
47 }
48 }
49 }
50
51 if (empty($rows)) {
52 $rows[] = array(array('data' => t('No data.'), 'colspan' => 3));
53 }
54
55 return theme('table', $head, $rows, array('class' => 'rdf-triples'));
56 }
57
58 function theme_rdf_triple_row($subject, $predicate, $object, array $options = array()) {
59 return array(
60 theme('rdf_triple_cell', $subject, $options),
61 theme('rdf_triple_cell', $predicate, $options),
62 theme('rdf_triple_cell', $object, $options),
63 );
64 }
65
66 function theme_rdf_triple_cell($value, array $options = array()) {
67 $value = (string)$value; // FIXME
68
69 if (rdf_is_valid_uri($value)) { // FIXME
70 $uri = $value;
71 $qname = @rdf_uri_to_qname($uri, FALSE);
72 $title = !empty($options['brackets']) ? ($qname ? "[$qname]" : "<$uri>") : ($qname ? $qname : $uri);
73 return _rdf_truncate_uri($uri, $title, $options);
74 }
75 else {
76 return check_plain(truncate_utf8($value, 56, TRUE, TRUE));
77 }
78 }
79
80 function theme_rdf_value($value) {
81 switch (rdf_get_type($value)) {
82 case 'bnode':
83 case 'uri':
84 return _rdf_truncate_uri((string)$value, rdf_uri_to_qname((string)$value, FALSE));
85 case 'string':
86 return check_plain(truncate_utf8($value, 56, TRUE, TRUE));
87 case 'literal':
88 $tooltip = !empty($value->language) ? '@' . $value->language : $value->qname();
89 return '<span' . drupal_attributes(array('title' => $tooltip)) . '>' . check_plain($value->value) . '</span>';
90 }
91 }
92
93 function _rdf_truncate_uri($uri, $title = NULL, $options = array()) {
94 $title = $title ? $title : $uri;
95 $function = isset($options['link']) ? $options['link'] : 'l';
96 return $function(
97 preg_replace('/ \.\.\.$/', '...', truncate_utf8($title, 32, TRUE, TRUE)),
98 $uri, array('attributes' => array('title' => $uri)));
99 }

  ViewVC Help
Powered by ViewVC 1.1.2