- <?php
- /**
- * <b>Utility Class : HTML</b><br />
- * A collection of utility functions for creating HTML.
- * Creates tables, specific forms, and specific links.
- * Map Link creates a link to specified location map on Map Quest.
- * Pay Pal Form creates a form for pre-entering Pay Pal form.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @link http://www.mapquest.com Map Quest
- * @link http://www.paypal.com PayPal
- * @package paristemi
- * @subpackage paristemi_util
- * @since Build 0.7
- * @version Build 0.7
- * @filesource
- */
- /**
- * Include the constants file and all of the files in the include list
- */
- if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
- if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
- else { require_once("../constants.php"); }
- }
- else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
-
- /**
- * Utility Class : HTML
- * A collection of utility functions for creating HTML.
- * Creates tables, specific forms, and specific links.
- * Map Link creates a link to specified location map on Map Quest.
- * Pay Pal Form creates a form for pre-entering Pay Pal form.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright © 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @link http://www.mapquest.com Map Quest
- * @link http://www.paypal.com PayPal
- * @package paristemi
- * @subpackage paristemi_util
- * @since Build 0.7
- * @version Build 0.7
- * @filesource
- */
- class UtilHtml {
-
- function HideEmailAddress($email,$linktext) {
- $emailarr = explode("@",$email);
- $emailtext = '<script language="JavaScript" type="text/javascript">';
- $emailtext .= "<!-- \ndocument.write('<a href=\"mailto:');";
- $emailtext .= "document.write('".$emailarr[0]."');";
- $emailtext .= "document.write('@');";
- $emailtext .= "document.write('".$emailarr[1]."');";
- $emailtext .= "document.write('\">');";
- if(strcmp($email,$linktext) == 0) {
- $emailtext .= "document.write('".$emailarr[0]."');";
- $emailtext .= "document.write('@');";
- $emailtext .= "document.write('".$emailarr[1]."');";
- $emailtext .= "document.write('</a>');";
- $emailtext .= "\n //--> </script>";
- }
- else {
- $emailtext .= "\n //--> </script>";
- $emailtext .= $linktext."</a>";
- }
- return $emailtext;
- }
-
- function createTable($tblarr,$tblheader="",$tblclass="",$tblfooter="",
- $tbltrclass="",$tbltdclass="") {
- $tbl = '<table';
- if($tblclass != "") { $tbl .= ' class="'.$tblclass.'"'; }
- $tbl .= '>'."\r\n";
- if($tblheader != "") {
- $tbl .= '<thead>'."\r\n".'<tr';
- if($tbltrclass != "") { $tbl .= ' class="'.$tbltrclass.'"'; }
- $tbl .= '>'."\r\n";
- if(is_array($tblheader)) {
- if(isset($tblheader[1])) {
- if(is_array($tblheader[1])) {
- $tbl .= '<th colspan="'.count($tblheader[1]).'"';
- $tbl .= '>'.$tblheader[0].'</th></tr>'."\r\n";
- $tbl .= '<tr';
- if($tbltrclass != "") { $tbl .= ' class="'.$tbltrclass.'"'; }
- $tbl .= '>'."\r\n";
- $thcount = 1;
- foreach($tblheader[1] as $thheader) {
- $tbl .= '<th';
- if($tbltdclass != "") {
- $tbl .= ' class="';
- if(is_array($tbltdclass)) { $tbl .= $tbltdclass[$thcount-1]; }
- else { $tbl .= $tbltdclass; }
- $tbl .= '"';
- }
- $tbl .= '>'.$thheader.'</th>'."\r\n";
- $thcount++;
- }
- }
- else {
- $tdcount = 0;
- foreach($tblheader as $heading) {
- $tbl .= '<th';
- if($tbltdclass != "") {
- if(is_array($tbltdclass)) {
- $tbl .= ' class="'.$tbltdclass[$tdcount].'"';
- $tdcount++;
- }
- else { $tbl .= ' class="'.$tbltdclass.'"'; }
- }
- $tbl .= '>'.$heading.'</th>'."\r\n";
- }
- }
- }
- }
- else {
- $tbl .= '<th';
- if(isset($tblarr[0])) { $tbl .= ' colspan="'.count($tblarr[0]).'"'; }
- $tbl .= ' class="tblheader">'.$tblheader.'</th>'."\r\n";
- }
- $tbl .= '</tr>'."\r\n".'</thead>'."\r\n";
- }
- if($tblarr != null) {
- $tbl .= '<tbody>'."\r\n";
- foreach($tblarr as $tblrow) {
- $tbl .= '<tr';
- if($tbltrclass != "") { $tbl .= ' class="'.$tbltrclass.'"'; }
- $tbl .= '>'."\r\n";
- if(isset($tblrow[0])) {
- for($i=0;$i<count($tblrow);$i++) {
- $tbl .= '<td';
- if(is_array($tbltdclass)) { $tbl .= ' class="'.$tbltdclass[$i].'"'; }
- else if($tbltdclass != "") { $tbl .= ' class="'.$tbltdclass.'"'; }
- $tbl .='>'.$tblrow[$i].'</td>'."\r\n";
- }
- }
- $tbl .= '</tr>'."\r\n";
- }
- $tbl .= '</tbody>'."\r\n";
- }
- if($tblfooter != "") {
- $tbl .= '<tfoot>'."\r\n".'<tr>'."\r\n".'<th colspan="'.count($tblarr[0]).'">'."\r\n";
- $tbl .= $tblfooter.'</th>'."\r\n".'</tr>'."\r\n".'</tfoot>'."\r\n";
- }
- $tbl .= '</table>'."\r\n";
- return $tbl;
- }
-
- function mapLink(&$value) {
- $maplink = "<a href=\"http://www.mapquest.com/maps/map.adp?city=";
- $tok = strtok($value->City," ");
- while ($tok) {
- $maplink .= $tok."+";
- $tok = strtok(" ");
- }
- $maplink .= "&state=".$value->State."&address=";
- $full_address = $value->Address." ".$value->Address2;
- $tok = strtok($full_address," ");
- while ($tok) {
- $maplink .= $tok."+";
- $tok = strtok(" ");
- }
- $maplink .= "&zip=".$value->Zip."&country=".$GLOBALS['COUNTRY']."&zoom=8";
- $maplink .= "\">".$value->Name."</a>";
- return $maplink;
- }
-
- function createPayPalForm($itemname,$cost,$itemnum,$note="",$returnurl="",$cancelurl="",
- $language="US",$noshowshipping=0,$tax=0,$shipping=0,$hiddenvals=null) {
- if($returnurl == "") { $returnurl = $GLOBALS['HTTP_DOCUMENT_ROOT']; }
- if($cancelurl == "") { $cancelurl = $GLOBALS['HTTP_DOCUMENT_ROOT']; }
- $form = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
- $form .= '<input type="hidden" name="cmd" value="_ext-enter" />';
- $form .= '<input type="hidden" name="redirect_cmd" value="_xclick" />';
- $form .= '<input type="hidden" name="no_shipping" value="'.$noshowshipping.'" />';
- $form .= '<input type="hidden" name="tax" value="'.$tax.'" />';
- $form .= "<input type=\"hidden\" name=\"business\" value=\"".$GLOBALS['PAY_PAL_USER_NAME']."\" />";
- $form .= "<input type=\"hidden\" name=\"item_name\" value=\"".$itemname."\" />";
- if($cost != 0) { $form .= '<input type="hidden" name="amount" value="'.$cost.'" />'; }
- $form .= '<input type="hidden" name="item_number" value="'.$itemnum.'" />';
- $form .= "<input type=\"hidden\" name=\"return\" value=\"".$returnurl."\" />";
- $form .= "<input type=\"hidden\" name=\"cancel_return\" value=\"".$cancelurl."\" />";
- $form .= "<input type=\"hidden\" name=\"cn\" value=\"".$note."\" />";
- $form .= '<input type="hidden" name="lc" value="'.$language.'" />';
- $form .= '<input type="hidden" name="currency_code" value="'.$GLOBALS['PAY_PAL_CURRENCY_CODE'].'" />';
-
- if($hiddenvals != null) {
- foreach($hiddenvals as $hiddenname => $hiddenvalue) {
- $form .= '<input type="hidden" name="'.$hiddenname.'" value="'.$hiddenvalue.'" />';
- }
- }
-
- $form .= '<p>'.$GLOBALS['S_FORM_FIRST_NAME'].': <input type="text" name="first_name" /></p>';
- $form .= '<p>'.$GLOBALS['S_FORM_LAST_NAME'].': <input type="text" name="last_name" /></p>';
- $form .= '<p>'.$GLOBALS['S_FORM_ADDRESS']." ".$GLOBALS['S_LINE_ONE'].': <input type="text" name="address1" /></p>';
- $form .= '<p>'.$GLOBALS['S_FORM_ADDRESS']." ".$GLOBALS['S_LINE_TWO'].': <input type="text" name="address2" /></p>';
- $form .= '<p>'.$GLOBALS['S_FORM_CITY'].': <input type="text" name="city" /></p>';
- $form .= '<p>'.$GLOBALS['S_FORM_STATE_ABRV'].': <input type="text" name="state" size="2" maxlength="2" /></p>';
- $form .= '<p>'.$GLOBALS['S_FORM_POSTAL_CODE'].': <input type="text" name="zip" size="8" /></p>';
- $form .= '<p>'.$GLOBALS['S_FORM_PHONE']." (".$GLOBALS['S_DAY'].")".': <input type="text" name="day_phone_a" size="3" maxlength="3" /> - ';
- $form .= '<input type="text" name="day_phone_b" size="3" maxlength="3" /> - ';
- $form .= '<input type="text" name="day_phone_c" size="4" maxlength="4" /></p>';
- $form .= '<p>'.$GLOBALS['S_FORM_PHONE']." (".$GLOBALS['S_NIGHT'].")".': <input type="text" name="night_phone_a" size="3" maxlength="3" /> - ';
- $form .= '<input type="text" name="night_phone_b" size="3" maxlength="3" /> - ';
- $form .= '<input type="text" name="night_phone_c" size="4" maxlength="4" /></p>';
- if($cost == 0) { $form .= '<p>'.$GLOBALS['S_FORM_AMOUNT'].' ('.$GLOBALS['PAY_PAL_CURRENCY_CODE'].'): <input type="text" name="amount" size="8" /></p>'; }
- $form .= '<p><em>'.$GLOBALS['S_NOTE_PAY_PAL'].'</em></p>';
- $form .= '<p><input type="submit" name="Submit" value="'.$GLOBALS['S_FORM_SUBMIT'].'" /></p></form>';
-
- return $form;
- }
- }
- ?>