21 if ( !is_object($cache) ){
22 import(
'Dataface/OutputCache.php');
30 $this->ifModifiedSince[$type][$name] = $timestamp;
34 if ( isset($this->ifModifiedSince[$type][$name]) ) {
35 return $this->ifModifiedSince[$type][$name];
43 if ( $since < $timestamp ){
58 if ( $time == null )
return true;
60 return $cache->isModified($time, $name);
69 $class = get_class($arg);
70 if ( is_array($arg) ){
73 eval(
'$result = $this->toXML_'.$class.
'($arg);');
78 trigger_error(
"Not implemented yet.", E_USER_ERROR);
85 $this->required_tables_loaded[$name] =
true;
89 if ( !isset($this->required_tables_loaded[$name]) ) $this->required_tables_loaded[$name] =
false;
94 foreach ( $this->required_tables_loaded as
$tablename=>$loaded){
101 return implode(
"\n",
$out);
109 list(
$tablename, $tablelabel) = array_map(array(&$this,
'xmlentities'), array(
$table->tablename,
$table->getLabel()));
113 $out[] =
"<$ns:table id=\"tables.{$tablename}\" name=\"$tablename\" http:status-code=\"304\" http:status-message=\"Not Modified\"></$ns:table>";
118 <
$ns:table
id=
"tables.{$tablename}" name=
"$tablename" label=
"$tablelabel">
120 $perms =
$table->getPermissions();
122 foreach ($perms as $pname=>$pval){
123 $pname = str_replace(
' ',
'_', $pname);
124 $patts[] = $pns.
':'.$pname.
'="'.$pval.
'"';
126 $patts = implode(
' ',$patts);
127 $out[] =
"\t<$ns:permissions $patts/>";
130 foreach (
$field as $key=>$val){
131 if ( is_scalar($val) ){
132 $atts[] = $ans.
':'.$key.
'="'.$this->
xmlentities($val).
'"';
135 $atts = implode(
' ', $atts);
136 $out[] =
"\t<$ns:field id=\"tables.{$tablename}.fields.{$field['name']}\" $atts>";
138 $fperms =
$table->getPermissions(array(
'field'=>
$field[
'name']));
140 foreach ($fperms as $fpkey=>$fpval){
141 $fpkey = str_replace(
' ',
'_', $fpkey);
142 $fpatts[] = $ans.
':'.$fpkey.
'="'.$fpval.
'"';
144 $fpatts = implode(
' ',$fpatts);
145 $out[] =
"\t\t<$ns:permissions $fpatts/>";
147 $widget =
$field[
'widget'];
149 foreach ($widget as $wkey=>$wval){
151 if ( is_scalar($wval) ){
152 $watts[] = $ans.
':'.$wkey.
'="'.$this->
xmlentities($wval).
'"';
156 $watts = implode(
' ',$watts);
157 $out[] =
"\t\t<$ns:widget $watts>";
158 if ( isset($widget[
'atts']) ){
160 foreach ($widget[
'atts'] as $akey=>$aval){
161 if (is_scalar($aval) ){
162 $aatts[] = $ans.
':'.$akey.
'="'.$this->
xmlentities($aval).
'"';
167 $aatts = implode(
' ',$aatts);
168 $out[] =
"\t\t\t<$ns:html_atts $aatts />";
170 $out[] =
"\t\t</$ns:widget>";
171 $out[] =
"\t</$ns:field>";
175 foreach (
$table->relationships() as $relationship){
178 $out[] =
"</$ns:table>";
181 return implode(
"\n",
$out);
190 $name = $this->
xmlentities($relationship->getName());
191 foreach ($relationship->_schema as $key=>$val){
192 if ( is_scalar($val) ){
193 $atts[] = $ans.
':'.$key.
'="'.$this->
xmlentities($val).
'"';
196 $sourceTable =& $relationship->getSourceTable();
198 $atts = implode(
' ',$atts);
199 $out[] =
"\t<$ns:relationship id=\"tables.{$tablename}.relationships.{$name}\" name=\"$name\" $atts />";
200 return implode(
"\n",
$out);
210 $out[] =
"\t\t<$ns:record id=\"".$this->xmlentities($record->getId()).
"\" table=\"".$record->_table->tablename.
"\">";
212 $perms = $record->getPermissions();
214 foreach ($perms as $pkey=>$pval){
215 $pkey = str_replace(
' ',
'_', $pkey);
216 $patts[] =
"$pns:$pkey=\"".$this->xmlentities($pval).
"\"";
218 $patts = implode(
' ', $patts);
219 $out[] =
"\t\t\t<$ns:permissions $patts/>";
221 foreach ( $record->_table->fields() as
$field){
222 $value = $record->val(
$field[
'name']);
223 $dispVal = $record->display(
$field[
'name']);
226 $out[] =
"\t\t\t<$ns:record_value field=\"".$this->xmlentities(
$field[
'name']).
"\">";
227 $perms = $record->getPermissions(array(
'field'=>
$field[
'name']));
229 foreach ($perms as $pkey=>$pval){
230 $pkey = str_replace(
' ',
'_', $pkey);
231 $patts[] =
"$pns:$pkey=\"".$this->xmlentities($pval).
"\"";
233 $patts = implode(
' ', $patts);
234 $out[] =
"\t\t\t\t<$ns:permissions $patts/>";
235 if ( $record->_table->isDate(
$field[
'name']) ){
239 if ( @
$field[
'vocabulary'] ) $valuelist =& $record->_table->getValuelist(
$field[
'vocabulary']);
241 if ( !is_array($value) ) $value = array($value);
243 foreach ($value as $vkey=>$vval){
248 if ( isset($valuelist) and isset($valuelist[$vval]) ){
250 $vval = $valuelist[$vval];
252 $out[] =
"\t\t\t\t<$ns:value key=\"".$this->xmlentities($vkey).
"\">".$this->
xmlentities($vval).
"</$ns:value>";
256 $out[] =
"\t\t\t\t<$ns:display_value>".$this->xmlentities($dispVal).
"</$ns:display_value>";
257 $out[] =
"\t\t\t\t<$ns:html_value>".$this->xmlentities( $record->htmlValue(
$field[
'name'])).
"</$ns:html_value>";
258 $out[] =
"\t\t\t</$ns:record_value>";
263 $out[] =
"\t\t</$ns:record>";
281 foreach ($table->fields() as
$field){
288 $it =& $tool->iterator();
289 while ($it->hasNext()){
294 $out[] =
"</$ns:results>";
295 return implode(
"\n",
$out);
302 $allowed_fields = array(
'_auth/auth_type'=>
true);
303 if ( isset(
$app->_conf[
"xml_public_info"]) ){
304 $allowed_fields = array_merge(
$app->_conf[
'xml_public_info'], $allowed_fields);
307 foreach ($allowed_fields as $key=>$value){
308 $path = explode(
'/', $key);
309 if ( count(
$path) == 1 ){
318 $out[] =
"<$ns:config>";
319 foreach (
$app->_conf as $key=>$value){
320 if ( !@$af[$key] )
continue;
321 $out[] =
"\t<$ns:param><$ns:key>".$this->xmlentities($key).
"</$ns:key>";
322 if ( is_scalar($value) ){
323 $out[] =
"\t\t<$ns:value>".$this->xmlentities($value).
"</$ns:value>";
325 $out[] =
"\t\t<$ns:value>";
326 foreach ($value as $vkey=>$vval){
327 if ( !@$af[$key][$vkey] )
continue;
328 if ( strcasecmp($vkey,
'password') === 0 )
continue;
329 $out[] =
"\t\t\t<$ns:param><$ns:key>".$this->xmlentities($vkey).
"</$ns:key><$ns:value>".$this->
xmlentities($vval).
"</$ns:value></$ns:param>";
331 $out[] =
"\t\t</$ns:value>";
335 $out[] =
"\t</$ns:param>";
337 $out[] =
"</$ns:config>";
338 return implode(
"\n",
$out);
347 header(
'Content-type: text/xml; charset='.
$app->_conf[
'oe']);
348 $out[] =
"<?xml version=\"1.0\"?>";
349 $out[] =
"<dataface_document xmlns:$ns=\"http://www.weblite.ca/dataface/2007/df\" xmlns:$ans=\"http://www.weblite.ca/dataface/2007/dfatts\" xmlns:$pns=\"http://www.weblite.ca/dataface/2007/dfperms\" xmlns:http=\"http://www.weblite.ca/dataface/2007/http\">";
350 return implode(
"\n",
$out);
360 return str_replace ( array (
'&',
'"',
"'",
'<',
'>',
'' ), array (
'&' ,
'"',
''' ,
'<' ,
'>',
''' ), $string );