[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_content 6 * 7 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Content\Administrator\Service\HTML; 12 13 use Joomla\CMS\Application\CMSApplication; 14 use Joomla\CMS\Factory; 15 use Joomla\CMS\HTML\HTMLHelper; 16 use Joomla\CMS\Language\Text; 17 use Joomla\CMS\Layout\LayoutHelper; 18 use Joomla\CMS\Router\Route; 19 use Joomla\CMS\Uri\Uri; 20 use Joomla\CMS\Workflow\Workflow; 21 use Joomla\Component\Content\Site\Helper\RouteHelper; 22 use Joomla\Registry\Registry; 23 24 // phpcs:disable PSR1.Files.SideEffects 25 \defined('_JEXEC') or die; 26 // phpcs:enable PSR1.Files.SideEffects 27 28 /** 29 * Content Component HTML Helper 30 * 31 * @since 4.0.0 32 */ 33 class Icon 34 { 35 /** 36 * Method to generate a link to the create item page for the given category 37 * 38 * @param object $category The category information 39 * @param Registry $params The item parameters 40 * @param array $attribs Optional attributes for the link 41 * @param boolean $legacy True to use legacy images, false to use icomoon based graphic 42 * 43 * @return string The HTML markup for the create item link 44 * 45 * @since 4.0.0 46 */ 47 public function create($category, $params, $attribs = array(), $legacy = false) 48 { 49 $uri = Uri::getInstance(); 50 51 $url = 'index.php?option=com_content&task=article.add&return=' . base64_encode($uri) . '&a_id=0&catid=' . $category->id; 52 53 $text = ''; 54 55 if ($params->get('show_icons')) { 56 $text .= '<span class="icon-plus icon-fw" aria-hidden="true"></span>'; 57 } 58 59 $text .= Text::_('COM_CONTENT_NEW_ARTICLE'); 60 61 // Add the button classes to the attribs array 62 if (isset($attribs['class'])) { 63 $attribs['class'] .= ' btn btn-primary'; 64 } else { 65 $attribs['class'] = 'btn btn-primary'; 66 } 67 68 $button = HTMLHelper::_('link', Route::_($url), $text, $attribs); 69 70 return $button; 71 } 72 73 /** 74 * Display an edit icon for the article. 75 * 76 * This icon will not display in a popup window, nor if the article is trashed. 77 * Edit access checks must be performed in the calling code. 78 * 79 * @param object $article The article information 80 * @param Registry $params The item parameters 81 * @param array $attribs Optional attributes for the link 82 * @param boolean $legacy True to use legacy images, false to use icomoon based graphic 83 * 84 * @return string The HTML for the article edit icon. 85 * 86 * @since 4.0.0 87 */ 88 public function edit($article, $params, $attribs = array(), $legacy = false) 89 { 90 $user = Factory::getUser(); 91 $uri = Uri::getInstance(); 92 93 // Ignore if in a popup window. 94 if ($params && $params->get('popup')) { 95 return ''; 96 } 97 98 // Ignore if the state is negative (trashed). 99 if (!in_array($article->state, [Workflow::CONDITION_UNPUBLISHED, Workflow::CONDITION_PUBLISHED])) { 100 return ''; 101 } 102 103 // Show checked_out icon if the article is checked out by a different user 104 if ( 105 property_exists($article, 'checked_out') 106 && property_exists($article, 'checked_out_time') 107 && !is_null($article->checked_out) 108 && $article->checked_out != $user->get('id') 109 ) { 110 $checkoutUser = Factory::getUser($article->checked_out); 111 $date = HTMLHelper::_('date', $article->checked_out_time); 112 $tooltip = Text::sprintf('COM_CONTENT_CHECKED_OUT_BY', $checkoutUser->name) 113 . ' <br> ' . $date; 114 115 $text = LayoutHelper::render('joomla.content.icons.edit_lock', array('article' => $article, 'tooltip' => $tooltip, 'legacy' => $legacy)); 116 117 $attribs['aria-describedby'] = 'editarticle-' . (int) $article->id; 118 $output = HTMLHelper::_('link', '#', $text, $attribs); 119 120 return $output; 121 } 122 123 $contentUrl = RouteHelper::getArticleRoute($article->slug, $article->catid, $article->language); 124 $url = $contentUrl . '&task=article.edit&a_id=' . $article->id . '&return=' . base64_encode($uri); 125 126 if ($article->state == Workflow::CONDITION_UNPUBLISHED) { 127 $tooltip = Text::_('COM_CONTENT_EDIT_UNPUBLISHED_ARTICLE'); 128 } else { 129 $tooltip = Text::_('COM_CONTENT_EDIT_PUBLISHED_ARTICLE'); 130 } 131 132 $text = LayoutHelper::render('joomla.content.icons.edit', array('article' => $article, 'tooltip' => $tooltip, 'legacy' => $legacy)); 133 134 $attribs['aria-describedby'] = 'editarticle-' . (int) $article->id; 135 $output = HTMLHelper::_('link', Route::_($url), $text, $attribs); 136 137 return $output; 138 } 139 140 /** 141 * Method to generate a link to print an article 142 * 143 * @param Registry $params The item parameters 144 * @param boolean $legacy True to use legacy images, false to use icomoon based graphic 145 * 146 * @return string The HTML markup for the popup link 147 * 148 * @since 4.0.0 149 */ 150 public function print_screen($params, $legacy = false) 151 { 152 $text = LayoutHelper::render('joomla.content.icons.print_screen', array('params' => $params, 'legacy' => $legacy)); 153 154 return '<button type="button" onclick="window.print();return false;">' . $text . '</button>'; 155 } 156 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |