Skip to content
Closed
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
69 changes: 69 additions & 0 deletions administrator/components/com_config/forms/application.xml
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,75 @@

</fieldset>

<fieldset
name="seo_metadata"
label="COM_CONFIG_SEO_METADATA_SETTINGS"
description="COM_CONFIG_SEO_METADATA_SETTINGS_DESCRIPTION">

<field
name="enable_seo_metadata"
type="radio"
label="COM_CONFIG_SEO_METADATA_ENABLE_LABEL"
class="switcher"
default="0"
filter="integer"
validate="options"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

<field
name="sef_owner"
type="radio"
label="COM_CONFIG_SEO_METADATA_CONTENT_OWNER_LABEL"
default="1"
filter="integer"
validate="options"
showon="enable_seo_metadata:1"
>
<option value="0">COM_CONFIG_SEO_METADATA_OWNER_ORGANISATION</option>
<option value="1">COM_CONFIG_SEO_METADATA_OWNER_INDIVIDUAL</option>
</field>

<!-- TODO: Make this a user field and just link to a Joomla user?? -->
<field
name="sef_individual"
type="text"
label="COM_CONFIG_SEO_METADATA_INDIVIDUAL_NAME"
showon="enable_seo_metadata:1[AND]sef_owner:1"
size="30"
>
</field>

<field
name="sef_individual_url"
type="text"
label="COM_CONFIG_SEO_METADATA_INDIVIDUAL_URL"
showon="enable_seo_metadata:1[AND]sef_owner:1"
size="30"
>
</field>

<field
name="sef_organisation"
type="text"
label="COM_CONFIG_SEO_METADATA_ORGANISATION_NAME"
showon="enable_seo_metadata:1[AND]sef_owner:0"
size="30"
>
</field>

<field
name="sef_organisation_logo"
type="media"
label="COM_CONFIG_SEO_METADATA_ORGANISATION_LOGO"
showon="enable_seo_metadata:1[AND]sef_owner:0"
>
</field>

</fieldset>

<fieldset
name="server"
label="CONFIG_SERVER_SETTINGS_LABEL">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<?php echo $this->loadTemplate('site'); ?>
<?php echo $this->loadTemplate('metadata'); ?>
<?php echo $this->loadTemplate('seo'); ?>
<?php echo $this->loadTemplate('seo_metadata'); ?>
<?php echo $this->loadTemplate('cookie'); ?>
</div>
<div id="page-system" class="tab-pane">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_config
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.

This comment was marked as abuse.

* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;

defined('_JEXEC') or die;

$this->name = Text::_('COM_CONFIG_SEO_METADATA_SETTINGS');
$this->fieldsname = 'seo_metadata';
$this->formclass = 'options-grid-form options-grid-form-full';
$this->description = Text::_('COM_CONFIG_SEO_METADATA_SETTINGS_DESCRIPTION');

echo LayoutHelper::render('joomla.content.options_default', $this);

// We don't use the description in any other options groups - remove it so the remaining groups don't use it
unset($this->description);
11 changes: 11 additions & 0 deletions administrator/language/en-GB/en-GB.com_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ COM_CONFIG_SENDMAIL_SUBJECT="Test mail from {SITENAME}"
COM_CONFIG_SENDMAIL_SUCCESS="The email was sent to <strong>%s</strong> using <strong>%s</strong>. You should check that you've received the test email."
COM_CONFIG_SENDMAIL_SUCCESS_FALLBACK="The email was sent to <strong>%s</strong> but using <strong>%s</strong> as fallback. You should check that you've received the test email."
COM_CONFIG_SEO_SETTINGS="SEO Settings"
COM_CONFIG_SEO_METADATA_CONTENT_OWNER_LABEL="Type of Content Owner"
COM_CONFIG_SEO_METADATA_ENABLE_LABEL="Enable SEO Metadata"
COM_CONFIG_SEO_METADATA_INDIVIDUAL_NAME="Individual Name"
COM_CONFIG_SEO_METADATA_ORGANISATION_NAME="Company Name"
COM_CONFIG_SEO_METADATA_ORGANISATION_LOGO="Organisation Logo"
COM_CONFIG_SEO_METADATA_OWNER_ORGANISATION="Organisation"
COM_CONFIG_SEO_METADATA_OWNER_INDIVIDUAL="Individual"
COM_CONFIG_SEO_METADATA_INDIVIDUAL_URL="Individual URL"
COM_CONFIG_SEO_METADATA_SETTINGS="SEO MetaData"
; Translation Teams can replace the search engines listed here with local search engines that use schema.org for rankings
COM_CONFIG_SEO_METADATA_SETTINGS_DESCRIPTION="This information is required for many search engines (such as Google, Yahoo etc) and whilst not shown on the screen is public to any search engines indexing your site. Please see <a href=\"TODO: LINK\">this article</a> for more information"
COM_CONFIG_SERVER="Server"
COM_CONFIG_SERVER_SETTINGS="Server Settings"
COM_CONFIG_SESSION_SETTINGS="Session Settings"
Expand Down
120 changes: 114 additions & 6 deletions components/com_contact/View/Contact/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\TagsHelper;
Expand All @@ -20,7 +21,12 @@
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\User;
use Joomla\Component\Contact\Site\Helper\Route as ContactHelperRoute;
use Spatie\SchemaOrg\Person;
use Spatie\SchemaOrg\PostalAddress;
use Spatie\SchemaOrg\Schema;

/**
* HTML Contact View class for the Contact component
Expand Down Expand Up @@ -107,12 +113,13 @@ class HtmlView extends BaseHtmlView
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
* @return void
* @throws \Exception
*/
public function display($tpl = null)
{
$app = Factory::getApplication();
$user = Factory::getUser();
$user = $app->getIdentity();
$state = $this->get('State');
$item = $this->get('Item');
$this->form = $this->get('Form');
Expand Down Expand Up @@ -181,7 +188,7 @@ public function display($tpl = null)
$app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error');
$app->setHeader('status', 403, true);

return false;
return;
}

$options['category_id'] = $item->catid;
Expand Down Expand Up @@ -383,7 +390,7 @@ public function display($tpl = null)
$item->text = $item->misc;
}

$app->triggerEvent('onContentPrepare', array ('com_contact.contact', &$item, &$this->params, $offset));
$app->triggerEvent('onContentPrepare', array('com_contact.contact', &$item, &$this->params, $offset));

// Store the events for later
$item->event = new \stdClass;
Expand All @@ -406,7 +413,7 @@ public function display($tpl = null)
if ($item->params->get('show_user_custom_fields') && $item->user_id && $contactUser = Factory::getUser($item->user_id))
{
$contactUser->text = '';
$app->triggerEvent('onContentPrepare', array ('com_users.user', &$contactUser, &$item->params, 0));
$app->triggerEvent('onContentPrepare', array('com_users.user', &$contactUser, &$item->params, 0));

if (!isset($contactUser->jcfields))
{
Expand Down Expand Up @@ -457,8 +464,9 @@ public function display($tpl = null)
}

$this->_prepareDocument();
$this->addJsonSchema();

return parent::display($tpl);
parent::display($tpl);
}

/**
Expand Down Expand Up @@ -574,4 +582,104 @@ protected function _prepareDocument()
}
}
}

/**
* Prepares the document.
*

This comment was marked as abuse.

* @return void
*/
private function addJsonSchema()
{
// Note we don't display tags here as the keywords property isn't valid for a person
$schema = Schema::person()
->if(
$this->item->params->get('show_name'),
function (Person $schema) {
$schema->name($this->item->name);
}
)
->if(
$this->item->image && $this->item->params->get('show_image'),
function (Person $schema) {
$schema->image(Uri::root() . $this->item->image);
}
)
->if(
$this->item->params->get('show_position'),
function (Person $schema) {
$schema->jobTitle($this->item->con_position);
}
)
->if(
$this->item->params->get('address_check') > 0,
function (Person $schema) {
$schema->address(
Schema::postalAddress()
->if(
$this->item->address && $this->params->get('show_street_address'),
function (PostalAddress $schema) {
$schema->streetAddress($this->item->address);
}
)
->if(
$this->item->suburb && $this->params->get('show_suburb'),
function (PostalAddress $schema) {
$schema->addressLocality($this->item->suburb);
}
)
->if(
$this->item->state && $this->params->get('show_state'),
function (PostalAddress $schema) {
$schema->addressRegion($this->item->state);
}
)
->if(
$this->item->postcode && $this->params->get('show_postcode'),
function (PostalAddress $schema) {
$schema->postalCode($this->item->postcode);
}
)
->if(
$this->item->country && $this->params->get('show_country'),
function (PostalAddress $schema) {
$schema->addressCountry($this->item->country);
}
)
);
}
)
// TODO: Should we expose the raw email like this?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do in the vcard download

->if(
$this->item->params->get('show_email') === '1',
function (Person $schema) {
$schema->email($this->item->email_raw);
}
)
->if(
$this->item->telephone && $this->params->get('show_telephone'),
function (Person $schema) {
$schema->telephone($this->item->telephone);
}
)
->if(
$this->item->fax && $this->params->get('show_fax'),
function (Person $schema) {
$schema->faxNumber($this->item->fax);
}
)
->if(
$this->item->mobile && $this->params->get('show_mobile'),
function (Person $schema) {
$schema->telephone($this->item->mobile);
}
)
->if(
$this->item->webpage && $this->params->get('show_webpage'),
function (Person $schema) {
$schema->url($this->item->webpage);
}
);

$this->document->addScriptDeclaration(json_encode($schema, JDEBUG ? JSON_PRETTY_PRINT : 0), 'application/ld+json');
}
}
8 changes: 4 additions & 4 deletions components/com_contact/tmpl/contact/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$tparams = $this->item->params;
?>

<div class="com-contact contact" itemscope itemtype="https://schema.org/Person">
<div class="com-contact contact">
<?php if ($tparams->get('show_page_heading')) : ?>
<h1>
<?php echo $this->escape($tparams->get('page_heading')); ?>
Expand All @@ -34,7 +34,7 @@
<?php if ($this->item->published == 0) : ?>
<span class="badge badge-warning"><?php echo Text::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<span class="contact-name" itemprop="name"><?php echo $this->item->name; ?></span>
<span class="contact-name"><?php echo $this->item->name; ?></span>
</h2>
</div>
<?php endif; ?>
Expand Down Expand Up @@ -77,14 +77,14 @@

<?php if ($this->item->image && $tparams->get('show_image')) : ?>
<div class="com-contact__thumbnail thumbnail float-right">
<?php echo HTMLHelper::_('image', $this->item->image, htmlspecialchars($this->item->name, ENT_QUOTES, 'UTF-8'), array('itemprop' => 'image')); ?>
<?php echo HTMLHelper::_('image', $this->item->image, htmlspecialchars($this->item->name, ENT_QUOTES, 'UTF-8')); ?>
</div>
<?php endif; ?>

<?php if ($this->item->con_position && $tparams->get('show_position')) : ?>
<dl class="com-contact__position contact-position dl-horizontal">
<dt><?php echo Text::_('COM_CONTACT_POSITION'); ?>:</dt>
<dd itemprop="jobTitle">
<dd>
<?php echo $this->item->con_position; ?>
</dd>
</dl>
Expand Down
Loading