| Current Path : /var/www/html/administrator/components/com_jchat/Field/ |
| Current File : /var/www/html/administrator/components/com_jchat/Field/ModulestatusField.php |
<?php
namespace JExtstore\Component\JChat\Administrator\Field;
/**
* @package JCHAT::CONFIG::administrator::components::com_jchat
* @subpackage Field
* @author Joomla! Extensions Store
* @copyright (C) 2024 - Joomla! Extensions Store
* @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
/**
* Form Field for module status
* @package JCHAT::CONFIG::administrator::components::com_jchat
* @subpackage Field
* @since 2.0
*/
class ModulestatusField extends FormField {
/**
* The form field type.
*
* @var string
* @since 11.1
*/
protected $type = 'modulestatus';
/**
* Method to get the radio button field input markup.
*
* @return string The field input markup.
*
* @since 11.1
*/
protected function getInput() {
// Initialize variables.
$html = array ();
// Retrieve status informations about the chat module
$db = Factory::getContainer()->get('DatabaseDriver');
$queryModuleStatus = "SELECT id, published, position" .
"\n FROM #__modules" .
"\n WHERE " . $db->quoteName('module') . "=" . $db->quote('mod_jchat') .
"\n AND " . $db->quoteName('published') . ">= 0" ;
$db->setQuery($queryModuleStatus);
$publishedModule = $db->loadObject();
if (is_object($publishedModule)) {
$isModulePublished = $publishedModule->published && ($publishedModule->position != '');
}
// Initialize some field attributes.
if ($isModulePublished) {
$html [] = '<a target="_blank" class="module_rendering_ctrl" href="index.php?option=com_modules&task=module.edit&id=' . $publishedModule->id . '">' .
'<span data-bs-content="' . Text::sprintf ( 'COM_JCHAT_MODULE_ENABLED_DESC', $publishedModule->position) .
'" class="badge bg-success label-large hasPopover">' . '<span class="icon-checkmark" aria-hidden="true"></span>' .
Text::sprintf ( 'COM_JCHAT_MODULE_ENABLED' ) . '</span></a>';
} else {
$html [] = '<a target="_blank" class="module_rendering_ctrl" href="index.php?option=com_modules&task=module.edit&id=' . $publishedModule->id . '">' .
'<span data-bs-content="' . Text::_ ( 'COM_JCHAT_MODULE_DISABLED_DESC' ) .
'" class="badge bg-danger label-large hasPopover">' . '<span class="icon-remove" aria-hidden="true"></span>' .
Text::sprintf ( 'COM_JCHAT_MODULE_DISABLED' ) . '</span></a>';
}
return implode ( $html );
}
}