Login   Register  
PHP Classes
elePHPant
Icontem

File: knowmoredemo.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of John Kawakami  >  KnowMore  >  knowmoredemo.php  >  Download  
File: knowmoredemo.php
Role: Example script
Content type: text/plain
Description: A script to show off features.
Class: KnowMore
Extract links about companies listed in KnowMore
Author: By
Last change:
Date: 2006-08-02 04:35
Size: 1,349 bytes
 

Contents

Class file image Download
<?php
/**
 * This is a script that shows off the KnowMore class.
 */
include('knowmore.php');

$w = new KnowMore();

if (
$_GET['select'])
{
    list( 
$url$name ) = $w->select($_GET['select']);
    print 
"<a href='http://knowmore.org$url'>$name</a>";
    exit;
}

if (
$_POST['text'])
{
    
$output $w->knoWiki$_POST['text'] );
    print 
$output;
    exit;
}
?>
<html>

<h1>Search</h1>
This form searchs the database for a company.  Near matches work.
It uses the select() method.
<form>
    Search: <input type="text" name="select">
    <input type="submit">
</form>

<hr>
<h1>WikiFication</h1>

This field can convert text with [braces] around company names into linked text.  It's useful if you want to 
link your content to knowmore.org.  It uses the knoWiki() method.
<br>
<form method="POST">
    <textarea name="text" rows="4" cols="40">[McDonalds], [Yum], [Pepsi], [Coca Cola], [Ford], [General Motors], and [Sears].</textarea>
    <input type="submit" value="Link Up">
</form>

<h1>Listing</h1>
<p>
This is a listing of the entire database.  It's done completely in javascript, and shows off the asJsArray() method.
</p>
<script type="text/javascript">
KnowMoreDb = <?=$w->asJsArray()?>

for( i=0; i < KnowMoreDb.length; i++ )
{
    name = KnowMoreDb[i][0];
    url = KnowMoreDb[i][1];
    document.write( '<a href="' + url + '">' + name + '</a><br>' );
}

</script>
</html>