PageRenderTime 36ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/components/com_contact/views/category/view.feed.php

https://github.com/joebushi/joomla
PHP | 84 lines | 53 code | 14 blank | 17 comment | 1 complexity | 039f962c69db796d1c964c26b5fde938 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @package Joomla.Site
  5. * @subpackage Contact
  6. * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. // No direct access
  10. defined('_JEXEC') or die;
  11. jimport('joomla.application.component.view');
  12. /**
  13. * @pacakge Joomla
  14. * @subpackage Contacts
  15. */
  16. class ContactViewCategory extends JView
  17. {
  18. function display()
  19. {
  20. $app = &JFactory::getApplication();
  21. $db = &JFactory::getDbo();
  22. $document = &JFactory::getDocument();
  23. $document->link = JRoute::_('index.php?option=com_contact&view=category&catid='.JRequest::getVar('catid',null, '', 'int'));
  24. $siteEmail = $app->getCfg('mailfrom');
  25. $fromName = $app->getCfg('fromname');
  26. $document->editor = $fromName;
  27. $document->editorEmail = $siteEmail;
  28. $limit = JRequest::getVar('limit', $app->getCfg('feed_limit'), '', 'int');
  29. $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
  30. $catid = JRequest::getVar('catid', 0, '', 'int');
  31. $where = ' WHERE a.published = 1';
  32. if ($catid) {
  33. $where .= ' AND a.catid = '. (int) $catid;
  34. }
  35. $query = 'SELECT'
  36. . ' a.name AS title,'
  37. . ' CONCAT(a.con_position, \' - \', a.misc) AS description,'
  38. . ' "" AS date,'
  39. . ' c.title AS category,'
  40. . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'
  41. . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as catslug'
  42. . ' FROM #__contact_details AS a'
  43. . ' LEFT JOIN #__categories AS c ON c.id = a.catid'
  44. . $where
  45. . ' ORDER BY a.catid, a.ordering'
  46. ;
  47. $db->setQuery($query, 0, $limit);
  48. $rows = $db->loadObjectList();
  49. foreach ($rows as $row)
  50. {
  51. // strip html from feed item title
  52. $title = $this->escape($row->title);
  53. $title = html_entity_decode($title);
  54. // url link to article
  55. $link = JRoute::_('index.php?option=com_contact&view=contact&id='. $row->slug .'&catid='.$row->catslug);
  56. // strip html from feed item description text
  57. $description = $row->description;
  58. $date = ($row->date ? date('r', strtotime($row->date)) : '');
  59. // load individual item creator class
  60. $item = new JFeedItem();
  61. $item->title = $title;
  62. $item->link = $link;
  63. $item->description = $description;
  64. $item->date = $date;
  65. $item->category = $row->category;
  66. // loads item info into rss array
  67. $document->addItem($item);
  68. }
  69. }
  70. }