/[drupal]/contributions/modules/exhibit/exhibit.pages.inc
ViewVC logotype

Contents of /contributions/modules/exhibit/exhibit.pages.inc

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


Revision 1.2 - (show annotations) (download) (as text)
Thu Jul 17 11:51:06 2008 UTC (16 months, 1 week ago) by arto
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-BETA1, DRUPAL-6--1-0-ALPHA2, HEAD
Changes since 1.1: +0 -8 lines
File MIME type: text/x-php
Imported latest 6.x version (8e74bbc) from the GitHub development repository.

Changelog:
- Changed profile fields to use name instead of title (by jhuckabee).
- Implemented facet generator and ability to add facets to a generic Exhibit block (by jhuckabee).
- Fixed bug with inserting facet definition on exhibit node creation (by jhuckabee).
- Corrected the schema update for the new facet_definition field, and also added the field to hook_schema().
- Corrected capitalization to adhere to Drupal guidelines.
- Added CVS keywords in order to conform to Drupal coding standards.
- Removed spurious PHPDoc headers.
- Refactored hook_block(); cleaned up trailing whitespace here and there.
1 <?php
2 // $Id$
3
4 //////////////////////////////////////////////////////////////////////////////
5 // Menu callbacks
6
7 function exhibit_output_convert($url, $callback, $input_format = NULL, $output_format = 'application/json') {
8 if (!preg_match('!^exhibit/[\w]+/(.*)$!', $_GET['q'], $matches)) {
9 return drupal_not_found();
10 }
11
12 $url = 'http://' . $matches[1];
13 if (!valid_url($url, TRUE)) {
14 return drupal_access_denied();
15 }
16
17 $response = drupal_http_request($url);
18 if (!empty($response->error)) {
19 // TODO
20 return drupal_access_denied();
21 }
22
23 $output = $callback($response->data);
24
25 exhibit_output($output_format, drupal_to_js($output));
26 }
27
28 function exhibit_output_node($node) {
29 $function = 'exhibit_output_node_' . $node->type;
30 exhibit_output('application/json', drupal_to_js(is_callable($function) ? call_user_func($function, $node) : array('items' => array())));
31 }
32
33 function exhibit_output_feed($feed) {
34 exhibit_output($feed['type'], exhibit_get_feed_contents($feed['url']));
35 }
36
37 function exhibit_output($type, $body) {
38 //$type = 'text/plain'; // DEBUG
39 drupal_set_header('Content-Type: ' . $type . '; charset=utf-8');
40 drupal_set_header('Content-Length: ' . strlen($body));
41
42 if (EXHIBIT_FEED_ETAG) {
43 $md5 = base64_encode(md5($body, TRUE));
44 drupal_set_header('Content-MD5: ' . $md5);
45 drupal_set_header('ETag: "' . $md5 . '"'); // strong entity tag
46 }
47
48 if (EXHIBIT_FEED_LIFETIME > 0) {
49 drupal_set_header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
50 drupal_set_header('Expires: ' . gmdate('D, d M Y H:i:s', time() + EXHIBIT_FEED_LIFETIME) . ' GMT');
51 drupal_set_header('Cache-Control: max-age=' . EXHIBIT_FEED_LIFETIME . ', private, must-revalidate');
52 drupal_set_header('Pragma: cache'); // need to override no-cache set by Drupal.
53 }
54
55 print $body;
56 }
57
58 /**
59 * @see http://simile.mit.edu/wiki/Exhibit/Template/_history_.html
60 */
61 function exhibit_output_history() {
62 print '<html><body></body></html>';
63 }
64
65 //////////////////////////////////////////////////////////////////////////////
66
67 function exhibit_parse_tsv($input) {
68 $output = array();
69
70 $lines = explode("\n", $input);
71 $fields = explode("\t", array_shift($lines));
72 foreach ($lines as $line) {
73 $item = array();
74 foreach (explode("\t", $line) as $index => $value) {
75 $item[$fields[$index]] = $value;
76 }
77 $output[] = $item;
78 }
79
80 return exhibit_json($output);
81 }

  ViewVC Help
Powered by ViewVC 1.1.2