Created
October 7, 2022 12:14
-
-
Save aeberhard/16aa822dc246f09526307707325d6640 to your computer and use it in GitHub Desktop.
Magazin-Layout REDAXO 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* -------------------------------------------------------------------- | |
* | |
* Modul-Input: magazin_Layout, Ausgabe von Bildern im Magazin-Layout | |
* Version: 1.8, 15.10.2010 | |
* | |
* Autor: Andreas Eberhard, [email protected] | |
* http://rex.andreaseberhard.de | |
* | |
* 2 bis n Bilder werden automatisch in der Größe angepasst und | |
* in einem "Magazin-Layout"-Block angeordnet. | |
* | |
* Verwendung findet eine "leicht" angepasste Original-PHP-Klasse von | |
* Harvey Kane. | |
* Das Originalscript ist zu finden auf | |
* http://ragepank.com/magazine-layouts/ | |
* Eine Beschreibung der Funktionalität der PHP-Klasse unter | |
* http://alistapart.com/articles/magazinelayout/ | |
* | |
* Features: | |
* - Einzel-Auswahl der Biler aus dem Medienpool oder einer Kategorie aus Medienpool | |
* - Zufallsbilder möglich | |
* - Bildergalerie über Addons möglich (z.B. Lightbox) | |
* - Grafikfilter für Magazinlayout und Bildergalerie möglich (ab 4.x) | |
* | |
* -------------------------------------------------------------------- | |
* | |
* Das Modul benötigt die Aktion "rexnames", bei Presave-Action ADD+EDIT | |
* und bei Postsave-Action ADD+EDIT (REDAXO 4.x) | |
* [POST|ADD|EDIT] und [PRE|ADD|EDIT] bei Redaxo 3.x | |
* | |
* PHP-Code für Aktion "rexnames" (### entfernen!): | |
* | |
<###?php | |
$rexname = rex_request("rexname", "array"); | |
$newname = ""; | |
for ($c = 0; $c < 99; $c++) | |
{ | |
if (isset($rexname[$c])) | |
{ | |
$newname .= $rexname[$c] . '~~'; | |
} else { | |
$newname .= '~~'; | |
} | |
} | |
if (isset($REX_ACTION['VALUE'][1]) and $REX_ACTION['VALUE'][1] != '') | |
{ | |
$rexname = preg_split('/~~/', $REX_ACTION['VALUE'][1]); | |
} else { | |
$REX_ACTION['VALUE'][1] = $newname; | |
} | |
?###> | |
* | |
* -------------------------------------------------------------------- | |
* | |
* Verwendete Redaxo-Variablen: | |
* | |
* REX_VALUE[1] rexnames | |
* rexname[0] Breite Magazinlayout | |
* rexname[1] Medienpool-Kategorie als Bilderquelle | |
* rexname[2] Ausrichtung des Magazinlayouts | |
* rexname[3] Schalter für Zufallsbilder | |
* rexname[4] Anzahl für Zufallsbilder | |
* rexname[5] Einzelbilder verlinken | |
* rexname[6] Bild-Größe für die Galeriebilder | |
* rexname[7] - | |
* rexname[8] Filter für das Magazinlayout (REDAXO 4.0.x) | |
* rexname[9] Filter für die Galeriebilder (REDAXO 4.0.x) | |
* rexname[10] Pre-HTML | |
* rexname[11] Post-HTML | |
* REX_VALUE[2] Abstand zwischen den Bildern | |
* REX_VALUE[3] CSS-Klasse für Wrapper-Div | |
* REX_VALUE[4] Anzeigetyp / Anzeige-Addon | |
* REX_VALUE[5] Hintergrundfarbe Magazinlayout | |
* REX_VALUE[6] Rahmenfarbe Magazinlayout | |
* REX_VALUE[7] Rahmenfarbe für Bilder | |
* REX_VALUE[8] Bildbeschriftung aus dem Medienpool | |
* REX_VALUE[9] Blockbildung | |
* REX_VALUE[10] Zufallszahl für mehrfache Einbindung | |
* REX_MEDIALIST[1] ausgewählte Bilder aus dem Medienpool | |
* | |
* -------------------------------------------------------------------- | |
* | |
* Changelog: | |
* 15.10.2010 Version 1.8 | |
* - Anpassung an REDAXO 4.3.x und höher | |
* - Code für Action rexnames angepasst | |
* - Möglichkeit zur Auswahl einer beliebigen Lightbox hinzugefügt | |
* (Tipp: im Output-Modul nach 'fancybox' suchen) | |
* - Maximale Bildgröße/Filter werden jetzt auch beim Popup berücksichtigt | |
* 15.05.2009 Version 1.7 | |
* - Anpassung an REDAXO 4.2.x ($REX_USER -> $REX['USER']) | |
* - jetzt auch Kategorie + Einzelauswahl möglich | |
* - Anpassungen Backend | |
* - Warning beseitigt wenn keine Bilder ausgewählt sind | |
* - Code für Action angepasst ($rexname = rex_request...) | |
* 25.08.2008 Version 1.6 | |
* - Fehler bei mehrfacher Einbindung mit Auswahl über Medialiste | |
* 08.07.2008 Version 1.5 | |
* - neuer Parameter für Ausrichtung des Magazinlayouts (links/mitte/rechts) (rexname[2]) | |
* - neuer Parameter Bildgröße für Bildergalerie (rexname[6]) | |
* - neue Parameter Grafik-Filter für Thumbnails und Bildergalerie (rexname[8],rexname[9]) | |
* - neue Option Zufallsbilder anzeigen (rexname[3]) | |
* - neue Option Anzahl Zufallsbilder/Bilder (rexname[4]) | |
* - neue Optionen PRE+POST-Html (rexname[10]+rexname[11]) | |
* - Anpassung der Auswahl Medienpool-Kategorie an Redaxo 3.2.x und 4.x | |
* - Anpassung an Redaxo 3.01 und 3.11 | |
* - Bildervorschau jetzt unter dem REX_MEDIALIST_BUTTON | |
* - Modul-Backend überarbeitet | |
* - Dokumentation der Redaxo-Variablen | |
* - PHP Warnings/Notices usw. entfernt | |
* - erweitert für Addons Lytebox, Lightview, Shadowbox | |
* - Ausgabe überarbeitet, angepasst an neue Optionen | |
* - Caching der Modulausgabe | |
* - Bugfix bei Auswahl Medienpool-Kategorie als Bilderquelle | |
* - Vorgabe einer CSS-Klasse wrapt jetzt einen Div-Container um das gesamte Magazinlayout | |
* - kleinere Bugfixes an der magazinelayout-Klasse | |
* 24.07.2007 Version 1.4 | |
* INPUT-Modul | |
* - rexnames[] für Magazinlayout-Breite und weitere Optionen | |
* - Medienpool-Kategorie als Bilderquelle auswählen (inkl. Zugriffs-Berechtigungen) | |
* - Prüfung der Addons geändert (OOAddon::isActivated) | |
* - Anpassung an Redaxo 3.3 Beta2 | |
* OUTPUT-Modul | |
* - rexnames[] für Magazinlayout-Breite und weitere Optionen | |
* - Bilder aus Medienpool-Kategorie ermitteln | |
* - Defaultwerte erweitert/überarbeitet | |
* 29.05.2007 Version 1.3 | |
* INTPUT-Modul | |
* - Defaultwerte entfernt | |
* - Neues Feld für Bildbeschriftungen | |
* - Addon Slimbox eingefügt | |
* OUTPUT-Modul | |
* - Defaultwerte können jetzt global über das Output-Modul | |
* gesteuert werden | |
* - Bildbeschriftung aus Medienpool laut Backend-Konfiguration | |
* übernehmen | |
* - Addon Slimbox eingefügt | |
* - XHTML 1.0 STRICT valider Code | |
* 19.02.2007 Version 1.2 | |
* OUTPUT-Modul | |
* - Ausgabe überarbeitet, Fehler bei Mozilla im strict-Mode | |
* 10.02.2007 Version 1.1 | |
* OUTPUT-Modul | |
* - Bugfix: Backenderror wenn ein Bild des Magazin-Layouts aus dem | |
* Medienpool gelöscht wurde behoben | |
* 30.01.2007 Version 1.0 Erste Version | |
* | |
* -------------------------------------------------------------------- | |
* | |
* Beispiel CSS (nicht unbedingt erforderlich): | |
.magazine-layout { | |
position: relative; | |
width: 100%; | |
} | |
.magazine-container { | |
background: #f6f6f6; | |
} | |
/ * magazin_Layout mit verlinkten Einzelbildern * / | |
.magazine-image a, .magazine-image a:link, .magazine-image a:visited { | |
color: #000; | |
display: table; | |
display: inline-block; | |
filter: alpha(opacity=80); | |
line-height: 0.0em; | |
opacity: 0.80; | |
-moz-opacity: 0.80; | |
} | |
.magazine-image a:focus, .magazine-image a:hover, .magazine-image a:active { | |
color: #000; | |
filter: alpha(opacity=100); | |
opacity: 1.00; | |
-moz-opacity: 1.00; | |
} | |
/ * komplett verlinktes magazin_Layout * / | |
a.magazine-link, a:link.magazine-link, a:visited.magazine-link { | |
cursor: pointer; | |
display: table; | |
display: inline-block; | |
filter: alpha(opacity=80); | |
line-height: 0.0em; | |
opacity: 0.80; | |
-moz-opacity: 0.80; | |
} | |
a:focus.magazine-link, a:hover.magazine-link, a:active.magazine-link { | |
cursor: pointer; | |
filter: alpha(opacity=100); | |
opacity: 1.00; | |
-moz-opacity: 1.00; | |
} | |
* -------------------------------------------------------------------- | |
*/ | |
unset($rxmodule); | |
$rxmodule['moduleversion'] = 'magazin_Layout 1.8'; | |
/** | |
* Ausrichtung für das Magazinlayout | |
*/ | |
$rxmodule['maglayout'] = array( | |
0 => 'links', | |
1 => 'mitte', | |
2 => 'rechts', | |
); | |
/** | |
* Anzeigetypen | |
* für den Anzeigetyp 'javascript' kann im Output-Modul das Template angepasst werden | |
* Voreingestellt ist hier die Fancybox (Tipp: im Output-Modul nach 'fancybox' suchen) | |
*/ | |
$rxmodule['options']['showonly'] = 'Bilder nur anzeigen'; | |
$rxmodule['options']['popup'] = 'Bilder in neuem Fenster anzeigen (Popup)'; | |
$rxmodule['options']['javascript'] = 'Bilder in einer JavaScript-Lightbox anzeigen'; | |
/** | |
* Box-Addons für die Anzeige | |
*/ | |
$rxmodule['boxaddons'] = array( | |
'greybox' => 'Bilder mit Greybox anzeigen', | |
'jquerylightbox' => 'Bilder mit jQueryLightbox anzeigen', | |
'lightbox' => 'Bilder mit Lightbox anzeigen', | |
'lightview' => 'Bilder mit Lightview anzeigen', | |
'lytebox' => 'Bilder mit Lytebox anzeigen', | |
'pho2' => 'Bilder mit Pho2 anzeigen', | |
'shadowbox' => 'Bilder mit Shadowbox anzeigen', | |
'slimbox' => 'Bilder mit Slimbox anzeigen', | |
'thickbox' => 'Bilder mit Thickbox anzeigen', | |
); | |
/** | |
* Werte übernehmen | |
*/ | |
// REDAXO-Version | |
$rxmodule['rexversion'] = isset($REX['VERSION']) ? $REX['VERSION'] . $REX['SUBVERSION'] : $REX['version'] . $REX['subversion']; | |
// rexnames | |
$rxmodule['rexname'] = preg_split('/~~/', "REX_VALUE[1]"); | |
$rxmodule['rexnames_inuse'] = count($rxmodule['rexname']) > 1; | |
if (!$rxmodule['rexnames_inuse']) { | |
$rxmodule['rexname'] = array_fill(0, 99, ''); | |
} | |
// Breite des Magazinlayouts | |
$rxmodule['magazinewidth'] = trim($rxmodule['rexname'][0])+0; | |
if ( $rxmodule['magazinewidth'] == 0 ) { | |
$rxmodule['magazinewidth'] = ''; | |
} | |
// Ausrichtung des Magazinlayouts | |
$rxmodule['layout'] = trim($rxmodule['rexname'][2]); | |
// Abstand zwischen den Bildern | |
$rxmodule['padding'] = trim("REX_VALUE[2]"); | |
// optionale CSS-Klasse | |
$rxmodule['cssclass'] = trim("REX_VALUE[3]"); | |
// Anzeigetyp bzw. Addon | |
$rxmodule['magazinetype'] = trim("REX_VALUE[4]"); | |
if ( $rxmodule['magazinetype'] == '' ) { | |
$rxmodule['magazinetype'] = 'showonly'; | |
} | |
// Farben | |
$rxmodule['bgcolor'] = trim("REX_VALUE[5]"); | |
$rxmodule['bordercolor'] = trim("REX_VALUE[6]"); | |
$rxmodule['imgbordercolor'] = trim("REX_VALUE[7]"); | |
// Bildbeschreibungen aus dem Medienpool | |
$rxmodule['imgdesc'] = trim("REX_VALUE[8]"); | |
// Blockbildung | |
$rxmodule['imgblock'] = trim("REX_VALUE[9]")+0; | |
if ( $rxmodule['imgblock'] == 0 ) { | |
$rxmodule['imgblock'] = ''; | |
} else if ( $rxmodule['imgblock'] < 3 ) { | |
$rxmodule['imgblock'] = 3; | |
} else if ( $rxmodule['imgblock'] > 8 ) { | |
$rxmodule['imgblock'] = 8; | |
} | |
// Zufallsbilder | |
$rxmodule['randompic'] = trim($rxmodule['rexname'][3]); | |
$rxmodule['randompiccount'] = trim($rxmodule['rexname'][4])+0; | |
if ($rxmodule['randompiccount'] == 0) { | |
$rxmodule['randompiccount'] = ''; | |
} | |
// Einzelbilder verlinken | |
$rxmodule['linkpics'] = trim($rxmodule['rexname'][5]); | |
if ($rxmodule['linkpics']=='') { | |
$rxmodule['linkpics'] = 1; | |
} | |
// Bild-Größe der Galeriebilder | |
$rxmodule['galimgsize'] = trim($rxmodule['rexname'][6]); | |
if ( trim($rxmodule['galimgsize']) <> '') { | |
if ( !in_array(substr($rxmodule['galimgsize'], strlen($rxmodule['galimgsize'])-1, 1), array('a', 'h', 'w')) ) { | |
$rxmodule['galimgsize'] = $rxmodule['galimgsize'] . 'w'; | |
} | |
} | |
// Filter für das Magazinlayout (ab REDAXO 4.0.x) | |
$rxmodule['filter'] = trim($rxmodule['rexname'][8]); | |
// Filter für die Bildergalerie (ab REDAXO 4.0.x) | |
$rxmodule['galfilter'] = trim($rxmodule['rexname'][9]); | |
// Pre + Post-HTML | |
$rxmodule['prehtml'] = stripslashes(trim($rxmodule['rexname'][10])); | |
$rxmodule['posthtml'] = stripslashes(trim($rxmodule['rexname'][11])); | |
// Zufallszahl | |
$rxmodule['magazineid'] = trim("REX_VALUE[10]"); | |
if ( $rxmodule['magazineid'] == '') { | |
// damit das Modul mehrfach auf einem Artikel verwendet werden kann | |
// wird in VALUE 10 eine Zufallszahl gespeichert! | |
srand((double)microtime()*1000000); | |
$rxmodule['magazineid'] = rand (100,900) . rand (100,900) . rand (100,900) . rand (100,900); | |
} | |
// Dateiname für Cachce | |
if ( in_array($rxmodule['rexversion'], array('3.01', '3.11', '32')) ) { | |
$rxmodule['cachefilename'] = $REX['HTDOCS_PATH'] . 'files/' . 'cache_resize___magazinlayout_' . "REX_CATEGORY_ID" . '_' . "REX_ARTICLE_ID" . '_' . $rxmodule['magazineid'] . '_' . $REX['CUR_CLANG'] . '.html'; | |
} else { | |
$rxmodule['cachefilename'] = $REX['HTDOCS_PATH'] . 'files/' . 'image_resize__magazinlayout_' . "REX_CATEGORY_ID" . '_' . "REX_ARTICLE_ID" . '_' . $rxmodule['magazineid'] . '_' . $REX['CUR_CLANG'] . '.html'; | |
} | |
// Cache auf jeden Fall löschen | |
if (file_exists($rxmodule['cachefilename'])) | |
{ | |
$rxmodule['rc'] = unlink($rxmodule['cachefilename']); | |
} | |
// zusätliche Anzeigetypen für Addons wie lightbox usw. | |
if (class_exists('OOAddon')) { | |
foreach ($rxmodule['boxaddons'] as $key => $value) { | |
if ( OOAddon::isActivated($key) ) { | |
$rxmodule['options'][$key] = $value; | |
} | |
} | |
} else { | |
foreach ($rxmodule['boxaddons'] as $key => $value) { | |
if (file_exists($REX[MEDIAFOLDER].'/'.$key)) { | |
$rxmodule['options'][$key] = $value; | |
} | |
} | |
} | |
// Addon ColorPicker vorhanden? | |
if ( file_exists($REX['HTDOCS_PATH'].'files/colorpicker/farbtastic.js') ) { | |
$rxmodule['cpplugin'] = 1; | |
} else { | |
$rxmodule['cpplugin'] = 0; | |
} | |
// ColorPicker-Plugin installiert | |
if ( $rxmodule['cpplugin'] ) { | |
echo "\n".'<script type="text/JavaScript">'; | |
echo "\n".'document.write(\'<link href="'.$REX['HTDOCS_PATH'].'/files/colorpicker/farbtastic.css" rel="stylesheet" type="text/css" />\');'; | |
echo "\n".'</script>'."\n"; | |
echo '<script src="'.$REX['HTDOCS_PATH'].'/files/colorpicker/jquery.js" type="text/JavaScript"></script>'; | |
echo '<script src="'.$REX['HTDOCS_PATH'].'/files/colorpicker/farbtastic.js" type="text/JavaScript"></script>'; | |
echo '<script type="text/javascript" charset="utf-8">'; | |
echo ' var ftpicker;'; | |
echo ' $(document).ready(function() {'; | |
echo ' $(\'#demo\').hide();'; | |
echo ' ftpicker = $.farbtastic(\'#picker\');'; | |
echo ' });'; | |
echo '</script>'."\n"; | |
echo '<div id="picker"></div>'."\n"; | |
} | |
?> | |
<input type="hidden" name="VALUE[10]" value="<?php echo $rxmodule['magazineid']; ?>" /> | |
<table width="98%" border="0"> | |
<tr> | |
<td style="padding:3px;"><strong style="display:block;width:185px;"> </strong></td> | |
<td style="padding:3px;" width="100%" align="right"><strong style="display:block;width:355px;">[ <?php echo $rxmodule['moduleversion']; ?> ]</strong></td> | |
</tr> | |
<tr> | |
<td style="padding:3px;" colspan="2"> | |
<strong>Bilder auswählen ...</strong> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding:3px;" colspan="2"> | |
REX_MEDIALIST_BUTTON[1] | |
<div id="REX_MEDIALIST_PREVIEWC" style="display:none;margin-bottom:25px;">Vorschau:<br /><img id="REX_MEDIALIST_PREVIEW" src="../files/clear.gif" style="cursor:pointer;border:solid 1px #999;" alt="Vorschau" title="Vorschau" /></div> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding:3px;" colspan="2"> | |
<em>Entweder einzelne Bilder aus dem Medienpool oder eine ganze Medienpool-Kategorie auswählen</em> | |
</td> | |
</tr> | |
<!-- | |
<tr> | |
<td style="padding:3px;vertical-align:top" valign="top"> | |
<strong>Bilder auswählen ...</strong><br /><br /> | |
<em>Entweder einzelne Bilder aus dem Medienpool oder eine ganze Medienpool-Kategorie auswählen</em> | |
</td> | |
<td> | |
EX_MEDIALIST_BUTTON[1] | |
<div id="REX_MEDIALIST_PREVIEWC" style="display:none;margin-bottom:25px;">Vorschau:<br /><img id="REX_MEDIALIST_PREVIEW" src="../files/clear.gif" style="cursor:pointer;border:solid 1px #999;" alt="Vorschau" title="Vorschau" /></div> | |
</td> | |
</tr> | |
--> | |
<tr> | |
<td style="padding:3px;vertical-align:top" valign="top"><strong>... oder Medienpool-Kategorie mit Bildern auswählen</strong></td> | |
<td style="padding:3px;"> | |
<?php | |
// Zugriffsberechtigungen für Medienpool | |
$PERMALL = false; | |
if (isset($REX['USER'])) { | |
if ($REX['USER']->isValueOf("rights","admin[]") or $REX['USER']->isValueOf("rights","media[0]")) $PERMALL = true; | |
} | |
if (isset($REX_USER)) { | |
if ($REX_USER->isValueOf("rights","admin[]") or $REX_USER->isValueOf("rights","media[0]")) $PERMALL = true; | |
$REX['USER'] = $REX_USER; | |
} | |
$GLOBALS['PERMALL'] = $PERMALL; | |
// Select-Options | |
if (!function_exists('magazinlayout_add_mediacat_options_wperm')) { | |
function magazinlayout_add_mediacat_options_wperm($rxmodule, &$select, &$mediacat, &$mediacat_ids, $groupName = '') { | |
global $PERMALL, $REX; | |
if(empty($mediacat)) return; | |
$mname = $mediacat->getName(); | |
$mediacat_ids[] = $mediacat->getId(); | |
if ( in_array($rxmodule['rexversion'], array('3.01', '3.11', '32')) ) { | |
if ($PERMALL || $REX['USER']->isValueOf("rights","media[".$mediacat->getId()."]")) $select->add_option($mname,$mediacat->getId(), $mediacat->getId(),$mediacat->getParentId()); | |
} else { | |
if ($PERMALL || $REX['USER']->isValueOf("rights","media[".$mediacat->getId()."]")) $select->addOption($mname,$mediacat->getId(), $mediacat->getId(),$mediacat->getParentId()); | |
} | |
$childs = $mediacat->getChildren(); | |
if (is_array($childs)) { | |
foreach ( $childs as $child) { | |
magazinlayout_add_mediacat_options_wperm($rxmodule, $select, $child, $mediacat_ids, $mname); | |
} | |
} | |
} | |
} // end function_exists | |
// Select aus Medienpool-Kategorien erstellen REDAXO 3.2, REDAXO 3.01, REDAXO 3.11 | |
if ( in_array($rxmodule['rexversion'], array('3.01', '3.11', '32')) ) { | |
$sel_media = new select; | |
$sel_media->set_style('width:100%;'); | |
$sel_media->set_size(1); | |
$sel_media->set_name("rexname[1]"); | |
$sel_media->add_option($I18N->msg('pool_kats_no'),"0"); | |
$sel_media->set_selected($rxmodule['rexname'][1]); | |
//$sel_media->setMultiple(false); | |
$mediacat_ids = array(); | |
if ($rootCats = OOMediaCategory::getRootCategories()) { | |
foreach( $rootCats as $rootCat) { | |
magazinlayout_add_mediacat_options_wperm($rxmodule, $sel_media, $rootCat, $mediacat_ids); | |
} | |
} | |
echo $sel_media->out(); | |
} else { | |
// Select aus Medienpool-Kategorien erstellen REDAXO 3.3 | |
$sel_media = new rex_select; | |
$sel_media->setStyle('width:100%;'); | |
$sel_media->setSize(1); | |
$sel_media->setName("rexname[1]"); | |
$sel_media->addOption($I18N->msg('pool_kats_no'),"0"); | |
$sel_media->setSelected($rxmodule['rexname'][1]); | |
//$sel_media->setMultiple(false); | |
$mediacat_ids = array(); | |
if ($rootCats = OOMediaCategory::getRootCategories()) { | |
foreach( $rootCats as $rootCat) { | |
magazinlayout_add_mediacat_options_wperm($rxmodule, $sel_media, $rootCat, $mediacat_ids); | |
} | |
} | |
echo $sel_media->show(); | |
} | |
?> | |
</td> | |
</tr> | |
<!-- | |
<tr><td style="padding:3px;"> </td><td> </td></tr> | |
<tr> | |
<td style="padding:3px;"><strong>Anzeigetyp</strong><br /></td> | |
<td style="padding:3px;"> | |
<select name="VALUE[4]" style="width:100%;"> | |
<?php | |
foreach ($rxmodule['options'] as $key => $value) { | |
echo '<option value="'.$key.'" '; | |
if ( $rxmodule['magazinetype']=="$key" ) { | |
echo 'selected="selected" '; | |
} | |
echo '>'.$value.'</option>'; | |
} | |
?> | |
</select> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding:3px;"><strong>Ausrichtung des Magazinlayouts</strong></td> | |
<td style="padding:3px;"> | |
<select name="rexname[2]" title="Ausrichtung des Magazinlayouts innerhalb der Seite" style="width:8.5em;"> | |
<?php | |
foreach ($rxmodule['maglayout'] as $key => $value) { | |
echo '<option value="'.$key.'" '; | |
if ( $rxmodule['layout']=="$key" ) { | |
echo 'selected="selected" '; | |
} | |
echo '>'.$value.'</option>'; | |
} | |
?> | |
</select> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding:3px;"><strong>Breite Magazinlayout</strong></td> | |
<td style="padding:3px;"> | |
<input title="Hier die Breite des Magazinlayouts in Pixeln angeben" type="text" style="width:8.0em;" maxlength="4" name="rexname[0]" value="<?php echo $rxmodule['magazinewidth']; ?>" /> | |
nur fixe Breite in Pixeln möglich (default 475) | |
</td> | |
</tr> | |
<tr><td style="padding:3px;"> </td><td> </td></tr> | |
<tr> | |
<td style="padding:3px;"><strong>Bildbeschriftungen aus dem Medienpool</strong></td> | |
<td style="padding:3px;"> | |
<select name="VALUE[8]" title="Feld für die Bildbeschriftungen auswählen" style="width:100%;"> | |
<?php | |
foreach (array('keine','Titel','Beschreibung','Copyright','Titel + Beschreibung','Titel + Copyright', 'Beschreibung + Copyright', 'Titel + Beschreibung + Copyright') as $key => $value) { | |
echo '<option value="' . $key . '" '; | |
if ( $rxmodule['imgdesc'] == "$key" ) { | |
echo 'selected="selected" '; | |
} | |
echo '>' . $value . '</option>'; | |
} | |
?> | |
</select> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding:3px;"><strong>Abstand zwischen den Bildern</strong></td> | |
<td style="padding:3px;"> | |
<input title="Hier den Abstand für die Bilder in Pixeln angeben" type="text" style="width:8.0em;" maxlength="3" name="VALUE[2]" value="<?php echo $rxmodule['padding']; ?>" /> | |
(default 5) | |
</td> | |
</tr> | |
<tr> | |
<td style="padding:3px;" valign="top"><strong>Anzahl Bilder die gruppiert werden sollen</strong></td> | |
<td style="padding:3px;"> | |
<input title="Hier einen Wert zwischen 3 und 8 eingeben" type="text" style="width:8.0em;" maxlength="1" name="VALUE[9]" value="<?php echo $rxmodule['imgblock']; ?>" /> | |
<br /> | |
Hinweis: Wert zwischen 3 und 8 (Default 8). Wenn hier ein Wert vorgegeben wird, kann sich die Reihenfolge der Bilder ändern. | |
</td> | |
</tr> | |
<tr><td style="padding:3px;"> </td><td> </td></tr> | |
<tr> | |
<td style="padding:3px;"><strong>Hintergrundfarbe</strong></td> | |
<td style="padding:3px;"> | |
<input <?php if ($rxmodule['cpplugin'] <> '') echo 'onfocus="javascript:linkToColor(-1,-1,ftpicker,\'VALUE5\');"'; ?> title="Hier die Hintergrundfarbe für das Magazinlayout angeben" type="text" style="width:8.0em;" maxlength="7" name="VALUE[5]" id="VALUE5" value="<?php echo $rxmodule['bgcolor']; ?>" /> | |
<?php if ($rxmodule['cpplugin'] <> '') echo '<a href="javascript:posPicker(-1,-1,ftpicker,\'VALUE5\');">Farbe auswählen</a>'; ?> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding:3px;"><strong>Rahmenfarbe</strong></td> | |
<td style="padding:3px;"> | |
<input <?php if ($rxmodule['cpplugin'] <> '') echo 'onfocus="javascript:linkToColor(-1,-1,ftpicker,\'VALUE6\');"'; ?> title="Hier die Rahmenfarbe für das Magazinlayout angeben" type="text" style="width:8.0em;" maxlength="7" name="VALUE[6]" id="VALUE6" value="<?php echo $rxmodule['bordercolor']; ?>" /> | |
<?php if ($rxmodule['cpplugin'] <> '') echo '<a href="javascript:posPicker(-1,-1,ftpicker,\'VALUE6\');">Farbe auswählen</a>'; ?> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding:3px;"><strong>Farbe Bildrahmen</strong></td> | |
<td style="padding:3px;"> | |
<input <?php if ($rxmodule['cpplugin'] <> '') echo 'onfocus="javascript:linkToColor(-1,-1,ftpicker,\'VALUE7\');"'; ?> title="Hier die Rahmenfarbe für die einzelnen Bilder angeben" type="text" style="width:8.0em;" maxlength="7" name="VALUE[7]" id="VALUE7" value="<?php echo $rxmodule['imgbordercolor']; ?>" /> | |
<?php if ($rxmodule['cpplugin'] <> '') echo '<a href="javascript:posPicker(-1,-1,ftpicker,\'VALUE7\');">Farbe auswählen</a>'; ?> | |
</td> | |
</tr> | |
<?php if ($rxmodule['rexversion'] >= '40') { // ab REDAXO 4.0.x ?> | |
<tr> | |
<td style="padding:3px;" valign="top"><strong>Grafik-Filter für das Magazinlayout</strong><br /> | |
mehrere Filter in der gewünschten Reihenfolge durch Komma getrennt | |
</td> | |
<td style="padding:3px;" valign="top"> | |
<input type="text" size="50" style="width:98%;" name="rexname[8]" value="<?php echo $rxmodule['filter']; ?>" /> | |
Vorhandene Filter: | |
<?php | |
$dir = $REX['INCLUDE_PATH'] . '/addons/image_resize/filters/'; | |
$k = ''; | |
if ( $dh = @opendir($dir) ) { | |
while ( ($file = @readdir($dh)) !== false ) { | |
if ( strstr($file, '.inc.php') and is_file($dir.$file) ) { | |
$va = explode('.', $file); | |
echo $k . $va[1]; | |
$k = ', '; | |
} | |
} | |
@closedir($dh); | |
} | |
?> | |
</td> | |
</tr> | |
<?php } ?> | |
--> | |
<tr><td style="padding:3px;"> </td><td> </td></tr> | |
<tr> | |
<td style="padding:3px;"><strong>Zufallsbilder anzeigen</strong></td> | |
<td style="padding:3px;"> | |
<select name="rexname[3]" style="width:8.5em;"> | |
<?php | |
foreach (array(0=>'nein',1=>'ja') as $key=>$value) { | |
echo '<option value="' . $key . '" '; | |
if ( $rxmodule['randompic'] == "$key" ) { | |
echo 'selected="selected" '; | |
} | |
echo '>' . $value . '</option>'; | |
} | |
?> | |
</select> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding:3px;" valign="top"><strong>Anzahl Bilder die angezeigt werden sollen</strong></td> | |
<td style="padding:3px;"> | |
<input title="Hier die gewünschte Anzahl an Bildern eingeben" type="text" style="width:8.0em;" maxlength="3" name="rexname[4]" value="<?php echo $rxmodule['randompiccount']; ?>" /> | |
<br /> | |
Hinweis: Es werden entsprechend viele Bilder aus den ausgewählten Bildern, der ausgewählten Medienpool-Kategorie, oder die entsprechende Anzahl an Zufallsbildern angezeigt | |
</td> | |
</tr> | |
<!-- | |
<tr> | |
<td style="padding:3px;" valign="top"><strong>Einzelbilder verlinken</strong></td> | |
<td style="padding:3px;"> | |
<select name="rexname[5]" style="width:8.5em;"> | |
<?php | |
foreach (array(1=>'ja', 0=>'nein') as $key=>$value) { | |
echo '<option value="' . $key . '" '; | |
if ( $rxmodule['linkpics'] == "$key" ) { | |
echo 'selected="selected" '; | |
} | |
echo '>' . $value . '</option>'; | |
} | |
?> | |
</select> | |
<br /> | |
Hinweis: Bei <em>nein</em> wird das gesamte Magazinlayout verlinkt.<br /> | |
Auswirkung nur bei Anzeige mit einem Addon (Lightbox usw.). Bei Klick wird die gesamte Galerie angezeigt, beginnend mit dem 1. Bild | |
</td> | |
</tr> | |
--> | |
</table> | |
<!-- | |
<a id="togglemoduleplusoptions" style="cursor:pointer;"><strong>[ Mehr Optionen ein/ausblenden ]</strong></a><br /> | |
<div id="moduleplusoptions" style="display:none;"> | |
<table width="98%" border="0"> | |
<tr> | |
<td style="padding:3px;"><strong style="display:block;width:185px;"> </strong></td> | |
<td style="padding:3px;" width="100%" align="right"> </td> | |
</tr> | |
<tr> | |
<td style="padding:3px;" valign="top"><strong>maximale Bildgröße für die Galeriebilder</strong></td> | |
<td style="padding:3px;" valign="top"> | |
<input type="text" size="7" style="width:8.0em;" name="rexname[6]" value="<?php echo $rxmodule['galimgsize']; ?>" /> | |
<br />(w=Breite, h=Höhe, a=die längere Seite, z.B.: 128w) | |
</td> | |
</tr> | |
<?php if ($rxmodule['rexversion'] >= '40') { // ab REDAXO 4.0.x ?> | |
<tr> | |
<td style="padding:3px;" valign="top"><strong>Grafik-Filter für die Galeriebilder</strong><br /> | |
<strong>(nur in Verbindung mit maximaler Bildgröße der Galeriebilder)</strong><br /> | |
mehrere Filter in der gewünschten Reihenfolge durch Komma getrennt | |
</td> | |
<td style="padding:3px;" valign="top"> | |
<input type="text" size="50" style="width:98%;" name="rexname[9]" value="<?php echo $rxmodule['galfilter']; ?>" /> | |
Vorhandene Filter: | |
<?php | |
$dir = $REX['INCLUDE_PATH'] . '/addons/image_resize/filters/'; | |
$k = ''; | |
if ( $dh = @opendir($dir) ) { | |
while ( ($file = @readdir($dh)) !== false ) { | |
if ( strstr($file, '.inc.php') and is_file($dir.$file) ) { | |
$va = explode('.', $file); | |
echo $k . $va[1]; | |
$k = ', '; | |
} | |
} | |
@closedir($dh); | |
} | |
?> | |
</td> | |
</tr> | |
<?php } ?> | |
<tr><td style="padding:3px;"> </td><td> </td></tr> | |
<tr> | |
<td style="padding:3px;" valign="top"><strong>CSS-Klasse</strong> (optional)</td> | |
<td style="padding:3px;"> | |
<input title="Hier die CSS-Klasse für das Modul angeben (optional)" type="text" style="width:100%;" name="VALUE[3]" value="<?php echo $rxmodule['cssclass']; ?>" /> | |
<br /><em>Wrapt einen DIV-Container mit der Klasse um das Magazinlayout</em> | |
</td> | |
</tr> | |
<tr><td style="padding:3px;"> </td><td> </td></tr> | |
<tr> | |
<td style="padding:3px;vertical-align:top;" valign="top"><strong>Pre-HTML</strong></td> | |
<td style="padding:3px;" valign="top"> | |
<textarea rows="2" title="Doppelklick für mehr/weniger Zeilen" ondblclick="this.rows!=8 ? this.rows=8 : this.rows=2;" style="width:98%;" name="rexname[10]"><?php echo $rxmodule['prehtml']; ?></textarea> | |
</td> | |
</tr> | |
<tr> | |
<td style="padding:3px;vertical-align:top;" valign="top"><strong>Post-HTML</strong></td> | |
<td style="padding:3px;" valign="top"> | |
<textarea rows="2" title="Doppelklick für mehr/weniger Zeilen" ondblclick="this.rows!=8 ? this.rows=8 : this.rows=2;" style="width:98%;" name="rexname[11]"><?php echo $rxmodule['posthtml']; ?></textarea> | |
</td> | |
</tr> | |
</table> | |
</div> | |
--> | |
<script type="text/javascript"> | |
function addEvent( obj, type, fn ) | |
{ | |
if (obj.addEventListener) { | |
obj.addEventListener( type, fn, false ); | |
} else if (obj.attachEvent) { | |
obj["e"+type+fn] = fn; | |
obj[type+fn] = function() { obj["e"+type+fn]( window.event ); } | |
obj.attachEvent( "on"+type, obj[type+fn] ); | |
} | |
} | |
function rex_media_preview(){ | |
var strFileName = document.getElementById("REX_MEDIALIST_SELECT_1").value; | |
if ( (strFileName.lastIndexOf(".jpg")>0) || (strFileName.lastIndexOf(".jpeg")>0) || (strFileName.lastIndexOf(".gif")>0) || (strFileName.lastIndexOf(".png")>0) || (strFileName.lastIndexOf(".bmp")>0) ) { | |
newImage = new Image(); | |
newImage.onload = function() { | |
document.getElementById("REX_MEDIALIST_PREVIEW").src = newImage.src; | |
document.getElementById("REX_MEDIALIST_PREVIEWC").style.display = "block"; | |
} | |
newImage.src = "../index.php?rex_resize=196a__"+document.getElementById("REX_MEDIALIST_SELECT_1").value; | |
} else { | |
document.getElementById("REX_MEDIALIST_PREVIEWC").style.display = "none"; | |
} | |
} | |
function rex_media_hidepreview(){ | |
document.getElementById("REX_MEDIALIST_PREVIEWC").style.display = "none"; | |
} | |
function rex_toggle_plusoptions(){ | |
if ( document.getElementById("moduleplusoptions").style.display == "none" ) { | |
document.getElementById("moduleplusoptions").style.display = "block"; | |
} else { | |
document.getElementById("moduleplusoptions").style.display = "none"; | |
} | |
} | |
addEvent(document.getElementById("REX_MEDIALIST_SELECT_1"), "change", rex_media_preview); | |
addEvent(document.getElementById("REX_MEDIALIST_SELECT_1"), "click", rex_media_preview); | |
addEvent(document.getElementById("REX_MEDIALIST_PREVIEW"), "click", rex_media_hidepreview); | |
addEvent(document.getElementById("togglemoduleplusoptions"), "click", rex_toggle_plusoptions); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* -------------------------------------------------------------------- | |
* | |
* Modul-Output: magazin_Layout, Ausgabe von Bildern im Magazin-Layout | |
* Version: 1.8, 15.10.2010 | |
* | |
* Autor: Andreas Eberhard, [email protected] | |
* http://rex.andreaseberhard.de | |
* | |
* 2 bis n Bilder werden automatisch in der Größe angepasst und | |
* in einem "Magazin-Layout"-Block angeordnet. | |
* | |
* Verwendung findet eine "leicht" angepasste Original-PHP-Klasse von | |
* Harvey Kane. | |
* Das Originalscript ist zu finden auf | |
* http://ragepank.com/magazine-layouts/ | |
* Eine Beschreibung der Funktionalität der PHP-Klasse unter | |
* http://alistapart.com/articles/magazinelayout/ | |
* | |
* Features: | |
* - Einzel-Auswahl der Biler aus dem Medienpool oder einer Kategorie aus Medienpool | |
* - Zufallsbilder möglich | |
* - Bildergalerie über Addons (z.B. Lightbox) | |
* - Grafikfilter möglich | |
* | |
* -------------------------------------------------------------------- | |
* | |
* Das Modul benötigt die Aktion "rexnames", bei Presave-Action ADD+EDIT | |
* und bei Postsave-Action ADD+EDIT (REDAXO 4.x) | |
* [POST|ADD|EDIT] und [PRE|ADD|EDIT] bei Redaxo 3.x | |
* | |
* PHP-Code für Aktion "rexnames" (### entfernen!): | |
* | |
<###?php | |
$rexname = rex_request("rexname", "array"); | |
$newname = ""; | |
for ($c = 0; $c < 99; $c++) | |
{ | |
if (isset($rexname[$c])) | |
{ | |
$newname .= $rexname[$c] . '~~'; | |
} else { | |
$newname .= '~~'; | |
} | |
} | |
if (isset($REX_ACTION['VALUE'][1]) and $REX_ACTION['VALUE'][1] != '') | |
{ | |
$rexname = preg_split('/~~/', $REX_ACTION['VALUE'][1]); | |
} else { | |
$REX_ACTION['VALUE'][1] = $newname; | |
} | |
?###> | |
* | |
* -------------------------------------------------------------------- | |
* | |
* Verwendete Redaxo-Variablen: | |
* | |
* REX_VALUE[1] rexnames | |
* rexname[0] Breite Magazinlayout | |
* rexname[1] Medienpool-Kategorie als Bilderquelle | |
* rexname[2] Ausrichtung des Magazinlayouts | |
* rexname[3] Schalter für Zufallsbilder | |
* rexname[4] Anzahl für Zufallsbilder | |
* rexname[5] Einzelbilder verlinken | |
* rexname[6] Bild-Größe für die Galeriebilder | |
* rexname[7] - | |
* rexname[8] Filter für das Magazinlayout (REDAXO 4.0.x) | |
* rexname[9] Filter für die Galeriebilder (REDAXO 4.0.x) | |
* rexname[10] Pre-HTML | |
* rexname[11] Post-HTML | |
* REX_VALUE[2] Abstand zwischen den Bildern | |
* REX_VALUE[3] CSS-Klasse für Wrapper-Div | |
* REX_VALUE[4] Anzeigetyp / Anzeige-Addon | |
* REX_VALUE[5] Hintergrundfarbe Magazinlayout | |
* REX_VALUE[6] Rahmenfarbe Magazinlayout | |
* REX_VALUE[7] Rahmenfarbe für Bilder | |
* REX_VALUE[8] Bildbeschriftung aus dem Medienpool | |
* REX_VALUE[9] Blockbildung | |
* REX_VALUE[10] Zufallszahl für mehrfache Einbindung | |
* REX_MEDIALIST[1] ausgewählte Bilder aus dem Medienpool | |
* | |
* -------------------------------------------------------------------- | |
* | |
* Changelog: | |
* 15.10.2010 Version 1.8 | |
* - Anpassung an REDAXO 4.3.x und höher | |
* - Code für Action rexnames angepasst | |
* - Möglichkeit zur Auswahl einer beliebigen Lightbox hinzugefügt | |
* (Tipp: im Output-Modul nach 'fancybox' suchen) | |
* - Maximale Bildgröße/Filter werden jetzt auch beim Popup berücksichtigt | |
* 15.05.2009 Version 1.7 | |
* - Anpassung an REDAXO 4.2.x ($REX_USER -> $REX['USER']) | |
* - jetzt auch Kategorie + Einzelauswahl möglich | |
* - Anpassungen Backend | |
* - Warning beseitigt wenn keine Bilder ausgewählt sind | |
* - Code für Action angepasst ($rexname = rex_request...) | |
* 25.08.2008 Version 1.6 | |
* - Fehler bei mehrfacher Einbindung mit Auswahl über Medialiste | |
* 08.07.2008 Version 1.5 | |
* - neuer Parameter für Ausrichtung des Magazinlayouts (links/mitte/rechts) (rexname[2]) | |
* - neuer Parameter Bildgröße für Bildergalerie (rexname[6]) | |
* - neue Parameter Grafik-Filter für Thumbnails und Bildergalerie (rexname[8],rexname[9]) | |
* - neue Option Zufallsbilder anzeigen (rexname[3]) | |
* - neue Option Anzahl Zufallsbilder/Bilder (rexname[4]) | |
* - neue Optionen PRE+POST-Html (rexname[10]+rexname[11]) | |
* - Anpassung der Auswahl Medienpool-Kategorie an Redaxo 3.2.x und 4.x | |
* - Anpassung an Redaxo 3.01 und 3.11 | |
* - Bildervorschau jetzt unter dem REX_MEDIALIST_BUTTON | |
* - Modul-Backend überarbeitet | |
* - Dokumentation der Redaxo-Variablen | |
* - PHP Warnings/Notices usw. entfernt | |
* - erweitert für Addons Lytebox, Lightview, Shadowbox | |
* - Ausgabe überarbeitet, angepasst an neue Optionen | |
* - Caching der Modulausgabe | |
* - Bugfix bei Auswahl Medienpool-Kategorie als Bilderquelle | |
* - Vorgabe einer CSS-Klasse wrapt jetzt einen Div-Container um das gesamte Magazinlayout | |
* - kleinere Bugfixes an der magazinelayout-Klasse | |
* 24.07.2007 Version 1.4 | |
* INPUT-Modul | |
* - rexnames[] für Magazinlayout-Breite und weitere Optionen | |
* - Medienpool-Kategorie als Bilderquelle auswählen (inkl. Zugriffs-Berechtigungen) | |
* - Prüfung der Addons geändert (OOAddon::isActivated) | |
* - Anpassung an Redaxo 3.3 Beta2 | |
* OUTPUT-Modul | |
* - rexnames[] für Magazinlayout-Breite und weitere Optionen | |
* - Bilder aus Medienpool-Kategorie ermitteln | |
* - Defaultwerte erweitert/überarbeitet | |
* 29.05.2007 Version 1.3 | |
* INTPUT-Modul | |
* - Defaultwerte entfernt | |
* - Neues Feld für Bildbeschriftungen | |
* - Addon Slimbox eingefügt | |
* OUTPUT-Modul | |
* - Defaultwerte können jetzt global über das Output-Modul | |
* gesteuert werden | |
* - Bildbeschriftung aus Medienpool laut Backend-Konfiguration | |
* übernehmen | |
* - Addon Slimbox eingefügt | |
* - XHTML 1.0 STRICT valider Code | |
* 19.02.2007 Version 1.2 | |
* OUTPUT-Modul | |
* - Ausgabe überarbeitet, Fehler bei Mozilla im strict-Mode | |
* 10.02.2007 Version 1.1 | |
* OUTPUT-Modul | |
* - Bugfix: Backenderror wenn ein Bild des Magazin-Layouts aus dem | |
* Medienpool gelöscht wurde behoben | |
* 30.01.2007 Version 1.0 Erste Version | |
* | |
* -------------------------------------------------------------------- | |
* | |
* Beispiel CSS (nicht unbedingt erforderlich): | |
.magazine-layout { | |
position: relative; | |
width: 100%; | |
} | |
.magazine-container { | |
background: #f6f6f6; | |
} | |
/ * magazin_Layout mit verlinkten Einzelbildern * / | |
.magazine-image a, .magazine-image a:link, .magazine-image a:visited { | |
color: #000; | |
display: table; | |
display: inline-block; | |
filter: alpha(opacity=80); | |
line-height: 0.0em; | |
opacity: 0.80; | |
-moz-opacity: 0.80; | |
} | |
.magazine-image a:focus, .magazine-image a:hover, .magazine-image a:active { | |
color: #000; | |
filter: alpha(opacity=100); | |
opacity: 1.00; | |
-moz-opacity: 1.00; | |
} | |
/ * komplett verlinktes magazin_Layout * / | |
a.magazine-link, a:link.magazine-link, a:visited.magazine-link { | |
cursor: pointer; | |
display: table; | |
display: inline-block; | |
filter: alpha(opacity=80); | |
line-height: 0.0em; | |
opacity: 0.80; | |
-moz-opacity: 0.80; | |
} | |
a:focus.magazine-link, a:hover.magazine-link, a:active.magazine-link { | |
cursor: pointer; | |
filter: alpha(opacity=100); | |
opacity: 1.00; | |
-moz-opacity: 1.00; | |
} | |
* -------------------------------------------------------------------- | |
*/ | |
/* -------------------------------------------------------------------- | |
* Der Programmcode für Redaxo am Ende dieses Moduls ! ! ! | |
* !! Ab hier die (fast) original PHP-Klasse von Harvey Kane | |
* !! | |
* \/ | |
* | |
*/ | |
?> | |
<?php | |
global $_sw_gallery_index; | |
if(!isset($_sw_gallery_index)) | |
{ | |
$_sw_gallery_index = 0; | |
} | |
else | |
{ | |
$_sw_gallery_index = $_sw_gallery_index + 1; | |
} | |
if (!class_exists('magazinelayout')) { | |
class magazinelayout | |
{ | |
var $images = array(); | |
var $_numimages = 0; | |
var $_magheight = 0; | |
var $_fullwidth; | |
var $_imagetemplate = ""; | |
var $_padding = 5; | |
var $_imgbordercolor = ''; | |
var $_linkimgsize = ''; | |
function magazinelayout($maxwidth=600,$padding=5,$imagetemplate='',$imgbordercolor='',$linkimgsize) | |
{ | |
$this->_fullwidth = $maxwidth; | |
$this->_padding = $padding; | |
$this->_imgbordercolor = $imgbordercolor; | |
$this->_linkimgsize = $linkimgsize; | |
if ($imagetemplate != '') $this->_imagetemplate = $imagetemplate; | |
} | |
/* Gets the file extension for a given filename */ | |
function _getFileExt($file) | |
{ | |
$ext = explode(".", $file); | |
if (count($ext) == 0) return ''; | |
return $ext[count($ext)-1]; | |
} | |
/* Converts the format of a 2D array from $arr[a][b] to $arr[b][a] - used for sorting the array*/ | |
function _transpose($arr) | |
{ | |
foreach($arr as $keyx => $valx) { | |
foreach($valx as $keyy => $valy) { | |
$newarr[$keyy][$keyx] = $valy; | |
} | |
} | |
return $newarr; | |
} | |
function magWidth() { | |
return $this->_fullwidth; | |
} | |
function magHeight() { | |
return $this->_magheight; | |
} | |
function addImage($filename,$url='',$title='') | |
{ | |
if ($url == '') $url = $filename; | |
/* Ensure the file is an image */ | |
if ( | |
(strtolower($this->_getFileExt($filename)) != "jpg") && | |
(strtolower($this->_getFileExt($filename)) != "jpeg") && | |
(strtolower($this->_getFileExt($filename)) != "gif") && | |
(strtolower($this->_getFileExt($filename)) != "png") | |
) { | |
return false; | |
} | |
/* Read the dimensions of the image */ | |
$imagesize = getimagesize($filename); | |
$w = $imagesize[0]; | |
$h = $imagesize[1]; | |
/* don't include zero sized images */ | |
if (($h == 0) || ($w == 0)) return false; | |
/* Find the ration of width:height */ | |
$ratio = $w / $h; | |
/* Set format based on the dimensions */ | |
$format = ($w > $h) ? 'landscape' : 'portrait'; | |
/* Keep a count on the total number of images */ | |
$this->_numimages++; | |
/* Save all image details to an array */ | |
$i = $this->_numimages - 1; | |
$this->images[$i] = array(); | |
$this->images[$i]['filename'] = $filename; | |
$this->images[$i]['url'] = $url; | |
$this->images[$i]['format'] = $format; | |
$this->images[$i]['ratio'] = $ratio; | |
$this->images[$i]['w'] = $w; //Not currently used | |
$this->images[$i]['h'] = $h; //Not currently used | |
$this->images[$i]['title'] = $title; | |
return true; | |
} | |
/* Replaces variables into the supplied image template */ | |
function insertImage($size,$name,$korrw=0,$korrh=0) | |
{ | |
foreach ($this->images as $i) { | |
if ($i['filename'] == $name) { | |
$img['owidth'] = $i['w']; | |
$img['oheight'] = $i['h']; | |
$img['title'] = $i['title']; | |
} | |
} | |
$name = basename($name); | |
$psize = $this->_linkimgsize; | |
if ( (substr($psize, 0, 1) == 'h') or (substr($psize, 0, 1) == 'w') ) { | |
$img['resizeto'] = substr($psize, 1); | |
$img['resizes'] = substr($psize, 0, 1); | |
} else { | |
$img['resizeto'] = $psize; | |
$img['resizes'] = 'w'; | |
} | |
if ($img['resizes']=='h') { | |
$img['pheight'] = $img['resizeto']; | |
$img['pwidth'] = $img['resizeto'] * $img['owidth'] / $img['oheight']; | |
$img['pwidth'] = intval($img['pwidth']); | |
} else { | |
$img['pwidth'] = $img['resizeto']; | |
$img['pheight'] = $img['resizeto'] * $img['oheight'] / $img['owidth']; | |
$img['pheight'] = intval($img['pheight']); | |
} | |
if ( (trim($img['pwidth'])=='') or (trim($img['pwidth'])=='0') or (trim($img['pheight'])=='') or (trim($img['pheight'])=='0') ) { | |
$img['pwidth'] = $img['owidth']; | |
$img['pheight'] = $img['oheight']; | |
} | |
if ( (substr($size, 0, 1) == 'h') or (substr($size, 0, 1) == 'w') ) { | |
$img['resizeto'] = substr($size, 1); | |
$img['resizes'] = substr($size, 0, 1); | |
$size = substr($size, 1) . substr($size, 0, 1); | |
} else { | |
$img['resizeto'] = $size; | |
$img['resizes'] = 'w'; | |
$size = $size . 'w'; | |
} | |
if ($img['resizes']=='h') { | |
$img['rheight'] = $img['resizeto']; | |
$img['rwidth'] = $img['resizeto'] * $img['owidth'] / $img['oheight']; | |
$img['rwidth'] = intval($img['rwidth']); | |
} else { | |
$img['rwidth'] = $img['resizeto']; | |
$img['rheight'] = $img['resizeto'] * $img['oheight'] / $img['owidth']; | |
$img['rheight'] = intval($img['rheight']); | |
} | |
if ( (trim($img['rwidth'])=='') or (trim($img['rwidth'])=='0') or (trim($img['rheight'])=='') or (trim($img['rheight'])=='0') ) { | |
$img['rwidth'] = $img['owidth']; | |
$img['rheight'] = $img['oheight']; | |
} | |
$img['borderstyle'] = 'style="'; | |
if ( $this->_imgbordercolor <> '' ) { | |
$img['borderstyle'] .= 'margin:0;padding:0;border: solid 1px '.$this->_imgbordercolor.';'; | |
} else { | |
$img['borderstyle'] .= 'margin:0;padding:0;border:0;'; | |
} | |
$img['borderstyle'] .= '"'; | |
$img['html'] = str_replace('[size]', $size, $this->_imagetemplate); | |
$img['html'] = str_replace('[image]', $name, $img['html']); | |
$img['html'] = str_replace('[width]', $img['rwidth']+$korrw, $img['html']); | |
$img['html'] = str_replace('[height]', $img['rheight']+$korrh, $img['html']); | |
$img['html'] = str_replace('[owidth]', $img['owidth'], $img['html']); | |
$img['html'] = str_replace('[oheight]', $img['oheight'], $img['html']); | |
$img['html'] = str_replace('[owidth+]', ($img['owidth']+20), $img['html']); | |
$img['html'] = str_replace('[oheight+]', ($img['oheight']+20), $img['html']); | |
$img['html'] = str_replace('[pwidth+]', ($img['pwidth']+20), $img['html']); | |
$img['html'] = str_replace('[pheight+]', ($img['pheight']+20), $img['html']); | |
$img['html'] = str_replace('[title]', $img['title'], $img['html']); | |
$img['html'] = str_replace('[borderstyle]', $img['borderstyle'], $img['html']); | |
return $img['html']; | |
} | |
/* Replaces variables into the supplied image template */ | |
function getWidth($size,$name) { | |
foreach ($this->images as $i) { | |
if ($i['filename'] == $name) { | |
$img['owidth'] = $i['w']; | |
$img['oheight'] = $i['h']; | |
$img['title'] = $i['title']; | |
} | |
} | |
if ( (substr($size, 0, 1) == 'h') or (substr($size, 0, 1) == 'w') ) { | |
$img['resizeto'] = substr($size, 1); | |
$img['resizes'] = substr($size, 0, 1); | |
$size = substr($size, 1) . substr($size, 0, 1); | |
} else { | |
$img['resizeto'] = $size; | |
$img['resizes'] = 'w'; | |
$size = $size . 'w'; | |
} | |
if ($img['resizes']=='h') { | |
$img['rheight'] = $img['resizeto']; | |
$img['rwidth'] = $img['resizeto'] * $img['owidth'] / $img['oheight']; | |
$img['rwidth'] = intval($img['rwidth']); | |
} else { | |
$img['rwidth'] = $img['resizeto']; | |
$img['rheight'] = $img['resizeto'] * $img['oheight'] / $img['owidth']; | |
$img['rheight'] = intval($img['rheight']); | |
} | |
if ( (trim($img['rwidth'])=='') or (trim($img['rwidth'])=='0') or (trim($img['rheight'])=='') or (trim($img['rheight'])=='0') ) { | |
$img['rwidth'] = $img['owidth']; | |
$img['rheight'] = $img['oheight']; | |
} | |
return $img['rwidth']; | |
} | |
function getHeight($size,$name) { | |
foreach ($this->images as $i) { | |
if ($i['filename'] == $name) { | |
$img['owidth'] = $i['w']; | |
$img['oheight'] = $i['h']; | |
$img['title'] = $i['title']; | |
} | |
} | |
if ( (substr($size, 0, 1) == 'h') or (substr($size, 0, 1) == 'w') ) { | |
$img['resizeto'] = substr($size, 1); | |
$img['resizes'] = substr($size, 0, 1); | |
$size = substr($size, 1) . substr($size, 0, 1); | |
} else { | |
$img['resizeto'] = $size; | |
$img['resizes'] = 'w'; | |
$size = $size . 'w'; | |
} | |
if ($img['resizes']=='h') { | |
$img['rheight'] = $img['resizeto']; | |
$img['rwidth'] = $img['resizeto'] * $img['owidth'] / $img['oheight']; | |
$img['rwidth'] = intval($img['rwidth']); | |
} else { | |
$img['rwidth'] = $img['resizeto']; | |
$img['rheight'] = $img['resizeto'] * $img['oheight'] / $img['owidth']; | |
$img['rheight'] = intval($img['rheight']); | |
} | |
if ( (trim($img['rwidth'])=='') or (trim($img['rwidth'])=='0') or (trim($img['rheight'])=='') or (trim($img['rheight'])=='0') ) { | |
$img['rwidth'] = $img['owidth']; | |
$img['rheight'] = $img['oheight']; | |
} | |
return $img['rheight']; | |
} | |
/* | |
IMAGE LAYOUTS | |
============= | |
These layouts are coded based on the number of images. | |
Some fairly heavy mathematics is used to calculate the image sizes and the excellent calculators at | |
http://www.quickmath.com/ were very useful. | |
Each of these layouts outputs a small piece of HTML code with the images and a containing div | |
around each. | |
*/ | |
function get1a($i1) { | |
/* | |
111 or 1 | |
1 | |
*/ | |
$m = $this->_imgbordercolor <> '' ? 2 : 0; | |
$s = floor($this->_fullwidth - ($this->_padding * 2) - $m); | |
$html = ''; | |
$html .= "\n <!-- get1a -->"; | |
$dw = $this->getWidth('w'.$s,$this->images[$i1]['url'])+$m; | |
$dh = $this->getHeight('w'.$s,$this->images[$i1]['url'])+$m; | |
$this->_magheight += $dh + $this->_padding; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;clear:both;\">".$this->insertImage('w'.$s,$this->images[$i1]['url'])."</div>"; | |
return $html; | |
} | |
function get2a($i1,$i2) { | |
/* | |
1122 | |
Equation: t = 4p + ha + hb Variable: h | |
*/ | |
$a = $this->images[$i1]['ratio']; | |
$b = $this->images[$i2]['ratio']; | |
$t = $this->_fullwidth; | |
$p = $this->_padding; | |
$m = $this->_imgbordercolor <> '' ? 2 : 0; | |
$h1 = floor( ((3*$p) - $t + (2*$m)) / (-$a - $b) ); | |
$re = ($this->_fullwidth-($this->_padding*2)) - | |
( | |
$this->getWidth('h'.$h1,$this->images[$i1]['url']) + $m + $this->_padding + | |
$this->getWidth('h'.$h1,$this->images[$i2]['url']) + $m | |
); | |
$r1=0;$r2=0;$r3=0;$r4=0; | |
if ( $re == 8) {$r1=4;$r2=4;} | |
if ( $re == 7) {$r1=4;$r2=3;} | |
if ( $re == 6) {$r1=3;$r2=3;} | |
if ( $re == 5) {$r1=2;$r2=3;} | |
if ( $re == 4) {$r1=2;$r2=2;} | |
if ( $re == 3) {$r1=2;$r2=1;} | |
if ( $re == 2) {$r1=1;$r2=1;} | |
if ( $re == 1) {$r1=1;} | |
$html = ''; | |
$html .= "\n <!-- get2a -->"; | |
$html .= "\n <div style=\"clear:both;font-size:0px;height:0px;line-height:0px;\"></div>"; | |
$dw = $this->getWidth('h'.$h1,$this->images[$i1]['url'])+$m+$r1; | |
$dh = $this->getHeight('h'.$h1,$this->images[$i1]['url'])+$m; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;clear:both;\">".$this->insertImage('h'.$h1,$this->images[$i1]['url'],$r1)."</div>"; | |
$dw = $this->getWidth('h'.$h1,$this->images[$i2]['url'])+$m+$r2; | |
$dh = $this->getHeight('h'.$h1,$this->images[$i2]['url'])+$m; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('h'.$h1,$this->images[$i2]['url'],$r2)."</div>"; | |
$this->_magheight += $dh + $this->_padding; | |
return $html; | |
} | |
function get3a($i1,$i2,$i3) { | |
/* | |
1223 | |
*/ | |
/* To save space in the equation */ | |
$a = $this->images[$i3]['ratio']; | |
$b = $this->images[$i1]['ratio']; | |
$c = $this->images[$i2]['ratio']; | |
$t = $this->_fullwidth; | |
$p = $this->_padding; | |
/* | |
Enter the following data at http://www.hostsrv.com/webmab/app1/MSP/quickmath/02/pageGenerate?site=quickmath&s1=equations&s2=solve&s3=advanced#reply | |
EQUATIONS | |
t = 6p + ah + bh + ch | |
VARIABLES | |
h | |
*/ | |
$m = $this->_imgbordercolor <> '' ? 2 : 0; | |
$h1 = floor( | |
((4*$p) - $t + (3*$m)) | |
/ | |
(-$a -$b -$c) | |
); | |
$re = ($this->_fullwidth-($this->_padding*2)) - | |
( | |
$this->getWidth('h'.$h1,$this->images[$i1]['url']) + $m + $this->_padding + | |
$this->getWidth('h'.$h1,$this->images[$i2]['url']) + $m + $this->_padding + | |
$this->getWidth('h'.$h1,$this->images[$i3]['url']) + $m | |
); | |
$r1=0;$r2=0;$r3=0;$r4=0; | |
if ( $re == 7) {$r1=2;$r2=3;$r3=2;} | |
if ( $re == 6) {$r1=2;$r2=2;$r3=2;} | |
if ( $re == 5) {$r1=2;$r2=1;$r3=2;} | |
if ( $re == 4) {$r1=2;$r2=1;$r3=1;} | |
if ( $re == 3) {$r1=1;$r2=1;$r3=1;} | |
if ( $re == 2) {$r2=1;$r3=1;} | |
if ( $re == 1) {$r3=1;} | |
$html = ''; | |
$html .= "\n <!-- get3a -->"; | |
$dw = $this->getWidth('h'.$h1,$this->images[$i1]['url'])+$m+$r1; | |
$dh = $this->getHeight('h'.$h1,$this->images[$i1]['url'])+$m; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;clear:both;\">".$this->insertImage('h'.$h1,$this->images[$i1]['url'],$r1)."</div>"; | |
$dw = $this->getWidth('h'.$h1,$this->images[$i3]['url'])+$m+$r3; | |
$dh = $this->getHeight('h'.$h1,$this->images[$i3]['url'])+$m; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('h'.$h1,$this->images[$i3]['url'],$r3)."</div>"; | |
$dw = $this->getWidth('h'.$h1,$this->images[$i2]['url'])+$m+$r2; | |
$dh = $this->getHeight('h'.$h1,$this->images[$i2]['url'])+$m; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('h'.$h1,$this->images[$i2]['url'],$r2)."</div>"; | |
$this->_magheight += $dh + $this->_padding; | |
return $html; | |
} | |
function get3b($i1,$i2,$i3) { | |
/* | |
1133 | |
2233 | |
*/ | |
/* To save space in the equation */ | |
$a = $this->images[$i3]['ratio']; | |
$b = $this->images[$i1]['ratio']; | |
$c = $this->images[$i2]['ratio']; | |
$t = $this->_fullwidth; | |
$p = $this->_padding; | |
/* | |
Enter the following data at http://www.hostsrv.com/webmab/app1/MSP/quickmath/02/pageGenerate?site=quickmath&s1=equations&s2=solve&s3=advanced#reply | |
EQUATIONS | |
x/a = w/b + w/c + 2p | |
w+x+4p = t | |
VARIABLES | |
w | |
x | |
*/ | |
/* width of left column with 2 small images */ | |
$m = $this->_imgbordercolor <> '' ? 2 : 0; | |
$w1 = floor( | |
-( | |
( 1 * $a * $b * $c * $p + 3 * $b * $c * $p - $b * $c * ($t-2*$m)) | |
/ | |
($a * $b + $c * $b + $a * $c) | |
) | |
); | |
/* width of right column with 1 large image */ | |
$w2 = floor( | |
($a * (-3 * $b * $p + $b * $c * $p - 3 * $c * $p + $b * ($t-2*$m) + $c * ($t-2*$m))) | |
/ | |
($a * $b + $c * $b + $a * $c) | |
); | |
$re = ($this->_fullwidth-($this->_padding*2)) - | |
( | |
$this->getWidth('w'.$w1,$this->images[$i1]['url']) + $m + $this->_padding + | |
$this->getWidth('w'.$w2,$this->images[$i3]['url']) + $m | |
); | |
$rw1=0;$rw2=0;$rw3=0; | |
if ( $re == 2) {$rw1=1;$rw2=1;$rw3=1;} | |
if ( $re == 1) {$rw3=1;} | |
$hl = $this->getHeight('w'.$w1,$this->images[$i1]['url']) + $m + $this->_padding + $this->getHeight('w'.$w1,$this->images[$i2]['url']) + $m; | |
$hr = $this->getHeight('w'.$w2,$this->images[$i3]['url']) + $m; | |
$rh = $hl - $hr; | |
$r1=0;$r2=0;$r3=0;$r4=0; | |
if ( $rh == -4) {$r1=2;$r2=2;} | |
if ( $rh == -3) {$r1=2;$r2=1;} | |
if ( $rh == -2) {$r1=1;$r2=1;} | |
if ( $rh == -1) {$r3=-1;} | |
if ( $rh == 4) {$r3=4;} | |
if ( $rh == 3) {$r3=3;} | |
if ( $rh == 2) {$r3=2;} | |
if ( $rh == 1) {$r3=1;} | |
$html = ''; | |
$html .= "\n <!-- get3b -->"; | |
$html .= "\n <div style=\"clear:both;font-size:0px;height:0px;line-height:0px;\"></div>"; | |
$dw = $this->getWidth('w'.$w2,$this->images[$i3]['url'])+$m+$rw3; | |
$dh = $this->getHeight('w'.$w2,$this->images[$i3]['url'])+$m+$r3; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px ".$this->_padding."px 0px ".$this->_padding."px;float:right;clear:both;\">".$this->insertImage('w'.$w2,$this->images[$i3]['url'],$rw3,$r3)."</div>"; | |
$this->_magheight += $dh + $this->_padding; | |
$dw = $this->getWidth('w'.$w1,$this->images[$i1]['url'])+$m+$rw1; | |
$dh = $this->getHeight('w'.$w1,$this->images[$i1]['url'])+$m+$r1; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('w'.$w1,$this->images[$i1]['url'],$rw1,$r1)."</div>"; | |
$dw = $this->getWidth('w'.$w1,$this->images[$i2]['url'])+$m+$rw2; | |
$dh = $this->getHeight('w'.$w1,$this->images[$i2]['url'])+$m+$r2; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('w'.$w1,$this->images[$i2]['url'],$rw2,$r2)."</div>"; | |
return $html; | |
} | |
function get4a($i1,$i2,$i3,$i4) { | |
/* | |
1234 | |
*/ | |
/* To save space in the equation */ | |
$a = $this->images[$i1]['ratio']; | |
$b = $this->images[$i2]['ratio']; | |
$c = $this->images[$i3]['ratio']; | |
$d = $this->images[$i4]['ratio']; | |
$t = $this->_fullwidth; | |
$p = $this->_padding; | |
/* | |
Enter the following data at http://www.hostsrv.com/webmab/app1/MSP/quickmath/02/pageGenerate?site=quickmath&s1=equations&s2=solve&s3=advanced#reply | |
EQUATIONS | |
t = 6p + ah + bh + ch + dh | |
VARIABLES | |
h | |
*/ | |
$m = $this->_imgbordercolor <> '' ? 2 : 0; | |
$h1 = floor( | |
(5 * $p - $t + (3*$m)) | |
/ | |
(-$a -$b -$c -$d) | |
); | |
$re = ($this->_fullwidth-($this->_padding*2)) - | |
( | |
$this->getWidth('h'.$h1,$this->images[$i1]['url']) + $m + $this->_padding + | |
$this->getWidth('h'.$h1,$this->images[$i2]['url']) + $m + $this->_padding + | |
$this->getWidth('h'.$h1,$this->images[$i3]['url']) + $m + $this->_padding + | |
$this->getWidth('h'.$h1,$this->images[$i4]['url']) + $m | |
); | |
$r1=0;$r2=0;$r3=0;$r4=0; | |
if ( $re == 5) {$r1=2;$r2=1;$r3=1;$r4=1;} | |
if ( $re == 4) {$r1=1;$r2=1;$r3=1;$r4=1;} | |
if ( $re == 3) {$r1=1;$r2=1;$r3=1;} | |
if ( $re == 2) {$r2=1;$r3=1;} | |
if ( $re == 1) {$r4=1;} | |
$html = ''; | |
$html .= "\n <!-- get4a -->"; | |
$dw = $this->getWidth('h'.$h1,$this->images[$i1]['url'])+$m+$r1; | |
$dh = $this->getHeight('h'.$h1,$this->images[$i1]['url'])+$m; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;clear:both;\">".$this->insertImage('h'.$h1,$this->images[$i1]['url'],$r1)."</div>"; | |
$dw = $this->getWidth('h'.$h1,$this->images[$i2]['url'])+$m+$r2; | |
$dh = $this->getHeight('h'.$h1,$this->images[$i2]['url'])+$m; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('h'.$h1,$this->images[$i2]['url'],$r2)."</div>"; | |
$dw = $this->getWidth('h'.$h1,$this->images[$i3]['url'])+$m+$r3; | |
$dh = $this->getHeight('h'.$h1,$this->images[$i3]['url'])+$m; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('h'.$h1,$this->images[$i3]['url'],$r3)."</div>"; | |
$dw = $this->getWidth('h'.$h1,$this->images[$i4]['url'])+$m+$r4; | |
$dh = $this->getHeight('h'.$h1,$this->images[$i4]['url'])+$m; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('h'.$h1,$this->images[$i4]['url'],$r4)."</div>"; | |
$this->_magheight += $dh + $this->_padding; | |
return $html; | |
} | |
function get4b($i1,$i2,$i3,$i4) { | |
/* | |
11444 | |
22444 | |
33444 | |
*/ | |
/* To save space in the equation */ | |
$a = $this->images[$i4]['ratio']; | |
$b = $this->images[$i1]['ratio']; | |
$c = $this->images[$i2]['ratio']; | |
$d = $this->images[$i3]['ratio']; | |
$t = $this->_fullwidth; | |
$p = $this->_padding; | |
$m = $this->_imgbordercolor <> '' ? 2 : 0; | |
/* | |
Enter the following data at http://www.hostsrv.com/webmab/app1/MSP/quickmath/02/pageGenerate?site=quickmath&s1=equations&s2=solve&s3=advanced#reply | |
EQUATIONS | |
x/a = w/b + w/c + 2p | |
w+x+4p = t | |
VARIABLES | |
w | |
x | |
*/ | |
$w1 = floor( | |
-( | |
(2 * $a * $b * $c * $d * $p + 3 * $b * $c * $d * $p - $b * $c * $d * ($t-3*$m)) | |
/ | |
($a * $b * $c + $a * $d * $c + $b * $d * $c + $a * $b * $d) | |
) | |
); | |
/* width of right column with 1 large image */ | |
$w2 = floor( | |
-( | |
(-2 * $p - (-(1/$c) -(1/$d) -(1/$b)) * (3 * $p - ($t-2*$m)) ) | |
/ | |
( (1/$b) + (1/$c) + (1/$d) + (1/$a) ) | |
) | |
); | |
$re = ($this->_fullwidth-($this->_padding*2)) - | |
( | |
$this->getWidth('w'.$w1,$this->images[$i1]['url']) + $m + $this->_padding + | |
$this->getWidth('w'.$w2,$this->images[$i4]['url']) + $m | |
); | |
$rw1=0;$rw2=0;$rw3=0;$rw4=0; | |
if ( $re == 2) {$rw1=2;$rw2=2;$rw3=2;$rw4=0;} | |
if ( $re == 1) {$rw1=1;$rw2=1;$rw3=1;$rw4=0;} | |
$hl = $this->getHeight('w'.$w1,$this->images[$i1]['url']) + $m + $this->_padding + $this->getHeight('w'.$w1,$this->images[$i2]['url']) + $m + $this->_padding + $this->getHeight('w'.$w1,$this->images[$i3]['url']) + $m; | |
$hr = $this->getHeight('w'.$w2,$this->images[$i4]['url']) + $m; | |
$rh = $hl - $hr; | |
$r1=0;$r2=0;$r3=0;$r4=0; | |
if ( $rh == -3) {$r1=2;$r2=1;} | |
if ( $rh == -2) {$r1=1;$r2=1;} | |
if ( $rh == -1) {$r2=1;} | |
if ( $rh == 3) {$r4=3;} | |
if ( $rh == 2) {$r4=2;} | |
if ( $rh == 1) {$r4=1;} | |
$html = ''; | |
$html .= "\n <!-- get4b -->"; | |
$html .= "\n <div>"; | |
$dw = $this->getWidth('w'.$w2,$this->images[$i4]['url'])+$m+$rw4; | |
$dh = $this->getHeight('w'.$w2,$this->images[$i4]['url'])+$m+$r4; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px ".$this->_padding."px 0px ".$this->_padding."px;float:right;clear:both;\">".$this->insertImage('w'.$w2,$this->images[$i4]['url'],$rw4,$r4)."</div>"; | |
$this->_magheight += $dh + $this->_padding; | |
$dw = $this->getWidth('w'.$w1,$this->images[$i1]['url'])+$m+$rw1; | |
$dh = $this->getHeight('w'.$w1,$this->images[$i1]['url'])+$m+$r1; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('w'.$w1,$this->images[$i1]['url'],$rw1,$r1)."</div>"; | |
$dw = $this->getWidth('w'.$w1,$this->images[$i2]['url'])+$m+$rw2; | |
$dh = $this->getHeight('w'.$w1,$this->images[$i2]['url'])+$m+$r2; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('w'.$w1,$this->images[$i2]['url'],$rw2,$r2)."</div>"; | |
$dw = $this->getWidth('w'.$w1,$this->images[$i3]['url'])+$m+$rw3; | |
$dh = $this->getHeight('w'.$w1,$this->images[$i3]['url'])+$m+$r3; | |
$html .= "\n <div style=\"width:".$dw."px;height:".$dh."px;padding: 0px 0px ".$this->_padding."px ".$this->_padding."px;float:left;\">".$this->insertImage('w'.$w1,$this->images[$i3]['url'],$rw3,$r3)."</div>"; | |
$html .= "\n </div>\n"; | |
return $html; | |
} | |
function getHtml() { | |
/* Sort the images array landscape first, then portrait */ | |
$this->images = $this->_transpose($this->images); | |
array_multisort($this->images['format'], SORT_STRING, SORT_ASC, $this->images['url'], $this->images['ratio']); | |
$this->images = $this->_transpose($this->images); | |
/* Profile explains the makeup of the images (landscape vs portrait) so we can use the best layout eg. LPPP or LLLP */ | |
$profile = ''; | |
foreach ($this->images as $i) { | |
$profile .= $i['format'] == 'landscape' ? 'L' : 'P'; | |
} | |
/* Open the containing DIV */ | |
$html = ''; | |
$html .= "\n <div class=\"magazine-image\" style=\"width: ".$this->_fullwidth."px;\">"; | |
/* 1 Images */ | |
if ($this->_numimages == 1) { | |
$html .= $this->get1a(0); | |
} | |
/* 2 Images */ | |
if ($this->_numimages == 2) { | |
$html .= $this->get2a(0,1); | |
} | |
/* 3 Images */ | |
if ($this->_numimages == 3) { | |
if ($profile == 'LLL') { | |
$html .= $this->get3b(0,1,2); | |
//$html .= $this->get2a(1,2); | |
//$html .= $this->get1a(0); | |
} else { | |
$html .= $this->get3b(0,1,2); | |
} | |
} | |
/* 4 Images */ | |
if ($this->_numimages == 4) { | |
if ($profile == 'LLLP') { | |
$html .= $this->get4b(0,1,2,3); | |
} elseif ($profile == 'LPPP') { | |
$html .= $this->get3a(1,2,3); | |
$html .= $this->get1a(0); | |
} else { // LLLL LLPP PPPP | |
$html .= $this->get2a(2,0); | |
$html .= $this->get2a(1,3); | |
} | |
} | |
/* 5 Images */ | |
if ($this->_numimages == 5) { | |
if ($profile == 'LLLLL') { | |
$html .= $this->get3a(0,1,2); | |
$html .= $this->get2a(3,4); | |
} elseif ($profile == 'LLLLP') { | |
$html .= $this->get3b(0,1,4); | |
$html .= $this->get2a(2,3); | |
} elseif ($profile == 'LLLPP') { | |
$html .= $this->get3b(0,1,4); | |
$html .= $this->get2a(2,3); | |
} elseif ($profile == 'LLPPP') { | |
$html .= $this->get3b(2,3,4); | |
$html .= $this->get2a(0,1); | |
} elseif ($profile == 'LPPPP') { | |
$html .= $this->get3b(2,3,4); | |
$html .= $this->get2a(0,1); | |
} elseif ($profile == 'PPPPP') { | |
$html .= $this->get2a(4,0); | |
$html .= $this->get3a(1,2,3); | |
} | |
} | |
/* 6 Images */ | |
if ($this->_numimages == 6) { | |
if ($profile == 'LLLLLL') { | |
$html .= $this->get2a(0,1); | |
$html .= $this->get2a(2,3); | |
$html .= $this->get2a(4,5); | |
} elseif ($profile == 'LLLLLP') { | |
$html .= $this->get4b(0,1,2,5); | |
$html .= $this->get2a(3,4); | |
} elseif ($profile == 'LLLLPP') { | |
$html .= $this->get3b(0,1,4); | |
$html .= $this->get3b(2,3,5); | |
} elseif ($profile == 'LLLPPP') { | |
$html .= $this->get3b(0,1,5); | |
$html .= $this->get3b(2,3,4); | |
} elseif ($profile == 'LLPPPP') { | |
$html .= $this->get3b(0,2,4); | |
$html .= $this->get3b(1,3,5); | |
} elseif ($profile == 'LPPPPP') { | |
$html .= $this->get3b(0,1,5); | |
$html .= $this->get3a(2,3,4); | |
} elseif ($profile == 'PPPPPP') { | |
$html .= $this->get3a(3,4,5); | |
$html .= $this->get3a(0,1,2); | |
} | |
} | |
/* 7 Images */ | |
if ($this->_numimages == 7) { | |
if ($profile == 'LLLLLLL') { | |
$html .= $this->get3a(0,1,2); | |
$html .= $this->get2a(3,4); | |
$html .= $this->get2a(5,6); | |
} elseif ($profile == 'LLLLLLP') { | |
$html .= $this->get4b(0,1,2,6); | |
$html .= $this->get3a(3,4,5); | |
} elseif ($profile == 'LLLLLPP') { | |
$html .= $this->get4b(0,1,2,5); | |
$html .= $this->get3b(3,4,6); | |
} elseif ($profile == 'LLLLPPP') { | |
$html .= $this->get3b(0,1,5); | |
$html .= $this->get4b(2,3,4,6); | |
} elseif ($profile == 'LLLPPPP') { | |
$html .= $this->get3b(0,1,5); | |
$html .= $this->get4b(2,3,4,6); | |
} elseif ($profile == 'LLPPPPP') { | |
$html .= $this->get3a(4,5,6); | |
$html .= $this->get2a(0,1); | |
$html .= $this->get2a(2,3); | |
} elseif ($profile == 'LPPPPPP') { | |
$html .= $this->get3a(0,1,2); | |
$html .= $this->get4b(3,4,5,6); | |
} elseif ($profile == 'PPPPPPP') { | |
$html .= $this->get4a(0,1,2,3); | |
$html .= $this->get3b(4,5,6); | |
} | |
} | |
/* 8 Images */ | |
if ($this->_numimages >= 8) { | |
/* | |
Note this code is applied for 8 or more images - any images over 8 are ignored. Adding support | |
for more than 8 images would be easy, but the layouts do start losing their effect as more images | |
are added. | |
*/ | |
if ($profile == 'LLLLLLLL') { | |
$html .= $this->get3a(0,1,2); | |
$html .= $this->get2a(3,4); | |
$html .= $this->get3a(5,6,7); | |
} elseif ($profile == 'LLLLLLLP') { | |
$html .= $this->get4b(0,1,2,7); | |
$html .= $this->get2a(3,4); | |
$html .= $this->get2a(5,6); | |
} elseif ($profile == 'LLLLLLPP') { | |
$html .= $this->get4b(0,1,2,6); | |
$html .= $this->get4b(3,4,5,7); | |
} elseif ($profile == 'LLLLLPPP') { | |
$html .= $this->get4b(0,1,2,6); | |
$html .= $this->get4b(3,4,5,7); | |
} elseif ($profile == 'LLLLPPPP') { | |
$html .= $this->get4b(0,1,2,6); | |
$html .= $this->get4b(3,4,5,7); | |
} elseif ($profile == 'LLLPPPPP') { | |
$html .= $this->get3a(4,5,6); | |
$html .= $this->get2a(0,1); | |
$html .= $this->get3a(2,3,7); | |
} elseif ($profile == 'LLPPPPPP') { | |
$html .= $this->get3b(5,6,7); | |
$html .= $this->get2a(0,1); | |
$html .= $this->get3b(2,3,4); | |
} elseif ($profile == 'LPPPPPPP') { | |
$html .= $this->get3b(5,6,7); | |
$html .= $this->get2a(0,1); | |
$html .= $this->get3b(2,3,4); | |
} elseif ($profile == 'PPPPPPP') { | |
$html .= $this->get4a(0,1,2,3); | |
$html .= $this->get4a(4,5,6,7); | |
} else { | |
$html .= $this->get3b(5,4,7); | |
$html .= $this->get2a(1,0); | |
$html .= $this->get3b(2,3,6); | |
} | |
} | |
/* Close the containing DIV */ | |
$html .= "\n <div style=\"clear:both;font-size:0px;height:0px;line-height:0px;\"></div>\n </div>"; | |
return $html; | |
} | |
} | |
/* End of Class */ | |
/** | |
* /\ | |
* !! | |
* !! Ab hier die original PHP-Klasse von Harvey Kane | |
*/ | |
} // End class_exists | |
?> | |
<?php | |
/** | |
* -------------------------------------------------------------------- | |
* Ab hier Anpassungen für Redaxo | |
* -------------------------------------------------------------------- | |
*/ | |
if (!function_exists("file_put_contents")) { | |
function file_put_contents($path, $content) { | |
$fp = @fopen($path, "wb"); | |
if ($fp) { | |
fwrite($fp, $content); | |
fclose($fp); | |
} | |
} | |
} // End function_exists | |
if (!function_exists("magazinelayout_getimagetitle")) | |
{ | |
function magazinelayout_getimagetitle($rxmodule) { | |
if ($rxmodule['imgdesc'] == '0') { | |
$w_outtitle = ''; | |
} else { | |
$w_media = OOMedia::getMediaByName($rxmodule['w_datei']); | |
if ($w_media) { | |
if ( in_array($rxmodule['rexversion'], array('3.01', '3.11', '32')) ) { | |
$w_title = str_replace(array("\r\n", "\n", "\r"), ' ', $w_media->getTitle()); | |
$w_desc = str_replace(array("\r\n", "\n", "\r"), ' ', $w_media->getDescription()); | |
$w_copy = str_replace(array("\r\n", "\n", "\r"), ' ', $w_media->getCopyright()); | |
} else { | |
$w_title = str_replace(array("\r\n", "\n", "\r"), ' ', $w_media->getValue('title')); | |
$w_desc = str_replace(array("\r\n", "\n", "\r"), ' ', $w_media->getValue('description')); | |
$w_copy = str_replace(array("\r\n", "\n", "\r"), ' ', $w_media->getValue('copyright')); | |
} | |
} | |
if ($w_media and ($rxmodule['imgdesc'] == '1') ) { | |
$w_outtitle = $w_title; | |
} | |
if ($w_media and ($rxmodule['imgdesc'] == '2') ) { | |
$w_outtitle = $w_desc; | |
} | |
if ($w_media and ($rxmodule['imgdesc'] == '3') ) { | |
$w_outtitle = $w_copy; | |
} | |
if ($w_media and ($rxmodule['imgdesc'] == '4') ) { | |
$w_outtitle = $w_title . ' ' . $w_desc; | |
} | |
if ($w_media and ($rxmodule['imgdesc'] == '5') ) { | |
$w_outtitle = $w_title . ' ' . $w_copy; | |
} | |
if ($w_media and ($rxmodule['imgdesc'] == '6') ) { | |
$w_outtitle = $w_desc . ' ' . $w_copy; | |
} | |
if ($w_media and ($rxmodule['imgdesc'] == '7') ) { | |
$w_outtitle = $w_title . ' ' . $w_desc . ' ' . $w_copy; | |
} | |
} | |
return trim($w_outtitle); | |
} | |
} // End function_exists | |
if (!function_exists("magazinelayout_gettemplatebox")) | |
{ | |
function magazinelayout_gettemplatebox($rxmodule) { | |
global $_sw_gallery_index; | |
// Template: Anzeige Greybox | |
if ( $rxmodule['magazinetype'] == 'greybox') { | |
$templatebox = 'rel="gb_imageset[magazine' . $rxmodule['magazineid'] . ']"'; | |
} | |
// Template: Anzeige jQueryLightbox | |
if ( $rxmodule['magazinetype'] == 'jquerylightbox') { | |
$templatebox = 'rel="lightbox[magazine' . $rxmodule['magazineid'] . ']"'; | |
} | |
// Template: Anzeige Lightbox | |
if ( $rxmodule['magazinetype'] == 'lightbox') { | |
$templatebox = 'rel="lightbox[magazine' . $rxmodule['magazineid'] . ']"'; | |
} | |
// Template: Anzeige Lightview | |
if ( $rxmodule['magazinetype'] == 'lightview') { | |
$templatebox = 'class="lightview" rel="gallery[magazine' . $rxmodule['magazineid'] . ']"'; | |
} | |
// Template: Anzeige Lytebox | |
if ( $rxmodule['magazinetype'] == 'lytebox') { | |
$templatebox = 'rel="lytebox[magazine' . $rxmodule['magazineid'] . ']"'; | |
} | |
// Template: Anzeige Pho2 | |
if ( $rxmodule['magazinetype'] == 'pho2') { | |
$templatebox = 'rel="pho2[magazine' . $rxmodule['magazineid'] . ']"'; | |
} | |
// Template: Anzeige Shadowbox | |
if ( $rxmodule['magazinetype'] == 'shadowbox') { | |
$templatebox = 'rel="shadowbox[magazine' . $rxmodule['magazineid'] . ']"'; | |
} | |
// Template: Anzeige Slimbox | |
if ( $rxmodule['magazinetype'] == 'slimbox') { | |
$templatebox = 'rel="lightbox[magazine' . $rxmodule['magazineid'] . ']"'; | |
} | |
// Template: Anzeige Thickbox | |
if ( $rxmodule['magazinetype'] == 'thickbox') { | |
$templatebox = 'class="thickbox" rel="magazine' . $rxmodule['magazineid'] . '"'; | |
} | |
// Template: Anzeige in beliebiger Lightbox, default hier 'fancybox' | |
if ( $rxmodule['magazinetype'] == 'javascript') { | |
$templatebox = ' rel="fancybox_gallery'.$_sw_gallery_index.'"'; | |
} | |
return $templatebox; | |
} | |
} // End function_exists | |
if (!function_exists("magazinelayout_createHtml")) | |
{ | |
function magazinelayout_createHtml(&$rxmodule) { | |
global $REX; | |
// Array mischen wg. Zufallsbildern, nur die gewünschte Anzahl Bilder beibehalten | |
if ( ($rxmodule['randompic'] == 1) and (count($rxmodule['imagelist']) > 1) and ($rxmodule['randompiccount'] > 1) ) { | |
shuffle($rxmodule['imagelist']); | |
$rxmodule['totalimagelist'] = $rxmodule['imagelist']; | |
$rxmodule['imagelist'] = array_slice($rxmodule['imagelist'], 0, $rxmodule['randompiccount']); | |
} else if ((count($rxmodule['imagelist']) > 1) and ($rxmodule['randompiccount'] > 1)) { | |
$rxmodule['totalimagelist'] = $rxmodule['imagelist']; | |
$rxmodule['imagelist'] = array_slice($rxmodule['imagelist'], 0, $rxmodule['randompiccount']); | |
} else { | |
$rxmodule['totalimagelist'] = $rxmodule['imagelist']; | |
} | |
/** | |
* Template für Anzeige des Magazin-Layouts | |
*/ | |
// Im Backend nur Anzeige mit maximal 555 Pixeln breite | |
if ($REX['REDAXO']) { | |
$rxmodule['magazinetype'] = 'showonly'; | |
if ( $rxmodule['magazinewidth'] > 555 ) | |
$rxmodule['magazinewidth'] = 555; | |
// Image-Resize ist erforderlich | |
if (!OOAddon::isAvailable('image_resize')) | |
{ | |
echo '<font color="#cc0000"><strong>Dieses Modul benötigt das Addon image_resize!</strong></font><br />'; | |
} | |
} | |
// Filter für Magazinlayout | |
if ($rxmodule['filter'] <> '') { | |
$va = explode(',', $rxmodule['filter']); | |
$rxmodule['filter'] = ''; | |
foreach( $va as $fi ) { | |
$rxmodule['filter'] .= '&rex_filter[]=' . trim($fi); | |
} | |
} | |
// Filter für die Bildergalerie | |
if ($rxmodule['galfilter'] <> '') { | |
$va = explode(',', $rxmodule['galfilter']); | |
$rxmodule['galfilter'] = ''; | |
foreach( $va as $fi ) { | |
$rxmodule['galfilter'] .= '&rex_filter[]=' . trim($fi); | |
} | |
} | |
// Template für die Addons | |
if (($rxmodule['magazinetype'] <> 'popup') and ($rxmodule['magazinetype'] <> 'showonly')) { | |
$rxmodule['templatebox'] = magazinelayout_gettemplatebox($rxmodule); | |
if (trim($rxmodule['galimgsize']) <> '') { | |
$rxmodule['template'] = '<a href="' . $REX['HTDOCS_PATH'] . 'index.php?rex_resize='.$rxmodule['galimgsize'].'__[image]'.$rxmodule['galfilter'].'" title="[title]" '.$rxmodule['templatebox'].'><img src="' . $REX['HTDOCS_PATH'] . 'index.php?rex_resize=[size]__[image]'.$rxmodule['filter'].'" alt="[title]" title="[title]" width="[width]" height="[height]" [borderstyle] /></a>'; | |
} else { | |
$rxmodule['template'] = '<a href="' . $REX['HTDOCS_PATH'] . 'files/' . '[image]" title="[title]" '.$rxmodule['templatebox'].'><img src="' . $REX['HTDOCS_PATH'] . 'index.php?rex_resize=[size]__[image]'.$rxmodule['filter'].'" alt="[title]" title="[title]" width="[width]" height="[height]" [borderstyle] /></a>'; | |
} | |
} | |
// Template: Anzeige Popup | |
if ( $rxmodule['magazinetype'] == 'popup' ) { | |
$rxmodule['templatebox'] = ''; | |
if (trim($rxmodule['galimgsize']) <> '') { | |
$rxmodule['popup'] = $REX['HTDOCS_PATH'] . 'index.php?rex_resize='.$rxmodule['galimgsize'].'__[image]'.$rxmodule['galfilter']; | |
} else { | |
$rxmodule['popup'] = $REX['HTDOCS_PATH'] . 'files/' . '[image]'; | |
} | |
$rxmodule['onClick'] = 'onclick="popup=window.open(\''.$rxmodule['popup'].'\',\'magazinepopup\',\'scrollbars=no,resizable=no,status=yes,menubar=no,width=[pwidth+],height=[pheight+],top=0,left=0\'); popup.focus(); return false;"'; | |
if (trim($rxmodule['galimgsize']) <> '') { | |
$rxmodule['template'] = '<a href="' . $REX['HTDOCS_PATH'] . 'index.php?rex_resize='.$rxmodule['galimgsize'].'__[image]'.$rxmodule['galfilter'] .'"' . $rxmodule['onClick'] . '><img src="' . $REX['HTDOCS_PATH'] . 'index.php?rex_resize=[size]__[image]'.$rxmodule['filter'].'" alt="[title]" title="[title]" width="[width]" height="[height]" [borderstyle] /></a>'; | |
} else { | |
$rxmodule['template'] = '<a href="' . $REX['HTDOCS_PATH'] . 'files/' . '[image]" ' . $rxmodule['onClick'] . '><img src="' . $REX['HTDOCS_PATH'] . 'index.php?rex_resize=[size]__[image]'.$rxmodule['filter'].'" alt="[title]" title="[title]" width="[width]" height="[height]" [borderstyle] /></a>'; | |
} | |
} | |
// Template: Nur Anzeige | |
if (($rxmodule['magazinetype'] == 'showonly') or ($rxmodule['linkpics'] == 0)) { | |
$rxmodule['template'] = '<img src="' . $REX['HTDOCS_PATH'] . 'index.php?rex_resize=[size]__[image]'.$rxmodule['filter'].'" alt="[title]" title="[title]" width="[width]" height="[height]" [borderstyle] />'; | |
} | |
/** | |
* Erstellen der Klassen und hinzufügen der Bilder | |
*/ | |
$rxmodule['i'] = $rxmodule['imgblock']; | |
$rxmodule['j'] = -1; | |
$rxmodule['s'] = $rxmodule['bordercolor'] <> '' ? 2 : 0; | |
$rxmodule['Browser'] = $_SERVER['HTTP_USER_AGENT']; | |
$rxmodule['p'] = (strstr($rxmodule['Browser'], 'MSIE 5') and ($rxmodule['bordercolor'] <> '')) ? 2 : 0; | |
if ( is_array($rxmodule['imagelist']) and (count($rxmodule['imagelist']) > 0) ) { | |
foreach ($rxmodule['imagelist'] as $rxmodule['w_datei']){ | |
if ( trim($rxmodule['w_datei']) <> '' ) { | |
$rxmodule['i']++; | |
$rxmodule['w_outtitle'] = ''; | |
if ($rxmodule['i'] > $rxmodule['imgblock']) { | |
$rxmodule['j']++; | |
$rxmodule['magazine'][$rxmodule['j']] = new magazinelayout($rxmodule['magazinewidth'] - $rxmodule['s'], $rxmodule['padding'], $rxmodule['template'], $rxmodule['imgbordercolor'], $rxmodule['galimgsize']); | |
$rxmodule['i'] = 1; | |
} | |
$rxmodule['w_outtitle'] = magazinelayout_getimagetitle($rxmodule); | |
$rxmodule['magazine'][$rxmodule['j']]->addImage($REX['HTDOCS_PATH'] . 'files/' . $rxmodule['w_datei'], '', $rxmodule['w_outtitle']); | |
} | |
} | |
} | |
// Ausgabe nur wenn auch Bilder ausgewählt wurden | |
if (isset($rxmodule['magazine']) and count($rxmodule['magazine']) > 0) { | |
// Gesamthöhe (Padding oben + Rahmen) | |
$rxmodule['totalheight'] = $rxmodule['padding'] + $rxmodule['s'] + $rxmodule['p']; | |
//$rxmodule['totalwidth'] = ($rxmodule['magazinewidth'] - $rxmodule['s'] + $rxmodule['p']); | |
$rxmodule['totalwidth'] = $rxmodule['magazinewidth']; | |
// Ausgeben der einzelnen Magazin-Blöcke a max. 8 Bildern | |
$rxmodule['magoutput'] = ''; | |
foreach ($rxmodule['magazine'] as $mag){ | |
$rxmodule['magoutput'] .= $mag->getHtml(); | |
// Gesamthöhe (Magazinhöhe incl. Padding unten) | |
$rxmodule['totalheight'] += $mag->magHeight(); | |
} | |
// Beginn der Ausgabe | |
$rxmodule['moduleoutput'] = ''; | |
$rxmodule['moduleoutput'] .= "\n<!-- " . $rxmodule['moduleversion'] . " -->"; | |
// Pre-HTML ausgeben | |
if ( $rxmodule['prehtml'] <> '' ) { | |
$rxmodule['moduleoutput'] .= "\n" . html_entity_decode(stripslashes($rxmodule['prehtml'])); | |
} | |
// evtl. wrappen mit Div und vorgegebener Klasse | |
if (trim($rxmodule['cssclass'] <> '')) { | |
$rxmodule['moduleoutput'] .= "\n" . '<div class="' . $rxmodule['cssclass'] . '">'; | |
} | |
// Ausrichtung links | |
if ($rxmodule['layout'] == '0') { | |
$rxmodule['layoutstyle'] = ''; | |
} | |
// Ausrichtung mitte | |
if ($rxmodule['layout'] == '1') { | |
$rxmodule['layoutstyle'] = 'text-align:center;'; | |
} | |
// Ausrichtung rechts | |
if ($rxmodule['layout'] == '2') { | |
$rxmodule['layoutstyle'] = ''; | |
} | |
$rxmodule['moduleoutput'] .= "\n" . '<div class="magazine-layout" style="'.$rxmodule['layoutstyle'].'">'; | |
// ganzes Magazinlayout verlinkt? dann jetzt den umschliessenden Link auf das erste Bild ausgeben | |
if ( (!$REX['REDAXO']) and ( $rxmodule['linkpics'] == 0 ) and ( ($rxmodule['magazinetype'] <> 'showonly') and ($rxmodule['magazinetype'] <> 'popup') ) ) { | |
$rxmodule['templatebox'] = magazinelayout_gettemplatebox($rxmodule); | |
if ( is_array($rxmodule['totalimagelist']) and (count($rxmodule['totalimagelist']) > 0) ) { | |
$rxmodule['w_datei'] = $rxmodule['totalimagelist'][0]; | |
} | |
$rxmodule['linkstyle'] = ' style="display:block;width:'.$rxmodule['totalwidth'].'px;height:'.$rxmodule['totalheight'].'px;text-decoration:none;font-size:0px;'; | |
if ($rxmodule['layout'] == '1') { | |
$rxmodule['linkstyle'] .= 'margin: 0 auto'; | |
} | |
$rxmodule['linkstyle'] .= '"'; | |
$rxmodule['w_outtitle'] = magazinelayout_getimagetitle($rxmodule); | |
if (trim($rxmodule['galimgsize']) <> '') { | |
$rxmodule['template'] = '<a class="magazine-link" href="' . $REX['HTDOCS_PATH'] . 'index.php?rex_resize='.$rxmodule['galimgsize'].'__'.$rxmodule['w_datei'].$rxmodule['galfilter'].'" title="'.$rxmodule['w_outtitle'].'" '.$rxmodule['templatebox'].$rxmodule['linkstyle'].'>'; | |
} else { | |
$rxmodule['template'] = '<a class="magazine-link" href="' . $REX['HTDOCS_PATH'] . 'files/' .$rxmodule['w_datei']. '" title="'.$rxmodule['w_outtitle'].'" '.$rxmodule['templatebox'].$rxmodule['linkstyle'].'>'; | |
} | |
$rxmodule['moduleoutput'] .= "\n".$rxmodule['template']; | |
} | |
// umschliessender DIV für Hintergrundfarbe, Rahmen und Abstand oben | |
$rxmodule['containerstyle'] = ''; | |
$rxmodule['containerstyle'] .= $rxmodule['bordercolor'] <> '' ? 'border:solid 1px '.$rxmodule['bordercolor'].';' : 'border:0;'; | |
$rxmodule['containerstyle'] .= 'margin:0;overflow:hidden;'; | |
$rxmodule['containerstyle'] .= 'padding:' . $rxmodule['padding'] . 'px 0px 0px 0px;'; | |
$rxmodule['containerstyle'] .= 'width:' . ($rxmodule['magazinewidth'] - $rxmodule['s'] + $rxmodule['p']).'px;'; | |
$rxmodule['containerstyle'] .= $rxmodule['bgcolor'] <> '' ? 'background-color:'.$rxmodule['bgcolor'].';' : ''; | |
$rxmodule['containerstyle'] .= $rxmodule['layout'] == '0' ? '' : ''; | |
$rxmodule['containerstyle'] .= $rxmodule['layout'] == '1' ? 'margin: 0 auto;' : ''; | |
$rxmodule['containerstyle'] .= $rxmodule['layout'] == '2' ? 'float:right;' : ''; | |
$rxmodule['moduleoutput'] .= "\n" . ' <div class="magazine-container" style="' . $rxmodule['containerstyle'] . '">'; | |
// Output der Klasse | |
$rxmodule['moduleoutput'] .= $rxmodule['magoutput']; | |
// Ende DIV Container | |
$rxmodule['moduleoutput'] .= "\n </div><!-- end class magazine-container -->"; | |
// Ende DIV Layout | |
$rxmodule['moduleoutput'] .= "\n <div style=\"clear:both;font-size:0px;height:0px;line-height:0px;\"></div>"; | |
// ganzes Magazinlayout verlinkt? dann jetzt die Links ausgeben | |
if ( (!$REX['REDAXO']) and ( $rxmodule['linkpics'] == 0 ) and ( ($rxmodule['magazinetype'] <> 'showonly') and ($rxmodule['magazinetype'] <> 'popup') ) ) { | |
$rxmodule['moduleoutput'] .= "\n</a>"; | |
unset($rxmodule['totalimagelist'][0]); | |
foreach ($rxmodule['totalimagelist'] as $rxmodule['w_datei']) { | |
if ( trim($rxmodule['w_datei']) <> '' ) { | |
$rxmodule['w_outtitle'] = magazinelayout_getimagetitle($rxmodule); | |
if (trim($rxmodule['galimgsize']) <> '') { | |
$rxmodule['moduleoutput'] .= "\n".'<a href="' . $REX['HTDOCS_PATH'] . 'index.php?rex_resize='.$rxmodule['galimgsize'].'__'.$rxmodule['w_datei'].$rxmodule['galfilter'].'" title="'.$rxmodule['w_outtitle'].'" '.$rxmodule['templatebox'].'></a>'; | |
} else { | |
$rxmodule['moduleoutput'] .= "\n".'<a href="' . $REX['HTDOCS_PATH'] . 'files/' .$rxmodule['w_datei']. '" title="'.$rxmodule['w_outtitle'].'" '.$rxmodule['templatebox'].'></a>'; | |
} | |
} | |
} | |
} | |
// Ende magazine-layout | |
$rxmodule['moduleoutput'] .= "\n</div><!-- end class magazine-layout -->"; | |
// Ende wrap | |
if (trim($rxmodule['cssclass'] <> '')) { | |
$rxmodule['moduleoutput'] .= "\n</div><!-- end class ".$rxmodule['cssclass']." -->"; | |
} | |
// Post-HTML ausgeben | |
if ( $rxmodule['posthtml'] <> '' ) { | |
$rxmodule['moduleoutput'] .= "\n" . html_entity_decode(stripslashes($rxmodule['posthtml'])); | |
} | |
$rxmodule['moduleoutput'] .= "\n<!-- end magazin_Layout -->"; | |
// Cache ausgeben | |
if (!$REX['REDAXO']) { | |
if ($rxmodule['randompic'] <> 1) { | |
file_put_contents($rxmodule['cachefilename'], $rxmodule['moduleoutput']); | |
} | |
} | |
// Keine Bilder ausgewählt | |
} else { | |
if ($REX['REDAXO']) { | |
$rxmodule['moduleoutput'] = '<font color="#cc0000">Keine Bilder ausgewählt! (evtl. action rexnames vergessen?)</font><br />'; | |
} | |
} | |
} | |
} // End function_exists | |
/** | |
* Werte übernehmen | |
*/ | |
unset($rxmodule); | |
$rxmodule['moduleversion'] = 'magazin_Layout 1.8'; | |
// REDAXO-Version | |
$rxmodule['rexversion'] = isset($REX['VERSION']) ? $REX['VERSION'] . $REX['SUBVERSION'] : $REX['version'] . $REX['subversion']; | |
// rexnames | |
$rxmodule['rexname'] = preg_split('/~~/', "REX_VALUE[1]"); | |
$rxmodule['rexnames_inuse'] = count($rxmodule['rexname']) > 1; | |
if (!$rxmodule['rexnames_inuse']) { | |
$rxmodule['rexname'] = array_fill(0, 99, ''); | |
} | |
// Standardwerte für die Ausgabe des Magazinlayouts | |
$rxmodule['default'] = array( | |
'width' => '630', | |
// mögliche Werte für layout | |
// 0=links,1=mitte,2=rechts | |
'layout' => '0', | |
'padding' => '10', | |
'cssclass' => '', | |
'bgcolor' => '', | |
'bordercolor '=> '', | |
'imgbordercolor '=> '', | |
// mögliche Werte für imgdesc | |
// 0=keine, 1=Titel aus Medienpool, 2=Beschreibung aus Medienpool, | |
// 3=Copyright aus Medienpool, 4=Titel + Beschreibung aus Medienpool, | |
// 5=Titel + Copyright aus Medienpool, 6=Beschreibung + Copyright aus Medienpool, | |
// 7=Titel + Beschreibung + Copyright aus Medienpool | |
'imgdesc' => '0', | |
'imgblock' => '8', // Anzahl Bilder die gruppiert werden sollen | |
// mögliche Werte für magazinetype | |
// showonly=nur Anzeige | |
// popup=Anzeige im Popup | |
// greybox,lightbox,pho2,slimbox,thickbox=Anzeige mit Addon | |
'magazinetype' => 'javascript' | |
); | |
if ("REX_CTYPE_ID" == '1') | |
{ | |
$rxmodule['default']['width'] = 630; | |
} | |
if ("REX_CTYPE_ID" == '2') | |
{ | |
$rxmodule['default']['width'] = 310; | |
} | |
// Breite Magazinlayout | |
$rxmodule['magazinewidth'] = trim($rxmodule['rexname'][0]); | |
if ( $rxmodule['magazinewidth'] == '' ) { | |
$rxmodule['magazinewidth'] = isset($rxmodule['default']['width']) ? $rxmodule['default']['width'] : '475'; | |
} | |
// Medienpool-Kategorie als Bilderquelle | |
$rxmodule['mediacat'] = trim($rxmodule['rexname'][1]); | |
// Ausrichtung des Magazinlayouts | |
$rxmodule['layout'] = trim($rxmodule['rexname'][2]); | |
if ($rxmodule['layout'] == '') { | |
$rxmodule['layout'] = isset($rxmodule['default']['layout']) ? $rxmodule['default']['layout'] : '0'; | |
} | |
// Abstand zwischen den Bildern | |
$rxmodule['padding'] = trim("REX_VALUE[2]"); | |
if ( $rxmodule['padding'] == '' ) { | |
$rxmodule['padding'] = isset($rxmodule['default']['padding']) ? $rxmodule['default']['padding'] : '5'; | |
} | |
// optionale CSS-Klasse | |
$rxmodule['cssclass'] = trim("REX_VALUE[3]"); | |
if ( $rxmodule['cssclass'] == '' ) { | |
$rxmodule['cssclass'] = isset($rxmodule['default']['cssclass']) ? $rxmodule['default']['cssclass'] : ''; | |
} | |
// Anzeigetyp | |
$rxmodule['magazinetype'] = trim("REX_VALUE[4]"); | |
if ( $rxmodule['magazinetype'] == '' ) { | |
$rxmodule['magazinetype'] = isset($rxmodule['default']['magazinetype']) ? $rxmodule['default']['magazinetype'] : 'showonly'; | |
} | |
// Farben | |
$rxmodule['bgcolor'] = trim("REX_VALUE[5]"); | |
if ( $rxmodule['bgcolor'] == '' ) { | |
$rxmodule['bgcolor'] = isset($rxmodule['default']['bgcolor']) ? $rxmodule['default']['bgcolor'] : ''; | |
} | |
$rxmodule['bordercolor'] = trim("REX_VALUE[6]"); | |
if ( $rxmodule['bordercolor'] == '' ) { | |
$rxmodule['bordercolor'] = isset($rxmodule['default']['bordercolor']) ? $rxmodule['default']['bordercolor'] : ''; | |
} | |
$rxmodule['imgbordercolor'] = trim("REX_VALUE[7]"); | |
if ( $rxmodule['imgbordercolor'] == '' ) { | |
$rxmodule['imgbordercolor'] = isset($rxmodule['default']['imgbordercolor']) ? $rxmodule['default']['imgbordercolor'] : ''; | |
} | |
// Bildbeschreibungen aus dem Medienpool | |
$rxmodule['imgdesc'] = trim("REX_VALUE[8]"); | |
if ( $rxmodule['imgdesc'] == '' ) { | |
$rxmodule['imgdesc'] = isset($rxmodule['default']['imgdesc']) ? $rxmodule['default']['imgdesc'] : '0'; | |
} | |
// Blockbildung | |
$rxmodule['imgblock'] = trim("REX_VALUE[9]"); | |
if ($rxmodule['imgblock'] == '') { | |
$rxmodule['imgblock'] = isset($rxmodule['default']['imgblock']) ? $rxmodule['default']['imgblock'] : '8'; | |
} | |
if ( $rxmodule['imgblock'] == '' ) $rxmodule['imgblock'] = 8; | |
if ( $rxmodule['imgblock'] < 3 ) $rxmodule['imgblock'] = 3; | |
if ( $rxmodule['imgblock'] > 8 ) $rxmodule['imgblock'] = 8; | |
// Zufallsbilder | |
$rxmodule['randompic'] = trim($rxmodule['rexname'][3]); | |
$rxmodule['randompiccount'] = trim($rxmodule['rexname'][4])+0; | |
if ($rxmodule['randompiccount'] == 0) { | |
$rxmodule['randompic'] = 0; | |
} | |
// Einzelbilder verlinken | |
$rxmodule['linkpics'] = trim($rxmodule['rexname'][5]); | |
if ($rxmodule['linkpics']=='') { | |
$rxmodule['linkpics'] = 1; | |
} | |
// Bild-Größe der Galeriebilder | |
$rxmodule['galimgsize'] = trim($rxmodule['rexname'][6]); | |
if ( trim($rxmodule['galimgsize']) <> '') { | |
if ( !in_array(substr($rxmodule['galimgsize'], strlen($rxmodule['galimgsize'])-1, 1), array('a', 'h', 'w')) ) { | |
$rxmodule['galimgsize'] = $rxmodule['galimgsize'] . 'w'; | |
} | |
} | |
// Filter für das Magazinlayout (ab REDAXO 4.0.x) | |
$rxmodule['filter'] = trim($rxmodule['rexname'][8]); | |
// Filter für die Bildergalerie (ab REDAXO 4.0.x) | |
$rxmodule['galfilter'] = trim($rxmodule['rexname'][9]); | |
// Pre + Post-HTML | |
$rxmodule['prehtml'] = stripslashes(trim($rxmodule['rexname'][10])); | |
$rxmodule['posthtml'] = stripslashes(trim($rxmodule['rexname'][11])); | |
// damit das Modul mehrfach auf einem Artikel verwendet werden kann | |
// wird in VALUE 10 eine Zufallszahl für den Dateinamen gespeichert! | |
$rxmodule['magazineid'] = trim("REX_VALUE[10]"); | |
// Dateiname für cachce | |
if ( in_array($rxmodule['rexversion'], array('3.01', '3.11', '32')) ) { | |
$rxmodule['cachefilename'] = $REX['HTDOCS_PATH'] . 'files/' . 'cache_resize___magazinlayout_' . "REX_CATEGORY_ID" . '_' . "REX_ARTICLE_ID" . '_' . $rxmodule['magazineid'] . '_' . $REX['CUR_CLANG'] . '.html'; | |
} else { | |
$rxmodule['cachefilename'] = $REX['HTDOCS_PATH'] . 'files/' . 'image_resize__magazinlayout_' . "REX_CATEGORY_ID" . '_' . "REX_ARTICLE_ID" . '_' . $rxmodule['magazineid'] . '_' . $REX['CUR_CLANG'] . '.html'; | |
} | |
// Wenn eine Cache-Version existiert dann diese anzeigen | |
$rxmodule['cached'] = false; | |
if (!$REX['REDAXO']) | |
{ | |
if (file_exists($rxmodule['cachefilename'])) { | |
$rxmodule['cachetime'] = @filemtime($rxmodule['cachefilename']); | |
$rxmodule['moduleoutput'] = trim(@file_get_contents($rxmodule['cachefilename'])); | |
if ( ($rxmodule['moduleoutput'] <> '') and ($rxmodule['randompic'] <> 1) ) { | |
$rxmodule['moduleoutput'] = "\n<!-- cached version -->" . $rxmodule['moduleoutput']; | |
$rxmodule['cached'] = true; | |
} | |
} | |
} | |
// Bilddateien aus Medialist | |
$rxmodule['imagelist'] = explode(',', trim("REX_MEDIALIST[1]")); | |
// Wenn eine Medienpool-Kategorie vorgegeben ist dann die Bilder aus dieser Kategorie verwenden | |
if (isset($rxmodule['mediacat']) and ($rxmodule['mediacat']<>'') and ($rxmodule['mediacat']<>'0') ) { | |
$rxmodule['media'] = OOMediaCategory::getCategoryById($rxmodule['mediacat']); | |
if ($rxmodule['media']) { | |
$rxmodule['mediafiles'] = $rxmodule['media']->getFiles(); | |
if (count($rxmodule['mediafiles'])>0) { | |
$rxmodule['filetypes'] = array('jpg', 'gif', 'jpeg', 'png', 'bmp', 'png'); | |
foreach ($rxmodule['mediafiles'] as $rxmodule['mediafile']) { | |
if ( in_array($rxmodule['rexversion'], array('3.01', '3.11', '32')) ) { | |
$rxmodule['file'] = $rxmodule['mediafile']->getFileName(); | |
} else { | |
$rxmodule['file'] = $rxmodule['mediafile']->getValue('name'); | |
} | |
$rxmodule['fileinfo'] = pathinfo($rxmodule['file']); | |
$rxmodule['extension'] = strtolower($rxmodule['fileinfo']['extension']); | |
if (in_array($rxmodule['extension'], $rxmodule['filetypes'])) { | |
$rxmodule['imagelist'][] = $rxmodule['file']; | |
} | |
} | |
} | |
} | |
} | |
// HTML erzeugen | |
if (!$rxmodule['cached']) { | |
magazinelayout_createHtml($rxmodule); | |
} | |
// Ausgeben | |
echo $rxmodule['moduleoutput']; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment