Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
helppage.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * return dynamic enum from family parameters
8  * @return string
9  */
10 function helppageenumlang()
11 {
12 
14 
15  $doc = new_Doc($dbaccess, 'HELPPAGE');
16  if ($doc->isAlive()) {
17  $all_lang_keys = $doc->rawValueToArray($doc->getFamilyParameterValue('help_p_lang_key'));
18  $all_lang_texts = $doc->rawValueToArray($doc->getFamilyParameterValue('help_p_lang_name'));
19  $langs = array();
20  foreach ($all_lang_keys as $i => $key) {
21  $langs[] = $key . '|' . $all_lang_texts[$i];
22  }
23  return implode(',', $langs);
24  }
25  return 'fr_FR|' . _('french');
26 }
27 
28 function helppage_editsection(Action & $action, $dbaccess, $docid)
29 {
30 
31  include_once ('FDL/editutil.php');
32  editmode($action);
33 
34  $imageFamily = new_Doc("", "IMAGE");
35  /**
36  * @var \Dcp\Family\HELPPAGE $doc
37  */
39  $action->lay->eset('DOCID', $docid);
40  $action->lay->eset('DOCTITLE', $doc->getTitle());
41 
42  $helps = $doc->getHelpByLang();
43  $langs = $doc->getFamilyLangs();
44 
45  $action->lay->set('JSONLANGS', json_encode($langs));
46 
47  $section_key = GetHttpVars('edit_section_key', '');
48  $action->lay->eset('SECTIONKEY', $section_key);
49 
50  $langitems = array();
51  foreach ($langs as $lang_key => $lang_name) {
52  $langitems[] = array(
53  'LANGKEY' => $lang_key,
54  'LANGISO' => strtolower(substr($lang_key, -2)) ,
55  'LANGNAME' => $lang_name,
56  );
57  }
58 
59  $action->lay->SetBlockData('LEGENDCSSLANGS', $langitems);
60  $action->lay->SetBlockData('LEGENDLANGS', $langitems);
61  $action->lay->SetBlockData('MENULANGS', $langitems);
62 
63  $action->lay->set("CanUploadImage", $imageFamily->hasPermission("create"));
64 }
65 /**
66  * @param NormalAttribute|FieldsetAttribute $oa
67  * @return string
68  */
70 {
71  if ($oa && $oa->fieldSet && $oa->fieldSet->id != \Adoc::HIDDENFIELD) {
72  return helppage_getParentLabel($oa->fieldSet) . $oa->fieldSet->getLabel() . '/';
73  }
74  return '';
75 }
76 // liste des attributs triable d'une famille
77 function helppage_getHelpAttr($famid, $name = "")
78 {
79  $docfam = new DocFam("", $famid);
80  //'lsociety(D,US_SOCIETY):US_IDSOCIETY,US_SOCIETY,
81  $doc = createDoc("", $famid, false);
82 
83  $tr = array();
84  $pattern_name = preg_quote($name, "/");
85 
86  $tinter = array_merge($doc->getFieldAttributes() , $doc->GetNormalAttributes());
87  /*
88  * @var NormalAttribute $v
89  */
90  foreach ($tinter as $k => $v) {
91  if ($v->id === \Adoc::HIDDENFIELD) {
92  continue;
93  }
94  if (($name == "") || (preg_match("/$pattern_name/i", $v->getLabel() , $reg))) {
95 
97  if ($parent) {
98  $dv = sprintf('<b><i>%s</i></b><br/><span>&nbsp;&nbsp;%s (%s)</span>', htmlspecialchars($parent) , htmlspecialchars($v->getLabel()) , htmlspecialchars($v->type));
99  } else {
100  $dv = sprintf('<b><i>%s</i></b> (%s)', htmlspecialchars($v->getLabel()) , htmlspecialchars($v->type));
101  }
102 
103  $tr[] = array(
104  $dv,
105  $v->id,
106  $v->getLabel() ,
107  $v->getOption('sortable')
108  );
109  }
110  }
111 
112  return $tr;
113 }
114 
115 function helppage_edithelp(Action & $action, $dbaccess, $docid)
116 {
117 
118  include_once ('FDL/editutil.php');
119  editmode($action);
120  /**
121  * @var \Dcp\Family\HELPPAGE $doc
122  */
124  $action->lay->eset('DOCID', $docid);
125  $action->lay->eset('DOCTITLE', $doc->getTitle());
126 
127  $helps = $doc->getHelpByLang();
128  $langs = $doc->getFamilyLangs();
129 
130  $action->lay->eset('JSONLANGS', json_encode($langs));
131  $helplangs = array();
132  $index = 0;
133  $displayed = false;
134  foreach ($langs as $lang_key => $lang_name) {
135  $item = array();
136  $item['LANGKEY'] = $lang_key;
137  $item['LANGISO'] = strtolower(substr($lang_key, -2));
138  $item['LANGNAME'] = $lang_name;
139  $item['LANGDISPLAY'] = 'none';
140  $oa1 = $doc->getAttribute('help_name');
141  $oa2 = $doc->getAttribute('help_description');
142  if (array_key_exists($lang_key, $helps)) {
143  if (!$displayed) {
144  $item['LANGDISPLAY'] = 'block';
145  $displayed = true;
146  }
147  $item['INPUTLANGNAME'] = getHtmlInput($doc, $oa1, $helps[$lang_key]['help_name'], $index, '', true);
148  $item['INPUTLANGDESCRIPTION'] = getHtmlInput($doc, $oa2, $helps[$lang_key]['help_description'], $index, '', true);
149  } else {
150  $item['INPUTLANGNAME'] = getHtmlInput($doc, $oa1, '', $index, '', true);
151  $item['INPUTLANGDESCRIPTION'] = getHtmlInput($doc, $oa2, '', $index, '', true);
152  }
153  $index++;
154  $helplangs[] = $item;
155  }
156  if (!empty($helplangs) && !$displayed) {
157  $helplangs[0]['LANGDISPLAY'] = 'block';
158  }
159  $action->lay->SetBlockData('HELPLANGS1', $helplangs);
160  $action->lay->SetBlockData('HELPLANGS2', $helplangs);
161 }
global $action
helppage_getParentLabel($oa)
Definition: helppage.php:69
$docid
Definition: cleanFamily.php:13
getHtmlInput(&$doc, &$oattr, $value, $index="", $jsevent="", $notd=false)
Definition: editutil.php:30
helppageenumlang()
Definition: helppage.php:10
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
getDbAccess()
Definition: Lib.Common.php:368
helppage_getHelpAttr($famid, $name="")
Definition: helppage.php:77
new_Doc($dbaccess, $id= '', $latest=false)
editmode(Action &$action)
Definition: editutil.php:41
$dbaccess
Definition: checkVault.php:17
← centre documentaire © anakeen