get_config(); $endpoint = ('' != $region && 'n/a' != $region) ? $region : $config['endpoint']; $log_message = "Set endpoint (".get_class($obj)."): $endpoint"; $log_message_append = ''; if (is_string($endpoint) && preg_match('/^(.*):(\d+)$/', $endpoint, $matches)) { $endpoint = $matches[1]; $port = $matches[2]; $log_message_append = ", port=$port"; $obj->setPort($port); } // This provider requires domain-style access. In future it might be better to provide an option rather than hard-coding the knowledge. if (is_string($endpoint) && preg_match('/\.aliyuncs\.com$/i', $endpoint)) { $obj->useDNSBucketName(true, $bucket_name); } global $updraftplus; if ($updraftplus->backup_time) $this->log($log_message.$log_message_append); $obj->setEndpoint($endpoint); } /** * This method overrides the parent method and lists the supported features of this remote storage option. * * @return Array - an array of supported features (any features not mentioned are asuumed to not be supported) */ public function get_supported_features() { // This options format is handled via only accessing options via $this->get_options() return array('multi_options', 'config_templates', 'multi_storage', 'conditional_logic'); } /** * Retrieve default options for this remote storage module. * * @return Array - an array of options */ public function get_default_options() { return array( 'accesskey' => '', 'secretkey' => '', 'path' => '', 'endpoint' => '', ); } /** * Retrieve specific options for this remote storage module * * @param Boolean $force_refresh - if set, and if relevant, don't use cached credentials, but get them afresh * * @return Array - an array of options */ protected function get_config($force_refresh = false) {// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- Filter use $opts = $this->get_options(); $opts['whoweare'] = 'S3'; $opts['whoweare_long'] = __('S3 (Compatible)', 'updraftplus'); $opts['key'] = 's3generic'; return $opts; } /** * Get the pre configuration template * * @return String - the template */ public function get_pre_configuration_template() { $opening_html = '
'.__('Examples of S3-compatible storage providers:', 'updraftplus').' DigitalOcean Spaces, Linode Object Storage, Cloudian, Connectria, Constant, Eucalyptus, Nifty, Cloudn'.__('... and many more!', 'updraftplus').'
'; $this->get_pre_configuration_template_engine('s3generic', 'S3', __('S3 (Compatible)', 'updraftplus'), 'S3', '', $opening_html); } /** * Get the configuration template * * @return String - the template, ready for substitutions to be carried out */ public function get_configuration_template() { // 5th parameter = control panel URL // 6th = image HTML return $this->get_configuration_template_engine('s3generic', 'S3', __('S3 (Compatible)', 'updraftplus'), 'S3', '', ''); } /** * Modifies handerbar template options * The function require because It should override parent class's UpdraftPlus_BackupModule_s3::transform_options_for_template() functionality with no operation. * * @param array $opts * @return Array - Modified handerbar template options */ public function transform_options_for_template($opts) { return $opts; } /** * Check whether options have been set up by the user, or not * * @param Array $opts - the potential options * * @return Boolean */ public function options_exist($opts) { return (parent::options_exist($opts) && !empty($opts['endpoint'])); } /** * Get handlebar partial template string for endpoint of s3 compatible remote storage method. Other child class can extend it. * * @return String the partial template string */ protected function get_partial_configuration_template_for_endpoint() { return '