nextcloud_webdav_client-1.0.x-dev/nextcloud_webdav_client.module
nextcloud_webdav_client.module
<?php
/**
* @file
* NextCloud WebDAV Client module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function nextcloud_webdav_client_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.nextcloud_webdav_client':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The NextCloud WebDAV Client module provides integration with NextCloud servers via the WebDAV protocol. It allows you to create folders and upload files to your NextCloud instance directly from Drupal.') . '</p>';
$output .= '<h3>' . t('Configuration') . '</h3>';
$output .= '<p>' . t('To configure the module, visit the <a href=":config">NextCloud WebDAV settings page</a> and enter your NextCloud server details.', [
':config' => '/admin/config/services/nextcloud-webdav',
]) . '</p>';
$output .= '<h3>' . t('Usage') . '</h3>';
$output .= '<p>' . t('Once configured, you can use the module programmatically in your custom code or test the functionality using the <a href=":test">test interface</a>.', [
':test' => '/admin/config/services/nextcloud-webdav/test',
]) . '</p>';
$output .= '<h3>' . t('Features') . '</h3>';
$output .= '<ul>';
$output .= '<li>' . t('Create folders and nested folder structures') . '</li>';
$output .= '<li>' . t('Upload files from local filesystem') . '</li>';
$output .= '<li>' . t('Upload Drupal file entities') . '</li>';
$output .= '<li>' . t('Upload text content as files') . '</li>';
$output .= '<li>' . t('List directory contents') . '</li>';
$output .= '<li>' . t('Batch upload operations') . '</li>';
$output .= '</ul>';
return $output;
case 'nextcloud_webdav_client.settings':
return '<p>' . t('Configure your NextCloud WebDAV connection settings. You will need your NextCloud server URL, username, and password or app password.') . '</p>';
case 'nextcloud_webdav_client.test':
return '<p>' . t('Use this interface to test your NextCloud WebDAV connection and perform basic operations like creating folders and uploading files.') . '</p>';
}
}
/**
* Helper function to get the NextCloud WebDAV manager service.
*
* @return \Drupal\nextcloud_webdav_client\NextCloudWebDavManager
* The NextCloud WebDAV manager service.
*/
function nextcloud_webdav_client_get_manager() {
return \Drupal::service('nextcloud_webdav_client.manager');
}
/**
* Helper function to get the NextCloud WebDAV client service.
*
* @return \Drupal\nextcloud_webdav_client\Service\NextCloudWebDavClient
* The NextCloud WebDAV client service.
*/
function nextcloud_webdav_client_get_client() {
return \Drupal::service('nextcloud_webdav_client.client');
}
/**
* Helper function to check if NextCloud WebDAV is configured.
*
* @return bool
* TRUE if configured, FALSE otherwise.
*/
function nextcloud_webdav_client_is_configured() {
return nextcloud_webdav_client_get_manager()->isConfigured();
}
/**
* Helper function to test NextCloud WebDAV connection.
*
* @return bool
* TRUE if connection is successful, FALSE otherwise.
*/
function nextcloud_webdav_client_test_connection() {
return nextcloud_webdav_client_get_manager()->testConnection();
} 