Moodle

File storage conversion of HTML block

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Blocks, Files API
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

I have no idea how to use the editor form control in the new blocks/html/edit_form.php I have just made.

At the moment this is used from blocks/edit.php, but that code may have to move to lib/blocklib.php.

There may be other blocks with HTML content, I am not sure yet.

By the way, people definitely like putting images in HTML blocks so we have to fix this. At least all blocks have a context now.

Activity

Hide
Sam Hemelryk added a comment -

Hi guys,

I've attached a patch to for this issue... I have no clue whether it will suit the needs of Moodle but it is based on code I had already written for a block. I've modified it slightly to integrate it with the main plugin.php file (I had created a separate plugin.php file for my block )

What you should know about it:

  1. For a block to make use of files + pluginfile.php it must define a method '''send_file'''
  2. The file area for the block MUST start with '''block_{blockname}'''
  3. Obviously it must use the blocks context

Cheers
Sam

Show
Sam Hemelryk added a comment - Hi guys, I've attached a patch to for this issue... I have no clue whether it will suit the needs of Moodle but it is based on code I had already written for a block. I've modified it slightly to integrate it with the main plugin.php file (I had created a separate plugin.php file for my block ) What you should know about it:
  1. For a block to make use of files + pluginfile.php it must define a method '''send_file'''
  2. The file area for the block MUST start with '''block_{blockname}'''
  3. Obviously it must use the blocks context
Cheers Sam
Hide
Petr Škoda (skodak) added a comment -

I always wonder about the block logic, but anyway it looks ok to me, +1 for commit

Show
Petr Škoda (skodak) added a comment - I always wonder about the block logic, but anyway it looks ok to me, +1 for commit
Hide
Sam Hemelryk added a comment -

Cool thanks for reviewing it Petr, I have now commit.
I would suppose that when it comes to implementing file use in the first core block we should take a good hard look at it again. At least with the callback we can easily edit the pluginfile code if need be.

Cheers
Sam

Show
Sam Hemelryk added a comment - Cool thanks for reviewing it Petr, I have now commit. I would suppose that when it comes to implementing file use in the first core block we should take a good hard look at it again. At least with the callback we can easily edit the pluginfile code if need be. Cheers Sam
Hide
Tim Hunt added a comment -

I don't understand the "when it comes to implementing file use in the first core block ..." bit.

Surely the HTML block allows images, and so on in the HTML?

Show
Tim Hunt added a comment - I don't understand the "when it comes to implementing file use in the first core block ..." bit. Surely the HTML block allows images, and so on in the HTML?
Hide
Sam Hemelryk added a comment -

Thats a good quesiton Tim, I'll have a look at that block and see what it is doing at the moment!

Show
Sam Hemelryk added a comment - Thats a good quesiton Tim, I'll have a look at that block and see what it is doing at the moment!
Hide
Petr Škoda (skodak) added a comment -

html block was not converted to new files api yet because the blocks were not finalised yet at the time I was working on that, I was expecting that somebody who starts solving of old blocks issues will solve that too...

Show
Petr Škoda (skodak) added a comment - html block was not converted to new files api yet because the blocks were not finalised yet at the time I was working on that, I was expecting that somebody who starts solving of old blocks issues will solve that too...
Hide
Martin Dougiamas added a comment -

This is a very quick stab at fixing the HTML block to use files.

The draft area is setup in edit_form.php and the draftfiles are processed in instance_config_save

it's not working right now, probably because of a typo somewhere, but I think the general approach is right.

Can someone fix my bug?

Show
Martin Dougiamas added a comment - This is a very quick stab at fixing the HTML block to use files. The draft area is setup in edit_form.php and the draftfiles are processed in instance_config_save it's not working right now, probably because of a typo somewhere, but I think the general approach is right. Can someone fix my bug?
Hide
Martin Dougiamas added a comment -

Just shortening the patch, since part of it has gone into CVS now.

Show
Martin Dougiamas added a comment - Just shortening the patch, since part of it has gone into CVS now.
Hide
Martin Dougiamas added a comment -

Dongsheng this would probably be pretty quick for you?

Show
Martin Dougiamas added a comment - Dongsheng this would probably be pretty quick for you?
Hide
Martin Dougiamas added a comment -

Dongsheng can you try a look at this today too?

Show
Martin Dougiamas added a comment - Dongsheng can you try a look at this today too?
Hide
Dongsheng Cai added a comment -

Looking

Show
Dongsheng Cai added a comment - Looking
Hide
Martin Dougiamas added a comment -

Yay! Thanks Dongsheng!! Working great for me

Show
Martin Dougiamas added a comment - Yay! Thanks Dongsheng!! Working great for me

People

Vote (3)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: