X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_ppdManager.inc;h=a9dfd1a7f995e5bb292b7985864ebac8984039c3;hb=6c6148c73fa05be5904cb13385ed133bc615fdca;hp=1152fccc13a1be9a21a7e2e3bd1eec16705e0825;hpb=0ec43ef600fb5f988711907ed55402b3905d55ca;p=gosa.git diff --git a/include/class_ppdManager.inc b/include/class_ppdManager.inc index 1152fccc1..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; @@ -136,7 +143,7 @@ class ppdManager { if(!is_readable($ppdFile)){ print_red(sprintf(_("Specified ppd file '%s' can't be opened for reading."),$ppdFile)); - }elseif(!is_writeable($ppdFile.".tmp")){ + }elseif(!is_writeable(preg_replace("#(^.*/).*$#","\\1",$ppdFile.".tmp"))){ print_red(sprintf(_("The required tmp file file '%s' can't be opened for writing."),$ppdFile.".tmp")); }else{ foreach ($properties as $name => $section){ @@ -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 ; }