PageRenderTime 67ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/component/site/views/subroutines.php

http://gigcalendar3.googlecode.com/
PHP | 686 lines | 527 code | 63 blank | 96 comment | 235 complexity | f5aa611a9eabe4a379b841df029af5e8 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: subroutines.php 1124 2005-12-15 06:37:21Z gsbe $
  4. * @package gigCalendar
  5. * @copyright Copyright (C) 2005 nuthin' werked. All rights reserved.
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  7. * This file is part of gigCalendar.
  8. * gigCalendar is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * gigCalendar is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with gigCalendar; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * See COPYRIGHT.php for copyright notices and details.
  23. */
  24. defined('_JEXEC') or die('Restricted access');
  25. function getAccessLevel() {
  26. global $my;
  27. $gid=$my->gid;
  28. return $gid;
  29. }
  30. function dbLookupDetails($what, $id)
  31. {
  32. $db =& JFactory::GetDBO();
  33. $sql='SELECT * FROM #__gigcal_'.$what.'s WHERE id='.$id;
  34. //error_log($sql);
  35. $db->setQuery($sql);
  36. return $db->loadAssoc();
  37. }
  38. function dbLookupFieldnames($display)
  39. {
  40. $db =& JFactory::GetDBO();
  41. $sql='SELECT fieldname FROM #__gigcal_'.$display.'_fields WHERE published=1 ORDER BY ordering';
  42. //error_log($sql);
  43. $db->setQuery($sql);
  44. return $db->loadResultArray();
  45. }
  46. function maplink($street, $street2, $city, $state, $zip, $country, $type="r")
  47. {
  48. //Initialize local variables.
  49. $Mlink = ""; //Return value
  50. //Strip periods, commas, leading, and tailing spaces from street, city,
  51. $street = trim($street);
  52. $street = str_replace('.','',$street);
  53. $street = str_replace(',','',$street);
  54. $street = str_replace(' ','+',$street);
  55. $street2 = trim($street2);
  56. $street2 = str_replace('.','',$street2);
  57. $street2 = str_replace(',','',$street2);
  58. $street2 = str_replace(' ','+',$street2);
  59. $city = trim($city);
  60. $city = str_replace('.','',$city);
  61. $city = str_replace(',','',$city);
  62. $city = str_replace(' ','+',$city);
  63. $zip = trim($zip);
  64. $country = trim($country);
  65. $state = trim($state);
  66. $Mlink = "http://maps.google.com/maps?q=" . $street . " " . $street2 . " " . $city . " " . $state . " " . $zip . " " . $country . "&hl=en";
  67. $Mlink = str_replace(" ", "+", $Mlink);
  68. $Mlink = str_replace("++", "+", $Mlink);
  69. global $config;
  70. if($type == "r") $Mlink = "<a target=\"_blank\" href=\"$Mlink\">";
  71. if($type == "l") $Mlink = "<a alt=\"$config[list_maplink_name]\" title=\"$config[list_maplink_name]\" target=\"_blank\" href=\"$Mlink\">";
  72. if($type == "a") $Mlink = "<a alt=\"$config[alist_maplink_name]\" title=\"$config[alist_maplink_name]\" target=\"_blank\" href=\"$Mlink\">";
  73. return $Mlink;
  74. }
  75. function date_reformater ($value) {
  76. $value = str_replace("%weekday", "l", $value);
  77. $value = str_replace("%wkdy", "D", $value);
  78. $value = str_replace("%month", "F", $value);
  79. $value = str_replace("%2nmonth", "m", $value);
  80. $value = str_replace("%day", "j", $value);
  81. $value = str_replace("%ordday", "jS", $value);
  82. $value = str_replace("%2year", "y", $value);
  83. $value = str_replace("%year", "Y", $value);
  84. $value = str_replace("%nmonth", "n", $value);
  85. $value = str_replace("%mon", "M", $value);
  86. /*
  87. %weekday Day of the week from language file Wednesday
  88. %wkdy. Abbreviated weekday from language file Wed.
  89. %wkdy Abbreviated weekday from language file, no period Wed
  90. %hour Hour of the day, in 12-hour (AM/PM) format 10
  91. %24hour Hour of the day, in 24-hour format 22
  92. %minute The number of minutes 44
  93. %ampm "am" or "pm" pm
  94. %AMPM "AM" or "PM" PM
  95. %month Name of the month from language file December
  96. %mon. Abbreviated month from language file Dec.
  97. %mon_ Abbreviated month from language file, no period Dec
  98. %nmonth Number of the month 1
  99. %2nmonth Number of the month in 2-digit format 01
  100. %day Number of the day 19
  101. %ordday Ordinal Number of the day (1st, 2st, 3st, 4st...) 19th
  102. %year Number of the year in 4-digit format 2001
  103. %2year Number of the year in 2-digit format 01
  104. */
  105. return $value;
  106. }
  107. function time_reformater ($value) {
  108. $value = str_replace("%hour", "g", $value);
  109. $value = str_replace("%24hour", "G", $value);
  110. $value = str_replace("%minute", "i", $value);
  111. $value = str_replace("%ampm", "a", $value);
  112. $value = str_replace("%AMPM", "A", $value);
  113. return $value;
  114. }
  115. //gigFilterBuilder
  116. // Builds the content of the gig filter (used in alist.php and cal.php)
  117. function gigFilterBuilder ($filter_display_len, $task, $limit, $keywordfilter, $bandfilter, $venuefilter)
  118. {
  119. global $database;
  120. if ($filter_display_len > 0) {
  121. // count some rows
  122. $sqlb = "SELECT band_id, bandname FROM #__gigcal_bands WHERE published=1";
  123. $database->setQuery($sqlb);
  124. $resultsb=$database->loadAssocList();
  125. $sqlv = "SELECT venue_id, venuename FROM #__gigcal_venues WHERE published=1";
  126. $database->setQuery($sqlv);
  127. $resultsv=$database->loadAssocList();
  128. $itemid=$_REQUEST['Itemid'];
  129. $itemidfix="&Itemid=".$itemid;
  130. $link = "index.php?option=com_gigcal&amp;task=".$task.$itemidfix;
  131. if ($limit > 0)
  132. $link .= '&amp;limit='.$limit."&amp;limitstart=0";
  133. $output = "\n".'<form action="'.$link.'" method="post" name="filterForm" id="filterForm" class="filterForm">'."\n";
  134. $output .= '<table>'."\n".' <tbody>'."\n".' <tr>'."\n".' <td>Filter: </td>'."\n";
  135. $output .= ' <td><input type="text" name="keywordfilter" value="'.$keywordfilter.'" class="inputbox" onChange="submit()" /></td>'."\n";
  136. if (count($resultsb) > 1) {
  137. $output .= ' <td><select name="bandfilter" size="1" onChange="submit()">'."\n";
  138. $output .= ' <option value="0">- Select Band -</option>'."\n";
  139. for($i=0; $i<count($resultsb); $i++) {
  140. $output .= ' <option value="'.$resultsb[$i]['band_id'].'"';
  141. if($resultsb[$i]['band_id'] == $bandfilter)
  142. $output .= ' "selected" ';
  143. $output .= '>'.substr($resultsb[$i]['bandname'], 0, $filter_display_len).'</option>'."\n";
  144. }
  145. $output .= '</select></td>'."\n";
  146. }
  147. if (count($resultsv) > 1) {
  148. $output .= ' <td><select name="venuefilter" size="1" onChange="submit()">'."\n";
  149. $output .= ' <option value="0">- Select Venue -</option>'."\n";
  150. for($i=0; $i<count($resultsv); $i++) {
  151. $output .= ' <option value="'.$resultsv[$i]['venue_id'].'"';
  152. if($resultsv[$i]['venue_id'] == $venuefilter)
  153. $output .= ' "selected" ';
  154. $output .= '>'.substr($resultsv[$i]['venuename'], 0, $filter_display_len).'</option>'."\n";
  155. }
  156. $output .= '</select></td>'."\n";
  157. }
  158. $output .= ' </tr>'."\n".' </tbody>'."\n".'</table>'."\n".'</form>';
  159. echo $output;
  160. }
  161. }
  162. // gigContentBuilder
  163. // Builds the content with overlib captions and text
  164. function gigContentBuilder ($config, $display, $gig)
  165. {
  166. $fieldnames = dbLookupFieldnames($display);
  167. $itemid=$_REQUEST['Itemid'];
  168. $itemidfix="&Itemid=".$itemid;
  169. $giglink = JRoute::_("index.php?option=com_gigcal&task=details&id=".$gig['id'].$itemidfix);
  170. $venuelink = JRoute::_("index.php?option=com_gigcal&task=details&venue_id=".$gig['venue_id'].$itemidfix);
  171. $bandlink = JRoute::_("index.php?option=com_gigcal&task=details&band_id=".$gig['band_id'].$itemidfix);
  172. $resultv=dbLookupDetails("venue", $gig['venue_id']);
  173. $resultb=dbLookupDetails("band", $gig['band_id']);
  174. $overlib_params = "";
  175. if($config[$display.'_hover_params'] != "")
  176. $overlib_params = ", " . $config[$display.'_hover_params'];
  177. $config[$display.'_dateformat'] = date_reformater($config[$display.'_dateformat']);
  178. $config[$display.'_dateformat2'] = date_reformater($config[$display.'_dateformat2']);
  179. $config[$display.'_timeformat'] = time_reformater($config[$display.'_timeformat']);
  180. switch ($display) {
  181. case 'list':
  182. case 'alist':
  183. $tag1open = "<tr>";
  184. $tag2open = "<td>";
  185. $tag1close = "</tr>";
  186. $tag2close = "</td>";
  187. break;
  188. case 'cal':
  189. $tag1open = "<dl>";
  190. $tag2open = "<dd>";
  191. $tag1close = "</dl>";
  192. $tag2close = "</dd>";
  193. break;
  194. case 'upcom':
  195. $tag1open = "<div class='mod_gigcal_upcom'>";
  196. $tag2open = " ";
  197. $tag1close = "</div>";
  198. $tag2close = " ";
  199. break;
  200. }
  201. // To eliminate huge tracts of whitespace, we'll build a huge output string as we loop,
  202. // then dump the whole thing to the screen in one go
  203. $output = " ".$tag1open."\n"; // Start building the output string
  204. $itemcount = 0;
  205. foreach($fieldnames as $item) {
  206. $output .= " ".$tag2open;
  207. // Gig Notes / Info
  208. if($item == "gigNotes/Info") {
  209. if($itemcount)
  210. $output .= $config[$display.'_delim'];
  211. if($config[$display.'_giginfo_link'])
  212. $output.= '<a href="'.$giglink.'">';
  213. $output .= $gig["info"];
  214. if($config[$display.'_giginfo_link'])
  215. $output .= '</a>';
  216. }
  217. // Title
  218. if ($item == "gigTitle") {
  219. if($itemcount)
  220. $output .= $config[$display.'_delim'];
  221. if($config[$display.'_gigtitle_hover']) {
  222. $gigtitle_caption = ", CAPTION, '".$gig["gigtitle"]."' ";
  223. $gigtitle_hover = "";
  224. if($config[$display.'_gigtitle_hover_bandname']) $gigtitle_hover .= $resultb["bandname"] . "<br />";
  225. if($config[$display.'_gigtitle_hover_venue']) $gigtitle_hover .= $resultv["venuename"] . "<br />";
  226. if($config[$display.'_gigtitle_hover_date']) $gigtitle_hover .= htmlspecialchars(date($config[$display.'_dateformat'], $gig["gigdate"]), ENT_QUOTES) . "<br />";
  227. if($config[$display.'_gigtitle_hover_time']) $gigtitle_hover .= htmlspecialchars(date($config[$display.'_timeformat'], $gig["gigdate"]), ENT_QUOTES) . "<br />";
  228. $output .= '<span onmouseover="return overlib(\''.htmlspecialchars(addslashes($gigtitle_hover)).'\''.$gigtitle_caption . $overlib_params.');" onmouseout="return nd();">';
  229. }
  230. if($config[$display.'_gigtitle_link']) { $output .= '<a href="'.$giglink.'">'; }
  231. $output .= htmlspecialchars($gig["gigtitle"]);
  232. if($config[$display.'_gigtitle_link']) { $output .= '</a>'; }
  233. if($config[$display.'_gigtitle_hover']) { $output .= '</span>'; }
  234. }
  235. // Cover Charge
  236. if($item == "gigCover Charge") {
  237. if ($gig['covercharge'] != "") {
  238. if($itemcount) {
  239. $output .= $config[$display.'_delim'].$config[$display.'_covercharge_name']." ".$gig['covercharge'];
  240. }
  241. }
  242. }
  243. // Buy Tickets
  244. if($item == "Link to online Ticket Sales") {
  245. if(($gig["saleslink"] != "") && ($gig["saleslink"] != "http://")) {
  246. if($itemcount)
  247. $output .= $config[$display.'_delim'];
  248. $output .= '<a alt="'.$config[$display.'_ticketlink_name'].' " target="_blank" title="'.$config[$display.'_ticketlink_name'].'" href="'.$gig["saleslink"].'">'.$config[$display.'_ticketlink_name'].'</a>';
  249. }
  250. }
  251. // Map Link
  252. if($item == "Link to Map") {
  253. if($itemcount)
  254. $output .= $config[$display.'_delim'];
  255. $output .= maplink($resultv['address1'], $resultv['address2'], $resultv['city'], $resultv['state'], $resultv['zip'], $resultv['country'], "l").$config['list_maplink_name'].'</a>';
  256. }
  257. // iCal Link
  258. if($item == "iCal Link") {
  259. if($itemcount)
  260. $output .= $config[$display.'_delim'];
  261. $output .= '<a alt="'.$config['list_ical_link_name'].'" title="'.$config['list_ical_link_name'].'" href="components/com_gigcal/exporta.php?id='.$gig['id'].'&ext=ics">'.$config['list_ical_link_name'].'</a>';
  262. }
  263. // vCal Link
  264. if($item == "vCal Link") {
  265. if($itemcount)
  266. $output .= $config[$display.'_delim'];
  267. $output .= '<a alt="'.$config['list_vcal_link_name'].'" title="'.$config['list_vcal_link_name'].'" href="components/com_gigcal/exporta.php?id='.$gig['id'].'&ext=vcs">'.$config['list_vcal_link_name'].'</a>';
  268. }
  269. // Band
  270. if($item == "gigBand") {
  271. if($itemcount)
  272. $output .= $config[$display.'_delim'];
  273. if($config[$display.'_gigband_popup']) {
  274. $gigband_caption = "";
  275. if($config[$display.'_gigband_link'] == "nothing") $gigband_caption = $resultb['bandname'];
  276. if($config[$display.'_gigband_link'] == "banddetails") $gigband_caption = "Click to learn more about " . $resultb['bandname'];
  277. if($config[$display.'_gigband_link'] == "gigdetails") $gigband_caption = $resultb['bandname'] . " @ " . $resultv['venuename'] . " " . htmlspecialchars(date($config[$display.'_timeformat'], $gig["gigdate"]));
  278. if(($config[$display.'_gigband_link'] == "bandwebsite") && ($resultb['website'] != "")) $gigband_caption = "Click to visit ".$resultb['bandname']."'s website";
  279. $gigband_caption = ", CAPTION, '" . addslashes($gigband_caption) . "' ";
  280. $nl2br_string = $resultb['bandname']." <br /> ".$resultb['city'].", ".$resultb['state']." <br /> ".$resultb['notes'];
  281. $output .= '<span onmouseover="return overlib(\''.htmlspecialchars(addslashes(str_replace("\r\n", "<br />", nl2br($nl2br_string)))).'\''.$gigband_caption.$overlib_params.');" onmouseout="return nd();">';
  282. }
  283. if($config[$display.'_gigband_link'] != "nothing") {
  284. $showlink = 0;
  285. if(($resultb['website'] != "") && ($resultb['website'] != "http://")) { $showlink = 1; }
  286. if(($config[$display.'_gigband_link'] == "bandwebsite") && ($showlink)) { $output .= "<a target=\"_blank\" href=\"".$resultb['website']."\">"; }
  287. if($config[$display.'_gigband_link'] == "banddetails") { $output.= '<a href="'.$bandlink.'">'; }
  288. if($config[$display.'_gigband_link'] == "gigdetails") { $output .= '<a href="'.$giglink.'">'; }
  289. }
  290. $output .= $resultb["bandname"];
  291. if(($config[$display.'_gigband_link'] != "nothing") && ($config[$display.'_gigband_link'] != "bandwebsite"))
  292. $output .= '</a>';
  293. if(($showlink) && ($config[$display.'_gigband_link'] == "bandwebsite"))
  294. $output .= '</a>';
  295. if($config[$display.'_gigband_popup'])
  296. $output .= '</span>';
  297. }
  298. // Venue
  299. if($item == "gigVenue") {
  300. if($itemcount)
  301. $output .= $config[$display.'_delim'];
  302. if($config[$display.'_gigvenue_popup']) {
  303. $gigvenue_caption = "";
  304. if($config[$display.'_gigvenue_link'] == "nothing") $gigvenue_caption = $resultv['venuename'];
  305. if($config[$display.'_gigvenue_link'] == "gigdetails") { $gigvenue_caption = $resultb['bandname']." @ ".$resultv['venuename'] . " " . htmlspecialchars(date($config['cal_timeformat'], $gig["gigdate"])); }
  306. if($config[$display.'_gigvenue_link'] == "venuedetails") $gigvenue_caption = "Click to learn more about " . $resultv['venuename'];
  307. if($config[$display.'_gigvenue_link'] == "map") $gigvenue_caption = "Click for directions to {$resultv['venuename']}";
  308. if(($config[$display.'_gigvenue_link'] == "venuewebsite") && ($resultv['website'] != "")) $gigvenue_caption = "Click to visit {$resultv['venuename']}'s website";
  309. $gigvenue_caption = ", CAPTION, '" . addslashes($gigvenue_caption) . "' ";
  310. $nl2br_string = $resultv['venuename'].'<br />'.$resultv['city'].','.$resultv['state'].'<br />'.$resultv['phone'].'<br />'.$resultv['info'];
  311. $output .= '<span onmouseover="return overlib(\''.htmlspecialchars(addslashes(str_replace("\r\n", "<br />", nl2br($nl2br_string)))).'\''.$gigvenue_caption.$overlib_params.');" onmouseout="return nd();">';
  312. }
  313. if($config[$display.'_gigvenue_link'] != "nothing") {
  314. $showlink = 0;
  315. if(($resultv['website'] != "") && ($resultv['website'] != "http://")) $showlink = 1;
  316. if(($config[$display.'_gigvenue_link'] == "venuewebsite") && ($showlink)) { $output .= "<a target=\"_blank\" href=\"" . $resultv['website'] . "\">"; }
  317. if($config[$display.'_gigvenue_link'] == "map") $output .= maplink($resultv['address1'], $resultv['address2'], $resultv['city'], $resultv['state'], $resultv['zip'], $resultv['country'], "l");
  318. if($config[$display.'_gigvenue_link'] == "venuedetails") { $output .= '<a href="'.$venuelink.'">'; }
  319. }
  320. $output .= $resultv["venuename"];
  321. if(($config[$display.'_gigvenue_link'] != "nothing") && ($config[$display.'_gigvenue_link'] != "venuewebsite"))
  322. $output .= '</a>';
  323. if(($showlink) && ($config[$display.'_gigvenue_link'] == "venuewebsite"))
  324. $output .= '</a>';
  325. if($config[$display.'_gigvenue_popup'])
  326. $output .= '</span>';
  327. }
  328. // Location
  329. if($item == "Location") {
  330. if($itemcount)
  331. $output .= $config[$display.'_delim'];
  332. if($config[$display.'_location_popup']) {
  333. $giglocation_caption = "";
  334. if($config[$display.'_location_link'] == "nothing") $giglocation_caption = $resultv['venuename'];
  335. if($config[$display.'_location_link'] == "gigdetails") $giglocation_caption = $resultv['venuename'];
  336. if($config[$display.'_location_link'] == "venuedetails") $giglocation_caption = "Click to learn more about " . $resultv['venuename'];
  337. if($config[$display.'_location_link'] == "map") $giglocation_caption = "Click for directions to {$resultv['venuename']}";
  338. if(($config[$display.'_location_link'] == "venuewebsite") && ($resultv['website'] != "")) $giglocation_caption = "Click to visit {$resultv['venuename']}'s website";
  339. $giglocation_caption = ", CAPTION, '" . addslashes($giglocation_caption) . "' ";
  340. $nl2br_string = $resultv['venuename'].'<br />'.$resultv['city'].', '.$resultv['state'].'<br />'.$resultv['phone'].'<br />'.$resultv['info'];
  341. $output .= '<span onmouseover="return overlib(\''.htmlspecialchars(str_replace("\r\n", "<br />", nl2br($nl2br_string))).'\''.$giglocation_caption.$overlib_params.');" onmouseout="return nd();">';
  342. }
  343. if($config['list_location_link'] != "nothing") {
  344. $showlink = 0;
  345. if(($resultv['website'] != "") && ($resultv['website'] != "http://")) $showlink = 1;
  346. if($config[$display.'_location_link'] == "venuewebsite") { if ($showlink) $output .= "<a target=\"_blank\" href=\"" . $resultv['website'] . "\">"; }
  347. if($config[$display.'_location_link'] == "map") $output .= maplink($resultv['address1'], $resultv['address2'], $resultv['city'], $resultv['state'], $resultv['zip'], $resultv['country'], "l");
  348. if($config[$display.'_location_link'] == "venuedetails") { $output .= '<a href="'.$venuelink.'">'; }
  349. if($config[$display.'_location_link'] == "gigdetails") { $output .= '<a href="'.JRoute::_("index.php?option=com_gigcal&task=details&id=".$gig['id'].$itemidfix).'">'; }
  350. }
  351. $output .= $resultv["city"].", ".$resultv['state'];
  352. if(($config[$display.'_location_link'] != "nothing") && ($config[$display.'_location_link'] != "venuewebsite")) { $output .= '</a>'; }
  353. if(($showlink) && ($config[$display.'_location_link'] == "venuewebsite")) { $output .= '</a>'; }
  354. if($config[$display.'_location_popup']) { $output .= '</span>'; }
  355. }
  356. // Country
  357. if($item == "Country") {
  358. if($itemcount)
  359. $output .= $config[$display.'_delim'];
  360. if($config[$display.'_country_popup']) {
  361. $gigcountry_caption = "";
  362. if($config[$display.'_country_link'] == "nothing") $gigcountry_caption = $resultv['venuename'];
  363. if($config[$display.'_country_link'] == "gigdetails") $gigcountry_caption = $resultv['venuename'];
  364. if($config[$display.'_country_link'] == "venuedetails") $gigcountry_caption = "Click to learn more about " . $resultv['venuename'];
  365. if($config[$display.'_country_link'] == "map") $gigcountry_caption = "Click for directions to {$resultv['venuename']}";
  366. if(($config[$display.'_country_link'] == "venuewebsite") && ($resultv['website'] != "")) $gigcountry_caption = "Click to visit {$resultv['venuename']}'s website";
  367. $gigcountry_caption = ", CAPTION, '" . addslashes($gigcountry_caption) . "' ";
  368. $nl2br_string = $resultv['venuename'].'<br />'.$resultv['city'].', '.$resultv['state'].'<br />'.$resultv['phone'].'<br />'.$resultv['info'];
  369. $output .= '<span onmouseover="return overlib(\''.htmlspecialchars(addslashes(str_replace("\r\n", "<br />", nl2br($nl2br_string)))).'\''.$gigcountry_caption . $overlib_params.');" onmouseout="return nd();">';
  370. }
  371. if($config[$display.'_country_link'] != "nothing") {
  372. $showlink = 0;
  373. if(($resultv['website'] != "") && ($resultv['website'] != "http://")) $showlink = 1;
  374. if(($config[$display.'_country_link'] == "venuewebsite") && ($showlink)) { $output .= "<a target=\"_blank\" href=\"" . $resultv['website'] . "\">"; }
  375. if($config[$display.'_country_link'] == "map") echo maplink($resultv['address1'], $resultv['address2'], $resultv['city'], $resultv['state'], $resultv['zip'], $resultv['country'], "l");
  376. if($config[$display.'_country_link'] == "venuedetails") { $output .= '<a href="'.$venuelink.'">'; }
  377. if($config[$display.'_country_link'] == "gigdetails") { $output .= '<a href="'.JRoute::_("index.php?option=com_gigcal&task=details&id=".$gig['id'].$itemidfix).'">'; }
  378. }
  379. $output .= $resultv["country"];
  380. if(($config[$display.'_country_link'] != "nothing") && ($config[$display.'_country_link'] != "venuewebsite")) { $output .= '</a>'; }
  381. if(($showlink) && ($config[$display.'_country_link'] == "venuewebsite")) { $output .= '</a>'; }
  382. if($config[$display.'_country_popup']) { $output .= '</span>'; }
  383. }
  384. // Date
  385. if($item == "gigDate") {
  386. if($itemcount)
  387. $output .= $config[$display.'_delim'];
  388. if($config[$display.'_gigdate_hover']) {
  389. $gigdate_caption = ", CAPTION, '" . addslashes(date($config[$display.'_dateformat'], $gig["gigdate"])) . "' ";
  390. $gigdate_hover = "";
  391. if(($config[$display.'_gigdate_hover_gigtitle']) && ($gig["gigtitle"] != "")) $gigdate_hover .= $gig["gigtitle"] . "<br />";
  392. if($config[$display.'_gigdate_hover_bandname']) $gigdate_hover .= $resultb["bandname"] . "<br />";
  393. if($config[$display.'_gigdate_hover_venue']) $gigdate_hover .= $resultv["venuename"] . "<br />";
  394. if($config[$display.'_gigdate_hover_cityst']) $gigdate_hover .= $resultv["city"] . ", " . $resultv['state'] . "<br />";
  395. if($config[$display.'_gigdate_hover_date']) $gigdate_hover .= htmlspecialchars(date($config[$display.'_dateformat'], $gig["gigdate"]), ENT_QUOTES) . "<br />";
  396. if($config[$display.'_gigdate_hover_time']) $gigdate_hover .= htmlspecialchars(date($config[$display.'_timeformat'], $gig["gigdate"]), ENT_QUOTES) . "<br />";
  397. if(($config[$display.'_gigdate_hover_covercharge']) && ($gig["covercharge"] != "")) $gigdate_hover .= $gig["covercharge"] . "<br />";
  398. if($config[$display.'_gigdate_hover_notes']) $gigdate_hover .= str_replace("\r\n", "<br />", nl2br($gig["info"]));
  399. $output .= '<span onmouseover="return overlib(\''.htmlspecialchars(addslashes($gigdate_hover)).'\''.$gigdate_caption . $overlib_params.');" onmouseout="return nd();">';
  400. }
  401. if($config[$display.'_gigdate_link']) { $output .= '<a href="'.$giglink.'">'; }
  402. $output .= htmlspecialchars(date($config[$display.'_dateformat'], $gig["gigdate"]));
  403. if($config[$display.'_gigdate_link']) { $output .= '</a>'; }
  404. if($config[$display.'_gigdate_hover']) { $output .= '</span>'; }
  405. }
  406. // Date2
  407. if($item == "gigDate2") {
  408. if($itemcount)
  409. $output .= $config[$display.'_delim'];
  410. if($config[$display.'_gigdate2_hover']) {
  411. $gigdate2_caption = ", CAPTION, '" . addslashes(date($config[$display.'_dateformat'], $gig["gigdate"])) . "' ";
  412. $gigdate2_hover = "";
  413. if(($config[$display.'_gigdate2_hover_gigtitle']) && ($gig["gigtitle"] != "")) $gigdate2_hover .= $gig["gigtitle"] . "<br />";
  414. if($config[$display.'_gigdate2_hover_bandname']) $gigdate2_hover .= $resultb["bandname"] . "<br />";
  415. if($config[$display.'_gigdate2_hover_venue']) $gigdate2_hover .= $resultv["venuename"] . "<br />";
  416. if($config[$display.'_gigdate2_hover_cityst']) $gigdate2_hover .= $resultv["city"] . ", " . $resultv['state'] . "<br />";
  417. if($config[$display.'_gigdate2_hover_date']) $gigdate2_hover .= htmlspecialchars(date($config[$display.'_dateformat2'], $gig["gigdate"]), ENT_QUOTES) . "<br />";
  418. if($config[$display.'_gigdate2_hover_time']) $gigdate2_hover .= htmlspecialchars(date($config[$display.'_timeformat'], $gig["gigdate"]), ENT_QUOTES) . "<br />";
  419. if(($config[$display.'_gigdate2_hover_covercharge']) && ($gig["covercharge"] != "")) $gigdate2_hover .= $gig["covercharge"] . "<br />";
  420. if($config[$display.'_gigdate2_hover_notes']) $gigdate2_hover .= str_replace("\r\n", "<br />", nl2br($gig["info"]));
  421. $output .= '<span onmouseover="return overlib(\''.htmlspecialchars(addslashes($gigdate2_hover)).'\''.$gigdate_caption . $overlib_params.');" onmouseout="return nd();">';
  422. }
  423. if($config[$display.'_gigdate2_link']) { $output .= '<a href="'.$giglink.'">'; }
  424. $output .= htmlspecialchars(date($config[$display.'_dateformat2'], $gig["gigdate"]));
  425. if($config[$display.'_gigdate2_link']) { $output .= '</a>'; }
  426. if($config[$display.'_gigdate2_hover']) { $output .= '</span>'; }
  427. }
  428. // Time
  429. if($item == "gigTime") {
  430. if($itemcount)
  431. $output .= $config[$display.'_delim'];
  432. if($config[$display.'_gigtime_link'])
  433. $output .= '<a href="'.$giglink.'">';
  434. $output .= htmlspecialchars(date($config[$display.'_timeformat'], $gig["gigdate"]));
  435. if($config[$display.'_gigtime_link'])
  436. $output .= '</a>';
  437. }
  438. $output .= $tag2close."\n";
  439. $itemcount++;
  440. }
  441. $output .= " ".$tag1close."\n";
  442. echo $output;
  443. }
  444. // END gigContentBuilder()
  445. // gigsTableBuilder()
  446. // Builds the table header, footer, and col headings for list.php and alist.php
  447. // 02.16.06 bruce42
  448. // The 'gigs' and 'archive' lists use the same table construction.
  449. // Gigs and Archive lists will now share the same table header text; why does alist
  450. // have seperate table header text fields?
  451. function gigsTableBuilder($config, $display) {
  452. $items = dbLookupFieldnames($display);
  453. //error_log('fieldnames('.$display.')='.print_r($items,true));
  454. //return;
  455. $output = '<style type="text/css">'.$config[$display.'_css'].'</style>'."\n";
  456. if($config[$display.'_text'] != "")
  457. $output .= '<span class="gigcal_'.$display.'_introtext">'.$config[$display.'_text'].'<br /></span>'."\n";
  458. $output .= '<table class="gigcal_'.$display.'_table">'."\n";
  459. $output .= ' <colgroup span="'.count($items).'">'."\n";
  460. foreach($items as $item) {
  461. if($item == "gigDate") { $output .= ' <col class="gigcal_'.$display.'_date" />'."\n"; }
  462. if($item == "gigDate2") { $output .= ' <col class="gigcal_'.$display.'_date2" />'."\n"; }
  463. if($item == "gigTitle") { $output .= ' <col class="gigcal_'.$display.'_title" />'."\n"; }
  464. if($item == "country") { $output .= ' <col class="gigcal_'.$display.'_country" />'."\n"; }
  465. if($item == "state") { $output .= ' <col class="gigcal_'.$display.'_state" />'."\n"; }
  466. if($item == "city") { $output .= ' <col class="gigcal_'.$display.'_city" />'."\n"; }
  467. if($item == "gigVenue") { $output .= ' <col class="gigcal_'.$display.'_venue" />'."\n"; }
  468. if($item == "Link to online Ticket Sales") { $output .= ' <col class="gigcal_'.$display.'_ticketlink" />'."\n"; }
  469. if($item == "Link to Map") { $output .= ' <col class="gigcal_'.$display.'_map" />'."\n"; }
  470. if($item == "gigCover Charge") { $output .= ' <col class="gigcal_'.$display.'_covercharge" />'."\n"; }
  471. if($item == "gigTime") { $output .= ' <col class="gigcal_'.$display.'_time" />'."\n"; }
  472. if($item == "download") { $output .= ' <col class="gigcal_'.$display.'_download" />'."\n"; }
  473. if($item == "gigNotes/Info") { $output .= ' <col class="gigcal_'.$display.'_notes" />'."\n"; }
  474. if($item == "gigBand") { $output .= ' <col class="gigcal_band" />'."\n"; }
  475. if($item == "Location") { $output .= ' <col class="gigcal_location" />'."\n"; }
  476. if($item == "iCal Link") { $output .= ' <col class="gigcal_ical" />'."\n"; }
  477. if($item == "vCal Link") { $output .= ' <col class="gigcal_vcal" />'."\n"; }
  478. }
  479. $output .= ' </colgroup>'."\n".' <thead>'."\n".' <tr>'."\n";
  480. foreach($items as $item) {
  481. if($item == "gigNotes/Info") { $output .= ' <th scope="col">'.$config['gignotes_header'].'</th>'."\n"; }
  482. elseif($item == "gigCover Charge") { $output .= ' <th scope="col">'.$config['covercharge_header'].'</th>'."\n"; }
  483. elseif($item == "Link to online Ticket Sales") { $output .= ' <th scope="col">'.$config['ticket_header'].'</th>'."\n"; }
  484. elseif($item == "Link to Map") { $output .= ' <th scope="col">'.$config['map_header'].'</th>'."\n"; }
  485. elseif($item == "gigTitle") { $output .= ' <th scope="col">'.$config['gigtitle_header'].'</th>'."\n"; }
  486. elseif($item == "iCal Link") {
  487. $output .= ' <th scope="col">';
  488. if ($config['export_all_cals']==1)
  489. $output .= '<a alt="Export ALL '.$config['ical_header'].'" title="'.$config['ical_header'].'" href="components/com_gigcal/exporta.php?ext=ics&display='.$display.'">'.$config['ical_header'].'</a>';
  490. else
  491. $output .= $config['ical_header'];
  492. $output .= '</th>'."\n";
  493. }
  494. elseif($item == "vCal Link") {
  495. $output .= ' <th scope="col">';
  496. if ($config['export_all_cals']==1)
  497. $output .= '<a alt="Export ALL '.$config['vcal_header'].'" title="'.$config['vcal_header'].'" href="components/com_gigcal/exporta.php?ext=vcs&display='.$display.'">'.$config['vcal_header'].'</a>';
  498. else
  499. $output .= $config['vcal_header'];
  500. $output .= '</th>'."\n";
  501. }
  502. else {
  503. $item_header = $item . "_header";
  504. $output .= ' <th scope="col">'.$config[$item_header].'</th>'."\n";
  505. }
  506. }
  507. $output .= ' </tr>'."\n".' </thead>'."\n".' <tfoot>'."\n".' <tr>'."\n";
  508. foreach($items as $item) {
  509. if($item == "gigNotes/Info") { $output .= ' <th scope="col">'.$config['gignotes_header'].'</th>'."\n"; }
  510. elseif($item == "gigCover Charge") { $output .= ' <th scope="col">'.$config['covercharge_header'].'</th>'."\n"; }
  511. elseif($item == "Link to online Ticket Sales") { $output .= ' <th scope="col">'.$config['ticket_header'].'</th>'."\n"; }
  512. elseif($item == "Link to Map") { $output .= ' <th scope="col">'.$config['map_header'].'</th>'."\n"; }
  513. elseif($item == "iCal Link") { $output .= ' <th scope="col">'.$config['ical_header'].'</th>'."\n"; }
  514. elseif($item == "vCal Link") { $output .= ' <th scope="col">'.$config['vcal_header'].'</th>'."\n"; }
  515. elseif($item == "gigTitle") { $output .= ' <th scope="col">'.$config['gigtitle_header'].'</th>'."\n"; }
  516. else {
  517. $item_header = $item . "_header";
  518. $output .= ' <th scope="col">'.$config[$item_header].'</th>'."\n";
  519. }
  520. }
  521. $output .= ' </tr>'."\n".' </tfoot>'."\n".' <tbody>'."\n";
  522. echo $output;
  523. } // END gigsTableBuilder()
  524. // detailsBuilder()
  525. // Builds and dumps details for all details pages and bandslist and venueslist
  526. //
  527. function detailsBuilder($config, $display, $item) {
  528. //error_log('display=['.$display.']');
  529. $contents = "";
  530. switch ($display) {
  531. case 'band':
  532. $contents = $config['details_band'];
  533. $contents = str_replace("<\$bandname\$>", $item['bandname'], $contents);
  534. $contents = str_replace("<\$website\$>", $item['website'], $contents);
  535. $contents = str_replace("<\$contactname\$>", $item['contactname'], $contents);
  536. $contents = str_replace("<\$contactemail\$>", $item['contactemail'], $contents);
  537. $contents = str_replace("<\$contactphone\$>", $item['contactphone'], $contents);
  538. $contents = str_replace("<\$city\$>", $item['city'], $contents);
  539. $contents = str_replace("<\$state\$>", $item['state'], $contents);
  540. $contents = str_replace("<\$notes\$>", $item['notes'], $contents);
  541. echo $contents;
  542. break;
  543. case 'gig':
  544. //error_log('detailBuilder(gig)='.print_r($item,true));
  545. $band = $item['band'];
  546. $venue = $item['venue'];
  547. $contents = $config['details_gig'];
  548. $contents = str_replace("<\$gigdate\$>", date(date_reformater($config['details_dateformat']), $item['gigdate']), $contents);
  549. $contents = str_replace("<\$gigtime\$>", date(time_reformater($config['details_timeformat']), $item['gigdate']), $contents);
  550. $contents = str_replace("<\$covercharge\$>", $item['covercharge'], $contents);
  551. $contents = str_replace("<\$gigtitle\$>", $item['gigtitle'], $contents);
  552. if(($item['saleslink'] != "") && ($item['saleslink'] != "http://"))
  553. $contents = str_replace("<\$saleslink\$>", "<a href=\"{$item['saleslink']}\" target=\"_blank\">{$item['saleslink']}</a>", $contents);
  554. else
  555. $contents = str_replace("<\$saleslink\$>", "", $contents);
  556. $contents = str_replace("<\$giginfo\$>", $item['info'], $contents);
  557. $contents = str_replace("<\$maplinkstart\$>", maplink($venue['address1'], $venue['address2'], $venue['city'], $venue['state'], $venue['zip'], $venue['country']), $contents);
  558. $contents = str_replace("<\$maplinkend\$>", "</a>", $contents);
  559. $contents = str_replace("<\$bandname\$>", $band['bandname'], $contents);
  560. $contents = str_replace("<\$bandwebsite\$>", $band['website'], $contents);
  561. $contents = str_replace("<\$bandcontactname\$>", $band['contactname'], $contents);
  562. $contents = str_replace("<\$bandcontactemail\$>", $band['contactemail'], $contents);
  563. $contents = str_replace("<\$bandcontactphone\$>", $band['contactphone'], $contents);
  564. $contents = str_replace("<\$bandcity\$>", $band['city'], $contents);
  565. $contents = str_replace("<\$bandstate\$>", $band['state'], $contents);
  566. $contents = str_replace("<\$bandnotes\$>", $band['notes'], $contents);
  567. $contents = str_replace("<\$venuename\$>", $venue['venuename'], $contents);
  568. $contents = str_replace("<\$venuewebsite\$>", $venue['website'], $contents);
  569. $contents = str_replace("<\$venuecontactname\$>", $venue['contactname'], $contents);
  570. $contents = str_replace("<\$venuecontactemail\$>", $venue['contactemail'], $contents);
  571. $contents = str_replace("<\$venuecontactphone\$>", $venue['contactphone'], $contents);
  572. $contents = str_replace("<\$venuecity\$>", $venue['city'], $contents);
  573. $contents = str_replace("<\$venuestate\$>", $venue['state'], $contents);
  574. $contents = str_replace("<\$venueinfo\$>", $venue['info'], $contents);
  575. $contents = str_replace("<\$venueaddress1\$>", $venue['address1'], $contents);
  576. $contents = str_replace("<\$venueaddress2\$>", $venue['address2'], $contents);
  577. $contents = str_replace("<\$venuezip\$>", $venue['zip'], $contents);
  578. $contents = str_replace("<\$venuecountry\$>", $venue['country'], $contents);
  579. $contents = str_replace("<\$venuefax\$>", $venue['fax'], $contents);
  580. echo $contents;
  581. break;
  582. case 'venue':
  583. $contents = $config['details_venue'];
  584. $contents = str_replace("<\$venuename\$>", $item['venuename'], $contents);
  585. $contents = str_replace("<\$website\$>", $item['website'], $contents);
  586. $contents = str_replace("<\$contactname\$>", $item['contactname'], $contents);
  587. $contents = str_replace("<\$contactemail\$>", $item['contactemail'], $contents);
  588. $contents = str_replace("<\$contactphone\$>", $item['contactphone'], $contents);
  589. $contents = str_replace("<\$city\$>", $item['city'], $contents);
  590. $contents = str_replace("<\$state\$>", $item['state'], $contents);
  591. $contents = str_replace("<\$info\$>", $item['info'], $contents);
  592. $contents = str_replace("<\$address1\$>", $item['address1'], $contents);
  593. $contents = str_replace("<\$address2\$>", $item['address2'], $contents);
  594. $contents = str_replace("<\$zip\$>", $item['zip'], $contents);
  595. $contents = str_replace("<\$country\$>", $item['country'], $contents);
  596. $contents = str_replace("<\$fax\$>", $item['fax'], $contents);
  597. $contents = str_replace("<\$maplinkstart\$>", maplink($item['address1'], $item['address2'], $item['city'], $item['state'], $item['zip'], $item['country']), $contents);
  598. $contents = str_replace("<\$maplinkend\$>", "</a>", $contents);
  599. echo $contents;
  600. break;
  601. }
  602. }// END detailsBuilder()
  603. /*
  604. * Loads all necessary files for JS Overlib tooltips
  605. */
  606. /*
  607. function myloadOverlib() {
  608. global $mosConfig_live_site, $mainframe;
  609. if ( !$mainframe->get( 'loadOverlib' ) ) {
  610. // check if this function is already loaded
  611. ?>
  612. <script language="javascript" type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_mini.js"></script>
  613. <script language="javascript" type="text/javascript" src="<?php echo $mosConfig_live_site;?>/includes/js/overlib_hideform_mini.js"></script>
  614. <?php
  615. // change state so it isnt loaded a second time
  616. $mainframe->set( 'loadOverlib', true );
  617. }
  618. }
  619. */
  620. ?>