Index: typo3/sysext/tsbrowser/class.tx_tsbrowser.php =================================================================== --- typo3/sysext/tsbrowser/class.tx_tsbrowser.php (revision 0) +++ typo3/sysext/tsbrowser/class.tx_tsbrowser.php (revision 0) @@ -0,0 +1,202 @@ + +* All rights reserved +* +* This script is part of the TYPO3 project. The TYPO3 project is +* free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* The GNU General Public License can be found at +* http://www.gnu.org/copyleft/gpl.html. +* +* This script is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* This copyright notice MUST APPEAR in all copies of the script! +***************************************************************/ +/** + * [CLASS/FUNCTION INDEX of SCRIPT] + * + * Hint: use extdeveval to insert/update function index above. + */ + +require_once(PATH_t3lib . 'class.t3lib_page.php'); +require_once(PATH_t3lib.'class.t3lib_tsparser.php'); +$GLOBALS['LANG']->includeLLFile('EXT:tsbrowser/locallang.xml'); + +class tx_tsbrowser { + +protected $pid; + + public function renderTSbrowser($parameters, $pObj) { + + if (!$parameters['e']['config']) { + return false; + } + + // add header files + $pObj->pObj->doc->addStyleSheet('tsbrowser', $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('tsbrowser') . 'tsbrowser.css'); + $pObj->pObj->doc->loadJavascriptLib(t3lib_extMgm::extRelPath('tsbrowser') . 'tsbrowser.js'); + + $this->pid = t3lib_div::_GET('id'); + $setting = t3lib_div::_GET('show_tsbrowser'); + + + if ($setting && $setting != intval($GLOBALS['BE_USER']->uc['tx_tsbrowser']['show'])) { + $GLOBALS['BE_USER']->uc['tx_tsbrowser']['show'] = $setting; + $GLOBALS['BE_USER']->writeUC(); + } + + $strInsert = ' +
+
+ uc['tx_tsbrowser']['show'] == 1 ? ' checked="checked"' : '') . '/> +
+ '; + + if ($GLOBALS['BE_USER']->uc['tx_tsbrowser']['show'] == 1) { + + // Get TypoScript template for current page + $conf = $this->getConfigArray(); + // Show TS template hierarchy + $tree = $this->showTemplate($conf); + + $strInsert .= ' + + +
' . $tree . '
+
+ '; + } else { + $strInsert .= ' +
+ '; + } + + + // insert tree in output string + $parameters['theOutput'] = preg_replace( + '/\/mi', + '' . $strInsert, + $parameters['theOutput'] + ); + } + + /** + * Get TS template + * + * This function creates instances of the class needed to render + * the TS template, and gets it as a multi-dimensionnal array. + * + * @return An array containing all the available TS objects + */ + protected function getConfigArray() { + + // Initialize the page selector + $this->sys_page = t3lib_div::makeInstance('t3lib_pageSelect'); + $this->sys_page->init(true); + + // initialize the TS template + $this->tmpl = t3lib_div::makeInstance('t3lib_TStemplate'); + $this->tmpl->init(); + + // Avoid an error + $this->tmpl->tt_track = 0; + + // Get rootline for current PID + $rootline = $this->sys_page->getRootLine($this->pid); + + // Start TS template + $this->tmpl->start($rootline); + + return $this->tmpl->setup; + } + + /** + * Show TS template hierarchy + * + * This function displays the TS template hierarchy as HTML list + * elements. Each section can be expanded/collapsed. + * + * @param $object A section of the TS template + * @param $object The path to the current object + * @return + */ + protected function showTemplate($conf, $pObj = false) { + + // Storage + $htmlCode = array(); + // pre-select a tag is possible with GPvar, not used at the moment + $curr = t3lib_div::GPvar('current'); + // Process each object of the configuration array + foreach($conf as $key => $value) { + $str = ''; + + // TS object ID + $id = $pObj . $key; + $sel = (strpos($curr, $id) === 0); + $mtc = ($curr == $id); + + $subKey = ''; + if (substr($key, -1) == '.') { + $subKey = substr($key, 0, -1); + } + + + // Check if object is a container + if (is_array($value)) { + // Check if object has a content type + if (substr($key, 0, - 1) != $lastKey) { + // No content type - Process sub configuration + $subArray = $this->showTemplate($value, $id); + // Check if objects are available + if ($subArray) { + // Add container + // remuve trailing point + if ($subKey) { + $key = $subKey; + if(!is_array($conf[$subKey])) { + $v = htmlspecialchars($conf[$subKey]); + $str = $conf[$subKey] ? ' [' . t3lib_div::fixed_lgd_cs($v,40) . ']' : ''; + } + } + $htmlCode[] = '
  • ' . $key . '' . $str . $subArray . '
  • '; + } + } + } else { + if (substr($key, -1) != '.' && is_array($conf[$key . '.'])) { + $subArray = $this->showTemplate($conf[$key . '.'], $id); + } else { + // Memorize key + $lastKey = $key; + // TS object + $v = htmlspecialchars($value); + $htmlCode[] = '
  • ' . htmlspecialchars($key) . ' [' . t3lib_div::fixed_lgd_cs($v,40) . ']
  • '; + } + } + } + + // Check if objects have been detected + if (count($htmlCode)) { + // insert css-class last to last li + array_push($htmlCode, preg_replace('/^
  • ' . + implode(chr(10), $htmlCode) . + ''; + } + } + + + +} +?> Index: typo3/sysext/tsbrowser/ext_emconf.php =================================================================== --- typo3/sysext/tsbrowser/ext_emconf.php (revision 0) +++ typo3/sysext/tsbrowser/ext_emconf.php (revision 0) @@ -0,0 +1,47 @@ + 'Typoscript Browser', + 'description' => 'shows Typoscript Browser in tstemplate_info-module', + 'category' => 'module', + 'author' => 'Steffen Kamper', + 'author_email' => 'info@sk-typo3.de', + 'shy' => '', + 'dependencies' => 'tstemplate_info', + 'conflicts' => '', + 'priority' => '', + 'module' => '', + 'state' => 'stable', + 'internal' => '', + 'uploadfolder' => 0, + 'createDirs' => '', + 'modify_tables' => '', + 'clearCacheOnLoad' => 0, + 'lockType' => '', + 'author_company' => '', + 'version' => '0.0.1', + 'constraints' => array( + 'depends' => array( + 'tstemplate_info' => '', + ), + 'conflicts' => array( + ), + 'suggests' => array( + ), + ), + '_md5_values_when_last_written' => 'a:6:{s:22:"class.tx_tsbrowser.php";s:4:"b4d8";s:12:"ext_icon.gif";s:4:"16ad";s:14:"ext_tables.php";s:4:"b5a8";s:13:"locallang.xml";s:4:"cb84";s:13:"tsbrowser.css";s:4:"6c6a";s:12:"tsbrowser.js";s:4:"36be";}', + 'suggests' => array( + ), +); + +?> \ No newline at end of file Index: typo3/sysext/tsbrowser/ext_icon.gif =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: typo3\sysext\tsbrowser\ext_icon.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: typo3/sysext/tsbrowser/ext_tables.php =================================================================== --- typo3/sysext/tsbrowser/ext_tables.php (revision 0) +++ typo3/sysext/tsbrowser/ext_tables.php (revision 0) @@ -0,0 +1,5 @@ +renderTSbrowser'; +} +?> Index: typo3/sysext/tsbrowser/locallang.xml =================================================================== --- typo3/sysext/tsbrowser/locallang.xml (revision 0) +++ typo3/sysext/tsbrowser/locallang.xml (revision 0) @@ -0,0 +1,14 @@ + + + + Labels for the Typoscript Browser + module + + + + + + + + + \ No newline at end of file Index: typo3/sysext/tsbrowser/tsbrowser.css =================================================================== --- typo3/sysext/tsbrowser/tsbrowser.css (revision 0) +++ typo3/sysext/tsbrowser/tsbrowser.css (revision 0) @@ -0,0 +1,83 @@ +/* CSS-class for the TS-tree */ +#ts-browser { + margin: 15px 0; +} +#ts-tree ul, #ts-tree li { + padding: 0; + margin: 0; + + list-style: none; + line-height: 16px; +} + +#ts-tree li { + padding-left: 20px; +} + +ul.tree { + padding-left: 2px; +} + +ul.tree li { + background: 0 0 url(../../gfx/ol/join.gif) no-repeat transparent; +} + +ul.tree li > span { + cursor: pointer; +} + +ul.tree li > strong { + cursor: pointer; +} + +ul.tree li.last { + background: 0 0 url(../../gfx/ol/joinbottom.gif) no-repeat transparent; +} + +ul.tree li.act > strong { + font-style: italic; +} + +ul.tree li.act > span { + font-style: italic; +} + +ul.tree li.pm > strong { + margin-left: -20px; + padding-left: 20px; +} + +ul.tree li.pm > ul { + margin-left: -20px !important; + padding-left: 20px !important; + background: 0 0 url(../../gfx/ol/line.gif) repeat-y transparent; +} + +ul.tree li.last.pm > ul { + background: none; +} + +ul.tree li.minus { + background: 0 0 url(../../gfx/ol/minus.gif) no-repeat transparent; +} + +ul.tree li.plus { + background: 0 0 url(../../gfx/ol/plus.gif) no-repeat transparent; +} + +ul.tree li.minus.last { + background: 0 0 url(../../gfx/ol/minusbottom.gif) no-repeat transparent; +} + +ul.tree li.plus.last { + background: 0 0 url(../../gfx/ol/plusbottom.gif) no-repeat transparent; +} + +ul.tree li.minus > ul { + display: block; +} + +ul.tree li.plus > ul { + display: none; +} + Index: typo3/sysext/tsbrowser/tsbrowser.js =================================================================== --- typo3/sysext/tsbrowser/tsbrowser.js (revision 0) +++ typo3/sysext/tsbrowser/tsbrowser.js (revision 0) @@ -0,0 +1,54 @@ +var TSbrowser = Class.create({ + initialize: function() { + Event.observe(window, 'load', function(){ + $$('#ts-tree ul li').invoke('observe', 'click', this.clickedNode.bind(this)); + }.bindAsEventListener(this)); + }, + + /** + * display node content in text field and toggle state for plus/minus + */ + clickedNode: function(event) { + var clickedElement = Event.element(event); + var old = $('selected'); + var tagName; + + if (old) old.id = ''; + + if (clickedElement.tagName == 'EM' || clickedElement.tagName == 'SPAN') { + $('node-value').value = this.readValue(clickedElement); + } + if (clickedElement.tagName == 'STRONG') { + clickedElement.up('li').id = 'selected'; + this.toggleState(clickedElement.up('li')); + } + + Event.stop(event); + + }, + + readValue: function(el) { + var str = ''; + + if (el.tagName == 'SPAN') { + el = el.next(); + } + str = '=' + el.readAttribute('title'); + + while (el = el.up('li')) { + str = el.readAttribute('name') + (str.startsWith('=') ? '' : '.') + str; + if (el.hasClassName('pm')) { + break; + } + } + return str; + }, + + toggleState: function(el) { + if (el.hasClassName('pm')) { + el.toggleClassName('plus').toggleClassName('minus'); + } + } +}); + +var TYPO3BackendTSbrowser = new TSbrowser(); \ No newline at end of file