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

/components/com_content/helpers/icon.php

https://github.com/cosmocommerce/joomla
PHP | 137 lines | 91 code | 28 blank | 18 comment | 14 complexity | 60e06fb1593e49f177d0f65b06b9d7e4 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @package Joomla.Site
  5. * @subpackage com_content
  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. /**
  12. * Content Component HTML Helper
  13. *
  14. * @static
  15. * @package Joomla.Site
  16. * @subpackage com_content
  17. * @since 1.5
  18. */
  19. class JHTMLIcon
  20. {
  21. static function create($article, $params)
  22. {
  23. $uri = &JFactory::getURI();
  24. $url = 'index.php?option=com_contenttask=article.add&return='.base64_encode($uri).'&id=0&sectionid='.$article->sectionid;
  25. if ($params->get('show_icons')) {
  26. $text = JHtml::_('image', 'system/new.png', JText::_('New'), NULL, true);
  27. } else {
  28. $text = JText::_('New').'&nbsp;';
  29. }
  30. $attribs = array('title' => JText::_('New'));
  31. return JHtml::_('link', JRoute::_($url), $text, $attribs);
  32. }
  33. static function email($article, $params, $attribs = array())
  34. {
  35. $uri = &JURI::getInstance();
  36. $base = $uri->toString(array('scheme', 'host', 'port'));
  37. $link = $base.JRoute::_(ContentRoute::article($article->slug, $article->catslug) , false);
  38. $url = 'index.php?option=com_mailto&tmpl=component&link='.base64_encode($link);
  39. $status = 'width=400,height=350,menubar=yes,resizable=yes';
  40. if ($params->get('show_icons')) {
  41. $text = JHtml::_('image', 'system/emailButton.png', JText::_('Email'), NULL, true);
  42. } else {
  43. $text = '&nbsp;'.JText::_('Email');
  44. }
  45. $attribs['title'] = JText::_('Email');
  46. $attribs['onclick'] = "window.open(this.href,'win2','".$status."'); return false;";
  47. $output = JHtml::_('link', JRoute::_($url), $text, $attribs);
  48. return $output;
  49. }
  50. static function edit($article, $params, $attribs = array())
  51. {
  52. $user = &JFactory::getUser();
  53. $uri = &JFactory::getURI();
  54. if ($params->get('popup')) {
  55. return;
  56. }
  57. if ($article->state < 0) {
  58. return;
  59. }
  60. if (!$user->authorise('core.edit', 'com_content.article.'.$article->id)) {
  61. return;
  62. }
  63. JHtml::_('behavior.tooltip');
  64. $url = 'index.php?task=article.edit&id='.$article->id.'&return='.base64_encode($uri);
  65. $icon = $article->state ? 'edit.png' : 'edit_unpublished.png';
  66. $text = JHtml::_('image', 'system/'.$icon, JText::_('Edit'), NULL, true);
  67. if ($article->state == 0) {
  68. $overlib = JText::_('Unpublished');
  69. } else {
  70. $overlib = JText::_('Published');
  71. }
  72. $date = JHtml::_('date', $article->created);
  73. $author = $article->created_by_alias ? $article->created_by_alias : $article->created_by;
  74. $overlib .= '&lt;br /&gt;';
  75. $overlib .= $date;
  76. $overlib .= '&lt;br /&gt;';
  77. $overlib .= $author;
  78. $button = JHtml::_('link', JRoute::_($url), $text);
  79. $output = '<span class="hasTip" title="'.JText::_('EDIT_ITEM').' :: '.$overlib.'">'.$button.'</span>';
  80. return $output;
  81. }
  82. static function print_popup($article, $params, $attribs = array())
  83. {
  84. $url = 'index.php?view=article';
  85. $url .= @$article->catslug ? '&catid='.$article->catslug : '';
  86. $url .= '&id='.$article->slug.'&tmpl=component&print=1&layout=default&page='.@ $request->limitstart;
  87. $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
  88. // checks template image directory for image, if non found default are loaded
  89. if ($params->get('show_icons')) {
  90. $text = JHtml::_('image', 'system/printButton.png', JText::_('Print'), NULL, true);
  91. } else {
  92. $text = JText::_('ICON_SEP') .'&nbsp;'. JText::_('Print') .'&nbsp;'. JText::_('ICON_SEP');
  93. }
  94. $attribs['title'] = JText::_('Print');
  95. $attribs['onclick'] = "window.open(this.href,'win2','".$status."'); return false;";
  96. $attribs['rel'] = 'nofollow';
  97. return JHtml::_('link', JRoute::_($url), $text, $attribs);
  98. }
  99. static function print_screen($article, $params, $attribs = array())
  100. {
  101. // checks template image directory for image, if non found default are loaded
  102. if ($params->get('show_icons')) {
  103. $text = JHtml::_('image', 'system/printButton.png', JText::_('Print'), NULL, true);
  104. } else {
  105. $text = JText::_('ICON_SEP') .'&nbsp;'. JText::_('Print') .'&nbsp;'. JText::_('ICON_SEP');
  106. }
  107. return '<a href="#" onclick="window.print();return false;">'.$text.'</a>';
  108. }
  109. }