require_once class plakat php define IMAGE_WIDTH 10000 define IMAGE_HE

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
<?
require_once('class.plakat.php');
define('IMAGE_WIDTH', 10000);
define('IMAGE_HEIGHT', 10000);
class HtmlPlakat extends Plakat
{
var $data;
var $curr;
var $currId;
function HtmlPlakat()
{
$this->Plakat(10, 20, 30);
}
function createHtml($ids, $showYear = false)
{
if (!is_array($ids))
{
$ids = array($ids);
}
$this->data = array();
$this->drawPage($ids, IMAGE_WIDTH, count($ids) * IMAGE_HEIGHT, 500, 0, 0, count($ids) * 3, 1, $showYear, true);
// save the last item to the data array
$this->_nextItem();
$output='<link href="assets/templates/html_plakat.css" rel="stylesheet">';
/*css is in file now*/
/*
$output = '<style type="text/css">
table.kktable {
width: 580px;
}
table.kkitem {
width: 100%;
}
table.kkitem td {
padding-bottom: 5px;
}
table.kkgroup {
}
table.kkgroup td {
padding: 0px;
padding-right: 10px;
}
.kktable h1, .kktable td, .kktable span {
font-family: Verdana,sans-serif;
}
.kktable h1 {
font-weight: bold;
font-size: 13px;
border: solid 1px black;
border-bottom: solid 2px black;
padding: 3px;
margin-top: 5px;
margin-bottom: 0px;
}
.kk30 {
font-weight: bold;
font-size: 16px;
}
.kk10 {
font-size: 11px;
}
.kktable hr {
border: solid 1px black;
}
</style>';
*/
$output .= '<table cellpadding="0" cellspacing="0" border="0" class="kktable"><tr><td>';
$output .= "\n";
foreach ($this->data as $concertId => $item)
{
reset($item);
list($firstKey, $firstItem) = each($item);
if ($firstItem == 'line')
{
$title = '<hr />';
}
else
{
$title = '<h1>'.$firstItem[0]['text'].'</h1>';
}
unset($item[$firstKey]);
$groups = array();
$groupIdx = -1;
$lastY = -1000;
foreach ($item as $y => $line)
{
if ($y - $lastY > 50)
{
$groupIdx++;
}
$lineSize = -1;
foreach ($line as $x => $part)
{
if ($lineSize < 0 || $lineSize == $part['size'])
{
$lineSize = $part['size'];
}
else
{
// add "follow" flag for all parts that are not the same size
// as the first part of the same line. This means it will
// follow immediately the previous text without going into
// a new cell
$line[$x]['follow'] = true;
}
}
$lastY = $y;
$groups[$groupIdx][$y] = $line;
}
$output .= '<a name="k'.$concertId.'"></a>';
$output .= '<table cellpadding="0" cellspacing="0" border="0" class="kkitem">';
$output .= '<tr><td>'.$title.'</td></tr></table>';
$output .= '<table cellpadding="0" cellspacing="0" border="0" class="kkitem"><tr><td>';
//$this->debug($groups);
foreach ($groups as $g => $group)
{
if ($g > 0)
{
$output .= '</td></tr><tr><td>';
}
$output .= '<table cellpadding="0" cellspacing="0" border="0" class="kkgroup">';
//$this->debug($group);
$xPositions = array();
$xPositions[] = 0; // ensure a column at position 0
$grid = array();
foreach ($group as $y => $line)
{
foreach ($line as $x => $cell)
{
if (!isset($cell['follow']))
{
$grid[$y][$x]['texts'][] = $cell;
$grid[$y][$x]['size'] = $cell['size'];
$prevX = $x;
if (!in_array($x, $xPositions))
{
$xPositions[] = $x;
}
}
else
{
$grid[$y][$prevX]['texts'][] = $cell;
$grid[$y][$prevX]['multisize'] = true;
}
//$this->debug(array('x' => $x, 'y' => $y, 'cell' => $cell));
}
}
sort($xPositions);
//$this->debug($xPositions);
//$this->debug($grid);
foreach ($grid as $y => $line)
{
$colSpan = 0;
$lastX = 100;
for ($i = count($xPositions) - 1; $i >= 0; $i--)
{
$x = $xPositions[$i];
$colSpan++;
if (isset($grid[$y][$x]))
{
$grid[$y][$x]['span'] = $colSpan;
//$grid[$y][$x]['width'] = ($lastX - $x).'%';
$colSpan = 0;
$lastX = $x;
}
}
if ($colSpan > 0)
{
$grid[$y][$xPositions[0]] = array('span' => $colSpan, 'size' => 10);
}
ksort($grid[$y]);
$output .= '<tr>';
foreach ($grid[$y] as $x => $cell)
{
// $cell = {texts?, size?, multisize?, span}
$multiSize = @$cell['multisize'];
$cellSize = @$cell['size'];
$output .= '<td nowrap="nowrap" valign="top"';
if ($cell['span'] > 1)
{
$output .= ' colspan="'.$cell['span'].'"';
}
if (!$multiSize && $cellSize)
{
$output .= ' class="kk'.$cellSize.'"';
}
$output .= '>';
//$this->debug($cell['lines']);
if (isset($cell['texts']))
{
foreach ($cell['texts'] as $part)
{
//var_dump($output);
//$this->debug($part);
if ($multiSize)
{
$output .= '<span class="kk'.$part['size'].'">';
}
# $output .= str_replace('(tel)', '&#9743;'/*'<img src="admin/images/tel.png" />'*/, $part['text']);
$output .= str_replace('(tel)', '<font size="3">&#9990;</font>'/*'<img src="admin/images/tel.png" />'*/, $part['text']);
if ($multiSize)
{
$output .= '</span>';
}
}
}
else
{
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
}
$output .= '</td>';
}
$output .= '</tr>';
}
$output .= '</table>';
//$this->debug($grid);
}
$flyerFile = '/home/www/web60/html/admin/upload/'.$concertId.'.pdf';
$output .= "<!-- $flyerFile -->";
if (!isset($_SESSION['cug']) && file_exists($flyerFile))
{
$fileSize = (int) (filesize($flyerFile) / 1024);
$output .= "</td></tr><tr><td class=\"kk10\"><a href=\"/admin/upload/$concertId.pdf\" target=\"_blank\">Mehr Informationen</a> (PDF, $fileSize kB)";
}
$output .= "</td></tr></table>\n";
$query = 'SELECT logo_url, logo_link
FROM mk_vereine
WHERE verein_id = (
SELECT konzert_verein
FROM mk_konzerte
WHERE konzert_id ='.$concertId.')';
$result = $this->db->safeQuery($query);
while ($row = mysql_fetch_assoc($result)) {
$logo_url=$row["logo_url"];
$logo_link=$row["logo_link"];
/*<div class='fb-like' data-href='".$urlik."' data-layout='standard' data-action='like' data-show-faces='false' data-share='true'></div>*/
if ($logo_url!='' && $logo_link!='') {
//echo '1<br>';
$output .= "<div class='logoimg'><a href='".$logo_link."'><img src='".$logo_url."'/></a></div>
<div id='share_on_facebook".$concertId."'><span class='pluginButtonLabel'>Share</span></div>
<script>
jQuery(function() {
jQuery('#share_on_facebook".$concertId."').click(function() {
FB.ui(
{
method: 'feed',
name: '".$title."',
link: 'http://konzerte-bern.ch/".$_SERVER['REQUEST_URI']."',
description: '".$this->tagsToSpaces($output)."',
picture:'http://konzerte-bern.ch/".$logo_url."'
},
function(response) {
if (response && !response.error_code) {
alert('Posting completed.');
} else {
alert('Error while posting.');
}
}
);
});});
</script>";
//$output = '';
}
/*<div class='fb-like' data-href='".$urlik."' data-layout='standard' data-action='like' data-show-faces='false' data-share='true'></div>*/
//$this->debug($this->data);
if ($logo_url!='' && $logo_link=='') {
// echo '2<br>';
$output .= "<div class='logoimg'><img src='".$logo_url."'/></div>
<div id='share_on_facebook".$concertId."'><span class='pluginButtonLabel'>Share</span></div>
<script>
jQuery(function() {
jQuery('#share_on_facebook".$concertId."').click(function() {
FB.ui(
{
method: 'feed',
name: '".$title."',
link: 'http://konzerte-bern.ch/".$_SERVER['REQUEST_URI']."',
description: '".$this->tagsToSpaces($output)."',
picture:'http://konzerte-bern.ch/".$logo_url."'
},
function(response) {
if (response && !response.error_code) {
alert('Posting completed.');
} else {
alert('Error while posting.');
}
}
);
});});
</script>";
//$output = '';
}
/*
if ($logo_url=='' && $logo_link=='') {
//echo '3<br>';
$output .="<div id='share_on_facebook".$concertId."'><span class='pluginButtonLabel'>Share</span></div>
<script>
jQuery(function() {
jQuery('#share_on_facebook".$concertId."').click(function() {
FB.ui(
{
method: 'feed',
name: '".$title."',
link: 'http://konzerte-bern.ch/".$_SERVER['REQUEST_URI']."',
description: '".$this->tagsToSpaces($output)."',
picture:''
},
function(response) {
if (response && !response.error_code) {
alert('Posting completed.');
} else {
alert('Error while posting.');
}
}
);
});});
</script>";
}
*/
}
}
$output .= "</td></tr></table>";
$output = $this->parseLinks($output);
return $output;
}
function parseLinks($str)
{
$str = str_replace('www.', 'http://www.', $str);
$str = preg_replace('|http://([a-zA-Z0-9-\./\?=_]+)|', '<a href="http://$1" target="_blank">$1</a>', $str);
$str = preg_replace('/(([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6})/', '<a href="mailto:$1">$1</a>', $str);
$str = preg_replace("/(<script>(.*?(\\n))+.*?link: \')((<a href=\"(.*)\")(.*,))((.*?(\\n))+.*?<\/script>)/U",'${1}$6\',${8}',$str);
$str = preg_replace("/(<script>(.*?(\\n))+.*?picture:\')((<a href=\"(.*)\")(.*'))((.*?(\\n))+.*?<\/script>)/U",'${1}$6\'${8}',$str);
$str = preg_replace("/((<script>(.*?(\\n))+.*?description: '(.*?(\\n))+.*?)(<a href=\"(.*))\"(.*?(\\n))+.*?)((.*?(\\n))+.*?<\/script>)/U",'${2}$8\',${11}',$str);
$str = preg_replace("/(&nbsp;)/U",'',$str);
$str = preg_replace("/(<script>(.*?(\\n))+.*?description: ')(\\s*)(\\w(.*?(\\n))+.*?<\/script>)/U",'${1}${5}',$str);
return $str;
}
//function added by kazak1377 17.09.2014 replecing all html tags by space
function tagsToSpaces($str) {
//$str = preg_replace("/(<\/tr>)/U",',',$str);
$str = preg_replace("/(<.*>)/U",' ',$str);
//$str=ltrim($str);
return $str;
}
function debug($mixed)
{
echo "<pre>";
print_r($mixed);
echo "</pre>";
}
function drawSingleItem($id, $width, $height, $x = 0, $y = 0, $dayHeader = true)
{
$this->_nextItem($id);
return Plakat::drawSingleItem($id, $width, $height, $x, $y, $dayHeader);
}
function drawText($x, $y, $text, $size, $border = false) // y = lower left position of the text
{
// this method must return the width of the drawn text
$this->curr[$y][$x] = array('text' => $text, 'size' => $size, 'border' => $border);
return $this->measureText($text, $size);
}
function drawLine($x1, $y1, $x2, $y2)
{
$this->curr[$y1] = 'line';
return 99;
}
function measureText($text, $size)
{
// this method must return the width of the text
return strlen($text);
}
function getLineHeight($size)
{
// this method must return the line height for a certain font size
return $size;
}
function _nextItem($id = 0)
{
if (count($this->curr))
{
$this->data[$this->currId] = $this->curr;
}
$this->currId = $id;
$this->curr = array();
}
}
?>