Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / content / class.tslib_content_phpscript.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Xavier Perseguers <typo3@perseguers.ch>
6 * (c) 2010-2011 Steffen Kamper <steffen@typo3.org>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 * A copy is found in the textfile GPL.txt and important notices to the license
18 * from the author is found in LICENSE.txt distributed with these scripts.
19 *
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28
29 /**
30 * Contains PHP_SCRIPT class object.
31 *
32 * $Id: class.tslib_content.php 7905 2010-06-13 14:42:33Z ohader $
33 * @author Xavier Perseguers <typo3@perseguers.ch>
34 * @author Steffen Kamper <steffen@typo3.org>
35 */
36 class tslib_content_PhpScript extends tslib_content_Abstract {
37
38 /**
39 * Rendering the cObject, PHP_SCRIPT
40 *
41 * @param array Array of TypoScript properties
42 * @return string Output
43 */
44 public function render($conf = array()) {
45
46 $file = isset($conf['file.'])
47 ? $this->cObj->stdWrap($conf['file'], $conf['file.'])
48 : $conf['file'];
49
50 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($file);
51 $content = '';
52 if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile)) {
53 // Added 31-12-00: Make backup...
54 $this->cObj->oldData = $this->cObj->data;
55 $RESTORE_OLD_DATA = FALSE;
56 // Include file..
57 include ('./' . $incFile);
58 // Added 31-12-00: restore...
59 if ($RESTORE_OLD_DATA) {
60 $this->cObj->data = $this->cObj->oldData;
61 }
62 }
63
64 if (isset($conf['stdWrap.'])) {
65 $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
66 }
67
68 return $content;
69 }
70
71 /**
72 * Allow access to other tslib_content methods.
73 *
74 * Provides backwards compatibility for older included PHP_SCRIPT which simply
75 * call methods like $this->typoLink (e.g. the old "languageMenu.php" sample).
76 *
77 * @deprecated since 4.5, will be removed in 4.7. Use $this->cObj-><method>() instead
78 *
79 * @param string $method The called method
80 * @param array $arguments The original arguments
81 * @return mixed
82 */
83 public function __call($method, $arguments) {
84 if (method_exists($this->cObj, $method)) {
85 $trail = debug_backtrace();
86 $location = $trail[1]['file'] . '#' . $trail[1]['line'];
87 t3lib_div::deprecationLog(
88 sprintf('%s: PHP_SCRIPT called $this->%s. Modify it to call $this->cObj->%s instead. Will be removed in 4.7.',
89 $location, $method, $method
90 )
91 );
92 return call_user_func_array(array($this->cObj, $method), $arguments);
93 } else {
94 trigger_error(sprintf('Call to undefined function: %s::%s().', get_class($this), $name), E_USER_ERROR);
95 }
96 }
97
98 /**
99 * Allow access to other tslib_content variables.
100 *
101 * Provides backwards compatibility for PHP_SCRIPT which simply
102 * accesses properties like $this->parameters.
103 *
104 * @deprecated since 4.5, will be removed in 4.7. Use $this->cObj-><property> instead.
105 *
106 * @param string $name The name of the property
107 * @return mixed
108 */
109 public function __get($name) {
110 if (array_key_exists($name, get_object_vars($this->cObj))) {
111 $trail = debug_backtrace();
112 $location = $trail[1]['file'] . '#' . $trail[1]['line'];
113 t3lib_div::deprecationLog(
114 sprintf('%s: PHP_SCRIPT accessed $this->%s. Modify it to access $this->cObj->%s instead. Will be removed in 4.7.',
115 $location, $name, $name
116 )
117 );
118 return $this->cObj->$name;
119 }
120 }
121
122 }
123
124
125 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_phpscript.php'])) {
126 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['tslib/content/class.tslib_content_phpscript.php']);
127 }
128
129 ?>