Skip to content

Commit

Permalink
Fix an error on J5, #7
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelSyomin committed May 14, 2024
1 parent ad5e6c9 commit 36e7592
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 71 deletions.
4 changes: 4 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ Fix a SQL warning in Joomla 4.

2.1.4 - November 11, 2022
Add class to typo form header, group form elements info a div.proofreader_form_body. element

2.2 - May 14, 2024
Fix an issue with form display error in J5.

136 changes: 68 additions & 68 deletions plugins/content/proofreader.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,83 +19,83 @@
*/
class plgContentProofreader extends JPlugin
{
protected static $tag = 'proofreader-prompt';
protected static $tag = 'proofreader-prompt';

/**
* Constructor
*
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
*/
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
/**
* Constructor
*
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
*/
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);

$language = JFactory::getLanguage();
$language->load('com_proofreader', JPATH_SITE, 'en-GB', true);
$language->load('com_proofreader', JPATH_SITE, null, true);
$language = JFactory::getLanguage();
$language->load('com_proofreader', JPATH_SITE, 'en-GB', true);
$language->load('com_proofreader', JPATH_SITE, null, true);

$this->params = JComponentHelper::getParams('com_proofreader', true);
}
$this->params = JComponentHelper::getParams('com_proofreader', true);
}

/**
* Replaces tag {proofreader-prompt} within content with Proofreader's prompt block
*
* @param string $context The context of the content being passed to the plugin.
* @param object &$article The article object. Note $article->text is also available
* @param mixed &$params The article params
* @param integer $page The 'page' number
*
* @return mixed true if there is an error. Void otherwise.
*/
public function onContentPrepare($context, &$article, &$params, $page = 0)
{
if ($context == 'com_finder.indexer')
{
return true;
}
/**
* Replaces tag {proofreader-prompt} within content with Proofreader's prompt block
*
* @param string $context The context of the content being passed to the plugin.
* @param object &$article The article object. Note $article->text is also available
* @param mixed &$params The article params
* @param integer $page The 'page' number
*
* @return mixed true if there is an error. Void otherwise.
*/
public function onContentPrepare($context, &$article, &$params, $page = 0)
{
if ($context == 'com_finder.indexer')
{
return true;
}

if (!isset($article->text) || strpos('{' . $article->text . '}', self::$tag) === false)
{
return true;
}
if (!isset($article->text) || strpos('{' . $article->text . '}', self::$tag) === false)
{
return true;
}

$pattern = '/\{' . self::$tag . '\}/i';
$replacement = $this->params->get('prompt', 1) == 1 ? $this->getPromptHtml() : '';
$article->text = preg_replace($pattern, $replacement, $article->text, 1);
}
$pattern = '/\{' . self::$tag . '\}/i';
$replacement = $this->params->get('prompt', 1) == 1 ? $this->getPromptHtml() : '';
$article->text = preg_replace($pattern, $replacement, $article->text, 1);
}

/**
* Displays the Proofreader's prompt text after the article's text
*
* @param string $context The context of the content being passed to the plugin
* @param object &$article The article object
* @param object &$params The article params
* @param integer $page The 'page' number
*
* @return mixed html string containing prompt text if in full article's view else boolean false
*/
public function onContentAfterDisplay($context, &$article, &$params, $page = 0)
{
if ($context == 'com_content.article' || $context == 'com_content.featured' || $context == 'com_content.category')
{
$view = JFactory::getApplication('site')->input->get('view');
$data = $params->toArray();
/**
* Displays the Proofreader's prompt text after the article's text
*
* @param string $context The context of the content being passed to the plugin
* @param object &$article The article object
* @param object &$params The article params
* @param integer $page The 'page' number
*
* @return mixed html string containing prompt text if in full article's view else boolean false
*/
public function onContentAfterDisplay($context, &$article, &$params, $page = 0)
{
if ($context == 'com_content.article' || $context == 'com_content.featured' || $context == 'com_content.category')
{
$view = JFactory::getApplication('site')->input->get('view');
$data = $params->toArray();

// display in articles and skip modules' content
if ($this->params->get('prompt', 1) == 1 && $view == 'article' && !isset($data['moduleclass_sfx']))
{
return $this->getPromptHtml();
}
}
// display in articles and skip modules' content
if ($this->params->get('prompt', 1) == 1 && $view == 'article' && !isset($data['moduleclass_sfx']))
{
return $this->getPromptHtml();
}
}

return false;
}
return '';
}

private function getPromptHtml()
{
$html = '<div class="proofreader_prompt">' . JText::_('COM_PROOFREADER_PROMPT') . '</div>';
private function getPromptHtml()
{
$html = '<div class="proofreader_prompt">' . JText::_('COM_PROOFREADER_PROMPT') . '</div>';

return $html;
}
return $html;
}
}
2 changes: 1 addition & 1 deletion proofreader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<authorEmail>[email protected]</authorEmail>
<copyright>Copyright 2005-2015 JoomlaTune.ru; Copyright 2022 Pavel Syomin All rights reserved!</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<version>2.1.4</version>
<version>2.2</version>
<description>COM_PROOFREADER_XML_DESCRIPTION</description>

<scriptfile>script.php</scriptfile>
Expand Down
4 changes: 2 additions & 2 deletions proofreader_update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<element>com_proofreader</element>
<type>component</type>
<client>administrator</client>
<version>2.1.4</version>
<version>2.2</version>
<infourl>https://github.com/PavelSyomin/proofreader/blob/main/Changelog</infourl>
<downloads>
<downloadurl type="full" format="zip">https://github.com/PavelSyomin/proofreader/releases/download/2.1.4/proofreader_2_1_4.zip</downloadurl>
<downloadurl type="full" format="zip">https://github.com/PavelSyomin/proofreader/releases/download/2.2/proofreader_2_2.zip</downloadurl>
</downloads>
<maintainer>Pavel Syomin</maintainer>
<maintainerurl>https://github.com/PavelSyomin</maintainerurl>
Expand Down

0 comments on commit 36e7592

Please sign in to comment.