Changeset 443

Show
Ignore:
Timestamp:
2007-05-31 15:11:40 (1 year ago)
Author:
tdb01r
Message:
  • Added doxygen configuration file
  • Added menu_fulltexts option to generate a break down of 'fulltexts' per repository (very slow though)
  • Fixed some documentation in the database classes
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/www/html/include/db_celestial.php

    r440 r443  
    11<?php 
     2 
     3function _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 */ 
    210 
    311class Fulltext 
     
    614        var $repo; 
    715        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        ); 
    824 
    925        function Fulltext($dbh, $repo, $id) 
     
    4258        } 
    4359 
     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 
    4471        function formatSummary() 
    4572        { 
     
    7097        } 
    7198 
     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 
    72144        function formatSummaryByYear() 
    73145        { 
     
    125197} 
    126198 
     199/** 
     200 * 
     201 * @brief A Celestial repository 
     202 * 
     203 */ 
     204 
    127205class Repository 
    128206{ 
     
    144222                return null; 
    145223        } 
     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         */ 
    146232 
    147233        function getFulltext() 
  • trunk/www/html/include/db_roar.php

    r440 r443  
    11<?php 
     2 
     3/** 
     4 * 
     5 * Creates the ROAR database object and provides some useful global methods 
     6 * 
     7 */ 
    28 
    39include("roardatabase.php"); 
  • trunk/www/html/include/roar_api.php

    r440 r443  
    22912291} 
    22922292 
     2293/** 
     2294 * 
     2295 * Generate a summary table of detected repository fulltexts from Celestial 
     2296 * 
     2297 */ 
     2298 
     2299function 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 
    22932338function roar_done() 
    22942339{ 
  • trunk/www/html/include/roardatabase.php

    r440 r443  
    22 
    33/** 
    4  * API to the ROAR database 
     4 * @brief API to the ROAR database 
    55 * 
    66 * @author Tim Brody <tdb01r@ecs.soton.ac.uk> 
  • trunk/www/html/index.php

    r440 r443  
    6565                break; 
    6666        } 
     67        case "fulltexts": { 
     68                menu_fulltexts(); 
     69                break; 
     70        } 
    6771        case "google": { 
    6872                menu_google();