diff --git a/public/main/inc/lib/elfinder/connectorAction.php b/public/main/inc/lib/elfinder/connectorAction.php deleted file mode 100644 index 486faef308..0000000000 --- a/public/main/inc/lib/elfinder/connectorAction.php +++ /dev/null @@ -1,42 +0,0 @@ -setDriverList($driverList); -$operations = $connector->getOperations(); - -// Run elFinder -$finder = new Finder($operations); -$elFinderConnector = new \elFinderConnector($finder); -$elFinderConnector->run(); diff --git a/src/CoreBundle/Component/Editor/Connector.php b/src/CoreBundle/Component/Editor/Connector.php deleted file mode 100644 index 98112bbc95..0000000000 --- a/src/CoreBundle/Component/Editor/Connector.php +++ /dev/null @@ -1,358 +0,0 @@ -paths = [ - //'root_sys' => api_get_path(SYS_PATH), - //'sys_root' => api_get_path(SYS_PATH), // just an alias - //'sys_course_path' => api_get_path(SYS_COURSE_PATH), - // 'sys_config_path' => $app['path.config'], - 'path.temp' => api_get_path(SYS_ARCHIVE_PATH), - //'sys_log_path' => $app['path.logs'] - ]; - $this->entityManager = $entityManager; - //$this->paths = $paths; - $this->urlGenerator = $urlGenerator; - $this->translator = $translator; - //$this->security = $security; - $this->user = $user; - $this->course = $course; - $this->session = $session; - $this->driverList = $this->getDefaultDriverList(); - } - - public function getDriverList(): array - { - return $this->driverList; - } - - /** - * Available driver list. - * - * @param array $list - */ - public function setDriverList($list): void - { - $this->driverList = $list; - } - - /** - * @param Driver $driver - */ - public function addDriver($driver): void - { - if (!empty($driver)) { - $this->drivers[$driver->getName()] = $driver; - } - } - - public function getDrivers(): array - { - return $this->drivers; - } - - /** - * @param string $driverName - * - * @return Driver - */ - public function getDriver($driverName) - { - if (isset($this->drivers[$driverName])) { - return $this->drivers[$driverName]; - } - - return null; - } - - /** - * @param bool $processDefaultValues - * - * @return array - */ - public function getRoots($processDefaultValues = true) - { - $roots = []; - $drivers = $this->getDrivers(); - /** @var Driver $driver */ - foreach ($drivers as $driver) { - if ($processDefaultValues) { - $plugin = [ - 'chamilo' => [ - 'driverName' => $driver->getName(), - 'connector' => $this, - ], - ]; - $configuration = $driver->getConfiguration(); - $driver->setup(); - $configuration['plugin'] = $plugin; - $root = $this->updateWithDefaultValues($configuration); - } - $roots[] = $root; - } - - return $roots; - } - - /** - * Merges the default driver settings. - * - * @param array $driver - * - * @return array - */ - public function updateWithDefaultValues($driver) - { - if (empty($driver) || !isset($driver['driver'])) { - return []; - } - - $defaultDriver = $this->getDefaultDriverSettings(); - - if (isset($driver['attributes'])) { - $attributes = array_merge($defaultDriver['attributes'], $driver['attributes']); - } else { - $attributes = $defaultDriver['attributes']; - } - - $driverUpdated = array_merge($defaultDriver, $driver); - $driverUpdated['driver'] = 'Chamilo\CoreBundle\Component\Editor\Driver\\'.$driver['driver']; - $driverUpdated['attributes'] = $attributes; - - return $driverUpdated; - } - - /** - * Get default driver settings. - */ - public function getDefaultDriverSettings(): array - { - // for more options: https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options - return [ - 'uploadOverwrite' => false, - // Replace files on upload or give them new name if the same file was uploaded - //'acceptedName' => - 'uploadAllow' => [ - 'image', - 'audio', - 'video', - 'text/html', - 'text/csv', - 'application/pdf', - 'application/postscript', - 'application/vnd.ms-word', - 'application/vnd.ms-excel', - 'application/vnd.ms-powerpoint', - 'application/pdf', - 'application/xml', - 'application/vnd.oasis.opendocument.text', - 'application/x-shockwave-flash', - 'application/vnd.adobe.flash.movie', - ], - // allow files - //'uploadDeny' => array('text/x-php'), - 'uploadOrder' => ['allow'], - // only executes allow - 'disabled' => [ - 'duplicate', - 'rename', - 'mkdir', - 'mkfile', - 'copy', - 'cut', - 'paste', - 'edit', - 'extract', - 'archive', - 'help', - 'resize', - ], - 'attributes' => [ - // Hiding dangerous files - [ - 'pattern' => '/\.(php|py|pl|sh|xml)$/i', - 'read' => false, - 'write' => false, - 'hidden' => true, - 'locked' => false, - ], - // Hiding _DELETED_ files - [ - 'pattern' => '/_DELETED_/', - 'read' => false, - 'write' => false, - 'hidden' => true, - 'locked' => false, - ], - // Hiding thumbnails - [ - 'pattern' => '/.tmb/', - 'read' => false, - 'write' => false, - 'hidden' => true, - 'locked' => false, - ], - [ - 'pattern' => '/.thumbs/', - 'read' => false, - 'write' => false, - 'hidden' => true, - 'locked' => false, - ], - [ - 'pattern' => '/.quarantine/', - 'read' => false, - 'write' => false, - 'hidden' => true, - 'locked' => false, - ], - ], - ]; - } - - public function getOperations(): array - { - //https://github.com/Studio-42/elFinder/wiki/Connector-configuration-options-2.1 - $opts = [ - //'debug' => true, - 'bind' => [ - 'upload rm mkdir' => [$this, 'manageCommands'], - ], - 'sessionCloseEarlier' => false, - ]; - - $this->setDrivers(); - $opts['roots'] = $this->getRoots(); - - return $opts; - } - - /** - * Set drivers from list. - */ - public function setDrivers(): void - { - foreach ($this->getDriverList() as $driverName) { - $this->setDriver($driverName); - } - } - - /** - * Sets a driver. - * - * @param string $driverName - */ - public function setDriver($driverName): void - { - $driverClass = $this->getDriverClass($driverName); - - /** @var Driver $driver */ - $driver = new $driverClass(); - $driver->setName($driverName); - $driver->setConnector($this); - $this->addDriver($driver); - } - - /** - * Simple function to demonstrate how to control file access using "accessControl" callback. - * This method will disable accessing files/folders starting from '.' (dot). - * - * @param string $attr attribute name (read|write|locked|hidden) - * @param string $path file path relative to volume root directory started with directory separator - * @param string $data - * @param string $volume - * - * @return null|bool - */ - public function access($attr, $path, $data, $volume) - { - return 0 === strpos(basename($path), '.') // if file/folder begins with '.' (dot) - ? !('read' === $attr || 'write' === $attr) // set read+write to false, other (locked+hidden) set to true - : null; // else elFinder decide it itself - } - - /** - * @param string $cmd - * @param array $result - * @param array $args - * @param Finder $elFinder - */ - public function manageCommands($cmd, $result, $args, $elFinder): void - { - } - - /** - * Available driver list. - * - * @return array - */ - private function getDefaultDriverList() - { - return [ - 'CourseDriver', - 'CourseUserDriver', - 'DropBoxDriver', - 'HomeDriver', - 'PersonalDriver', - ]; - } - - /** - * @param string $driver - * - * @return string - */ - private function getDriverClass($driver) - { - return 'Chamilo\CoreBundle\Component\Editor\Driver\\'.$driver; - } -} diff --git a/src/CoreBundle/Component/Editor/Driver/Driver.php b/src/CoreBundle/Component/Editor/Driver/Driver.php deleted file mode 100644 index 550a6a23b6..0000000000 --- a/src/CoreBundle/Component/Editor/Driver/Driver.php +++ /dev/null @@ -1,105 +0,0 @@ -name; - } - - /** - * Gets driver name. - * - * @param string $name - */ - public function setName($name): void - { - $this->name = $name; - } - - public function setConnector(Connector $connector): void - { - $this->connector = $connector; - } - - /** - * @return array - */ - public function getAppPluginOptions() - { - return $this->getOptionsPlugin('chamilo'); - } - - /** - * @return Connector - */ - public function setConnectorFromPlugin() - { - $options = $this->getAppPluginOptions(); - $this->setConnector($options['connector']); - } - - /** - * This is a copy of rename function only to be used when uploading a file - * {@inheritdoc} - */ - public function customRename($hash, $name) - { - if (!$this->nameAccepted($name)) { - return $this->setError(elFinder::ERROR_INVALID_NAME, $name); - } - - if (!($file = $this->file($hash))) { - return $this->setError(elFinder::ERROR_FILE_NOT_FOUND); - } - - if ($name === $file['name']) { - return $file; - } - - if (!empty($file['locked'])) { - return $this->setError(elFinder::ERROR_LOCKED, $file['name']); - } - - $path = $this->decode($hash); - $dir = $this->dirnameCE($path); - $stat = $this->stat($this->joinPathCE($dir, $name)); - - if ($stat) { - return $this->setError(elFinder::ERROR_EXISTS, $name); - } - - if (!$this->allowCreate($dir, $name, ('directory' === $file['mime']))) { - return $this->setError(elFinder::ERROR_PERM_DENIED); - } - - $this->rmTmb($file); // remove old name tmbs, we cannot do this after dir move - - if ($path = $this->convEncOut($this->_move($this->convEncIn($path), $this->convEncIn($dir), $this->convEncIn($name)))) { - $this->clearcache(); - - return $this->stat($path); - } - - return false; - } -} diff --git a/src/CoreBundle/Component/Editor/Driver/DriverInterface.php b/src/CoreBundle/Component/Editor/Driver/DriverInterface.php deleted file mode 100644 index 2ccc92f9c6..0000000000 --- a/src/CoreBundle/Component/Editor/Driver/DriverInterface.php +++ /dev/null @@ -1,47 +0,0 @@ -