first commit
This commit is contained in:
18
administrator/modules/mod_sampledata/mod_sampledata.php
Normal file
18
administrator/modules/mod_sampledata/mod_sampledata.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_sampledata
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
$items = \Joomla\Module\Sampledata\Administrator\Helper\SampledataHelper::getList();
|
||||
|
||||
// Filter out empty entries
|
||||
$items = array_filter($items);
|
||||
|
||||
require \Joomla\CMS\Helper\ModuleHelper::getLayoutPath('mod_sampledata', $params->get('layout', 'default'));
|
||||
39
administrator/modules/mod_sampledata/mod_sampledata.xml
Normal file
39
administrator/modules/mod_sampledata/mod_sampledata.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="module" client="administrator" method="upgrade">
|
||||
<name>mod_sampledata</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2017-07</creationDate>
|
||||
<copyright>(C) 2017 Open Source Matters, Inc.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.8.0</version>
|
||||
<description>MOD_SAMPLEDATA_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Module\Sampledata</namespace>
|
||||
<files>
|
||||
<filename module="mod_sampledata">mod_sampledata.php</filename>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<media destination="mod_sampledata" folder="media">
|
||||
<folder>js</folder>
|
||||
</media>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/mod_sampledata.ini</language>
|
||||
<language tag="en-GB">language/en-GB/mod_sampledata.sys.ini</language>
|
||||
</languages>
|
||||
<help key="Admin_Modules:_Sample_Data" />
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="advanced">
|
||||
<field
|
||||
name="layout"
|
||||
type="modulelayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
validate="moduleLayout"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_sampledata
|
||||
*
|
||||
* @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\Module\Sampledata\Administrator\Helper;
|
||||
|
||||
use Joomla\CMS\Event\AbstractEvent;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Helper for mod_sampledata
|
||||
*
|
||||
* @since 3.8.0
|
||||
*/
|
||||
abstract class SampledataHelper
|
||||
{
|
||||
/**
|
||||
* Get a list of sampledata.
|
||||
*
|
||||
* @return mixed An array of sampledata, or false on error.
|
||||
*
|
||||
* @since 3.8.0
|
||||
*/
|
||||
public static function getList()
|
||||
{
|
||||
PluginHelper::importPlugin('sampledata');
|
||||
|
||||
return Factory::getApplication()
|
||||
->getDispatcher()
|
||||
->dispatch(
|
||||
'onSampledataGetOverview',
|
||||
AbstractEvent::create(
|
||||
'onSampledataGetOverview',
|
||||
[
|
||||
'subject' => new \stdClass(),
|
||||
]
|
||||
)
|
||||
)
|
||||
->getArgument('result') ?? [];
|
||||
}
|
||||
}
|
||||
59
administrator/modules/mod_sampledata/tmpl/default.php
Normal file
59
administrator/modules/mod_sampledata/tmpl/default.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_sampledata
|
||||
*
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
$app->getDocument()->getWebAssetManager()
|
||||
->registerAndUseScript('mod_sampledata', 'mod_sampledata/sampledata-process.js', [], ['type' => 'module'], ['core']);
|
||||
|
||||
Text::script('MOD_SAMPLEDATA_COMPLETED');
|
||||
Text::script('MOD_SAMPLEDATA_CONFIRM_START');
|
||||
Text::script('MOD_SAMPLEDATA_ERROR_RESPONSE');
|
||||
Text::script('MOD_SAMPLEDATA_INVALID_RESPONSE');
|
||||
Text::script('MOD_SAMPLEDATA_ITEM_ALREADY_PROCESSED');
|
||||
|
||||
$app->getDocument()->addScriptOptions(
|
||||
'sample-data',
|
||||
[
|
||||
'icon' => Uri::root(true) . '/media/system/images/ajax-loader.gif',
|
||||
]
|
||||
);
|
||||
?>
|
||||
<?php if ($items) : ?>
|
||||
<ul id="sample-data-wrapper" class="list-group list-group-flush sample-data">
|
||||
<?php foreach ($items as $i => $item) : ?>
|
||||
<li class="list-group-item sampledata-<?php echo $item->name; ?>">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="sample-data__title">
|
||||
<span class="sample-data__icon icon-<?php echo $item->icon; ?> me-1" aria-hidden="true"></span>
|
||||
<?php echo htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8'); ?>
|
||||
</div>
|
||||
<button type="button" class="btn btn-secondary btn-sm apply-sample-data" data-type="<?php echo $item->name; ?>" data-steps="<?php echo $item->steps; ?>">
|
||||
<span class="icon-upload" aria-hidden="true"></span> <?php echo Text::_('JLIB_INSTALLER_INSTALL'); ?>
|
||||
<span class="visually-hidden"><?php echo $item->title; ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="sample-data__desc small mt-1"><?php echo $item->description; ?></p>
|
||||
</li>
|
||||
<?php // Progress bar ?>
|
||||
<li class="list-group-item sampledata-progress-<?php echo $item->name; ?> d-none">
|
||||
<div class="progress mb-3">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar"></div>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<a href="index.php?option=com_plugins&filter[folder]=sampledata" class="btn btn-secondary btn-sm manage-sample-data float-end m-3">
|
||||
<span class="icon-tasks" aria-hidden="true"></span> <?php echo Text::_('MOD_SAMPLEDATA_MANAGE_SAMPLEDATA'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user