Some ideas for file uploads

Discuss MySQL Ajax Table Editor Paid Version

Re: Some ideas for file uploads

Postby pq_rar » Thu Jul 22, 2010 5:37 pm

works fine if I call addDeleteIcon() manually:
Code: Select all
$this->Editor->retArr[] = array('where' => 'javascript', 'value' => 'addDeleteIcon("3dvideo");');

how I can generalize this for each upload column?
this is what I tried but with no luck
Code: Select all
$this->Editor->retArr[] = array('where' => 'javascript', 'value' => 'addDeleteIcon("'.$this->Editor->tableColumns.'");');

tableColumns seems to be an array but I don't know how to call the column name for each file column.
pq_rar
 
Posts: 89
Joined: Thu May 27, 2010 4:44 am

Re: Some ideas for file uploads

Postby admin » Thu Jul 22, 2010 6:01 pm

Try something like
Code: Select all
if($this->Editor->data->action == 'edit_row')
{
   foreach($this->Editor->tableColumns as $colName => $info)
   {
      if(isset($info['file_upload']))
      {
         $this->Editor->retArr[] = array('where' => 'javascript', 'value' => 'addDeleteIcon("'.$colName.'");');
      }
   }
}
admin
Site Admin
 
Posts: 1502
Joined: Fri Jul 11, 2008 1:34 am

Re: Some ideas for file uploads

Postby pq_rar » Thu Jul 22, 2010 6:22 pm

Thank you very much for your help.
It is working fine now.
pq_rar
 
Posts: 89
Joined: Thu May 27, 2010 4:44 am

Re: Some ideas for file uploads

Postby ericimprint » Thu Feb 17, 2011 10:14 pm

So I am doing an upload to dir delete. Here are the changes I have made and I can not get it to show the delete option:

Code: Select all
echo $javascript;
   
   //Add Delete Functions
   ?>
        <script type="text/javascript">>
        function addDeleteIcon(col)
              {
              var id = $('idreport').value;
              var html = $(col+'_input_cell').innerHTML;
              var htmlParts = html.split(/<br>/);
              if(htmlParts.length == 2)
              {
              var newHtml = '<table id="'+col+'_file_name_table"><tr><td style="border: none;">'+htmlParts[0]+'</td><td style="border: none;"><ul class="actions"><li class="delete"><a href="javascript: void(0);" onclick="deleteFile(\''+id+'\',\''+col+'\');" title="Delete '+htmlParts[0]+'"></a></li></ul></td></tr></table>';
              newHtml += htmlParts[1];
              $(col+'_input_cell').innerHTML = newHtml;
              }
              }

        function deleteFile(id)
                {
                   if(confirm('Are you sure you would like to delete this file?'))
                   {
                      toAjaxTableEditor('delete_file',id);
                   }
                }
            </script>
          <?
       }
    function deleteFile($info)
        {
        $query = "update asi_product_overrides set '$info->col' = '' where UniqueId = '$info->id'";
        $result = mysql_query($query);
        if($result)
        {
        $this->Editor->retArr[] = array('where' => 'javascript', 'value' => '$("file_name_table").remove();');
        }
        }

   
   function formatFileSize


Code: Select all
$userActions = array('delete_file' => array(&$this,'deleteFile'));
        $this->Editor->setConfig('userActions',$userActions);
      
      //Add Delete Button
      if($this->Editor->data->action == 'edit_row')
         {
            foreach($this->Editor->tableColumns as $colName => $info)
            {
               if(isset($info['file_upload']))
               {
                  $this->Editor->retArr[] = array('where' => 'javascript', 'value' => 'addDeleteIcon("'.$colName.'");');
               }
            }
         }
   }
   
   function


Here are the columns I am uploading to (which is working and has files uploaded to it):

Code: Select all
//Images
      $tableColumns['ImageIdLG'] = array('display_text' => 'ImageIdLG', 'perms' => 'EVCAXQS',
         'file_upload' => array('upload_fun' => array(&$this,'handleUpload')),
         'table_fun' => array(&$this,'formatImage'), 'view_fun' => array(&$this,'formatImage')
      );
      $tableColumns['ImageIdSM'] = array('display_text' => 'ImageIdSM', 'perms' => 'EVCAXQS',
         'file_upload' => array('upload_fun' => array(&$this,'handleUpload')),
         'table_fun' => array(&$this,'formatImage'), 'view_fun' => array(&$this,'formatImage')
      );


Can you see what I am doing wrong?
ericimprint
 
Posts: 24
Joined: Wed Feb 02, 2011 1:05 am

Re: Some ideas for file uploads

Postby admin » Thu Feb 17, 2011 10:21 pm

What is happening? Do the icons get displayed? I would throw an alert in the addDeleteIcon function to make sure it is getting called.
admin
Site Admin
 
Posts: 1502
Joined: Fri Jul 11, 2008 1:34 am

Re: Some ideas for file uploads

Postby ericimprint » Thu Feb 17, 2011 10:27 pm

admin wrote:What is happening? Do the icons get displayed? I would throw an alert in the addDeleteIcon function to make sure it is getting called.


Sorry, I wasn't clear. The delete "icon" / link is not there at all. I am guessing something is wrong in the call to add the delete "icon".
ericimprint
 
Posts: 24
Joined: Wed Feb 02, 2011 1:05 am

Re: Some ideas for file uploads

Postby admin » Fri Feb 18, 2011 4:01 pm

You are putting this code in the construct right?
Code: Select all
 //Add Delete Button
      if($this->Editor->data->action == 'edit_row')
         {
            foreach($this->Editor->tableColumns as $colName => $info)
            {
               if(isset($info['file_upload']))
               {
                  $this->Editor->retArr[] = array('where' => 'javascript', 'value' => 'addDeleteIcon("'.$colName.'");');
               }
            }
         }
   }

also you may have to change this line of javascript code because it looks like it is hard coded
Code: Select all
var id = $('idreport').value;
admin
Site Admin
 
Posts: 1502
Joined: Fri Jul 11, 2008 1:34 am

Re: Some ideas for file uploads

Postby admin » Fri Feb 18, 2011 5:20 pm

You will also want to modify the delete file function so that not only does it blank out the database field but it also unlinks/deletes the file from the server.
admin
Site Admin
 
Posts: 1502
Joined: Fri Jul 11, 2008 1:34 am

Re: Some ideas for file uploads

Postby ericimprint » Fri Feb 18, 2011 6:21 pm

admin wrote:You are putting this code in the construct right?


Correct, I have added that.

Code: Select all
   $this->Editor->main();
                 //Add Delete Button
                 if($this->Editor->data->action == 'edit_row')
                 {
                    foreach($this->Editor->tableColumns as $colName => $info)
                    {
                       if(isset($info['file_upload']))
                       {
                          $this->Editor->retArr[] = array('where' => 'javascript', 'value' => 'addDeleteIcon("'.$colName.'");');
                       }
                    }
                 }


You will also want to modify the delete file function so that not only does it blank out the database field but it also unlinks/deletes the file from the server.


Do you have an example of the code to do that, I looked through this thread and could not find one.
ericimprint
 
Posts: 24
Joined: Wed Feb 02, 2011 1:05 am

Re: Some ideas for file uploads

Postby admin » Fri Feb 18, 2011 6:36 pm

Take a look at the handle upload function. It has some unlink code in there.
admin
Site Admin
 
Posts: 1502
Joined: Fri Jul 11, 2008 1:34 am

PreviousNext

Return to Paid Version

Who is online

Users browsing this forum: No registered users and 2 guests

cron