From c45826dd59027f19e074ec268ade18f482aea4c4 Mon Sep 17 00:00:00 2001 From: Oliver Hader Date: Fri, 11 Jan 2008 13:08:29 +0000 Subject: [PATCH] Added feature #7124: Add some more functionality to new AJAX interface in the TYPO3 back-end git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2881 709f56b5-9817-0410-a4d7-c38de5d9e867 --- ChangeLog | 4 ++++ t3lib/config_default.php | 4 ++-- typo3/alt_db_navframe.php | 5 +++-- typo3/alt_file_navframe.php | 7 ++++--- typo3/classes/class.typo3ajax.php | 26 ++++++++++++++++++++++---- typo3/tree.js | 2 +- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index d07aaab364c7..9460436f6ae7 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-01-11 Oliver Hader + + * (feature) Added feature #7124: Add some more functionality to new AJAX interface in the TYPO3 back-end + 2008-01-10 Benjamin Mack * (feature) Added #7096: Consistent interface for AJAX calls in the TYPO3 Backend diff --git a/t3lib/config_default.php b/t3lib/config_default.php index f770c43ff4d9..7e5aaeee17e9 100755 --- a/t3lib/config_default.php +++ b/t3lib/config_default.php @@ -172,8 +172,8 @@ $TYPO3_CONF_VARS = Array( 'compactFlexFormXML' => 0, // If set, the flexform XML will not contain indentation spaces making XML more compact 'elementVersioningOnly' => FALSE, // If true, only element versioning is allowed in the backend. This is recommended for new installations of TYPO3 4.2+ since "page" and "branch" versioning types are known for the drawbacks of loosing ids and "element" type versions supports moving now. 'AJAX' => array( // array of key-value pairs for a unified use of AJAX calls in the TYPO3 backend. Keys are the unique ajaxIDs where the value will be resolved to call a method in an object. See ajax.php and the classes/class.typo3ajax.php for more information. - 'pagetree_ExpandCollapse' => 'typo3/alt_db_navframe.php:SC_alt_db_navframe->ajaxExpandCollapse', - 'foldertree_ExpandCollapse' => 'typo3/alt_file_navframe.php:SC_alt_file_navframe->ajaxExpandCollapse', + 'SC_alt_db_navframe::expandCollapse' => 'typo3/alt_db_navframe.php:SC_alt_db_navframe->ajaxExpandCollapse', + 'SC_alt_file_navframe::expandCollapse' => 'typo3/alt_file_navframe.php:SC_alt_file_navframe->ajaxExpandCollapse', ), ), 'FE' => Array( // Configuration for the TypoScript frontend (FE). Nothing here relates to the administration backend! diff --git a/typo3/alt_db_navframe.php b/typo3/alt_db_navframe.php index ca4b49ac135d..86a493b8f01d 100755 --- a/typo3/alt_db_navframe.php +++ b/typo3/alt_db_navframe.php @@ -332,8 +332,9 @@ class SC_alt_db_navframe { * Makes the AJAX call to expand or collapse the pagetree. * Called by typo3/ajax.php * - * @param array additional parameters (not used here) - * @param object the TYPO3AJAX object of this request + * @param array $params: additional parameters (not used here) + * @param TYPO3AJAX &$ajaxObj: reference of the TYPO3AJAX object of this request + * @return void */ public function ajaxExpandCollapse($params, &$ajaxObj) { global $LANG; diff --git a/typo3/alt_file_navframe.php b/typo3/alt_file_navframe.php index aa199e815359..b7ba7128aa8f 100755 --- a/typo3/alt_file_navframe.php +++ b/typo3/alt_file_navframe.php @@ -135,7 +135,7 @@ class SC_alt_file_navframe { ($this->currentSubScript?'top.currentSubScript=unescape("'.rawurlencode($this->currentSubScript).'");':'').' // setting prefs for foldertree - Tree.ajaxID = "foldertree_ExpandCollapse"; + Tree.ajaxID = "SC_alt_file_navframe::expandCollapse"; // Function, loading the list frame from navigation tree: function jumpTo(id, linkObj, highlightID, bank) { @@ -214,8 +214,9 @@ class SC_alt_file_navframe { * Makes the AJAX call to expand or collapse the foldertree. * Called by typo3/ajax.php * - * @param array additional parameters (not used here) - * @param object the TYPO3AJAX object of this request + * @param array $params: additional parameters (not used here) + * @param TYPO3AJAX &$ajaxObj: reference of the TYPO3AJAX object of this request + * @return void */ public function ajaxExpandCollapse($params, &$ajaxObj) { global $LANG; diff --git a/typo3/classes/class.typo3ajax.php b/typo3/classes/class.typo3ajax.php index 1c7f00d4f80e..a6ff751755d2 100644 --- a/typo3/classes/class.typo3ajax.php +++ b/typo3/classes/class.typo3ajax.php @@ -67,20 +67,38 @@ class TYPO3AJAX { } + /** + * overwrites the existing content with the first parameter + * + * @param array the new content + * @return mixed the old content as array; if the new content was not an array, false is returned + */ + public function setContent($content) { + $oldcontent = false; + if (is_array($content)) { + $oldcontent = $this->content; + $this->content = $content; + } + return $oldcontent; + } + + /** * adds new content * * @param string the new content key where the content should be added in the content array * @param string the new content to add - * @return string the old content + * @return mixed the old content; if the old content didn't exist before, false is returned */ public function addContent($key, $content) { - $oldcontent = ''; + $oldcontent = false; if (array_key_exists($key, $this->content)) { $oldcontent = $this->content[$key]; } - if (!$content) { + if (!isset($content) || !strlen($content)) { unset($this->content[$key]); + } elseif (!isset($key) || !strlen($key)) { + $this->content[] = $content; } else { $this->content[$key] = $content; } @@ -105,7 +123,7 @@ class TYPO3AJAX { * @return void */ public function setContentFormat($format) { - if (t3lib_div::inArray(array('plain', 'xml', 'json'), $format)) { + if (t3lib_div::inArray(array('plain', 'xml', 'json', 'jsonhead', 'jsonbody'), $format)) { $this->contentFormat = $format; } } diff --git a/typo3/tree.js b/typo3/tree.js index 0e0370e25397..814229e04c1a 100755 --- a/typo3/tree.js +++ b/typo3/tree.js @@ -75,7 +75,7 @@ function filterTraverse (eUL,strToDim) { var Tree = { thisScript: 'ajax.php', - ajaxID: 'pagetree_ExpandCollapse', // has to be either "pagetree_ExpandCollapse" or "foldertree_ExpandCollapse" + ajaxID: 'SC_alt_db_navframe::expandCollapse', // has to be either "SC_alt_db_navframe::expandCollapse" or "SC_alt_file_navframe::expandCollapse" frameSetModule: null, activateDragDrop: true, highlightClass: 'active', -- 2.20.1