PageRenderTime 64ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/ext/typoflash/pi1/class.tx_typoflash_pi1.php

https://github.com/elhakim22003/TypoFlash
PHP | 1723 lines | 925 code | 367 blank | 431 comment | 143 complexity | fe0387bf8a62cdfc0f5c58b8627b3bde MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /***************************************************************
  3. * Copyright notice
  4. *
  5. * (c) 2004 Andreas Borg (borg@elevated.to)
  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 net.typoflash 2 of the License, or
  12. * (at your option) any later net.typoflash.
  13. *
  14. * The GNU General Public License can be found at
  15. * http://www.gnu.org/copyleft/gpl.html.
  16. *
  17. * This script is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * This copyright notice MUST APPEAR in all copies of the script!
  23. ***************************************************************/
  24. /**
  25. * Plugin 'Flash component' for the 'typoflash' extension.
  26. *
  27. * @author Andreas Borg <borg@elevated.to>
  28. Affected database tables:
  29. tx_typoflash_component
  30. tx_typoflash_template
  31. pages
  32. tt_content
  33. Flash:
  34. Templates
  35. | |
  36. |-Fixed objects |-Dynamic objects
  37. | |
  38. |-Menus |-Template or page level components
  39. |
  40. |-Components in content holder
  41. |
  42. |-Frames
  43. |
  44. |-Components
  45. Page/template data structure:
  46. LANG[uid]
  47. |
  48. |-[movieclip]
  49. |
  50. |-name/value pairs
  51. |
  52. |-hidden
  53. |
  54. |-name/value pairs
  55. Todo:
  56. SEO and non flash content
  57. Use expressinstall in flash
  58. */
  59. require_once(PATH_tslib."class.tslib_pibase.php");
  60. class tx_typoflash_pi1 extends tslib_pibase {
  61. var $prefixId = "tx_typoflash_pi1"; // Same as class name
  62. var $scriptRelPath = "pi1/class.tx_typoflash_pi1.php"; // Path to this script relative to the extension dir.
  63. var $extKey = "typoflash"; // The extension key.
  64. var $tmplTFdata;//template level data, mainly relevant for htmlVars to be output in html
  65. /**
  66. * [Put your description here]
  67. */
  68. function main($content,$conf) {
  69. //$GLOBALS["TSFE"]->set_no_cache();//comment out later
  70. $GLOBALS['TSFE']->additionalHeaderData['credit'] = '
  71. <!--
  72. TypoFlash is an extension developed by Andreas Borg @ Elevated.
  73. It boosts Typo3 with Flash Remoting and a Flash CMS making it easy and fast to edit and update
  74. fully interactive multimedia websites. Nice eh!
  75. Visit http://typoflash.net for more info.
  76. -->';
  77. $GLOBALS['TSFE']->additionalHeaderData['swfobject_script'] = '
  78. <script type="text/javascript" src="typo3conf/ext/typoflash/pi1/js/swfobject.js"></script>
  79. <script type="text/javascript" src="typo3conf/ext/typoflash/pi1/js/swfaddress.js"></script>';
  80. /*$GLOBALS['TSFE']->additionalHeaderData['flash_script'] = '
  81. <script language="JavaScript" src="typo3conf/ext/typoflash/pi1/js/browserdet.js"></script>
  82. <script language="JavaScript" src="typo3conf/ext/typoflash/pi1/js/flashdet.js"></script>
  83. <script language="JavaScript" src="typo3conf/ext/typoflash/pi1/js/AC_RunActiveContent.js"></script>';*/
  84. $this->conf=$conf; // Setting the TypoScript passed to this function in $this->conf
  85. $this->pi_setPiVarDefaults();
  86. $this->pi_loadLL();
  87. $this->LLuid = $GLOBALS['TSFE']->config['config']['sys_language_uid'];
  88. if(!isset($this->LLuid)){
  89. $this->LLuid = 0;
  90. }
  91. // Init flexform configuration of the plugin
  92. $this->pi_initPIflexForm();
  93. // Get flexform informations
  94. $piFlexForm = $this->cObj->data['pi_flexform'];
  95. $this->tx_typoflash_template = $this->pi_getFFvalue($piFlexForm,'tx_typoflash_template');
  96. $this->tx_typoflash_target = $this->pi_getFFvalue($piFlexForm,'target');
  97. $this->tx_typoflash_conf = $this->pi_getFFvalue($piFlexForm,'conf');
  98. //flash content records
  99. $this->tx_typoflash_what_to_render = $this->pi_getFFvalue($piFlexForm,'what_to_render','content_records');
  100. $this->tx_typoflash_records = $this->pi_getFFvalue($piFlexForm,'records','content_records');
  101. $this->tx_typoflash_pages = $this->pi_getFFvalue($piFlexForm,'pages','content_records');
  102. $this->tx_typoflash_tables = $this->pi_getFFvalue($piFlexForm,'tables','content_records');
  103. $this->tx_typoflash_recordLimit = $this->pi_getFFvalue($piFlexForm,'recordLimit','content_records');
  104. $this->tx_typoflash_orderBy = $this->pi_getFFvalue($piFlexForm,'orderBy','content_records');
  105. //non flash content records
  106. $this->tx_typoflash_nf_what_to_render = $this->pi_getFFvalue($piFlexForm,'what_to_render','non_flash');
  107. $this->tx_typoflash_nf_records = $this->pi_getFFvalue($piFlexForm,'records','non_flash');
  108. $this->tx_typoflash_nf_pages = $this->pi_getFFvalue($piFlexForm,'pages','non_flash');
  109. $this->tx_typoflash_nf_showlink = $this->pi_getFFvalue($piFlexForm,'show_plugin_link','non_flash');
  110. //seo content records
  111. $this->tx_typoflash_seo_what_to_render = $this->pi_getFFvalue($piFlexForm,'what_to_render','seo');
  112. $this->tx_typoflash_seo_records = $this->pi_getFFvalue($piFlexForm,'records','seo');
  113. $this->tx_typoflash_seo_pages = $this->pi_getFFvalue($piFlexForm,'pages','seo');
  114. /*
  115. flex vars
  116. tx_typoflash_component
  117. target
  118. conf
  119. sheet: content_records
  120. records
  121. pages
  122. tables
  123. recordLimit
  124. orderBy
  125. */
  126. return $this->pi_wrapInBaseClass($this->renderTemplateInline());
  127. /*switch((string)$conf["CMD"]) {
  128. case "singleView":
  129. list($t) = explode(":",$this->cObj->currentRecord);
  130. $this->internal["currentTable"]=$t;
  131. $this->internal["currentRow"]=$this->cObj->data;
  132. return $this->pi_wrapInBaseClass($this->singleView($content,$conf));
  133. break;
  134. default:
  135. if (strstr($this->cObj->currentRecord,"tt_content")) {
  136. $conf["pidList"] = $this->cObj->data["pages"];
  137. $conf["recursive"] = $this->cObj->data["recursive"];
  138. }
  139. return $this->pi_wrapInBaseClass($this->listView($content,$conf));
  140. break;
  141. }*/
  142. }
  143. /**
  144. * Main function for rendering of Page Templates of TypoFlash as fullpage alternative page renderer
  145. page = PAGE
  146. page.typeNum = 0
  147. page.10 = USER
  148. page.10.userFunc = tx_typoflash_pi1->main_page
  149. page.10.HOST_URL= http://inspira.tion.to/
  150. page.10.REMOTING_RELAY_SOCKET = inspira.tion.to
  151. page.10.REMOTING_RELAY_PORT = 8888
  152. page.10.RELAY_SERVER = projects.puertaandaluza.com_8888.php
  153. page.10.CODE_PAGE = true
  154. page.10.SCALE_MODE = noScale
  155. page.10.ALIGN = TL
  156. */
  157. function main_page($content,$conf) {
  158. $this->conf =$conf;
  159. // Current page record which we MIGHT manipulate a little:
  160. $pageRecord = $GLOBALS['TSFE']->page;
  161. $this->tmplTFdata = unserialize($pageRecord['tx_typoflash_data']);
  162. $this->tmplTFdata = $this->tmplTFdata[$pageRecord['tx_typoflash_template']];
  163. // Find Template in root line IF there is no Data Structure set for the current page:
  164. if (!$pageRecord['tx_typoflash_template']) {
  165. foreach($GLOBALS['TSFE']->tmpl->rootLine as $pRec) {
  166. if ($pageRecord['uid'] != $pRec['uid']) {
  167. if ($pRec['tx_typoflash_template']) { // If there is a next-level DS:
  168. $pageRecord['tx_typoflash_template'] = $pRec['tx_typoflash_template'];
  169. $this->tmplTFdata = unserialize($pRec['tx_typoflash_data']);
  170. $this->tmplTFdata = $this->tmplTFdata[$pRec['uid']];
  171. }
  172. } else break;
  173. }
  174. }
  175. return $this->renderElement($pageRecord, 'pages');
  176. }
  177. /**
  178. * Main function for rendering of Page Templates of TypoFlash as inline objects
  179. lib.flash = USER
  180. lib.flash.userFunc =tx_typoflash_pi1->main_inline
  181. lib.flash.HOST_URL= http://inspira.tion.to/
  182. lib.flash.REMOTING_RELAY_SOCKET = inspira.tion.to
  183. #lib.flash.REMOTING_RELAY_PORT = 8888
  184. #lib.flash.RELAY_SERVER = projects.puertaandaluza.com_8888.php
  185. lib.flash.CODE_PAGE = true
  186. lib.flash.SCALE_MODE = noScale
  187. lib.flash.ALIGN = TL
  188. */
  189. function main_inline($content,$conf) {
  190. $this->conf =$conf;
  191. $this->LLuid = $GLOBALS['TSFE']->config['config']['sys_language_uid'];
  192. if(!isset($this->LLuid)){
  193. $this->LLuid = 0;
  194. }
  195. //flash content records
  196. $this->tx_typoflash_what_to_render = $this->conf['CONTENT_RECORDS.what_to_render'];
  197. $this->tx_typoflash_records = $this->conf['CONTENT_RECORDS.records'];
  198. $this->tx_typoflash_pages = $this->conf['CONTENT_RECORDS.pages'];
  199. $this->tx_typoflash_tables = $this->conf['CONTENT_RECORDS.tables'];
  200. $this->tx_typoflash_recordLimit = $this->conf['CONTENT_RECORDS.recordLimit'];
  201. $this->tx_typoflash_orderBy = $this->conf['CONTENT_RECORDS.orderBy'];
  202. //non flash content records
  203. $this->tx_typoflash_nf_what_to_render = $this->conf['NON_FLASH.what_to_render'];
  204. $this->tx_typoflash_nf_records = $this->conf['NON_FLASH.records'];
  205. $this->tx_typoflash_nf_pages = $this->conf['NON_FLASH.pages'];
  206. $this->tx_typoflash_nf_showlink = $this->conf['NON_FLASH.show_plugin_link'];
  207. //seo content records
  208. $this->tx_typoflash_seo_what_to_render = $this->conf['SEO.what_to_render'];
  209. $this->tx_typoflash_seo_records = $this->conf['SEO.records'];
  210. $this->tx_typoflash_seo_pages = $this->conf['SEO.pages'];
  211. $GLOBALS['TSFE']->additionalHeaderData['credit'] = '
  212. <!--
  213. TypoFlash is an extension developed by Andreas Borg @ Elevated.
  214. It boosts Typo3 with Flash Remoting and a Flash CMS making it easy and fast to edit and update
  215. fully interactive multimedia websites. Nice eh!
  216. Visit http://typoflash.net for more info.
  217. -->';
  218. $GLOBALS['TSFE']->additionalHeaderData['swfobject_script'] = '
  219. <script type="text/javascript" src="typo3conf/ext/typoflash/pi1/js/swfobject.js"></script>
  220. <script type="text/javascript" src="typo3conf/ext/typoflash/pi1/js/swfaddress.js"></script>';
  221. // Current page record which we MIGHT manipulate a little:
  222. $pageRecord = $GLOBALS['TSFE']->page;
  223. $this->tmplTFdata = unserialize($pageRecord['tx_typoflash_data']);
  224. //it is nested on template uid so as to prevent mixups
  225. //NOTE 12/05/2008 double check this is actually properly stored on template level as it seemed to trace empty templ uid key
  226. $this->tmplTFdata = $this->tmplTFdata[$pageRecord['tx_typoflash_template']];
  227. // Find Template in root line IF there is no Data Structure set for the current page:
  228. if (!$pageRecord['tx_typoflash_template']) {
  229. foreach($GLOBALS['TSFE']->tmpl->rootLine as $pRec) {
  230. if ($pageRecord['uid'] != $pRec['uid']) {
  231. if ($pRec['tx_typoflash_template']) { // If there is a next-level DS:
  232. $pageRecord['tx_typoflash_template'] = $pRec['tx_typoflash_template'];
  233. $this->tmplTFdata = unserialize($pRec['tx_typoflash_data']);
  234. $this->tmplTFdata = $this->tmplTFdata[$pRec['tx_typoflash_template']];
  235. }
  236. } else break;
  237. }
  238. }
  239. return $this->renderInlineElement($pageRecord, 'pages');
  240. }
  241. function renderInlineElement($row,$table) {
  242. global $TYPO3_CONF_VARS;
  243. // Get data structure:
  244. $srcPointer = $row['tx_typoflash_template'];
  245. if (t3lib_div::testInt($srcPointer)) { // If integer, then its a record we will look up:
  246. $this->tx_typoflash_template = $GLOBALS['TSFE']->sys_page->checkRecord('tx_typoflash_template', $srcPointer);
  247. }
  248. $content = '';
  249. /*
  250. //Deprecated with dhtmlHistory 09/11/2006
  251. if($this->tx_typoflash_template['historyframe']=='1'){
  252. $content .='<iframe style="left:-1000;top:-1000;position:absolute" name="historyframe" src="" width="50" height="50" frameborder="0" align="left" scrolling="no" ></iframe>';
  253. };
  254. */
  255. $content .= $this->renderTemplateInline($this->tx_typoflash_template, true);
  256. //$content .=$this->tx_typoflash_template;
  257. return $content;
  258. }
  259. function renderElement($row,$table) {
  260. global $TYPO3_CONF_VARS;
  261. // Get data structure:
  262. $srcPointer = $row['tx_typoflash_template'];
  263. if (t3lib_div::testInt($srcPointer)) { // If integer, then its a record we will look up:
  264. $fTemplate = $GLOBALS['TSFE']->sys_page->checkRecord('tx_typoflash_template', $srcPointer);
  265. } else { // Otherwise expect it to be a file:
  266. $file = t3lib_div::getFileAbsFileName($srcPointer);
  267. if ($file && @is_file($file)) {
  268. $DS = t3lib_div::xml2array(t3lib_div::getUrl($file));
  269. }
  270. }
  271. $content = '';
  272. if($fTemplate){
  273. $content .='
  274. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  275. <html>
  276. <head>
  277. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  278. <!--
  279. TypoFlash is an extension developed by Andreas Borg @ Elevated.
  280. It boosts Typo3 with Flash Remoting and a Flash CMS making it easy and fast to edit and update
  281. fully interactive multimedia websites. Nice eh!
  282. Visit http://typoflash.net for more info.
  283. -->';
  284. if(strlen($fTemplate['css'])>0){
  285. $content .='
  286. <style type="text/css">
  287. \/*<![CDATA[*/
  288. <!--
  289. \/* styles for extension "tx_typoflash_pi1" */
  290. '.
  291. $fTemplate['css'] .'
  292. -->
  293. \/*]]>*/
  294. </style>';}
  295. if(strlen($fTemplate['title'])>0){
  296. $content .='
  297. <title>'.$fTemplate['title'].'</title>';
  298. }
  299. $content .='
  300. <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  301. <meta name="author" content="Elevated" />
  302. </head>
  303. <body marginheight="0" topmargin="0" leftmargin="0" marginwidth="0">
  304. ';
  305. $GLOBALS['TSFE']->additionalHeaderData['swfobject_script'] = '
  306. <script type="text/javascript" src="typo3conf/ext/typoflash/pi1/js/swfobject.js"></script>
  307. <script type="text/javascript" src="typo3conf/ext/typoflash/pi1/js/swfaddress.js"></script>';
  308. if($fTemplate['historyframe']=='1'){
  309. /*$GLOBALS['TSFE']->additionalHeaderData['dhtmlHistory_script'] = '
  310. <script type="text/javascript" src="typo3conf/ext/typoflash/pi1/js/dhtmlHistory.js"></script>';
  311. $GLOBALS['TSFE']->additionalHeaderData['typoFlashHistory_script'] = '
  312. <script type="text/javascript" src="typo3conf/ext/typoflash/pi1/js/typoFlashHistory.js"></script>';//this will generate error in IE if no frame loaded, ie history disabled
  313. $content .='<iframe style="left:-1000;top:-1000;position:absolute" name="historyframe" src="" width="50" height="50" frameborder="0" align="left" scrolling="no" ></iframe>';*/
  314. };
  315. $content .='<div id="flashContent"></div>
  316. <script language="JavaScript">
  317. <!--//';
  318. if(strlen($fTemplate['redirectpage'])>0){
  319. //We have a redirect page
  320. $content .='
  321. requiredVersion = '.$fTemplate['version'].';
  322. //flash detection
  323. if (actualVersion < requiredVersion){
  324. self.location.href = "'.$fTemplate['redirectpage'].'";
  325. }';
  326. }else{
  327. //No redirect. Urge to install plugin
  328. $content .='
  329. requiredVersion = '.$fTemplate['version'].';
  330. //flash detection
  331. if (actualVersion < requiredVersion){
  332. htmlStr = \'<p class="tx_typoflash_pi1">To view this site you need to install a current version of the Flash player. It is quick and free. Follow this <a href="https://www.macromedia.com/go/getflashplayer" target="_blank">link</a>. </p>\';
  333. document.write(htmlStr);
  334. }';
  335. }
  336. $requiredVersion = $fTemplate['version'];
  337. $width = $fTemplate['width'];
  338. $height = $fTemplate['height'];
  339. $bgcolour = $fTemplate['bgcolour'];
  340. //+
  341. if($fTemplate['codepage']){
  342. $codepage = '&CODE_PAGE='.$fTemplate['codepage'];
  343. }else if($this->conf['CODE_PAGE']){
  344. $codepage = '&CODE_PAGE='.$this->conf['CODE_PAGE'];
  345. }else{
  346. $codepage = '&CODE_PAGE=0';
  347. }
  348. if($fTemplate['scalemode']){
  349. $scalemode = '&SCALE_MODE='.$fTemplate['scalemode'];
  350. }else if($this->conf['SCALE_MODE']){
  351. $scalemode = '&SCALE_MODE='.$this->conf['SCALE_MODE'];
  352. }else{
  353. $scalemode = '&SCALE_MODE=noScale';
  354. }
  355. if($fTemplate['align']){
  356. $align = '&ALIGN='.$fTemplate['align'];
  357. }else{
  358. $align = '&ALIGN=TL';
  359. }
  360. if($fTemplate['windowmode']){
  361. $windowmode = $fTemplate['windowmode'];
  362. }else{
  363. $windowmode = 'window';
  364. }
  365. if($fTemplate['hosturl']){
  366. $hosturl = '&HOST_URL='.$fTemplate['hosturl'];
  367. }else if($this->conf['HOST_URL']){
  368. $hosturl = '&HOST_URL='.$this->conf['HOST_URL'];
  369. }else{
  370. $hosturl = '&HOST_URL=http://'.$_SERVER['HTTP_HOST'].'/';
  371. }
  372. if($fTemplate['relaysocket']){
  373. $relaysocket = '&REMOTING_RELAY_SOCKET='.$fTemplate['relaysocket'];
  374. }else if($this->conf['REMOTING_RELAY_SOCKET']){
  375. $relaysocket = '&REMOTING_RELAY_SOCKET='.$this->conf['REMOTING_RELAY_SOCKET'];
  376. }else{
  377. $relaysocket = '';
  378. }
  379. if($fTemplate['relayport']){
  380. $relayport = '&REMOTING_RELAY_PORT='.$fTemplate['relayport'];
  381. }else if($this->conf['REMOTING_RELAY_PORT']){
  382. $relayport = '&REMOTING_RELAY_PORT='.$this->conf['REMOTING_RELAY_PORT'];
  383. }else{
  384. $relayport = '';
  385. }
  386. if($fTemplate['relayserver']){
  387. $relayserver = '&RELAY_SERVER='.$fTemplate['relayserver'];
  388. }else if($this->conf['RELAY_SERVER']){
  389. $relayserver = '&RELAY_SERVER='.$this->conf['RELAY_SERVER'];
  390. }else{
  391. $relayserver = '';
  392. }
  393. if($fTemplate['preloader']){
  394. $preloader = '&PRELOADER='.$fTemplate['preloader'];
  395. $file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$fTemplate['preloader']);
  396. $fsize = round(filesize($file)/1024) . ',';
  397. }else{
  398. $preloader = '';
  399. $fsize = '';
  400. }
  401. $swfs = $fTemplate['swfs'];
  402. if(strlen($swfs)>1){
  403. //get files sizes
  404. $ff = explode(',',$swfs);
  405. foreach($ff as $k=>$v){
  406. $file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$v);
  407. $fsize.= round(filesize($file)/1024) . ',';
  408. }
  409. }
  410. if($fTemplate['dynamic_fonts']){
  411. $dynamic_fonts = '&DYNAMIC_FONTS=';
  412. $df = explode(',',$fTemplate['dynamic_fonts']);
  413. foreach($df as $k=>$v){
  414. //we need to copy font file and library to base directory...only way I got it to work as the link url in the library didn't have any effect even if absolute path..and I didn't want to make assets base directory
  415. //AS3 fonts begin with _ char
  416. if ($fTemplate['asversion'] == 'as3') {
  417. $v = '_' . $v;
  418. }
  419. $fontsToAdd .= $v .',';
  420. $font_file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$v);
  421. if(!file_exists($font_file)){
  422. $font_scr = t3lib_div::getFileAbsFileName('typo3conf/ext/typoflash/assets/'.$v);
  423. copy($font_scr,PATH_site.'uploads/tx_typoflash/'.$v);
  424. }
  425. if ($fTemplate['asversion'] == 'as2') {
  426. //as2 version loads two files for each font
  427. $fontName = substr($v,0,-4);
  428. $font_lib_file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$fontName.'_lib.swf');
  429. if(!file_exists($font_lib_file)){
  430. $font_lib_scr = t3lib_div::getFileAbsFileName('typo3conf/ext/typoflash/assets/'.$fontName.'_lib.swf');
  431. copy($font_lib_scr,PATH_site.'uploads/tx_typoflash/'.$fontName.'_lib.swf');
  432. }
  433. }
  434. $file = t3lib_div::getFileAbsFileName('typo3conf/ext/typoflash/assets/'.$v);
  435. $fsize.= round(filesize($file)/1024) . ',';
  436. }
  437. //remove trailing ,
  438. $fontsToAdd = substr($fontsToAdd, 0, -1);
  439. $dynamic_fonts = '&DYNAMIC_FONTS='.$fontsToAdd;
  440. }else{
  441. $dynamic_fonts = '';
  442. }
  443. if($fTemplate['fonts']){
  444. $fonts = '&FONTS='.$fTemplate['fonts'];
  445. $file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$fTemplate['fonts']);
  446. $fsize .= round(filesize($file)/1024) . ',';
  447. }else{
  448. $fonts = '';
  449. }
  450. //finally add the template filesize too
  451. $file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$fTemplate['file']);
  452. if(strlen($fsize)>1){
  453. $fsize.= round(filesize($file)/1024);
  454. }else{
  455. $fsize= round(filesize($file)/1024);
  456. }
  457. if($fTemplate['swfs']){
  458. $swfs = '&SWFS='.$fTemplate['swfs'];
  459. $swfSize = '&SWFS_SIZE='.$fsize;
  460. }else{
  461. $swfs = '';
  462. $swfSize = '&SWFS_SIZE='.$fsize;//can only add template size
  463. }
  464. //some conf data need to be passed directy into the html rather than on getPage...eg root pid of menus...by storing that
  465. //as a special template level conf data "htmlVars" we can pass it it
  466. $data = $this->tmplTFdata;
  467. $htmlVars = '';
  468. if(is_array($data['htmlVars'][$this->LLuid])){
  469. foreach($data['htmlVars'][$this->LLuid] as $key=>$obj){
  470. if(is_array($obj)){
  471. foreach($obj as $k=>$v){
  472. if($v!=''){
  473. $htmlVars .= '&'.$key .'|'.$k.'='.$v;
  474. }
  475. }
  476. }
  477. }
  478. }
  479. /*
  480. preloader
  481. swfs
  482. hosturl
  483. relaysocket
  484. relayport
  485. relayserver
  486. codepage
  487. scalemode
  488. align
  489. windowmode
  490. */
  491. //-
  492. $codebaseURL="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='".$fTemplate['version'].",0,0,0'";
  493. $pluginsURL='https://www.macromedia.com/go/getflashplayer';
  494. $base = 'uploads/tx_typoflash/';
  495. //$base = '/typo3conf/ext/typoflash/assets/';
  496. $language = t3lib_div::GPvar('L') ? t3lib_div::GPvar('L') : $GLOBALS['TSFE']->config['config']['sys_language_uid'];
  497. if($GLOBALS['BE_USER']->user['uid']>0){
  498. $GLOBALS['TSFE']->set_no_cache();
  499. $beAccess = "&BE_USER=" .$GLOBALS['BE_USER']->user['uid'];
  500. }else{
  501. $beAccess = "";
  502. }
  503. //Added 26/03/2008
  504. $sitetitle = $GLOBALS['TSFE']->tmpl->sitetitle;
  505. $sitetitle = "&SITE_TITLE=". $sitetitle;
  506. $title = $GLOBALS['TSFE']->page['title'];
  507. $title = "&TITLE=". $title;
  508. $vars = $hosturl. $relaysocket. $relayport.$relayserver.$preloader.$swfs.'&TEMPLATE='.$fTemplate['file'].$fonts.$dynamic_fonts.$swfSize. '&PAGE_ALIAS='.$row['alias'] .'&PAGE_ID='.$row['uid'] .'&L='.$language .$htmlVars.$sitetitle.$title .$codepage.$scalemode.$align.'&BG_COLOUR='.$bgcolour.'&IS_LIVE=1&HISTORY_ENABLED='.$fTemplate['historyframe'].$beAccess.'&QUERY_STRING='. rawurlencode($_SERVER['QUERY_STRING']);//append pid and query string, if the page is cached already you must append &no_cache=1 to get latest version
  509. //$movie = $base.$fTemplate['file'] .'?'. $fTemplate['conf'] . '&PAGE_ID='.$row['uid'] .'&IS_LIVE=1&HISTORY_ENABLED='.$fTemplate['historyframe'].'&'. $_SERVER['QUERY_STRING'];//append pid and query string
  510. $movie = '/typo3conf/ext/typoflash/pi1/'.$this->getCoreVersion($fTemplate['version'],$fTemplate['asversion']).'?'. $vars;
  511. $quality = 'high';
  512. if($fTemplate['menu']){
  513. $menu = 'true';
  514. }else{
  515. $menu = 'false';
  516. }
  517. if($fTemplate['fullscreen']){
  518. $fullscreen = 'true';
  519. }else{
  520. $fullscreen = 'false';
  521. }
  522. if($fTemplate['historyframe']=='1'){
  523. $movieId = 'main';//this is needed by historyframe
  524. }else{
  525. $movieId = $fTemplate['movieId'];
  526. }
  527. //Continue with real flash content
  528. $content .='else{
  529. var fo = new SWFObject("'.$movie.'", "main", "'.$width.'", "'.$height.'", "'.$fTemplate['version'].'", "'.$bgcolour.'",true);
  530. fo.addParam("quality", "'.($conf['conf.']['quality'] ? 'low' : 'high').'");
  531. fo.addParam("allowScriptAccess", "always");
  532. fo.addParam("wmode", "window");
  533. fo.addParam("menu", "'.$menu.'");
  534. fo.addParam("allowFullScreen", "'.$fullscreen.'");
  535. fo.addParam("align", "middle");
  536. fo.addParam("scale", "showall");
  537. fo.addParam("base", "'.$base.'");';
  538. fo.addParam("bgcolor", "'.$bgcolor.'");';
  539. fo.write("flashContent");
  540. </script>
  541. //-->
  542. ';
  543. $content .=' <noscript>
  544. <p>Please enable javascript</p>
  545. </noscript>
  546. </div>
  547. </body>
  548. </html>';
  549. } else {
  550. $content = $this->formatError(' Couldn\'t find a TypoFlash template set for table/row "'.$table.':'.$row['uid'].'"
  551. If you think there are templates in the rootline that aren\'t found, try adding this line to the end of typo3conf/localconf.php
  552. $TYPO3_CONF_VARS[\'FE\'][\'addRootLineFields\'] .= \',tx_typoflash_template,tx_typoflash_conf\';');
  553. }
  554. return $content;
  555. }
  556. function getCoreVersion($version,$asversion){
  557. switch ($version){
  558. case '5':
  559. return 'core5.swf';
  560. break;
  561. case '6':
  562. return 'core6.swf';
  563. break;
  564. case '7':
  565. return 'core7.swf';
  566. break;
  567. case '8':
  568. return 'core8.swf';
  569. break;
  570. case '9':
  571. return 'core9_'.$asversion.'.swf';
  572. break;
  573. case '10':
  574. return 'core10_'.$asversion.'.swf';
  575. break;
  576. case 'lite1.0':
  577. return 'core_lite1_0.swf';
  578. break;
  579. case 'lite1.1':
  580. return 'core_lite1_1.swf';
  581. break;
  582. case 'lite2.0':
  583. return 'core_lite2_0.swf';
  584. break;
  585. case 'lite2.1':
  586. return 'core_lite2_1.swf';
  587. break;
  588. default:
  589. return 'core8.swf';
  590. break;
  591. }
  592. }
  593. function renderTemplateInline($fTemplate = false, $core = false) {
  594. global $TYPO3_CONF_VARS;
  595. // Get data structure:
  596. if (t3lib_div::testInt($this->tx_typoflash_template) && !$fTemplate) { // If integer, then its a record we will look up:
  597. $fTemplate = $GLOBALS['TSFE']->sys_page->checkRecord('tx_typoflash_template', $this->tx_typoflash_template);
  598. }
  599. $content = '';
  600. if($fTemplate){
  601. /*
  602. $content .='
  603. <script language="JavaScript">
  604. <!--//';
  605. //No redirect. Urge to install plugin
  606. $content .='
  607. requiredVersion = '.$fTemplate['version'].';
  608. //flash detection
  609. if (actualVersion < requiredVersion){
  610. htmlStr = \'<p class="tx_typoflash_pi1">To view this site you need to install a current version of the Flash player. It is quick and free. Follow this <a href="https://www.macromedia.com/go/getflashplayer" target="_blank">link</a>. </p>\';
  611. document.write(htmlStr);
  612. }';
  613. */
  614. $requiredVersion = $fTemplate['version'];
  615. $width = $fTemplate['width'];
  616. $height = $fTemplate['height'];
  617. $bgcolour = $fTemplate['bgcolour'];
  618. //+
  619. if($fTemplate['codepage']){
  620. $codepage = '&CODE_PAGE='.$fTemplate['codepage'];
  621. }else if($this->conf['CODE_PAGE']){
  622. $codepage = '&CODE_PAGE='.$this->conf['CODE_PAGE'];
  623. }else{
  624. $codepage = '&CODE_PAGE=0';
  625. }
  626. if($fTemplate['scalemode']){
  627. $scalemode = '&SCALE_MODE='.$fTemplate['scalemode'];
  628. }else if($this->conf['SCALE_MODE']){
  629. $scalemode = '&SCALE_MODE='.$this->conf['SCALE_MODE'];
  630. }else{
  631. $scalemode = '&SCALE_MODE=noScale';
  632. }
  633. if($fTemplate['align']){
  634. $align = '&ALIGN='.$fTemplate['align'];
  635. }else{
  636. $align = '&ALIGN=TL';
  637. }
  638. if($fTemplate['windowmode']){
  639. $windowmode = $fTemplate['windowmode'];
  640. }else{
  641. $windowmode = 'window';
  642. }
  643. if($fTemplate['historyframe']=='1'){
  644. //this will generate error in IE if no frame loaded, ie history disabled
  645. /*$GLOBALS['TSFE']->additionalHeaderData['dhtmlHistory_script'] = '
  646. <script type="text/javascript" src="typo3conf/ext/typoflash/pi1/js/dhtmlHistory.js"></script>';
  647. $GLOBALS['TSFE']->additionalHeaderData['typoFlashHistory_script'] = '
  648. <script type="text/javascript" src="typo3conf/ext/typoflash/pi1/js/typoFlashHistory.js"></script>';*/
  649. }
  650. if($fTemplate['hosturl']){
  651. $hosturl = '&HOST_URL='.$fTemplate['hosturl'];
  652. }else if($this->conf['HOST_URL']){
  653. $hosturl = '&HOST_URL='.$this->conf['HOST_URL'];
  654. }else{
  655. $hosturl = '&HOST_URL=http://'.$_SERVER['HTTP_HOST'].'/';
  656. }
  657. if($fTemplate['relaysocket']){
  658. $relaysocket = '&REMOTING_RELAY_SOCKET='.$fTemplate['relaysocket'];
  659. }else if($this->conf['REMOTING_RELAY_SOCKET']){
  660. $relaysocket = '&REMOTING_RELAY_SOCKET='.$this->conf['REMOTING_RELAY_SOCKET'];
  661. }else{
  662. $relaysocket = '';
  663. }
  664. if($fTemplate['relayport']){
  665. $relayport = '&REMOTING_RELAY_PORT='.$fTemplate['relayport'];
  666. }else if($this->conf['REMOTING_RELAY_PORT']){
  667. $relayport = '&REMOTING_RELAY_PORT='.$this->conf['REMOTING_RELAY_PORT'];
  668. }else{
  669. $relayport = '';
  670. }
  671. if($fTemplate['relayserver']){
  672. $relayserver = '&RELAY_SERVER='.$fTemplate['relayserver'];
  673. }else if($this->conf['RELAY_SERVER']){
  674. $relayserver = '&RELAY_SERVER='.$this->conf['RELAY_SERVER'];
  675. }else{
  676. $relayserver = '';
  677. }
  678. if($fTemplate['preloader']){
  679. $preloader = '&PRELOADER='.$fTemplate['preloader'];
  680. $file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$fTemplate['preloader']);
  681. $fsize = round(filesize($file)/1024) . ',';
  682. }else{
  683. $preloader = '';
  684. $fsize = '';
  685. }
  686. if($fTemplate['dynamic_fonts']){
  687. $df = explode(',',$fTemplate['dynamic_fonts']);
  688. foreach($df as $k=>$v){
  689. //we need to copy font file and library to base directory...only way I got it to work as the link url in the library didn't have any effect even if absolute path..and I didn't want to make assets base directory
  690. //AS3 fonts begin with _ char
  691. if ($fTemplate['asversion'] == 'as3') {
  692. $v = '_' . $v;
  693. }
  694. $fontsToAdd .= $v .',';
  695. $font_file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$v);
  696. if(!file_exists($font_file)){
  697. $font_scr = t3lib_div::getFileAbsFileName('typo3conf/ext/typoflash/assets/'.$v);
  698. copy($font_scr,PATH_site.'uploads/tx_typoflash/'.$v);
  699. }
  700. if ($fTemplate['asversion'] == 'as2') {
  701. //as2 version loads two files for each font
  702. $fontName = substr($v,0,-4);
  703. $font_lib_file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$fontName.'_lib.swf');
  704. if(!file_exists($font_lib_file)){
  705. $font_lib_scr = t3lib_div::getFileAbsFileName('typo3conf/ext/typoflash/assets/'.$fontName.'_lib.swf');
  706. copy($font_lib_scr,PATH_site.'uploads/tx_typoflash/'.$fontName.'_lib.swf');
  707. }
  708. }
  709. $file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$v);
  710. $fsize.= round(filesize($file)/1024) . ',';
  711. }
  712. //remove trailing ,
  713. $fontsToAdd = substr($fontsToAdd, 0, -1);
  714. $dynamic_fonts = '&DYNAMIC_FONTS='.$fontsToAdd;
  715. }else{
  716. $dynamic_fonts = '';
  717. }
  718. if($fTemplate['fonts']){
  719. $fonts = '&FONTS='.$fTemplate['fonts'];
  720. $file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$fTemplate['fonts']);
  721. $fsize .= round(filesize($file)/1024) . ',';
  722. }else{
  723. $fonts = '';
  724. }
  725. $swfs = $fTemplate['swfs'];
  726. if(strlen($swfs)>1){
  727. //get files sizes
  728. $ff = explode(',',$swfs);
  729. foreach($ff as $k=>$v){
  730. $file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$v);
  731. $fsize.= round(filesize($file)/1024) . ',';
  732. }
  733. }
  734. //finally add the template filesize too
  735. $file = t3lib_div::getFileAbsFileName('uploads/tx_typoflash/'.$fTemplate['file']);
  736. if(strlen($fsize)>1){
  737. $fsize.= round(filesize($file)/1024);
  738. }else{
  739. $fsize= round(filesize($file)/1024);
  740. }
  741. if($fTemplate['swfs']){
  742. $swfs = '&SWFS='.$fTemplate['swfs'];
  743. $swfSize = '&SWFS_SIZE='.$fsize;
  744. }else{
  745. $swfs = '';
  746. $swfSize = '&SWFS_SIZE='.$fsize;//can only add template size
  747. }
  748. //some conf data need to be passed directy into the html rather than on getPage...eg root pid of menus...by storing that
  749. //as a special template level conf data "htmlVars" we can pass it it
  750. $data = $this->tmplTFdata;
  751. $htmlVars = '';
  752. if(is_array($data['htmlVars'][$this->LLuid])){
  753. foreach($data['htmlVars'][$this->LLuid] as $key=>$obj){
  754. if(is_array($obj)){
  755. foreach($obj as $k=>$v){
  756. if($v!=''){
  757. $htmlVars .= '&'.$key .'|'.$k.'='.$v;
  758. }
  759. }
  760. }
  761. }
  762. }
  763. /*
  764. preloader
  765. swfs
  766. hosturl
  767. relaysocket
  768. relayport
  769. relayserver
  770. codepage
  771. scalemode
  772. align
  773. windowmode
  774. */
  775. //-
  776. $codebaseURL="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='".$fTemplate['version'].",0,0,0'";
  777. $pluginsURL='https://www.macromedia.com/go/getflashplayer';
  778. $base = 'uploads/tx_typoflash/';
  779. //$base = '/typo3conf/ext/typoflash/assets/';
  780. $language = t3lib_div::GPvar('L') ? t3lib_div::GPvar('L') : $GLOBALS['TSFE']->config['config']['sys_language_uid'];
  781. if($GLOBALS['BE_USER']->user['uid']>0){
  782. $GLOBALS['TSFE']->set_no_cache();
  783. $beAccess = "&BE_USER=" .$GLOBALS['BE_USER']->user['uid'];
  784. }else{
  785. $beAccess = "";
  786. }
  787. /*
  788. Content rendering options.
  789. We either choose
  790. 1. all content records from same page,
  791. 2. else select specific records
  792. 3. else content from other page
  793. 4. or all content records from specified table and page
  794. */
  795. //what page to get content from
  796. if($this->tx_typoflash_what_to_render==1){
  797. //select all tt_content from this page
  798. $fPages = '&PAGES='.$GLOBALS['TSFE']->id;
  799. }else{
  800. if($this->tx_typoflash_pages){
  801. $fPages = '&PAGES='.$this->tx_typoflash_pages;
  802. }else{
  803. $fPages = '';
  804. }
  805. }
  806. if($this->tx_typoflash_records){
  807. $fRecs = '&RECS='.$this->tx_typoflash_records;
  808. }else{
  809. $fRecs = '';
  810. }
  811. if($this->tx_typoflash_tables){
  812. $fTables = '&TABLES='.$this->tx_typoflash_tables;
  813. }else{
  814. $fTables = '';
  815. }
  816. if($this->tx_typoflash_recordLimit){
  817. $fLimit = '&LIMIT='.$this->tx_typoflash_recordLimit;
  818. }else{
  819. $fLimit = '';
  820. }
  821. if($this->tx_typoflash_orderBy){
  822. $fOrder = '&ORDER_BY='.$this->tx_typoflash_orderBy;
  823. }else{
  824. $fOrder = '';
  825. }
  826. ;//append pid and query string, if the page is cached already you must append &no_cache=1 to get latest version
  827. if($core){
  828. $addToCore = '&TEMPLATE='.$fTemplate['file'];
  829. $movie = '/typo3conf/ext/typoflash/pi1/'.$this->getCoreVersion($fTemplate['version'],$fTemplate['asversion']);
  830. }else{
  831. $addToCore = '';
  832. $movie = '/uploads/tx_typoflash/'. $fTemplate['file'];
  833. }
  834. //Added 26/03/2008
  835. $sitetitle = $GLOBALS['TSFE']->tmpl->sitetitle;
  836. $sitetitle = "&SITE_TITLE=". $sitetitle;
  837. $title = $GLOBALS['TSFE']->page['title'];
  838. $title = "&TITLE=". $title;
  839. //'&HTTP_USER_AGENT='.$_SERVER['HTTP_USER_AGENT']. //removed this since its getting cached and thus bit useless
  840. $vars = $hosturl. $relaysocket. $relayport.$relayserver.$preloader.$fonts.$dynamic_fonts.$swfs.$swfSize. '&PAGE_ALIAS='.$row['alias']. '&PAGE_ID='.$GLOBALS['TSFE']->id .'&L='.$language .$sitetitle.$title.$htmlVars.$codepage.$scalemode.$align.'&BG_COLOUR='.$bgcolour.'&IS_LIVE=1&IS_INLINE=1&HISTORY_ENABLED='.$fTemplate['historyframe'].'&'.$beAccess.'&QUERY_STRING='. rawurlencode($_SERVER['QUERY_STRING']).$fRecs.$fPages.$fTables.$fLimit.$fOrder.$fConf.$addToCore.'&TYPO3_OS='.TYPO3_OS;
  841. //$movie = $base.$fTemplate['file'] .'?'. $fTemplate['conf'] . '&PAGE_ID='.$row['uid'] .'&IS_LIVE=1&HISTORY_ENABLED='.$fTemplate['historyframe'].'&'. $_SERVER['QUERY_STRING'];//append pid and query string
  842. $quality = 'high';
  843. if($fTemplate['menu']){
  844. $menu = 'true';
  845. }else{
  846. $menu = 'false';
  847. }
  848. if($fTemplate['fullscreen']){
  849. $fullscreen = 'true';
  850. }else{
  851. $fullscreen = 'false';
  852. }
  853. if($fTemplate['movieId']){
  854. $movieId = $fTemplate['movieId'];
  855. }else{
  856. $movieId = 'movie_'.$this->cObj->data['uid'];
  857. }
  858. if(!isset($this->conf['DIV_TAG'])){
  859. $content .='<div id="flashcontent_'.$this->cObj->data['uid'].'" class="typoflash_content" style="width:'.$width.',height:'.$height.',overflow:auto">';
  860. }
  861. /*****************************
  862. Searchengine optimization
  863. *****************************/
  864. /*
  865. if(stristr($HTTP_USER_AGENT,"Googlebot")) {
  866. $logtext = "Google";
  867. } elseif (stristr($HTTP_USER_AGENT,"Slurp")) {
  868. $logtext = "Yahoo!";
  869. } elseif (stristr($HTTP_USER_AGENT,"msnbot")) {
  870. $logtext = "MSN";
  871. } elseif (stristr($HTTP_USER_AGENT,"Yandex")) {
  872. $logtext = "Yandex";
  873. }
  874. $ceoConf = array('table' => 'tt_content',
  875. 'select.' => array('pidInList' => $GLOBALS['TSFE']->id,
  876. 'orderBy' => 'sorting'));
  877. $content .='<div class="SEO" id="SEO_'.$this->cObj->data['uid'].'">';
  878. $content .= $this->cObj->CONTENT($ceoConf);
  879. $content .= '</div>';
  880. }
  881. $this->tx_typoflash_seo_what_to_render = $this->pi_getFFvalue($piFlexForm,'what_to_render','seo');
  882. $this->tx_typoflash_seo_records = $this->pi_getFFvalue($piFlexForm,'records','seo');
  883. $this->tx_typoflash_seo_pages = $this->pi_getFFvalue($piFlexForm,'pages','seo');
  884. */
  885. if(stristr($HTTP_USER_AGENT,"Googlebot") || stristr($HTTP_USER_AGENT,"Slurp") || stristr($HTTP_USER_AGENT,"msnbot") || stristr($HTTP_USER_AGENT,"Yandex") && ($this->tx_typoflash_seo_what_to_render>0)) {
  886. /*
  887. Content cloaked for search engines produced here
  888. */
  889. $content .='<div class="SEO" id="SEO_'.$this->cObj->data['uid'].'">';
  890. if($this->tx_typoflash_seo_what_to_render==0){
  891. //content selected below
  892. if($this->tx_typoflash_nf_records){
  893. //extract records
  894. $content .= $this->cObj->RECORDS(array('source'=>$this->tx_typoflash_nf_records));
  895. /*$rr = explode(',',$this->tx_typoflash_nf_records);
  896. foreach($rr as $k=>$v){
  897. $tn = $this->getTableName($v);
  898. $ri = $this->getRecordId($v);
  899. $ceoConf = array('table' =>$tn,'select.' => array('where' =>'uid='. $ri));
  900. //output actual content
  901. $content .= $this->cObj->CONTENT($ceoConf);
  902. }*/
  903. }else if($this->tx_typoflash_nf_pages){
  904. //content from selected pages
  905. $rr = explode(',',$this->tx_typoflash_nf_pages);
  906. $pi='-10000';
  907. foreach($rr as $k=>$v){
  908. $pi .= ','.$this->getRecordId($v);
  909. }
  910. $ceoConf = array('table' => 'tt_content','select.' => array('pidInList' => $pi,'orderBy' => 'sorting'));
  911. //output actual content
  912. $content .= $this->cObj->CONTENT($ceoConf);
  913. }
  914. }else if($this->tx_typoflash_seo_what_to_render==1){
  915. //same as flash
  916. $ceoConf = array('table' => 'tt_content','select.' => array('pidInList' => $tt_pages_uid,'orderBy' => 'sorting'));
  917. //output actual content
  918. $content .= $this->cObj->CONTENT($ceoConf);
  919. }else if($this->tx_typoflash_seo_what_to_render==2){
  920. //all content from this page
  921. $ceoConf = array('table' => 'tt_content','select.' => array('pidInList' => $GLOBALS['TSFE']->id,'orderBy' => 'sorting'));
  922. }
  923. $content .= $this->cObj->CONTENT($ceoConf);
  924. $content .='';
  925. $content .='</div>';
  926. }else{
  927. /****************************
  928. Normal non flash content for all
  929. ****************************/
  930. //wrap in special div tag with desired styling
  931. $content .='<div class="non_flash" id="non_flash_'.$this->cObj->data['uid'].'">';
  932. if($this->tx_typoflash_nf_what_to_render==0){
  933. //content selected below
  934. if($this->tx_typoflash_nf_records){
  935. //extract records
  936. $content .= $this->cObj->RECORDS(array('source'=>$this->tx_typoflash_nf_records));
  937. //untested http://typo3.org/documentation/document-library/references/doc_core_tsref/current/view/8/10/
  938. /*$rr = explode(',',$this->tx_typoflash_nf_records);
  939. foreach($rr as $k=>$v){
  940. $tn = $this->getTableName($v);
  941. $ri = $this->getRecordId($v);
  942. $ceoConf = array('table' =>$tn,'select.' => array('where' =>'uid='. $ri));
  943. //output actual content
  944. $content .= $this->cObj->CONTENT($ceoConf);
  945. }*/
  946. }else if($this->tx_typoflash_nf_pages){
  947. //content from selected pages
  948. $rr = explode(',',$this->tx_typoflash_nf_pages);
  949. $pi='-10000';
  950. foreach($rr as $k=>$v){
  951. $pi .= ','.$this->getRecordId($v);
  952. }
  953. $ceoConf = array('table' => 'tt_content','select.' => array('pidInList' => $pi,'orderBy' => 'sorting'));
  954. //output actual content
  955. $content .= $this->cObj->CONTENT($ceoConf);
  956. }
  957. }else if($this->tx_typoflash_nf_what_to_render==1){
  958. //same records as flash
  959. $ceoConf = array('table' => 'tt_content','select.' => array('pidInList' => $tt_pages_uid,'orderBy' => 'sorting'));
  960. //output actual content
  961. $content .= $this->cObj->CONTENT($ceoConf);
  962. }else if($this->tx_typoflash_nf_what_to_render==2){
  963. //all content from this page
  964. $ceoConf = array('table' => 'tt_content','select.' => array('pidInList' => $GLOBALS['TSFE']->id,'orderBy' => 'sorting'));
  965. //output actual content
  966. $content .= $this->cObj->CONTENT($ceoConf);
  967. }
  968. if($this->tx_typoflash_nf_showlink){
  969. $content .= '
  970. <a href="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">Get Flash player here</a>';
  971. }
  972. $content .='</div>';
  973. }
  974. if(!isset($this->conf['DIV_TAG'])){
  975. //end normal flashcontent div
  976. $content .='</div>
  977. ';
  978. }
  979. $content .='
  980. <script type="text/javascript">
  981. // <![CDATA[
  982. ';
  983. /*
  984. //23/08/2009 smarter to add style header than modify with javascript
  985. if($this->conf['DIV_TAG']){
  986. //add styling to alternative div tag to make sure it sits nicely with w and h
  987. $content .='
  988. var altTag = document.getElementById('.$this->conf['DIV_TAG'].');
  989. var browser=navigator.appName;
  990. var b_version=navigator.appVersion;
  991. var version=parseFloat(b_version);
  992. if (browser=="Microsoft Internet Explorer" && version>=6){
  993. altTag.style.setAttribute("cssText", "width:'.$width.',height:'.$height.',overflow:auto", 0);
  994. }else{
  995. //Non IE6
  996. altTag.setAttribute("style","width:'.$width.',height:'.$height.',min-height:'.$height.',overflow:auto");
  997. }
  998. ';
  999. }
  1000. */
  1001. $flashStyle = '
  1002. <style>
  1003. ';
  1004. //23/08/2009 added min-height and html,body height 100% in to be able to fill entire height
  1005. if($height=='100%'){
  1006. $flashStyle .=
  1007. '
  1008. html,body{
  1009. height:100%;
  1010. margin:0;
  1011. overflow:hidden;
  1012. }
  1013. ';
  1014. if($this->conf['DIV_TAG']){
  1015. $flashStyle .=
  1016. '
  1017. #'.$this->conf['DIV_TAG'].'{
  1018. width:'.$width.';
  1019. height:'.$height.';
  1020. min-height:'.$height.';
  1021. overflow:hidden;
  1022. }
  1023. ';
  1024. }
  1025. }else if($this->conf['DIV_TAG']){
  1026. $flashStyle .=
  1027. '
  1028. #'.$this->conf['DIV_TAG'].'{
  1029. width:'.$width.';
  1030. height:'.$height.';
  1031. min-height:'.$height.';
  1032. overflow:hidden;
  1033. }
  1034. ';
  1035. }
  1036. $flashStyle .= '
  1037. </style>
  1038. ';
  1039. $GLOBALS['TSFE']->additionalHeaderData['flashStyle'] = $flashStyle;
  1040. $content .='
  1041. var fo = new SWFObject("'.$movie.'", "main", "'.$width.'", "'.$height.'", "'.$fTemplate['version'].'", "'.$bgcolour.'",true);
  1042. fo.addParam("quality", "'.($conf['conf.']['quality'] ? 'low' : 'high').'");
  1043. fo.addParam("allowScriptAccess", "always");
  1044. fo.addParam("wmode", "'.$windowmode.'");
  1045. fo.addParam("menu", "'.$menu.'");
  1046. fo.addParam("base", "'.$base.'");
  1047. fo.addParam("allowFullScreen", "'.$fullscreen.'");';
  1048. if($vars){
  1049. //break special variables up into Querystring format and url encode
  1050. $qs = explode('&',$vars);
  1051. foreach($qs as $ix=>$var){
  1052. $qqs = explode('=',$var);
  1053. if($qqs[0] != null){
  1054. $content .='
  1055. fo.addVariable("'.$qqs[0].'", "'.rawurlencode($qqs[1]).'");';
  1056. }
  1057. }
  1058. }
  1059. if($this->tx_typoflash_conf){
  1060. //break special variables up into Querystring format and url encode
  1061. $qs = explode('&',$this->tx_typoflash_conf);
  1062. foreach($qs as $ix=>$var){
  1063. $qqs = explode('=',$var);
  1064. $content .='
  1065. fo.addVariable("'.$qqs[0].'", "'.rawurlencode($qqs[1]).'");';
  1066. }
  1067. }
  1068. //DIV_TAG is the alternative html tag to write the content into, if not into flashcontent_
  1069. if($this->conf['DIV_TAG']){
  1070. $content .='
  1071. fo.write("'.$this->conf['DIV_TAG'].'");
  1072. // ]]>
  1073. </script>';
  1074. }else{
  1075. $content .='
  1076. fo.write("flashcontent_'.$this->cObj->data['uid'].'");
  1077. // ]]>
  1078. </script>';
  1079. }
  1080. $content .=' <noscript>
  1081. <p>Please enable javascript</p>
  1082. </noscript>
  1083. ';
  1084. /*
  1085. searchengine optimizatin
  1086. */
  1087. //getTableName
  1088. //getRecordId
  1089. //if(eregi("googlebot",$HTTP_USER_AGENT)){}
  1090. /*
  1091. if(stristr($HTTP_USER_AGENT,"Googlebot")) {
  1092. $logtext = "Google";
  1093. } elseif (stristr($HTTP_USER_AGENT,"Slurp")) {
  1094. $logtext = "Yahoo!";
  1095. } elseif (stristr($HTTP_USER_AGENT,"msnbot")) {
  1096. $logtext = "MSN";
  1097. } elseif (stristr($HTTP_USER_AGENT,"Yandex")) {
  1098. $logtext = "Yandex";
  1099. }
  1100. if($fTemplate['searchengine'] && $this->tx_typoflash_records){
  1101. $ceoConf = array('table' => 'tt_content',
  1102. 'select.' => array('pidInList' => $GLOBALS['TSFE']->id,
  1103. 'orderBy' => 'sorting'));
  1104. $content .='<div class="SEO" id="SEO_'.$this->cObj->data['uid'].'">';
  1105. $content .= $this->cObj->CONTENT($ceoConf);
  1106. $content .= '</div>';
  1107. }
  1108. */
  1109. } else {
  1110. $content = $this->formatError(' Couldn\'t find a TypoFlash template set for table/row "'.$table.':'.$row['uid'].'"
  1111. If you think there are templates in the rootline that aren\'t found, try adding this line to the end of typo3conf/localconf.php
  1112. $TYPO3_CONF_VARS[\'FE\'][\'addRootLineFields\'] .= \',tx_typoflash_template,tx_typoflash_conf\';');
  1113. }
  1114. return $content;
  1115. }
  1116. function init_typoflashHistory($content,$conf) {
  1117. global $TYPO3_CONF_VARS;
  1118. $this->conf =$conf;
  1119. // Current page record which we MIGHT manipulate a little:
  1120. $pageRecord = $GLOBALS['TSFE']->page;
  1121. // Find Template in root line IF there is no Data Structure set for the current page:
  1122. if (!$pageRecord['tx_typoflash_template']) {
  1123. foreach($GLOBALS['TSFE']->tmpl->rootLine as $pRec) {
  1124. if ($pageRecord['uid'] != $pRec['uid']) {
  1125. if ($pRec['tx_typoflash_template']) { // If there is a next-level DS:
  1126. $pageRecord['tx_typoflash_template'] = $pRec['tx_typoflash_template'];
  1127. }
  1128. } else break;
  1129. }
  1130. }
  1131. // Get data structure:
  1132. $srcPointer = $pageRecord['tx_typoflash_template'];
  1133. if (t3lib_div::testInt($srcPointer)) { // If integer, then its a record we will look up:
  1134. $this->tx_typoflash_template = $GLOBALS['TSFE']->sys_page->checkRecord('tx_typoflash_template', $srcPointer);
  1135. }
  1136. $content = '';
  1137. if($this->tx_typoflash_template['historyframe']=='1'){
  1138. $content .='<script type="text/javascript">initialize_typoflashHistory();</script>';
  1139. }
  1140. return $content;
  1141. }
  1142. /**
  1143. * Creates an error message for frontend output
  1144. *
  1145. * @param [type] $string: ...
  1146. * @return string Error message output
  1147. * @string string Error message input
  1148. */
  1149. function formatError($string) {
  1150. // Set no-cache since the error message shouldn't be cached of course...
  1151. $GLOBALS['TSFE']->set_no_cache();
  1152. //
  1153. $output = '
  1154. <!-- TypoFlash ERROR message: -->
  1155. <div class="tx_templavoila_pi1-error" style="
  1156. border: 2px red solid;
  1157. background-color: yellow;
  1158. color: black;
  1159. text-align: center;
  1160. padding: 20px 20px 20px 20px;
  1161. margin: 20px 20px 20px 20px;
  1162. ">'.
  1163. '<strong>TypoFlash ERROR:</strong><br /><br />'.nl2br(htmlspecialchars(trim($string))).
  1164. '</div>';
  1165. return $output;
  1166. }
  1167. /**
  1168. * [Put your description here]
  1169. */
  1170. function listView($content,$conf) {
  1171. $this->conf=$conf; // Setting the TypoScript passed to this function in $this->conf
  1172. $this->pi_setPiVarDefaults();
  1173. $this->pi_loadLL(); // Loading the LOCAL_LANG values
  1174. $lConf = $this->conf["listView."]; // Local settings for the listView function
  1175. if ($this->piVars["showUid"]) { // If a single element should be displayed:
  1176. $this->internal["currentTable"] = "tx_typoflash_component";
  1177. $this->internal["currentRow"] = $this->pi_getRecord("tx_typoflash_component",$this->piVars["showUid"]);
  1178. $content = $this->singleView($content,$conf);
  1179. return $content;
  1180. } else {
  1181. $items=array(
  1182. "1"=> $this->pi_getLL("list_mode_1","Mode 1"),
  1183. "2"=> $this->pi_getLL("list_mode_2","Mode 2"),
  1184. "3"=> $this->pi_getLL("list_mode_3","Mode 3"),
  1185. );
  1186. if (!isset($this->piVars["pointer"])) $this->piVars["pointer"]=0;
  1187. if (!isset($this->piVars["mode"])) $this->piVars["mode"]=1;
  1188. // Initializing the query parameters:
  1189. list($this->internal["orderBy"],$this->internal["descFlag"]) = explode(":",$this->piVars["sort"]);
  1190. $this->internal["results_at_a_time"]=t3lib_div::intInRange($lConf["results_at_a_time"],0,1000,3); // Number of results to show in a listing.
  1191. $this->internal["maxPages"]=t3lib_div::intInRange($lConf["maxPages"],0,1000,2);; // The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
  1192. $this->internal["searchFieldList"]="name,prop_x,prop_y,prop_alpha,path,initobj";
  1193. $this->internal["orderByList"]="uid,name,prop_x,prop_y,prop_alpha,path";
  1194. // Get number of records:
  1195. $res = $this->pi_exec_query("tx_typoflash_component",1);
  1196. list($this->internal["res_count"]) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
  1197. // Make listing query, pass query to SQL database:
  1198. $res = $this->pi_exec_query("tx_typoflash_component");
  1199. $this->internal["currentTable"] = "tx_typoflash_component";
  1200. // Put the whole list together:
  1201. $fullTable=""; // Clear var;
  1202. # $fullTable.=t3lib_div::view_array($this->piVars); // DEBUG: Output the content of $this->piVars for debug purposes. REMEMBER to comment out the IP-lock in the debug() function in t3lib/config_default.php if nothing happens when you un-comment this line!
  1203. // Adds the mode selector.
  1204. $fullTable.=$this->pi_list_modeSelector($items);
  1205. // Adds the whole list table
  1206. $fullTable.=$this->pi_list_makelist($res);
  1207. // Adds the search box:
  1208. $fullTable.=$this->pi_list_searchBox();
  1209. // Adds the result browser:
  1210. $fullTable.=$this->pi_list_browseresults();
  1211. // Returns the content from the plugin.
  1212. return $fullTable;
  1213. }
  1214. }
  1215. /**
  1216. * [Put your description here]
  1217. */
  1218. function getTableName($str){
  1219. //Find tableName as "tx_flashtemplate_content" in "tx_flashtemplate_content_12"
  1220. //$ditchMe = substr($str,-3,3);
  1221. $ditchMe = strrchr($str,'_');
  1222. if(strlen($ditchMe)>0){
  1223. $arr = explode($ditchMe ,$str);
  1224. return $arr[0];
  1225. }else{
  1226. return '';
  1227. }
  1228. // return $tName;
  1229. }
  1230. function getRecordId($str){
  1231. //Find recordId as last number of string, eg 12 in "tx_flashtemplate_content_12"
  1232. $arr = explode("_",$str);
  1233. $recId = $arr[count($arr)-1];
  1234. return $recId;
  1235. }
  1236. /**
  1237. * [Put your description here]
  1238. */
  1239. function pi_list_row($c) {
  1240. $editPanel = $this->pi_getEditPanel();
  1241. if ($editPanel) $editPanel="<TD>".$editPanel."</TD>";
  1242. return '<tr'.($c%2 ? $this->pi_classParam("listrow-odd") : "").'>
  1243. <td><p>'.$this->getFieldContent("uid").'</p></td>
  1244. <td valign="top"><p>'.$this->getFieldContent("name").'</p></td>
  1245. <td valign="top"><p>'.$this->getFieldContent("prop_x").'</p></td>
  1246. <td valign="top"><p>'.$this->getFieldContent("prop_y").'</p></td>
  1247. <td valign="top"><p>'.$this->getFieldContent("prop_alpha").'</p></td>
  1248. <td valign="top"><p>'.$this->getFieldContent("file").'</p></td>
  1249. <td valign="top"><p>'.$this->getFieldContent("path").'</p></td>
  1250. '.$editPanel.'
  1251. </tr>';
  1252. }
  1253. /**
  1254. * [Put your description here]
  1255. */
  1256. function pi_list_header() {
  1257. return '<tr'.$this->pi_classParam("listrow-header").'>
  1258. <td><p>'.$this->getFieldHeader_sortLink("uid").'</p></td>
  1259. <td><p>'.$this->getFieldHeader_sortLink("name").'</p></td>
  1260. <td><p>'.$this->getFieldHeader_sortLink("prop_x").'</p></td>
  1261. <td><p>'.$this->getFieldHeader_sortLink("prop_y").'</p></td>
  1262. <td><p>'.$this->getFieldHeader_sortLink("prop_alpha").'</p></td>
  1263. <td nowrap><p>'.$this->getFieldHeader("file").'</p></td>
  1264. <td><p>'.$this->getFieldHeader_sortLink("path").'</p></td>
  1265. </tr>';
  1266. }
  1267. /**
  1268. * [Put your description here]
  1269. */
  1270. function getFieldContent($fN) {
  1271. switch($fN) {
  1272. case "uid":
  1273. return $this->pi_list_linkSingle($this->internal["currentRow"][$fN],$this->internal["currentRow"]["uid"],1); // The "1" means that the display of single items is CACHED! Set to zero to disable caching.
  1274. break;
  1275. default:
  1276. return $this->internal["currentRow"][$fN];
  1277. break;
  1278. }
  1279. }
  1280. /**
  1281. * [Put your description here]
  1282. */
  1283. function getFieldHeader($fN) {
  1284. switch($fN) {
  1285. default:
  1286. return $this->pi_getLL("listFieldHeader_".$fN,"[".$fN."]");
  1287. break;
  1288. }
  1289. }
  1290. /**
  1291. * [Put your description here]
  1292. */
  1293. function getFieldHeader_sortLink($fN) {
  1294. return $this->pi_linkTP_keepPIvars($this->getFieldHeader($fN),array("sort"=>$fN.":".($this->internal["descFlag"]?0:1)));
  1295. }
  1296. }
  1297. if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/typoflash/pi1/class.tx_typoflash_pi1.php"]) {
  1298. include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/typoflash/pi1/class.tx_typoflash_pi1.php"]);
  1299. }
  1300. ?>