31require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
43 public $element =
'websitepage';
48 public $table_element =
'website_page';
53 public $picto =
'file-code';
58 public $fk_element =
'fk_website_page';
63 protected $childtablesoncascade = array(
'categorie_website_page');
93 public $type_container;
123 public $allowed_in_frames;
128 public $keep_history;
143 public $disable_waf =
'NOSCANAUDIOFORINJECTION,NOSCANIFRAMEFORINJECTION,NOSCANOBJECTFORINJECTION';
158 public $grabbed_from;
168 public $fk_user_creat;
173 public $fk_user_modif;
178 public $author_alias;
196 const STATUS_DRAFT = 0;
197 const STATUS_VALIDATED = 1;
228 public $fields = array(
229 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'index' => 1,
'position' => 1,
'comment' =>
'Id'),
230 'pageurl' => array(
'type' =>
'varchar(16)',
'label' =>
'WEBSITE_PAGENAME',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'index' => 1,
'position' => 10,
'searchall' => 1,
'comment' =>
'Ref/alias of page'),
231 'aliasalt' => array(
'type' =>
'varchar(255)',
'label' =>
'AliasAlt',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'index' => 0,
'position' => 11,
'searchall' => 0,
'comment' =>
'Alias alternative of page'),
232 'type_container' => array(
'type' =>
'varchar(16)',
'label' =>
'Type',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'index' => 0,
'position' => 12,
'comment' =>
'Type of container'),
233 'title' => array(
'type' =>
'varchar(255)',
'label' =>
'Label',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'searchall' => 1,
'help' =>
'UseTextBetween5And70Chars'),
234 'description' => array(
'type' =>
'varchar(255)',
'label' =>
'Description',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'searchall' => 1),
235 'image' => array(
'type' =>
'varchar(255)',
'label' =>
'Image',
'enabled' => 1,
'visible' => 1,
'position' => 32,
'searchall' => 0,
'help' =>
'Relative path of media. Used if Type is "blogpost"'),
236 'keywords' => array(
'type' =>
'varchar(255)',
'label' =>
'Keywords',
'enabled' => 1,
'visible' => 1,
'position' => 45,
'searchall' => 0),
237 'lang' => array(
'type' =>
'varchar(6)',
'label' =>
'Lang',
'enabled' => 1,
'notnull' => -1,
'visible' => 1,
'position' => 45,
'searchall' => 0),
239 'fk_website' => array(
'type' =>
'integer',
'label' =>
'WebsiteId',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 40,
'searchall' => 0,
'foreignkey' =>
'websitepage.rowid'),
240 'fk_page' => array(
'type' =>
'integer',
'label' =>
'ParentPageId',
'enabled' => 1,
'visible' => 1,
'notnull' => -1,
'position' => 45,
'searchall' => 0,
'foreignkey' =>
'website.rowid'),
241 'allowed_in_frames' => array(
'type' =>
'integer',
'label' =>
'AllowedInFrames',
'enabled' => 1,
'visible' => -1,
'position' => 48,
'searchall' => 0,
'default' =>
'0'),
242 'keep_history' => array(
'type' =>
'integer',
'label' =>
'NumberOfVersionsToKeepInHistory',
'enabled' => 1,
'visible' => -1,
'position' => 49,
'default' =>
'5',
'help' =>
'NumberOfVersionsToKeepInHistoryHelp'),
243 'htmlheader' => array(
'type' =>
'html',
'label' =>
'HtmlHeader',
'enabled' => 1,
'visible' => 0,
'position' => 50,
'searchall' => 0),
244 'content' => array(
'type' =>
'html',
'label' =>
'Content',
'enabled' => 1,
'visible' => 0,
'position' => 51,
'searchall' => 0),
245 'grabbed_from' => array(
'type' =>
'varchar(255)',
'label' =>
'GrabbedFrom',
'enabled' => 1,
'visible' => 1,
'index' => 1,
'position' => 400,
'comment' =>
'URL page content was grabbed from'),
246 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 500),
247 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 501),
249 'fk_user_creat' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserAuthor',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 510),
250 'author_alias' => array(
'type' =>
'varchar(64)',
'label' =>
'AuthorAlias',
'enabled' => 1,
'visible' => -1,
'index' => 0,
'position' => 511,
'comment' =>
'Author alias'),
251 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'visible' => -1,
'position' => 512),
253 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -1,
'index' => 1,
'position' => 1000,
'notnull' => -1),
254 'object_type' => array(
'type' =>
'varchar(255)',
'label' =>
'ObjectType',
'enabled' => 1,
'visible' => 0,
'position' => 46,
'searchall' => 0,
'help' =>
''),
255 'fk_object' => array(
'type' =>
'varchar(255)',
'label' =>
'ObjectId',
'enabled' => 1,
'visible' => 0,
'position' => 47,
'searchall' => 0,
'help' =>
''),
256 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 510),
266 public function __construct(
DoliDB $db)
279 public function create(
User $user, $notrigger = 0, $phpwrappers = array())
282 $this->keywords =
dol_trunc($this->keywords, 255,
'right',
'utf-8', 1);
283 if ($this->aliasalt) {
284 $this->aliasalt =
','.preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $this->aliasalt)).
',';
287 $this->pageurl = preg_replace(
'/[^a-z0-9\-\_]/i',
'', $this->pageurl);
288 $this->pageurl = preg_replace(
'/\-\-+/',
'-', $this->pageurl);
289 $this->pageurl = preg_replace(
'/^\-/',
'', $this->pageurl);
292 $this->lang = preg_replace(
'/[_-].*$/',
'', trim($this->lang));
295 $dataposted = trim($this->htmlheader);
296 $dataposted = preg_replace(array(
'/<html>\n*/ims',
'/<\/html>\n*/ims'), array(
'',
''), $dataposted);
297 $dataposted = str_replace(
'<?=',
'<?php', $dataposted);
304 $this->error =
'Error: you try to create htmlheader with PHP content inside, this is not allowed.';
305 $this->errors[] = $this->error;
310 if (!$user->hasRight(
'website',
'writephp')) {
313 $contenttocheck = (string) $this->content;
314 if (is_array($phpwrappers)) {
315 foreach ($phpwrappers as $wrapper) {
316 $contenttocheck = str_replace((
string) $wrapper,
'', $contenttocheck);
322 $this->error =
'Error: you try to create a page with PHP content in HTML body without having permissions for that.';
323 $this->errors[] = $this->error;
344 public function fetch(
$id, $website_id =
null, $page =
null, $aliasalt =
null, $translationparentid = 0, $translationparentlang =
'')
350 $sql .=
" t.fk_website,";
351 $sql .=
' t.type_container,';
352 $sql .=
" t.pageurl,";
353 $sql .=
" t.aliasalt,";
355 $sql .=
" t.description,";
357 $sql .=
" t.keywords,";
358 $sql .=
" t.htmlheader,";
359 $sql .=
" t.content,";
361 $sql .=
" t.fk_page,";
362 $sql .=
" t.allowed_in_frames,";
363 $sql .=
" t.keep_history,";
364 $sql .=
" t.status,";
365 $sql .=
" t.grabbed_from,";
366 $sql .=
" t.date_creation,";
367 $sql .=
" t.tms as date_modification,";
368 $sql .=
" t.fk_user_creat,";
369 $sql .=
" t.author_alias,";
370 $sql .=
" t.fk_user_modif,";
371 $sql .=
" t.import_key,";
372 $sql .=
" t.object_type,";
373 $sql .=
" t.fk_object";
374 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
376 $sql .=
' WHERE 1 = 1';
378 $sql .=
' AND t.rowid = '.((int)
$id);
381 $sql .=
' AND t.rowid <> '.((int) abs(
$id));
383 if (
null !== $website_id) {
384 $sql .=
" AND t.fk_website = ".((int) $website_id);
388 $tmppage = explode(
'/', $page);
389 if (!empty($tmppage[1])) {
390 $pagetouse = $tmppage[1];
391 if (strlen($tmppage[0])) {
392 $langtouse = $tmppage[0];
395 $sql .=
" AND t.pageurl = '".$this->db->escape($pagetouse).
"'";
397 $sql .=
" AND t.lang = '".$this->db->escape($langtouse).
"'";
401 $sql .=
" AND (t.aliasalt LIKE '%,".$this->db->escape($this->db->escapeforlike($aliasalt)).
",%' OR t.aliasalt LIKE '%, ".$this->db->escape($this->db->escapeforlike($aliasalt)).
",%')";
403 if ($translationparentid && $translationparentlang) {
404 $sql .=
" AND t.fk_page = ".((int) $translationparentid);
405 $sql .=
" AND t.lang = '".$this->db->escape($translationparentlang).
"'";
409 $sql .= $this->db->plimit(1);
411 $resql = $this->db->query($sql);
413 $numrows = $this->db->num_rows($resql);
415 $obj = $this->db->fetch_object($resql);
417 $this->
id = $obj->rowid;
419 $this->fk_website = (int) $obj->fk_website;
422 $this->pageurl = preg_replace(
'/[^\w_-]+/',
'', $obj->pageurl);
423 $this->
ref = $obj->pageurl;
424 $this->aliasalt = preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $obj->aliasalt));
426 $this->title = $obj->title;
428 $this->image = $obj->image;
429 $this->keywords = $obj->keywords;
430 $this->htmlheader = $obj->htmlheader;
431 $this->content = $obj->content;
432 $this->lang = $obj->lang;
433 $this->fk_page = $obj->fk_page;
434 $this->allowed_in_frames = $obj->allowed_in_frames;
435 $this->keep_history = $obj->keep_history;
436 $this->
status = (int) $obj->status;
437 $this->grabbed_from = $obj->grabbed_from;
438 $this->date_creation = $this->db->jdate($obj->date_creation);
439 $this->date_modification = $this->db->jdate($obj->date_modification);
440 $this->fk_user_creat = $obj->fk_user_creat;
441 $this->author_alias = $obj->author_alias;
442 $this->fk_user_modif = $obj->fk_user_modif;
443 $this->import_key = $obj->import_key;
444 $this->object_type = $obj->object_type;
445 $this->fk_object = $obj->fk_object;
447 $this->db->free($resql);
455 $this->errors[] =
'Error '.$this->db->lasterror();
456 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
475 public function fetchAll($websiteid =
'', $sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
483 $sql .=
" t.fk_website,";
484 $sql .=
" t.type_container,";
485 $sql .=
" t.pageurl,";
486 $sql .=
" t.aliasalt,";
488 $sql .=
" t.description,";
490 $sql .=
" t.keywords,";
491 $sql .=
" t.htmlheader,";
492 $sql .=
" t.content,";
494 $sql .=
" t.fk_page,";
495 $sql .=
" t.allowed_in_frames,";
496 $sql .=
" t.status,";
497 $sql .=
" t.grabbed_from,";
498 $sql .=
" t.date_creation,";
499 $sql .=
" t.tms as date_modification,";
500 $sql .=
" t.fk_user_creat,";
501 $sql .=
" t.author_alias,";
502 $sql .=
" t.fk_user_modif,";
503 $sql .=
" t.import_key,";
504 $sql .=
" t.object_type,";
505 $sql .=
" t.fk_object";
506 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
507 if (!empty($websiteid)) {
508 $sql .=
' WHERE t.fk_website = '.((int) $websiteid);
512 if (is_array($filter)) {
515 if (count($filter) > 0) {
516 foreach ($filter as $key => $value) {
517 if ($key ==
't.rowid' || $key ==
'rowid' || $key ==
't.fk_website' || $key ==
'fk_website' || $key ==
'status' || $key ==
't.status') {
518 $sqlwhere[] = $key.
" = ".((int) $value);
519 } elseif ($key ==
'type_container' || $key ==
't.type_container') {
520 $sqlwhere[] = $key.
" = '".$this->db->escape($value).
"'";
521 } elseif ($key ==
'lang' || $key ==
't.lang') {
522 $listoflang = array();
524 foreach (explode(
',', $value) as $tmpvalue) {
525 if ($tmpvalue ==
'null') {
529 $listoflang[] =
"'".$this->db->escape(substr(str_replace(
"'",
'', $tmpvalue), 0, 2)).
"'";
531 $sql_extrawhere = $this->db->sanitize($key).
" IN (".$this->db->sanitize(implode(
',', $listoflang), 1).
")";
533 $sql_extrawhere =
"(".$sql_extrawhere.
" OR ".$this->db->sanitize($key).
" IS NULL)";
535 $sqlwhere[] = $sql_extrawhere;
537 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($value).
"%'";
541 if (count($sqlwhere) > 0) {
542 if (!empty($websiteid)) {
543 $sql .=
" AND (".implode(
' '.$this->db->sanitize($filtermode).
' ', $sqlwhere).
')';
545 $sql .=
" WHERE ".implode(
' '.$this->db->sanitize($filtermode).
' ', $sqlwhere);
555 $this->errors[] = $errormessage;
556 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
560 if (!empty($sortfield)) {
561 $sql .= $this->db->order($sortfield, $sortorder);
563 if (!empty($limit)) {
564 $sql .= $this->db->plimit($limit, $offset);
567 $resql = $this->db->query($sql);
569 $num = $this->db->num_rows($resql);
571 while ($obj = $this->db->fetch_object($resql)) {
572 $record =
new self($this->db);
574 $record->id = $obj->rowid;
575 $record->fk_website = $obj->fk_website;
576 $record->type_container = $obj->type_container;
577 $record->pageurl = $obj->pageurl;
578 $record->aliasalt = preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $obj->aliasalt));
579 $record->title = $obj->title;
580 $record->description = $obj->description;
581 $record->image = $obj->image;
582 $record->keywords = $obj->keywords;
583 $record->htmlheader = $obj->htmlheader;
584 $record->content = $obj->content;
585 $record->lang = $obj->lang;
586 $record->fk_page = $obj->fk_page;
587 $record->allowed_in_frames = $obj->allowed_in_frames;
588 $record->status = $obj->status;
589 $record->grabbed_from = $obj->grabbed_from;
590 $record->date_creation = $this->db->jdate($obj->date_creation);
591 $record->date_modification = $this->db->jdate($obj->date_modification);
592 $record->fk_user_creat = $obj->fk_user_creat;
593 $record->author_alias = $obj->author_alias;
594 $record->fk_user_modif = $obj->fk_user_modif;
595 $record->import_key = $obj->import_key;
596 $record->object_type = $obj->object_type;
597 $record->fk_object = $obj->fk_object;
599 $records[$record->id] = $record;
601 $this->db->free($resql);
605 $this->error =
'Error '.$this->db->lasterror();
606 $this->errors[] = $this->error;
607 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
622 public function countAll($websiteid, $filter =
'', $filtermode =
'AND')
628 $sql =
'SELECT COUNT(t.rowid) as nb';
629 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
630 $sql .=
' WHERE t.fk_website = '.((int) $websiteid);
633 if (is_array($filter)) {
636 if (count($filter) > 0) {
637 foreach ($filter as $key => $value) {
638 if ($key ==
't.rowid' || $key ==
'rowid' || $key ==
't.fk_website' || $key ==
'fk_website' || $key ==
'status' || $key ==
't.status') {
639 $sqlwhere[] = $key.
" = ".((int) $value);
640 } elseif ($key ==
'type_container' || $key ==
't.type_container') {
641 $sqlwhere[] = $key.
" = '".$this->db->escape($value).
"'";
642 } elseif ($key ==
'lang' || $key ==
't.lang') {
643 $listoflang = array();
645 foreach (explode(
',', $value) as $tmpvalue) {
646 if ($tmpvalue ==
'null') {
650 $listoflang[] =
"'".$this->db->escape(substr(str_replace(
"'",
'', $tmpvalue), 0, 2)).
"'";
652 $sql_extrawhere = $this->db->sanitize($key).
" IN (".$this->db->sanitize(implode(
',', $listoflang), 1).
")";
654 $sql_extrawhere =
"(".$sql_extrawhere.
" OR ".$this->db->sanitize($key).
" IS NULL)";
656 $sqlwhere[] = $sql_extrawhere;
658 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($value).
"%'";
662 if (count($sqlwhere) > 0) {
663 if (!empty($websiteid)) {
664 $sql .=
" AND (".implode(
' '.$this->db->sanitize($filtermode).
' ', $sqlwhere).
')';
666 $sql .=
" WHERE ".implode(
' '.$this->db->sanitize($filtermode).
' ', $sqlwhere);
676 $this->errors[] = $errormessage;
677 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
681 $resql = $this->db->query($sql);
683 $obj = $this->db->fetch_object($resql);
688 $this->db->free($resql);
692 $this->error =
'Error '.$this->db->lasterror();
693 $this->errors[] = $this->error;
694 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
707 public function update(
User $user, $notrigger = 0)
710 $this->keywords =
dol_trunc($this->keywords, 255,
'right',
'utf-8', 1);
711 if ($this->aliasalt) {
712 $this->aliasalt =
','.preg_replace(
'/,+$/',
'', preg_replace(
'/^,+/',
'', $this->aliasalt)).
',';
715 $this->pageurl = preg_replace(
'/[^a-z0-9\-\_]/i',
'', $this->pageurl);
716 $this->pageurl = preg_replace(
'/\-\-+/',
'-', $this->pageurl);
717 $this->pageurl = preg_replace(
'/^\-/',
'', $this->pageurl);
720 $this->lang = preg_replace(
'/[_-].*$/',
'', trim($this->lang));
722 if ($this->fk_page > 0) {
723 if (empty($this->lang)) {
724 $this->error =
"ErrorLanguageMandatoryIfPageSetAsTranslationOfAnother";
727 $tmppage =
new WebsitePage($this->db);
728 $tmppage->fetch((
int) $this->fk_page);
729 if ($tmppage->lang == $this->lang) {
730 $this->error =
"ErrorLanguageOfTranslatedPageIsSameThanThisPage";
740 $this->error =
'Error: you try to create htmlheader with PHP content inside, this is not allowed.';
741 $this->errors[] = $this->error;
755 public function delete(
User $user, $notrigger = 0)
763 foreach ($this->childtablesoncascade as $table) {
764 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$table;
765 $sql .=
" WHERE fk_website_page = ".(int) $this->
id;
767 $result = $this->db->query($sql);
770 $this->errors[] = $this->db->lasterror();
784 $websiteobj =
new Website($this->db);
785 $result = $websiteobj->fetch($this->fk_website);
788 global $dolibarr_main_data_root;
789 $pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ?
'/'.$conf->entity :
'').
'/website/'.$websiteobj->ref;
791 $filealias = $pathofwebsite.
'/'.$this->pageurl.
'.php';
792 $filetpl = $pathofwebsite.
'/page'.$this->
id.
'.tpl.php';
797 $this->error = $websiteobj->error;
798 $this->errors = $websiteobj->errors;
822 public function createFromClone(
User $user, $fromid, $newref, $newlang =
'', $istranslation = 0, $newwebsite = 0, $newtitle =
'', $website =
null)
824 global $hookmanager, $langs;
834 if (empty($newref) && !empty($newtitle)) {
839 if (empty($newref)) {
840 $langs->load(
"errors");
841 $this->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"WEBSITE_TITLE"));
845 if ($istranslation) {
846 if (is_null($website)) {
847 $website =
new Website($this->db);
849 $website->fetch(
$object->fk_website);
851 if ($website->id != $newwebsite) {
852 $langs->load(
"errors");
853 $this->error = $langs->trans(
"WebsiteMustBeSameThanClonedPageIfTranslation");
869 $object->fk_user_creat = $user->id;
874 if (!empty($newlang)) {
878 if ($istranslation) {
879 if ($website->lang == $newlang) {
889 if (!empty($newwebsite)) {
890 $object->fk_website = $newwebsite;
893 $object->status = self::STATUS_DRAFT;
896 $object->context[
'createfromclone'] =
'createfromclone';
897 $result =
$object->create($user);
901 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
904 if ($istranslation) {
905 if ($website->lang == $newlang) {
907 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"website_page SET fk_page = ".((int) $result).
" WHERE rowid = ".((int) $fromid);
909 $result = $this->db->query($sql);
912 $this->error = $this->db->lasterror();
917 unset(
$object->context[
'createfromclone']);
925 $this->db->rollback();
942 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $maxlen = 24, $morecss =
'')
944 global $langs,
$conf, $db;
945 global $dolibarr_main_authentication, $dolibarr_main_demo;
950 $label =
'<u>'.$langs->trans(
"Page").
'</u>';
952 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->
ref.
'<br>';
953 $label .=
'<b>'.$langs->trans(
'ID').
':</b> '.$this->
id.
'<br>';
954 $label .=
'<b>'.$langs->trans(
'Title').
':</b> '.$this->title.
'<br>';
955 $label .=
'<b>'.$langs->trans(
'Language').
':</b> '.$this->lang;
957 $url = DOL_URL_ROOT.
'/website/index.php?websiteid='.$this->fk_website.
'&pageid='.
$this->id;
960 if (empty($notooltip)) {
962 $label = $langs->trans(
"ShowMyObject");
963 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
965 $linkclose .=
' title="'.dolPrintHTMLForAttribute($label).
'"';
966 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
968 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
971 $linkstart =
'<a href="'.$url.
'"';
972 $linkstart .= $linkclose.
'>';
977 $result .= $linkstart;
979 $result .= img_picto(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
981 if ($withpicto != 2) {
982 $result .= $this->ref;
995 public function getLibStatut($mode = 0)
997 return $this->LibStatut($this->
status, $mode);
1008 public function LibStatut($status, $mode = 0)
1013 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1016 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Offline');
1017 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Online');
1018 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Offline');
1019 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Online');
1022 $statusType =
'status5';
1023 if ($status == self::STATUS_VALIDATED) {
1024 $statusType =
'status4';
1027 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1040 public function setCategories($categories)
1042 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
1052 public function initAsSpecimen()
1060 $this->fk_website = 0;
1061 $this->type_container =
'page';
1062 $this->pageurl =
'specimen';
1063 $this->aliasalt =
'specimenalt';
1064 $this->title =
'My Page';
1067 $this->keywords =
'keyword1, keyword2';
1068 $this->allowed_in_frames = 1;
1069 $this->htmlheader =
'';
1070 $this->content =
'<html><body>This is a html content</body></html>';
1071 $this->
status = self::STATUS_DRAFT;
1072 $this->grabbed_from =
'';
1073 $this->date_creation = $now - (24 * 30 * 3600);
1074 $this->date_modification = $now - (24 * 7 * 3600);
1075 $this->fk_user_creat = $user->id;
1076 $this->author_alias =
'mypublicpseudo';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
setErrorsFromObject($object)
setErrorsFromObject
createCommon(User $user, $notrigger=0)
Create object in the database.
updateCommon(User $user, $notrigger=0)
Update object into database.
setCategoriesCommon($categories, $type_categ='', $remove_existing=true)
Sets object to given categories.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
dolKeepOnlyPhpCode($str)
Keep only PHP code part from a HTML string page.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_now($mode='gmt')
Return date for now.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_sanitizeKeyCode($str)
Clean a string to use it as a key or code.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.