8 Commits
3.4.1 ... 3.4.3

10 changed files with 70 additions and 73 deletions

View File

@ -90,7 +90,7 @@ class DcaHelper extends \Backend
} }
} else { } else {
$this->Database->prepare("UPDATE tl_rateit_items SET active='' WHERE rkey=? and typ=?") $this->Database->prepare("UPDATE tl_rateit_items SET active='' WHERE rkey=? and typ=?")
->execute($dc->activeRecord->id, $typ) ->execute($dc->activeRecord->id, $type)
->updatedId; ->updatedId;
} }

View File

@ -633,13 +633,9 @@ class rateitBackendModule extends \BackendModule
$cntSql = str_replace('%s', $where, $cntSql); $cntSql = str_replace('%s', $where, $cntSql);
$count = $this->Database->prepare($cntSql) $count = $this->Database->query($cntSql)->fetchRow();
->execute()
->fetchRow();
$arrRatingItems = $this->Database->prepare($sql) $arrRatingItems = $this->Database->query($sql)->fetchAllAssoc();
->execute()
->fetchAllAssoc();
$arrReturn = array(); $arrReturn = array();
foreach ($arrRatingItems as $rating) { foreach ($arrRatingItems as $rating) {
if ($rating['active'] != '1') $rating['active'] = '0'; if ($rating['active'] != '1') $rating['active'] = '0';

View File

@ -22,11 +22,11 @@
"php":">=5.3", "php":">=5.3",
"contao/core":">=3.0", "contao/core":">=3.0",
"contao-community-alliance/composer-plugin": "~2.0", "contao-community-alliance/composer-plugin": "~2.0",
"cgo-it/simple_ajax":"1.0.1", "leounglaub/contao-simple-ajax":"3.2.x-dev",
"cgo-it/xls_export":"3.0.0" "cgo-it/xls_export":"3.0.0"
}, },
"replace": { "replace": {
"cgo-it/rate-it": "self.version" "cgo-it/rate-it": "<3.4.3"
}, },
"conflict": { "conflict": {
"contao/core": "2.11.*" "contao/core": "2.11.*"

View File

@ -70,11 +70,14 @@ class tl_content_rateit extends rateit\DcaHelper {
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
} }
public function insert(\DC_Table $dc) { public function insert(\DC_Table $dc) {
if ($dc->activeRecord->type == "gallery") { if ($dc->activeRecord->type == "gallery") {
$type = 'galpic'; $type = 'galpic';
// Alle vorherigen Bilder erst mal auf inaktiv setzen
$this->Database->prepare("UPDATE tl_rateit_items SET active='' WHERE rkey LIKE ? AND typ=?")->execute($dc->activeRecord->id.'|%', $type);
if (version_compare(VERSION, '3.2', '>=')) { if (version_compare(VERSION, '3.2', '>=')) {
$objFiles = \FilesModel::findMultipleByUuids(deserialize($dc->activeRecord->multiSRC)); $objFiles = \FilesModel::findMultipleByUuids(deserialize($dc->activeRecord->multiSRC));
} else { } else {
@ -131,56 +134,9 @@ class tl_content_rateit extends rateit\DcaHelper {
public function delete(\DC_Table $dc) { public function delete(\DC_Table $dc) {
if ($dc->activeRecord->type == "gallery") { if ($dc->activeRecord->type == "gallery") {
if (version_compare(VERSION, '3.2', '>=')) { $this->Database->prepare("DELETE FROM tl_rateit_ratings WHERE pid IN (SELECT `id` FROM tl_rateit_items WHERE rkey LIKE ? AND typ=?)")
$objFiles = \FilesModel::findMultipleByUuids(deserialize($dc->activeRecord->multiSRC)); ->execute($dc->activeRecord->id.'|%', 'galpic');
} else { $this->Database->prepare("DELETE FROM tl_rateit_items WHERE rkey LIKE ? AND typ=?")->execute($dc->activeRecord->id.'|%', 'galpic');
$objFiles = \FilesModel::findMultipleByIds(deserialize($dc->activeRecord->multiSRC));
}
// Get all images
while ($objFiles->next()) {
// Single files
if ($objFiles->type == 'file') {
$objFile = new \File($objFiles->path, true);
if (!$objFile->isGdImage) {
continue;
}
$rkey = $dc->activeRecord->id.'_'.$objFiles->id;
$this->Database->prepare("DELETE FROM tl_rateit_items WHERE rkey=? and typ=?")
->execute($rkey, 'galpic');
}
// Folders
else {
if (version_compare(VERSION, '3.2', '>=')) {
$objSubfiles = \FilesModel::findByPid($objFiles->uuid);
} else {
$objSubfiles = \FilesModel::findByPid($objFiles->id);
}
if ($objSubfiles === null) {
continue;
}
while ($objSubfiles->next()) {
// Skip subfolders
if ($objSubfiles->type == 'folder') {
continue;
}
$objFile = new \File($objSubfiles->path, true);
if (!$objFile->isGdImage) {
continue;
}
$rkey = $dc->activeRecord->id.'_'.$objSubfiles->id;
$this->Database->prepare("DELETE FROM tl_rateit_items WHERE rkey=? and typ=?")
->execute($rkey, 'galpic');
}
}
}
return true; return true;
} else { } else {
return $this->deleteRatingKey($dc, 'ce'); return $this->deleteRatingKey($dc, 'ce');

View File

@ -65,7 +65,7 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['rateit_types'] = array
'label' => &$GLOBALS['TL_LANG']['tl_module']['rateit_types'], 'label' => &$GLOBALS['TL_LANG']['tl_module']['rateit_types'],
'exclude' => true, 'exclude' => true,
'inputType' => 'checkboxWizard', 'inputType' => 'checkboxWizard',
'options' => array('page', 'article', 'ce', 'module', 'news', 'faq', 'galpic'), 'options' => array('page', 'article', 'ce', 'module', 'news', 'faq', 'galpic', 'news4ward'),
'eval' => array('multiple'=>true, 'mandatory'=>true), 'eval' => array('multiple'=>true, 'mandatory'=>true),
'reference' => &$GLOBALS['TL_LANG']['tl_module']['rateit_types'], 'reference' => &$GLOBALS['TL_LANG']['tl_module']['rateit_types'],
'sql' => "varchar(255) NOT NULL default ''" 'sql' => "varchar(255) NOT NULL default ''"

View File

@ -38,7 +38,7 @@ $GLOBALS['TL_LANG']['tl_module']['rateit_legend'] = 'Rate It-Einstellungen';
*/ */
$GLOBALS['TL_LANG']['tl_module']['rateit_title'] = array('Titel der Bewertung', 'Titel der Bewertung (wird im Backend angezeigt).'); $GLOBALS['TL_LANG']['tl_module']['rateit_title'] = array('Titel der Bewertung', 'Titel der Bewertung (wird im Backend angezeigt).');
$GLOBALS['TL_LANG']['tl_module']['rateit_active'] = array('Aktiv', 'Aktiv bedeutet, dass die Bewertung sichtbar für den Frontend-Nutzer ist.'); $GLOBALS['TL_LANG']['tl_module']['rateit_active'] = array('Aktiv', 'Aktiv bedeutet, dass die Bewertung sichtbar für den Frontend-Nutzer ist.');
$GLOBALS['TL_LANG']['tl_module']['rateit_types'] = array('Seite', 'Artikel', 'Inhaltselement', 'Modul', 'Nachrichten', 'FAQ', 'Galeriebild'); $GLOBALS['TL_LANG']['tl_module']['rateit_types'] = array('Typen', 'Art der Bewertung');
$GLOBALS['TL_LANG']['tl_module']['rateit_count'] = array('Max. Anzahl', 'Max. Anzahl anzuzeigender Einträge.'); $GLOBALS['TL_LANG']['tl_module']['rateit_count'] = array('Max. Anzahl', 'Max. Anzahl anzuzeigender Einträge.');
$GLOBALS['TL_LANG']['tl_module']['rateit_toptype'] = array('Art der Liste', 'Die x bestbewerteten Einträge oder die x meistbewerteten Einträge.'); $GLOBALS['TL_LANG']['tl_module']['rateit_toptype'] = array('Art der Liste', 'Die x bestbewerteten Einträge oder die x meistbewerteten Einträge.');
$GLOBALS['TL_LANG']['tl_module']['rateit_template'] = array('Template', 'Hier können Sie das Template für die Bewertung des Artikels auswählen.'); $GLOBALS['TL_LANG']['tl_module']['rateit_template'] = array('Template', 'Hier können Sie das Template für die Bewertung des Artikels auswählen.');
@ -50,6 +50,7 @@ $GLOBALS['TL_LANG']['tl_module']['rateit_types']['module'] = 'Modul';
$GLOBALS['TL_LANG']['tl_module']['rateit_types']['news'] = 'Nachrichten'; $GLOBALS['TL_LANG']['tl_module']['rateit_types']['news'] = 'Nachrichten';
$GLOBALS['TL_LANG']['tl_module']['rateit_types']['faq'] = 'FAQ'; $GLOBALS['TL_LANG']['tl_module']['rateit_types']['faq'] = 'FAQ';
$GLOBALS['TL_LANG']['tl_module']['rateit_types']['galpic'] = 'Galeriebild'; $GLOBALS['TL_LANG']['tl_module']['rateit_types']['galpic'] = 'Galeriebild';
$GLOBALS['TL_LANG']['tl_module']['rateit_types']['news4ward'] = 'Beitrag';
$GLOBALS['TL_LANG']['tl_module']['rateit_toptype']['best'] = 'Beste Bewertungen'; $GLOBALS['TL_LANG']['tl_module']['rateit_toptype']['best'] = 'Beste Bewertungen';
$GLOBALS['TL_LANG']['tl_module']['rateit_toptype']['most'] = 'Meiste Bewertungen'; $GLOBALS['TL_LANG']['tl_module']['rateit_toptype']['most'] = 'Meiste Bewertungen';

View File

@ -50,6 +50,7 @@ $GLOBALS['TL_LANG']['tl_module']['rateit_types']['module'] = 'Module';
$GLOBALS['TL_LANG']['tl_module']['rateit_types']['news'] = 'News'; $GLOBALS['TL_LANG']['tl_module']['rateit_types']['news'] = 'News';
$GLOBALS['TL_LANG']['tl_module']['rateit_types']['faq'] = 'FAQ'; $GLOBALS['TL_LANG']['tl_module']['rateit_types']['faq'] = 'FAQ';
$GLOBALS['TL_LANG']['tl_module']['rateit_types']['galpic'] = 'Gallery Picture'; $GLOBALS['TL_LANG']['tl_module']['rateit_types']['galpic'] = 'Gallery Picture';
$GLOBALS['TL_LANG']['tl_module']['rateit_types']['news4ward'] = 'Blog entry';
$GLOBALS['TL_LANG']['tl_module']['rateit_toptype']['best'] = 'Best votes'; $GLOBALS['TL_LANG']['tl_module']['rateit_toptype']['best'] = 'Best votes';
$GLOBALS['TL_LANG']['tl_module']['rateit_toptype']['most'] = 'Most votes'; $GLOBALS['TL_LANG']['tl_module']['rateit_toptype']['most'] = 'Most votes';

View File

@ -312,9 +312,10 @@ function doRateIt() {
el.data('selected', el.find('.rateItRating-selected')); el.data('selected', el.find('.rateItRating-selected'));
el.data('hover', el.find('.rateItRating-hover')); el.data('hover', el.find('.rateItRating-hover'));
var backgroundImage = self.getBackgroundImage(el.data('wrapper')); jQuery.when(self.getBackgroundImage(el.data('wrapper'))).done(function(backgroundImageSize) {
self.options.starwidth = backgroundImage.width; self.options.starwidth = backgroundImageSize[0];
self.options.starheight = backgroundImage.height / 3; // da immer drei Sterne "übereinander" gebraucht werden self.options.starheight = backgroundImageSize[1] / 3; // da immer drei Sterne "übereinander" gebraucht werden
});
if (self.options.starwidth === undefined || self.options.starwidth < 16) { if (self.options.starwidth === undefined || self.options.starwidth < 16) {
self.options.starwidth = 16; self.options.starwidth = 16;
} }
@ -498,13 +499,21 @@ function doRateIt() {
}, },
getBackgroundImage: function(el) { getBackgroundImage: function(el) {
var dfd = jQuery.Deferred();
var backgroundImageSize = new Array();
var reg_imgFile = /url\s*\(["']?(.*)["']?\)/i; var reg_imgFile = /url\s*\(["']?(.*)["']?\)/i;
var dummy = document.createElement('img');
var string = this.getBackgroundImagePath(el); var string = this.getBackgroundImagePath(el);
string = string.match(reg_imgFile)[1]; string = string.match(reg_imgFile)[1];
string = string.replace('\"', ''); string = string.replace('\"', '');
dummy.src = string;
return dummy; jQuery('<img/>')
.attr('src', string)
.load(function() {
backgroundImageSize.push(this.width);
backgroundImageSize.push(this.height);
dfd.resolve(backgroundImageSize);
});
return dfd.promise();
}, },
updateText: function(el, text) { updateText: function(el, text) {

File diff suppressed because one or more lines are too long

View File

@ -133,8 +133,19 @@ class RateIt extends \Frontend {
->count(); ->count();
// Die with an error if the insert fails (duplicate IP or duplicate member id for a vote). // Die with an error if the insert fails (duplicate IP or duplicate member id for a vote).
if (((!$this->allowDuplicates && $countIp == 0) || $this->allowDuplicates) || if ((!$this->allowDuplicatesForMembers && (isset($countUser) ? $countUser == 0 : false)) || ($this->allowDuplicatesForMembers && isset($userId))) {
((!$this->allowDuplicatesForMembers && (isset($countUser) ? $countUser == 0 : false)) || ($this->allowDuplicatesForMembers && isset($userId)))) { // Insert the data.
$arrSet = array('pid' => $ratableKeyId['id'],
'tstamp' => time(),
'ip_address' => $ip,
'memberid' => isset($userId) ? $userId : null,
'rating' => $rating,
'createdat'=> time()
);
$this->Database->prepare('INSERT INTO tl_rateit_ratings %s')
->set($arrSet)
->execute();
} elseif (!isset($countUser) && ((!$this->allowDuplicates && $countIp == 0) || $this->allowDuplicates)) {
// Insert the data. // Insert the data.
$arrSet = array('pid' => $ratableKeyId['id'], $arrSet = array('pid' => $ratableKeyId['id'],
'tstamp' => time(), 'tstamp' => time(),
@ -147,7 +158,7 @@ class RateIt extends \Frontend {
->set($arrSet) ->set($arrSet)
->execute(); ->execute();
} else { } else {
header(RETURN_AJAX_HEADER); header(RETURN_AJAX_HEADER);
echo $GLOBALS['TL_LANG']['rateit']['error']['duplicate_vote']; echo $GLOBALS['TL_LANG']['rateit']['error']['duplicate_vote'];
exit; exit;
} }