MediaSearch_File
[ class tree: MediaSearch_File ] [ index: MediaSearch_File ] [ all elements ]

Source for file Folder.php

Documentation is available at Folder.php

  1. <?php
  2. /**
  3.  * MediaSearch
  4.  *
  5.  * LICENSE
  6.  *
  7.  * "THE BEER-WARE LICENSE" (Revision 42):
  8.  * "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
  9.  * As long as you retain this notice you can do whatever you want with
  10.  * this stuff. If we meet some day, and you think this stuff is worth it,
  11.  * you can buy me a beer in return.
  12.  *
  13.  * $Author$
  14.  * $Revision$
  15.  *
  16.  * @category    MediaSearch
  17.  * @package     MediaSearch_File
  18.  * @copyright   Copyright (c) 2009 Sven Strittmatter
  19.  */
  20.  
  21. /**
  22.  * @see MediaSearch_File_Abstract
  23.  */
  24. require_once('MediaSearch/File/Abstract.php');
  25.  
  26. /**
  27.  * Concrete implementation of a folder. Objects of this type are nodes
  28.  * in a file tree. A folder can have some files as chields. Theese could
  29.  * be files or folders. This is the composite part of the composite
  30.  * pattern (see GoF).
  31.  *
  32.  * @category   MediaSearch
  33.  * @package    MediaSearch_File
  34.  * @copyright  Copyright (c) 2009 Sven Strittmatter
  35.  */
  36.     const TRACE_LELVEL = 24;
  37.  
  38.     /**
  39.      * Contains any number of child
  40.      * MediaSearch_File_Abstract objects.
  41.      *
  42.      * @access private
  43.      * @var array 
  44.      */
  45.     private $files;
  46.  
  47.     /**
  48.      * @see MediaSearch_File_Abstract
  49.      */
  50.     public function __construct($fileInfo{
  51.         parent::__construct($fileInfo);
  52.         $this->files array();
  53.     }
  54.  
  55.     /**
  56.      * Adds files as childs to the node.
  57.      *
  58.      * @access public
  59.      * @param MediaSearch_File_Abstract $file 
  60.      */
  61.     public function addFile(MediaSearch_File_Abstract $file{
  62.         $this->files[$file;
  63.     }
  64.  
  65.     /**
  66.      * Returns whether this node has childs or not.
  67.      *
  68.      * @access public
  69.      * @return bool 
  70.      */
  71.     public function hasFiles({
  72.         return (count($this->files0);
  73.     }
  74.     
  75.     /**
  76.      * Implements MediaSearch_Interface_Visitable.
  77.      * Lets the visitor visit all files if there are any.
  78.      *
  79.      * @access public
  80.      * @param MediaSearch_Interface_Visitor $visitor 
  81.      */
  82.     public function acceptVisitor(MediaSearch_File_Visitor $visitor{
  83.         if ($this->hasFiles()) {
  84.             foreach ($this->getFiles(as $file{
  85.                 $file->acceptVisitor($visitor);
  86.             }
  87.         }
  88.     }
  89.  
  90.     /**
  91.      * Returns the files if there are any
  92.      *
  93.      * @acces public
  94.      * @return array 
  95.      */
  96.     public function getFiles({
  97.         return $this->getFiles;
  98.     }
  99. }

Documentation generated on Mon, 17 Aug 2009 14:52:55 +0200 by phpDocumentor 1.4.2