PHP Classes

File: test_link.php

Recommend this page to a friend!
  Classes of MT Jordan   link.class.php   test_link.php   Download  
File: test_link.php
Role: Example script
Content type: text/plain
Description: Dynamic Links Class demo
Class: link.class.php
Auto generate URL and image links
Author: By
Last change: Updated demo
Date: 21 years ago
Size: 6,213 bytes
 

Contents

Class file image Download
<?php
include_once 'link.class.php';
$link = new dyna_links;
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Emmsoft.com - Dynamic Link Class</title>
<style type="text/css">
<!--
body {
font-family: verdana,helvetica,arial,sans-serif;
font-size: 11px;
}
h1 {
font-family: verdana,helvetica,arial,sans-serif;
font-size: 16pt;
font-weight: bold;
}
h2 {
font-family: verdana,helvetica,arial,sans-serif;
font-size: 13pt;
font-weight: bold;
}
a:active, a:link, a:visited {
font-family: verdana,helvetica,arial,sans-serif;
font-size: 12px;
color: blue;
}
a:hover {
font-family: verdana,helvetica,arial,sans-serif;
font-size: 12px;
color: red;
}
a.nav:active, a.nav:link, a.nav:visited {
font-family: verdana,helvetica,arial,sans-serif;
font-size: 12px;
color: purple;
}
a.nav:hover {
font-family: verdana,helvetica,arial,sans-serif;
font-size: 12px;
color: orange;
}
a.foot:active, a.foot:link, a.foot:visited {
font-family: verdana,helvetica,arial,sans-serif;
font-size: 11px;
}
a.foot:hover {
font-family: verdana,helvetica,arial,sans-serif;
font-size: 11px;
}
-->
</style>

</head>
<body>
<h1>Dynamic Link Class</h1>
<p>Dynamic Link Class is a PHP script written to generate uniform and accessible links for any webpage or intranet application. The width and height attributes for images are automatically generated by the getimagesize() function or can be entered as user defined arguments. Link title tips default to the link anchor text if left empty or URL if link anchor text left empty and alternate text for images defaults to the filename and path if left empty. E-mail links are automatically encoded to equivilent HTML entities to avoid e-mail spambots.</p>

<?php

if($_GET['demo'] != 1)
{
    echo
$link->text('link_class.zip','Download link_class.zip','Download Dynamic Link Class','','');
    echo
'<br><br>';
}

echo
'<hr>';
?>
<h2>Declare Class</h2>
<font color="#000000"><code>
<font color="#0000BB">&lt;?php</font><br>
<br><font color="#007700">include_once </font><font color="#DD0000">'path/to/link.class.php'</font><font color="#007700">;</font>
</font>
</code><br><code><font color="#000000">
<font color="#0000BB">$link </font><font color="#007700">= new </font><font color="#0000BB">dyna_link</font><font color="#007700">; </font><br>
<br><font color="#0000BB">?&gt;</font></code>
</font>

<?php
echo '<br><br>';

echo
'<hr>';

echo
'<h2>Static Image</h2>';

$img = '<?php echo $link->img(\'images/about.gif\',\'\',\'\',1,\'\'); ?>';
$img2 = '<?php echo $link->img(\'image path\',width,height,bordersize,\'alt= text\'); ?>';

echo
'Usage: ';
highlight_string($img2);
echo
'<br>';
echo
'Example: ';
highlight_string($img);

echo
'<p>Note: If bordersize left empty or isn\'t a numeric, defaults to 0<br>Note: Alternate text defaults to image file name if left empty<br>Note: If width or height left empty or are not numeric, default to the getimagesize() function</p>';

echo
$link->img('images/about.gif','','','','');

echo
'<hr>';

echo
'<h2>Clickable Image Link</h2>';

$img_link = '<?php echo $link->img_link(\'images/about.gif\',\'\',\'\',\'\',\'http://google.com\',\'Go to some file\',\'_blank\'); ?>';
$img_link2 = '<?php echo $link->img_link(\'path to image\',width,height,bordersize,\'URL to go to\',\'alt= text\',\'target\'); ?>';
$img_link3 = '<?php echo $link->img_link(\'images/about.gif\',\'\',\'\',\'\',\'me@me.com\',\'Contact Me\',\'\'); ?>';

echo
'Usage: ';
highlight_string($img_link2);
echo
'<br>';
echo
'Example: ';
highlight_string($img_link);
echo
'<br>';
echo
'Example: ';
highlight_string($img_link3);

echo
'<p>Note: Leave target argument empty for _self or e-mail link<br>Note: If bordersize left empty or isn\'t a numeric, defaults to 0<br>Note: Alternate text defaults to Go to URL if left empty<br>Note: E-mail address is encoded automatically to equivilent HTML entities to avoid e-mail spambots<br>Note: If width or height left empty or are not numeric, default to the getimagesize() function</p>';

echo
$link->img_link('images/about.gif','','',1,'http://google.com','Go to some file','_empty');

echo
'<hr>';

echo
'<h2>Text Link</h2>';

$_link = '<?php echo $link->text(\'URL to go to\',\'link text\',\'link title tip\',\'CSS classID\',\'target\'); ?>';
$_link2 = '<?php echo $link->text(\'http://google.com\',\'Search Web\',\'Search with Google\',\'navID\',\'_blank\'); ?>';
$_email = '<?php echo $link->text(\'me@me.com\',\'Contact\',\'Contact Me\',\'navID\',\'\'); ?>';


echo
'Usage: ';
highlight_string($_link);
echo
'<br>';
echo
'Example: ';
highlight_string($_link2);
echo
'<br>';
echo
'Example: ';
highlight_string($_email);

echo
'<p>Note: Leave target argument empty for _self or e-mail link<br>Note: Link text defaults to link URL or encoded e-mail address if left empty<br>Note: Tooltip defaults to link text. Defaults to goto URL or encoded e-mail address if link text left empty<br>Note: E-mail address is encoded automatically to equivilent HTML entities to avoid e-mail spambots</p>';

echo
$link->text('http://google.com','','','','_empty');

echo
'<hr>';

echo
'<h2>Javascript History Link</h2>';

$JS = '<?php echo $link->JS(\'# of pages to jump\',\'link text\',\'link title tip\',\'CSS classID\'); ?>';
$JS2 = '<?php echo $link->JS(-1,\'Back\',\'Return to Previous Page\',\'navID\'); ?>';

echo
'Usage: ';
highlight_string($JS);
echo
'<br>';
echo
'Example: ';
highlight_string($JS2);

echo
'<p>Note: Tooltip defaults to link text if left empty<br>Note: "# of pages to jump" defaults to 0 if left empty or isn\'t a numeric</p>';

echo
$link->JS(-1,'Previous','Return to previous page','navID');

echo
'<hr>';

echo
'<h2>Back to Top Link</h2>';

$JS = '<?php echo $link->top(\'link text\',\'link title tip\',\'CSS classID\'); ?>';
$JS2 = '<?php echo $link->top(\'\',\'Top of Page\',\'\'); ?>';

echo
'Usage: ';
highlight_string($JS);
echo
'<br>';
echo
'Example: ';
highlight_string($JS2);

echo
'<p>Note: Link text and tooltip default to "Back to Top" if left empty</p>';

echo
$link->top('','Return to top of Page','');
?>
<hr>
<?php echo $link->text('mtjo@netzero.net','','','foot',''); ?><br>
Copyright &copy; 2003 Emmsoft.com<br>
GPL License<br>
Updated: May 30, 2003
</body>
</html>