66 public function selectWebsite($selected =
'', $htmlname =
'exportmodelid', $useempty = 0)
70 $sql =
"SELECT rowid, ref";
71 $sql .=
" FROM ".$this->db->prefix().
"website";
72 $sql .=
" WHERE 1 = 1";
73 $sql .=
" ORDER BY rowid";
74 $result = $this->db->query($sql);
76 $out .=
'<select class="flat minwidth100" name="'.$htmlname.
'" id="'.$htmlname.
'">';
78 $out .=
'<option value="-1"> </option>';
81 $num = $this->db->num_rows($result);
84 $obj = $this->db->fetch_object($result);
85 if ($selected == $obj->rowid) {
86 $out .=
'<option value="'.$obj->rowid.
'" selected>';
88 $out .=
'<option value="'.$obj->rowid.
'">';
114 public function selectTypeOfContainer($htmlname, $selected =
'', $useempty = 0, $moreattrib =
'', $addjscombo = 0, $morecss =
'minwidth200')
116 global $langs,
$conf, $user;
118 $langs->load(
"admin");
122 $sql =
"SELECT rowid, code, label, entity, position, typecontainer";
123 $sql .=
" FROM ".$this->db->prefix().
'c_type_container';
124 $sql .=
" WHERE active = 1 AND entity IN (".getEntity(
'c_type_container').
")";
125 $sql .=
" ORDER BY position ASC, typecontainer DESC, label ASC";
127 dol_syslog(get_class($this).
"::selectTypeOfContainer", LOG_DEBUG);
129 $result = $this->db->query($sql);
131 $num = $this->db->num_rows($result);
134 $out .=
'<select id="select'.$htmlname.
'" class="flat selectTypeOfContainer'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
135 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
136 $out .=
'<option value="-1"> </option>';
139 $lasttypecontainer =
'';
141 $obj = $this->db->fetch_object($result);
148 if ($obj->typecontainer != $lasttypecontainer) {
149 $out .=
'<option value="0" disabled>--- ';
150 $transcodecontainer = ucfirst($obj->typecontainer);
151 if ($obj->typecontainer ==
'page') {
152 $transcodecontainer =
'CompletePage';
153 } elseif ($obj->typecontainer ==
'container') {
154 $transcodecontainer =
'PortionOfPage';
155 } elseif ($obj->typecontainer ==
'service') {
156 $transcodecontainer =
'ServiceComponent';
158 $out .= $langs->trans($transcodecontainer);
159 $out .=
' ---</option>';
160 $lasttypecontainer = $obj->typecontainer;
163 if ($selected == $obj->rowid || $selected == $obj->code) {
164 $out .=
'<option value="'.$obj->code.
'" selected>';
166 $out .=
'<option value="'.$obj->code.
'">';
168 $out .= $langs->trans($obj->label);
171 $conf->cache[
'type_of_container'][$obj->code] = $obj->label;
177 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
184 $out .= $langs->trans(
"NoTypeOfPagePleaseEditDictionary");
187 $this->error = $this->db->lasterror();
204 public function selectSampleOfContainer($htmlname, $selected =
'', $useempty = 0, $moreattrib =
'', $addjscombo = 0, $morecss =
'minwidth200')
206 global $langs, $user;
208 $langs->load(
"admin");
210 $listofsamples =
dol_dir_list(DOL_DOCUMENT_ROOT.
'/website/samples',
'files', 0,
'^page-sample-.*\.html$');
211 $arrayofsamples = array();
212 $arrayofsamples[
'empty'] =
'EmptyPage';
213 foreach ($listofsamples as $sample) {
215 if (preg_match(
'/^page-sample-(.*)\.html$/', $sample[
'name'], $reg)) {
217 $labelkey = ucfirst($key);
218 if ($key ==
'empty') {
219 $labelkey =
'EmptyPage';
221 $arrayofsamples[$key] = $labelkey;
226 $out .=
'<select id="select'.$htmlname.
'" class="selectSampleOfContainer'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
228 if ($useempty == 1 || $useempty == 2) {
229 $out .=
'<option value="-1"> </option>';
232 foreach ($arrayofsamples as $key => $val) {
233 if ($selected == $key) {
234 $out .=
'<option value="'.$key.
'" selected>';
236 $out .=
'<option value="'.$key.
'">';
238 $out .= $langs->trans($val);
264 public function selectContainer($website, $htmlname =
'pageid', $pageid = 0, $showempty = 0, $action =
'', $morecss =
'minwidth200', $excludeids =
null)
266 global
$conf, $langs;
270 $atleastonepage = (is_array($website->lines) && count($website->lines) > 0);
273 if ($atleastonepage && $action !=
'editsource') {
274 $out .=
'<select name="'.$htmlname.
'" id="'.$htmlname.
'" class="maxwidth300'.($morecss ?
' '.$morecss :
'').
'">';
276 $out .=
'<select name="pageidbis" id="pageid" class="maxwidth300'.($morecss ?
' '.$morecss :
'').
'"'.($action ==
'editsource' ?
' disabled="disabled"' :
'').
'>';
279 if ($showempty || !$atleastonepage) {
280 $out .=
'<option class="optiongrey" value="-1">'.(is_numeric($showempty) ?
' ' : $showempty).
'</option>';
288 if ($atleastonepage) {
289 if (empty($pageid) && $action !=
'createcontainer') {
292 foreach ($website->lines as $key => $valpage) {
293 if (empty($firstpageid)) {
294 $firstpageid = $valpage->id;
296 if ($website->fk_default_home && $key == $website->fk_default_home) {
297 $homepageid = $valpage->id;
300 $pageid = $homepageid ? $homepageid : $firstpageid;
303 foreach ($website->lines as $key => $valpage) {
304 if (is_array($excludeids) && count($excludeids) && in_array($valpage->id, $excludeids)) {
308 $valueforoption =
'<span class="opacitymedium">['.$valpage->type_container.
' '.sprintf(
"%03d", $valpage->id).
']</span> ';
309 $valueforoption .= $valpage->pageurl.
' - '.$valpage->title;
310 if ($website->otherlang) {
311 if ($valpage->lang) {
312 $valueforoption .=
' <span class="opacitymedium">('.$valpage->lang.
')</span>';
315 if ($website->fk_default_home && $key == $website->fk_default_home) {
317 $valueforoption .=
' <span class="opacitymedium fas fa-home"></span>';
320 $out .=
'<option value="'.$key.
'"';
321 if ($pageid > 0 && $pageid == $key) {
324 $out .=
' data-html="'.dol_escape_htmltag($valueforoption).
'"';
326 $out .= $valueforoption;
334 if ($atleastonepage && $action !=
'editsource') {
337 $out .=
'<input type="hidden" name="'.$htmlname.
'" value="'.$pageid.
'">';
352 global $user, $langs;
354 $htmlContent = preg_replace(
'/[^a-z0-9_]/',
'', $htmlContent);
356 require_once DOL_DOCUMENT_ROOT.
'/core/lib/emaillayout.lib.php';
358 $listofsamples =
dol_dir_list(DOL_DOCUMENT_ROOT.
'/website/samples',
'files', 0,
'^page-sample-.*\.html$');
359 $arrayofsamples = array();
360 $arrayofsamples[
'empty'] =
'EmptyPage';
361 foreach ($listofsamples as $sample) {
363 if (preg_match(
'/^page-sample-(.*)\.html$/', $sample[
'name'], $reg)) {
365 $labelkey = ucfirst($key);
366 if ($key ==
'empty') {
367 $labelkey =
'EmptyPage';
369 $arrayofsamples[$key] = $labelkey;
372 $out =
'<div id="template-selector" class="template-container hidden">';
375 unset($arrayofsamples[
'dynamiccontent']);
378 $templates = $arrayofsamples;
380 foreach ($templates as $template => $templateFunction) {
381 $substitutionarray = array();
382 $substitutionarray[
'__WEBSITE_CREATED_BY__'] = $user->getFullName($langs);
383 $substitutionarray[
'__WEBSITE_CONTENT__'] = $langs->trans(
"WebpageContent");
384 $substitutionarray[
'__WEBSITE_TITLE1__'] = $langs->trans(
"Title1");
385 $substitutionarray[
'__WEBSITE_TITLE2__'] = $langs->trans(
"Title2");
387 $pathtoTemplateFile = DOL_DOCUMENT_ROOT.
'/website/samples/page-sample-'.
dol_sanitizeFileName($template).
'.html';
388 $contentHtml = file_exists($pathtoTemplateFile) ?
make_substitutions(@file_get_contents($pathtoTemplateFile), $substitutionarray) :
'';
390 $out .=
'<div class="template-option" data-template="'.$template.
'" data-content="'.htmlentities($contentHtml).
'">';
391 $out .=
'<img class="maillayout" alt="'.$template.
'" src="'.DOL_URL_ROOT.
'/theme/common/maillayout/'.$template.
'.png" />';
392 $out .=
'<span class="template-option-text">'.($template !=
'text' ? ucfirst($template) : ucfirst($templateFunction)).
'</span>';
395 $out .=
'<input type="hidden" name="sample" value="" />';
398 $out .=
'<script type="text/javascript">
399 $(document).ready(function() {
400 $(".template-option").click(function() {
401 console.log("We choose a layout for website, we fill the field \''.$htmlContent.
'\'");
403 $(".
template-option
").removeClass("selected
");
404 $(this).addClass("selected
");
406 var template = $(this).data("template");
407 var contentHtml = $(this).data("content
");
409 jQuery("#
'.$htmlContent.'").val(contentHtml);
410 //jQuery("#
'.$htmlContent.'preview
").val(contentHtml);
412 var editorInstance = CKEDITOR.instances.'.$htmlContent.';
413 if (editorInstance) {
414 editorInstance.setData(contentHtml);
416 //var editorInstance = CKEDITOR.instances.'.$htmlContent.'preview;
417 //if (editorInstance) {
418 // editorInstance.setData(contentHtml);
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...