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
Expand Up @@ -78,7 +78,7 @@
"szymach/c-pchart": "1.*", "szymach/c-pchart": "1.*",
"aferrandini/phpqrcode": "1.0.1", "aferrandini/phpqrcode": "1.0.1",
"mpdf/mpdf": "6.1.*", "mpdf/mpdf": "6.1.*",
"barryvdh/elfinder-builds": "2.1.0.3", "studio-42/elfinder": "2.1.*",
"jbroadway/urlify": "dev-master", "jbroadway/urlify": "dev-master",
"monolog/monolog": "~1.0", "monolog/monolog": "~1.0",
"ircmaxell/password-compat": "~1.0.4", "ircmaxell/password-compat": "~1.0.4",
Expand Down
@@ -1,4 +1,4 @@
{% set finderFolder = _p.web ~ 'vendor/barryvdh/elfinder-builds/' %} {% set finderFolder = _p.web ~ 'vendor/studio-42/elfinder/' %}
<!-- elFinder CSS (REQUIRED) --> <!-- 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/elfinder.full.css">
<link rel="stylesheet" type="text/css" media="screen" href="{{ finderFolder }}css/theme.css"> <link rel="stylesheet" type="text/css" media="screen" href="{{ finderFolder }}css/theme.css">
Expand Down
Expand Up @@ -219,7 +219,7 @@ public function getCourseDirectory()
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function upload($fp, $dst, $name, $tmpname) public function upload($fp, $dst, $name, $tmpname, $hashes = array())
{ {
$this->setConnectorFromPlugin(); $this->setConnectorFromPlugin();


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

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

$userId = api_get_user_id(); $userId = api_get_user_id();


if (!empty($userId)) { if (!empty($userId)) {

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

if ($this->allow()) { if ($this->allow()) {

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


if ($this->allow()) { if ($this->allow()) {

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

return !api_is_anonymous(); return !api_is_anonymous();
} }
} }

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.