1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

form modification

Discussion in 'JavaScript' started by gclass, Jul 16, 2009.

  1. #1
    Hi

    I have a form that allow users to create new file/folder and symbolic link to it.

    I want to make the form only create folders with no symbolic link,
    and hide the "file/folder" combo and "symbolic link" text field.

    Thanks,
    Kobi


    
    function execAction($dir) {		// make new directory or file
    		if(($GLOBALS["permissions"]&01)!=01) ext_Result::sendResult( 'mkitem', false, $GLOBALS["error_msg"]["accessfunc"]);
    		
    		if( extGetParam($_POST,'confirm') == 'true') {
    			$mkname=$GLOBALS['__POST']["mkname"];
    			$mktype=$GLOBALS['__POST']["mktype"];
    			$symlink_target = $GLOBALS['__POST']['symlink_target'];
    			
    			$mkname=basename(stripslashes($mkname));
    			if($mkname=="") ext_Result::sendResult( 'mkitem', false,  $GLOBALS["error_msg"]["miscnoname"] );
    			
    			$new = get_abs_item($dir,$mkname);
    		
    			if(@$GLOBALS['ext_File']->file_exists($new)) {
    				ext_Result::sendResult( 'mkitem', false, $mkname.": ".$GLOBALS["error_msg"]["itemdoesexist"]);
    			}
    			$err = print_r( $_POST, true );
    			if($mktype=="dir") {
    				$ok=@$GLOBALS['ext_File']->mkdir($new, 0777);
    				$err=$GLOBALS["error_msg"]["createdir"];
    			} elseif( $mktype == 'file') {
    				$ok=@$GLOBALS['ext_File']->mkfile($new);
    				$err=$GLOBALS["error_msg"]["createfile"];
    			} elseif( $mktype == 'symlink' ) {
    				if( empty( $symlink_target )) {
    					ext_Result::sendResult( 'mkitem', false, 'Please provide a valid <strong>target</strong> for the symbolic link.');
    				}
    				if( !file_exists($symlink_target) || !is_readable($symlink_target)) {
    					ext_Result::sendResult( 'mkitem', false, 'The file you wanted to make a symbolic link to does not exist or is not accessible by PHP.');
    				}
    				$ok = symlink( $symlink_target, $new );
    				$err = 'The symbolic link could not be created.';
    			}
    			
    			if($ok==false || PEAR::isError( $ok )) {
    				if( PEAR::isError( $ok ) ) $err.= $ok->getMessage();
    				ext_Result::sendResult( 'mkitem', false, $err);
    			}
    			ext_Result::sendResult( 'mkitem', true, 'The item '.$new.' was created' );
    			
    			return;
    		}
    	?>
    		<div>
    	    <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>
    	    <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc">
    	
    	        <h3 style="margin-bottom:5px;">Create New Directory</h3>
    	        <div id="adminForm">
    	
    	        </div>
    	    </div></div></div>
    	    <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>
    	</div>
    	<script type="text/javascript">
    	var mktypes = new Ext.data.SimpleStore({
    	    fields: ['mktype', 'type'],
    	    data :  [
    	        ['file', '<?php echo ext_Lang::mime( 'file', true ) ?>'],
    	        ['dir', '<?php echo ext_Lang::mime( 'dir', true ) ?>']
    	        <?php
    	        if( !ext_isFTPMode() && !$GLOBALS['isWindows']) { ?>
    	        	,['symlink', '<?php echo ext_Lang::mime( 'symlink', true ) ?>']
    	        	<?php
    	        } ?>
    	        ]
    	});
    	var simple = new Ext.form.Form({
    	    labelWidth: 125, // label settings here cascade unless overridden
    	    url:'<?php echo basename( $GLOBALS['script_name']) ?>'
    	});
    	simple.add(
    	    new Ext.form.TextField({
    	        fieldLabel: '<?php echo ext_Lang::msg( 'nameheader', true ) ?>',
    	        name: 'mkname',
    	        width:175,
    	        allowBlank:false
    	    }),
    		new Ext.form.ComboBox({
    			fieldLabel: 'Type',
    		    store: mktypes,
    		    displayField:'type',
    		    valueField: 'mktype',
    		    value: 'file',
    		    hiddenName: 'mktype',
    		    disableKeyFilter: true,
    		    editable: false,
    		    triggerAction: 'all',
    		    mode: 'local',
    		    allowBlank: false,
    		    selectOnFocus:true
    		}),
    	    new Ext.form.TextField({
    	        fieldLabel: '<?php echo ext_Lang::msg( 'symlink_target', true ) ?>',
    	        name: 'symlink_target',
    	        width:175,
    	        allowBlank:true
    	    })
    	);
    	
    	simple.addButton('<?php echo ext_Lang::msg( 'btncreate', true ) ?>', function() {
    		statusBarMessage( 'Please wait...', true );
    	    simple.submit({
    	        //reset: true,
    	        reset: false,
    	        success: function(form, action) {	
    	        	statusBarMessage( action.result.message, false, true );
    	        	try{ 
    	        		dirTree.getSelectionModel().getSelectedNode().reload(); 
    	        	} catch(e) {}
    				datastore.reload();
    				dialog.destroy();
    	        },
    	        failure: function(form, action) {
    	        	if( !action.result ) return;
    				Ext.MessageBox.alert('Error!', action.result.error);
    				statusBarMessage( action.result.error, false, true );
    	        },
    	        scope: simple,
    	        // add some vars to the request, similar to hidden fields
    	        params: {option: 'com_extplorer', 
    	        		action: 'mkitem', 
    	        		dir: datastore.directory, 
    	        		confirm: 'true'}
    	    })
    	});
    	simple.addButton('<?php echo ext_Lang::msg( 'btncancel', true ) ?>', function() { dialog.destroy(); } );
    	simple.render('adminForm');
    	simple.findField( 'mkname').focus();
    	</script>
    PHP:
     
    gclass, Jul 16, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    how is that a javascript question? you use EXT, yes, but the folder creation etc would be done by the php processor. i suggest you try the php forum or better yet, the ext one as it seems to use a serverside framework as well...
     
    dimitar christoff, Jul 17, 2009 IP
  3. gclass

    gclass Active Member

    Messages:
    337
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    thanks dimitar,
    I wanst sure where to post it, but I spent some time reading forums and solved it.
     
    gclass, Jul 17, 2009 IP
  4. DollarTrader

    DollarTrader Banned

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Dude is there any way to learn java like you guys??
     
    DollarTrader, Jul 17, 2009 IP
  5. gclass

    gclass Active Member

    Messages:
    337
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #5
    I would say try lynda.com and other video tutorials,
    Install XAMPP and try it..
     
    gclass, Jul 17, 2009 IP