Commit ab63b3fa authored by Sven Rhinow's avatar Sven Rhinow

push new files

parent ff2f097c
<?php
/**
* PHP version 5
*
* Class ModuleSRLayer
*
* @copyright sr-tag 2014
* @author Sven Rhinow <support@sr-tag.de>
* @package srlayer
*/
class ModuleSRLayer extends \Module
{
/**
* Template
* @var string
*/
protected $strTemplate = 'srl_default';
/**
* Target pages
* @var array
*/
protected $arrTargets = array();
/**
* Options for JS
* @var array
*/
protected $optionsArr = array();
/**
* show files and layer
* @var bool
*/
protected $show = false;
/**
* Display a wildcard in the back end
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE')
{
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### SR-LAYER ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate->href = 'typolight/main.php?do=modules&amp;act=edit&amp;id=' . $this->id;
return $objTemplate->parse();
}
if($this->SRL_template != '') $strTemplate = $this->SRL_template;
return parent::generate();
}
/**
* Generate module
*/
protected function compile()
{
//sucht in den Get-Keys nach einer bestimmten Teil-Zeichenkette
$pos = false;
if(count($_GET)>0)
{
foreach($_GET AS $k => $v)
{
$k = strip_tags(trim($k));
$getPos = strcmp($k,$this->srl_substr)==0 ? true : false;
}
}
//test Start-Date
if(strlen($this->srl_start) && ($this->srl_start > time()))
{
return false;
}
//test Stop-Date
if(strlen($this->srl_stop) && ($this->srl_stop < time()))
{
return false;
}
//Modul-Flag fuer "keine Parameter notwendig" pruefen
if($this->srl_no_param || $getPos)
{
$this->optionsArr[] = 'showNow: true';
$this->show = true;
}
//Modul-Flag fuer "Layer per Link öffnen" pruefen
if($this->srl_set_mkLinkEvents)
{
$this->optionsArr[] = 'mkLinkEvents: true';
$this->show = true;
}
//Cookie
if($this->srl_set_cookie && $this->show)
{
//Name des Cookies
if(!$this->srl_cookie_name) $this->srl_cookie_name = 'LAYER_'.$this->id.'_COOKIE';
if(!$this->Input->cookie($this->srl_cookie_name))
{
if(!$this->srl_cookie_dauer) $this->srl_cookie_dauer = 3600;
$this->setCookie( $this->srl_cookie_name, 1, time() + $this->srl_cookie_dauer );
}else $this->show = false;
}
//Session
if($this->srl_set_session && $this->show)
{
$this->import('Session');
$this->srl_session_name = 'LAYER_'.$this->id.'_SESSION';
if(!$this->Session->get($this->srl_session_name))
{
$this->Session->set($this->srl_session_name,'1');
}else $this->show = false;
}
// nur wenn Fund dann CSS, JS und HTML einfuegen
if($this->show)
{
$layerName = $this->srl_substr;
if(is_numeric($this->srl_option_layerwidth)) $this->optionsArr[] = 'layerWidth:'.$this->srl_option_layerwidth;
if(is_numeric($this->srl_option_layerheight)) $this->optionsArr[] = 'layerHeight:'.$this->srl_option_layerheight;
//expert options
if($this->srl_set_expertoptions == 1)
{
if(strlen($this->srl_set_overLayID)) $this->optionsArr[] = "overLayID:'".$this->srl_set_overLayID."'";
if(strlen($this->srl_set_layerID)) $this->optionsArr[] = "layerID:'".$this->srl_set_layerID."'";
if(strlen($this->srl_set_closeID)) $this->optionsArr[] = "closeID:'".$this->srl_set_closeID."'";
if(strlen($this->srl_set_closeClass)) $this->optionsArr[] = "closeClass:'".$this->srl_set_closeClass."'";
if(strlen($this->srl_set_overLayOpacity)) $this->optionsArr[] = 'overLayOpacity:'.$this->srl_set_overLayOpacity;
if(strlen($this->srl_set_duration)) $this->optionsArr[] = 'duration:'.$this->srl_set_duration;
if(!$this->srl_set_closePerEsc) $this->optionsArr[] = 'closePerEsc:false';
if(!$this->srl_set_closePerLayerClick) $this->optionsArr[] = 'closePerLayerClick:false';
if(!$this->srl_set_drawLayerCenterX) $this->optionsArr[] = 'drawLayerCenterX:false';
if(!$this->srl_set_drawLayerCenterY) $this->optionsArr[] = 'drawLayerCenterY:false';
}
$jsOptions = implode(', ',$this->optionsArr);
//eigene CSS-Auszeichnungen aus CSS-Datei
if($this->srl_css_file) $GLOBALS['TL_CSS'][] = $this->srl_css_file;
else $GLOBALS['TL_CSS'][] = $GLOBALS['SRL_CSS'].'?'.time();
foreach($GLOBALS['SRL_JS']['mootools'] as $jsSource)
{
$GLOBALS['TL_JAVASCRIPT'][] = $jsSource.'?'.time();
}
if((int) $this->srl_delay > 0) $GLOBALS['TL_MOOTOOLS'][] = '<script type="text/javascript"> window.addEvent(\'domready\', function() { var ml = new myLayer( { '.$jsOptions.', '.$this->srl_option_other.' } ); }.delay('.$this->srl_delay.'));</script>';
else $GLOBALS['TL_MOOTOOLS'][] = '<script type="text/javascript"> window.addEvent(\'domready\', function() { var ml = new myLayer( { '.$jsOptions.', '.$this->srl_option_other.' } ); });</script>';
$this->Template->content = $this->srl_content;
$this->Template->showLayerHtml = $this->show;
}
}
}
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
#overLay{
position: fixed;
z-index: 9998;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000;
cursor: pointer;
display:none;
/* border:3px solid #f00; */
}
#layer{
position:fixed;
z-index: 9999;
height:460px;
width:790px;
display:none;
overflow: auto;
background-color: #fff;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
#closeBtn {
position:absolute;
right:10px;
top:10px;
width: 21px;
height:21px;
background: transparent url("../images/layer_CloseBtn.png") no-repeat center;
z-index: 10000;
text-indent:-9999px;
cursor: pointer;
}
.layer_content{
position:relative;
overflow: auto;
padding:20px;
}
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
// author: Sven Rhinow website: http://www.sr-tag.de
// myLayer is MIT-Licensed
var myLayer = new Class
( {
Implements: [ Options ],
options:{
parentEl : 'top',
overLayID: 'overLay',
drawOverLay: false, // false = nicht erstellen wenn ein Element mit dieser ID schon im HTML existiert
overLayOpacity: 0.7,
layerID : 'layer',
layerWidth: 500,
layerHeight: 400,
drawLayer: false, //false = nicht erstellen wenn ein Element mit dieser ID schon im HTML existiert
closePerLayerClick:true,
closePerEsc:true,
closeID : 'closeBtn',
closeClass: 'closer',
drawCloseBtn: false, //false = nicht erstellen wenn ein Element mit dieser ID schon im HTML existiert
contentID : 'layercontent',
mkLinkEvents: true, // wenn false wird kein Link mit dem Click-Event ausgestattet (z.B. beim sortigen anzeigen)
duration : 1000,
drawLayerCenterY:true,
drawLayerCenterX:true,
// Höhe vom Headimage + Höhe der Hauptnavigation
topheight : 0, // differenz wenn der Layer obere Bereiche überdecken soll
parentsize : '',
showNow: false //der Layer wird direkt beim laden der Seite angezeigt
},
initialize: function(options)
{
//overwrite options
this.setOptions(options);
this.parentEl = document.id(this.options.parentEl);
this.overLayID = this.options.overLayID;
this.layerID = this.options.layerID;
this.layerWidth = this.options.layerWidth,
this.layerHeight = this.options.layerHeight,
this.closePerLayerClick = this.options.closePerLayerClick;
this.closePerEsc = this.options.closePerEsc;
this.closeID = this.options.closeID;
this.closeClass = this.options.closeClass;
this.contentID = this.options.contentID;
this.mkLinkEvents = this.options.mkLinkEvents;
this.duration = this.options.duration;
this.topheight = this.options.topheight;
this.parentsize = this.options.parentsize;
this.showNow = this.options.showNow;
this.overLayOpacity = this.options.overLayOpacity;
this.drawLayerCenterY = this.options.drawLayerCenterY;
this.drawLayerCenterX = this.options.drawLayerCenterX;
//resize and positon if resize browser
window.addEvent('resize', function()
{
//your logic goes here
this.parentsize = this.parentEl.getSize();
$(this.overLayID).setStyles({
width : this.parentsize.x,
height : this.parentsize.y
});
if(this.drawLayerCenterX) $(this.layerID).setStyles({ 'left': (this.parentsize.x - this.layerWidth) / 2 });
if(this.drawLayerCenterY) $(this.layerID).setStyles({ 'top': (this.parentsize.y - this.layerHeight) / 2 });
}.bind(this));
//key-events verarbeiten
if(this.closePerEsc)
{
document.addEvent('keydown', function(event){
switch(event.code){
case 27: // Esc
case 88: // 'x'
case 67: // 'c'
this.close();
break
}
}.bind(this));
}
//add event of all links with rel="openlayer"
if(this.mkLinkEvents)
{
var links = $$("a").filter(function(el) {
return el.rel && el.rel.test(/^openlayer/i);
});
links.each(function(item,index)
{
item.addEvent('click', function(event)
{
event.stop(); //Prevents the browser from following the link.
window.scrollTo(0, 0);
this.open(item);
}.bind(this));
}.bind(this));
}
this.createHtml();
if(this.showNow)
{
this.open();
}
else
{
$(this.layerID).setStyle('display', 'none');
}
},
createHtml: function()
{
this.parentsize = this.parentEl.getSize();
// position overlay
if($(this.overLayID))
{
$(this.overLayID).setStyles({
width : this.parentsize.x,
height : this.parentsize.y,
top: this.topheight,
opacity: 0
});
//add event on overlay
if(this.closePerLayerClick)
{
$(this.overLayID).addEvent('click', function(event)
{
event.stop(); //Prevents the browser from following the link.
this.close();
}.bind(this));
}
}
// position layer
if( $(this.layerID) )
{
$(this.layerID).setStyles(
{
width : this.layerWidth,
height : this.layerHeight,
opacity: 0
});
var centerLeft = (this.parentsize.x - this.layerWidth) / 2;
var centerTop = (this.parentsize.y - this.layerHeight) / 2;
if(this.drawLayerCenterX) $(this.layerID).setStyle( 'left', centerLeft );
if(this.drawLayerCenterY) $(this.layerID).setStyle( 'top',centerTop );
}
// add event on close-button
if($(this.closeID))
{
$(this.closeID).addEvent('click', function(event)
{
event.stop(); //Prevents the browser from following the link.
this.close();
}.bind(this));
}
// add event on close-link
if($$(this.closeClass))
{
$$('.'+this.closeClass).addEvent('click', function(event)
{
event.stop(); //Prevents the browser from following the link.
this.close();
}.bind(this));
}
},
close: function()
{
$(this.layerID).tween('opacity',0).setStyle('display', 'none');
$(this.overLayID).tween('opacity',0).setStyle('display', 'none');
},
open: function(el)
{
$(this.layerID).set('tween',{
duration: this.duration,
transition: Fx.Transitions.Quad.easeIn,
});
$(this.layerID).setStyle('display', 'block').tween('opacity',1);
$(this.overLayID).set('tween',{
duration: this.duration,
transition: Fx.Transitions.Quad.easeIn,
});
$(this.overLayID).setStyle('display', 'block').tween('opacity',this.overLayOpacity);
}
} );
// var ml = new myLayer();
;;
; List modules which are required to be loaded beforehand
;;
requires[] = "core"
;;
; Configure what you want the autoload creator to register
;;
register_namespaces = true
register_classes = true
register_templates = true
;;
; Override the default configuration for certain sub directories
;;
[vendor/*]
register_namespaces = false
register_classes = false
register_templates = false
<?php
/**
* Contao Open Source CMS
*
* Copyright (c) 2005-2014 Leo Feyer
*
* @package Srlayer
* @link https://contao.org
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
*/
/**
* Register the classes
*/
ClassLoader::addClasses(array
(
'ModuleSRLayer' => 'system/modules/srlayer/ModuleSRLayer.php',
));
/**
* Register the templates
*/
TemplateLoader::addFiles(array
(
'srl_default' => 'system/modules/srlayer/templates',
));
<?php if($this->showLayerHtml): ?>
<div id="overLay"></div>
<div id="layer">
<div id="closeBtn">schliessen</div>
<div class="layer_content">
<?php echo $this->content; ?>
</div>
</div><!--#layer-->
<?php endif; ?>
<div id="overLay"></div>
<div id="layer">
<div id="closeBtn">schliessen</div>
<?php echo $this->content; ?>
</div><!--#layer-->
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