Commit 74477be3 authored by Tino Goratsch's avatar Tino Goratsch

bug fixes, minor improvements and changes for the social sharing module

parent 72da6e5c
......@@ -27,5 +27,5 @@
{/if}
</ul>
{/if}
{event name="share.layout.add_shariff"}
{event name="share.layout.add_social_sharing"}
{/block}
......@@ -25,7 +25,7 @@
</a>
</footer>
</div>
{event name="share.layout.add_shariff"}
{event name="share.layout.add_social_sharing"}
</section>
{if $comments_allowed === true}
<section>
......
......@@ -21,7 +21,7 @@
<div class="description">
{$picture.description}
</div>
{event name="share.layout.add_shariff"}
{event name="share.layout.add_social_sharing"}
<footer>
<ul class="pagination">
{if !empty($picture_previous)}
......
......@@ -27,7 +27,7 @@
</a>
{/foreach}
{/if}
{event name="share.layout.add_shariff"}
{event name="share.layout.add_social_sharing"}
{else}
{include file="asset:System/Partials/no_results.tpl" no_results_text={lang t="gallery|no_pictures"}}
{/if}
......
......@@ -21,7 +21,7 @@
{/if}
</div>
{event name="news.event.news_details_after" id=$news.id title=$news.title}
{event name="share.layout.add_shariff"}
{event name="share.layout.add_social_sharing"}
</section>
{if $comments_allowed === true}
<section>
......
......@@ -13,6 +13,6 @@
<div class="content">
{$newsletter.text|nl2p}
</div>
{event name="share.layout.add_shariff"}
{event name="share.layout.add_social_sharing"}
</article>
{/block}
......@@ -8,6 +8,7 @@
namespace ACP3\Modules\ACP3\Seo\Event\Listener;
use ACP3\Core\Model\Event\ModelSaveEvent;
use ACP3\Core\Modules;
use ACP3\Core\Settings\SettingsInterface;
use ACP3\Modules\ACP3\Seo\Exception\SitemapGenerationException;
use ACP3\Modules\ACP3\Seo\Installer\Schema;
......@@ -33,17 +34,23 @@ class GenerateSitemapOnModelAfterSaveListener
* @var SitemapGenerationModel
*/
private $sitemapGenerationModel;
/**
* @var \ACP3\Core\Modules
*/
private $modules;
/**
* GenerateSitemapOnModelAfterSaveListener constructor.
*
* @param LoggerInterface $logger
* @param \ACP3\Core\Modules $modules
* @param SettingsInterface $settings
* @param SitemapAvailabilityRegistrar $sitemapRegistrar
* @param SitemapGenerationModel $sitemapGenerationModel
*/
public function __construct(
LoggerInterface $logger,
Modules $modules,
SettingsInterface $settings,
SitemapAvailabilityRegistrar $sitemapRegistrar,
SitemapGenerationModel $sitemapGenerationModel
......@@ -52,6 +59,7 @@ class GenerateSitemapOnModelAfterSaveListener
$this->settings = $settings;
$this->sitemapRegistrar = $sitemapRegistrar;
$this->sitemapGenerationModel = $sitemapGenerationModel;
$this->modules = $modules;
}
/**
......@@ -59,6 +67,10 @@ class GenerateSitemapOnModelAfterSaveListener
*/
public function generateSeoSitemap(ModelSaveEvent $event)
{
if (!$this->modules->isActive(Schema::MODULE_NAME)) {
return;
}
if ($this->canGenerateSitemapAutomatically() && $this->isAllowedModule($event->getModuleName())) {
try {
$this->sitemapGenerationModel->save();
......
......@@ -61,6 +61,8 @@ class SitemapGenerationModel
/**
* @return bool
*
* @throws \ACP3\Modules\ACP3\Seo\Exception\SitemapGenerationException
*/
public function save()
{
......@@ -82,7 +84,7 @@ class SitemapGenerationModel
*
* @throws SitemapGenerationException
*/
protected function checkSitemapFilePermissions($filename)
protected function checkSitemapFilePermissions(string $filename)
{
$filePath = $this->getSitemapFilePath($filename);
......@@ -103,7 +105,7 @@ class SitemapGenerationModel
*
* @return string
*/
protected function getSitemapFilePath($filename)
protected function getSitemapFilePath(string $filename)
{
return ACP3_ROOT_DIR . $filename;
}
......@@ -113,7 +115,7 @@ class SitemapGenerationModel
*
* @return Urlset
*/
protected function collectSitemapItems($isSecure)
protected function collectSitemapItems(?bool $isSecure)
{
$urlSet = new Urlset();
foreach ($this->sitemapRegistrar->getAvailableModules() as $module) {
......@@ -131,7 +133,7 @@ class SitemapGenerationModel
*
* @return bool
*/
protected function saveSitemap(Urlset $urlSet, $filename)
protected function saveSitemap(Urlset $urlSet, string $filename)
{
$output = (new Output())->getOutput($urlSet);
......
......@@ -39,6 +39,7 @@ services:
class: ACP3\Modules\ACP3\Seo\Event\Listener\GenerateSitemapOnModelAfterSaveListener
arguments:
- '@seo.sitemap_logger'
- '@core.modules'
- '@core.config'
- '@seo.utility.sitemap_availability_registrar'
- '@seo.model.sitemap_generation_model'
......
......@@ -83,6 +83,6 @@ class Index extends AbstractWidgetAction
$services = $this->socialServices->getActiveServices();
}
return $services;
return \array_values($services);
}
}
......@@ -13,7 +13,7 @@ use ACP3\Core\View;
use ACP3\Modules\ACP3\Share\Helpers\SocialServices;
use ACP3\Modules\ACP3\Share\Model\Repository\ShareRepository;
class AddShariffOnLayoutContentAfterListener
class AddSocialSharingListener
{
/**
* @var \ACP3\Core\Http\RequestInterface
......@@ -33,7 +33,7 @@ class AddShariffOnLayoutContentAfterListener
private $shareRepository;
/**
* AddShariffOnLayoutContentAfterListener constructor.
* AddSocialSharingListener constructor.
*
* @param \ACP3\Core\Http\RequestInterface $request
* @param \ACP3\Core\View $view
......@@ -66,7 +66,7 @@ class AddShariffOnLayoutContentAfterListener
'services' => \json_encode($this->socialServices->getActiveServices()),
]);
$this->view->displayTemplate('Share/Partials/add_shariff.tpl');
$this->view->displayTemplate('Share/Partials/add_social_sharing.tpl');
}
}
}
......
......@@ -59,7 +59,9 @@ class UpdateServicesOnSettingsSaveBeforeListener
if (!empty($services) && \is_array($services)) {
$data = [
'share_services' => \array_diff($services, $diff),
'share_services' => \array_values(
\array_diff($services, $diff)
),
];
$this->shareModel->save($data, $result['id']);
}
......
......@@ -4,15 +4,15 @@ services:
tags:
- { name: core.eventListener, event: core.assets.add_libraries, method: execute }
share.event.add_shariff_on_layout_content_after_listener:
class: ACP3\Modules\ACP3\Share\Event\Listener\AddShariffOnLayoutContentAfterListener
share.event.add_social_sharing_listener:
class: ACP3\Modules\ACP3\Share\Event\Listener\AddSocialSharingListener
arguments:
- '@core.http.request'
- '@core.view'
- '@share.helpers.social_services'
- '@share.model.share_repository'
tags:
- { name: core.eventListener, event: share.layout.add_shariff, method: execute }
- { name: core.eventListener, event: share.layout.add_social_sharing, method: execute }
share.event.validate_sharing_info_on_validation_listener:
class: ACP3\Modules\ACP3\Share\Event\Listener\ValidateSharingInfoOnValidationInfo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment