PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/typo3/browse_links.php

https://bitbucket.org/linxpinx/mercurial
PHP | 253 lines | 105 code | 42 blank | 106 comment | 14 complexity | ffdbead645f8a60c29087154aa0c32e0 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-2010 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. * Displays the page/file tree for browsing database records or files.
  29. * Used from TCEFORMS an other elements
  30. * In other words: This is the ELEMENT BROWSER!
  31. *
  32. * $Id: browse_links.php 7905 2010-06-13 14:42:33Z ohader $
  33. * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
  34. * XHTML compliant
  35. *
  36. * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
  37. */
  38. /**
  39. * [CLASS/FUNCTION INDEX of SCRIPT]
  40. *
  41. *
  42. *
  43. * 78: class SC_browse_links
  44. * 99: function init ()
  45. * 120: function main()
  46. * 174: function printContent()
  47. *
  48. * TOTAL FUNCTIONS: 3
  49. * (This index is automatically created/updated by the extension "extdeveval")
  50. *
  51. */
  52. $BACK_PATH='';
  53. require ('init.php');
  54. require ('template.php');
  55. $LANG->includeLLFile('EXT:lang/locallang_browse_links.xml');
  56. require_once (PATH_typo3.'/class.browse_links.php');
  57. /**
  58. * Script class for the Element Browser window.
  59. *
  60. * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
  61. * @package TYPO3
  62. * @subpackage core
  63. */
  64. class SC_browse_links {
  65. /**
  66. * The mode determines the main kind of output from the element browser.
  67. * There are these options for values: rte, db, file, filedrag, wizard.
  68. * "rte" will show the link selector for the Rich Text Editor (see main_rte())
  69. * "db" will allow you to browse for pages or records in the page tree (for TCEforms, see main_db())
  70. * "file"/"filedrag" will allow you to browse for files or folders in the folder mounts (for TCEforms, main_file())
  71. * "wizard" will allow you to browse for links (like "rte") which are passed back to TCEforms (see main_rte(1))
  72. *
  73. * @see main()
  74. */
  75. var $mode;
  76. /**
  77. * holds Instance of main browse_links class
  78. * needed fo intercommunication between various classes that need access to variables via $GLOBALS['SOBE']
  79. * Not the most nice solution but introduced since we don't have another general way to return class-instances or registry for now
  80. *
  81. * @var browse_links
  82. */
  83. var $browser;
  84. /**
  85. * document template object
  86. *
  87. * @var template
  88. */
  89. var $doc;
  90. /**
  91. * not really needed but for backwards compatibility ...
  92. *
  93. * @return void
  94. */
  95. function init () {
  96. // Find "mode"
  97. $this->mode = t3lib_div::_GP('mode');
  98. if (!$this->mode) {
  99. $this->mode = 'rte';
  100. }
  101. // Creating backend template object:
  102. // this might not be needed but some classes refer to $GLOBALS['SOBE']->doc, so ...
  103. $this->doc = t3lib_div::makeInstance('template');
  104. $this->doc->backPath = $GLOBALS['BACK_PATH'];
  105. }
  106. /**
  107. * Main function, detecting the current mode of the element browser and branching out to internal methods.
  108. *
  109. * @return void
  110. */
  111. function main() {
  112. // Clear temporary DB mounts
  113. $tmpMount = t3lib_div::_GET('setTempDBmount');
  114. if (isset($tmpMount)) {
  115. $GLOBALS['BE_USER']->setAndSaveSessionData('pageTree_temporaryMountPoint', intval($tmpMount));
  116. }
  117. // Set temporary DB mounts
  118. $tempDBmount = intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint'));
  119. if ($tempDBmount) {
  120. $altMountPoints = $tempDBmount;
  121. }
  122. if ($altMountPoints) {
  123. $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints)));
  124. $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
  125. }
  126. $this->content = '';
  127. // look for alternativ mountpoints
  128. switch((string)$this->mode) {
  129. case 'rte':
  130. case 'db':
  131. case 'wizard':
  132. // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
  133. $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
  134. if ($altMountPoints) {
  135. $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints)));
  136. $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
  137. }
  138. case 'file':
  139. case 'filedrag':
  140. case 'folder':
  141. // Setting additional read-only browsing file mounts
  142. $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
  143. if ($altMountPoints) {
  144. $altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
  145. foreach($altMountPoints as $filePathRelativeToFileadmindir) {
  146. $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 'readonly');
  147. }
  148. $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
  149. }
  150. break;
  151. }
  152. // render type by user func
  153. $browserRendered = false;
  154. if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
  155. foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
  156. $browserRenderObj = t3lib_div::getUserObj($classRef);
  157. if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
  158. if ($browserRenderObj->isValid($this->mode, $this)) {
  159. $this->content.= $browserRenderObj->render($this->mode, $this);
  160. $browserRendered = true;
  161. break;
  162. }
  163. }
  164. }
  165. }
  166. // if type was not rendered use default rendering functions
  167. if(!$browserRendered) {
  168. $this->browser = t3lib_div::makeInstance('browse_links');
  169. $this->browser->init();
  170. $modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php', 'ses');
  171. list($modData, $store) = $this->browser->processSessionData($modData);
  172. $GLOBALS['BE_USER']->pushModuleData('browse_links.php', $modData);
  173. // Output the correct content according to $this->mode
  174. switch((string)$this->mode) {
  175. case 'rte':
  176. $this->content = $this->browser->main_rte();
  177. break;
  178. case 'db':
  179. $this->content = $this->browser->main_db();
  180. break;
  181. case 'file':
  182. case 'filedrag':
  183. $this->content = $this->browser->main_file();
  184. break;
  185. case 'folder':
  186. $this->content = $this->browser->main_folder();
  187. break;
  188. case 'wizard':
  189. $this->content = $this->browser->main_rte(1);
  190. break;
  191. }
  192. }
  193. }
  194. /**
  195. * Print module content
  196. *
  197. * @return void
  198. */
  199. function printContent() {
  200. echo $this->content;
  201. }
  202. }
  203. if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']) {
  204. include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/browse_links.php']);
  205. }
  206. // Make instance:
  207. $SOBE = t3lib_div::makeInstance('SC_browse_links');
  208. $SOBE->init();
  209. $SOBE->main();
  210. $SOBE->printContent();
  211. ?>