2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg */
6 /* Adaptive Technology Resource Centre / University of Toronto */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
15 define('AT_INCLUDE_PATH', 'include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
20 /* called at the start of en element */
21 /* builds the $path array which is the path from the root to the current element */
22 function startElement($parser, $name, $attrs) {
24 array_push($path, $name);
27 /* called when an element ends */
28 /* removed the current element from the $path */
29 function endElement($parser, $name) {
30 global $my_data, $path, $tile_title, $tile_description, $tile_identifier;
32 if ($path == array('lom', 'general', 'title', 'langstring')) {
33 $tile_title = $my_data;
34 } else if ($path == array('lom', 'general', 'description', 'langstring')) {
35 $tile_description = $my_data;
36 } else if ($path == array('lom', 'general', 'identifier')) {
37 $tile_identifier = $my_data;
44 /* called when there is character data within elements */
45 /* constructs the $items array using the last entry in $path as the parent element */
46 function characterData($parser, $data){
51 require (AT_INCLUDE_PATH.'header.inc.php');
54 <form action="<?php echo $_SERVER['PHP_SELF']; ?>#search_results" method="get" name="form">
56 <div class="input-form" style="width: 40%">
58 <label for="words2"><?php echo _AT('search_words'); ?></label><br />
59 <input type="text" name="query" size="40" id="words2" value="<?php echo stripslashes(htmlspecialchars($_GET['query'])); ?>" />
63 <?php echo _AT('search_in'); ?><br />
65 <input type="radio" name="field" value="anyField" id="taf" <?php if (!isset($_GET['field']) || ($_GET['field'] == 'anyField')) { echo 'checked="checked"'; } ?> /><label for="taf"><?php echo _AT('tile_any_field'); ?></label><br />
66 <input type="radio" name="field" value="title" id="tt" <?php if ($_GET['field'] == 'title') { echo 'checked="checked"'; } ?> /><label for="tt"><?php echo _AT('title'); ?></label><br />
67 <input type="radio" name="field" value="author" id="ta" <?php if ($_GET['field'] == 'author') { echo 'checked="checked"'; } ?> /><label for="ta"><?php echo _AT('tile_author'); ?></label><br />
68 <input type="radio" name="field" value="subject" id="tk" <?php if ($_GET['field'] == 'subject') { echo 'checked="checked"'; } ?> /><label for="tk"><?php echo _AT('tile_keyword'); ?></label><br />
69 <input type="radio" name="field" value="description" id="td" <?php if ($_GET['field'] == 'description') { echo 'checked="checked"'; } ?> /><label for="td"><?php echo _AT('description'); ?></label><br />
70 <input type="radio" name="field" value="technicalFormat" id="tf" <?php if ($_GET['field'] == 'technicalFormat') { echo 'checked="checked"'; } ?> /><label for="tf"><?php echo _AT('tile_technical_format'); ?></label>
73 <div class="row buttons">
74 <input type="submit" name="submit" value="<?php echo _AT('search'); ?>" />
81 if (isset($_GET['query'])) {
83 if (!extension_loaded('soap')) {
84 require(AT_INCLUDE_PATH . 'classes/nusoap.php');
85 // Create the client instance
86 $client = new nusoapclient(AT_TILE_WSDL, true);
89 $error = $client->getError();
93 $msg->addError('TILE_UNAVAILABLE');
96 require(AT_INCLUDE_PATH.'footer.inc.php');
101 $proxy = $client->getProxy();
103 // Create the client instance
104 $proxy = new soapclient(AT_TILE_WSDL);
107 $search_input = array('query' => $_GET['query'], 'field' => $_GET['field'], 'content' => 'contentPackage');
109 $results = $proxy->doSearch($search_input);
113 $num_results = count($results);
117 echo '<h3>'. _AT('results_found', $num_results).'</h3>';
120 foreach ($results as $result) {
122 $xml_parser = xml_parser_create();
124 xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); /* conform to W3C specs */
125 xml_set_element_handler($xml_parser, 'startElement', 'endElement');
126 xml_set_character_data_handler($xml_parser, 'characterData');
128 if (!xml_parse($xml_parser, $result, true)) {
129 die(sprintf("XML error: %s at line %d",
130 xml_error_string(xml_get_error_code($xml_parser)),
131 xml_get_current_line_number($xml_parser)));
134 xml_parser_free($xml_parser);
136 $tile_title = str_replace('<', '<', $tile_title);
138 echo '<li><strong>' . $tile_title . '</strong> - ';
139 echo '<a href="'.AT_TILE_PREVIEW .'cp='.$tile_identifier.'&item='.$tile_identifier.'" target="_new">'._AT('preview').'</a>';
140 echo ' | <a href="'.AT_TILE_EXPORT.'?cp='.$tile_identifier.'">'._AT('download').'</a>';
142 if (strlen($tile_description) > 200) {
143 echo '<small>' . $tile_description . '</small>';
145 echo $tile_description;
151 unset($tile_description);
152 unset($tile_identifier);
157 require(AT_INCLUDE_PATH.'footer.inc.php');