From 4c577e3b9d4253d8ccd7d71adc5fa02fa6145c8b Mon Sep 17 00:00:00 2001
From: Alisha <alishakamat8@gmail.com>
Date: Sun, 12 Jun 2022 14:52:50 +0530
Subject: [PATCH 1/4] Create SEO tab

---
 .../com_content/tmpl/article/edit.php         | 33 +++++++++++++++++++
 administrator/language/en-GB/com_content.ini  |  1 +
 administrator/language/en-GB/joomla.ini       |  4 +++
 3 files changed, 38 insertions(+)

diff --git a/administrator/components/com_content/tmpl/article/edit.php b/administrator/components/com_content/tmpl/article/edit.php
index 29ce01e10f..3ea410ba3d 100644
--- a/administrator/components/com_content/tmpl/article/edit.php
+++ b/administrator/components/com_content/tmpl/article/edit.php
@@ -171,6 +171,39 @@
 			<?php echo HTMLHelper::_('uitab.endTab'); ?>
 		<?php endif; ?>
 
+			<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'seo', Text::_('COM_CONTENT_FIELDSET_SEO')); ?>
+			<div class="row">
+				<div class="col-12 col-lg-6">
+					<fieldset id="fieldset-articlepreview" class="options-form">
+						<legend><?php echo Text::_('JGLOBAL_FIELDSET_ARTICLE_PREVIEW'); ?></legend>
+						<div>
+						<?php echo LayoutHelper::render('joomla.edit.articlepreview', $this); ?>
+						</div>
+					</fieldset>
+					<fieldset id="fieldset-paragraphstructure" class="options-form">
+						<legend><?php echo Text::_('JGLOBAL_FIELDSET_PARAGRAPH_STRUCTURE'); ?></legend>
+						<div>
+						<?php echo LayoutHelper::render('joomla.edit.paragraphstructure', $this); ?>
+						</div>
+					</fieldset>
+				</div>
+				<div class="col-12 col-lg-6">
+					<fieldset id="fieldset-pageperformance" class="options-form">
+						<legend><?php echo Text::_('JGLOBAL_FIELDSET_PAGE_PERFORMANCE'); ?></legend>
+						<div>
+						<?php echo LayoutHelper::render('joomla.edit.pageperformance', $this); ?>
+						</div>
+					</fieldset>
+					<fieldset id="fieldset-linkchecker" class="options-form">
+						<legend><?php echo Text::_('JGLOBAL_FIELDSET_LINK_CHECKER'); ?></legend>
+						<div>
+						<?php echo LayoutHelper::render('joomla.edit.linkchecker', $this); ?>
+						</div>
+					</fieldset>
+				</div>
+			</div>
+			<?php echo HTMLHelper::_('uitab.endTab'); ?>
+
 		<?php echo HTMLHelper::_('uitab.endTabSet'); ?>
 
 		<?php // Creating 'id' hiddenField to cope with com_associations sidebyside loop ?>
diff --git a/administrator/language/en-GB/com_content.ini b/administrator/language/en-GB/com_content.ini
index 23dcc8ccc7..d30e991d25 100644
--- a/administrator/language/en-GB/com_content.ini
+++ b/administrator/language/en-GB/com_content.ini
@@ -96,6 +96,7 @@ COM_CONTENT_FIELDS_ARTICLE_FIELDS_TITLE="Articles: Fields"
 COM_CONTENT_FIELDS_TYPE_MODAL_ARTICLE="Article"
 COM_CONTENT_FIELDSET_PUBLISHING="Publishing"
 COM_CONTENT_FIELDSET_RULES="Permissions"
+COM_CONTENT_FIELDSET_SEO="SEO"
 COM_CONTENT_FIELDSET_URLS_AND_IMAGES="Images and Links"
 COM_CONTENT_FILTER_FEATURED_NO="Unfeatured Articles"
 COM_CONTENT_FILTER_FEATURED_YES="Featured Articles"
diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini
index 36b9f884ec..e1c0debe16 100644
--- a/administrator/language/en-GB/joomla.ini
+++ b/administrator/language/en-GB/joomla.ini
@@ -446,6 +446,7 @@ JGLOBAL_FIELD_VERSION_NOTE_LABEL="Version Note"
 JGLOBAL_FIELDS="Fields"
 JGLOBAL_FIELDS_TITLE="Custom Fields"
 JGLOBAL_FIELDSET_ADVANCED="Advanced"
+JGLOBAL_FIELDSET_ARTICLE_PREVIEW="Article Preview"
 JGLOBAL_FIELDSET_ASSOCIATIONS="Associations"
 JGLOBAL_FIELDSET_BASIC="Options"
 JGLOBAL_FIELDSET_CONTENT="Content"
@@ -454,8 +455,11 @@ JGLOBAL_FIELDSET_DISPLAY_OPTIONS="Display"
 JGLOBAL_FIELDSET_GLOBAL="Main Options"
 JGLOBAL_FIELDSET_IMAGE_OPTIONS="Images"
 JGLOBAL_FIELDSET_INTEGRATION="Integration"
+JGLOBAL_FIELDSET_LINK_CHECKER="Outgoing Dofollow / Nofollow Link Checker"
 JGLOBAL_FIELDSET_METADATA_OPTIONS="Metadata"
 JGLOBAL_FIELDSET_OPTIONS="Options"
+JGLOBAL_FIELDSET_PAGE_PERFORMANCE="Page Performance"
+JGLOBAL_FIELDSET_PARAGRAPH_STRUCTURE="Paragraph structure"
 JGLOBAL_FIELDSET_PUBLISHING="Publishing"
 JGLOBAL_FILTER_ATTRIBUTES_DESC="3. List additional attributes, separating each attribute name with a space or comma. For example: <em>class,title,id</em>."
 JGLOBAL_FILTER_ATTRIBUTES_LABEL="Filter Attributes<sup>3</sup>"

From 4b2636c1cc38aaff1f08445dd17363e83e89aab6 Mon Sep 17 00:00:00 2001
From: Alisha <alishakamat8@gmail.com>
Date: Fri, 24 Jun 2022 23:09:07 +0530
Subject: [PATCH 2/4] Add Sentence Structure

---
 .../com_content/tmpl/article/edit.php         |  6 ++
 administrator/language/en-GB/com_content.ini  |  3 +
 administrator/language/en-GB/joomla.ini       |  1 +
 layouts/joomla/edit/sentencestructure.php     | 56 +++++++++++++++++++
 4 files changed, 66 insertions(+)
 create mode 100644 layouts/joomla/edit/sentencestructure.php

diff --git a/administrator/components/com_content/tmpl/article/edit.php b/administrator/components/com_content/tmpl/article/edit.php
index 3ea410ba3d..4d497ec73c 100644
--- a/administrator/components/com_content/tmpl/article/edit.php
+++ b/administrator/components/com_content/tmpl/article/edit.php
@@ -200,6 +200,12 @@
 						<?php echo LayoutHelper::render('joomla.edit.linkchecker', $this); ?>
 						</div>
 					</fieldset>
+					<fieldset id="fieldset-sentencestructure" class="options-form">
+						<legend><?php echo Text::_('JGLOBAL_FIELDSET_SENTENCE_STRUCTURE'); ?></legend>
+						<div>
+						<?php echo LayoutHelper::render('joomla.edit.sentencestructure', $this); ?>
+						</div>
+					</fieldset>					
 				</div>
 			</div>
 			<?php echo HTMLHelper::_('uitab.endTab'); ?>
diff --git a/administrator/language/en-GB/com_content.ini b/administrator/language/en-GB/com_content.ini
index f5ce5720b8..9e16e9314d 100644
--- a/administrator/language/en-GB/com_content.ini
+++ b/administrator/language/en-GB/com_content.ini
@@ -78,6 +78,9 @@ COM_CONTENT_FIELD_OPTION_SPLIT="Split"
 COM_CONTENT_FIELD_PUBLISH_DOWN_LABEL="Finish Publishing"
 COM_CONTENT_FIELD_PUBLISH_UP_LABEL="Start Publishing"
 COM_CONTENT_FIELD_SELECT_ARTICLE_LABEL="Select Article"
+COM_CONTENT_FIELD_SENTENCE_STRUCTURE_TITLE_1="Concise sentences are ideal for SEO. Try to limit your sentences to {max_length} words.<br><br>"
+COM_CONTENT_FIELD_SENTENCE_STRUCTURE_TITLE_2="A few sentences that you could work on:<br><br>"
+COM_CONTENT_FIELD_SENTENCE_STRUCTURE_NONE="No sentence exceeds the {max_length} words limit."
 COM_CONTENT_FIELD_SHOW_CAT_TAGS_LABEL="Tags"
 COM_CONTENT_FIELD_SHOW_TAGS_LABEL="Tags"
 COM_CONTENT_FIELD_URLA_LABEL="Link A"
diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini
index e8319e3c8a..55c94f7612 100644
--- a/administrator/language/en-GB/joomla.ini
+++ b/administrator/language/en-GB/joomla.ini
@@ -464,6 +464,7 @@ JGLOBAL_FIELDSET_OPTIONS="Options"
 JGLOBAL_FIELDSET_PAGE_PERFORMANCE="Page Performance"
 JGLOBAL_FIELDSET_PARAGRAPH_STRUCTURE="Paragraph structure"
 JGLOBAL_FIELDSET_PUBLISHING="Publishing"
+JGLOBAL_FIELDSET_SENTENCE_STRUCTURE="Sentence structure"
 JGLOBAL_FILTER_ATTRIBUTES_DESC="3. List additional attributes, separating each attribute name with a space or comma. For example: <em>class,title,id</em>."
 JGLOBAL_FILTER_ATTRIBUTES_LABEL="Filter Attributes<sup>3</sup>"
 JGLOBAL_FILTER_CLIENT="- Select Location -"
diff --git a/layouts/joomla/edit/sentencestructure.php b/layouts/joomla/edit/sentencestructure.php
new file mode 100644
index 0000000000..616f13ec23
--- /dev/null
+++ b/layouts/joomla/edit/sentencestructure.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * @package     Joomla.Site
+ * @subpackage  Layout
+ *
+ * @copyright   (C) 2013 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;
+
+//Define maximum word count limit for sentence
+$max_length = 20;
+
+$title_text = str_replace('{max_length}', $max_length, Text::_('COM_CONTENT_FIELD_SENTENCE_STRUCTURE_TITLE_1'));
+echo $title_text;
+
+$form = $displayData->getForm();
+$total_sentences = preg_match_all('/[^\s]{1,2}(.*?)(\.|\!|\?){1,3}(?!\w)/', strip_tags($form->getValue('articletext')), $matches);
+
+$sentence = 0;
+$sentence_displayed = 0;
+
+//Displays the first 5 ill-formed sentences
+while($sentence < $total_sentences && $sentence_displayed < 5)
+{
+	if(str_word_count(strip_tags($matches[0][$sentence])) > $max_length)
+    {
+        if($sentence_displayed == 0)
+        {
+            echo Text::_('COM_CONTENT_FIELD_SENTENCE_STRUCTURE_TITLE_2');
+            echo "<ul>";
+        }
+        echo "<li>";
+        echo "<i>" . substr(strip_tags($matches[0][$sentence]), 0, 30) . "...</i>\n";
+        echo "[" . str_word_count(strip_tags($matches[0][$sentence])) . " " . Text::_('COM_CONTENT_FIELD_WORDS_DESC') . "]";// . ($matches[0][$i]);
+        echo "</li>";
+        $sentence_displayed++;
+    }
+    $sentence++;
+}
+echo "</ul>";
+
+
+if($sentence_displayed == 0)
+{
+    $none_text = str_replace('{max_length}', $max_length, Text::_('COM_CONTENT_FIELD_SENTENCE_STRUCTURE_NONE'));
+    echo "<i>" . $none_text . "</i>";
+}
+
+
+
+?>
\ No newline at end of file

From 2ee60641058e20fdad32e62727a150569c095528 Mon Sep 17 00:00:00 2001
From: Alisha <alishakamat8@gmail.com>
Date: Mon, 27 Jun 2022 12:45:30 +0530
Subject: [PATCH 3/4] Update language file

---
 administrator/language/en-GB/com_content.ini | 1 +
 1 file changed, 1 insertion(+)

diff --git a/administrator/language/en-GB/com_content.ini b/administrator/language/en-GB/com_content.ini
index 9e16e9314d..a120a9deca 100644
--- a/administrator/language/en-GB/com_content.ini
+++ b/administrator/language/en-GB/com_content.ini
@@ -93,6 +93,7 @@ COM_CONTENT_FIELD_URLS_OPTIONS="URL Options"
 COM_CONTENT_FIELD_URLSPOSITION_LABEL="Positioning of the Links"
 COM_CONTENT_FIELD_VALUE_USE_ARTICLE_SETTINGS="Use Article Settings"
 COM_CONTENT_FIELD_VERSION_LABEL="Revision"
+COM_CONTENT_FIELD_WORDS_DESC=" words"
 COM_CONTENT_FIELDS_ARTICLE_FIELD_ADD_TITLE="Articles: New Field"
 COM_CONTENT_FIELDS_ARTICLE_FIELD_EDIT_TITLE="Articles: Edit Field"
 COM_CONTENT_FIELDS_ARTICLE_FIELDS_TITLE="Articles: Fields"

From b65ade10f283ebf289eb8c1fd292e19609268e82 Mon Sep 17 00:00:00 2001
From: Alisha <alishakamat8@gmail.com>
Date: Wed, 10 Aug 2022 02:13:36 +0530
Subject: [PATCH 4/4] Feature Enhancements for Sentence Structure

---
 administrator/language/en-GB/com_content.ini |  1 +
 layouts/joomla/edit/sentencestructure.php    | 53 ++++++++++++++------
 2 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/administrator/language/en-GB/com_content.ini b/administrator/language/en-GB/com_content.ini
index a120a9deca..59d5c117fd 100644
--- a/administrator/language/en-GB/com_content.ini
+++ b/administrator/language/en-GB/com_content.ini
@@ -81,6 +81,7 @@ COM_CONTENT_FIELD_SELECT_ARTICLE_LABEL="Select Article"
 COM_CONTENT_FIELD_SENTENCE_STRUCTURE_TITLE_1="Concise sentences are ideal for SEO. Try to limit your sentences to {max_length} words.<br><br>"
 COM_CONTENT_FIELD_SENTENCE_STRUCTURE_TITLE_2="A few sentences that you could work on:<br><br>"
 COM_CONTENT_FIELD_SENTENCE_STRUCTURE_NONE="No sentence exceeds the {max_length} words limit."
+COM_CONTENT_FIELD_SENTENCE_TERMINATOR="/[^\s]{1,2}(.*?)(\.|\!|\?){1,3}(?!\w)/"
 COM_CONTENT_FIELD_SHOW_CAT_TAGS_LABEL="Tags"
 COM_CONTENT_FIELD_SHOW_TAGS_LABEL="Tags"
 COM_CONTENT_FIELD_URLA_LABEL="Link A"
diff --git a/layouts/joomla/edit/sentencestructure.php b/layouts/joomla/edit/sentencestructure.php
index 616f13ec23..8c1a9626bf 100644
--- a/layouts/joomla/edit/sentencestructure.php
+++ b/layouts/joomla/edit/sentencestructure.php
@@ -19,38 +19,63 @@
 echo $title_text;
 
 $form = $displayData->getForm();
-$total_sentences = preg_match_all('/[^\s]{1,2}(.*?)(\.|\!|\?){1,3}(?!\w)/', strip_tags($form->getValue('articletext')), $matches);
+$total_sentences = preg_match_all(Text::_('COM_CONTENT_FIELD_SENTENCE_TERMINATOR'), strip_tags($form->getValue('articletext')), $matches);
 
 $sentence = 0;
 $sentence_displayed = 0;
+$long_sentences = 0;
+$sentence_list = array();
 
-//Displays the first 5 ill-formed sentences
-while($sentence < $total_sentences && $sentence_displayed < 5)
+while($sentence < $total_sentences)
 {
 	if(str_word_count(strip_tags($matches[0][$sentence])) > $max_length)
     {
-        if($sentence_displayed == 0)
+        $sentence_list[$long_sentences] = strip_tags($matches[0][$sentence]);
+        $long_sentences++;
+    }
+    $sentence++;
+}
+
+for($i=0;$i<$long_sentences-1;$i++)
+{
+    for($j=0;$j<$long_sentences-$i-1;$j++)
+    {
+        if(str_word_count($sentence_list[$j]) < str_word_count($sentence_list[$j+1]))
         {
-            echo Text::_('COM_CONTENT_FIELD_SENTENCE_STRUCTURE_TITLE_2');
-            echo "<ul>";
+            $temp = $sentence_list[$j];
+            $sentence_list[$j] = $sentence_list[$j+1];
+            $sentence_list[$j+1] = $temp;
         }
-        echo "<li>";
-        echo "<i>" . substr(strip_tags($matches[0][$sentence]), 0, 30) . "...</i>\n";
-        echo "[" . str_word_count(strip_tags($matches[0][$sentence])) . " " . Text::_('COM_CONTENT_FIELD_WORDS_DESC') . "]";// . ($matches[0][$i]);
-        echo "</li>";
-        $sentence_displayed++;
     }
-    $sentence++;
 }
-echo "</ul>";
 
+$sentence = 0;
 
-if($sentence_displayed == 0)
+if($long_sentences == 0)
 {
     $none_text = str_replace('{max_length}', $max_length, Text::_('COM_CONTENT_FIELD_SENTENCE_STRUCTURE_NONE'));
     echo "<i>" . $none_text . "</i>";
 }
+else
+{
+    echo $long_sentences . " discovered out of total " . $total_sentences . "<br>";
 
+    while($sentence < $long_sentences && $sentence_displayed < 5)
+    {
+        if($sentence_displayed == 0)
+        {
+            echo Text::_('COM_CONTENT_FIELD_SENTENCE_STRUCTURE_TITLE_2');
+            echo "<ul>";
+        }
+        echo "<li>";
+        echo "<i>" . substr($sentence_list[$sentence_displayed], 0, 30) . "...</i>\n";
+        echo "[" . str_word_count($sentence_list[$sentence_displayed]) . " " . Text::_('COM_CONTENT_FIELD_WORDS_DESC') . "]";// . ($matches[0][$i]);
+        echo "</li>";
+        $sentence_displayed++;
+        $sentence++;
+    }
+    echo "</ul>";
+}
 
 
 ?>
\ No newline at end of file