Imports für DcaHelper ergänzt
This commit is contained in:
parent
d15a1b43d2
commit
93e4d2dd63
@ -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
|
||||||
|
@ -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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user