-
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.
fix "Event onContentAfterDisplay only accepts String results" error if show in category = false Refactor plugin as service provider +Dynamic version from manifest file
- Loading branch information
1 parent
0fd7acd
commit 80c1400
Showing
10 changed files
with
193 additions
and
14 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
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,2 +1,2 @@ | ||
PLG_CONTENT_CG_LIKE="Content - CG Like" | ||
PLG_CONTENT_CG_LIKE_XML_DESCRIPTION="<p>CG Like - Content Plugin - version 2.0.4.</p><p>Don't forget to activate <b>Ajax CG Like plugin</b>, and this plugin, of course.</p>" | ||
PLG_CONTENT_CG_LIKE_XML_DESCRIPTION="<p>CG Like - Content Plugin.</p><p>Don't forget to activate <b>Ajax CG Like plugin</b>, and this plugin, of course.</p>" |
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,2 +1,2 @@ | ||
PLG_CONTENT_CG_LIKE="Contenu - CG Like" | ||
PLG_CONTENT_CG_LIKE_XML_DESCRIPTION="<p>CG Like - Content Plugin - version 2.0.4.</p><p>N'oubliez pas d'activer le plugin <b>Ajax CG Like</b> ainsi que ce plugin</p>" | ||
PLG_CONTENT_CG_LIKE_XML_DESCRIPTION="<p>CG Like - Content Plugin.</p><p>N'oubliez pas d'activer le plugin <b>Ajax CG Like</b> ainsi que ce plugin</p>" |
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,46 @@ | ||
<?php | ||
|
||
/** | ||
* CG Like plugin for Joomla 4.x/5.x | ||
* @author ConseilgGouz | ||
* @copyright (C) 2023 www.conseilgouz.com. All Rights Reserved. | ||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
use Joomla\CMS\Extension\PluginInterface; | ||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Plugin\PluginHelper; | ||
use Joomla\DI\Container; | ||
use Joomla\DI\ServiceProviderInterface; | ||
use Joomla\Event\DispatcherInterface; | ||
use ConseilGouz\Plugin\Content\Cglike\Extension\Cglike; | ||
|
||
return new class () implements ServiceProviderInterface { | ||
/** | ||
* Registers the service provider with a DI container. | ||
* | ||
* @param Container $container The DI container. | ||
* | ||
* @return void | ||
* | ||
* @since 4.3.0 | ||
*/ | ||
public function register(Container $container) | ||
{ | ||
$container->set( | ||
PluginInterface::class, | ||
function (Container $container) { | ||
$dispatcher = $container->get(DispatcherInterface::class); | ||
$plugin = new Cglike( | ||
$dispatcher, | ||
(array) PluginHelper::getPlugin('content', 'cglike') | ||
); | ||
$plugin->setApplication(Factory::getApplication()); | ||
|
||
return $plugin; | ||
} | ||
); | ||
} | ||
}; |
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,111 @@ | ||
<?php | ||
/** | ||
* CG Like plugin | ||
* | ||
* @author ConseilgGouz | ||
* @copyright (C) 2023 www.conseilgouz.com. All Rights Reserved. | ||
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html | ||
*/ | ||
|
||
namespace ConseilGouz\Plugin\Content\Cglike\Field; | ||
|
||
use Joomla\CMS\Component\ComponentHelper; | ||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Form\FormField; | ||
use Joomla\CMS\Language\Text; | ||
use Joomla\String\StringHelper; | ||
|
||
// Prevent direct access | ||
defined('_JEXEC') || die; | ||
|
||
class VersionField extends FormField | ||
{ | ||
/** | ||
* Element name | ||
* | ||
* @var string | ||
*/ | ||
protected $_name = 'Version'; | ||
private $plg_full_name; | ||
private $default_lang; | ||
private $langShortCode; | ||
|
||
function getInput() | ||
{ | ||
$return = ''; | ||
|
||
$xml = $this->def('xml'); | ||
|
||
// Load language | ||
$jinput = Factory::getApplication()->input; | ||
$db = Factory::getDBO(); | ||
$query = $db->getQuery(true); | ||
$query | ||
->select($db->quoteName(array('element','folder','type'))) | ||
->from($db->quoteName('#__extensions')) | ||
->where($db->quoteName('extension_id') . '=' . $db->Quote($jinput->get('extension_id', null))); | ||
$db->setQuery($query, 0, 1); | ||
$row = $db->loadAssoc(); | ||
|
||
if ($row['type'] == 'plugin') | ||
{ | ||
$this->plg_full_name = 'plg_' . $row['folder'] . '_' . $row['element']; | ||
|
||
// Is used for building joomfish links | ||
$this->langShortCode = null; | ||
|
||
$this->default_lang = ComponentHelper::getParams('com_languages')->get('admin'); | ||
$language = Factory::getLanguage(); | ||
$language->load($this->plg_full_name, JPATH_ROOT . dirname($xml), 'en-GB', true); | ||
$language->load($this->plg_full_name, JPATH_ROOT . dirname($xml), $this->default_lang, true); | ||
} | ||
|
||
$extension = $this->def('extension'); | ||
|
||
$user = Factory::getUser(); | ||
$authorise = $user->authorise('core.manage', 'com_installer'); | ||
|
||
if (!StringHelper::strlen($extension) || !StringHelper::strlen($xml) || !$authorise) | ||
{ | ||
return; | ||
} | ||
|
||
$version = ''; | ||
|
||
if ($xml) | ||
{ | ||
$xml = simplexml_load_file(JPATH_SITE . '/' . $xml); | ||
if ($xml && isset($xml->version)) | ||
{ | ||
$version = $xml->version; | ||
} | ||
} | ||
$margintop = $this->def('margintop'); | ||
|
||
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ | ||
$wa = Factory::getApplication()->getDocument()->getWebAssetManager(); | ||
|
||
$css = ''; | ||
$css .= ".version {display:block;text-align:right;color:brown;font-size:10px;}"; | ||
$css .= ".readonly.plg-desc {font-weight:normal;}"; | ||
$css .= "fieldset.radio label {width:auto;}"; | ||
$wa->addInlineStyle($css); | ||
$margintop = $this->def('margintop'); | ||
if (StringHelper::strlen($margintop)) { | ||
$js = "document.addEventListener('DOMContentLoaded', function() { | ||
vers = document.querySelector('.version'); | ||
parent = vers.parentElement.parentElement; | ||
parent.style.marginTop = '".$margintop."'; | ||
})"; | ||
$wa->addInlineScript($js); | ||
} | ||
$return .= '<span class="version">' . Text::_('JVERSION') . ' ' . $version . "</span>"; | ||
|
||
return $return; | ||
} | ||
public function def($val, $default = '') | ||
{ | ||
return ( isset( $this->element[$val] ) && (string) $this->element[$val] != '' ) ? (string) $this->element[$val] : $default; | ||
} | ||
|
||
} |
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 @@ | ||
<!DOCTYPE html><html><body></body></html> |