Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
freedom_rss.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * RSS syndication on a folder (search, folders, report....)
8  *
9  * @author Anakeen
10  * @version $Id: freedom_rss.php,v 1.11 2009/01/14 13:09:53 jerome Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/freedom_util.php");
18 include_once ("FDL/Lib.Dir.php");
19 
20 function freedom_rss(Action & $action)
21 {
22 
23  $id = GetHttpVars("id", 0);
24  $dhtml = (GetHttpVars("dh", 1) == 1 ? true : false);
25  $action->lay->set("html", $dhtml);
26  $lim = GetHttpVars("lim", 100);
27  $order = GetHttpVars("order");
28 
29  $dbaccess = $action->dbaccess;
30 
31  header('Content-type: text/xml; charset=utf-8');
32 
33  $baseurl = $action->getparam("CORE_EXTERNURL");
34 
35  if (!$action->auth) $addauth = '&authtype=basic';
36  else $addauth = '';
37 
38  $standurl = __xmlentities($action->GetParam("CORE_STANDURL"));
39  $action->lay->set("standurl", $standurl);
40  $action->lay->set("server", substr($baseurl, 0, strrpos($baseurl, '/')));
41 
42  $cssf = getparam("CORE_STANDURL") . "$addauth&app=CORE&action=CORE_CSS&session=" . $action->session->id . "&layout=FDL:RSS.CSS";
43  $action->lay->set("rsscss", $cssf);
44 
45  setlocale(LC_TIME, "C");
46  $rsslink = $baseurl . __xmlentities("?sole=Y$addauth&app=FDL&action=FDL_CARD&latest=Y&id=" . $id);
47  $action->lay->set("rsslink", $rsslink);
48  $action->lay->set("copy", "Copyright 2006 Anakeen");
49  $action->lay->set("lang", substr(getParam("CORE_LANG") , 0, 2));
50  $action->lay->set("datepub", strftime("%a, %d %b %Y %H:%M:%S %z", time()));
51  $action->lay->set("ttl", 60);
52  $action->lay->set("category", "Dynacase documents");
53  $action->lay->set("generator", "Dynacase version " . $action->parent->getParam("VERSION"));
54 
55  $doc = new_Doc($dbaccess, $id);
56  $action->lay->set("lastbuild", strftime("%a, %d %b %Y %H:%M:%S %z", intval($doc->revdate)));
57  // Check right for doc access
58  if ($doc->defDoctype == 'S') $aclctrl = "execute";
59  else $aclctrl = "open";
60  if (($err = $doc->Control($aclctrl)) != "") {
61  $action->log->error($err);
62  return;
63  }
64  $report = false;
65  $tcolshown = array();
66  $items = array();
67  $action->lay->set("icon", $doc->getIcon());
68  if ($doc->doctype != 'S' && $doc->doctype != 'D') {
69 
70  $ldoc = array(
71  getTDoc($dbaccess, $id)
72  );
73  } else {
74 
75  $filter = array();
76  $famid = "";
77  $report = ($doc->fromid == getIdFromName($dbaccess, "REPORT") ? true : false);
78  if (!$order) {
79  if ($doc->getRawValue("REP_IDSORT")) {
80  $order = $doc->getRawValue("REP_IDSORT");
81  $order.= " " . $doc->getRawValue("REP_ORDERSORT");
82  } else $order = "revdate desc";
83  }
84  $ldoc = internalGetDocCollection($dbaccess, $doc->id, 0, $lim, $filter, $action->user->id, "TABLE", $famid, false, $order);
85  }
86  $lattr = array();
87  if ($report) {
88  /**
89  * @var \Dcp\Family\REPORT $tmpdoc
90  */
91  $tmpdoc = createDoc($dbaccess, getIdFromName($dbaccess, "REPORT") , false);
92  $fdoc = createDoc($dbaccess, $doc->getRawValue("SE_FAMID") , false);
93  $lattr = $fdoc->GetNormalAttributes();
94  $tcol1 = array();
95  foreach ($lattr as $k => $v) {
96  $tcol1[$v->id] = array(
97  "colid" => $v->id,
98  "collabel" => $v->getLabel() ,
99  "rightfornumber" => ($v->type == "money") ? "right" : "left"
100  );
101  }
102  $tinternals = $tmpdoc->_getInternals();
103  foreach ($tinternals as $k => $v) {
104  $tcol1[$k] = array(
105  "colid" => $k,
106  "collabel" => $v,
107  "rightfornumber" => "left"
108  );
109  }
110 
111  $tcols = $doc->getMultipleRawValues("REP_IDCOLS");
112  foreach ($tcols as $val) {
113  $tcolshown[$val] = $tcol1[$val];
114  }
115  }
116  // $action->lay->set("rssname", $doc->getTitle()." -".count($ldoc)."-");
117  $action->lay->set("rssname", __xmlentities($doc->getTitle()));
118 
119  $lines = array();
120  foreach ($ldoc as $kdoc => $vdoc) {
121  $zdoc = getDocObject($dbaccess, $vdoc);
122  $descr = '';
123 
124  $items[$zdoc->id] = array(
125  "title" => "",
126  "link" => $baseurl . __xmlentities("?sole=Y$addauth&app=FDL&action=FDL_CARD&id=" . $zdoc->id) ,
127  "descr" => "",
128  "revdate" => strftime("%a, %d %b %Y %H:%M:%S %z", intval($zdoc->revdate)) ,
129  "id" => $zdoc->id,
130  "category" => $zdoc->fromname,
131  "author" => __xmlentities(getMailAddr($zdoc->owner, true)) ,
132  "rssname" => __xmlentities($doc->getTitle()) ,
133  "rsslink" => $rsslink,
134  "report" => $report,
135  );
136  if ($report) {
137  $lines = array();
138  $i = 0;
139  foreach ($tcolshown as $kc => $vc) {
140  if ($zdoc->getRawValue($kc) == "") $lines[] = array(
141  "attr" => $vc["collabel"],
142  "val" => ""
143  );
144  else {
145  switch ($kc) {
146  case "revdate":
147  $cval = strftime("%x %T", $vdoc[$kc]);
148  break;
149 
150  case "state":
151  $cval = _($vdoc[$kc]);
152  break;
153 
154  case "title":
155  $cval = $zdoc->getTitle();
156  break;
157 
158  default:
159  if (isset($lattr[$kc])) {
160  $cval = $zdoc->getHtmlValue($lattr[$kc], $zdoc->getRawValue($kc) , "", false);
161  if ($lattr[$kc]->type == "image") $cval = "<img width=\"30px\" src=\"$cval\">";
162  } else $cval = $zdoc->getPropertyValue($kc);
163  }
164  if ($i == 0) {
165  $items[$zdoc->id]["title"] = __xmlentities(html_entity_decode($cval, ENT_NOQUOTES, 'UTF-8'));
166  $i++;
167  } else {
168  $cval = __xmlentities($cval);
169  $lines[] = array(
170  "attr" => $vc["collabel"],
171  "val" => ($cval)
172  );
173  }
174  }
175  }
176  $action->lay->setBlockData("lines" . $zdoc->id, $lines);
177  } else {
178  $items[$zdoc->id]["descr"] = ($dhtml ? __xmlentities(($zdoc->viewdoc("FDL:VIEWTHUMBCARD"))) : "...");
179  $items[$zdoc->id]["title"] = __xmlentities($zdoc->getTitle());
180  }
181  }
182  $action->lay->setBlockData("Items", $items);
183  $action->lay->set("report", $report);
184 }
185 
186 function __xmlentities($string)
187 {
188  return Doc::htmlEncode($string);
189 }
$s type
Definition: dav.php:73
static htmlEncode($s)
Definition: Class.Doc.php:8765
getTDoc($dbaccess, $id, $sqlfilters=array(), $result=array())
global $action
getMailAddr($userid, $full=false)
Definition: Lib.Common.php:133
__xmlentities($string)
error($msg)
getParam($name, $def="")
must be in core or global type
Definition: Lib.Common.php:193
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
internalGetDocCollection($dbaccess, $dirid, $start="0", $slice="ALL", $sqlfilters=array(), $userid=1, $qtype="LIST", $fromid="", $distinct=false, $orderby="title", $latest=true, $trash="", &$debug=null, $folderRecursiveLevel=2, $join= '',\SearchDoc &$searchDoc=null)
Definition: Lib.Dir.php:428
new_Doc($dbaccess, $id= '', $latest=false)
getParam($name, $def="")
$dbaccess
Definition: checkVault.php:17
getIdFromName($dbaccess, $name)
if($file) if($subject==""&&$file) if($subject=="") $err
getDocObject($dbaccess, $v, $k=0)
← centre documentaire © anakeen