<?php
/**
 * Configuration Base Implementation
 * 
 * Implementation of the Configuration Interface. Should not be used
 * in real projects, purely demonstrational
 * 
 * @author Visual Media 
 */

namespace VisualM\MediaManagerBundle\Configuration;

/**
 * Configuration Base Implementation
 * 
 * @author Visual Media 
 */
class ConfigurationBaseImpl implements ConfigurationInterface
{
    /**
     * Base Path
     * @var string
     */
    private $base_path;
    
    /**
     * Constructor
     * 
     * @param string $base_path Base path
     */
    function __construct($base_path)
    {
        $this->base_path = $base_path;
    }

    
    /**
     * {@inheritDoc}
     */
    public function getBasePath()
    {
        return $this->base_path;
    }
    
    /**
     * {@inheritDoc}
     */
    public function getRelativeToWebroot()
    {
        return '';
    }
    
    /**
     * {@inheritDoc}
     */
    public function allowedForUpload($filename) 
    {
        $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
        if (in_array($extension, array(
            'php', 'js', 'exe', 'jar', 'pif', 'application', 'gadget', 'msi', 'msp', 'scr', 'com', 'hta', 'cpl', 'msc',
            'bat', 'vb', 'vbs', 'cmd', 'jse', 'ws', 'ws', 'wsf', 'wsc', 'wsh'
        ))) {
            return false;
        }
        return true;
    }
    
    /**
     * {@inheritDoc}
     */
    public function getFileFlags($filename)
    {
        return ConfigurationInterface::FLAG_ALL;
    }

    /**
     * {@inheritDoc}
     */
    public function getFolderFlags($folder) 
    {
        return ConfigurationInterface::FLAG_ALL;
    }
    
}