<?php
//define this module's name and path
$mn = basename(__FILE__, ".php");
include("modules/modules.php");

/*
Available variables:
All system classes
All request variables
$p (the template path)
$mp (the module path)
$sufixID (id sufix for this module's divs)
*/

$marginTop = ($moduleParameters['marginTop'] == "__EMPTY__" || empty($moduleParameters['marginTop'])) ? 0 : $moduleParameters['marginTop'];
$marginRight = ($moduleParameters['marginRight'] == "__EMPTY__" || empty($moduleParameters['marginRight'])) ? 0 : $moduleParameters['marginRight'];
$marginBottom = ($moduleParameters['marginBottom'] == "__EMPTY__" || empty($moduleParameters['marginBottom'])) ? 0 : $moduleParameters['marginBottom'];
$marginLeft = ($moduleParameters['marginLeft'] == "__EMPTY__" || empty($moduleParameters['marginLeft'])) ? 0 : $moduleParameters['marginLeft'];
$paddingTop = ($moduleParameters['paddingTop'] == "__EMPTY__" || empty($moduleParameters['paddingTop'])) ? 0 : $moduleParameters['paddingTop'];
$paddingRight = ($moduleParameters['paddingRight'] == "__EMPTY__" || empty($moduleParameters['paddingRight'])) ? 0 : $moduleParameters['paddingRight'];
$paddingBottom = ($moduleParameters['paddingBottom'] == "__EMPTY__" || empty($moduleParameters['paddingBottom'])) ? 0 : $moduleParameters['paddingBottom'];
$paddingLeft = ($moduleParameters['paddingLeft'] == "__EMPTY__" || empty($moduleParameters['paddingLeft'])) ? 0 : $moduleParameters['paddingLeft'];
$useModuleContainer = ($moduleParameters['useModuleContainer'] == "__EMPTY__" || empty($moduleParameters['useModuleContainer'])) ? 0 : (int)$moduleParameters['useModuleContainer'];
$widthInPixels = ($moduleParameters['widthInPixels'] == "__EMPTY__" || empty($moduleParameters['widthInPixels'])) ? null : (int)$moduleParameters['widthInPixels'];


if (empty($marginTop) && empty($marginRight) && empty($marginBottom) && empty($marginLeft)) {
    $Mmargin = "0";
} else {
    $Mmargin = $marginTop . " " . $marginRight . " " . $marginBottom . " " . $marginLeft . " ";
}
if (empty($paddingTop) && empty($paddingRight) && empty($paddingBottom) && empty($paddingLeft)) {
    $Mpadding = "0";
} else {
    $Mpadding = $paddingTop . " " . $paddingRight . " " . $paddingBottom . " " . $paddingLeft . " ";
}

$createdText_1 = $moduleParameters['createdText_1'];
$createdLinkText_1 = $moduleParameters['createdLinkText_1'];
$createdURL_1 = $moduleParameters['createdURL_1'];
$createdText_2 = $moduleParameters['createdText_2'];
$createdLinkText_2 = $moduleParameters['createdLinkText_2'];
$createdURL_2 = $moduleParameters['createdURL_2'];
global $domain_name;
global $protocol;
$domain_name = ($domain_name) ? $domain_name : $_SERVER["SERVER_NAME"];
$showTimer = $moduleParameters['show_timer'];
$odysseyLink = ($showTimer) ? '<a data-type="copyright" href="javascript:void(0)" class="osx" >odyssey</a>' : '<a data-type="copyright" href="' . $protocol . '://odyssey.webpage.gr/" data-rel="external">Odyssey</a>';

if ($useModuleContainer){
?>

<div id="<?php echo $mn . $sufixID; ?>" data-editable="editable" class="responsive_float">
    <?php
    }
    if ($moduleParameters['moduleAlign'] && $moduleParameters['moduleHR']){ // there are system parameters...
    ?>
    <style type="text/css">
        <?php
        if($useModuleContainer ){
        ?>
        #<?php echo $mn.$sufixID;?>{
	<?php 
	$alignRule = ($moduleParameters['moduleAlign'] == "center") ? "text-align" : "float";
	echo $alignRule.": ".$moduleParameters['moduleAlign'].";".PHP_EOL;
	?>
	margin : <?php echo $Mmargin;?>;
	padding : <?php echo $Mpadding;?>;
<?php
if($widthInPixels){
	?>
	width: <?php echo $widthInPixels;?>px;
	<?php 
}	
if($moduleParameters['moduleHR'] == "top" || $moduleParameters['moduleHR'] == "bottom"){
?>
	border-<?php echo $moduleParameters['moduleHR'];?> : 1px solid black;
<?php 
}
?>	
}<?php
}
if($moduleParameters['use_colors']){
?> #<?php echo $mn.$sufixID;?>{
	color: #<?php echo $moduleParameters['footer_text_color'];?>;	
}
#<?php echo $mn.$sufixID;?> a {
            color: #<?php echo $moduleParameters['link_text_color'];?>;
        }

        <?php
        }
        ?>
    </style>

<div id="copyright_text">
<?php
}

echo '&copy; ' . $dates->getCopyRightYears() . " " . $domain_name . "<wbr>";
if (!empty($createdText_1) && !empty($createdLinkText_1)) {
    $buffer = ' • ' . $createdText_1 . ' <wbr>';
    if (!empty($createdURL_1)) {
        $buffer .= '<a data-type="copyright" href="' . $createdURL_1 . '" data-rel="external">' . t($createdLinkText_1) . '</a><wbr>';
    } else {
        $buffer .= t($createdLinkText_1) . "<wbr>";
    }
}
if (!empty($createdText_2) && !empty($createdLinkText_2)) {
    $buffer .= ' • ' . $createdText_2 . ' <wbr>';
    if (!empty($createdURL_2)) {
        $buffer .= '<a data-type="copyright" href="' . $createdURL_2 . '" data-rel="external">' . t($createdLinkText_2) . '</a><wbr>';
    } else {
        $buffer .= t($createdLinkText_2) . "<wbr>";
    }
}
if (empty($buffer) && $createdText_1) echo " • " . $createdText_1 . "<wbr>";
if (empty($buffer) && $createdText_2) echo " • " . $createdText_2 . "<wbr>";
echo $buffer;
unset($buffer);
?>
  <span style="white-space: nowrap">  • powered by&nbsp;&nbsp;<?php echo $odysseyLink; ?> </span>
</div>

    <?php
    if ($moduleParameters['show_timer']) {
        require_once("library/timer.php");
        $timer = new timer();
        $startFromSeconds = $timer->getUserTime();
        ?>
        <div id="osx-modal-content">
            <div id="osx-modal-title" style="text-align:right"><a href="javascript:void(0)" class="simplemodal-close"><img src="<?php echo $mp; ?>images/modal_close.gif" width="20" height="20" alt="close"></a></div>
            <div id="osx-modal-data">
                <div style="text-align:center; height:310px; background:#151515;">
                    <div id="o_timer_message"><?php echo t("Χρόνος παραμονής σας στο site<br>κατά την τρέχουσα συνεδρία:"); ?></div>
                    <div id="o_timer_container"></div>
                    <div id="o_timer_logo">
                        <a href="//odyssey.webpage.gr" title="visit Odyssey website" data-rel="external"><img src="<?php echo $mp; ?>images/logo.png"></a>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            jQuery().ready(function () {
                $('#o_timer_container').jOtimer({
                    'start': '<?php echo $startFromSeconds;?>',
                    'hours_label': '<?php echo t("Ώρες"); ?>',
                    'minutes_label': '<?php echo t("Λεπτά"); ?>',
                    'seconds_label': '<?php echo t("Δεύτ."); ?>'
                });
            });
        </script>
        <?php
    }
    if ($useModuleContainer){
    ?>
</div>
<?php
}
?>
