Changeset 443
- Timestamp:
- 2007-05-31 15:11:40 (1 year ago)
- Files:
-
- trunk/www/html/Doxyfile (added)
- trunk/www/html/api (added)
- trunk/www/html/include/db_celestial.php (modified) (6 diffs)
- trunk/www/html/include/db_roar.php (modified) (1 diff)
- trunk/www/html/include/roar_api.php (modified) (1 diff)
- trunk/www/html/include/roardatabase.php (modified) (1 diff)
- trunk/www/html/index.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/www/html/include/db_celestial.php
r440 r443 1 1 <?php 2 3 function _sql_format_value($n) { return "`format` LIKE '".mysql_real_escape_string($n)."%'"; } 4 5 /** 6 * 7 * @brief Query the fulltext data held on a repository. 8 * 9 */ 2 10 3 11 class Fulltext … … 6 14 var $repo; 7 15 var $id; 16 17 var $fulltext_formats = array( 18 "Portable Document Format", 19 "Rich Text Format", 20 "Microsoft Word for Windows Document", 21 "Postscript", 22 "OpenOffice Writer" 23 ); 8 24 9 25 function Fulltext($dbh, $repo, $id) … … 42 58 } 43 59 60 /** 61 * 62 * @brief Get a summary table of all the formats contained in this repository. 63 * 64 * @return An array of two arrays. 65 * 66 * The first array is the name of the format. The second array is the number of files in that format. 67 * 68 * A special entry is the '[No files found]' field, which is the total number of OAI records with no files recorded. 69 */ 70 44 71 function formatSummary() 45 72 { … … 70 97 } 71 98 99 /** 100 * 101 * @brief Get a summary of all formats, but only count one format per OAI record 102 * 103 * @return array 104 * 105 * Returns an associative array with the following values filled in: fulltexts, documents and html. 106 * 107 */ 108 109 function recordsSummary() 110 { 111 $ftable = $this->table(); 112 $repo = $this->repo; 113 $md = $repo->getOaiDc(); 114 $mtable = $md->table(); 115 116 $data = array(); 117 118 // How many records have a fulltext attached 119 $query = mysql_query("SELECT COUNT(DISTINCT `record`) FROM $ftable") 120 or trigger_error(mysql_query($this->dbh)); 121 $line = mysql_fetch_array($query); 122 $data['fulltexts'] = $line[0]; 123 124 // How many records have one of the normal documenty formats 125 $sql = "SELECT COUNT(DISTINCT `record`) FROM $ftable WHERE `format` LIKE 'Hypertext Markup Language%'"; 126 $query = mysql_query($sql) 127 or trigger_error(mysql_query($this->dbh)); 128 $line = mysql_fetch_array($query); 129 $data['html'] = $line[0]; 130 131 // How many records have an HTML record attached (this may get 132 // confused by other links, access denied pages etc.) 133 $sql = "SELECT COUNT(DISTINCT `record`) FROM $ftable WHERE "; 134 $formats = array_map("_sql_format_value", $this->fulltext_formats); 135 $sql .= implode(" OR ", $formats); 136 $query = mysql_query($sql) 137 or trigger_error(mysql_query($this->dbh)); 138 $line = mysql_fetch_array($query); 139 $data['documents'] = $line[0]; 140 141 return $data; 142 } 143 72 144 function formatSummaryByYear() 73 145 { … … 125 197 } 126 198 199 /** 200 * 201 * @brief A Celestial repository 202 * 203 */ 204 127 205 class Repository 128 206 { … … 144 222 return null; 145 223 } 224 225 /** 226 * 227 * @brief Gets an object to query fulltext data for this repository. 228 * 229 * @return A Fulltext object for this repository. 230 * 231 */ 146 232 147 233 function getFulltext() trunk/www/html/include/db_roar.php
r440 r443 1 1 <?php 2 3 /** 4 * 5 * Creates the ROAR database object and provides some useful global methods 6 * 7 */ 2 8 3 9 include("roardatabase.php"); trunk/www/html/include/roar_api.php
r440 r443 2291 2291 } 2292 2292 2293 /** 2294 * 2295 * Generate a summary table of detected repository fulltexts from Celestial 2296 * 2297 */ 2298 2299 function menu_fulltexts() 2300 { 2301 global $DBH_ROAR, $DBH_CEL; 2302 2303 $ARCHIVES = $DBH_ROAR->read_archives( 'live' ); 2304 2305 header("Content-type: text/plain"); 2306 2307 foreach($ARCHIVES as $archive) 2308 { 2309 $archive_summary = array(); 2310 $archive_summary['name'] = $archive['name']; 2311 $archive_summary['url'] = $archive['url']; 2312 $archive_summary['records'] = isset($archive['recordcount']) ? $archive['recordcount'] : 0; 2313 $archive_summary['fulltexts'] = $archive_summary['documents'] = $archive_summary['html'] = 0; 2314 2315 if( $archive_summary['records'] == 0 ) 2316 continue; 2317 2318 foreach($archive['oai'] as $oai) 2319 { 2320 if( !$DBH_CEL->hasProfile( $oai ) ) 2321 continue; 2322 $repository = $DBH_CEL->getRepository( $oai ); 2323 $format = $repository->getFulltext(); 2324 2325 $data = $format->recordsSummary(); 2326 2327 $archive_summary = array_merge( $archive_summary, $data ); 2328 } 2329 2330 foreach(array('records','fulltexts','documents','html','url','name') as $col) 2331 { 2332 print $archive_summary[$col] . "\t"; 2333 } 2334 print "\n"; 2335 } 2336 } 2337 2293 2338 function roar_done() 2294 2339 { trunk/www/html/include/roardatabase.php
r440 r443 2 2 3 3 /** 4 * API to the ROAR database4 * @brief API to the ROAR database 5 5 * 6 6 * @author Tim Brody <tdb01r@ecs.soton.ac.uk> trunk/www/html/index.php
r440 r443 65 65 break; 66 66 } 67 case "fulltexts": { 68 menu_fulltexts(); 69 break; 70 } 67 71 case "google": { 68 72 menu_google();