<?php
/**
 * ShopEx licence
 *
 * @copyright  Copyright (c) 2005-2010 ShopEx Technologies Inc. (http://www.shopex.cn)
 * @license  http://ecos.shopex.cn/ ShopEx License
 */
 
class wap_application_prototype_themefile extends base_application_prototype_filepath{

    var $current;
    var $path;
    private $_mtime = 0;

    public function detect($theme,$current=null){
        $this->iterator = null;
        $this->target_theme = $theme;
        if($current){
            $this->set_current($current);
        }
        return $this;
    }

    function init_iterator(){
        if(is_dir(WAP_THEME_DIR.'/'.$this->target_theme.'/'.$this->path)){
            $this->_mtime = filemtime(WAP_THEME_DIR.'/'.$this->target_theme.'/'.$this->path);
            return new DirectoryIterator(WAP_THEME_DIR.'/'.$this->target_theme.'/'.$this->path);
        }else{
            return new ArrayIterator(array());
        }
    }

    public function getPathname(){
        return $this->iterator()->getPathname();
    }

    public function current() {
        $this->key = $this->iterator()->getFilename();
        return $this;
    }

    function prototype_filter(){
        $filename = $this->iterator()->getFilename();
        if($filename{0}=='.'){
            return false;
        }else{
            return $this->filter();
        }
    }

}
