OpenSencillo  2015.002
filesList Class Reference

Public Member Functions

 __construct ($path)
 scanDir ($dir='./')
 findFiles ($dir, &$dir_array)
 findFilesStructure ($dir)
 arrayToHtml ($style, $folderStyle=null, $ftypes=null, $dot=null)

Protected Attributes

 $path
 $folderlist

Private Attributes

 $files
 $out

Detailed Description

Definition at line 2 of file files.management.fman.php.


Constructor & Destructor Documentation

__construct ( path)

Definition at line 9 of file files.management.fman.php.

    {
        $this->files = scandir($path);
        $this->path = $path;
        
        if (!file_exists($path)) 
        {
            mkdir($path, 0777, true);
            chmod($path,0777);
        }
    }

Member Function Documentation

arrayToHtml ( style,
folderStyle = null,
ftypes = null,
dot = null 
)

Convert array to html list

Parameters:
array$style
array$folderStyle
bool$dot
Returns:
string

Definition at line 106 of file files.management.fman.php.

    {
        $i=0;
        $this->out='';
        
        while(sizeof($this->files)>$i)
        {
            if(($dot==false)||($dot==null))
            {
                if(stristr($this->files[$i],$ftypes)!=false)
                {
                    //is file
                    if(($this->files[$i]!='.')&&($this->files[$i]!='..'))
                    {
                        $this->out.=$style[0].$this->files[$i++].$style[1];
                    }
                    else
                    {
                        $i++;
                    }
                }
                else
                {
                    //is folder
                    if(($this->files[$i]!='.')&&($this->files[$i]!='..'))
                    {
                        $this->out.=$folderStyle[0].$this->files[$i++].$folderStyle[1];
                    }
                    else
                    {
                        $i++;
                    }
                }
            }
            else 
            {
                if(is_file($this->files[$i]))
                {
                    $this->out.=$style[0].$this->files[$i++].$style[1];
                }
                else 
                {
                    $this->out.=$folderStyle[0].$this->files[$i++].$folderStyle[1];
                }
            }
        }
        return $this->out;
    }
findFiles ( dir,
&$  dir_array 
)

Get all files, folders, subfiles and subfolders from directory

Parameters:
string$dir(path to start directory)
array&$dir_array(array for update)

Definition at line 39 of file files.management.fman.php.

    {
        // Create array of current directory
        $files = scandir($dir);
       
        if(is_array($files))
        {
            foreach($files as $val)
            {
                // Skip home and previous listings
                if($val == '.' || $val == '..')
                    continue;
               
                // If directory then dive deeper, else add file to directory key
                if(is_dir($dir.'/'.$val))
                {
                    // Add value to current array, dir or file
                    $dir_array[$dir][] = $val;
                   
                    findFiles($dir.'/'.$val, $dir_array);
                }
                else
                {
                    $dir_array[$dir][] = $val;
                }
            }
        }
        ksort($dir_array);
    }
findFilesStructure ( dir)

Scan directory structure and recursive scannig subdirectory structure

Parameters:
string$dir
Returns:
array

Definition at line 76 of file files.management.fman.php.

    {
        $result = array();
        
        $cdir = scandir($dir);
        foreach ($cdir as $key => $value)
        {
            if (!in_array($value,array(".","..")))
            {
                if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
                {
                    $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
                }
                else
                {
                    $result[] = $value;
                }
            }
        }
        
        return $result;
    }
scanDir ( dir = './')

Create complet file list

Parameters:
string$dir(path)
Returns:
array

Definition at line 27 of file files.management.fman.php.

    {
        $this->folderlist = array();
        $this->findFiles($dir, $this->folderlist);
        return $this->folderlist;
    }

Field Documentation

$files [private]

Definition at line 4 of file files.management.fman.php.

$folderlist [protected]

Definition at line 7 of file files.management.fman.php.

$out [private]

Definition at line 5 of file files.management.fman.php.

$path [protected]

Definition at line 6 of file files.management.fman.php.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables