PageRenderTime 24ms CodeModel.GetById 9ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/typo3/sysext/statictemplates/media/scripts/postit.inc

https://bitbucket.org/linxpinx/mercurial
PHP | 162 lines | 42 code | 22 blank | 98 comment | 9 complexity | 942dc70ee990b55e11461603df42dc8a MD5 | raw file
  1<?php
  2/***************************************************************
  3*  Copyright notice
  4*
  5*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
  6*  All rights reserved
  7*
  8*  This script is part of the TYPO3 project. The TYPO3 project is
  9*  free software; you can redistribute it and/or modify
 10*  it under the terms of the GNU General Public License as published by
 11*  the Free Software Foundation; either version 2 of the License, or
 12*  (at your option) any later version.
 13*
 14*  The GNU General Public License can be found at
 15*  http://www.gnu.org/copyleft/gpl.html.
 16*  A copy is found in the textfile GPL.txt and important notices to the license
 17*  from the author is found in LICENSE.txt distributed with these scripts.
 18*
 19*
 20*  This script is distributed in the hope that it will be useful,
 21*  but WITHOUT ANY WARRANTY; without even the implied warranty of
 22*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 23*  GNU General Public License for more details.
 24*
 25*  This copyright notice MUST APPEAR in all copies of the script!
 26***************************************************************/
 27/**
 28 * postit.inc
 29 *
 30 * Creates graphical postit notes with text on them.
 31 *
 32 * $Id: postit.inc 5165 2009-03-09 18:28:59Z ohader $
 33 * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
 34 * XHTML compliant
 35 *
 36 * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
 37 */
 38
 39
 40
 41if (!is_object($this)) die ('Error: No parent object present.');
 42
 43
 44
 45
 46
 47
 48/***************************************************************
 49TypoScript config:
 50
 51
 52
 53.data		[string / stdWrap]		The data for the notes. Every line is a new note. Each line is divided by "|" where the first part is the test, the second part is the type (1-) and the third part is the optional link (typolink-format)
 54.charsPerLine	[string]			The max number of chars per line of text on the note.
 55.images.[x]		[image-contentObjects]   [x] is the type-number defined by the second parameter in each line of data.
 56.textBox {
 57    chars						integer, the number of chars on each line
 58    lineDist					integer, the number of pixels between each line
 59    tmplObjNumber 				integer, pointer to the GIFBUILDER-OBJECT (of type TEXT!!) which serves as a TEMPLATE for the objects used to create the textlines
 60    Valign 						string. If set to "center", the tmplObjNumber-TEXT-object is expected to be centeret in the image and calculations will be done to spred the lines above and below in case of multiple lines. (based on .angle of the TEXT object also.)
 61	maxLines
 62  }
 63
 64
 65Example:
 66
 67
 68// Postit:
 69tt_content.splash.20 = PHP_SCRIPT
 70tt_content.splash.20 {
 71  file = media/scripts/postit.inc
 72  data.field = bodytext
 73  cols = 3
 74  textBox {
 75    chars = 16
 76    lineDist = 18
 77    tmplObjNumber = 100
 78    Valign = center
 79	maxLines = 5
 80  }
 81  typolink {
 82    parameter.current = 1
 83    extTarget = {$styles.content.links.extTarget}
 84    target = {$styles.content.links.target}
 85  }
 86  images.1 = IMAGE
 87  images.1.file = GIFBUILDER
 88  images.1.file {
 89    XY = [5.w],[5.h]
 90    5 = IMAGE
 91    5.file = media/uploads/postit_1.gif
 92    100 = TEXT
 93    100.text = Testing
 94    100.offset = -5,60
 95    100.fontFile = fileadmin/fonts/arial_bold.ttf
 96    100.fontSize = 15
 97    100.align=center
 98  }
 99  images.2 < .images.1
100  images.2.file.5.file = media/uploads/postit_2.gif
101  images.2.file.100.angle = 11
102  images.2.file.100.offset = -2,79
103  images.3 < .images.1
104  images.3.file.5.file = media/uploads/postit_3.gif
105  images.3.file.100.angle = -13
106  images.3.file.100.offset = -7,81
107}
108
109****************************************************************/
110
111
112
113
114
115$data = $this->stdWrap($conf['data'],$conf['data.']);
116$cols = intval($conf['cols']) ? intval($conf['cols']) : 3;
117
118
119$lines = explode(chr(10),$data);
120$imageArr = array();
121foreach ($lines as $key => $content) {
122	$content = trim($content);
123	if ($content)	{
124		$parts = explode('|',$content);
125		$text = trim($parts[0]);
126		$type = t3lib_div::intInRange($parts[1],1,3);
127		$link = trim($parts[2]);
128		if ($text)	{
129			$imgConf = $conf['images.'][$type.'.'];
130			$imgConf['file.'] = $this->gifBuilderTextBox ($imgConf['file.'], $conf['textBox.'], $text);
131
132			$image = $this->IMAGE($imgConf);
133			if ($image)	{
134				$this->setCurrentVal($link);
135				$imageArr[] = $this->typolink($image,$conf['typolink.']);
136			}
137		}
138	}
139}
140
141
142if (is_array($imageArr))	{
143	reset($imageArr);
144	if ($cols)	{
145		$res = '';
146		$rows = ceil(count($imageArr)/$cols);
147
148		for ($a=0;$a<$rows;$a++)	{
149			$res.='<tr>';
150			for ($b=0;$b<$cols;$b++)	{
151				$res.='<td>'.$imageArr[(($a*$cols)+$b)].'</td>';
152			}
153			$res.='</tr>';
154		}
155
156		$content='<table border="0" cellspacing="0" cellpadding="0">'.$res.'</table>';
157	} else {
158		$content.=implode($imageArr,'');
159	}
160}
161
162?>