PageRenderTime 51ms CodeModel.GetById 27ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause, GPL-2.0, Unlicense, LGPL-2.1, Apache-2.0
  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. if (!is_object($this)) die ('Error: No parent object present.');
  39. /***************************************************************
  40. TypoScript config:
  41. .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)
  42. .charsPerLine [string] The max number of chars per line of text on the note.
  43. .images.[x] [image-contentObjects] [x] is the type-number defined by the second parameter in each line of data.
  44. .textBox {
  45. chars integer, the number of chars on each line
  46. lineDist integer, the number of pixels between each line
  47. tmplObjNumber integer, pointer to the GIFBUILDER-OBJECT (of type TEXT!!) which serves as a TEMPLATE for the objects used to create the textlines
  48. 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.)
  49. maxLines
  50. }
  51. Example:
  52. // Postit:
  53. tt_content.splash.20 = PHP_SCRIPT
  54. tt_content.splash.20 {
  55. file = media/scripts/postit.inc
  56. data.field = bodytext
  57. cols = 3
  58. textBox {
  59. chars = 16
  60. lineDist = 18
  61. tmplObjNumber = 100
  62. Valign = center
  63. maxLines = 5
  64. }
  65. typolink {
  66. parameter.current = 1
  67. extTarget = {$styles.content.links.extTarget}
  68. target = {$styles.content.links.target}
  69. }
  70. images.1 = IMAGE
  71. images.1.file = GIFBUILDER
  72. images.1.file {
  73. XY = [5.w],[5.h]
  74. 5 = IMAGE
  75. 5.file = media/uploads/postit_1.gif
  76. 100 = TEXT
  77. 100.text = Testing
  78. 100.offset = -5,60
  79. 100.fontFile = fileadmin/fonts/arial_bold.ttf
  80. 100.fontSize = 15
  81. 100.align=center
  82. }
  83. images.2 < .images.1
  84. images.2.file.5.file = media/uploads/postit_2.gif
  85. images.2.file.100.angle = 11
  86. images.2.file.100.offset = -2,79
  87. images.3 < .images.1
  88. images.3.file.5.file = media/uploads/postit_3.gif
  89. images.3.file.100.angle = -13
  90. images.3.file.100.offset = -7,81
  91. }
  92. ****************************************************************/
  93. $data = $this->stdWrap($conf['data'],$conf['data.']);
  94. $cols = intval($conf['cols']) ? intval($conf['cols']) : 3;
  95. $lines = explode(chr(10),$data);
  96. $imageArr = array();
  97. foreach ($lines as $key => $content) {
  98. $content = trim($content);
  99. if ($content) {
  100. $parts = explode('|',$content);
  101. $text = trim($parts[0]);
  102. $type = t3lib_div::intInRange($parts[1],1,3);
  103. $link = trim($parts[2]);
  104. if ($text) {
  105. $imgConf = $conf['images.'][$type.'.'];
  106. $imgConf['file.'] = $this->gifBuilderTextBox ($imgConf['file.'], $conf['textBox.'], $text);
  107. $image = $this->IMAGE($imgConf);
  108. if ($image) {
  109. $this->setCurrentVal($link);
  110. $imageArr[] = $this->typolink($image,$conf['typolink.']);
  111. }
  112. }
  113. }
  114. }
  115. if (is_array($imageArr)) {
  116. reset($imageArr);
  117. if ($cols) {
  118. $res = '';
  119. $rows = ceil(count($imageArr)/$cols);
  120. for ($a=0;$a<$rows;$a++) {
  121. $res.='<tr>';
  122. for ($b=0;$b<$cols;$b++) {
  123. $res.='<td>'.$imageArr[(($a*$cols)+$b)].'</td>';
  124. }
  125. $res.='</tr>';
  126. }
  127. $content='<table border="0" cellspacing="0" cellpadding="0">'.$res.'</table>';
  128. } else {
  129. $content.=implode($imageArr,'');
  130. }
  131. }
  132. ?>