62 public function selectWebsite($selected =
'', $htmlname =
'exportmodelid', $useempty = 0)
66 $sql =
"SELECT rowid, ref";
67 $sql .=
" FROM ".$this->db->prefix().
"website";
68 $sql .=
" WHERE 1 = 1";
69 $sql .=
" ORDER BY rowid";
70 $result = $this->db->query($sql);
72 $out .=
'<select class="flat minwidth100" name="'.$htmlname.
'" id="'.$htmlname.
'">';
74 $out .=
'<option value="-1"> </option>';
77 $num = $this->db->num_rows($result);
80 $obj = $this->db->fetch_object($result);
81 if ($selected == $obj->rowid) {
82 $out .=
'<option value="'.$obj->rowid.
'" selected>';
84 $out .=
'<option value="'.$obj->rowid.
'">';
110 public function selectTypeOfContainer($htmlname, $selected =
'', $useempty = 0, $moreattrib =
'', $addjscombo = 0, $morecss =
'minwidth200')
112 global $langs, $conf, $user;
114 $langs->load(
"admin");
118 $sql =
"SELECT rowid, code, label, entity, position, typecontainer";
119 $sql .=
" FROM ".$this->db->prefix().
'c_type_container';
120 $sql .=
" WHERE active = 1 AND entity IN (".getEntity(
'c_type_container').
")";
121 $sql .=
" ORDER BY position ASC, typecontainer DESC, label ASC";
123 dol_syslog(get_class($this).
"::selectTypeOfContainer", LOG_DEBUG);
125 $result = $this->db->query($sql);
127 $num = $this->db->num_rows($result);
130 $out .=
'<select id="select'.$htmlname.
'" class="flat selectTypeOfContainer'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
131 if ($useempty == 1 || ($useempty == 2 &&
$num > 1)) {
132 $out .=
'<option value="-1"> </option>';
135 $lasttypecontainer =
'';
137 $obj = $this->db->fetch_object($result);
144 if ($obj->typecontainer != $lasttypecontainer) {
145 $out .=
'<option value="0" disabled>--- ';
146 $transcodecontainer = ucfirst($obj->typecontainer);
147 if ($obj->typecontainer ==
'page') {
148 $transcodecontainer =
'CompletePage';
149 } elseif ($obj->typecontainer ==
'container') {
150 $transcodecontainer =
'PortionOfPage';
151 } elseif ($obj->typecontainer ==
'service') {
152 $transcodecontainer =
'ServiceComponent';
154 $out .= $langs->trans($transcodecontainer);
155 $out .=
' ---</option>';
156 $lasttypecontainer = $obj->typecontainer;
159 if ($selected == $obj->rowid || $selected == $obj->code) {
160 $out .=
'<option value="'.$obj->code.
'" selected>';
162 $out .=
'<option value="'.$obj->code.
'">';
164 $out .= $langs->trans($obj->label);
167 $conf->cache[
'type_of_container'][$obj->code] = $obj->label;
173 $out .=
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
180 $out .= $langs->trans(
"NoTypeOfPagePleaseEditDictionary");
183 $this->error = $this->db->lasterror();
200 public function selectSampleOfContainer($htmlname, $selected =
'', $useempty = 0, $moreattrib =
'', $addjscombo = 0, $morecss =
'minwidth200')
202 global $langs, $user;
204 $langs->load(
"admin");
206 $listofsamples =
dol_dir_list(DOL_DOCUMENT_ROOT.
'/website/samples',
'files', 0,
'^page-sample-.*\.html$');
207 $arrayofsamples = array();
208 $arrayofsamples[
'empty'] =
'EmptyPage';
209 foreach ($listofsamples as $sample) {
211 if (preg_match(
'/^page-sample-(.*)\.html$/', $sample[
'name'], $reg)) {
213 $labelkey = ucfirst($key);
214 if ($key ==
'empty') {
215 $labelkey =
'EmptyPage';
217 $arrayofsamples[$key] = $labelkey;
222 $out .=
'<select id="select'.$htmlname.
'" class="selectSampleOfContainer'.($morecss ?
' '.$morecss :
'').
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
224 if ($useempty == 1 || $useempty == 2) {
225 $out .=
'<option value="-1"> </option>';
228 foreach ($arrayofsamples as $key => $val) {
229 if ($selected == $key) {
230 $out .=
'<option value="'.$key.
'" selected>';
232 $out .=
'<option value="'.$key.
'">';
234 $out .= $langs->trans($val);
260 public function selectContainer($website, $htmlname =
'pageid', $pageid = 0, $showempty = 0, $action =
'', $morecss =
'minwidth200', $excludeids =
null)
262 global $conf, $langs;
266 $atleastonepage = (is_array($website->lines) && count($website->lines) > 0);
269 if ($atleastonepage && $action !=
'editsource') {
270 $out .=
'<select name="'.$htmlname.
'" id="'.$htmlname.
'" class="maxwidth300'.($morecss ?
' '.$morecss :
'').
'">';
272 $out .=
'<select name="pageidbis" id="pageid" class="maxwidth300'.($morecss ?
' '.$morecss :
'').
'"'.($action ==
'editsource' ?
' disabled="disabled"' :
'').
'>';
275 if ($showempty || !$atleastonepage) {
276 $out .=
'<option class="optiongrey" value="-1">'.(is_numeric($showempty) ?
' ' : $showempty).
'</option>';
284 if ($atleastonepage) {
285 if (empty($pageid) && $action !=
'createcontainer') {
288 foreach ($website->lines as $key => $valpage) {
289 if (empty($firstpageid)) {
290 $firstpageid = $valpage->id;
292 if ($website->fk_default_home && $key == $website->fk_default_home) {
293 $homepageid = $valpage->id;
296 $pageid = $homepageid ? $homepageid : $firstpageid;
299 foreach ($website->lines as $key => $valpage) {
300 if (is_array($excludeids) && count($excludeids) && in_array($valpage->id, $excludeids)) {
304 $valueforoption =
'<span class="opacitymedium">['.$valpage->type_container.
' '.sprintf(
"%03d", $valpage->id).
']</span> ';
305 $valueforoption .= $valpage->pageurl.
' - '.$valpage->title;
306 if ($website->otherlang) {
307 if ($valpage->lang) {
308 $valueforoption .=
' <span class="opacitymedium">('.$valpage->lang.
')</span>';
311 if ($website->fk_default_home && $key == $website->fk_default_home) {
313 $valueforoption .=
' <span class="opacitymedium fas fa-home"></span>';
316 $out .=
'<option value="'.$key.
'"';
317 if ($pageid > 0 && $pageid == $key) {
320 $out .=
' data-html="'.dol_escape_htmltag($valueforoption).
'"';
322 $out .= $valueforoption;
330 if ($atleastonepage && $action !=
'editsource') {
333 $out .=
'<input type="hidden" name="'.$htmlname.
'" value="'.$pageid.
'">';
348 global $user, $langs;
350 $htmlContent = preg_replace(
'/[^a-z0-9_]/',
'', $htmlContent);
352 require_once DOL_DOCUMENT_ROOT.
'/core/lib/emaillayout.lib.php';
354 $listofsamples =
dol_dir_list(DOL_DOCUMENT_ROOT.
'/website/samples',
'files', 0,
'^page-sample-.*\.html$');
355 $arrayofsamples = array();
356 $arrayofsamples[
'empty'] =
'EmptyPage';
357 foreach ($listofsamples as $sample) {
359 if (preg_match(
'/^page-sample-(.*)\.html$/', $sample[
'name'], $reg)) {
361 $labelkey = ucfirst($key);
362 if ($key ==
'empty') {
363 $labelkey =
'EmptyPage';
365 $arrayofsamples[$key] = $labelkey;
368 $out =
'<div id="template-selector" class="template-container hidden">';
371 unset($arrayofsamples[
'dynamiccontent']);
372 unset($arrayofsamples[
'news']);
374 $templates = $arrayofsamples;
376 foreach ($templates as $template => $templateFunction) {
377 $substitutionarray = array();
378 $substitutionarray[
'__WEBSITE_CREATED_BY__'] = $user->getFullName($langs);
379 $substitutionarray[
'__WEBSITE_CONTENT__'] = $langs->trans(
"WebpageContent");
380 $substitutionarray[
'__WEBSITE_TITLE1__'] = $langs->trans(
"Title1");
381 $substitutionarray[
'__WEBSITE_TITLE2__'] = $langs->trans(
"Title2");
383 $pathtoTemplateFile = DOL_DOCUMENT_ROOT.
'/website/samples/page-sample-'.
dol_sanitizeFileName($template).
'.html';
384 $contentHtml = file_exists($pathtoTemplateFile) ?
make_substitutions(@file_get_contents($pathtoTemplateFile), $substitutionarray) :
'';
386 $out .=
'<div class="template-option" data-template="'.$template.
'" data-content="'.htmlentities($contentHtml).
'">';
387 $out .=
'<img class="maillayout" alt="'.$template.
'" src="'.DOL_URL_ROOT.
'/theme/common/maillayout/'.$template.
'.png" />';
388 $out .=
'<span class="template-option-text">'.($template !=
'text' ? ucfirst($template) : ucfirst($templateFunction)).
'</span>';
391 $out .=
'<input type="hidden" name="sample" value="" />';
394 $out .=
'<script type="text/javascript">
395 $(document).ready(function() {
396 $(".template-option").click(function() {
397 console.log("We choose a layout for website, we fill the field \''.$htmlContent.
'\'");
399 $(".
template-option
").removeClass("selected
");
400 $(this).addClass("selected
");
402 var template = $(this).data("template");
403 var contentHtml = $(this).data("content
");
405 jQuery("#
'.$htmlContent.'").val(contentHtml);
406 //jQuery("#
'.$htmlContent.'preview
").val(contentHtml);
408 var editorInstance = CKEDITOR.instances.'.$htmlContent.';
409 if (editorInstance) {
410 editorInstance.setData(contentHtml);
412 //var editorInstance = CKEDITOR.instances.'.$htmlContent.'preview;
413 //if (editorInstance) {
414 // 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.