-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from jonathanheilmann/develop_v1.2.2
Develop v1.2.2
- Loading branch information
Showing
10 changed files
with
182 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,38 @@ | ||
## TYPO3 v4 | ||
# Ignore serveral upload and file directories. | ||
/fileadmin/user_upload/ | ||
/fileadmin/_temp_/ | ||
/uploads/ | ||
# Ignore cache | ||
/typo3conf/temp_CACHED* | ||
/typo3conf/temp_fieldInfo.php | ||
# Ignore local config which overrides typo3 config. | ||
# You should include your local stuff with `@include('localconf_local.php');` at the end of localconf.php. | ||
# See http://stackoverflow.com/questions/11905360/how-best-to-manage-typo3-installations-using-git for details. | ||
/typo3conf/localconf_local.php | ||
# Ignore system folders, you should have them symlinked. | ||
# If not comment out the following two entries. | ||
/typo3 | ||
/t3lib | ||
# Ignore temp directory. | ||
/typo3temp/ | ||
## | ||
# Local | ||
## | ||
.idea/* | ||
|
||
## | ||
# https://gist.github.com/jonathanheilmann/79228adada3521a90a54 | ||
## | ||
|
||
## | ||
# OSX | ||
## | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
## | ||
# Windows | ||
## | ||
# Windows image file caches | ||
Thumbs.db | ||
ehthumbs.db | ||
# Folder config file | ||
Desktop.ini | ||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
# Windows Installer files | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
# Windows shortcuts | ||
*.lnk | ||
|
||
## | ||
# all OS | ||
## | ||
*.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,9 @@ | |
***************************************************************/ | ||
|
||
use TYPO3\CMS\Core\Resource\FileReference; | ||
use TYPO3\CMS\Core\Resource\FileRepository; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Core\Utility\ArrayUtility; | ||
use TYPO3\CMS\Extbase\Utility\DebuggerUtility; | ||
|
||
/** | ||
* Class OgRendererService | ||
|
@@ -64,20 +64,23 @@ public function main($content, $conf) | |
$content = ''; | ||
$og = array(); | ||
|
||
if ($this->signalSlotDispatcher == null) { | ||
if ($this->signalSlotDispatcher == null) | ||
{ | ||
/* @var \TYPO3\CMS\Extbase\Object\ObjectManager */ | ||
$objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); | ||
$this->signalSlotDispatcher = $objectManager->get('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher'); | ||
} | ||
|
||
// 2013-04-22 [email protected] | ||
// Check if the tt_news "displaySingle" method has been called before | ||
if (class_exists('tx_jhopengraphttnews_displaySingleHook')) { | ||
if (class_exists('tx_jhopengraphttnews_displaySingleHook')) | ||
{ | ||
$hookObject = GeneralUtility::makeInstance('tx_jhopengraphttnews_displaySingleHook'); | ||
if ($hookObject->singleViewDisplayed()) | ||
return $content; | ||
} | ||
if (class_exists(\Heilmann\JhOpengraphTtnews\Hooks\DisplaySingle::class)) { | ||
if (class_exists(\Heilmann\JhOpengraphTtnews\Hooks\DisplaySingle::class)) | ||
{ | ||
$hookObject = GeneralUtility::makeInstance(\Heilmann\JhOpengraphTtnews\Hooks\DisplaySingle::class); | ||
if ($hookObject->singleViewDisplayed()) | ||
return $content; | ||
|
@@ -86,76 +89,82 @@ public function main($content, $conf) | |
//if there has been no return, get og properties and render output | ||
|
||
// Get title | ||
if (!empty($this->cObj->data['tx_jhopengraphprotocol_ogtitle'])) { | ||
$og['title'] = $this->cObj->data['tx_jhopengraphprotocol_ogtitle']; | ||
} else { | ||
$og['title'] = $GLOBALS['TSFE']->page['title']; | ||
} | ||
$og['title'] = htmlspecialchars($og['title']); | ||
$og['title'] = htmlspecialchars(!empty($GLOBALS['TSFE']->page['tx_jhopengraphprotocol_ogtitle']) ? | ||
$GLOBALS['TSFE']->page['tx_jhopengraphprotocol_ogtitle'] : | ||
$GLOBALS['TSFE']->page['title']); | ||
|
||
// Get type | ||
if (!empty($this->cObj->data['tx_jhopengraphprotocol_ogtype'])) { | ||
$og['type'] = $this->cObj->data['tx_jhopengraphprotocol_ogtype']; | ||
} else { | ||
$og['type'] = $conf['type']; | ||
} | ||
$og['type'] = htmlspecialchars($og['type']); | ||
|
||
// Get image | ||
/** @var \TYPO3\CMS\Core\Resource\FileRepository $fileRepository */ | ||
$fileRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository'); | ||
$fileObjects = $fileRepository->findByRelation('pages', 'tx_jhopengraphprotocol_ogfalimages', $GLOBALS['TSFE']->id); | ||
if (count($fileObjects)) { | ||
foreach ($fileObjects as $key => $fileObject) { | ||
/** @var FileReference $fileObject */ | ||
$og['image'][] = $fileObject; | ||
} | ||
} else { | ||
$og['type'] = htmlspecialchars(!empty($GLOBALS['TSFE']->page['tx_jhopengraphprotocol_ogtype']) ? | ||
$GLOBALS['TSFE']->page['tx_jhopengraphprotocol_ogtype'] : | ||
$conf['type']); | ||
|
||
// Get images | ||
/** @var FileRepository $fileRepository */ | ||
$fileRepository = GeneralUtility::makeInstance(FileRepository::class); | ||
|
||
$fileObjects = array(); | ||
if ($GLOBALS['TSFE']->page['_PAGES_OVERLAY_UID']) | ||
{ | ||
// Get images if there is a language overlay | ||
// This is somehow a hack, as l10n_mode 'mergeIfNotBlack' does not work in this case. | ||
// PageRepository->shouldFieldBeOverlaid does not work for config type 'inline' with "DEFAULT '0'" database config, | ||
// as an empty inline field is '0', and '0' is treated as not empty. | ||
// Setting 'Default NULL' in database config won't work, too, as it isn't easier to check, if value in | ||
// $GLOBALS['TSFE']->page['tx_jhopengraphprotocol_ogtype'] is related to table 'pages' or 'pages_language_overlay'. | ||
|
||
$overlayFileObjects = $fileRepository->findByRelation('pages_language_overlay', 'tx_jhopengraphprotocol_ogfalimages', $GLOBALS['TSFE']->page['_PAGES_OVERLAY_UID']); | ||
if (count($overlayFileObjects) > 0) | ||
$fileObjects = $overlayFileObjects; | ||
else if (isset($GLOBALS['TCA']['pages_language_overlay']['columns']['tx_jhopengraphprotocol_ogfalimages']['l10n_mode']) && | ||
$GLOBALS['TCA']['pages_language_overlay']['columns']['tx_jhopengraphprotocol_ogfalimages']['l10n_mode'] === 'mergeIfNotBlank') | ||
$fileObjects = $fileRepository->findByRelation('pages', 'tx_jhopengraphprotocol_ogfalimages', $GLOBALS['TSFE']->id); | ||
} else | ||
$fileObjects = $fileRepository->findByRelation('pages', 'tx_jhopengraphprotocol_ogfalimages', $GLOBALS['TSFE']->id); | ||
|
||
if (count($fileObjects) === 0) | ||
{ | ||
// check if an image is given in page --> media, if not use default image | ||
$fileObjects = $fileRepository->findByRelation('pages', 'media', $GLOBALS['TSFE']->id); | ||
if (count($fileObjects)) { | ||
foreach ($fileObjects as $key => $fileObject) { | ||
/** @var FileReference $fileObject */ | ||
$og['image'][] = $fileObject; | ||
} | ||
} else { | ||
$fileObjects = $fileRepository->findByRelation( | ||
($GLOBALS['TSFE']->page['_PAGES_OVERLAY_UID'] ? 'pages_language_overlay' : 'pages'), | ||
'media', | ||
($GLOBALS['TSFE']->page['_PAGES_OVERLAY_UID'] ?:$GLOBALS['TSFE']->id) | ||
); | ||
if (count($fileObjects) === 0) | ||
{ | ||
$imageFileName = $GLOBALS['TSFE']->tmpl->getFileName($conf['image']); | ||
if (!empty($imageFileName)) { | ||
if (!empty($imageFileName)) | ||
$og['image'][] = $imageFileName; | ||
} | ||
} | ||
} | ||
|
||
} else | ||
$og['image'] = $fileObjects; | ||
} else | ||
$og['image'] = $fileObjects; | ||
|
||
// Get url | ||
$og['url'] = htmlentities(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')); | ||
|
||
// Get site_name | ||
if (!empty($conf['sitename'])) { | ||
$og['site_name'] = $conf['sitename']; | ||
} else { | ||
$og['site_name'] = $GLOBALS['TSFE']->tmpl->setup['sitetitle']; | ||
} | ||
$og['site_name'] = htmlspecialchars($og['site_name']); | ||
$og['site_name'] = htmlspecialchars(!empty($conf['sitename']) ? | ||
$conf['sitename'] : | ||
$GLOBALS['TSFE']->tmpl->setup['sitetitle']); | ||
|
||
// Get description | ||
if (!empty($this->cObj->data['tx_jhopengraphprotocol_ogdescription'])) { | ||
$og['description'] = $this->cObj->data['tx_jhopengraphprotocol_ogdescription']; | ||
} else { | ||
if (!empty($GLOBALS['TSFE']->page['description'])) { | ||
$og['description'] = $GLOBALS['TSFE']->page['description']; | ||
} else { | ||
$og['description'] = $conf['description']; | ||
} | ||
} | ||
if (!empty($GLOBALS['TSFE']->page['tx_jhopengraphprotocol_ogdescription'])) | ||
$og['description'] = $GLOBALS['TSFE']->page['tx_jhopengraphprotocol_ogdescription']; | ||
else | ||
$og['description'] = !empty($GLOBALS['TSFE']->page['description']) ? | ||
$GLOBALS['TSFE']->page['description'] : | ||
$conf['description']; | ||
|
||
$og['description'] = htmlspecialchars($og['description']); | ||
|
||
// Get locale | ||
$localeParts = explode('.', $GLOBALS['TSFE']->tmpl->setup['config.']['locale_all']); | ||
if (isset($localeParts[0])) { | ||
if (isset($localeParts[0])) | ||
$og['locale'] = str_replace('-', '_', $localeParts[0]); | ||
} | ||
|
||
// Signal to manipulate og-properties before header creation | ||
// Please do not use the second parameter ($this->cObj) in your dispatcher, but $GLOBALS['TSFE']->page instead. | ||
// This allows you to use the advantage of easy multilingual page handling. | ||
$this->signalSlotDispatcher->dispatch( | ||
__CLASS__, | ||
'beforeHeaderCreation', | ||
|
@@ -189,22 +198,13 @@ protected function renderHeaderLines($array) | |
{ | ||
// A og property that accepts more than one value | ||
foreach ($value as $multiPropertyValue) | ||
{ | ||
// Render each value to a new og property meta-tag | ||
if ($key == 'image') | ||
{ | ||
// Add image details | ||
$res[] = $this->buildOgImageProperties($key, $multiPropertyValue); | ||
} else | ||
{ | ||
$res[] = $this->buildProperty($key, $multiPropertyValue); | ||
} | ||
} | ||
$res[] = $key == 'image' ? | ||
$this->buildOgImageProperties($key, $multiPropertyValue) : | ||
$this->buildProperty($key, $multiPropertyValue); | ||
} else | ||
{ | ||
// A og property with child-properties | ||
$res .= $this->renderHeaderLines($this->remapArray($key, $value)); | ||
} | ||
} else | ||
{ | ||
// A single og property to be rendered | ||
|
@@ -229,13 +229,13 @@ protected function buildOgImageProperties($key, $value) | |
if (is_object($value) && $value instanceOf FileReference) | ||
{ | ||
/** @var FileReference $value */ | ||
$res[] = $this->buildProperty($key, | ||
GeneralUtility::locationHeaderUrl($value->getPublicUrl())); | ||
$res[] = $this->buildProperty($key . ':type', $value->getMimeType()); | ||
$res[] = $this->buildProperty($key . ':width', | ||
$value->getProperty('width')); | ||
$res[] = $this->buildProperty($key . ':height', | ||
$value->getProperty('height')); | ||
$res[] = $this->buildProperty($key, GeneralUtility::locationHeaderUrl($value->getPublicUrl())); | ||
if ($value->getMimeType()) | ||
$res[] = $this->buildProperty($key . ':type', $value->getMimeType()); | ||
if ($value->getProperty('width')) | ||
$res[] = $this->buildProperty($key . ':width', $value->getProperty('width')); | ||
if ($value->getProperty('height')) | ||
$res[] = $this->buildProperty($key . ':height', $value->getProperty('height')); | ||
} else if (is_string($value)) | ||
{ | ||
$imageSize = array(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# cat=basic/enable/100; type=boolean; label=Title mergeIfNotBlank: Use title of default language if localized title is empty | ||
languageOverlay.tx_jhopengraphprotocol_ogtitle.mergeIfNotBlank = 0 | ||
|
||
# cat=basic/enable/101; type=boolean; label=Type mergeIfNotBlank: Use type of default language if localized type is empty | ||
languageOverlay.tx_jhopengraphprotocol_ogtype.mergeIfNotBlank = 0 | ||
|
||
# cat=basic/enable/102; type=boolean; label=Image(s) mergeIfNotBlank: Use image(s) of default language if localized image(s) is empty | ||
languageOverlay.tx_jhopengraphprotocol_ogfalimages.mergeIfNotBlank = 0 | ||
|
||
# cat=basic/enable/103; type=boolean; label=Description mergeIfNotBlank: Use description of default language if localized description is empty | ||
languageOverlay.tx_jhopengraphprotocol_ogdescription.mergeIfNotBlank = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.