Documents upgrade ..

This commit is contained in:
Hugo Loza
2011-02-04 22:05:14 +00:00
parent 98c686e005
commit 483544b652
4 changed files with 975 additions and 874 deletions

View File

@@ -1,17 +1,30 @@
<?php
//if (($RBAC_Response=$RBAC->userCanAccess("PM_USERS"))!=1) return $RBAC_Response;
G::LoadInclude ( 'ajax' );
$_POST ['action'] = get_ajax_value ( 'action' );
if (! isset ( $_REQUEST ['action'] )) {
$res ['success'] = 'failure';
$res ['message'] = 'You may request an action';
print G::json_encode ( $res);
die ();
}
if (! function_exists ( $_REQUEST ['action'] )) {
$res ['success'] = 'failure';
$res ['message'] = 'The requested action doesn\'t exists';
print G::json_encode ( $res );
die ();
}
require_once ("classes/model/AppFolder.php");
$functionName = $_REQUEST ['action'];
$functionParams = isset ( $_REQUEST ['params'] ) ? $_REQUEST ['params'] : array ();
$oPMFolder = new AppFolder ( );
$functionName ( $functionParams );
$rootFolder = "/";
switch ($_POST ['action']) {
function expandNode(){
require_once ("classes/model/AppFolder.php");
$oPMFolder = new AppFolder ( );
$rootFolder = "/";
case 'expandNode':
if($_POST ['node']=="") $_POST ['node'] ="/";
if($_POST ['node']=="root") $_POST ['node'] ="/";
if(!(isset($_POST['sendWhat']))) $_POST['sendWhat']="both";
@@ -178,8 +191,9 @@ switch ($_POST ['action']) {
}
print G::json_encode ( $processListTree );
break;
case 'openPMFolder' :
}
function openPMFolder(){
$WIDTH_PANEL = 350;
G::LoadClass ( 'tree' );
$folderContent = $oPMFolder->getFolderList ( $_POST ['folderID'] != '0' ? $_POST ['folderID'] == 'NA' ? "" : $_POST ['folderID'] : $rootFolder );
@@ -243,8 +257,9 @@ GHTML;
print ($tree->render ()) ;
break;
case 'getPMFolderContent' :
}
function getPMFolderContent(){
$swSearch = false;
if (isset ( $_POST ['folderID'] )) { //Render content of a folder
@@ -289,9 +304,9 @@ GHTML;
G::RenderPage ( 'publish', 'raw' );
break;
}
case "getPMFolderTags" :
function getPMFolderTags(){
// Default font sizes
$min_font_size = 12;
$max_font_size = 30;
@@ -323,9 +338,9 @@ GHTML;
print "$cloud_html";
break;
}
case "uploadDocument" :
function uploadDocument(){
$uploadDocumentComponent=array();
@@ -379,7 +394,7 @@ GHTML;
$itemA["single_file_select"]=false; // Set to true if you only want to select one file from the FileDialog.
$itemA["confirm_delete"]=false; // This will prompt for removing files from queue.
$itemA["remove_completed"]=false; // Remove file from grid after uploaded.
//$uploadDocumentComponent["items"][]=$itemA;
//$uploadDocumentComponent["items"][]=$itemA;
//Standard Upload
$itemA=array();
@@ -468,7 +483,7 @@ GHTML;
$buttonA["text"]= "btncancel";
$buttonA["handler"]="function_standardupload_btncancel";
$functionsToReplace["function_standardupload_btncancel"]=' function() { Ext.getCmp("dialog").destroy(); }';
$itemA["buttons"][]=$buttonA;
$itemA["buttons"][]=$buttonA;
$uploadDocumentComponent["items"][]=$itemA;
@@ -539,19 +554,19 @@ $itemA["buttons"][]=$buttonA;
$buttonA["text"]="btncancel";
$buttonA["handler"]="function_transfer_btncancel";
$functionsToReplace["function_transfer_btncancel"]='function() { Ext.getCmp("dialog").destroy(); }';
$itemA["buttons"]=$buttonA;
$itemA["buttons"]=$buttonA;
// $uploadDocumentComponent["items"][]=$itemA;
$finalResponse=G::json_encode($uploadDocumentComponent);
$finalResponse=str_replace("URL_SCRIPT","../appFolder/appFolderAjax.php",$finalResponse);
foreach($functionsToReplace as $key => $originalFunction){
$finalResponse=G::json_encode($uploadDocumentComponent);
$finalResponse=str_replace("URL_SCRIPT","../appFolder/appFolderAjax.php",$finalResponse);
foreach($functionsToReplace as $key => $originalFunction){
$finalResponse=str_replace('"'.$key.'"',$originalFunction,$finalResponse);
}
}
echo ($finalResponse);
/*
/*
//krumo($_POST);
G::LoadClass ( 'case' );
$oCase = new Cases ( );
@@ -566,9 +581,82 @@ foreach($functionsToReplace as $key => $originalFunction){
$Fields ['docType'] = $_POST ['docType'];
$G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'appFolderSaveDocument?UID=' . $_POST ['docID'] . '&appId=' . $_POST ['appId'] . '&docType=' . $_POST ['docType'] );
G::RenderPage ( 'publish', 'raw' );
*/
break;
case "documentVersionHistory" :
*/
}
function copyAction(){
$dir=$_REQUEST['dir'];
$copyDialog["xtype"]="form";
$copyDialog["id"]="simpleform";
$copyDialog["labelWidth"]=125;
$copyDialog["width"]=340;
$copyDialog["url"]="URL_SCRIPT";
$copyDialog["dialogtitle"]= "Copy/Move";
$copyDialog["frame"]= true;
$copyDialog["items"]=array();
$itemField=array();
$itemField["xtype"]="textfield";
$itemField["fieldLabel"]="Destination";
$itemField["name"]="new_dir";
$itemField["value"]="$dir/";
$itemField["width"]=175;
$itemField["allowBlank"]=false;
$copyDialog["items"][]=$itemField;
$copyDialog["buttons"]=array();
$itemButton=array();
$itemButton["text"]= "Create";
$itemButton["handler"]="copyDialogCreateButtonFunction";
$functionsToReplace["copyDialogCreateButtonFunction"]="function() {
form = Ext.getCmp('simpleform').getForm();
statusBarMessage( 'Please wait...', true );
var requestParams = getRequestParams();
requestParams.confirm = 'true';
requestParams.action = 'copyExecute';
form.submit({
//reset: true,
reset: false,
success: function(form, action) {
statusBarMessage( action.result.message, false, true );
try{
dirTree.getSelectionModel().getSelectedNode().reload();
} catch(e) {}
datastore.reload();
Ext.getCmp('dialog').destroy();
},
failure: function(form, action) {
if( !action.result ) return;
Ext.MessageBox.alert('Error!', action.result.error);
statusBarMessage( action.result.error, false, false );
},
scope: form,
// add some vars to the request, similar to hidden fields
params: requestParams
});
}";
$copyDialog["buttons"][]=$itemButton;
$itemButton=array();
$itemButton["text"]="Cancel";
$itemButton["handler"]= "copyDialogCancelButtonFunction";
$functionsToReplace["copyDialogCancelButtonFunction"]="function() { Ext.getCmp('dialog').destroy(); }";
$copyDialog["buttons"][]=$itemButton;
$finalResponse=G::json_encode($copyDialog);
foreach($functionsToReplace as $key => $originalFunction){
$finalResponse=str_replace('"'.$key.'"',$originalFunction,$finalResponse);
}
$finalResponse=str_replace("URL_SCRIPT","../appFolder/appFolderAjax.php",$finalResponse);
echo ($finalResponse);
}
function documentVersionHistory(){
$folderID = $_POST ['folderID'] != '0' ? $_POST ['folderID'] == 'NA' ? "" : $_POST ['folderID'] : $rootFolder;
$folderContent = $oPMFolder->getFolderContent ( $folderID, array ($_POST ['appDocId'] ) );
@@ -593,9 +681,9 @@ foreach($functionsToReplace as $key => $originalFunction){
G::RenderPage ( 'publish', 'raw' );
break;
}
case "uploadExternalDocument" :
function uploadExternalDocument(){
$response['action']=$_POST['action']. " - ".$_POST['option'];
$response['error']="error";
@@ -745,7 +833,7 @@ foreach($functionsToReplace as $key => $originalFunction){
$ext = (isset($info['extension']) ? $info['extension'] : '');
//save the file
// if (!empty($_FILES['form'])) {
// if (!empty($_FILES['form'])) {
// if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) {
$sPathName = PATH_DOCUMENT . $appId . PATH_SEP;
$sFileName = $sAppDocUid . "_".$iDocVersion. '.' . $ext;
@@ -800,7 +888,7 @@ foreach($functionsToReplace as $key => $originalFunction){
}
print_r(G::json_encode($response));
/*
/*
G::LoadClass ( 'case' );
$oCase = new Cases ( );
@@ -811,10 +899,10 @@ foreach($functionsToReplace as $key => $originalFunction){
$G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'cases/cases_AttachInputDocumentGeneral', '', $Fields, 'appFolderSaveDocument?UID=-1&appId=' . $Fields ['appId'] . "&folderId=" . $_POST ['folderID'] );
G::RenderPage ( 'publish', 'raw' );
*/
break;
*/
}
case "newFolder" :
function newFolder(){
//G::pr($_POST);
if($_POST ['dir']=="") $_POST ['dir']="/";
$folderStructure = $oPMFolder->getFolderStructure ( $_POST ['dir'] );
@@ -937,8 +1025,9 @@ foreach($functionsToReplace as $key => $originalFunction){
$G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'appFolder/appFolderEdit', '', $Fields, 'appFolderSave' );
G::RenderPage ( 'publish', 'raw' );
*/
break;
case "appFolderSave":
}
function appFolderSave(){
$form = $_POST['form'];
$FolderUid = $form['FOLDER_UID'];
$FolderParentUid = $form['FOLDER_PARENT_UID'];
@@ -956,8 +1045,9 @@ foreach($functionsToReplace as $key => $originalFunction){
print_r(G::json_encode($response));
break;
case "documentInfo" :
}
function documentInfo(){
$oFolder = new AppFolder ( );
$Fields = $oPMFolder->getCompleteDocumentInfo ( $_POST ['appId'], $_POST ['appDocId'], $_POST ['docVersion'], $_POST ['docID'], $_POST ['usrUid'] );
$G_PUBLISH = new Publisher ( );
@@ -965,9 +1055,9 @@ foreach($functionsToReplace as $key => $originalFunction){
$G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'appFolder/appFolderDocumentInfo', '', $Fields, '' );
G::RenderPage ( 'publish', 'raw' );
break;
}
case "documentdelete":
function documentdelete(){
include_once ("classes/model/AppDocument.php");
$oAppDocument = new AppDocument ( );
$oAppDocument->remove($_POST['sFileUID'],$_POST['docVersion']);
@@ -975,16 +1065,15 @@ foreach($functionsToReplace as $key => $originalFunction){
$appId= "00000000000000000000000000000000";
$sPathName = PATH_DOCUMENT . $appId . PATH_SEP;
unlink($sPathName.$_POST['sFileUID'].'_1.jpg');*/
break;
}
case "deletePMFolder":
function deletePMFolder(){
include_once ("classes/model/AppFolder.php");
$oAppFoder = new AppFolder ( );
$oAppFoder->remove($_POST['sFileUID'],$_POST['rootfolder']);
break;
}
function getMime($fileName){
$fileName=basename($fileName);
$fileNameA=explode(".",$fileName);
@@ -997,9 +1086,11 @@ function getMime($fileName){
}
return $return;
}
function get_max_file_size() { // get php max_upload_file_size
return calc_php_setting_bytes( ini_get("upload_max_filesize") );
}
function get_max_upload_limit() {
return calc_php_setting_bytes( ini_get('post_max_size'));
}
@@ -1018,6 +1109,7 @@ function calc_php_setting_bytes( $value ) {
return $value;
}
function get_abs_item($dir, $item) { // get absolute file+path
if( is_array( $item )) {
// FTP Mode
@@ -1027,6 +1119,7 @@ function get_abs_item($dir, $item) { // get absolute file+path
}
return extPathName( get_abs_dir($dir)."/".$item );
}
function extPathName($p_path,$p_addtrailingslash = false) {
$retval = "";

View File

@@ -5,9 +5,12 @@ Ext.FlashComponent.EXPRESS_INSTALL_URL = '/images/expressinstall.swf';
// The Quicktips are used for the toolbar and Tree mouseover tooltips!
Ext.QuickTips.init();
try{rc=new RegExp('^("(\\\\.|[^"\\\\\\n\\r])*?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?$')}
catch(z){rc=/^(true|false|null|\[.*\]|\{.*\}|".*"|\d+|\d+\.\d+)$/}
var conn = new Ext.data.Connection();
function chDir( directory, loadGridOnly ) {
function chDir( directory, loadGridOnly ) {
// console.info("**** Changing Directory: "+directory+" --
// "+loadGridOnly);
if( datastore.directory.replace( /\//g, '' ) == directory.replace( /\//g, '' )
@@ -24,9 +27,9 @@ var conn = new Ext.data.Connection();
if( !loadGridOnly ) {
expandTreeToDir( null, directory );
}
}
}
function expandTreeToDir( node, dir ) {
function expandTreeToDir( node, dir ) {
// console.info("Expanding Tree to Dir "+node+" - "+dir);
dir = dir ? dir : new String('');
var dirs = dir.split('/');
@@ -42,8 +45,8 @@ var conn = new Ext.data.Connection();
node.on('load', function() { expandNode( node, dir ); } );
node.expand();
}
}
function expandNode( node, dir ) {
}
function expandNode( node, dir ) {
// console.info("Expanding Node "+node+" - "+dir);
var fulldirpath, dirpath;
@@ -84,15 +87,15 @@ var conn = new Ext.data.Connection();
}
}
}
function handleNodeClick( sm, node ) {
}
function handleNodeClick( sm, node ) {
if( node && node.id ) {
// console.log("Node Clicked: "+node);
chDir( node.id );
}
}
}
function showLoadingIndicator( el, replaceContent ) {
function showLoadingIndicator( el, replaceContent ) {
// console.info("showLoadingIndicator");
if( !el ) return;
var loadingimg = '/images/documents/_indicator.gif';
@@ -104,8 +107,8 @@ var conn = new Ext.data.Connection();
else {
el.innerHTML += imgtag;
}
}
function getURLParam( strParamName, myWindow){
}
function getURLParam( strParamName, myWindow){
// console.info("getURLParam");
// console.trace();
if( !myWindow ){
@@ -125,9 +128,9 @@ var conn = new Ext.data.Connection();
}
}
return strReturn;
}
}
function openActionDialog( caller, action ) {
function openActionDialog( caller, action ) {
// console.log("Dialog open: "+caller+" ->"+action);
var dialog;
var selectedRows = ext_itemgrid.getSelectionModel().getSelections();
@@ -144,7 +147,7 @@ var conn = new Ext.data.Connection();
}
switch( action ) {
case 'copy':
case 'copyAction':
case 'edit':
case 'newFolder':
case 'move':
@@ -192,7 +195,9 @@ var conn = new Ext.data.Connection();
// Ext.Msg.alert("Debug",
// oResponse.responseText
// );
try{ json = Ext.decode( oResponse.responseText );
try{
json = Ext.decode( oResponse.responseText );
if( json.error && typeof json.error != 'xml' ) {
Ext.Msg.alert( "error", json.error );
dialog.destroy();
@@ -297,8 +302,9 @@ var conn = new Ext.data.Connection();
document.location = '?option=com_extplorer&action=download&item='+ encodeURIComponent(ext_itemgrid.getSelectionModel().getSelected().get('name')) + '&dir=' + encodeURIComponent( datastore.directory );
break;
}
}
function handleCallback(requestParams, node) {
}
function handleCallback(requestParams, node) {
// console.log("handleCallback "+requestParams +" -- "+node);
// console.trace();
var conn = new Ext.data.Connection();
@@ -335,7 +341,7 @@ var conn = new Ext.data.Connection();
}
});
}
}
function getRequestParams() {
// console.info("Get Request params ");
var selitems, dir, node;
@@ -670,7 +676,7 @@ var gridtb = new Ext.Toolbar(
cls : 'x-btn-icon',
disabled : false,
handler : function() {
openActionDialog(this, 'copy');
openActionDialog(this, 'copyAction');
}
},
{
@@ -993,7 +999,7 @@ gridCtxMenu = new Ext.menu.Menu({
icon : '/images/documents/_editcopy.png',
text : 'copylink',
handler : function() {
openActionDialog(this, 'copy');
openActionDialog(this, 'copyAction');
}
}, {
id : 'gc_move',
@@ -1100,7 +1106,7 @@ var dirCtxMenu = new Ext.menu.Menu(
text : 'Copy',
handler : function() {
dirCtxMenu.hide();
openActionDialog(this, 'copy');
openActionDialog(this, 'copyAction');
}
},
{
@@ -1155,7 +1161,7 @@ var copymoveCtxMenu = new Ext.menu.Menu({
text : 'copylink',
handler : function() {
copymoveCtxMenu.hide();
copymove('copy');
copymove('copyAction');
}
}, {
id : 'copymoveCtxMenu_move',
@@ -1300,6 +1306,7 @@ var documentsTab = {
tbar : gridtb,
bbar : gridbb,
ddGroup : 'TreeDD',
enableDragDrop: true,
selModel : new Ext.grid.RowSelectionModel({
listeners : {
'rowselect' : {
@@ -1318,7 +1325,7 @@ var documentsTab = {
stopEvent : true,
handler : function() {
openActionDialog(this,
'copy');
'copyAction');
}
},

View File

@@ -7,7 +7,6 @@ Ext.QuickTips.init();
var conn = new Ext.data.Connection();
function getOtherDashboards(dashboardTabPanels) {
conn.request({
url : 'casesStartPage_Ajax.php',
@@ -108,7 +107,7 @@ Ext
{
initEvents : function() {
MainPanel.superclass.initEvents.call(this);
this.body.on('click', this.onClick, this);
//this.body.on('click', this.onClick, this);
},
onClick : function(e, target, elementselected) {
@@ -149,6 +148,8 @@ Ext
"action" : 'getRegisteredDashboards'
},
success : function(responseObject) {
var response = Ext.util.JSON
.decode(responseObject.responseText);
for (var i in response) {