-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option load single module on Module element
Showing
7 changed files
with
126 additions
and
35 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/** | ||
* @package Astroid Framework | ||
* @author Astroid Framework Team https://astroidframe.work | ||
* @copyright Copyright (C) 2024 AstroidFrame.work. | ||
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or Later | ||
*/ | ||
defined('JPATH_BASE') or die; | ||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Form\FormHelper; | ||
use Joomla\CMS\Form\Field\ListField; | ||
use Joomla\Database\DatabaseInterface; | ||
use Joomla\CMS\Language\Text; | ||
FormHelper::loadFieldClass('list'); | ||
|
||
/** | ||
* Modules Position field. | ||
* | ||
* @since 3.4.2 | ||
*/ | ||
class JFormFieldAstroidModulesList extends ListField | ||
{ | ||
|
||
/** | ||
* The form field type. | ||
* | ||
* @var string | ||
* @since 3.4.2 | ||
*/ | ||
protected $type = 'AstroidModulesList'; | ||
protected $ordering; | ||
|
||
/** | ||
* Method to get the field options. | ||
* | ||
* @return array The field option objects. | ||
* | ||
* @since 3.4.2 | ||
*/ | ||
public function getOptions() | ||
{ | ||
$db = Factory::getContainer()->get(DatabaseInterface::class); | ||
$query = $db->getQuery(true); | ||
$extension = (string)$this->element['extension']; | ||
if ($extension) { | ||
$query->select('m.id, m.title') | ||
->from('#__modules AS m') | ||
->where('m.module' . ' = ' . $db->quote($extension)) | ||
->where('m.published' . ' = 1') | ||
->where('m.client_id' . ' = 0'); | ||
} else { | ||
$query->select('m.id, m.title') | ||
->from('#__modules AS m') | ||
->where('m.published' . ' = 1') | ||
->where('m.client_id' . ' = 0'); | ||
} | ||
|
||
return $db->setQuery($query)->loadObjectList(); | ||
} | ||
|
||
protected function getInput() | ||
{ | ||
// Get the field options. | ||
$options = (array) $this->getOptions(); | ||
|
||
$json = [ | ||
'id' => $this->id, | ||
'name' => $this->name, | ||
'value' => htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8'), | ||
'options' => $options, | ||
'type' => strtolower($this->type), | ||
]; | ||
return json_encode($json); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters