Konfiguration Positionierung Rating auf Seiten (oberhalb/unterhalb) eingebaut

This commit is contained in:
Carsten Götzinger 2015-06-12 07:39:01 +02:00
parent 3ce491f16c
commit 0f080a32be
5 changed files with 41 additions and 16 deletions

View File

@ -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() {

View File

@ -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');

View File

@ -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 {

View File

@ -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');
?>

View File

@ -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');
?>