PageRenderTime 36ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_content/helpers/icon.php

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