summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cbd5874)
raw | patch | inline | side by side (parent: cbd5874)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 24 Feb 2009 08:47:38 +0000 (08:47 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 24 Feb 2009 08:47:38 +0000 (08:47 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@13446 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/trunk/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc b/trunk/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc
index e12c79d6b9d022905079d7e4dfc58716a7910bc4..377f6c4b1c5029e83c90211e85d3f3ceac232bd4 100644 (file)
if((!file_exists($path.$this->gotoPrinterPPD))){
$smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD)."</b>");
}else{
- $smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
+ $ppdDesc = $ppdManager->loadDescription($path.$this->gotoPrinterPPD);
+ $smarty->assign("driverInfo", $ppdDesc['name']);
}
}else{
$smarty->assign("driverInfo", _("Not defined"));
diff --git a/trunk/gosa-plugins/goto/admin/systems/ppd/class_ppdManager.inc b/trunk/gosa-plugins/goto/admin/systems/ppd/class_ppdManager.inc
index fe72164d2ea787168b9528d62d5b275d3fec9439..db3e50c60c90f55c7887a7cc7c35fae716af36ae 100644 (file)
function loadDescription($ppdFile)
{
- $model= "";
- $manufacturer= "";
-
-
+ $ppdDesc = array();
+
/* 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]){
/* Extract interesting informations */
if (preg_match('/^\*Manufacturer:/i', $line)){
- $manufacturer= preg_replace('/^\*Manufacturer:\s+"?([^"]+)"?.*$/i', '\1', $line);
+ $ppdDesc['manufacturer'] = trim(preg_replace('/^\*Manufacturer:\s+"?([^"]+)"?.*$/i', '\1', $line));
}
if (preg_match('/^\*ModelName:/i', $line)){
- $model= preg_replace('/^\*ModelName:\s+"?([^"]+)"?.*$/i', '\1', $line);
+ $ppdDesc['model'] = trim(preg_replace('/^\*ModelName:\s+"?([^"]+)"?.*$/i', '\1', $line));
}
/* Got everything we need? Skip rest for speed reasons... */
- if ($model != '' && $manufacturer != ''){
+ if (isset($ppdDesc['manufacturer']) && isset($ppdDesc['model'])){
break;
}
}
gzclose ($fh);
+ /* If model contains manufacturer strip it */
+ $ppdDesc['model'] = str_replace($ppdDesc['manufacturer']." ", '', $ppdDesc['model']);
+
/* Write out a notice that the PPD file seems to be broken if we can't
extract any usefull informations */
- if ($model == '' || $manufacturer == ''){
+ if ($ppdDesc['manufacturer'] == '' || $ppdDesc['model'] == ''){
trigger_error(sprintf(_('Parsing PPD file %s failed - no information found.'), $ppdFile), E_USER_WARNING);
}
- return ($manufacturer.' - '.$model);
+ $ppdDesc['name'] = $ppdDesc['manufacturer'] . " - " . $ppdDesc['model'];
+
+ return $ppdDesc;
}
diff --git a/trunk/gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc b/trunk/gosa-plugins/goto/admin/systems/ppd/class_printerPPDDialog.inc
index 2f176e75a93eed251cc7bce270434166127c9ae2..149dc8608b377ece7d070b905b882666bf0ed878 100644 (file)
if(!file_exists($this->pathToPPD.$this->pathToModified.$ppdfile)){
msg_dialog::display(_("PPD error"), sprintf(_("Cannot open PPD '%s'!"), $ppdfile), ERROR_DIALOG);
}else{
- $res = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$ppdfile);
- if($res){
- $tmp = split("\n",$res);
- $tmp3 = array();
- $tmp3['name'] = trim(preg_replace("/^\-/","",trim($tmp[1])));
- $tmp3['link'] = $ppdfile;
- $tmp3['ppd'] = $res;
+ $ppdDesc = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$ppdfile);
+ if($ppdDesc){
+ $selectedPPD = array();
+ $selectedPPD['name'] = $ppdDesc['name'];
+ $selectedPPD['link'] = $ppdfile;
+ $selectedPPD['ppd'] = $ppdDesc;
}
- $this->selectedPPD = $tmp3;
+ $this->selectedPPD = $selectedPPD;
}
}
}
msg_dialog::display(_("PPD error"), msgPool::cannotReadFile($AbsoluteSourceName), ERROR_DIALOG);
return;
}
- $res = $this->ppdManager->loadDescription($AbsoluteSourceName);
- if($res){
- $tmp = split("\n",$res);
- $Name = trim(preg_replace("/^\-/","",trim($tmp[1])));
- $Vendor = trim($tmp[0]);
- $Model = trim(preg_replace("/".$Vendor."/","",$Name));
+ $ppdDesc = $this->ppdManager->loadDescription($AbsoluteSourceName);
+ if($ppdDesc){
+ $Name = $ppdDesc['name'];
+ $Vendor = $ppdDesc['manufacturer'];
+ $Model = $ppdDesc['model'];
}
$PrinterName = $this->cn."-".preg_replace("/[^a-z0-9-_\.]/i","_",$Name);
$this->getPrinterReload();
/* Get Description from ppd, & parse out some informations */
- $res = @$this->ppdManager->loadDescription($_PathOnHdd);
- if($res){
- $tmp = split("\n",$res);
- $name = @trim(preg_replace("/^\-/","",trim($tmp[1])));
- $vendor = @trim($tmp[0]);
- $model = @trim(preg_replace("/".$vendor."/","",$name));
+ $ppdDesc = @$this->ppdManager->loadDescription($_PathOnHdd);
+ if($ppdDesc){
+ $name = $ppdDesc['name'];
+ $vendor = $ppdDesc['manufacturer'];
+ $model = $ppdDesc['model'];
}
/* Check if parse was successfull */
/* Sort all available files, and create header (Vendor index) */
foreach($tmp as $file=>$ppd){
-
+
if(preg_match("#".$this->pathToModified."#",$file)) continue;
- $tmp2 = split("\n",$ppd);
- if(!isset($this->ppdListHeader[$tmp2[0]])){
- $this->ppdListHeader[$tmp2[0]]=0;
+ if(!isset($this->ppdListHeader[$ppd['manufacturer']])){
+ $this->ppdListHeader[$ppd['manufacturer']]=0;
}
- $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2]);
+
+ $tmp3['name'] =$ppd['name'];
$tmp3['link'] =$file;
$tmp3['ppd'] =$ppd;
- $this->ppdListHeader[$tmp2[0]]++;
- $this->ppdList[$tmp2[0]][preg_replace("/^ -/","",$tmp2[1]." - ".$tmp2[2])]=$tmp3;
+ $this->ppdListHeader[$ppd['manufacturer']]++;
+ $this->ppdList[$ppd['manufacturer']][$ppd['name']]=$tmp3;
}
}
}
{
$str = "none";
if(!empty($this->selectedPPD)){
- $str = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']);
+ $ppdDesc = $this->ppdManager->loadDescription($this->pathToPPD.$this->pathToModified.$this->selectedPPD['link']);
+ $str = $ppdDesc['name'];
}
return($str) ;
}
-
/* Display all options from the selected ppd file */
function generateProperties()
{
diff --git a/trunk/gosa-plugins/goto/admin/systems/ppd/class_printerPPDSelectionDialog.inc b/trunk/gosa-plugins/goto/admin/systems/ppd/class_printerPPDSelectionDialog.inc
index 8d109d11bf0219ec120a67ddaad781b1613f3037..f9f32f8da55ecb14609407c1171d3539d9def099 100644 (file)
$list = array();
foreach($this->list as $cat => $ppds){
foreach($ppds as $ppd){
- if(preg_match("/^".str_replace("*",".*",$regex)."/i",$ppd['ppd'])){
+ $name = $ppd['ppd']['name'];
+ if(preg_match("/^".str_replace("*",".*",$regex)."/i",$name)){
if(is_readable($ppd['link'])){
$list[$ppd['link']] = $ppd;
}
if(empty($this->Vendor)){
foreach($this-> header as $key => $entry){
$div ->AddEntry (array(
+
array("string"=>sprintf($linkopen,base64_encode($key),$key),"attach"=>"style='border-right:0px;'")
));
}
array("string"=>sprintf($linkopen,"",".. ["._("back")."]"),"attach"=>"style='border-right:0px;'")
));
foreach($list as $key => $ppd){
- if(preg_match("/^".$this->Vendor."/",$ppd['ppd'])){
+ $name = $ppd['ppd']['name'];
+ if(preg_match("/^".$this->Vendor."/", $name)){
if(is_writeable($ppd['link'])){
$del_str = sprintf($dellink,base64_encode($key));
}
$div ->AddEntry (array(
- array("string"=>sprintf($uselink,base64_encode($key),$ppd['ppd'])),
+ array("string"=>sprintf($uselink,base64_encode($key),$name)),
array("string"=>$del_str,"attach"=>"style='border-right:0px;'")
));