14 Commits
3.5.4 ... 4.0.0

123 changed files with 489 additions and 619 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/.project
/vendor

View File

@ -1,8 +1,9 @@
{ {
"name":"cgo-it/rate-it", "name":"cgo-it/contao-rate-it-bundle",
"description":"RateIt extension for the Contao Open Source CMS", "description":"RateIt extension for the Contao Open Source CMS as contao 4 bundle",
"keywords":["contao", "rating", "rateit", "bewertung"], "keywords":["contao", "rating", "rateit", "bewertung", "bundle"],
"type":"contao-module", "type":"contao-bundle",
"homepage":"https://cgo-it.de",
"license":"LGPL-3.0+", "license":"LGPL-3.0+",
"authors":[ "authors":[
{ {
@ -13,34 +14,41 @@
} }
], ],
"support": { "support": {
"email": "info@cgo-it.de", "issues": "https://git.cgo-it.de/contao/rate-it/issues",
"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", "forum": "https://community.contao.org/de/showthread.php?38471-Rate-It",
"source": "https://bitbucket.org/cgo-it/contao-rate-it/src" "source": "https://git.cgo-it.de/contao/rate-it.git"
}, },
"require":{ "require":{
"php":">=5.3", "php":">=7.0",
"contao/core":">=3.0", "contao/core-bundle": "^4.4",
"contao-community-alliance/composer-plugin": "~2.0", "cgo-it/contao-xls_export-bundle": "^4.0",
"cgo-it/xls_export":"3.0.0" "richardhj/contao-simple-ajax": "^1.3"
}, },
"replace": { "require-dev": {
"cgo-it/rate-it": "<3.5.4" "contao/manager-plugin": "^2.0"
}, },
"conflict": { "conflict": {
"contao/core": "2.11.*" "contao/core": "*",
"contao/manager-plugin": "<2.0 || >=3.0"
}, },
"extra":{ "autoload": {
"psr-4": {
"cgoIT\\rateit\\": "src/"
},
"classmap": [
"src/Resources/contao/"
],
"exclude-from-classmap": [
"src/Resources/contao/config/",
"src/Resources/contao/dca/",
"src/Resources/contao/languages/",
"src/Resources/contao/templates/"
]
},
"extra": {
"contao": { "contao": {
"sources":{ "runonce": ["src/Resources/contao/runonce/create-initial-data.php"]
"":"system/modules/rateit" },
}, "contao-manager-plugin": "cgoIT\\rateit\\ContaoManagerPlugin"
"transifex":{
"project": "rateit",
"prefix": "core-",
"languages_cto": "languages",
"languages_tx": "languages"
}
}
} }
} }

View File

@ -1,7 +0,0 @@
;;
; Configure what you want the autoload creator to register
;;
register_namespaces = true
register_classes = true
register_templates = true

View File

@ -1,73 +0,0 @@
<?php
/**
* Contao Open Source CMS
*
* Copyright (c) 2005-2014 Leo Feyer
*
* @package Rateit
* @link https://contao.org
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
*/
/**
* Register the namespaces
*/
ClassLoader::addNamespaces(array
(
'cgoIT',
));
/**
* Register the classes
*/
ClassLoader::addClasses(array
(
// Classes
'cgoIT\rateit\DcaHelper' => 'system/modules/rateit/classes/DcaHelper.php',
'cgoIT\rateit\RateItArticle' => 'system/modules/rateit/classes/RateItArticle.php',
'cgoIT\rateit\RateItBackend' => 'system/modules/rateit/classes/RateItBackend.php',
'cgoIT\rateit\RateItCE' => 'system/modules/rateit/classes/RateItCE.php',
'cgoIT\rateit\RateItFaq' => 'system/modules/rateit/classes/RateItFaq.php',
'cgoIT\rateit\RateItFrontend' => 'system/modules/rateit/classes/RateItFrontend.php',
'cgoIT\rateit\RateItHybrid' => 'system/modules/rateit/classes/RateItHybrid.php',
'cgoIT\rateit\RateItModule' => 'system/modules/rateit/classes/RateItModule.php',
'cgoIT\rateit\RateItNews' => 'system/modules/rateit/classes/RateItNews.php',
'cgoIT\rateit\RateItPage' => 'system/modules/rateit/classes/RateItPage.php',
'cgoIT\rateit\RateItRating' => 'system/modules/rateit/classes/RateItRating.php',
'cgoIT\rateit\RateItBackendModule' => 'system/modules/rateit/classes/RateItBackendModule.php',
'cgoIT\rateit\RateItTopRatingsModule' => 'system/modules/rateit/classes/RateItTopRatingsModule.php',
'cgoIT\rateit\RateIt' => 'system/modules/rateit/public/php/rateit.php',
'simple_html_dom' => 'system/modules/rateit/classes/extern/simple_html_dom.php',
));
/**
* Register the templates
*/
TemplateLoader::addFiles(array
(
'article_rateit_default' => 'system/modules/rateit/templates',
'article_rateit_default_microdata' => 'system/modules/rateit/templates',
'gallery_rateit_default' => 'system/modules/rateit/templates',
'j_colorbox_rateit' => 'system/modules/rateit/templates',
'mod_article_list_rateit' => 'system/modules/rateit/templates',
'mod_article_rateit_default_microdata_teaser' => 'system/modules/rateit/templates',
'mod_article_rateit_default_teaser' => 'system/modules/rateit/templates',
'mod_rateit_top_ratings' => 'system/modules/rateit/templates',
'moo_mediabox_rateit' => 'system/modules/rateit/templates',
'news_full_rateit' => 'system/modules/rateit/templates',
'news_full_rateit_microdata' => 'system/modules/rateit/templates',
'news_latest_rateit' => 'system/modules/rateit/templates',
'news_latest_rateit_microdata' => 'system/modules/rateit/templates',
'news_short_rateit' => 'system/modules/rateit/templates',
'news_short_rateit_microdata' => 'system/modules/rateit/templates',
'news_simple_rateit' => 'system/modules/rateit/templates',
'news_simple_rateit_microdata' => 'system/modules/rateit/templates',
'rateitbe_ratinglist' => 'system/modules/rateit/templates',
'rateitbe_ratingview' => 'system/modules/rateit/templates',
'rateit_default' => 'system/modules/rateit/templates',
'rateit_microdata' => 'system/modules/rateit/templates',
));

View File

@ -1,139 +0,0 @@
<?php
/**
* Contao Open Source CMS
* Copyright (C) 2005-2011 Leo Feyer
*
* Formerly known as TYPOlight Open Source CMS.
*
* This program is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, please visit the Free
* Software Foundation website at <http://www.gnu.org/licenses/>.
*
* PHP version 5
* @copyright Leo Unglaub 2012
* @author Leo Unglaub <leo@leo-unglaub.net>
* @package simple_ajax
* @license LGPL
*/
// simple trick for Contao < 2.10
$arrPost = $_POST;
unset($_POST);
// inizialize the contao framework
define('TL_MODE', 'FE');
require('../../../../initialize.php');
// write the post data back into the array
$_POST = $arrPost;
/**
* Class RateitAjax
* Contain methods to catch ajax requests and send responses back to the client.
*
* Description
* ```````````
*
* The usage of the RateitAjax extensions is very easy. The extension provides
* the hook $GLOBALS['TL_HOOKS']['rateitAjax'] for extension developers. You
* simply have to register your class/method and the extension will call
* your class if there is an incomming ajax request.
*
* You simply have to deside if it's an ajax request for your module and return
* the data you want.
*
* There are a few thinks you should know about the extension:
* * YOU have the full controll over the response. That also means
* that you have to set the correct header.
* * YOU have to terminate the request after you have send the response.
* * If the ajax request is not for your method you simply have nothing to
* * return.
*
*
* Usage
* `````
* // config.php
* $GLOBALS['TL_HOOKS']['rateitAjax'][] = array('MyClass', 'myMethod');
*
* // MyClass.php
* class MyClass extends System
* {
* public function myMethod()
* {
* if ($this->Input->get('acid') == 'myrequest')
* {
* $arrReturn = array('foo', 'bar', 'foobar');
*
* header('Content-Type: application/json');
* echo json_encode($arrReturn);
* exit;
* }
* }
* }
*/
class RateitAjax extends Controller
{
/**
* Call the parent constructor.
*
* !!! DON'T REMOVE THIS !!!
*
* If you remove this you get the following error message:
* Fatal error: Call to protected System::__construct() from invalid
* context
*
* @param void
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Get the ajax request and call all hooks
*
* @param void
* @return void
*/
public function run()
{
// check if a hook is registered
if (is_array($GLOBALS['TL_HOOKS']['rateitAjax']) && count($GLOBALS['TL_HOOKS']['rateitAjax']) > 0)
{
// execute every registered callback
foreach ($GLOBALS['TL_HOOKS']['rateitAjax'] as $callback)
{
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}();
}
}
// if there is no other output, we generate a 412 error response
header('HTTP/1.1 412 Precondition Failed');
die('Rateit Ajax: Invalid AJAX call.');
}
}
// create a rateit-ajax instance and run it
$objRateitAjax = new RateitAjax();
$objRateitAjax->run();
?>

14
src/CgoITRateItBundle.php Normal file
View File

@ -0,0 +1,14 @@
<?php
namespace cgoIT\rateit;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* Configures the Contao aeo bundle.
*
* @author Carsten Götzinger
*/
class CgoITRateItBundle extends Bundle
{
}

View File

@ -0,0 +1,28 @@
<?php
namespace cgoIT\rateit;
use Contao\CoreBundle\ContaoCoreBundle;
use Contao\ManagerPlugin\Bundle\Config\BundleConfig;
use Contao\ManagerPlugin\Bundle\BundlePluginInterface;
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface;
/**
* Plugin for the Contao Manager.
*
* @author Carsten Götzinger
*/
class ContaoManagerPlugin implements BundlePluginInterface
{
/**
* {@inheritdoc}
*/
public function getBundles(ParserInterface $parser)
{
return [
BundleConfig::create(CgoITRateItBundle::class)
->setLoadAfter([ContaoCoreBundle::class])
->setReplace(['rate-it']),
];
}
}

View File

@ -30,18 +30,23 @@
namespace cgoIT\rateit; namespace cgoIT\rateit;
define(RETURN_AJAX_HEADER, 'Content-Type: text/html'); use cgoIT\rateit\RateItFrontend;
use SimpleAjax\Event\SimpleAjax;
use Symfony\Component\HttpFoundation\JsonResponse;
class RateIt extends \Frontend {
class RateIt extends \Frontend {
var $allowDuplicates = false; var $allowDuplicates = false;
var $rateItFrontend;
/** /**
* Initialize the controller * Initialize the controller
*/ */
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
$this->rateItFrontend = new RateItFrontend();
$this->loadLanguageFile('default'); $this->loadLanguageFile('default');
$this->allowDuplicates = $GLOBALS['TL_CONFIG']['rating_allow_duplicate_ratings']; $this->allowDuplicates = $GLOBALS['TL_CONFIG']['rating_allow_duplicate_ratings'];
$this->allowDuplicatesForMembers = $GLOBALS['TL_CONFIG']['rating_allow_duplicate_ratings_for_members']; $this->allowDuplicatesForMembers = $GLOBALS['TL_CONFIG']['rating_allow_duplicate_ratings_for_members'];
@ -57,72 +62,80 @@ class RateIt extends \Frontend {
* such, it unitlizes the die() function to display its errors. THIS * such, it unitlizes the die() function to display its errors. THIS
* WOULD BE A VERY BAD FUNCTION TO CALL FROM WITHIN ANOTHER PAGE. * WOULD BE A VERY BAD FUNCTION TO CALL FROM WITHIN ANOTHER PAGE.
* *
* @param integer id - The id of key to register a rating for. * @param integer id - The id of key to register a rating for.
* @param integer percent - The rating in percentages. * @param integer percent - The rating in percentages.
*/ */
function doVote() { public function doVote(SimpleAjax $event) {
if ($this->Input->get('do') == 'rateit') { $input = $event->getEnvironment()->getInputProvider();
if ((true === $input->hasParameter('do'))
&& ('rateit' === $input->getParameter('do'))
) {
$ip = $_SERVER['REMOTE_ADDR']; $ip = $_SERVER['REMOTE_ADDR'];
$rkey = $this->Input->post('id'); $rkey = $input->getParameter('id');
$percent = $this->Input->post('vote'); $percent = $input->getParameter('vote');
$type = $this->Input->post('type'); $type = $input->getParameter('type');
//Make sure that the ratable ID is a number and not something crazy. //Make sure that the ratable ID is a number and not something crazy.
if (strstr($rkey, '|')) { if (strstr($rkey, '|')) {
$arrRkey = explode('|', $rkey); $arrRkey = explode('|', $rkey);
foreach ($arrRkey as $key) { foreach ($arrRkey as $key) {
if (!is_numeric($key)) { if (!is_numeric($key)) {
header(RETURN_AJAX_HEADER); $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']];
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']; $response = new JsonResponse($return);
exit; $event->setResponse($response);
return $event;
} }
$id = $rkey; $id = $rkey;
} }
} else { } else {
if (is_numeric($rkey)) { if (is_numeric($rkey)) {
$id = $rkey; $id = $rkey;
} else { } else {
header(RETURN_AJAX_HEADER); $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']];
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']; $response = new JsonResponse($return);
exit; $event->setResponse($response);
return $event;
} }
} }
//Make sure the percent is a number and under 100. //Make sure the percent is a number and under 100.
if (is_numeric($percent) && $percent < 101) { if (is_numeric($percent) && $percent < 101) {
$rating = $percent; $rating = $percent;
} else { } else {
header(RETURN_AJAX_HEADER); $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']];
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_rating']; $response = new JsonResponse($return);
exit; $event->setResponse($response);
return $event;
} }
//Make sure that the ratable type is 'page' or 'ce' or 'module' //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' || $type === 'news4ward')) { if (!($type === 'page' || $type === 'article' || $type === 'ce' || $type === 'module' || $type === 'news' || $type === 'faq' || $type === 'galpic' || $type === 'news4ward')) {
header(RETURN_AJAX_HEADER); $return = [$GLOBALS['TL_LANG']['rateit']['error']['invalid_type']];
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_type']; $response = new JsonResponse($return);
exit; $event->setResponse($response);
return $event;
} }
$strHash = sha1(session_id() . (!$GLOBALS['TL_CONFIG']['disableIpCheck'] ? \Environment::get('ip') : '') . 'FE_USER_AUTH'); $strHash = sha1(session_id() . (!$GLOBALS['TL_CONFIG']['disableIpCheck'] ? \Environment::get('ip') : '') . 'FE_USER_AUTH');
// FrontendUser auslesen // FrontendUser auslesen
if (FE_USER_LOGGED_IN) { if (FE_USER_LOGGED_IN) {
$objUser = $this->Database->prepare("SELECT pid FROM tl_session WHERE hash=?") $objUser = $this->Database->prepare("SELECT pid FROM tl_session WHERE hash=?")
->limit(1) ->limit(1)
->execute($strHash); ->execute($strHash);
if ($objUser->numRows) { if ($objUser->numRows) {
$userId = $objUser->pid; $userId = $objUser->pid;
} }
} }
$ratableKeyId = $this->Database->prepare('SELECT id FROM tl_rateit_items WHERE rkey=? and typ=?') $ratableKeyId = $this->Database->prepare('SELECT id FROM tl_rateit_items WHERE rkey=? and typ=?')
->execute($id, $type) ->execute($id, $type)
->fetchAssoc(); ->fetchAssoc();
$canVote = false; $canVote = false;
if (isset($userId)) { if (isset($userId)) {
$countUser = $this->Database->prepare('SELECT * FROM tl_rateit_ratings WHERE pid=? and memberid=?') $countUser = $this->Database->prepare('SELECT * FROM tl_rateit_ratings WHERE pid=? and memberid=?')
@ -132,7 +145,7 @@ class RateIt extends \Frontend {
$countIp = $this->Database->prepare('SELECT * FROM tl_rateit_ratings WHERE pid=? and ip_address=?') $countIp = $this->Database->prepare('SELECT * FROM tl_rateit_ratings WHERE pid=? and ip_address=?')
->execute($ratableKeyId['id'], $ip) ->execute($ratableKeyId['id'], $ip)
->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->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. // Insert the data.
@ -151,7 +164,7 @@ class RateIt extends \Frontend {
$arrSet = array('pid' => $ratableKeyId['id'], $arrSet = array('pid' => $ratableKeyId['id'],
'tstamp' => time(), 'tstamp' => time(),
'ip_address' => $ip, 'ip_address' => $ip,
'memberid' => isset($userId) ? $userId : null, 'memberid' => isset($userId) ? $userId : null,
'rating' => $rating, 'rating' => $rating,
'createdat'=> time() 'createdat'=> time()
); );
@ -159,19 +172,20 @@ class RateIt extends \Frontend {
->set($arrSet) ->set($arrSet)
->execute(); ->execute();
} else { } else {
header(RETURN_AJAX_HEADER); $return = [$GLOBALS['TL_LANG']['rateit']['error']['duplicate_vote']];
echo $GLOBALS['TL_LANG']['rateit']['error']['duplicate_vote']; $response = new JsonResponse($return);
exit; $event->setResponse($response);
return $event;
} }
$this->import('rateit\\RateItFrontend', 'RateItFrontend'); $rating = $this->rateItFrontend->loadRating($id, $type);
$rating = $this->RateItFrontend->loadRating($id, $type);
$return = [$this->rateItFrontend->getStarMessage($rating)];
header(RETURN_AJAX_HEADER); $response = new JsonResponse($return);
echo $this->RateItFrontend->getStarMessage($rating); $event->setResponse($response);
exit; return $event;
} }
} }
} }
?> ?>

View File

@ -90,15 +90,15 @@ class RateItArticle extends RateItFrontend {
$objTemplate->rateit_rating_after = true; $objTemplate->rateit_rating_after = true;
} }
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/onReadyRateIt.js|static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/rateit.js|static';
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/rateit.min.css||static';
switch ($GLOBALS['TL_CONFIG']['rating_type']) { switch ($GLOBALS['TL_CONFIG']['rating_type']) {
case 'hearts' : case 'hearts' :
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/heart.min.css||static';
break; break;
default: default:
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/star.min.css||static';
} }
} }
@ -114,7 +114,7 @@ class RateItArticle extends RateItFrontend {
->limit(1) ->limit(1)
->execute($article['articleId']) ->execute($article['articleId'])
->fetchAssoc(); ->fetchAssoc();
if ($arrArticle['addRating']) { if ($arrArticle['addRating']) {
if (!$bolTemplateFixed) { if (!$bolTemplateFixed) {
$objTemplate->setName($objTemplate->getName().'_rateit'); $objTemplate->setName($objTemplate->getName().'_rateit');
@ -125,7 +125,7 @@ class RateItArticle extends RateItFrontend {
$rating = $this->loadRating($ratingId, 'article'); $rating = $this->loadRating($ratingId, 'article');
$stars = !$rating ? 0 : $this->percentToStars($rating['rating']); $stars = !$rating ? 0 : $this->percentToStars($rating['rating']);
$percent = round($rating['rating'], 0)."%"; $percent = round($rating['rating'], 0)."%";
$article['descriptionId'] = 'rateItRating-'.$ratingId.'-description'; $article['descriptionId'] = 'rateItRating-'.$ratingId.'-description';
$article['description'] = $this->getStarMessage($rating); $article['description'] = $this->getStarMessage($rating);
$article['rateItID'] = 'rateItRating-'.$ratingId.'-article-'.$stars.'_'.$this->intStars; $article['rateItID'] = 'rateItRating-'.$ratingId.'-article-'.$stars.'_'.$this->intStars;
@ -134,32 +134,32 @@ class RateItArticle extends RateItFrontend {
$article['actRating'] = $this->percentToStars($rating['rating']); $article['actRating'] = $this->percentToStars($rating['rating']);
$article['maxRating'] = $this->intStars; $article['maxRating'] = $this->intStars;
$article['votes'] = $rating[totalRatings]; $article['votes'] = $rating[totalRatings];
if ($this->strTextPosition == "before") { if ($this->strTextPosition == "before") {
$article['showBefore'] = true; $article['showBefore'] = true;
} }
else if ($this->strTextPosition == "after") { else if ($this->strTextPosition == "after") {
$article['showAfter'] = true; $article['showAfter'] = true;
} }
if ($arrArticle['rateit_position'] == 'before') { if ($arrArticle['rateit_position'] == 'before') {
$article['rateit_rating_before'] = true; $article['rateit_rating_before'] = true;
} else if ($arrArticle['rateit_position'] == 'after') { } else if ($arrArticle['rateit_position'] == 'after') {
$article['rateit_rating_after'] = true; $article['rateit_rating_after'] = true;
} }
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/onReadyRateIt.js|static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/rateit.js|static';
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/rateit.min.css||static';
switch ($GLOBALS['TL_CONFIG']['rating_type']) { switch ($GLOBALS['TL_CONFIG']['rating_type']) {
case 'hearts' : case 'hearts' :
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/heart.min.css||static';
break; break;
default: default:
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/star.min.css||static';
} }
} }
$arrArticles[] = $article; $arrArticles[] = $article;
} }
$objTemplate->articles = $arrArticles; $objTemplate->articles = $arrArticles;
@ -172,10 +172,10 @@ class RateItArticle extends RateItFrontend {
->limit(1) ->limit(1)
->execute($objTemplate->id) ->execute($objTemplate->id)
->fetchAssoc(); ->fetchAssoc();
if ($arrGallery['rateit_active']) { if ($arrGallery['rateit_active']) {
$arrRating = array(); $arrRating = array();
if (version_compare(VERSION, '3.2', '>=')) { if (version_compare(VERSION, '3.2', '>=')) {
$objFiles = \FilesModel::findMultipleByUuids(deserialize($arrGallery['multiSRC'])); $objFiles = \FilesModel::findMultipleByUuids(deserialize($arrGallery['multiSRC']));
} else { } else {
@ -185,19 +185,19 @@ class RateItArticle extends RateItFrontend {
if ($objFiles !== null) { if ($objFiles !== null) {
// Get all images // Get all images
while ($objFiles->next()) { while ($objFiles->next()) {
// Continue if the files has been processed or does not exist // Continue if the files has been processed or does not exist
if (isset($arrRating[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) { if (isset($arrRating[$objFiles->path]) || !file_exists(TL_ROOT . '/' . $objFiles->path)) {
continue; continue;
} }
// Single files // Single files
if ($objFiles->type == 'file') { if ($objFiles->type == 'file') {
$objFile = new \File($objFiles->path, true); $objFile = new \File($objFiles->path, true);
if (!$objFile->isGdImage) { if (!$objFile->isGdImage) {
continue; continue;
} }
$this->addRatingForImage($arrRating, $arrGallery['id'], $objFiles->id, $objFile->path); $this->addRatingForImage($arrRating, $arrGallery['id'], $objFiles->id, $objFile->path);
} }
// Folders // Folders
@ -207,23 +207,23 @@ class RateItArticle extends RateItFrontend {
} else { } else {
$objSubfiles = \FilesModel::findByPid($objFiles->id); $objSubfiles = \FilesModel::findByPid($objFiles->id);
} }
if ($objSubfiles === null) { if ($objSubfiles === null) {
continue; continue;
} }
while ($objSubfiles->next()) { while ($objSubfiles->next()) {
// Skip subfolders // Skip subfolders
if ($objSubfiles->type == 'folder') { if ($objSubfiles->type == 'folder') {
continue; continue;
} }
$objFile = new \File($objSubfiles->path, true); $objFile = new \File($objSubfiles->path, true);
if (!$objFile->isGdImage) { if (!$objFile->isGdImage) {
continue; continue;
} }
$this->addRatingForImage($arrRating, $arrGallery['id'], $objSubfiles->id, $objSubfiles->path); $this->addRatingForImage($arrRating, $arrGallery['id'], $objSubfiles->id, $objSubfiles->path);
} }
} }
@ -232,27 +232,27 @@ class RateItArticle extends RateItFrontend {
$objTemplate->arrRating = $arrRating; $objTemplate->arrRating = $arrRating;
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/onReadyRateIt.js|static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/rateit.js|static';
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/rateit.min.css||static';
switch ($GLOBALS['TL_CONFIG']['rating_type']) { switch ($GLOBALS['TL_CONFIG']['rating_type']) {
case 'hearts' : case 'hearts' :
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/heart.min.css||static';
break; break;
default: default:
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/star.min.css||static';
} }
} }
return $objTemplate; return $objTemplate;
} }
private function addRatingForImage(&$arrRating, $galleryId, $picId, $picPath) { private function addRatingForImage(&$arrRating, $galleryId, $picId, $picPath) {
$ratingId = $galleryId.'|'.$picId; $ratingId = $galleryId.'|'.$picId;
$rating = $this->loadRating($ratingId, 'galpic'); $rating = $this->loadRating($ratingId, 'galpic');
$stars = !$rating ? 0 : $this->percentToStars($rating['rating']); $stars = !$rating ? 0 : $this->percentToStars($rating['rating']);
$percent = round($rating['rating'], 0)."%"; $percent = round($rating['rating'], 0)."%";
$arrRating[$picPath] = array(); $arrRating[$picPath] = array();
$arrRating[$picPath]['descriptionId'] = 'rateItRating-'.$ratingId.'-description'; $arrRating[$picPath]['descriptionId'] = 'rateItRating-'.$ratingId.'-description';
$arrRating[$picPath]['description'] = $this->getStarMessage($rating); $arrRating[$picPath]['description'] = $this->getStarMessage($rating);
@ -262,7 +262,7 @@ class RateItArticle extends RateItFrontend {
$arrRating[$picPath]['actRating'] = $this->percentToStars($rating['rating']); $arrRating[$picPath]['actRating'] = $this->percentToStars($rating['rating']);
$arrRating[$picPath]['maxRating'] = $this->intStars; $arrRating[$picPath]['maxRating'] = $this->intStars;
$arrRating[$picPath]['votes'] = $rating[totalRatings]; $arrRating[$picPath]['votes'] = $rating[totalRatings];
if ($this->strTextPosition == "before") { if ($this->strTextPosition == "before") {
$arrRating[$picPath]['showBefore'] = true; $arrRating[$picPath]['showBefore'] = true;
} }
@ -271,4 +271,4 @@ class RateItArticle extends RateItFrontend {
} }
} }
} }
?> ?>

View File

@ -32,7 +32,7 @@ namespace cgoIT\rateit;
class RateItBackend class RateItBackend
{ {
const path = 'system/modules/rateit/'; const path = 'bundles/cgoitrateit/';
/** /**
* Get a css file. * Get a css file.
@ -41,7 +41,7 @@ class RateItBackend
*/ */
public static function css($file) public static function css($file)
{ {
return self::path.'public/css/'. $file.'.css'; return self::path.'css/'. $file.'.css';
} // file } // file
/** /**
@ -51,7 +51,7 @@ class RateItBackend
*/ */
public static function js($file) public static function js($file)
{ {
return self::path.'public/js/'. $file.'.js'; return self::path.'js/'. $file.'.js';
} // file } // file
/** /**
@ -61,7 +61,7 @@ class RateItBackend
*/ */
public static function image($file) public static function image($file)
{ {
$url = self::path.'public/images/'; $url = self::path.'images/';
if (is_file(TL_ROOT.'/'.$url.$file.'.png')) return $url.$file.'.png'; if (is_file(TL_ROOT.'/'.$url.$file.'.png')) return $url.$file.'.png';
if (is_file(TL_ROOT.'/'.$url.$file.'.gif')) return $url.$file.'.gif'; if (is_file(TL_ROOT.'/'.$url.$file.'.gif')) return $url.$file.'.gif';
return $url.'default.png'; return $url.'default.png';

View File

@ -235,7 +235,7 @@ class rateitBackendModule extends \BackendModule
*/ */
protected function exportRatings() protected function exportRatings()
{ {
$this->import('String'); $this->import('StringUtil');
$rateit = &$this->Template->rateit; $rateit = &$this->Template->rateit;
$options['order'] = 'rating desc'; $options['order'] = 'rating desc';
@ -264,11 +264,11 @@ class rateitBackendModule extends \BackendModule
// Werte setzen // Werte setzen
foreach($rateit->ratingitems as $item) { foreach($rateit->ratingitems as $item) {
$arrItem = (array)$item; $arrItem = (array)$item;
$intColCounter = 0; $intColCounter = 0;
foreach(array_keys($this->arrExportHeader) as $key) { foreach(array_keys($this->arrExportHeader) as $key) {
$strVal = $arrItem[$key]; $strVal = $arrItem[$key];
$strVal = $this->String->decodeEntities($strVal); $strVal = $this->StringUtil->decodeEntities($strVal);
$strVal = preg_replace(array('/<br.*\/*>/si'), array("\n"), $strVal); $strVal = preg_replace(array('/<br.*\/*>/si'), array("\n"), $strVal);
$strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252'); $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
@ -299,7 +299,7 @@ class rateitBackendModule extends \BackendModule
$xls->setcell(array("sheetname" => $strXlsSheet,"row" => $intRowCounter, "col" => $intColCounter, "data" => $strVal, "type" => $cellType, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL)); $xls->setcell(array("sheetname" => $strXlsSheet,"row" => $intRowCounter, "col" => $intColCounter, "data" => $strVal, "type" => $cellType, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL));
$intColCounter++; $intColCounter++;
} }
$intRowCounter++; $intRowCounter++;
} }
@ -449,7 +449,7 @@ class rateitBackendModule extends \BackendModule
'typ' => $typ 'typ' => $typ
); );
$this->import('String'); $this->import('StringUtil');
$rateit = &$this->Template->rateit; $rateit = &$this->Template->rateit;
// query ratings // query ratings
@ -480,11 +480,11 @@ class rateitBackendModule extends \BackendModule
// Werte setzen // Werte setzen
foreach($ext->ratings as $item) { foreach($ext->ratings as $item) {
$arrItem = (array)$item; $arrItem = (array)$item;
$intColCounter = 0; $intColCounter = 0;
foreach(array_keys($this->arrExportHeaderDetails) as $key) { foreach(array_keys($this->arrExportHeaderDetails) as $key) {
$strVal = $arrItem[$key]; $strVal = $arrItem[$key];
$strVal = $this->String->decodeEntities($strVal); $strVal = $this->StringUtil->decodeEntities($strVal);
$strVal = preg_replace(array('/<br.*\/*>/si'), array("\n"), $strVal); $strVal = preg_replace(array('/<br.*\/*>/si'), array("\n"), $strVal);
$strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252'); $strVal = $this->convertEncoding($strVal, $GLOBALS['TL_CONFIG']['characterSet'], 'CP1252');
@ -509,7 +509,7 @@ class rateitBackendModule extends \BackendModule
$xls->setcell(array("sheetname" => $strXlsSheet,"row" => $intRowCounter, "col" => $intColCounter, "data" => $strVal, "type" => $cellType, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL)); $xls->setcell(array("sheetname" => $strXlsSheet,"row" => $intRowCounter, "col" => $intColCounter, "data" => $strVal, "type" => $cellType, "vallign" => XLSXF_VALLIGN_TOP, "fontfamily" => XLSFONT_FAMILY_NORMAL));
$intColCounter++; $intColCounter++;
} }
$intRowCounter++; $intRowCounter++;
} }

View File

@ -30,64 +30,69 @@
namespace cgoIT\rateit; namespace cgoIT\rateit;
class RateItFaq extends RateItFrontend { use cgoIT\rateit\RateItRating;
class RateItFaq extends RateItFrontend {
var $rateItRating;
/** /**
* Initialize the controller * Initialize the controller
*/ */
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
$this->rateItRating = new RateItRating();
} }
public function getContentElementRateIt($objRow, $strBuffer) { public function getContentElementRateIt($objRow, $strBuffer) {
if ($objRow->type == 'module') { if ($objRow->type == 'module') {
$objModule = $this->Database->prepare("SELECT * FROM tl_module WHERE id=? AND type IN ('faqpage', 'faqreader')") $objModule = $this->Database->prepare("SELECT * FROM tl_module WHERE id=? AND type IN ('faqpage', 'faqreader')")
->limit(1) ->limit(1)
->execute($objRow->module); ->execute($objRow->module);
if ($objModule->numRows == 1) { if ($objModule->numRows == 1) {
$this->faq_categories = deserialize($objModule->faq_categories); $this->faq_categories = deserialize($objModule->faq_categories);
if ($objModule->type == 'faqreader') { if ($objModule->type == 'faqreader') {
$strBuffer = $this->generateForFaqReader($objModule, $strBuffer); $strBuffer = $this->generateForFaqReader($objModule, $strBuffer);
} else { } else {
$strBuffer = $this->generateForFaqPage($objModule, $strBuffer); $strBuffer = $this->generateForFaqPage($objModule, $strBuffer);
} }
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/onReadyRateIt.js|static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/rateit.js|static';
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/rateit.min.css||static';
switch ($GLOBALS['TL_CONFIG']['rating_type']) { switch ($GLOBALS['TL_CONFIG']['rating_type']) {
case 'hearts' : case 'hearts' :
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/heart.min.css||static';
break; break;
default: default:
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/star.min.css||static';
} }
} }
} }
return $strBuffer; return $strBuffer;
} }
private function generateForFaqPage($objModule, $strBuffer) { private function generateForFaqPage($objModule, $strBuffer) {
$objFaq = $this->Database $objFaq = $this->Database
->execute("SELECT *, author AS authorId, (SELECT headline FROM tl_faq_category WHERE tl_faq_category.id=tl_faq.pid) AS category, (SELECT name FROM tl_user WHERE tl_user.id=tl_faq.author) AS author FROM tl_faq WHERE pid IN(" . implode(',', array_map('intval', $this->faq_categories)) . ")" . (!BE_USER_LOGGED_IN ? " AND published=1" : "")); ->execute("SELECT *, author AS authorId, (SELECT headline FROM tl_faq_category WHERE tl_faq_category.id=tl_faq.pid) AS category, (SELECT name FROM tl_user WHERE tl_user.id=tl_faq.author) AS author FROM tl_faq WHERE pid IN(" . implode(',', array_map('intval', $this->faq_categories)) . ")" . (!BE_USER_LOGGED_IN ? " AND published=1" : ""));
if ($objFaq->numRows < 1) { if ($objFaq->numRows < 1) {
return $strBuffer; return $strBuffer;
} }
$htmlBuffer = new \simple_html_dom(); $htmlBuffer = new \simple_html_dom();
$htmlBuffer->load($strBuffer); $htmlBuffer->load($strBuffer);
$arrFaqs = $objFaq->fetchAllAssoc(); $arrFaqs = $objFaq->fetchAllAssoc();
foreach ($arrFaqs as $arrFaq) { foreach ($arrFaqs as $arrFaq) {
$rating = $this->generateSingle($arrFaq, $strBuffer); $rating = $this->generateSingle($arrFaq, $strBuffer);
$h3 = $htmlBuffer->find('#'.$arrFaq['alias']); $h3 = $htmlBuffer->find('#'.$arrFaq['alias']);
if (is_array($h3) && count($h3) == 1) { if (is_array($h3) && count($h3) == 1) {
$section = $h3[0]->parent(); $section = $h3[0]->parent();
if ($arrFaq['rateit_position'] == 'before') { if ($arrFaq['rateit_position'] == 'before') {
$section->innertext = $rating.$section->innertext; $section->innertext = $rating.$section->innertext;
} else if ($arrFaq['rateit_position'] == 'after') { } else if ($arrFaq['rateit_position'] == 'after') {
@ -95,37 +100,37 @@ class RateItFaq extends RateItFrontend {
} }
} }
} }
$strBuffer = $htmlBuffer->save(); $strBuffer = $htmlBuffer->save();
// Aufräumen // Aufräumen
$htmlBuffer->clear(); $htmlBuffer->clear();
unset($htmlBuffer); unset($htmlBuffer);
return $strBuffer; return $strBuffer;
} }
private function generateForFaqReader($objModule, $strBuffer) { private function generateForFaqReader($objModule, $strBuffer) {
// Set the item from the auto_item parameter // Set the item from the auto_item parameter
if ($GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) { if ($GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) {
$this->Input->setGet('items', $this->Input->get('auto_item')); $this->Input->setGet('items', $this->Input->get('auto_item'));
} }
// Do not index or cache the page if no FAQ has been specified // Do not index or cache the page if no FAQ has been specified
if (!$this->Input->get('items')) { if (!$this->Input->get('items')) {
return $strBuffer; return $strBuffer;
} }
$objFaq = $this->Database->prepare("SELECT *, author AS authorId, (SELECT title FROM tl_faq_category WHERE tl_faq_category.id=tl_faq.pid) AS category, (SELECT name FROM tl_user WHERE tl_user.id=tl_faq.author) AS author FROM tl_faq WHERE pid IN(" . implode(',', array_map('intval', $this->faq_categories)) . ") AND (id=? OR alias=?)" . (!BE_USER_LOGGED_IN ? " AND published=1" : "")) $objFaq = $this->Database->prepare("SELECT *, author AS authorId, (SELECT title FROM tl_faq_category WHERE tl_faq_category.id=tl_faq.pid) AS category, (SELECT name FROM tl_user WHERE tl_user.id=tl_faq.author) AS author FROM tl_faq WHERE pid IN(" . implode(',', array_map('intval', $this->faq_categories)) . ") AND (id=? OR alias=?)" . (!BE_USER_LOGGED_IN ? " AND published=1" : ""))
->limit(1) ->limit(1)
->execute((is_numeric($this->Input->get('items')) ? $this->Input->get('items') : 0), $this->Input->get('items')); ->execute((is_numeric($this->Input->get('items')) ? $this->Input->get('items') : 0), $this->Input->get('items'));
if ($objFaq->numRows == 1) { if ($objFaq->numRows == 1) {
$arrFaq = $objFaq->fetchAssoc(); $arrFaq = $objFaq->fetchAssoc();
$rating = $this->generateSingle($arrFaq, $strBuffer); $rating = $this->generateSingle($arrFaq, $strBuffer);
} }
if ($arrFaq['rateit_position'] == 'before') { if ($arrFaq['rateit_position'] == 'before') {
$strBuffer = $rating.$strBuffer; $strBuffer = $rating.$strBuffer;
} else if ($arrFaq['rateit_position'] == 'after') { } else if ($arrFaq['rateit_position'] == 'after') {
@ -134,26 +139,25 @@ class RateItFaq extends RateItFrontend {
return $strBuffer; return $strBuffer;
} }
private function generateSingle($arrFaq, $strBuffer) { private function generateSingle($arrFaq, $strBuffer) {
$rating = ''; $rating = '';
if ($arrFaq['addRating']) { if ($arrFaq['addRating']) {
$actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ='faq'") $actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ='faq'")
->execute($arrFaq['id']) ->execute($arrFaq['id'])
->fetchAssoc(); ->fetchAssoc();
if ($actRecord['active']) { if ($actRecord['active']) {
$this->import('rateit\\RateItRating', 'RateItRating'); $this->rateItRating->rkey = $arrFaq['id'];
$this->RateItRating->rkey = $arrFaq['id']; $this->rateItRating->ratingType = 'faq';
$this->RateItRating->ratingType = 'faq'; $this->rateItRating->generate();
$this->RateItRating->generate();
$rating = $this->rateItRating->output();
$rating = $this->RateItRating->output();
} }
} }
return $rating; return $rating;
} }
} }
?> ?>

View File

@ -41,31 +41,31 @@ class RateItFrontend extends \Hybrid
* @var string * @var string
*/ */
protected $strPk = 'id'; protected $strPk = 'id';
/** /**
* Typ * Typ
* @var string * @var string
*/ */
protected $strType = 'hearts'; protected $strType = 'hearts';
/** /**
* Template * Template
* @var string * @var string
*/ */
protected $strTemplate = 'rateit_default'; protected $strTemplate = 'rateit_default';
/** /**
* Anzahl der Herzen/Sterne * Anzahl der Herzen/Sterne
* @var int * @var int
*/ */
protected $intStars = 5; protected $intStars = 5;
/** /**
* Textposition * Textposition
* @var string * @var string
*/ */
protected $strTextPosition = 'after'; protected $strTextPosition = 'after';
/** /**
* Initialize the controller * Initialize the controller
*/ */
@ -77,10 +77,10 @@ class RateItFrontend extends \Hybrid
elseif ($objElement instanceof \Model\Collection) { elseif ($objElement instanceof \Model\Collection) {
$this->strTable = $objElement->current()->getTable(); $this->strTable = $objElement->current()->getTable();
} }
$this->strKey = $this->strPk; $this->strKey = $this->strPk;
} }
$stars = intval($GLOBALS['TL_CONFIG']['rating_count']); $stars = intval($GLOBALS['TL_CONFIG']['rating_count']);
if ($stars > 0) { if ($stars > 0) {
$this->intStars = $stars; $this->intStars = $stars;
@ -110,7 +110,7 @@ class RateItFrontend extends \Hybrid
*/ */
protected function compile() { protected function compile() {
} }
public function getStarMessage($rating) { public function getStarMessage($rating) {
$this->loadLanguageFile('default'); $this->loadLanguageFile('default');
$stars = $this->percentToStars($rating['rating']); $stars = $this->percentToStars($rating['rating']);
@ -136,12 +136,12 @@ class RateItFrontend extends \Hybrid
public function loadRating($rkey, $typ) { public function loadRating($rkey, $typ) {
$SQL_GET_RATINGS = "SELECT i.rkey AS rkey, $SQL_GET_RATINGS = "SELECT i.rkey AS rkey,
i.title AS title, i.title AS title,
IFNULL(AVG(r.rating),0) AS rating, IFNULL(AVG(r.rating),0) AS rating,
COUNT( r.rating ) AS totalRatings COUNT( r.rating ) AS totalRatings
FROM tl_rateit_items i FROM tl_rateit_items i
LEFT OUTER JOIN tl_rateit_ratings r LEFT OUTER JOIN tl_rateit_ratings r
ON ( i.id = r.pid ) WHERE i.rkey = ? and typ=? and active='1' ON ( i.id = r.pid ) WHERE i.rkey = ? and typ=? and active='1'
GROUP BY i.rkey;"; GROUP BY i.rkey, i.title;";
$result = $this->Database->prepare($SQL_GET_RATINGS) $result = $this->Database->prepare($SQL_GET_RATINGS)
->execute($rkey, $typ) ->execute($rkey, $typ)
->fetchAssoc(); ->fetchAssoc();
@ -154,4 +154,4 @@ class RateItFrontend extends \Hybrid
} }
} }
?> ?>

View File

@ -66,15 +66,15 @@ abstract class RateItHybrid extends RateItFrontend
$this->strType = $GLOBALS['TL_CONFIG']['rating_type']; $this->strType = $GLOBALS['TL_CONFIG']['rating_type'];
$this->strTextPosition = $GLOBALS['TL_CONFIG']['rating_textposition']; $this->strTextPosition = $GLOBALS['TL_CONFIG']['rating_textposition'];
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/onReadyRateIt.js|static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/rateit.js|static';
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/rateit.min.css||static';
switch ($this->strType) { switch ($this->strType) {
case 'hearts' : case 'hearts' :
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/heart.min.css||static';
break; break;
default: default:
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/star.min.css||static';
} }
return parent::generate(); return parent::generate();

View File

@ -69,15 +69,15 @@ class RateItNews extends RateItFrontend {
$objTemplate->rateit_rating_after = true; $objTemplate->rateit_rating_after = true;
} }
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/onReadyRateIt.js|static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/rateit.js|static';
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/rateit.min.css||static';
switch ($GLOBALS['TL_CONFIG']['rating_type']) { switch ($GLOBALS['TL_CONFIG']['rating_type']) {
case 'hearts' : case 'hearts' :
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/heart.min.css||static';
break; break;
default: default:
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/star.min.css||static';
} }
} }
} }

View File

@ -29,32 +29,36 @@
namespace cgoIT\rateit; namespace cgoIT\rateit;
use cgoIT\rateit\RateItRating;
class RateItPage extends \Frontend { class RateItPage extends \Frontend {
var $rateItRating;
/** /**
* Initialize the controller * Initialize the controller
*/ */
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
$this->rateItRating = new RateItRating();
$this->loadDataContainer('settings'); $this->loadDataContainer('settings');
} }
public function generatePage($objPage, $objLayout, $objPageType) { public function generatePage($objPage, $objLayout, $objPageType) {
if ($objPage->addRating) { if ($objPage->addRating) {
$actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ='page'") $actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ='page'")
->execute($objPage->id) ->execute($objPage->id)
->fetchAssoc(); ->fetchAssoc();
if ($actRecord['active']) { if ($actRecord['active']) {
$this->import('rateit\\RateItRating', 'RateItRating'); $this->rateItRating->rkey = $objPage->id;
$this->RateItRating->rkey = $objPage->id; $this->rateItRating->generate();
$this->RateItRating->generate();
$rating = $this->rateItRating->output();
$rating = $this->RateItRating->output();
$rating .= $this->includeJs(); $rating .= $this->includeJs();
$rating .= $this->includeCss(); $rating .= $this->includeCss();
$objTemplate = $objPageType->Template; $objTemplate = $objPageType->Template;
if ($objTemplate) { if ($objTemplate) {
if ($objPage->rateit_position == 'after') { if ($objPage->rateit_position == 'after') {
@ -72,7 +76,7 @@ class RateItPage extends \Frontend {
$strHeadTags = ''; $strHeadTags = '';
if (is_array($GLOBALS['TL_CSS'])) { if (is_array($GLOBALS['TL_CSS'])) {
foreach ($GLOBALS['TL_CSS'] as $script) { foreach ($GLOBALS['TL_CSS'] as $script) {
if ($this->startsWith($script, 'system/modules/rateit/public/css/rateit') === true) { if ($this->startsWith($script, 'bundles/cgoitrateit/css/rateit') === true) {
$included = true; $included = true;
break; break;
} }
@ -80,24 +84,24 @@ class RateItPage extends \Frontend {
} }
if (!$included) { if (!$included) {
$strHeadTags = '<link rel="stylesheet" href="'.$this->addStaticUrlTo('system/modules/rateit/public/css/rateit.min.css').'">'; $strHeadTags = '<link rel="stylesheet" href="'.$this->addStaticUrlTo('bundles/cgoitrateit/css/rateit.min.css').'">';
switch ($GLOBALS['TL_CONFIG']['rating_type']) { switch ($GLOBALS['TL_CONFIG']['rating_type']) {
case 'hearts' : case 'hearts' :
$strHeadTags .= '<link rel="stylesheet" href="'.$this->addStaticUrlTo('system/modules/rateit/public/css/heart.min.css').'">'; $strHeadTags .= '<link rel="stylesheet" href="'.$this->addStaticUrlTo('bundles/cgoitrateit/css/heart.min.css').'">';
break; break;
default: default:
$strHeadTags .= '<link rel="stylesheet" href="'.$this->addStaticUrlTo('system/modules/rateit/public/css/star.min.css').'">'; $strHeadTags .= '<link rel="stylesheet" href="'.$this->addStaticUrlTo('bundles/cgoitrateit/css/star.min.css').'">';
} }
} }
return $strHeadTags; return $strHeadTags;
} }
private function includeJs() { private function includeJs() {
$included = false; $included = false;
$strHeadTags = ''; $strHeadTags = '';
if (is_array($GLOBALS['TL_JAVASCRIPT'])) { if (is_array($GLOBALS['TL_JAVASCRIPT'])) {
foreach ($GLOBALS['TL_JAVASCRIPT'] as $script) { foreach ($GLOBALS['TL_JAVASCRIPT'] as $script) {
if ($this->startsWith($script, 'system/modules/rateit/public/js/rateit') === true) { if ($this->startsWith($script, 'bundles/cgoitrateit/js/rateit') === true) {
$included = true; $included = true;
break; break;
} }
@ -105,15 +109,15 @@ class RateItPage extends \Frontend {
} }
if (!$included) { if (!$included) {
$strHeadTags = '<script' . (($objPage->outputFormat == 'xhtml') ? ' type="text/javascript"' : '') . ' src="' . $this->addStaticUrlTo('system/modules/rateit/public/js/onReadyRateIt.js') . '"></script>' . "\n"; $strHeadTags = '<script' . (($objPage->outputFormat == 'xhtml') ? ' type="text/javascript"' : '') . ' src="' . $this->addStaticUrlTo('bundles/cgoitrateit/js/onReadyRateIt.js') . '"></script>' . "\n";
$strHeadTags .= '<script' . (($objPage->outputFormat == 'xhtml') ? ' type="text/javascript"' : '') . ' src="' . $this->addStaticUrlTo('system/modules/rateit/public/js/rateit.js') . '"></script>' . "\n"; $strHeadTags .= '<script' . (($objPage->outputFormat == 'xhtml') ? ' type="text/javascript"' : '') . ' src="' . $this->addStaticUrlTo('bundles/cgoitrateit/js/rateit.js') . '"></script>' . "\n";
} }
return $strHeadTags; return $strHeadTags;
} }
function startsWith($haystack, $needle) { function startsWith($haystack, $needle) {
// search backwards starting from haystack length characters from the end // search backwards starting from haystack length characters from the end
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
} }
} }
?> ?>

View File

@ -36,13 +36,13 @@ namespace cgoIT\rateit;
class RateItTopRatingsModule extends RateItFrontend class RateItTopRatingsModule extends RateItFrontend
{ {
private static $arrUrlCache = array(); private static $arrUrlCache = array();
/** /**
* Initialize the controller * Initialize the controller
*/ */
public function __construct($objElement) { public function __construct($objElement) {
parent::__construct($objElement); parent::__construct($objElement);
$this->strKey = "rateit_top_ratings"; $this->strKey = "rateit_top_ratings";
} }
@ -62,22 +62,22 @@ class RateItTopRatingsModule extends RateItFrontend
return $objTemplate->parse(); return $objTemplate->parse();
} }
$this->strTemplate = $this->rateit_template; $this->strTemplate = $this->rateit_template;
$this->arrTypes = deserialize($this->rateit_types); $this->arrTypes = deserialize($this->rateit_types);
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/onReadyRateIt.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/onReadyRateIt.js|static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/rateit.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/rateit.js|static';
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/rateit.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/rateit.min.css||static';
switch ($GLOBALS['TL_CONFIG']['rating_type']) { switch ($GLOBALS['TL_CONFIG']['rating_type']) {
case 'hearts' : case 'hearts' :
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/heart.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/heart.min.css||static';
break; break;
default: default:
$GLOBALS['TL_CSS'][] = 'system/modules/rateit/public/css/star.min.css||static'; $GLOBALS['TL_CSS'][] = 'bundles/cgoitrateit/css/star.min.css||static';
} }
return parent::generate(); return parent::generate();
} }
@ -86,9 +86,9 @@ class RateItTopRatingsModule extends RateItFrontend
*/ */
protected function compile() { protected function compile() {
$this->Template = new \FrontendTemplate($this->strTemplate); $this->Template = new \FrontendTemplate($this->strTemplate);
$this->Template->setData($this->arrData); $this->Template->setData($this->arrData);
$this->import("\\Database", "Database"); $this->import("\\Database", "Database");
$arrResult = $this->Database->prepare("SELECT i.id AS item_id, $arrResult = $this->Database->prepare("SELECT i.id AS item_id,
i.rkey AS rkey, i.rkey AS rkey,
@ -114,32 +114,32 @@ class RateItTopRatingsModule extends RateItFrontend
$return = new \stdClass(); $return = new \stdClass();
$return->title = $result['title']; $return->title = $result['title'];
$return->typ = $result['typ']; $return->typ = $result['typ'];
// ID ermitteln // ID ermitteln
$stars = $this->percentToStars($result['best']); $stars = $this->percentToStars($result['best']);
$return->rateItID = 'rateItRating-'.$result['rkey'].'-'.$result['typ'].'-'. $return->rateItID = 'rateItRating-'.$result['rkey'].'-'.$result['typ'].'-'.
$stars.'_'.intval($GLOBALS['TL_CONFIG']['rating_count']); $stars.'_'.intval($GLOBALS['TL_CONFIG']['rating_count']);
$return->descriptionId = 'rateItRating-'.$result['rkey'].'-description'; $return->descriptionId = 'rateItRating-'.$result['rkey'].'-description';
$return->rateit_class = 'rateItRating'; $return->rateit_class = 'rateItRating';
$return->url = $this->getUrl($result); $return->url = $this->getUrl($result);
// Beschriftung ermitteln // Beschriftung ermitteln
$rating = array(); $rating = array();
$rating['totalRatings'] = $result['most']; $rating['totalRatings'] = $result['most'];
$rating['rating'] = $result['best']; $rating['rating'] = $result['best'];
$return->description = $this->getStarMessage($rating); $return->description = $this->getStarMessage($rating);
$return->rating = $result['best']; $return->rating = $result['best'];
$return->count = $result['most']; $return->count = $result['most'];
$return->rel = 'not-rateable'; $return->rel = 'not-rateable';
$objReturn[] = $return; $objReturn[] = $return;
} }
$this->Template->arrRatings = $objReturn; $this->Template->arrRatings = $objReturn;
} }
private function getUrl($rating) { private function getUrl($rating) {
if ($rating['typ'] === 'page') { if ($rating['typ'] === 'page') {
return \PageModel::findById($rating['rkey'])->getAbsoluteUrl(); return \PageModel::findById($rating['rkey'])->getAbsoluteUrl();
@ -153,25 +153,25 @@ class RateItTopRatingsModule extends RateItFrontend
if ($rating['typ'] === 'news') { if ($rating['typ'] === 'news') {
$objNews = \NewsModel::findById($rating['rkey']); $objNews = \NewsModel::findById($rating['rkey']);
$objArticle = \NewsModel::findPublishedByPid($objNews->pid); $objArticle = \NewsModel::findPublishedByPid($objNews->pid);
// Internal link // Internal link
if ($objArticle->source != 'external') { if ($objArticle->source != 'external') {
return $this->generateNewsUrl($objNews); return $this->generateNewsUrl($objNews);
} }
// Encode e-mail addresses // Encode e-mail addresses
if (substr($objArticle->url, 0, 7) == 'mailto:') { if (substr($objArticle->url, 0, 7) == 'mailto:') {
$strArticleUrl = \StringUtil::encodeEmail($objArticle->url); $strArticleUrl = \StringUtil::encodeEmail($objArticle->url);
} }
// Ampersand URIs // Ampersand URIs
else { else {
$strArticleUrl = ampersand($objArticle->url); $strArticleUrl = ampersand($objArticle->url);
} }
/** @var \PageModel $objPage */ /** @var \PageModel $objPage */
global $objPage; global $objPage;
// External link // External link
return $strArticleUrl; return $strArticleUrl;
} }
@ -180,15 +180,15 @@ class RateItTopRatingsModule extends RateItFrontend
private function generateNewsUrl($objItem) { private function generateNewsUrl($objItem) {
$strCacheKey = 'id_' . $objItem->id; $strCacheKey = 'id_' . $objItem->id;
// Load the URL from cache // Load the URL from cache
if (isset(self::$arrUrlCache[$strCacheKey])) { if (isset(self::$arrUrlCache[$strCacheKey])) {
return self::$arrUrlCache[$strCacheKey]; return self::$arrUrlCache[$strCacheKey];
} }
// Initialize the cache // Initialize the cache
self::$arrUrlCache[$strCacheKey] = null; self::$arrUrlCache[$strCacheKey] = null;
switch ($objItem->source) { switch ($objItem->source) {
// Link to an external page // Link to an external page
case 'external' : case 'external' :
@ -198,7 +198,7 @@ class RateItTopRatingsModule extends RateItFrontend
self::$arrUrlCache[$strCacheKey] = ampersand($objItem->url); self::$arrUrlCache[$strCacheKey] = ampersand($objItem->url);
} }
break; break;
// Link to an internal page // Link to an internal page
case 'internal' : case 'internal' :
if (($objTarget = $objItem->getRelated('jumpTo')) !== null) { if (($objTarget = $objItem->getRelated('jumpTo')) !== null) {
@ -206,7 +206,7 @@ class RateItTopRatingsModule extends RateItFrontend
self::$arrUrlCache[$strCacheKey] = ampersand($objTarget->getFrontendUrl()); self::$arrUrlCache[$strCacheKey] = ampersand($objTarget->getFrontendUrl());
} }
break; break;
// Link to an article // Link to an article
case 'article' : case 'article' :
if (($objArticle = \ArticleModel::findByPk($objItem->articleId, array( if (($objArticle = \ArticleModel::findByPk($objItem->articleId, array(
@ -217,25 +217,25 @@ class RateItTopRatingsModule extends RateItFrontend
} }
break; break;
} }
// Link to the default page // Link to the default page
if (self::$arrUrlCache[$strCacheKey] === null) { if (self::$arrUrlCache[$strCacheKey] === null) {
$objPage = \PageModel::findWithDetails($objItem->getRelated('pid')->jumpTo); $objPage = \PageModel::findWithDetails($objItem->getRelated('pid')->jumpTo);
if ($objPage === null) { if ($objPage === null) {
self::$arrUrlCache[$strCacheKey] = ampersand(\Environment::get('request'), true); self::$arrUrlCache[$strCacheKey] = ampersand(\Environment::get('request'), true);
} else { } else {
self::$arrUrlCache[$strCacheKey] = ampersand($objPage->getFrontendUrl(((\Config::get('useAutoItem') && ! \Config::get('disableAlias')) ? '/' : '/items/') . ((! \Config::get('disableAlias') && $objItem->alias != '') ? $objItem->alias : $objItem->id))); self::$arrUrlCache[$strCacheKey] = ampersand($objPage->getFrontendUrl(((\Config::get('useAutoItem') && ! \Config::get('disableAlias')) ? '/' : '/items/') . ((! \Config::get('disableAlias') && $objItem->alias != '') ? $objItem->alias : $objItem->id)));
} }
// Add the current archive parameter (news archive) // Add the current archive parameter (news archive)
if ($blnAddArchive && \Input::get('month') != '') { if ($blnAddArchive && \Input::get('month') != '') {
self::$arrUrlCache[$strCacheKey] .= (\Config::get('disableAlias') ? '&amp;' : '?') . 'month=' . \Input::get('month'); self::$arrUrlCache[$strCacheKey] .= (\Config::get('disableAlias') ? '&amp;' : '?') . 'month=' . \Input::get('month');
} }
} }
return self::$arrUrlCache[$strCacheKey]; return self::$arrUrlCache[$strCacheKey];
} }
} }
?> ?>

View File

@ -33,33 +33,32 @@ use cgoIT\rateit\RateItBackend;
/** /**
* Hooks * Hooks
*/ */
$GLOBALS['TL_HOOKS']['generatePage'][] = array('rateit\\RateItPage', 'generatePage'); $GLOBALS['TL_HOOKS']['generatePage'][] = array('cgoIT\\rateit\\RateItPage', 'generatePage');
$GLOBALS['TL_HOOKS']['rateitAjax'][] = array('rateit\\RateIt', 'doVote'); $GLOBALS['TL_HOOKS']['parseArticles'][] = array('cgoIT\\rateit\\RateItNews', 'parseArticle');
$GLOBALS['TL_HOOKS']['parseArticles'][] = array('rateit\\RateItNews', 'parseArticle'); $GLOBALS['TL_HOOKS']['getContentElement'][] = array('cgoIT\\rateit\\RateItFaq', 'getContentElementRateIt');
$GLOBALS['TL_HOOKS']['getContentElement'][] = array('rateit\\RateItFaq', 'getContentElementRateIt'); $GLOBALS['TL_HOOKS']['parseTemplate'][] = array('cgoIT\\rateit\\RateItArticle', 'parseTemplateRateIt');
$GLOBALS['TL_HOOKS']['parseTemplate'][] = array('rateit\\RateItArticle', 'parseTemplateRateIt');
/** /**
* Back end modules * Back end modules
*/ */
array_insert($GLOBALS['BE_MOD']['content'], count($GLOBALS['BE_MOD']['content']), array_insert($GLOBALS['BE_MOD']['content'], count($GLOBALS['BE_MOD']['content']),
array('rateit' => array ( array('rateit' => array (
'callback' => 'rateit\\RateItBackendModule', 'callback' => 'cgoIT\\rateit\\RateItBackendModule',
'icon' => rateit\RateItBackend::image('icon'), 'icon' => RateItBackend::image('icon'),
'stylesheet' => rateit\RateItBackend::css('backend'), 'stylesheet' => RateItBackend::css('backend'),
'javascript' => rateit\RateItBackend::js('RateItBackend') 'javascript' => RateItBackend::js('RateItBackend')
) )
)); ));
/** /**
* frontend moduls * frontend moduls
*/ */
$GLOBALS['FE_MOD']['application']['rateit'] = 'rateit\\RateItModule'; $GLOBALS['FE_MOD']['application']['rateit'] = 'cgoIT\\rateit\\RateItModule';
$GLOBALS['FE_MOD']['application']['rateit_top_ratings'] = 'rateit\\RateItTopRatingsModule'; $GLOBALS['FE_MOD']['application']['rateit_top_ratings'] = 'cgoIT\\rateit\\RateItTopRatingsModule';
/** /**
* content elements * content elements
*/ */
$GLOBALS['TL_CTE']['includes']['rateit'] = 'rateit\\RateItCE'; $GLOBALS['TL_CTE']['includes']['rateit'] = 'cgoIT\\rateit\\RateItCE';
?> ?>

View File

@ -0,0 +1,18 @@
<?php
use cgoIT\rateit\RateIt;
use SimpleAjax\Event\SimpleAjax;
if (class_exists(SimpleAjax::class)) {
return array
(
SimpleAjax::NAME => array(
array(
array(new RateIt(), 'doVote'),
RateIt::PRIORITY
)
)
);
}
return array();

View File

@ -27,8 +27,9 @@
* @license GNU/LGPL * @license GNU/LGPL
* @filesource * @filesource
*/ */
use cgoIT\rateit\DcaHelper;
/** /**
* Extend tl_article * Extend tl_article
*/ */
@ -80,14 +81,14 @@ $GLOBALS['TL_DCA']['tl_article']['fields']['rateit_template'] = array
'eval' => array('mandatory'=>true, 'tl_class'=>'w50') 'eval' => array('mandatory'=>true, 'tl_class'=>'w50')
); );
class tl_article_rating extends rateit\DcaHelper { class tl_article_rating extends DcaHelper {
/** /**
* Constructor * Constructor
*/ */
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
} }
/** /**
* Return all navigation templates as array * Return all navigation templates as array
* @param DataContainer * @param DataContainer

View File

@ -28,6 +28,8 @@
* @filesource * @filesource
*/ */
use cgoIT\rateit\DcaHelper;
$GLOBALS['TL_DCA']['tl_content']['config']['onsubmit_callback'][] = array('tl_content_rateit','insert'); $GLOBALS['TL_DCA']['tl_content']['config']['onsubmit_callback'][] = array('tl_content_rateit','insert');
$GLOBALS['TL_DCA']['tl_content']['config']['ondelete_callback'][] = array('tl_content_rateit','delete'); $GLOBALS['TL_DCA']['tl_content']['config']['ondelete_callback'][] = array('tl_content_rateit','delete');
@ -62,7 +64,7 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['rateit_active'] = array
/** /**
* Class tl_content_rateit * Class tl_content_rateit
*/ */
class tl_content_rateit extends rateit\DcaHelper { class tl_content_rateit extends DcaHelper {
/** /**
* Constructor * Constructor
@ -70,31 +72,31 @@ 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 // 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); $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 {
$objFiles = \FilesModel::findMultipleByIds(deserialize($dc->activeRecord->multiSRC)); $objFiles = \FilesModel::findMultipleByIds(deserialize($dc->activeRecord->multiSRC));
} }
if ($objFiles !== null) { if ($objFiles !== null) {
// Get all images // Get all images
while ($objFiles->next()) { while ($objFiles->next()) {
// Single files // Single files
if ($objFiles->type == 'file') { if ($objFiles->type == 'file') {
$objFile = new \File($objFiles->path, true); $objFile = new \File($objFiles->path, true);
if (!$objFile->isGdImage) { if (!$objFile->isGdImage) {
continue; continue;
} }
$this->insertOrUpdateRatingItemGallery($dc, $type, $objFile->name, $objFiles->id, ($dc->activeRecord->rateit_active ? '1' : '')); $this->insertOrUpdateRatingItemGallery($dc, $type, $objFile->name, $objFiles->id, ($dc->activeRecord->rateit_active ? '1' : ''));
} }
// Folders // Folders
@ -104,23 +106,23 @@ class tl_content_rateit extends rateit\DcaHelper {
} else { } else {
$objSubfiles = \FilesModel::findByPid($objFiles->id); $objSubfiles = \FilesModel::findByPid($objFiles->id);
} }
if ($objSubfiles === null) { if ($objSubfiles === null) {
continue; continue;
} }
while ($objSubfiles->next()) { while ($objSubfiles->next()) {
// Skip subfolders // Skip subfolders
if ($objSubfiles->type == 'folder') { if ($objSubfiles->type == 'folder') {
continue; continue;
} }
$objFile = new \File($objSubfiles->path, true); $objFile = new \File($objSubfiles->path, true);
if (!$objFile->isGdImage) { if (!$objFile->isGdImage) {
continue; continue;
} }
$this->insertOrUpdateRatingItemGallery($dc, $type, $objSubfiles->name, $objSubfiles->id, ($dc->activeRecord->rateit_active ? '1' : '')); $this->insertOrUpdateRatingItemGallery($dc, $type, $objSubfiles->name, $objSubfiles->id, ($dc->activeRecord->rateit_active ? '1' : ''));
} }
} }
@ -142,7 +144,7 @@ class tl_content_rateit extends rateit\DcaHelper {
return $this->deleteRatingKey($dc, 'ce'); return $this->deleteRatingKey($dc, 'ce');
} }
} }
private function insertOrUpdateRatingItemGallery(\DC_Table &$dc, $type, $strName, $imgId, $active) { private function insertOrUpdateRatingItemGallery(\DC_Table &$dc, $type, $strName, $imgId, $active) {
$rkey = $dc->activeRecord->id.'|'.$imgId; $rkey = $dc->activeRecord->id.'|'.$imgId;
$headline = deserialize($dc->activeRecord->headline); $headline = deserialize($dc->activeRecord->headline);
@ -173,4 +175,4 @@ class tl_content_rateit extends rateit\DcaHelper {
} }
} }
} }
?> ?>

View File

@ -27,8 +27,9 @@
* @license GNU/LGPL * @license GNU/LGPL
* @filesource * @filesource
*/ */
use cgoIT\rateit\DcaHelper;
/** /**
* Extend tl_article * Extend tl_article
*/ */
@ -69,14 +70,14 @@ $GLOBALS['TL_DCA']['tl_faq']['fields']['rateit_position'] = array
'eval' => array('mandatory'=>true, 'tl_class'=>'w50') 'eval' => array('mandatory'=>true, 'tl_class'=>'w50')
); );
class tl_faq_rating extends rateit\DcaHelper { class tl_faq_rating extends DcaHelper {
/** /**
* Constructor * Constructor
*/ */
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
} }
public function insert(\DC_Table $dc) { public function insert(\DC_Table $dc) {
return $this->insertOrUpdateRatingKey($dc, 'faq', $dc->activeRecord->question); return $this->insertOrUpdateRatingKey($dc, 'faq', $dc->activeRecord->question);
} }

View File

@ -1,4 +1,4 @@
<?php <?php
/** /**
* Contao Open Source CMS * Contao Open Source CMS
@ -28,6 +28,8 @@
* @filesource * @filesource
*/ */
use cgoIT\rateit\DcaHelper;
$GLOBALS['TL_DCA']['tl_module']['config']['onsubmit_callback'][] = array('tl_module_rateit','insert'); $GLOBALS['TL_DCA']['tl_module']['config']['onsubmit_callback'][] = array('tl_module_rateit','insert');
$GLOBALS['TL_DCA']['tl_module']['config']['ondelete_callback'][] = array('tl_module_rateit','delete'); $GLOBALS['TL_DCA']['tl_module']['config']['ondelete_callback'][] = array('tl_module_rateit','delete');
@ -107,7 +109,7 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['rateit_template'] = array
/** /**
* Class tl_module_rateit * Class tl_module_rateit
*/ */
class tl_module_rateit extends rateit\DcaHelper { class tl_module_rateit extends DcaHelper {
/** /**
* Constructor * Constructor
@ -115,7 +117,7 @@ class tl_module_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) {
return $this->insertOrUpdateRatingKey($dc, 'module', $dc->activeRecord->rateit_title); return $this->insertOrUpdateRatingKey($dc, 'module', $dc->activeRecord->rateit_title);
} }
@ -137,4 +139,4 @@ class tl_module_rateit extends rateit\DcaHelper {
return $this->getTemplateGroup('mod_rateit_top', $intPid); return $this->getTemplateGroup('mod_rateit_top', $intPid);
} }
} }
?> ?>

View File

@ -27,8 +27,9 @@
* @license GNU/LGPL * @license GNU/LGPL
* @filesource * @filesource
*/ */
use cgoIT\rateit\DcaHelper;
/** /**
* Extend tl_article * Extend tl_article
*/ */
@ -69,14 +70,14 @@ $GLOBALS['TL_DCA']['tl_news']['fields']['rateit_position'] = array
'eval' => array('mandatory'=>true, 'tl_class'=>'w50') 'eval' => array('mandatory'=>true, 'tl_class'=>'w50')
); );
class tl_news_rating extends rateit\DcaHelper { class tl_news_rating extends DcaHelper {
/** /**
* Constructor * Constructor
*/ */
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
} }
public function insert(\DC_Table $dc) { public function insert(\DC_Table $dc) {
return $this->insertOrUpdateRatingKey($dc, 'news', $dc->activeRecord->headline); return $this->insertOrUpdateRatingKey($dc, 'news', $dc->activeRecord->headline);
} }

View File

@ -27,8 +27,10 @@
* @license GNU/LGPL * @license GNU/LGPL
* @filesource * @filesource
*/ */
use cgoIT\rateit\DcaHelper;
/** /**
* Extend tl_page * Extend tl_page
*/ */
@ -81,14 +83,14 @@ $GLOBALS['TL_DCA']['tl_page']['fields']['rateit_position'] = array
'eval' => array('mandatory'=>true, 'tl_class'=>'w50') 'eval' => array('mandatory'=>true, 'tl_class'=>'w50')
); );
class tl_page_rateit extends rateit\DcaHelper { class tl_page_rateit extends DcaHelper {
/** /**
* Constructor * Constructor
*/ */
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
} }
public function insert(\DC_Table $dc) { public function insert(\DC_Table $dc) {
return $this->insertOrUpdateRatingKey($dc, 'page', $dc->activeRecord->title); return $this->insertOrUpdateRatingKey($dc, 'page', $dc->activeRecord->title);
} }

View File

@ -28,6 +28,8 @@
* @filesource * @filesource
*/ */
use cgoIT\rateit\DcaHelper;
/** /**
* palettes * palettes
*/ */
@ -113,21 +115,7 @@ $GLOBALS['TL_DCA']['tl_settings']['fields']['rating_description'] = array
'eval' => array('mandatory'=>true, 'allowHtml'=>true, 'tl_class'=>'w50') 'eval' => array('mandatory'=>true, 'allowHtml'=>true, 'tl_class'=>'w50')
); );
class tl_settings_rateit extends rateit\DcaHelper class tl_settings_rateit extends DcaHelper
{ {
public function getUserFullName() {
$this->import('jicw\\JICWHelper', 'JICWHelper');
return $this->JICWHelper->getUserFullName();
}
public function getUserEmail() {
$this->import('jicw\\JICWHelper', 'JICWHelper');
return $this->JICWHelper->getUserEmail();
}
public function getInstalledModules() {
$this->import('jicw\\JICWHelper', 'JICWHelper');
return $this->JICWHelper->getInstalledModules();
}
} }
?> ?>

View File

@ -2,7 +2,7 @@
// Add the colorbox style sheet and javascript // Add the colorbox style sheet and javascript
$GLOBALS['TL_CSS'][] = 'assets/jquery/colorbox/'. COLORBOX .'/css/colorbox.min.css||static'; $GLOBALS['TL_CSS'][] = 'assets/jquery/colorbox/'. COLORBOX .'/css/colorbox.min.css||static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/jquery/colorbox/colorbox-rateit.min.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/jquery/colorbox/colorbox-rateit.min.js|static';
?> ?>

View File

@ -2,7 +2,7 @@
// Add the colorbox style sheet and javascript // Add the colorbox style sheet and javascript
$GLOBALS['TL_CSS'][] = 'assets/jquery/colorbox/'. COLORBOX .'/css/colorbox.min.css||static'; $GLOBALS['TL_CSS'][] = 'assets/jquery/colorbox/'. COLORBOX .'/css/colorbox.min.css||static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/jquery/colorbox/colorbox-rateit.min.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/jquery/colorbox/colorbox-rateit.min.js|static';
?> ?>

View File

@ -2,7 +2,7 @@
// Add the mediabox style sheet and javascript // Add the mediabox style sheet and javascript
$GLOBALS['TL_CSS'][] = 'assets/mootools/mediabox/'. MEDIABOX .'/css/mediaboxAdvBlack21.css||static'; $GLOBALS['TL_CSS'][] = 'assets/mootools/mediabox/'. MEDIABOX .'/css/mediaboxAdvBlack21.css||static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/mootools/mediabox/mediabox-rateit.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/mootools/mediabox/mediabox-rateit.js|static';
?> ?>

View File

@ -2,7 +2,7 @@
// Add the mediabox style sheet // Add the mediabox style sheet
$GLOBALS['TL_CSS'][] = 'assets/mootools/mediabox/'. MEDIABOX .'/css/mediaboxAdvBlack21.css||static'; $GLOBALS['TL_CSS'][] = 'assets/mootools/mediabox/'. MEDIABOX .'/css/mediaboxAdvBlack21.css||static';
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/rateit/public/js/mootools/mediabox/mediabox-rateit.js|static'; $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/cgoitrateit/js/mootools/mediabox/mediabox-rateit.js|static';
?> ?>

Some files were not shown because too many files have changed in this diff Show More