Hi again,
Well, I have done some research in my free time and I have learnt a bit of javascript, YUI and the way Moodle uses them. I used this knowledge to modify the private_files block and now I feel I'm really close to find the solution for adding a button in that block that lets users to refresh its content. But I could still use some help!
Basically, I first added the button icon to the block (block_private_files.php file):
$refresh_button = '<input type="image" id="refreshEJSAppFBBut" align="left" src="' . $CFG->wwwroot . '/blocks/private_files/pix/refresh.png" name="image" width="25" height="25")";>';
Then I wrote this line to the render_private_files_tree() function in renderer.php:
$this->page->requires->js_init_call('M.block_ejsapp_file_browser.init_reload', array($htmlid));
and finally added this to the module.js file inside the private_files block:
M.block_ejsapp_file_browser.init_reload = function(Y, htmlid){
var button = Y.one("#refreshEJSAppFBBut");
button.on("click", function (e) {
div = document.getElementById(htmlid);
div.innerHTML = "Whatever";
});
};
This way, when a user clicks in the new refresh button that appears in the block, its content will change from the tree view of the files that user has in his private files, to a simple text (Whatever). Now I just need to replace "Whatever" with new a call to the function that generates the tree view of the private files.
And this is where I'm stucked at the moment. How can I do that? I think I would need to call the htmllize_tree() function of the renderer.php file from the javascript code in M.block_ejsapp_file_browser.init_reload (module.js file). Is that right? If so, how can I do that?
Thanks again!