Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.PostIt.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * templates for postit
8  */
9 namespace Dcp\Core;
11 {
12 
13  var $defaultview = "FDL:VIEWPOSTIT:T";
14  var $defaultedit = "FDL:EDITPOSTIT:T";
15  // -----------------------------------
16 
17  /**
18  * @templateController special view postit
19  * @param string $target
20  * @param bool $ulink
21  * @param bool $abstract
22  */
23  function viewpostit($target = "_self", $ulink = true, $abstract = false)
24  {
25  // -----------------------------------
26  $tcomment = $this->getMultipleRawValues("PIT_COM");
27  $tuser = $this->getMultipleRawValues("PIT_USER");
28  $tdate = $this->getMultipleRawValues("PIT_DATE");
29  $tcolor = $this->getMultipleRawValues("PIT_COLOR");
30 
31  $nbcar = strlen($this->getRawValue("PIT_COM"));
32  if ($nbcar < 60) $fontsize = 120;
33  elseif ($nbcar < 200) $fontsize = 100;
34  else $fontsize = 80;
35  $tlaycomment = array();
36  foreach ($tcomment as $k => $v) {
37  $tlaycomment[] = array(
38  "comments" => $this->getHtmlValue($this->getAttribute('PIT_COM') , $v, '_blank') ,
39  "user" => str_replace(array(
40  '[',
41  ']'
42  ) , array(
43  '&#91;',
44  '&#93;'
45  ) , htmlspecialchars($tuser[$k], ENT_QUOTES)) ,
46  "date" => htmlspecialchars(stringDateToLocaleDate($tdate[$k]) , ENT_QUOTES) ,
47  "color" => htmlspecialchars($tcolor[$k], ENT_QUOTES)
48  );
49  }
50 
51  $this->lay->rSet("EMPTY", (bool)(count($tcomment) == 0));
52  $this->lay->rSet("fontsize", (int)$fontsize);
53  // Out
54  $this->lay->SetBlockData("TEXT", $tlaycomment);
55  }
56  /**
57  *
58  * @templateController special view postit
59  */
60  function editpostit()
61  {
62  $this->editattr();
63  }
64 
65  function getpostittitle($s)
66  {
67  return sprintf(_("postit of %s") , $this->getTitle($s));
68  }
69  function postStore()
70  {
71  $docid = $this->getRawValue("PIT_IDADOC");
72  if ($docid > 0) {
73  $doc = new_Doc($this->dbaccess, $docid);
74  if (intval($doc->postitid) == 0) {
75  $doc->disableEditControl();
76  $doc->postitid = $this->id;
77  $doc->modify();
78  $doc->enableEditControl();
79  }
80  }
81 
82  $ncom = $this->getRawValue("PIT_NCOM");
83  if ($ncom != "") {
84 
85  $tcom = $this->getMultipleRawValues("PIT_COM");
86  $tdate = $this->getMultipleRawValues("PIT_DATE");
87  $tiduser = $this->getMultipleRawValues("PIT_IDUSER");
88  $tcolor = $this->getMultipleRawValues("PIT_COLOR");
89 
90  foreach ($tcom as $k => $v) {
91  if ($v == "") {
92  unset($tcom[$k]);
93  unset($tdate[$k]);
94  unset($tiduser[$k]);
95  unset($tcolor[$k]);
96  }
97  }
98  $nk = count($tcom);
99  $tcom[$nk] = $ncom;
100  $tdate[$nk] = $this->getDate();
101  $tiduser[$nk] = $this->getUserId();
102  $tcolor[$nk] = $this->getRawValue("PIT_NCOLOR");
103 
104  $this->setValue("PIT_COM", $tcom);
105  $this->setValue("PIT_DATE", $tdate);
106  $this->setValue("PIT_IDUSER", $tiduser);
107  $this->setValue("PIT_COLOR", $tcolor);
108  $this->clearValue("PIT_NCOLOR");
109  $this->clearValue("PIT_NCOM");
110  }
111  }
112 
113  function PostDelete()
114  {
115  $docid = $this->getRawValue("PIT_IDADOC");
116  if ($docid > 0) {
117  $doc = new_Doc($this->dbaccess, $docid);
118  if ($doc->locked == - 1) $doc = new_Doc($this->dbaccess, $doc->getLatestId());
119  if (intval($doc->postitid) > 0) {
120  $doc->disableEditControl();
121  $doc->postitid = 0;
122  $doc->modify();
123  $doc->enableEditControl();
124  }
125  }
126  }
127 
128  function preCreated()
129  {
130 
131  $tcomment = $this->getRawValue("PIT_NCOM");
132  if ($tcomment == "") return (_("no message : post-it creation aborted"));
133  return '';
134  }
135 }
static getUserId()
Definition: Class.Doc.php:8960
& getAttribute($idAttr, &$oa=null, $useMask=true)
Definition: Class.Doc.php:2152
static getDate($daydelta=0, $dayhour="", $daymin="", $getlocale=false)
Definition: Class.Doc.php:8783
stringDateToLocaleDate($fdate, $format= '')
Definition: Lib.Util.php:98
clearValue($attrid)
Definition: Class.Doc.php:4409
if($famId) $s
editattr($withtd=true)
Definition: Class.Doc.php:8129
$docid
Definition: cleanFamily.php:13
setValue($attrid, $value, $index=-1, &$kvalue=null)
Definition: Class.Doc.php:3528
getMultipleRawValues($idAttr, $def="", $index=-1)
Definition: Class.Doc.php:3240
getTitle($id="-1", $def="", $latest=false)
Definition: Class.Doc.php:8715
getHtmlValue($oattr, $value, $target="_self", $htmllink=true, $index=-1, $entities=true, $abstract=false)
Definition: Class.Doc.php:6457
viewpostit($target="_self", $ulink=true, $abstract=false)
new_Doc($dbaccess, $id= '', $latest=false)
getRawValue($idAttr, $def="")
Definition: Class.Doc.php:3117
← centre documentaire © anakeen