3 * PHP module for the Common UNIX Printing System (CUPS).
5 * Copyright 1997-2003 by Easy Software Products.
7 * These coded instructions, statements, and computer programs are the
8 * property of Easy Software Products and are protected by Federal
9 * copyright law. Distribution and use rights are outlined in the file
10 * "LICENSE.txt" which should have been included with this file. If this
11 * file is missing or damaged please contact Easy Software Products
14 * Attn: CUPS Licensing Information
15 * Easy Software Products
16 * 44141 Airport View Drive, Suite 204
17 * Hollywood, Maryland 20636-3111 USA
19 * Voice: (301) 373-9603
20 * EMail: cups-info@cups.org
21 * WWW: http://www.cups.org
25 * Basic CupsPrinter class. Will be extended in next release.
28 if (!$INCLUDED_PHPCUPS_INC)
30 $INCLUDED_PHPCUPS_INC = True;
37 var $printer_instance;
41 var $printer_state_message;
43 var $queued_job_count;
47 var $printer_more_info;
51 var $job_quota_period;
55 var $pages_per_minute;
56 var $finishings_supported; // Array
57 var $finishings_default;
59 var $operations_supported; // Array
60 var $multiple_document_jobs_supported;
61 var $multiple_operation_time_out;
62 var $job_priority_supported_lower;
63 var $job_priority_supported_upper;
64 var $job_priority_default;
65 var $copies_supported_lower;
66 var $copies_supported_upper;
68 var $page_range_supported;
69 var $number_up_supported; // Array
70 var $number_up_default;
71 var $orientation_requested_supported; // Array
72 var $orientation_requested_default;
73 var $media_supported; // Array
76 function CupsPrinter()
78 $this->printer_name
= "";
79 $this->printer_destination
= "";
80 $this->is_default
= 0;
81 $this->options
= Array();
82 $this->printer_state
= -1;
83 $this->printer_state_message
= "";
84 $this->accepting_jobs
= FALSE;
85 $this->queued_job_count
= 0;
86 $this->description
= "";
88 $this->printer_info
= "";
89 $this->printer_more_info
= "";
90 $this->make_and_model
= "";
91 $this->printer_uri_supported
= Array();
92 $this->device_uri
= "";
93 $this->job_quota_period
= 0;
94 $this->job_k_limit
= 0;
95 $this->job_page_limit
= 0;
96 $this->color_supported
= FALSE;
97 $this->pages_per_minute
= 0;
98 $this->finishings_supported
= Array();
99 $this->finishings_default
= 0;
100 $this->printer_type
= 0;
101 $this->operations_supported
= Array();
102 $this->multiple_document_jobs_supported
= FALSE;
103 $this->multiple_operation_time_out
= 0;
104 $this->job_priority_supported_lower
= 0;
105 $this->job_priority_supported_upper
= 100;
106 $this->job_priority_default
= 50;
107 $this->copies_supported_lower
= 1;
108 $this->copies_supported_upper
= 1;
109 $this->copies_default
= 1;
110 $this->page_range_supported
= FALSE;
111 $this->number_up_supported
= Array();
112 $this->number_up_default
= 0;
113 $this->orientation_requested_supported
= Array();
114 $this->orientation_requested_default
= 3;
115 $this->media_supported
= Array();
116 $this->media_default
= "";
118 } // End of constructor
122 // Get the attributes
124 function getAttributes()
126 $o_arr = cups_get_dest_options($this->printer_server
,
128 $this->printer_instance
);
129 $this->printer_options
= $o_arr;
131 $attrs = cups_get_printer_attributes( "localhost", $this->printer_name
);
132 while ($obj = current($attrs))
136 if ($obj->name
== "printer-state")
138 $this->printer_state
= $obj->value
;
140 else if ($obj->name
== "printer-state-message")
142 $this->printer_state_message
= $obj->value
;
144 else if ($obj->name
== "printer-location")
146 $this->location
= $obj->value
;
148 else if ($obj->name
== "printer-make-and-model")
150 $this->description
= $obj->value
;
152 else if ($obj->name
== "printer-uri-supported")
154 $this->printer_uri_supported
[$obj->value
] = $obj->value
;
156 else if ($obj->name
== "device-uri")
158 $this->device_uri
= $obj->value
;
160 else if ($obj->name
== "queued-job-count")
162 $this->queued_job_count
= $obj->value
;
164 else if ($obj->name
== "printer-is-accepting-jobs")
166 $this->accepting_jobs
= $obj->value ?
TRUE : FALSE;
168 else if ($obj->name
== "color-supported")
170 $this->color_supported
= $obj->value ?
TRUE : FALSE;
172 else if ($obj->name
== "pages-per-minute")
174 $this->pages_per_minute
= $obj->value
;
176 else if ($obj->name
== "operations-supported")
178 $this->operations_supported
["O$obj->value"] = $obj->value
;
180 else if ($obj->name
== "orientation-requested-supported")
182 $this->orientation_requested_supported
["O$obj->value"] = $obj->value
;
184 else if ($obj->name
== "orientation-requested-default")
186 $this->orientation_requested_default
= $obj->value
;
188 else if ($obj->name
== "finishings-supported")
190 $this->finishings_supported
["F$obj->value"] = $obj->value
;
192 else if ($obj->name
== "finishings-default")
194 $this->finishings_default
= $obj->value
;
196 else if ($obj->name
== "number-up-supported")
198 $this->number_up_supported
["N$obj->value"] = $obj->value
;
200 else if ($obj->name
== "number-up-default")
202 $this->number_up_default
= $obj->value
;
204 else if ($obj->name
== "printer-type")
206 $this->printer_type
= $obj->value
;
208 else if ($obj->name
== "multiple-document-jobs-suppoted")
210 $this->multiple_document_jobs_supported
= $obj->value ?
TRUE : FALSE;
212 else if ($obj->name
== "multiple-operation-time-out")
214 $this->multiple_operation_time_out
= $obj->value
;
216 else if ($obj->name
== "job-priority-supported")
218 $this->job_priority_supported_upper
= $obj->value
;
220 else if ($obj->name
== "job-priority-default")
222 $this->job_priority_default
= $obj->value
;
224 else if ($obj->name
== "copies-supported")
226 $tmpa = explode("-",$obj->value
);
227 if (count($tmpa) > 1)
229 $this->copies_supported_lower
= $tmpa[0];
230 $this->copies_supported_upper
= $tmpa[1];
232 else if (count($tmpa) == 1)
234 $this->copies_supported_lower
= $tmpa[0];
235 $this->copies_supported_upper
= $tmpa[0];
238 else if ($obj->name
== "copies-default")
240 $this->copies_supported_default
= $obj->value
;
242 else if ($obj->name
== "page-ranges-supported")
244 $this->page_ranges_supported
= $obj->value ?
TRUE : FALSE;
246 else if ($obj->name
== "media-default")
248 $this->media_default
= $obj->value
;
250 else if ($obj->name
== "media-supported")
252 $this->media_supported
[$obj->value
] = $obj->value
;
257 } // End of getAttributes
260 } // End of CupsPrinter class
266 // Get the printer / destination list.
268 function phpcups_getDestList()
270 $return_value = Array();
273 // Get the destination objects array.
275 $p_arr = cups_get_dest_list();
277 if (!IS_ARRAY($p_arr))
284 while ($p_obj = current($p_arr))
289 // Get the options for the current destination.
291 $o_arr = cups_get_dest_options("localhost",$p_obj->name
,$p_obj->instance
);
293 $p = new CupsPrinter();
294 $p->printer_name
= $p_obj->name
;
295 $p->printer_instance
= $p_obj->instance
;
296 $p->is_default
= $p_obj->is_default
;
297 $p->printer_options
= $o_arr;
300 $return_value[$p->printer_name
] = $p;
302 return($return_value);
304 } // End of phpcups_getDestList()