Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
editframe.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Generate Layout to edit frame (fieldset)
8  *
9  * @author Anakeen
10  * @version $Id: editframe.php,v 1.27 2008/08/14 09:59:14 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 include_once ("FDL/Class.DocAttr.php");
19 
20 include_once ("FDL/freedom_util.php");
21 include_once ("FDL/editutil.php");
22 // Compute value to be inserted in a specific layout
23 // -----------------------------------
24 function editframe(Action & $action)
25 {
26  // -----------------------------------
27  // GetAllParameters
28  $docid = $action->getArgument("id", 0);
29  $classid = $action->getArgument("classid");
30  $frameid = strtolower($action->getArgument("frameid"));
31  $vid = $action->getArgument("vid"); // special controlled view
32  // Set the globals elements
33  $dbaccess = $action->dbaccess;
34 
35  if ($docid == 0) {
36  $doc = createDoc($dbaccess, $classid);
37  if (fdl_setHttpVars($doc)) $doc->refresh();
38  } else $doc = new_Doc($dbaccess, $docid);
39 
40  if (($vid != "") && ($doc->cvid > 0)) {
41  /**
42  * special controled view
43  * @var CVDoc $cvdoc
44  */
45  $cvdoc = new_Doc($dbaccess, $doc->cvid);
46  $tview = $cvdoc->getView($vid);
47  if ($tview) $doc->setMask($tview["CV_MSKID"]);
48  }
49 
50  $listattr = $doc->GetNormalAttributes();
51 
52  if ($action->getArgument("viewconstraint") == "Y") { // from modcard function if constraint error
53  include_once ("FDL/modcard.php");
54  setPostVars($doc); // HTTP VARS comes from previous edition
55 
56  }
57 
58  $help = $doc->getHelpPage();
59 
60  $thval = array();
61  $tval = array();
62 
63  $foa = $doc->getAttribute($frameid);
64  if (!$foa) $action->exitError(sprintf("attribute %s not found", $frameid));
65  if ($foa->getOption("vlabel") == "none") $action->lay->set("flabel", '');
66  else $action->lay->set("flabel", mb_ucfirst($foa->getLabel()));
67  $action->lay->set("frameid", $foa->id);
68 
69  foreach ($listattr as $k => $v) {
70  /*
71  * @var NormalAttribute $v
72  */
73  if (($v->fieldSet->id != $frameid)) continue;
74  if ($v->inArray()) continue;
75  if ($v->mvisibility == "I") continue; // not editable
76  $action->lay->set("ehelp", ($help->isAlive()) ? $help->getAttributeHelpUrl($v->fieldSet->id) : false);
77  $action->lay->set("ehelpid", ($help->isAlive()) ? $help->id : false);
78  //------------------------------
79  // Set the table value elements
80  $value = chop($doc->getRawValue($v->id));
81  if ($docid == 0) {
82  $value = $doc->GetValueMethod($value); // execute method for default values
83 
84  }
85  if (($v->mvisibility == "H") || ($v->mvisibility == "R")) {
86 
87  $thval[$k]["avalue"] = getHtmlInput($doc, $v, $value);
88  // special case for hidden values
89 
90  } else {
91  $tval[$k]["alabel"] = $v->getLabel();
92  if ($v->needed) $tval[$k]["labelclass"] = "FREEDOMLabelNeeded";
93  else $tval[$k]["labelclass"] = "FREEDOMLabel";
94  $tval[$k]["avalue"] = getHtmlInput($doc, $v, $value);
95 
96  $vlabel = $v->getOption("vlabel");
97  $tval[$k]["winput"] = ($v->type == "array") ? "1%" : "30%"; // width
98  $tval[$k]["TESTARRAY"] = (($v->type == "array") || (($v->type == "htmltext") && ($vlabel != 'left')) || ($vlabel == 'up') || ($vlabel == 'none'));
99  $tval[$k]["viewlabel"] = (($v->type != "array") && ($vlabel != 'none'));
100  $tval[$k]["aehelp"] = ($help->isAlive()) ? $help->getAttributeHelpUrl($v->id) : false;
101  $tval[$k]["aehelpid"] = ($help->isAlive()) ? $help->id : false;
102  }
103  }
104  $action->lay->setBlockData("FVALUES", $tval);
105  $action->lay->setBlockData("FHIDDENS", $thval);
106  if ((count($tval) + count($thval)) > 0) {
107 
108  $action->lay->setBlockData("FRAME", array(
109  array(
110  "bou"
111  )
112  ));
113  }
114 }
global $action
fdl_setHttpVars(&$doc)
Definition: editcard.php:381
setPostVars(Doc &$doc, &$info=array())
Definition: modcard.php:259
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
getHtmlInput(&$doc, &$oattr, $value, $index="", $jsevent="", $notd=false)
Definition: editutil.php:30
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
mb_ucfirst($s)
Definition: Lib.Common.php:105
new_Doc($dbaccess, $id= '', $latest=false)
static getArgument($k, $def= '')
$dbaccess
Definition: checkVault.php:17
$value
← centre documentaire © anakeen