Project

General

Profile

Feature #15033 ยป 2005-10-23_bugfix_1577_4.patch

Administrator Admin, 2005-10-25 16:17

View differences:

TYPO3core/typo3/alt_clickmenu.php 2005-10-23 22:11:27.000000000 +0200
require ('init.php');
require ('template.php');
require_once (PATH_t3lib.'class.t3lib_clipboard.php');
require_once(PATH_t3lib.'class.t3lib_ajax.php');
$LANG->includeLLFile('EXT:lang/locallang_misc.xml');
......
var $dontDisplayTopFrameCM=0; // If true, the context sensitive menu will not appear in the top frame, only as a layer.
var $leftIcons=0; // If true, Show icons on the left.
var $extClassArray=array(); // Array of classes to be used for user processing of the menu content. This is for the API of adding items to the menu from outside.
var $ajax=0; // enable/disable ajax behavior
// Internal, dynamic:
var $elCount=0; // Counter for elements in the menu. Used to number the name / id of the mouse-over icon.
......
/**
* Initialize click menu
*
* @param string Input "item" GET var.
* @return string The clickmenu HTML content
*/
function init($item) {
function init() {
// Setting GPvars:
$this->cmLevel = intval(t3lib_div::_GP('cmLevel'));
$this->CB = t3lib_div::_GP('CB');
if(t3lib_div::_GP('ajax')) {
$this->ajax = 1;
ini_set('display_errors',0); // XML has to be parsed, no parse errors allowed
}
// Explode the incoming command:
$this->iParts = explode('|',$item);
// can be set differently as well
$this->iParts[0] = t3lib_div::_GP('table');
$this->iParts[1] = t3lib_div::_GP('uid');
$this->iParts[2] = t3lib_div::_GP('listFr');
$this->iParts[3] = t3lib_div::_GP('enDisItems');
// Setting flags:
if ($this->iParts[2]) $this->listFrame=1;
if ($GLOBALS['BE_USER']->uc['condensedMode'] || $this->iParts[2]==2) $this->alwaysContentFrame=1;
......
}
}
// Return clickmenu conten:
// Return clickmenu content:
return $CMcontent;
}
......
* @return boolean
*/
function doDisplayTopFrameCM() {
return !$GLOBALS['SOBE']->doc->isCMlayers() || !$this->dontDisplayTopFrameCM;
if($this->ajax) {
return false;
} else {
return !$GLOBALS['SOBE']->doc->isCMlayers() || !$this->dontDisplayTopFrameCM;
}
}
......
// Set back path place holder to real back path
$CMtable = str_replace($this->PH_backPath,$this->backPath,$CMtable);
if($this->ajax) {
$innerXML = '<data><clickmenu><htmltable><![CDATA['.$CMtable.']]></htmltable><cmlevel>'.$this->cmLevel.'</cmlevel></clickmenu></data>';
return $innerXML;
} else {
// Create JavaScript section:
$script=$GLOBALS['TBE_TEMPLATE']->wrapScriptTags('
if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
}
'.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
);
if (top.content && top.content'.$frameName.' && top.content'.$frameName.'.setLayerObj) {
top.content'.$frameName.'.setLayerObj(unescape("'.t3lib_div::rawurlencodeJS($CMtable).'"),'.$this->cmLevel.');
}
'.(!$this->doDisplayTopFrameCM()?'hideCM();':'')
);
return $script;
}
}
return $script;
}
/**
......
*/
function linkItem($str,$icon,$onClick,$onlyCM=0,$dontHide=0) {
$this->elCount++;
if($this->ajax) {
$onClick = str_replace('top.loadTopMenu', 'showClickmenu_raw', $onClick);
}
$WHattribs = t3lib_iconWorks::skinImg($BACK_PATH,'gfx/content_client.gif','width="7" height="10"',2);
return array(
......
* @return boolean
*/
function isCMlayers() {
return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
if($this->ajax) {
return !$this->CB;
} else {
return $GLOBALS['SOBE']->doc->isCMlayers() && !$this->CB;
}
}
/**
......
}
// Initialize template object
$this->doc = t3lib_div::makeInstance('template');
$this->doc->docType='xhtml_trans';
$this->doc->backPath = $BACK_PATH;
if(!$this->ajax) {
$this->doc = t3lib_div::makeInstance('template');
$this->doc->docType='xhtml_trans';
$this->doc->backPath = $BACK_PATH;
}
// Setting mode for display and background image in the top frame
$this->dontDisplayTopFrameCM= $this->doc->isCMlayers() && !$BE_USER->getTSConfigVal('options.contextMenu.options.alwaysShowClickMenuInTopFrame');
......
*/
function main() {
$this->ajax = t3lib_div::_GP('ajax')?TRUE:FALSE;
// Initialize Clipboard object:
$clipObj = t3lib_div::makeInstance('t3lib_clipboard');
$clipObj->initializeClipboard();
......
$clickMenu->backPath = $this->backPath;
// Start page
$this->content.=$this->doc->startPage('Context Sensitive Menu');
if(!$this->ajax) {
$this->content.=$this->doc->startPage('Context Sensitive Menu');
}
// Set content of the clickmenu with the incoming var, "item"
$this->content.= $clickMenu->init($this->item);
$this->content.= $clickMenu->init();
}
/**
......
* @return void
*/
function printContent() {
$this->content.= $this->doc->endPage();
echo $this->content;
if(!$this->ajax) {
$this->content.= $this->doc->endPage();
echo $this->content;
} else {
t3lib_ajax::outputXMLreply($this->content);
}
}
}
-- TYPO3core_orig/typo3/template.php 2005-10-21 10:06:59.000000000 +0200
++ TYPO3core/typo3/template.php 2005-10-23 21:54:48.000000000 +0200
......
if (!defined('TYPO3_MODE')) die("Can't include this file directly.");
require_once(PATH_t3lib.'class.t3lib_ajax.php');
......
* @return string The link-wrapped input string.
*/
function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE) {
$backPath = '&backPath='.rawurlencode($this->backPath).'|'.t3lib_div::shortMD5($this->backPath.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
$onClick = 'top.loadTopMenu(\''.$this->backPath.'alt_clickmenu.php?item='.rawurlencode($table.'|'.$uid.'|'.$listFr.'|'.$enDisItems).$backPath.$addParams.'\');'.$this->thisBlur().'return false;';
$backPath = rawurlencode($this->backPath).'|'.t3lib_div::shortMD5($this->backPath.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
$onClick = 'showClickmenu("'.$table.'","'.$uid.'","'.$listFr.'","'.$enDisItems.'","'.str_replace('&','&amp;',addcslashes($backPath,'"')).'","'.str_replace('&','&amp;',addcslashes($addParams,'"')).'");return false;';
return $returnOnClick ? $onClick : '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'] ? ' oncontextmenu="'.htmlspecialchars($onClick).'"' : '').'>'.$str.'</a>';
}
......
* @return array If values are present: [0] = A <script> section for the HTML page header, [1] = onmousemove/onload handler for HTML tag or alike, [2] = Two empty <div> layers for the context menu
*/
function getContextMenuCode() {
if ($this->isCMlayers()) {
$content='
$content = '
<script type="text/javascript">
/*<![CDATA[*/
// is called from most clickmenu links
function showClickmenu(table, uid, listFr, enDisItems, backPath, addParams) {
var url = "'.$this->backPath.'alt_clickmenu.php?table=" + table
+ "&uid=" + uid
+ "&listFr=" + listFr
+ "&enDisItems=" + enDisItems
+ "&backPath=" + backPath
+ "&addParams=" + addParams;
showClickmenu_raw(url);
}
// switch - either forwards call to ajax or does the request in the top frame
function showClickmenu_raw(url) {';
if($this->isCMlayers()) { // ajax
$content .= '
url += "&ajax=1";
ajax_doRequest(url);';
} else { // no ajax
$content .= '
showClickmenu_noajax(url);';
}
$content .= '
}
function showClickmenu_noajax(url) {
top.loadTopMenu(url);
}';
if ($this->isCMlayers()) {
$content .= t3lib_ajax::getJScode('showClickmenu_ajax', 'showClickmenu_noajax');
$content.='
// opens the clickmenu, is called from ajax_doRequest
function showClickmenu_ajax(t3ajax) {
var clickmenu = t3ajax.getElementsByTagName("data")[0].getElementsByTagName("clickmenu")[0];
var tableData = clickmenu.getElementsByTagName("htmltable")[0].firstChild.data;
var cmlevel = clickmenu.getElementsByTagName("cmlevel")[0].firstChild.data;
setLayerObj(tableData,cmlevel);
}
var GLV_gap=10;
var GLV_curLayerX=new Array(0,0);
var GLV_curLayerY=new Array(0,0);
......
}
}
}
}
/*]]>*/
</script>
';
}';
$content.=' /*]]>*/
</script>';
return array(
$content,
' onmousemove="GL_getMouse(event);" onload="initLayer();"',
'<div id="contentMenu0" style="z-index:1; position:absolute;visibility:hidden"></div><div id="contentMenu1" style="z-index:2; position:absolute;visibility:hidden"></div>'
);
} else return array('','','');
} else {
$content.=' /*]]>*/
</script>';
return array($content,'','');
}
}
/**
    (1-1/1)