Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Paragraph structure section #5

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions administrator/components/com_content/tmpl/article/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,39 @@
</fieldset>
<?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'); ?>

Expand Down
5 changes: 5 additions & 0 deletions administrator/language/en-GB/com_content.ini
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ COM_CONTENT_FIELD_NOTE_LABEL="Note"
COM_CONTENT_FIELD_OPTION_ABOVE="Above"
COM_CONTENT_FIELD_OPTION_BELOW="Below"
COM_CONTENT_FIELD_OPTION_SPLIT="Split"
COM_CONTENT_FIELD_PARAGRAPH_STRUCTURE_TITLE_1="Readers find long paragraphs difficult to understand. Aim to keep them at less than {max_length} words.<br><br>"
COM_CONTENT_FIELD_PARAGRAPH_STRUCTURE_TITLE_2="Here are some of the paragraphs that you could work on:<br><br>"
COM_CONTENT_FIELD_PARAGRAPH_STRUCTURE_NONE="No paragraph exceeds the {max_length} words limit."
COM_CONTENT_FIELD_PUBLISH_DOWN_LABEL="Finish Publishing"
COM_CONTENT_FIELD_PUBLISH_UP_LABEL="Start Publishing"
COM_CONTENT_FIELD_SELECT_ARTICLE_LABEL="Select Article"
Expand All @@ -90,12 +93,14 @@ 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"
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_AUTHORS_BY_ME="Created by me"
COM_CONTENT_FILTER_FEATURED_NO="Unfeatured Articles"
Expand Down
4 changes: 4 additions & 0 deletions administrator/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,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"
Expand All @@ -457,8 +458,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>"
Expand Down
80 changes: 80 additions & 0 deletions layouts/joomla/edit/paragraphstructure.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?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 paragraph
$max_length = 200;

$title_text = str_replace('{max_length}', $max_length, Text::_('COM_CONTENT_FIELD_PARAGRAPH_STRUCTURE_TITLE_1'));
echo $title_text;

$form = $displayData->getForm();
$total_paragraphs = preg_match_all("/<p.*?>(.*?)<\/p>/is", $form->getValue('articletext'), $matches);

$paragraph = 0;
$paragraph_displayed = 0;
$long_paragraphs = 0;
$paragraph_list = array();

while($paragraph < $total_paragraphs)
{
if(str_word_count(strip_tags($matches[0][$paragraph])) > $max_length)
{
$paragraph_list[$long_paragraphs] = strip_tags($matches[0][$paragraph]);
$long_paragraphs++;
}
$paragraph++;
}

for($i=0;$i<$long_paragraphs-1;$i++)
{
for($j=0;$j<$long_paragraphs-$i-1;$j++)
{
if(str_word_count($paragraph_list[$j]) < str_word_count($paragraph_list[$j+1]))
{
$temp = $paragraph_list[$j];
$paragraph_list[$j] = $paragraph_list[$j+1];
$paragraph_list[$j+1] = $temp;
}
}
}

$paragraph = 0;

if($long_paragraphs == 0)
{
$none_text = str_replace('{max_length}', $max_length, Text::_('COM_CONTENT_FIELD_PARAGRAPH_STRUCTURE_NONE'));
echo "<i>" . $none_text . "</i>";
}
else
{
echo $long_paragraphs . " discovered out of total " . $total_paragraphs . "<br>";

while($paragraph < $long_paragraphs && $paragraph_displayed < 5)
{
if($paragraph_displayed == 0)
{
echo Text::_('COM_CONTENT_FIELD_PARAGRAPH_STRUCTURE_TITLE_2');
echo "<ul>";
}
echo "<li>";
echo "<i>" . substr($paragraph_list[$paragraph_displayed], 0, 30) . "...</i>\n";
echo "[" . str_word_count($paragraph_list[$paragraph_displayed]) . " " . Text::_('COM_CONTENT_FIELD_WORDS_DESC') . "]";// . ($matches[0][$i]);
echo "</li>";
$paragraph_displayed++;
$paragraph++;
}
echo "</ul>";
}

?>