Feature #18071 » 20080221_opendocs_fixes.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()
|
||
* @deprecated since TYPO3 4.2, please use the setUpdateSignal function instead, as it allows you to add more parameters
|
||
*/
|
||
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 { // clear the module data
|
||
$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() {
|
||
$signals = array();
|
||
$modData = $GLOBALS['BE_USER']->getModuleData('t3lib_BEfunc::getUpdateSignal', 'ses');
|
||
if (!count($modData)) {
|
||
return '';
|
||
}
|
||
// Hook: Allows to let TYPO3 execute your JS code
|
||
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['updateSignalHook'])) {
|
||
$updateSignals = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['updateSignalHook'];
|
||
} 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();
|
||
$modData['set']='';
|
||
$BE_USER->pushModuleData($key,$modData);
|
||
$updateSignals = array();
|
||
}
|
||
// loop through all setUpdateSignals and get the JS code
|
||
foreach ($modData as $set => $val) {
|
||
if (isset($updateSignals[$set])) {
|
||
$params = array('set' => $set, 'parameter' => $val['parameter'], 'JScode' => '');
|
||
$ref = NULL;
|
||
t3lib_div::callUserFunction($updateSignals[$set], $params, $ref);
|
||
$signals[] = $params['JScode'];
|
||
} else if ($set == 'updatePageTree' || $set == 'updateFolderTree') {
|
||
$signals[] = '
|
||
if (top && top.content && top.content.nav_frame && top.content.nav_frame.Tree) {
|
||
top.content.nav_frame.Tree.refresh();
|
||
}';
|
||
}
|
||
}
|
||
return $out;
|
||
$content = implode(chr(10), $signals);
|
||
t3lib_BEfunc::setUpdateSignal(); // for backwards compatibility, should be replaced
|
||
return $content;
|
||
}
|
||
typo3/template.php (working copy) | ||
---|---|---|
$str = $this->sectionEnd().
|
||
$this->postCode.
|
||
$this->endPageJS().
|
||
t3lib_BEfunc::getSetUpdateSignal().
|
||
$this->wrapScriptTags(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');
|
||
t3lib_BEfunc::setUpdateSignal('updatePageTree');
|
||
}
|
||
... | ... | |
$this->editRegularContentFromId();
|
||
}
|
||
// Creating the editing form, wrap it with buttons, document selector etc.
|
||
$editForm = $this->makeEditForm();
|
||
// Checking if the currently open document is stored in the list of "open documents" - if not, then add it:
|
||
if ((strcmp($this->docDat[1], $this->storeUrlMd5) || !isset($this->docHandler[$this->storeUrlMd5])) && !$this->dontStoreDocumentRef) {
|
||
$this->docHandler[$this->storeUrlMd5] = array($this->storeTitle, $this->storeArray, $this->storeUrl);
|
||
$BE_USER->pushModuleData('alt_doc.php', array($this->docHandler, $this->storeUrlMd5));
|
||
t3lib_BEfunc::setUpdateSignal('tx_opendocs::updateNumber', count($this->docHandler));
|
||
}
|
||
if ($editForm) {
|
||
$this->firstEl = reset($this->elementsData);
|
||
... | ... | |
$buttons['open_in_new_window'] = $this->openInNewWindowLink();
|
||
return $buttons;
|
||
}
|
||
|
||
/**
|
||
* Returns the language switch/selector for editing,
|
||
* show only when a single record is edited
|
||
* - multiple records are too confusing
|
||
* @return string the HTML
|
||
*/
|
||
function langSelector() {
|
||
$langSelector = '';
|
||
|
||
// language switch/selector for editing, show only when a single record is edited
|
||
// - multiple records are too confusing
|
||
if (count($this->elementsData) == 1) {
|
||
$langSelector = $this->languageSwitch($this->firstEl['table'], $this->firstEl['uid'], $this->firstEl['pid']);
|
||
}
|
||
return $langSelector;
|
||
}
|
||
|
||
/**
|
||
* Compiles the extra form headers if the tceforms
|
||
*
|
||
* @return string the HTML
|
||
*/
|
||
function extraFormHeaders() {
|
||
$extraHeader = '';
|
||
$extraTemplate = '';
|
||
|
||
if (is_array($this->tceforms->extraFormHeaders)) {
|
||
$extraTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###DOCHEADER_EXTRAHEADER###');
|
||
... | ... | |
return $extraTemplate;
|
||
}
|
||
/**
|
||
* Put together the various elements (buttons, selectors, form) into a table
|
||
*
|
typo3/sysext/opendocs/class.tx_opendocs.php (working copy) | ||
---|---|---|
* @return boolean true if user has access, false if not
|
||
*/
|
||
public function checkAccess() {
|
||
// FIXME - needs proper access check
|
||
return true;
|
||
$conf = $GLOBALS['BE_USER']->getTSConfig('t3backend.toolbarItem.tx_opendocs.disabled');
|
||
return ($conf['value'] == 1 ? false : true);
|
||
}
|
||
/**
|
||
... | ... | |
public function render() {
|
||
$this->addJavascriptToBackend();
|
||
$this->addCssToBackend();
|
||
$docs = $this->getOpenDocuments();
|
||
// return the toolbar item and an empty UL
|
||
$output = '<a href="#" class="toolbar-item">';
|
||
$output .= '<span id="tx-opendocs-num">'.(count($docs) ? count($docs) : '').'</span>';
|
||
$output .= '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], t3lib_extMgm::extRelPath($this->EXTKEY).'opendocs.png', 'width="23" height="14"').' title="'.$GLOBALS['LANG']->getLL('toolbaritem',1).'" alt="" />';
|
||
$output .= '</a>';
|
||
$output .= '<ul class="toolbar-item-menu" style="display: none;"></ul>';
|
||
... | ... | |
}
|
||
/**
|
||
* returns the opened documents list for the AJAX call formatted as HTML list
|
||
* called as a hook in t3lib_BEfunc::setUpdateSignal,
|
||
*
|
||
* @return string list item HTML attibutes
|
||
*/
|
||
public function updateNumberOfOpenDocs(&$params, &$ref) {
|
||
$docs = $this->getOpenDocuments();
|
||
$num = (count($docs) ? count($docs) : '');
|
||
$params['JScode'] = '
|
||
if (top && top.TYPO3BackendOpenDocs) {
|
||
top.TYPO3BackendOpenDocs.updateNumberOfDocs('.$num.');
|
||
}
|
||
';
|
||
}
|
||
/**
|
||
* returns the opened documents list for the AJAX call formatted as HTML list
|
||
*
|
||
* @param array array full of additional params, not used yet
|
||
* @param TYPO3AJAX Ajax request object
|
||
* @return string list item HTML attibutes
|
||
*/
|
||
public function renderBackendMenuContents($params, &$ajaxObj) {
|
typo3/sysext/opendocs/ext_tables.php (working copy) | ||
---|---|---|
// register AJAX call
|
||
$GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX']['tx_opendocs::backendmenu'] = t3lib_extMgm::extPath('opendocs').'class.tx_opendocs.php:tx_opendocs->renderBackendMenuContents';
|
||
// register update signal to update the number of open documents
|
||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['updateSignalHook']['tx_opendocs::updateNumber'] = t3lib_extMgm::extPath('opendocs').'class.tx_opendocs.php:tx_opendocs->updateNumberOfOpenDocs';
|
||
// register menu module if option is wanted
|
||
$_EXTCONF = unserialize($_EXTCONF);
|
||
if ($_EXTCONF['enableModule']) {
|
||
... | ... | |
}
|
||
}
|
||
?>
|
||
?>
|
typo3/sysext/opendocs/opendocs.css (working copy) | ||
---|---|---|
#open-documents-menu {
|
||
width: 30px;
|
||
width: auto;
|
||
}
|
||
#open-documents-menu img {
|
||
... | ... | |
font-weight: bold;
|
||
padding: 2px 0 2px 3px;
|
||
}
|
||
span#tx-opendocs-num {
|
||
padding: 2px;
|
||
}
|
typo3/sysext/opendocs/opendocs.js (working copy) | ||
---|---|---|
/**
|
||
* toggles the visibility of the menu and places it under the toolbar icon
|
||
*/
|
||
toggleMenu: function() {
|
||
toggleMenu: function(event) {
|
||
Event.stop(event);
|
||
this.toolbarItem.blur();
|
||
if(!this.toolbarItem.hasClassName('toolbar-item-active')) {
|
||
this.showMenu();
|
||
... | ... | |
hideMenu: function() {
|
||
Effect.Fade(this.menu, {duration: 0.1});
|
||
this.toolbarItem.removeClassName('toolbar-item-active');
|
||
},
|
||
/**
|
||
* updates the number of open documents in the toolbar
|
||
*/
|
||
updateNumberOfDocs: function(num) {
|
||
$('tx-opendocs-num').innerHTML = num;
|
||
}
|
||
});
|
||