X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_ppdManager.inc;h=a9dfd1a7f995e5bb292b7985864ebac8984039c3;hb=b55c9da0cc1fed54d967f22d17380948e94d40a0;hp=c533fb800586e3ee19838a6ea736253aa9a1c3aa;hpb=7eed0341040c6a6907cbbc9d490991daa9b0c49e;p=gosa.git diff --git a/include/class_ppdManager.inc b/include/class_ppdManager.inc index c533fb800..a9dfd1a7f 100644 --- a/include/class_ppdManager.inc +++ b/include/class_ppdManager.inc @@ -4,6 +4,7 @@ class ppdManager { var $path= ""; var $cachedList= array(); + var $timestamps = array(); function ppdManager($path) { @@ -73,6 +74,12 @@ class ppdManager continue; } + /* Change model name .. */ + if ((preg_match("/^\*".$attribute.":*\s+/",$line)) && ($attribute == "ModelName")){ + $line= "*$attribute: \"$value\"\n"; + $done =true; + } + if (($fsection) && ($section != "NO_SECTION")){ if (preg_match("/^\*CloseGroup:*\s+\**$section\/*/", $line)){ $fsection= false; @@ -282,6 +289,16 @@ class ppdManager $model= ""; $manufacturer= ""; + + /* Only parse complete PPD file again, if it was changed */ + $modified = filemtime($ppdFile); + if(isset($this->cachedList[$ppdFile]) && isset($this->timestamps[$ppdFile]) && $modified == $this->timestamps[$ppdFile]){ + return($this->cachedList[$ppdFile]); + } + + /* Remember modified timestamp, to speed up next request */ + $this->timestamps[$ppdFile] = filemtime($ppdFile); + $fh= fopen ($ppdFile, 'r'); while ((!feof($fh))&&($fh)) { @@ -323,10 +340,11 @@ class ppdManager $list= $this->findPPD($this->path); /* Load descriptive informations to build final printer list */ - $this->cachedList= array(); + $new = array(); foreach ($list as $ppdFile){ - $this->cachedList[$ppdFile]= $this->loadDescription($ppdFile); + $new[$ppdFile] = $this->loadDescription($ppdFile); } + $this->cachedList= $new ; }