mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge pull request #5134 from rubencm/ticket/15553
[ticket/15553] Add method to get direct link
This commit is contained in:
commit
9b79b56e7e
3 changed files with 41 additions and 4 deletions
|
@ -85,4 +85,14 @@ interface adapter_interface
|
||||||
* When the file cannot be copied
|
* When the file cannot be copied
|
||||||
*/
|
*/
|
||||||
public function copy($path_orig, $path_dest);
|
public function copy($path_orig, $path_dest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get direct link.
|
||||||
|
*
|
||||||
|
* @param string $path The file
|
||||||
|
*
|
||||||
|
* @return string Returns link.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function get_link($path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,11 @@ class local implements adapter_interface, stream_interface
|
||||||
*/
|
*/
|
||||||
protected $root_path;
|
protected $root_path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string path
|
||||||
|
*/
|
||||||
|
protected $path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
@ -73,12 +78,13 @@ class local implements adapter_interface, stream_interface
|
||||||
*/
|
*/
|
||||||
public function configure($options)
|
public function configure($options)
|
||||||
{
|
{
|
||||||
$this->root_path = $this->phpbb_root_path . $options['path'];
|
if (substr($options['path'], -1, 1) !== DIRECTORY_SEPARATOR)
|
||||||
|
|
||||||
if (substr($this->root_path, -1, 1) !== DIRECTORY_SEPARATOR)
|
|
||||||
{
|
{
|
||||||
$this->root_path = $this->root_path . DIRECTORY_SEPARATOR;
|
$options['path'] = $options['path'] . DIRECTORY_SEPARATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->path = $options['path'];
|
||||||
|
$this->root_path = $this->phpbb_root_path . $options['path'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -331,4 +337,12 @@ class local implements adapter_interface, stream_interface
|
||||||
{
|
{
|
||||||
return $this->image_dimensions($path);
|
return $this->image_dimensions($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get_link($path)
|
||||||
|
{
|
||||||
|
return generate_board_url() . $this->path . $path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,4 +216,17 @@ class storage
|
||||||
{
|
{
|
||||||
return new file_info($this->adapter, $path);
|
return new file_info($this->adapter, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get direct link
|
||||||
|
*
|
||||||
|
* @param string $path The file
|
||||||
|
*
|
||||||
|
* @return string Returns link.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function get_link($path)
|
||||||
|
{
|
||||||
|
return $this->get_adapter()->get_link($path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue