Skip to content

Commit

Permalink
Update elfinder to latest version Important: requires composer update.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Feb 9, 2017
1 parent 5607ff6 commit ac8a66b
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 105 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"szymach/c-pchart": "1.*",
"aferrandini/phpqrcode": "1.0.1",
"mpdf/mpdf": "6.1.*",
"barryvdh/elfinder-builds": "2.1.0.3",
"studio-42/elfinder": "2.1.*",
"jbroadway/urlify": "dev-master",
"monolog/monolog": "~1.0",
"ircmaxell/password-compat": "~1.0.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set finderFolder = _p.web ~ 'vendor/barryvdh/elfinder-builds/' %}
{% set finderFolder = _p.web ~ 'vendor/studio-42/elfinder/' %}
<!-- elFinder CSS (REQUIRED) -->
<link rel="stylesheet" type="text/css" media="screen" href="{{ finderFolder }}css/elfinder.full.css">
<link rel="stylesheet" type="text/css" media="screen" href="{{ finderFolder }}css/theme.css">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function getCourseDirectory()
/**
* {@inheritdoc}
*/
public function upload($fp, $dst, $name, $tmpname)
public function upload($fp, $dst, $name, $tmpname, $hashes = array())
{
$this->setConnectorFromPlugin();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public function setup()
$userId = api_get_user_id();
$dir = \UserManager::getUserPathById($userId, 'system');
if (!empty($dir)) {

if (!is_dir($dir)) {
mkdir($dir);
}
Expand All @@ -37,11 +36,9 @@ public function setup()
public function getConfiguration()
{
if ($this->allow()) {

$userId = api_get_user_id();

if (!empty($userId)) {

// Adding user personal files
$dir = \UserManager::getUserPathById($userId, 'system');
$dirWeb = \UserManager::getUserPathById($userId, 'web');
Expand Down Expand Up @@ -78,12 +75,10 @@ public function getConfiguration()
/**
* {@inheritdoc}
*/
public function upload($fp, $dst, $name, $tmpname)
public function upload($fp, $dst, $name, $tmpname, $hashes = array())
{
$this->setConnectorFromPlugin();

if ($this->allow()) {

return parent::upload($fp, $dst, $name, $tmpname);
}
}
Expand All @@ -96,7 +91,6 @@ public function rm($hash)
$this->setConnectorFromPlugin();

if ($this->allow()) {

return parent::rm($hash);
}
}
Expand All @@ -107,7 +101,6 @@ public function rm($hash)
public function allow()
{
//if ($this->connector->security->isGranted('IS_AUTHENTICATED_FULLY')) {

return !api_is_anonymous();
}
}
Loading

3 comments on commit ac8a66b

@ywarnier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how/why it worked for you, but for all of us here with different versions of PHP, this change broke the elfinder popup (it appears blank).
When doing composer update, in the notes, we get:

studio-42/elfinder suggests installing barryvdh/elfinder-flysystem-driver (VolumeDriver for elFinder to use Flysystem as a root.)
studio-42/elfinder suggests installing dropbox-php/dropbox-php (elFinder Volume driver `Dropbox` require `dropbox-php/dropbox-php`.)
studio-42/elfinder suggests installing nao-pon/flysystem-google-drive (require in GoogleDrive network volume mounting.)
studio-42/elfinder suggests installing pear/http_oauth (dropbox-php require `pear/http_oauth` or `PHP OAuth extension`.)

And then it finishes without error, but when opening the elfinder window, we get a blank page and the JS console shows:

"NetworkError: 404 Not Found - https://www.peruanojaponesvirtual.apj.org.pe/vendor/barryvdh/elfinder-builds/js/i18n/elfinder.ru.js"
"NetworkError: 404 Not Found - https://www.peruanojaponesvirtual.apj.org.pe/vendor/barryvdh/elfinder-builds/js/elfinder.full.js"
"NetworkError: 404 Not Found - https://www.peruanojaponesvirtual.apj.org.pe/vendor/barryvdh/elfinder-builds/css/theme.css"
...a series of other similar lines...
TypeError: $(...).elfinder is not a function

This prevents us from uploading anything. This is relatively important, but the big mystery is how it can work for you...

@ywarnier
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind this comment above: the portals we were testing were all using custom template folders (super weird circumstances), and so our elfinder tpl was not updated by your commit!
That was resolved by copying the main/template/default/javascript/editor/elfinder_standalone.tpl file to the custom template.

@jmontoyaa
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😼

Please sign in to comment.