PHP
  Home arrow PHP arrow Page 3 - Working with Directory Iterators and P...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Working with Directory Iterators and Proxy Classes with PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2007-01-09

    Table of Contents:
  • Working with Directory Iterators and Proxy Classes with PHP 5
  • Defining the initial structure of a proxy directory class
  • Improving the functionality of the proxy class
  • Completing the proxy pattern
  • Developing a final example

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Working with Directory Iterators and Proxy Classes with PHP 5 - Improving the functionality of the proxy class


    (Page 3 of 5 )

    Since the initial functionality provided by the prior "ProxyDirectoryProcessor" class is pretty limited, it would be desirable to add to it some additional methods. These will help with performing some useful tasks, such as retrieving the access timestamps that correspond to the different directory entries, as well as fetching some information concerning the respective index nodes.

    Aside from all the operations that I mentioned before, it's necessary to define another specific method. This method will be responsible for creating a directory processor object when this process will be required by the proxy class in question.

    Therefore, keeping in mind all the functionality that I want to give to the proxy class, below I listed its improved signature. Have a look at it, please:

    // define 'DirectoryProcessor' class class ProxyDirectoryProcessor{ private $dirPath; private $dirProcessor=NULL; public function __construct($dirPath='defaultPath'){ if(!is_dir($dirPath)){ throw new Exception('Invalid input directory');                 } $this->dirPath=$dirPath; } // get directory path public function getPath(){ if($this->dirProcessor==NULL){ $this->createDirectoryProcessor(); } return $this->dirProcessor->getPath(); } // get size of directory entries public function getSize(){ if($this->dirProcessor==NULL){ $this->createDirectoryProcessor(); } return $this->dirProcessor->getSize(); } // get names of directory entries public function getFileNames(){ if($this->dirProcessor==NULL){ $this->createDirectoryProcessor(); } return $this->dirProcessor->getFileNames(); } // get timestamps of directory entries public function getTimeStamps(){ if($this->dirProcessor==NULL){ $this->createDirectoryProcessor(); } return $this->dirProcessor->getTimeStamps(); } // get last-access timestamps of directory entries public function getLastTimeStamps(){ if($this->dirProcessor==NULL){ $this->createDirectoryProcessor(); } return $this->dirProcessor->getLastTimeStamps(); } // get last access timestamps of inodes public function getInodeLastTimeStamps(){ if($this->dirProcessor==NULL){ $this->createDirectoryProcessor(); } return $this->dirProcessor->getInodeLastTimeStamps(); } // instantiate dirProcessor object private function createDirectoryProcessor(){ $dirObj=new DirectoryProcessor($this->dirPath); $this->dirProcessor=$dirObj->getDirectoryProcessor(); } }

    As you can see above, now the proxy class is capable of performing all the additional tasks that I discussed a few lines before, since I included some extra methods. Most of them deal with different types of timestamps. Besides, you'll realize that there's a new method called the "createDirectoryProcessor()" object, which is tasked with returning to calling code a directory processor object. That was easy, wasn't it?

    All right, at this stage, the previously defined proxy class possess some decent functionality. This functionality is logically provided by a directory processor object, according to the definition for the proxy pattern. So what's the next step? Naturally, the next thing that I'm going to do is show you the signature for the pertinent directory processor class, in this way getting the pattern's schema completed.

    To learn how this new directory processor class will be created, please click on the link shown below and keep reading.

    More PHP Articles
    More By Alejandro Gervasio


       · Over this final installment of the series, you'll learn how to create proxy objects,...
     

       

    PHP ARTICLES

    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...
    - Protecting PHP 5 Class Data with Member Visi...
    - Setting Up a Web-based Image Hosting Service
    - Comparing Files and Databases with PHP Bench...
    - Setting Up a Web-Based Image Gallery





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway