<?php

    
// Import function
    
require_once "inc_dt.phps";
    
    
// Choose database to use
    
require_once "../database-details.php";
    
$DATATYPE 'pgsql';
    
$database pg_connect($databasedetails);
    
    
// Choose table to query
    
$table 'link';
    
    
// Options to use
    
$options = array(
        
"showsql"=>1,
        
"caption"=>"Contents of the <b>link</b> table."
    
);
    
    
// Describe table columns
    
$columns = array(
        
"article"   => array("label"=>"Article",
                    
"type"=>"string",
                    
"sortable"=>1,
                    
"searchable"=>1,
                    
"searchpolicy"=>'exact'),
        
"relation"  => array("label"=>"Relationship",
                    
"type"=>"string",
                    
"sortable"=>1,
                    
"searchable"=>1,
                    
"searchpolicy"=>'exact'),
        
"uri"       => array("label"=>"Destination",
                    
"type"=>"string",
                    
"searchable"=>1,
                    
"searchpolicy"=>'partial',
                    
"function"=>"mycallbackfunc"),
        
"title"     => array("label"=>"Link Title",
                    
"type"=>"string",
                    
"searchable"=>1,
                    
"searchpolicy"=>'partial'),
        
"lang"      => array("displayable"=>0),
        
"type"      => array("displayable"=>0),
        
"media"     => array("displayable"=>0)
    );

    
// Define "mycallbackfunc"
    
function mycallbackfunc ($dummy1$dummy2$url)
    {
        if (
preg_match("/^http.\/\//",$url))
            return 
"<a href=\"$url\">$url</a>";
        
$url preg_replace('/^\.\//'''$url);
        return 
"<a href=\"http://tobyinkster.co.uk/$url\">http://tobyinkster.co.uk/$url</a>"
    }
    
    
// Finally: call the function
    
display_table($columns$table$database$options);

?>