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

/plugins/system/t3/base-bs3/html/com_content/icon.php

https://gitlab.com/lankerd/paGO---Testing-Site
PHP | 299 lines | 184 code | 41 blank | 74 comment | 29 complexity | c947aa717196ca969a24e7225cb0bc42 MD5 | raw file
  1. <?php
  2. /**
  3. * @package Joomla.Site
  4. * @subpackage com_content
  5. *
  6. * @copyright Copyright (C) 2005 - 2015 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. use Joomla\Registry\Registry;
  11. /**
  12. * Content Component HTML Helper
  13. *
  14. * @package Joomla.Site
  15. * @subpackage com_content
  16. * @since 1.5
  17. */
  18. abstract class JHtmlIcon
  19. {
  20. /**
  21. * Method to generate a link to the create item page for the given category
  22. *
  23. * @param object $category The category information
  24. * @param Registry $params The item parameters
  25. * @param array $attribs Optional attributes for the link
  26. * @param boolean $legacy True to use legacy images, false to use icomoon based graphic
  27. *
  28. * @return string The HTML markup for the create item link
  29. */
  30. public static function create($category, $params, $attribs = array(), $legacy = false)
  31. {
  32. JHtml::_('bootstrap.tooltip');
  33. $uri = JUri::getInstance();
  34. $url = 'index.php?option=com_content&task=article.add&return=' . base64_encode($uri) . '&a_id=0&catid=' . $category->id;
  35. if ($params->get('show_icons'))
  36. {
  37. if ($legacy)
  38. {
  39. $text = JHtml::_('image', 'system/new.png', JText::_('JNEW'), null, true);
  40. }
  41. else
  42. {
  43. $text = '<span class="fa fa-plus"></span>&#160;' . JText::_('JNEW') . '&#160;';
  44. }
  45. }
  46. else
  47. {
  48. $text = JText::_('JNEW') . '&#160;';
  49. }
  50. // Add the button classes to the attribs array
  51. if (isset($attribs['class']))
  52. {
  53. $attribs['class'] = $attribs['class'] . ' btn btn-primary';
  54. }
  55. else
  56. {
  57. $attribs['class'] = 'btn btn-primary';
  58. }
  59. $button = JHtml::_('link', JRoute::_($url), $text, $attribs);
  60. $output = '<span class="hasTooltip" title="' . T3J::tooltipText('COM_CONTENT_CREATE_ARTICLE') . '">' . $button . '</span>';
  61. return $output;
  62. }
  63. /**
  64. * Method to generate a link to the email item page for the given article
  65. *
  66. * @param object $article The article information
  67. * @param JRegistry $params The item parameters
  68. * @param array $attribs Optional attributes for the link
  69. * @param boolean $legacy True to use legacy images, false to use icomoon based graphic
  70. *
  71. * @return string The HTML markup for the email item link
  72. */
  73. public static function email($article, $params, $attribs = array(), $legacy = false)
  74. {
  75. require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php';
  76. $uri = JUri::getInstance();
  77. $base = $uri->toString(array('scheme', 'host', 'port'));
  78. $template = JFactory::getApplication()->getTemplate();
  79. $link = $base . JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language), false);
  80. $url = 'index.php?option=com_mailto&tmpl=component&template=' . $template . '&link=' . MailToHelper::addLink($link);
  81. $status = 'width=400,height=350,menubar=yes,resizable=yes';
  82. if ($params->get('show_icons'))
  83. {
  84. if ($legacy)
  85. {
  86. $text = JHtml::_('image', 'system/emailButton.png', JText::_('JGLOBAL_EMAIL'), null, true);
  87. }
  88. else
  89. {
  90. $text = '<span class="fa fa-envelope"></span> ' . JText::_('JGLOBAL_EMAIL');
  91. }
  92. }
  93. else
  94. {
  95. $text = JText::_('JGLOBAL_EMAIL');
  96. }
  97. $attribs['title'] = JText::_('JGLOBAL_EMAIL');
  98. $attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;";
  99. $output = JHtml::_('link', JRoute::_($url), $text, $attribs);
  100. return $output;
  101. }
  102. /**
  103. * Display an edit icon for the article.
  104. *
  105. * This icon will not display in a popup window, nor if the article is trashed.
  106. * Edit access checks must be performed in the calling code.
  107. *
  108. * @param object $article The article information
  109. * @param JRegistry $params The item parameters
  110. * @param array $attribs Optional attributes for the link
  111. * @param boolean $legacy True to use legacy images, false to use icomoon based graphic
  112. *
  113. * @return string The HTML for the article edit icon.
  114. * @since 1.6
  115. */
  116. public static function edit($article, $params, $attribs = array(), $legacy = false)
  117. {
  118. $user = JFactory::getUser();
  119. $uri = JUri::getInstance();
  120. // Ignore if in a popup window.
  121. if ($params && $params->get('popup'))
  122. {
  123. return;
  124. }
  125. // Ignore if the state is negative (trashed).
  126. if ($article->state < 0)
  127. {
  128. return;
  129. }
  130. JHtml::_('bootstrap.tooltip');
  131. // Show checked_out icon if the article is checked out by a different user
  132. if (property_exists($article, 'checked_out') && property_exists($article, 'checked_out_time') && $article->checked_out > 0 && $article->checked_out != $user->get('id'))
  133. {
  134. $checkoutUser = JFactory::getUser($article->checked_out);
  135. $date = JHtml::_('date', $article->checked_out_time);
  136. $tooltip = JText::_('JLIB_HTML_CHECKED_OUT') . ' :: ' . JText::sprintf('COM_CONTENT_CHECKED_OUT_BY', $checkoutUser->name)
  137. . ' <br /> ' . $date;
  138. if ($legacy)
  139. {
  140. $button = JHtml::_('image', 'system/checked_out.png', null, null, true);
  141. $text = '<span class="hasTooltip" title="' . JHtml::tooltipText($tooltip . '', 0) . '">'
  142. . $button . '</span> ' . JText::_('JLIB_HTML_CHECKED_OUT');
  143. }
  144. else
  145. {
  146. $text = '<span class="hasTooltip icon-lock" title="' . T3J::tooltipText($tooltip . '', 0) . '"></span> ' . JText::_('JLIB_HTML_CHECKED_OUT');
  147. }
  148. $output = JHtml::_('link', '#', $text, $attribs);
  149. return $output;
  150. }
  151. $url = 'index.php?option=com_content&task=article.edit&a_id=' . $article->id . '&return=' . base64_encode($uri);
  152. if ($article->state == 0)
  153. {
  154. $overlib = JText::_('JUNPUBLISHED');
  155. }
  156. else
  157. {
  158. $overlib = JText::_('JPUBLISHED');
  159. }
  160. $date = JHtml::_('date', $article->created);
  161. $author = $article->created_by_alias ? $article->created_by_alias : $article->author;
  162. $overlib .= '&lt;br /&gt;';
  163. $overlib .= $date;
  164. $overlib .= '&lt;br /&gt;';
  165. $overlib .= JText::sprintf('COM_CONTENT_WRITTEN_BY', htmlspecialchars($author, ENT_COMPAT, 'UTF-8'));
  166. if ($legacy)
  167. {
  168. $icon = $article->state ? 'edit.png' : 'edit_unpublished.png';
  169. if (strtotime($article->publish_up) > strtotime(JFactory::getDate())
  170. || ((strtotime($article->publish_down) < strtotime(JFactory::getDate())) && $article->publish_down != JFactory::getDbo()->getNullDate()))
  171. {
  172. $icon = 'edit_unpublished.png';
  173. }
  174. $text = JHtml::_('image', 'system/' . $icon, JText::_('JGLOBAL_EDIT'), null, true);
  175. }
  176. else
  177. {
  178. $icon = $article->state ? 'edit' : 'eye-close';
  179. if (strtotime($article->publish_up) > strtotime(JFactory::getDate())
  180. || ((strtotime($article->publish_down) < strtotime(JFactory::getDate())) && $article->publish_down != JFactory::getDbo()->getNullDate()))
  181. {
  182. $icon = 'eye-close';
  183. }
  184. $text = '<span class="hasTooltip fa fa-' . $icon . ' tip" title="' . T3J::tooltipText(JText::_('COM_CONTENT_EDIT_ITEM'), $overlib, 0) . '"></span>&#160;' . JText::_('JGLOBAL_EDIT') . '&#160;';
  185. }
  186. $output = JHtml::_('link', JRoute::_($url), $text, $attribs);
  187. return $output;
  188. }
  189. /**
  190. * Method to generate a popup link to print an article
  191. *
  192. * @param object $article The article information
  193. * @param JRegistry $params The item parameters
  194. * @param array $attribs Optional attributes for the link
  195. * @param boolean $legacy True to use legacy images, false to use icomoon based graphic
  196. *
  197. * @return string The HTML markup for the popup link
  198. */
  199. public static function print_popup($article, $params, $attribs = array(), $legacy = false)
  200. {
  201. $app = JFactory::getApplication();
  202. $input = $app->input;
  203. $request = $input->request;
  204. $url = ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->language);
  205. $url .= '&tmpl=component&print=1&layout=default&page=' . @ $request->limitstart;
  206. $status = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no';
  207. // checks template image directory for image, if non found default are loaded
  208. if ($params->get('show_icons'))
  209. {
  210. if ($legacy)
  211. {
  212. $text = JHtml::_('image', 'system/printButton.png', JText::_('JGLOBAL_PRINT'), null, true);
  213. }
  214. else
  215. {
  216. $text = '<span class="fa fa-print"></span>&#160;' . JText::_('JGLOBAL_PRINT') . '&#160;';
  217. }
  218. }
  219. else
  220. {
  221. $text = JText::_('JGLOBAL_PRINT');
  222. }
  223. $attribs['title'] = JText::_('JGLOBAL_PRINT');
  224. $attribs['onclick'] = "window.open(this.href,'win2','" . $status . "'); return false;";
  225. $attribs['rel'] = 'nofollow';
  226. return JHtml::_('link', JRoute::_($url), $text, $attribs);
  227. }
  228. /**
  229. * Method to generate a link to print an article
  230. *
  231. * @param object $article Not used, @deprecated for 4.0
  232. * @param JRegistry $params The item parameters
  233. * @param array $attribs Not used, @deprecated for 4.0
  234. * @param boolean $legacy True to use legacy images, false to use icomoon based graphic
  235. *
  236. * @return string The HTML markup for the popup link
  237. */
  238. public static function print_screen($article, $params, $attribs = array(), $legacy = false)
  239. {
  240. // Checks template image directory for image, if none found default are loaded
  241. if ($params->get('show_icons'))
  242. {
  243. if ($legacy)
  244. {
  245. $text = JHtml::_('image', 'system/printButton.png', JText::_('JGLOBAL_PRINT'), null, true);
  246. }
  247. else
  248. {
  249. $text = '<span class="fa fa-print"></span>&#160;' . JText::_('JGLOBAL_PRINT') . '&#160;';
  250. }
  251. }
  252. else
  253. {
  254. $text = JText::_('JGLOBAL_PRINT');
  255. }
  256. return '<a href="#" onclick="window.print();return false;">' . $text . '</a>';
  257. }
  258. }