<?php
/**
 * Configuration Interface
 * 
 * The Media Manager allows multiple configurations that can be selected
 * based on an key. This configurations are based on this interface
 * 
 * @author Visual Media 
 */

namespace VisualM\MediaManagerBundle\Configuration;

/**
 * Configuration Interface
 * 
 * @author Visual Media 
 */
interface ConfigurationInterface
{
    /**
     * Allow File/Folder to be viewed
     */
    const FLAG_VIEW   = 1;
    
    /**
     * Allow File to be edited, or Files in Folder to be added
     */
    const FLAG_EDIT   = 2;
    
    /**
     * Allow File/Folder to be deleted
     */
    const FLAG_DELETE = 4;
    
    /**
     * Allow File to be inserted
     */
    const FLAG_INSERT = 8;
    
    /**
     * Combination of all Flags, use this in combination 
     * with the other flags to rule out a single permission
     * like $flag = ConfigurationInterface::FLAG_ALL & ~FLAG_DELETE
     */
    const FLAG_ALL = 0xFF;
    
    /**
     * Get Path where browsing starts. 
     * 
     * Must return an full file path. Only Files and Folders above this 
     * path can be browsed, opened and edited. Path can be in any format that
     * is supported by PHP
     * 
     * @return string FULL Base path 
     */
    public function getBasePath();
    
    /**
     * Get Path that is prepended to file URL when selecting file
     * 
     * @return string
     */
    public function getRelativeToWebroot();
    
    /**
     * Get Flags for given File
     * 
     * Should return an ORed integer with FLAG_* constants
     * 
     * @param string $filename Full filename
     * 
     * @return integer Flags
     */
    public function getFileFlags($filename);

    
    /**
     * Check if given filename is allowed for upload
     * 
     * This function can be used to check for forbidden file types
     * like .php, .js, .exe, etc.
     * 
     * @param string $filename Filename (without path)
     * 
     * @return boolean Allowed
     */
    public function allowedForUpload($filename);
    
    /**
     * Get Flags for given Folder
     * 
     * Should return an ORed integer with FLAG_* constants
     * 
     * @param string $folder Full folder name
     * 
     * @return integer Flags
     */
    public function getFolderFlags($folder);
    
}