PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_content/helpers/icon.php

https://bitbucket.org/eternaware/joomus
PHP | 161 lines | 98 code | 30 blank | 33 comment | 19 complexity | 7bcb236e1eb830667e97c39aaf1e1d2c MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /**
  3. * @package Joomla.Site
  4. * @subpackage com_content
  5. *
  6. * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. defined('_JEXEC') or die;
  10. /**
  11. * Content Component HTML Helper
  12. *
  13. * @static
  14. * @package Joomla.Site
  15. * @subpackage com_content
  16. * @since 1.5
  17. */
  18. class JHtmlIcon
  19. {
  20. public static function create($category, $params)
  21. {
  22. $uri = JURI::getInstance();
  23. $url = 'index.php?option=com_content&task=article.add&return='.base64_encode($uri).'&a_id=0&catid=' . $category->id;
  24. if ($params->get('show_icons')) {
  25. $text = '<i class="icon-plus"></i> ' . JText::_('JNEW') . '&#160;';
  26. } else {
  27. $text = JText::_('JNEW').'&#160;';
  28. }
  29. $button = JHtml::_('link', JRoute::_($url), $text, 'class="btn btn-primary"');
  30. $output = '<span class="hasTip" title="'.JText::_('COM_CONTENT_CREATE_ARTICLE').'">'.$button.'</span>';
  31. return $output;
  32. }
  33. public static function email($article, $params, $attribs = array())
  34. {
  35. require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php';
  36. $uri = JURI::getInstance();
  37. $base = $uri->toString(array('scheme', 'host', 'port'));
  38. $template = JFactory::getApplication()->getTemplate();
  39. $link = $base.JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid), false);
  40. $url = 'index.php?option=com_mailto&tmpl=component&template='.$template.'&link='.MailToHelper::addLink($link);
  41. $status = 'width=400,height=350,menubar=yes,resizable=yes';
  42. if ($params->get('show_icons')) {
  43. $text = '<i class="icon-envelope"></i> ' . JText::_('JGLOBAL_EMAIL');
  44. } else {
  45. $text = JText::_('JGLOBAL_EMAIL');
  46. }
  47. $attribs['title'] = JText::_('JGLOBAL_EMAIL');
  48. $attribs['onclick'] = "window.open(this.href,'win2','".$status."'); return false;";
  49. $output = JHtml::_('link', JRoute::_($url), $text, $attribs);
  50. return $output;
  51. }
  52. /**
  53. * Display an edit icon for the article.
  54. *
  55. * This icon will not display in a popup window, nor if the article is trashed.
  56. * Edit access checks must be performed in the calling code.
  57. *
  58. * @param object $article The article in question.
  59. * @param object $params The article parameters
  60. * @param array $attribs Not used??
  61. *
  62. * @return string The HTML for the article edit icon.
  63. * @since 1.6
  64. */
  65. public static function edit($article, $params, $attribs = array())
  66. {
  67. $user = JFactory::getUser();
  68. $userId = $user->get('id');
  69. $uri = JURI::getInstance();
  70. // Ignore if in a popup window.
  71. if ($params && $params->get('popup')) {
  72. return;
  73. }
  74. // Ignore if the state is negative (trashed).
  75. if ($article->state < 0) {
  76. return;
  77. }
  78. JHtml::_('behavior.tooltip');
  79. // Show checked_out icon if the article is checked out by a different user
  80. if (property_exists($article, 'checked_out') && property_exists($article, 'checked_out_time') && $article->checked_out > 0 && $article->checked_out != $user->get('id')) {
  81. $checkoutUser = JFactory::getUser($article->checked_out);
  82. $button = JHtml::_('image', 'system/checked_out.png', null, null, true);
  83. $date = JHtml::_('date', $article->checked_out_time);
  84. $tooltip = JText::_('JLIB_HTML_CHECKED_OUT').' :: '.JText::sprintf('COM_CONTENT_CHECKED_OUT_BY', $checkoutUser->name).' <br /> '.$date;
  85. return '<span class="hasTip" title="'.htmlspecialchars($tooltip, ENT_COMPAT, 'UTF-8').'">'.$button.'</span>';
  86. }
  87. $url = 'index.php?option=com_content&task=article.edit&a_id='.$article->id.'&return='.base64_encode($uri);
  88. if ($article->state == 0) {
  89. $overlib = JText::_('JUNPUBLISHED');
  90. }
  91. else {
  92. $overlib = JText::_('JPUBLISHED');
  93. }
  94. $date = JHtml::_('date', $article->created);
  95. $author = $article->created_by_alias ? $article->created_by_alias : $article->author;
  96. $overlib .= '&lt;br /&gt;';
  97. $overlib .= $date;
  98. $overlib .= '&lt;br /&gt;';
  99. $overlib .= JText::sprintf('COM_CONTENT_WRITTEN_BY', htmlspecialchars($author, ENT_COMPAT, 'UTF-8'));
  100. $icon = $article->state ? 'edit' : 'eye-close';
  101. $text = '<i class="hasTip icon-'.$icon.' tip" title="'.JText::_('COM_CONTENT_EDIT_ITEM').' :: '.$overlib.'"></i> '.JText::_('JGLOBAL_EDIT');
  102. $output = JHtml::_('link', JRoute::_($url), $text);
  103. return $output;
  104. }
  105. public static function print_popup($article, $params, $attribs = array())
  106. {
  107. $url = ContentHelperRoute::getArticleRoute($article->slug, $article->catid);
  108. $url .= '&tmpl=component&print=1&layout=default&page='.@ $request->limitstart;
  109. $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
  110. // checks template image directory for image, if non found default are loaded
  111. if ($params->get('show_icons')) {
  112. $text = '<i class="icon-print"></i> '.JText::_('JGLOBAL_PRINT');
  113. } else {
  114. $text = JText::_('JGLOBAL_PRINT');
  115. }
  116. $attribs['title'] = JText::_('JGLOBAL_PRINT');
  117. $attribs['onclick'] = "window.open(this.href,'win2','".$status."'); return false;";
  118. $attribs['rel'] = 'nofollow';
  119. return JHtml::_('link', JRoute::_($url), $text, $attribs);
  120. }
  121. public static function print_screen($article, $params, $attribs = array())
  122. {
  123. // checks template image directory for image, if non found default are loaded
  124. if ($params->get('show_icons')) {
  125. $text = $text = '<i class="icon-print"></i> '.JText::_('JGLOBAL_PRINT');
  126. } else {
  127. $text = JText::_('JGLOBAL_PRINT');
  128. }
  129. return '<a href="#" onclick="window.print();return false;">'.$text.'</a>';
  130. }
  131. }