Imports für DcaHelper ergänzt

This commit is contained in:
Carsten Götzinger 2018-02-14 12:51:55 +01:00
parent d15a1b43d2
commit 93e4d2dd63
6 changed files with 43 additions and 34 deletions

View File

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

View File

@ -28,6 +28,8 @@
* @filesource
*/
use cgoIT/rateit/DcaHelper;
$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');
@ -62,7 +64,7 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['rateit_active'] = array
/**
* Class tl_content_rateit
*/
class tl_content_rateit extends rateit\DcaHelper {
class tl_content_rateit extends DcaHelper {
/**
* Constructor
@ -70,31 +72,31 @@ class tl_content_rateit extends rateit\DcaHelper {
public function __construct() {
parent::__construct();
}
public function insert(\DC_Table $dc) {
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 {
$objFiles = \FilesModel::findMultipleByIds(deserialize($dc->activeRecord->multiSRC));
}
if ($objFiles !== null) {
// Get all images
while ($objFiles->next()) {
// Single files
if ($objFiles->type == 'file') {
$objFile = new \File($objFiles->path, true);
if (!$objFile->isGdImage) {
continue;
}
$this->insertOrUpdateRatingItemGallery($dc, $type, $objFile->name, $objFiles->id, ($dc->activeRecord->rateit_active ? '1' : ''));
}
// Folders
@ -104,23 +106,23 @@ class tl_content_rateit extends rateit\DcaHelper {
} 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;
}
$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');
}
}
private function insertOrUpdateRatingItemGallery(\DC_Table &$dc, $type, $strName, $imgId, $active) {
$rkey = $dc->activeRecord->id.'|'.$imgId;
$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
* @filesource
*/
use cgoIT/rateit/DcaHelper;
/**
* Extend tl_article
*/
@ -69,14 +70,14 @@ $GLOBALS['TL_DCA']['tl_faq']['fields']['rateit_position'] = array
'eval' => array('mandatory'=>true, 'tl_class'=>'w50')
);
class tl_faq_rating extends rateit\DcaHelper {
class tl_faq_rating extends DcaHelper {
/**
* Constructor
*/
public function __construct() {
parent::__construct();
}
public function insert(\DC_Table $dc) {
return $this->insertOrUpdateRatingKey($dc, 'faq', $dc->activeRecord->question);
}

View File

@ -1,4 +1,4 @@
<?php
<?php
/**
* Contao Open Source CMS
@ -28,6 +28,8 @@
* @filesource
*/
use cgoIT/rateit/DcaHelper;
$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');
@ -107,7 +109,7 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['rateit_template'] = array
/**
* Class tl_module_rateit
*/
class tl_module_rateit extends rateit\DcaHelper {
class tl_module_rateit extends DcaHelper {
/**
* Constructor
@ -115,7 +117,7 @@ class tl_module_rateit extends rateit\DcaHelper {
public function __construct() {
parent::__construct();
}
public function insert(\DC_Table $dc) {
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);
}
}
?>
?>

View File

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

View File

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