Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
a6f5648fbd | |||
65bbc92119 | |||
61b4ea3613 | |||
290ac55974 | |||
121168f005 | |||
8cc7a80182 | |||
b1934458fd | |||
0bcf4fbed4 | |||
e2a1ac4dbf | |||
19feefda83 | |||
90a65bcc43 |
@ -90,7 +90,7 @@ class DcaHelper extends \Backend
|
||||
}
|
||||
} else {
|
||||
$this->Database->prepare("UPDATE tl_rateit_items SET active='' WHERE rkey=? and typ=?")
|
||||
->execute($dc->activeRecord->id, $typ)
|
||||
->execute($dc->activeRecord->id, $type)
|
||||
->updatedId;
|
||||
|
||||
}
|
||||
|
@ -633,13 +633,9 @@ class rateitBackendModule extends \BackendModule
|
||||
|
||||
$cntSql = str_replace('%s', $where, $cntSql);
|
||||
|
||||
$count = $this->Database->prepare($cntSql)
|
||||
->execute()
|
||||
->fetchRow();
|
||||
$count = $this->Database->query($cntSql)->fetchRow();
|
||||
|
||||
$arrRatingItems = $this->Database->prepare($sql)
|
||||
->execute()
|
||||
->fetchAllAssoc();
|
||||
$arrRatingItems = $this->Database->query($sql)->fetchAllAssoc();
|
||||
$arrReturn = array();
|
||||
foreach ($arrRatingItems as $rating) {
|
||||
if ($rating['active'] != '1') $rating['active'] = '0';
|
||||
|
@ -115,7 +115,7 @@ class RateItFrontend extends \Hybrid
|
||||
$this->loadLanguageFile('default');
|
||||
$stars = $this->percentToStars($rating['rating']);
|
||||
preg_match('/^.*\[(.+)\|(.+)\].*$/i', $GLOBALS['TL_CONFIG']['rating_description'], $labels);
|
||||
if (!is_array($labels) || !count($labels) == 2 || !count($labels) == 3) {
|
||||
if (!is_array($labels) && (!count($labels) == 2 || !count($labels) == 3)) {
|
||||
$label = ($rating[totalRatings] > 1 || $rating[totalRatings] == 0) || !$rating ? $GLOBALS['TL_LANG']['rateit']['rating_label'][1] : $GLOBALS['TL_LANG']['rateit']['rating_label'][0];
|
||||
$description = '%current%/%max% %type% (%count% ['.$GLOBALS['TL_LANG']['tl_rateit']['vote'][0].'|'.$GLOBALS['TL_LANG']['tl_rateit']['vote'][1].'])';
|
||||
} else {
|
||||
|
41
composer.json
Normal file
41
composer.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"name":"cgo-it/rate-it",
|
||||
"description":"RateIt extension for the Contao Open Source CMS",
|
||||
"keywords":["contao", "rating", "rateit", "bewertung"],
|
||||
"type":"contao-module",
|
||||
"license":"LGPL-3.0+",
|
||||
"authors":[
|
||||
{
|
||||
"name":"cgo IT",
|
||||
"email":"info@cgo-it.de",
|
||||
"homepage":"https://cgo-it.de",
|
||||
"role":"Developer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"email": "info@cgo-it.de",
|
||||
"issues": "https://bitbucket.org/cgo-it/contao-rate-it/issues?status=new&status=open",
|
||||
"forum": "https://community.contao.org/de/showthread.php?38471-Rate-It",
|
||||
"source": "https://bitbucket.org/cgo-it/contao-rate-it/src"
|
||||
},
|
||||
"require":{
|
||||
"php":">=5.3",
|
||||
"contao/core":">=3.0",
|
||||
"contao-community-alliance/composer-plugin": "~2.0",
|
||||
"leounglaub/contao-simple-ajax":"3.2.x-dev",
|
||||
"cgo-it/xls_export":"3.0.0"
|
||||
},
|
||||
"replace": {
|
||||
"cgo-it/rate-it": "<3.4.3"
|
||||
},
|
||||
"conflict": {
|
||||
"contao/core": "2.11.*"
|
||||
},
|
||||
"extra":{
|
||||
"contao": {
|
||||
"sources":{
|
||||
"":"system/modules/rateit"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -75,6 +75,9 @@ class tl_content_rateit extends rateit\DcaHelper {
|
||||
if ($dc->activeRecord->type == "gallery") {
|
||||
$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', '>=')) {
|
||||
$objFiles = \FilesModel::findMultipleByUuids(deserialize($dc->activeRecord->multiSRC));
|
||||
} else {
|
||||
@ -131,56 +134,9 @@ class tl_content_rateit extends rateit\DcaHelper {
|
||||
|
||||
public function delete(\DC_Table $dc) {
|
||||
if ($dc->activeRecord->type == "gallery") {
|
||||
if (version_compare(VERSION, '3.2', '>=')) {
|
||||
$objFiles = \FilesModel::findMultipleByUuids(deserialize($dc->activeRecord->multiSRC));
|
||||
} else {
|
||||
$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');
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->Database->prepare("DELETE FROM tl_rateit_ratings WHERE pid IN (SELECT `id` FROM tl_rateit_items WHERE rkey LIKE ? AND typ=?)")
|
||||
->execute($dc->activeRecord->id.'|%', 'galpic');
|
||||
$this->Database->prepare("DELETE FROM tl_rateit_items WHERE rkey LIKE ? AND typ=?")->execute($dc->activeRecord->id.'|%', 'galpic');
|
||||
return true;
|
||||
} else {
|
||||
return $this->deleteRatingKey($dc, 'ce');
|
||||
|
@ -65,7 +65,7 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['rateit_types'] = array
|
||||
'label' => &$GLOBALS['TL_LANG']['tl_module']['rateit_types'],
|
||||
'exclude' => true,
|
||||
'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),
|
||||
'reference' => &$GLOBALS['TL_LANG']['tl_module']['rateit_types'],
|
||||
'sql' => "varchar(255) NOT NULL default ''"
|
||||
|
@ -67,6 +67,7 @@ $GLOBALS['TL_LANG']['tl_rateit_type_options']['faq'] = 'FAQ';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_type_options']['ce'] = 'Inhaltselement';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_type_options']['module'] = 'Modul';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_type_options']['galpic'] = 'Galerie-Bild';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_type_options']['news4ward'] = 'Beitrag';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_order_options']['rating desc'] = 'Bewertung';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_order_options']['title'] = 'Titel';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_order_options']['typ'] = 'Typ';
|
||||
|
@ -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_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_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.');
|
||||
@ -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']['faq'] = 'FAQ';
|
||||
$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']['most'] = 'Meiste Bewertungen';
|
||||
|
@ -67,6 +67,7 @@ $GLOBALS['TL_LANG']['tl_rateit_type_options']['faq'] = 'FAQ';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_type_options']['ce'] = 'Content element';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_type_options']['module'] = 'Module';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_type_options']['galpic'] = 'Gallery picture';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_type_options']['news4ward'] = 'Blog entry';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_order_options']['rating desc'] = 'Rating';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_order_options']['title'] = 'Title';
|
||||
$GLOBALS['TL_LANG']['tl_rateit_order_options']['typ'] = 'Type';
|
||||
|
@ -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']['faq'] = 'FAQ';
|
||||
$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']['most'] = 'Most votes';
|
||||
|
@ -90,6 +90,7 @@
|
||||
.mod_rateit table.rating td.type-faq { background-color:#ffe0aa; }
|
||||
.mod_rateit table.rating td.type-article { background-color:#ffcce0; }
|
||||
.mod_rateit table.rating td.type-galpic { background-color:#ffe066; }
|
||||
.mod_rateit table.rating td.type-news4ward { background-color:#ffe011; }
|
||||
.mod_rateit table.rating td.active-1, .mod_rateit table.rating td.type-page { background-color:#e0ffe0; }
|
||||
.mod_rateit table.rating td.
|
||||
|
||||
|
@ -212,7 +212,7 @@ function doRateIt() {
|
||||
getStarPercent: function(id) {
|
||||
/* Format = anyStringHere-<id>-<float(currentStars)>_(scale);
|
||||
* Example: RateItRatings-5-3_5 //Primary key id = 5, 3/5 stars. */
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
if (stars != null) {
|
||||
var score = stars[3].toFloat();
|
||||
var scale = stars[4].toFloat();
|
||||
@ -236,17 +236,17 @@ function doRateIt() {
|
||||
},
|
||||
|
||||
getRatableId: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? stars[1] : '';
|
||||
},
|
||||
|
||||
getRatableType: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? stars[2] : '';
|
||||
},
|
||||
|
||||
getRatableMaxValue: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? stars[4].toInt() : 0;
|
||||
},
|
||||
|
||||
@ -312,9 +312,10 @@ function doRateIt() {
|
||||
el.data('selected', el.find('.rateItRating-selected'));
|
||||
el.data('hover', el.find('.rateItRating-hover'));
|
||||
|
||||
var backgroundImage = self.getBackgroundImage(el.data('wrapper'));
|
||||
self.options.starwidth = backgroundImage.width;
|
||||
self.options.starheight = backgroundImage.height / 3; // da immer drei Sterne "übereinander" gebraucht werden
|
||||
jQuery.when(self.getBackgroundImage(el.data('wrapper'))).done(function(backgroundImageSize) {
|
||||
self.options.starwidth = backgroundImageSize[0];
|
||||
self.options.starheight = backgroundImageSize[1] / 3; // da immer drei Sterne "übereinander" gebraucht werden
|
||||
});
|
||||
if (self.options.starwidth === undefined || self.options.starwidth < 16) {
|
||||
self.options.starwidth = 16;
|
||||
}
|
||||
@ -451,7 +452,7 @@ function doRateIt() {
|
||||
getStarPercent: function(id) {
|
||||
/* Format = anyStringHere-<id>-<float(currentStars)>_(scale);
|
||||
* Example: RateItRatings-5-3_5 //Primary key id = 5, 3/5 stars. */
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
if (stars != null) {
|
||||
var score = parseFloat(stars[3]);
|
||||
var scale = parseFloat(stars[4]);
|
||||
@ -475,17 +476,17 @@ function doRateIt() {
|
||||
},
|
||||
|
||||
getRatableId: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? stars[1] : '';
|
||||
},
|
||||
|
||||
getRatableType: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? stars[2] : '';
|
||||
},
|
||||
|
||||
getRatableMaxValue: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? parseInt(stars[4]) : 0;
|
||||
},
|
||||
|
||||
@ -498,13 +499,21 @@ function doRateIt() {
|
||||
},
|
||||
|
||||
getBackgroundImage: function(el) {
|
||||
var dfd = jQuery.Deferred();
|
||||
var backgroundImageSize = new Array();
|
||||
var reg_imgFile = /url\s*\(["']?(.*)["']?\)/i;
|
||||
var dummy = document.createElement('img');
|
||||
var string = this.getBackgroundImagePath(el);
|
||||
string = string.match(reg_imgFile)[1];
|
||||
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) {
|
||||
|
File diff suppressed because one or more lines are too long
@ -98,7 +98,7 @@ class RateIt extends \Frontend {
|
||||
}
|
||||
|
||||
//Make sure that the ratable type is 'page' or 'ce' or 'module'
|
||||
if (!($type === 'page' || $type === 'article' || $type === 'ce' || $type === 'module' || $type === 'news' || $type === 'faq' || $type === 'galpic')) {
|
||||
if (!($type === 'page' || $type === 'article' || $type === 'ce' || $type === 'module' || $type === 'news' || $type === 'faq' || $type === 'galpic' || $type === 'news4ward')) {
|
||||
header(RETURN_AJAX_HEADER);
|
||||
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_type'];
|
||||
exit;
|
||||
@ -133,8 +133,19 @@ class RateIt extends \Frontend {
|
||||
->count();
|
||||
|
||||
// Die with an error if the insert fails (duplicate IP or duplicate member id for a vote).
|
||||
if (((!$this->allowDuplicates && $countIp == 0) || $this->allowDuplicates) ||
|
||||
((!$this->allowDuplicatesForMembers && (isset($countUser) ? $countUser == 0 : false)) || ($this->allowDuplicatesForMembers && isset($userId)))) {
|
||||
if ((!$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.
|
||||
$arrSet = array('pid' => $ratableKeyId['id'],
|
||||
'tstamp' => time(),
|
||||
|
@ -66,7 +66,6 @@
|
||||
</div>
|
||||
<?php if ($this->rateit_rating_after): ?>
|
||||
<!-- indexer::stop -->
|
||||
<div itemtype="http://data-vocabulary.org/Review-aggregate" itemscope="" class="rating-microdata">
|
||||
<div id="<?php echo $this->id; ?>" class="<?php echo $this->class; ?> <?php echo $this->rateit_class; ?>">
|
||||
<?php if ($this->showBefore) : ?>
|
||||
<div id="<?php echo $this->descriptionId; ?>" class="ratingText"><?php echo $this->description; ?></div>
|
||||
@ -79,12 +78,5 @@
|
||||
<div id="<?php echo $this->descriptionId; ?>" class="ratingText"><?php echo $this->description; ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<span class="rating-microdata" itemprop="itemreviewed"><?php echo $this->itemreviewed; ?></span>
|
||||
<span class="rating-microdata" itemtype="http://data-vocabulary.org/Rating" itemscope="" itemprop="rating">
|
||||
<span itemprop="average"><?php echo $this->actRating; ?></span>
|
||||
<span itemprop="best"><?php echo $this->maxRating; ?></span>
|
||||
</span>
|
||||
<span class="rating-microdata" itemprop="votes"><?php echo $this->votes; ?></span>
|
||||
</div>
|
||||
<!-- indexer::continue -->
|
||||
<?php endif; ?>
|
||||
|
Reference in New Issue
Block a user