$Date$ | > $Revision$ | > $Author$ +-------------------------------------------------------------------------- | > Filename: xajaxUpload.inc.php | > Date started: Tue Nov 27 13:51:18 CET 2007 +-------------------------------------------------------------------------- */ if (false == class_exists('xajaxPlugin') || false == class_exists('xajaxPluginManager')) { if (false == class_exists('xajaxPlugin') ) { //require_once( 'xajaxPlugin.inc.php' ); } if (false == class_exists('xajaxPluginManager') ) { require_once( $core. '\xajaxPluginManager.inc.php' ); } } # // /* require_once( 'xajaxPlugin.inc.php' ); require_once( 'xajaxPluginManager.inc.php' ); */ class xajaxResponseUpload extends xajaxResponsePlugin { public $bInlineScript = false; private $iframeId = null; public function __construct() { $this->bInlineScript = true; //parent::__construct(); $base = dirname(dirname(__FILE__)); $core = $base . '\xajax_core'; require_once( $core . '/xajaxControl.inc.php' ); require_once( $base . '/xajax_controls/structure.inc.php' ); require_once( $base . '/xajax_controls/document.inc.php' ); require_once( $base . '/xajax_controls/content.inc.php' ); require_once( $base . '/xajax_controls/form.inc.php' ); } public function generateClientScript() { // tmp $newQueryPart .= html_entity_decode(ini_get('arg_separator.output')); echo << function xajax_upload() { var age = navigator.userAgent; if(age.search("MSIE 6.0")!= -1) { alert('You can“t use xAJAX fileuploads, please update your Internet Explorer to a version 7.0 or above.'); } xajax.newSessionID = function() { var sessionID; sessionID = new String(new Date().getTime()); var random = new String(Math.random( )).substr(2); sessionID = sessionID + random; return sessionID; } xajax.upload = function (rpcFunc, iframeID ) { var is_ie6 = false; if (document.body && xajax.config.waitCursor) { document.body.style.cursor = 'wait'; } var form = xajax.$('form' + iframeID); if(!form) { return false; } var url = ""; if(!url) { url = xajax.config.requestURI; } // check url var separator = '{$newQueryPart}'; if(url.indexOf('?') != -1 ) { var last = url.charAt(url.length - 1); if ( last.charCodeAt(0) != separator.charCodeAt(0) ) { url += separator; } } else { url += '?'; } url += 'xjxfun='+encodeURIComponent(rpcFunc); url += "&xjxr=" + new Date().getTime(); for(var i=0; i 1 && xml.childNodes[i].firstChild.nodeName == "#cdata-section") { callargs.data = ""; for (var j=0; j 1) { for (var j=0; j 1 && xml.childNodes[i].childNodes[j].firstChild.nodeName == "#cdata-section") { var internalData = ""; for (var k=0; k EOF; } public function addUpload($sTarget,$sAttribute,$iName) { $sData = new clsDiv( array( 'attributes' => array( 'id' => 'div_' . $iName, ) ) ); $input = new clsInput( array( 'attributes' => array( 'type' => 'file', 'name' => $iName, ), ) ); $sData->addChild($input); return $this->addCommand( array( 'n'=>'as', 't'=>$sTarget, 'p'=>$sAttribute ), $sData->getHTML() ); } public function addTargetIframe( $sTarget,$sAttribute ) { $this->iframeId = md5( microtime( ) ); $sData = new clsIframe( array( 'attributes' => array( 'id' => $this->iframeId, 'name' => $this->iframeId, 'style' => "width:300px;height:300px;" ) ) ); return $this->addCommand( array( 'n'=>'ap', 't'=>$sTarget, 'p'=>$sAttribute ), $sData->getHTML() ); } public function getIframeName() { // change to return if the plugin-layer allows that echo $this->iframeId; } public function addAPC($sTarget,$sAttribute) { $APCId = md5( microtime( ) ); $sData = new clsInput( array( 'attributes' => array( 'type' => 'hidden', 'name' => 'APC_UPLOAD_PROGRESS', 'value' => $APCId ), ) ); return $this->addCommand( array( 'n'=>'ap', 't'=>$sTarget, 'p'=>$sAttribute ), $sData->getHTML() ); } } class xajaxRequestUpload extends xajaxRequestPlugin { function canProcessRequest() { if ( $_GET['xjxfun'] ) { return true; } return false; } function processRequest() { if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['xjxfun'])) { $this->initProcessRequests(); } return true; } function initProcessRequests() { $xajaxRequest = array(); $xajaxRequest['xjxr'] = @$_GET['xjxr']; $xajaxRequest['xjxfun'] = @$_GET['xjxfun']; // reset RequestMode if(isset($_GET['xjxfun'])) { $_GET['xjxfun'] = null; unset($_GET['xjxfun']); } // get the upload file local path foreach(array_keys($_FILES) as $name) { if(isset($_GET[$name]) && !isset($_POST[$name])) { $_POST[$name] = $_GET[$name]; } } #$xajaxargs = array($_POST); #$xajaxRequest['xjxargs'] = $xajaxargs; #$_POST = $xajaxRequest; } } $objPluginManager =& xajaxPluginManager::getInstance(); $objPluginManager->registerPlugin(new xajaxResponseUpload()); $objPluginManager->registerPlugin(new xajaxRequestUpload()); ?>