-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
243 additions
and
166 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# WT-Content-spoiler-Joomla-plugin | ||
This plugin hide a **part of text** between short codes {spoiler} {/spoiler} to spoiler | ||
Support Joomla 4+ | ||
This plugin hide a **part of text** between short codes `{spoiler} {/spoiler}` to spoiler | ||
Support Joomla 4 and Joomla 5. |
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 |
---|---|---|
@@ -1,143 +1,210 @@ | ||
<?php | ||
// No direct access to this file | ||
defined('_JEXEC') or die('Restricted access'); | ||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Installer\Installer; | ||
use Joomla\CMS\Installer\InstallerHelper; | ||
use Joomla\CMS\Language\Text; | ||
use Joomla\CMS\Plugin\PluginHelper; | ||
|
||
/** | ||
* Script file of HelloWorld component. | ||
* | ||
* The name of this class is dependent on the component being installed. | ||
* The class name should have the component's name, directly followed by | ||
* the text InstallerScript (ex:. com_helloWorldInstallerScript). | ||
* | ||
* This class will be called by Joomla!'s installer, if specified in your component's | ||
* manifest file, and is used for custom automation actions in its installation process. | ||
* | ||
* In order to use this automation script, you should reference it in your component's | ||
* manifest file as follows: | ||
* <scriptfile>script.php</scriptfile> | ||
* | ||
* @package Joomla.Administrator | ||
* @subpackage com_helloworld | ||
* | ||
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
* @package WT Content spoiler | ||
* @version 1.0.1 | ||
* @Author Sergey Tolkachyov, https://web-tolk.ru | ||
* @сopyright (c) 2022 - October 2023 Sergey Tolkachyov. All rights reserved. | ||
* @license GNU/GPL3 http://www.gnu.org/licenses/gpl-3.0.html | ||
* @since 1.0.0 | ||
*/ | ||
class plgContentWt_content_spoilerInstallerScript | ||
{ | ||
/** | ||
* This method is called after a component is installed. | ||
* | ||
* @param \stdClass $parent - Parent object calling this method. | ||
* | ||
* @return void | ||
*/ | ||
public function install($parent) | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* This method is called after a component is uninstalled. | ||
* | ||
* @param \stdClass $parent - Parent object calling this method. | ||
* | ||
* @return void | ||
*/ | ||
public function uninstall($parent) | ||
{ | ||
|
||
|
||
} | ||
|
||
/** | ||
* This method is called after a component is updated. | ||
* | ||
* @param \stdClass $parent - Parent object calling object. | ||
* | ||
* @return void | ||
*/ | ||
public function update($parent) | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Runs just before any installation action is performed on the component. | ||
* Verifications and pre-requisites should run in this function. | ||
* | ||
* @param string $type - Type of PreFlight action. Possible values are: | ||
* - * install | ||
* - * update | ||
* - * discover_install | ||
* @param \stdClass $parent - Parent object calling object. | ||
* | ||
* @return void | ||
*/ | ||
public function preflight($type, $parent) | ||
{ | ||
|
||
} | ||
|
||
|
||
|
||
/** | ||
* Runs right after any installation action is performed on the component. | ||
* | ||
* @param string $type - Type of PostFlight action. Possible values are: | ||
* - * install | ||
* - * update | ||
* - * discover_install | ||
* @param \stdClass $parent - Parent object calling object. | ||
* | ||
* @return void | ||
*/ | ||
function postflight($type, $installer) | ||
{ | ||
|
||
$jversion = new JVersion(); | ||
|
||
// only for Joomla 3.x | ||
|
||
if (version_compare($jversion->getShortVersion(), '4.0', '<')) { | ||
|
||
$element = strtoupper($installer->get("element")); // ex. "$parent" | ||
$class = 'span'; | ||
$web_tolk_site_icon = "<i class='icon-share-alt'></i>"; | ||
|
||
} else { | ||
|
||
$element = strtoupper($installer->getElement()); | ||
$class = 'col-'; | ||
$web_tolk_site_icon = ''; | ||
} | ||
|
||
|
||
|
||
echo " | ||
<div class='row bg-white m-0' style='margin:25px auto; border:1px solid rgba(0,0,0,0.125); box-shadow:0px 0px 10px rgba(0,0,0,0.125); padding: 10px 20px;'> | ||
<div class='".$class."8'> | ||
<h2>".Text::_("PLG_".$element."_AFTER_".$type)." <br/>".Text::_("PLG_".$element)."</h2> | ||
".Text::_("PLG_".$element."_DESC"); | ||
|
||
echo Text::_("PLG_".$element."_WHATS_NEW"); | ||
|
||
echo "</div> | ||
<div class='".$class."4' style='display:flex; flex-direction:column; justify-content:center;'> | ||
<img width='200px' src='https://web-tolk.ru/web_tolk_logo_wide.png'> | ||
<p>Joomla Extensions</p> | ||
<p class='btn-group'> | ||
<a class='btn btn-sm btn-outline-primary' href='https://web-tolk.ru' target='_blank'>".$web_tolk_site_icon." https://web-tolk.ru</a> | ||
<a class='btn btn-sm btn-outline-primary' href='mailto:[email protected]'><i class='icon-envelope'></i> [email protected]</a> | ||
</p> | ||
".Text::_("PLG_".$element."_MAYBE_INTERESTING")." | ||
</div> | ||
"; | ||
|
||
} | ||
} | ||
\defined('_JEXEC') or die; | ||
|
||
use Joomla\CMS\Application\AdministratorApplication; | ||
use Joomla\CMS\Cache\Cache; | ||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Helper\LibraryHelper; | ||
use Joomla\CMS\Installer\InstallerAdapter; | ||
use Joomla\CMS\Installer\InstallerScriptInterface; | ||
use Joomla\CMS\Language\Text; | ||
use Joomla\Database\DatabaseDriver; | ||
use Joomla\DI\Container; | ||
use Joomla\DI\ServiceProviderInterface; | ||
|
||
return new class () implements ServiceProviderInterface { | ||
public function register(Container $container) | ||
{ | ||
$container->set(InstallerScriptInterface::class, new class ($container->get(AdministratorApplication::class)) implements InstallerScriptInterface { | ||
|
||
/** | ||
* The application object | ||
* | ||
* @var AdministratorApplication | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
protected AdministratorApplication $app; | ||
|
||
/** | ||
* The Database object. | ||
* | ||
* @var DatabaseDriver | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
protected DatabaseDriver $db; | ||
|
||
/** | ||
* Minimum Joomla version required to install the extension. | ||
* | ||
* @var string | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
protected string $minimumJoomla = '4.0'; | ||
|
||
/** | ||
* Minimum PHP version required to install the extension. | ||
* | ||
* @var string | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
protected string $minimumPhp = '7.4'; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param AdministratorApplication $app The application object. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function __construct(AdministratorApplication $app) | ||
{ | ||
$this->app = $app; | ||
$this->db = Factory::getContainer()->get('DatabaseDriver'); | ||
} | ||
|
||
/** | ||
* This method is called after a component is installed. | ||
* | ||
* @param \stdClass $installer - Parent object calling this method. | ||
* | ||
* @return void | ||
*/ | ||
public function install(InstallerAdapter $adapter): bool | ||
{ | ||
|
||
return true; | ||
|
||
} | ||
|
||
/** | ||
* Function called after the extension is uninstalled. | ||
* | ||
* @param InstallerAdapter $adapter The adapter calling this method | ||
* | ||
* @return boolean True on success | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function uninstall(InstallerAdapter $adapter): bool | ||
{ | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Function called after the extension is updated. | ||
* | ||
* @param InstallerAdapter $adapter The adapter calling this method | ||
* | ||
* @return boolean True on success | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function update(InstallerAdapter $adapter): bool | ||
{ | ||
|
||
return true; | ||
|
||
} | ||
|
||
/** | ||
* Function called before extension installation/update/removal procedure commences. | ||
* | ||
* @param string $type The type of change (install or discover_install, update, uninstall) | ||
* @param InstallerAdapter $adapter The adapter calling this method | ||
* | ||
* @return boolean True on success | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function preflight(string $type, InstallerAdapter $adapter): bool | ||
{ | ||
|
||
return true; | ||
|
||
} | ||
|
||
|
||
/** | ||
* Function called after extension installation/update/removal procedure commences. | ||
* | ||
* @param string $type The type of change (install or discover_install, update, uninstall) | ||
* @param InstallerAdapter $adapter The adapter calling this method | ||
* | ||
* @return boolean True on success | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function postflight(string $type, InstallerAdapter $adapter): bool | ||
{ | ||
|
||
$smile = ''; | ||
if ($type != 'uninstall') | ||
{ | ||
$smiles = ['☺', '😀', '😉', '😍', '😎', '😊', '🙏']; | ||
$smile_key = array_rand($smiles, 1); | ||
$smile = $smiles[$smile_key]; | ||
} | ||
|
||
$element = strtoupper($adapter->getElement()); | ||
$type = strtoupper($type); | ||
$html = ' | ||
<div class="row bg-white m-0"> | ||
<div class="col-12 col-md-8 p-0 pe-2"> | ||
<h2>'.$smile.' '.Text::_($element.'_AFTER_'.$type).' <br/>'.Text::_($element).'</h2> | ||
'.Text::_($element.'_DESC'); | ||
|
||
$html .= Text::_($element.'_WHATS_NEW'); | ||
|
||
$html .= '</div> | ||
<div class="col-12 col-md-4 p-0 d-flex flex-column justify-content-start"> | ||
<img width="180" src="https://web-tolk.ru/web_tolk_logo_wide.png"> | ||
<p>Joomla Extensions</p> | ||
<p class="btn-group"> | ||
<a class="btn btn-sm btn-outline-primary" href="https://web-tolk.ru" target="_blank"> https://web-tolk.ru</a> | ||
<a class="btn btn-sm btn-outline-primary" href="mailto:[email protected]"><i class="icon-envelope"></i> [email protected]</a> | ||
</p> | ||
'.Text::_($element."_MAYBE_INTERESTING").' | ||
</div> | ||
'; | ||
$this->app->enqueueMessage($html, 'info'); | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Enable plugin after installation. | ||
* | ||
* @param InstallerAdapter $adapter Parent object calling object. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
protected function enablePlugin(InstallerAdapter $adapter) | ||
{ | ||
// Prepare plugin object | ||
$plugin = new \stdClass(); | ||
$plugin->type = 'plugin'; | ||
$plugin->element = $adapter->getElement(); | ||
$plugin->folder = (string) $adapter->getParent()->manifest->attributes()['group']; | ||
$plugin->enabled = 1; | ||
|
||
// Update record | ||
$this->db->updateObject('#__extensions', $plugin, ['type', 'element', 'folder']); | ||
} | ||
|
||
}); | ||
} | ||
}; |
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
Oops, something went wrong.