/[drupal]/contributions/modules/parser_kml/parser_kml.module
ViewVC logotype

Contents of /contributions/modules/parser_kml/parser_kml.module

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


Revision 1.2 - (show annotations) (download) (as text)
Thu Dec 4 21:17:14 2008 UTC (11 months, 3 weeks ago) by alexb
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +7 -9 lines
File MIME type: text/x-php
Clean up test function.
1 <?php
2 // $Id: parser_kml.module,v 1.1 2008/12/04 00:05:11 alexb Exp $
3
4 /**
5 * @file
6 * Parse the incoming URL with SimpleXML into a FeedAPI compatible data structure.
7 */
8
9 /**
10 * Implementation of hook_help().
11 */
12 function parser_kml_help($path, $arg) {
13 switch ($path) {
14 case 'admin/modules#description':
15 return t('KML Parser is a FeedAPI-compatible parser for feeds in the Keyhole Markup Language. Requires PHP5.');
16 case 'feedapi/full_name':
17 return t('KML Parser');
18 }
19 }
20
21 /**
22 * Implementation of hook_feedapi_feed().
23 */
24 function parser_kml_feedapi_feed($op) {
25 $args = func_get_args();
26 switch ($op) {
27 case 'type':
28 return array("XML feed");
29 case 'compatible':
30 // @todo: determine compatibility.
31 return TRUE;
32 case 'parse':
33 if (is_object($args[1])) {
34 return parser_kml_parse($args[1]->url);
35 }
36 break;
37 }
38 }
39
40 /**
41 * Parse document given at URL.
42 *
43 * @param URL string $url
44 * @return parsed data as FeedAPI feed array
45 */
46 function parser_kml_parse($url) {
47 static $loaded = FALSE;
48 if (!$loaded) {
49 require(drupal_get_path('module', 'parser_kml') .'/parser_kml.inc');
50 $loaded = TRUE;
51 }
52 return _parser_kml_parse($url);
53 }
54
55 /**
56 * Test function.
57 */
58 function parser_kml_test($file = null) {
59 if (!$file) {
60 $file = 'test01.kml';
61 }
62 $testfilepath = url(drupal_get_path('module', 'parser_kml') .'/tests/feeds/'. $file, array('absolute' => TRUE));
63 drupal_set_message("Parse ". $testfilepath);
64 $parsed = parser_kml_parse($testfilepath);
65
66 drupal_set_message('<pre>'. print_r($parsed, true) .'</pre>');
67 }

  ViewVC Help
Powered by ViewVC 1.1.2