append() public method

Appends an item.
public append ( mixed $value )
$value mixed The item to append.
Example #1
0
 /**
  * List directory content
  *
  * @param string $path
  * @return boolean
  */
 public function ls($path = null)
 {
     $path = "{$this->_location}/{$path}";
     if (is_dir($path)) {
         $directory = new DirectoryIterator($path);
     } else {
         return false;
     }
     $collection = new Collection();
     foreach ($directory as $d) {
         if ($d->isDot()) {
             continue;
         }
         $url = rtrim($this->_config['url'], '/');
         $path = rtrim(substr($d->getPath(), strlen($this->_location)), '/') . '/';
         if ($url) {
             $url .= "{$path}{$d->getFilename()}";
         }
         $collection->append(new Entity(array('name' => $d->getFilename(), 'dir' => $d->isDir(), 'url' => $url, 'path' => $path, 'size' => $d->isDir() ? null : $d->getSize(), 'mode' => substr(sprintf('%o', $d->getPerms()), -4), 'adapter' => $this)));
     }
     return $collection;
 }
Example #2
0
 /**
  * List directory content
  *
  * @param string $path
  * @return boolean
  */
 public function ls($path = null)
 {
     if (!($path = $this->_prependLocation($path))) {
         $path = '/';
     }
     if (!$this->_is_dir($path)) {
         return false;
     }
     $collection = new Collection();
     foreach (ftp_nlist($this->_connection, $path) as $d) {
         if ($d === '.' || $d === '..') {
             continue;
         }
         if ($path === '/') {
             $path_d = $path;
             $url = "/{$d}";
         } else {
             $path_d = "/{$path}";
             $url = "{$path}/{$d}";
         }
         if (($size = ftp_size($this->_connection, $url)) < 0) {
             $size = null;
         }
         $collection->append(new Entity(array('name' => $d, 'dir' => $this->_is_dir($url), 'url' => "{$this->_config['url']}{$url}", 'path' => $path, 'size' => $size, 'mode' => null)));
     }
     return $collection;
 }