Вход Регистрация
Файл: concrete5.7.5.6/concrete/src/File/StorageLocation/Configuration/LocalConfiguration.php
Строк: 62
<?php
namespace ConcreteCoreFileStorageLocationConfiguration;
use 
ConcreteCoreErrorError;
use 
ConcreteFlysystemAdapterLocal;

class 
LocalConfiguration extends Configuration implements ConfigurationInterface
{

    protected 
$path;
    protected 
$relativePath;

    public function 
setRootPath($path)
    {
        
$this->path $path;
    }

    public function 
getRootPath()
    {
        return 
$this->path;
    }

    public function 
setWebRootRelativePath($relativePath)
    {
        
$this->relativePath $relativePath;
    }

    public function 
getWebRootRelativePath()
    {
        return 
$this->relativePath;
    }

    public function 
hasPublicURL()
    {
        return 
$this->hasRelativePath();
    }

    public function 
hasRelativePath()
    {
        return 
$this->relativePath != '';
    }

    public function 
getRelativePathToFile($file)
    {
        return 
$this->relativePath $file;
    }

    public function 
getPublicURLToFile($file)
    {
        
$rel $this->getRelativePathToFile($file);
        if(
strpos($rel'://')) {
            return 
$rel;
        }

        
$url Core::getApplicationURL(true);
        
$url $url->setPath($rel);
        return 
trim((string) $url'/');
    }

    public function 
loadFromRequest(ConcreteCoreHttpRequest $req)
    {
        
$data $req->get('fslType');
        
$this->path rtrim($data['path'], '/');
        if (isset(
$data['relativePath'])) {
            
$this->relativePath rtrim($data['relativePath'], '/');
        }
    }

    
/**
     * @param ConcreteCoreHttpRequest $req
     * @return Error
     */
    
public function validateRequest(ConcreteCoreHttpRequest $req)
    {
        
$e = new Error();
        
$data $req->get('fslType');
        
$this->path $data['path'];
        if (!
$this->path) {
            
$e->add(t("You must include a root path for this storage location."));
        } else if (!
is_dir($this->path)) {
            
$e->add(t("The specified root path does not exist."));
        } else if (
$this->path == '/') {
            
$e->add(t('Invalid path to file storage location. You may not choose the root directory.'));
        }
        return 
$e;
    }

    public function 
getAdapter()
    {
        
$local = new Local($this->getRootPath());
        return 
$local;
    }
}
Онлайн: 1
Реклама