Feature #16919 ยป 20080203_ajax_updatesignal.patch
t3lib/class.t3lib_befunc.php (working copy) | ||
---|---|---|
* Call to update the page tree frame (or something else..?) after
|
||
* t3lib_BEfunc::getSetUpdateSignal('updatePageTree') -> will set the page tree to be updated.
|
||
* t3lib_BEfunc::getSetUpdateSignal() -> will return some JavaScript that does the update (called in the typo3/template.php file, end() function)
|
||
* please use the setUpdateSignal function instead now, as it allows you to add more parameters
|
||
* Usage: 11
|
||
*
|
||
* @param string Whether to set or clear the update signal. When setting, this value contains strings telling WHAT to set. At this point it seems that the value "updatePageTree" is the only one it makes sense to set.
|
||
* @return string HTML code (<script> section)
|
||
* @see t3lib_BEfunc::getUpdateSignalCode()
|
||
* @see t3lib_BEfunc::setUpdateSignal()
|
||
*/
|
||
function getSetUpdateSignal($set='') {
|
||
function getSetUpdateSignal($set = '') {
|
||
// kept for backwards compatibility if $set is empty, use "getUpdateSignalCode()" instead
|
||
if ($set) {
|
||
return t3lib_BEfunc::setUpdateSignal($set);
|
||
} else {
|
||
return t3lib_BEfunc::getUpdateSignalCode();
|
||
}
|
||
}
|
||
/**
|
||
* Call to update the page tree frame (or something else..?) after
|
||
* use 'updatePageTree' as a first parameter will set the page tree to be updated.
|
||
* Usage: 10
|
||
*
|
||
* @param string Key to set the update signal. When setting, this value contains strings telling WHAT to set. At this point it seems that the value "updatePageTree" is the only one it makes sense to set. If empty, all update signals will be removed.
|
||
* @param mixed Additional information for the update signal, used to only refresh a branch of the tree
|
||
* @return void
|
||
* @see t3lib_BEfunc::getUpdateSignalCode()
|
||
*/
|
||
public function setUpdateSignal($set = '', $params = '') {
|
||
global $BE_USER;
|
||
$key = 't3lib_BEfunc::getSetUpdateSignal';
|
||
$out='';
|
||
if ($set) {
|
||
$modData=array();
|
||
$modData['set']=$set;
|
||
$BE_USER->pushModuleData($key,$modData);
|
||
$modData = $BE_USER->getModuleData('t3lib_BEfunc::getUpdateSignal', 'ses');
|
||
if ($set) {
|
||
$modData[$set] = array(
|
||
'set' => $set,
|
||
'parameter' => $params);
|
||
} else {
|
||
$modData = $BE_USER->getModuleData($key,'ses');
|
||
if (trim($modData['set'])) {
|
||
$l=explode(',',$modData['set']);
|
||
while(list(,$v)=each($l)) {
|
||
switch($v) {
|
||
case 'updatePageTree':
|
||
case 'updateFolderTree':
|
||
$out.='
|
||
<script type="text/javascript">
|
||
/*<![CDATA[*/
|
||
if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
|
||
top.content.nav_frame.refresh_nav();
|
||
}
|
||
/*]]>*/
|
||
</script>';
|
||
break;
|
||
$modData = array();
|
||
}
|
||
$BE_USER->pushModuleData('t3lib_BEfunc::getUpdateSignal', $modData);
|
||
}
|
||
/**
|
||
* Call to update the page tree frame (or something else..?) if this is set by the function
|
||
* setUpdateSignal(). It will return some JavaScript that does the update (called in the typo3/template.php file, end() function)
|
||
* Usage: 1
|
||
*
|
||
* @return string HTML javascript code
|
||
* @see t3lib_BEfunc::setUpdateSignal()
|
||
*/
|
||
public function getUpdateSignalCode() {
|
||
$out = '';
|
||
$modData = $GLOBALS['BE_USER']->getModuleData('t3lib_BEfunc::getUpdateSignal', 'ses');
|
||
if (!count($modData)) {
|
||
return $out;
|
||
}
|
||
foreach($modData as $set => $val) {
|
||
switch ($set) {
|
||
case 'updatePageTree':
|
||
case 'updateFolderTree':
|
||
if (isset($val['parameter'])) {
|
||
$funcName = 'top.content.nav_frame.Tree.refreshBranch('.htmlspecialchars($val['parameter']).');';
|
||
} else {
|
||
$funcName = 'top.content.nav_frame.Tree.refresh();';
|
||
}
|
||
}
|
||
$modData=array();
|
||
$modData['set']='';
|
||
$BE_USER->pushModuleData($key,$modData);
|
||
$out .= '
|
||
<script type="text/javascript">
|
||
/*<![CDATA[*/
|
||
if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
|
||
'.$funcName.'
|
||
}
|
||
/*]]>*/
|
||
</script>';
|
||
break;
|
||
}
|
||
}
|
||
t3lib_BEfunc::setUpdateSignal();
|
||
return $out;
|
||
}
|
||
typo3/tree.js (working copy) | ||
---|---|---|
var Tree = {
|
||
thisScript: 'ajax.php',
|
||
thisScript: top.TS.PATH_typo3 + 'alt_db_navframe.php',
|
||
ajaxScript: top.TS.PATH_typo3 + 'ajax.php',
|
||
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,
|
||
... | ... | |
load: function(params, isExpand, obj) {
|
||
// fallback if AJAX is not possible (e.g. IE < 6)
|
||
if (typeof Ajax.getTransport() != 'object') {
|
||
window.location.href = this.thisScript + '?ajaxID=' + this.ajaxID + '&PM=' + params;
|
||
window.location.href = this.thisScript + '?PM=' + params;
|
||
return;
|
||
}
|
||
... | ... | |
obj.style.cursor = 'wait';
|
||
}
|
||
new Ajax.Request(this.thisScript, {
|
||
new Ajax.Request(this.ajaxScript, {
|
||
method: 'get',
|
||
parameters: 'ajaxID=' + this.ajaxID + '&PM=' + params,
|
||
onComplete: function(xhr) {
|
||
... | ... | |
});
|
||
},
|
||
// does the complete page refresh (previously known as "_refresh_nav()")
|
||
// does the complete page refresh (previously known as "_refresh_nav()")
|
||
refresh: function() {
|
||
var r = new Date();
|
||
// randNum is useful so pagetree does not get cached in browser cache when refreshing
|
||
window.location.href = '?randNum=' + r.getTime();
|
||
window.location.href = this.thisScript + '?randNum=' + r.getTime();
|
||
},
|
||
// refreshes only a part of the tree (right now only works with pages)
|
||
// gets a comma-separated list of page IDs (branches) to update
|
||
refreshBranch: function(branch) {
|
||
if (!branch) {
|
||
this.refresh();
|
||
return;
|
||
}
|
||
branch = String(branch);
|
||
var branches = ((!branch.include(',')) ? $A(branch) : branch.split(','));
|
||
branches.each(function(branch) {
|
||
var itm = $('pages'+branch+'_0');
|
||
if (!itm) {
|
||
this.refresh();
|
||
return;
|
||
}
|
||
if (itm.hasClassName('expanded')) {
|
||
this.load('0_1_'+branch+'_browsePages', 1, itm.firstChild);
|
||
} else {
|
||
this.load('0_0_'+branch+'_browsePages', 1, itm.firstChild);
|
||
}
|
||
}.bind(this));
|
||
},
|
||
// attaches the events to the elements needed for the drag and drop (for the titles and the icons)
|
||
registerDragDropHandlers: function() {
|
||
if (!this.activateDragDrop) return;
|
||
... | ... | |
// Set the new item
|
||
top.fsMod.navFrameHighlightedID[frameSetModule] = highlightID;
|
||
if ($(highlightID)) Element.addClassName(highlightID, this.highlightClass);
|
||
if ($(highlightID)) {
|
||
Element.addClassName(highlightID, this.highlightClass);
|
||
}
|
||
}
|
||
};
|
||
typo3/template.php (working copy) | ||
---|---|---|
$str = $this->sectionEnd().
|
||
$this->postCode.
|
||
$this->endPageJS().
|
||
t3lib_BEfunc::getSetUpdateSignal().
|
||
t3lib_BEfunc::getUpdateSignalCode().
|
||
$this->parseTime().
|
||
($this->form?'
|
||
</form>':'');
|
typo3/alt_doc.php (working copy) | ||
---|---|---|
// If pages are being edited, we set an instruction about updating the page tree after this operation.
|
||
if (isset($this->data['pages'])) {
|
||
t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
|
||
$pageRecords = array_keys($this->data['pages']);
|
||
if (count($pageRecords)) {
|
||
$pageRecords = implode(',', $pageRecords);
|
||
}
|
||
t3lib_BEfunc::setUpdateSignal('updatePageTree', $pageRecords);
|
||
}
|
||
typo3/alt_file_navframe.php (working copy) | ||
---|---|---|
// setting prefs for foldertree
|
||
Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
|
||
Tree.thisScript = top.TS.PATH_typo3 + "alt_file_navframe.php";
|
||
// Function, loading the list frame from navigation tree:
|
||
function jumpTo(id, linkObj, highlightID, bank) {
|