PageRenderTime 27ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_xmap/extensions/com_kb.php

https://github.com/Ratmir15/Joomla---formula-of-success
PHP | 156 lines | 136 code | 12 blank | 8 comment | 27 complexity | 3bf80a0e4708965d243962ff3c4530a6 MD5 | raw file
  1. <?php
  2. /**
  3. * @author Guillermo Vargas, http://joomla.vargas.co.cr
  4. * @email guille@vargas.co.cr
  5. * @version $Id: com_kb.php 52 2009-10-24 22:35:11Z guilleva $
  6. * @package Xmap
  7. * @license GNU/GPL
  8. * @description Xmap plugin for Joomla KnowledgeBase component
  9. */
  10. defined( '_JEXEC' ) or die( 'Restricted access.' );
  11. class xmap_com_kb {
  12. function getTree( &$xmap, &$parent, &$params) {
  13. if ( strpos($parent->link, 'task=article') ) {
  14. return true;
  15. }
  16. $link_query = parse_url( $parent->link );
  17. parse_str( html_entity_decode($link_query['query']), $link_vars );
  18. $catid = JArrayHelper::getValue($link_vars,'category',0);
  19. $include_articles = JArrayHelper::getValue( $params, 'include_articles',1,'' );
  20. $include_articles = ( $include_articles == 1
  21. || ( $include_articles == 2 && $xmap->view == 'xml')
  22. || ( $include_articles == 3 && $xmap->view == 'html'));
  23. $params['include_articles'] = $include_articles;
  24. $params['include_feeds'] = JArrayHelper::getValue( $params, 'include_feeds',1,'' );
  25. if ($xmap->view != 'xml' ) {
  26. $params['include_feeds']=0;
  27. }
  28. $priority = JArrayHelper::getValue($params,'cat_priority',$parent->priority,'');
  29. $changefreq = JArrayHelper::getValue($params,'cat_changefreq',$parent->changefreq,'');
  30. if ($priority == '-1')
  31. $priority = $parent->priority;
  32. if ($changefreq == '-1')
  33. $changefreq = $parent->changefreq;
  34. $params['cat_priority'] = $priority;
  35. $params['cat_changefreq'] = $changefreq;
  36. $priority = JArrayHelper::getValue($params,'article_priority',$parent->priority,'');
  37. $changefreq = JArrayHelper::getValue($params,'article_changefreq',$parent->changefreq,'');
  38. if ($priority == '-1')
  39. $priority = $parent->priority;
  40. if ($changefreq == '-1')
  41. $changefreq = $parent->changefreq;
  42. $params['article_priority'] = $priority;
  43. $params['article_changefreq'] = $changefreq;
  44. $priority = JArrayHelper::getValue($params,'feed_priority',$parent->priority,'');
  45. $changefreq = JArrayHelper::getValue($params,'feed_changefreq',$parent->changefreq,'');
  46. if ($priority == '-1')
  47. $priority = $parent->priority;
  48. if ($changefreq == '-1')
  49. $changefreq = $parent->changefreq;
  50. $params['feed_priority'] = $priority;
  51. $params['feed_changefreq'] = $changefreq;
  52. if ( $include_articles ) {
  53. $params['limit'] = '';
  54. $params['days'] = '';
  55. $limit = JArrayHelper::getValue($params,'max_articles','','');
  56. if ( intval($limit) )
  57. $params['limit'] = ' LIMIT '.$limit;
  58. $days = JArrayHelper::getValue($params,'max_age','','');
  59. if ( intval($days) )
  60. $params['days'] = ' AND a.`created` >= \''.date('Y-m-d H:m:s', ($xmap->now - ($days*86400)) ) ."' ";
  61. }
  62. if ( $params['include_feeds'] ) {
  63. // Include the latest listings feed
  64. $node = new stdclass;
  65. $node->id = $parent->id;
  66. $node->uid = $parent->uid.'flatest';
  67. $node->name = 'Latest Listings';
  68. $node->priority = $params['feed_priority'];
  69. $node->changefreq = $params['feed_changefreq'];
  70. $node->link = 'index.php?option=com_kb&amp;task=rss&amp;format=RSS2.0&amp;no_html=1&amp;pop=1&amp;type=latestlistings';
  71. $node->expandible = false;
  72. $xmap->printNode($node);
  73. // Include the Top 10 Most Popular Listings feed
  74. $node = new stdclass;
  75. $node->id = $parent->id;
  76. $node->uid = $parent->uid.'ftop10';
  77. $node->name = 'Top 10 Most Popular Listings';
  78. $node->priority = $params['feed_priority'];
  79. $node->changefreq = $params['feed_changefreq'];
  80. $node->expandible = false;
  81. $node->link = 'index.php?option=com_kb&amp;task=rss&amp;format=RSS2.0&amp;no_html=1&amp;pop=1&amp;type=mostpopular';
  82. $xmap->printNode($node);
  83. }
  84. xmap_com_kb::getKBTree( $xmap, $parent, $params, $catid );
  85. }
  86. function getKBTree ( &$xmap, &$parent, &$params, &$catid ) {
  87. $db = JFactory::getDBO();
  88. $db->setQuery("select `id`, `title`,UNIX_TIMESTAMP(`created`) as `created`,UNIX_TIMESTAMP(`modified`) as `modified` from #__kb_categorys where parentid=$catid and published = '1' and access<=".$xmap->gid." order by ordering");
  89. # echo $db->getQuery();
  90. $cats = $db->loadObjectList();
  91. $xmap->changeLevel(1);
  92. foreach($cats as $cat) {
  93. $node = new stdclass;
  94. $node->id = $parent->id;
  95. $node->uid = $parent->uid.'c'.$cat->id;
  96. $node->name = $cat->title;
  97. $node->modified = ($cat->modified? $cat->modified : $cat->created);
  98. $node->priority = $params['cat_priority'];
  99. $node->changefreq = $params['cat_changefreq'];
  100. $node->expandible = true;
  101. $node->link = 'index.php?option=com_kb&amp;task=category&amp;category='.$cat->id;
  102. if ( $xmap->printNode($node) !== FALSE ) { // To allow the items exclusion feature
  103. if ( $params['include_feeds'] ) {
  104. $node = new stdclass;
  105. $node->id = $parent->id;
  106. $node->uid = $parent->uid.'f'.$cat->id;
  107. $node->name = $cat->title . ' feed';
  108. $node->priority = $params['feed_priority'];
  109. $node->changefreq = $params['feed_changefreq'];
  110. $node->link = 'index.php?option=com_kb&amp;task=rss&amp;format=RSS2.0&amp;no_html=1&amp;pop=1&amp;type=latestlistingspercategory&amp;category='.$cat->id;
  111. $node->expandible = false;
  112. $xmap->printNode($node);
  113. }
  114. xmap_com_kb::getKBTree($xmap, $parent, $params, $cat->id);
  115. }
  116. }
  117. if ($params['include_articles']) {
  118. $db->setQuery ("select a.`id`, a.`title`,UNIX_TIMESTAMP(a.`created`) as `created`,UNIX_TIMESTAMP(a.`modified`) as `modified` from #__kb_articles a, #__kb_category_map m where m.category_id=$catid and m.article_id=a.id and a.`published` = '1' and a.`access`<=".$xmap->gid." ".$params['days']." order by m.ordering" . $params['limit']);
  119. $cats = $db->loadObjectList();
  120. foreach($cats as $article) {
  121. $node = new stdclass;
  122. $node->id = $parent->id;
  123. $node->uid = $parent->uid .'c'.$catid.'a'.$article->id;
  124. $node->name = $article->title;
  125. $node->modified = ($article->modified? $article->modified : $article->created);
  126. $node->link = 'index.php?option=com_kb&amp;task=article&amp;article='.$article->id;
  127. $node->priority = $params['article_priority'];
  128. $node->changefreq = $params['article_changefreq'];
  129. $node->expandible = false;
  130. $xmap->printNode($node);
  131. }
  132. }
  133. $xmap->changeLevel(-1);
  134. }
  135. }