Commit f6876f0c authored by Thomas Löffler's avatar Thomas Löffler Committed by GitHub

Merge pull request #1 from TYPO3-typo3org/6_2_compatible

[TASK] Make the extension 6.2 Compatible
parents dde634b6 0b7b5a5d
......@@ -9,8 +9,8 @@ class RandomBannersAjax {
protected $objectManager;
public function __construct() {
$this->bannerRepository = t3lib_div::makeInstance('Tx_Randombanners_Domain_Repository_BannerRepository');
$this->objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
$this->bannerRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Randombanners_Domain_Repository_BannerRepository');
$this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Object_ObjectManager');
$this->persistenceManager = $this->objectManager->get('Tx_Extbase_Persistence_Manager');
}
......@@ -21,11 +21,11 @@ class RandomBannersAjax {
}
}
$function = t3lib_div::_GET('function');
$function = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('function');
switch ($function) {
case 'clickBanner':
if ($uid = intval(t3lib_div::_GET('banner'))) {
if ($uid = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('banner'))) {
$output = new RandomBannersAjax();
$output->increaseClickNumber($uid);
}
......
......@@ -43,18 +43,10 @@ class Tx_Randombanners_Controller_BannerController extends Tx_Extbase_MVC_Contro
/**
*
*
* @return void
*/
public function indexAction() {
$banners = $this->bannerRepository->findAll();
foreach ($banners as $banner) {
if (!($banner->getLogo() instanceof Tx_Extbase_Domain_Model_Dam)) {
$banner->setLogo(Tx_ExtbaseDam_Utility_Dam::getOne('tx_randombanners_domain_model_banner', $banner->getUid(), 'tx_randombanner_dam_images'));
}
}
$this->view->assign('banners', $banners);
}
......
......@@ -50,9 +50,9 @@ class Tx_Randombanners_Domain_Model_Banner extends Tx_Extbase_DomainObject_Abstr
protected $email;
/**
* logo
* Logo
*
* @var integer
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
protected $logo;
......@@ -118,12 +118,18 @@ class Tx_Randombanners_Domain_Model_Banner extends Tx_Extbase_DomainObject_Abstr
* @param integer $logo
* @return void
*/
/**
* Set Logo
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $logo
*/
public function setLogo($logo) {
$this->logo = $logo;
}
/**
* @return integer
* Get logo
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $logo
*/
public function getLogo() {
return $this->logo;
......
......@@ -117,11 +117,7 @@
* @return boolean
*/
protected function sendReport(Tx_Randombanners_Domain_Model_Banner $banner) {
$message = "Your banner statistics for " . date('F Y', strtotime('-1 month')) . ":\n"
. "\nClicked: ".$banner->getClickedThisMonth()." times\n"
. "\nThanks for sponsoring\nTYPO3 Association";
$message = "Your banner statistics for ".date('F Y', strtotime('-1 month')).":\n\nDisplayed: ".$banner->getDisplayedThisMonth()." times\nClicked: ".$banner->getClickedThisMonth()." times\n\nThanks for sponsoring\nTYPO3 Association";
$this->htmlMail->start();
$this->htmlMail->subject = 'Report for your banner on typo3.org on '.date('F', strtotime('-1 month'));
......
......@@ -50,17 +50,17 @@
*/
static protected function initialize() {
// Get configuration manager
$objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_Object_ObjectManager');
self::$configurationManager = $objectManager->get('Tx_Extbase_Configuration_ConfigurationManager');
// Simulate Frontend
if (TYPO3_MODE == 'BE') {
Tx_Extbase_Utility_FrontendSimulator::simulateFrontendEnvironment();
\TYPO3\CMS\Extbase\Utility\FrontendSimulatorUtility::simulateFrontendEnvironment();
if (empty($GLOBALS['TSFE']->sys_page)) {
$GLOBALS['TSFE']->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
$GLOBALS['TSFE']->sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_pageSelect');
}
if (empty($GLOBALS['TT'])) {
$GLOBALS['TT'] = t3lib_div::makeInstance('t3lib_TimeTrackNull');
$GLOBALS['TT'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_TimeTrackNull');
}
self::$configurationManager->setContentObject($GLOBALS['TSFE']->cObj);
}
......@@ -68,12 +68,12 @@
// Get content object
self::$contentObject = self::$configurationManager->getContentObject();
if (empty(self::$contentObject)) {
self::$contentObject = t3lib_div::makeInstance('tslib_cObj');
self::$contentObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_cObj');
}
// Reset Frontend if modified
if (TYPO3_MODE == 'BE') {
Tx_Extbase_Utility_FrontendSimulator::resetFrontendEnvironment();
\TYPO3\CMS\Extbase\Utility\FrontendSimulatorUtility::resetFrontendEnvironment();
}
}
......@@ -89,7 +89,7 @@
}
$setup = self::$configurationManager->getConfiguration(
Tx_Extbase_Configuration_ConfigurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
);
if (empty($setup['plugin.']['tx_randombanners.'])) {
......@@ -114,12 +114,12 @@
// Convert to classic TypoScript array
if ($isPlain) {
$configuration = Tx_Extbase_Utility_TypoScript::convertPlainArrayToTypoScriptArray($configuration);
$configuration = \TYPO3\CMS\Extbase\Service\TypoScriptService::convertPlainArrayToTypoScriptArray($configuration);
}
// Parse configuration
$configuration = self::parseTypoScriptArray($configuration);
$configuration = t3lib_div::removeDotsFromTS($configuration);
$configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($configuration);
return $configuration;
}
......
......@@ -123,7 +123,19 @@ $TCA['tx_randombanners_domain_model_banner'] = array(
'max' => 256
)
),
'logo' => txdam_getMediaTCA('image_field', 'tx_randombanner_dam_images'),
'logo' => array(
'exclude' => 1,
'l10n_mode' => 'mergeIfNotBlank',
'label' => 'LLL:EXT:randombanners/Resources/Private/Language/locallang_db.xml:tx_randombanners_domain_model_banner.logo',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'logo',
array(
'minitems' => 0,
'maxitems' => 1,
'foreign_sortby' => '__UNSET'
)
),
),
'displayed_this_month' => array(
'exclude' => 0,
'label' => 'LLL:EXT:randombanners/Resources/Private/Language/locallang_db.xml:tx_randombanners_domain_model_banner.displayed_this_month',
......
plugin.tx_randombanners {
view {
# cat=plugin.tx_randombanners/file; type=string; label=Path to template root (FE)
templateRootPath = EXT:bannermanagement/Resources/Private/Templates/
templateRootPath = EXT:randombanners/Resources/Private/Templates/
# cat=plugin.tx_randombanners/file; type=string; label=Path to template partials (FE)
partialRootPath = EXT:bannermanagement/Resources/Private/Partials/
partialRootPath = EXT:randombanners/Resources/Private/Partials/
# cat=plugin.tx_randombanners/file; type=string; label=Path to template layouts (FE)
layoutRootPath = EXT:bannermanagement/Resources/Private/Layouts/
layoutRootPath = EXT:randombanners/Resources/Private/Layouts/
}
persistence {
# cat=plugin.tx_randombanners//a; type=int+; label=Default storage PID
......
<label for="displayedThisMonth">
<f:translate key="tx_randombanners_domain_model_banner.displayed_this_month" />
</label><br />
<f:form.textbox property="displayedThisMonth" /><br />
<f:form.textfield property="displayedThisMonth" /><br />
<label for="clickedThisMonth">
<f:translate key="tx_randombanners_domain_model_banner.clicked_this_month" />
</label><br />
<f:form.textbox property="clickedThisMonth" /><br />
<f:form.textfield property="clickedThisMonth" /><br />
<label for="displayedLastMonth">
<f:translate key="tx_randombanners_domain_model_banner.displayed_last_month" />
</label><br />
<f:form.textbox property="displayedLastMonth" /><br />
<f:form.textfield property="displayedLastMonth" /><br />
<label for="clickedLastMonth">
<f:translate key="tx_randombanners_domain_model_banner.clicked_last_month" />
</label><br />
<f:form.textbox property="clickedLastMonth" /><br />
\ No newline at end of file
<f:form.textfield property="clickedLastMonth" /><br />
......@@ -5,12 +5,12 @@
<f:if condition="{settings.noFollowTag} == 1">
<f:then>
<a class="tx-randombanners-link" onclick="clickBanner($(this));" href="<f:uri.external uri='{banner.link}' />" data-itemId="{banner.uid}" rel="nofollow" target="_blank">
<f:image src="{banner.logo.filePath}{banner.logo.fileName}" alt="{banner.name}" />
<f:image src="{banner.logo.uid}" treatIdAsReference="1" alt="{banner.name}" />
</a>
</f:then>
<f:else>
<a class="tx-randombanners-link" onclick="clickBanner($(this));" href="<f:uri.external uri='{banner.link}' />" data-itemId="{banner.uid}" target="_blank">
<f:image src="{banner.logo.filePath}{banner.logo.fileName}" alt="{banner.name}" />
<f:image src="{banner.logo.uid}" treatIdAsReference="1" alt="{banner.name}" />
</a>
</f:else>
</f:if>
......
BannerRotator = function(selector) {
this.containerCount = 4;
this.switchPause = 4000;
this.switchDelay = 100;
if ($(selector).length == 0) {
return;
}
this.bannerCount = $(selector + " div.tx-randombanners-item").length;
this.initialize = function() {
this.combinations = this.createCombinations(this.containerCount, this.generateIterativeArray(this.bannerCount));
this.hitCombinations = [];
for (i = 1; i < this.containerCount; i++) {
$(selector + " .tx-randombanners:eq(0)").clone().insertAfter(selector + " .tx-randombanners:eq(0)").hide();
}
for (i = 1; i < this.containerCount; i+=2) {
$(selector + " .tx-randombanners").eq(i).addClass('rightbanner');
}
this.animate();
};
this.generateIterativeArray = function(limit) {
array = [];
for (i = 0; i < limit; i++) {
array.push(i);
}
return array;
};
this.activateCombination = function(combination) {
indexOrder = this.generateOrdering();
this.activateBannerInBox(0, indexOrder, combination);
};
this.activateBannerInBox = function(iterationIndex, indexOrder , combination) {
var self = this;
boxId = indexOrder[iterationIndex];
$(selector + " .tx-randombanners").eq(boxId).find('.tx-randombanners-item').hide().eq(combination[boxId]).fadeIn(this.switchDelay, function() {
if (iterationIndex < indexOrder.length - 1) {
self.activateBannerInBox(iterationIndex + 1, indexOrder, combination);
}
});
$(selector + " .tx-randombanners").eq(boxId).show();
};
this.generateOrdering = function() {
orderings = this.createCombinations(this.containerCount, this.generateIterativeArray(this.containerCount));
return orderings[Math.floor((Math.random() * orderings.length))];
};
this.animate = function() {
if (this.combinations.length == 0 && this.hitCombinations.length > 0) {
this.combinations = this.hitCombinations;
this.hitCombinations = [];
}
nextCombinationIndex = Math.floor((Math.random() * this.combinations.length));
this.activateCombination(this.combinations[nextCombinationIndex]);
this.hitCombinations.push(this.combinations[nextCombinationIndex]);
this.combinations.slice(nextCombinationIndex, 1);
var self = this;
window.setTimeout(function() {self.animate()}, this.switchPause);
};
this.createCombinations = function(num, source) {
var combinations = [];
if (num == 1) {
for (i = 0; i < source.length; i++) {
combinations.push([source[i]]);
}
} else {
for (var i = 0; i < source.length; i++) {
var newSource = source.slice(0);
newSource.splice(i, 1);
var subCombinations = this.createCombinations(num - 1, newSource);
for (j = 0; j < subCombinations.length; j++) {
var currentCombination = [source[i]].concat(subCombinations[j]);
combinations.push(currentCombination);
}
}
}
return combinations;
};
};
var banner_position_array = new Array();
function clickBanner(el) {
$.ajax({
url: '/index.php?type=69&tx_randombanners_list[action]=show&tx_randombanners_list[banner]=' + parseInt($(el).attr('data-itemId')) +'&tx_randombanners_list[controller]=Banner',
......@@ -97,14 +9,80 @@ function clickBanner(el) {
}
function initBanners() {
var rotator = new BannerRotator("#randombanners");
/* platin members at the left navigation */
if($(".d.navigationbanners .tx-randombanners").length > 0) {
rotator.containerCount = 2;
rotator.switchDelay = 0;
rotator.switchPause = 5000;
if($(".d.navigationbanners .tx-randombanners").length > 0) {
var container = $('#randombanners .tx-randombanners');
var banners = $(".d.navigationbanners .tx-randombanners-item");
var numBanners = banners.length;
for(var i=0; i< 4; i++) {
var banner = banners[Math.floor(Math.random() * numBanners)];
container.prepend(banner);
}
banners.each(function(){
if($(this).index() > 1)
$(this).css("display","none");
});
$(".d.navigationbanners .tx-randombanners-item:eq(0), .d.navigationbanners .tx-randombanners-item:eq(1)").addClass("shown");
}
/* platin members at the homepage */
if($(".col-md-4 .tx-randombanners").length > 0) {
for(var banneri = 0; banneri < 4; banneri++) {
banner_position_array[banneri] = banneri;
}
for(var bannerfields = 0; bannerfields < 3; bannerfields++)
$(".col-md-4 .tx-randombanners:eq(0)").clone().insertAfter(".tx-randombanners:eq(0)");
for(var bannerfields = 0; bannerfields < 4; bannerfields++){
if(bannerfields%2 != 0)
$(".col-md-4 .tx-randombanners:eq("+bannerfields+")").addClass("rightbanner");
$(".col-md-4 .tx-randombanners:eq("+bannerfields+")").children(".tx-randombanners-item").addClass("banner"+((bannerfields)));
}
$(".col-md-4 .tx-randombanners-item").each(function(){
$(this).css("display","none");
});
$(".col-md-4 .tx-randombanners:eq(0) .tx-randombanners-item:eq(0), .col-md-4 .tx-randombanners:eq(1) .tx-randombanners-item:eq(1), .col-md-4 .tx-randombanners:eq(2) .tx-randombanners-item:eq(2), .col-md-4 .tx-randombanners:eq(3) .tx-randombanners-item:eq(3)").addClass("shown").fadeIn("slow", function() {
});
banner_amount = $(".col-md-4 .tx-randombanners:first .tx-randombanners-item").length;
var rotateNext = function() {
var banneri = $(this).data('no');
var next = (banneri + 1)%4;
current_banner = banner_position_array[banneri];
new_banner = banner_position_array[banneri] = (banner_position_array[banneri]-1+banner_amount)%banner_amount;
$(".banner"+banneri+":eq("+current_banner+")").data('banners', {banneri: banneri, new_banner: new_banner}).fadeOut("slow", function() {
$(".banner"+$(this).data('banners').banneri+":eq("+$(this).data('banners').new_banner+")").fadeIn("slow", function() { $(this).addClass("shown")});
});
$('.col-md-4 .tx-randombanners:eq(' + next + ')').data('no', next).oneTime((Math.PI + 1) * 1000 /* Why not? */, 'premiumbanner', rotateNext);
}
$('.col-md-4 .tx-randombanners:eq(0)').data('no', 0).oneTime((Math.PI + 1) * 1000 /* Why not? */, 'premiumbanner', rotateNext);
}
rotator.initialize();
$(document).everyTime(5000,function(){
if($(".d.navigationbanners .tx-randombanners").length > 0) {
var first_shown = $(".d.navigationbanners #randombanners .shown:first").index(".tx-randombanners-item");
var last_shown = $(".d.navigationbanners #randombanners .shown:last").index(".tx-randombanners-item");
$(".d.navigationbanners #randombanners .shown").each(function(){
$(this).removeClass("shown").fadeOut("slow",function(){
if(last_shown == $(".d.navigationbanners .tx-randombanners-item:last").index(".tx-randombanners-item") && first_shown == 0){
$(".d.navigationbanners .tx-randombanners-item:eq(1), .d.navigationbanners .tx-randombanners-item:eq(2)").fadeIn("slow").addClass("shown");
}
else if(last_shown == $(".d.navigationbanners .tx-randombanners-item:last").index(".tx-randombanners-item")-1){
$(".d.navigationbanners .tx-randombanners-item:eq(0), .d.navigationbanners .tx-randombanners-item:last").fadeIn("slow").addClass("shown");
}
else if(last_shown == $(".d.navigationbanners .tx-randombanners-item:last").index(".tx-randombanners-item") && first_shown == $(".d.navigationbanners .tx-randombanners-item:last").index(".tx-randombanners-item")-1){
$(".d.navigationbanners .tx-randombanners-item:first, .d.navigationbanners .tx-randombanners-item:eq(1)").fadeIn("slow").addClass("shown");
}
else{
$(".d.navigationbanners .tx-randombanners-item:eq("+(last_shown+1)+"), .d.navigationbanners .tx-randombanners-item:eq("+(last_shown+2)+")").fadeIn("slow").addClass("shown");
}
});
});
}
});
}
......@@ -112,4 +90,5 @@ $(document).ready(function() {
if ($('#randombanners')) {
initBanners();
}
});
\ No newline at end of file
......@@ -36,7 +36,7 @@
*
* @author Thomas Loeffler <loeffler@spooner-web.de>
*/
class Tx_Randombanners_Domain_Model_BannerTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
class Tx_Randombanners_Domain_Model_BannerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
/**
* @var Tx_Randombanners_Domain_Model_Banner
*/
......
<?php
########################################################################
# Extension Manager/Repository config file for ext: "randombanners"
#
# Auto generated by Extbase Kickstarter 2011-04-18
#
# Manual updates:
# Only the data in the array - anything else is removed by next write.
# "version" and "dependencies" must not be touched!
########################################################################
/***************************************************************
* Extension Manager/Repository config file for ext "randombanners".
*
* Auto generated 29-05-2015 01:20
*
* Manual updates:
* Only the data in the array - everything else is removed by next
* writing. "version" and "dependencies" must not be touched!
***************************************************************/
$EM_CONF[$_EXTKEY] = array(
$EM_CONF[$_EXTKEY] = array (
'title' => 'Random banner display',
'description' => 'Random banner with display and click statistics',
'category' => 'plugin',
'version' => '0.1.0',
'state' => 'beta',
'uploadfolder' => 0,
'createDirs' => '',
'clearcacheonload' => 0,
'author' => 'Thomas Loeffler',
'author_email' => 'loeffler@spooner-web.de',
'author_company' => '',
'shy' => '',
'dependencies' => 'cms,extbase,fluid,extbase_dam',
'conflicts' => '',
'priority' => '',
'module' => '',
'state' => 'beta',
'internal' => '',
'uploadfolder' => '0',
'createDirs' => '',
'modify_tables' => '',
'clearCacheOnLoad' => 0,
'lockType' => '',
'version' => '0.0.2',
'constraints' => array(
'depends' => array(
'cms' => '',
'extbase' => '',
'fluid' => '',
'extbase_dam' => '',
'constraints' =>
array (
'depends' =>
array (
'typo3' => '6.2.0-6.2.99'
),
'conflicts' => array(
'conflicts' =>
array (
),
'suggests' => array(
'suggests' =>
array (
),
),
);
?>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment