Skip to content

Commit

Permalink
fix ghost page
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Jun 14, 2017
1 parent be571b9 commit a2419cc
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 20 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ define([
});

if (!!component.data.type && component.data.type.name === 'ghost') {
component.data['_hash'] = null;
delete component.data['_hash'];
}

return ArticleManager.save(component.data, component.data.id, component.options.locale, action);
Expand Down
3 changes: 3 additions & 0 deletions Resources/public/js/components/articles/edit/details/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ define([

var data = this.options.adapter.prepareData(this.data, this);
if (data.type && data.type.name === 'ghost') {
var titleProperty = this.getTitleProperty(),
pageTitleProperty = this.getPageTitleProperty();

this.ghost = {
locale: data.type.value,
title: titleProperty ? data[titleProperty.name] : '',
Expand Down
53 changes: 36 additions & 17 deletions Sitemap/ArticleSitemapProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,56 @@ public function build($page, $portalKey)
do {
$bulk = $this->getBulk($repository, $from, $size);
/** @var SitemapUrl[] $alternatives */
$alternatives = [];
$sitemapUrlListByUuid = [];

/** @var ArticleViewDocumentInterface $item */
foreach ($bulk as $item) {
$sitemapUrl = new SitemapUrl($item->getRoutePath(), $item->getLocale(), $item->getChanged());
$result[] = $sitemapUrl;

if (!isset($alternatives[$item->getUuid()])) {
$alternatives[$item->getUuid()] = [];
} else {
foreach ($alternatives as $alternative) {
// Add current as alternative to exist.
$alternative->addAlternateLink(
new SitemapAlternateLink($item->getRoutePath(), $item->getLocale())
);

// Add others as alternative to current.
$sitemapUrl->addAlternateLink(
new SitemapAlternateLink($alternative->getLoc(), $alternative->getLocale())
);
}
if (!isset($sitemapUrlListByUuid[$item->getUuid()])) {
$sitemapUrlListByUuid[$item->getUuid()] = [];
}

$alternatives[$item->getUuid()][] = $sitemapUrl;
$result[] = $sitemapUrl;
$sitemapUrlListByUuid[$item->getUuid()] = $this->setAlternatives(
$sitemapUrlListByUuid[$item->getUuid()],
$sitemapUrl
);
}

$from += $size;
} while ($bulk->count() > $from || $from > self::PAGE_SIZE);

return $result;
}

/**
* Set alternatives to sitemap url.
*
* @param SitemapUrl[] $sitemapUrlList
* @param SitemapUrl $sitemapUrl
*
* @return $sitemapUrlList[]
*/
private function setAlternatives(array $sitemapUrlList, SitemapUrl $sitemapUrl)
{
foreach ($sitemapUrlList as $sitemapUrlFromList) {
// Add current as alternative to exist.
$sitemapUrlFromList->addAlternateLink(
new SitemapAlternateLink($sitemapUrl->getLoc(), $sitemapUrl->getLocale())
);

// Add others as alternative to current.
$sitemapUrl->addAlternateLink(
new SitemapAlternateLink($alternative->getLoc(), $alternative->getLocale())
);
}

$sitemapUrlList[] = $sitemapUrl;

return $sitemapUrlList;
}

private function getBulk(Repository $repository, $from, $size)
{
$search = $repository->createSearch()
Expand Down

0 comments on commit a2419cc

Please sign in to comment.