Файловый менеджер - Редактировать - /home/harasnat/www/mf/HTML.zip
Назад
PK ��/[C��, , Helpers/StringHelper.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\HTML\HTMLHelper; use Joomla\String\StringHelper as FrameworkStringHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * HTML helper class for rendering manipulated strings. * * @since 1.6 */ abstract class StringHelper { /** * Truncates text blocks over the specified character limit and closes * all open HTML tags. The method will optionally not truncate an individual * word, it will find the first space that is within the limit and * truncate at that point. This method is UTF-8 safe. * * @param string $text The text to truncate. * @param integer $length The maximum length of the text. * @param boolean $noSplit Don't split a word if that is where the cutoff occurs (default: true). * @param boolean $allowHtml Allow HTML tags in the output, and close any open tags (default: true). * * @return string The truncated text. * * @since 1.6 */ public static function truncate($text, $length = 0, $noSplit = true, $allowHtml = true) { // Assume a lone open tag is invalid HTML. if ($length === 1 && $text[0] === '<') { return '...'; } // Check if HTML tags are allowed. if (!$allowHtml) { // Decode entities $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8'); // Deal with spacing issues in the input. $text = str_replace('>', '> ', $text); $text = str_replace([' ', ' '], ' ', $text); $text = FrameworkStringHelper::trim(preg_replace('#\s+#mui', ' ', $text)); // Strip tags from the input. $text = strip_tags($text); // Remove remaining extra spaces. $text = str_replace(' ', ' ', $text); $text = FrameworkStringHelper::trim(preg_replace('#\s+#mui', ' ', $text)); } // Whether or not allowing HTML, truncate the item text if it is too long. if ($length > 0 && FrameworkStringHelper::strlen($text) > $length) { $tmp = trim(FrameworkStringHelper::substr($text, 0, $length)); if ($tmp[0] === '<' && strpos($tmp, '>') === false) { return '...'; } // $noSplit true means that we do not allow splitting of words. if ($noSplit) { // Find the position of the last space within the allowed length. $offset = FrameworkStringHelper::strrpos($tmp, ' '); $tmp = FrameworkStringHelper::substr($tmp, 0, $offset + 1); // If there are no spaces and the string is longer than the maximum // we need to just use the ellipsis. In that case we are done. if ($offset === false && strlen($text) > $length) { return '...'; } if (FrameworkStringHelper::strlen($tmp) > $length - 3) { $tmp = trim(FrameworkStringHelper::substr($tmp, 0, FrameworkStringHelper::strrpos($tmp, ' '))); } } if ($allowHtml) { // Put all opened tags into an array preg_match_all("#<([a-z][a-z0-9]*)\b.*?(?!/)>#i", $tmp, $result); $openedTags = $result[1]; // Some tags self close so they do not need a separate close tag. $openedTags = array_diff($openedTags, ['img', 'hr', 'br']); $openedTags = array_values($openedTags); // Put all closed tags into an array preg_match_all("#</([a-z][a-z0-9]*)\b(?:[^>]*?)>#iU", $tmp, $result); $closedTags = $result[1]; $numOpened = count($openedTags); // Not all tags are closed so trim the text and finish. if (count($closedTags) !== $numOpened) { // Closing tags need to be in the reverse order of opening tags. $openedTags = array_reverse($openedTags); // Close tags for ($i = 0; $i < $numOpened; $i++) { if (!in_array($openedTags[$i], $closedTags)) { $tmp .= '</' . $openedTags[$i] . '>'; } else { unset($closedTags[array_search($openedTags[$i], $closedTags)]); } } } // Check if we are within a tag if (FrameworkStringHelper::strrpos($tmp, '<') > FrameworkStringHelper::strrpos($tmp, '>')) { $offset = FrameworkStringHelper::strrpos($tmp, '<'); $tmp = FrameworkStringHelper::trim(FrameworkStringHelper::substr($tmp, 0, $offset)); } } if ($tmp === false || strlen($text) > strlen($tmp)) { $text = trim($tmp) . '...'; } } // Clean up any internal spaces created by the processing. $text = str_replace(' </', '</', $text); $text = str_replace(' ...', '...', $text); return $text; } /** * Method to extend the truncate method to more complex situations * * The goal is to get the proper length plain text string with as much of * the html intact as possible with all tags properly closed. * * @param string $html The content of the introtext to be truncated * @param integer $maxLength The maximum number of characters to render * @param boolean $noSplit Don't split a word if that is where the cutoff occurs (default: true). * * @return string The truncated string. If the string is truncated an ellipsis * (...) will be appended. * * @note If a maximum length of 3 or less is selected and the text has more than * that number of characters an ellipsis will be displayed. * This method will not create valid HTML from malformed HTML. * * @since 3.1 */ public static function truncateComplex($html, $maxLength = 0, $noSplit = true) { // Start with some basic rules. $baseLength = strlen($html); // If the original HTML string is shorter than the $maxLength do nothing and return that. if ($baseLength <= $maxLength || $maxLength === 0) { return $html; } // Take care of short simple cases. if ($maxLength <= 3 && $html[0] !== '<' && strpos(substr($html, 0, $maxLength - 1), '<') === false && $baseLength > $maxLength) { return '...'; } // Deal with maximum length of 1 where the string starts with a tag. if ($maxLength === 1 && $html[0] === '<') { $endTagPos = strlen(strstr($html, '>', true)); $tag = substr($html, 1, $endTagPos); $l = $endTagPos + 1; if ($noSplit) { return substr($html, 0, $l) . '</' . $tag . '...'; } // @todo: $character doesn't seem to be used... $character = substr(strip_tags($html), 0, 1); return substr($html, 0, $l) . '</' . $tag . '...'; } // First get the truncated plain text string. This is the rendered text we want to end up with. $ptString = HTMLHelper::_('string.truncate', $html, $maxLength, $noSplit, $allowHtml = false); // It's all HTML, just return it. if ($ptString === '') { return $html; } // If the plain text is shorter than the max length the variable will not end in ... // In that case we use the whole string. if (substr($ptString, -3) !== '...') { return $html; } // Regular truncate gives us the ellipsis but we want to go back for text and tags. if ($ptString === '...') { $stripped = substr(strip_tags($html), 0, $maxLength); $ptString = HTMLHelper::_('string.truncate', $stripped, $maxLength, $noSplit, $allowHtml = false); } // We need to trim the ellipsis that truncate adds. $ptString = rtrim($ptString, '.'); // Now deal with more complex truncation. while ($maxLength <= $baseLength) { // Get the truncated string assuming HTML is allowed. $htmlString = HTMLHelper::_('string.truncate', $html, $maxLength, $noSplit, $allowHtml = true); if ($htmlString === '...' && strlen($ptString) + 3 > $maxLength) { return $htmlString; } $htmlString = rtrim($htmlString, '.'); // Now get the plain text from the HTML string and trim it. $htmlStringToPtString = HTMLHelper::_('string.truncate', $htmlString, $maxLength, $noSplit, $allowHtml = false); $htmlStringToPtString = rtrim($htmlStringToPtString, '.'); // If the new plain text string matches the original plain text string we are done. if ($ptString === $htmlStringToPtString) { return $htmlString . '...'; } // Get the number of HTML tag characters in the first $maxLength characters $diffLength = strlen($ptString) - strlen($htmlStringToPtString); if ($diffLength <= 0) { return $htmlString . '...'; } // Set new $maxlength that adjusts for the HTML tags $maxLength += $diffLength; } } /** * Abridges text strings over the specified character limit. The * behavior will insert an ellipsis into the text replacing a section * of variable size to ensure the string does not exceed the defined * maximum length. This method is UTF-8 safe. * * For example, it transforms "Really long title" to "Really...title". * * Note that this method does not scan for HTML tags so will potentially break them. * * @param string $text The text to abridge. * @param integer $length The maximum length of the text (default is 50). * @param integer $intro The maximum length of the intro text (default is 30). * * @return string The abridged text. * * @since 1.6 */ public static function abridge($text, $length = 50, $intro = 30) { // Abridge the item text if it is too long. if (FrameworkStringHelper::strlen($text) > $length) { // Determine the remaining text length. $remainder = $length - ($intro + 3); // Extract the beginning and ending text sections. $beg = FrameworkStringHelper::substr($text, 0, $intro); $end = FrameworkStringHelper::substr($text, FrameworkStringHelper::strlen($text) - $remainder); // Build the resulting string. $text = $beg . '...' . $end; } return $text; } } PK ��/[�� Helpers/User.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Access\Access; use Joomla\CMS\Factory; use Joomla\CMS\Helper\UserGroupsHelper; use Joomla\CMS\HTML\HTMLHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Utility class working with users * * @since 2.5 */ abstract class User { /** * Displays a list of user groups. * * @param boolean $includeSuperAdmin true to include super admin groups, false to exclude them * * @return array An array containing a list of user groups. * * @since 2.5 */ public static function groups($includeSuperAdmin = false) { $options = array_values(UserGroupsHelper::getInstance()->getAll()); for ($i = 0, $n = count($options); $i < $n; $i++) { $options[$i]->value = $options[$i]->id; $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->title; $groups[] = HTMLHelper::_('select.option', $options[$i]->value, $options[$i]->text); } // Exclude super admin groups if requested if (!$includeSuperAdmin) { $filteredGroups = []; foreach ($groups as $group) { if (!Access::checkGroup($group->value, 'core.admin')) { $filteredGroups[] = $group; } } $groups = $filteredGroups; } return $groups; } /** * Get a list of users. * * @return string * * @since 2.5 */ public static function userlist() { $db = Factory::getDbo(); $query = $db->getQuery(true) ->select( [ $db->quoteName('a.id', 'value'), $db->quoteName('a.name', 'text'), ] ) ->from($db->quoteName('#__users', 'a')) ->where($db->quoteName('a.block') . ' = 0') ->order($db->quoteName('a.name')); $db->setQuery($query); return $db->loadObjectList(); } } PK ��/[��) ) Helpers/Access.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Access\Access as AccessCheck; use Joomla\CMS\Factory; use Joomla\CMS\Helper\UserGroupsHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Extended Utility class for all HTML drawing classes. * * @since 1.6 */ abstract class Access { /** * A cached array of the asset groups * * @var array * @since 1.6 */ protected static $asset_groups = null; /** * Displays a list of the available access view levels * * @param string $name The form field name. * @param string $selected The name of the selected section. * @param string $attribs Additional attributes to add to the select field. * @param mixed $params True to add "All Sections" option or an array of options * @param mixed $id The form field id or false if not used * * @return string The required HTML for the SELECT tag. * * @see \Joomla\CMS\Form\Field\AccesslevelField * @since 1.6 */ public static function level($name, $selected, $attribs = '', $params = true, $id = false) { $db = Factory::getDbo(); $query = $db->getQuery(true) ->select( [ $db->quoteName('a.id', 'value'), $db->quoteName('a.title', 'text'), ] ) ->from($db->quoteName('#__viewlevels', 'a')) ->group( [ $db->quoteName('a.id'), $db->quoteName('a.title'), $db->quoteName('a.ordering'), ] ) ->order( [ $db->quoteName('a.ordering') . ' ASC', $db->quoteName('a.title') . ' ASC', ] ); // Get the options. $db->setQuery($query); $options = $db->loadObjectList(); // If params is an array, push these options to the array if (is_array($params)) { $options = array_merge($params, $options); } elseif ($params) { // If all levels is allowed, push it into the array. array_unshift($options, HTMLHelper::_('select.option', '', Text::_('JOPTION_ACCESS_SHOW_ALL_LEVELS'))); } return HTMLHelper::_( 'select.genericlist', $options, $name, [ 'list.attr' => $attribs, 'list.select' => $selected, 'id' => $id, ] ); } /** * Displays a list of the available user groups. * * @param string $name The form field name. * @param string $selected The name of the selected section. * @param string $attribs Additional attributes to add to the select field. * @param boolean $allowAll True to add "All Groups" option. * @param mixed $id The form field id * * @return string The required HTML for the SELECT tag. * * @see \Joomla\CMS\Form\Field\UsergrouplistField * @since 1.6 */ public static function usergroup($name, $selected, $attribs = '', $allowAll = true, $id = false) { $options = array_values(UserGroupsHelper::getInstance()->getAll()); for ($i = 0, $n = count($options); $i < $n; $i++) { $options[$i]->value = $options[$i]->id; $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->title; } // If all usergroups is allowed, push it into the array. if ($allowAll) { array_unshift($options, HTMLHelper::_('select.option', '', Text::_('JOPTION_ACCESS_SHOW_ALL_GROUPS'))); } return HTMLHelper::_('select.genericlist', $options, $name, ['list.attr' => $attribs, 'list.select' => $selected, 'id' => $id]); } /** * Returns a UL list of user groups with checkboxes * * @param string $name The name of the checkbox controls array * @param array $selected An array of the checked boxes * @param boolean $checkSuperAdmin If false only super admins can add to super admin groups * * @return string * * @since 1.6 */ public static function usergroups($name, $selected, $checkSuperAdmin = false) { static $count; $count++; $isSuperAdmin = Factory::getUser()->authorise('core.admin'); $groups = array_values(UserGroupsHelper::getInstance()->getAll()); $html = []; for ($i = 0, $n = count($groups); $i < $n; $i++) { $item = &$groups[$i]; // If checkSuperAdmin is true, only add item if the user is superadmin or the group is not super admin if ((!$checkSuperAdmin) || $isSuperAdmin || (!AccessCheck::checkGroup($item->id, 'core.admin'))) { // Set up the variable attributes. ID may not start with a number (CSS) $eid = 'group_' . $item->id . '_' . $count; // Don't call in_array unless something is selected $checked = ''; if ($selected) { $checked = in_array($item->id, $selected) ? ' checked="checked"' : ''; } $rel = ($item->parent_id > 0) ? ' rel="group_' . $item->parent_id . '_' . $count . '"' : ''; // Build the HTML for the item. $html[] = ' <div class="control-group">'; $html[] = ' <div class="controls">'; $html[] = ' <label class="form-check-label checkbox" for="' . $eid . '">'; $html[] = ' <input class="form-check-input" type="checkbox" name="' . $name . '[]" value="' . $item->id . '" id="' . $eid . '"'; $html[] = ' ' . $checked . $rel . '>'; $html[] = ' ' . LayoutHelper::render('joomla.html.treeprefix', ['level' => $item->level + 1]) . $item->title; $html[] = ' </label>'; $html[] = ' </div>'; $html[] = ' </div>'; } } return implode("\n", $html); } /** * Returns a UL list of actions with checkboxes * * @param string $name The name of the checkbox controls array * @param array $selected An array of the checked boxes * @param string $component The component the permissions apply to * @param string $section The section (within a component) the permissions apply to * * @return string * * @see AccessCheck * @since 1.6 */ public static function actions($name, $selected, $component, $section = 'global') { static $count; $count++; $actions = AccessCheck::getActionsFromFile( JPATH_ADMINISTRATOR . '/components/' . $component . '/access.xml', "/access/section[@name='" . $section . "']/" ); $html = []; $html[] = '<ul class="checklist access-actions">'; for ($i = 0, $n = count($actions); $i < $n; $i++) { $item = &$actions[$i]; // Setup the variable attributes. $eid = $count . 'action_' . $item->id; $checked = in_array($item->id, $selected) ? ' checked="checked"' : ''; // Build the HTML for the item. $html[] = ' <li>'; $html[] = ' <input type="checkbox" name="' . $name . '[]" value="' . $item->id . '" id="' . $eid . '"'; $html[] = ' ' . $checked . '>'; $html[] = ' <label for="' . $eid . '">'; $html[] = ' ' . Text::_($item->title); $html[] = ' </label>'; $html[] = ' </li>'; } $html[] = '</ul>'; return implode("\n", $html); } /** * Gets a list of the asset groups as an array of JHtml compatible options. * * @return mixed An array or false if an error occurs * * @since 1.6 */ public static function assetgroups() { if (empty(static::$asset_groups)) { $db = Factory::getDbo(); $query = $db->getQuery(true) ->select( [ $db->quoteName('a.id', 'value'), $db->quoteName('a.title', 'text'), ] ) ->from($db->quoteName('#__viewlevels', 'a')) ->group( [ $db->quoteName('a.id'), $db->quoteName('a.title'), $db->quoteName('a.ordering'), ] ) ->order($db->quoteName('a.ordering') . ' ASC'); $db->setQuery($query); static::$asset_groups = $db->loadObjectList(); } return static::$asset_groups; } /** * Displays a Select list of the available asset groups * * @param string $name The name of the select element * @param mixed $selected The selected asset group id * @param string $attribs Optional attributes for the select field * @param array $config An array of options for the control * * @return mixed An HTML string or null if an error occurs * * @since 1.6 */ public static function assetgrouplist($name, $selected, $attribs = null, $config = []) { static $count; $options = static::assetgroups(); if (isset($config['title'])) { array_unshift($options, HTMLHelper::_('select.option', '', $config['title'])); } return HTMLHelper::_( 'select.genericlist', $options, $name, [ 'id' => isset($config['id']) ? $config['id'] : 'assetgroups_' . (++$count), 'list.attr' => $attribs === null ? 'class="inputbox" size="3"' : $attribs, 'list.select' => (int) $selected, ] ); } } PK ��/[�D�m� � Helpers/Email.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Uri\Uri; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Utility class for cloaking email addresses * * @since 1.5 */ abstract class Email { /** * Simple JavaScript email cloaker * * By default replaces an email with a mailto link with email cloaked * * @param string $mail The -mail address to cloak. * @param boolean $mailto True if text and mailing address differ * @param string $text Text for the link * @param boolean $email True if text is an email address * @param string $attribsBefore Any attributes before the email address * @param string $attribsAfter Any attributes before the email address * * @return string The cloaked email. * * @since 1.5 */ public static function cloak($mail, $mailto = true, $text = '', $email = true, $attribsBefore = '', $attribsAfter = '') { // Handle IDN addresses: punycode for href but utf-8 for text displayed. if ($mailto && (empty($text) || $email)) { // Use dedicated $text whereas $mail is used as href and must be punycoded. $text = PunycodeHelper::emailToUTF8($text ?: $mail); } elseif (!$mailto) { // In that case we don't use link - so convert $mail back to utf-8. $mail = PunycodeHelper::emailToUTF8($mail); } // Split email by @ symbol $mail = explode('@', $mail); $name = @$mail[0]; $domain = @$mail[1]; // Include the email cloaking script Factory::getDocument()->getWebAssetManager() ->useScript('webcomponent.hidden-mail'); return '<joomla-hidden-mail ' . $attribsBefore . ' is-link="' . $mailto . '" is-email="' . $email . '" first="' . base64_encode($name) . '" last="' . base64_encode($domain) . '" text="' . base64_encode($text) . '" base="' . Uri::root(true) . '" ' . $attribsAfter . '>' . Text::_('JLIB_HTML_CLOAKING') . '</joomla-hidden-mail>'; } } PK ��/[F�H$ $ Helpers/Number.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Language\Text; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * HTML helper class for rendering numbers. * * @since 1.6 */ abstract class Number { /** * Converts bytes to more distinguishable formats such as: * kilobytes, megabytes, etc. * * By default, the proper format will automatically be chosen. * However, one of the allowed unit types (viz. 'b', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB') may also be used instead. * IEC standard unit types ('KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB') can be used as well. * * @param string $bytes The number of bytes. Can be either numeric or suffixed format: 32M, 60K, 12G or 812b * @param string $unit The type of unit to return, few special values are: * Blank string '' for no unit, * 'auto' to choose automatically (default) * 'binary' to choose automatically but use binary unit prefix * @param integer $precision The number of digits to be used after the decimal place. * @param bool $iec Whether to be aware of IEC standards. IEC prefixes are always acceptable in input. * When IEC is ON: KiB = 1024 B, KB = 1000 B * When IEC is OFF: KiB = 1024 B, KB = 1024 B * * @return string The number of bytes in the proper units. * * @since 1.6 * @link https://en.wikipedia.org/wiki/Binary_prefix */ public static function bytes($bytes, $unit = 'auto', $precision = 2, $iec = false) { /* * Allowed 123.45, 123.45 M, 123.45 Mi, 123.45 MB, 123.45 MiB, 1.2345E+12MB, 1.2345E+12 MB , 1.2345E+12 MiB etc. * Meaning any number in decimal digits or in sci. notation, optional space, optional 1-3 letter unit suffix */ if (is_numeric($bytes)) { $oBytes = $bytes; } else { preg_match('/(.*?)\s?((?:[KMGTPEZY]i?)?B?)$/i', trim($bytes), $matches); list(, $oBytes, $oUnit) = $matches; if ($oUnit && is_numeric($oBytes)) { $oBase = $iec && strpos($oUnit, 'i') === false ? 1000 : 1024; $factor = pow($oBase, stripos('BKMGTPEZY', $oUnit[0])); $oBytes *= $factor; } } if (empty($oBytes) || !is_numeric($oBytes)) { return 0; } $oBytes = round($oBytes); // If no unit is requested return early if ($unit === '') { return (string) $oBytes; } $stdSuffixes = ['b', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $iecSuffixes = ['b', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; // User supplied method if (in_array($unit, $iecSuffixes)) { $base = 1024; $i = array_search($unit, $iecSuffixes, true); $suffix = $unit; } elseif (in_array($unit, $stdSuffixes)) { $base = $iec ? 1000 : 1024; $i = array_search($unit, $stdSuffixes, true); $suffix = $unit; } elseif ($unit === 'binary') { $base = 1024; $i = (int) floor(log($oBytes, $base)); $suffix = $iecSuffixes[$i]; } else { // Default method $base = $iec ? 1000 : 1024; $i = (int) floor(log($oBytes, $base)); $suffix = $stdSuffixes[$i]; } return number_format( round($oBytes / pow($base, $i), (int) $precision), (int) $precision, Text::_('DECIMALS_SEPARATOR'), Text::_('THOUSANDS_SEPARATOR') ) . ' ' . $suffix; } } PK ��/[��p� � Helpers/Date.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Date\Date as DateHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Extended Utility class for handling date display. * * @since 2.5 */ abstract class Date { /** * Function to convert a static time into a relative measurement * * @param string $date The date to convert * @param string $unit The optional unit of measurement to return * if the value of the diff is greater than one * @param string $time An optional time to compare to, defaults to now * @param string $format An optional format for the HTMLHelper::date output * * @return string The converted time string * * @since 2.5 */ public static function relative($date, $unit = null, $time = null, $format = null) { if ($time === null) { // Get now $time = new DateHelper('now'); } // Get the difference in seconds between now and the time $diff = strtotime($time) - strtotime($date); // Less than a minute if ($diff < 60) { return Text::_('JLIB_HTML_DATE_RELATIVE_LESSTHANAMINUTE'); } // Round to minutes $diff = round($diff / 60); // 1 to 59 minutes if ($diff < 60 || $unit === 'minute') { return Text::plural('JLIB_HTML_DATE_RELATIVE_MINUTES', $diff); } // Round to hours $diff = round($diff / 60); // 1 to 23 hours if ($diff < 24 || $unit === 'hour') { return Text::plural('JLIB_HTML_DATE_RELATIVE_HOURS', $diff); } // Round to days $diff = round($diff / 24); // 1 to 6 days if ($diff < 7 || $unit === 'day') { return Text::plural('JLIB_HTML_DATE_RELATIVE_DAYS', $diff); } // Round to weeks $diff = round($diff / 7); // 1 to 4 weeks if ($diff <= 4 || $unit === 'week') { return Text::plural('JLIB_HTML_DATE_RELATIVE_WEEKS', $diff); } // Over a month, return the absolute time return HTMLHelper::_('date', $date, $format); } } PK ��/[�� : Helpers/Jquery.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Utility class for jQuery JavaScript behaviors * * @since 3.0 */ abstract class Jquery { /** * Array containing information for loaded files * * @var array * @since 3.0 */ protected static $loaded = []; /** * Method to load the jQuery JavaScript framework into the document head * * If debugging mode is on an uncompressed version of jQuery is included for easier debugging. * * @param boolean $noConflict True to load jQuery in noConflict mode [optional] * @param mixed $debug Is debugging mode on? [optional] * @param boolean $migrate True to enable the jQuery Migrate plugin * * @return void * * @since 3.0 * * @deprecated 4.0 will be removed in 6.0 * Use webasset manager instead * Example: * $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); * $wa->useScript('jquery'); * $wa->useScript('jquery-noconflict'); * $wa->useScript('jquery-migrate'); */ public static function framework($noConflict = true, $debug = null, $migrate = false) { $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); $wa->useScript('jquery'); // Check if we are loading in noConflict if ($noConflict) { $wa->useScript('jquery-noconflict'); } // Check if we are loading Migrate if ($migrate) { $wa->useScript('jquery-migrate'); } } /** * Auto set CSRF token to ajaxSetup so all jQuery ajax call will contains CSRF token. * * @param string $name The CSRF meta tag name. * * @return void * * @throws \InvalidArgumentException * * @since 3.8.0 */ public static function token($name = 'csrf.token') { // Only load once if (!empty(static::$loaded[__METHOD__][$name])) { return; } static::framework(); HTMLHelper::_('form.csrf', $name); $doc = Factory::getDocument(); $doc->addScriptDeclaration( <<<JS ;(function ($) { $.ajaxSetup({ headers: { 'X-CSRF-Token': Joomla.getOptions('$name') } }); })(jQuery); JS ); static::$loaded[__METHOD__][$name] = true; } } PK ��/[m}Y� � Helpers/ActionsDropdown.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * HTML utility class for building a dropdown menu * * @since 3.2 */ abstract class ActionsDropdown { /** * @var string HTML markup for the dropdown list * @since 3.2 */ protected static $dropDownList = []; /** * Method to render current dropdown menu * * @param string $item An item to render. * * @return string HTML markup for the dropdown list * * @since 3.2 */ public static function render($item = '') { $html = []; $html[] = '<button data-bs-toggle="dropdown" class="dropdown-toggle btn btn-sm btn-secondary">'; $html[] = '<span class="caret"></span>'; if ($item) { $html[] = '<span class="visually-hidden">' . Text::sprintf('JACTIONS', $item) . '</span>'; } $html[] = '</button>'; $html[] = '<ul class="dropdown-menu">'; $html[] = implode('', static::$dropDownList); $html[] = '</ul>'; static::$dropDownList = null; return implode('', $html); } /** * Append a publish item to the current dropdown menu * * @param string $id ID of corresponding checkbox of the record * @param string $prefix The task prefix * * @return void * * @since 3.2 */ public static function publish($id, $prefix = '') { $task = ($prefix ? $prefix . '.' : '') . 'publish'; static::addCustomItem(Text::_('JTOOLBAR_PUBLISH'), 'publish', $id, $task); } /** * Append an unpublish item to the current dropdown menu * * @param string $id ID of corresponding checkbox of the record * @param string $prefix The task prefix * * @return void * * @since 3.2 */ public static function unpublish($id, $prefix = '') { $task = ($prefix ? $prefix . '.' : '') . 'unpublish'; static::addCustomItem(Text::_('JTOOLBAR_UNPUBLISH'), 'unpublish', $id, $task); } /** * Append a feature item to the current dropdown menu * * @param string $id ID of corresponding checkbox of the record * @param string $prefix The task prefix * * @return void * * @since 3.2 */ public static function feature($id, $prefix = '') { $task = ($prefix ? $prefix . '.' : '') . 'featured'; static::addCustomItem(Text::_('JFEATURE'), 'featured', $id, $task); } /** * Append an unfeature item to the current dropdown menu * * @param string $id ID of corresponding checkbox of the record * @param string $prefix The task prefix * * @return void * * @since 3.2 */ public static function unfeature($id, $prefix = '') { $task = ($prefix ? $prefix . '.' : '') . 'unfeatured'; static::addCustomItem(Text::_('JUNFEATURE'), 'unfeatured', $id, $task); } /** * Append an archive item to the current dropdown menu * * @param string $id ID of corresponding checkbox of the record * @param string $prefix The task prefix * * @return void * * @since 3.2 */ public static function archive($id, $prefix = '') { $task = ($prefix ? $prefix . '.' : '') . 'archive'; static::addCustomItem(Text::_('JTOOLBAR_ARCHIVE'), 'archive', $id, $task); } /** * Append an unarchive item to the current dropdown menu * * @param string $id ID of corresponding checkbox of the record * @param string $prefix The task prefix * * @return void * * @since 3.2 */ public static function unarchive($id, $prefix = '') { $task = ($prefix ? $prefix . '.' : '') . 'unpublish'; static::addCustomItem(Text::_('JTOOLBAR_UNARCHIVE'), 'unarchive', $id, $task); } /** * Append a duplicate item to the current dropdown menu * * @param string $id ID of corresponding checkbox of the record * @param string $prefix The task prefix * * @return void * * @since 3.2 */ public static function duplicate($id, $prefix = '') { $task = ($prefix ? $prefix . '.' : '') . 'duplicate'; static::addCustomItem(Text::_('JTOOLBAR_DUPLICATE'), 'copy', $id, $task); } /** * Append a trash item to the current dropdown menu * * @param string $id ID of corresponding checkbox of the record * @param string $prefix The task prefix * * @return void * * @since 3.2 */ public static function trash($id, $prefix = '') { $task = ($prefix ? $prefix . '.' : '') . 'trash'; static::addCustomItem(Text::_('JTOOLBAR_TRASH'), 'trash', $id, $task); } /** * Append an untrash item to the current dropdown menu * * @param string $id ID of corresponding checkbox of the record * @param string $prefix The task prefix * * @return void * * @since 3.2 */ public static function untrash($id, $prefix = '') { self::publish($id, $prefix); } /** * Writes a divider between dropdown items * * @return void * * @since 3.0 */ public static function divider() { static::$dropDownList[] = '<li class="divider"></li>'; } /** * Append a custom item to current dropdown menu. * * @param string $label The label of the item. * @param string $icon The icon classname. * @param string $id The item id. * @param string $task The task. * * @return void * * @since 3.2 */ public static function addCustomItem($label, $icon = '', $id = '', $task = '') { Factory::getDocument()->getWebAssetManager()->useScript('list-view'); static::$dropDownList[] = '<li>' . HTMLHelper::link( '#', ($icon ? LayoutHelper::render('joomla.icon.iconclass', ['icon' => $icon]) : '') . $label, [ 'data-item-id' => $id, 'data-item-task' => $task, 'class' => 'js-grid-item-action', ] ) . '</li>'; } } PK ��/[6�!�׃ ׃ Helpers/Bootstrap.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Layout\FileLayout; use Joomla\CMS\Layout\LayoutHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Utility class for Bootstrap elements. * * @since 3.0 */ abstract class Bootstrap { /** * @var array Array containing information for loaded files * @since 3.0 */ protected static $loaded = []; /** * Add javascript support for Bootstrap alerts * * @param string $selector Common class for the alerts * * @return void * * @throws \Exception * * @since 3.0 */ public static function alert($selector = ''): void { // Only load once if (!empty(static::$loaded[__METHOD__][$selector])) { return; } $doc = Factory::getDocument(); if ($selector !== '') { $scriptOptions = $doc->getScriptOptions('bootstrap.alert'); $options = [$selector]; if (is_array($scriptOptions)) { $options = array_merge($scriptOptions, $options); } $doc->addScriptOptions('bootstrap.alert', $options, false); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.alert'); static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap buttons * * @param string $selector Common class for the buttons * * @return void * * @throws \Exception * * @since 3.1 */ public static function button($selector = ''): void { // Only load once if (!empty(static::$loaded[__METHOD__][$selector])) { return; } $doc = Factory::getDocument(); if ($selector !== '') { $scriptOptions = $doc->getScriptOptions('bootstrap.button'); $options = [$selector]; if (is_array($scriptOptions)) { $options = array_merge($scriptOptions, $options); } $doc->addScriptOptions('bootstrap.button', $options, false); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.button'); static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap carousels * * @param string $selector Common class for the carousels. * @param array $params An array of options for the carousel. * * @return void * * @throws \Exception * * @since 3.0 * * Options for the carousel can be: * - interval number 5000 The amount of time to delay between automatically cycling an item. * If false, carousel will not automatically cycle. * - keyboard boolean true Whether the carousel should react to keyboard events. * - pause string| hover Pauses the cycling of the carousel on mouseenter and resumes the cycling * boolean of the carousel on mouseleave. * - slide string| false Autoplays the carousel after the user manually cycles the first item. * boolean If "carousel", autoplays the carousel on load. */ public static function carousel($selector = '', $params = []): void { // Only load once if (!empty(static::$loaded[__METHOD__][$selector])) { return; } if ($selector !== '') { // Setup options object $opt = [ 'interval' => (isset($params['interval']) ? (int) $params['interval'] : 5000), 'keyboard' => (isset($params['keyboard']) ? (bool) $params['keyboard'] : true), 'pause' => (isset($params['pause']) ? $params['pause'] : 'hover'), 'slide' => (isset($params['slide']) ? (bool) $params['slide'] : false), 'wrap' => (isset($params['wrap']) ? (bool) $params['wrap'] : true), 'touch' => (isset($params['touch']) ? (bool) $params['touch'] : true), ]; Factory::getDocument()->addScriptOptions('bootstrap.carousel', [$selector => (object) array_filter((array) $opt)]); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.carousel'); static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap collapse * * @param string $selector Common class for the collapse * @param string[] $params Additional parameters - see below * * @return void * * @throws \Exception * * @since 4.0.0 * * Options for the collapse can be: * - parent string false If parent is provided, then all collapsible elements under the specified parent will * be closed when this collapsible item is shown. * - toggle boolean true Toggles the collapsible element on invocation */ public static function collapse($selector = '', $params = []): void { // Only load once if (!empty(static::$loaded[__METHOD__][$selector])) { return; } if ($selector !== '') { // Setup options object $opt = []; $opt['parent'] = isset($params['parent']) ? $params['parent'] : false; $opt['toggle'] = isset($params['toggle']) ? (bool) $params['toggle'] : true; Factory::getDocument()->addScriptOptions('bootstrap.collapse', [$selector => (object) array_filter((array) $opt)]); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.collapse'); static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap dropdowns * * @param string $selector Common class for the dropdowns * @param array $params The options for the dropdowns * * @return void * * @since 4.0.0 * * Options for the collapse can be: * - flip boolean true Allow Dropdown to flip in case of an overlapping on the reference element * - boundary string scrollParent Overflow constraint boundary of the dropdown menu * - reference string toggle Reference element of the dropdown menu. Accepts 'toggle' or 'parent' * - display string dynamic By default, we use Popper for dynamic positioning. Disable this with static */ public static function dropdown($selector = '', $params = []): void { // Only load once if (!empty(static::$loaded[__METHOD__][$selector])) { return; } if ($selector !== '') { // Setup options object $opt = []; $opt['flip'] = isset($params['flip']) ? $params['flip'] : true; $opt['boundary'] = isset($params['boundary']) ? $params['boundary'] : 'scrollParent'; $opt['reference'] = isset($params['reference']) ? $params['reference'] : 'toggle'; $opt['display'] = isset($params['display']) ? $params['display'] : 'dynamic'; $opt['popperConfig'] = isset($params['popperConfig']) ? (bool) $params['popperConfig'] : true; Factory::getDocument()->addScriptOptions('bootstrap.dropdown', [$selector => (object) array_filter((array) $opt)]); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.dropdown'); static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap modal * * @param string $selector The ID selector for the modal. * @param array $options An array of options for the modal. * * @return void * * @since 4.0.0 * * Options for the modal can be: * - backdrop string| true Includes a modal-backdrop element. Alternatively, specify static * boolean for a backdrop which doesn't close the modal on click. * - keyboard boolean true Closes the modal when escape key is pressed * - focus boolean true Closes the modal when escape key is pressed */ public static function modal($selector = '', $options = []): void { // Only load once if (!empty(static::$loaded[__METHOD__][$selector])) { return; } if ($selector !== '') { // Setup options object $opt = [ 'backdrop' => (isset($options['backdrop']) ? $options['backdrop'] : false), 'keyboard' => (isset($options['keyboard']) ? (bool) $options['keyboard'] : true), 'focus' => (isset($options['focus']) ? (bool) $options['focus'] : true), ]; Factory::getDocument()->addScriptOptions('bootstrap.modal', [$selector => (object) array_filter((array) $opt)]); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.modal'); static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap offcanvas * * @param string $selector The ID selector for the offcanvas. * @param array $options An array of options for the offcanvas. * * @return void * * @since 4.0.0 * * Options for the offcanvas can be: * - backdrop boolean true Apply a backdrop on body while offcanvas is open * - keyboard boolean true Closes the offcanvas when escape key is pressed * - scroll boolean false Allow body scrolling while offcanvas is open */ public static function offcanvas($selector = '', $options = []): void { // Only load once if (!empty(static::$loaded[__METHOD__][$selector])) { return; } if ($selector !== '') { // Setup options object $opt = [ 'backdrop' => (isset($options['backdrop']) ? (bool) $options['backdrop'] : true), 'keyboard' => (isset($options['keyboard']) ? (bool) $options['keyboard'] : true), 'scroll' => (isset($options['scroll']) ? (bool) $options['scroll'] : false), ]; Factory::getDocument()->addScriptOptions('bootstrap.offcanvas', [$selector => (object) array_filter((array) $opt)]); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.offcanvas'); static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap popovers * * Use element's Title as popover content * * @param string $selector Selector for the popover * @param array $options The options for the popover * * @return void * * @since 3.0 * * - Options for the popover can be: * - animation boolean true Apply a CSS fade transition to the popover * - container string| false Appends the popover to a specific element. Eg.: 'body' * boolean * - content string null Default content value if data-bs-content attribute isn't present * - delay number 0 Delay showing and hiding the popover (ms) * does not apply to manual trigger type * - html boolean true Insert HTML into the popover. If false, innerText property will be used * to insert content into the DOM. * - placement string right How to position the popover - auto | top | bottom | left | right. * When auto is specified, it will dynamically reorient the popover * - selector string false If a selector is provided, popover objects will be delegated to the * specified targets. * - template string null Base HTML to use when creating the popover. * - title string null Default title value if `title` tag isn't present * - trigger string click How popover is triggered - click | hover | focus | manual * - offset integer 0 Offset of the popover relative to its target. */ public static function popover($selector = '', $options = []): void { // Only load once if (isset(static::$loaded[__METHOD__][$selector])) { return; } if ($selector !== '') { // Setup options object $opt = [ 'animation' => isset($options['animation']) ? (bool) $options['animation'] : true, 'container' => isset($options['container']) ? $options['container'] : 'body', 'content' => isset($options['content']) ? $options['content'] : null, 'delay' => isset($options['delay']) ? (int) $options['delay'] : ['show' => 50, 'hide' => 200], 'html' => isset($options['html']) ? (bool) $options['html'] : true, 'placement' => isset($options['placement']) ? $options['placement'] : null, 'selector' => isset($options['selector']) ? $options['selector'] : false, 'template' => isset($options['template']) ? $options['template'] : null, 'title' => isset($options['title']) ? $options['title'] : null, 'trigger' => isset($options['trigger']) ? $options['trigger'] : 'click', 'offset' => isset($options['offset']) ? $options['offset'] : [0, 10], 'fallbackPlacement' => isset($options['fallbackPlacement']) ? $options['fallbackPlacement'] : null, 'boundary' => isset($options['boundary']) ? $options['boundary'] : 'scrollParent', 'customClass' => isset($options['customClass']) ? $options['customClass'] : null, 'sanitize' => isset($options['sanitize']) ? (bool) $options['sanitize'] : null, 'allowList' => isset($options['allowList']) ? $options['allowList'] : null, ]; Factory::getDocument()->addScriptOptions('bootstrap.popover', [$selector => (object) array_filter((array) $opt)]); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.popover'); static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap Scrollspy * * @param string $selector The ID selector for the ScrollSpy element. * @param array $options An array of options for the ScrollSpy. * * @return void * * @since 3.0 * * Options for the Scrollspy can be: * - offset number Pixels to offset from top when calculating position of scroll. * - method string Finds which section the spied element is in. * - target string Specifies element to apply Scrollspy plugin. */ public static function scrollspy($selector = '', $options = []): void { // Only load once if (isset(static::$loaded[__METHOD__][$selector])) { return; } if ($selector !== '') { // Setup options object $opt = [ 'offset' => isset($options['offset']) ? (int) $options['offset'] : 10, 'method' => isset($options['method']) ? $options['method'] : 'auto', 'target' => isset($options['target']) ? $options['target'] : null, ]; Factory::getDocument()->addScriptOptions('bootstrap.scrollspy', [$selector => (object) array_filter((array) $opt)]); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.scrollspy'); static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap tab * * @param string $selector Common class for the tabs * @param array $options Options for the tabs * * @return void * * @throws \Exception * * @since 4.0.0 */ public static function tab($selector = '', $options = []): void { // Only load once if (!empty(static::$loaded[__METHOD__][$selector])) { return; } if ($selector !== '') { Factory::getDocument()->addScriptOptions('bootstrap.tabs', [$selector => (object) $options]); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.tab'); static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap tooltips * * Add a title attribute to any element in the form * title="title::text" * * @param string $selector The ID selector for the tooltip. * @param array $options An array of options for the tooltip. * * @return void * * @since 3.0 * * Options for the tooltip can be: * - animation boolean apply a css fade transition to the popover * - container string|boolean Appends the popover to a specific element: { container: 'body' } * - delay number|object delay showing and hiding the popover (ms) - does not apply to manual trigger type * If a number is supplied, delay is applied to both hide/show * Object structure is: delay: { show: 500, hide: 100 } * - html boolean Insert HTML into the popover. If false, jQuery's text method will be used to * insert content into the dom. * - placement string|function how to position the popover - top | bottom | left | right * - selector string If a selector is provided, popover objects will be * delegated to the specified targets. * - template string Base HTML to use when creating the popover. * - title string|function default title value if `title` tag isn't present * - trigger string how popover is triggered - hover | focus | manual * - constraints array An array of constraints - passed through to Popper. * - offset string Offset of the popover relative to its target. */ public static function tooltip($selector = '', $options = []): void { // Only load once if (isset(static::$loaded[__METHOD__][$selector])) { return; } if ($selector !== '') { // Setup options object $opt = [ 'animation' => isset($options['animation']) ? (bool) $options['animation'] : true, 'container' => isset($options['container']) ? $options['container'] : 'body', 'delay' => isset($options['delay']) ? (int) $options['delay'] : 0, 'html' => isset($options['html']) ? (bool) $options['html'] : true, 'placement' => isset($options['placement']) ? $options['placement'] : null, 'selector' => isset($options['selector']) ? $options['selector'] : false, 'template' => isset($options['template']) ? $options['template'] : null, 'title' => isset($options['title']) ? $options['title'] : null, 'trigger' => isset($options['trigger']) ? $options['trigger'] : 'hover focus', 'fallbackPlacement' => isset($options['fallbackPlacement']) ? $options['fallbackPlacement'] : null, 'boundary' => isset($options['boundary']) ? $options['boundary'] : 'clippingParents', 'customClass' => isset($options['customClass']) ? $options['customClass'] : null, 'sanitize' => isset($options['sanitize']) ? (bool) $options['sanitize'] : true, 'allowList' => isset($options['allowList']) ? $options['allowList'] : null, ]; Factory::getDocument()->addScriptOptions('bootstrap.tooltip', [$selector => (object) array_filter((array) $opt)]); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.popover'); // Set static array static::$loaded[__METHOD__][$selector] = true; } /** * Add javascript support for Bootstrap toasts * * @param string $selector Common class for the toasts * @param array $options Options for the toasts * * @return void * * @throws \Exception * * @since 4.0.0 */ public static function toast($selector = '', $options = []): void { // Only load once if (!empty(static::$loaded[__METHOD__][$selector])) { return; } if ($selector !== '') { // Setup options object $opt = [ 'animation' => isset($options['animation']) ? (string) $options['animation'] : null, 'autohide' => isset($options['autohide']) ? (bool) $options['autohide'] : true, 'delay' => isset($options['delay']) ? (int) $options['delay'] : 5000, ]; Factory::getDocument()->addScriptOptions('bootstrap.toast', [$selector => (object) array_filter((array) $opt)]); } // Include the Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.toast'); static::$loaded[__METHOD__][$selector] = true; } /** * Method to load the ALL the Bootstrap Components * * If debugging mode is on an uncompressed version of Bootstrap is included for easier debugging. * * @param mixed $debug Is debugging mode on? [optional] * * @return void * * @since 3.0 * * @deprecated 4.0 will be removed in 6.0 * Will be removed without replacement * Load the different scripts with their individual method calls */ public static function framework($debug = null): void { $wa = Factory::getApplication() ->getDocument() ->getWebAssetManager(); array_map( function ($script) use ($wa) { $wa->useScript('bootstrap.' . $script); }, ['alert', 'button', 'carousel', 'collapse', 'dropdown', 'modal', 'offcanvas', 'popover', 'scrollspy', 'tab', 'toast'] ); } /** * Loads CSS files needed by Bootstrap * * @param boolean $includeMainCss If true, main bootstrap.css files are loaded * @param string $direction rtl or ltr direction. If empty, ltr is assumed * @param array $attribs Optional array of attributes to be passed to HTMLHelper::_('stylesheet') * * @return void * * @since 3.0 */ public static function loadCss($includeMainCss = true, $direction = 'ltr', $attribs = []): void { // Load Bootstrap main CSS if ($includeMainCss) { Factory::getDocument()->getWebAssetManager()->useStyle('bootstrap.css'); } } /** * Add javascript support for Bootstrap accordions and insert the accordion * * @param string $selector The ID selector for the tooltip. Expects a valid ID without the #! * @param array $options An array of options for the tooltip. * * @return string HTML for the accordion * * @since 3.0 * * Options for the tooltip can be: * - parent selector If selector then all collapsible elements under the specified parent will be closed when this * collapsible item is shown. (similar to traditional accordion behavior) * - toggle boolean Toggles the collapsible element on invocation * - active string Sets the active slide during load */ public static function startAccordion($selector = 'myAccordian', $options = []): string { // Only load once if (isset(static::$loaded[__METHOD__][$selector])) { return ''; } // Include Bootstrap component Factory::getApplication() ->getDocument() ->getWebAssetManager() ->useScript('bootstrap.collapse'); // Setup options object $opt = []; $opt['parent'] = isset($options['parent']) ? ($options['parent'] == true ? '#' . preg_replace('/^[\.#]/', '', $selector) : $options['parent']) : ''; $opt['toggle'] = isset($options['toggle']) ? (bool) $options['toggle'] : !($opt['parent'] === false || isset($options['active'])); $opt['active'] = isset($options['active']) ? (string) $options['active'] : ''; // Initialise with the Joomla specifics $opt['isJoomla'] = true; Factory::getDocument()->addScriptOptions('bootstrap.accordion', ['#' . preg_replace('/^[\.#]/', '', $selector) => (object) array_filter((array) $opt)]); static::$loaded[__METHOD__][$selector] = $opt; return '<div id="' . $selector . '" class="accordion" role="tablist">'; } /** * Close the current accordion * * @return string HTML to close the accordion * * @since 3.0 */ public static function endAccordion(): string { return '</div>'; } /** * Begins the display of a new accordion slide. * * @param string $selector Identifier of the accordion group. * @param string $text Text to display. * @param string $id Identifier of the slide. * @param string $class Class of the accordion group. * * @return string HTML to add the slide * * @since 3.0 */ public static function addSlide($selector, $text, $id, $class = ''): string { $in = static::$loaded[__CLASS__ . '::startAccordion'][$selector]['active'] === $id ? ' show' : ''; $collapsed = static::$loaded[__CLASS__ . '::startAccordion'][$selector]['active'] === $id ? '' : ' collapsed'; $parent = static::$loaded[__CLASS__ . '::startAccordion'][$selector]['parent'] ? 'data-bs-parent="' . static::$loaded[__CLASS__ . '::startAccordion'][$selector]['parent'] . '"' : ''; $class = (!empty($class)) ? ' ' . $class : ''; $ariaExpanded = $in === 'show' ? true : false; return <<<HTMLSTR <div class="accordion-item $class"> <h2 class="accordion-header" id="$id-heading"> <button class="accordion-button $collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#$id" aria-expanded="$ariaExpanded" aria-controls="$id" role="tab"> $text </button> </h2> <div id="$id" class="accordion-collapse collapse $in" aria-labelledby="$id-heading" $parent role="tabpanel"> <div class="accordion-body"> HTMLSTR; } /** * Close the current slide * * @return string HTML to close the slide * * @since 3.0 */ public static function endSlide(): string { return <<<HTMLSTR </div> </div> </div> HTMLSTR; } /** * Method to render a Bootstrap modal * * @param string $selector The ID selector for the modal. Expects a valid ID without the #! * @param array $options An array of options for the modal. * @param string $body Markup for the modal body. Appended after the `<iframe>` if the URL option is set * * @return string HTML markup for a modal * * @since 3.0 * * Options for the modal can be: * - backdrop string| true Includes a modal-backdrop element. Alternatively, specify static * boolean for a backdrop which doesn't close the modal on click. * - keyboard boolean true Closes the modal when escape key is pressed * - focus boolean true Closes the modal when escape key is pressed * - title string null The modal title * - closeButton boolean true Display modal close button (default = true) * - footer string null Optional markup for the modal footer * - url string null URL of a resource to be inserted as an `<iframe>` inside the modal body * - height string null Height of the `<iframe>` containing the remote resource * - width string null Width of the `<iframe>` containing the remote resource */ public static function renderModal($selector = 'modal', $options = [], $body = ''): string { // Only load once if (!empty(static::$loaded[__METHOD__][$selector])) { return ''; } // Initialise with the Joomla specifics $options['isJoomla'] = true; // Include Basic Bootstrap component HTMLHelper::_('bootstrap.modal', '#' . preg_replace('/^[\.#]/', '', $selector), $options); $layoutData = [ 'selector' => $selector, 'params' => $options, 'body' => $body, ]; static::$loaded[__METHOD__][$selector] = true; return LayoutHelper::render('libraries.html.bootstrap.modal.main', $layoutData); } /** * Creates a tab pane * * @param string $selector The pane identifier. Expects a valid ID without the #! * @param array $params The parameters for the pane * * @return string * * @since 3.1 */ public static function startTabSet($selector = 'myTab', $params = []): string { $sig = md5(serialize([$selector, $params])); if (!isset(static::$loaded[__METHOD__][$sig])) { // Setup options object $opt = []; $opt['active'] = (isset($params['active']) && ($params['active'])) ? (string) $params['active'] : ''; // Initialise with the Joomla specifics $opt['isJoomla'] = true; // Include the Bootstrap Tab Component HTMLHelper::_('bootstrap.tab', '#' . preg_replace('/^[\.#]/', '', $selector), $opt); // Set static array static::$loaded[__METHOD__][$sig] = true; static::$loaded[__METHOD__][$selector]['active'] = $opt['active']; return LayoutHelper::render('libraries.html.bootstrap.tab.starttabset', ['selector' => $selector]); } } /** * Close the current tab pane * * @return string HTML to close the pane * * @since 3.1 */ public static function endTabSet(): string { return LayoutHelper::render('libraries.html.bootstrap.tab.endtabset'); } /** * Begins the display of a new tab content panel. * * @param string $selector Identifier of the panel. Expects a valid ID without the #! * @param string $id The ID of the div element. Expects a valid ID without the #! * @param string $title The title text for the new UL tab * * @return string HTML to start a new panel * * @since 3.1 */ public static function addTab($selector, $id, $title): string { static $tabLayout = null; $tabLayout = $tabLayout === null ? new FileLayout('libraries.html.bootstrap.tab.addtab') : $tabLayout; $active = (static::$loaded[__CLASS__ . '::startTabSet'][$selector]['active'] == $id) ? ' active' : ''; return $tabLayout->render(['id' => preg_replace('/^[\.#]/', '', $id), 'active' => $active, 'title' => $title]); } /** * Close the current tab content panel * * @return string HTML to close the pane * * @since 3.1 */ public static function endTab(): string { return LayoutHelper::render('libraries.html.bootstrap.tab.endtab'); } } PK ��/[��e� Helpers/Debug.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Filesystem\Path; use Joomla\CMS\HTML\HTMLHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Extended Utility class for render debug information. * * @since 3.7.0 */ abstract class Debug { /** * xdebug.file_link_format from the php.ini. * * Make this property public to support test. * * @var string * * @since 3.7.0 */ public static $xdebugLinkFormat; /** * Replaces the Joomla! root with "JROOT" to improve readability. * Formats a link with a special value xdebug.file_link_format * from the php.ini file. * * @param string $file The full path to the file. * @param string $line The line number. * * @return string * * @throws \InvalidArgumentException * * @since 3.7.0 */ public static function xdebuglink($file, $line = '') { if (static::$xdebugLinkFormat === null) { static::$xdebugLinkFormat = ini_get('xdebug.file_link_format'); } $link = str_replace(JPATH_ROOT, 'JROOT', Path::clean($file)); $link .= $line ? ':' . $line : ''; if (static::$xdebugLinkFormat) { $href = static::$xdebugLinkFormat; $href = str_replace('%f', $file, $href); $href = str_replace('%l', $line, $href); $html = HTMLHelper::_('link', $href, $link); } else { $html = $link; } return $html; } } PK ��/[�+0M� � Helpers/FormBehavior.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Utility class for form related behaviors * * @since 3.0 * * @deprecated 4.0 will be removed in 6.0 * Will be removed without replacement * Use choice.js instead * Example: * Factory::getDocument()->getWebAssetManager()->enableAsset('choicesjs'); * HTMLHelper::_('webcomponent', 'system/webcomponents/joomla-field-fancy-select.min.js', ['version' => 'auto', 'relative' => true]); */ abstract class FormBehavior { /** * @var array Array containing information for loaded files * @since 3.0 */ protected static $loaded = []; /** * Method to load the Chosen JavaScript framework and supporting CSS into the document head * * If debugging mode is on an uncompressed version of Chosen is included for easier debugging. * * @param string $selector Class for Chosen elements. * @param mixed $debug Is debugging mode on? [optional] * @param array $options the possible Chosen options as name => value [optional] * * @return void * * @since 3.0 */ public static function chosen($selector = '.advancedSelect', $debug = null, $options = []) { if (isset(static::$loaded[__METHOD__][$selector])) { return; } // If no debugging value is set, use the configuration setting if ($debug === null) { $debug = JDEBUG; } // Default settings if (!isset($options['disable_search_threshold'])) { $options['disable_search_threshold'] = 10; } // Allow searching contains space in query if (!isset($options['search_contains'])) { $options['search_contains'] = true; } if (!isset($options['allow_single_deselect'])) { $options['allow_single_deselect'] = true; } if (!isset($options['placeholder_text_multiple'])) { $options['placeholder_text_multiple'] = Text::_('JGLOBAL_TYPE_OR_SELECT_SOME_OPTIONS'); } if (!isset($options['placeholder_text_single'])) { $options['placeholder_text_single'] = Text::_('JGLOBAL_SELECT_AN_OPTION'); } if (!isset($options['no_results_text'])) { $options['no_results_text'] = Text::_('JGLOBAL_SELECT_NO_RESULTS_MATCH'); } // Options array to json options string $options_str = \json_encode($options, ($debug && \defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : false)); // Add chosen.js assets /** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); $wa->usePreset('chosen') ->registerAndUseScript('joomla-chosen', 'legacy/joomla-chosen.min.js', [], [], ['chosen']) ->addInlineScript( " jQuery(document).ready(function (){ jQuery('" . $selector . "').jchosen(" . $options_str . "); }); " ); static::$loaded[__METHOD__][$selector] = true; } /** * Method to load the AJAX Chosen library * * If debugging mode is on an uncompressed version of AJAX Chosen is included for easier debugging. * * @param Registry $options Options in a Registry object * @param mixed $debug Is debugging mode on? [optional] * * @return void * * @since 3.0 */ public static function ajaxchosen(Registry $options, $debug = null) { // Retrieve options/defaults $selector = $options->get('selector', '.tagfield'); $type = $options->get('type', 'GET'); $url = $options->get('url', null); $dataType = $options->get('dataType', 'json'); $jsonTermKey = $options->get('jsonTermKey', 'term'); $afterTypeDelay = $options->get('afterTypeDelay', '500'); $minTermLength = $options->get('minTermLength', '3'); // Ajax URL is mandatory if (!empty($url)) { if (isset(static::$loaded[__METHOD__][$selector])) { return; } // Requires chosen to work static::chosen($selector, $debug); Text::script('JGLOBAL_KEEP_TYPING'); Text::script('JGLOBAL_LOOKING_FOR'); // Include scripts HTMLHelper::_('behavior.core'); HTMLHelper::_('jquery.framework'); HTMLHelper::_('script', 'legacy/ajax-chosen.min.js', ['version' => 'auto', 'relative' => true, 'detectDebug' => $debug]); Factory::getDocument()->addScriptOptions( 'ajax-chosen', [ 'url' => $url, 'debug' => $debug, 'options' => $options, 'selector' => $selector, 'type' => $type, 'dataType' => $dataType, 'jsonTermKey' => $jsonTermKey, 'afterTypeDelay' => $afterTypeDelay, 'minTermLength' => $minTermLength, ] ); static::$loaded[__METHOD__][$selector] = true; } } } PK ��/[v� ��u �u Helpers/Select.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\Utilities\ArrayHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Utility class for creating HTML select lists * * @since 1.5 */ abstract class Select { /** * Default values for options. Organized by option group. * * @var array * @since 1.5 */ protected static $optionDefaults = [ 'option' => [ 'option.attr' => null, 'option.disable' => 'disable', 'option.id' => null, 'option.key' => 'value', 'option.key.toHtml' => true, 'option.label' => null, 'option.label.toHtml' => true, 'option.text' => 'text', 'option.text.toHtml' => true, 'option.class' => 'class', 'option.onclick' => 'onclick', ], ]; /** * Generates a yes/no radio list. * * @param string $name The value of the HTML name attribute * @param array $attribs Additional HTML attributes for the `<select>` tag * @param string $selected The key that is selected * @param string $yes Language key for Yes * @param string $no Language key for no * @param mixed $id The id for the field or false for no id * * @return string HTML for the radio list * * @since 1.5 * @see \Joomla\CMS\Form\Field\RadioField */ public static function booleanlist($name, $attribs = [], $selected = null, $yes = 'JYES', $no = 'JNO', $id = false) { $arr = [HTMLHelper::_('select.option', '0', Text::_($no)), HTMLHelper::_('select.option', '1', Text::_($yes))]; return HTMLHelper::_('select.radiolist', $arr, $name, $attribs, 'value', 'text', (int) $selected, $id); } /** * Generates an HTML selection list. * * @param array $data An array of objects, arrays, or scalars. * @param string $name The value of the HTML name attribute. * @param mixed $attribs Additional HTML attributes for the `<select>` tag. This * can be an array of attributes, or an array of options. Treated as options * if it is the last argument passed. Valid options are: * Format options, see {@see HTMLHelper::$formatOptions}. * Selection options, see {@see JHtmlSelect::options()}. * list.attr, string|array: Additional attributes for the select * element. * id, string: Value to use as the select element id attribute. * Defaults to the same as the name. * list.select, string|array: Identifies one or more option elements * to be selected, based on the option key values. * @param string $optKey The name of the object variable for the option value. If * set to null, the index of the value array is used. * @param string $optText The name of the object variable for the option text. * @param mixed $selected The key that is selected (accepts an array or a string). * @param mixed $idtag Value of the field id or null by default * @param boolean $translate True to translate * * @return string HTML for the select list. * * @since 1.5 */ public static function genericlist( $data, $name, $attribs = null, $optKey = 'value', $optText = 'text', $selected = null, $idtag = false, $translate = false ) { // Set default options $options = array_merge(HTMLHelper::$formatOptions, ['format.depth' => 0, 'id' => false]); if (is_array($attribs) && func_num_args() === 3) { // Assume we have an options array $options = array_merge($options, $attribs); } else { // Get options from the parameters $options['id'] = $idtag; $options['list.attr'] = $attribs; $options['list.translate'] = $translate; $options['option.key'] = $optKey; $options['option.text'] = $optText; $options['list.select'] = $selected; } $attribs = ''; if (isset($options['list.attr'])) { if (is_array($options['list.attr'])) { $attribs = ArrayHelper::toString($options['list.attr']); } else { $attribs = $options['list.attr']; } if ($attribs !== '') { $attribs = ' ' . $attribs; } } $id = $options['id'] !== false ? $options['id'] : $name; $id = str_replace(['[', ']', ' '], '', $id); // If the selectbox contains "form-select-color-state" then load the JS file if (strpos($attribs, 'form-select-color-state') !== false) { Factory::getDocument()->getWebAssetManager() ->registerScript( 'webcomponent.select-colour-es5', 'system/fields/select-colour-es5.min.js', ['dependencies' => ['wcpolyfill']], ['defer' => true, 'nomodule' => true] ) ->registerAndUseScript( 'webcomponent.select-colour', 'system/fields/select-colour.min.js', ['dependencies' => ['webcomponent.select-colour-es5']], ['type' => 'module'] ); } $baseIndent = str_repeat($options['format.indent'], $options['format.depth']++); $html = $baseIndent . '<select' . ($id !== '' ? ' id="' . $id . '"' : '') . ' name="' . $name . '"' . $attribs . '>' . $options['format.eol'] . static::options($data, $options) . $baseIndent . '</select>' . $options['format.eol']; return $html; } /** * Generates a grouped HTML selection list from nested arrays. * * @param array $data An array of groups, each of which is an array of options. * @param string $name The value of the HTML name attribute * @param array $options Options, an array of key/value pairs. Valid options are: * Format options, {@see HTMLHelper::$formatOptions}. * Selection options. See {@see JHtmlSelect::options()}. * group.id: The property in each group to use as the group id * attribute. Defaults to none. * group.label: The property in each group to use as the group * label. Defaults to "text". If set to null, the data array index key is * used. * group.items: The property in each group to use as the array of * items in the group. Defaults to "items". If set to null, group.id and * group. label are forced to null and the data element is assumed to be a * list of selections. * id: Value to use as the select element id attribute. Defaults to * the same as the name. * list.attr: Attributes for the select element. Can be a string or * an array of key/value pairs. Defaults to none. * list.select: either the value of one selected option or an array * of selected options. Default: none. * list.translate: Boolean. If set, text and labels are translated via * Text::_(). * * @return string HTML for the select list * * @since 1.5 * @throws \RuntimeException If a group has contents that cannot be processed. */ public static function groupedlist($data, $name, $options = []) { // Set default options and overwrite with anything passed in $options = array_merge( HTMLHelper::$formatOptions, ['format.depth' => 0, 'group.items' => 'items', 'group.label' => 'text', 'group.label.toHtml' => true, 'id' => false], $options ); // Apply option rules if ($options['group.items'] === null) { $options['group.label'] = null; } $attribs = ''; if (isset($options['list.attr'])) { if (is_array($options['list.attr'])) { $attribs = ArrayHelper::toString($options['list.attr']); } else { $attribs = $options['list.attr']; } if ($attribs !== '') { $attribs = ' ' . $attribs; } } $id = $options['id'] !== false ? $options['id'] : $name; $id = str_replace(['[', ']', ' '], '', $id); // Disable groups in the options. $options['groups'] = false; $baseIndent = str_repeat($options['format.indent'], $options['format.depth']++); $html = $baseIndent . '<select' . ($id !== '' ? ' id="' . $id . '"' : '') . ' name="' . $name . '"' . $attribs . '>' . $options['format.eol']; $groupIndent = str_repeat($options['format.indent'], $options['format.depth']++); foreach ($data as $dataKey => $group) { $label = $dataKey; $id = ''; $noGroup = is_int($dataKey); if ($options['group.items'] == null) { // Sub-list is an associative array $subList = $group; } elseif (is_array($group)) { // Sub-list is in an element of an array. $subList = $group[$options['group.items']]; if (isset($group[$options['group.label']])) { $label = $group[$options['group.label']]; $noGroup = false; } if (isset($options['group.id']) && isset($group[$options['group.id']])) { $id = $group[$options['group.id']]; $noGroup = false; } } elseif (is_object($group)) { // Sub-list is in a property of an object $subList = $group->{$options['group.items']}; if (isset($group->{$options['group.label']})) { $label = $group->{$options['group.label']}; $noGroup = false; } if (isset($options['group.id']) && isset($group->{$options['group.id']})) { $id = $group->{$options['group.id']}; $noGroup = false; } } else { throw new \RuntimeException('Invalid group contents.', 1); } if ($noGroup) { $html .= static::options($subList, $options); } else { $html .= $groupIndent . '<optgroup' . (empty($id) ? '' : ' id="' . $id . '"') . ' label="' . ($options['group.label.toHtml'] ? htmlspecialchars($label, ENT_COMPAT, 'UTF-8') : $label) . '">' . $options['format.eol'] . static::options($subList, $options) . $groupIndent . '</optgroup>' . $options['format.eol']; } } $html .= $baseIndent . '</select>' . $options['format.eol']; return $html; } /** * Generates a selection list of integers. * * @param integer $start The start integer * @param integer $end The end integer * @param integer $inc The increment * @param string $name The value of the HTML name attribute * @param mixed $attribs Additional HTML attributes for the `<select>` tag, an array of * attributes, or an array of options. Treated as options if it is the last * argument passed. * @param mixed $selected The key that is selected * @param string $format The printf format to be applied to the number * * @return string HTML for the select list * * @since 1.5 */ public static function integerlist($start, $end, $inc, $name, $attribs = null, $selected = null, $format = '') { // Set default options $options = array_merge(HTMLHelper::$formatOptions, ['format.depth' => 0, 'option.format' => '', 'id' => false]); if (is_array($attribs) && func_num_args() === 5) { // Assume we have an options array $options = array_merge($options, $attribs); // Extract the format and remove it from downstream options $format = $options['option.format']; unset($options['option.format']); } else { // Get options from the parameters $options['list.attr'] = $attribs; $options['list.select'] = $selected; } $start = (int) $start; $end = (int) $end; $inc = (int) $inc; $data = []; for ($i = $start; $i <= $end; $i += $inc) { $data[$i] = $format ? sprintf($format, $i) : $i; } // Tell genericlist() to use array keys $options['option.key'] = null; return HTMLHelper::_('select.genericlist', $data, $name, $options); } /** * Create an object that represents an option in an option list. * * @param string $value The value of the option * @param string $text The text for the option * @param mixed $optKey If a string, the returned object property name for * the value. If an array, options. Valid options are: * attr: String|array. Additional attributes for this option. * Defaults to none. * disable: Boolean. If set, this option is disabled. * label: String. The value for the option label. * option.attr: The property in each option array to use for * additional selection attributes. Defaults to none. * option.disable: The property that will hold the disabled state. * Defaults to "disable". * option.key: The property that will hold the selection value. * Defaults to "value". * option.label: The property in each option array to use as the * selection label attribute. If a "label" option is provided, defaults to * "label", if no label is given, defaults to null (none). * option.text: The property that will hold the displayed text. * Defaults to "text". If set to null, the option array is assumed to be a * list of displayable scalars. * @param string $optText The property that will hold the displayed text. This * parameter is ignored if an options array is passed. * @param boolean $disable Not used. * * @return \stdClass * * @since 1.5 */ public static function option($value, $text = '', $optKey = 'value', $optText = 'text', $disable = false) { $options = [ 'attr' => null, 'disable' => false, 'option.attr' => null, 'option.disable' => 'disable', 'option.key' => 'value', 'option.label' => null, 'option.text' => 'text', ]; if (is_array($optKey)) { // Merge in caller's options $options = array_merge($options, $optKey); } else { // Get options from the parameters $options['option.key'] = $optKey; $options['option.text'] = $optText; $options['disable'] = $disable; } $obj = new \stdClass(); $obj->{$options['option.key']} = $value; $obj->{$options['option.text']} = trim($text) ? $text : $value; /* * If a label is provided, save it. If no label is provided and there is * a label name, initialise to an empty string. */ $hasProperty = $options['option.label'] !== null; if (isset($options['label'])) { $labelProperty = $hasProperty ? $options['option.label'] : 'label'; $obj->$labelProperty = $options['label']; } elseif ($hasProperty) { $obj->{$options['option.label']} = ''; } // Set attributes only if there is a property and a value if ($options['attr'] !== null) { $obj->{$options['option.attr']} = $options['attr']; } // Set disable only if it has a property and a value if ($options['disable'] !== null) { $obj->{$options['option.disable']} = $options['disable']; } return $obj; } /** * Generates the option tags for an HTML select list (with no select tag * surrounding the options). * * @param array $arr An array of objects, arrays, or values. * @param mixed $optKey If a string, this is the name of the object variable for * the option value. If null, the index of the array of objects is used. If * an array, this is a set of options, as key/value pairs. Valid options are: * -Format options, {@see HTMLHelper::$formatOptions}. * -groups: Boolean. If set, looks for keys with the value * "<optgroup>" and synthesizes groups from them. Deprecated. Defaults * true for backwards compatibility. * -list.select: either the value of one selected option or an array * of selected options. Default: none. * -list.translate: Boolean. If set, text and labels are translated via * Text::_(). Default is false. * -option.id: The property in each option array to use as the * selection id attribute. Defaults to none. * -option.key: The property in each option array to use as the * selection value. Defaults to "value". If set to null, the index of the * option array is used. * -option.label: The property in each option array to use as the * selection label attribute. Defaults to null (none). * -option.text: The property in each option array to use as the * displayed text. Defaults to "text". If set to null, the option array is * assumed to be a list of displayable scalars. * -option.attr: The property in each option array to use for * additional selection attributes. Defaults to none. * -option.disable: The property that will hold the disabled state. * Defaults to "disable". * -option.key: The property that will hold the selection value. * Defaults to "value". * -option.text: The property that will hold the displayed text. * Defaults to "text". If set to null, the option array is assumed to be a * list of displayable scalars. * @param string $optText The name of the object variable for the option text. * @param mixed $selected The key that is selected (accepts an array or a string) * @param boolean $translate Translate the option values. * * @return string HTML for the select list * * @since 1.5 */ public static function options($arr, $optKey = 'value', $optText = 'text', $selected = null, $translate = false) { $options = array_merge( HTMLHelper::$formatOptions, static::$optionDefaults['option'], ['format.depth' => 0, 'groups' => true, 'list.select' => null, 'list.translate' => false] ); if (is_array($optKey)) { // Set default options and overwrite with anything passed in $options = array_merge($options, $optKey); } else { // Get options from the parameters $options['option.key'] = $optKey; $options['option.text'] = $optText; $options['list.select'] = $selected; $options['list.translate'] = $translate; } $html = ''; $baseIndent = str_repeat($options['format.indent'], $options['format.depth']); foreach ($arr as $elementKey => &$element) { $attr = ''; $extra = ''; $label = ''; $id = ''; if (is_array($element)) { $key = $options['option.key'] === null ? $elementKey : $element[$options['option.key']]; $text = $element[$options['option.text']]; if (isset($element[$options['option.attr']])) { $attr = $element[$options['option.attr']]; } if (isset($element[$options['option.id']])) { $id = $element[$options['option.id']]; } if (isset($element[$options['option.label']])) { $label = $element[$options['option.label']]; } if (isset($element[$options['option.disable']]) && $element[$options['option.disable']]) { $extra .= ' disabled="disabled"'; } } elseif (is_object($element)) { $key = $options['option.key'] === null ? $elementKey : $element->{$options['option.key']}; $text = $element->{$options['option.text']}; if (isset($element->{$options['option.attr']})) { $attr = $element->{$options['option.attr']}; } if (isset($element->{$options['option.id']})) { $id = $element->{$options['option.id']}; } if (isset($element->{$options['option.label']})) { $label = $element->{$options['option.label']}; } if (isset($element->{$options['option.disable']}) && $element->{$options['option.disable']}) { $extra .= ' disabled="disabled"'; } if (isset($element->{$options['option.class']}) && $element->{$options['option.class']}) { $extra .= ' class="' . $element->{$options['option.class']} . '"'; } if (isset($element->{$options['option.onclick']}) && $element->{$options['option.onclick']}) { $extra .= ' onclick="' . $element->{$options['option.onclick']} . '"'; } } else { // This is a simple associative array $key = $elementKey; $text = $element; } /* * The use of options that contain optgroup HTML elements was * somewhat hacked for J1.5. J1.6 introduces the grouplist() method * to handle this better. The old solution is retained through the * "groups" option, which defaults true in J1.6, but should be * deprecated at some point in the future. */ $key = (string) $key; if ($key === '<OPTGROUP>' && $options['groups']) { $html .= $baseIndent . '<optgroup label="' . ($options['list.translate'] ? Text::_($text) : $text) . '">' . $options['format.eol']; $baseIndent = str_repeat($options['format.indent'], ++$options['format.depth']); } elseif ($key === '</OPTGROUP>' && $options['groups']) { $baseIndent = str_repeat($options['format.indent'], --$options['format.depth']); $html .= $baseIndent . '</optgroup>' . $options['format.eol']; } else { // If no string after hyphen - take hyphen out $splitText = explode(' - ', $text, 2); $text = $splitText[0]; if (isset($splitText[1]) && $splitText[1] !== '' && !preg_match('/^[\s]+$/', $splitText[1])) { $text .= ' - ' . $splitText[1]; } if (!empty($label) && $options['list.translate']) { $label = Text::_($label); } if ($options['option.label.toHtml']) { $label = htmlentities($label); } if (is_array($attr)) { $attr = ArrayHelper::toString($attr); } else { $attr = trim($attr); } $extra = ($id ? ' id="' . $id . '"' : '') . ($label ? ' label="' . $label . '"' : '') . ($attr ? ' ' . $attr : '') . $extra; if (is_array($options['list.select'])) { foreach ($options['list.select'] as $val) { $key2 = is_object($val) ? $val->{$options['option.key']} : $val; if ($key == $key2) { $extra .= ' selected="selected"'; break; } } } elseif ((string) $key === (string) $options['list.select']) { $extra .= ' selected="selected"'; } if ($options['list.translate']) { $text = Text::_($text); } // Generate the option, encoding as required $html .= $baseIndent . '<option value="' . ($options['option.key.toHtml'] ? htmlspecialchars($key, ENT_COMPAT, 'UTF-8') : $key) . '"' . $extra . '>'; $html .= $options['option.text.toHtml'] ? htmlentities(html_entity_decode($text, ENT_COMPAT, 'UTF-8'), ENT_COMPAT, 'UTF-8') : $text; $html .= '</option>' . $options['format.eol']; } } return $html; } /** * Generates an HTML radio list. * * @param array $data An array of objects * @param string $name The value of the HTML name attribute * @param string $attribs Additional HTML attributes for the `<select>` tag * @param mixed $optKey The key that is selected * @param string $optText The name of the object variable for the option value * @param string $selected The name of the object variable for the option text * @param boolean $idtag Value of the field id or null by default * @param boolean $translate True if options will be translated * * @return string HTML for the select list * * @since 1.5 */ public static function radiolist( $data, $name, $attribs = null, $optKey = 'value', $optText = 'text', $selected = null, $idtag = false, $translate = false ) { if (is_array($attribs)) { $attribs = ArrayHelper::toString($attribs); } $id_text = $idtag ?: $name; $html = '<div class="controls">'; foreach ($data as $obj) { $html .= '<div class="form-check form-check-inline">'; $k = $obj->$optKey; $t = $translate ? Text::_($obj->$optText) : $obj->$optText; $id = (isset($obj->id) ? $obj->id : null); $extra = ''; $id = $id ? $obj->id : $id_text . $k; if (is_array($selected)) { foreach ($selected as $val) { $k2 = is_object($val) ? $val->$optKey : $val; if ($k == $k2) { $extra .= ' selected="selected" '; break; } } } else { $extra .= ((string) $k === (string) $selected ? ' checked="checked" ' : ''); } $html .= '<input type="radio" class="form-check-input" name="' . $name . '" id="' . $id . '" value="' . $k . '" ' . $extra . $attribs . '>'; $html .= '<label for="' . $id . '" class="form-check-label" id="' . $id . '-lbl">' . $t . '</label>'; $html .= '</div>'; } $html .= '</div>'; return $html; } } PK ��/[��O O Helpers/JGrid.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; use Joomla\Utilities\ArrayHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Utility class for creating HTML Grids * * @since 1.6 */ abstract class JGrid { /** * Returns an action on a grid * * @param integer $i The row index * @param string $task The task to fire * @param string|array $prefix An optional task prefix or an array of options * @param string $activeTitle An optional active tooltip to display if $enable is true * @param string $inactiveTitle An optional inactive tooltip to display if $enable is true * @param boolean $tip An optional setting for tooltip * @param string $activeClass An optional active HTML class * @param string $inactiveClass An optional inactive HTML class * @param boolean $enabled An optional setting for access control on the action. * @param boolean $translate An optional setting for translation. * @param string $checkbox An optional prefix for checkboxes. * @param string $formId An optional form selector. * * @return string The HTML markup * * @since 1.6 */ public static function action( $i, $task, $prefix = '', $activeTitle = '', $inactiveTitle = '', $tip = false, $activeClass = '', $inactiveClass = '', $enabled = true, $translate = true, $checkbox = 'cb', $formId = null ) { $html = []; if (is_array($prefix)) { $options = $prefix; $activeTitle = array_key_exists('active_title', $options) ? $options['active_title'] : $activeTitle; $inactiveTitle = array_key_exists('inactive_title', $options) ? $options['inactive_title'] : $inactiveTitle; $tip = array_key_exists('tip', $options) ? $options['tip'] : $tip; $activeClass = array_key_exists('active_class', $options) ? $options['active_class'] : $activeClass; $inactiveClass = array_key_exists('inactive_class', $options) ? $options['inactive_class'] : $inactiveClass; $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $translate = array_key_exists('translate', $options) ? $options['translate'] : $translate; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } if ($tip) { $title = $enabled ? $activeTitle : $inactiveTitle; $title = $translate ? Text::_($title) : $title; $ariaid = $checkbox . $task . $i . '-desc'; // Don't show empty tooltip. if ($title === '') { $tip = false; } } if ($enabled) { Factory::getDocument()->getWebAssetManager()->useScript('list-view'); $html[] = '<a href="#" class="js-grid-item-action tbody-icon' . ($activeClass === 'publish' ? ' active' : '') . '"'; $html[] = ' data-item-id="' . $checkbox . $i . '" data-item-task="' . $prefix . $task . '" data-item-form-id="' . $formId . '"'; $html[] = $tip ? ' aria-labelledby="' . $ariaid . '"' : ''; $html[] = '>'; $html[] = LayoutHelper::render('joomla.icon.iconclass', ['icon' => $activeClass]); $html[] = '</a>'; $html[] = $tip ? '<div role="tooltip" id="' . $ariaid . '">' . $title . '</div>' : ''; } else { $html[] = '<span class="tbody-icon jgrid"'; $html[] = $tip ? ' aria-labelledby="' . $ariaid . '"' : ''; $html[] = '>'; $html[] = LayoutHelper::render('joomla.icon.iconclass', ['icon' => $inactiveClass]); $html[] = '</span>'; $html[] = $tip ? '<div role="tooltip" id="' . $ariaid . '">' . $title . '</div>' : ''; } return implode($html); } /** * Returns a state on a grid * * @param array $states array of value/state. Each state is an array of the form * (task, text, active title, inactive title, tip (boolean), HTML active class, HTML inactive class) * or ('task'=>task, 'text'=>text, 'active_title'=>active title, * 'inactive_title'=>inactive title, 'tip'=>boolean, 'active_class'=>html active class, * 'inactive_class'=>html inactive class) * @param integer $value The state value. * @param integer $i The row index * @param string|array $prefix An optional task prefix or an array of options * @param boolean $enabled An optional setting for access control on the action. * @param boolean $translate An optional setting for translation. * @param string $checkbox An optional prefix for checkboxes. * @param string $formId An optional form selector. * * @return string The HTML markup * * @since 1.6 */ public static function state($states, $value, $i, $prefix = '', $enabled = true, $translate = true, $checkbox = 'cb', $formId = null) { if (is_array($prefix)) { $options = $prefix; $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $translate = array_key_exists('translate', $options) ? $options['translate'] : $translate; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } $state = ArrayHelper::getValue($states, (int) $value, $states[0]); $task = array_key_exists('task', $state) ? $state['task'] : $state[0]; $text = array_key_exists('text', $state) ? $state['text'] : (array_key_exists(1, $state) ? $state[1] : ''); $activeTitle = array_key_exists('active_title', $state) ? $state['active_title'] : (array_key_exists(2, $state) ? $state[2] : ''); $inactiveTitle = array_key_exists('inactive_title', $state) ? $state['inactive_title'] : (array_key_exists(3, $state) ? $state[3] : ''); $tip = array_key_exists('tip', $state) ? $state['tip'] : (array_key_exists(4, $state) ? $state[4] : false); $activeClass = array_key_exists('active_class', $state) ? $state['active_class'] : (array_key_exists(5, $state) ? $state[5] : ''); $inactiveClass = array_key_exists('inactive_class', $state) ? $state['inactive_class'] : (array_key_exists(6, $state) ? $state[6] : ''); return static::action( $i, $task, $prefix, $activeTitle, $inactiveTitle, $tip, $activeClass, $inactiveClass, $enabled, $translate, $checkbox, $formId ); } /** * Returns a published state on a grid * * @param integer $value The state value. * @param integer $i The row index * @param string|array $prefix An optional task prefix or an array of options * @param boolean $enabled An optional setting for access control on the action. * @param string $checkbox An optional prefix for checkboxes. * @param string $publishUp An optional start publishing date. * @param string $publishDown An optional finish publishing date. * @param string $formId An optional form selector. * * @return string The HTML markup * * @see JHtmlJGrid::state() * @since 1.6 */ public static function published( $value, $i, $prefix = '', $enabled = true, $checkbox = 'cb', $publishUp = null, $publishDown = null, $formId = null ) { if (is_array($prefix)) { $options = $prefix; $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } $states = [ 1 => ['unpublish', 'JPUBLISHED', 'JLIB_HTML_UNPUBLISH_ITEM', 'JPUBLISHED', true, 'publish', 'publish'], 0 => ['publish', 'JUNPUBLISHED', 'JLIB_HTML_PUBLISH_ITEM', 'JUNPUBLISHED', true, 'unpublish', 'unpublish'], 2 => ['unpublish', 'JARCHIVED', 'JLIB_HTML_UNPUBLISH_ITEM', 'JARCHIVED', true, 'archive', 'archive'], -2 => ['publish', 'JTRASHED', 'JLIB_HTML_PUBLISH_ITEM', 'JTRASHED', true, 'trash', 'trash'], ]; // Special state for dates if ($publishUp || $publishDown) { $nullDate = Factory::getDbo()->getNullDate(); $nowDate = Factory::getDate()->toUnix(); $tz = Factory::getUser()->getTimezone(); $publishUp = ($publishUp !== null && $publishUp !== $nullDate) ? Factory::getDate($publishUp, 'UTC')->setTimezone($tz) : false; $publishDown = ($publishDown !== null && $publishDown !== $nullDate) ? Factory::getDate($publishDown, 'UTC')->setTimezone($tz) : false; // Create tip text, only we have publish up or down settings $tips = []; if ($publishUp) { $tips[] = Text::sprintf('JLIB_HTML_PUBLISHED_START', HTMLHelper::_('date', $publishUp, Text::_('DATE_FORMAT_LC5'), 'UTC')); } if ($publishDown) { $tips[] = Text::sprintf('JLIB_HTML_PUBLISHED_FINISHED', HTMLHelper::_('date', $publishDown, Text::_('DATE_FORMAT_LC5'), 'UTC')); } $tip = empty($tips) ? false : implode('<br>', $tips); // Add tips and special titles foreach ($states as $key => $state) { // Create special titles for published items if ($key == 1) { $states[$key][2] = $states[$key][3] = 'JLIB_HTML_PUBLISHED_ITEM'; if ($publishUp > $nullDate && $nowDate < $publishUp->toUnix()) { $states[$key][2] = $states[$key][3] = 'JLIB_HTML_PUBLISHED_PENDING_ITEM'; $states[$key][5] = $states[$key][6] = 'pending'; } if ($publishDown > $nullDate && $nowDate > $publishDown->toUnix()) { $states[$key][2] = $states[$key][3] = 'JLIB_HTML_PUBLISHED_EXPIRED_ITEM'; $states[$key][5] = $states[$key][6] = 'expired'; } } // Add tips to titles if ($tip) { $states[$key][1] = Text::_($states[$key][1]); $states[$key][2] = Text::_($states[$key][2]) . '<br>' . $tip; $states[$key][3] = Text::_($states[$key][3]) . '<br>' . $tip; $states[$key][4] = true; } } return static::state($states, $value, $i, ['prefix' => $prefix, 'translate' => !$tip], $enabled, true, $checkbox, $formId); } return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox, $formId); } /** * Returns an isDefault state on a grid * * @param integer $value The state value. * @param integer $i The row index * @param string|array $prefix An optional task prefix or an array of options * @param boolean $enabled An optional setting for access control on the action. * @param string $checkbox An optional prefix for checkboxes. * @param string $formId An optional form selector. * @param string $active_class The class for active items. * @param string $inactive_class The class for inactive items. * * @return string The HTML markup * * @see JHtmlJGrid::state() * @since 1.6 */ public static function isdefault($value, $i, $prefix = '', $enabled = true, $checkbox = 'cb', $formId = null, $active_class = 'icon-color-featured icon-star', $inactive_class = 'icon-unfeatured') { if (is_array($prefix)) { $options = $prefix; $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } $states = [ 0 => ['setDefault', '', 'JLIB_HTML_SETDEFAULT_ITEM', '', 1, $inactive_class, $inactive_class], 1 => ['unsetDefault', 'JDEFAULT', 'JLIB_HTML_UNSETDEFAULT_ITEM', 'JDEFAULT', 1, $active_class, $active_class], ]; return static::state($states, $value, $i, $prefix, $enabled, true, $checkbox, $formId); } /** * Returns an array of standard published state filter options. * * @param array $config An array of configuration options. * This array can contain a list of key/value pairs where values are boolean * and keys can be taken from 'published', 'unpublished', 'archived', 'trash', 'all'. * These pairs determine which values are displayed. * * @return array The array of standard published state filter options * * @since 1.6 */ public static function publishedOptions($config = []) { // Build the active state filter options. $options = []; if (!array_key_exists('published', $config) || $config['published']) { $options[] = HTMLHelper::_('select.option', '1', 'JPUBLISHED'); } if (!array_key_exists('unpublished', $config) || $config['unpublished']) { $options[] = HTMLHelper::_('select.option', '0', 'JUNPUBLISHED'); } if (!array_key_exists('archived', $config) || $config['archived']) { $options[] = HTMLHelper::_('select.option', '2', 'JARCHIVED'); } if (!array_key_exists('trash', $config) || $config['trash']) { $options[] = HTMLHelper::_('select.option', '-2', 'JTRASHED'); } if (!array_key_exists('all', $config) || $config['all']) { $options[] = HTMLHelper::_('select.option', '*', 'JALL'); } return $options; } /** * Returns a checked-out icon * * @param integer $i The row index. * @param string $editorName The name of the editor. * @param string $time The time that the object was checked out. * @param string|array $prefix An optional task prefix or an array of options * @param boolean $enabled True to enable the action. * @param string $checkbox An optional prefix for checkboxes. * @param string $formId An optional form selector. * * @return string The HTML markup * * @since 1.6 */ public static function checkedout($i, $editorName, $time, $prefix = '', $enabled = false, $checkbox = 'cb', $formId = null) { if (is_array($prefix)) { $options = $prefix; $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } $text = $editorName . '<br>' . HTMLHelper::_('date', $time, Text::_('DATE_FORMAT_LC')) . '<br>' . HTMLHelper::_('date', $time, 'H:i'); $activeTitle = HTMLHelper::_('tooltipText', Text::_('JLIB_HTML_CHECKIN'), $text, 0); $inactiveTitle = HTMLHelper::_('tooltipText', Text::_('JLIB_HTML_CHECKED_OUT'), $text, 0); return static::action( $i, 'checkin', $prefix, html_entity_decode($activeTitle, ENT_QUOTES, 'UTF-8'), html_entity_decode($inactiveTitle, ENT_QUOTES, 'UTF-8'), true, 'checkedout', 'checkedout', $enabled, false, $checkbox, $formId ); } /** * Creates an order-up action icon. * * @param integer $i The row index. * @param string $task An optional task to fire. * @param string|array $prefix An optional task prefix or an array of options * @param string $text An optional text to display * @param boolean $enabled An optional setting for access control on the action. * @param string $checkbox An optional prefix for checkboxes. * @param string $formId An optional form selector. * * @return string The HTML markup * * @since 1.6 */ public static function orderUp($i, $task = 'orderup', $prefix = '', $text = 'JLIB_HTML_MOVE_UP', $enabled = true, $checkbox = 'cb', $formId = null) { if (is_array($prefix)) { $options = $prefix; $text = array_key_exists('text', $options) ? $options['text'] : $text; $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } return static::action($i, $task, $prefix, $text, $text, false, 'uparrow', 'uparrow_disabled', $enabled, true, $checkbox, $formId); } /** * Creates an order-down action icon. * * @param integer $i The row index. * @param string $task An optional task to fire. * @param string|array $prefix An optional task prefix or an array of options * @param string $text An optional text to display * @param boolean $enabled An optional setting for access control on the action. * @param string $checkbox An optional prefix for checkboxes. * @param string $formId An optional form selector. * * @return string The HTML markup * * @since 1.6 */ public static function orderDown( $i, $task = 'orderdown', $prefix = '', $text = 'JLIB_HTML_MOVE_DOWN', $enabled = true, $checkbox = 'cb', $formId = null ) { if (is_array($prefix)) { $options = $prefix; $text = array_key_exists('text', $options) ? $options['text'] : $text; $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled; $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; } return static::action($i, $task, $prefix, $text, $text, false, 'downarrow', 'downarrow_disabled', $enabled, true, $checkbox, $formId); } } PK ��/[�~�� Helpers/SortableList.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2012 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\HTML\HTMLHelper; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * HTML utility class for creating a sortable table list * * @since 3.0 * * @deprecated 4.0 will be removed in 6.0 * Sortable List will be deprecated in favour of a new dragula script in 4.0 */ abstract class SortableList { /** * Method to load the Sortable script and make table sortable * * @param string $tableId DOM id of the table * @param string $formId DOM id of the form * @param string $sortDir Sort direction * @param string $saveOrderingUrl Save ordering url, ajax-load after an item dropped * @param boolean $proceedSaveOrderButton Set whether a save order button is displayed * @param boolean $nestedList Set whether the list is a nested list * * @return void * * @since 3.0 * * @deprecated 4.0 will be removed in 6.0 * Use the new dragula script * Example: JHtml::_('draggablelist.draggable') and add a class of js-draggable to the tbody element of the table */ public static function sortable($tableId, $formId, $sortDir = 'asc', $saveOrderingUrl = null, $proceedSaveOrderButton = true, $nestedList = false) { HTMLHelper::_('draggablelist.draggable', $tableId, $formId, $sortDir, $saveOrderingUrl, $proceedSaveOrderButton, $nestedList); } } PK ��/[���� � Helpers/Links.phpnu �[��� <?php /** * Joomla! Content Management System * * @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\HTML\Helpers; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Layout\FileLayout; // phpcs:disable PSR1.Files.SideEffects \defined('JPATH_PLATFORM') or die; // phpcs:enable PSR1.Files.SideEffects /** * Utility class for icons. * * @since 3.2 */ abstract class Links { /** * Method to generate html code for groups of lists of links * * @param array $groupsOfLinks Array of links * * @return string * * @since 3.2 */ public static function linksgroups($groupsOfLinks) { $html = []; if (count($groupsOfLinks) > 0) { $layout = new FileLayout('joomla.links.groupsopen'); $html[] = $layout->render(''); foreach ($groupsOfLinks as $title => $links) { if (isset($links[0]['separategroup'])) { $layout = new FileLayout('joomla.links.groupseparator'); $html[] = $layout->render($title); } $layout = new FileLayout('joomla.links.groupopen'); $htmlHeader = $layout->render($title); $htmlLinks = HTMLHelper::_('links.links', $links); if ($htmlLinks !== '') { $html[] = $htmlHeader; $html[] = $htmlLinks; $layout = new FileLayout('joomla.links.groupclose'); $html[] = $layout->render(''); } } $layout = new FileLayout('joomla.links.groupsclose'); $html[] = $layout->render(''); } return implode($html); } /** * Method to generate html code for a list of links * * @param array $links Array of links * * @return string * * @since 3.2 */ public static function links($links) { $html = []; foreach ($links as $link) { $html[] = HTMLHelper::_('links.link', $link); } return implode($html); } /** * Method to generate html code for a single link * * @param array $link link properties * * @return string * * @since 3.2 */ public static function link($link) { if (isset($link['access'])) { if (is_bool($link['access'])) { if ($link['access'] == false) { return ''; } } else { // Get the user object to verify permissions $user = Factory::getUser(); // Take each pair of permission, context values. for ($i = 0, $n = count($link['access']); $i < $n; $i += 2) { if (!$user->authorise($link['access'][$i], $link['access'][$i + 1])) { return ''; } } } } // Instantiate a new FileLayout instance and render the layout $layout = new FileLayout('joomla.links.link'); return $layout->render($link); } } PK ��/[��5&�&