paristemi
[ class tree: paristemi ] [ index: paristemi ] [ all elements ]

Source for file util_html.php

Documentation is available at util_html.php

  1. <?php
  2. /**
  3. * <b>Utility Class : HTML</b><br />
  4. * A collection of utility functions for creating HTML.
  5. * Creates tables, specific forms, and specific links.
  6. * Map Link creates a link to specified location map on Map Quest.
  7. * Pay Pal Form creates a form for pre-entering Pay Pal form.
  8. * @author Kristen O'Brien <kristen_paristemi-com>
  9. * @copyright Copyright 2004, Kristen O'Brien
  10. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11. * @link http://www.paristemi.com Paristemi Main Site
  12. * @link http://www.mapquest.com Map Quest
  13. * @link http://www.paypal.com PayPal
  14. * @package paristemi
  15. * @subpackage paristemi_util
  16. * @since Build 0.7
  17. * @version Build 0.7
  18. * @filesource
  19. */
  20. /**
  21. * Include the constants file and all of the files in the include list
  22. */
  23. if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
  24. if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
  25. else { require_once("../constants.php"); }
  26. }
  27. else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
  28. /**
  29. * Utility Class : HTML
  30. * A collection of utility functions for creating HTML.
  31. * Creates tables, specific forms, and specific links.
  32. * Map Link creates a link to specified location map on Map Quest.
  33. * Pay Pal Form creates a form for pre-entering Pay Pal form.
  34. * @author Kristen O'Brien <kristen_paristemi-com>
  35. * @copyright Copyright &copy; 2004, Kristen O'Brien
  36. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  37. * @link http://www.paristemi.com Paristemi Main Site
  38. * @link http://www.mapquest.com Map Quest
  39. * @link http://www.paypal.com PayPal
  40. * @package paristemi
  41. * @subpackage paristemi_util
  42. * @since Build 0.7
  43. * @version Build 0.7
  44. * @filesource
  45. */
  46. class UtilHtml {
  47. function HideEmailAddress($email,$linktext) {
  48. $emailarr = explode("@",$email);
  49. $emailtext = '<script language="JavaScript" type="text/javascript">';
  50. $emailtext .= "<!-- \ndocument.write('<a href=\"mailto:');";
  51. $emailtext .= "document.write('".$emailarr[0]."');";
  52. $emailtext .= "document.write('@');";
  53. $emailtext .= "document.write('".$emailarr[1]."');";
  54. $emailtext .= "document.write('\">');";
  55. if(strcmp($email,$linktext) == 0) {
  56. $emailtext .= "document.write('".$emailarr[0]."');";
  57. $emailtext .= "document.write('@');";
  58. $emailtext .= "document.write('".$emailarr[1]."');";
  59. $emailtext .= "document.write('</a>');";
  60. $emailtext .= "\n //--> </script>";
  61. }
  62. else {
  63. $emailtext .= "\n //--> </script>";
  64. $emailtext .= $linktext."</a>";
  65. }
  66. return $emailtext;
  67. }
  68. function createTable($tblarr,$tblheader="",$tblclass="",$tblfooter="",
  69. $tbltrclass="",$tbltdclass="") {
  70. $tbl = '<table';
  71. if($tblclass != "") { $tbl .= ' class="'.$tblclass.'"'; }
  72. $tbl .= '>'."\r\n";
  73. if($tblheader != "") {
  74. $tbl .= '<thead>'."\r\n".'<tr';
  75. if($tbltrclass != "") { $tbl .= ' class="'.$tbltrclass.'"'; }
  76. $tbl .= '>'."\r\n";
  77. if(is_array($tblheader)) {
  78. if(isset($tblheader[1])) {
  79. if(is_array($tblheader[1])) {
  80. $tbl .= '<th colspan="'.count($tblheader[1]).'"';
  81. $tbl .= '>'.$tblheader[0].'</th></tr>'."\r\n";
  82. $tbl .= '<tr';
  83. if($tbltrclass != "") { $tbl .= ' class="'.$tbltrclass.'"'; }
  84. $tbl .= '>'."\r\n";
  85. $thcount = 1;
  86. foreach($tblheader[1] as $thheader) {
  87. $tbl .= '<th';
  88. if($tbltdclass != "") {
  89. $tbl .= ' class="';
  90. if(is_array($tbltdclass)) { $tbl .= $tbltdclass[$thcount-1]; }
  91. else { $tbl .= $tbltdclass; }
  92. $tbl .= '"';
  93. }
  94. $tbl .= '>'.$thheader.'</th>'."\r\n";
  95. $thcount++;
  96. }
  97. }
  98. else {
  99. $tdcount = 0;
  100. foreach($tblheader as $heading) {
  101. $tbl .= '<th';
  102. if($tbltdclass != "") {
  103. if(is_array($tbltdclass)) {
  104. $tbl .= ' class="'.$tbltdclass[$tdcount].'"';
  105. $tdcount++;
  106. }
  107. else { $tbl .= ' class="'.$tbltdclass.'"'; }
  108. }
  109. $tbl .= '>'.$heading.'</th>'."\r\n";
  110. }
  111. }
  112. }
  113. }
  114. else {
  115. $tbl .= '<th';
  116. if(isset($tblarr[0])) { $tbl .= ' colspan="'.count($tblarr[0]).'"'; }
  117. $tbl .= ' class="tblheader">'.$tblheader.'</th>'."\r\n";
  118. }
  119. $tbl .= '</tr>'."\r\n".'</thead>'."\r\n";
  120. }
  121. if($tblarr != null) {
  122. $tbl .= '<tbody>'."\r\n";
  123. foreach($tblarr as $tblrow) {
  124. $tbl .= '<tr';
  125. if($tbltrclass != "") { $tbl .= ' class="'.$tbltrclass.'"'; }
  126. $tbl .= '>'."\r\n";
  127. if(isset($tblrow[0])) {
  128. for($i=0;$i<count($tblrow);$i++) {
  129. $tbl .= '<td';
  130. if(is_array($tbltdclass)) { $tbl .= ' class="'.$tbltdclass[$i].'"'; }
  131. else if($tbltdclass != "") { $tbl .= ' class="'.$tbltdclass.'"'; }
  132. $tbl .='>'.$tblrow[$i].'</td>'."\r\n";
  133. }
  134. }
  135. $tbl .= '</tr>'."\r\n";
  136. }
  137. $tbl .= '</tbody>'."\r\n";
  138. }
  139. if($tblfooter != "") {
  140. $tbl .= '<tfoot>'."\r\n".'<tr>'."\r\n".'<th colspan="'.count($tblarr[0]).'">'."\r\n";
  141. $tbl .= $tblfooter.'</th>'."\r\n".'</tr>'."\r\n".'</tfoot>'."\r\n";
  142. }
  143. $tbl .= '</table>'."\r\n";
  144. return $tbl;
  145. }
  146.  
  147. function mapLink(&$value) {
  148. $maplink = "<a href=\"http://www.mapquest.com/maps/map.adp?city=";
  149. $tok = strtok($value->City," ");
  150. while ($tok) {
  151. $maplink .= $tok."+";
  152. $tok = strtok(" ");
  153. }
  154. $maplink .= "&amp;state=".$value->State."&amp;address=";
  155. $full_address = $value->Address." ".$value->Address2;
  156. $tok = strtok($full_address," ");
  157. while ($tok) {
  158. $maplink .= $tok."+";
  159. $tok = strtok(" ");
  160. }
  161. $maplink .= "&amp;zip=".$value->Zip."&amp;country=".$GLOBALS['COUNTRY']."&amp;zoom=8";
  162. $maplink .= "\">".$value->Name."</a>";
  163. return $maplink;
  164. }
  165. function createPayPalForm($itemname,$cost,$itemnum,$note="",$returnurl="",$cancelurl="",
  166. $language="US",$noshowshipping=0,$tax=0,$shipping=0,$hiddenvals=null) {
  167. if($returnurl == "") { $returnurl = $GLOBALS['HTTP_DOCUMENT_ROOT']; }
  168. if($cancelurl == "") { $cancelurl = $GLOBALS['HTTP_DOCUMENT_ROOT']; }
  169. $form = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
  170. $form .= '<input type="hidden" name="cmd" value="_ext-enter" />';
  171. $form .= '<input type="hidden" name="redirect_cmd" value="_xclick" />';
  172. $form .= '<input type="hidden" name="no_shipping" value="'.$noshowshipping.'" />';
  173. $form .= '<input type="hidden" name="tax" value="'.$tax.'" />';
  174. $form .= "<input type=\"hidden\" name=\"business\" value=\"".$GLOBALS['PAY_PAL_USER_NAME']."\" />";
  175. $form .= "<input type=\"hidden\" name=\"item_name\" value=\"".$itemname."\" />";
  176. if($cost != 0) { $form .= '<input type="hidden" name="amount" value="'.$cost.'" />'; }
  177. $form .= '<input type="hidden" name="item_number" value="'.$itemnum.'" />';
  178. $form .= "<input type=\"hidden\" name=\"return\" value=\"".$returnurl."\" />";
  179. $form .= "<input type=\"hidden\" name=\"cancel_return\" value=\"".$cancelurl."\" />";
  180. $form .= "<input type=\"hidden\" name=\"cn\" value=\"".$note."\" />";
  181. $form .= '<input type="hidden" name="lc" value="'.$language.'" />';
  182. $form .= '<input type="hidden" name="currency_code" value="'.$GLOBALS['PAY_PAL_CURRENCY_CODE'].'" />';
  183. if($hiddenvals != null) {
  184. foreach($hiddenvals as $hiddenname => $hiddenvalue) {
  185. $form .= '<input type="hidden" name="'.$hiddenname.'" value="'.$hiddenvalue.'" />';
  186. }
  187. }
  188. $form .= '<p>'.$GLOBALS['S_FORM_FIRST_NAME'].': <input type="text" name="first_name" /></p>';
  189. $form .= '<p>'.$GLOBALS['S_FORM_LAST_NAME'].': <input type="text" name="last_name" /></p>';
  190. $form .= '<p>'.$GLOBALS['S_FORM_ADDRESS']." ".$GLOBALS['S_LINE_ONE'].': <input type="text" name="address1" /></p>';
  191. $form .= '<p>'.$GLOBALS['S_FORM_ADDRESS']." ".$GLOBALS['S_LINE_TWO'].': <input type="text" name="address2" /></p>';
  192. $form .= '<p>'.$GLOBALS['S_FORM_CITY'].': <input type="text" name="city" /></p>';
  193. $form .= '<p>'.$GLOBALS['S_FORM_STATE_ABRV'].': <input type="text" name="state" size="2" maxlength="2" /></p>';
  194. $form .= '<p>'.$GLOBALS['S_FORM_POSTAL_CODE'].': <input type="text" name="zip" size="8" /></p>';
  195. $form .= '<p>'.$GLOBALS['S_FORM_PHONE']." (".$GLOBALS['S_DAY'].")".': <input type="text" name="day_phone_a" size="3" maxlength="3" /> - ';
  196. $form .= '<input type="text" name="day_phone_b" size="3" maxlength="3" /> - ';
  197. $form .= '<input type="text" name="day_phone_c" size="4" maxlength="4" /></p>';
  198. $form .= '<p>'.$GLOBALS['S_FORM_PHONE']." (".$GLOBALS['S_NIGHT'].")".': <input type="text" name="night_phone_a" size="3" maxlength="3" /> - ';
  199. $form .= '<input type="text" name="night_phone_b" size="3" maxlength="3" /> - ';
  200. $form .= '<input type="text" name="night_phone_c" size="4" maxlength="4" /></p>';
  201. if($cost == 0) { $form .= '<p>'.$GLOBALS['S_FORM_AMOUNT'].' ('.$GLOBALS['PAY_PAL_CURRENCY_CODE'].'): <input type="text" name="amount" size="8" /></p>'; }
  202. $form .= '<p><em>'.$GLOBALS['S_NOTE_PAY_PAL'].'</em></p>';
  203. $form .= '<p><input type="submit" name="Submit" value="'.$GLOBALS['S_FORM_SUBMIT'].'" /></p></form>';
  204. return $form;
  205. }
  206. }
  207. ?>

Documentation generated on Mon, 10 May 2004 12:11:12 -0700 by phpDocumentor 1.3.0RC3