Browse Source

Konfiguration Positionierung Rating auf Seiten (oberhalb/unterhalb) eingebaut

dev-contao3 3.5.0
Carsten Götzinger 7 years ago
parent
commit
0f080a32be
  1. 22
      classes/RateItPage.php
  2. 2
      config/config.php
  3. 21
      dca/tl_page.php
  4. 6
      languages/de/tl_page.php
  5. 6
      languages/en/tl_page.php

22
classes/RateItPage.php

@ -40,10 +40,8 @@ class RateItPage extends \Frontend {
$this->loadDataContainer('settings');
}
public function outputFrontendTemplate($strContent, $strTemplate) {
global $objPage;
if ($objPage->addRating && !($strTemplate == $GLOBALS['TL_CONFIG']['rating_template'])) {
public function generatePage($objPage, $objLayout, $objPageType) {
if ($objPage->addRating) {
$actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ='page'")
->execute($objPage->id)
->fetchAssoc();
@ -57,16 +55,16 @@ class RateItPage extends \Frontend {
$rating .= $this->includeJs();
$rating .= $this->includeCss();
$posMainDiv = strpos($strContent, '<div id="main">');
$posInsideDiv = strpos($strContent, '<div class="inside">', $posMainDiv);
$return = substr($strContent, 0, $posInsideDiv).'<div class="inside">';
$return .= $rating;
$return .= substr($strContent, $posInsideDiv + strlen('<div id="inside">') + 3);
$strContent = $return;
$objTemplate = $objPageType->Template;
if ($objTemplate) {
if ($objPage->rateit_position == 'after') {
$objTemplate->main .= $rating;
} else {
$objTemplate->main = $rating.$objTemplate->main;
}
}
}
}
return $strContent;
}
private function includeCss() {

2
config/config.php

@ -33,7 +33,7 @@ use cgoIT\rateit\RateItBackend;
/**
* Hooks
*/
$GLOBALS['TL_HOOKS']['outputFrontendTemplate'][] = array('rateit\\RateItPage', 'outputFrontendTemplate');
$GLOBALS['TL_HOOKS']['generatePage'][] = array('rateit\\RateItPage', 'generatePage');
$GLOBALS['TL_HOOKS']['simpleAjax'][] = array('rateit\\RateIt', 'doVote');
$GLOBALS['TL_HOOKS']['parseArticles'][] = array('rateit\\RateItNews', 'parseArticle');
$GLOBALS['TL_HOOKS']['getContentElement'][] = array('rateit\\RateItFaq', 'getContentElementRateIt');

21
dca/tl_page.php

@ -39,6 +39,7 @@ $GLOBALS['TL_DCA']['tl_page']['config']['ondelete_callback'][] = array('tl_page_
/**
* Palettes
*/
$GLOBALS['TL_DCA']['tl_page']['palettes']['__selector__'][] = 'addRating';
foreach ($GLOBALS['TL_DCA']['tl_page']['palettes'] as $keyPalette => $valuePalette)
{
// Skip if we have a array or the palettes for subselections
@ -53,13 +54,31 @@ foreach ($GLOBALS['TL_DCA']['tl_page']['palettes'] as $keyPalette => $valuePalet
$GLOBALS['TL_DCA']['tl_page']['palettes'][$keyPalette] = $valuePalette;
}
/**
* Add subpalettes to tl_page
*/
$GLOBALS['TL_DCA']['tl_page']['subpalettes']['addRating'] = 'rateit_position';
// Fields
$GLOBALS['TL_DCA']['tl_page']['fields']['addRating'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_page']['addRating'],
'label' => &$GLOBALS['TL_LANG']['tl_page']['addRating'],
'exclude' => true,
'inputType' => 'checkbox',
'sql' => "char(1) NOT NULL default ''",
'eval' => array('tl_class'=>'w50 m12', 'submitOnChange'=>true)
);
$GLOBALS['TL_DCA']['tl_page']['fields']['rateit_position'] = array
(
'label' => &$GLOBALS['TL_LANG']['tl_page']['rateit_position'],
'default' => 'before',
'exclude' => true,
'inputType' => 'select',
'options' => array('after', 'before'),
'reference' => &$GLOBALS['TL_LANG']['tl_page'],
'sql' => "varchar(6) NOT NULL default ''",
'eval' => array('mandatory'=>true, 'tl_class'=>'w50')
);
class tl_page_rateit extends rateit\DcaHelper {

6
languages/de/tl_page.php

@ -31,6 +31,10 @@
$GLOBALS['TL_LANG']['tl_page']['rateit_legend'] = 'Rate It-Einstellungen';
$GLOBALS['TL_LANG']['tl_page']['addRating'] = array('Rating aktivieren', 'Aktiviert das Rating für diese Seite');
$GLOBALS['TL_LANG']['tl_page']['addRating'] = array('Rating aktivieren', 'Aktiviert das Rating für diese Seite');
$GLOBALS['TL_LANG']['tl_page']['rateit_position'] = array('Position', 'Position des Rating (ober- oder unterhalb) der Seite.');
$GLOBALS['TL_LANG']['tl_page']['before'] = array('oberhalb', 'Anzeige des Texts oberhalb der Seite');
$GLOBALS['TL_LANG']['tl_page']['after'] = array('unterhalb', 'Anzeige des Texts unterhalb der Seite');
?>

6
languages/en/tl_page.php

@ -31,6 +31,10 @@
$GLOBALS['TL_LANG']['tl_page']['rateit_legend'] = 'Rate It-Settings';
$GLOBALS['TL_LANG']['tl_page']['addRating'] = array('activate rating', 'Enables the rating for this page');
$GLOBALS['TL_LANG']['tl_page']['addRating'] = array('activate rating', 'Enables the rating for this page');
$GLOBALS['TL_LANG']['tl_page']['rateit_position'] = array('position', 'position of the rating (before or above) the page.');
$GLOBALS['TL_LANG']['tl_page']['before'] = array('above', 'Display the text above the page');
$GLOBALS['TL_LANG']['tl_page']['after'] = array('below', 'Display the text below the page');
?>
Loading…
Cancel
Save