PageRenderTime 70ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_xmap/extensions/com_eventlist.php

https://github.com/Ratmir15/Joomla---formula-of-success
PHP | 232 lines | 199 code | 14 blank | 19 comment | 37 complexity | e8503638bd2f14516d9735ce9499a2de MD5 | raw file
  1. <?php
  2. /**
  3. * $Id: com_eventlist.php 52 2009-10-24 22:35:11Z guilleva $
  4. * $LastChangedDate: 2009-10-24 16:35:11 -0600 (Sat, 24 Oct 2009) $
  5. * $LastChangedBy: guilleva $
  6. * Xmap by Guillermo Vargas
  7. * a sitemap component for Joomla! CMS (http://www.joomla.org)
  8. * Author Website: http://joomla.vargas.co.cr
  9. * Project License: GNU/GPL http://www.gnu.org/copyleft/gpl.html
  10. */
  11. /*
  12. * Handles EventList Category structure
  13. */
  14. class xmap_com_eventlist
  15. {
  16. /*
  17. * This function is called before a menu item is printed. We use it to set the
  18. * proper uniqueid for the item
  19. */
  20. function prepareMenuItem(&$node) {
  21. $link_query = parse_url( $node->link );
  22. parse_str( html_entity_decode($link_query['query']), $link_vars);
  23. $id = intval(xmap_com_eventlist::getParam($link_vars,'id',0));
  24. $view = xmap_com_eventlist::getParam($link_vars,'view',0);
  25. if ( !$id ) {
  26. $menu =& JSite::getMenu();
  27. $params = $menu->getParams($node->id);
  28. $id = $params->get('id',0);
  29. }
  30. if ( $id ) {
  31. if ( $view == 'details' ) {
  32. $node->uid = 'com_eventliste'.$id;
  33. $node->expandible = false;
  34. } elseif ( $view == 'categoryevents' ) {
  35. $node->expandible = true;
  36. $node->uid = 'com_eventlistc'.$id;
  37. } elseif ( $view == 'venueevents' ) {
  38. $node->expandible = true;
  39. $node->uid = 'com_eventlistv'.$id;
  40. }
  41. } else {
  42. $node->expandible = true;
  43. }
  44. }
  45. /*
  46. * Return Category tree
  47. */
  48. function getTree( &$xmap, &$parent, $params )
  49. {
  50. $catid=0;
  51. $venid=0;
  52. $link_query = parse_url( $parent->link );
  53. parse_str( html_entity_decode($link_query['query']), $link_vars );
  54. $view = JArrayHelper::getValue($link_vars,'view','');
  55. if ( $view == 'categoryevents' ) {
  56. $catid = intval(JArrayHelper::getValue($link_vars,'id',0));
  57. }elseif ( $view == 'venueevents' ) {
  58. $venid = intval(JArrayHelper::getValue($link_vars,'id',0));
  59. }elseif ( $view != 'venues' && $view != 'categories' ) { //Do not expand other kind of menu items
  60. return true;
  61. }
  62. $include_events = JArrayHelper::getValue( $params, 'include_events',1,'' );
  63. $include_events = ( $include_events == 1
  64. || ( $include_events == 2 && $xmap->view == 'xml')
  65. || ( $include_events == 3 && $xmap->view == 'html'));
  66. $params['include_events'] = $include_events;
  67. $priority = JArrayHelper::getValue($params,'cat_priority',$parent->priority,'');
  68. $changefreq = JArrayHelper::getValue($params,'cat_changefreq',$parent->changefreq,'');
  69. if ($priority == '-1')
  70. $priority = $parent->priority;
  71. if ($changefreq == '-1')
  72. $changefreq = $parent->changefreq;
  73. $params['cat_priority'] = $priority;
  74. $params['cat_changefreq'] = $changefreq;
  75. $priority = JArrayHelper::getValue($params,'venue_priority',$parent->priority,'');
  76. $changefreq = JArrayHelper::getValue($params,'venue_changefreq',$parent->changefreq,'');
  77. if ($priority == '-1')
  78. $priority = $parent->priority;
  79. if ($changefreq == '-1')
  80. $changefreq = $parent->changefreq;
  81. $params['venue_priority'] = $priority;
  82. $params['venue_changefreq'] = $changefreq;
  83. $priority = JArrayHelper::getValue($params,'event_priority',$parent->priority,'');
  84. $changefreq = JArrayHelper::getValue($params,'event_changefreq',$parent->changefreq,'');
  85. if ($priority == '-1')
  86. $priority = $parent->priority;
  87. if ($changefreq == '-1')
  88. $changefreq = $parent->changefreq;
  89. $params['event_priority'] = $priority;
  90. $params['event_changefreq'] = $changefreq;
  91. if ( $include_events ) {
  92. $params['limit'] = '';
  93. $params['days'] = '';
  94. $limit = JArrayHelper::getValue($params,'max_events','','');
  95. if ( intval($limit) )
  96. $params['limit'] = ' LIMIT '.$limit;
  97. $days = JArrayHelper::getValue($params,'max_age','','');
  98. if ( intval($days) )
  99. $params['days'] = ' AND filedate >= \''.date('Y-m-d H:m:s', ($xmap->now - ($days*86400)) ) ."' ";
  100. }
  101. switch ($view) {
  102. case 'categories':
  103. case 'categoriesdetailed':
  104. case 'categoryevents':
  105. xmap_com_eventlist::getCategoryTree( $xmap, $parent, $params, $catid );
  106. break;
  107. case 'venues':
  108. case 'venueevents':
  109. xmap_com_eventlist::getVenueTree( $xmap, $parent, $params, $venid );
  110. break;
  111. }
  112. }
  113. function getCategoryTree(&$xmap, &$parent, $params,$catid=0)
  114. {
  115. $db = &JFactory::getDBO();
  116. $gid = intval($xmap->gid);
  117. $query = "SELECT id , catname, alias"
  118. . "\nFROM #__eventlist_categories"
  119. . "\nWHERE published = 1 and parent_id=$catid"
  120. . "\nAND access <= $gid"
  121. . "\nORDER BY ordering";
  122. $db->setQuery($query);
  123. $cats = $db->loadObjectList();
  124. $xmap->changeLevel(1);
  125. foreach($cats as $cat)
  126. {
  127. $node = new stdclass;
  128. $node->id = $parent->id;
  129. $node->uid = $parent->uid.'c'.$cat->id;
  130. $node->name = $cat->catname;
  131. $node->link = 'index.php?option=com_eventlist&amp;view=categoryevents&amp;id='.$cat->id.':'.$cat->alias;
  132. $node->expandible = true;
  133. $xmap->printNode($node);
  134. }
  135. if ($params['include_events']) {
  136. $db->setQuery ("select `id`, `title`,`alias`,UNIX_TIMESTAMP(`created`) as `created`,UNIX_TIMESTAMP(`modified`) as `modified` from #__eventlist_events where catsid=$catid and `published` = '1' ".$params['days']." order by dates,times,enddates,endtimes " . $params['limit']);
  137. # echo $db->getQuery ();
  138. $rows = $db->loadObjectList();
  139. foreach ($rows as $event) {
  140. $node = new stdclass;
  141. $node->id = $parent->id;
  142. $node->uid = $parent->uid .'e'.$event->id;
  143. $node->name = $event->title;
  144. $node->modified = ($event->modified? $event->modified : $event->created);
  145. $node->link = 'index.php?option=com_eventlist&amp;view=details&amp;id='.$event->id.':'.$event->alias;
  146. $node->priority = $params['event_priority'];
  147. $node->changefreq = $params['event_changefreq'];
  148. $node->expandible = false;
  149. $xmap->printNode($node);
  150. }
  151. }
  152. $xmap->changeLevel(-1);
  153. }
  154. function getVenueTree(&$xmap, &$parent, $params,$id=0)
  155. {
  156. $db = &JFactory::getDBO();
  157. $gid = intval($xmap->gid);
  158. $xmap->changeLevel(1);
  159. if ( !$id ) {
  160. $query = "SELECT id , venue, alias"
  161. . "\nFROM #__eventlist_venues"
  162. . "\nWHERE published = 1"
  163. . "\nORDER BY ordering";
  164. $db->setQuery($query);
  165. $venues = $db->loadObjectList();
  166. foreach($venues as $venue)
  167. {
  168. $node = new stdclass;
  169. $node->id = $parent->id;
  170. $node->uid = $parent->uid.'v'.$venue->id;
  171. $node->name = $venue->venue;
  172. $node->link = 'index.php?option=com_eventlist&amp;view=venueevents&amp;id='.$venue->id.':'.$venue->alias;
  173. $node->expandible = true;
  174. if ( $xmap->printNode($node) ) {
  175. xmap_com_eventlist::getVenueTree($xmap, $parent,$params,$venue->id);
  176. }
  177. }
  178. } else {
  179. if ($params['include_events']) {
  180. $db->setQuery ("select `id`, `title`,`alias`,UNIX_TIMESTAMP(`created`) as `created`,UNIX_TIMESTAMP(`modified`) as `modified` from #__eventlist_events where catsid=$id and `published` = '1' ".$params['days']." order by dates,times,enddates,endtimes " . $params['limit']);
  181. $rows = $db->loadObjectList();
  182. foreach($rows as $event) {
  183. $node = new stdclass;
  184. $node->id = $parent->id;
  185. $node->uid = $parent->uid .'e'.$event->id;
  186. $node->name = $event->title;
  187. $node->modified = ($event->modified? $event->modified : $event->created);
  188. $node->link = 'index.php?option=com_eventlist&amp;view=details&amp;id='.$event->id.':'.$event->alias;
  189. $node->priority = $params['event_priority'];
  190. $node->changefreq = $params['event_changefreq'];
  191. $node->expandible = false;
  192. $xmap->printNode($node);
  193. }
  194. }
  195. }
  196. $xmap->changeLevel(-1);
  197. }
  198. function &getParam($arr, $name, $def) {
  199. $var = JArrayHelper::getValue( $arr, $name, $def, '' );
  200. return $var;
  201. }
  202. }
  203. ?>